{"version":3,"file":"server-Cvg4Ggu4.mjs","names":["serverComponentRegistry: Record<string, ComponentSchema>","resistorSchema","capacitorSchema","groundSchema","switchSchema","batterySchema","voltageSourceSchema","diodeSchema","transistorNpnSchema","ledSchema","icSchema","schema: ComponentSchema","id: string","category: string"],"sources":["../../src/registry/server.ts"],"sourcesContent":["/**\n * Server-side registry module for component schemas\n *\n * This module provides server-side compatible registry functions\n * without any client-side dependencies or \"use client\" directives.\n * It's specifically designed for use in server-side environments\n * like API routes and LLM integrations.\n */\n\nimport { ComponentSchema } from '../schemas/componentSchema';\n\n// Import component schemas directly\nimport resistorSchema from './components/resistor.json';\nimport capacitorSchema from './components/capacitor.json';\nimport batterySchema from './components/battery.json';\nimport groundSchema from './components/ground.json';\nimport switchSchema from './components/switch.json';\nimport voltageSourceSchema from './components/voltage-source.json';\nimport diodeSchema from './components/diode.json';\nimport transistorNpnSchema from './components/transistor-npn.json';\nimport ledSchema from './components/led.json';\nimport icSchema from './components/ic.json';\n\n// Server-side registry storage\nconst serverComponentRegistry: Record<string, ComponentSchema> = {};\n\n/**\n * Initialize the server-side registry with built-in components\n */\nfunction initializeServerRegistry(): void {\n  // Only initialize once\n  if (Object.keys(serverComponentRegistry).length > 0) {\n    return;\n  }\n\n  // Register built-in components\n  const components = [\n    resistorSchema,\n    capacitorSchema,\n    groundSchema,\n    switchSchema,\n    batterySchema,\n    voltageSourceSchema,\n    diodeSchema,\n    transistorNpnSchema,\n    ledSchema,\n    icSchema\n  ];\n\n  for (const schema of components) {\n    try {\n      // Simple validation - just check if required fields exist\n      if (schema && schema.id && schema.name && schema.category) {\n        serverComponentRegistry[schema.id] = schema as ComponentSchema;\n      } else {\n        console.warn(`Invalid component schema ${schema.id}: missing required fields`);\n      }\n    } catch (error) {\n      console.warn(`Failed to register component ${schema.id}:`, error);\n    }\n  }\n}\n\n/**\n * Register a component schema in the server-side registry\n */\nexport function registerServerComponent(schema: ComponentSchema): void {\n  initializeServerRegistry();\n\n  // Simple validation - just check if required fields exist\n  if (!schema || !schema.id || !schema.name || !schema.category) {\n    throw new Error(`Invalid component schema: missing required fields (id, name, category)`);\n  }\n\n  if (serverComponentRegistry[schema.id]) {\n    console.warn(`Component with ID ${schema.id} already exists in server registry. Overwriting.`);\n  }\n\n  serverComponentRegistry[schema.id] = schema;\n}\n\n/**\n * Get a component schema from the server-side registry by ID\n */\nexport function getServerComponentSchema(id: string): ComponentSchema | undefined {\n  initializeServerRegistry();\n  return serverComponentRegistry[id];\n}\n\n/**\n * Get all component schemas in the server-side registry\n */\nexport function getAllServerComponents(): ComponentSchema[] {\n  initializeServerRegistry();\n  return Object.values(serverComponentRegistry);\n}\n\n/**\n * Get component schemas by category from the server-side registry\n */\nexport function getServerComponentsByCategory(category: string): ComponentSchema[] {\n  initializeServerRegistry();\n  return Object.values(serverComponentRegistry)\n    .filter(schema => schema.category === category);\n}\n\n/**\n * Get all unique categories from the server-side registry\n */\nexport function getServerCategories(): string[] {\n  initializeServerRegistry();\n  const allComponents = getAllServerComponents();\n  const categories = [...new Set(allComponents.map(schema => schema.category))];\n  return categories.sort();\n}\n\nexport default serverComponentRegistry;\n"],"mappings":";;;;AAwBA,MAAMA,0BAA2D,CAAE;;;;AAKnE,SAAS,2BAAiC;AAExC,KAAI,OAAO,KAAK,wBAAwB,CAAC,SAAS,EAChD;CAIF,MAAM,aAAa;EACjBC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;EACAC;CACD;AAED,MAAK,MAAM,UAAU,WACnB,KAAI;AAEF,MAAI,UAAU,OAAO,MAAM,OAAO,QAAQ,OAAO,SAC/C,yBAAwB,OAAO,MAAM;MAErC,SAAQ,MAAM,2BAA2B,OAAO,GAAG,2BAA2B;CAEjF,SAAQ,OAAO;AACd,UAAQ,MAAM,+BAA+B,OAAO,GAAG,IAAI,MAAM;CAClE;AAEJ;;;;AAKD,SAAgB,wBAAwBC,QAA+B;AACrE,2BAA0B;AAG1B,MAAK,WAAW,OAAO,OAAO,OAAO,SAAS,OAAO,SACnD,OAAM,IAAI,OAAO;AAGnB,KAAI,wBAAwB,OAAO,IACjC,SAAQ,MAAM,oBAAoB,OAAO,GAAG,kDAAkD;AAGhG,yBAAwB,OAAO,MAAM;AACtC;;;;AAKD,SAAgB,yBAAyBC,IAAyC;AAChF,2BAA0B;AAC1B,QAAO,wBAAwB;AAChC;;;;AAKD,SAAgB,yBAA4C;AAC1D,2BAA0B;AAC1B,QAAO,OAAO,OAAO,wBAAwB;AAC9C;;;;AAKD,SAAgB,8BAA8BC,UAAqC;AACjF,2BAA0B;AAC1B,QAAO,OAAO,OAAO,wBAAwB,CAC1C,OAAO,YAAU,OAAO,aAAa,SAAS;AAClD;;;;AAKD,SAAgB,sBAAgC;AAC9C,2BAA0B;CAC1B,MAAM,gBAAgB,wBAAwB;CAC9C,MAAM,aAAa,CAAC,GAAG,IAAI,IAAI,cAAc,IAAI,YAAU,OAAO,SAAS,CAAE;AAC7E,QAAO,WAAW,MAAM;AACzB;AAED,qBAAe"}