@nodaro/shared 3.61.0 → 3.63.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 (313) hide show
  1. package/dist/{chunk-4KYLNTR7.cjs → chunk-2PU3AGGS.cjs} +27 -4
  2. package/dist/chunk-2PU3AGGS.cjs.map +1 -0
  3. package/dist/{chunk-43TGSZRJ.js → chunk-2QKF7M2Z.js} +3 -3
  4. package/dist/{chunk-43TGSZRJ.js.map → chunk-2QKF7M2Z.js.map} +1 -1
  5. package/dist/{chunk-B6BG3LV2.js → chunk-34QLPTSA.js} +3 -3
  6. package/dist/{chunk-B6BG3LV2.js.map → chunk-34QLPTSA.js.map} +1 -1
  7. package/dist/chunk-3K24DWOH.js +453 -0
  8. package/dist/chunk-3K24DWOH.js.map +1 -0
  9. package/dist/{chunk-IRQ3SPX7.js → chunk-4DVWXEB6.js} +23 -4
  10. package/dist/chunk-4DVWXEB6.js.map +1 -0
  11. package/dist/{chunk-ZES6EZC4.js → chunk-4MMZD63H.js} +3 -3
  12. package/dist/{chunk-ZES6EZC4.js.map → chunk-4MMZD63H.js.map} +1 -1
  13. package/dist/{chunk-MQZRQ5LM.cjs → chunk-63H4C56Q.cjs} +8 -8
  14. package/dist/{chunk-MQZRQ5LM.cjs.map → chunk-63H4C56Q.cjs.map} +1 -1
  15. package/dist/{chunk-IVXSNW2B.cjs → chunk-6BZC2ZHC.cjs} +18 -332
  16. package/dist/chunk-6BZC2ZHC.cjs.map +1 -0
  17. package/dist/{chunk-M3SXUUWC.cjs → chunk-6FQBKI2A.cjs} +4 -11
  18. package/dist/chunk-6FQBKI2A.cjs.map +1 -0
  19. package/dist/{chunk-673E4KYC.js → chunk-6M563QE6.js} +134 -8
  20. package/dist/chunk-6M563QE6.js.map +1 -0
  21. package/dist/chunk-6TGB7ECA.cjs +48 -0
  22. package/dist/chunk-6TGB7ECA.cjs.map +1 -0
  23. package/dist/{chunk-XUJC6GHE.cjs → chunk-6XUG4L7X.cjs} +6 -6
  24. package/dist/{chunk-XUJC6GHE.cjs.map → chunk-6XUG4L7X.cjs.map} +1 -1
  25. package/dist/{chunk-XZKFZMRT.cjs → chunk-77WU3V3J.cjs} +6 -6
  26. package/dist/{chunk-XZKFZMRT.cjs.map → chunk-77WU3V3J.cjs.map} +1 -1
  27. package/dist/{chunk-ZFJN23V4.cjs → chunk-A2PX5IRC.cjs} +4 -4
  28. package/dist/{chunk-ZFJN23V4.cjs.map → chunk-A2PX5IRC.cjs.map} +1 -1
  29. package/dist/{chunk-ZDBPQBAA.js → chunk-AE3AAJ4O.js} +3 -3
  30. package/dist/{chunk-ZDBPQBAA.js.map → chunk-AE3AAJ4O.js.map} +1 -1
  31. package/dist/chunk-ALRXY4QH.cjs +13 -0
  32. package/dist/chunk-ALRXY4QH.cjs.map +1 -0
  33. package/dist/{chunk-UARGJ5IZ.js → chunk-BMJVKYVB.js} +56 -12
  34. package/dist/chunk-BMJVKYVB.js.map +1 -0
  35. package/dist/{chunk-6XVHYD5R.js → chunk-CLAKSLXF.js} +4 -9
  36. package/dist/chunk-CLAKSLXF.js.map +1 -0
  37. package/dist/chunk-CTANEPMY.js +61 -0
  38. package/dist/chunk-CTANEPMY.js.map +1 -0
  39. package/dist/chunk-CZ5IQB3L.js +42 -0
  40. package/dist/chunk-CZ5IQB3L.js.map +1 -0
  41. package/dist/{chunk-WGKAOUEQ.cjs → chunk-D34K455O.cjs} +3 -2
  42. package/dist/chunk-D34K455O.cjs.map +1 -0
  43. package/dist/chunk-EPXGG27L.js +331 -0
  44. package/dist/chunk-EPXGG27L.js.map +1 -0
  45. package/dist/{chunk-3M4BNKFJ.cjs → chunk-F6WGGYQW.cjs} +167 -3
  46. package/dist/chunk-F6WGGYQW.cjs.map +1 -0
  47. package/dist/{chunk-7FCTCWHD.js → chunk-FXGNRYQQ.js} +3 -3
  48. package/dist/{chunk-7FCTCWHD.js.map → chunk-FXGNRYQQ.js.map} +1 -1
  49. package/dist/{chunk-ZNM2LW3D.cjs → chunk-GMBDLNLD.cjs} +105 -56
  50. package/dist/chunk-GMBDLNLD.cjs.map +1 -0
  51. package/dist/{chunk-NJVOJXBS.cjs → chunk-GSKLPI3J.cjs} +104 -49
  52. package/dist/chunk-GSKLPI3J.cjs.map +1 -0
  53. package/dist/{chunk-EWS2VFO4.js → chunk-HBXF6RUU.js} +4 -4
  54. package/dist/{chunk-EWS2VFO4.js.map → chunk-HBXF6RUU.js.map} +1 -1
  55. package/dist/{chunk-MOMFX32D.js → chunk-HWQ2SYNA.js} +194 -325
  56. package/dist/chunk-HWQ2SYNA.js.map +1 -0
  57. package/dist/{chunk-SCMTN57Y.js → chunk-IY3Y462W.js} +3 -3
  58. package/dist/{chunk-SCMTN57Y.js.map → chunk-IY3Y462W.js.map} +1 -1
  59. package/dist/{chunk-ZZGQRRN7.js → chunk-KCZHQH2O.js} +6 -306
  60. package/dist/chunk-KCZHQH2O.js.map +1 -0
  61. package/dist/{chunk-XROE3CAS.cjs → chunk-KHH54GRP.cjs} +120 -79
  62. package/dist/chunk-KHH54GRP.cjs.map +1 -0
  63. package/dist/{chunk-FVVD6XY2.js → chunk-KL6GAYTT.js} +13 -4
  64. package/dist/chunk-KL6GAYTT.js.map +1 -0
  65. package/dist/{chunk-FVII3KHN.js → chunk-KMGCHV6O.js} +163 -4
  66. package/dist/chunk-KMGCHV6O.js.map +1 -0
  67. package/dist/{chunk-FMXFHJWX.cjs → chunk-L2TVY6XN.cjs} +4 -4
  68. package/dist/{chunk-FMXFHJWX.cjs.map → chunk-L2TVY6XN.cjs.map} +1 -1
  69. package/dist/{chunk-FQXRYPCX.cjs → chunk-LH72PQO2.cjs} +505 -68
  70. package/dist/chunk-LH72PQO2.cjs.map +1 -0
  71. package/dist/chunk-LMAQUR55.cjs +506 -0
  72. package/dist/chunk-LMAQUR55.cjs.map +1 -0
  73. package/dist/{chunk-F5YEMSNK.cjs → chunk-M5OCFGHF.cjs} +571 -30
  74. package/dist/chunk-M5OCFGHF.cjs.map +1 -0
  75. package/dist/{chunk-VOWJCUMR.js → chunk-MD4XHED4.js} +3 -3
  76. package/dist/{chunk-VOWJCUMR.js.map → chunk-MD4XHED4.js.map} +1 -1
  77. package/dist/chunk-N5HH46JF.cjs +68 -0
  78. package/dist/chunk-N5HH46JF.cjs.map +1 -0
  79. package/dist/{chunk-G4XWVWRI.js → chunk-NIAFR5EE.js} +5 -4
  80. package/dist/chunk-NIAFR5EE.js.map +1 -0
  81. package/dist/{chunk-CF4S4N5X.js → chunk-O2QOBA6Q.js} +2 -2
  82. package/dist/{chunk-CF4S4N5X.js.map → chunk-O2QOBA6Q.js.map} +1 -1
  83. package/dist/{chunk-4GGLKRYI.cjs → chunk-O6TBB4IF.cjs} +2 -2
  84. package/dist/{chunk-4GGLKRYI.cjs.map → chunk-O6TBB4IF.cjs.map} +1 -1
  85. package/dist/{chunk-SWVGHAYO.js → chunk-O7RZRUMZ.js} +110 -74
  86. package/dist/chunk-O7RZRUMZ.js.map +1 -0
  87. package/dist/{chunk-LLOIAGFB.js → chunk-OV3JTKBY.js} +449 -51
  88. package/dist/chunk-OV3JTKBY.js.map +1 -0
  89. package/dist/{chunk-A3FHTSLB.js → chunk-PSKZKLDG.js} +550 -31
  90. package/dist/chunk-PSKZKLDG.js.map +1 -0
  91. package/dist/{chunk-VB2ARGQ6.js → chunk-RGNHHIMN.js} +3 -3
  92. package/dist/chunk-RGNHHIMN.js.map +1 -0
  93. package/dist/chunk-SMOO5FAH.js +10 -0
  94. package/dist/chunk-SMOO5FAH.js.map +1 -0
  95. package/dist/{chunk-5XRRENHD.cjs → chunk-TM5JYSJF.cjs} +170 -17
  96. package/dist/chunk-TM5JYSJF.cjs.map +1 -0
  97. package/dist/{chunk-PONP5J5E.cjs → chunk-V24EPI5N.cjs} +13 -3
  98. package/dist/chunk-V24EPI5N.cjs.map +1 -0
  99. package/dist/{chunk-RQ4F3AJH.cjs → chunk-V5EEQR2U.cjs} +21 -21
  100. package/dist/{chunk-RQ4F3AJH.cjs.map → chunk-V5EEQR2U.cjs.map} +1 -1
  101. package/dist/chunk-WZVIBAKN.cjs +351 -0
  102. package/dist/chunk-WZVIBAKN.cjs.map +1 -0
  103. package/dist/{chunk-5M43XMRB.cjs → chunk-X5BAFW3Q.cjs} +8 -8
  104. package/dist/{chunk-5M43XMRB.cjs.map → chunk-X5BAFW3Q.cjs.map} +1 -1
  105. package/dist/{chunk-RUHKBEFF.js → chunk-XBTYGQ6Z.js} +63 -10
  106. package/dist/chunk-XBTYGQ6Z.js.map +1 -0
  107. package/dist/{chunk-JHTT2V4A.cjs → chunk-XGGZWA4A.cjs} +118 -52
  108. package/dist/chunk-XGGZWA4A.cjs.map +1 -0
  109. package/dist/{chunk-5I4T4QR5.cjs → chunk-XGVJGNZW.cjs} +5 -5
  110. package/dist/{chunk-5I4T4QR5.cjs.map → chunk-XGVJGNZW.cjs.map} +1 -1
  111. package/dist/{chunk-7ARKVJTN.cjs → chunk-Y35JQPT6.cjs} +228 -383
  112. package/dist/chunk-Y35JQPT6.cjs.map +1 -0
  113. package/dist/{chunk-AFQFGZN7.cjs → chunk-Y4GCJJPF.cjs} +8 -6
  114. package/dist/chunk-Y4GCJJPF.cjs.map +1 -0
  115. package/dist/{chunk-C77F4ZTL.js → chunk-YUER7TJG.js} +3 -3
  116. package/dist/{chunk-C77F4ZTL.js.map → chunk-YUER7TJG.js.map} +1 -1
  117. package/dist/{chunk-HGI2VKIV.js → chunk-YX6TFX7H.js} +67 -14
  118. package/dist/chunk-YX6TFX7H.js.map +1 -0
  119. package/dist/{chunk-TWF2OSH4.cjs → chunk-ZPE2ZTJ4.cjs} +4 -4
  120. package/dist/{chunk-TWF2OSH4.cjs.map → chunk-ZPE2ZTJ4.cjs.map} +1 -1
  121. package/dist/entries/apps.cjs +44 -44
  122. package/dist/entries/apps.js +9 -9
  123. package/dist/entries/credits.cjs +286 -153
  124. package/dist/entries/credits.d.cts +254 -5
  125. package/dist/entries/credits.d.ts +254 -5
  126. package/dist/entries/credits.js +14 -9
  127. package/dist/entries/entities.cjs +188 -143
  128. package/dist/entries/entities.d.cts +122 -1
  129. package/dist/entries/entities.d.ts +122 -1
  130. package/dist/entries/entities.js +2 -1
  131. package/dist/entries/llm-models.cjs +77 -57
  132. package/dist/entries/llm-models.d.cts +85 -5
  133. package/dist/entries/llm-models.d.ts +85 -5
  134. package/dist/entries/llm-models.js +2 -2
  135. package/dist/entries/media.cjs +92 -87
  136. package/dist/entries/media.d.cts +19 -1
  137. package/dist/entries/media.d.ts +19 -1
  138. package/dist/entries/media.js +3 -2
  139. package/dist/entries/model-catalog.cjs +211 -103
  140. package/dist/entries/model-catalog.d.cts +135 -19
  141. package/dist/entries/model-catalog.d.ts +135 -19
  142. package/dist/entries/model-catalog.js +5 -5
  143. package/dist/entries/models.cjs +504 -295
  144. package/dist/entries/models.d.cts +71 -4
  145. package/dist/entries/models.d.ts +71 -4
  146. package/dist/entries/models.js +7 -6
  147. package/dist/entries/nodes.cjs +249 -233
  148. package/dist/entries/nodes.d.cts +35 -6
  149. package/dist/entries/nodes.d.ts +35 -6
  150. package/dist/entries/nodes.js +10 -10
  151. package/dist/entries/pipeline.cjs +152 -152
  152. package/dist/entries/pipeline.d.cts +3 -2
  153. package/dist/entries/pipeline.d.ts +3 -2
  154. package/dist/entries/pipeline.js +3 -3
  155. package/dist/entries/runtime-config.cjs +29 -29
  156. package/dist/entries/runtime-config.d.cts +10 -7
  157. package/dist/entries/runtime-config.d.ts +10 -7
  158. package/dist/entries/runtime-config.js +1 -1
  159. package/dist/entries/social.cjs +177 -177
  160. package/dist/entries/social.js +2 -2
  161. package/dist/entries/types.d.cts +8 -0
  162. package/dist/entries/types.d.ts +8 -0
  163. package/dist/entries/ugc.cjs +71 -71
  164. package/dist/entries/ugc.js +4 -4
  165. package/dist/entries/video.cjs +316 -208
  166. package/dist/entries/video.d.cts +490 -99
  167. package/dist/entries/video.d.ts +490 -99
  168. package/dist/entries/video.js +8 -4
  169. package/dist/entries/workflow.cjs +102 -102
  170. package/dist/entries/workflow.d.cts +5 -4
  171. package/dist/entries/workflow.d.ts +5 -4
  172. package/dist/entries/workflow.js +2 -2
  173. package/dist/{gpt-image-2-6-BeZdT-pW.d.cts → gpt-image-2-6-jIRQBRag.d.cts} +6 -0
  174. package/dist/{gpt-image-2-6-BeZdT-pW.d.ts → gpt-image-2-6-jIRQBRag.d.ts} +6 -0
  175. package/dist/index.cjs +2727 -2092
  176. package/dist/index.d.cts +11 -11
  177. package/dist/index.d.ts +11 -11
  178. package/dist/index.js +30 -27
  179. package/dist/{model-catalog-BgSvskgY.d.ts → model-catalog-C_Eo35tL.d.cts} +158 -14
  180. package/dist/{model-catalog-BgSvskgY.d.cts → model-catalog-C_Eo35tL.d.ts} +158 -14
  181. package/dist/{model-constants-DHd9jwQ7.d.cts → model-constants-Bg4ccSQb.d.ts} +427 -34
  182. package/dist/{model-constants-DHd9jwQ7.d.ts → model-constants-DWcxOmaY.d.cts} +427 -34
  183. package/package.json +1 -1
  184. package/src/__tests__/credit-identifiers.test.ts +29 -0
  185. package/src/__tests__/extend-providers.test.ts +194 -0
  186. package/src/__tests__/fixtures/mask-composite-quote-parity.json +118 -0
  187. package/src/__tests__/fixtures/root-exports.baseline.json +68 -0
  188. package/src/__tests__/gpt-image-2-6-formats.test.ts +4 -1
  189. package/src/__tests__/grok-video-15-catalog.test.ts +189 -0
  190. package/src/__tests__/gvp-supported-providers.test.ts +32 -4
  191. package/src/__tests__/lip-sync-audio-rate.test.ts +74 -0
  192. package/src/__tests__/lip-sync-levers.test.ts +31 -0
  193. package/src/__tests__/llm-models.test.ts +132 -3
  194. package/src/__tests__/llm-price-key.test.ts +152 -1
  195. package/src/__tests__/minimax-h3-image.test.ts +140 -0
  196. package/src/__tests__/model-makers.test.ts +49 -11
  197. package/src/__tests__/model-tree.test.ts +13 -0
  198. package/src/__tests__/nemotron-transcribe-pricing.test.ts +61 -0
  199. package/src/__tests__/normalize-node-params.test.ts +25 -0
  200. package/src/__tests__/pixverse-v6-max-catalog.test.ts +271 -0
  201. package/src/__tests__/prompt-length-limits.test.ts +4 -0
  202. package/src/__tests__/retired-video-provider.test.ts +15 -5
  203. package/src/__tests__/seedance-25-catalog-modes.test.ts +1 -1
  204. package/src/__tests__/seedance-task-type.test.ts +188 -0
  205. package/src/__tests__/seedream-5-5.test.ts +117 -0
  206. package/src/__tests__/transcribe-capabilities.test.ts +39 -2
  207. package/src/__tests__/transcribe-preflight.test.ts +50 -1
  208. package/src/__tests__/unit-contract-compose.test.ts +27 -1
  209. package/src/__tests__/unit-contracts.test.ts +20 -6
  210. package/src/__tests__/upscale-factors.test.ts +107 -0
  211. package/src/__tests__/video-audio-capability.test.ts +35 -6
  212. package/src/__tests__/video-character-refs.test.ts +20 -2
  213. package/src/__tests__/video-collapse-parity.test.ts +19 -0
  214. package/src/__tests__/video-overlay-geometry.test.ts +68 -0
  215. package/src/__tests__/video-overlay-layer-plan.test.ts +3 -4
  216. package/src/__tests__/video-overlay-layouts.test.ts +529 -0
  217. package/src/__tests__/video-overlay-pricing.test.ts +61 -0
  218. package/src/__tests__/video-overlay-validate.test.ts +128 -0
  219. package/src/__tests__/video-overlay-wired-kind.test.ts +207 -0
  220. package/src/__tests__/video-overlay.test.ts +280 -194
  221. package/src/__tests__/video-ref-limits.test.ts +2 -1
  222. package/src/__tests__/video-reference-only.test.ts +6 -2
  223. package/src/__tests__/video-resolution-billed-as-named.test.ts +30 -0
  224. package/src/__tests__/video-start-frame-only.test.ts +98 -0
  225. package/src/__tests__/video-upscale-params.test.ts +62 -0
  226. package/src/__tests__/wired-character-names.test.ts +220 -0
  227. package/src/catalog-projection.ts +8 -0
  228. package/src/credit-estimators/index.ts +18 -0
  229. package/src/credit-estimators/nemotron-transcribe.ts +87 -0
  230. package/src/credit-estimators/video-overlay.ts +70 -0
  231. package/src/credit-identifiers.ts +183 -16
  232. package/src/entity-image-url.ts +21 -0
  233. package/src/entries/credits.ts +26 -1
  234. package/src/entries/entities.ts +14 -0
  235. package/src/entries/llm-models.ts +6 -0
  236. package/src/entries/model-catalog.ts +44 -1
  237. package/src/entries/models.ts +69 -0
  238. package/src/entries/nodes.ts +4 -0
  239. package/src/entries/video.ts +7 -1
  240. package/src/freecut-protocol.ts +8 -0
  241. package/src/generated/unit-contracts.ts +8 -1
  242. package/src/gpt-image-2-6.ts +6 -0
  243. package/src/input-image-pricing.ts +76 -0
  244. package/src/lip-sync-levers.ts +56 -0
  245. package/src/lip-sync-pricing.ts +91 -1
  246. package/src/llm-models.ts +249 -4
  247. package/src/mask-composite.ts +11 -0
  248. package/src/minimax-h3-image.ts +61 -0
  249. package/src/model-catalog.ts +604 -40
  250. package/src/model-constants.ts +860 -55
  251. package/src/model-tree.ts +2 -1
  252. package/src/nodaro-video-upscale.ts +48 -0
  253. package/src/node-default-mappings.ts +15 -2
  254. package/src/node-execution-state.ts +4 -3
  255. package/src/normalize-node-params.ts +49 -1
  256. package/src/producer-types.ts +23 -1
  257. package/src/runtime-config/contract.ts +10 -7
  258. package/src/seedance-draft.ts +2 -1
  259. package/src/seedance-task-type.ts +37 -0
  260. package/src/seedream-5-5.ts +45 -0
  261. package/src/transcribe-preflight.ts +58 -7
  262. package/src/unit-contract-compose.ts +4 -1
  263. package/src/upscale-factors.ts +111 -0
  264. package/src/video-character-refs.ts +7 -4
  265. package/src/video-duration.ts +9 -0
  266. package/src/video-overlay-geometry.ts +99 -0
  267. package/src/video-overlay-input.ts +25 -0
  268. package/src/video-overlay-layout-ids.ts +48 -0
  269. package/src/video-overlay-layouts.ts +315 -0
  270. package/src/video-overlay-validate.ts +223 -0
  271. package/src/video-overlay-video-layers.ts +304 -0
  272. package/src/video-overlay.ts +165 -297
  273. package/src/video-ui-defaults.ts +11 -7
  274. package/src/video-upscale-params.ts +67 -0
  275. package/src/wired-character-names.ts +202 -0
  276. package/dist/chunk-3M4BNKFJ.cjs.map +0 -1
  277. package/dist/chunk-4KYLNTR7.cjs.map +0 -1
  278. package/dist/chunk-5XRRENHD.cjs.map +0 -1
  279. package/dist/chunk-673E4KYC.js.map +0 -1
  280. package/dist/chunk-6XVHYD5R.js.map +0 -1
  281. package/dist/chunk-7ARKVJTN.cjs.map +0 -1
  282. package/dist/chunk-7WGKP3EU.js +0 -23
  283. package/dist/chunk-7WGKP3EU.js.map +0 -1
  284. package/dist/chunk-A3FHTSLB.js.map +0 -1
  285. package/dist/chunk-AFQFGZN7.cjs.map +0 -1
  286. package/dist/chunk-F5YEMSNK.cjs.map +0 -1
  287. package/dist/chunk-FQXRYPCX.cjs.map +0 -1
  288. package/dist/chunk-FVII3KHN.js.map +0 -1
  289. package/dist/chunk-FVVD6XY2.js.map +0 -1
  290. package/dist/chunk-G4XWVWRI.js.map +0 -1
  291. package/dist/chunk-HGI2VKIV.js.map +0 -1
  292. package/dist/chunk-IRQ3SPX7.js.map +0 -1
  293. package/dist/chunk-IVXSNW2B.cjs.map +0 -1
  294. package/dist/chunk-JHTT2V4A.cjs.map +0 -1
  295. package/dist/chunk-KHZAQGRP.js +0 -17
  296. package/dist/chunk-KHZAQGRP.js.map +0 -1
  297. package/dist/chunk-LLOIAGFB.js.map +0 -1
  298. package/dist/chunk-M3SXUUWC.cjs.map +0 -1
  299. package/dist/chunk-MOMFX32D.js.map +0 -1
  300. package/dist/chunk-NCOGGRRP.cjs +0 -27
  301. package/dist/chunk-NCOGGRRP.cjs.map +0 -1
  302. package/dist/chunk-NJVOJXBS.cjs.map +0 -1
  303. package/dist/chunk-PONP5J5E.cjs.map +0 -1
  304. package/dist/chunk-RUHKBEFF.js.map +0 -1
  305. package/dist/chunk-SWVGHAYO.js.map +0 -1
  306. package/dist/chunk-UARGJ5IZ.js.map +0 -1
  307. package/dist/chunk-VB2ARGQ6.js.map +0 -1
  308. package/dist/chunk-WGKAOUEQ.cjs.map +0 -1
  309. package/dist/chunk-XROE3CAS.cjs.map +0 -1
  310. package/dist/chunk-ZLDFPVVI.cjs +0 -19
  311. package/dist/chunk-ZLDFPVVI.cjs.map +0 -1
  312. package/dist/chunk-ZNM2LW3D.cjs.map +0 -1
  313. package/dist/chunk-ZZGQRRN7.js.map +0 -1
