@nodaro/shared 3.58.0 → 3.60.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/dist/{chunk-OWNPYQSH.cjs → chunk-4GGLKRYI.cjs} +16 -3
  2. package/dist/chunk-4GGLKRYI.cjs.map +1 -0
  3. package/dist/{chunk-5PJC4ZWO.cjs → chunk-5G23AJBU.cjs} +6 -6
  4. package/dist/{chunk-5PJC4ZWO.cjs.map → chunk-5G23AJBU.cjs.map} +1 -1
  5. package/dist/{chunk-IKOKRJDI.cjs → chunk-5HK5Z5OB.cjs} +4 -4
  6. package/dist/{chunk-IKOKRJDI.cjs.map → chunk-5HK5Z5OB.cjs.map} +1 -1
  7. package/dist/{chunk-WLFT5UVV.cjs → chunk-5Y42RIGY.cjs} +8 -8
  8. package/dist/{chunk-WLFT5UVV.cjs.map → chunk-5Y42RIGY.cjs.map} +1 -1
  9. package/dist/{chunk-L26G7B27.js → chunk-6AJOTEVC.js} +3 -3
  10. package/dist/{chunk-L26G7B27.js.map → chunk-6AJOTEVC.js.map} +1 -1
  11. package/dist/{chunk-OMUYZKRB.js → chunk-6Q6SI7AG.js} +3 -3
  12. package/dist/{chunk-OMUYZKRB.js.map → chunk-6Q6SI7AG.js.map} +1 -1
  13. package/dist/{chunk-4ZZ6SVIQ.cjs → chunk-A6HRY3WF.cjs} +269 -37
  14. package/dist/chunk-A6HRY3WF.cjs.map +1 -0
  15. package/dist/{chunk-ZX6RRM6R.cjs → chunk-AXT7YNOR.cjs} +51 -51
  16. package/dist/{chunk-ZX6RRM6R.cjs.map → chunk-AXT7YNOR.cjs.map} +1 -1
  17. package/dist/{chunk-ODTZV3BW.js → chunk-AZGONXWV.js} +4 -4
  18. package/dist/{chunk-ODTZV3BW.js.map → chunk-AZGONXWV.js.map} +1 -1
  19. package/dist/{chunk-S5VBJJUT.cjs → chunk-BDXXOEBZ.cjs} +80 -57
  20. package/dist/chunk-BDXXOEBZ.cjs.map +1 -0
  21. package/dist/{chunk-QPBBIRLF.cjs → chunk-BGIJO5V4.cjs} +39 -39
  22. package/dist/{chunk-QPBBIRLF.cjs.map → chunk-BGIJO5V4.cjs.map} +1 -1
  23. package/dist/{chunk-NZRG5CXQ.cjs → chunk-BLJUCPMV.cjs} +5 -2
  24. package/dist/chunk-BLJUCPMV.cjs.map +1 -0
  25. package/dist/{chunk-KYHDKKUJ.cjs → chunk-BXNPO3PL.cjs} +8 -8
  26. package/dist/{chunk-KYHDKKUJ.cjs.map → chunk-BXNPO3PL.cjs.map} +1 -1
  27. package/dist/{chunk-S7FCFQ6X.js → chunk-CF4S4N5X.js} +16 -4
  28. package/dist/chunk-CF4S4N5X.js.map +1 -0
  29. package/dist/{chunk-4UUX62S3.cjs → chunk-CIOXUPCJ.cjs} +12 -12
  30. package/dist/{chunk-4UUX62S3.cjs.map → chunk-CIOXUPCJ.cjs.map} +1 -1
  31. package/dist/{chunk-5UVBFY2G.cjs → chunk-DQIJPDHC.cjs} +11 -11
  32. package/dist/{chunk-5UVBFY2G.cjs.map → chunk-DQIJPDHC.cjs.map} +1 -1
  33. package/dist/{chunk-UMPZR56R.js → chunk-DS2TOM32.js} +3 -3
  34. package/dist/{chunk-UMPZR56R.js.map → chunk-DS2TOM32.js.map} +1 -1
  35. package/dist/{chunk-K6UMB37V.js → chunk-EN2YI5TV.js} +3 -3
  36. package/dist/{chunk-K6UMB37V.js.map → chunk-EN2YI5TV.js.map} +1 -1
  37. package/dist/{chunk-SEQ5L72K.js → chunk-G6GMY5BC.js} +21 -4
  38. package/dist/chunk-G6GMY5BC.js.map +1 -0
  39. package/dist/chunk-G7ZYZQKO.cjs +27 -0
  40. package/dist/{chunk-QCW6J6BQ.cjs.map → chunk-G7ZYZQKO.cjs.map} +1 -1
  41. package/dist/{chunk-WBERPAXE.cjs → chunk-GNPJ2JLE.cjs} +6 -6
  42. package/dist/{chunk-WBERPAXE.cjs.map → chunk-GNPJ2JLE.cjs.map} +1 -1
  43. package/dist/{chunk-VZXRDSWA.cjs → chunk-GWBQ3GPO.cjs} +43 -21
  44. package/dist/chunk-GWBQ3GPO.cjs.map +1 -0
  45. package/dist/{chunk-DCP7JFSE.cjs → chunk-HDHLZK7C.cjs} +5 -5
  46. package/dist/{chunk-DCP7JFSE.cjs.map → chunk-HDHLZK7C.cjs.map} +1 -1
  47. package/dist/{chunk-QVPIO2NU.cjs → chunk-HNEF2N5C.cjs} +5 -5
  48. package/dist/{chunk-QVPIO2NU.cjs.map → chunk-HNEF2N5C.cjs.map} +1 -1
  49. package/dist/{chunk-7JM5EZF3.cjs → chunk-HOKWJXHA.cjs} +13 -13
  50. package/dist/{chunk-7JM5EZF3.cjs.map → chunk-HOKWJXHA.cjs.map} +1 -1
  51. package/dist/{chunk-FVKCNAEQ.js → chunk-HP3YIWNJ.js} +9 -4
  52. package/dist/chunk-HP3YIWNJ.js.map +1 -0
  53. package/dist/{chunk-UJJUX6NW.cjs → chunk-HW6TLOK4.cjs} +9 -3
  54. package/dist/chunk-HW6TLOK4.cjs.map +1 -0
  55. package/dist/{chunk-A5ESI2NY.js → chunk-ICDLYU4I.js} +9 -9
  56. package/dist/{chunk-A5ESI2NY.js.map → chunk-ICDLYU4I.js.map} +1 -1
  57. package/dist/{chunk-JUEFRVHZ.js → chunk-IV6IDECY.js} +4 -4
  58. package/dist/{chunk-JUEFRVHZ.js.map → chunk-IV6IDECY.js.map} +1 -1
  59. package/dist/{chunk-HEUWAIXG.js → chunk-JKZVRKN3.js} +36 -14
  60. package/dist/chunk-JKZVRKN3.js.map +1 -0
  61. package/dist/{chunk-ZMH56CLL.js → chunk-KJZVQIN4.js} +3 -3
  62. package/dist/{chunk-ZMH56CLL.js.map → chunk-KJZVQIN4.js.map} +1 -1
  63. package/dist/{chunk-6CYS7VRH.js → chunk-KOLC7AF2.js} +262 -38
  64. package/dist/chunk-KOLC7AF2.js.map +1 -0
  65. package/dist/{chunk-CNSRCZYY.js → chunk-LN3EVFRS.js} +5 -5
  66. package/dist/{chunk-CNSRCZYY.js.map → chunk-LN3EVFRS.js.map} +1 -1
  67. package/dist/{chunk-DC2QPACA.js → chunk-MHY47BLL.js} +4 -4
  68. package/dist/{chunk-DC2QPACA.js.map → chunk-MHY47BLL.js.map} +1 -1
  69. package/dist/{chunk-AWS4BWEC.js → chunk-Q6IES3U2.js} +5 -2
  70. package/dist/chunk-Q6IES3U2.js.map +1 -0
  71. package/dist/{chunk-PK4ZR2SK.cjs → chunk-RRPPXZ36.cjs} +4 -4
  72. package/dist/{chunk-PK4ZR2SK.cjs.map → chunk-RRPPXZ36.cjs.map} +1 -1
  73. package/dist/{chunk-6TFWFYYI.js → chunk-SCYBGTX6.js} +3 -3
  74. package/dist/{chunk-6TFWFYYI.js.map → chunk-SCYBGTX6.js.map} +1 -1
  75. package/dist/{chunk-I7NG2D6X.cjs → chunk-SKFJIFEV.cjs} +21 -21
  76. package/dist/{chunk-I7NG2D6X.cjs.map → chunk-SKFJIFEV.cjs.map} +1 -1
  77. package/dist/{chunk-VVGSIWNL.js → chunk-TZ42IVSF.js} +4 -4
  78. package/dist/{chunk-VVGSIWNL.js.map → chunk-TZ42IVSF.js.map} +1 -1
  79. package/dist/{chunk-IQBIH3AE.js → chunk-URLDVK67.js} +3 -3
  80. package/dist/{chunk-IQBIH3AE.js.map → chunk-URLDVK67.js.map} +1 -1
  81. package/dist/{chunk-IOET54EV.js → chunk-VB2ARGQ6.js} +35 -3
  82. package/dist/chunk-VB2ARGQ6.js.map +1 -0
  83. package/dist/{chunk-BSENM6HM.js → chunk-VYQ25YQF.js} +3 -3
  84. package/dist/{chunk-BSENM6HM.js.map → chunk-VYQ25YQF.js.map} +1 -1
  85. package/dist/{chunk-QSWUSXRL.cjs → chunk-WGKAOUEQ.cjs} +41 -2
  86. package/dist/chunk-WGKAOUEQ.cjs.map +1 -0
  87. package/dist/{chunk-M7SMSAOU.js → chunk-YHVEZVAO.js} +4 -4
  88. package/dist/{chunk-M7SMSAOU.js.map → chunk-YHVEZVAO.js.map} +1 -1
  89. package/dist/entries/apps.cjs +43 -43
  90. package/dist/entries/apps.js +8 -8
  91. package/dist/entries/credits.cjs +155 -151
  92. package/dist/entries/credits.d.cts +32 -3
  93. package/dist/entries/credits.d.ts +32 -3
  94. package/dist/entries/credits.js +8 -8
  95. package/dist/entries/edl.cjs +63 -59
  96. package/dist/entries/edl.d.cts +15 -1
  97. package/dist/entries/edl.d.ts +15 -1
  98. package/dist/entries/edl.js +1 -1
  99. package/dist/entries/llm-models.d.cts +1 -1
  100. package/dist/entries/llm-models.d.ts +1 -1
  101. package/dist/entries/model-catalog.cjs +144 -84
  102. package/dist/entries/model-catalog.d.cts +4 -47
  103. package/dist/entries/model-catalog.d.ts +4 -47
  104. package/dist/entries/model-catalog.js +5 -5
  105. package/dist/entries/models.cjs +308 -288
  106. package/dist/entries/models.d.cts +3 -3
  107. package/dist/entries/models.d.ts +3 -3
  108. package/dist/entries/models.js +4 -4
  109. package/dist/entries/nodes.cjs +208 -208
  110. package/dist/entries/nodes.d.cts +1 -1
  111. package/dist/entries/nodes.d.ts +1 -1
  112. package/dist/entries/nodes.js +10 -10
  113. package/dist/entries/pipeline.cjs +152 -152
  114. package/dist/entries/pipeline.d.cts +1 -1
  115. package/dist/entries/pipeline.d.ts +1 -1
  116. package/dist/entries/pipeline.js +3 -3
  117. package/dist/entries/runtime-config.cjs +32 -28
  118. package/dist/entries/runtime-config.d.cts +24 -2
  119. package/dist/entries/runtime-config.d.ts +24 -2
  120. package/dist/entries/runtime-config.js +1 -1
  121. package/dist/entries/ugc.cjs +71 -71
  122. package/dist/entries/ugc.js +4 -4
  123. package/dist/entries/video.cjs +117 -117
  124. package/dist/entries/video.js +4 -4
  125. package/dist/entries/workflow.cjs +147 -147
  126. package/dist/entries/workflow.d.cts +8 -0
  127. package/dist/entries/workflow.d.ts +8 -0
  128. package/dist/entries/workflow.js +2 -2
  129. package/dist/gpt-image-2-6-BeZdT-pW.d.cts +98 -0
  130. package/dist/gpt-image-2-6-BeZdT-pW.d.ts +98 -0
  131. package/dist/index.cjs +1412 -1320
  132. package/dist/index.d.cts +7 -6
  133. package/dist/index.d.ts +7 -6
  134. package/dist/index.js +22 -22
  135. package/dist/{model-catalog-CCsA1isC.d.ts → model-catalog-D6Es7VG-.d.cts} +59 -3
  136. package/dist/{model-catalog-CCsA1isC.d.cts → model-catalog-D6Es7VG-.d.ts} +59 -3
  137. package/dist/{model-constants-BtXkUsX3.d.cts → model-constants-22k3fjp1.d.cts} +22 -1
  138. package/dist/{model-constants-BtXkUsX3.d.ts → model-constants-22k3fjp1.d.ts} +22 -1
  139. package/package.json +1 -1
  140. package/src/__tests__/camera-switch-contract.test.ts +12 -3
  141. package/src/__tests__/credit-identifiers.test.ts +18 -9
  142. package/src/__tests__/gpt-image-2-6-formats.test.ts +171 -0
  143. package/src/__tests__/gpt-image-2-size-rules.test.ts +80 -0
  144. package/src/__tests__/normalize-model-input.test.ts +10 -10
  145. package/src/__tests__/runtime-config.test.ts +28 -0
  146. package/src/camera-switch-contract.ts +13 -1
  147. package/src/credit-identifiers.ts +63 -3
  148. package/src/entries/credits.ts +1 -0
  149. package/src/entries/model-catalog.ts +17 -0
  150. package/src/entries/models.ts +7 -0
  151. package/src/entries/runtime-config.ts +1 -0
  152. package/src/gpt-image-2-6.ts +72 -0
  153. package/src/model-catalog.ts +350 -40
  154. package/src/model-constants.ts +40 -0
  155. package/src/node-execution-state.ts +8 -0
  156. package/src/node-runtime-keys.ts +3 -0
  157. package/src/runtime-config/contract.ts +34 -0
  158. package/dist/chunk-4ZZ6SVIQ.cjs.map +0 -1
  159. package/dist/chunk-6CYS7VRH.js.map +0 -1
  160. package/dist/chunk-AWS4BWEC.js.map +0 -1
  161. package/dist/chunk-FVKCNAEQ.js.map +0 -1
  162. package/dist/chunk-HEUWAIXG.js.map +0 -1
  163. package/dist/chunk-IOET54EV.js.map +0 -1
  164. package/dist/chunk-NZRG5CXQ.cjs.map +0 -1
  165. package/dist/chunk-OWNPYQSH.cjs.map +0 -1
  166. package/dist/chunk-QCW6J6BQ.cjs +0 -27
  167. package/dist/chunk-QSWUSXRL.cjs.map +0 -1
  168. package/dist/chunk-S5VBJJUT.cjs.map +0 -1
  169. package/dist/chunk-S7FCFQ6X.js.map +0 -1
  170. package/dist/chunk-SEQ5L72K.js.map +0 -1
  171. package/dist/chunk-UJJUX6NW.cjs.map +0 -1
  172. package/dist/chunk-VZXRDSWA.cjs.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/gpt-image-2-6.ts"],"names":[],"mappings":";;;AASO,IAAM,wBAAA,GAA2B,CAAC,qBAAA,EAAuB,wBAAwB;AACjF,IAAM,wBAAA,GAA2B,CAAC,yBAAA,EAA2B,4BAA4B;AAKzF,IAAM,0BAA0B,CAAC,MAAA,EAAQ,OAAO,QAAA,EAAU,MAAA,EAAQ,SAAS,KAAK;AAOhF,IAAM,6BAAA,GAAmD;AACzD,IAAM,yBAAA,GAA4B,CAAC,IAAA,EAAM,IAAA,EAAM,IAAI;AAGnD,IAAM,6BAAA,GAAmD;AACzD,IAAM,gCAAA,GAAyD;AAE/D,IAAM,8BAAA,GAAiC;AAEvC,SAAS,gBAAgB,KAAA,EAAwB;AACtD,EAAA,OAAQ,wBAAA,CAA+C,SAAS,KAAK,CAAA;AACvE;AAEO,SAAS,mBAAmB,KAAA,EAA+C;AAChF,EAAA,OAAO,eAAA,CAAgB,KAAK,CAAA,IAAM,wBAAA,CAA+C,SAAS,KAAK,CAAA;AACjG;AAGO,SAAS,mBAAA,CAAoB,UAAmB,OAAA,EAA2B;AAChF,EAAA,OAAO,OAAO,QAAA,KAAa,QAAA,IAAY,kBAAA,CAAmB,QAAQ,KAAK,OAAA,KAAY,6BAAA;AACrF;AAQO,SAAS,oBAAA,CACd,QAAA,EACA,UAAA,EACA,YAAA,EACQ;AACR,EAAA,MAAM,UAAA,GACJ,QAAA,KAAa,MAAA,IACb,kBAAA,CAAmB,QAAQ,CAAA,IAC3B,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AA,GAAI,CAAA,CAAA;AAElC","file":"chunk-QSWUSXRL.cjs","sourcesContent":["/**\n * What makes GPT Image 2.6 Flare and Sunburst price differently from every\n * other image model: a quality setting AND a size, and on an edit the number of\n * input images as well. Economy is a flat price and is not listed here.\n *\n * Only the ids and levers live in this published package. The rates and the\n * formula are `backend/src/ee/billing/gpt-image-2-6-pricing.ts`.\n */\n\nexport const GPT_IMAGE_2_6_TIERED_T2I = [\"gpt-image-2-6-flare\", \"gpt-image-2-6-sunburst\"] as const\nexport const GPT_IMAGE_2_6_TIERED_I2I = [\"gpt-image-2-6-flare-i2i\", \"gpt-image-2-6-sunburst-i2i\"] as const\nexport type GptImage26TieredModel =\n | (typeof GPT_IMAGE_2_6_TIERED_T2I)[number]\n | (typeof GPT_IMAGE_2_6_TIERED_I2I)[number]\n\nexport const GPT_IMAGE_2_6_QUALITIES = [\"auto\", \"low\", \"medium\", \"high\", \"xhigh\", \"max\"] as const\nexport type GptImage26Quality = (typeof GPT_IMAGE_2_6_QUALITIES)[number]\n/**\n * The quality whose price is known only after the run: KIE picks the level. It\n * is reserved at the Max row and settled on what KIE really billed; every other\n * quality keeps its fixed row.\n */\nexport const GPT_IMAGE_2_6_METERED_QUALITY: GptImage26Quality = \"auto\"\nexport const GPT_IMAGE_2_6_RESOLUTIONS = [\"1K\", \"2K\", \"4K\"] as const\nexport type GptImage26Resolution = (typeof GPT_IMAGE_2_6_RESOLUTIONS)[number]\n\nexport const GPT_IMAGE_2_6_DEFAULT_QUALITY: GptImage26Quality = \"medium\"\nexport const GPT_IMAGE_2_6_DEFAULT_RESOLUTION: GptImage26Resolution = \"1K\"\n/** The most input images an edit is priced for (`REF_IMAGE_MAX_LIMITS`). */\nexport const GPT_IMAGE_2_6_MAX_INPUT_IMAGES = 16\n\nexport function isGptImage26I2i(model: string): boolean {\n return (GPT_IMAGE_2_6_TIERED_I2I as readonly string[]).includes(model)\n}\n\nexport function isGptImage26Tiered(model: string): model is GptImage26TieredModel {\n return isGptImage26I2i(model) || (GPT_IMAGE_2_6_TIERED_T2I as readonly string[]).includes(model)\n}\n\n/** True for a run whose charge is settled on KIE's own bill: Flare or Sunburst at quality Auto. */\nexport function isGptImage26AutoRun(provider: unknown, quality: unknown): boolean {\n return typeof provider === \"string\" && isGptImage26Tiered(provider) && quality === GPT_IMAGE_2_6_METERED_QUALITY\n}\n\n/**\n * The images a Generate Image run sends to KIE on GPT Image 2.6: its references\n * and, when it edits a base image, that image too (the worker puts it first,\n * unless it is already one of the references). Any other model is priced on its\n * references alone.\n */\nexport function gptImage26SentImages(\n provider: string | undefined,\n references: readonly string[],\n baseImageUrl: unknown,\n): number {\n const countsBase =\n provider !== undefined &&\n isGptImage26Tiered(provider) &&\n typeof baseImageUrl === \"string\" &&\n baseImageUrl.length > 0 &&\n !references.includes(baseImageUrl)\n return references.length + (countsBase ? 1 : 0)\n}\n\n/**\n * The most pictures a saved moodboard holds. A run sends them as references in\n * the seats the node's own images leave free. An estimate cannot read the\n * moodboard, so it counts this many.\n */\nexport const GPT_IMAGE_2_6_MOODBOARD_MAX_IMAGES = 12\n\nfunction namesMoodboard(direction: unknown): boolean {\n if (direction === null || typeof direction !== \"object\") return false\n const style = (direction as Record<string, unknown>).style\n return (Array.isArray(style) ? style : [style]).some(\n (value) => typeof value === \"string\" && value.startsWith(\"moodboard:\"),\n )\n}\n\n/**\n * The input images a workflow estimate counts for one node on a model priced\n * per input image: every list on the node, its source or base image, what is\n * wired in, a moodboard its direction names, and an image-to-image model's own\n * source. An estimate may over-quote, never under.\n */\nexport function gptImage26EstimatedImages(\n model: string,\n data: Record<string, unknown>,\n wiredImages: number,\n): number {\n const listed = (v: unknown) => (Array.isArray(v) ? v.length : 0)\n const single = (v: unknown) => (typeof v === \"string\" && v.length > 0 ? 1 : 0)\n return (\n listed(data.referenceImageUrls) +\n listed(data.characterDefinitionIds) +\n listed(data.extraRefs) +\n single(data.referenceImageUrl) +\n single(data.baseImageUrl) +\n single(data.sourceImageUrl) +\n wiredImages +\n (namesMoodboard(data.direction) ? GPT_IMAGE_2_6_MOODBOARD_MAX_IMAGES : 0) +\n (isGptImage26I2i(model) ? 1 : 0)\n )\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/credit-identifiers.ts"],"names":["FLUX2_RES_MP","defaultResolutionFor","GPT_IMAGE_2_6_QUALITIES","GPT_IMAGE_2_6_DEFAULT_QUALITY","GPT_IMAGE_2_6_RESOLUTIONS","GPT_IMAGE_2_6_DEFAULT_RESOLUTION","isGptImage26I2i","T2I_TO_I2I_VARIANT","GPT_IMAGE_2_6_MAX_INPUT_IMAGES","isFlux2Model","isGptImage26Tiered","HIGH_QUALITY_PROVIDERS","TWO_K_RESOLUTION_PROVIDERS","RESOLUTION_2K_4K_TIERED_PROVIDERS","IDEOGRAM_PROVIDERS","autoAspectNeedsSourceImage","normalizeModelInput","snapToNearestDuration","pricedOutputDurationSec","isWan3Provider","normalizeWan3Resolution","isViduQ4Provider","normalizeViduQ4Resolution","isKling4Provider","normalizeKling4Resolution","canonicalVideoProvider","DURATION_PRICED_PROVIDERS","isVeoProvider","VEO_RESOLUTION_TIERED_PROVIDERS","isGeminiOmniProvider","isGeminiOmniPerSecondProvider","VIDEO_DURATION_TIERS","getVideoAudioCapability","AUDIO_ADDON_PROVIDERS","MODE_ADDON_PROVIDERS","RESOLUTION_VIDEO_REF_PRICING","MODEL_CATALOG","PRICING_DEFAULT_RESOLUTION","RESOLUTION_DURATION_PRICING","VIDEO_REF_RATE_PROVIDERS","isMinimaxH3Provider","normalizeMinimaxH3Resolution","normalizeVideoRequestParams","uiResolutionFill","VIDEO_DURATION_AUTO","MOTION_DURATION_TIERS"],"mappings":";;;;;;;;AA6EA,SAAS,kBAAA,CAAmB,OAAmB,UAAA,EAA6B;AAC1E,EAAA,MAAM,IAAA,GAAO,CAAC,CAAA,KAAc,CAAA,CAAE,QAAQ,SAAA,EAAW,EAAE,EAAE,IAAA,EAAK;AAC1D,EAAA,MAAM,MAAM,OAAO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2B,SAAA,EAA2B;AACnF,EAAA,IAAI,CAAE,8BAAA,CAAqD,QAAA,CAAS,SAAS,CAAA,EAAG;AAC9E,IAAA,OAAO,SAAA;AAAA,EACT;AACA,EAAA,OAAQ,KAAA,IAAS,wBAAA,CAAyB,KAAK,CAAA,IAAM,SAAA;AACvD;AAUO,IAAM,wBAAA,GAA6D;AAAA,EACxE,EAAA,EAAI,SAAA;AAAA,EACJ,OAAA,EAAS,cAAA;AAAA,EACT,OAAA,EAAS,cAAA;AAAA,EACT,IAAA,EAAM,WAAA;AAAA,EACN,EAAA,EAAI;AACN","file":"chunk-S5VBJJUT.cjs","sourcesContent":["/**\n * Build composite credit model identifiers for variable pricing.\n * Shared between frontend and backend.\n */\n\nimport {\n HIGH_QUALITY_PROVIDERS,\n TWO_K_RESOLUTION_PROVIDERS,\n RESOLUTION_2K_4K_TIERED_PROVIDERS,\n IDEOGRAM_PROVIDERS,\n DURATION_PRICED_PROVIDERS,\n AUDIO_ADDON_PROVIDERS,\n MODE_ADDON_PROVIDERS,\n RESOLUTION_VIDEO_REF_PRICING,\n RESOLUTION_DURATION_PRICING,\n VEO_RESOLUTION_TIERED_PROVIDERS,\n VIDEO_DURATION_TIERS,\n pricedOutputDurationSec,\n snapToNearestDuration,\n PRICING_DEFAULT_RESOLUTION,\n MOTION_DURATION_TIERS,\n T2I_TO_I2I_VARIANT,\n isVeoProvider,\n isMinimaxH3Provider,\n isGeminiOmniProvider,\n isGeminiOmniPerSecondProvider,\n isWan3Provider,\n isViduQ4Provider,\n isKling4Provider,\n normalizeKling4Resolution,\n VIDEO_REF_RATE_PROVIDERS,\n normalizeMinimaxH3Resolution,\n normalizeWan3Resolution,\n normalizeViduQ4Resolution,\n getVideoAudioCapability,\n canonicalVideoProvider,\n} from \"./model-constants.js\"\nimport { isFlux2Model, FLUX2_RES_MP, type Flux2Model } from \"./flux2-pricing.js\"\nimport {\n GPT_IMAGE_2_6_DEFAULT_QUALITY,\n GPT_IMAGE_2_6_DEFAULT_RESOLUTION,\n GPT_IMAGE_2_6_MAX_INPUT_IMAGES,\n GPT_IMAGE_2_6_QUALITIES,\n GPT_IMAGE_2_6_RESOLUTIONS,\n isGptImage26I2i,\n isGptImage26Tiered,\n type GptImage26TieredModel,\n} from \"./gpt-image-2-6.js\"\nimport { VIDEO_DURATION_AUTO } from \"./video-duration-auto.js\"\nimport { uiResolutionFill } from \"./video-ui-defaults.js\"\nimport { MODEL_CATALOG, autoAspectNeedsSourceImage, normalizeModelInput, normalizeVideoRequestParams, defaultResolutionFor, type ModelInputAdjustment, type SourceImageSize } from \"./model-catalog.js\"\n\n/**\n * The megapixel tier a Flux 2 credit identifier is keyed on, for ANY incoming\n * `resolution` value.\n *\n * Flux 2 is the only family whose identifier INTERPOLATES the resolution\n * instead of matching it against a known set, and its callers are not\n * guaranteed to hand it a Flux 2 value:\n * - the multi-provider cost preview prices one node's data against EVERY\n * selected provider (`frontend/src/ee/hooks/use-providers-credits-sum.ts`),\n * so a node whose `resolution` is \"2K\" (the flux / nano-banana-pro value\n * space) reaches this branch verbatim;\n * - node data written straight into workflow JSON by an agent, an import or\n * a template never ran the config panel's provider-change fail-safe.\n * Interpolating that produced the off-grid id `flux-2-pro:2KMP:0ref`, which no\n * pricing row can answer — every cost badge 503'd `price_not_configured`\n * (18 production app-reports, 2026-09-07..14).\n *\n * A value off the grid snaps to the model's DEFAULT tier — the same `preferred`\n * value `normalizeModelInput` uses — so the preview asks for exactly the id the\n * route will reserve (both routes and the orchestrator normalize through\n * `resolveNormalizedImageGen` first, which makes this snap a no-op for them).\n * An ABSENT resolution keeps its long-standing meaning (\"this caller has no\n * resolution dimension at all\") and stays on 1 MP rather than moving to the\n * model default, which would silently re-price every resolution-less node.\n */\nfunction flux2MegapixelTier(model: Flux2Model, resolution?: string): string {\n const bare = (v: string) => v.replace(/\\s*MP$/i, \"\").trim()\n const raw = typeof resolution === \"string\" ? bare(resolution) : \"\"\n if (raw === \"\") return \"1\"\n // Numeric match so \"2.0\"/\" 2 MP\" land on the same grid point as \"2\", and the\n // GRID's own spelling is what gets emitted — returning the caller's \"2.0\"\n // would build \":2.0MP:\", another id no pricing row carries.\n const tier = FLUX2_RES_MP.find((t) => Number(t) === Number(raw))\n return tier ?? bare(defaultResolutionFor(model) ?? \"1 MP\")\n}\n\n/**\n * The price id of a GPT Image 2.6 Flare or Sunburst run: `<id>:<quality>:<size>`,\n * and on an edit `<id>:<quality>:<size>:<N>ref`, N being the input images.\n *\n * A value off the grid (a stored node, the multi-provider preview pricing one\n * node's data against every model) lands on the default rather than building\n * an id no row answers. A text-to-image id sent input images runs on the edit\n * endpoint, so a caller that does not swap the model first (the entity routes,\n * a pipeline pin) is priced there too. An edit always has at least its source.\n */\nfunction gptImage26CreditId(\n provider: GptImage26TieredModel,\n quality: string | undefined,\n resolution: string | undefined,\n referenceImageCount: number | undefined,\n): string {\n const q = (GPT_IMAGE_2_6_QUALITIES as readonly string[]).includes(quality ?? \"\") ? quality : GPT_IMAGE_2_6_DEFAULT_QUALITY\n const r = (GPT_IMAGE_2_6_RESOLUTIONS as readonly string[]).includes(resolution ?? \"\") ? resolution : GPT_IMAGE_2_6_DEFAULT_RESOLUTION\n const images = Math.trunc(referenceImageCount ?? 0)\n const model = !isGptImage26I2i(provider) && images > 0 ? T2I_TO_I2I_VARIANT[provider]! : provider\n if (!isGptImage26I2i(model)) return `${model}:${q}:${r}`\n return `${model}:${q}:${r}:${Math.min(Math.max(1, images), GPT_IMAGE_2_6_MAX_INPUT_IMAGES)}ref`\n}\n\n/**\n * Compute composite model identifier for variable credit pricing.\n * Examples: \"gpt-image:high\", \"flux:2K\", \"nano-banana-pro:4K\", \"ideogram:TURBO\",\n * \"flux-2-pro:2MP\", \"flux-2-max:2MP:1ref\" (Flux 2 — billed per megapixel).\n *\n * For image models, uses quality/resolution/renderingSpeed and (Flux 2) the output\n * megapixel count plus (Flux 2 Max) the number of reference images attached at request time.\n * For video models, uses duration/sound params when the model has variable pricing.\n */\nexport function buildCreditModelIdentifier(\n provider: string,\n quality?: string,\n resolution?: string,\n renderingSpeed?: string,\n targetResolution?: string,\n referenceImageCount?: number,\n): string {\n // Flux 2 family: billed per output megapixel AND per reference image (each\n // ref counts as input megapixels). Resolution arrives as \"N MP\" strings (the\n // UI value space); strip the unit. ALL three models encode the ref count\n // (capped at 8): Pro/Klein i2i always carry the source image as a ref and\n // their cost formula charges per input MP, so the reserved identifier must\n // reflect refs (there is no metered true-up to correct an under-reserved tier).\n if (isFlux2Model(provider)) {\n return `${provider}:${flux2MegapixelTier(provider, resolution)}MP:${Math.min(referenceImageCount ?? 0, 8)}ref`\n }\n if (isGptImage26Tiered(provider)) {\n return gptImage26CreditId(provider, quality, resolution, referenceImageCount)\n }\n if (HIGH_QUALITY_PROVIDERS.has(provider) && quality === \"high\") {\n return `${provider}:high`\n }\n if (TWO_K_RESOLUTION_PROVIDERS.has(provider) && resolution === \"2K\") {\n return `${provider}:2K`\n }\n if (provider === \"nano-banana-pro\" && resolution === \"4K\") {\n return `${provider}:4K`\n }\n if (RESOLUTION_2K_4K_TIERED_PROVIDERS.has(provider) && (resolution === \"2K\" || resolution === \"4K\")) {\n return `${provider}:${resolution}`\n }\n // Topaz Image Upscale: 2K is default (no suffix), 4K/8K get composite identifiers\n if (provider === \"topaz-image-upscale\" && targetResolution && targetResolution !== \"2K\") {\n return `${provider}:${targetResolution}`\n }\n if (IDEOGRAM_PROVIDERS.has(provider)) {\n if (renderingSpeed === \"TURBO\") return `${provider}:TURBO`\n if (renderingSpeed === \"QUALITY\") return `${provider}:QUALITY`\n }\n return provider\n}\n\n/**\n * An image request's catalog-snapped parameters PLUS the credit identifier\n * priced off them.\n *\n * `adjustments` is the disclosure channel: every lever this changed, why, and\n * to what. Routes return it in the 200 body so a caller learns their value was\n * corrected instead of silently getting something else.\n */\nexport interface NormalizedImageGen {\n /** Credit identifier, priced off the SNAPPED `resolution` / `quality`. */\n identifier: string\n /** The catalog model id the params were snapped against (post T2I→I2I swap). */\n modelId: string\n aspectRatio?: string\n resolution?: string\n quality?: string\n background?: string\n /** Empty when the caller's values were already valid for `modelId`. */\n adjustments: ModelInputAdjustment[]\n}\n\n/**\n * The catalog model `resolveNormalizedImageGen` snaps against: the provider\n * (Nano Banana when none is named), or — with `swapToI2i` and references\n * attached — its i2i sibling, the model the generate-image route and the\n * workflow payload builder then send. That sibling has its OWN catalog entry\n * and lever lists. Exported so a caller that has to decide something about\n * those lists before the snap (whether a photo's size is worth reading) asks\n * about the same model the snap will use.\n */\nexport function normalizedImageGenModelId(opts: {\n provider: unknown\n refCount: number\n swapToI2i?: boolean\n}): string {\n const provider = typeof opts.provider === \"string\" && opts.provider.length > 0 ? opts.provider : \"nano-banana\"\n return opts.swapToI2i && opts.refCount > 0 ? (T2I_TO_I2I_VARIANT[provider] ?? provider) : provider\n}\n\n/**\n * Whether \"auto\" on a Generate Image request can need its photo's size: the\n * model the snap runs against (`normalizedImageGenModelId` with the swap on)\n * has no native auto. Given the ASSEMBLED reference count, it asks about exactly\n * that model; without one — a write boundary, or a run before its references\n * assemble — about both the provider and its i2i sibling, since references may\n * yet attach.\n */\nexport function imageGenAutoAspectNeedsSourceImage(opts: {\n provider: unknown\n aspectRatio: unknown\n refCount?: number\n}): boolean {\n const asks = (refCount: number) =>\n autoAspectNeedsSourceImage(normalizedImageGenModelId({ provider: opts.provider, refCount, swapToI2i: true }), opts.aspectRatio)\n return opts.refCount === undefined ? asks(0) || asks(1) : asks(opts.refCount)\n}\n\n/**\n * Snap an image request's catalog-governed levers to a combination the model\n * actually accepts, and price the credit identifier off the SNAPPED values.\n *\n * WHY THE SNAP LIVES HERE and not at the call site. Both image routes compute\n * their credit identifier TWICE — once in the `creditGuard` preHandler (the\n * CHECK) and once at the handler's `reserveCreditsForJob` (the DEBIT) — and a\n * dedicated test asserts the two stay byte-identical (see\n * `backend/src/routes/__tests__/generate-image.test.ts`, \"CHECK === DEBIT\").\n * `resolution` and `quality` are pricing dimensions, so a snap applied at only\n * one of those sites breaks that invariant, and `commit_credits` never collects\n * an upward delta — the reserve IS the charge. Putting the snap inside the\n * primitive makes CHECK, DEBIT and the workflow orchestrator agree by\n * construction rather than by everyone remembering to call a normalizer.\n *\n * Inputs are typed `unknown` on purpose: the preHandler runs BEFORE Zod, so a\n * caller can put a number or an object in `resolution`. Non-strings become\n * `undefined` rather than reaching `normalizeModelInput` as a lie.\n *\n * Unknown model ids pass through untouched (same contract as\n * `normalizeModelInput`) — the route's provider enum is the gate for those.\n *\n * `sourceImage` is the size of the photo the request transforms or is drawn\n * from (an image-to-image / edit source, or Generate Image's first wired\n * reference). It only decides \"auto\" on a model without a native auto, and the\n * ratio is not a pricing dimension on any such model (pinned across the catalog\n * by `auto-aspect-source.test.ts`), so a CHECK that runs before the size is\n * known prices the same identifier as the DEBIT that knows it.\n */\nexport function resolveNormalizedImageGen(opts: {\n provider: string | undefined\n aspectRatio?: unknown\n quality?: unknown\n resolution?: unknown\n renderingSpeed?: unknown\n /** Does not price on its own, but a transparent background can move the size. */\n background?: unknown\n refCount: number\n swapToI2i?: boolean\n sourceImage?: SourceImageSize\n}): NormalizedImageGen {\n const str = (v: unknown): string | undefined =>\n typeof v === \"string\" && v.length > 0 ? v : undefined\n\n const modelId = normalizedImageGenModelId(opts)\n\n const n = normalizeModelInput(\n modelId,\n {\n aspectRatio: str(opts.aspectRatio),\n resolution: str(opts.resolution),\n quality: str(opts.quality),\n background: str(opts.background),\n },\n { sourceImage: opts.sourceImage },\n )\n\n return {\n identifier: buildCreditModelIdentifier(\n modelId,\n n.quality,\n n.resolution,\n str(opts.renderingSpeed),\n undefined,\n opts.refCount,\n ),\n modelId,\n aspectRatio: n.aspectRatio,\n resolution: n.resolution,\n quality: n.quality,\n background: n.background,\n adjustments: n.adjustments,\n }\n}\n\n/**\n * Reference-aware image-generation credit identifier — the SINGLE source of\n * truth shared by the single-node routes (`/v1/generate-image`,\n * `/v1/image-to-image`) and the workflow orchestrator\n * (`payload-builder.ts`). It centralises the two pricing dimensions that must\n * match across both paths or a Flux 2 generation is billed the wrong tier\n * (Flux 2 commits non-metered / has no upward true-up, so the reserved\n * identifier IS the final charge):\n * - `refCount`: the number of reference images sent to the provider (Flux 2\n * bills per ref). generate-image passes the assembled count (0 for pure\n * text-to-image); image-to-image passes 1 (the primary `imageUrl`) + extras.\n * - `swapToI2i`: generate-image auto-swaps a bare T2I provider to its i2i\n * sibling (`T2I_TO_I2I_VARIANT`) when refs are attached, so the credit id\n * matches the variant actually invoked. image-to-image is already an i2i\n * provider → pass `false`.\n *\n * The LoRA short-circuit (`flux-lora-character`) stays at the call site because\n * the routing decision needs a DB lookup the routes/orchestrator own.\n */\nexport function resolveImageGenCreditIdentifier(opts: {\n provider: string | undefined\n quality?: string\n resolution?: string\n renderingSpeed?: string\n refCount: number\n swapToI2i?: boolean\n}): string {\n return resolveNormalizedImageGen(opts).identifier\n}\n\n// T2V-specific credit overrides: some providers have different costs for T2V\n// vs I2V/V2V due to different default resolutions or colliding with image model names.\nconst T2V_CREDIT_OVERRIDES: Record<string, string> = {\n \"grok\": \"grok-i2v\", // T2V grok, same as I2V grok (not image grok = 4 cr)\n \"wan\": \"wan-t2v\", // T2V wan 1080p = (V2V wan 720p = 70 cr)\n \"wan-turbo\": \"wan-turbo-t2v\", // T2V wan-turbo 720p = (I2V wan-turbo 480p = 40 cr)\n}\n\n/**\n * Compute composite model identifier for video models with duration/audio-based pricing.\n * Examples: \"kling-3.0:5s\", \"kling-3.0:10s:audio\", \"seedance-2:8s:720p-ref\"\n *\n * @param provider - Video model key (e.g., \"kling-3.0\")\n * @param duration - Video duration in seconds\n * @param sound - Whether audio/sound is enabled\n * @param nodeType - Node type for T2V-specific cost overrides\n * @param mode - Quality variant that affects pricing\n * @param resolution - Output resolution (used by Seedance 2 for 480p/720p pricing)\n * @param hasVideoRef - Whether a reference video is connected (Seedance 2 uses a lower per-second rate when true)\n */\n/**\n * LTX 2.3 (Lightricks via Replicate) credit tiers: priced by\n * (resolution-band × duration-seconds). Keys mirror STATIC_CREDIT_COSTS /\n * model_pricing EXACTLY (lowercase band + raw seconds + \"s\"), e.g.\n * \"ltx-2.3-pro:1080p:6s\". This map is the source of truth for the nearest-tier\n * snap below, so an off-catalog (resolution, duration) from a direct API/SDK\n * call maps to a SEEDED price instead of hard-failing (price_not_configured\n * 503). Pro: 6/8/10s at every band. Fast: up to 20s at 1080p, 6/8/10s at 2k/4k.\n */\nconst LTX_DURATION_TIERS: Record<string, Record<string, number[]>> = {\n \"ltx-2.3-pro\": { \"1080p\": [6, 8, 10], \"2k\": [6, 8, 10], \"4k\": [6, 8, 10] },\n \"ltx-2.3-fast\": { \"1080p\": [6, 8, 10, 12, 14, 16, 18, 20], \"2k\": [6, 8, 10], \"4k\": [6, 8, 10] },\n}\n\n/**\n * The (band, duration) tier the LTX pricing ladder charges for a request, or\n * `undefined` for a non-LTX provider. Extracted so\n * `buildVideoCreditModelIdentifier` and `pricedVideoSelection` read the ladder\n * ONCE — the routes must send the tier they reserved, and a second copy of this\n * math is exactly how the two drift apart.\n *\n * An unknown/absent band falls back to 1080p (LTX's own default, and the band\n * `snapLtxInput` snaps to at the Replicate call), and an off-tier duration\n * snaps to the NEAREST seeded one so the emitted composite always prices.\n */\nfunction ltxPricedTier(\n provider: string,\n resolution?: string,\n duration?: number | string,\n): { band: string; duration: number } | undefined {\n const bands = LTX_DURATION_TIERS[provider]\n if (!bands) return undefined\n const band = bands[String(resolution)] ? String(resolution) : \"1080p\"\n const allowed = bands[band]!\n // The model's own default (catalog `defaultDuration`) when unset, then the\n // nearest rung of THIS band's ladder — the length LTX renders.\n const dur = snapToNearestDuration(pricedOutputDurationSec(provider, duration), allowed)\n return { band, duration: dur }\n}\n\n/**\n * The resolution a provider whose runner NORMALIZES the lever actually renders,\n * in the lowercase spelling of its credit composites — billing collapses\n * through the very normalizer the runner sends, so render == billed for every\n * spelling. `undefined` passes through untouched for every other provider.\n */\nfunction wireNormalizedResolution(provider: string, resolution: string | undefined): string | undefined {\n if (isWan3Provider(provider)) return normalizeWan3Resolution(resolution).toLowerCase()\n if (isViduQ4Provider(provider)) return normalizeViduQ4Resolution(resolution)\n if (isKling4Provider(provider)) return normalizeKling4Resolution(resolution)\n return resolution\n}\n\nexport function buildVideoCreditModelIdentifier(\n rawProvider: string,\n duration?: number | string,\n sound?: boolean,\n nodeType?: \"image-to-video\" | \"text-to-video\",\n mode?: string,\n resolution?: string,\n hasVideoRef?: boolean,\n): string {\n // A retired model (RETIRED_VIDEO_PROVIDERS) is priced as the model it runs as.\n const provider = canonicalVideoProvider(rawProvider) as string\n // T2V overrides: some providers have different base costs for text-to-video\n let effectiveProvider = provider\n if (nodeType === \"text-to-video\") {\n const override = T2V_CREDIT_OVERRIDES[provider]\n if (override) {\n // If override target also has duration pricing, use it as effective provider\n if (DURATION_PRICED_PROVIDERS.has(override)) {\n effectiveProvider = override\n } else {\n return override\n }\n }\n }\n\n // VEO 3.x resolution-tiered pricing: 720p is the base (no suffix), 1080p gets\n // \":1080p\" (Fast/Lite only), and 4K gets \":4k\" for ALL three tiers — direct-4K\n // generation chains KIE's get-4k-video off the base generation (the base runs\n // at 1080p). Duration is fixed at 8s for VEO so the duration-tier path below\n // does not apply.\n if (isVeoProvider(effectiveProvider)) {\n if (resolution === \"4k\") return `${effectiveProvider}:4k`\n // 1080p tier is Fast/Lite only (Quality has no 1080p surcharge).\n if (resolution === \"1080p\" && VEO_RESOLUTION_TIERED_PROVIDERS.has(effectiveProvider)) return `${effectiveProvider}:1080p`\n return effectiveProvider\n }\n\n // Gemini Omni family (gemini-omni-video + gemini-omni-flash): priced by\n // (resolution-band × duration), with a flat per-generation rate when a source\n // video is supplied (V2V). Lowercase \"4k\". The prefix is TEMPLATED from the\n // provider id, so a further Omni SKU needs no edit here — it only has to join\n // GEMINI_OMNI_PROVIDERS and seed its rows. These models are deliberately NOT\n // in DURATION_PRICED_PROVIDERS; this branch early-returns before that gate.\n // A per-second SKU (Omni Flash 1.2) prices on the `:<N>s:<res>` ladder below.\n if (isGeminiOmniProvider(effectiveProvider) && !isGeminiOmniPerSecondProvider(effectiveProvider)) {\n if (hasVideoRef) {\n return resolution === \"4k\" ? `${effectiveProvider}:4k:vref` : `${effectiveProvider}:vref`\n }\n // The rendered length through the catalog funnel (nearest legal tier, the\n // model's own default when unset) so the composite is always a SEEDED one.\n const d = pricedOutputDurationSec(effectiveProvider, duration)\n return resolution === \"4k\" ? `${effectiveProvider}:4k:${d}` : `${effectiveProvider}:${d}`\n }\n\n // LTX 2.3: priced by (resolution-band × duration-seconds). The RESERVE must be\n // the correct composite — commit_credits (migration 176) only refunds a surplus\n // (actual < reserved) and NEVER collects an upward delta, so an under-reserved\n // LTX run (the bare-id default = cheapest 1080p:6s tier) stays under-charged\n // even with meteredCost:true. Snap to a seeded tier so the id always prices.\n const ltxTier = ltxPricedTier(effectiveProvider, resolution, duration)\n if (ltxTier) {\n return `${effectiveProvider}:${ltxTier.band}:${ltxTier.duration}s`\n }\n\n if (!DURATION_PRICED_PROVIDERS.has(effectiveProvider)) {\n return effectiveProvider\n }\n\n // A named-provider request with NO duration renders the model's own default\n // (kie/models.ts extraParams), so price that default — not the global 5s —\n // for providers whose per-second tiers wouldn't snap 5 up to it\n // (minimax-h3, seedance-2-5). One helper, shared with the dynamic\n // reference-video reservations, so the tier and the scaled reserve agree.\n const durationSec = pricedOutputDurationSec(effectiveProvider, duration)\n const tiers = VIDEO_DURATION_TIERS[effectiveProvider]\n if (!tiers) return effectiveProvider\n\n // Find the matching duration tier\n const tier = tiers.find(t => durationSec <= t.maxSeconds) ?? tiers[tiers.length - 1]\n let identifier = `${effectiveProvider}:${tier.suffix}`\n\n // Append audio suffix if applicable. When the caller expressed no intent\n // (sound === undefined), fall back to the model's own default (capability\n // `defaultOn` — kling-3.0 generates audio unless explicitly disabled), so an\n // intent-less request is billed for the audio it actually produces instead\n // of reserving the cheaper no-audio tier against an audio-on generation.\n const soundOn = sound ?? (getVideoAudioCapability(effectiveProvider).defaultOn === true)\n if (AUDIO_ADDON_PROVIDERS.has(effectiveProvider) && soundOn) {\n identifier += \":audio\"\n }\n\n // Append mode suffix for providers with quality-tiered pricing\n // \"high\" comes from I2V videoSize field, \"pro\" comes from T2V mode field\n if (MODE_ADDON_PROVIDERS.has(effectiveProvider) && (mode === \"high\" || mode === \"pro\")) {\n identifier += \":high\"\n }\n\n // Seedance 2.0 family: per-second billing with resolution + video-ref dimensions.\n // KIE accepts 480p / 720p / 1080p natively; per-second rates rise non-linearly\n // so each tier gets its own composite identifier.\n if (RESOLUTION_VIDEO_REF_PRICING.has(effectiveProvider)) {\n // Clamp to the model's catalog resolutions (single source of truth): e.g.\n // seedance-2-mini exposes only 480p/720p, so a stale/explicit 1080p (or 4k)\n // maps to its top priced tier instead of emitting an unpriced composite\n // (which the hard-fail credit guard would 503 on at runtime).\n const supported = MODEL_CATALOG[effectiveProvider]?.resolutions ?? [\"480p\", \"720p\", \"1080p\"]\n // An OMITTED resolution renders the model's KIE-side default, so price that\n // default rather than the cheapest tier — otherwise an intent-less request\n // reserves 480p against a 720p render and commit_credits (refund-only) can\n // never collect the delta. Providers without an entry keep the historical\n // 480p fallback, so this cannot reprice anything already live.\n const requested = resolution ?? PRICING_DEFAULT_RESOLUTION[effectiveProvider]\n const want = requested === \"4k\" ? \"4k\" : requested === \"1080p\" ? \"1080p\" : requested === \"720p\" ? \"720p\" : \"480p\"\n // Unsupported (e.g. a stale 1080p on seedance-2-mini) clamps to the model's\n // top priced tier so the emitted composite is always seeded.\n const res = supported.includes(want) ? want : (supported[supported.length - 1] ?? \"480p\")\n identifier += `:${res}`\n if (hasVideoRef) identifier += \"-ref\"\n }\n\n // Duration × resolution pricing without a -ref dimension. Resolutions\n // outside the provider's priced tiers (or undefined) collapse to the first\n // (default) tier so the emitted composite is always seeded — the hard-fail\n // guard fuzzes the whole resolution space.\n const resTiers = RESOLUTION_DURATION_PRICING[effectiveProvider]\n if (resTiers) {\n // The \"default tier\" is the provider's DECLARED default when it has one\n // (PRICING_DEFAULT_RESOLUTION — wan-3 renders 720p, not the cheapest tier),\n // otherwise the first listed tier. Declaring it explicitly means a cosmetic\n // reorder of the tier list can never reprice a live model, and an OMITTED\n // *or* unsupported resolution both land on what actually renders instead of\n // on the cheapest row (commit_credits refunds a surplus but can never\n // collect a shortfall). Behaviour-neutral for every member without a\n // declared default.\n const declaredDefault = PRICING_DEFAULT_RESOLUTION[effectiveProvider]\n const fallback = declaredDefault && resTiers.includes(declaredDefault) ? declaredDefault : resTiers[0]!\n // Wan 3.0 renders through `normalizeWan3Resolution`, which is CASE-INSENSITIVE\n // (\"1080P\" — KIE's own OpenAPI enum spelling, and the natural value for an\n // integrator reading the provider docs — renders 1080P). The tier list here is\n // lowercase and `Array.includes` is case-sensitive, so without this the render\n // path and the billing path disagree: \"1080P\" rendered the top tier and billed\n // the 720p row, a shortfall `commit_credits` (refund-only) can never collect.\n // Collapsing through the SAME normalizer the runner uses makes render == billed\n // by construction for every spelling, including garbage (→ the declared 720p).\n // Scoped to the families whose runner normalizes on purpose (Wan 3.0, Vidu\n // Q4): the other RESOLUTION_DURATION_PRICING members pass `resolution` to\n // their wire verbatim, so case-folding their billing without probing their\n // wire would reprice live models.\n const requested = wireNormalizedResolution(effectiveProvider, resolution)\n const res = requested && resTiers.includes(requested) ? requested : fallback\n identifier += `:${res}`\n // A reference VIDEO bills at its own per-second rate (Kling 4.0).\n if (hasVideoRef && VIDEO_REF_RATE_PROVIDERS.has(effectiveProvider)) identifier += \"-ref\"\n }\n\n // MiniMax Hailuo 3 (768P lever, 2026-08-03): bare duration composites stay\n // the 2K (default) rate — byte-identical to the pre-lever seeded rows, so\n // existing workflows and admin overrides keep their ids — and only a\n // verified 768P selection appends \":768p\". normalizeMinimaxH3Resolution\n // collapses anything else to 2K, matching what KIE renders for an\n // omitted/unknown value, so billing can never undercut the render.\n if (isMinimaxH3Provider(effectiveProvider) && normalizeMinimaxH3Resolution(resolution) === \"768P\") {\n identifier += \":768p\"\n }\n\n return identifier\n}\n\n/**\n * The credit identifier a video GENERATION node is quoted at — Generate Video\n * (and the legacy Image/Text to Video nodes) and the Video to Video Seedance\n * edit lane, on every surface that quotes one: the node's cost pill, the\n * editor's run estimate, the prompt modal and the backend pre-run estimator.\n *\n * It applies the request levers the run applies BEFORE it prices\n * (payload-builder's `resolveVideoRequestNorm`): the model's UI resolution fill\n * when the node names none (`uiResolutionFill` — what the run sends), then the\n * catalog normalizer `normalizeVideoRequestParams`, which also owns the Seedance\n * Draft rule (a draft is priced AND sent at 480p whatever resolution came with\n * it). Without that, a node with no resolution was quoted at the identifier's\n * own default band (720p on Seedance 2.5) while the run sent and reserved 480p.\n *\n * `hasVideoRef` must come from the GRAPH (a wired reference-video edge, e.g.\n * `countRefModalityEdges(edges, id, \"video\") > 0`), never node data: nothing\n * writes `referenceVideoUrls` into a video node, so reading it there always\n * quoted the plain ladder for a run that reserves on the `-ref` one.\n */\nexport function videoGenerationCreditId(args: {\n provider: string\n duration?: number | string\n sound?: boolean\n nodeType?: \"image-to-video\" | \"text-to-video\"\n mode?: string\n resolution?: string\n draft?: boolean\n hasVideoRef?: boolean\n}): string {\n const { resolution } = normalizeVideoRequestParams(args.provider, {\n resolution: args.resolution ?? uiResolutionFill(args.provider),\n draft: args.draft === true,\n })\n return buildVideoCreditModelIdentifier(\n args.provider,\n args.duration,\n args.sound,\n args.nodeType ?? \"image-to-video\",\n args.mode,\n resolution,\n args.hasVideoRef === true,\n )\n}\n\n/**\n * The credit identifier a Video to Video node's Seedance EDIT lane reserves\n * under. Seedance has no v2v endpoint — the lane is a text-to-video job in edit\n * shape with the source clip as reference video 1 — so it prices on the\n * REFERENCE-VIDEO ladder at the model's LONGEST clip (Auto duration), and the\n * measured settlement refunds down to what was actually delivered.\n *\n * A thin call into {@link videoGenerationCreditId}, so a Generate Video node\n * making the same KIE call (Seedance, Auto, a wired reference video) is quoted\n * the same id. FOUR surfaces must agree on it exactly: the orchestrator's\n * reservation (payload-builder.ts), the backend pre-run estimator\n * (ee/billing/credits.ts), the node's cost pill, and the frontend run-level\n * estimate (config-panels/helpers.ts). A quote that disagrees with the reserve\n * is the documented `price_not_configured` / blank-pill trap.\n *\n * `resolution` is the node's one `v2vResolution` field; when unset the model's\n * own UI fill is priced, which is what the lane will send. `draft` is the\n * node's Seedance Draft toggle (priced at 480p).\n */\nexport function seedanceVideoEditCreditId(provider: string, resolution?: string, draft?: boolean): string {\n return videoGenerationCreditId({\n provider,\n duration: VIDEO_DURATION_AUTO,\n nodeType: \"text-to-video\",\n resolution,\n draft,\n hasVideoRef: true,\n })\n}\n\n/** What the video credit identifier PRICES for a request, for the levers whose\n * priced value must also be the value we SEND. */\nexport interface PricedVideoSelection {\n /** The resolution band the reservation is priced at when the request omitted\n * one — and only where the platform DECLARES that band as the provider's own\n * default. `undefined` means \"leave `resolution` exactly as the request had\n * it\": either the caller supplied one, or the provider's real default is not\n * known to be the band the identifier assumes. */\n resolution?: string\n /** The length the reservation is priced at and the wire carries, for a\n * provider whose price follows the clip length (LTX's seeded tier, the KIE\n * ladders, Gemini Omni). `undefined` for every other provider, and for Auto:\n * their duration passes through. */\n duration?: number\n /** Non-empty only for a lever the caller ASKED for and did not get (a 7s\n * request snapped to the 6s tier). Filling an omitted lever is a disclosure of\n * the price already being charged, not a correction, so it reports nothing. */\n adjustments: ModelInputAdjustment[]\n}\n\n/**\n * The other half of the video money path: `normalizeVideoRequestParams` snaps a\n * value the CATALOG governs; this returns the value the PRICE ladder governs.\n *\n * Two defects it closes, both of the same shape — the identifier prices one\n * thing and the wire carries another, and `commit_credits` (migration 176) only\n * ever refunds a surplus, so the reservation is the final charge:\n *\n * 1. **Absent resolution.** `buildVideoCreditModelIdentifier` prices an omitted\n * `resolution` as a concrete band (LTX → 1080p; a\n * {@link PRICING_DEFAULT_RESOLUTION} member → its declared default). Leaving\n * the key unset then lets the provider pick — documented for the KIE members\n * (their `extraParams` pin the same band) but UNDOCUMENTED for LTX on\n * Replicate. Sending the band we priced makes the two agree by construction.\n *\n * The fill is deliberately limited to providers with a DECLARED default.\n * `buildVideoCreditModelIdentifier` also has un-declared fallbacks — the\n * cheapest tier for a resolution-priced provider with no\n * `PRICING_DEFAULT_RESOLUTION` row — and those are a HEDGE, not a verified\n * provider default: seedance-2 / -fast / -mini pin `resolution: \"720p\"`\n * KIE-side while the identifier prices 480p, so filling 480p would downgrade\n * the render to match a price we already know is wrong. That mismatch is a\n * pre-existing identifier bug and is fixed by seeding the row, not here.\n *\n * 2. **Duration.** Every provider whose price follows the clip length is\n * charged at the length it RENDERS: its own default when the request named\n * none (catalog `defaultDuration`), the nearest length it offers otherwise\n * (`pricedOutputDurationSec` — the runners' own snap rule). The LTX ladder is\n * seeded per (band × seconds), so a 7s request snaps onto the 6s tier;\n * sending 7s would bill six and render seven. The same value is returned for\n * the other length-priced providers (the KIE ladders, Gemini Omni), so what\n * is priced is what is sent. Auto (-1) is the model's call and is untouched.\n *\n * Pure, and IDEMPOTENT against the identifier: feeding its output back in\n * cannot move the reserved tier. `video-request-normalize.test.ts` proves that\n * over every provider × resolution × duration.\n */\nexport function pricedVideoSelection(opts: {\n provider: string\n resolution?: string\n duration?: number | string\n}): PricedVideoSelection {\n const adjustments: ModelInputAdjustment[] = []\n const ltx = ltxPricedTier(opts.provider, opts.resolution, opts.duration)\n\n // The band the request will be priced AND rendered at. An explicit value\n // always wins — this only ever fills an omission.\n const resolution = opts.resolution\n ?? (ltx ? ltx.band : PRICING_DEFAULT_RESOLUTION[opts.provider])\n\n const requested = typeof opts.duration === \"string\" ? parseInt(opts.duration, 10) : opts.duration\n const asked = requested !== undefined && !Number.isNaN(requested)\n\n // Every provider whose price follows the clip length sends the length it is\n // CHARGED at (the catalog funnel: its own default when unset, the nearest\n // legal length otherwise). Auto (-1) is the model's call and is left alone.\n const lengthPriced = !!ltx || DURATION_PRICED_PROVIDERS.has(opts.provider) || isGeminiOmniProvider(opts.provider)\n if (!lengthPriced || (!ltx && asked && requested! <= 0)) return { resolution, adjustments }\n\n const duration = ltx ? ltx.duration : pricedOutputDurationSec(opts.provider, opts.duration)\n if (asked && requested !== duration) {\n adjustments.push({\n field: \"duration\",\n from: requested!,\n to: duration,\n reason: ltx\n ? `LTX renders ${ltx.band} in ${ltx.duration}s steps — using ${ltx.duration}s instead of ${requested}s.`\n : `${opts.provider} renders ${duration}s clips at the nearest length it offers — using ${duration}s instead of ${requested}s.`,\n })\n }\n return { resolution, duration, adjustments }\n}\n\n/**\n * Compute composite model identifier for motion control with duration-tiered pricing.\n * Examples: \"kling-3.0-motion:10s\", \"kling-3.0-motion:1080p:15s\", \"motion-transfer:5s\"\n *\n * Wan Animate providers use resolution-tiered pricing (not per-second):\n * \"wan-animate-move\" (480p default), \"wan-animate-move:580p\", \"wan-animate-move:720p\"\n *\n * @param provider - Motion control provider key (\"kling\" for 2.6, \"kling-3.0\", \"wan-animate-move\", \"wan-animate-replace\")\n * @param resolution - \"720p\" or \"1080p\" (Kling), \"480p\" or \"580p\" or \"720p\" (Wan Animate)\n * @param videoDuration - Reference video duration in seconds (defaults to 10s, unused for Wan Animate)\n */\nexport function buildMotionCreditModelIdentifier(\n provider: string,\n resolution: string,\n videoDuration?: number,\n): string {\n // Wan Animate providers use resolution-tiered pricing (not duration-based)\n if (provider === \"wan-animate-move\" || provider === \"wan-animate-replace\") {\n // 480p is the default (base identifier), 580p and 720p get composite suffix\n if (resolution === \"580p\" || resolution === \"720p\") {\n return `${provider}:${resolution}`\n }\n return provider\n }\n\n const raw = videoDuration ?? 10\n const durationSec = Math.floor(Number.isNaN(raw) ? 10 : raw) // default 10s; floor to match KIE per-second billing\n const tier = MOTION_DURATION_TIERS.find(t => durationSec <= t.maxSeconds)\n ?? MOTION_DURATION_TIERS[MOTION_DURATION_TIERS.length - 1]\n\n const base = provider === \"kling-3.0\" ? \"kling-3.0-motion\" : \"motion-transfer\"\n const resSuffix = resolution === \"1080p\" ? \":1080p\" : \"\"\n return `${base}${resSuffix}:${tier.suffix}`\n}\n\n/**\n * The Suno operations whose credit key depends on the model VERSION.\n *\n * `/v1/suno/generate`, `/cover` and `/extend` resolve their creditGuard\n * identifier through `sunoCreditType(model, <operation>)` (routes/suno.ts\n * :247-249, :335-337, :407-409). EVERY other Suno route charges a flat\n * per-operation key and ignores the version the node carries — mashup (:648),\n * add-instrumental (:852), add-vocals (:907), upload-extend (:1016),\n * replace-section (:710), style-boost (:771), convert-wav (:962),\n * lyrics (:482), music-video (:594), voice (:1218).\n *\n * Anything that QUOTES a Suno price — a dropdown row, a node badge, the\n * workflow-credit estimator — must follow the same split, or it displays a\n * credit key the route never charges.\n */\nexport const SUNO_VERSION_PRICED_OPERATIONS = [\n \"suno-generate\",\n \"suno-cover\",\n \"suno-extend\",\n] as const\n\n/**\n * The seven Suno operations that appear behind a select/dropdown UI (model\n * pickers, node badges, the credit estimator) — the three version-priced\n * operations above, plus the four flat-key operations exercised by\n * `sunoCreditType`'s own test suite. A readonly tuple so later tasks (the\n * model dropdowns, node badges) can iterate or count it without redeclaring\n * the list and drifting from this one.\n */\nexport const SUNO_SELECT_OPERATIONS = [\n \"suno-generate\",\n \"suno-cover\",\n \"suno-extend\",\n \"suno-mashup\",\n \"suno-add-instrumental\",\n \"suno-add-vocals\",\n \"suno-upload-extend\",\n] as const\n\n/**\n * Adjust Speed's price id: motion-compensated (\"smooth\") interpolation is its\n * own, dearer tier. The route, the workflow run, and the editor's badge and\n * run estimate all price through this, so none of them can quote the fast tier\n * for a smooth run.\n */\nexport function speedRampCreditId(quality: unknown): \"speed-ramp\" | \"speed-ramp:smooth\" {\n return quality === \"smooth\" ? \"speed-ramp:smooth\" : \"speed-ramp\"\n}\n\n/**\n * Apply EDL's price id: a `proxy` render (the 720p preview) is its own,\n * cheaper per-output-minute row; a `final` render keeps the bare id. One id per\n * QUALITY, for a video and an audio output alike (decided 2026-10-04). Anything\n * that is not exactly \"proxy\" is the final, as the route and the node default\n * it. The route, the workflow run, and the editor's badge and run estimate all\n * price through this; the job itself is always named `apply-edl`.\n */\nexport function applyEdlCreditId(quality: unknown): \"apply-edl\" | \"apply-edl:proxy\" {\n return quality === \"proxy\" ? \"apply-edl:proxy\" : \"apply-edl\"\n}\n\n/**\n * Speaker View's price tiers (decided 2026-10-10, C4): a render is priced by\n * how many speakers it composites at once. `standard` — at most two tiles on\n * any segment and no zoom; `complex` — three to six tiles, or any zoom. Which\n * tier a render is in is the render rule's to say (the app's\n * `@nodaro/render-rules`), never this vocabulary's.\n */\nexport const SPEAKER_VIEW_PRICE_TIERS = [\"standard\", \"complex\"] as const\nexport type SpeakerViewPriceTier = (typeof SPEAKER_VIEW_PRICE_TIERS)[number]\n\nexport type SpeakerViewCreditId = \"speaker-view\" | \"speaker-view:proxy\" | \"speaker-view:complex\" | \"speaker-view:complex:proxy\"\n\n/** Every id `speakerViewCreditId` can name. */\nexport const SPEAKER_VIEW_CREDIT_IDS: readonly SpeakerViewCreditId[] = Object.freeze([\n \"speaker-view\",\n \"speaker-view:proxy\",\n \"speaker-view:complex\",\n \"speaker-view:complex:proxy\",\n] as const)\n\n/**\n * The credit id of a Speaker View render (F4, decided 2026-09-23; tiers\n * decided 2026-10-10): a Preview (`quality` \"proxy\") reserves on its own row,\n * anything else on the final's, and each in its price tier — `standard` on\n * `speaker-view` / `speaker-view:proxy`, `complex` on `speaker-view:complex` /\n * `speaker-view:complex:proxy`. A tier that is not exactly `standard` (absent\n * included) names the `complex` row: a caller that cannot tell quotes high,\n * never low. The job is always named `speaker-view`; only its credit id\n * follows the quality and the tier.\n */\nexport function speakerViewCreditId(quality: unknown, tier?: unknown): SpeakerViewCreditId {\n const proxy = quality === \"proxy\"\n if (tier === \"standard\") return proxy ? \"speaker-view:proxy\" : \"speaker-view\"\n return proxy ? \"speaker-view:complex:proxy\" : \"speaker-view:complex\"\n}\n\n/**\n * OUR Nodaro credit key for a Suno operation, given the model version and the\n * operation (which is also the node type and the BullMQ job name).\n *\n * This is the single source of truth for the Suno pricing contract, shared by\n * the reservation path (routes/suno.ts creditGuard), the egress seam\n * (workers/handlers/suno.ts `modelKey`, which must match what was reserved),\n * both workflow-credit estimators (ee/billing/credits.ts and the frontend\n * config-panels/helpers.ts), the seven Suno model dropdowns and the three Suno\n * node badges. It is a billing key — NEVER a KIE provider id — which is what\n * satisfies the B3 egress invariant.\n *\n * The version → key map is {@link SUNO_VERSION_CREDIT_KEYS}; a version with no\n * entry (V4 / V4_5 / V4_5ALL / V4_5PLUS) falls back to the operation key, and a\n * non-version-priced operation is returned unchanged.\n */\nexport function sunoCreditType(model: string | undefined, operation: string): string {\n if (!(SUNO_VERSION_PRICED_OPERATIONS as readonly string[]).includes(operation)) {\n return operation\n }\n return (model && SUNO_VERSION_CREDIT_KEYS[model]) || operation\n}\n\n/**\n * Suno version → Nodaro credit key for the version-priced operations. One row\n * per version that has its own `model_pricing` row / `STATIC_CREDIT_COSTS`\n * entry / `MODEL_CATALOG` pricing row, so an admin can reprice one version\n * without touching code. Every ACTIVE version MUST have a row here — guarded\n * by `__tests__/suno-credit-type.test.ts` (a new active version with no key\n * would silently bill at the operation key).\n */\nexport const SUNO_VERSION_CREDIT_KEYS: Readonly<Record<string, string>> = {\n V6: \"suno-v6\",\n V6_WILD: \"suno-v6_wild\",\n V6_MINI: \"suno-v6_mini\",\n V5_5: \"suno-v5_5\",\n V5: \"suno-v5\",\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/runtime-config/worlds.ts","../src/runtime-config/contract.ts"],"names":["strings"],"mappings":";AAaO,IAAM,SAAA,GAAY,MAAA,CAAO,MAAA,CAAO,CAAC,SAAA,EAAW,OAAA,EAAS,OAAA,EAAS,OAAA,EAAS,QAAA,EAAU,QAAA,EAAU,OAAA,EAAS,KAAA,EAAO,QAAQ,CAAU;AAIpI,IAAM,YAAA,GAAoC,IAAI,GAAA,CAAI,SAAS,CAAA;AAEpD,SAAS,UAAU,KAAA,EAAkC;AAC1D,EAAA,OAAO,OAAO,KAAA,KAAU,QAAA,IAAY,YAAA,CAAa,IAAI,KAAK,CAAA;AAC5D;AAiBO,IAAM,yBAAA,GA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,MAAO,OAAA,GAAU,mBAAA,CAAoB,IAAI,OAAO,CAAA;AACxE,EAAA,IAAI,QAAA,CAAS,GAAA,CAAI,UAAU,CAAA,IAAK,GAAA,CAAI,UAAA,CAAW,WAAA,KAAgB,IAAA,EAAM,GAAA,CAAI,UAAA,GAAa,EAAE,WAAA,EAAa,IAAA,EAAK;AAC1G,EAAA,IAAI,GAAA,CAAI,eAAA,KAAoB,IAAA,EAAM,GAAA,CAAI,eAAA,GAAkB,IAAA;AACxD,EAAA,IAAI,cAAc,GAAA,CAAI,WAAW,CAAA,EAAG,GAAA,CAAI,cAAc,GAAA,CAAI,WAAA;AAC1D,EAAA,OAAO,GAAA;AACT;AAGO,SAAS,iBAAA,CAAkB,QAAiB,UAAA,EAAiC;AAClF,EAAA,IAAI;AACF,IAAA,OAAO,kBAAA,CAAmB,QAAA,CAAS,KAAK,CAAA,IAAK,OAAO,UAAU,UAAA,GAAc,KAAA,CAAc,qBAAqB,CAAA,GAAI,KAAA,CAAS,CAAA;AAAA,EAC9H,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,EAAC;AAAA,EACV;AACF","file":"chunk-S7FCFQ6X.js","sourcesContent":["/**\n * The worlds a Nodaro deployment can offer — the tabs of the shared site\n * header, in its canonical display order — and the node types each one runs.\n *\n * A world is offered to a viewer when the deployment's profile allows it\n * (`surface.worlds.allow`, when set) AND every node type it runs is available\n * to that viewer. The platform's `GET /v1/surface/availability` answers both\n * per viewer; this table is the one copy that answer and every client read,\n * so a world is never shown where its runs would be refused.\n *\n * Structural vocabulary only (ids and node-type names), no content.\n */\n\nexport const WORLD_IDS = Object.freeze([\"explore\", \"image\", \"video\", \"music\", \"trends\", \"motion\", \"voice\", \"app\", \"studio\"] as const)\n\nexport type WorldId = (typeof WORLD_IDS)[number]\n\nconst WORLD_ID_SET: ReadonlySet<string> = new Set(WORLD_IDS)\n\nexport function isWorldId(value: unknown): value is WorldId {\n return typeof value === \"string\" && WORLD_ID_SET.has(value)\n}\n\n/**\n * The node types each world runs: a world is offered only while every one of\n * them is available to the viewer. A world with none runs no node of its own\n * and is gated by the allowlist alone: Explore is a showcase, App is the\n * workflow editor (whose nodes are gated one by one inside it), Studio is its\n * own product.\n *\n * - `image`: Generate Image (`POST /v1/generate-image`).\n * - `video`: Generate Video and Text to Video — the world's two routes\n * (`/v1/generate-video` from a start frame, `/v1/text-to-video` from a\n * prompt). The canvas's Image to Video node is not one of them.\n * - `music`: Suno Create Music (`/v1/suno/generate`).\n * - `trends`, `motion`: Cast Swap (`/v1/cast-swap`), the run both worlds start.\n * - `voice`: Voice Changer Pro (`/v1/voice-changer-pro`).\n */\nexport const WORLD_REQUIRED_NODE_TYPES: Readonly<Record<WorldId, readonly string[]>> = Object.freeze({\n explore: Object.freeze([]),\n image: Object.freeze([\"generate-image\"]),\n video: Object.freeze([\"generate-video\", \"text-to-video\"]),\n music: Object.freeze([\"suno-generate\"]),\n trends: Object.freeze([\"cast-swap\"]),\n motion: Object.freeze([\"cast-swap\"]),\n voice: Object.freeze([\"voice-changer-pro\"]),\n app: Object.freeze([]),\n studio: Object.freeze([]),\n})\n\n/** The worlds part of a deployment's surface profile. */\nexport interface SurfaceWorlds {\n /**\n * When PRESENT, exactly these worlds are offered (`[]` offers none). Absent:\n * every world is, subject to its node types. Unlike the profile's other\n * lists, presence is what narrows, so a list whose ids are all unknown\n * offers nothing instead of everything.\n */\n readonly allow?: readonly string[]\n /** The world a visit to the site's root lands on. Always one `allow` lets through. */\n readonly home?: WorldId\n /** Display order; worlds it leaves out follow in canonical order. */\n readonly order?: readonly WorldId[]\n}\n\n/** Does the profile's allowlist let this world through? (Node availability is checked separately.) */\nexport function worldAllowed(worlds: SurfaceWorlds | undefined, id: string): boolean {\n return worlds?.allow === undefined || worlds.allow.includes(id)\n}\n\n/** Every world, `order`'s known ids first (each once), then the rest in canonical order. */\nexport function orderWorlds(order?: readonly string[]): WorldId[] {\n const out: WorldId[] = []\n for (const id of order ?? []) if (isWorldId(id) && !out.includes(id)) out.push(id)\n for (const id of WORLD_IDS) if (!out.includes(id)) out.push(id)\n return out\n}\n","import { isWorldId, type SurfaceWorlds, type WorldId } from \"./worlds.js\"\n\n/**\n * The deployment runtime config — the object a Nodaro platform container\n * writes to `/config.js` at boot as `window.__NODARO_RUNTIME__`, and that every\n * product served from the same site reads before its app starts. One published\n * build then serves any deployment without a rebuild.\n *\n * This module is the contract between that writer and its readers: the key\n * names, their shapes, and a lenient parser. Structural vocabulary only: no\n * content, no prices, nothing about any one deployment. The platform's own\n * schema stays the authority on what a deployment may set. What reaches the\n * page has already been validated there and stripped of every server-only\n * value; this parser only refuses to hand a reader a value of the wrong type.\n */\n\n/** The global `/config.js` assigns. */\nexport const RUNTIME_CONFIG_GLOBAL = \"__NODARO_RUNTIME__\"\n\n/** Every top-level key `/config.js` can carry. */\nexport const RUNTIME_CONFIG_KEYS = Object.freeze([\n \"apiUrl\",\n \"supabaseUrl\",\n \"supabaseAnonKey\",\n \"freecutUrl\",\n \"audiomassUrl\",\n \"defaultLocale\",\n \"surface\",\n \"moderation\",\n \"previewStopRule\",\n \"mediaOrigin\",\n] as const)\nexport type RuntimeConfigKey = (typeof RUNTIME_CONFIG_KEYS)[number]\n\nexport const SURFACE_HEADER_MODES = Object.freeze([\"default\", \"white-label\"] as const)\n/** `white-label`: the deployment's own header, with no platform links or art. */\nexport type SurfaceHeaderMode = (typeof SURFACE_HEADER_MODES)[number]\n\nexport const SURFACE_CATALOG_IMAGES = Object.freeze([\"default\", \"none\", \"own\"] as const)\n/** Pictures on picker options: the platform's (`default`), none, or the deployment's own (`own`). */\nexport type SurfaceCatalogImages = (typeof SURFACE_CATALOG_IMAGES)[number]\n\nexport interface RuntimeSurfaceSibling {\n readonly label: string\n readonly url: string\n readonly urlByHost?: Readonly<Record<string, string>>\n}\n\nexport interface RuntimeSurfaceBrand {\n readonly productName: string\n readonly description?: string\n readonly wordmark?: string\n readonly platformLinks?: boolean\n /** A same-site path (`/brand/logo.svg`) or an https URL. */\n readonly logo?: string\n /** The page's icons, each a path on this site (`/brand/favicon.svg`): see `isSameSitePath`. */\n readonly favicon?: readonly string[]\n}\n\n/**\n * Overrides of a product's UI strings, `product → locale id → message key →\n * text`. Each product reads only its own namespace (`UI_STRING_PRODUCTS`). The\n * platform checks every entry against that product's dictionary before it\n * reaches a page: the key exists, the locale is one the deployment offers, the\n * text is plain and keeps the base string's `{placeholders}`.\n */\nexport type RuntimeSurfaceStrings = Readonly<Record<string, Readonly<Record<string, Readonly<Record<string, string>>>>>>\n\n/** The display side of billing. The server-only billing keys never reach a page. */\nexport interface RuntimeSurfaceBilling {\n readonly costTab: \"inherit\" | \"hidden\"\n readonly sidebarCard: \"inherit\" | \"hidden\"\n readonly selfServe: boolean\n readonly unitLabel?: string\n readonly unitRate?: number\n readonly unitDecimals?: number\n /**\n * The unit's word per interface language, beside the single `unitLabel`: a\n * language the deployment gives no word for uses `unitLabel`. Read with\n * `surfaceUnitLabel`.\n */\n readonly unitLabels?: Readonly<Record<string, string>>\n}\n\n/**\n * The deployment's surface profile as a page receives it, with every default\n * applied. Lists that are empty keep the product's own default, except\n * `worlds.allow` (see `SurfaceWorlds`).\n */\nexport interface RuntimeSurface {\n readonly nav: { readonly hide: readonly string[] }\n readonly features: { readonly hide: readonly string[] }\n readonly dashboard: { readonly tabs: readonly string[] }\n readonly nodes: { readonly deny: readonly string[]; readonly allow: readonly string[] }\n readonly models: { readonly deny: readonly string[]; readonly allow: readonly string[] }\n /** `requireSignIn`: no guest visits. When the deployment does not say, true exactly when sign-in is SSO-only. */\n readonly auth: { readonly methods: readonly string[]; readonly ssoLabel?: string; readonly requireSignIn: boolean }\n readonly siblings: { readonly apps: readonly RuntimeSurfaceSibling[] }\n readonly brand: RuntimeSurfaceBrand\n /** `offered`: the languages a visitor may pick from; absent = every language the product ships. */\n readonly locale: { readonly default?: string; readonly picker: boolean; readonly offered?: readonly string[] }\n readonly outputs: { readonly allowPublic: boolean }\n readonly voice: { readonly allowedGenders: readonly string[] }\n readonly billing: RuntimeSurfaceBilling\n readonly catalogs: { readonly required: boolean; readonly factoryPresets: boolean; readonly images: SurfaceCatalogImages }\n /** `links`: whether media may be imported from a link to another site. */\n readonly imports: { readonly links: boolean }\n readonly header: SurfaceHeaderMode\n readonly worlds: SurfaceWorlds\n /** The deployment's own wording for UI strings; `{}` = none. Read with `surfaceStringOverride`. */\n readonly strings: RuntimeSurfaceStrings\n /** Carried as given; no reader acts on it. */\n readonly catalogPolicy?: unknown\n}\n\nexport interface NodaroRuntimeConfig {\n /** The API base. `\"/\"` means this page's own origin: see `resolveRuntimeApiBase`. */\n readonly apiUrl?: string\n /** The Supabase URL. `\"/supabase\"` means this page's own origin: see `resolveRuntimeSupabaseUrl`. */\n readonly supabaseUrl?: string\n readonly supabaseAnonKey?: string\n /** The platform editor's embedded video editor. */\n readonly freecutUrl?: string\n /** The platform editor's embedded audio editor. */\n readonly audiomassUrl?: string\n /** The language a first-time visitor starts in. */\n readonly defaultLocale?: string\n /** Present only when the deployment configured a surface profile. */\n readonly surface?: RuntimeSurface\n /** The platform editor's upload-moderation capability. */\n readonly moderation?: { readonly uploadImage?: boolean }\n /** A platform editor rollout flag. */\n readonly previewStopRule?: boolean\n /**\n * The https origin this deployment serves user media from\n * (`https://media.example.com`). Present only on a white-label deployment\n * whose public media URL is https; absent, a reader trusts no media host\n * beyond its own site.\n */\n readonly mediaOrigin?: string\n}\n\n// ── Rules shared by the platform and its readers ─────────────────────────────\n\n/** Sign-in is SSO-only when SSO is the one method offered. */\nexport function isSsoOnly(methods: readonly unknown[]): boolean {\n return methods.length > 0 && methods.every((m) => m === \"sso\")\n}\n\n/** An explicit `requireSignIn` wins; otherwise a deployment requires sign-in exactly when it is SSO-only. */\nexport function surfaceRequiresSignIn(auth: { readonly methods?: unknown; readonly requireSignIn?: unknown } | undefined): boolean {\n if (typeof auth?.requireSignIn === \"boolean\") return auth.requireSignIn\n return isSsoOnly(strings(auth?.methods))\n}\n\n// Whitespace, control characters and backslashes never belong in a logo\n// reference, and a browser reads `/\\host` as `//host`: another site.\nconst UNSAFE_REF_CHARS = /[\\s\\u0000-\\u001f\\u007f\\\\]/\nconst PROBE_ORIGIN = \"https://origin.invalid\"\n\n/**\n * A brand logo reference a page may load: a path on the page's own site\n * (`/brand/logo.svg`), or an https URL without credentials. A protocol-relative\n * `//host/…`, any other scheme (`http:`, `data:`, `javascript:`) and anything\n * with whitespace or a backslash is not one.\n */\nexport function isBrandLogoRef(value: unknown): value is string {\n if (typeof value !== \"string\" || value.length === 0 || UNSAFE_REF_CHARS.test(value)) return false\n try {\n if (value.startsWith(\"/\")) return !value.startsWith(\"//\") && new URL(value, PROBE_ORIGIN).origin === PROBE_ORIGIN\n const url = new URL(value)\n return url.protocol === \"https:\" && url.hostname.length > 0 && !url.username && !url.password\n } catch {\n return false\n }\n}\n\n// Quotes, angle brackets and backticks would end an HTML attribute that holds\n// the path, and none belongs in a path anyway.\nconst HTML_SPECIAL_CHARS = /[\"'<>`]/\n\n/**\n * A path on the page's own site (`/brand/favicon.svg`, `/icon.png?v=2`): what\n * `brand.favicon` holds, written into the page's `<head>` as a link. Stricter\n * than `isBrandLogoRef`: no URL to another site at all, and no character that\n * could end an HTML attribute.\n */\nexport function isSameSitePath(value: unknown): value is string {\n return typeof value === \"string\" && value.startsWith(\"/\") && !HTML_SPECIAL_CHARS.test(value) && isBrandLogoRef(value)\n}\n\n/**\n * The products whose UI strings a deployment may override, each keyed in\n * `surface.strings` by its id and checked against that product's own\n * dictionary. `flow`: the platform's workflow editor; `tools`: the tools app;\n * `voice`: the voice app. One profile words them all. A product adopts the\n * overrides by adding its id here and giving the platform its key manifest\n * (`uiStringManifestFile`), which a deployment composing the app into one\n * image copies next to Flow's own.\n */\nexport const UI_STRING_PRODUCTS = Object.freeze([\"flow\", \"tools\", \"voice\"] as const)\nexport type UiStringProduct = (typeof UI_STRING_PRODUCTS)[number]\n\n/**\n * What a product's build emits beside its output so the platform can check a\n * deployment's overrides at boot: every key of its base (English) dictionary\n * with the placeholder names that key's text uses, and the locales the product\n * offers. Keys and names only, never the text.\n */\nexport interface UiStringManifest {\n /** The `surface.strings` namespace the dictionary answers to (`UI_STRING_PRODUCTS`). */\n readonly product: string\n /** The locales overrides may target when the deployment sets no `locale.offered`. */\n readonly locales: readonly string[]\n /** Every key a deployment may override → the placeholder names its base text uses, sorted. */\n readonly keys: Readonly<Record<string, readonly string[]>>\n}\n\n/** The manifest's file name, at the root of the product's build output. */\nexport function uiStringManifestFile(product: string): string {\n return `ui-strings-manifest.${product}.json`\n}\n\n// `{name}`: anything else in braces (`{{now}}`, `{image:1}`, `{ variables`) is\n// text, the same way the dictionaries' interpolation reads it.\nconst UI_STRING_PLACEHOLDER = /\\{(\\w+)\\}/g\n\n/** The placeholder names `text` uses, each once, sorted. */\nexport function uiStringPlaceholders(text: string): string[] {\n return [...new Set(Array.from(text.matchAll(UI_STRING_PLACEHOLDER), (m) => m[1]))].sort()\n}\n\n/**\n * The manifest of a base dictionary. A key whose base text is blank is left\n * out: it is grammar data (a word's grammatical gender, the gap between two\n * joined fragments), not wording, and overriding it would only break the\n * sentences built from it.\n */\nexport function buildUiStringManifest(product: string, dict: Readonly<Record<string, string>>, locales: readonly string[]): UiStringManifest {\n const keys = Object.entries(dict)\n .filter(([, text]) => text.trim() !== \"\")\n .map(([key, text]): [string, string[]] => [key, uiStringPlaceholders(text)])\n return { product, locales: [...locales], keys: Object.fromEntries(keys) }\n}\n\n/** The deployment's text for `key` in `locale` of `product`, or undefined. */\nexport function surfaceStringOverride(strings: RuntimeSurfaceStrings | undefined, product: string, locale: string, key: string): string | undefined {\n const byLocale = strings && Object.hasOwn(strings, product) ? strings[product] : undefined\n const texts = byLocale && Object.hasOwn(byLocale, locale) ? byLocale[locale] : undefined\n const text = texts && Object.hasOwn(texts, key) ? texts[key] : undefined\n return typeof text === \"string\" ? text : undefined\n}\n\n/**\n * The deployment's word for its unit in `locale`: the `billing.unitLabels`\n * entry for that language, else its single `unitLabel` (`single`). `labels` is\n * the map as it arrives, on the surface or on a `display` object beside its\n * `unit`.\n */\nexport function surfaceUnitLabel(labels: Readonly<Record<string, string>> | undefined, locale: string | undefined, single: string): string {\n const word = labels && locale !== undefined && Object.hasOwn(labels, locale) ? labels[locale] : undefined\n return typeof word === \"string\" && word.length > 0 ? word : single\n}\n\n/**\n * An https origin, spelled exactly as a browser spells one\n * (`https://media.example.com`, a port only when it is not 443): what\n * `new URL(src).origin` is compared with, so a path, a trailing slash,\n * credentials, another letter case or any other scheme could never match, and\n * is not one.\n */\nexport function isHttpsOrigin(value: unknown): value is string {\n if (typeof value !== \"string\") return false\n try {\n const url = new URL(value)\n return url.protocol === \"https:\" && url.origin === value\n } catch {\n return false\n }\n}\n\n/**\n * The base a client builds API URLs on. `\"/\"` is the same-origin sentinel (a\n * site answering on more than one hostname cannot name one) and resolves to\n * `\"\"`: build every URL relative to the page. `undefined` when the config names\n * none, so the app keeps its own build-time value. It never makes up a URL.\n */\nexport function resolveRuntimeApiBase(cfg: Pick<NodaroRuntimeConfig, \"apiUrl\"> | undefined): string | undefined {\n const value = typeof cfg?.apiUrl === \"string\" ? cfg.apiUrl.trim() : \"\"\n if (!value) return undefined\n return value === \"/\" ? \"\" : value\n}\n\n/**\n * The Supabase URL a browser client uses. supabase-js needs an absolute URL, so\n * the same-origin sentinel `\"/supabase\"` resolves against `origin`, the page's\n * own (`location.origin`). `undefined` when the config names none.\n */\nexport function resolveRuntimeSupabaseUrl(cfg: Pick<NodaroRuntimeConfig, \"supabaseUrl\"> | undefined, origin: string): string | undefined {\n const value = typeof cfg?.supabaseUrl === \"string\" ? cfg.supabaseUrl.trim() : \"\"\n if (!value) return undefined\n return value === \"/supabase\" ? `${origin.replace(/\\/+$/, \"\")}/supabase` : value\n}\n\n// ── The parser ───────────────────────────────────────────────────────────────\n\ntype Rec = Readonly<Record<string, unknown>>\n\nfunction isRecord(value: unknown): value is Rec {\n return typeof value === \"object\" && value !== null && !Array.isArray(value)\n}\nconst record = (value: unknown): Rec => (isRecord(value) ? value : {})\nfunction strings(value: unknown): string[] {\n return Array.isArray(value) ? value.filter((x): x is string => typeof x === \"string\") : []\n}\nconst optional = <K extends string, V>(key: K, value: V | undefined): { [P in K]?: V } =>\n (value === undefined ? {} : { [key]: value }) as { [P in K]?: V }\nconst asString = (value: unknown): string | undefined => (typeof value === \"string\" ? value : undefined)\nconst asBoolean = (value: unknown): boolean | undefined => (typeof value === \"boolean\" ? value : undefined)\n\nfunction siblingApps(value: unknown): RuntimeSurfaceSibling[] {\n if (!Array.isArray(value)) return []\n return value.flatMap((raw) => {\n if (!isRecord(raw) || typeof raw.label !== \"string\" || typeof raw.url !== \"string\") return []\n const byHost = isRecord(raw.urlByHost)\n ? Object.fromEntries(Object.entries(raw.urlByHost).filter((e): e is [string, string] => typeof e[1] === \"string\"))\n : {}\n return [{ label: raw.label, url: raw.url, ...optional(\"urlByHost\", Object.keys(byHost).length ? byHost : undefined) }]\n })\n}\n\nfunction faviconsOf(value: unknown): string[] | undefined {\n const paths = (Array.isArray(value) ? value : [value]).filter(isSameSitePath)\n return paths.length ? [...new Set(paths)] : undefined\n}\n\nfunction brandOf(value: unknown): RuntimeSurfaceBrand {\n const b = record(value)\n return {\n productName: typeof b.productName === \"string\" && b.productName ? b.productName : \"Nodaro\",\n ...optional(\"description\", asString(b.description)),\n ...optional(\"wordmark\", asString(b.wordmark)),\n ...optional(\"platformLinks\", asBoolean(b.platformLinks)),\n ...optional(\"logo\", isBrandLogoRef(b.logo) ? b.logo : undefined),\n ...optional(\"favicon\", faviconsOf(b.favicon)),\n }\n}\n\n/**\n * `surface.strings`, keeping only text: a product, locale or key whose value\n * has the wrong type is left out, and an emptied level with it. Built from\n * entries, so a `\"__proto__\"` key stays an ordinary key. Never throws.\n */\nexport function parseRuntimeStrings(raw: unknown): RuntimeSurfaceStrings {\n const products: [string, Record<string, Record<string, string>>][] = []\n for (const [product, byLocale] of Object.entries(record(raw))) {\n const locales: [string, Record<string, string>][] = []\n for (const [locale, texts] of Object.entries(record(byLocale))) {\n const kept = Object.entries(record(texts)).filter((e): e is [string, string] => typeof e[1] === \"string\")\n if (kept.length) locales.push([locale, Object.fromEntries(kept)])\n }\n if (locales.length) products.push([product, Object.fromEntries(locales)])\n }\n return Object.fromEntries(products)\n}\n\nfunction localeOf(value: unknown): RuntimeSurface[\"locale\"] {\n const l = record(value)\n return {\n ...optional(\"default\", asString(l.default)),\n picker: l.picker !== false,\n ...optional(\"offered\", Array.isArray(l.offered) ? strings(l.offered) : undefined),\n }\n}\n\n/** Text words only, built from entries so a `\"__proto__\"` key stays an ordinary key; nothing usable leaves the key out. */\nfunction unitLabelsOf(value: unknown): Readonly<Record<string, string>> | undefined {\n const words = Object.entries(record(value)).filter((e): e is [string, string] => typeof e[1] === \"string\" && e[1].length > 0)\n return words.length ? Object.fromEntries(words) : undefined\n}\n\nfunction billingOf(value: unknown): RuntimeSurfaceBilling {\n const b = record(value)\n // Both or neither: a label without a rate (or the reverse) would put one\n // unit's name on another unit's numbers. The per-language words stand beside\n // the label, so they live and fall with it.\n const coherent = typeof b.unitLabel === \"string\" && b.unitLabel.length > 0 && typeof b.unitRate === \"number\" && Number.isFinite(b.unitRate) && b.unitRate > 0\n const decimals = typeof b.unitDecimals === \"number\" && Number.isInteger(b.unitDecimals) && b.unitDecimals >= 0 && b.unitDecimals <= 4 ? b.unitDecimals : undefined\n return {\n costTab: b.costTab === \"hidden\" ? \"hidden\" : \"inherit\",\n sidebarCard: b.sidebarCard === \"hidden\" ? \"hidden\" : \"inherit\",\n selfServe: b.selfServe !== false,\n ...(coherent\n ? { unitLabel: b.unitLabel as string, unitRate: b.unitRate as number, ...optional(\"unitDecimals\", decimals), ...optional(\"unitLabels\", unitLabelsOf(b.unitLabels)) }\n : {}),\n }\n}\n\n/** A value outside the known set reads as the restrictive one: a reader older than its platform must not show more. */\nfunction catalogImagesOf(value: unknown): SurfaceCatalogImages {\n if (value === undefined) return \"default\"\n return (SURFACE_CATALOG_IMAGES as readonly unknown[]).includes(value) ? (value as SurfaceCatalogImages) : \"none\"\n}\n\nfunction linksAllowed(value: unknown): boolean {\n if (value === undefined) return true\n if (!isRecord(value)) return false\n return value.links === undefined ? true : value.links === true\n}\n\nfunction headerModeOf(value: unknown): SurfaceHeaderMode {\n return value === undefined || value === \"default\" ? \"default\" : \"white-label\"\n}\n\nfunction worldsOf(value: unknown): SurfaceWorlds {\n if (value === undefined) return {}\n // Present but not an object: offer none rather than everything.\n if (!isRecord(value)) return { allow: [] }\n const allow = value.allow === undefined ? undefined : strings(value.allow)\n const order = Array.isArray(value.order) ? [...new Set(value.order.filter(isWorldId))] : []\n const home: WorldId | undefined = isWorldId(value.home) && (allow === undefined || allow.includes(value.home)) ? value.home : undefined\n return { ...optional(\"allow\", allow), ...optional(\"home\", home), ...optional(\"order\", order.length ? order : undefined) }\n}\n\n/** The surface block of `/config.js`, every default applied. Never throws. */\nexport function parseRuntimeSurface(raw: unknown): RuntimeSurface {\n const s = record(raw)\n const auth = record(s.auth)\n const methods = strings(auth.methods)\n const allowDeny = (v: unknown) => ({ deny: strings(record(v).deny), allow: strings(record(v).allow) })\n const catalogs = record(s.catalogs)\n return {\n nav: { hide: strings(record(s.nav).hide) },\n features: { hide: strings(record(s.features).hide) },\n dashboard: { tabs: strings(record(s.dashboard).tabs) },\n nodes: allowDeny(s.nodes),\n models: allowDeny(s.models),\n auth: { methods, ...optional(\"ssoLabel\", asString(auth.ssoLabel)), requireSignIn: surfaceRequiresSignIn({ methods, requireSignIn: auth.requireSignIn }) },\n siblings: { apps: siblingApps(record(s.siblings).apps) },\n brand: brandOf(s.brand),\n locale: localeOf(s.locale),\n outputs: { allowPublic: record(s.outputs).allowPublic !== false },\n voice: { allowedGenders: strings(record(s.voice).allowedGenders) },\n billing: billingOf(s.billing),\n catalogs: { required: catalogs.required === true, factoryPresets: catalogs.factoryPresets !== false, images: catalogImagesOf(catalogs.images) },\n imports: { links: linksAllowed(s.imports) },\n header: headerModeOf(s.header),\n worlds: worldsOf(s.worlds),\n strings: parseRuntimeStrings(s.strings),\n ...optional(\"catalogPolicy\", s.catalogPolicy),\n }\n}\n\nfunction deepFreeze<T>(value: T): T {\n if (typeof value === \"object\" && value !== null) {\n for (const child of Object.values(value)) deepFreeze(child)\n Object.freeze(value)\n }\n return value\n}\n\n/** The surface a deployment that configured none renders. */\nexport const RUNTIME_SURFACE_DEFAULT: RuntimeSurface = deepFreeze(parseRuntimeSurface(undefined))\n\nconst STRING_KEYS = [\"apiUrl\", \"supabaseUrl\", \"supabaseAnonKey\", \"freecutUrl\", \"audiomassUrl\", \"defaultLocale\"] as const\n\n/**\n * `/config.js`'s object, typed. Keeps each key only when it has the expected\n * type; a blank string is no value. Never throws.\n */\nexport function parseRuntimeConfig(raw: unknown): NodaroRuntimeConfig {\n if (!isRecord(raw)) return {}\n const out: { -readonly [K in keyof NodaroRuntimeConfig]: NodaroRuntimeConfig[K] } = {}\n for (const key of STRING_KEYS) {\n const value = raw[key]\n if (typeof value === \"string\" && value.trim()) out[key] = value.trim()\n }\n if (isRecord(raw.surface)) out.surface = parseRuntimeSurface(raw.surface)\n if (isRecord(raw.moderation) && raw.moderation.uploadImage === true) out.moderation = { uploadImage: true }\n if (raw.previewStopRule === true) out.previewStopRule = true\n if (isHttpsOrigin(raw.mediaOrigin)) out.mediaOrigin = raw.mediaOrigin\n return out\n}\n\n/** Read and parse the runtime config `/config.js` set on `scope` (default: the global object). */\nexport function readRuntimeConfig(scope: unknown = globalThis): NodaroRuntimeConfig {\n try {\n return parseRuntimeConfig(isRecord(scope) || typeof scope === \"function\" ? (scope as Rec)[RUNTIME_CONFIG_GLOBAL] : undefined)\n } catch {\n return {}\n }\n}\n"]}