{"version":3,"file":"brand-C8nMKhJC.mjs","names":[],"sources":["../src/utils/brand.ts"],"sourcesContent":["// Symbol.for ensures the same symbol is returned across different ESM module instances,\n// avoiding identity mismatches when multiple copies of the SDK are loaded.\nexport const SDK_BRAND: unique symbol = Symbol.for(\"tailor-platform/sdk\");\n\nexport type SdkBrandKind =\n  | \"tailordb-type\"\n  | \"resolver\"\n  | \"executor\"\n  | \"workflow\"\n  | \"workflow-job\"\n  | \"wait-point\"\n  | \"execution-policy\"\n  | \"http-adapter\";\n\n/**\n * Adds a non-enumerable SDK brand symbol to the given object (in-place).\n * The brand stores the kind so service loaders can distinguish between\n * different SDK object types (e.g. a type loader skips executors).\n * @param value - The object to brand\n * @param kind - The kind of SDK object\n * @returns The same object with the brand applied\n */\nexport function brandValue<T extends object>(value: T, kind: SdkBrandKind): T {\n  Object.defineProperty(value, SDK_BRAND, {\n    value: kind,\n    enumerable: false,\n    configurable: false,\n    writable: false,\n  });\n  return value;\n}\n\n/**\n * Checks whether the given value has been branded by the SDK.\n * When kind is specified, only returns true if the brand matches that kind.\n * Accepts a single kind or an array of kinds for multi-kind matching.\n * @param value - The value to check\n * @param kind - Optional kind or kinds to match against\n * @returns True if the value has the SDK brand symbol (and matches kind if specified)\n */\nexport function isSdkBranded(\n  value: unknown,\n  kind?: SdkBrandKind | readonly SdkBrandKind[],\n): boolean {\n  if (value === null || typeof value !== \"object\" || !(SDK_BRAND in value)) return false;\n  const stored = (value as Record<symbol, unknown>)[SDK_BRAND];\n  // No kind filter → any brand matches. Legacy `true` brand → matches any kind.\n  return (\n    kind === undefined ||\n    stored === true ||\n    (Array.isArray(kind) ? kind.includes(stored) : stored === kind)\n  );\n}\n"],"mappings":"AAEA,MAAa,EAA2B,OAAO,IAAI,qBAAqB,EAoBxE,SAAgB,WAA6B,EAAU,EAAuB,CAO5E,OANA,OAAO,eAAe,EAAO,EAAW,CACtC,MAAO,EACP,WAAY,GACZ,aAAc,GACd,SAAU,EACZ,CAAC,EACM,CACT,CAUA,SAAgB,aACd,EACA,EACS,CACT,GAAsB,OAAO,GAAU,WAAnC,GAA+C,EAAE,KAAa,GAAQ,MAAO,GACjF,IAAM,EAAU,EAAkC,GAElD,OACE,IAAS,IAAA,IACT,IAAW,KACV,MAAM,QAAQ,CAAI,EAAI,EAAK,SAAS,CAAM,EAAI,IAAW,EAE9D"}