{"version":3,"sources":["/home/runner/work/openframe-oss-lib/openframe-oss-lib/openframe-frontend-core/dist/chunk-CCWI3622.cjs","../src/utils/search-params.ts","../src/utils/embed-content-fetch.ts"],"names":[],"mappings":"AAAA,6rBAAY;AACZ;AACE;AACA;AACF,wDAA6B;AAC7B;AACA;ACyBO,SAAS,WAAA,CACd,GAAA,EACA,QAAA,EACA,EAAE,IAAA,EAAM,CAAA,EAAG,IAAI,EAAA,EAAwB,CAAC,CAAA,EACpB;AAIpB,EAAA,MAAM,OAAA,EAAS,CAAC,CAAA,EAAA,GAAe,IAAA,GAAO,KAAA,EAAO,EAAA,EAAI,IAAA,CAAK,GAAA,CAAI,CAAA,EAAG,GAAG,CAAA;AAChE,EAAA,GAAA,CAAI,IAAA,IAAQ,KAAA,GAAQ,IAAA,IAAQ,KAAA,EAAA,GAAa,IAAA,IAAQ,EAAA,EAAI;AACnD,IAAA,OAAO,OAAO,SAAA,IAAa,SAAA,EAAW,MAAA,CAAO,QAAQ,EAAA,EAAI,QAAA;AAAA,EAC3D;AACA,EAAA,MAAM,EAAA,EAAI,IAAA,CAAK,KAAA,CAAM,MAAA,CAAO,GAAG,CAAC,CAAA;AAChC,EAAA,GAAA,CAAI,CAAC,MAAA,CAAO,QAAA,CAAS,CAAC,EAAA,GAAK,EAAA,EAAI,GAAA,EAAK;AAClC,IAAA,OAAO,OAAO,SAAA,IAAa,SAAA,EAAW,MAAA,CAAO,QAAQ,EAAA,EAAI,QAAA;AAAA,EAC3D;AACA,EAAA,OAAO,MAAA,CAAO,CAAC,CAAA;AACjB;AAGO,IAAM,kBAAA,EAAoB,EAAE,OAAA,EAAS,GAAA,EAAQ,WAAA,EAAa,IAAI,CAAA;AAG9D,SAAS,SAAA,CAAU,KAAA,EAAe,QAAA,EAA0B;AACjE,EAAA,GAAA,CAAI,CAAC,MAAA,CAAO,QAAA,CAAS,KAAK,EAAA,GAAK,CAAC,MAAA,CAAO,QAAA,CAAS,QAAQ,EAAA,GAAK,SAAA,G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,IAAA,CAAA,MAAW,KAAA,GAAQ,KAAA,EAAO,MAAA,CAAO,MAAA,CAAO,GAAA,EAAK,MAAA,CAAO,IAAI,CAAC,CAAA;AAC9D,MAAA,QAAA;AAAA,IACF;AACA,IAAA,GAAA,CAAI,OAAO,MAAA,IAAU,QAAA,EAAU;AAC7B,MAAA,MAAA,CAAO,GAAA,CAAI,GAAA,EAAK,IAAA,CAAK,SAAA,CAAU,KAAK,CAAC,CAAA;AACrC,MAAA,QAAA;AAAA,IACF;AACA,IAAA,MAAA,CAAO,GAAA,CAAI,GAAA,EAAK,MAAA,CAAO,KAAK,CAAC,CAAA;AAAA,EAC/B;AACA,EAAA,OAAO,MAAA;AACT;AAGO,SAAS,qBAAA,CACd,MAAA,EACA,MAAA,EACA,OAAA,EACQ;AACR,EAAA,MAAM,KAAA,EAAgC,CAAC,CAAA;AACvC,EAAA,IAAA,CAAA,MAAW,CAAC,GAAA,EAAK,KAAK,EAAA,GAAK,MAAA,CAAO,OAAA,CAAQ,MAAM,CAAA,EAAG;AACjD,IAAA,GAAA,CAAI,kBAAA,CAAmB,KAAA,EAAO,MAAA,CAAO,GAAG,CAAC,CAAA,EAAG,IAAA,CAAK,GAAG,EAAA,EAAI,KAAA;AAAA,EAC1D;AACA,EAAA,OAAO,kBAAA,CAAmB,IAAA,EAAM,OAAO,CAAA,CAAE,QAAA,CAAS,CAAA;AACpD;AAGO,SAAS,SAAA,CAAU,IAAA,EAAc,WAAA,EAAgD;AACtF,EAAA,OAAO,YAAA,EAAc,CAAA,EAAA;AACvB;AD7KwB;AACA;AEpGmB;AACpC,EAAA;AAGc,EAAA;AACZ,EAAA;AACT;AFoGwB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/openframe-oss-lib/openframe-oss-lib/openframe-frontend-core/dist/chunk-CCWI3622.cjs","sourcesContent":[null,"/**\n * URL parameter schema engine — the ONE grammar for every URL/API integer,\n * the ONE omission rule, the ONE serializer.\n *\n * Hoisted out of `hooks/state/` so SERVER code (route handlers, DALs) and the\n * CLIENT hook parse the same URL with the same function: a param contract that\n * disagrees across the wire is the bug class this removes. JSX-free leaf with\n * its own `exports` subpath; `hooks/state/*` re-exports every name it used to own.\n */\n\n/** JavaScript types a URL parameter can carry. `int` is a whole number with a floor. */\nexport type JSType = 'string' | 'number' | 'int' | 'boolean' | 'array' | 'object';\n\n// ── The integer grammar ─────────────────────────────────────────────────────\n\nexport interface PositiveIntOptions {\n  /** Smallest accepted value (default 1). Anything below falls back. */\n  min?: number;\n  /** Largest accepted value. Applied to the PARSED value AND to the fallback. */\n  max?: number;\n}\n\n/**\n * THE integer grammar for URL params, env vars, and page sizes.\n *\n * `null`/`undefined`/`''` → fallback. Otherwise `Math.trunc(Number(raw))`, which\n * accepts `'12'`, `12`, `'12.9'` (→ 12) and `'0x10'` (→ 16), and rejects `'12abc'`\n * and `'abc'` (`NaN`) — the historical `parseInt` accepted `'12abc'` as 12 and\n * produced `NaN` for `'abc'`. A value below `min` falls back. The RESULT (parsed\n * value or fallback alike) is clamped to `max`, so \"never exceeds max\" has one owner.\n */\nexport function positiveInt<TFallback = number>(\n  raw: string | number | null | undefined,\n  fallback: TFallback,\n  { min = 1, max }: PositiveIntOptions = {},\n): number | TFallback {\n  // The fallback is returned AS GIVEN — capping only ever applies to a value\n  // parsed out of the input, so a caller with no default (`null`) gets its\n  // sentinel back untouched instead of `Math.min(null, max)`.\n  const capped = (v: number) => (max == null ? v : Math.min(v, max));\n  if (raw === null || raw === undefined || raw === '') {\n    return typeof fallback === 'number' ? capped(fallback) : fallback;\n  }\n  const n = Math.trunc(Number(raw));\n  if (!Number.isFinite(n) || n < min) {\n    return typeof fallback === 'number' ? capped(fallback) : fallback;\n  }\n  return capped(n);\n}\n\n/** Ceilings every paged surface shares. */\nexport const PAGE_PARAM_LIMITS = { maxPage: 10_000, maxPageSize: 100 } as const;\n\n/** Total pages for a row count. Floors at 1, so an empty result is still \"page 1 of 1\". */\nexport function pageCount(total: number, pageSize: number): number {\n  if (!Number.isFinite(total) || !Number.isFinite(pageSize) || pageSize <= 0) return 1;\n  return Math.max(1, Math.ceil(total / pageSize));\n}\n\n/** Clamp a requested page into `1..totalPages`. */\nexport function clampPageToTotal(page: number, totalPages: number): number {\n  return Math.min(page, Math.max(1, totalPages));\n}\n\n// ── Schema ──────────────────────────────────────────────────────────────────\n\ntype OutputTypeMap = {\n  string: string;\n  number: number;\n  int: number;\n  boolean: boolean;\n  array: string[];\n  object: Record<string, unknown>;\n};\n\nexport type OutputTypeForJSType<T extends JSType> = OutputTypeMap[T];\n\nexport interface BaseParamConfig<T extends JSType = JSType> {\n  type: T;\n  default?: OutputTypeMap[T];\n  required?: boolean;\n}\n\n/** An integer parameter with an optional floor and ceiling. */\nexport interface IntParamConfig extends BaseParamConfig<'int'> {\n  min?: number;\n  max?: number;\n}\n\nexport type ParamConfig<T extends JSType = JSType> = T extends 'int' ? IntParamConfig : BaseParamConfig<T>;\n\nexport type ParamSchema = Record<string, ParamConfig>;\n\n/** Identity helper that preserves literal types through a schema object. */\nexport function defineParamSchema<T extends ParamSchema>(schema: T): T {\n  return schema;\n}\n\n/**\n * Build a `Record<K, V>` from a key tuple. Keeps `keyof` EXACT when spreading a\n * shared config across derived keys (an inline `Object.fromEntries` widens to\n * `Record<string, V>` and loses the key union).\n */\nexport function fromKeys<K extends string, V>(keys: readonly K[], value: V): Record<K, V> {\n  return Object.fromEntries(keys.map(k => [k, value])) as Record<K, V>;\n}\n\n// ── Reading ─────────────────────────────────────────────────────────────────\n\n/** Anything a URL can be read from: `URLSearchParams`, Next's `searchParams`, or a plain record. */\nexport type ParamInput = URLSearchParams | Record<string, string | string[] | undefined> | null | undefined;\n\n/** THE first-value rule for a duplicated key (`?a=1&a=2` reads as `1`). */\nexport function firstParamValue(input: ParamInput, key: string): string | undefined {\n  if (!input) return undefined;\n  if (input instanceof URLSearchParams) return input.get(key) ?? undefined;\n  const value = input[key];\n  return Array.isArray(value) ? value[0] : value;\n}\n\n/** Every value for a key (arrays read repeated params, then a `,`-joined single value). */\nfunction allParamValues(input: ParamInput, key: string): string[] {\n  if (!input) return [];\n  const raw = input instanceof URLSearchParams ? input.getAll(key) : input[key];\n  const list = Array.isArray(raw) ? raw : raw === undefined ? [] : [raw];\n  if (list.length === 1 && list[0]?.includes(',')) return list[0].split(',').filter(Boolean);\n  return list.filter(v => v !== undefined && v !== '');\n}\n\nexport interface ParseSchemaOptions {\n  /**\n   * What an ABSENT scalar with no declared `default` resolves to.\n   * `'undefined'` (default) keeps today's behaviour; `'null'` is the explicit\n   * \"this filter is unset\" spelling that survives JSON and `URLSearchParams`.\n   */\n  absent?: 'undefined' | 'null';\n}\n\nexport type AbsentValue<Opts extends ParseSchemaOptions | undefined> = Opts extends { absent: 'null' }\n  ? null\n  : undefined;\n\n/**\n * The parsed shape of a schema: keys with a `default` and every array key are\n * non-nullable; an undefaulted scalar carries the caller's absent value.\n */\nexport type InferParsedParams<TSchema extends ParamSchema, Absent = undefined> = {\n  [K in keyof TSchema]: TSchema[K] extends { type: 'array' }\n    ? string[]\n    : TSchema[K] extends { default: infer D }\n      ? D\n      : TSchema[K]['type'] extends infer T\n        ? T extends JSType\n          ? OutputTypeForJSType<T> | Absent\n          : never\n        : never;\n};\n\nfunction coerceScalar(raw: string | undefined, config: ParamConfig): unknown {\n  if (raw === undefined || raw === '') return undefined;\n  switch (config.type) {\n    case 'int': {\n      const int = config;\n      // ONE integer grammar, default or not. Without a declared default the\n      // fallback is `undefined` (an unparseable value is absent), which\n      // `positiveInt` returns untouched — the branch used to open-code the\n      // truncation, the min floor and the max clamp a second time.\n      return positiveInt<undefined>(raw, int.default as undefined, { min: int.min, max: int.max });\n    }\n    case 'number': {\n      const n = Number(raw);\n      return Number.isFinite(n) ? n : undefined;\n    }\n    case 'boolean':\n      return raw === 'true' || raw === '1';\n    case 'object':\n      try {\n        return JSON.parse(raw) as Record<string, unknown>;\n      } catch {\n        return undefined;\n      }\n    default:\n      return raw;\n  }\n}\n\n/**\n * Parse a URL into a schema's shape. THE reader — the server route and the\n * client hook both call this, so a URL means exactly one thing.\n *\n * PRECEDENCE: an absent or empty SCALAR takes the declared `default` when there\n * is one, else the `absent` value. ARRAY keys never take `absent`: they are `[]`.\n */\nexport function parseSchemaParams<TSchema extends ParamSchema, Opts extends ParseSchemaOptions = Record<string, never>>(\n  schema: TSchema,\n  input: ParamInput,\n  options?: Opts,\n): InferParsedParams<TSchema, AbsentValue<Opts>> {\n  const absent = options?.absent === 'null' ? null : undefined;\n  const out: Record<string, unknown> = {};\n  for (const [key, config] of Object.entries(schema)) {\n    if (config.type === 'array') {\n      const values = allParamValues(input, key);\n      out[key] = values.length > 0 ? values : (config.default ?? []);\n      continue;\n    }\n    const coerced = coerceScalar(firstParamValue(input, key), config);\n    out[key] = coerced !== undefined ? coerced : (config.default ?? absent);\n  }\n  return out as InferParsedParams<TSchema, AbsentValue<Opts>>;\n}\n\n// ── Writing ─────────────────────────────────────────────────────────────────\n\n/**\n * A schema entry OR a legacy flattened param (which spells its default\n * `defaultValue`).\n *\n * A UNION, not a bag of two optional fields: with only `default?` and\n * `defaultValue?` this is a WEAK TYPE, and TypeScript rejects any argument\n * sharing neither — including `{ type: 'string' }`, the single most common\n * schema entry there is. Naming the real config shapes fixes that without an\n * index signature, which `FlattenedParam` (an interface) could never satisfy.\n */\ntype OmissionConfig = ParamConfig | { default?: unknown; defaultValue?: unknown };\n\n/**\n * THE omission rule: `null`, `undefined`, `''`, `[]`, and a value equal to the\n * declared default are left out, so a URL only ever carries what differs.\n */\nexport function shouldIncludeInUrl(value: unknown, config: OmissionConfig | undefined): boolean {\n  if (value === null || value === undefined) return false;\n  if (Array.isArray(value) && value.length === 0) return false;\n  if (value === '') return false;\n  // `in` narrowing rather than a cast: the union's members genuinely differ —\n  // a schema entry spells its default `default`, a flattened param spells it\n  // `defaultValue`, and neither is obliged to carry the other's field.\n  const fromDefault = config && 'default' in config ? config.default : undefined;\n  const fromLegacy = config && 'defaultValue' in config ? config.defaultValue : undefined;\n  const declared = fromDefault !== undefined ? fromDefault : fromLegacy;\n  if (declared !== undefined && value === declared) return false;\n  return true;\n}\n\nexport interface CreateSearchParamsOptions {\n  /** Join arrays with this separator instead of repeating the key (`;` for the hub's list APIs). */\n  arrayJoin?: string;\n}\n\n/** Build `URLSearchParams` from a value record (arrays repeat the key by default). */\nexport function createSearchParams(\n  params: Record<string, unknown>,\n  { arrayJoin }: CreateSearchParamsOptions = {},\n): URLSearchParams {\n  const search = new URLSearchParams();\n  for (const [key, value] of Object.entries(params)) {\n    // The emptiness half of the omission rule has ONE owner. (No config here:\n    // callers that must also drop schema DEFAULTS filter through\n    // `shouldIncludeInUrl` with the config first — see `serializeSchemaParams`.)\n    if (!shouldIncludeInUrl(value, undefined)) continue;\n    if (Array.isArray(value)) {\n      // Empty ELEMENTS are dropped, and an array that filters to nothing is\n      // absent (a cleared multi-select must not leave `?tags=` behind).\n      const items = value.filter(v => v !== null && v !== undefined && v !== '');\n      if (items.length === 0) continue;\n      if (arrayJoin) search.set(key, items.join(arrayJoin));\n      else for (const item of items) search.append(key, String(item));\n      continue;\n    }\n    if (typeof value === 'object') {\n      search.set(key, JSON.stringify(value));\n      continue;\n    }\n    search.set(key, String(value));\n  }\n  return search;\n}\n\n/** Serialize params to a query string, omitting everything `shouldIncludeInUrl` rejects. */\nexport function serializeSchemaParams<TSchema extends ParamSchema>(\n  schema: TSchema,\n  params: Record<string, unknown>,\n  options?: CreateSearchParamsOptions,\n): string {\n  const kept: Record<string, unknown> = {};\n  for (const [key, value] of Object.entries(params)) {\n    if (shouldIncludeInUrl(value, schema[key])) kept[key] = value;\n  }\n  return createSearchParams(kept, options).toString();\n}\n\n/** Append a query string to a path, or return the path unchanged when it is empty. */\nexport function withQuery(path: string, queryString: string | null | undefined): string {\n  return queryString ? `${path}?${queryString}` : path;\n}\n","'use client';\n\n/**\n * `contentFetch` — the fetch the lib's SELF-FETCHING content surfaces use:\n * roadmap (list + vote + per-task refresh), delivery, product releases,\n * onboarding guides (catalog + detail), legal docs, and the release-detail\n * injected roadmap/delivery sections.\n *\n * It deliberately reuses the SINGLE embed-auth knob — the registered\n * `EmbedAuthAdapter` — instead of introducing a second registration:\n *   - adapter registered (host opted into embedded auth, e.g. openframe-frontend\n *     for its embedded chat) → route through `embedAuthedFetch`, so content GETs/\n *     POSTs carry the SAME bearer/cookie + 401-refresh as the chat.\n *   - no adapter (the public hub, or the embedding example whose proxy injects\n *     auth server-side) → a plain, byte-for-byte unchanged `fetch`.\n *\n * So a host wires auth ONCE (the chat adapter) and content inherits it; there is\n * no content-specific fetcher to configure.\n */\n\nimport { embedAuthedFetch, hasEmbedAuthAdapter } from './embed-authed-fetch';\n\nexport const contentFetch: typeof fetch = (input, init) => {\n  if (!hasEmbedAuthAdapter()) return fetch(input, init);\n  // embedAuthedFetch takes a string url; coerce the broader `fetch` input shape\n  // (content surfaces always pass strings, but handle URL/Request defensively).\n  const url = typeof input === 'string' ? input : input instanceof URL ? input.href : input.url;\n  return embedAuthedFetch(url, init);\n};\n"]}