@@ -0,0 +1,223 @@
1
+ /**
2
+ * Video Overlay — the request validator: what a schema cannot express, run at
3
+ * every engine entry. It returns a CODE, never English: `formatVideoOverlayError`
4
+ * renders the route / worker text, the canvas renders the code through its
5
+ * dictionaries. A sibling of `video-overlay.ts`, which it imports from; nothing
6
+ * there imports this file.
7
+ * Wire contract only — no prompt content, no I/O.
8
+ */
9
+ import { OVERLAY_ANCHORS } from "./image-overlay-layers.js"
10
+ import {
11
+ VIDEO_OVERLAY_BOUNDS, VIDEO_OVERLAY_BOX_FIELDS, VIDEO_OVERLAY_FITS, VIDEO_OVERLAY_MAX_LAYERS, VIDEO_OVERLAY_MAX_TIME_SEC,
12
+ VIDEO_OVERLAY_MAX_VIDEO_LAYERS, VIDEO_OVERLAY_VOLUME_BOUNDS, isVideoOverlayOutputAspect, isVideoOverlayPresetId,
13
+ type VideoOverlayBoxInput, type VideoOverlayErrorCode, type VideoOverlayLayerInput,
14
+ } from "./video-overlay.js"
15
+ import { asLayer, isFit, nonEmpty, storedLayout } from "./video-overlay-input.js"
16
+ import { isVideoOverlayVideoLayer } from "./video-overlay-video-layers.js"
17
+ import {
18
+ VIDEO_OVERLAY_LAYOUT_IDS, isVideoOverlayLayoutId, videoOverlayLayoutNeedsAspect, videoOverlayLayoutNeedsVideoLayer, videoOverlayLayoutPlacesBase,
19
+ type VideoOverlayLayoutId,
20
+ } from "./video-overlay-layout-ids.js"
21
+
22
+ export interface VideoOverlayIssue {
23
+ readonly ok: false
24
+ readonly code: VideoOverlayErrorCode
25
+ /** 0-based index into the validated `layers[]`. */
26
+ readonly layer?: number
27
+ readonly slot?: number
28
+ readonly planLayer?: number
29
+ readonly params: Readonly<Record<string, string | number>>
30
+ }
31
+ export type VideoOverlayValidation = { readonly ok: true } | VideoOverlayIssue
32
+
33
+ export interface VideoOverlayValidationInput {
34
+ readonly layers?: ReadonlyArray<VideoOverlayLayerInput | null | undefined> | null
35
+ readonly outputAspect?: string | null
36
+ readonly baseFit?: string | null
37
+ readonly backgroundColor?: string | null
38
+ readonly baseBox?: VideoOverlayBoxInput | null
39
+ readonly layout?: string | null
40
+ /** From `assembleVideoOverlayRequest`: the wired layer plan was unreadable. */
41
+ readonly planError?: "invalid_layer_plan"
42
+ }
43
+
44
+ const inTimeRange = (v: unknown): v is number =>
45
+ typeof v === "number" && Number.isFinite(v) && v >= 0 && v <= VIDEO_OVERLAY_MAX_TIME_SEC
46
+
47
+ type BoundedField = keyof typeof VIDEO_OVERLAY_BOUNDS
48
+ const BOUNDED_FIELDS = Object.keys(VIDEO_OVERLAY_BOUNDS) as BoundedField[]
49
+
50
+ /**
51
+ * The first present (non-null) box / look field outside its domain, with the
52
+ * domain as a symbolic `allowed` string; null when every present field is in
53
+ * range. Only PRESENT fields are checked, so the verdict is the same before and
54
+ * after the expansion (it fills in-range defaults only). This is what keeps a
55
+ * JSON-written layer (MCP `update_workflow_json`, copilot, templates) from
56
+ * reaching the geometry with an unbounded box — `drawn ≤ canvas` (§3.4) holds
57
+ * only for boxes inside these bounds.
58
+ */
59
+ function outOfBounds(l: VideoOverlayLayerInput): { field: string; allowed: string } | null {
60
+ for (const f of BOUNDED_FIELDS) {
61
+ const v = l[f]
62
+ if (v === undefined || v === null) continue
63
+ const [min, max] = VIDEO_OVERLAY_BOUNDS[f]
64
+ const integer = f === "zIndex"
65
+ if (typeof v !== "number" || !Number.isFinite(v) || v < min || v > max || (integer && !Number.isInteger(v))) {
66
+ return { field: f, allowed: `${integer ? "integers " : ""}${min}..${max}` }
67
+ }
68
+ }
69
+ if (l.anchor != null && !(OVERLAY_ANCHORS as readonly unknown[]).includes(l.anchor)) {
70
+ return { field: "anchor", allowed: OVERLAY_ANCHORS.join(", ") }
71
+ }
72
+ if (l.fit != null && !isFit(l.fit)) return { field: "fit", allowed: VIDEO_OVERLAY_FITS.join(", ") }
73
+ if (l.animate != null && typeof l.animate !== "boolean") return { field: "animate", allowed: "true, false" }
74
+ return null
75
+ }
76
+
77
+ /**
78
+ * A present `sound` that is not `{ volume }` with the volume inside
79
+ * `VIDEO_OVERLAY_VOLUME_BOUNDS`. Kept out of `outOfBounds`: a bad volume is
80
+ * refused, but it does not stop the stage from drawing the layer.
81
+ */
82
+ function soundOutOfBounds(sound: unknown): { field: string; allowed: string } | null {
83
+ if (sound === undefined || sound === null) return null
84
+ const [min, max] = VIDEO_OVERLAY_VOLUME_BOUNDS
85
+ const v = typeof sound === "object" && !Array.isArray(sound) ? (sound as { volume?: unknown }).volume : undefined
86
+ return typeof v === "number" && Number.isFinite(v) && v >= min && v <= max ? null : { field: "sound.volume", allowed: `${min}..${max}` }
87
+ }
88
+
89
+ /** A present base box under the layer rule: anchor and width (a non-object reads as an empty box), every present box field in range. */
90
+ function baseBoxIssue(raw: unknown): VideoOverlayIssue | null {
91
+ const own = asLayer(raw) ?? {}
92
+ const box = Object.fromEntries(VIDEO_OVERLAY_BOX_FIELDS.map((f) => [f, own[f]])) as VideoOverlayLayerInput
93
+ if (box.anchor == null || box.width == null) return { ok: false, code: "incomplete_box", params: { field: "baseBox" } }
94
+ const bad = outOfBounds(box)
95
+ return bad ? { ok: false, code: "field_out_of_bounds", params: { ...bad, field: `baseBox.${bad.field}` } } : null
96
+ }
97
+
98
+ /**
99
+ * Can `resolveVideoOverlayGeometry` place this layer? True when its box is what
100
+ * the validator's box checks require: `anchor` one of the nine anchors, `width`
101
+ * a finite number, and every present box / look field in range
102
+ * (`VIDEO_OVERLAY_BOUNDS`, enums). A partial box saved from workflow JSON
103
+ * (`{ imageUrl, start, width }`, `anchor: null`) is stored as written — the
104
+ * expansion leaves it for the validator's `incomplete_box` — so any reader
105
+ * that DRAWS a stored layer (the canvas stage) must skip one that fails this;
106
+ * the geometry would throw on it.
107
+ */
108
+ export function hasDrawableVideoOverlayBox(layer: unknown): boolean {
109
+ const l = asLayer(layer)
110
+ if (!l) return false
111
+ if (!(OVERLAY_ANCHORS as readonly unknown[]).includes(l.anchor)) return false
112
+ if (typeof l.width !== "number" || !Number.isFinite(l.width)) return false
113
+ return outOfBounds(l) === null
114
+ }
115
+
116
+ /**
117
+ * Spec §3.5 — what a schema cannot express, and what the DAG path skips. Run
118
+ * at every engine entry: the route (`.superRefine`, before the expansion), the
119
+ * canvas single-node run, payload-builder and the worker (after it) — the
120
+ * verdict is the same on either side of the expansion (no code reads an
121
+ * expanded field). Also refuses a PRESENT box / look field outside
122
+ * `VIDEO_OVERLAY_BOUNDS` or its enum / type (`field_out_of_bounds`, spec §4.4's
123
+ * "out-of-bounds box/opacity/zIndex" row — on the DAG path this validator is
124
+ * the only check). A layer carries an image or a video, never both
125
+ * (`layer_two_sources`), at most `VIDEO_OVERLAY_MAX_VIDEO_LAYERS` are videos,
126
+ * and only a video layer has `sound`. A non-object `layers[]` entry reads as
127
+ * an empty layer. A `layout` (`""` reads as absent) must be known, a stack
128
+ * takes no `baseBox` (`layout_conflicts_base_box`: it places the base
129
+ * itself); a `baseBox` follows the layer rule (`incomplete_box`,
130
+ * `field_out_of_bounds` as `baseBox.<field>`) and needs an `outputAspect`; a
131
+ * layout gets what it needs (an aspect, a video layer) — checked before
132
+ * `base_box_needs_aspect`, so writing a layout's base box does not change the
133
+ * verdict. The FIRST failure, as a code.
134
+ */
135
+ export function validateVideoOverlayRequest(body: VideoOverlayValidationInput): VideoOverlayValidation {
136
+ if (body.planError) return { ok: false, code: "invalid_layer_plan", params: {} }
137
+ const layers = Array.isArray(body.layers) ? body.layers : []
138
+ if (layers.length === 0) return { ok: false, code: "no_layers", params: {} }
139
+ if (layers.length > VIDEO_OVERLAY_MAX_LAYERS) {
140
+ return { ok: false, code: "too_many_layers", params: { max: VIDEO_OVERLAY_MAX_LAYERS, count: layers.length } }
141
+ }
142
+ const videoCount = layers.filter(isVideoOverlayVideoLayer).length
143
+ if (videoCount > VIDEO_OVERLAY_MAX_VIDEO_LAYERS) {
144
+ return { ok: false, code: "too_many_video_layers", params: { max: VIDEO_OVERLAY_MAX_VIDEO_LAYERS, count: videoCount } }
145
+ }
146
+ for (let i = 0; i < layers.length; i++) {
147
+ const l: VideoOverlayLayerInput = asLayer(layers[i]) ?? {}
148
+ const at = (code: VideoOverlayErrorCode, params: Record<string, string | number> = {}): VideoOverlayIssue => ({
149
+ ok: false,
150
+ code,
151
+ layer: i,
152
+ ...(typeof l.slot === "number" ? { slot: l.slot } : {}),
153
+ ...(typeof l.planLayer === "number" ? { planLayer: l.planLayer } : {}),
154
+ params,
155
+ })
156
+ const boxFields = VIDEO_OVERLAY_BOX_FIELDS.filter((f) => l[f] !== undefined && l[f] !== null)
157
+ if (!isVideoOverlayPresetId(l.preset) && boxFields.length > 0 && (l.anchor == null || l.width == null)) return at("incomplete_box")
158
+ const bad = outOfBounds(l) ?? soundOutOfBounds(l.sound)
159
+ if (bad) return at("field_out_of_bounds", bad)
160
+ const hasVideo = nonEmpty(l.videoUrl)
161
+ if (nonEmpty(l.imageUrl) && hasVideo) return at("layer_two_sources")
162
+ if (!nonEmpty(l.imageUrl) && !hasVideo) return at("layer_without_image")
163
+ if (l.sound != null && !hasVideo) return at("sound_without_video")
164
+ if (!inTimeRange(l.start)) return at("time_out_of_range", { field: "start", max: VIDEO_OVERLAY_MAX_TIME_SEC })
165
+ if (l.end !== undefined && l.end !== null) {
166
+ if (!inTimeRange(l.end)) return at("time_out_of_range", { field: "end", max: VIDEO_OVERLAY_MAX_TIME_SEC })
167
+ if (!(l.end > l.start)) return at("end_before_start", { start: l.start, end: l.end })
168
+ }
169
+ }
170
+ const hasAspect = isVideoOverlayOutputAspect(body.outputAspect)
171
+ if (!hasAspect && (body.baseFit != null || body.backgroundColor != null)) {
172
+ return { ok: false, code: "fit_without_aspect", params: {} }
173
+ }
174
+ const stored = storedLayout(body.layout)
175
+ if (stored !== undefined && !isVideoOverlayLayoutId(stored)) {
176
+ return { ok: false, code: "field_out_of_bounds", params: { field: "layout", allowed: VIDEO_OVERLAY_LAYOUT_IDS.join(", ") } }
177
+ }
178
+ const layout = stored as VideoOverlayLayoutId | undefined
179
+ if (layout && body.baseBox != null && videoOverlayLayoutPlacesBase(layout)) return { ok: false, code: "layout_conflicts_base_box", params: { layout } }
180
+ const boxIssue = body.baseBox != null ? baseBoxIssue(body.baseBox) : null
181
+ if (boxIssue) return boxIssue
182
+ if (layout && !hasAspect && videoOverlayLayoutNeedsAspect(layout)) return { ok: false, code: "layout_needs_aspect", params: { layout } }
183
+ if (layout && videoOverlayLayoutNeedsVideoLayer(layout) && !layers.some(isVideoOverlayVideoLayer)) {
184
+ return { ok: false, code: "layout_needs_video_layer", params: { layout } }
185
+ }
186
+ if (body.baseBox != null && !hasAspect) return { ok: false, code: "base_box_needs_aspect", params: {} }
187
+ return { ok: true }
188
+ }
189
+
190
+ const MESSAGES: { readonly [C in VideoOverlayErrorCode]: (p: Readonly<Record<string, string | number>>) => string } = {
191
+ no_layers: () => "At least 1 layer is required",
192
+ too_many_layers: (p) => `At most ${p.max} layers (got ${p.count})`,
193
+ incomplete_box: (p) => (p.field ? `${p.field} needs an anchor and a width` : "anchor and width are required without a preset"),
194
+ layer_without_image: () => "no image or video — connect one to the layer's handle or set imageUrl or videoUrl",
195
+ time_out_of_range: (p) => `${p.field} must be between 0 and ${p.max} s`,
196
+ end_before_start: (p) => `end (${p.end} s) must be after start (${p.start} s)`,
197
+ fit_without_aspect: () => "baseFit and backgroundColor need an outputAspect",
198
+ field_out_of_bounds: (p) => `${p.field} is out of range (allowed: ${p.allowed})`,
199
+ invalid_layer_plan: () => "the layer plan must be a list of layers",
200
+ layer_two_sources: () => "has both an image and a video — keep one (imageUrl or videoUrl)",
201
+ too_many_video_layers: (p) => `At most ${p.max} video layers (got ${p.count})`,
202
+ sound_without_video: () => "sound is only for a video layer — remove it or set videoUrl",
203
+ base_box_needs_aspect: () => "baseBox needs an outputAspect",
204
+ layout_needs_aspect: (p) => `layout ${p.layout} needs an outputAspect`,
205
+ layout_needs_video_layer: (p) => `layout ${p.layout} needs a video layer — set videoUrl on a layer or connect a video to a layer's handle`,
206
+ layout_conflicts_base_box: () => "A stack layout places the base itself — remove baseBox or choose Custom",
207
+ }
208
+
209
+ const PLAN_LAYER_WITHOUT_IMAGE = "no image or video — set imageUrl or videoUrl on this layer in the plan."
210
+
211
+ /** `Plan layer <n>` for a layer-plan entry, `Layer <slot>` when the layer came from the canvas, else `layers[<index>]`; "" for a request-wide failure. */
212
+ export function videoOverlayLayerLabel(ref: { readonly layer?: number; readonly slot?: number; readonly planLayer?: number }): string {
213
+ if (typeof ref.planLayer === "number") return `Plan layer ${ref.planLayer}`
214
+ return typeof ref.slot === "number" ? `Layer ${ref.slot}` : typeof ref.layer === "number" ? `layers[${ref.layer}]` : ""
215
+ }
216
+
217
+ /** The ONE English rendering of a verdict — the route's 400 text and the worker's error message. */
218
+ export function formatVideoOverlayError(issue: VideoOverlayIssue): string {
219
+ const label = videoOverlayLayerLabel(issue)
220
+ // A plan layer has no handle to connect — its source can only come from its own imageUrl or videoUrl.
221
+ const text = issue.code === "layer_without_image" && typeof issue.planLayer === "number" ? PLAN_LAYER_WITHOUT_IMAGE : MESSAGES[issue.code](issue.params)
222
+ return label ? `${label}: ${text}` : text
223
+ }
@@ -0,0 +1,304 @@
1
+ /**
2
+ * Video Overlay video layers — what makes a layer a video, and what kind of
3
+ * layer a wired source becomes. A sibling of `video-overlay.ts`, which imports
4
+ * from here at run time; this file imports from it for TYPES only, so the
5
+ * dependency stays one-way.
6
+ *
7
+ * A layer is a video layer when it carries a non-empty `videoUrl`: the
8
+ * validator's count, the `animate` default and `videoOverlayHasVideoLayer`
9
+ * all read it through `isVideoOverlayVideoLayer`, so they cannot disagree.
10
+ * Wire contract only — no I/O.
11
+ */
12
+ import type { VideoOverlayLayerInput } from "./video-overlay.js"
13
+ import { DYNAMIC_PRODUCER_TYPES, IMAGE_PRODUCER_TYPES, VIDEO_PRODUCER_TYPES } from "./producer-types.js"
14
+ import { resolveEffectiveSourceType } from "./entity-image-handle.js"
15
+
16
+ /** File extensions a wired source from a node of no fixed kind is read as a video by. */
17
+ const LAYER_VIDEO_EXTENSIONS = [".mp4", ".mov", ".webm", ".m4v"] as const
18
+ /** File extensions it is read as an image by (a recognisable image stays an image, whatever a List column says). */
19
+ const LAYER_IMAGE_EXTENSIONS = [".png", ".jpg", ".jpeg", ".webp", ".gif", ".avif", ".bmp", ".tif", ".tiff", ".heic", ".heif", ".svg"] as const
20
+
21
+ /** True when the layer is a plain object with a non-empty `videoUrl`. */
22
+ export function isVideoOverlayVideoLayer(layer: unknown): boolean {
23
+ if (layer === null || typeof layer !== "object" || Array.isArray(layer)) return false
24
+ const url = (layer as VideoOverlayLayerInput).videoUrl
25
+ return typeof url === "string" && url.length > 0
26
+ }
27
+
28
+ /** True when any layer is a video layer. Non-array input and non-object entries read as none. */
29
+ export function videoOverlayHasVideoLayer(
30
+ layers: ReadonlyArray<VideoOverlayLayerInput | null | undefined> | null | undefined,
31
+ ): boolean {
32
+ return Array.isArray(layers) && layers.some(isVideoOverlayVideoLayer)
33
+ }
34
+
35
+ /** The URL's path, lower-cased, without query or fragment; a relative or unparseable URL is cut at `?` / `#`. */
36
+ function lowerPath(url: string): string {
37
+ try {
38
+ return new URL(url).pathname.toLowerCase()
39
+ } catch {
40
+ return url.split(/[?#]/, 1)[0]!.toLowerCase()
41
+ }
42
+ }
43
+
44
+ export type VideoOverlayWiredLayerKind = "image" | "video"
45
+
46
+ /** The wire a layer handle receives, as both engines' resolvers know it. */
47
+ export interface VideoOverlayWiredSource {
48
+ /** The source node's type. */
49
+ readonly type?: string | null
50
+ /** The source handle the wire leaves (through any teleport). */
51
+ readonly handle?: string | null
52
+ /** The medium the source declares for that handle — a component's or sub-workflow's port (`declaredOutputMediaType`). */
53
+ readonly declaredMediaType?: string | null
54
+ /**
55
+ * The medium a List column's type declares for that handle
56
+ * (`listColumnMediaType`). It ranks BELOW the URL's extension: it only fills
57
+ * the gap for a link with no recognisable one.
58
+ */
59
+ readonly columnMediaType?: string | null
60
+ }
61
+
62
+ /**
63
+ * Pips whose medium the shared effective-type tables (`resolveEffectiveSourceType`)
64
+ * do not name, kept here so the layer rule reads them without changing how
65
+ * those tables route or validate a wire. 3D Render Pro sits in both producer
66
+ * sets: its `stills` pip carries one PNG per shot, its `video` pip the MP4.
67
+ * The dynamic producers hand on a video or an audio file by pip: their video
68
+ * pips are videos whatever their file's name. A frontend guard holds every
69
+ * image or video pip the editor draws, that a layer handle accepts, to its own
70
+ * medium with an extension-less URL.
71
+ */
72
+ const LAYER_PIP_KINDS: Readonly<Record<string, Readonly<Record<string, VideoOverlayWiredLayerKind>>>> = {
73
+ "pro-3d-render": { stills: "image", video: "video" },
74
+ "adjust-volume": { "video-out": "video" },
75
+ "pitch-tempo": { "video-out": "video" },
76
+ "voice-changer": { video: "video" },
77
+ "voice-changer-pro": { video: "video" },
78
+ dubbing: { video: "video" },
79
+ "split-media": { video: "video" },
80
+ }
81
+
82
+ /**
83
+ * Layer-plan pips whose plan carries layers of one medium only, so a run
84
+ * estimate can price the node they feed before the plan exists: UGC Cards'
85
+ * plan is its card images. On the `layerPlan` handle nothing else answers
86
+ * `image` before the run (`videoOverlayWireMediumBeforeRun`).
87
+ */
88
+ const LAYER_PLAN_PIP_KINDS: Readonly<Record<string, Readonly<Record<string, VideoOverlayWiredLayerKind>>>> = {
89
+ "ugc-cards": { layerPlan: "image" },
90
+ }
91
+
92
+ const ownKey = <T>(table: Readonly<Record<string, T>>, key: string): T | undefined => (Object.hasOwn(table, key) ? table[key] : undefined)
93
+
94
+ /** The kind of a single-medium producer: in exactly one of the image and video producer sets, and not dynamic. */
95
+ function producerKind(type: string): VideoOverlayWiredLayerKind | undefined {
96
+ if (DYNAMIC_PRODUCER_TYPES.has(type)) return undefined
97
+ const video = VIDEO_PRODUCER_TYPES.has(type)
98
+ if (video === IMAGE_PRODUCER_TYPES.has(type)) return undefined
99
+ return video ? "video" : "image"
100
+ }
101
+
102
+ /**
103
+ * What a source wired to a layer handle draws as — the ONE rule both engines
104
+ * call, in this order:
105
+ * 1. the medium the wire is known to carry: a pip row of its own
106
+ * (`LAYER_PIP_KINDS`), the medium a port declares (`declaredMediaType`:
107
+ * `image` or `video`), or the source's effective type for that handle
108
+ * (an aggregate lane, a scraper's typed pip, an entity's or an output's
109
+ * image pip — `resolveEffectiveSourceType`) when that is a single-medium producer;
110
+ * 2. the producer sets, for a single-medium producer only;
111
+ * 3. the URL path's extension, when it is a recognisable video or image one
112
+ * (a list, a sub-workflow, a producer in both sets);
113
+ * 4. a List column's declared type (`columnMediaType`: `image` or `video`),
114
+ * for a link with no recognisable extension — so a `.png` in a
115
+ * `video-url` column stays an image, as it was before video layers;
116
+ * 5. an image, as every layer was before video layers existed.
117
+ */
118
+ export function videoOverlayWiredLayerKind(source: VideoOverlayWiredSource, url: string): VideoOverlayWiredLayerKind {
119
+ return kindOfSource(source) ?? kindOfFile(source, url)
120
+ }
121
+
122
+ /** Steps 3–5 of {@link videoOverlayWiredLayerKind}: what the file says, for a source that does not decide by itself. */
123
+ function kindOfFile(source: VideoOverlayWiredSource, url: string): VideoOverlayWiredLayerKind {
124
+ const column = source.columnMediaType === "image" || source.columnMediaType === "video" ? source.columnMediaType : undefined
125
+ return kindOfUrl(url) ?? column ?? "image"
126
+ }
127
+
128
+ /** Steps 1–2 of {@link videoOverlayWiredLayerKind}: the kind the source decides by itself, or undefined when its file decides. */
129
+ function kindOfSource(source: VideoOverlayWiredSource): VideoOverlayWiredLayerKind | undefined {
130
+ const type = source.type ?? ""
131
+ const handle = source.handle ?? undefined
132
+ const pip = pipRowKind(LAYER_PIP_KINDS, source)
133
+ if (pip) return pip
134
+ if (source.declaredMediaType === "image" || source.declaredMediaType === "video") return source.declaredMediaType
135
+ const effective = resolveEffectiveSourceType(type, handle)
136
+ const carried = effective !== type ? producerKind(effective) : undefined
137
+ if (carried) return carried
138
+ return producerKind(type)
139
+ }
140
+
141
+ /** Step 3: the URL path's recognisable extension, or undefined. */
142
+ function kindOfUrl(url: string): VideoOverlayWiredLayerKind | undefined {
143
+ const path = lowerPath(url)
144
+ if (LAYER_VIDEO_EXTENSIONS.some((ext) => path.endsWith(ext))) return "video"
145
+ if (LAYER_IMAGE_EXTENSIONS.some((ext) => path.endsWith(ext))) return "image"
146
+ return undefined
147
+ }
148
+
149
+ /** What a wire hands a Video Overlay before the run: an image, a video, or not known yet. */
150
+ export type VideoOverlayWireMedium = VideoOverlayWiredLayerKind | "unknown"
151
+
152
+ /** Where a wire lands on a Video Overlay: a layer handle, or the `layerPlan` handle. */
153
+ export interface VideoOverlayWireBeforeRun {
154
+ /** Default `layer`. */
155
+ readonly target?: "layer" | "plan"
156
+ /** A layer wire's files already known before the run (a List's own cells); none = not known. */
157
+ readonly knownUrls?: readonly string[]
158
+ }
159
+
160
+ /**
161
+ * What a source wired to a Video Overlay hands it, as far as it is known
162
+ * BEFORE the run: the ONE place a run estimate asks.
163
+ *
164
+ * On a layer handle, by the run's own rule ({@link videoOverlayWiredLayerKind}):
165
+ * a source that decides by itself (a pip row, a declared port, a single-medium
166
+ * producer) answers its kind; one whose kind follows its file answers by the
167
+ * files already known (`knownUrls`, read in the run's order: the extension,
168
+ * then a List column's type), and is `unknown` when none is.
169
+ *
170
+ * On the `layerPlan` handle, only a plan pip row answers `image`
171
+ * (`LAYER_PLAN_PIP_KINDS`: UGC Cards' plan is its card images): a declared
172
+ * port, a producer set or a List column says what a FILE is, not what a
173
+ * plan's layers are, so any other plan is `video` when its source is a video
174
+ * and `unknown` otherwise.
175
+ *
176
+ * A run estimate prices `unknown` as a video run, so a quote is never below
177
+ * what the run is charged; once a file is known, the answer is the run's.
178
+ */
179
+ export function videoOverlayWireMediumBeforeRun(source: VideoOverlayWiredSource, wire: VideoOverlayWireBeforeRun = {}): VideoOverlayWireMedium {
180
+ if (wire.target === "plan") {
181
+ const row = pipRowKind(LAYER_PLAN_PIP_KINDS, source)
182
+ return row ?? (kindOfSource(source) === "video" ? "video" : "unknown")
183
+ }
184
+ const decided = kindOfSource(source)
185
+ if (decided) return decided
186
+ const known = wire.knownUrls ?? []
187
+ if (known.length === 0) return "unknown"
188
+ return known.some((url) => kindOfFile(source, url) === "video") ? "video" : "image"
189
+ }
190
+
191
+ /** The row of `table` naming the source's handle, or undefined. */
192
+ function pipRowKind(
193
+ table: Readonly<Record<string, Readonly<Record<string, VideoOverlayWiredLayerKind>>>>,
194
+ source: VideoOverlayWiredSource,
195
+ ): VideoOverlayWiredLayerKind | undefined {
196
+ const pips = ownKey(table, source.type ?? "")
197
+ const handle = source.handle ?? undefined
198
+ return pips && handle !== undefined ? ownKey(pips, handle) : undefined
199
+ }
200
+
201
+ /** `list[i]` with `id === id`, its `key` when that is a string. */
202
+ function portMedium(list: unknown, id: string, key: "mediaType" | "type"): string | undefined {
203
+ if (!Array.isArray(list)) return undefined
204
+ const port = list.find((p) => p !== null && typeof p === "object" && (p as { id?: unknown }).id === id) as Record<string, unknown> | undefined
205
+ const value = port?.[key]
206
+ return typeof value === "string" ? value : undefined
207
+ }
208
+
209
+ const field = (v: unknown, key: string): unknown => (v !== null && typeof v === "object" ? (v as Record<string, unknown>)[key] : undefined)
210
+
211
+ /**
212
+ * The medium a component or sub-workflow declares for the handle a wire
213
+ * leaves (`image`, `video`, `audio`, `text`, `any`), or undefined. A
214
+ * sub-workflow (and a component) names its output ports in
215
+ * `routeSnapshot.outputPorts`, its handles `out_<port>`; a component falls back
216
+ * to `componentMetadata.outputs[].type`; a sub-workflow input node names its
217
+ * ports in `ports`, by their own ids. The same fields both engines' input
218
+ * resolvers route these wires by. (A List's column type is not a port
219
+ * declaration: `listColumnMediaType` reads it, and it ranks below the URL's
220
+ * extension.) Untrusted node data: anything malformed declares nothing.
221
+ */
222
+ export function declaredOutputMediaType(type: string | null | undefined, data: unknown, handle: string | null | undefined): string | undefined {
223
+ if (typeof handle !== "string" || data === null || typeof data !== "object") return undefined
224
+ if (type === "sub-workflow-input") return portMedium(field(data, "ports"), handle, "mediaType")
225
+ if (type !== "sub-workflow" && type !== "component") return undefined
226
+ const portId = handle.replace(/^out_/, "")
227
+ const fromSnapshot = portMedium(field(field(data, "routeSnapshot"), "outputPorts"), portId, "mediaType")
228
+ if (fromSnapshot !== undefined || type !== "component") return fromSnapshot
229
+ return portMedium(field(field(data, "componentMetadata"), "outputs"), portId, "type")
230
+ }
231
+
232
+ /** A List column type → the medium its cells declare (its text and JSON columns declare none). */
233
+ const LIST_COLUMN_MEDIA: Readonly<Record<string, string>> = { "image-url": "image", "video-url": "video", "audio-url": "audio" }
234
+
235
+ /**
236
+ * The medium a List's column type declares for the pip a wire leaves
237
+ * (`image-url` → image, `video-url` → video, `audio-url` → audio): the column
238
+ * whose `handleId` the pip names, else its first column — the column a List's
239
+ * own `list` pip carries, as both engines' input resolvers route it. Undefined
240
+ * for any other source, a text or JSON column, or malformed data. Handed to the
241
+ * wired-kind rule as `columnMediaType`, where it ranks below the URL's extension.
242
+ */
243
+ export function listColumnMediaType(type: string | null | undefined, data: unknown, handle: string | null | undefined): string | undefined {
244
+ if (type !== "list" || data === null || typeof data !== "object") return undefined
245
+ const columns = field(data, "columns")
246
+ if (!Array.isArray(columns)) return undefined
247
+ const isColumn = (c: unknown): c is Record<string, unknown> => c !== null && typeof c === "object"
248
+ const column = columns.find((c) => isColumn(c) && c.handleId === handle) ?? columns[0]
249
+ const columnType = isColumn(column) ? column.type : undefined
250
+ return typeof columnType === "string" && Object.hasOwn(LIST_COLUMN_MEDIA, columnType) ? LIST_COLUMN_MEDIA[columnType] : undefined
251
+ }
252
+
253
+ /**
254
+ * A WIRED slot's layer as it is stored: the expanded layer `expanded`, minus an
255
+ * `animate` its writer did not set (`written`: the stored layer and the edit
256
+ * applied to it). A wired slot's kind is its wire's, known only where the wire
257
+ * is read — the run's assembly and the canvas stage — and the expansion there
258
+ * fills the fade default by that kind (on for an image, off for a video); a
259
+ * default stored here would fix one kind's default on the other, so a video
260
+ * wired in later would fade. `written` itself when the result has the same
261
+ * fields (an idempotent write); `expanded` by reference when nothing is removed.
262
+ */
263
+ export function withoutImpliedVideoOverlayAnimate(
264
+ expanded: VideoOverlayLayerInput,
265
+ written: VideoOverlayLayerInput | null | undefined,
266
+ ): VideoOverlayLayerInput {
267
+ if (written?.animate != null || expanded.animate === undefined) return expanded
268
+ const { animate: _implied, ...rest } = expanded
269
+ const fields = rest as Readonly<Record<string, unknown>>
270
+ const keys = Object.keys(fields)
271
+ const same = written != null && keys.length === Object.keys(written).length && keys.every((k) => fields[k] === (written as Readonly<Record<string, unknown>>)[k])
272
+ return same ? written : rest
273
+ }
274
+
275
+ /**
276
+ * A WIRED slot's layer as the run reads it when its wire is an image: without
277
+ * a stored `sound`. A wired slot's kind is its wire's, read at the run, so a
278
+ * sound set while the wire was a video (or before a List column's type, a
279
+ * dynamic source's output or an upstream re-run changed it) is skipped rather
280
+ * than refused: the run goes ahead, silent, and its fade default follows the
281
+ * image. Only the assembly calls this, for wired slots; a layer that carries
282
+ * its OWN image (the API, MCP, an unwired slot, a plan) keeps its sound and
283
+ * the validator refuses it (`sound_without_video`). By reference when there is
284
+ * no sound.
285
+ */
286
+ export function withoutVideoOverlaySound<T extends VideoOverlayLayerInput>(layer: T): T {
287
+ if (!Object.hasOwn(layer, "sound")) return layer
288
+ const { sound: _skipped, ...rest } = layer
289
+ return rest as T
290
+ }
291
+
292
+ /**
293
+ * A layer without an empty-string `imageUrl` / `videoUrl`: every reader treats
294
+ * one as absent, and the REST route's URL schema refuses it, so the assembly
295
+ * drops it and a stored `{ imageUrl, videoUrl: "" }` runs as an image layer on
296
+ * both engines. By reference when it has none.
297
+ */
298
+ export function withoutEmptyVideoOverlaySources<T extends VideoOverlayLayerInput>(layer: T): T {
299
+ if (layer.imageUrl !== "" && layer.videoUrl !== "") return layer
300
+ const out: Record<string, unknown> = { ...layer }
301
+ if (out.imageUrl === "") delete out.imageUrl
302
+ if (out.videoUrl === "") delete out.videoUrl
303
+ return out as T
304
+ }