@nodaro/shared 3.50.0 → 3.52.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 (175) hide show
  1. package/dist/{chunk-XQBBBQZH.cjs → chunk-25OWMP6B.cjs} +47 -47
  2. package/dist/{chunk-XQBBBQZH.cjs.map → chunk-25OWMP6B.cjs.map} +1 -1
  3. package/dist/{chunk-T4EBNTKT.js → chunk-2LNQ2MDO.js} +3 -3
  4. package/dist/{chunk-T4EBNTKT.js.map → chunk-2LNQ2MDO.js.map} +1 -1
  5. package/dist/{chunk-HPT244UT.cjs → chunk-34EXMNOX.cjs} +9 -7
  6. package/dist/chunk-34EXMNOX.cjs.map +1 -0
  7. package/dist/{chunk-7VDPBFER.cjs → chunk-3M4BNKFJ.cjs} +32 -2
  8. package/dist/chunk-3M4BNKFJ.cjs.map +1 -0
  9. package/dist/{chunk-D33YBZ3B.cjs → chunk-5M43XMRB.cjs} +8 -8
  10. package/dist/{chunk-D33YBZ3B.cjs.map → chunk-5M43XMRB.cjs.map} +1 -1
  11. package/dist/{chunk-QZANEGZ3.cjs → chunk-66GADQRV.cjs} +21 -21
  12. package/dist/{chunk-QZANEGZ3.cjs.map → chunk-66GADQRV.cjs.map} +1 -1
  13. package/dist/{chunk-KOVIMPZS.js → chunk-6CVY3345.js} +3 -3
  14. package/dist/{chunk-KOVIMPZS.js.map → chunk-6CVY3345.js.map} +1 -1
  15. package/dist/{chunk-DZOCFLMK.js → chunk-6LCZPDIF.js} +3 -3
  16. package/dist/{chunk-DZOCFLMK.js.map → chunk-6LCZPDIF.js.map} +1 -1
  17. package/dist/{chunk-QLCSS6DK.js → chunk-7FCTCWHD.js} +3 -3
  18. package/dist/{chunk-QLCSS6DK.js.map → chunk-7FCTCWHD.js.map} +1 -1
  19. package/dist/{chunk-BQSXEU3O.cjs → chunk-7HWXJIQ6.cjs} +4 -4
  20. package/dist/{chunk-BQSXEU3O.cjs.map → chunk-7HWXJIQ6.cjs.map} +1 -1
  21. package/dist/{chunk-2JUNYRMS.cjs → chunk-7YFQKR5C.cjs} +21 -21
  22. package/dist/{chunk-2JUNYRMS.cjs.map → chunk-7YFQKR5C.cjs.map} +1 -1
  23. package/dist/{chunk-ML7Q2LTB.js → chunk-A24LLEXS.js} +9 -6
  24. package/dist/chunk-A24LLEXS.js.map +1 -0
  25. package/dist/{chunk-6TL7JMVF.js → chunk-AJFQ5242.js} +5 -5
  26. package/dist/{chunk-6TL7JMVF.js.map → chunk-AJFQ5242.js.map} +1 -1
  27. package/dist/{chunk-AENQLVQH.js → chunk-AJPV3RZJ.js} +5 -5
  28. package/dist/{chunk-AENQLVQH.js.map → chunk-AJPV3RZJ.js.map} +1 -1
  29. package/dist/{chunk-NEJ2PV4C.cjs → chunk-ANMCMSGR.cjs} +6 -3
  30. package/dist/chunk-ANMCMSGR.cjs.map +1 -0
  31. package/dist/{chunk-U6BDA2CX.cjs → chunk-AVUW7XKP.cjs} +16 -16
  32. package/dist/{chunk-U6BDA2CX.cjs.map → chunk-AVUW7XKP.cjs.map} +1 -1
  33. package/dist/{chunk-HCZYIYKK.js → chunk-BG5272F5.js} +4 -4
  34. package/dist/{chunk-HCZYIYKK.js.map → chunk-BG5272F5.js.map} +1 -1
  35. package/dist/{chunk-NU6UR5RI.cjs → chunk-CSPELPDB.cjs} +8 -8
  36. package/dist/{chunk-NU6UR5RI.cjs.map → chunk-CSPELPDB.cjs.map} +1 -1
  37. package/dist/{chunk-P4QT7JGD.cjs → chunk-FBLMWA2R.cjs} +13 -13
  38. package/dist/{chunk-P4QT7JGD.cjs.map → chunk-FBLMWA2R.cjs.map} +1 -1
  39. package/dist/{chunk-X62EMX7Y.js → chunk-FIROF3TM.js} +5 -5
  40. package/dist/{chunk-X62EMX7Y.js.map → chunk-FIROF3TM.js.map} +1 -1
  41. package/dist/{chunk-27LQR7DO.js → chunk-FRXVOYL2.js} +6 -4
  42. package/dist/chunk-FRXVOYL2.js.map +1 -0
  43. package/dist/{chunk-2BHOAYZW.js → chunk-FVII3KHN.js} +32 -2
  44. package/dist/chunk-FVII3KHN.js.map +1 -0
  45. package/dist/{chunk-VCHWYREY.js → chunk-GL5Z3CC4.js} +3 -3
  46. package/dist/{chunk-VCHWYREY.js.map → chunk-GL5Z3CC4.js.map} +1 -1
  47. package/dist/chunk-H7HKLN2W.cjs +27 -0
  48. package/dist/{chunk-QIXL2ZLX.cjs.map → chunk-H7HKLN2W.cjs.map} +1 -1
  49. package/dist/{chunk-WPT5ZTA2.js → chunk-HZL7QMXK.js} +17 -4
  50. package/dist/chunk-HZL7QMXK.js.map +1 -0
  51. package/dist/{chunk-TZBIY5C3.js → chunk-IB5B3EBD.js} +6 -3
  52. package/dist/chunk-IB5B3EBD.js.map +1 -0
  53. package/dist/{chunk-DDTA6X2S.cjs → chunk-IJ6XNHSD.cjs} +10 -10
  54. package/dist/{chunk-DDTA6X2S.cjs.map → chunk-IJ6XNHSD.cjs.map} +1 -1
  55. package/dist/{chunk-NGT2FYP2.cjs → chunk-J3HPEKGJ.cjs} +9 -6
  56. package/dist/chunk-J3HPEKGJ.cjs.map +1 -0
  57. package/dist/{chunk-HSJU5KNR.cjs → chunk-J4CVGAAV.cjs} +17 -4
  58. package/dist/chunk-J4CVGAAV.cjs.map +1 -0
  59. package/dist/{chunk-FV43YJ5I.js → chunk-JAD2SBD4.js} +4 -4
  60. package/dist/{chunk-FV43YJ5I.js.map → chunk-JAD2SBD4.js.map} +1 -1
  61. package/dist/{chunk-WAUWKYLF.js → chunk-JAGYUDOK.js} +3 -3
  62. package/dist/{chunk-WAUWKYLF.js.map → chunk-JAGYUDOK.js.map} +1 -1
  63. package/dist/{chunk-77R3HYOE.js → chunk-JZJRD7RG.js} +6 -6
  64. package/dist/{chunk-77R3HYOE.js.map → chunk-JZJRD7RG.js.map} +1 -1
  65. package/dist/{chunk-MFM7XRFO.js → chunk-KWC53X5Q.js} +5 -4
  66. package/dist/chunk-KWC53X5Q.js.map +1 -0
  67. package/dist/{chunk-UDYFWB7D.cjs → chunk-MI63SSCJ.cjs} +4 -4
  68. package/dist/{chunk-UDYFWB7D.cjs.map → chunk-MI63SSCJ.cjs.map} +1 -1
  69. package/dist/{chunk-TA5MZZKE.cjs → chunk-MI6CZQCG.cjs} +45 -45
  70. package/dist/{chunk-TA5MZZKE.cjs.map → chunk-MI6CZQCG.cjs.map} +1 -1
  71. package/dist/{chunk-HLPRXII4.cjs → chunk-N2KMFVHU.cjs} +5 -3
  72. package/dist/chunk-N2KMFVHU.cjs.map +1 -0
  73. package/dist/{chunk-HNBJP2IR.js → chunk-OWVWV4T2.js} +3 -3
  74. package/dist/{chunk-HNBJP2IR.js.map → chunk-OWVWV4T2.js.map} +1 -1
  75. package/dist/{chunk-TMXFL6RC.cjs → chunk-QBXC3AXS.cjs} +12 -12
  76. package/dist/{chunk-TMXFL6RC.cjs.map → chunk-QBXC3AXS.cjs.map} +1 -1
  77. package/dist/{chunk-FEPSSBD5.cjs → chunk-SRLWSI6Q.cjs} +5 -5
  78. package/dist/{chunk-FEPSSBD5.cjs.map → chunk-SRLWSI6Q.cjs.map} +1 -1
  79. package/dist/{chunk-GIU37YMD.js → chunk-TRZMLQSL.js} +3 -3
  80. package/dist/{chunk-GIU37YMD.js.map → chunk-TRZMLQSL.js.map} +1 -1
  81. package/dist/{chunk-PSAWDKO3.cjs → chunk-TWF2OSH4.cjs} +4 -4
  82. package/dist/{chunk-PSAWDKO3.cjs.map → chunk-TWF2OSH4.cjs.map} +1 -1
  83. package/dist/{chunk-6GTTATPR.cjs → chunk-VLNOQJDO.cjs} +6 -6
  84. package/dist/{chunk-6GTTATPR.cjs.map → chunk-VLNOQJDO.cjs.map} +1 -1
  85. package/dist/{chunk-DPUIJHM7.cjs → chunk-VNHX6TQT.cjs} +5 -5
  86. package/dist/{chunk-DPUIJHM7.cjs.map → chunk-VNHX6TQT.cjs.map} +1 -1
  87. package/dist/{chunk-JGCGLHZL.js → chunk-VSNQLSME.js} +3 -3
  88. package/dist/{chunk-JGCGLHZL.js.map → chunk-VSNQLSME.js.map} +1 -1
  89. package/dist/{chunk-26L7NHK4.js → chunk-WBPJNXYN.js} +4 -4
  90. package/dist/{chunk-26L7NHK4.js.map → chunk-WBPJNXYN.js.map} +1 -1
  91. package/dist/{chunk-S5CRPOYD.cjs → chunk-XRXPWW7P.cjs} +52 -52
  92. package/dist/chunk-XRXPWW7P.cjs.map +1 -0
  93. package/dist/{chunk-QBRTPVT6.js → chunk-YOH5AUYL.js} +10 -10
  94. package/dist/chunk-YOH5AUYL.js.map +1 -0
  95. package/dist/{chunk-BLZBDPZJ.js → chunk-ZES6EZC4.js} +3 -3
  96. package/dist/{chunk-BLZBDPZJ.js.map → chunk-ZES6EZC4.js.map} +1 -1
  97. package/dist/entries/apps.cjs +43 -43
  98. package/dist/entries/apps.d.cts +1 -1
  99. package/dist/entries/apps.d.ts +1 -1
  100. package/dist/entries/apps.js +8 -8
  101. package/dist/entries/credits.cjs +151 -151
  102. package/dist/entries/credits.d.cts +1 -1
  103. package/dist/entries/credits.d.ts +1 -1
  104. package/dist/entries/credits.js +8 -8
  105. package/dist/entries/llm-models.cjs +57 -57
  106. package/dist/entries/llm-models.d.cts +7 -0
  107. package/dist/entries/llm-models.d.ts +7 -0
  108. package/dist/entries/llm-models.js +2 -2
  109. package/dist/entries/media.cjs +59 -55
  110. package/dist/entries/media.d.cts +42 -6
  111. package/dist/entries/media.d.ts +42 -6
  112. package/dist/entries/media.js +1 -1
  113. package/dist/entries/model-catalog.cjs +66 -66
  114. package/dist/entries/model-catalog.d.cts +2 -2
  115. package/dist/entries/model-catalog.d.ts +2 -2
  116. package/dist/entries/model-catalog.js +4 -4
  117. package/dist/entries/models.cjs +277 -277
  118. package/dist/entries/models.d.cts +1 -1
  119. package/dist/entries/models.d.ts +1 -1
  120. package/dist/entries/models.js +5 -5
  121. package/dist/entries/nodes.cjs +208 -208
  122. package/dist/entries/nodes.d.cts +9 -6
  123. package/dist/entries/nodes.d.ts +9 -6
  124. package/dist/entries/nodes.js +10 -10
  125. package/dist/entries/pipeline.cjs +149 -149
  126. package/dist/entries/pipeline.js +3 -3
  127. package/dist/entries/social.cjs +177 -177
  128. package/dist/entries/social.js +2 -2
  129. package/dist/entries/ugc.cjs +71 -71
  130. package/dist/entries/ugc.js +4 -4
  131. package/dist/entries/video.cjs +141 -141
  132. package/dist/entries/video.d.cts +1 -1
  133. package/dist/entries/video.d.ts +1 -1
  134. package/dist/entries/video.js +5 -5
  135. package/dist/entries/workflow.cjs +146 -146
  136. package/dist/entries/workflow.d.cts +13 -0
  137. package/dist/entries/workflow.d.ts +13 -0
  138. package/dist/entries/workflow.js +2 -2
  139. package/dist/index.cjs +1515 -1511
  140. package/dist/index.d.cts +2 -2
  141. package/dist/index.d.ts +2 -2
  142. package/dist/index.js +24 -24
  143. package/dist/{model-catalog-Ciqsc0ha.d.ts → model-catalog-Dm2UiwUe.d.cts} +4 -3
  144. package/dist/{model-catalog-Ciqsc0ha.d.cts → model-catalog-Dm2UiwUe.d.ts} +4 -3
  145. package/package.json +1 -1
  146. package/src/__tests__/llm-models.test.ts +18 -0
  147. package/src/__tests__/model-makers.test.ts +10 -0
  148. package/src/__tests__/model-tree.test.ts +5 -4
  149. package/src/__tests__/node-runtime-keys.test.ts +11 -0
  150. package/src/__tests__/preview-gate-use-case.test.ts +6 -0
  151. package/src/__tests__/template-categories.test.ts +9 -3
  152. package/src/__tests__/video-face-mesh.test.ts +7 -0
  153. package/src/llm-models.ts +37 -0
  154. package/src/model-catalog.ts +11 -7
  155. package/src/node-execution-state.ts +13 -0
  156. package/src/node-runtime-keys.ts +13 -0
  157. package/src/preview-gate.ts +7 -4
  158. package/src/template-categories.ts +2 -0
  159. package/src/video-face-mesh.ts +43 -5
  160. package/src/video-link.ts +3 -0
  161. package/dist/chunk-27LQR7DO.js.map +0 -1
  162. package/dist/chunk-2BHOAYZW.js.map +0 -1
  163. package/dist/chunk-7VDPBFER.cjs.map +0 -1
  164. package/dist/chunk-HLPRXII4.cjs.map +0 -1
  165. package/dist/chunk-HPT244UT.cjs.map +0 -1
  166. package/dist/chunk-HSJU5KNR.cjs.map +0 -1
  167. package/dist/chunk-MFM7XRFO.js.map +0 -1
  168. package/dist/chunk-ML7Q2LTB.js.map +0 -1
  169. package/dist/chunk-NEJ2PV4C.cjs.map +0 -1
  170. package/dist/chunk-NGT2FYP2.cjs.map +0 -1
  171. package/dist/chunk-QBRTPVT6.js.map +0 -1
  172. package/dist/chunk-QIXL2ZLX.cjs +0 -27
  173. package/dist/chunk-S5CRPOYD.cjs.map +0 -1
  174. package/dist/chunk-TZBIY5C3.js.map +0 -1
  175. package/dist/chunk-WPT5ZTA2.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/node-refs.ts","../src/trigger-feeds.ts","../src/node-runtime-keys.ts","../src/json-path.ts","../src/filter-condition.ts","../src/selector.ts"],"names":["SUNO_SEPARATE_RESULT_FIELDS","SUNO_SEPARATE_META_FIELDS"],"mappings":";;;;;AAMO,IAAM,gBAAA,GAAmB;AAGzB,IAAM,sBAAA,uBAA6B,GAAA,CAAI;AAAA,EAC5C,MAAA;AAAA,EACA,aAAA;AAAA,EACA,YAAA;AAAA,EACA,mBAAA;AAAA,EACA;AACF,CAAC;AAUM,SAAS,aAAa,GAAA,EAAwD;AACnF,EAAA,MAAM,CAAA,GAAI,GAAA,CAAI,OAAA,CAAQ,IAAI,CAAA;AAC1B,EAAA,IAAI,CAAA,KAAM,IAAI,OAAO,EAAE,MAAM,GAAA,CAAI,IAAA,EAAK,EAAG,QAAA,EAAU,IAAA,EAAK;AACxD,EAAA,OAAO,EAAE,IAAA,EAAM,GAAA,CAAI,KAAA,CAAM,CAAA,EAAG,CAAC,CAAA,CAAE,IAAA,EAAK,EAAG,QAAA,EAAU,IAAI,KAAA,CAAM,CAAA,GAAI,CAAC,CAAA,CAAE,MAAK,EAAE;AAC3E;AAYO,SAAS,iBAAiB,KAAA,EAAuB;AACtD,EAAA,OAAO,KA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AA,IAC3C,IAAA,EAAM,OAAA,CAAQ,MAAA,CAAO,IAAI;AAAA,GAC3B;AACF","file":"chunk-HSJU5KNR.cjs","sourcesContent":["/**\n * Node reference pattern and resolution for {Node Label} template syntax.\n * Shared between frontend and backend.\n */\n\n/** Matches {Node Label} references in text. */\nexport const NODE_REF_PATTERN = /\\{([^}]+)\\}/g\n\n/** Reserved template variable names that should NOT be resolved as node refs */\nexport const RESERVED_TEMPLATE_VARS = new Set([\n \"name\",\n \"description\",\n \"userPrompt\",\n \"assetDescriptions\",\n \"outputCount\",\n])\n\n/**\n * Split a `{...}` token body into its node name and optional fallback. Splits on the FIRST `||`\n * (a fallback may itself contain `||`); both sides are trimmed. `fallback` is null when there is\n * no `||`, preserving the legacy \"leave the literal token\" behavior.\n * \"person || man\" -> { name: \"person\", fallback: \"man\" }\n * \"person || \" -> { name: \"person\", fallback: \"\" } (resolves to empty when absent)\n * \"person\" -> { name: \"person\", fallback: null } (literal {person} when absent)\n */\nexport function parseNodeRef(raw: string): { name: string; fallback: string | null } {\n const i = raw.indexOf(\"||\")\n if (i === -1) return { name: raw.trim(), fallback: null }\n return { name: raw.slice(0, i).trim(), fallback: raw.slice(i + 2).trim() }\n}\n\n/**\n * Canonical form of a node-name variable: trimmed + lowercased. Node-name\n * variables are CASE-INSENSITIVE with lowercase as canonical, so nodes labeled\n * `TEXt`, `TEXT`, `text` all feed the one `{text}` variable and `{TEXT}` /\n * `{Text}` / `{text}` in a prompt all resolve to it.\n *\n * Reserved template vars (RESERVED_TEMPLATE_VARS, e.g. `userPrompt`) are matched\n * case-sensitively on the ORIGINAL token BEFORE canonicalization, so `{userPrompt}`\n * stays a reserved token rather than becoming a `userprompt` node ref.\n */\nexport function canonicalVarName(label: string): string {\n return label.trim().toLowerCase()\n}\n\n/**\n * The distinct `{label}` names referenced across the given texts. Mirrors the\n * canvas-side `referencedRefs`: strips the `|| fallback`, and ignores empty\n * tokens, image-ref tokens (`{image:N}`), and RESERVED_TEMPLATE_VARS. Used to\n * SUPPRESS auto-injection of a connected node the author already placed\n * explicitly via `{label}` (so it isn't injected twice). `matchAll` over the\n * global pattern does not mutate its lastIndex, so sharing the constant is safe.\n *\n * Deliberately NOT `REF_TOKEN_NAMESPACE_PREFIXES`: widening this changes\n * run-time auto-injection on BOTH engines (follow-up ticket), not just the\n * editor.\n */\nexport function extractReferencedLabels(\n ...texts: ReadonlyArray<string | undefined | null>\n): Set<string> {\n const refs = new Set<string>()\n for (const text of texts) {\n if (typeof text !== \"string\" || text.length === 0) continue\n for (const m of text.matchAll(NODE_REF_PATTERN)) {\n const { name } = parseNodeRef(m[1] ?? \"\")\n if (name === \"\" || name.startsWith(\"image:\") || RESERVED_TEMPLATE_VARS.has(name)) continue\n refs.add(canonicalVarName(name)) // case-insensitive: {Foo} suppresses a `foo` node\n }\n }\n return refs\n}\n\n/** Handle → combine-order category for same-label `{label}` merging. Lower wins\n * first: prompt (0) → elements (1) → look family (2). Other handles are -1\n * (not combinable — they keep the per-engine last-wins/suffix behavior). */\nexport const REF_HANDLE_CATEGORY: Readonly<Record<string, number>> = {\n prompt: 0,\n elements: 1,\n look: 2,\n cinematography: 2,\n style: 2,\n}\n\n/** Combine-order category for a direct-parent edge's `targetHandle`; -1 when the\n * handle isn't one of the combinable prompt/elements/look handles. */\nexport function refHandleCategory(targetHandle: string | null | undefined): number {\n if (targetHandle != null && Object.prototype.hasOwnProperty.call(REF_HANDLE_CATEGORY, targetHandle)) {\n return REF_HANDLE_CATEGORY[targetHandle]\n }\n return -1\n}\n\n/**\n * Reference-handle id → resolved-input key. The SINGLE SOURCE OF TRUTH for which\n * `targetHandle` ids carry image / video / audio reference inputs. Shared by the\n * backend input-resolver (routes the wired URL into the matching\n * `referenceImageUrls` / `referenceVideoUrls` / `referenceAudioUrls` slot) AND\n * the positional `{image:N}` / `{video:N}` / `{audio:N}` body-token COUNTS in the\n * FE preview (`video-prompt-assembly.ts`), FE run (`execute-node.ts`), and BE\n * payload-builder.\n *\n * Two handle families map to the same keys:\n * - Legacy / i2v single-name ids (`references` / `reference-videos` /\n * `reference-audio`) — kept for un-migrated workflows.\n * - Canonical typed-handle ids the modern Generate Video node exposes\n * (`imageReferences` / `videoReferences` / `audioReferences`) — share the\n * resolved-input keys with the legacy ids so consumer code never forks.\n */\nexport const REFERENCE_HANDLE_MAP: Record<string, \"referenceImageUrls\" | \"referenceVideoUrls\" | \"referenceAudioUrls\"> = {\n // Legacy / i2v single-name handle ids (kept for un-migrated workflows)\n \"references\": \"referenceImageUrls\",\n \"reference-videos\": \"referenceVideoUrls\",\n \"reference-audio\": \"referenceAudioUrls\",\n // New canonical typed-handle ids (Generate Video) — share the resolved-input\n // keys with the legacy ids so payload-builder code doesn't fork.\n \"imageReferences\": \"referenceImageUrls\",\n \"videoReferences\": \"referenceVideoUrls\",\n \"audioReferences\": \"referenceAudioUrls\",\n}\n\n/** The three reference modalities a reference handle can carry. */\nexport type ReferenceModality = \"image\" | \"video\" | \"audio\"\n\n/**\n * The reference MODALITY a `targetHandle` carries, or null when the handle is\n * not a reference handle. Resolves BOTH the legacy single-name ids and the\n * canonical Generate Video ids (via REFERENCE_HANDLE_MAP), so positional\n * `{image:N}` / `{video:N}` / `{audio:N}` token counts cover every handle alias\n * — without this, the generate-video `imageReferences` handle was silently\n * uncounted and `{image:N}` tokens dropped to bare labels on the only creatable\n * video node.\n */\nexport function referenceModalityForHandle(targetHandle: string | null | undefined): ReferenceModality | null {\n if (targetHandle == null) return null\n const key = REFERENCE_HANDLE_MAP[targetHandle]\n return key === \"referenceImageUrls\" ? \"image\" : key === \"referenceVideoUrls\" ? \"video\" : key === \"referenceAudioUrls\" ? \"audio\" : null\n}\n\n/**\n * Frame target handles (start / end keyframes). An image wired into one of these\n * is a KEYFRAME, not an `{image:N}` reference: the backend appends frames at the\n * TAIL of `reference_image_urls` (`resolveSeedance2Inputs`), never numbered. The\n * editor MUST therefore exclude them from `{image:N}` numbering so editor token N\n * equals the worker reference slot N.\n *\n * The SINGLE source of truth for \"is this a frame handle,\" shared by the\n * config-panel autocomplete (`video-configs.tsx`) AND the inline/modal builder\n * (`connected-references.ts`) — without ONE definition those two surfaces drifted\n * and the inline editor numbered the frame as `{image:1}` (the C1 bug). Frames\n * are deliberately NOT in `REFERENCE_HANDLE_MAP`: they carry no reference\n * modality, so `referenceModalityForHandle` already returns `null` for them on\n * the count side — this set is the exclusion lever for the EDITOR-numbering side.\n */\nexport const FRAME_TARGET_HANDLES: ReadonlySet<string> = new Set([\"startFrame\", \"endFrame\"])\n\n/**\n * Minimal structural edge shape {@link countRefModalityEdges} reads — only the\n * two fields the count needs. Both the FE `WorkflowEdge` (xyflow `Edge`, whose\n * `target` is a non-null string) and the BE `SimpleEdge` satisfy it.\n */\nexport interface RefModalityEdge {\n target?: string | null\n targetHandle?: string | null\n}\n\n/**\n * Count the reference-handle edges of a given reference MODALITY wired into a\n * node — the ONE positional `{image:N}` / `{video:N}` / `{audio:N}` counter\n * shared by the FE preview (`video-prompt-assembly.ts`), the FE run\n * (`execute-node.ts`), and the BE orchestrator (`payload-builder.ts`). Counting\n * via `referenceModalityForHandle` (not a single handle string) covers BOTH the\n * legacy single-name ids (`references` / `reference-videos` / `reference-audio`)\n * AND the canonical Generate Video ids (`imageReferences` / `videoReferences` /\n * `audioReferences`), so editor token N maps 1:1 to the worker\n * `referenceImageUrls` / `referenceVideoUrls` / `referenceAudioUrls` slot N on\n * every handle alias. This is the EDGE count (not the resolved/list-expanded URL\n * count) so all three paths stay byte-identical; the edge-vs-resolved divergence\n * for a reference edge that fans out to >1 URL (a List producer) is a shared,\n * documented v1 limitation.\n */\nexport function countRefModalityEdges(\n edges: ReadonlyArray<RefModalityEdge>,\n nodeId: string,\n modality: ReferenceModality,\n): number {\n let n = 0\n for (const e of edges) {\n if (e.target === nodeId && referenceModalityForHandle(e.targetHandle) === modality) n += 1\n }\n return n\n}\n\n/** A candidate contribution to the `{label}` map: the node's label, its resolved\n * output, and its direct-parent handle category (-1 = not combinable / deeper). */\nexport interface RefCandidate {\n label: string\n output: string\n category: number\n}\n\n/**\n * Same-label COMBINE: when ≥2 direct-parent candidates (category ≥ 0) share a\n * label, `{label}` resolves to their values joined by \", \" ordered prompt →\n * elements → look, and within a category by candidate (edge) order. Returns a\n * Map of ONLY the combined labels; the caller fills the rest with its own\n * (FE suffix / BE last-wins) logic, skipping any label present here. Shared so\n * the frontend executor and backend orchestrator never drift.\n */\nexport function combineSameLabelRefs(candidates: ReadonlyArray<RefCandidate>): Map<string, string> {\n const byLabel = new Map<string, RefCandidate[]>()\n for (const c of candidates) {\n if (c.category < 0) continue\n const key = canonicalVarName(c.label) // TEXt + TEXT + text collapse into one {text}\n const arr = byLabel.get(key)\n if (arr) arr.push(c)\n else byLabel.set(key, [c])\n }\n const combined = new Map<string, string>()\n for (const [label, group] of byLabel) {\n if (group.length < 2) continue\n const ordered = group\n .map((c, i) => ({ c, i }))\n .sort((a, b) => a.c.category - b.c.category || a.i - b.i)\n .map((x) => x.c.output)\n combined.set(label, ordered.join(\", \"))\n }\n return combined\n}\n\n/**\n * Resolve {Node Label} references in text by replacing them with actual node outputs.\n * Skips reserved template variables used by applyTemplate().\n * Iterates until stable to handle nested refs (e.g. {List} → {Animal1} → \"dog\").\n */\nexport function resolveNodeRefs(\n text: string,\n labelToOutput: ReadonlyMap<string, string>,\n): string {\n const MAX_PASSES = 10\n let result = text\n for (let i = 0; i < MAX_PASSES; i++) {\n const next = result.replace(NODE_REF_PATTERN, (match, raw: string) => {\n const { name, fallback } = parseNodeRef(raw)\n if (RESERVED_TEMPLATE_VARS.has(name)) return match\n // Node-name vars are case-insensitive: try the literal key first (keeps\n // original-cased maps like condition-variables working), then the\n // lowercase-canonical key (node-ref maps are canonical-keyed).\n const output = labelToOutput.get(name) ?? labelToOutput.get(canonicalVarName(name))\n if (output !== undefined) return output // connected, non-empty output → its value\n if (fallback !== null) return fallback // absent/empty + fallback → default (\"\" for {name || })\n return match // absent + no || → literal {name}\n })\n if (next === result) break\n result = next\n }\n return result\n}\n\n/**\n * Token namespaces that are NOT node-label references. `{image:1:face}` is the\n * unified-reference grammar, `{slot:x}` is recast's, `{video:N}`/`{audio:N}`\n * are reference handles, and `{ref:<id>}` is the id-addressed reference form —\n * all five are substituted by their own resolvers (`resolveReferenceTokens`,\n * `resolveRefIdTokens`, the recast slot pass), not by resolveNodeRefs. Before\n * this list existed, only `image:` was excluded, so `{video:1}` classified as a\n * MISSING node ref.\n *\n * Compared against the LOWERCASED token name: `REFERENCE_TOKEN_RE` is `/gi` and\n * `REF_ID_TOKEN_RE` spells `[rR][eE][fF]`, so `{Image:1}` / `{Ref:x}` really do\n * resolve downstream and must never read as a missing node ref.\n */\nexport const REF_TOKEN_NAMESPACE_PREFIXES: readonly string[] = [\n \"image:\", \"video:\", \"audio:\", \"slot:\", \"ref:\",\n]\n\nexport type RefTokenKind = \"wired\" | \"reserved\" | \"missing\" | \"skip\" | \"unknown\"\n\n/**\n * Classify a parsed `{...}` token name against the resolvable label set.\n * `resolvable === null` means the caller has no ref data at all — such tokens\n * classify `unknown` and must render like wired, so \"no data\" never\n * masquerades as \"nothing wired\".\n *\n * Single source of truth for the editor decoration, the missing-refs chip\n * (frontend/src/lib/prompt-ref-scan.ts delegates here) and the execution\n * engine's dispatch guard.\n */\nexport function classifyRefToken(\n name: string,\n resolvable: ReadonlySet<string> | null,\n): RefTokenKind {\n const lower = name.toLowerCase()\n if (name === \"\" || REF_TOKEN_NAMESPACE_PREFIXES.some((p) => lower.startsWith(p))) return \"skip\"\n if (RESERVED_TEMPLATE_VARS.has(name)) return \"reserved\"\n if (resolvable === null) return \"unknown\"\n return resolvable.has(canonicalVarName(name)) ? \"wired\" : \"missing\"\n}\n\n/**\n * The `{Label}` tokens in `text` that `resolveNodeRefs` would leave LITERAL and\n * that no upstream node can explain — i.e. exactly what would reach a provider\n * as the characters `{Label}`. Evidence for why this matters: `{Describe Image}`\n * ×2 (gpt-image-2) and `{gravity flip}` / `{rewind}` (seedance-2-5) in the\n * 2026-09-01 app-reports export.\n *\n * `resolvable` — labels with a value in the ref map (canonical/lowercase).\n * `known` — canonical labels of the nodes the caller considers to EXIST\n * (no state requirement; the backend passes every node in the\n * run's graph).\n *\n * A token whose label is in `known` but not `resolvable` PASSES: the node\n * exists and simply produced nothing, which is the caller's to substitute (the\n * backend resolves it to empty text), not this function's to refuse. A token\n * with an explicit `|| fallback` passes too — the fallback is substituted.\n * Returns original-cased names, de-duplicated by canonical form, for the\n * user-facing message.\n */\nexport function unresolvedRefTokens(\n text: string,\n opts: { resolvable: ReadonlySet<string>; known: ReadonlySet<string> },\n): string[] {\n if (typeof text !== \"string\" || text.length === 0) return []\n const seen = new Set<string>()\n const out: string[] = []\n for (const m of text.matchAll(NODE_REF_PATTERN)) {\n const { name, fallback } = parseNodeRef(m[1] ?? \"\")\n if (fallback !== null) continue\n if (classifyRefToken(name, opts.resolvable) !== \"missing\") continue\n const canon = canonicalVarName(name)\n if (opts.known.has(canon) || seen.has(canon)) continue\n seen.add(canon)\n out.push(name)\n }\n return out\n}\n","/**\n * Every way one node FEEDS another — the ONE definition the server's run\n * scope (`triggerRunScope`) and the editor's \"is this trigger wired?\" read\n * from, so the card can never say \"the branch\" while the server runs the\n * whole workflow, or the other way round:\n *\n * - a drawn edge whose two ends are both on the graph (a delta that deleted a\n * node leaves its edges behind; those feed nothing);\n * - Group membership: a node inside a Group feeds the group (`parentId`),\n * the way the engine orders a group after its members;\n * - a field mapping: `data.fieldMappings[field].sourceNodeId` feeds the node\n * that carries the mapping, even after the edge it was made from is gone.\n */\n\nexport interface FeedNode {\n readonly id: string\n readonly parentId?: string | null\n readonly data?: unknown\n}\n\nexport interface FeedEdge {\n readonly source: string\n readonly target: string\n}\n\nexport interface FeedMaps {\n /** node id → the ids it feeds */\n readonly children: ReadonlyMap<string, ReadonlyArray<string>>\n /** node id → the ids that feed it */\n readonly parents: ReadonlyMap<string, ReadonlyArray<string>>\n}\n\nexport function buildFeedMaps(nodes: ReadonlyArray<FeedNode>, edges: ReadonlyArray<FeedEdge>): FeedMaps {\n const live = new Set(nodes.map((n) => n.id))\n const children = new Map<string, string[]>()\n const parents = new Map<string, string[]>()\n const feeds = (source: string, target: string) => {\n if (!live.has(source) || !live.has(target) || source === target) return\n children.set(source, [...(children.get(source) ?? []), target])\n parents.set(target, [...(parents.get(target) ?? []), source])\n }\n for (const edge of edges) feeds(edge.source, edge.target)\n for (const n of nodes) {\n if (typeof n.parentId === \"string\" && n.parentId) feeds(n.id, n.parentId)\n const mappings = (n.data as { fieldMappings?: unknown } | null | undefined)?.fieldMappings\n if (mappings && typeof mappings === \"object\") {\n for (const mapping of Object.values(mappings as Record<string, unknown>)) {\n const sourceNodeId = (mapping as { sourceNodeId?: unknown } | null)?.sourceNodeId\n if (typeof sourceNodeId === \"string\" && sourceNodeId) feeds(sourceNodeId, n.id)\n }\n }\n }\n return { children, parents }\n}\n\n/** Does this node feed anything? A trigger that does not runs the whole workflow. */\nexport function nodeFeedsAnything(nodes: ReadonlyArray<FeedNode>, edges: ReadonlyArray<FeedEdge>, nodeId: string): boolean {\n return (buildFeedMaps(nodes, edges).children.get(nodeId) ?? []).length > 0\n}\n","import { SUNO_SEPARATE_META_FIELDS, SUNO_SEPARATE_RESULT_FIELDS } from \"./suno-separate.js\"\n\n/**\n * Field names on a node's `data` that hold runtime / result / transient execution\n * state (job ids, progress, generated outputs, fan-out bookkeeping). These are NEVER\n * part of a node's reusable configuration.\n *\n * Single source of truth, consumed by:\n * - the workflow store's undo logic (execution-only updates skip undo capture, so job\n * polling does not pollute undo history or flip `isDirty`)\n * - the node-preset extractor (presets must never capture runtime state)\n * - the backend defensive strip on preset writes\n *\n * When adding a new runtime/result field to a node's data, add its key here — or, when it is a\n * generic name only one node type writes as a result, to that type's row of\n * NODE_TYPE_EXECUTION_DATA_KEYS (read through `isExecutionDataKey` / `executionDataKeysOf`).\n */\nexport const EXECUTION_DATA_KEYS: ReadonlySet<string> = new Set([\n \"executionStatus\",\n \"currentJobId\",\n \"currentJobProgress\",\n \"errorMessage\",\n // Structured detail alongside errorMessage for a safety-filter block\n // (see `JobErrorHint` in the app's frontend/src/types/nodes.ts). Same\n // lifecycle as errorMessage: a RESULT the user expects to survive reload,\n // never user-edited config.\n \"errorHint\",\n // A job policy registered by the deployment held this node's result for a\n // human reviewer (`jobs.status = \"pending_review\"`). Pure run state, like\n // executionStatus: the node is still \"running\" and the flag disappears the\n // moment the review resolves — so it is ALSO in TRANSIENT_RUNTIME_KEYS\n // below. Without the transient half, a flip into review marks a passive tab\n // dirty and a preset captures \"awaiting review\".\n \"jobAwaitingReview\",\n // The editor cannot reach the server to read this node's job. The job keeps\n // running and the watch keeps polling. Pure run state, cleared by the next\n // check that gets through, so it is ALSO in TRANSIENT_RUNTIME_KEYS below.\n \"jobConnectionLost\",\n \"isStreaming\",\n \"generatedImageUrl\",\n \"generatedVideoUrl\",\n \"generatedAudioUrl\",\n \"generatedText\",\n \"generatedScript\",\n \"generatedItems\",\n \"generatedResults\",\n \"activeResultIndex\",\n \"sourceImageUrl\",\n \"__listTotal\",\n \"__listCompleted\",\n \"__listResults\",\n // Row-aligned twin of __listResults (Extract Field, List output) — read only\n // by the fan-out so two lists cut from one array pair by row.\n \"__alignedListResults\",\n // A render's fan-out row stamps, row-aligned with __listResults: each row's\n // take identity, and the clip every row was sent for (a failed row too).\n \"__listResultStamps\",\n // List fan-out window flag (abandon-guard exemption). Set/cleared by\n // executeNodeForList — purely execution-related, never user-edited.\n \"__listRunning\",\n // Why the last server run skipped this node (`empty_input`): a chip on the\n // card for the run that just ended, never a saved result — also in\n // TRANSIENT_RUNTIME_KEYS below.\n \"__runSkipReason\",\n // One token per paid run still out on this node that no executor mark\n // covers (the editor's `withRunInFlight`, around each paid call outside the\n // executors). Purely execution-related, never user-edited; also in\n // TRANSIENT_RUNTIME_KEYS.\n \"__runsInFlight\",\n // Selector node dual-channel outputs (picked + rest). Server-side execution\n // output, not user-edited config.\n \"pickedResults\",\n \"restResults\",\n \"__pickedResults\",\n \"__restResults\",\n \"__pickedTotal\",\n \"__restTotal\",\n \"generatedJson\",\n // A render's remapped transcript on its own pip (Speaker View's\n // `transcript`, RENDER_NODE_TYPES transcriptOutput) — run-result data.\n \"generatedTranscript\",\n // Edit Plan: a person's review of the plan (`EditedEdl`, edit-plan-review.ts),\n // kept beside `generatedJson` and fingerprinted against it. Run-result data\n // (TA14, decided 2026-10-04): out of undo, presets, templates and exports,\n // and Clear results wipes it. Persisted — never transient.\n \"editedEdl\",\n \"subWorkflowProgress\",\n \"outputResults\",\n \"shots\",\n \"result\",\n \"processedResult\",\n \"activeRoutes\",\n \"routeOutputs\",\n \"_upstreamRefresh\",\n \"zoom\",\n // Character LoRA training status fields — written every 8s while training.\n \"loraReplicateVersion\",\n \"loraTriggerWord\",\n \"loraTrainingStatus\",\n // Collect (fan-in) execution snapshot.\n \"lastInputs\",\n \"lastMeta\",\n \"__upstreamCount\",\n // Video URL node — the download's live percent/phase, written on every\n // progress tick (~2/s). Pure run-state; also in TRANSIENT_RUNTIME_KEYS below.\n \"downloadPercent\",\n \"downloadPhase\",\n // Webhook Output's delivery receipt. A webhook target may reflect the\n // request back (httpbin, RequestBin, an API that 400s with \"headers\n // received: …\"), so `webhookResponseBody` can carry whatever the request\n // carried — with an attached credential, the secret itself. Listing the three\n // here is what keeps the receipt out of template exports (GENERATED_FIELDS\n // derives from this set), out of node presets, and out of undo history.\n \"webhookSuccess\",\n \"webhookStatusCode\",\n \"webhookResponseBody\",\n // Content Ideas: one creative brief per idea (the node's list output — kept\n // out of __listResults, which would clone the node). And the non-fatal notes\n // a Content Recipe / Content Ideas run returns (\"read the first of 3 posts\").\n // Both are RESULTS: they persist, and a preset, a template or a run-only\n // patch must never treat them as config.\n \"ideaBriefs\",\n \"runWarnings\",\n // Content Ideas: the own brand whose results the last run leaned on — a\n // RESULT naming the runner's brand, so a template or a preset never carries it.\n \"brandLessons\",\n // Social Search: every post the last search found (the picker's grid), the\n // ids a person picked from them, and the run's non-fatal notes (\"only part\n // of the results loaded\"). All RESULTS: a template, a preset or a run-only\n // patch must never carry yesterday's posts or picks as configuration.\n \"searchResults\",\n \"pickedIds\",\n \"searchWarnings\",\n // Save to Collection: how the last run ended for this node (inserted /\n // duplicate / replayed) and how many old records the cap evicted. RESULTS of\n // a run — Clear results wipes them, and a template, a preset or a run-only\n // patch never carries them as configuration.\n \"lastOutcome\",\n \"lastEvicted\",\n // When the editor's \"Clear results\" last emptied this node (ISO time). Not a\n // result and not config: bookkeeping that tells the load-time recovery lanes\n // \"this node is empty ON PURPOSE\" — without it, every reload reads an empty\n // node as \"ran while the editor was closed\" and paints the last run back.\n // Persisted (never transient): the reload is exactly when it is read.\n \"resultsClearedAt\",\n // The id of the trigger-started run whose results this node shows (the\n // editor paints a Telegram run onto the canvas). Bookkeeping, not a result\n // and not config: it stops a reload from painting the same run again over\n // edits made since. Persisted for the same reason as resultsClearedAt.\n \"resultsRunId\",\n // When that run ended the node (beside resultsRunId): the editor's reopen\n // keeps a result a NEWER run left even when its own run listing cannot see\n // that run. Bookkeeping, persisted for the same reason.\n \"resultsRunEndedAt\",\n // A trigger's last run values (also in TRANSIENT_RUNTIME_KEYS: never saved).\n \"__triggerData\",\n // A fan-out's notes rows, every fan-out's (row-aligned with __listResults):\n // a row's warnings and length. A RESULT: persisted.\n \"__listResultMeta\",\n // A use-case node's continuation of one of its runs (Tighten Episode): set\n // for ONE run only, as that run's input override (an app's or the editor's\n // Render final, the canvas Continue's run option). Never saved — also in\n // TRANSIENT_RUNTIME_KEYS — so a saved one can never turn a later plain run\n // into a continuation of an old run.\n \"useCaseContinue\",\n])\n\n/**\n * Run results a node type writes under a GENERIC name — `quote`, `durationSec`,\n * `candidates` — that are execution data on THAT type only. Another node may\n * keep a setting under the same name; filing these globally would misfile it\n * (out of undo, presets, templates and the copilot's view). Same lifecycle as\n * the global results: persisted, and a run writing them is never an undo step.\n *\n * UGC video (Nodaro Cloud): the outputs a node hands on (`ugcOutputs`), UGC\n * Creator's options of a draw and their note, UGC Clips' quote, and UGC Clip's\n * warnings, length and Re-render marks (`rerenderPending`: the clips pressed for\n * Re-render that no run has rendered yet — run bookkeeping; the press itself,\n * `rerender`, is a choice).\n *\n * Suno Separate: every stem / take URL a run writes and the run's facts (its\n * engine, a Demucs fallback's refusal and reason, its mode) — not `stemName`,\n * the node's instrument setting that the run only echoes back.\n */\nexport const NODE_TYPE_EXECUTION_DATA_KEYS: Readonly<Record<string, readonly string[]>> = {\n \"ugc-creator\": [\"ugcOutputs\", \"candidates\", \"optionFailed\"],\n \"ugc-script\": [\"ugcOutputs\"],\n \"ugc-clips\": [\"ugcOutputs\", \"quote\"],\n \"ugc-clip\": [\"ugcOutputs\", \"clipWarnings\", \"durationSec\", \"rerenderPending\"],\n \"ugc-cards\": [\"ugcOutputs\"],\n \"suno-separate\": [...SUNO_SEPARATE_RESULT_FIELDS, ...SUNO_SEPARATE_META_FIELDS.filter((key) => key !== \"stemName\")],\n}\n\n/** Is `key` execution data (run state or a run's result) on a node of `type`: global, or that type's own? */\nexport function isExecutionDataKey(key: string, type: string | null | undefined): boolean {\n if (EXECUTION_DATA_KEYS.has(key)) return true\n return typeof type === \"string\" && Object.hasOwn(NODE_TYPE_EXECUTION_DATA_KEYS, type) && NODE_TYPE_EXECUTION_DATA_KEYS[type]!.includes(key)\n}\n\nconst EXECUTION_DATA_KEYS_BY_TYPE = new Map<string, ReadonlySet<string>>(\n Object.entries(NODE_TYPE_EXECUTION_DATA_KEYS).map(([type, keys]) => [type, new Set([...EXECUTION_DATA_KEYS, ...keys])]),\n)\n\n/** Every execution-data key on a node of `type`, as one set: the global ones, plus the type's own. */\nexport function executionDataKeysOf(type: string | null | undefined): ReadonlySet<string> {\n return (typeof type === \"string\" ? EXECUTION_DATA_KEYS_BY_TYPE.get(type) : undefined) ?? EXECUTION_DATA_KEYS\n}\n\n/**\n * The PURE RUN-STATE subset of EXECUTION_DATA_KEYS: per-tick values (status\n * flips, job ids, progress counters, fan-out bookkeeping) that must NEITHER\n * mark the workflow dirty NOR be persisted in the save payload. Everything\n * else in EXECUTION_DATA_KEYS is a RESULT the user expects to survive reload\n * (generated URLs/results, errorMessage, LoRA outputs, collect snapshots).\n *\n * Why this split exists: writing these keys used to set `isDirty`, so job\n * polling phantom-dirtied passive tabs → spurious autosaves → false\n * \"changed in another tab\" banners → the remote-ahead latch froze autosave\n * (the \"not saved for a long time\" report). Consumed by the workflow\n * store's dirty decision and the save-payload sanitizer below.\n *\n * Invariant (guarded by node-runtime-keys.test.ts): subset of\n * EXECUTION_DATA_KEYS — anything transient is also undo-exempt.\n */\nexport const TRANSIENT_RUNTIME_KEYS: ReadonlySet<string> = new Set([\n \"executionStatus\",\n \"currentJobId\",\n \"currentJobProgress\",\n \"jobAwaitingReview\",\n \"jobConnectionLost\",\n \"isStreaming\",\n \"subWorkflowProgress\",\n \"__listTotal\",\n \"__listCompleted\",\n \"__listRunning\",\n \"__runSkipReason\",\n // A paid run still out, held by the editor tab that started it. Never\n // saved, so a reload, which has no such run, starts without one.\n \"__runsInFlight\",\n \"_upstreamRefresh\",\n \"__upstreamCount\",\n // Video URL node download ticks. They used to dirty the workflow twice a\n // second for the length of the download — the same phantom-save chain the\n // job-progress keys above were moved here to stop. What SURVIVES a reload is\n // `downloadStatus` + `downloadId`; the percent is re-read from the server.\n \"downloadPercent\",\n \"downloadPhase\",\n // A trigger's last run values, shown in the editor after a run (a webhook's\n // body, a Telegram message and its post). Never saved: the workflow is not\n // where a message's content is kept — runs are, under their retention.\n \"__triggerData\",\n // A use-case node's continuation: one run's override, never config (above).\n \"useCaseContinue\",\n])\n\n/**\n * Pure save-payload sanitizer: returns new node objects with the transient\n * run-state keys removed from `data`. Nodes without transient keys (or\n * without `data`) are returned by reference — cheap for the common case.\n */\nexport function stripTransientRuntimeData<\n T extends { data?: Record<string, unknown> | undefined },\n>(nodes: readonly T[]): T[] {\n return nodes.map((node) => {\n const data = node.data\n if (!data) return node\n let hasTransient = false\n for (const key of TRANSIENT_RUNTIME_KEYS) {\n if (key in data) {\n hasTransient = true\n break\n }\n }\n if (!hasTransient) return node\n const cleaned: Record<string, unknown> = {}\n for (const [key, value] of Object.entries(data)) {\n if (!TRANSIENT_RUNTIME_KEYS.has(key)) cleaned[key] = value\n }\n return { ...node, data: cleaned }\n })\n}\n","/**\n * Evaluate a dot-notation path against a JSON value.\n *\n * Auto-iterates arrays at any depth: if the current value is an array,\n * the evaluator iterates and applies the remaining path to each element,\n * flattening results. This lets simple paths like \"caption\" work on a\n * top-level array and \"pages.markdown\" work on a nested array without\n * any wildcard syntax.\n *\n * Returns an array of values. Missing properties are skipped (empty for\n * that branch). Null/undefined leaf values are included — callers coerce.\n * Empty path returns `[value]` (a single-element array wrapping the\n * value) when the value is scalar/object, or the array elements flat\n * when the root is an array.\n */\nexport function evaluateJsonPath(value: unknown, path: string): unknown[] {\n const segments = path.length === 0 ? [] : path.split(\".\")\n return walk(value, segments, 0)\n}\n\n/**\n * Coerce an array of unknown values (typically from evaluateJsonPath) to\n * strings, skipping null/undefined. Primitives are stringified; objects\n * are JSON-encoded.\n */\nexport function stringifyPathResults(raw: unknown[]): string[] {\n const out: string[] = []\n for (const v of raw) {\n if (v === null || v === undefined) continue\n if (typeof v === \"string\") out.push(v)\n else if (typeof v === \"number\" || typeof v === \"boolean\") out.push(String(v))\n else out.push(JSON.stringify(v))\n }\n return out\n}\n\nfunction walk(value: unknown, segments: string[], offset: number): unknown[] {\n if (Array.isArray(value)) {\n const results: unknown[] = []\n for (const item of value) {\n for (const v of walk(item, segments, offset)) results.push(v)\n }\n return results\n }\n if (offset >= segments.length) return [value]\n if (value !== null && typeof value === \"object\") {\n const head = segments[offset]\n if (!Object.hasOwn(value as object, head)) return []\n return walk((value as Record<string, unknown>)[head], segments, offset + 1)\n }\n return []\n}\n","/** Pure condition evaluator shared by filter-list and router (conditional mode). */\n\nimport { evaluateJsonPath } from \"./json-path.js\"\nimport { resolveNodeRefs } from \"./node-refs.js\"\n\nexport type FilterListOperator =\n | \">\" | \"<\" | \">=\" | \"<=\"\n | \"=\" | \"!=\"\n | \"contains\" | \"not_contains\"\n | \"starts_with\" | \"ends_with\" | \"regex\"\n | \"exists\" | \"not_exists\"\n\nexport interface FilterListCondition {\n id?: string\n field?: string\n operator: FilterListOperator\n value?: string\n valueType?: \"static\" | \"variable\"\n /** UI-only hint on the config panel — irrelevant to evaluation. */\n mode?: \"dropdown\" | \"custom\"\n}\n\n/** AND/OR condition bundle used by the router's conditional mode. When a\n * group matches, every routeId is added to activeRoutes. Multiple groups\n * union (deduped). */\nexport interface RouterConditionGroup {\n id?: string\n conditions?: FilterListCondition[]\n conditionLogic?: \"AND\" | \"OR\"\n routeIds?: string[]\n}\n\n/**\n * Options for `evaluateCondition` / `evaluateConditionGroup`.\n */\nexport interface EvaluateConditionOptions {\n /** When `false`, text operators (`contains`, `not_contains`, `starts_with`,\n * `ends_with`, `=`, `!=`) compare case-insensitively using case-folded\n * string equality.\n *\n * Note: `=` and `!=` lose their default numeric-coercion semantics under\n * `caseSensitive: false`. Under the default (case-sensitive), `1 == \"1.0\"`\n * via `valuesEqual`; under `caseSensitive: false`, comparison is pure\n * case-folded string equality, so `\"1\" !== \"1.0\"`.\n *\n * Default (when undefined): `true` (case-sensitive) — preserves existing\n * behavior for all callers.\n *\n * Non-text operators (`>`, `<`, `>=`, `<=`, `exists`, `not_exists`,\n * `regex`) are unaffected by this flag. */\n caseSensitive?: boolean\n /** Label→output map for `{Node Label}` refs inside condition values.\n * Populated from a filter-list / router node's `\"variables\"` target\n * handle. Resolved via `resolveNodeRefs` — unknown labels preserve\n * the original `{...}` text, so JSON-literal values stay intact. */\n variables?: ReadonlyMap<string, string>\n}\n\nexport function tryParseJson(item: unknown): unknown {\n if (typeof item !== \"string\") return item\n const trimmed = item.trim()\n if (!trimmed) return item\n const first = trimmed[0]\n if (first !== \"{\" && first !== \"[\" && first !== \"\\\"\" && !/^-?\\d/.test(trimmed) && trimmed !== \"true\" && trimmed !== \"false\" && trimmed !== \"null\") {\n return item\n }\n try { return JSON.parse(trimmed) } catch { return item }\n}\n\nconst HOUR_MS = 60 * 60 * 1000\nconst DAY_MS = 24 * HOUR_MS\nconst WEEK_MS = 7 * DAY_MS\n\n/** Resolve a relative-window token like `last_N_hours:3` to an ISO timestamp\n * N units before `Date.now()`. Returns undefined for malformed tokens. */\nexport function resolveRelativeWindowToken(key: string): string | undefined {\n const m = /^last_N_(hours|days|weeks):(-?\\d+)$/.exec(key)\n if (!m) return undefined\n const n = parseInt(m[2], 10)\n if (!Number.isFinite(n)) return undefined\n const unitMs = m[1] === \"hours\" ? HOUR_MS : m[1] === \"days\" ? DAY_MS : WEEK_MS\n return new Date(Date.now() - n * unitMs).toISOString()\n}\n\n/**\n * Substitute `{{...}}` template tokens — `{{now}}`, `{{trigger.<path>}}`,\n * and relative-window tokens (`{{last_N_hours:N}}` / days / weeks). Reused\n * by `resolveConditionValue` (filter-list / router) and `resolveSelectorRefs`\n * (selector node) so token semantics stay identical across the workflow-engine\n * ref-resolution surface.\n *\n * Pure: returns a new string. Strings with no `{{...}}` tokens pass through\n * unchanged.\n */\nexport function substituteTriggerTokens(\n raw: string,\n triggerData?: Record<string, unknown>,\n): string {\n if (!/\\{\\{/.test(raw)) return raw\n return raw.replace(/\\{\\{\\s*([^}]+?)\\s*\\}\\}/g, (_m, expr) => {\n const key = String(expr).trim()\n if (key === \"now\") return new Date().toISOString()\n if (key === \"trigger.last_triggered_at\") {\n const v = triggerData?.last_triggered_at\n return v == null ? \"\" : String(v)\n }\n if (key.startsWith(\"trigger.\")) {\n const path = key.slice(\"trigger.\".length)\n const v = triggerData?.[path]\n return v == null ? \"\" : String(v)\n }\n const relative = resolveRelativeWindowToken(key)\n if (relative !== undefined) return relative\n return \"\"\n })\n}\n\nexport function resolveConditionValue(\n raw: string,\n valueType: string | undefined,\n triggerData?: Record<string, unknown>,\n variables?: ReadonlyMap<string, string>,\n): string {\n let value = raw\n if (variables && variables.size > 0) {\n value = resolveNodeRefs(value, variables)\n }\n const hasTemplate = /\\{\\{/.test(value)\n if (valueType !== \"variable\" && !hasTemplate) return value\n return substituteTriggerTokens(value, triggerData)\n}\n\nfunction asComparableNumber(v: unknown): number {\n if (typeof v === \"number\") return v\n if (typeof v === \"boolean\") return v ? 1 : 0\n if (typeof v === \"string\") {\n const trimmed = v.trim()\n if (trimmed === \"\") return NaN\n const n = Number(trimmed)\n if (!isNaN(n)) return n\n const d = Date.parse(trimmed)\n if (!isNaN(d)) return d\n }\n return NaN\n}\n\n// Numeric-first ordering compare used by >, <, >=, <=. Falls back to\n// localeCompare when either side can't be parsed as a number.\nfunction compareValues(a: unknown, b: unknown): number {\n const na = asComparableNumber(a)\n const nb = asComparableNumber(b)\n if (!isNaN(na) && !isNaN(nb)) return na - nb\n return String(a ?? \"\").localeCompare(String(b ?? \"\"))\n}\n\n// Numeric-first equality used by = and !=. So \"432\" == 432, and 432 == \"432\".\n// Falls back to strict string equality (null/undefined coerced to \"\") so\n// alpha values still work.\nfunction valuesEqual(a: unknown, b: unknown): boolean {\n const na = asComparableNumber(a)\n const nb = asComparableNumber(b)\n if (!isNaN(na) && !isNaN(nb)) return na === nb\n return String(a ?? \"\") === String(b ?? \"\")\n}\n\nfunction applyCase(s: string, caseSensitive: boolean): string {\n return caseSensitive ? s : s.toLowerCase()\n}\n\nexport function evaluateCondition(\n parsedItem: unknown,\n rawItem: string,\n condition: FilterListCondition,\n triggerData?: Record<string, unknown>,\n options?: EvaluateConditionOptions,\n): boolean {\n const path = (condition.field ?? \"\").trim()\n let fieldValue: unknown\n if (path === \"\") {\n fieldValue = parsedItem ?? rawItem\n } else {\n const matches = evaluateJsonPath(parsedItem ?? rawItem, path)\n fieldValue = matches.length > 0 ? matches[0] : undefined\n }\n\n const targetStr = resolveConditionValue(condition.value ?? \"\", condition.valueType, triggerData, options?.variables)\n // Default to case-sensitive when the flag is not explicitly set. This\n // preserves existing behavior for Router conditional mode and legacy\n // Filter List nodes that don't carry the new `caseSensitive` field.\n const cs = options?.caseSensitive ?? true\n const fieldStr = String(fieldValue ?? \"\")\n\n switch (condition.operator) {\n case \"exists\":\n return fieldValue !== undefined && fieldValue !== null\n case \"not_exists\":\n return fieldValue === undefined || fieldValue === null\n case \"contains\":\n return applyCase(fieldStr, cs).includes(applyCase(targetStr, cs))\n case \"not_contains\":\n return !applyCase(fieldStr, cs).includes(applyCase(targetStr, cs))\n case \"starts_with\":\n return applyCase(fieldStr, cs).startsWith(applyCase(targetStr, cs))\n case \"ends_with\":\n return applyCase(fieldStr, cs).endsWith(applyCase(targetStr, cs))\n case \"regex\": {\n if (!targetStr) return false\n try {\n return new RegExp(targetStr).test(fieldStr)\n } catch {\n return false\n }\n }\n case \"=\":\n return cs\n ? valuesEqual(fieldValue, targetStr)\n : applyCase(fieldStr, false) === applyCase(targetStr, false)\n case \"!=\":\n return cs\n ? !valuesEqual(fieldValue, targetStr)\n : applyCase(fieldStr, false) !== applyCase(targetStr, false)\n case \">\":\n return compareValues(fieldValue, targetStr) > 0\n case \"<\":\n return compareValues(fieldValue, targetStr) < 0\n case \">=\":\n return compareValues(fieldValue, targetStr) >= 0\n case \"<=\":\n return compareValues(fieldValue, targetStr) <= 0\n default:\n return false\n }\n}\n\n/** Evaluate a single AND/OR-joined group against one item. Empty condition\n * list evaluates to `true` — typical when the user has just added a group\n * and hasn't configured any conditions yet. */\nexport function evaluateConditionGroup(\n parsedItem: unknown,\n rawItem: string,\n conditions: readonly FilterListCondition[],\n logic: \"AND\" | \"OR\",\n triggerData?: Record<string, unknown>,\n options?: EvaluateConditionOptions,\n): boolean {\n const effective = conditions.filter((c) => c && c.operator)\n if (effective.length === 0) return true\n const results = effective.map((c) => evaluateCondition(parsedItem, rawItem, c, triggerData, options))\n return logic === \"OR\" ? results.some(Boolean) : results.every(Boolean)\n}\n","/**\n * Edge range utilities for resolving 1-based index expressions\n * and applying range/step slicing to output lists.\n *\n * Used by both frontend DAG executor and backend orchestrator\n * to support edge-level range, step, and item selection.\n */\n\nimport { evaluateCondition, substituteTriggerTokens, tryParseJson } from \"./filter-condition.js\"\nimport { resolveNodeRefs } from \"./node-refs.js\"\n\n/** Selector tab on an edge — \"range\" (from/to/step) or \"list\" (expression). */\nexport type SelectorMode = \"range\" | \"list\"\n\n/** Per-edge output mode controlling how upstream results reach downstream. */\nexport type OutputMode = \"last\" | \"each\" | \"all\" | \"item\"\n\n/** Edge-data fields consumed by selectListItems / isDefaultSelectorConfig. */\nexport type SelectorFields = {\n selectorMode?: SelectorMode\n listExpression?: string\n rangeFrom?: string\n rangeTo?: string\n rangeStep?: number\n}\n\n/** Full selector mode set — extends the edge-selector modes with new operators. */\nexport type FullSelectorMode =\n | \"item\"\n | \"range\"\n | \"list\"\n | \"random\"\n | \"modulo\"\n | \"predicate\"\n | \"named-key\"\n\n/** Operator set for predicate mode — reused from filter-list. */\nexport type SelectorPredicateOp =\n | \">\" | \"<\" | \">=\" | \"<=\"\n | \"=\" | \"!=\"\n | \"contains\" | \"not_contains\"\n | \"starts_with\" | \"ends_with\"\n | \"regex\"\n | \"exists\" | \"not_exists\"\n\n/** Config consumed by `runSelector` and `resolveSelectorRefs`. */\nexport type SelectorConfig = {\n mode: FullSelectorMode\n // item\n itemIndex?: string\n // range\n rangeFrom?: string\n rangeTo?: string\n rangeStep?: number\n // list\n listExpression?: string\n // random\n seed?: string\n randomCount?: number\n // modulo\n moduloDivisor?: string\n // predicate\n predicateField?: string\n predicateOp?: SelectorPredicateOp\n predicateValue?: string\n predicateMatch?: \"first\" | \"all\"\n predicateCaseSensitive?: boolean\n // named-key\n namedKeyField?: string\n namedKeyValue?: string\n}\n\n/** Result of a selector run. `picked ∪ rest = items`, `picked ∩ rest = ∅`. */\nexport type SelectorResult = { picked: string[]; rest: string[] }\n\n/**\n * Resolves a 1-based index expression to a 0-based array index.\n *\n * Supported expressions:\n * - \"1\", \"2\", ... — absolute 1-based index\n * - \"last\" — last element\n * - \"last-1\", \"last-2\", ... — relative from end\n *\n * Out-of-bounds values are clamped. Malformed input falls back to `defaultExpr`.\n */\nexport function resolveIndex(\n expr: string,\n listLength: number,\n defaultExpr: string = \"1\",\n): number {\n if (listLength <= 0) return 0\n\n const trimmed = expr.trim()\n let index: number\n\n if (trimmed === \"last\") {\n index = listLength - 1\n } else if (trimmed.startsWith(\"last-\")) {\n const offset = parseInt(trimmed.slice(5), 10)\n if (isNaN(offset) || offset < 0) return resolveIndex(defaultExpr === expr ? \"1\" : defaultExpr, listLength)\n index = listLength - 1 - offset\n } else {\n const n = parseInt(trimmed, 10)\n if (isNaN(n)) return resolveIndex(defaultExpr === expr ? \"1\" : defaultExpr, listLength)\n index = n - 1\n }\n\n return Math.max(0, Math.min(index, listLength - 1))\n}\n\n/**\n * Applies range and step slicing to a list of strings.\n *\n * `from` and `to` are 1-based index expressions (see `resolveIndex`).\n * `step` controls iteration direction and stride:\n * - positive step: forward iteration (from must be <= to)\n * - negative step: reverse iteration (from must be >= to)\n * - step 0 is treated as step 1\n *\n * Returns empty array if direction mismatches (e.g., from < to with negative step).\n */\nexport function applyRange(\n list: string[],\n from?: string,\n to?: string,\n step?: number,\n): string[] {\n if (list.length === 0) return []\n\n const fromIdx = resolveIndex(from ?? \"1\", list.length, \"1\")\n const toIdx = resolveIndex(to ?? \"last\", list.length, \"last\")\n const effectiveStep = step === 0 || step === undefined ? 1 : step\n\n if (effectiveStep > 0 && fromIdx > toIdx) return []\n if (effectiveStep < 0 && fromIdx < toIdx) return []\n\n const result: string[] = []\n if (effectiveStep > 0) {\n for (let i = fromIdx; i <= toIdx; i += effectiveStep) result.push(list[i])\n } else {\n for (let i = fromIdx; i >= toIdx; i += effectiveStep) result.push(list[i])\n }\n return result\n}\n\n/**\n * Migrates legacy `item:N` (0-based) outputMode to structured format.\n *\n * Legacy: `{ outputMode: \"item:0\" }` — 0-based index baked into mode string\n * New: `{ outputMode: \"item\", itemIndex: \"1\" }` — 1-based expression\n *\n * Returns the data unchanged if not a legacy item mode.\n */\nexport function migrateEdgeOutputMode(\n data: Record<string, unknown> | undefined,\n): Record<string, unknown> | undefined {\n if (!data) return data\n\n const mode = data.outputMode as string | undefined\n if (!mode || !mode.startsWith(\"item:\")) return data\n\n const idx = parseInt(mode.split(\":\")[1], 10)\n return {\n ...data,\n outputMode: \"item\",\n itemIndex: String(isNaN(idx) ? 1 : idx + 1),\n }\n}\n\n/**\n * Builds the edge range label shown as a pill on the edge.\n * Examples:\n * - \"2..last-1 +2\" — range with step 2\n * - \"last..1 -1\" — reversed\n * - \"3\" — item mode, index 3\n * - undefined — \"last\" mode has no label\n */\nexport function buildRangeLabel(\n mode: string,\n rangeFrom?: string,\n rangeTo?: string,\n rangeStep?: number,\n itemIndex?: string,\n selectorMode?: SelectorMode,\n listExpression?: string,\n): string | undefined {\n return buildItemLabel(mode, rangeFrom, rangeTo, rangeStep, itemIndex, selectorMode, listExpression)\n}\n\n/** Internal: builds the item-side label (range / list / item / each). Mode \"last\" returns undefined. */\nfunction buildItemLabel(\n mode: string,\n rangeFrom?: string,\n rangeTo?: string,\n rangeStep?: number,\n itemIndex?: string,\n selectorMode?: SelectorMode,\n listExpression?: string,\n): string | undefined {\n if (mode === \"last\") return undefined\n\n if ((mode === \"each\" || mode === \"all\") && selectorMode === \"list\") {\n const trimmed = (listExpression ?? \"\").trim()\n if (trimmed === \"\") return undefined\n return truncateLabel(trimmed, 18)\n }\n\n if (mode === \"item\") return itemIndex || undefined\n\n const from = rangeFrom ?? \"1\"\n const to = rangeTo ?? \"last\"\n const step = rangeStep ?? 1\n const isDefaultRange = from === \"1\" && to === \"last\"\n const isDefaultStep = step === 1\n if (isDefaultRange && isDefaultStep) return undefined\n\n let label = `${from}..${to}`\n if ((mode === \"each\" || mode === \"all\") && !isDefaultStep) {\n label += step > 0 ? ` +${step}` : ` ${step}`\n }\n return label\n}\n\nfunction truncateLabel(s: string, maxLen: number): string {\n if (s.length <= maxLen) return s\n return s.slice(0, maxLen) + \"…\"\n}\n\n/**\n * Validates a list expression without resolving indices.\n * Used for live UI validation in the List tab input.\n *\n * Returns { ok: true } for empty/whitespace input — matches the\n * \"empty = all items\" runtime semantics.\n */\nexport function parseListExpression(\n expr: string,\n): { ok: true } | { ok: false; error: string } {\n const result = parseListTerms(expr.trim())\n return result.ok ? { ok: true } : { ok: false, error: result.error }\n}\n\n/** Internal: validates a single index token (\"1\", \"last\", \"last-3\"). */\nfunction isValidIndexToken(token: string): boolean {\n if (token === \"last\") return true\n if (/^[1-9]\\d*$/.test(token)) return true\n const m = /^last-(\\d+)$/.exec(token)\n if (m) return !isNaN(parseInt(m[1], 10))\n return false\n}\n\n/**\n * Parses a list expression and returns 0-based indices into the list,\n * in user-specified order. Preserves duplicates.\n *\n * Supported syntax:\n * <expr> := <term> (\",\" <term>)*\n * <term> := <index> | <index> \"..\" <index> (\":\" <step>)?\n * <index> := <number> | \"last\" | \"last-\" <number>\n * <step> := integer (0 coerced to 1)\n *\n * Clamps out-of-bounds indices. Malformed input logs a warning and\n * returns [0..listLength-1] (matches applyRange leniency).\n */\nexport function resolveListExpression(expr: string, listLength: number): number[] {\n if (listLength <= 0) return []\n const result = parseListTerms(expr.trim())\n if (!result.ok) {\n console.warn(\"[edge-range] invalid list expression:\", expr, \"—\", result.error)\n return indexRange(0, listLength - 1, 1)\n }\n if (result.terms.length === 0) return indexRange(0, listLength - 1, 1)\n\n const out: number[] = []\n for (const term of result.terms) {\n if (term.kind === \"index\") {\n out.push(resolveIndex(term.token, listLength))\n } else {\n const from = resolveIndex(term.from, listLength)\n const to = resolveIndex(term.to, listLength)\n for (const idx of indexRange(from, to, term.step)) out.push(idx)\n }\n }\n return out\n}\n\n/** Internal: inclusive index range with step. Returns [] if direction mismatches. */\nfunction indexRange(from: number, to: number, step: number): number[] {\n const out: number[] = []\n if (step > 0) {\n if (from > to) return []\n for (let i = from; i <= to; i += step) out.push(i)\n } else {\n if (from < to) return []\n for (let i = from; i >= to; i += step) out.push(i)\n }\n return out\n}\n\n/**\n * Dispatches to either applyRange() or resolveListExpression() based on\n * edgeData.selectorMode. Returns a new string[] containing the selected\n * subset of items — or `items` unchanged when the edge has no filter.\n */\nexport function selectListItems(\n items: string[],\n edgeData: SelectorFields | undefined,\n): string[] {\n if (items.length === 0) return []\n if (isDefaultSelectorConfig(edgeData)) return items\n if (edgeData?.selectorMode === \"list\") {\n const indices = resolveListExpression(edgeData.listExpression ?? \"\", items.length)\n return indices.map((i) => items[i])\n }\n return applyRange(items, edgeData?.rangeFrom, edgeData?.rangeTo, edgeData?.rangeStep)\n}\n\n/**\n * Returns true when edge data carries no active filter — empty/whitespace list\n * expression in list mode, or defaults (1..last, step 1) in range mode.\n * Callers can skip filtering entirely when this returns true.\n */\nexport function isDefaultSelectorConfig(edgeData: SelectorFields | undefined): boolean {\n if (!edgeData) return true\n if (edgeData.selectorMode === \"list\") {\n return ((edgeData.listExpression ?? \"\").trim()) === \"\"\n }\n const { from, to, step } = canonicalRange(edgeData)\n return from === \"1\" && to === \"last\" && step === 1\n}\n\nexport function describeEdgeBehavior(\n edgeData:\n | {\n outputMode?: string\n selectorMode?: SelectorMode\n listExpression?: string\n rangeFrom?: string\n rangeTo?: string\n rangeStep?: number\n itemIndex?: string\n }\n | undefined,\n): string {\n const mode = edgeData?.outputMode\n return buildBaseSentence(edgeData, mode)\n}\n\nfunction buildBaseSentence(\n edgeData: Parameters<typeof describeEdgeBehavior>[0],\n mode: string | undefined,\n): string {\n if (mode === \"last\") return \"Passes the selected result.\"\n if (mode === \"item\") return buildItemSentence(edgeData)\n if (mode === \"each\") return buildEachSentence(edgeData)\n if (mode === \"all\") return buildAllSentence(edgeData)\n return \"Passes all items at once.\"\n}\n\nfunction buildItemSentence(\n edgeData: Parameters<typeof describeEdgeBehavior>[0],\n): string {\n const canonical = canonicalItemIndex(edgeData?.itemIndex)\n return `Passes only ${itemModeForm(canonical)}.`\n}\n\nfunction buildEachSentence(\n edgeData: Parameters<typeof describeEdgeBehavior>[0],\n): string {\n if (isDefaultSelectorConfig(edgeData)) return \"Runs the next node one by one, per item.\"\n if (edgeData?.selectorMode === \"list\") {\n const result = parseListTerms((edgeData.listExpression ?? \"\").trim())\n if (!result.ok) return \"Runs the next node one by one, per item.\"\n }\n const phrase = buildSelectionPhrase(edgeData)\n if (phrase.kind === \"empty-result\") {\n return \"Nothing selected — the next node won't run.\"\n }\n if (phrase.kind === \"single-index\") {\n return `Runs the next node only on ${phrase.itemModeForm}.`\n }\n return `Runs the next node once for ${phrase.text}.`\n}\n\nfunction buildAllSentence(\n edgeData: Parameters<typeof describeEdgeBehavior>[0],\n): string {\n if (isDefaultSelectorConfig(edgeData)) return \"Passes all items at once.\"\n if (edgeData?.selectorMode === \"list\") {\n const result = parseListTerms((edgeData.listExpression ?? \"\").trim())\n if (!result.ok) return \"Passes all items at once.\"\n }\n const phrase = buildSelectionPhrase(edgeData)\n if (phrase.kind === \"empty-result\") {\n return \"Nothing selected — the next node will get an empty bundle.\"\n }\n if (phrase.kind === \"single-index\") {\n return `Passes only ${phrase.itemModeForm}.`\n }\n return `Passes ${phrase.text} at once.`\n}\n\ntype CanonicalRange = { from: string; to: string; step: number }\n\nfunction canonicalItemIndex(raw: string | undefined): string {\n const trimmed = (raw ?? \"\").trim()\n if (trimmed === \"\") return \"1\"\n if (!isValidIndexToken(trimmed)) return \"1\"\n return trimmed\n}\n\nfunction canonicalRange(\n edgeData: Parameters<typeof describeEdgeBehavior>[0],\n): CanonicalRange {\n const from = ((edgeData?.rangeFrom ?? \"\").trim() || \"1\")\n const to = ((edgeData?.rangeTo ?? \"\").trim() || \"last\")\n const rawStep = edgeData?.rangeStep\n const step = rawStep === undefined || rawStep === 0 ? 1 : rawStep\n return { from, to, step }\n}\n\n\nfunction itemModeForm(canonical: string): string {\n if (canonical === \"1\") return \"the first item\"\n if (/^\\d+$/.test(canonical)) return `item ${canonical}`\n if (canonical === \"last\" || canonical === \"last-0\") return \"the last item\"\n const m = /^last-(\\d+)$/.exec(canonical)\n if (m) {\n const n = parseInt(m[1], 10)\n if (n === 1) return \"the second-to-last item\"\n if (n === 2) return \"the third-to-last item\"\n if (n === 3) return \"the fourth-to-last item\"\n return `the ${ordinal(n + 1)}-from-last item`\n }\n return \"the first item\"\n}\n\nfunction compactForm(canonical: string): string {\n if (/^\\d+$/.test(canonical)) return canonical\n if (canonical === \"last\" || canonical === \"last-0\") return \"the last one\"\n const m = /^last-(\\d+)$/.exec(canonical)\n if (m) {\n const n = parseInt(m[1], 10)\n if (n === 1) return \"the second-to-last\"\n if (n === 2) return \"the third-to-last\"\n if (n === 3) return \"the fourth-to-last\"\n return `the ${ordinal(n + 1)}-from-last`\n }\n return canonical\n}\n\nfunction ordinal(n: number): string {\n const absN = Math.abs(n)\n const lastTwo = absN % 100\n if (lastTwo >= 11 && lastTwo <= 13) return `${n}th`\n switch (absN % 10) {\n case 1: return `${n}st`\n case 2: return `${n}nd`\n case 3: return `${n}rd`\n default: return `${n}th`\n }\n}\n\ntype SelectionPhrase =\n | { kind: \"items\"; text: string }\n | { kind: \"single-index\"; itemModeForm: string }\n | { kind: \"empty-result\" }\n\nfunction buildSelectionPhrase(\n edgeData: Parameters<typeof describeEdgeBehavior>[0],\n): SelectionPhrase {\n if (edgeData?.selectorMode === \"list\") {\n return buildListSelectionPhrase((edgeData.listExpression ?? \"\").trim())\n }\n return buildRangeSelectionPhrase(canonicalRange(edgeData))\n}\n\nfunction indexKind(token: string): \"concrete\" | \"relative\" | \"invalid\" {\n if (/^[1-9]\\d*$/.test(token)) return \"concrete\"\n if (token === \"last\" || /^last-\\d+$/.test(token)) return \"relative\"\n return \"invalid\"\n}\n\nfunction relativeOffset(token: string): number {\n if (token === \"last\") return 0\n const m = /^last-(\\d+)$/.exec(token)\n return m ? parseInt(m[1], 10) : 0\n}\n\nfunction compareTokens(a: string, b: string): -1 | 0 | 1 | \"indeterminate\" {\n const ka = indexKind(a)\n const kb = indexKind(b)\n if (ka !== kb) return \"indeterminate\"\n if (ka === \"concrete\") {\n const na = parseInt(a, 10)\n const nb = parseInt(b, 10)\n return na < nb ? -1 : na > nb ? 1 : 0\n }\n if (ka === \"relative\") {\n const oa = relativeOffset(a)\n const ob = relativeOffset(b)\n return oa < ob ? 1 : oa > ob ? -1 : 0\n }\n return \"indeterminate\"\n}\n\nfunction buildRangeSelectionPhrase(r: CanonicalRange): SelectionPhrase {\n const { from, to, step } = r\n\n const cmp = compareTokens(from, to)\n if (cmp !== \"indeterminate\") {\n if (step > 0 && cmp === 1) return { kind: \"empty-result\" }\n if (step < 0 && cmp === -1) return { kind: \"empty-result\" }\n }\n\n if (cmp === 0) {\n return { kind: \"single-index\", itemModeForm: itemModeForm(from) }\n }\n\n const absStep = Math.abs(step)\n if (step === -1 && from === \"last\" && to === \"1\") {\n return { kind: \"items\", text: \"all items in reverse order\" }\n }\n\n let text = `items ${compactForm(from)} through ${compactForm(to)}`\n if (absStep === 1 && step < 0) {\n text += \" in reverse order\"\n } else if (absStep > 1 && step > 0) {\n text += ` (every ${ordinal(absStep)} item)`\n } else if (absStep > 1 && step < 0) {\n text += ` (every ${ordinal(absStep)} item, in reverse)`\n }\n return { kind: \"items\", text }\n}\n\ntype ListTerm =\n | { kind: \"index\"; token: string }\n | { kind: \"range\"; from: string; to: string; step: number }\n\ntype ParseResult =\n | { ok: true; terms: ListTerm[] }\n | { ok: false; error: string }\n\n/**\n * Core list-expression parser. Returns structured terms on success or a\n * specific error message on failure. Empty input → zero terms (not an error).\n * Error messages are surfaced unchanged in the edge-config tooltip, so they\n * must stay stable:\n * - \"Empty item between commas\"\n * - \"Invalid index: <token>\"\n * - \"Range missing endpoint: <term>\"\n * - \"Step must be an integer\"\n */\nfunction parseListTerms(expr: string): ParseResult {\n if (expr === \"\") return { ok: true, terms: [] }\n const terms: ListTerm[] = []\n const raw = expr.split(\",\")\n for (const rawTerm of raw) {\n const term = rawTerm.trim()\n if (term === \"\") return { ok: false, error: \"Empty item between commas\" }\n const rangeIdx = term.indexOf(\"..\")\n if (rangeIdx === -1) {\n if (!isValidIndexToken(term)) return { ok: false, error: `Invalid index: ${term}` }\n terms.push({ kind: \"index\", token: term })\n continue\n }\n const left = term.slice(0, rangeIdx).trim()\n const rightWithStep = term.slice(rangeIdx + 2).trim()\n if (left === \"\" || rightWithStep === \"\") {\n return { ok: false, error: `Range missing endpoint: ${term}` }\n }\n const colonIdx = rightWithStep.indexOf(\":\")\n const right = colonIdx === -1 ? rightWithStep : rightWithStep.slice(0, colonIdx).trim()\n const stepStr = colonIdx === -1 ? null : rightWithStep.slice(colonIdx + 1).trim()\n if (right === \"\") return { ok: false, error: `Range missing endpoint: ${term}` }\n if (!isValidIndexToken(left)) return { ok: false, error: `Invalid index: ${left}` }\n if (!isValidIndexToken(right)) return { ok: false, error: `Invalid index: ${right}` }\n let step = 1\n if (stepStr !== null) {\n if (!/^-?\\d+$/.test(stepStr)) return { ok: false, error: \"Step must be an integer\" }\n const parsed = parseInt(stepStr, 10)\n step = parsed === 0 ? 1 : parsed\n }\n terms.push({ kind: \"range\", from: left, to: right, step })\n }\n return { ok: true, terms }\n}\n\nfunction buildListSelectionPhrase(expr: string): SelectionPhrase {\n const result = parseListTerms(expr)\n if (!result.ok) return { kind: \"empty-result\" }\n if (result.terms.length === 0) return { kind: \"items\", text: \"items\" } // unreachable via callers; default-config catches empty\n\n const normalized = result.terms.map<ListTerm>((t) => {\n if (t.kind === \"range\") {\n const cmp = compareTokens(t.from, t.to)\n if (cmp === 0) return { kind: \"index\", token: t.from }\n }\n return t\n })\n\n if (normalized.length === 1 && normalized[0].kind === \"index\") {\n return { kind: \"single-index\", itemModeForm: itemModeForm(normalized[0].token) }\n }\n\n const rendered = normalized.map((t) => {\n if (t.kind === \"index\") return compactForm(t.token)\n let text = `${compactForm(t.from)} through ${compactForm(t.to)}`\n const absStep = Math.abs(t.step)\n if (absStep === 1 && t.step < 0) {\n if (t.from === \"last\" && t.to === \"1\") return \"all items in reverse\"\n text += \" in reverse\"\n } else if (absStep > 1 && t.step > 0) {\n text += ` (every ${ordinal(absStep)})`\n } else if (absStep > 1 && t.step < 0) {\n text += ` (every ${ordinal(absStep)}, in reverse)`\n }\n return text\n })\n\n let joined: string\n if (rendered.length === 1) {\n joined = rendered[0]\n } else if (rendered.length === 2) {\n joined = `${rendered[0]} and ${rendered[1]}`\n } else {\n const head = rendered.slice(0, -1).join(\", \")\n joined = `${head}, and ${rendered[rendered.length - 1]}`\n }\n return { kind: \"items\", text: `items ${joined}` }\n}\n\n/**\n * Run the selector against `items`. Returns the picked subset plus the\n * complement (`rest`). For modes that pick by index, `rest` is computed by\n * index exclusion (not value) so duplicate items are handled correctly.\n */\nexport function runSelector(items: string[], config: SelectorConfig): SelectorResult {\n if (items.length === 0) return { picked: [], rest: [] }\n\n switch (config.mode) {\n case \"item\": {\n const idx = resolveIndex(config.itemIndex ?? \"1\", items.length, \"1\")\n return splitByIndices(items, [idx])\n }\n case \"range\": {\n const indices = applyRangeIndices(items.length, config.rangeFrom, config.rangeTo, config.rangeStep)\n return splitByIndices(items, indices)\n }\n case \"list\": {\n const indices = resolveListExpression(config.listExpression ?? \"\", items.length)\n return splitByIndices(items, indices)\n }\n case \"random\":\n return selectRandom(items, config.randomCount ?? 1, config.seed)\n case \"modulo\":\n return selectByModulo(items, config.moduloDivisor)\n case \"predicate\":\n return selectByPredicate(items, config)\n case \"named-key\":\n return selectByNamedKey(items, config.namedKeyField, config.namedKeyValue)\n default:\n return { picked: [], rest: items.slice() }\n }\n}\n\n/**\n * Partition `items` into picked (indices ∈ pickedIndices, in their original\n * order in the source list) and rest (everything else). Deduplicates\n * `pickedIndices` so passing the same index twice doesn't double-count.\n */\nfunction splitByIndices(items: string[], pickedIndices: number[]): SelectorResult {\n const pickedSet = new Set(pickedIndices.filter((i) => i >= 0 && i < items.length))\n const picked: string[] = []\n const rest: string[] = []\n for (let i = 0; i < items.length; i++) {\n if (pickedSet.has(i)) picked.push(items[i])\n else rest.push(items[i])\n }\n return { picked, rest }\n}\n\n/**\n * Returns the indices that `applyRange` would pick. Extracted so `runSelector`\n * range mode can compute the exact picked-index set (`items.indexOf(value)`\n * would return the wrong duplicate when the list contains repeated values).\n */\nexport function applyRangeIndices(\n length: number,\n from?: string,\n to?: string,\n step?: number,\n): number[] {\n if (length === 0) return []\n const fromIdx = resolveIndex(from ?? \"1\", length, \"1\")\n const toIdx = resolveIndex(to ?? \"last\", length, \"last\")\n const effectiveStep = step === 0 || step === undefined ? 1 : step\n if (effectiveStep > 0 && fromIdx > toIdx) return []\n if (effectiveStep < 0 && fromIdx < toIdx) return []\n const result: number[] = []\n if (effectiveStep > 0) {\n for (let i = fromIdx; i <= toIdx; i += effectiveStep) result.push(i)\n } else {\n for (let i = fromIdx; i >= toIdx; i += effectiveStep) result.push(i)\n }\n return result\n}\n\n/** mulberry32 PRNG — deterministic given a seed (any 32-bit signed integer).\n *\n * TWIN WARNING: backend/src/providers/video/audio-fx.ts carries its own\n * private mulberry32 (cosmetically different — `>>> 0` seed masking — but the\n * same sequence). The two are deliberately INDEPENDENT and both frozen: the\n * audio-fx copy seeds every reverb impulse response that the committed\n * characterization goldens (and every customer's rendered reverb waveform)\n * are pinned to. Do NOT \"deduplicate\" them into one shared export or \"sync\"\n * one to match the other — a change to either sequence is a silent behavior\n * change in its domain. */\nfunction mulberry32(seed: number): () => number {\n let a = seed | 0\n return () => {\n a = (a + 0x6D2B79F5) | 0\n let t = a\n t = Math.imul(t ^ (t >>> 15), t | 1)\n t ^= t + Math.imul(t ^ (t >>> 7), t | 61)\n return ((t ^ (t >>> 14)) >>> 0) / 4294967296\n }\n}\n\n/** Hash a seed string to a 32-bit integer (FNV-1a variant). */\nfunction hashSeed(s: string): number {\n let h = 2166136261 | 0\n for (let i = 0; i < s.length; i++) {\n h ^= s.charCodeAt(i)\n h = Math.imul(h, 16777619)\n }\n return h\n}\n\n/**\n * Pick `count` items uniformly at random without replacement.\n * If `seed` is non-empty, the PRNG is seeded deterministically.\n * Otherwise `Math.random` is used (fresh randomness per call).\n */\nexport function selectRandom(items: string[], count: number, seed?: string): SelectorResult {\n if (items.length === 0) return { picked: [], rest: [] }\n const k = Math.max(0, Math.min(count, items.length))\n const rand = seed && seed.length > 0 ? mulberry32(hashSeed(seed)) : Math.random\n // Partial Fisher-Yates: shuffle the first k positions, pick those indices.\n const indices = items.map((_, i) => i)\n for (let i = 0; i < k; i++) {\n const j = i + Math.floor(rand() * (indices.length - i))\n ;[indices[i], indices[j]] = [indices[j], indices[i]]\n }\n return splitByIndices(items, indices.slice(0, k))\n}\n\n/**\n * Pick a single item at `divisor % items.length`. Non-numeric `divisor`\n * falls back to index 0. Caller is responsible for resolving any\n * `{NodeLabel}` template refs in `divisor` BEFORE calling this — see\n * `resolveSelectorRefs`.\n */\nexport function selectByModulo(items: string[], divisor: string | undefined): SelectorResult {\n if (items.length === 0) return { picked: [], rest: [] }\n const n = divisor ? Number.parseInt(divisor.trim(), 10) : NaN\n const safeN = Number.isFinite(n) ? n : 0\n const idx = ((safeN % items.length) + items.length) % items.length\n return splitByIndices(items, [idx])\n}\n\n/**\n * Pick items whose parsed JSON satisfies the predicate. `match: \"first\"`\n * (default) stops at the first hit; `\"all\"` collects every hit.\n *\n * Reuses the filter-list condition evaluator so operator semantics\n * (numeric coercion on `=`/`!=`, locale-aware ordering, case-sensitive\n * text ops) stay identical to the Filter List node.\n */\nexport function selectByPredicate(\n items: string[],\n config: SelectorConfig,\n): SelectorResult {\n if (items.length === 0) return { picked: [], rest: [] }\n // Default operator to \"=\" so the UI's visual default (selector-config.tsx\n // shows `op={config.predicateOp ?? \"=\"}`) matches runtime; first-time\n // predicate use without explicitly setting an operator used to silently\n // return picked=[].\n // predicateField is intentionally allowed to be empty/undefined —\n // evaluateCondition treats an empty path as \"compare against the whole\n // item\" (filter-condition.ts:161), matching the UI placeholder hint\n // \"blank = whole item\" on the field input.\n const op = config.predicateOp ?? \"=\"\n // Pass caseSensitive explicitly. evaluateCondition defaults undefined to\n // `true` (case-sensitive) to preserve legacy callers, but the selector\n // UI checkbox shows unchecked by default — so undefined config must map\n // to case-INsensitive at runtime to match what the user sees.\n const opts = { caseSensitive: config.predicateCaseSensitive ?? false }\n const matchAll = config.predicateMatch === \"all\"\n const cond = {\n id: \"selector-predicate\",\n field: config.predicateField ?? \"\",\n operator: op,\n value: config.predicateValue ?? \"\",\n valueType: \"static\" as const,\n }\n const matchedIndices: number[] = []\n for (let i = 0; i < items.length; i++) {\n const parsed = tryParseJson(items[i])\n const hit = evaluateCondition(parsed, items[i], cond, undefined, opts)\n if (hit) {\n matchedIndices.push(i)\n if (!matchAll) break\n }\n }\n return splitByIndices(items, matchedIndices)\n}\n\n/**\n * Shortcut for `predicate(op=\"=\", match=\"first\")` — pick the first item\n * whose `field` strictly equals `value`. Implemented as a thin wrapper\n * so the UI can offer a 2-field form (\"look up by name\") instead of the\n * full 4-field predicate form.\n */\nexport function selectByNamedKey(\n items: string[],\n field: string | undefined,\n value: string | undefined,\n): SelectorResult {\n return selectByPredicate(items, {\n mode: \"predicate\",\n predicateField: field,\n predicateOp: \"=\",\n predicateValue: value,\n predicateMatch: \"first\",\n })\n}\n\n/**\n * Returns a new SelectorConfig with `{NodeLabel}` refs and `{{trigger.*}}` /\n * `{{now}}` / `{{last_N_*:N}}` template tokens resolved in the four\n * template-aware fields: moduloDivisor, predicateValue, namedKeyValue, seed.\n * All other fields are passed through unchanged. Callers must build\n * `variables` via `buildConditionVariables` (or equivalent) BEFORE calling.\n *\n * Other selector fields (itemIndex, range/list expressions, randomCount, etc.)\n * are treated as literals — they have their own selector-lib syntax and are\n * not resolved against the variable space.\n *\n * Token resolution matches `resolveConditionValue` exactly (both reuse\n * `substituteTriggerTokens`) so the selector's `{{trigger.foo}}` semantics\n * stay in lockstep with filter-list / router conditions.\n *\n * Pure: returns a new object; the input config is not mutated.\n */\nexport function resolveSelectorRefs(\n config: SelectorConfig,\n triggerData: Record<string, unknown> | undefined,\n variables: ReadonlyMap<string, string>,\n): SelectorConfig {\n const resolve = (v: string | undefined): string | undefined => {\n if (v == null) return v\n const refsResolved = resolveNodeRefs(v, variables)\n return substituteTriggerTokens(refsResolved, triggerData)\n }\n return {\n ...config,\n moduloDivisor: resolve(config.moduloDivisor),\n predicateValue: resolve(config.predicateValue),\n namedKeyValue: resolve(config.namedKeyValue),\n seed: resolve(config.seed),\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/freecut-protocol.ts","../src/inpaint-region.ts","../src/lottie-slots.ts","../src/lottie-overlay-catalog.ts","../src/audio-fx-presets.ts","../src/video-mask.ts","../src/video-face-mesh.ts","../src/generate-mask.ts","../src/mask-composite.ts"],"names":["clamp01","copy"],"mappings":";AAMO,IAAM,iBAAA,GAAoB;AAI1B,IAAM,oBAAA,GAAuB;AAC7B,IAAM,mBAAA,GAAsB;AAC5B,IAAM,oBAAA,GAAuB;AAG7B,IAAM,aAAA,GAAgB;AACtB,IAAM,uBAAA,GAA0B;AAChC,IAAM,uBAAA,GAA0B;AAChC,IAAM,sBAAA,GAAyB;;;ACPtC,SAAS,KAAK,MAAA,EAAwC;AACpD,EAAA,IAAI,MAAA,GAAS,CAAA,GAAI,CAAA,EAAG,OAAO,KAAA;AAC3B,EAAA,IAAI,MAAA,GAAS,CAAA,GAAI,CAAA,EAAG,OAAO,MAAA;AAC3B,EAAA,OAAO,KAAA;AACT;AAEA,IAAM,OAAO,EAAE,GAAA,EAAK,SAAS,GAAA,EAAK,QAAA,EAAU,MAAM,OAAA,EAAQ;AAC1D,IAAM,OAAO,EAAE,GAAA,EAAK,QAAQ,GAAA,EAAK,QAAA,EAAU,MAAM,OAAA,EAAQ;AAQlD,SAAS,kBAAA,CAAmB,KAAe,KAAA,EAAgE;AAChH,EAAA,MAAMA,QAAAA,GAAU,CAAC,CAAA,KAAc,IAAA,CAAK,GAAA,CAAI,GAAG,IAAA,CAAK,GAAA,CAAI,CAAA,EAAG,CAAC,CAAC,CAAA;AACzD,EAAA,MAAM,SAAS,CAAC,CAAA,KAAc,KAAK,KAAA,CAAM,CAAA,GAAI,GAAG,CAAA,GAAI,GAAA;AACpD,EAAA,MAAM,EAAA,GAAKA,Q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IAAA,CAAK,eAAA,EAAiB,EAAE,qBAAA,EAAuB,CAAA,CAAE,qBAAA,EAAuB,CAAA,CAAE,eAAe,CAAA;AAAA,IACtH,aAAA,EAAgB,+BAAqD,QAAA,CAAS,IAAA,CAAK,aAAuB,CAAA,GACrG,IAAA,CAAK,gBACN,CAAA,CAAE,aAAA;AAAA,IACN,WAAA,EAAc,6BAAmD,QAAA,CAAS,IAAA,CAAK,WAAqB,CAAA,GAC/F,IAAA,CAAK,cACN,CAAA,CAAE;AAAA,GACR;AACF;AAGO,SAAS,oBAAoB,IAAA,EAA+E;AACjH,EAAA,MAAM,IAAI,IAAA,EAAM,IAAA;AAChB,EAAA,OAAQ,oBAAA,CAA2C,QAAA,CAAS,CAAW,CAAA,GAAK,IAA0B,uBAAA,CAAwB,IAAA;AAChI;AAGO,SAAS,4BAA4B,IAAA,EAAkC;AAC5E,EAAA,OAAO,IAAA,KAAS,OAAA;AAClB;AAQO,SAAS,wBAAwB,IAAA,EAA0F;AAChI,EAAA,OAAO,2BAAA,CAA4B,mBAAA,CAAoB,IAAI,CAAC,IAAI,OAAA,GAAU,kBAAA;AAC5E;AAQO,SAAS,kCAAkC,CAAA,EAAkF;AAClI,EAAA,IAAI,2BAAA,CAA4B,CAAA,CAAE,IAAI,CAAA,SAAU,CAAA,CAAE,WAAA;AAClD,EAAA,OAAO,YAAA;AACT","file":"chunk-MFM7XRFO.js","sourcesContent":["// Single source of truth for the Nodaro <-> FreeCut iframe postMessage protocol.\n// Imported by app's freecut-editor-modal and Studio's ported modal so the wire\n// format cannot drift. The fork (Nodaro-ai/freecut-fork) mirrors these strings in\n// src/features/embedded/services/embedded-message-handler.ts + use-send-back.ts.\n\n// Nodaro (parent) -> FreeCut (iframe)\nexport const NODARO_LOAD_VIDEO = \"NODARO_LOAD_VIDEO\"\n// Multi-clip analog of NODARO_LOAD_VIDEO: lay N ordered urls on the timeline as\n// sequential clips (FreeCut fetches them itself). Used by Studio's production\n// \"Edit in FreeCut\" to assemble the whole cut.\nexport const NODARO_LOAD_TIMELINE = \"NODARO_LOAD_TIMELINE\"\nexport const NODARO_IMPORT_FILES = \"NODARO_IMPORT_FILES\"\nexport const NODARO_RESET_PROJECT = \"NODARO_RESET_PROJECT\"\n\n// FreeCut (iframe) -> Nodaro (parent)\nexport const FREECUT_READY = \"FREECUT_READY\"\nexport const FREECUT_EXPORT_COMPLETE = \"FREECUT_EXPORT_COMPLETE\"\nexport const FREECUT_EXPORT_PROGRESS = \"FREECUT_EXPORT_PROGRESS\" // reserved; fork emits it, v1 parents ignore it\nexport const FREECUT_REQUEST_IMPORT = \"FREECUT_REQUEST_IMPORT\"\n\nexport interface FreecutImportFile {\n readonly name: string\n readonly type: string\n readonly size: number\n readonly buffer: ArrayBuffer\n}\n\nexport interface NodaroLoadVideoPayload {\n readonly videoUrl: string\n /** Display/file name for the primary video (\"Shot 1.mp4\") — optional; absent = URL-derived name (fork default). */\n readonly videoName?: string\n readonly videoBuffer?: ArrayBuffer\n readonly projectJson?: unknown\n readonly additionalFiles?: ReadonlyArray<FreecutImportFile>\n}\n\nexport interface NodaroLoadTimelinePayload {\n // Ordered clip urls; FreeCut fetches each and lays them end-to-end on the timeline.\n readonly clips: ReadonlyArray<string>\n}\n\nexport interface FreecutExportCompletePayload {\n readonly videoBuffer: ArrayBuffer\n readonly projectJson?: unknown\n}\n\nexport interface FreecutExportProgressPayload {\n readonly percent: number\n}\n\nexport interface FreecutRequestImportPayload {\n readonly accept?: string\n readonly multiple?: boolean\n}\n","export interface PixelBox { x: number; y: number; width: number; height: number }\n\nexport interface MaskRegionDescriptor {\n /** bbox normalized to 0..1 against the image, clamped so x+width ≤ 1 and y+height ≤ 1. */\n normBbox: PixelBox\n /** Natural-language location, e.g. \"the upper-left region\" / \"the center\". */\n location: string\n /** Prompt fragment to PREPEND to the user instruction. */\n fragment: string\n}\n\nfunction band(center: number): \"low\" | \"mid\" | \"high\" {\n if (center < 1 / 3) return \"low\"\n if (center > 2 / 3) return \"high\"\n return \"mid\"\n}\n\nconst VERT = { low: \"upper\", mid: \"middle\", high: \"lower\" } as const\nconst HORZ = { low: \"left\", mid: \"center\", high: \"right\" } as const\n\n/**\n * Turn a pixel bounding box of the masked (edit) region into a normalized bbox\n * + natural-language location + a prompt fragment. Pure — no IO. This is the\n * Tier-B descriptor injected for strong instruction-following editors, and the\n * exact primitive Phase 2 (named regions) will reuse.\n */\nexport function describeMaskRegion(box: PixelBox, image: { width: number; height: number }): MaskRegionDescriptor {\n const clamp01 = (n: number) => Math.max(0, Math.min(1, n))\n const round2 = (n: number) => Math.round(n * 100) / 100\n const nx = clamp01(box.x / image.width)\n const ny = clamp01(box.y / image.height)\n const normBbox: PixelBox = {\n x: round2(nx),\n y: round2(ny),\n width: round2(Math.max(0, Math.min(1 - nx, box.width / image.width))),\n height: round2(Math.max(0, Math.min(1 - ny, box.height / image.height))),\n }\n\n const cx = (box.x + box.width / 2) / image.width\n const cy = (box.y + box.height / 2) / image.height\n const v = VERT[band(cy)]\n const h = HORZ[band(cx)]\n const location = v === \"middle\" && h === \"center\" ? \"the center\" : `the ${v}-${h} region`\n\n const fragment =\n `Apply the following change ONLY to ${location} of the image ` +\n `(normalized region x=${normBbox.x} y=${normBbox.y} w=${normBbox.width} h=${normBbox.height}), ` +\n `leaving everything else unchanged: `\n\n return { normBbox, location, fragment }\n}\n","/**\n * Lottie slot substitution — single source of truth (design §5).\n *\n * A slotted property is an object containing a `sid` key (canonically exactly\n * `{\"sid\": \"name\"}`; tolerantly also the annotation form `{a, k, sid}`). The\n * slot manifest maps sid → { p: <whatever belongs at the reference position> }.\n * Overrides map sid → raw value (what UI controls write).\n *\n * KEY CONVENTION: a slot's `p` is, by design, EXACTLY what belongs at the\n * reference position — and we substitute it VERBATIM, never auto-wrapping it in\n * an `{a:0,k:...}` envelope. At a property position (a fill color, a shape size)\n * that means `p` is a property object like `{\"a\":0,\"k\":[1,0,0,1]}`. At a RAW\n * position inside a text document — `layers[].t.d.k[0].s.t`, where lottie-web's\n * `buildFinalText` iterates string characters — `p` is a BARE string, e.g.\n * `{ \"nameText\": { \"p\": \"John Smith\" } }` substitutes the string `\"John Smith\"`\n * straight onto `s.t`. (Auto-wrapping there produced `{a:0,k:\"John Smith\"}` and\n * broke text rendering — the defect this contract fixes.)\n *\n * An override is wrapped ONLY when it lands on a property-object default: the\n * `{...p, k: override}` form preserves the default's envelope (animated/static\n * flags). On a raw default (or a missing slot) the override is substituted\n * verbatim too — so a raw text override stays a bare string.\n *\n * Substitution is renderer-agnostic: we replace every sid node ourselves and\n * never rely on lottie-web's version-dependent native slot support.\n */\n\ntype JsonRecord = Record<string, unknown>\n\nfunction isPlainObject(v: unknown): v is JsonRecord {\n return typeof v === \"object\" && v !== null && !Array.isArray(v)\n}\n\n/** True when `p` already looks like a lottie animated-property object. */\nfunction isPropertyObject(v: unknown): v is JsonRecord {\n return isPlainObject(v) && \"k\" in v\n}\n\nfunction resolveSlotNode(\n node: JsonRecord,\n slots: JsonRecord,\n overrides: JsonRecord,\n): unknown {\n const sid = node.sid as string\n const slot = slots[sid]\n const slotP = isPlainObject(slot) ? (slot as JsonRecord).p : undefined\n const override = overrides[sid]\n\n if (override !== undefined) {\n // Wrap into the default's property-object envelope when the default IS one\n // (preserves animated/static flags); otherwise substitute the raw override\n // verbatim — a raw text override must stay a bare string at `s.t`.\n if (isPropertyObject(slotP)) return { ...slotP, k: structuredClone(override) }\n return structuredClone(override)\n }\n if (slotP !== undefined) {\n // `p` is by convention exactly what belongs at the reference position —\n // substitute it verbatim, never auto-wrap (a bare string stays a string).\n return structuredClone(slotP)\n }\n // No slot, no override — leave the node as-is (validator rule #6 should\n // prevent this; belt-and-braces for hand-fed documents).\n return node\n}\n\nfunction walk(value: unknown, slots: JsonRecord, overrides: JsonRecord): unknown {\n if (Array.isArray(value)) {\n return value.map((item) => walk(item, slots, overrides))\n }\n if (isPlainObject(value)) {\n if (typeof value.sid === \"string\") {\n const resolved = resolveSlotNode(value, slots, overrides)\n // The original node comes back only in the missing-slot case; replacements\n // are leaf property objects and need no further walking.\n if (resolved === value) {\n const copy: JsonRecord = {}\n for (const [k, v] of Object.entries(value)) copy[k] = walk(v, slots, overrides)\n return copy\n }\n return resolved\n }\n const copy: JsonRecord = {}\n for (const [k, v] of Object.entries(value)) copy[k] = walk(v, slots, overrides)\n return copy\n }\n return value\n}\n\n/** Pure: returns a new document; never mutates inputs. */\nexport function applySlots(\n lottie: JsonRecord,\n slots: JsonRecord | undefined,\n overrides: JsonRecord | undefined,\n): JsonRecord {\n return walk(lottie, slots ?? {}, overrides ?? {}) as JsonRecord\n}\n\n// ── Playback normalization ───────────────────────────────────────────────────\n//\n// lottie-web computes a layer's local time as `frame - layer.st` and gates the\n// layer on `local >= ip && local < op`. A layer missing `st` yields NaN, fails\n// the gate, and stays `display:none` forever — the document \"loads\" (DOMLoaded\n// fires) but every frame renders blank (prod incident 2026-06-12: all authored\n// lottie renders came out as empty frames in headless Chrome). `st` and `sr`\n// are spec-optional with defaults, so documents routinely omit them; complete\n// them at the playback boundary so any source — authored plan, baked export,\n// catalog asset, external URL — renders. Mutates `doc` in place and returns it\n// (callers pass freshly fetched or freshly copied documents).\n\nexport function normalizeLottieLayers<T>(doc: T): T {\n if (!isPlainObject(doc)) return doc\n const fix = (layers: unknown): void => {\n if (!Array.isArray(layers)) return\n for (const layer of layers) {\n if (!isPlainObject(layer)) continue\n if (typeof layer.st !== \"number\") layer.st = 0\n if (typeof layer.sr !== \"number\") layer.sr = 1\n }\n }\n fix((doc as JsonRecord).layers)\n const assets = (doc as JsonRecord).assets\n if (Array.isArray(assets)) {\n for (const asset of assets) {\n if (isPlainObject(asset)) fix(asset.layers)\n }\n }\n return doc\n}\n\n// ── Slot control descriptors (Phase 2 — UI mapping) ──────────────────────────\n//\n// A slot manifest entry is `{ p: <whatever belongs at the reference position> }`\n// (Amendment 1). `describeSlotControl` unwraps that envelope to the editable raw\n// value and classifies it into the control kind the config panel should render.\n// `p` is either a property object `{a, k}` (colors, sizes, scalars) whose `k`\n// holds the value, or a bare raw value (text strings live unwrapped at `s.t`).\n\nexport type SlotControlKind = \"color\" | \"text\" | \"number\" | \"point\"\nexport interface SlotControlDescriptor {\n kind: SlotControlKind\n value: unknown\n}\n\n/**\n * Unwraps a slot entry to its editable raw value and classifies it:\n * {p:{a:0,k:[1,0,0,1]}} → { kind:\"color\", value:[1,0,0,1] }\n * {p:\"John\"} → { kind:\"text\", value:\"John\" }\n * {p:{a:0,k:42}} → { kind:\"number\", value:42 }\n * {p:{a:0,k:[10,20]}} → { kind:\"point\", value:[10,20] }\n * Animated property objects (`a:1`) and anything that doesn't map to a known\n * control kind return null (no editable control).\n */\nexport function describeSlotControl(slot: unknown): SlotControlDescriptor | null {\n if (!isPlainObject(slot)) return null\n const p = (slot as JsonRecord).p\n let value: unknown = p\n if (isPropertyObject(p)) {\n if ((p as JsonRecord).a === 1) return null\n value = (p as JsonRecord).k\n }\n if (typeof value === \"string\") return { kind: \"text\", value }\n if (typeof value === \"number\") return { kind: \"number\", value }\n if (\n Array.isArray(value) &&\n value.length === 4 &&\n value.every((n) => typeof n === \"number\" && n >= 0 && n <= 1)\n ) {\n return { kind: \"color\", value }\n }\n if (Array.isArray(value) && value.length === 2 && value.every((n) => typeof n === \"number\")) {\n return { kind: \"point\", value }\n }\n return null\n}\n\nfunction clamp01(n: number): number {\n if (Number.isNaN(n)) return 0\n return n < 0 ? 0 : n > 1 ? 1 : n\n}\n\nfunction toHexByte(component: number): string {\n return Math.round(clamp01(component) * 255)\n .toString(16)\n .padStart(2, \"0\")\n}\n\n/**\n * RGBA array (components 0..1) → hex string. The alpha component is omitted\n * when it is exactly 1 (`[1,0,0,1]` → `\"#ff0000\"`); otherwise an 8-digit hex is\n * emitted (`[0,1,0,0.5]` → `\"#00ff0080\"`). Output is always lowercase.\n */\nexport function rgbaArrayToHex(rgba: number[]): string {\n const [r = 0, g = 0, b = 0, a = 1] = rgba\n const base = `#${toHexByte(r)}${toHexByte(g)}${toHexByte(b)}`\n return a >= 1 ? base : `${base}${toHexByte(a)}`\n}\n\n/**\n * Hex string → RGBA array (components 0..1). Accepts `#rgb`, `#rrggbb`, and\n * `#rrggbbaa`; alpha defaults to 1 when absent. Leading `#` is optional.\n */\nexport function hexToRgbaArray(hex: string): number[] {\n let h = hex.trim().replace(/^#/, \"\")\n if (h.length === 3) {\n h = h\n .split(\"\")\n .map((c) => c + c)\n .join(\"\")\n }\n const r = parseInt(h.slice(0, 2), 16) / 255\n const g = parseInt(h.slice(2, 4), 16) / 255\n const b = parseInt(h.slice(4, 6), 16) / 255\n const a = h.length >= 8 ? parseInt(h.slice(6, 8), 16) / 255 : 1\n return [r, g, b, a]\n}\n\n/** Manifest sids in insertion order (drives the slot-control list ordering). */\nexport function listSlotSids(slots: Record<string, unknown>): string[] {\n return Object.keys(slots ?? {})\n}\n\n// ── Slot → app-field derivation (Phase 3 — single source of truth) ────────────\n//\n// `deriveLottieSlotFields` turns a lottie-graphic plan's slot manifest into\n// ExposableField-shaped descriptors. ONE function feeds three surfaces: the\n// editor's publish picker, the published-app runtime, and the backend MCP\n// schema extractor — so the set of slots an app exposes can never drift between\n// them. It deliberately mirrors `describeSlotControl`'s classification (the\n// editor's live slot controls use the same source of truth).\n\n/** Prefix for the synthetic field key of a derived slot field: `slot:<sid>`. */\nexport const LOTTIE_SLOT_FIELD_PREFIX = \"slot:\"\n\n/** \"primaryColor\" → \"Primary Color\"; \"bar_size\" → \"Bar Size\". */\nexport function humanizeSlotSid(sid: string): string {\n return sid\n .replace(/([a-z0-9])([A-Z])/g, \"$1 $2\")\n .replace(/[_-]+/g, \" \")\n .replace(/\\s+/g, \" \")\n .trim()\n .replace(/\\b\\w/g, (c) => c.toUpperCase())\n}\n\n/** ExposableField-shaped descriptor derived from one slot. */\nexport interface LottieSlotField {\n /** Synthetic field key: `slot:<sid>`. */\n key: string\n /** Humanized sid (camelCase / snake_case → Title Case). */\n label: string\n /** Maps onto the `ExposableField.type` members used in apps. */\n type: \"color\" | \"text\" | \"slider\"\n min?: number\n max?: number\n step?: number\n /** Hex string for color; raw value for text/number. */\n defaultValue?: unknown\n}\n\n/**\n * Derive ExposableField-shaped descriptors from a motion-graphics node's plan.\n *\n * Returns [] unless `motionPlan.planType === \"lottie-graphic\"` and `slots` is a\n * non-empty object — the elements engine and absent plans expose nothing.\n *\n * Per slot, via `describeSlotControl`:\n * - color → `{ type: \"color\", defaultValue: rgbaArrayToHex(value) }`\n * - text → `{ type: \"text\", defaultValue: value }`\n * - number → `{ type: \"slider\", min, max, step, defaultValue: value }`\n * (0–1 values → 0..1 step 0.01; larger → 0..ceil(value*2) step 1)\n * - point / null → SKIPPED. Point-kind slots are intentionally not exposed in\n * apps (no paired-number card; positions are rarely end-user-meaningful).\n */\nexport function deriveLottieSlotFields(\n motionPlan: Record<string, unknown> | undefined,\n): LottieSlotField[] {\n if (!motionPlan || motionPlan.planType !== \"lottie-graphic\") return []\n const slots = motionPlan.slots\n if (!isPlainObject(slots)) return []\n\n const fields: LottieSlotField[] = []\n for (const [sid, slot] of Object.entries(slots)) {\n const control = describeSlotControl(slot)\n if (!control) continue\n const base = { key: `${LOTTIE_SLOT_FIELD_PREFIX}${sid}`, label: humanizeSlotSid(sid) }\n\n if (control.kind === \"color\") {\n fields.push({\n ...base,\n type: \"color\",\n defaultValue: rgbaArrayToHex(control.value as number[]),\n })\n } else if (control.kind === \"text\") {\n fields.push({ ...base, type: \"text\", defaultValue: control.value })\n } else if (control.kind === \"number\") {\n const value = Number(control.value)\n const isUnit = value <= 1\n fields.push({\n ...base,\n type: \"slider\",\n min: 0,\n max: isUnit ? 1 : Math.ceil(value * 2) || 100,\n step: isUnit ? 0.01 : 1,\n defaultValue: control.value,\n })\n }\n // point / unrecognized kinds are intentionally not exposed.\n }\n return fields\n}\n","/**\n * Built-in Lottie Overlay catalog — single source of truth.\n *\n * The Lottie Overlay node ships a curated set of 12 animations the overlay LLM\n * can pick from. They were originally served from the third-party lottie.host\n * CDN, which went dead (origin returns 403) and broke every catalog-based\n * overlay render in production. The replacements were authored with our own\n * Lottie engine, baked (slots resolved, no `sid` refs), and are now self-hosted\n * on the Nodaro CDN at `https://cdn.nodaro.ai/lottie-catalog/<slug>.json`.\n *\n * This module is the ONE place the catalog lives:\n * - `LOTTIE_OVERLAY_CATALOG` feeds the overlay system prompt (the LLM's menu).\n * - `LEGACY_LOTTIE_HOST_REMAP` + `resolveLottieOverlaySrc` heal saved overlay\n * plans at render time — a plan authored before the cut-over still points at\n * a dead lottie.host URL, so the renderer rewrites it to its self-hosted\n * replacement before fetching.\n */\n\nexport interface LottieOverlayCatalogEntry {\n /** Stable system key — the R2 object is `lottie-catalog/<slug>.json`. */\n readonly slug: string\n /** Display name — mirrors the original prompt's catalog labels. */\n readonly name: string\n /** Catalog group (drives the grouped layout in the system prompt). */\n readonly group:\n | \"Celebration\"\n | \"Social / Reactions\"\n | \"UI / Indicators\"\n | \"Ambient / Decorative\"\n /** One placement-intent line for the overlay LLM. */\n readonly description: string\n /** Public CDN URL: `https://cdn.nodaro.ai/lottie-catalog/<slug>.json`. */\n readonly url: string\n /** Whether the animation is continuous (loop) or a one-shot effect. */\n readonly loop: boolean\n}\n\nconst CDN_BASE = \"https://cdn.nodaro.ai/lottie-catalog\"\n\nexport const LOTTIE_OVERLAY_CATALOG: readonly LottieOverlayCatalogEntry[] = [\n // ── Celebration ────────────────────────────────────────────────────────────\n {\n slug: \"confetti-burst\",\n name: \"Confetti burst\",\n group: \"Celebration\",\n description: \"Multicolor confetti shower — large coverage at a celebratory peak; one-shot.\",\n url: `${CDN_BASE}/confetti-burst.json`,\n loop: false,\n },\n {\n slug: \"fireworks\",\n name: \"Fireworks\",\n group: \"Celebration\",\n description: \"Bursting fireworks against the sky — big-moment payoff over the upper frame; one-shot.\",\n url: `${CDN_BASE}/fireworks.json`,\n loop: false,\n },\n {\n slug: \"party-popper\",\n name: \"Party popper\",\n group: \"Celebration\",\n description: \"Party popper streamers from a corner — a quick celebratory accent; one-shot.\",\n url: `${CDN_BASE}/party-popper.json`,\n loop: false,\n },\n {\n slug: \"stars-sparkle\",\n name: \"Stars sparkle\",\n group: \"Celebration\",\n description: \"Twinkling stars/sparkles — small accent over a highlight; loops.\",\n url: `${CDN_BASE}/stars-sparkle.json`,\n loop: true,\n },\n // ── Social / Reactions ──────────────────────────────────────────────────────\n {\n slug: \"heart-pulse\",\n name: \"Heart pulse\",\n group: \"Social / Reactions\",\n description: \"Pulsing heart reaction — medium size at a corner or edge; loops.\",\n url: `${CDN_BASE}/heart-pulse.json`,\n loop: true,\n },\n {\n slug: \"thumbs-up\",\n name: \"Thumbs up\",\n group: \"Social / Reactions\",\n description: \"Thumbs-up approval reaction — medium size, pops in once; one-shot.\",\n url: `${CDN_BASE}/thumbs-up.json`,\n loop: false,\n },\n {\n slug: \"fire-flame\",\n name: \"Fire emoji\",\n group: \"Social / Reactions\",\n description: \"Flickering flame reaction (“this is fire”) — small size at an edge; loops.\",\n url: `${CDN_BASE}/fire-flame.json`,\n loop: true,\n },\n // ── UI / Indicators ─────────────────────────────────────────────────────────\n {\n slug: \"loading-spinner\",\n name: \"Loading spinner\",\n group: \"UI / Indicators\",\n description: \"Circular loading spinner — small, centered, signals progress; loops.\",\n url: `${CDN_BASE}/loading-spinner.json`,\n loop: true,\n },\n {\n slug: \"checkmark-success\",\n name: \"Checkmark success\",\n group: \"UI / Indicators\",\n description: \"Animated success checkmark — small, marks a completed/correct moment; one-shot.\",\n url: `${CDN_BASE}/checkmark-success.json`,\n loop: false,\n },\n {\n slug: \"arrow-pointer\",\n name: \"Arrow pointer\",\n group: \"UI / Indicators\",\n description: \"Animated arrow drawing attention to a spot — small, timed to a key area; loops.\",\n url: `${CDN_BASE}/arrow-pointer.json`,\n loop: true,\n },\n // ── Ambient / Decorative ────────────────────────────────────────────────────\n {\n slug: \"floating-particles\",\n name: \"Floating particles\",\n group: \"Ambient / Decorative\",\n description: \"Soft drifting particles — large coverage, low opacity, full-duration ambience; loops.\",\n url: `${CDN_BASE}/floating-particles.json`,\n loop: true,\n },\n {\n slug: \"glowing-ring\",\n name: \"Glowing ring\",\n group: \"Ambient / Decorative\",\n description: \"Pulsing glowing ring/halo — decorative accent around a focal point; loops.\",\n url: `${CDN_BASE}/glowing-ring.json`,\n loop: true,\n },\n] as const\n\n/**\n * Dead lottie.host URLs (origin returns 403) → their replacement catalog URLs.\n * Heals saved plans at render time. The keys are copied EXACTLY from the\n * original `lottie-overlay-system.ts` prompt — they are the literal `src`\n * strings the overlay LLM emitted before the cut-over.\n */\nexport const LEGACY_LOTTIE_HOST_REMAP: Readonly<Record<string, string>> = {\n // Celebration\n \"https://lottie.host/d7313e87-e4c9-4e0d-8e03-c3a59e87d8fb/TjHnrCGBjI.json\": `${CDN_BASE}/confetti-burst.json`,\n \"https://lottie.host/d5cad0dd-4e93-4bbe-b023-e94a04bc1581/JHEZMrqfMk.json\": `${CDN_BASE}/fireworks.json`,\n \"https://lottie.host/0060c9cd-75da-42d5-af7c-1a191fa8a8fd/c1xHMRnGTO.json\": `${CDN_BASE}/party-popper.json`,\n \"https://lottie.host/c04a2758-a1d9-40a9-b81f-6f3e4e13a88c/xKCYDU2w0O.json\": `${CDN_BASE}/stars-sparkle.json`,\n // Social / Reactions\n \"https://lottie.host/44c9e8d1-856c-4641-bfbe-d0e2a5c9850e/GIBsMSIkkq.json\": `${CDN_BASE}/heart-pulse.json`,\n \"https://lottie.host/9a611d56-1f35-4f51-9fa4-6a4daa6b8714/EH71MjHKPD.json\": `${CDN_BASE}/thumbs-up.json`,\n \"https://lottie.host/66db1de9-c1a8-4d0b-bb03-47a8932a8a86/q5JBGQ8fxu.json\": `${CDN_BASE}/fire-flame.json`,\n // UI / Indicators\n \"https://lottie.host/b03d748c-3b4a-4c07-a10c-e9eb3c967349/eMVAVEnb5x.json\": `${CDN_BASE}/loading-spinner.json`,\n \"https://lottie.host/3ffaab4a-58b0-4a72-9f1c-5eaa484d8c88/g27v7IPaJc.json\": `${CDN_BASE}/checkmark-success.json`,\n \"https://lottie.host/6f831c6e-693a-4d1d-90a0-d7e2b3f00e68/PFj0MwSPrj.json\": `${CDN_BASE}/arrow-pointer.json`,\n // Ambient / Decorative\n \"https://lottie.host/9c8e1aef-f8e5-4ce8-bc80-1647ffb0724d/mNDClfKJVB.json\": `${CDN_BASE}/floating-particles.json`,\n \"https://lottie.host/b5d3e7e7-40bc-44fa-9a53-78b98ad66e80/pQVdNsVDmQ.json\": `${CDN_BASE}/glowing-ring.json`,\n}\n\n/**\n * Resolve an overlay `src` through the legacy remap: a dead lottie.host URL is\n * rewritten to its self-hosted replacement; everything else (already-migrated\n * catalog URLs, user-provided assets) passes through unchanged.\n */\nexport function resolveLottieOverlaySrc(src: string): string {\n return LEGACY_LOTTIE_HOST_REMAP[src] ?? src\n}\n","/**\n * Audio FX node — preset id union (single source of truth).\n *\n * Shared so the backend Zod route enum, the frontend config dropdown, and the\n * `AudioFxData` node type can't drift. The per-preset FFmpeg filter chains\n * (IR DUR/SHAPE, delay/EQ knobs) live in the backend provider's PRESET_CHAINS\n * map — this file only fixes the id set + their human labels.\n *\n * Reverb presets are named by ON-SCREEN SCENARIO (where the voice is happening\n * in the scene) rather than abstract size, so a creator picking \"Church\" or\n * \"Car\" gets a believable space for that shot.\n */\n\nexport const AUDIO_FX_PRESETS = [\n // — reverb / spaces (afir + inline-synth IR), ordered small → large —\n \"room\", // ordinary indoor room — bedroom / office dialogue\n \"bathroom\", // small, bright, tiled — hard early reflections\n \"car\", // tight, very damped cabin\n \"hall\", // lobby / corridor / large room\n \"concert-hall\", // big, lush, musical tail\n \"church\", // cathedral — long, dark, reverberant\n \"cave\", // dark, diffuse, long\n \"arena\", // stadium / PA — huge, bright tail\n \"outdoor\", // open air — almost dry, faint early reflections\n // — character / non-reverb —\n \"telephone\", // band-limited phone line\n \"megaphone\", // PA / bullhorn — mid-forward + light grit\n \"echo\", // discrete echo / slap-back\n \"custom\", // manual: reverb wet · delay · EQ\n] as const\n\nexport type AudioFxPreset = (typeof AUDIO_FX_PRESETS)[number]\n\nexport const AUDIO_FX_PRESET_SET: ReadonlySet<string> = new Set(AUDIO_FX_PRESETS)\n\n/** Display labels for the config dropdown. */\nexport const AUDIO_FX_PRESET_LABELS: Record<AudioFxPreset, string> = {\n room: \"Room (indoor)\",\n bathroom: \"Bathroom\",\n car: \"Car interior\",\n hall: \"Hall / Lobby\",\n \"concert-hall\": \"Concert Hall\",\n church: \"Church\",\n cave: \"Cave\",\n arena: \"Arena / Stadium\",\n outdoor: \"Outdoor (open air)\",\n telephone: \"Telephone\",\n megaphone: \"Megaphone / PA\",\n echo: \"Echo / Slap-back\",\n custom: \"Custom\",\n}\n\n/** Presets that apply convolution reverb (afir + inline-synth IR). */\nexport const AUDIO_FX_REVERB_PRESETS: ReadonlySet<AudioFxPreset> = new Set<AudioFxPreset>([\n \"room\",\n \"bathroom\",\n \"car\",\n \"hall\",\n \"concert-hall\",\n \"church\",\n \"cave\",\n \"arena\",\n \"outdoor\",\n])\n","/**\n * Video Mask — text-prompted video segmentation (SAM 3.1 / SAM 3). The wire contract of\n * the `video-mask` node, `POST /v1/video-mask`, the `video_mask` MCP verb,\n * `client.media.videoMask` and `nodaro media video-mask`, defined ONCE:\n * - every bound the route schema, the node panel and the MCP verb read;\n * - `videoMaskBilledSeconds`: the length a run is priced at — the clip's\n * length at the 30 fps basis, so a 60 fps clip is priced at twice its\n * length (the segmentation works per FRAME);\n * - `videoMaskCreditId`: which price row (`model_pricing`) that length is\n * charged from. The credit amounts live in the rows, never here.\n *\n * Worked examples (repeated in docs/nodes/ai-video/video-mask.md):\n * 4 s at 30 fps → `sam-3.1-video:5s`, 12 s at 24 fps → `sam-3.1-video:15s`,\n * 10 s at 60 fps (priced as 20 s) → `sam-3.1-video:30s`, 45 s at 30 fps → `sam-3.1-video:60s`,\n * 100 s at 30 fps → `sam-3.1-video:120s`, 4 min at 30 fps on SAM 3 → `sam-3-video:240s`.\n *\n * Wire contract only — no I/O.\n */\n\n/** Segmentation models a Video Mask run can use. SAM 3.1 (the default)\n * tracks several objects in one pass and runs faster; SAM 3 costs half. */\nexport const VIDEO_MASK_PROVIDERS = [\"sam-3.1\", \"sam-3\"] as const\nexport type VideoMaskProvider = (typeof VIDEO_MASK_PROVIDERS)[number]\nexport const DEFAULT_VIDEO_MASK_PROVIDER: VideoMaskProvider = \"sam-3.1\"\n\n/**\n * `zone`: keep only the subjects whose bounding-box CENTRE lies inside an\n * inner rectangle, given as margins in % of the frame (each\n * `VIDEO_MASK_LIMITS.ZONE_MARGIN_PCT_MIN`–`ZONE_MARGIN_PCT_MAX`). All zero, or\n * no zone, = off.\n */\nexport interface VideoMaskZone {\n readonly leftPct: number\n readonly rightPct: number\n readonly topPct: number\n readonly bottomPct: number\n}\n\n/** A new Video Mask node's settings — spread into its node definition. */\nexport const VIDEO_MASK_DEFAULTS = {\n threshold: 0.5,\n provider: \"sam-3.1\" as VideoMaskProvider,\n /** Off: the mask is the model's, frame for frame (see `HOLD_EMPTY_BELOW_FRACTION`). */\n holdLastMask: false,\n /** 0 = off: every region the model finds is kept (see `MIN_SUBJECT_HEIGHT_PCT_*`). */\n minSubjectHeightPct: 0,\n /** 0 = off: no ceiling on a region's height (see `MAX_SUBJECT_HEIGHT_PCT_*`). */\n maxSubjectHeightPct: 0,\n /** Off: subjects anywhere in the frame are kept (see `ZONE_MARGIN_PCT_*`). */\n zone: null as VideoMaskZone | null,\n /**\n * Off: one pass over the whole clip. On: the clip's scene cuts are found\n * first and each shot is segmented on its own — the model starts afresh\n * after every cut (finding the new shot's subjects), and `holdLastMask`\n * never carries a mask across a cut. A clip with no cut (a flash is\n * usually not one) is one shot: the same mask, fitted to the clip's exact\n * frame count.\n */\n perShot: false,\n /**\n * 0 = off: a new detection only where a request starts anyway (the clip's\n * start, every 1,800 frames, and every cut with `perShot`). Above 0: the\n * model is also sent a new request every this many seconds of footage, so a\n * subject that first appears mid-shot is found within that time (see\n * `REDETECT_EVERY_SEC_*`). These boundaries are not cuts: `holdLastMask`\n * keeps holding across them.\n */\n redetectEverySec: 0,\n} as const\n\nexport const VIDEO_MASK_LIMITS = {\n /** The longest input clip a run accepts, in seconds of PRICED length (see `videoMaskBilledSeconds`). */\n MAX_BILLED_SEC: 300,\n /** Frame rate the price rows assume. A faster clip is priced proportionally longer. */\n FPS_BASIS: 30,\n /** Subject description length cap. */\n PROMPT_MAX_LENGTH: 500,\n /** Detection confidence bounds (the model's own range, narrowed to useful values). */\n THRESHOLD_MIN: 0.05,\n THRESHOLD_MAX: 0.95,\n THRESHOLD_STEP: 0.05,\n /** Default detection confidence. Lower finds more (and less precise) regions. */\n THRESHOLD_DEFAULT: VIDEO_MASK_DEFAULTS.threshold,\n /**\n * `holdLastMask`: a frame whose mask covers less than this fraction of the\n * picture (0.002 % — about 41 px at 1080p: a stray speck, never a subject) counts as empty — the subject lost (hidden behind a\n * hand, turned away) — and shows the most recent non-empty frame's mask\n * instead. Frames before the first detection stay as they are.\n */\n HOLD_EMPTY_BELOW_FRACTION: 0.00002,\n /**\n * `holdLastMask`: the longest a mask is held, in seconds of frames (at the\n * clip's rate). The hold is for a subject hidden for a moment; a run of\n * empty frames longer than this shows the held mask for its first second\n * and then nothing, until the model finds the subject again — a mask held\n * on for longer sits where the subject no longer is.\n */\n HOLD_MAX_SEC: 1,\n /**\n * `minSubjectHeightPct`: drop every connected white region (8-connected)\n * whose bounding box is shorter than this % of the frame height — extras'\n * small faces behind the main subject. 0 = off. Applied before\n * `holdLastMask`, so a frame left with only small regions counts as empty\n * and is held from the last frame with a big subject.\n */\n MIN_SUBJECT_HEIGHT_PCT_MIN: 0,\n MIN_SUBJECT_HEIGHT_PCT_MAX: 100,\n /**\n * `maxSubjectHeightPct`, the mirror: drop every region whose bounding box is\n * TALLER than this % of the frame height (keep only the small subjects — a\n * paste-back mask of the background faces). 0 = off. With both set, a\n * region is kept when min ≤ height ≤ max (min > max is refused). Same pass,\n * same order (before `holdLastMask`).\n */\n MAX_SUBJECT_HEIGHT_PCT_MIN: 0,\n MAX_SUBJECT_HEIGHT_PCT_MAX: 100,\n /**\n * `zone` margins (left / right / top / bottom, % of the frame width or\n * height): drop every connected region whose bounding-box centre lies\n * outside `[w·left/100, w·(1−right/100)] × [h·top/100, h·(1−bottom/100)]`\n * — the faces at the edges of the picture. At most 49 % a side, so the\n * inner rectangle is never empty. Applied after the size cut and before\n * `holdLastMask`, so a frame left with nothing inside counts as empty.\n */\n ZONE_MARGIN_PCT_MIN: 0,\n ZONE_MARGIN_PCT_MAX: 49,\n /**\n * `redetectEverySec`: 0 (off) or `REDETECT_EVERY_SEC_MIN`–`MAX` seconds. The\n * model picks up its subjects near the start of each request; a face that\n * turns to the camera, or a person who walks in, partway through a request is\n * never masked. On, the clip (each shot, with `perShot`) is cut into requests\n * of at most this many seconds of frames — counted from the shot's start, a\n * last piece shorter than `VIDEO_MASK_MIN_SHOT_FRAMES` joining the one before\n * — so the subjects are detected again at every such boundary. Each request\n * adds wall time (they run three at a time); the price follows the clip's\n * length and does not change.\n */\n REDETECT_EVERY_SEC_MIN: 1,\n REDETECT_EVERY_SEC_MAX: 10,\n /** The panel's step (the API takes any value in range). */\n REDETECT_EVERY_SEC_STEP: 1,\n} as const\n\n/**\n * The version of what a Video Mask run's mask looks like for a given clip and\n * settings: every finished `video-mask` job reports it as `output_data.recipe`.\n * A mask stored ahead of time and reused (a trend's approved face mask) is\n * held to it, and reads as out of date once it changes.\n *\n * BUMP IT (to the date of the change) whenever the algorithm changes the mask\n * a run produces from the same clip and settings: the cut rule (`perShot`),\n * the hold (`holdLastMask`, `HOLD_*`), the size and zone filters, the\n * rendering. Never for a change that leaves every mask the same (pricing,\n * limits on what is accepted, messages). `\"2026-10-25\"`: the lone-spike cut\n * rule and the 1 s hold cap.\n */\nexport const VIDEO_MASK_RECIPE = \"2026-10-25\"\n\nconst VIDEO_MASK_BUCKETS_SEC = [5, 10, 15, 30, 60, 90, 120, 180, 240, 300] as const\n\n/** Every price row a provider can be charged from, smallest first. */\nexport function videoMaskCreditIds(provider: VideoMaskProvider = DEFAULT_VIDEO_MASK_PROVIDER): string[] {\n return VIDEO_MASK_BUCKETS_SEC.map((sec) => `${provider}-video:${sec}s`)\n}\n\n/**\n * The length a clip is priced at: its duration at the 30 fps basis. A clip\n * at or under 30 fps is priced at its own length; a 60 fps clip at twice it.\n * An unknown frame rate counts as the basis.\n */\nexport function videoMaskBilledSeconds(durationSec: number, fps?: number | null): number {\n const rate = typeof fps === \"number\" && Number.isFinite(fps) && fps > 0 ? fps : VIDEO_MASK_LIMITS.FPS_BASIS\n return durationSec * Math.max(1, rate / VIDEO_MASK_LIMITS.FPS_BASIS)\n}\n\n/**\n * The price row for a clip priced at `billedSec` seconds. An unknown or\n * non-positive length prices the LONGEST row (a clip the route could not\n * measure is refused, so this is only the pre-run quote for a clip whose\n * length is not known yet); anything past the cap prices the last row.\n */\nexport function videoMaskCreditId(\n billedSec: number | null | undefined,\n provider: VideoMaskProvider = DEFAULT_VIDEO_MASK_PROVIDER,\n): string {\n const ids = videoMaskCreditIds(provider)\n if (typeof billedSec !== \"number\" || !Number.isFinite(billedSec) || billedSec <= 0) return ids[ids.length - 1]!\n const i = VIDEO_MASK_BUCKETS_SEC.findIndex((b) => billedSec <= b)\n return ids[i === -1 ? ids.length - 1 : i]!\n}\n\n/** Narrow an arbitrary value to a known provider, falling back to the default. */\nexport function resolveVideoMaskProvider(value: unknown): VideoMaskProvider {\n return (VIDEO_MASK_PROVIDERS as readonly string[]).includes(value as string)\n ? (value as VideoMaskProvider)\n : DEFAULT_VIDEO_MASK_PROVIDER\n}\n\n/**\n * A zone as the region filter reads it: each margin a finite number clamped\n * to `ZONE_MARGIN_PCT_MIN`–`ZONE_MARGIN_PCT_MAX` (anything else is 0), and\n * null when there is no zone or every margin is 0 (off). The one reading\n * shared by the worker, a workflow run's payload and the node's own run.\n */\nexport function resolveVideoMaskZone(value: unknown): VideoMaskZone | null {\n if (!value || typeof value !== \"object\") return null\n const v = value as Record<string, unknown>\n const margin = (x: unknown) =>\n typeof x === \"number\" && Number.isFinite(x)\n ? Math.min(VIDEO_MASK_LIMITS.ZONE_MARGIN_PCT_MAX, Math.max(VIDEO_MASK_LIMITS.ZONE_MARGIN_PCT_MIN, x))\n : 0\n const zone = { leftPct: margin(v.leftPct), rightPct: margin(v.rightPct), topPct: margin(v.topPct), bottomPct: margin(v.bottomPct) }\n return zone.leftPct > 0 || zone.rightPct > 0 || zone.topPct > 0 || zone.bottomPct > 0 ? zone : null\n}\n\n/**\n * `redetectEverySec` as a run reads it: a finite number above 0 clamped to\n * `REDETECT_EVERY_SEC_MIN`–`MAX` (a value between 0 and the minimum snaps up\n * to it — it asked for re-detection); anything else (absent, 0, negative,\n * not a number) is 0 = off. The one reading shared by the worker, a workflow\n * run's payload, the node's own run and its panel (the route refuses a value\n * out of range instead).\n */\nexport function resolveVideoMaskRedetectSec(value: unknown): number {\n if (typeof value !== \"number\" || !Number.isFinite(value) || value <= 0) return 0\n return Math.min(VIDEO_MASK_LIMITS.REDETECT_EVERY_SEC_MAX, Math.max(VIDEO_MASK_LIMITS.REDETECT_EVERY_SEC_MIN, value))\n}\n\n/** `POST /v1/video-mask` request body. */\nexport interface VideoMaskRequest {\n /** The clip to segment. */\n readonly videoUrl: string\n /** What to track: a short noun phrase; separate several with commas. */\n readonly prompt: string\n /** Detection confidence, `VIDEO_MASK_LIMITS.THRESHOLD_MIN`–`THRESHOLD_MAX` (default 0.5). */\n readonly threshold?: number\n readonly provider?: VideoMaskProvider\n /** Hold the last mask where the subject is lost (default false): an empty frame\n * after the first detection repeats the most recent non-empty one. */\n readonly holdLastMask?: boolean\n /** Ignore subjects smaller than this % of the frame height, 0–100 (default 0 = off):\n * connected regions whose bounding box is shorter are dropped from every frame. */\n readonly minSubjectHeightPct?: number\n /** Ignore subjects larger than this % of the frame height, 0–100 (default 0 = off):\n * connected regions whose bounding box is taller are dropped from every frame. */\n readonly maxSubjectHeightPct?: number\n /** Keep only the subjects whose bounding-box centre is inside these margins, each\n * 0–49 % of the frame (a margin left out is 0). null / omitted / all 0 = off. */\n readonly zone?: Partial<VideoMaskZone> | null\n /** Segment each shot on its own (default false): the clip's scene cuts are found\n * first and the subjects are detected again in every shot; `holdLastMask` never\n * carries a mask across a cut. The output then carries `shots`. */\n readonly perShot?: boolean\n /** Detect the subjects again every this many seconds (0 = off, the default, or\n * `VIDEO_MASK_LIMITS.REDETECT_EVERY_SEC_MIN`–`MAX`): the clip — each shot, with\n * `perShot` — is sent to the model in pieces of at most that length, so a subject\n * that first appears mid-shot is masked from the next boundary on. Not a cut:\n * `holdLastMask` holds across these boundaries. Slower (more requests); same price. */\n readonly redetectEverySec?: number\n}\n","/**\n * Video Face Mesh (`POST /v1/video-face-mesh`, job type `video-face-mesh`):\n * thin face lines — a blue mesh, a blue lip outline, green eye outlines —\n * drawn on the faces of a clip, frame for frame. An internal step of Nodaro\n * Motion's face masking: the lines go on the masked (or depth) clip so the\n * video model still sees where the mouth and the eyes are.\n *\n * Priced by the clip's length at the 30 fps basis Video Mask uses\n * (`videoMaskBilledSeconds`), one row per length bucket.\n */\nimport { VIDEO_MASK_LIMITS, type VideoMaskZone } from \"./video-mask.js\"\n\n/** The route, as the Cast Swap engine calls it. */\nexport const VIDEO_FACE_MESH_PATH = \"/v1/video-face-mesh\"\n\nexport const VIDEO_FACE_MESH_LIMITS = {\n /** The longest clip a run accepts, in seconds of PRICED length (the 30 fps basis): Video Mask's own cap. */\n MAX_BILLED_SEC: VIDEO_MASK_LIMITS.MAX_BILLED_SEC,\n /** `minFaceHeightPct` / `maxFaceHeightPct` bounds (0 = off). */\n FACE_HEIGHT_PCT_MIN: 0,\n FACE_HEIGHT_PCT_MAX: 100,\n /** `zone` margin bounds, as Video Mask's. */\n ZONE_MARGIN_PCT_MIN: VIDEO_MASK_LIMITS.ZONE_MARGIN_PCT_MIN,\n ZONE_MARGIN_PCT_MAX: VIDEO_MASK_LIMITS.ZONE_MARGIN_PCT_MAX,\n} as const\n\n/**\n * The version of what a face mesh run draws for a given clip and settings:\n * every finished `video-face-mesh` job reports it as `output_data.recipe`,\n * for the caller to record beside a clip it stores with the lines on it (a\n * trend's approved face mask). Nothing on the platform compares it yet: a\n * stored mask is held to Video Mask's recipe and the engine's own.\n *\n * BUMP IT (to the date of the change) whenever the drawing changes for the\n * same input: the model, the crop, the smoothing, the filters, the colours or\n * the widths. Never for pricing, limits or messages.\n */\nexport const VIDEO_FACE_MESH_RECIPE = \"2026-10-31\"\n\nconst VIDEO_FACE_MESH_BUCKETS_SEC = [5, 10, 15, 30, 60, 120, 300] as const\n\n/** Every price row, smallest first (`video-face-mesh:<n>s`). */\nexport function videoFaceMeshCreditIds(): string[] {\n return VIDEO_FACE_MESH_BUCKETS_SEC.map((sec) => `video-face-mesh:${sec}s`)\n}\n\n/**\n * The price row for a clip priced at `billedSec` seconds: the smallest bucket\n * that holds it. An unknown or non-positive length, or one past the cap,\n * prices the LONGEST row (the route measures every clip and refuses one past\n * the cap, so this is only ever a ceiling).\n */\nexport function videoFaceMeshCreditId(billedSec: number | null | undefined): string {\n const ids = videoFaceMeshCreditIds()\n if (typeof billedSec !== \"number\" || !Number.isFinite(billedSec) || billedSec <= 0) return ids[ids.length - 1]!\n const i = VIDEO_FACE_MESH_BUCKETS_SEC.findIndex((b) => billedSec <= b)\n return ids[i === -1 ? ids.length - 1 : i]!\n}\n\n/** `POST /v1/video-face-mesh` request body. */\nexport interface VideoFaceMeshRequest {\n /** The clip the faces are FOUND in (the original). */\n readonly videoUrl: string\n /** The clip the lines are DRAWN on (default `videoUrl`): the masked or depth clip. Same frame count. */\n readonly drawOnUrl?: string\n /** A mask video (white = covered, same frame count): only faces whose box centre lies inside it are drawn. */\n readonly maskUrl?: string\n /** Draw only faces at least this % of the frame's height (default 0 = off). */\n readonly minFaceHeightPct?: number\n /** Draw only faces at most this % of the frame's height (0 = no cap). */\n readonly maxFaceHeightPct?: number\n /** Margins (% of the frame) where no face is drawn. */\n readonly zone?: Partial<VideoMaskZone> | null\n}\n\n/** A finished `video-face-mesh` job's `output_data`. */\nexport interface VideoFaceMeshOutput {\n /** The drawn clip: `drawOnUrl`'s frame count, size and frame rate, its audio copied untouched. */\n readonly videoUrl: string\n readonly width: number\n readonly height: number\n readonly frames: number\n /** Frames with at least one face drawn. */\n readonly framesWithFaces: number\n /** Faces drawn, summed over the frames (0 = nothing drawn; the clip comes back as it was sent). */\n readonly facesDrawn: number\n readonly recipe: string\n}\n","/**\n * Generate Mask — text-prompted IMAGE segmentation (Grounded SAM). The wire\n * contract of `POST /v1/generate-mask`, the `generate_mask` MCP verb, the SDK's\n * `nodes.run(\"generate-mask\", …)` and `nodaro media generate-mask`, defined ONCE:\n * every bound the route schema and the SDK/CLI read.\n *\n * The finished job's output is `{ maskUrl, imageUrl }`: `maskUrl` is the\n * black-and-white mask PNG (white = the subject), `imageUrl` is the SOURCE\n * image passed through unchanged, so an inpainting step can take the pair.\n *\n * Wire contract only — no I/O.\n */\n\nexport const GENERATE_MASK_LIMITS = {\n /** Subject description length cap. */\n PROMPT_MAX_LENGTH: 500,\n /** Segmentation confidence bounds. */\n THRESHOLD_MIN: 0,\n THRESHOLD_MAX: 1,\n /** Default segmentation confidence. Lower selects more (and less precise) regions. */\n THRESHOLD_DEFAULT: 0.3,\n} as const\n\n/** `POST /v1/generate-mask` request body. */\nexport interface GenerateMaskRequest {\n /** The image to segment. */\n readonly imageUrl: string\n /** What to select, in plain words (e.g. \"the person\", \"sky and clouds\"). 1–500 characters. */\n readonly prompt: string\n /** Segmentation confidence, `GENERATE_MASK_LIMITS.THRESHOLD_MIN`–`THRESHOLD_MAX` (default 0.3). */\n readonly threshold?: number\n}\n\n/** A completed Generate Mask job's `output_data`. */\nexport interface GenerateMaskOutput {\n /** The mask: a black-and-white PNG, white = the subject. */\n readonly maskUrl: string\n /** The source image, passed through unchanged. */\n readonly imageUrl: string\n}\n","/**\n * Mask Composite — place a foreground video over a background video through a\n * mask video (white = keep the foreground, black = show the background). The\n * wire contract of the `mask-composite` node, `POST /v1/mask-composite`, the\n * `mask_composite` MCP verb, `client.media.maskComposite` and\n * `nodaro media mask-composite`, defined ONCE. Pair it with Video Mask, whose\n * output is exactly such a mask.\n *\n * The render follows the FOREGROUND: its size, frame rate and length. The\n * background is fitted to that frame (`backgroundFit`) and loops when shorter;\n * the mask is stretched to the frame and holds its last frame when shorter.\n *\n * `fill` picks what fills the masked area. `\"video\"` (the default) is the\n * foreground, as above. `\"pixelate\"` and `\"blur\"` fill it with the BACKGROUND\n * itself, pixelated or blurred: there is no foreground then (a sent\n * `foregroundUrl` is ignored), so the render follows the BACKGROUND (its size,\n * frame rate and length; `backgroundFit` has nothing to fit), and the run is\n * priced on the background's length. With no foreground the result always\n * carries the background's sound — `audioSource` is ignored there\n * ({@link maskCompositeEffectiveAudioSource}); the canvas hides the control.\n *\n * Priced per started 5 seconds of the result (the foreground's length), like\n * Trim / Loop / Combine Videos: the node's own `model_pricing` row is ONE unit\n * (`maskCompositeUnits` counts them). Worked examples (repeated in\n * docs/nodes/processing-video/mask-composite.md, at the 10-credit row):\n * 3 s → 1 unit (10), 10 s → 2 units (20), 61 s → 13 units (130), 5 min → 60 units (600).\n *\n * Wire contract only — no I/O.\n */\n\n/** How the background is fitted to the foreground's frame. */\nexport const MASK_COMPOSITE_BACKGROUND_FITS = [\"cover\", \"contain\", \"stretch\"] as const\nexport type MaskCompositeBackgroundFit = (typeof MASK_COMPOSITE_BACKGROUND_FITS)[number]\n\n/** What fills the masked area: the foreground video, or the background itself pixelated or blurred. */\nexport const MASK_COMPOSITE_FILLS = [\"video\", \"pixelate\", \"blur\"] as const\nexport type MaskCompositeFill = (typeof MASK_COMPOSITE_FILLS)[number]\n\n/** Which sound the result carries. `mix` blends both tracks at equal level. */\nexport const MASK_COMPOSITE_AUDIO_SOURCES = [\"foreground\", \"background\", \"mix\", \"none\"] as const\nexport type MaskCompositeAudioSource = (typeof MASK_COMPOSITE_AUDIO_SOURCES)[number]\n\nexport const MASK_COMPOSITE_BOUNDS = {\n /** Edge softening, pixels of blur radius on the mask (0 = hard edge). */\n FEATHER_MIN: 0,\n FEATHER_MAX: 20,\n /** Grow (+) or shrink (−) the white region, pixels. */\n GROW_MIN: -10,\n GROW_MAX: 10,\n /** How strongly the foreground covers the background inside the mask\n * (1 = fully, today's output; 0 = not at all). */\n OPACITY_MIN: 0,\n OPACITY_MAX: 1,\n /** Pixelate: the block size as a % of the frame's WIDTH (relative, so a\n * setting looks the same at any resolution); the worker makes the blocks\n * max(2, round(width × pct / 100)) px. 1.25 % = 16 px on a 1280-wide frame. */\n PIXEL_SIZE_PCT_MIN: 0.2,\n PIXEL_SIZE_PCT_MAX: 10,\n /** Blur: the gaussian's sigma as a % of the frame's WIDTH (2 % ≈ sigma 25 px on a 1280-wide frame). */\n BLUR_STRENGTH_PCT_MIN: 0.1,\n BLUR_STRENGTH_PCT_MAX: 5,\n /** The longest leading video (the foreground; the background when `fill` is not video) a run accepts, seconds. */\n MAX_DURATION_SEC: 300,\n} as const\n\n/** Seconds of result one pricing unit covers. */\nexport const MASK_COMPOSITE_UNIT_SEC = 5\n\n/**\n * Pricing units for a result `durationSec` long: one per started 5 seconds,\n * at least one. An unknown length counts the longest result a run accepts\n * (an upper bound — the pre-run quote for a clip whose length is not known\n * yet; every run measures its foreground).\n */\nexport function maskCompositeUnits(durationSec: number | null | undefined): number {\n const sec =\n typeof durationSec === \"number\" && Number.isFinite(durationSec) && durationSec > 0\n ? Math.min(durationSec, MASK_COMPOSITE_BOUNDS.MAX_DURATION_SEC)\n : MASK_COMPOSITE_BOUNDS.MAX_DURATION_SEC\n // The epsilon absorbs float noise (a 10.0000001 s probe is 2 units, not 3).\n return Math.max(1, Math.ceil(sec / MASK_COMPOSITE_UNIT_SEC - 1e-6))\n}\n\nexport const MASK_COMPOSITE_DEFAULTS = {\n invertMask: false,\n feather: 2,\n grow: 0,\n opacity: 1,\n fill: \"video\" as MaskCompositeFill,\n pixelSizePct: 1.25,\n blurStrengthPct: 2,\n backgroundFit: \"cover\" as MaskCompositeBackgroundFit,\n audioSource: \"foreground\" as MaskCompositeAudioSource,\n} as const\n\nexport interface MaskCompositeSettings {\n readonly invertMask: boolean\n readonly feather: number\n readonly grow: number\n /** Inside the mask: opacity × foreground + (1 − opacity) × background. */\n readonly opacity: number\n /** What fills the masked area (`video` = the foreground). */\n readonly fill: MaskCompositeFill\n /** Pixelate block size, % of the frame width (used when `fill` is `pixelate`). */\n readonly pixelSizePct: number\n /** Blur strength: the gaussian's sigma as a % of the frame width (used when `fill` is `blur`). */\n readonly blurStrengthPct: number\n readonly backgroundFit: MaskCompositeBackgroundFit\n readonly audioSource: MaskCompositeAudioSource\n}\n\nconst clampInt = (v: unknown, min: number, max: number, fallback: number): number =>\n typeof v === \"number\" && Number.isFinite(v) ? Math.min(max, Math.max(min, Math.round(v))) : fallback\n\nconst clampNumber = (v: unknown, min: number, max: number, fallback: number): number =>\n typeof v === \"number\" && Number.isFinite(v) ? Math.min(max, Math.max(min, v)) : fallback\n\n/**\n * Node data (or any loose object) → settings every engine renders with.\n * Unknown enum values fall back to the default and numbers are clamped, so a\n * node written straight into workflow JSON renders the same as one set in the\n * panel. The ONE normaliser both workflow engines and the worker call.\n */\nexport function resolveMaskCompositeSettings(data: Readonly<Record<string, unknown>>): MaskCompositeSettings {\n const d = MASK_COMPOSITE_DEFAULTS\n const b = MASK_COMPOSITE_BOUNDS\n return {\n invertMask: typeof data.invertMask === \"boolean\" ? data.invertMask : d.invertMask,\n feather: clampInt(data.feather, b.FEATHER_MIN, b.FEATHER_MAX, d.feather),\n grow: clampInt(data.grow, b.GROW_MIN, b.GROW_MAX, d.grow),\n opacity: clampNumber(data.opacity, b.OPACITY_MIN, b.OPACITY_MAX, d.opacity),\n fill: maskCompositeFillOf(data),\n pixelSizePct: clampNumber(data.pixelSizePct, b.PIXEL_SIZE_PCT_MIN, b.PIXEL_SIZE_PCT_MAX, d.pixelSizePct),\n blurStrengthPct: clampNumber(data.blurStrengthPct, b.BLUR_STRENGTH_PCT_MIN, b.BLUR_STRENGTH_PCT_MAX, d.blurStrengthPct),\n backgroundFit: (MASK_COMPOSITE_BACKGROUND_FITS as readonly string[]).includes(data.backgroundFit as string)\n ? (data.backgroundFit as MaskCompositeBackgroundFit)\n : d.backgroundFit,\n audioSource: (MASK_COMPOSITE_AUDIO_SOURCES as readonly string[]).includes(data.audioSource as string)\n ? (data.audioSource as MaskCompositeAudioSource)\n : d.audioSource,\n }\n}\n\n/** The fill a node, payload or request body asks for: an unknown value is `video` (the default). */\nexport function maskCompositeFillOf(data: Readonly<Record<string, unknown>> | null | undefined): MaskCompositeFill {\n const f = data?.fill\n return (MASK_COMPOSITE_FILLS as readonly string[]).includes(f as string) ? (f as MaskCompositeFill) : MASK_COMPOSITE_DEFAULTS.fill\n}\n\n/** Does this fill take a foreground video? Only `video` does; pixelate and blur fill from the background. */\nexport function maskCompositeUsesForeground(fill: MaskCompositeFill): boolean {\n return fill === \"video\"\n}\n\n/**\n * The input whose size, rate and length the result has (and so the one a run\n * is measured and priced on): the canvas handle — `video` (the foreground) for\n * the video fill, `background-video` for pixelate and blur. The one rule the\n * route, the workflow run, the run estimates and the length walks read.\n */\nexport function maskCompositeLeadHandle(data: Readonly<Record<string, unknown>> | null | undefined): \"video\" | \"background-video\" {\n return maskCompositeUsesForeground(maskCompositeFillOf(data)) ? \"video\" : \"background-video\"\n}\n\n/**\n * The sound a render actually carries. With no foreground (pixelate / blur) it\n * is ALWAYS the background's — the only track there is — whatever\n * `audioSource` says (the canvas hides that control for these fills, so a\n * stored `none` from the Video fill can never silently mute the result).\n */\nexport function maskCompositeEffectiveAudioSource(s: Pick<MaskCompositeSettings, \"fill\" | \"audioSource\">): MaskCompositeAudioSource {\n if (maskCompositeUsesForeground(s.fill)) return s.audioSource\n return \"background\"\n}\n\n/** `POST /v1/mask-composite` request body. */\nexport interface MaskCompositeRequest extends Partial<MaskCompositeSettings> {\n /** The video whose white-masked region is kept (its size, rate and length lead).\n * Required when `fill` is `video` (the default); not used by `pixelate` / `blur`. */\n readonly foregroundUrl?: string\n /** The video shown where the mask is black. */\n readonly backgroundUrl: string\n /** The mask video — white = foreground (Video Mask's output). */\n readonly maskUrl: string\n}\n"]}