{"version":3,"file":"index.mjs","names":["classMetadataMap","WeakMap","getConstructor","prototype","constructor","createClassContext","target","has","set","metadata","get","kind","name","addInitializer","createMethodContext","propertyKey","descriptor","Error","static","private","access","value","Injectable","OriginalInjectable","createClassContext","options","target","context","originalDecorator","Object","keys","length","Factory","OriginalFactory","createClassContext","options","target","context","originalDecorator","Object","keys","length"],"sources":["../../src/legacy-compat/context-compat.mts","../../src/legacy-compat/injectable.decorator.mts","../../src/legacy-compat/factory.decorator.mts"],"sourcesContent":["/**\n * Compatibility layer for converting legacy decorator signatures to Stage 3 format.\n *\n * This module provides utilities to create mock Stage 3 decorator contexts\n * from legacy decorator arguments, and manages metadata storage using WeakMap.\n */\n\nimport type { ClassType } from '../token/injection-token.mjs'\n\n// WeakMap to store metadata for legacy decorators\n// Keyed by class constructor for class decorators\n// For method decorators, we use the class constructor (extracted from the prototype)\nconst classMetadataMap = new WeakMap<ClassType, Record<string | symbol, any>>()\n\n/**\n * Gets the constructor from a prototype (for method decorators).\n */\nfunction getConstructor(prototype: any): ClassType | null {\n  if (!prototype || typeof prototype !== 'object') {\n    return null\n  }\n  // In legacy decorators, target is the prototype\n  // The constructor is typically available via prototype.constructor\n  const constructor = prototype.constructor\n  if (constructor && typeof constructor === 'function') {\n    return constructor as ClassType\n  }\n  return null\n}\n\n/**\n * Creates a mock ClassDecoratorContext for legacy class decorators.\n * @internal\n */\nexport function createClassContext(target: ClassType): ClassDecoratorContext {\n  // Get or create metadata storage for this class\n  if (!classMetadataMap.has(target)) {\n    classMetadataMap.set(target, {})\n  }\n  const metadata = classMetadataMap.get(target)!\n\n  return {\n    kind: 'class',\n    name: target.name,\n    metadata,\n    addInitializer() {\n      // Legacy decorators don't support initializers\n    },\n  } as ClassDecoratorContext\n}\n\n/**\n * Creates a mock ClassMethodDecoratorContext for legacy method decorators.\n *\n * Note: Method decorators need to share metadata with the class context\n * because endpoint metadata is stored at the class level.\n * @internal\n */\nexport function createMethodContext(\n  target: any,\n  propertyKey: string | symbol,\n  descriptor: PropertyDescriptor,\n): ClassMethodDecoratorContext {\n  // For method decorators, target is the prototype\n  // We need to get the class constructor to access class-level metadata\n  const constructor = getConstructor(target)\n  if (!constructor) {\n    throw new Error(\n      '[Navios] Could not determine class constructor from method decorator target.',\n    )\n  }\n\n  // Get or create metadata storage for the class\n  // Method decorators share metadata with the class\n  if (!classMetadataMap.has(constructor)) {\n    classMetadataMap.set(constructor, {})\n  }\n  const metadata = classMetadataMap.get(constructor)!\n\n  return {\n    kind: 'method',\n    name: propertyKey,\n    metadata,\n    static: false, // We can't determine this from legacy decorators\n    private: false, // We can't determine this from legacy decorators\n    access: {\n      has: () => true,\n      get: () => descriptor.value,\n      set: () => {},\n    },\n    addInitializer() {\n      // Legacy decorators don't support initializers\n    },\n  } as ClassMethodDecoratorContext\n}\n","import type { ClassType } from '../token/injection-token.mjs'\n\nimport {\n  Injectable as OriginalInjectable,\n  type InjectableOptions,\n} from '../decorators/index.mjs'\n\nimport { createClassContext } from './context-compat.mjs'\n\nexport type { InjectableOptions }\n\n/**\n * Legacy-compatible Injectable decorator.\n *\n * Works with TypeScript experimental decorators (legacy API).\n *\n * @param options - Injectable configuration options\n * @returns A class decorator compatible with legacy decorator API\n *\n * @example\n * ```typescript\n * @Injectable()\n * export class UserService {\n *   getUser(id: string) {\n *     return { id, name: 'John' }\n *   }\n * }\n * ```\n */\nexport function Injectable(options: InjectableOptions = {}) {\n  return function (target: ClassType) {\n    const context = createClassContext(target)\n    // Use the no-args overload when options is empty, otherwise pass options\n    const originalDecorator =\n      Object.keys(options).length === 0\n        ? OriginalInjectable()\n        : // @ts-expect-error - InjectableOptions is a union type, we let runtime handle it\n          OriginalInjectable(options)\n    return originalDecorator(target, context)\n  }\n}\n","import type { ClassType } from '../token/injection-token.mjs'\n\nimport { Factory as OriginalFactory, type FactoryOptions } from '../decorators/index.mjs'\n\nimport { createClassContext } from './context-compat.mjs'\n\nexport type { FactoryOptions }\n\n/**\n * Legacy-compatible Factory decorator.\n *\n * Works with TypeScript experimental decorators (legacy API).\n *\n * @param options - Factory configuration options\n * @returns A class decorator compatible with legacy decorator API\n *\n * @example\n * ```typescript\n * @Factory()\n * export class DatabaseConnectionFactory {\n *   create() {\n *     return { host: 'localhost', port: 5432 }\n *   }\n * }\n * ```\n */\nexport function Factory(options: FactoryOptions = {}) {\n  return function (target: ClassType) {\n    const context = createClassContext(target)\n    // Use the no-args overload when options is empty, otherwise pass options\n    const originalDecorator =\n      Object.keys(options).length === 0\n        ? OriginalFactory()\n        : OriginalFactory(options)\n    return originalDecorator(target, context)\n  }\n}\n"],"mappings":";;;;;;;;;GAYA,MAAMA,mCAAmB,IAAIC,SAAAA;;;GAK7B,SAASC,eAAeC,WAAc;AACpC,KAAI,CAACA,aAAa,OAAOA,cAAc,SACrC,QAAO;CAIT,MAAMC,cAAcD,UAAU;AAC9B,KAAIC,eAAe,OAAOA,gBAAgB,WACxC,QAAOA;AAET,QAAO;;;;;GAOT,SAAgBC,mBAAmBC,QAAiB;AAElD,KAAI,CAACN,iBAAiBO,IAAID,OAAAA,CACxBN,kBAAiBQ,IAAIF,QAAQ,EAAC,CAAA;CAEhC,MAAMG,WAAWT,iBAAiBU,IAAIJ,OAAAA;AAEtC,QAAO;EACLK,MAAM;EACNC,MAAMN,OAAOM;EACbH;EACAI,iBAAAA;EAGF;;;;;;;;GAUF,SAAgBC,oBACdR,QACAS,aACAC,YAA8B;CAI9B,MAAMZ,cAAcF,eAAeI,OAAAA;AACnC,KAAI,CAACF,YACH,OAAM,IAAIa,MACR,+EAAA;AAMJ,KAAI,CAACjB,iBAAiBO,IAAIH,YAAAA,CACxBJ,kBAAiBQ,IAAIJ,aAAa,EAAC,CAAA;AAIrC,QAAO;EACLO,MAAM;EACNC,MAAMG;EACNN,UALeT,iBAAiBU,IAAIN,YAAAA;EAMpCc,QAAQ;EACRC,SAAS;EACTC,QAAQ;GACNb,WAAW;GACXG,WAAWM,WAAWK;GACtBb,WAAK;GACP;EACAK,iBAAAA;EA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