{"version":3,"sources":["../src/deriveAssetName.ts"],"names":[],"mappings":";AAOA,SAAS,SAAS,CAAA,EAAmB;AACnC,EAAA,MAAM,OAAA,GAAU,CAAA,CAAE,OAAA,CAAQ,SAAA,EAAW,EAAE,CAAA;AACvC,EAAA,MAAM,GAAA,GAAM,IAAA,CAAK,GAAA,CAAI,OAAA,CAAQ,WAAA,CAAY,GAAG,CAAA,EAAG,OAAA,CAAQ,WAAA,CAAY,IAAI,CAAC,CAAA;AACxE,EAAA,OAAO,QAAQ,EAAA,GAAK,OAAA,GAAU,OAAA,CAAQ,KAAA,CAAM,MAAM,CAAC,CAAA;AACrD;AAmBO,SAAS,eAAA,CACd,WAAA,EACA,WAAA,EACA,UAAA,EACQ;AACR,EAAA,IAAI,eAAe,MAAA,EAAW;AAC5B,IAAA,OAAO,UAAA;AAAA,EACT;AACA,EAAA,IAAI,gBAAgB,IAAA,EAAM;AACxB,IAAA,OAAO,EAAA;AAAA,EACT;AACA,EAAA,OAAO,SAAS,WAAW,CAAA;AAC7B","file":"name.mjs","sourcesContent":["/**\n * Last path segment of a `/`- or `\\`-separated path, trailing separators\n * stripped. Inlined rather than imported from `node:path` so this module stays\n * browser-safe: the dev-server pack path (`vite-plugin-pack` `/__pack/`) runs\n * `buildCatalog` -> `deriveAssetName` in client code where `node:path` is\n * externalized and `path.basename` throws.\n */\nfunction baseName(p: string): string {\n  const trimmed = p.replace(/[/\\\\]+$/, '');\n  const idx = Math.max(trimmed.lastIndexOf('/'), trimmed.lastIndexOf('\\\\'));\n  return idx === -1 ? trimmed : trimmed.slice(idx + 1);\n}\n\n/**\n * Derive an asset's display name from package metadata.\n *\n * Pure function -- zero IO, zero side effects, browser-safe. Build-time\n * (build-catalog) and runtime (resolveName) share this single source of truth\n * for deterministic asset display-name resolution.\n *\n * Resolution contract:\n *   - an explicit storedName is authoritative;\n *   - a package path is the fallback when no storedName is present;\n *   - an asset without a package and without a storedName resolves to ''.\n *\n * `assetCount` remains in the signature because callers derive it from their\n * package model, but it must not erase an explicitly authored name. In\n * particular, a single authored entry in `Materials.pack.json` resolves to its\n * entry name rather than temporarily appearing as the package basename.\n */\nexport function deriveAssetName(\n  packagePath: string | null,\n  _assetCount: number,\n  storedName?: string,\n): string {\n  if (storedName !== undefined) {\n    return storedName;\n  }\n  if (packagePath === null) {\n    return '';\n  }\n  return baseName(packagePath);\n}\n"]}