@nodaro/shared 3.70.0 → 3.71.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 (136) hide show
  1. package/dist/{chunk-FMQ43SJP.cjs → chunk-4A3ITJJB.cjs} +6 -6
  2. package/dist/{chunk-FMQ43SJP.cjs.map → chunk-4A3ITJJB.cjs.map} +1 -1
  3. package/dist/{chunk-XBHDXURR.cjs → chunk-4HV3LY4A.cjs} +78 -78
  4. package/dist/chunk-4HV3LY4A.cjs.map +1 -0
  5. package/dist/{chunk-52JNQG4K.js → chunk-6FUVGATF.js} +3 -3
  6. package/dist/{chunk-52JNQG4K.js.map → chunk-6FUVGATF.js.map} +1 -1
  7. package/dist/{chunk-GC77W57T.cjs → chunk-6PEWM2B3.cjs} +9 -9
  8. package/dist/{chunk-GC77W57T.cjs.map → chunk-6PEWM2B3.cjs.map} +1 -1
  9. package/dist/{chunk-BIQ7COJP.js → chunk-BO6IKV24.js} +5 -5
  10. package/dist/{chunk-BIQ7COJP.js.map → chunk-BO6IKV24.js.map} +1 -1
  11. package/dist/{chunk-IKN54UGB.js → chunk-BQV6NV7E.js} +3 -3
  12. package/dist/{chunk-IKN54UGB.js.map → chunk-BQV6NV7E.js.map} +1 -1
  13. package/dist/{chunk-LTBM2KMY.js → chunk-BVP4M5AK.js} +235 -9
  14. package/dist/chunk-BVP4M5AK.js.map +1 -0
  15. package/dist/{chunk-OW5AXH2Y.js → chunk-CL7ECTK2.js} +5 -4
  16. package/dist/chunk-CL7ECTK2.js.map +1 -0
  17. package/dist/{chunk-R22UHRR6.js → chunk-COA2OJIH.js} +39 -23
  18. package/dist/chunk-COA2OJIH.js.map +1 -0
  19. package/dist/{chunk-HW6TLOK4.cjs → chunk-DRPHRE4J.cjs} +2 -2
  20. package/dist/{chunk-HW6TLOK4.cjs.map → chunk-DRPHRE4J.cjs.map} +1 -1
  21. package/dist/{chunk-EWNDK4FV.js → chunk-F3XG5J5V.js} +3 -3
  22. package/dist/{chunk-EWNDK4FV.js.map → chunk-F3XG5J5V.js.map} +1 -1
  23. package/dist/{chunk-4U7QAUV3.cjs → chunk-H52P7DD2.cjs} +61 -61
  24. package/dist/{chunk-4U7QAUV3.cjs.map → chunk-H52P7DD2.cjs.map} +1 -1
  25. package/dist/{chunk-MZ772ZXA.cjs → chunk-HUCGHMOI.cjs} +17 -17
  26. package/dist/{chunk-MZ772ZXA.cjs.map → chunk-HUCGHMOI.cjs.map} +1 -1
  27. package/dist/{chunk-PYYYBINP.cjs → chunk-I4C6ZYU4.cjs} +6 -6
  28. package/dist/{chunk-PYYYBINP.cjs.map → chunk-I4C6ZYU4.cjs.map} +1 -1
  29. package/dist/{chunk-QCVQVKCI.js → chunk-JPSKVBYB.js} +3 -3
  30. package/dist/{chunk-QCVQVKCI.js.map → chunk-JPSKVBYB.js.map} +1 -1
  31. package/dist/{chunk-QVAUBB2T.js → chunk-K2P7KOIT.js} +9 -9
  32. package/dist/{chunk-QVAUBB2T.js.map → chunk-K2P7KOIT.js.map} +1 -1
  33. package/dist/{chunk-QV32JI4L.cjs → chunk-K5WRF2F3.cjs} +4 -4
  34. package/dist/{chunk-QV32JI4L.cjs.map → chunk-K5WRF2F3.cjs.map} +1 -1
  35. package/dist/{chunk-YLDY23N2.js → chunk-KD4UUCMW.js} +5 -5
  36. package/dist/{chunk-YLDY23N2.js.map → chunk-KD4UUCMW.js.map} +1 -1
  37. package/dist/{chunk-OZHE77T3.cjs → chunk-LBKMQAXD.cjs} +9 -9
  38. package/dist/{chunk-OZHE77T3.cjs.map → chunk-LBKMQAXD.cjs.map} +1 -1
  39. package/dist/{chunk-HBRDKHIW.cjs → chunk-MI4WEFJ4.cjs} +21 -21
  40. package/dist/{chunk-HBRDKHIW.cjs.map → chunk-MI4WEFJ4.cjs.map} +1 -1
  41. package/dist/{chunk-DOY47F7S.cjs → chunk-MN7BUGXF.cjs} +7 -7
  42. package/dist/{chunk-DOY47F7S.cjs.map → chunk-MN7BUGXF.cjs.map} +1 -1
  43. package/dist/{chunk-BLGZW3UF.cjs → chunk-NNCHSLFD.cjs} +291 -20
  44. package/dist/chunk-NNCHSLFD.cjs.map +1 -0
  45. package/dist/{chunk-NS34PZ2S.js → chunk-PPXUSZJU.js} +3 -3
  46. package/dist/{chunk-NS34PZ2S.js.map → chunk-PPXUSZJU.js.map} +1 -1
  47. package/dist/{chunk-PKWRAMVB.js → chunk-QME5O4NG.js} +7 -5
  48. package/dist/chunk-QME5O4NG.js.map +1 -0
  49. package/dist/{chunk-42ICEVUN.js → chunk-SAOIGWA2.js} +3 -3
  50. package/dist/{chunk-42ICEVUN.js.map → chunk-SAOIGWA2.js.map} +1 -1
  51. package/dist/{chunk-V6TC2NDG.js → chunk-SHSDGAI4.js} +4 -4
  52. package/dist/{chunk-V6TC2NDG.js.map → chunk-SHSDGAI4.js.map} +1 -1
  53. package/dist/{chunk-JEUZNHLL.cjs → chunk-SR7WH4FX.cjs} +33 -33
  54. package/dist/{chunk-JEUZNHLL.cjs.map → chunk-SR7WH4FX.cjs.map} +1 -1
  55. package/dist/{chunk-2VOXSVIE.js → chunk-SZ7ALYPK.js} +3 -3
  56. package/dist/{chunk-2VOXSVIE.js.map → chunk-SZ7ALYPK.js.map} +1 -1
  57. package/dist/{chunk-O53P2D4V.js → chunk-T4YYUI5Q.js} +3 -3
  58. package/dist/{chunk-O53P2D4V.js.map → chunk-T4YYUI5Q.js.map} +1 -1
  59. package/dist/{chunk-HWBLZSM3.cjs → chunk-TOYWEF6E.cjs} +39 -23
  60. package/dist/chunk-TOYWEF6E.cjs.map +1 -0
  61. package/dist/{chunk-FWPGRC4X.cjs → chunk-U6APV2PO.cjs} +5 -5
  62. package/dist/{chunk-FWPGRC4X.cjs.map → chunk-U6APV2PO.cjs.map} +1 -1
  63. package/dist/{chunk-QCZYYAPZ.cjs → chunk-UJIPIVTB.cjs} +48 -48
  64. package/dist/{chunk-QCZYYAPZ.cjs.map → chunk-UJIPIVTB.cjs.map} +1 -1
  65. package/dist/{chunk-KKFFQUMM.js → chunk-VZIMLPDC.js} +5 -5
  66. package/dist/chunk-VZIMLPDC.js.map +1 -0
  67. package/dist/{chunk-PWIKUOLB.cjs → chunk-W4CJ2P3F.cjs} +8 -8
  68. package/dist/{chunk-PWIKUOLB.cjs.map → chunk-W4CJ2P3F.cjs.map} +1 -1
  69. package/dist/{chunk-HP3YIWNJ.js → chunk-WARGPM7P.js} +2 -2
  70. package/dist/{chunk-HP3YIWNJ.js.map → chunk-WARGPM7P.js.map} +1 -1
  71. package/dist/{chunk-POZBRZUM.cjs → chunk-WHK3HTFY.cjs} +41 -41
  72. package/dist/{chunk-POZBRZUM.cjs.map → chunk-WHK3HTFY.cjs.map} +1 -1
  73. package/dist/{chunk-H2E4QXEZ.js → chunk-X3YRSRHP.js} +3 -3
  74. package/dist/{chunk-H2E4QXEZ.js.map → chunk-X3YRSRHP.js.map} +1 -1
  75. package/dist/{chunk-HA2PVTER.js → chunk-XK75VOEH.js} +4 -4
  76. package/dist/{chunk-HA2PVTER.js.map → chunk-XK75VOEH.js.map} +1 -1
  77. package/dist/{chunk-5DRSENY3.cjs → chunk-YHZUTPZL.cjs} +14 -12
  78. package/dist/{chunk-PKWRAMVB.js.map → chunk-YHZUTPZL.cjs.map} +1 -1
  79. package/dist/{chunk-WHV7MDNC.cjs → chunk-ZJQ2L3MI.cjs} +5 -3
  80. package/dist/chunk-ZJQ2L3MI.cjs.map +1 -0
  81. package/dist/entries/apps.cjs +42 -42
  82. package/dist/entries/apps.js +7 -7
  83. package/dist/entries/credits.cjs +418 -238
  84. package/dist/entries/credits.d.cts +262 -1
  85. package/dist/entries/credits.d.ts +262 -1
  86. package/dist/entries/credits.js +9 -9
  87. package/dist/entries/edl.cjs +60 -60
  88. package/dist/entries/edl.d.cts +96 -1
  89. package/dist/entries/edl.d.ts +96 -1
  90. package/dist/entries/edl.js +1 -1
  91. package/dist/entries/model-catalog.cjs +133 -133
  92. package/dist/entries/model-catalog.js +4 -4
  93. package/dist/entries/models.cjs +404 -404
  94. package/dist/entries/models.js +5 -5
  95. package/dist/entries/nodes.cjs +212 -212
  96. package/dist/entries/nodes.js +8 -8
  97. package/dist/entries/pipeline.cjs +153 -153
  98. package/dist/entries/pipeline.js +3 -3
  99. package/dist/entries/social.cjs +195 -191
  100. package/dist/entries/social.d.cts +9 -3
  101. package/dist/entries/social.d.ts +9 -3
  102. package/dist/entries/social.js +1 -1
  103. package/dist/entries/ugc.cjs +71 -71
  104. package/dist/entries/ugc.js +4 -4
  105. package/dist/entries/video.cjs +152 -152
  106. package/dist/entries/video.js +6 -6
  107. package/dist/index.cjs +1812 -1628
  108. package/dist/index.d.cts +3 -3
  109. package/dist/index.d.ts +3 -3
  110. package/dist/index.js +20 -20
  111. package/package.json +1 -1
  112. package/src/__tests__/audio-isolation-pricing.test.ts +49 -0
  113. package/src/__tests__/competitors.test.ts +6 -1
  114. package/src/__tests__/credit-identifiers.test.ts +9 -10
  115. package/src/__tests__/motion-transfer-pricing.test.ts +252 -0
  116. package/src/__tests__/video-to-video-pricing.test.ts +151 -0
  117. package/src/audio-isolation-pricing.ts +80 -0
  118. package/src/competitors.ts +8 -2
  119. package/src/credit-identifiers.ts +6 -0
  120. package/src/entries/credits.ts +54 -0
  121. package/src/entries/edl.ts +2 -0
  122. package/src/entries/social.ts +1 -0
  123. package/src/model-catalog.ts +34 -18
  124. package/src/motion-transfer-pricing.ts +239 -0
  125. package/src/producer-types.ts +2 -0
  126. package/src/use-case-output.ts +102 -0
  127. package/src/video-to-video-pricing.ts +248 -0
  128. package/dist/chunk-5DRSENY3.cjs.map +0 -1
  129. package/dist/chunk-BLGZW3UF.cjs.map +0 -1
  130. package/dist/chunk-HWBLZSM3.cjs.map +0 -1
  131. package/dist/chunk-KKFFQUMM.js.map +0 -1
  132. package/dist/chunk-LTBM2KMY.js.map +0 -1
  133. package/dist/chunk-OW5AXH2Y.js.map +0 -1
  134. package/dist/chunk-R22UHRR6.js.map +0 -1
  135. package/dist/chunk-WHV7MDNC.cjs.map +0 -1
  136. package/dist/chunk-XBHDXURR.cjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/audio-crossfade-curves.ts","../src/smart-cut-windows.ts","../src/speaker-tracks.ts","../src/speaker-map-contract.ts","../src/camera-switch-contract.ts","../src/edit-plan-contract.ts"],"names":["num"],"mappings":";;;AAkBO,IAAM,sBAAA,GAAyD;AAAA,EACpE;AAAA,IACE,EAAA,EAAI,QAAA;AAAA,IACJ,MAAA,EAAQ,KAAA;AAAA,IACR,KAAA,EAAO,QAAA;AAAA,IACP,WAAA,EAAa;AAAA,GACf;AAAA,EACA;AAAA,IACE,EAAA,EAAI,aAAA;AAAA,IACJ,MAAA,EAAQ,MAAA;AAAA,IACR,KAAA,EAAO,aAAA;AAAA,IACP,WAAA,EAAa;AAAA,GACf;AAAA,EACA;AAAA,IACE,EAAA,EAAI,QAAA;AAAA,IACJ,MAAA,EAAQ,MAAA;AAAA,IACR,KAAA,EAAO,eAAA;AAAA,IACP,WAAA,EAAa;AAAA,GACf;AAAA,EACA;AAAA,IACE,EAAA,EAAI,aAAA;AAAA,IACJ,MAAA,EAAQ,KAAA;AAAA,IACR,KAAA,EAAO,aAAA;AAAA,IACP,WAAA,EAAa;AAAA,GACf;AAAA,EACA;AAAA,IACE,EAAA,EAAI,aAAA;AAAA,IACJ,MAAA,EAAQ,KAAA;AAAA,IACR,KAAA,EAAO,aAAA;AAAA,IACP,WAAA,EAAa;AAAA;AAEjB;AAEO,IAAM,4BACX,sBAAA,CAAuB,GAAA,CAAI,CAAC,CAAA,KAAM,EAAE,EAAE;AAEjC,IAAM,gCAAA,GAAmC;AAEhD,IAAM,eAAyD,IAAI,GAAA;AAAA,EACjE,sBAAA,CAAuB,IAAI,CAAC,CAAA,KAAM,CAAC,CAAA,CAAE,EAAA,EAAI,CAAC,CAAC;AAC7C,CAAA;AAEO,SAAS,uBAAuB,EAAA,EAA6C;AAClF,EAAA,OAAO,YAAA,CAAa,IA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AAA,IAAa,CAAA,KAAM,SAAA,GAAY,CAAA,GAAI,UAAA;AAClD;AAkBO,SAAS,qBAAqB,UAAA,EAA8B;AACjE,EAAA,IAAI,CAAC,UAAA,IAAc,OAAO,UAAA,KAAe,UAAU,OAAO,UAAA;AAC1D,EAAA,MAAM,CAAA,GAAI,UAAA;AAEV,EAAA,IAAI,MAAM,OAAA,CAAQ,CAAA,CAAE,KAAK,CAAA,SAAU,CAAA,CAAE,KAAA;AAErC,EAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,CAAA,CAAE,QAAQ,CAAA,EAAG,OAAO,EAAE,OAAA,EAAS,WAAA,EAAa,QAAA,EAAU,CAAA,CAAE,QAAA,EAAS;AAEnF,EAAA,MAAM,EAAE,cAAA,EAAgB,eAAA,EAAiB,GAAG,MAAK,GAAI,CAAA;AACrD,EAAA,OAAO,IAAA;AACT","file":"chunk-HP3YIWNJ.js","sourcesContent":["/**\n * Curated subset of FFmpeg `acrossfade=curve=...` options for combine-videos\n * audio crossfades. We expose 5 well-understood presets out of the ~21 raw\n * curves FFmpeg supports; the rest are either visually indistinguishable to\n * non-audio-engineers or rarely useful in this context.\n *\n * Default `linear` matches today's behavior — adding this catalog is a pure\n * additive change for existing workflows.\n */\n\nexport interface AudioCrossfadeCurve {\n readonly id: string\n /** FFmpeg `acrossfade=curve=...` name. */\n readonly ffmpeg: string\n readonly label: string\n readonly description: string\n}\n\nexport const AUDIO_CROSSFADE_CURVES: readonly AudioCrossfadeCurve[] = [\n {\n id: \"linear\",\n ffmpeg: \"tri\",\n label: \"Linear\",\n description: \"Straight-line fade. Default; predictable but can dip in the middle for music.\",\n },\n {\n id: \"equal-power\",\n ffmpeg: \"qsin\",\n label: \"Equal Power\",\n description: \"Quarter-sine. Keeps perceived loudness roughly constant across the crossfade — best for music.\",\n },\n {\n id: \"smooth\",\n ffmpeg: \"hsin\",\n label: \"Smooth (Sine)\",\n description: \"Half-sine. Gentler than equal-power; good for dialogue and ambient.\",\n },\n {\n id: \"logarithmic\",\n ffmpeg: \"log\",\n label: \"Logarithmic\",\n description: \"Compensates for the ear's logarithmic loudness response. Long, slow tails.\",\n },\n {\n id: \"exponential\",\n ffmpeg: \"exp\",\n label: \"Exponential\",\n description: \"Sharp out / slow in (or vice versa). Punchy — good for impact moments.\",\n },\n]\n\nexport const AUDIO_CROSSFADE_CURVE_IDS: readonly string[] =\n AUDIO_CROSSFADE_CURVES.map((c) => c.id)\n\nexport const DEFAULT_AUDIO_CROSSFADE_CURVE_ID = \"linear\"\n\nconst CURVES_BY_ID: ReadonlyMap<string, AudioCrossfadeCurve> = new Map(\n AUDIO_CROSSFADE_CURVES.map((c) => [c.id, c]),\n)\n\nexport function getAudioCrossfadeCurve(id: string): AudioCrossfadeCurve | undefined {\n return CURVES_BY_ID.get(id)\n}\n\n/**\n * Resolve a curve id to its FFmpeg `acrossfade=curve=` name. Unknown ids fall\n * back to `tri` (linear) — this matches the route's Zod default so callers\n * downstream of validation never see undefined.\n */\nexport function resolveAudioCrossfadeCurve(id: string | undefined): string {\n if (!id) return \"tri\"\n return CURVES_BY_ID.get(id)?.ffmpeg ?? \"tri\"\n}\n","/**\n * Smart-cut SEARCH WINDOWS — the shared bound + clamp for the\n * `smartCutFramesPrev` / `smartCutFramesNext` of BOTH smart-cut nodes:\n * generate-video-pro (segment boundaries) and combine-videos (clip joins).\n *\n * They bound how much of each side of a boundary the engine considers when\n * it places the cut: N frames from the end of a segment and M from the start\n * of the next. Absent → the engine's own default, byte-identical to the\n * behavior before they were exposed. A boundary the engine cannot resolve\n * inside the window falls back to the fixed freeze-trims; recast pins 24/24.\n *\n * Why a shared clamp: the config panel, the canvas node (single-node Run) and\n * the orchestrator (workflow Run) are three independent writers/send paths into\n * the same route, whose Zod schema REJECTS out-of-range values (its `.min()` /\n * `.max()` are these very constants). Deriving all of them from this one\n * function means a stale, imported or hand-edited node value degrades to a\n * legal request instead of 400-ing an entire run — and the paths cannot drift\n * apart. An `<input type=\"number\" max={…}>` is not a substitute: the browser\n * does not stop a typed or pasted value from reaching React's onChange.\n */\n\n/** Widest window we accept anywhere — the UI's `max`, the clamp's ceiling and\n * `/v1/combine-videos`' own Zod `.max()` (the generate-video-pro engine route\n * itself accepts up to 48). Past this, added frames only cost search time and\n * invite a false match. */\nexport const SMART_CUT_WINDOW_MAX = 24\n/** Narrowest meaningful window — one frame each side. */\nexport const SMART_CUT_WINDOW_MIN = 1\n/** The engine's default when the field is absent. Documented here so the UI\n * can show it as the placeholder without hardcoding a second copy. */\nexport const SMART_CUT_WINDOW_DEFAULT = 8\n\n/**\n * Narrow an arbitrary node value to a legal window, or `undefined` to mean\n * \"let the engine use its default\". Non-numbers, NaN, and non-integers all\n * collapse to `undefined` rather than to a guessed number: a malformed value\n * should fall back to the proven default, not silently pick a different\n * search width than the user asked for.\n */\nexport function clampSmartCutWindow(value: unknown): number | undefined {\n if (typeof value !== \"number\" || !Number.isFinite(value)) return undefined\n const n = Math.round(value)\n if (n < SMART_CUT_WINDOW_MIN) return SMART_CUT_WINDOW_MIN\n if (n > SMART_CUT_WINDOW_MAX) return SMART_CUT_WINDOW_MAX\n return n\n}\n","import type { Edl, EdlSource, EdlValidation } from \"./edl.js\"\n\n/**\n * Speaker tracks — where each speaker's face is, over time, per camera.\n *\n * WHY THIS EXISTS\n * A face-tracking analysis node samples each camera an edit shows, finds the\n * faces, links them into tracks and labels each track with a speaker. Its\n * result feeds the framing rung `resolveEdlSegmentSlots` reserves for a\n * per-segment resolver (D20, edl-multicam.ts). This module is the wire shape\n * of that result plus the pure functions that read it: structural vocabulary\n * only — no detector, no linking or attribution rule, no framing or follow\n * math, no thresholds. That is why it lives in the Apache-licensed\n * `@nodaro/shared` (the public contract: the API response, the SDK type and\n * the MCP output). Every published version is an irrevocable grant, so every\n * later field is optional and additive.\n *\n * TWO SHAPES, ONE PROJECTION\n * - `SpeakerTrackSet` — the full set, boxes included. At a long multi-camera\n * edit it is megabytes of JSON, so it is stored as a JSON artifact (the\n * versioned box body), never inline in a job row or a node's data.\n * - `SpeakerTrackSetDescriptor` — what the node outputs: the same set with\n * every box removed (a `boxCount` per track instead) plus the artifact's\n * `url`, `sha256` and `bytes`. Consumers fetch the body by URL, check the\n * hash, run `normalizeSpeakerTracks` + `validateSpeakerTracks` on it, and\n * can confirm it is the body the descriptor names with\n * `describeSpeakerTracks(body, artifact)` deep-equal to the descriptor.\n *\n * CLOCK (D19)\n * Boxes are per SOURCE and on that source's own clock (`clock: \"source\"`), in\n * integer ms. A consumer maps to the master clock through the EDL source's\n * offset: `masterMs = ms + offsetMs` (`remapMsThroughEdl(edl, ms, sourceId)`).\n * Nothing here applies the offset, and nothing ever rescales a time (no\n * seconds→ms guessing — an implausible value is a validation error).\n *\n * GEOMETRY\n * Box coordinates are fractions 0..1 of `frame`: the display-oriented frame\n * (after rotation, square pixels) the producer sampled.\n *\n * SAMPLING\n * `sampledSpans` say what was looked at. No box for a track outside them means\n * \"not sampled\"; inside them it means \"no face there\". Spans are half-open\n * `[startMs, endMs)`, like EDL segments.\n */\n\nexport const SPEAKER_TRACKS_VERSION = 1 as const\n\n/** How a track got its speaker. Open: a newer producer may add a method, which\n * an older validator reports as a WARNING, never an issue. */\nexport const SPEAKER_TRACK_ATTRIBUTION_METHODS = [\"source-map\", \"region\", \"mouth-motion\", \"manual\"] as const\nexport type SpeakerTrackAttributionMethod = (typeof SPEAKER_TRACK_ATTRIBUTION_METHODS)[number]\nconst KNOWN_METHODS: ReadonlySet<string> = new Set(SPEAKER_TRACK_ATTRIBUTION_METHODS)\n\n/** Default hard cap on boxes per source. The longest edit the platform plans\n * for (180 minutes) sampled at 2 per second is 21,600 samples per source; the\n * cap leaves room for several faces in every sample. Override per call with\n * `maxBoxesPerSource`. */\nexport const SPEAKER_TRACKS_MAX_BOXES_PER_SOURCE = 100_000\n/** Default hard cap on the serialized size of a track set (UTF-8 bytes of its\n * JSON), so no consumer ever loads an unbounded body. Override per call with\n * `maxBytes`. */\nexport const SPEAKER_TRACKS_MAX_BYTES = 64 * 1024 * 1024\n\n/** One detection. `ms` on the source clock; x/y/w/h fractions 0..1 of the frame. */\nexport interface SpeakerTrackBox {\n readonly ms: number\n readonly x: number\n readonly y: number\n readonly w: number\n readonly h: number\n /** Detector confidence 0..1, when the detector reports one. */\n readonly score?: number\n}\n\nexport interface SpeakerTrackAttribution {\n /** Known: `SPEAKER_TRACK_ATTRIBUTION_METHODS`. */\n readonly method: SpeakerTrackAttributionMethod | (string & {})\n /** 0..1. */\n readonly confidence: number\n /** The transcript's own label for this speaker, kept beside the display name\n * in `speaker` so a later rename re-maps instead of orphaning the track. */\n readonly rawSpeaker?: string\n}\n\n/** What a track says about itself, without its boxes. */\nexport interface SpeakerTrackHeader {\n /** Unique in the whole set, e.g. \"wide/t3\". */\n readonly id: string\n /** A label in the edit's speaker space. Absent = unattributed. */\n readonly speaker?: string\n readonly attribution?: SpeakerTrackAttribution\n}\n\nexport interface SpeakerTrack extends SpeakerTrackHeader {\n /** Strictly increasing `ms`, each inside one of the source's `sampledSpans`. */\n readonly boxes: readonly SpeakerTrackBox[]\n}\n\nexport interface SpeakerTrackSummary extends SpeakerTrackHeader {\n readonly boxCount: number\n}\n\nexport interface SpeakerTrackSpan {\n readonly startMs: number\n /** Exclusive, > startMs. */\n readonly endMs: number\n}\n\ninterface SpeakerTrackSourceFields {\n /** `EdlSource.id` of a video source. */\n readonly sourceId: string\n /** Boxes, spans and cuts are ms on this SOURCE's own clock (D19). */\n readonly clock: \"source\"\n /** The display-oriented frame (after rotation, square pixels), in pixels, that box fractions refer to. */\n readonly frame: { readonly w: number; readonly h: number }\n /** What was sampled: sorted, non-overlapping, half-open. */\n readonly sampledSpans: readonly SpeakerTrackSpan[]\n /** Source-clock ms of detected scene changes, ascending. No track spans one. */\n readonly cuts?: readonly number[]\n}\n\nexport interface SpeakerTrackSource extends SpeakerTrackSourceFields {\n readonly tracks: readonly SpeakerTrack[]\n}\n\nexport interface SpeakerTrackSourceSummary extends SpeakerTrackSourceFields {\n readonly tracks: readonly SpeakerTrackSummary[]\n}\n\ninterface SpeakerTrackSetFields {\n readonly version: 1\n /** Samples per second the producer looked at. */\n readonly sampleFps: number\n /** Informational: which detector produced the boxes, e.g. \"example:face-detector\". */\n readonly detector: { readonly id: string; readonly version?: string }\n}\n\n/** The full set — the versioned box body, stored as a JSON artifact. */\nexport interface SpeakerTrackSet extends SpeakerTrackSetFields {\n readonly sources: readonly SpeakerTrackSource[]\n}\n\n/** What the analysis node outputs: the set without its boxes, plus where the body is. */\nexport interface SpeakerTrackSetDescriptor extends SpeakerTrackSetFields {\n readonly sources: readonly SpeakerTrackSourceSummary[]\n /** Where the `SpeakerTrackSet` body is stored. */\n readonly url: string\n /** SHA-256 of the stored body's bytes, 64 lowercase hex characters. */\n readonly sha256: string\n /** Size of the stored body in bytes. */\n readonly bytes: number\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// Normalization (coerce, never reject — and never reinterpret)\n// ─────────────────────────────────────────────────────────────────────────\n\nconst isObj = (v: unknown): v is Record<string, unknown> => !!v && typeof v === \"object\" && !Array.isArray(v)\nconst isNum = (v: unknown): v is number => typeof v === \"number\" && Number.isFinite(v)\nconst num = (v: unknown, fallback = 0): number => (isNum(v) ? v : fallback)\nconst str = (v: unknown): string | undefined => (typeof v === \"string\" ? v : undefined)\nconst clamp01 = (v: number): number => Math.min(1, Math.max(0, v))\n/** A readonly array field of a value that may have skipped normalization. */\nconst arr = <T,>(v: readonly T[] | undefined): readonly T[] => (Array.isArray(v) ? v : [])\n/** Integer ms; never -0 (JSON cannot carry it, so a round trip would differ). */\nconst int = (v: number): number => {\n const r = Math.round(v)\n return r === 0 ? 0 : r\n}\n\n/** One axis of a detection, cropped to the frame: the visible part of\n * `[p, p+s]` within `[0, 1]`, or undefined when none of it is visible. An\n * in-frame axis is returned untouched (so a second pass cannot drift by a\n * float ulp); an overhanging one becomes the intersection, whichever edge it\n * crosses, so its centre only ever moves toward the visible part. */\nfunction cropAxis(p: number, s: number): readonly [number, number] | undefined {\n if (!(s > 0)) return undefined\n if (p >= 0 && p + s <= 1) return [p, s]\n const lo = clamp01(p)\n const hi = clamp01(p + s)\n return hi > lo ? [lo, hi - lo] : undefined\n}\n\nfunction normalizeBox(raw: unknown): SpeakerTrackBox | undefined {\n if (!isObj(raw)) return undefined\n if (![raw.ms, raw.x, raw.y, raw.w, raw.h].every(isNum)) return undefined\n // A detection is cropped to the frame, never moved: a face at the frame edge\n // keeps only its visible part, and one entirely off-frame is dropped. This is\n // deliberately NOT `normalizeRegion`'s clamp-then-shrink (edl.ts), which is\n // fine for a region a user draws but would shift a left/top overhang and turn\n // an off-frame detection into an in-frame face.\n const xs = cropAxis(raw.x as number, raw.w as number)\n const ys = cropAxis(raw.y as number, raw.h as number)\n if (!xs || !ys) return undefined\n const [x, w] = xs\n const [y, h] = ys\n return { ms: int(raw.ms as number), x, y, w, h, ...(isNum(raw.score) ? { score: clamp01(raw.score) } : {}) }\n}\n\nfunction normalizeSpans(raw: unknown): SpeakerTrackSpan[] {\n if (!Array.isArray(raw)) return []\n const spans = raw\n .filter(isObj)\n .filter((s) => isNum(s.startMs) && isNum(s.endMs))\n .map((s) => ({ startMs: int(s.startMs as number), endMs: int(s.endMs as number) }))\n .filter((s) => s.endMs > s.startMs)\n .sort((a, b) => a.startMs - b.startMs || a.endMs - b.endMs)\n const merged: SpeakerTrackSpan[] = []\n for (const s of spans) {\n const last = merged[merged.length - 1]\n if (last && s.startMs <= last.endMs) merged[merged.length - 1] = { startMs: last.startMs, endMs: Math.max(last.endMs, s.endMs) }\n else merged.push(s)\n }\n return merged\n}\n\nfunction normalizeCuts(raw: unknown): number[] {\n if (!Array.isArray(raw)) return []\n const sorted = raw.filter(isNum).map(int).sort((a, b) => a - b)\n return sorted.filter((c, i) => i === 0 || c !== sorted[i - 1])\n}\n\nfunction normalizeAttribution(raw: unknown): SpeakerTrackAttribution | undefined {\n if (!isObj(raw)) return undefined\n const method = str(raw.method)\n if (!method) return undefined\n const rawSpeaker = str(raw.rawSpeaker)\n return { method, confidence: clamp01(num(raw.confidence)), ...(rawSpeaker ? { rawSpeaker } : {}) }\n}\n\nfunction normalizeHeader(raw: Record<string, unknown>, fallbackId: string): SpeakerTrackHeader {\n const speaker = str(raw.speaker)\n const attribution = normalizeAttribution(raw.attribution)\n return {\n id: str(raw.id) || fallbackId,\n ...(speaker ? { speaker } : {}),\n ...(attribution ? { attribution } : {}),\n }\n}\n\nfunction normalizeSetFields(o: Record<string, unknown>): SpeakerTrackSetFields {\n const detector = isObj(o.detector) ? o.detector : {}\n const detectorVersion = str(detector.version)\n return {\n // Only an ABSENT version defaults to 1. Any present value — another\n // number, \"2\", null — is kept as is so validate refuses it rather than\n // reading a newer (or broken) body as this one.\n version: (o.version === undefined ? SPEAKER_TRACKS_VERSION : o.version) as 1,\n sampleFps: num(o.sampleFps),\n detector: { id: str(detector.id) ?? \"\", ...(detectorVersion ? { version: detectorVersion } : {}) },\n }\n}\n\nfunction normalizeSources<T>(\n raw: unknown,\n track: (t: Record<string, unknown>, fallbackId: string) => T,\n): Array<SpeakerTrackSourceFields & { readonly tracks: readonly T[] }> {\n if (!Array.isArray(raw)) return []\n return raw.map((r) => {\n const s = isObj(r) ? r : {}\n const sourceId = str(s.sourceId) ?? \"\"\n const frame = isObj(s.frame) ? s.frame : {}\n const cuts = normalizeCuts(s.cuts)\n const tracks = Array.isArray(s.tracks) ? s.tracks.map((t, k) => track(isObj(t) ? t : {}, `${sourceId}/t${k + 1}`)) : []\n return {\n sourceId,\n // A clock other than \"source\" cannot be repaired: boxes on another clock\n // would land offsetMs away from their frame. Keep it for validate to refuse.\n clock: (typeof s.clock === \"string\" ? s.clock : \"source\") as \"source\",\n frame: { w: int(num(frame.w)), h: int(num(frame.h)) },\n sampledSpans: normalizeSpans(s.sampledSpans),\n tracks,\n ...(cuts.length > 0 ? { cuts } : {}),\n }\n })\n}\n\n/**\n * Coerce an unknown value into a well-formed `SpeakerTrackSet` (the box body):\n * drop unknown keys and malformed boxes, crop every box to the frame (an\n * entirely off-frame box is dropped, an overhang keeps its visible part), clamp\n * scores and confidences to 0..1, round every time to integer ms, sort each\n * track's boxes by time (box order IS time, unlike EDL segment order), sort and\n * merge sampled spans, sort and de-duplicate cuts.\n *\n * It never repairs what would change meaning: a box outside every sampled\n * span, two boxes at one instant, a track across a cut, another version or\n * another clock all survive for `validateSpeakerTracks` to report.\n */\nexport function normalizeSpeakerTracks(input: unknown): SpeakerTrackSet {\n const o = isObj(input) ? input : {}\n return {\n ...normalizeSetFields(o),\n sources: normalizeSources(o.sources, (t, fallbackId) => {\n const boxes = Array.isArray(t.boxes) ? t.boxes.map(normalizeBox).filter((b): b is SpeakerTrackBox => b !== undefined) : []\n return { ...normalizeHeader(t, fallbackId), boxes: [...boxes].sort((a, b) => a.ms - b.ms) }\n }),\n }\n}\n\n/** Coerce an unknown value into a `SpeakerTrackSetDescriptor`, by the same rules\n * as `normalizeSpeakerTracks`; a missing or broken `boxCount` becomes 0. */\nexport function normalizeSpeakerTrackSetDescriptor(input: unknown): SpeakerTrackSetDescriptor {\n const o = isObj(input) ? input : {}\n return {\n ...normalizeSetFields(o),\n sources: normalizeSources(o.sources, (t, fallbackId) => ({\n ...normalizeHeader(t, fallbackId),\n boxCount: Math.max(0, int(num(t.boxCount))),\n })),\n url: str(o.url) ?? \"\",\n sha256: str(o.sha256) ?? \"\",\n bytes: int(num(o.bytes)),\n }\n}\n\n/** The descriptor of a (normalized) set stored at `artifact.url`: every box\n * removed, a `boxCount` per track. Pure; the caller hashes and stores the body. */\nexport function describeSpeakerTracks(\n set: SpeakerTrackSet,\n artifact: { readonly url: string; readonly sha256: string; readonly bytes: number },\n): SpeakerTrackSetDescriptor {\n return {\n version: set.version,\n sampleFps: set.sampleFps,\n detector: { ...set.detector },\n sources: set.sources.map((s) => ({\n sourceId: s.sourceId,\n clock: s.clock,\n frame: { ...s.frame },\n sampledSpans: s.sampledSpans.map((sp) => ({ ...sp })),\n tracks: s.tracks.map((t) => ({\n id: t.id,\n ...(t.speaker !== undefined ? { speaker: t.speaker } : {}),\n ...(t.attribution ? { attribution: { ...t.attribution } } : {}),\n boxCount: t.boxes.length,\n })),\n ...(s.cuts && s.cuts.length > 0 ? { cuts: [...s.cuts] } : {}),\n })),\n url: artifact.url,\n sha256: artifact.sha256,\n bytes: artifact.bytes,\n }\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// The edit's speaker space\n// ─────────────────────────────────────────────────────────────────────────\n\n/** The speaker labels an edit uses: the union of `sources[].speakers`,\n * `segments[].speaker` and `segments[].layout.slots[].speaker`, over every EDL\n * given (a clip pack), sorted by code unit. Tracks must be labelled in this\n * space, or no track ever matches a segment's speaker. */\nexport function edlSpeakerSpace(edl: Edl | readonly Edl[]): string[] {\n const out = new Set<string>()\n const add = (v: unknown) => {\n if (typeof v === \"string\" && v) out.add(v)\n }\n for (const e of edlList(edl)) {\n for (const s of Array.isArray(e.sources) ? e.sources : []) {\n for (const sp of Array.isArray(s?.speakers) ? s.speakers : []) add(sp)\n }\n for (const seg of Array.isArray(e.segments) ? e.segments : []) {\n add(seg?.speaker)\n for (const slot of Array.isArray(seg?.layout?.slots) ? seg.layout!.slots! : []) add(slot?.speaker)\n }\n }\n return [...out].sort()\n}\n\nfunction edlList(edl: Edl | readonly Edl[] | undefined): readonly Edl[] {\n if (!edl) return []\n const all: readonly unknown[] = Array.isArray(edl) ? edl : [edl]\n return all.filter((e): e is Edl => isObj(e))\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// Validation\n// ─────────────────────────────────────────────────────────────────────────\n\nexport interface SpeakerTracksValidateOptions {\n /** The edit the tracks are for — one EDL, or every clip of a pack. When given,\n * every source must resolve to one of its video sources, and attributed\n * speakers must be in its speaker space (`edlSpeakerSpace`). */\n readonly edl?: Edl | readonly Edl[]\n /** Default `SPEAKER_TRACKS_MAX_BOXES_PER_SOURCE`. */\n readonly maxBoxesPerSource?: number\n /** Default `SPEAKER_TRACKS_MAX_BYTES`. */\n readonly maxBytes?: number\n /** `validateSpeakerTracks` only: the body's known size in bytes (e.g. the\n * fetched length), so a large body is not serialized again to measure it. */\n readonly serializedBytes?: number\n}\n\nconst SHA256_HEX = /^[0-9a-f]{64}$/\n\ntype Findings = { issues: string[]; warnings: string[] }\n\n/** The rules shared by the body and the descriptor. `perTrack` adds the body's\n * box rules and returns the track's box count. */\nfunction validateCommon<T extends SpeakerTrackHeader>(\n set: SpeakerTrackSetFields & { readonly sources: ReadonlyArray<SpeakerTrackSourceFields & { readonly tracks: readonly T[] }> },\n opts: SpeakerTracksValidateOptions,\n perTrack: (track: T, source: SpeakerTrackSourceFields, f: Findings) => number,\n): Findings {\n const f: Findings = { issues: [], warnings: [] }\n const { issues, warnings } = f\n const sources = arr(set.sources)\n const maxBoxes = opts.maxBoxesPerSource ?? SPEAKER_TRACKS_MAX_BOXES_PER_SOURCE\n\n if (set.version !== SPEAKER_TRACKS_VERSION) issues.push(`version must be ${SPEAKER_TRACKS_VERSION}`)\n if (!(isNum(set.sampleFps) && set.sampleFps > 0)) issues.push(\"sampleFps must be a finite number > 0\")\n\n const edls = edlList(opts.edl)\n const edlSources = new Map<string, EdlSource>()\n for (const e of edls) {\n for (const s of Array.isArray(e.sources) ? e.sources : []) {\n if (s && typeof s.id === \"string\" && !edlSources.has(s.id)) edlSources.set(s.id, s)\n }\n }\n\n const sourceIds = new Set<string>()\n const trackIds = new Set<string>()\n sources.forEach((s, i) => {\n const sid = s.sourceId\n const at = `source \"${sid}\"`\n if (!sid) issues.push(`source[${i}]: sourceId is empty`)\n else if (sourceIds.has(sid)) issues.push(`duplicate source id \"${sid}\"`)\n sourceIds.add(sid)\n if (sid && edls.length > 0) {\n const es = edlSources.get(sid)\n if (!es) issues.push(`${at}: not a source of the EDL`)\n else if (es.kind !== \"video\") issues.push(`${at}: the EDL source is kind:\"${es.kind}\", tracks need a video source`)\n }\n if (s.clock !== \"source\") issues.push(`${at}: clock must be \"source\"`)\n if (!(isObj(s.frame) && isNum(s.frame.w) && isNum(s.frame.h) && s.frame.w > 0 && s.frame.h > 0)) {\n issues.push(`${at}: frame w/h must be positive`)\n }\n\n const spans = arr<SpeakerTrackSpan>(s.sampledSpans)\n spans.forEach((sp, j) => {\n const startMs: unknown = sp?.startMs\n const endMs: unknown = sp?.endMs\n if (!(isNum(startMs) && isNum(endMs) && endMs > startMs)) {\n issues.push(`${at}: sampledSpans[${j}] [${startMs},${endMs}) is not positive`)\n return\n }\n if (!(Number.isInteger(startMs) && Number.isInteger(endMs))) issues.push(`${at}: sampledSpans[${j}] [${startMs},${endMs}) is not integer ms`)\n if (startMs < 0) issues.push(`${at}: sampledSpans[${j}] starts before 0`)\n const prevEnd: unknown = spans[j - 1]?.endMs\n if (j > 0 && isNum(prevEnd) && startMs < prevEnd) {\n issues.push(`${at}: sampledSpans must be sorted and non-overlapping (span ${j})`)\n }\n })\n\n const cuts = s.cuts\n if (cuts !== undefined) {\n const okCuts = Array.isArray(cuts) && cuts.every((c, k) => Number.isInteger(c) && c >= 0 && (k === 0 || c > cuts[k - 1]))\n if (!okCuts) issues.push(`${at}: cuts must be ascending non-negative ms`)\n }\n\n let boxes = 0\n const tracks = arr<T>(s.tracks)\n tracks.forEach((t, k) => {\n if (!t?.id) issues.push(`${at} track[${k}]: id is empty`)\n else if (trackIds.has(t.id)) issues.push(`duplicate track id \"${t.id}\"`)\n if (t?.id) trackIds.add(t.id)\n const a = t?.attribution\n if (a) {\n if (!(isNum(a.confidence) && a.confidence >= 0 && a.confidence <= 1)) {\n issues.push(`track \"${t.id}\": attribution.confidence=${a.confidence} out of 0..1`)\n }\n if (!KNOWN_METHODS.has(a.method)) {\n warnings.push(`track \"${t.id}\": unknown attribution method \"${a.method}\" (known: ${SPEAKER_TRACK_ATTRIBUTION_METHODS.join(\", \")})`)\n }\n }\n boxes += perTrack(t, s, f)\n })\n if (boxes > maxBoxes) issues.push(`${at}: ${boxes} boxes is over the cap of ${maxBoxes}`)\n })\n\n // The speaker name space: labels from the raw transcript against an edit\n // that uses display names (or the reverse) match nothing, and every slot\n // would silently fall back to static framing.\n if (edls.length > 0) {\n const space = edlSpeakerSpace(edls)\n const attributed = sources.flatMap((s) => (Array.isArray(s.tracks) ? s.tracks : [])).filter((t) => !!t?.speaker)\n if (space.length > 0 && attributed.length > 0) {\n const inSpace = new Set(space)\n const matches = (t: T) => inSpace.has(t.speaker!) || (!!t.attribution?.rawSpeaker && inSpace.has(t.attribution.rawSpeaker))\n if (!attributed.some(matches)) {\n const labels = [...new Set(attributed.map((t) => t.speaker!))].sort()\n issues.push(\n `no tracked speaker is in the edit's speaker set: the tracks are labelled ${labels.map((l) => `\"${l}\"`).join(\", \")}` +\n ` and the edit uses ${space.map((l) => `\"${l}\"`).join(\", \")} — wire Speaker Frames to the same transcript as Camera Switch`,\n )\n } else {\n for (const t of attributed) {\n if (!matches(t)) warnings.push(`track \"${t.id}\": speaker \"${t.speaker}\" is not in the edit's speaker set`)\n }\n }\n }\n }\n return f\n}\n\n/** Per-box findings listed per track and rule before the rest are summarized\n * in one line, and the most issues a validation lists before one truncation\n * line. A systematic producer bug (a clock off by `offsetMs`, say) puts EVERY\n * box out of span; the refusal must stay readable wherever it is shown. */\nconst BOX_FINDINGS_PER_RULE = 5\nconst MAX_LISTED_FINDINGS = 100\n\n/** A per-box finding: the rule (what the per-track summary line counts, as\n * \"N more boxes <rule>\") and the message for one box. */\ntype BoxFinding = readonly [rule: string, message: string]\n\nfunction boxIssues(b: SpeakerTrackBox, at: string): BoxFinding[] {\n const out: BoxFinding[] = []\n for (const k of [\"x\", \"y\", \"w\", \"h\"] as const) {\n const v = b?.[k]\n if (!isNum(v) || v < 0 || v > 1) out.push([`with ${k} out of 0..1`, `${at}: ${k}=${v} out of 0..1`])\n }\n if (out.length > 0) return out\n // The same edge tolerance as validateEdl's regions, so the two never disagree.\n if (b.w <= 0 || b.h <= 0) out.push([\"with a non-positive w/h\", `${at}: non-positive w/h`])\n if (b.x + b.w > 1 + 1e-9) out.push([\"extending past the right edge\", `${at}: extends past the right edge (x+w>1)`])\n if (b.y + b.h > 1 + 1e-9) out.push([\"extending past the bottom edge\", `${at}: extends past the bottom edge (y+h>1)`])\n if (b.score !== undefined && !(isNum(b.score) && b.score >= 0 && b.score <= 1)) out.push([\"with a score out of 0..1\", `${at}: score=${b.score} out of 0..1`])\n return out\n}\n\n/** Cap a findings list at `MAX_LISTED_FINDINGS`, ending in one line that counts\n * the rest. Never empties a non-empty list, so `ok` is unchanged. */\nfunction capListed(list: readonly string[], noun: \"issues\" | \"warnings\"): string[] {\n if (list.length <= MAX_LISTED_FINDINGS) return [...list]\n return [...list.slice(0, MAX_LISTED_FINDINGS), `${list.length - MAX_LISTED_FINDINGS} more ${noun} not listed`]\n}\n\n/** Is `ms` inside one of `spans` (sorted, half-open)? Binary search. */\nfunction inSpans(spans: readonly SpeakerTrackSpan[], ms: number): boolean {\n let lo = 0\n let hi = spans.length - 1\n while (lo <= hi) {\n const mid = (lo + hi) >> 1\n const sp = spans[mid]\n if (ms < sp.startMs) hi = mid - 1\n else if (ms >= sp.endMs) lo = mid + 1\n else return true\n }\n return false\n}\n\n/**\n * Structural validation of a track set (the box body). Normalization is\n * `normalizeSpeakerTracks`'s job; this reports what is still wrong after it.\n * Issues are facts intrinsic to the set (or to the set against the EDL);\n * warnings are judgements an older validator must not turn into a refusal\n * (an unknown attribution method, one stray speaker label).\n *\n * Rules: version; a positive sample rate; unique source ids that resolve to\n * the EDL's video sources; the source clock; a positive frame; sorted,\n * non-overlapping, positive, integer-ms spans; ascending integer cuts; unique\n * track ids; every box in-frame, at an integer ms, strictly after the previous\n * one and inside a sampled span; no track across a cut; the speaker name\n * space; the box and byte caps.\n *\n * The listing is bounded: per track, the first few boxes breaking each rule\n * are listed and the rest counted in one line; past a fixed total, one line\n * counts the issues (or warnings) not listed. `ok` counts every finding.\n */\nexport function validateSpeakerTracks(set: SpeakerTrackSet, opts: SpeakerTracksValidateOptions = {}): EdlValidation {\n const safe = isObj(set) ? set : ({} as SpeakerTrackSet)\n const f = validateCommon(safe, opts, (t, source, { issues }) => {\n const boxes = Array.isArray(t?.boxes) ? t.boxes : []\n const spans = Array.isArray(source.sampledSpans) ? source.sampledSpans : []\n let first = Infinity\n let last = -Infinity\n // The first few findings of each rule are listed; the rest are counted.\n const seen = new Map<string, number>()\n const report = ([rule, message]: BoxFinding) => {\n const n = (seen.get(rule) ?? 0) + 1\n seen.set(rule, n)\n if (n <= BOX_FINDINGS_PER_RULE) issues.push(message)\n }\n const outside = `outside every sampled span of source \"${source.sourceId}\"`\n boxes.forEach((b, j) => {\n const at = `track \"${t.id}\" box[${j}]`\n boxIssues(b, at).forEach(report)\n if (!isNum(b?.ms)) {\n report([\"whose ms is not a number\", `${at}: ms is not a number`])\n return\n }\n if (!Number.isInteger(b.ms)) report([\"whose ms is not an integer\", `${at}: ms ${b.ms} is not an integer`])\n const prev = boxes[j - 1]?.ms\n if (j > 0 && isNum(prev) && !(b.ms > prev)) report([\"not after the previous box\", `${at}: ms ${b.ms} is not after the previous box (${prev})`])\n if (!inSpans(spans, b.ms)) report([outside, `${at}: ms ${b.ms} is ${outside}`])\n first = Math.min(first, b.ms)\n last = Math.max(last, b.ms)\n })\n for (const [rule, n] of seen) {\n if (n > BOX_FINDINGS_PER_RULE) issues.push(`track \"${t.id}\": ${n - BOX_FINDINGS_PER_RULE} more boxes ${rule}`)\n }\n const cut = (Array.isArray(source.cuts) ? source.cuts : []).find((c) => first < c && c <= last)\n if (cut !== undefined) issues.push(`track \"${t.id}\": spans the cut at ${cut} ms (boxes ${first}..${last})`)\n return boxes.length\n })\n const maxBytes = opts.maxBytes ?? SPEAKER_TRACKS_MAX_BYTES\n const bytes = opts.serializedBytes ?? new TextEncoder().encode(JSON.stringify(safe)).length\n if (bytes > maxBytes) f.issues.push(`the track set is ${bytes} bytes, over the cap of ${maxBytes}`)\n return { ok: f.issues.length === 0, issues: capListed(f.issues, \"issues\"), warnings: capListed(f.warnings, \"warnings\") }\n}\n\n/**\n * Structural validation of a descriptor (the node's output): the same rules as\n * `validateSpeakerTracks` minus the per-box ones (it has no boxes; `boxCount`\n * feeds the per-source cap), plus a non-empty `url`, a well-formed `sha256`\n * and a positive `bytes` within the byte cap.\n */\nexport function validateSpeakerTrackSetDescriptor(\n d: SpeakerTrackSetDescriptor,\n opts: Omit<SpeakerTracksValidateOptions, \"serializedBytes\"> = {},\n): EdlValidation {\n const safe = isObj(d) ? d : ({} as SpeakerTrackSetDescriptor)\n const f = validateCommon(safe, opts, (t, _source, { issues }) => {\n if (!(Number.isInteger(t?.boxCount) && t.boxCount >= 0)) {\n issues.push(`track \"${t?.id}\": boxCount must be a non-negative integer`)\n return 0\n }\n return t.boxCount\n })\n if (!(typeof safe.url === \"string\" && safe.url.trim())) f.issues.push(\"url is empty\")\n if (!(typeof safe.sha256 === \"string\" && SHA256_HEX.test(safe.sha256))) f.issues.push(\"sha256 must be 64 lowercase hex characters\")\n const maxBytes = opts.maxBytes ?? SPEAKER_TRACKS_MAX_BYTES\n if (!(Number.isInteger(safe.bytes) && safe.bytes > 0)) f.issues.push(\"bytes must be a positive integer\")\n else if (safe.bytes > maxBytes) f.issues.push(`the track set is ${safe.bytes} bytes, over the cap of ${maxBytes}`)\n return { ok: f.issues.length === 0, issues: capListed(f.issues, \"issues\"), warnings: capListed(f.warnings, \"warnings\") }\n}\n","/**\n * speaker-map (podcast use-case nodes, decided 2026-10-12/17) — which camera\n * each speaker is on, worked out from the cameras' own microphones: the\n * structural pieces every caller shares (the canvas engines, MCP, the SDK).\n * HOW the levels are compared is the server's. Pure, no I/O.\n */\nimport type { Edl } from \"./edl.js\"\n\nexport const SPEAKER_MAP_VERSION = 1 as const\n/** Recordings one run reads (cameras, plus the master when it also emits the edit). */\nexport const SPEAKER_MAP_MAX_SOURCES = 6\n/** Candidate cameras a comparison needs. */\nexport const SPEAKER_MAP_MIN_CAMERAS = 2\n/** How far the loudest camera must beat the next for the speaker to get it. */\nexport const SPEAKER_MAP_DEFAULT_MARGIN_DB = 3\n\nexport interface SpeakerMapConfidence {\n /** The camera the speaker got; \"\" = none clear (shown on the wide shot). */\n readonly camera: string\n /** The loudest camera's lead over the next, in dB; null when there was nothing to compare. */\n readonly marginDb: number | null\n}\n\nexport interface SpeakerMapResult {\n readonly version: typeof SPEAKER_MAP_VERSION\n /** Transcript speaker label → camera source id; \"\" = no camera of their own. Feeds Camera Switch's `speakerMap`. */\n readonly speakerMap: Readonly<Record<string, string>>\n readonly confidence: Readonly<Record<string, SpeakerMapConfidence>>\n readonly notes: readonly string[]\n /** The recordings as one edit on the master clock (offsets applied, roles and speakers set, one segment). */\n readonly edl?: Edl\n}\n\nconst parse = (raw: unknown): unknown => {\n if (typeof raw !== \"string\") return raw\n try { return JSON.parse(raw) } catch { return undefined }\n}\nconst isRecord = (v: unknown): v is Record<string, unknown> => !!v && typeof v === \"object\" && !Array.isArray(v)\n\nconst isConfidence = (v: unknown): boolean =>\n isRecord(v) && typeof v.camera === \"string\" && (v.marginDb === null || (typeof v.marginDb === \"number\" && Number.isFinite(v.marginDb)))\n\n/** A Speaker Map result (an object or its JSON string), or null when it is not\n * one: every map value and confidence camera a string, every margin a finite\n * number or null, every note a string — so a reader can trust each field. */\nexport function speakerMapResultOf(raw: unknown): SpeakerMapResult | null {\n const v = parse(raw)\n if (!isRecord(v) || v.version !== SPEAKER_MAP_VERSION || !isRecord(v.speakerMap) || !isRecord(v.confidence) || !Array.isArray(v.notes)) return null\n if (!Object.values(v.speakerMap).every((c) => typeof c === \"string\")) return null\n if (!Object.values(v.confidence).every(isConfidence)) return null\n if (!v.notes.every((n) => typeof n === \"string\")) return null\n return v as unknown as SpeakerMapResult\n}\n\n/** An ordinal key: a whole number from 1, written plainly (\"1\", \"12\" — never \" 1\", \"01\", \"1.0\", \"1e0\"). */\nconst ORDINAL = /^[1-9]\\d*$/\n\n/**\n * The override keyed by ordinal (\"1\" = the first voice heard) as a map keyed\n * by the transcript's own labels. `labels` is the transcript's speakers in\n * first-heard order — the caller passes `transcriptSpeakerLabels(transcript)`,\n * so this module imports nothing from camera-switch-contract (one import\n * direction: camera-switch-contract → speaker-map-contract, no cycle for the\n * structure ratchet). An ordinal past the transcript's speakers maps nobody,\n * and so do a key that is not a plain ordinal and an override that is not an\n * object (a hand-written workflow).\n */\nexport function speakerMapByOrdinal(labels: readonly string[], byOrder: Readonly<Record<string, string>> | undefined): Record<string, string> {\n if (!isRecord(byOrder)) return {}\n const out: Record<string, string> = {}\n for (const [ordinal, camera] of Object.entries(byOrder)) {\n if (!ORDINAL.test(ordinal)) continue\n const label = labels[Number(ordinal) - 1]\n if (label !== undefined && typeof camera === \"string\") out[label] = camera\n }\n return out\n}\n","/**\n * camera-switch (podcast B5, decided 2026-10-03) — the structural pieces every\n * caller shares: the canvas engines, the editor, MCP and the SDK. WHO is on\n * screen is decided by the Cloud plugin; these only read the inputs it needs\n * and pre-fill the speaker table. Pure, no I/O.\n */\nimport { normalizeTranscript } from \"./edl.js\"\nimport { speakerMapByOrdinal, speakerMapResultOf } from \"./speaker-map-contract.js\"\n\n/** The settings and their decided defaults (the plugin holds its own copy, D13). */\nexport const CAMERA_SWITCH_DEFAULTS = Object.freeze({\n /** The shortest shot; a shorter turn (an interjection) holds the shot. */\n minShotMs: 2_500,\n /** Cut this long before the new speaker starts. */\n leadMs: 200,\n /** Delay each cut by this long — `leadMs`'s counterpart. A route setting\n * only: no node carries it (`CAMERA_SWITCH_NODE_SETTINGS`). */\n lagMs: 0,\n /** With a `wide` camera: break to it after this long on one camera. */\n maxShotMs: 20_000,\n /** With a `wide` camera: every N-th cut goes to the wide (0 = off). */\n wideEvery: 0,\n /** Overlapping speech → a side-by-side / stacked layout hint. */\n layoutHints: false,\n})\n\n/** The flat credit id and price (decided 2026-10-03). */\nexport const CAMERA_SWITCH_CREDIT_ID = \"camera-switch\"\n\nconst parseMaybe = (raw: unknown): unknown => {\n if (typeof raw !== \"string\") return raw\n try { return JSON.parse(raw) } catch { return undefined }\n}\n\n/** Distinct speaker labels of a transcript (an object or its JSON string), in\n * order of first appearance in time. Read through `normalizeTranscript`\n * (decided 2026-10-08) — the Cloud plugin's reading — so a broken word (no\n * usable time) names no speaker here either; a zero-width word is a point\n * and does. Empty → camera-switch refuses before charging. */\nexport function transcriptSpeakerLabels(transcript: unknown): string[] {\n const parsed = parseMaybe(transcript)\n if (!parsed || typeof parsed !== \"object\") return []\n const seen = new Set<string>()\n for (const w of normalizeTranscript(parsed).words) {\n if (w.speaker && !seen.has(w.speaker)) seen.add(w.speaker)\n }\n return [...seen]\n}\n\n/** The cameras a speaker can be given: an EDL's video sources in order,\n * without the `wide` / `screen` angles (those are not anyone's close-up). */\nexport function cameraSwitchCameras(edl: unknown): Array<{ id: string; role?: string }> {\n const sources = (parseMaybe(edl) as { sources?: unknown } | null | undefined)?.sources\n if (!Array.isArray(sources)) return []\n return sources\n .filter((s): s is { id: string; kind?: string; role?: string } => !!s && typeof (s as { id?: unknown }).id === \"string\")\n .filter((s) => s.kind !== \"audio\" && s.role !== \"wide\" && s.role !== \"screen\" && s.role !== \"master-audio\")\n .map((s) => ({ id: s.id, ...(s.role ? { role: s.role } : {}) }))\n}\n\n/** The settings' accepted ranges — exactly the Cloud route's (it answers 400\n * outside them), so every caller clamps to the same numbers before sending. */\nexport const CAMERA_SWITCH_BOUNDS = Object.freeze({\n minShotMs: Object.freeze({ min: 500, max: 60_000 }),\n leadMs: Object.freeze({ min: 0, max: 5_000 }),\n lagMs: Object.freeze({ min: 0, max: 5_000 }),\n maxShotMs: Object.freeze({ min: 0, max: 600_000 }),\n wideEvery: Object.freeze({ min: 0, max: 20 }),\n})\n\n/** The longest display name a speaker can be given. */\nexport const CAMERA_SWITCH_NAME_MAX = 80\n\nexport type CameraSwitchNumericSetting = keyof typeof CAMERA_SWITCH_BOUNDS\n\n/**\n * The numeric settings a Camera Switch NODE carries (its data, which the\n * canvas and the server's executor send through `cameraSwitchSettingsPayload`).\n * `lagMs` is a setting of the route alone — the API, the SDK and the CLI send\n * it; no node does — so it is not one of them.\n */\nexport const CAMERA_SWITCH_NODE_SETTINGS = Object.freeze([\"minShotMs\", \"leadMs\", \"maxShotMs\", \"wideEvery\"] as const satisfies readonly CameraSwitchNumericSetting[])\n\n/** A setting as a whole number inside its range; undefined when unset. */\nexport function clampCameraSwitchSetting(key: CameraSwitchNumericSetting, value: unknown): number | undefined {\n if (typeof value !== \"number\" || !Number.isFinite(value)) return undefined\n const { min, max } = CAMERA_SWITCH_BOUNDS[key]\n return Math.min(max, Math.max(min, Math.round(value)))\n}\n\n/** Display names trimmed, empty ones dropped, each cut to\n * `CAMERA_SWITCH_NAME_MAX` characters. */\nexport function cleanSpeakerNames(raw: unknown): Record<string, string> {\n if (!raw || typeof raw !== \"object\" || Array.isArray(raw)) return {}\n const out: Record<string, string> = {}\n for (const [label, name] of Object.entries(raw as Record<string, unknown>)) {\n const trimmed = typeof name === \"string\" ? name.trim() : \"\"\n if (label && trimmed) out[label] = trimmed.slice(0, CAMERA_SWITCH_NAME_MAX)\n }\n return out\n}\n\n/** Why camera-switch would refuse this edit (the route's 400 `invalid_edl`),\n * or null. One edit (an object or its JSON string) on the master clock, with\n * sources and at least one segment of numeric inMs < outMs; a clip SET is\n * refused — on the canvas each clip fans out to its own run. */\nexport function cameraSwitchEdlProblem(edl: unknown): string | null {\n const v = parseMaybe(edl) as Record<string, unknown> | null | undefined\n if (!v || typeof v !== \"object\" || Array.isArray(v)) return \"camera-switch: `edl` must be one edit (an EDL object).\"\n if (Array.isArray(v.clips)) return \"camera-switch: `edl` is a clip set — pass one clip's EDL (a clip set fans out one run per clip on the canvas).\"\n if (!Array.isArray(v.sources) || !Array.isArray(v.segments)) return \"camera-switch: `edl` needs `sources` and `segments`.\"\n if (v.segments.length === 0) return \"camera-switch: `edl` has no segments.\"\n const num = (x: unknown) => (typeof x === \"number\" && Number.isFinite(x) ? x : undefined)\n for (const [i, row] of (v.segments as unknown[]).entries()) {\n const seg = row as { inMs?: unknown; outMs?: unknown } | null\n const inMs = num(seg?.inMs), outMs = num(seg?.outMs)\n if (inMs === undefined || outMs === undefined || !(outMs > inMs)) return `camera-switch: segment ${i} needs a numeric inMs < outMs.`\n }\n if (v.clock === \"output\") return \"camera-switch: the edit must be on the master clock (an edit-plan EDL), not a rendered output's.\"\n return null\n}\n\n/** The speaker table pre-filled by order (decided 2026-10-03): speaker 1 →\n * camera 1, speaker 2 → camera 2 … A speaker past the last camera stays\n * unmapped (the wide shows them, else any camera with picture). `existing`\n * entries are kept as the person set them — an explicit `\"\"` means \"no\n * camera of their own\" and is SENT as `\"\"`, so it also beats a source whose\n * `speakers` list names them. */\nexport function defaultSpeakerMap(\n labels: readonly string[],\n cameraIds: readonly string[],\n existing: Readonly<Record<string, string>> = {},\n): Record<string, string> {\n const out: Record<string, string> = {}\n labels.forEach((label, i) => {\n if (Object.prototype.hasOwnProperty.call(existing, label)) {\n const kept = existing[label]\n if (typeof kept === \"string\") out[label] = kept\n return\n }\n if (i < cameraIds.length) out[label] = cameraIds[i]!\n })\n return out\n}\n\n/** What a Camera Switch node sends besides its two inputs — ONE funnel for the\n * canvas executor and the orchestrator, so both send the same clamped\n * settings and the same pre-filled speaker table. */\nexport interface CameraSwitchNodeSettings {\n readonly speakerMap?: Readonly<Record<string, string>>\n /** Who is on which camera by ordinal — \"1\" the first voice heard → a camera\n * SOURCE id, \"\" none; what a use-case node's override writes (decided\n * 2026-10-17). A label in `speakerMap` beats it. */\n readonly speakerMapByOrder?: Readonly<Record<string, string>>\n readonly speakerNames?: Readonly<Record<string, string>>\n readonly minShotMs?: number\n readonly leadMs?: number\n readonly maxShotMs?: number\n readonly wideEvery?: number\n readonly layoutHints?: boolean\n}\n/**\n * Who is on which camera — the ONE merge of the speaker table's layers\n * (decided 2026-10-17). Per speaker, the first that names them wins: an\n * explicit label in `speakerMap`, the ordinal override `speakerMapByOrder`, a\n * wired Speaker Map result, then the order default (`defaultSpeakerMap`).\n * Each layer above the default is passed as `existing`, so its \"\" (no camera\n * of their own) is SENT as \"\" and is never re-filled by the order default; an\n * explicit entry that is not a string is ignored, so it never hides a layer\n * below it. `cameraSwitchSettingsPayload` sends this; the config panel's\n * \"What the run will use\" shows this — never a second copy of the order.\n */\nexport function cameraSwitchSpeakerMap(\n data: Pick<CameraSwitchNodeSettings, \"speakerMap\" | \"speakerMapByOrder\">,\n edl: unknown,\n transcript: unknown,\n wired?: { readonly speakerMap?: unknown },\n): Record<string, string> {\n const labels = transcriptSpeakerLabels(transcript)\n const explicit = data.speakerMap && typeof data.speakerMap === \"object\" && !Array.isArray(data.speakerMap)\n ? Object.fromEntries(Object.entries(data.speakerMap).filter(([, camera]) => typeof camera === \"string\"))\n : {}\n const existing = {\n ...(speakerMapResultOf(wired?.speakerMap)?.speakerMap ?? {}),\n ...speakerMapByOrdinal(labels, data.speakerMapByOrder),\n ...explicit,\n }\n return defaultSpeakerMap(labels, cameraSwitchCameras(edl).map((c) => c.id), existing)\n}\n\nexport function cameraSwitchSettingsPayload(\n data: CameraSwitchNodeSettings,\n edl: unknown,\n transcript: unknown,\n wired?: { readonly speakerMap?: unknown },\n): {\n speakerMap: Record<string, string>\n speakerNames: Record<string, string>\n minShotMs?: number\n leadMs?: number\n maxShotMs?: number\n wideEvery?: number\n layoutHints: boolean\n} {\n const out: ReturnType<typeof cameraSwitchSettingsPayload> = {\n speakerMap: cameraSwitchSpeakerMap(data, edl, transcript, wired),\n speakerNames: cleanSpeakerNames(data.speakerNames),\n layoutHints: data.layoutHints === true,\n }\n for (const key of CAMERA_SWITCH_NODE_SETTINGS) {\n const v = clampCameraSwitchSetting(key, data[key])\n if (v !== undefined) out[key] = v\n }\n return out\n}\n","/**\n * The edit-plan node's credit-id scheme and output unwrap — split out of\n * `edl.ts` (which keeps the EDL shape itself) so that module stays within the\n * file-size cap. Re-exported from the package index, so importers of\n * `@nodaro/shared` are unaffected.\n */\nimport { EDL_VERSION } from \"./edl.js\"\n\n// ─────────────────────────────────────────────────────────────────────────\n// edit-plan credit-id scheme (STRUCTURE only — the per-mode/tier/bucket credit\n// VALUES live app-side in backend/ee/billing/credits.ts + migration 432, since\n// they are probe-set placeholders and the DB row wins at runtime). Lives HERE\n// so BOTH core payload-builder and ee credits.ts read one id builder — core\n// may not import ee (check-ee-imports), the same reason buildVideoAnalysisCreditId\n// is shared. Mirrors the plugin's own (D13-local) pricing.ts scheme.\n// ─────────────────────────────────────────────────────────────────────────\n\n/** `trailer` (Track D1): one short teaser EDL built from the strongest moments,\n * priced like `clips` (the per-minute rate plus the clips flat). */\nexport type EditPlanMode = \"tighten\" | \"clips\" | \"chapters\" | \"trailer\"\nexport type EditPlanTier = \"economy\" | \"standard\" | \"premium\"\nexport const EDIT_PLAN_MODES: readonly EditPlanMode[] = [\"tighten\", \"clips\", \"chapters\", \"trailer\"]\nexport const EDIT_PLAN_TIERS: readonly EditPlanTier[] = [\"economy\", \"standard\", \"premium\"]\n/** The coarse duration ladder (MINUTES) a probed source duration rounds UP to;\n * the composite credit id carries the bucket. 4 modes × 3 tiers × 6 buckets =\n * 72 composites (+ the bare `edit-plan`). */\nexport const EDIT_PLAN_BUCKET_MINUTES: readonly number[] = [15, 30, 60, 90, 120, 180]\n/** Hard duration cap (design §7.4). */\nexport const EDIT_PLAN_MAX_MINUTES = 180\n/** `clips` mode: how many clips a plan returns when the caller names no count,\n * and the most it may be asked for. One source for the credit estimate, the\n * orchestrated payload clamp and the request schema. */\nexport const EDIT_PLAN_DEFAULT_CLIP_COUNT = 8\nexport const EDIT_PLAN_MAX_CLIP_COUNT = 50\n\n/** Clamp a requested clip count into `[1, EDIT_PLAN_MAX_CLIP_COUNT]`; `undefined`\n * for anything that is not a positive number (the planner then uses its default). */\nexport function clampEditPlanClipCount(count: unknown): number | undefined {\n if (typeof count !== \"number\" || !Number.isFinite(count) || count <= 0) return undefined\n return Math.min(EDIT_PLAN_MAX_CLIP_COUNT, Math.max(1, Math.floor(count)))\n}\n/** The bare estimator / DB-down fallback id. */\nexport const EDIT_PLAN_BASE_CREDIT_ID = \"edit-plan\"\n\n/** Round a source duration (seconds) UP to the smallest covering ladder bucket\n * (capped at the max), in minutes. `undefined` / non-finite → the ceiling\n * bucket (the safe over-reserve direction). */\nexport function editPlanBucketMinutes(durationSec: number | undefined): number {\n const secs = typeof durationSec === \"number\" && Number.isFinite(durationSec) ? durationSec : EDIT_PLAN_MAX_MINUTES * 60\n const mins = Math.max(1, Math.ceil(secs / 60))\n const capped = Math.min(mins, EDIT_PLAN_MAX_MINUTES)\n for (const b of EDIT_PLAN_BUCKET_MINUTES) if (capped <= b) return b\n return EDIT_PLAN_BUCKET_MINUTES[EDIT_PLAN_BUCKET_MINUTES.length - 1]!\n}\n\n/** `edit-plan:<mode>:<tier>:<bucket>m`. `durationSec` undefined → the ceiling\n * bucket. Single source of truth for the composite id shape. */\nexport function buildEditPlanCreditId(mode: EditPlanMode, tier: EditPlanTier, durationSec?: number): string {\n return editPlanMinutesCreditId(mode, tier, editPlanBucketMinutes(durationSec))\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// Per started minute (decided 2026-10-07). A plugin that declares\n// `supports().editPlanPerMinute` reserves `edit-plan:<mode>:<tier>:<N>m` with\n// N = the started minutes of the source (1..180), priced flat + rate × N from\n// ONE rate row and ONE flat row per mode × tier. The step ids above have the\n// same shape (N = a step), so one parser reads both, and the plugin's money\n// gate (`:(\\d+)m$`) accepts both.\n// ─────────────────────────────────────────────────────────────────────────\n\n/** Started minutes of a source (seconds): ceil(sec / 60), at least 1, capped at\n * the maximum. `undefined` / non-finite → the maximum (over-reserve direction). */\nexport function editPlanStartedMinutes(durationSec: number | undefined): number {\n const secs = typeof durationSec === \"number\" && Number.isFinite(durationSec) ? durationSec : EDIT_PLAN_MAX_MINUTES * 60\n return Math.min(EDIT_PLAN_MAX_MINUTES, Math.max(1, Math.ceil(secs / 60)))\n}\n\n/** `edit-plan:<mode>:<tier>:<N>m` for N minutes (a started-minute count or a step). */\nexport function editPlanMinutesCreditId(mode: EditPlanMode, tier: EditPlanTier, minutes: number): string {\n return `edit-plan:${mode}:${tier}:${minutes}m`\n}\n\n/** The id a run of this mode/tier on a source of `durationSec` reserves: per\n * started minute when the plugin charges that way (`perMinute`), else the step\n * the length rounds up to. An unknown length → the 180-minute maximum either way. */\nexport function editPlanReserveCreditId(\n mode: EditPlanMode,\n tier: EditPlanTier,\n durationSec: number | undefined,\n perMinute: boolean,\n): string {\n return perMinute\n ? editPlanMinutesCreditId(mode, tier, editPlanStartedMinutes(durationSec))\n : buildEditPlanCreditId(mode, tier, durationSec)\n}\n\n/** The rate row: credits per started source minute for a mode/tier. Never reserved. */\nexport function editPlanRateCreditId(mode: EditPlanMode, tier: EditPlanTier): string {\n return `edit-plan:${mode}:${tier}:per-minute`\n}\n\n/** The flat row: credits once per plan for a mode/tier (0 for tighten and chapters). Never reserved. */\nexport function editPlanFlatCreditId(mode: EditPlanMode, tier: EditPlanTier): string {\n return `edit-plan:${mode}:${tier}:flat`\n}\n\n/** The mode, tier and minutes of an `edit-plan:<mode>:<tier>:<N>m` id (1 ≤ N ≤\n * the maximum), or `undefined` for anything else (the bare id, a rate or flat\n * row, an unknown mode or tier). */\nexport function parseEditPlanMinutesCreditId(\n id: string,\n): { mode: EditPlanMode; tier: EditPlanTier; minutes: number } | undefined {\n const m = /^edit-plan:([a-z]+):([a-z]+):(\\d+)m$/.exec(id)\n if (!m) return undefined\n const mode = parseEditPlanMode(m[1])\n const tier = (EDIT_PLAN_TIERS as readonly string[]).includes(m[2]!) ? (m[2] as EditPlanTier) : undefined\n const minutes = Number(m[3])\n if (!mode || !tier || !Number.isInteger(minutes) || minutes < 1 || minutes > EDIT_PLAN_MAX_MINUTES) return undefined\n return { mode, tier, minutes }\n}\n\n/** flat + rate × N, rounded up, at least 1 credit — what an\n * `edit-plan:<mode>:<tier>:<N>m` id costs from its two rows (the plugin's formula). */\nexport function editPlanMinutesBaseCredits(flat: number, rate: number, minutes: number): number {\n return Math.max(1, Math.ceil(flat + rate * minutes))\n}\n\n/** Narrow an arbitrary value to a known edit-plan mode, defaulting to \"tighten\".\n * For display and estimates only: anything that DISPATCHES a plan must use\n * {@link parseEditPlanMode} and refuse an unknown mode, or that mode is planned\n * (and charged) as tighten. */\nexport function asEditPlanMode(v: unknown): EditPlanMode {\n return parseEditPlanMode(v) ?? \"tighten\"\n}\n\n/** The strict sibling of {@link asEditPlanMode}: the mode when `v` is exactly a\n * known edit-plan mode, otherwise `undefined` — never a substitute. */\nexport function parseEditPlanMode(v: unknown): EditPlanMode | undefined {\n return typeof v === \"string\" && (EDIT_PLAN_MODES as readonly string[]).includes(v) ? (v as EditPlanMode) : undefined\n}\n\n/** Narrow an arbitrary value to a known edit-plan tier, defaulting to \"standard\". */\nexport function asEditPlanTier(v: unknown): EditPlanTier {\n return v === \"economy\" || v === \"premium\" ? v : \"standard\"\n}\n\n/**\n * Unwrap an `edit-plan` job's `output_data` into the value stored on the node's\n * `data.generatedJson`, which every output extractor then reads. This is the ONE\n * place the modes are normalized (the same rule on both engines and every\n * result-application site, so audit-dag parity can't drift):\n * - `clips` → the BARE `Edl[]` (T5: the `list` fan-out reads `Array.isArray`\n * on `generatedJson`; each element becomes one JSON-stringified\n * item a downstream `edl` input `normalizeEdl`-parses).\n * - `chapters` → the `{ version, chapters }` object.\n * - `tighten` / `trailer` → the `Edl` object at top level.\n *\n * The cloud relay object-spreads `output_data` and adds `viaNodaroCloud: true`;\n * that key (and any other bookkeeping) is stripped here. The unwrap lives HERE —\n * NEVER in `output_data` — because a bare array written into `output_data` would\n * be corrupted into numeric keys by the relay's object-spread (see `EdlClipSet`).\n */\nexport function unwrapEditPlanOutput(outputData: unknown): unknown {\n if (!outputData || typeof outputData !== \"object\") return outputData\n const o = outputData as Record<string, unknown>\n // clips: EdlClipSet { version, clips: Edl[] } → the bare Edl[].\n if (Array.isArray(o.clips)) return o.clips\n // chapters: { version, chapters: [...] } → the object, minus bookkeeping.\n if (Array.isArray(o.chapters)) return { version: EDL_VERSION, chapters: o.chapters }\n // tighten / trailer: the Edl object at top level → drop the relay's viaNodaroCloud.\n const { viaNodaroCloud: _viaNodaroCloud, ...rest } = o\n return rest\n}\n"]}
1
+ {"version":3,"sources":["../src/audio-crossfade-curves.ts","../src/smart-cut-windows.ts","../src/speaker-tracks.ts","../src/speaker-map-contract.ts","../src/camera-switch-contract.ts","../src/edit-plan-contract.ts"],"names":["num"],"mappings":";;;AAkBO,IAAM,sBAAA,GAAyD;AAAA,EACpE;AAAA,IACE,EAAA,EAAI,QAAA;AAAA,IACJ,MAAA,EAAQ,KAAA;AAAA,IACR,KAAA,EAAO,QAAA;AAAA,IACP,WAAA,EAAa;AAAA,GACf;AAAA,EACA;AAAA,IACE,EAAA,EAAI,aAAA;AAAA,IACJ,MAAA,EAAQ,MAAA;AAAA,IACR,KAAA,EAAO,aAAA;AAAA,IACP,WAAA,EAAa;AAAA,GACf;AAAA,EACA;AAAA,IACE,EAAA,EAAI,QAAA;AAAA,IACJ,MAAA,EAAQ,MAAA;AAAA,IACR,KAAA,EAAO,eAAA;AAAA,IACP,WAAA,EAAa;AAAA,GACf;AAAA,EACA;AAAA,IACE,EAAA,EAAI,aAAA;AAAA,IACJ,MAAA,EAAQ,KAAA;AAAA,IACR,KAAA,EAAO,aAAA;AAAA,IACP,WAAA,EAAa;AAAA,GACf;AAAA,EACA;AAAA,IACE,EAAA,EAAI,aAAA;AAAA,IACJ,MAAA,EAAQ,KAAA;AAAA,IACR,KAAA,EAAO,aAAA;AAAA,IACP,WAAA,EAAa;AAAA;AAEjB;AAEO,IAAM,4BACX,sBAAA,CAAuB,GAAA,CAAI,CAAC,CAAA,KAAM,EAAE,EAAE;AAEjC,IAAM,gCAAA,GAAmC;AAEhD,IAAM,eAAyD,IAAI,GAAA;AAAA,EACjE,sBAAA,CAAuB,IAAI,CAAC,CAAA,KAAM,CAAC,CAAA,CAAE,EAAA,EAAI,CAAC,CAAC;AAC7C,CAAA;AAEO,SAAS,uBAAuB,EAAA,EAA6C;AAClF,EAAA,OAAO,YAAA,CAAa,IAAI,EAAE,CAAA;AAC5B;AAOO,SAAS,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CAAA,GAAI,UAAA;AAClD;AAkBO,SAAS,qBAAqB,UAAA,EAA8B;AACjE,EAAA,IAAI,CAAC,UAAA,IAAc,OAAO,UAAA,KAAe,UAAU,OAAO,UAAA;AAC1D,EAAA,MAAM,CAAA,GAAI,UAAA;AAEV,EAAA,IAAI,MAAM,OAAA,CAAQ,CAAA,CAAE,KAAK,CAAA,SAAU,CAAA,CAAE,KAAA;AAErC,EAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,CAAA,CAAE,QAAQ,CAAA,EAAG,OAAO,EAAE,OAAA,EAAS,WAAA,EAAa,QAAA,EAAU,CAAA,CAAE,QAAA,EAAS;AAEnF,EAAA,MAAM,EAAE,cAAA,EAAgB,eAAA,EAAiB,GAAG,MAAK,GAAI,CAAA;AACrD,EAAA,OAAO,IAAA;AACT","file":"chunk-WARGPM7P.js","sourcesContent":["/**\n * Curated subset of FFmpeg `acrossfade=curve=...` options for combine-videos\n * audio crossfades. We expose 5 well-understood presets out of the ~21 raw\n * curves FFmpeg supports; the rest are either visually indistinguishable to\n * non-audio-engineers or rarely useful in this context.\n *\n * Default `linear` matches today's behavior — adding this catalog is a pure\n * additive change for existing workflows.\n */\n\nexport interface AudioCrossfadeCurve {\n readonly id: string\n /** FFmpeg `acrossfade=curve=...` name. */\n readonly ffmpeg: string\n readonly label: string\n readonly description: string\n}\n\nexport const AUDIO_CROSSFADE_CURVES: readonly AudioCrossfadeCurve[] = [\n {\n id: \"linear\",\n ffmpeg: \"tri\",\n label: \"Linear\",\n description: \"Straight-line fade. Default; predictable but can dip in the middle for music.\",\n },\n {\n id: \"equal-power\",\n ffmpeg: \"qsin\",\n label: \"Equal Power\",\n description: \"Quarter-sine. Keeps perceived loudness roughly constant across the crossfade — best for music.\",\n },\n {\n id: \"smooth\",\n ffmpeg: \"hsin\",\n label: \"Smooth (Sine)\",\n description: \"Half-sine. Gentler than equal-power; good for dialogue and ambient.\",\n },\n {\n id: \"logarithmic\",\n ffmpeg: \"log\",\n label: \"Logarithmic\",\n description: \"Compensates for the ear's logarithmic loudness response. Long, slow tails.\",\n },\n {\n id: \"exponential\",\n ffmpeg: \"exp\",\n label: \"Exponential\",\n description: \"Sharp out / slow in (or vice versa). Punchy — good for impact moments.\",\n },\n]\n\nexport const AUDIO_CROSSFADE_CURVE_IDS: readonly string[] =\n AUDIO_CROSSFADE_CURVES.map((c) => c.id)\n\nexport const DEFAULT_AUDIO_CROSSFADE_CURVE_ID = \"linear\"\n\nconst CURVES_BY_ID: ReadonlyMap<string, AudioCrossfadeCurve> = new Map(\n AUDIO_CROSSFADE_CURVES.map((c) => [c.id, c]),\n)\n\nexport function getAudioCrossfadeCurve(id: string): AudioCrossfadeCurve | undefined {\n return CURVES_BY_ID.get(id)\n}\n\n/**\n * Resolve a curve id to its FFmpeg `acrossfade=curve=` name. Unknown ids fall\n * back to `tri` (linear) — this matches the route's Zod default so callers\n * downstream of validation never see undefined.\n */\nexport function resolveAudioCrossfadeCurve(id: string | undefined): string {\n if (!id) return \"tri\"\n return CURVES_BY_ID.get(id)?.ffmpeg ?? \"tri\"\n}\n","/**\n * Smart-cut SEARCH WINDOWS — the shared bound + clamp for the\n * `smartCutFramesPrev` / `smartCutFramesNext` of BOTH smart-cut nodes:\n * generate-video-pro (segment boundaries) and combine-videos (clip joins).\n *\n * They bound how much of each side of a boundary the engine considers when\n * it places the cut: N frames from the end of a segment and M from the start\n * of the next. Absent → the engine's own default, byte-identical to the\n * behavior before they were exposed. A boundary the engine cannot resolve\n * inside the window falls back to the fixed freeze-trims; recast pins 24/24.\n *\n * Why a shared clamp: the config panel, the canvas node (single-node Run) and\n * the orchestrator (workflow Run) are three independent writers/send paths into\n * the same route, whose Zod schema REJECTS out-of-range values (its `.min()` /\n * `.max()` are these very constants). Deriving all of them from this one\n * function means a stale, imported or hand-edited node value degrades to a\n * legal request instead of 400-ing an entire run — and the paths cannot drift\n * apart. An `<input type=\"number\" max={…}>` is not a substitute: the browser\n * does not stop a typed or pasted value from reaching React's onChange.\n */\n\n/** Widest window we accept anywhere — the UI's `max`, the clamp's ceiling and\n * `/v1/combine-videos`' own Zod `.max()` (the generate-video-pro engine route\n * itself accepts up to 48). Past this, added frames only cost search time and\n * invite a false match. */\nexport const SMART_CUT_WINDOW_MAX = 24\n/** Narrowest meaningful window — one frame each side. */\nexport const SMART_CUT_WINDOW_MIN = 1\n/** The engine's default when the field is absent. Documented here so the UI\n * can show it as the placeholder without hardcoding a second copy. */\nexport const SMART_CUT_WINDOW_DEFAULT = 8\n\n/**\n * Narrow an arbitrary node value to a legal window, or `undefined` to mean\n * \"let the engine use its default\". Non-numbers, NaN, and non-integers all\n * collapse to `undefined` rather than to a guessed number: a malformed value\n * should fall back to the proven default, not silently pick a different\n * search width than the user asked for.\n */\nexport function clampSmartCutWindow(value: unknown): number | undefined {\n if (typeof value !== \"number\" || !Number.isFinite(value)) return undefined\n const n = Math.round(value)\n if (n < SMART_CUT_WINDOW_MIN) return SMART_CUT_WINDOW_MIN\n if (n > SMART_CUT_WINDOW_MAX) return SMART_CUT_WINDOW_MAX\n return n\n}\n","import type { Edl, EdlSource, EdlValidation } from \"./edl.js\"\n\n/**\n * Speaker tracks — where each speaker's face is, over time, per camera.\n *\n * WHY THIS EXISTS\n * A face-tracking analysis node samples each camera an edit shows, finds the\n * faces, links them into tracks and labels each track with a speaker. Its\n * result feeds the framing rung `resolveEdlSegmentSlots` reserves for a\n * per-segment resolver (D20, edl-multicam.ts). This module is the wire shape\n * of that result plus the pure functions that read it: structural vocabulary\n * only — no detector, no linking or attribution rule, no framing or follow\n * math, no thresholds. That is why it lives in the Apache-licensed\n * `@nodaro/shared` (the public contract: the API response, the SDK type and\n * the MCP output). Every published version is an irrevocable grant, so every\n * later field is optional and additive.\n *\n * TWO SHAPES, ONE PROJECTION\n * - `SpeakerTrackSet` — the full set, boxes included. At a long multi-camera\n * edit it is megabytes of JSON, so it is stored as a JSON artifact (the\n * versioned box body), never inline in a job row or a node's data.\n * - `SpeakerTrackSetDescriptor` — what the node outputs: the same set with\n * every box removed (a `boxCount` per track instead) plus the artifact's\n * `url`, `sha256` and `bytes`. Consumers fetch the body by URL, check the\n * hash, run `normalizeSpeakerTracks` + `validateSpeakerTracks` on it, and\n * can confirm it is the body the descriptor names with\n * `describeSpeakerTracks(body, artifact)` deep-equal to the descriptor.\n *\n * CLOCK (D19)\n * Boxes are per SOURCE and on that source's own clock (`clock: \"source\"`), in\n * integer ms. A consumer maps to the master clock through the EDL source's\n * offset: `masterMs = ms + offsetMs` (`remapMsThroughEdl(edl, ms, sourceId)`).\n * Nothing here applies the offset, and nothing ever rescales a time (no\n * seconds→ms guessing — an implausible value is a validation error).\n *\n * GEOMETRY\n * Box coordinates are fractions 0..1 of `frame`: the display-oriented frame\n * (after rotation, square pixels) the producer sampled.\n *\n * SAMPLING\n * `sampledSpans` say what was looked at. No box for a track outside them means\n * \"not sampled\"; inside them it means \"no face there\". Spans are half-open\n * `[startMs, endMs)`, like EDL segments.\n */\n\nexport const SPEAKER_TRACKS_VERSION = 1 as const\n\n/** How a track got its speaker. Open: a newer producer may add a method, which\n * an older validator reports as a WARNING, never an issue. */\nexport const SPEAKER_TRACK_ATTRIBUTION_METHODS = [\"source-map\", \"region\", \"mouth-motion\", \"manual\"] as const\nexport type SpeakerTrackAttributionMethod = (typeof SPEAKER_TRACK_ATTRIBUTION_METHODS)[number]\nconst KNOWN_METHODS: ReadonlySet<string> = new Set(SPEAKER_TRACK_ATTRIBUTION_METHODS)\n\n/** Default hard cap on boxes per source. The longest edit the platform plans\n * for (180 minutes) sampled at 2 per second is 21,600 samples per source; the\n * cap leaves room for several faces in every sample. Override per call with\n * `maxBoxesPerSource`. */\nexport const SPEAKER_TRACKS_MAX_BOXES_PER_SOURCE = 100_000\n/** Default hard cap on the serialized size of a track set (UTF-8 bytes of its\n * JSON), so no consumer ever loads an unbounded body. Override per call with\n * `maxBytes`. */\nexport const SPEAKER_TRACKS_MAX_BYTES = 64 * 1024 * 1024\n\n/** One detection. `ms` on the source clock; x/y/w/h fractions 0..1 of the frame. */\nexport interface SpeakerTrackBox {\n readonly ms: number\n readonly x: number\n readonly y: number\n readonly w: number\n readonly h: number\n /** Detector confidence 0..1, when the detector reports one. */\n readonly score?: number\n}\n\nexport interface SpeakerTrackAttribution {\n /** Known: `SPEAKER_TRACK_ATTRIBUTION_METHODS`. */\n readonly method: SpeakerTrackAttributionMethod | (string & {})\n /** 0..1. */\n readonly confidence: number\n /** The transcript's own label for this speaker, kept beside the display name\n * in `speaker` so a later rename re-maps instead of orphaning the track. */\n readonly rawSpeaker?: string\n}\n\n/** What a track says about itself, without its boxes. */\nexport interface SpeakerTrackHeader {\n /** Unique in the whole set, e.g. \"wide/t3\". */\n readonly id: string\n /** A label in the edit's speaker space. Absent = unattributed. */\n readonly speaker?: string\n readonly attribution?: SpeakerTrackAttribution\n}\n\nexport interface SpeakerTrack extends SpeakerTrackHeader {\n /** Strictly increasing `ms`, each inside one of the source's `sampledSpans`. */\n readonly boxes: readonly SpeakerTrackBox[]\n}\n\nexport interface SpeakerTrackSummary extends SpeakerTrackHeader {\n readonly boxCount: number\n}\n\nexport interface SpeakerTrackSpan {\n readonly startMs: number\n /** Exclusive, > startMs. */\n readonly endMs: number\n}\n\ninterface SpeakerTrackSourceFields {\n /** `EdlSource.id` of a video source. */\n readonly sourceId: string\n /** Boxes, spans and cuts are ms on this SOURCE's own clock (D19). */\n readonly clock: \"source\"\n /** The display-oriented frame (after rotation, square pixels), in pixels, that box fractions refer to. */\n readonly frame: { readonly w: number; readonly h: number }\n /** What was sampled: sorted, non-overlapping, half-open. */\n readonly sampledSpans: readonly SpeakerTrackSpan[]\n /** Source-clock ms of detected scene changes, ascending. No track spans one. */\n readonly cuts?: readonly number[]\n}\n\nexport interface SpeakerTrackSource extends SpeakerTrackSourceFields {\n readonly tracks: readonly SpeakerTrack[]\n}\n\nexport interface SpeakerTrackSourceSummary extends SpeakerTrackSourceFields {\n readonly tracks: readonly SpeakerTrackSummary[]\n}\n\ninterface SpeakerTrackSetFields {\n readonly version: 1\n /** Samples per second the producer looked at. */\n readonly sampleFps: number\n /** Informational: which detector produced the boxes, e.g. \"example:face-detector\". */\n readonly detector: { readonly id: string; readonly version?: string }\n}\n\n/** The full set — the versioned box body, stored as a JSON artifact. */\nexport interface SpeakerTrackSet extends SpeakerTrackSetFields {\n readonly sources: readonly SpeakerTrackSource[]\n}\n\n/** What the analysis node outputs: the set without its boxes, plus where the body is. */\nexport interface SpeakerTrackSetDescriptor extends SpeakerTrackSetFields {\n readonly sources: readonly SpeakerTrackSourceSummary[]\n /** Where the `SpeakerTrackSet` body is stored. */\n readonly url: string\n /** SHA-256 of the stored body's bytes, 64 lowercase hex characters. */\n readonly sha256: string\n /** Size of the stored body in bytes. */\n readonly bytes: number\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// Normalization (coerce, never reject — and never reinterpret)\n// ─────────────────────────────────────────────────────────────────────────\n\nconst isObj = (v: unknown): v is Record<string, unknown> => !!v && typeof v === \"object\" && !Array.isArray(v)\nconst isNum = (v: unknown): v is number => typeof v === \"number\" && Number.isFinite(v)\nconst num = (v: unknown, fallback = 0): number => (isNum(v) ? v : fallback)\nconst str = (v: unknown): string | undefined => (typeof v === \"string\" ? v : undefined)\nconst clamp01 = (v: number): number => Math.min(1, Math.max(0, v))\n/** A readonly array field of a value that may have skipped normalization. */\nconst arr = <T,>(v: readonly T[] | undefined): readonly T[] => (Array.isArray(v) ? v : [])\n/** Integer ms; never -0 (JSON cannot carry it, so a round trip would differ). */\nconst int = (v: number): number => {\n const r = Math.round(v)\n return r === 0 ? 0 : r\n}\n\n/** One axis of a detection, cropped to the frame: the visible part of\n * `[p, p+s]` within `[0, 1]`, or undefined when none of it is visible. An\n * in-frame axis is returned untouched (so a second pass cannot drift by a\n * float ulp); an overhanging one becomes the intersection, whichever edge it\n * crosses, so its centre only ever moves toward the visible part. */\nfunction cropAxis(p: number, s: number): readonly [number, number] | undefined {\n if (!(s > 0)) return undefined\n if (p >= 0 && p + s <= 1) return [p, s]\n const lo = clamp01(p)\n const hi = clamp01(p + s)\n return hi > lo ? [lo, hi - lo] : undefined\n}\n\nfunction normalizeBox(raw: unknown): SpeakerTrackBox | undefined {\n if (!isObj(raw)) return undefined\n if (![raw.ms, raw.x, raw.y, raw.w, raw.h].every(isNum)) return undefined\n // A detection is cropped to the frame, never moved: a face at the frame edge\n // keeps only its visible part, and one entirely off-frame is dropped. This is\n // deliberately NOT `normalizeRegion`'s clamp-then-shrink (edl.ts), which is\n // fine for a region a user draws but would shift a left/top overhang and turn\n // an off-frame detection into an in-frame face.\n const xs = cropAxis(raw.x as number, raw.w as number)\n const ys = cropAxis(raw.y as number, raw.h as number)\n if (!xs || !ys) return undefined\n const [x, w] = xs\n const [y, h] = ys\n return { ms: int(raw.ms as number), x, y, w, h, ...(isNum(raw.score) ? { score: clamp01(raw.score) } : {}) }\n}\n\nfunction normalizeSpans(raw: unknown): SpeakerTrackSpan[] {\n if (!Array.isArray(raw)) return []\n const spans = raw\n .filter(isObj)\n .filter((s) => isNum(s.startMs) && isNum(s.endMs))\n .map((s) => ({ startMs: int(s.startMs as number), endMs: int(s.endMs as number) }))\n .filter((s) => s.endMs > s.startMs)\n .sort((a, b) => a.startMs - b.startMs || a.endMs - b.endMs)\n const merged: SpeakerTrackSpan[] = []\n for (const s of spans) {\n const last = merged[merged.length - 1]\n if (last && s.startMs <= last.endMs) merged[merged.length - 1] = { startMs: last.startMs, endMs: Math.max(last.endMs, s.endMs) }\n else merged.push(s)\n }\n return merged\n}\n\nfunction normalizeCuts(raw: unknown): number[] {\n if (!Array.isArray(raw)) return []\n const sorted = raw.filter(isNum).map(int).sort((a, b) => a - b)\n return sorted.filter((c, i) => i === 0 || c !== sorted[i - 1])\n}\n\nfunction normalizeAttribution(raw: unknown): SpeakerTrackAttribution | undefined {\n if (!isObj(raw)) return undefined\n const method = str(raw.method)\n if (!method) return undefined\n const rawSpeaker = str(raw.rawSpeaker)\n return { method, confidence: clamp01(num(raw.confidence)), ...(rawSpeaker ? { rawSpeaker } : {}) }\n}\n\nfunction normalizeHeader(raw: Record<string, unknown>, fallbackId: string): SpeakerTrackHeader {\n const speaker = str(raw.speaker)\n const attribution = normalizeAttribution(raw.attribution)\n return {\n id: str(raw.id) || fallbackId,\n ...(speaker ? { speaker } : {}),\n ...(attribution ? { attribution } : {}),\n }\n}\n\nfunction normalizeSetFields(o: Record<string, unknown>): SpeakerTrackSetFields {\n const detector = isObj(o.detector) ? o.detector : {}\n const detectorVersion = str(detector.version)\n return {\n // Only an ABSENT version defaults to 1. Any present value — another\n // number, \"2\", null — is kept as is so validate refuses it rather than\n // reading a newer (or broken) body as this one.\n version: (o.version === undefined ? SPEAKER_TRACKS_VERSION : o.version) as 1,\n sampleFps: num(o.sampleFps),\n detector: { id: str(detector.id) ?? \"\", ...(detectorVersion ? { version: detectorVersion } : {}) },\n }\n}\n\nfunction normalizeSources<T>(\n raw: unknown,\n track: (t: Record<string, unknown>, fallbackId: string) => T,\n): Array<SpeakerTrackSourceFields & { readonly tracks: readonly T[] }> {\n if (!Array.isArray(raw)) return []\n return raw.map((r) => {\n const s = isObj(r) ? r : {}\n const sourceId = str(s.sourceId) ?? \"\"\n const frame = isObj(s.frame) ? s.frame : {}\n const cuts = normalizeCuts(s.cuts)\n const tracks = Array.isArray(s.tracks) ? s.tracks.map((t, k) => track(isObj(t) ? t : {}, `${sourceId}/t${k + 1}`)) : []\n return {\n sourceId,\n // A clock other than \"source\" cannot be repaired: boxes on another clock\n // would land offsetMs away from their frame. Keep it for validate to refuse.\n clock: (typeof s.clock === \"string\" ? s.clock : \"source\") as \"source\",\n frame: { w: int(num(frame.w)), h: int(num(frame.h)) },\n sampledSpans: normalizeSpans(s.sampledSpans),\n tracks,\n ...(cuts.length > 0 ? { cuts } : {}),\n }\n })\n}\n\n/**\n * Coerce an unknown value into a well-formed `SpeakerTrackSet` (the box body):\n * drop unknown keys and malformed boxes, crop every box to the frame (an\n * entirely off-frame box is dropped, an overhang keeps its visible part), clamp\n * scores and confidences to 0..1, round every time to integer ms, sort each\n * track's boxes by time (box order IS time, unlike EDL segment order), sort and\n * merge sampled spans, sort and de-duplicate cuts.\n *\n * It never repairs what would change meaning: a box outside every sampled\n * span, two boxes at one instant, a track across a cut, another version or\n * another clock all survive for `validateSpeakerTracks` to report.\n */\nexport function normalizeSpeakerTracks(input: unknown): SpeakerTrackSet {\n const o = isObj(input) ? input : {}\n return {\n ...normalizeSetFields(o),\n sources: normalizeSources(o.sources, (t, fallbackId) => {\n const boxes = Array.isArray(t.boxes) ? t.boxes.map(normalizeBox).filter((b): b is SpeakerTrackBox => b !== undefined) : []\n return { ...normalizeHeader(t, fallbackId), boxes: [...boxes].sort((a, b) => a.ms - b.ms) }\n }),\n }\n}\n\n/** Coerce an unknown value into a `SpeakerTrackSetDescriptor`, by the same rules\n * as `normalizeSpeakerTracks`; a missing or broken `boxCount` becomes 0. */\nexport function normalizeSpeakerTrackSetDescriptor(input: unknown): SpeakerTrackSetDescriptor {\n const o = isObj(input) ? input : {}\n return {\n ...normalizeSetFields(o),\n sources: normalizeSources(o.sources, (t, fallbackId) => ({\n ...normalizeHeader(t, fallbackId),\n boxCount: Math.max(0, int(num(t.boxCount))),\n })),\n url: str(o.url) ?? \"\",\n sha256: str(o.sha256) ?? \"\",\n bytes: int(num(o.bytes)),\n }\n}\n\n/** The descriptor of a (normalized) set stored at `artifact.url`: every box\n * removed, a `boxCount` per track. Pure; the caller hashes and stores the body. */\nexport function describeSpeakerTracks(\n set: SpeakerTrackSet,\n artifact: { readonly url: string; readonly sha256: string; readonly bytes: number },\n): SpeakerTrackSetDescriptor {\n return {\n version: set.version,\n sampleFps: set.sampleFps,\n detector: { ...set.detector },\n sources: set.sources.map((s) => ({\n sourceId: s.sourceId,\n clock: s.clock,\n frame: { ...s.frame },\n sampledSpans: s.sampledSpans.map((sp) => ({ ...sp })),\n tracks: s.tracks.map((t) => ({\n id: t.id,\n ...(t.speaker !== undefined ? { speaker: t.speaker } : {}),\n ...(t.attribution ? { attribution: { ...t.attribution } } : {}),\n boxCount: t.boxes.length,\n })),\n ...(s.cuts && s.cuts.length > 0 ? { cuts: [...s.cuts] } : {}),\n })),\n url: artifact.url,\n sha256: artifact.sha256,\n bytes: artifact.bytes,\n }\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// The edit's speaker space\n// ─────────────────────────────────────────────────────────────────────────\n\n/** The speaker labels an edit uses: the union of `sources[].speakers`,\n * `segments[].speaker` and `segments[].layout.slots[].speaker`, over every EDL\n * given (a clip pack), sorted by code unit. Tracks must be labelled in this\n * space, or no track ever matches a segment's speaker. */\nexport function edlSpeakerSpace(edl: Edl | readonly Edl[]): string[] {\n const out = new Set<string>()\n const add = (v: unknown) => {\n if (typeof v === \"string\" && v) out.add(v)\n }\n for (const e of edlList(edl)) {\n for (const s of Array.isArray(e.sources) ? e.sources : []) {\n for (const sp of Array.isArray(s?.speakers) ? s.speakers : []) add(sp)\n }\n for (const seg of Array.isArray(e.segments) ? e.segments : []) {\n add(seg?.speaker)\n for (const slot of Array.isArray(seg?.layout?.slots) ? seg.layout!.slots! : []) add(slot?.speaker)\n }\n }\n return [...out].sort()\n}\n\nfunction edlList(edl: Edl | readonly Edl[] | undefined): readonly Edl[] {\n if (!edl) return []\n const all: readonly unknown[] = Array.isArray(edl) ? edl : [edl]\n return all.filter((e): e is Edl => isObj(e))\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// Validation\n// ─────────────────────────────────────────────────────────────────────────\n\nexport interface SpeakerTracksValidateOptions {\n /** The edit the tracks are for — one EDL, or every clip of a pack. When given,\n * every source must resolve to one of its video sources, and attributed\n * speakers must be in its speaker space (`edlSpeakerSpace`). */\n readonly edl?: Edl | readonly Edl[]\n /** Default `SPEAKER_TRACKS_MAX_BOXES_PER_SOURCE`. */\n readonly maxBoxesPerSource?: number\n /** Default `SPEAKER_TRACKS_MAX_BYTES`. */\n readonly maxBytes?: number\n /** `validateSpeakerTracks` only: the body's known size in bytes (e.g. the\n * fetched length), so a large body is not serialized again to measure it. */\n readonly serializedBytes?: number\n}\n\nconst SHA256_HEX = /^[0-9a-f]{64}$/\n\ntype Findings = { issues: string[]; warnings: string[] }\n\n/** The rules shared by the body and the descriptor. `perTrack` adds the body's\n * box rules and returns the track's box count. */\nfunction validateCommon<T extends SpeakerTrackHeader>(\n set: SpeakerTrackSetFields & { readonly sources: ReadonlyArray<SpeakerTrackSourceFields & { readonly tracks: readonly T[] }> },\n opts: SpeakerTracksValidateOptions,\n perTrack: (track: T, source: SpeakerTrackSourceFields, f: Findings) => number,\n): Findings {\n const f: Findings = { issues: [], warnings: [] }\n const { issues, warnings } = f\n const sources = arr(set.sources)\n const maxBoxes = opts.maxBoxesPerSource ?? SPEAKER_TRACKS_MAX_BOXES_PER_SOURCE\n\n if (set.version !== SPEAKER_TRACKS_VERSION) issues.push(`version must be ${SPEAKER_TRACKS_VERSION}`)\n if (!(isNum(set.sampleFps) && set.sampleFps > 0)) issues.push(\"sampleFps must be a finite number > 0\")\n\n const edls = edlList(opts.edl)\n const edlSources = new Map<string, EdlSource>()\n for (const e of edls) {\n for (const s of Array.isArray(e.sources) ? e.sources : []) {\n if (s && typeof s.id === \"string\" && !edlSources.has(s.id)) edlSources.set(s.id, s)\n }\n }\n\n const sourceIds = new Set<string>()\n const trackIds = new Set<string>()\n sources.forEach((s, i) => {\n const sid = s.sourceId\n const at = `source \"${sid}\"`\n if (!sid) issues.push(`source[${i}]: sourceId is empty`)\n else if (sourceIds.has(sid)) issues.push(`duplicate source id \"${sid}\"`)\n sourceIds.add(sid)\n if (sid && edls.length > 0) {\n const es = edlSources.get(sid)\n if (!es) issues.push(`${at}: not a source of the EDL`)\n else if (es.kind !== \"video\") issues.push(`${at}: the EDL source is kind:\"${es.kind}\", tracks need a video source`)\n }\n if (s.clock !== \"source\") issues.push(`${at}: clock must be \"source\"`)\n if (!(isObj(s.frame) && isNum(s.frame.w) && isNum(s.frame.h) && s.frame.w > 0 && s.frame.h > 0)) {\n issues.push(`${at}: frame w/h must be positive`)\n }\n\n const spans = arr<SpeakerTrackSpan>(s.sampledSpans)\n spans.forEach((sp, j) => {\n const startMs: unknown = sp?.startMs\n const endMs: unknown = sp?.endMs\n if (!(isNum(startMs) && isNum(endMs) && endMs > startMs)) {\n issues.push(`${at}: sampledSpans[${j}] [${startMs},${endMs}) is not positive`)\n return\n }\n if (!(Number.isInteger(startMs) && Number.isInteger(endMs))) issues.push(`${at}: sampledSpans[${j}] [${startMs},${endMs}) is not integer ms`)\n if (startMs < 0) issues.push(`${at}: sampledSpans[${j}] starts before 0`)\n const prevEnd: unknown = spans[j - 1]?.endMs\n if (j > 0 && isNum(prevEnd) && startMs < prevEnd) {\n issues.push(`${at}: sampledSpans must be sorted and non-overlapping (span ${j})`)\n }\n })\n\n const cuts = s.cuts\n if (cuts !== undefined) {\n const okCuts = Array.isArray(cuts) && cuts.every((c, k) => Number.isInteger(c) && c >= 0 && (k === 0 || c > cuts[k - 1]))\n if (!okCuts) issues.push(`${at}: cuts must be ascending non-negative ms`)\n }\n\n let boxes = 0\n const tracks = arr<T>(s.tracks)\n tracks.forEach((t, k) => {\n if (!t?.id) issues.push(`${at} track[${k}]: id is empty`)\n else if (trackIds.has(t.id)) issues.push(`duplicate track id \"${t.id}\"`)\n if (t?.id) trackIds.add(t.id)\n const a = t?.attribution\n if (a) {\n if (!(isNum(a.confidence) && a.confidence >= 0 && a.confidence <= 1)) {\n issues.push(`track \"${t.id}\": attribution.confidence=${a.confidence} out of 0..1`)\n }\n if (!KNOWN_METHODS.has(a.method)) {\n warnings.push(`track \"${t.id}\": unknown attribution method \"${a.method}\" (known: ${SPEAKER_TRACK_ATTRIBUTION_METHODS.join(\", \")})`)\n }\n }\n boxes += perTrack(t, s, f)\n })\n if (boxes > maxBoxes) issues.push(`${at}: ${boxes} boxes is over the cap of ${maxBoxes}`)\n })\n\n // The speaker name space: labels from the raw transcript against an edit\n // that uses display names (or the reverse) match nothing, and every slot\n // would silently fall back to static framing.\n if (edls.length > 0) {\n const space = edlSpeakerSpace(edls)\n const attributed = sources.flatMap((s) => (Array.isArray(s.tracks) ? s.tracks : [])).filter((t) => !!t?.speaker)\n if (space.length > 0 && attributed.length > 0) {\n const inSpace = new Set(space)\n const matches = (t: T) => inSpace.has(t.speaker!) || (!!t.attribution?.rawSpeaker && inSpace.has(t.attribution.rawSpeaker))\n if (!attributed.some(matches)) {\n const labels = [...new Set(attributed.map((t) => t.speaker!))].sort()\n issues.push(\n `no tracked speaker is in the edit's speaker set: the tracks are labelled ${labels.map((l) => `\"${l}\"`).join(\", \")}` +\n ` and the edit uses ${space.map((l) => `\"${l}\"`).join(\", \")} — wire Speaker Frames to the same transcript as Camera Switch`,\n )\n } else {\n for (const t of attributed) {\n if (!matches(t)) warnings.push(`track \"${t.id}\": speaker \"${t.speaker}\" is not in the edit's speaker set`)\n }\n }\n }\n }\n return f\n}\n\n/** Per-box findings listed per track and rule before the rest are summarized\n * in one line, and the most issues a validation lists before one truncation\n * line. A systematic producer bug (a clock off by `offsetMs`, say) puts EVERY\n * box out of span; the refusal must stay readable wherever it is shown. */\nconst BOX_FINDINGS_PER_RULE = 5\nconst MAX_LISTED_FINDINGS = 100\n\n/** A per-box finding: the rule (what the per-track summary line counts, as\n * \"N more boxes <rule>\") and the message for one box. */\ntype BoxFinding = readonly [rule: string, message: string]\n\nfunction boxIssues(b: SpeakerTrackBox, at: string): BoxFinding[] {\n const out: BoxFinding[] = []\n for (const k of [\"x\", \"y\", \"w\", \"h\"] as const) {\n const v = b?.[k]\n if (!isNum(v) || v < 0 || v > 1) out.push([`with ${k} out of 0..1`, `${at}: ${k}=${v} out of 0..1`])\n }\n if (out.length > 0) return out\n // The same edge tolerance as validateEdl's regions, so the two never disagree.\n if (b.w <= 0 || b.h <= 0) out.push([\"with a non-positive w/h\", `${at}: non-positive w/h`])\n if (b.x + b.w > 1 + 1e-9) out.push([\"extending past the right edge\", `${at}: extends past the right edge (x+w>1)`])\n if (b.y + b.h > 1 + 1e-9) out.push([\"extending past the bottom edge\", `${at}: extends past the bottom edge (y+h>1)`])\n if (b.score !== undefined && !(isNum(b.score) && b.score >= 0 && b.score <= 1)) out.push([\"with a score out of 0..1\", `${at}: score=${b.score} out of 0..1`])\n return out\n}\n\n/** Cap a findings list at `MAX_LISTED_FINDINGS`, ending in one line that counts\n * the rest. Never empties a non-empty list, so `ok` is unchanged. */\nfunction capListed(list: readonly string[], noun: \"issues\" | \"warnings\"): string[] {\n if (list.length <= MAX_LISTED_FINDINGS) return [...list]\n return [...list.slice(0, MAX_LISTED_FINDINGS), `${list.length - MAX_LISTED_FINDINGS} more ${noun} not listed`]\n}\n\n/** Is `ms` inside one of `spans` (sorted, half-open)? Binary search. */\nfunction inSpans(spans: readonly SpeakerTrackSpan[], ms: number): boolean {\n let lo = 0\n let hi = spans.length - 1\n while (lo <= hi) {\n const mid = (lo + hi) >> 1\n const sp = spans[mid]\n if (ms < sp.startMs) hi = mid - 1\n else if (ms >= sp.endMs) lo = mid + 1\n else return true\n }\n return false\n}\n\n/**\n * Structural validation of a track set (the box body). Normalization is\n * `normalizeSpeakerTracks`'s job; this reports what is still wrong after it.\n * Issues are facts intrinsic to the set (or to the set against the EDL);\n * warnings are judgements an older validator must not turn into a refusal\n * (an unknown attribution method, one stray speaker label).\n *\n * Rules: version; a positive sample rate; unique source ids that resolve to\n * the EDL's video sources; the source clock; a positive frame; sorted,\n * non-overlapping, positive, integer-ms spans; ascending integer cuts; unique\n * track ids; every box in-frame, at an integer ms, strictly after the previous\n * one and inside a sampled span; no track across a cut; the speaker name\n * space; the box and byte caps.\n *\n * The listing is bounded: per track, the first few boxes breaking each rule\n * are listed and the rest counted in one line; past a fixed total, one line\n * counts the issues (or warnings) not listed. `ok` counts every finding.\n */\nexport function validateSpeakerTracks(set: SpeakerTrackSet, opts: SpeakerTracksValidateOptions = {}): EdlValidation {\n const safe = isObj(set) ? set : ({} as SpeakerTrackSet)\n const f = validateCommon(safe, opts, (t, source, { issues }) => {\n const boxes = Array.isArray(t?.boxes) ? t.boxes : []\n const spans = Array.isArray(source.sampledSpans) ? source.sampledSpans : []\n let first = Infinity\n let last = -Infinity\n // The first few findings of each rule are listed; the rest are counted.\n const seen = new Map<string, number>()\n const report = ([rule, message]: BoxFinding) => {\n const n = (seen.get(rule) ?? 0) + 1\n seen.set(rule, n)\n if (n <= BOX_FINDINGS_PER_RULE) issues.push(message)\n }\n const outside = `outside every sampled span of source \"${source.sourceId}\"`\n boxes.forEach((b, j) => {\n const at = `track \"${t.id}\" box[${j}]`\n boxIssues(b, at).forEach(report)\n if (!isNum(b?.ms)) {\n report([\"whose ms is not a number\", `${at}: ms is not a number`])\n return\n }\n if (!Number.isInteger(b.ms)) report([\"whose ms is not an integer\", `${at}: ms ${b.ms} is not an integer`])\n const prev = boxes[j - 1]?.ms\n if (j > 0 && isNum(prev) && !(b.ms > prev)) report([\"not after the previous box\", `${at}: ms ${b.ms} is not after the previous box (${prev})`])\n if (!inSpans(spans, b.ms)) report([outside, `${at}: ms ${b.ms} is ${outside}`])\n first = Math.min(first, b.ms)\n last = Math.max(last, b.ms)\n })\n for (const [rule, n] of seen) {\n if (n > BOX_FINDINGS_PER_RULE) issues.push(`track \"${t.id}\": ${n - BOX_FINDINGS_PER_RULE} more boxes ${rule}`)\n }\n const cut = (Array.isArray(source.cuts) ? source.cuts : []).find((c) => first < c && c <= last)\n if (cut !== undefined) issues.push(`track \"${t.id}\": spans the cut at ${cut} ms (boxes ${first}..${last})`)\n return boxes.length\n })\n const maxBytes = opts.maxBytes ?? SPEAKER_TRACKS_MAX_BYTES\n const bytes = opts.serializedBytes ?? new TextEncoder().encode(JSON.stringify(safe)).length\n if (bytes > maxBytes) f.issues.push(`the track set is ${bytes} bytes, over the cap of ${maxBytes}`)\n return { ok: f.issues.length === 0, issues: capListed(f.issues, \"issues\"), warnings: capListed(f.warnings, \"warnings\") }\n}\n\n/**\n * Structural validation of a descriptor (the node's output): the same rules as\n * `validateSpeakerTracks` minus the per-box ones (it has no boxes; `boxCount`\n * feeds the per-source cap), plus a non-empty `url`, a well-formed `sha256`\n * and a positive `bytes` within the byte cap.\n */\nexport function validateSpeakerTrackSetDescriptor(\n d: SpeakerTrackSetDescriptor,\n opts: Omit<SpeakerTracksValidateOptions, \"serializedBytes\"> = {},\n): EdlValidation {\n const safe = isObj(d) ? d : ({} as SpeakerTrackSetDescriptor)\n const f = validateCommon(safe, opts, (t, _source, { issues }) => {\n if (!(Number.isInteger(t?.boxCount) && t.boxCount >= 0)) {\n issues.push(`track \"${t?.id}\": boxCount must be a non-negative integer`)\n return 0\n }\n return t.boxCount\n })\n if (!(typeof safe.url === \"string\" && safe.url.trim())) f.issues.push(\"url is empty\")\n if (!(typeof safe.sha256 === \"string\" && SHA256_HEX.test(safe.sha256))) f.issues.push(\"sha256 must be 64 lowercase hex characters\")\n const maxBytes = opts.maxBytes ?? SPEAKER_TRACKS_MAX_BYTES\n if (!(Number.isInteger(safe.bytes) && safe.bytes > 0)) f.issues.push(\"bytes must be a positive integer\")\n else if (safe.bytes > maxBytes) f.issues.push(`the track set is ${safe.bytes} bytes, over the cap of ${maxBytes}`)\n return { ok: f.issues.length === 0, issues: capListed(f.issues, \"issues\"), warnings: capListed(f.warnings, \"warnings\") }\n}\n","/**\n * speaker-map (podcast use-case nodes, decided 2026-10-12/17) — which camera\n * each speaker is on, worked out from the cameras' own microphones: the\n * structural pieces every caller shares (the canvas engines, MCP, the SDK).\n * HOW the levels are compared is the server's. Pure, no I/O.\n */\nimport type { Edl } from \"./edl.js\"\n\nexport const SPEAKER_MAP_VERSION = 1 as const\n/** Recordings one run reads (cameras, plus the master when it also emits the edit). */\nexport const SPEAKER_MAP_MAX_SOURCES = 6\n/** Candidate cameras a comparison needs. */\nexport const SPEAKER_MAP_MIN_CAMERAS = 2\n/** How far the loudest camera must beat the next for the speaker to get it. */\nexport const SPEAKER_MAP_DEFAULT_MARGIN_DB = 3\n\nexport interface SpeakerMapConfidence {\n /** The camera the speaker got; \"\" = none clear (shown on the wide shot). */\n readonly camera: string\n /** The loudest camera's lead over the next, in dB; null when there was nothing to compare. */\n readonly marginDb: number | null\n}\n\nexport interface SpeakerMapResult {\n readonly version: typeof SPEAKER_MAP_VERSION\n /** Transcript speaker label → camera source id; \"\" = no camera of their own. Feeds Camera Switch's `speakerMap`. */\n readonly speakerMap: Readonly<Record<string, string>>\n readonly confidence: Readonly<Record<string, SpeakerMapConfidence>>\n readonly notes: readonly string[]\n /** The recordings as one edit on the master clock (offsets applied, roles and speakers set, one segment). */\n readonly edl?: Edl\n}\n\nconst parse = (raw: unknown): unknown => {\n if (typeof raw !== \"string\") return raw\n try { return JSON.parse(raw) } catch { return undefined }\n}\nconst isRecord = (v: unknown): v is Record<string, unknown> => !!v && typeof v === \"object\" && !Array.isArray(v)\n\nconst isConfidence = (v: unknown): boolean =>\n isRecord(v) && typeof v.camera === \"string\" && (v.marginDb === null || (typeof v.marginDb === \"number\" && Number.isFinite(v.marginDb)))\n\n/** A Speaker Map result (an object or its JSON string), or null when it is not\n * one: every map value and confidence camera a string, every margin a finite\n * number or null, every note a string — so a reader can trust each field. */\nexport function speakerMapResultOf(raw: unknown): SpeakerMapResult | null {\n const v = parse(raw)\n if (!isRecord(v) || v.version !== SPEAKER_MAP_VERSION || !isRecord(v.speakerMap) || !isRecord(v.confidence) || !Array.isArray(v.notes)) return null\n if (!Object.values(v.speakerMap).every((c) => typeof c === \"string\")) return null\n if (!Object.values(v.confidence).every(isConfidence)) return null\n if (!v.notes.every((n) => typeof n === \"string\")) return null\n return v as unknown as SpeakerMapResult\n}\n\n/** An ordinal key: a whole number from 1, written plainly (\"1\", \"12\" — never \" 1\", \"01\", \"1.0\", \"1e0\"). */\nconst ORDINAL = /^[1-9]\\d*$/\n\n/**\n * The override keyed by ordinal (\"1\" = the first voice heard) as a map keyed\n * by the transcript's own labels. `labels` is the transcript's speakers in\n * first-heard order — the caller passes `transcriptSpeakerLabels(transcript)`,\n * so this module imports nothing from camera-switch-contract (one import\n * direction: camera-switch-contract → speaker-map-contract, no cycle for the\n * structure ratchet). An ordinal past the transcript's speakers maps nobody,\n * and so do a key that is not a plain ordinal and an override that is not an\n * object (a hand-written workflow).\n */\nexport function speakerMapByOrdinal(labels: readonly string[], byOrder: Readonly<Record<string, string>> | undefined): Record<string, string> {\n if (!isRecord(byOrder)) return {}\n const out: Record<string, string> = {}\n for (const [ordinal, camera] of Object.entries(byOrder)) {\n if (!ORDINAL.test(ordinal)) continue\n const label = labels[Number(ordinal) - 1]\n if (label !== undefined && typeof camera === \"string\") out[label] = camera\n }\n return out\n}\n","/**\n * camera-switch (podcast B5, decided 2026-10-03) — the structural pieces every\n * caller shares: the canvas engines, the editor, MCP and the SDK. WHO is on\n * screen is decided by the Cloud plugin; these only read the inputs it needs\n * and pre-fill the speaker table. Pure, no I/O.\n */\nimport { normalizeTranscript } from \"./edl.js\"\nimport { speakerMapByOrdinal, speakerMapResultOf } from \"./speaker-map-contract.js\"\n\n/** The settings and their decided defaults (the plugin holds its own copy, D13). */\nexport const CAMERA_SWITCH_DEFAULTS = Object.freeze({\n /** The shortest shot; a shorter turn (an interjection) holds the shot. */\n minShotMs: 2_500,\n /** Cut this long before the new speaker starts. */\n leadMs: 200,\n /** Delay each cut by this long — `leadMs`'s counterpart. A route setting\n * only: no node carries it (`CAMERA_SWITCH_NODE_SETTINGS`). */\n lagMs: 0,\n /** With a `wide` camera: break to it after this long on one camera. */\n maxShotMs: 20_000,\n /** With a `wide` camera: every N-th cut goes to the wide (0 = off). */\n wideEvery: 0,\n /** Overlapping speech → a side-by-side / stacked layout hint. */\n layoutHints: false,\n})\n\n/** The flat credit id and price (decided 2026-10-03). */\nexport const CAMERA_SWITCH_CREDIT_ID = \"camera-switch\"\n\nconst parseMaybe = (raw: unknown): unknown => {\n if (typeof raw !== \"string\") return raw\n try { return JSON.parse(raw) } catch { return undefined }\n}\n\n/** Distinct speaker labels of a transcript (an object or its JSON string), in\n * order of first appearance in time. Read through `normalizeTranscript`\n * (decided 2026-10-08) — the Cloud plugin's reading — so a broken word (no\n * usable time) names no speaker here either; a zero-width word is a point\n * and does. Empty → camera-switch refuses before charging. */\nexport function transcriptSpeakerLabels(transcript: unknown): string[] {\n const parsed = parseMaybe(transcript)\n if (!parsed || typeof parsed !== \"object\") return []\n const seen = new Set<string>()\n for (const w of normalizeTranscript(parsed).words) {\n if (w.speaker && !seen.has(w.speaker)) seen.add(w.speaker)\n }\n return [...seen]\n}\n\n/** The cameras a speaker can be given: an EDL's video sources in order,\n * without the `wide` / `screen` angles (those are not anyone's close-up). */\nexport function cameraSwitchCameras(edl: unknown): Array<{ id: string; role?: string }> {\n const sources = (parseMaybe(edl) as { sources?: unknown } | null | undefined)?.sources\n if (!Array.isArray(sources)) return []\n return sources\n .filter((s): s is { id: string; kind?: string; role?: string } => !!s && typeof (s as { id?: unknown }).id === \"string\")\n .filter((s) => s.kind !== \"audio\" && s.role !== \"wide\" && s.role !== \"screen\" && s.role !== \"master-audio\")\n .map((s) => ({ id: s.id, ...(s.role ? { role: s.role } : {}) }))\n}\n\n/** The settings' accepted ranges — exactly the Cloud route's (it answers 400\n * outside them), so every caller clamps to the same numbers before sending. */\nexport const CAMERA_SWITCH_BOUNDS = Object.freeze({\n minShotMs: Object.freeze({ min: 500, max: 60_000 }),\n leadMs: Object.freeze({ min: 0, max: 5_000 }),\n lagMs: Object.freeze({ min: 0, max: 5_000 }),\n maxShotMs: Object.freeze({ min: 0, max: 600_000 }),\n wideEvery: Object.freeze({ min: 0, max: 20 }),\n})\n\n/** The longest display name a speaker can be given. */\nexport const CAMERA_SWITCH_NAME_MAX = 80\n\nexport type CameraSwitchNumericSetting = keyof typeof CAMERA_SWITCH_BOUNDS\n\n/**\n * The numeric settings a Camera Switch NODE carries (its data, which the\n * canvas and the server's executor send through `cameraSwitchSettingsPayload`).\n * `lagMs` is a setting of the route alone — the API, the SDK and the CLI send\n * it; no node does — so it is not one of them.\n */\nexport const CAMERA_SWITCH_NODE_SETTINGS = Object.freeze([\"minShotMs\", \"leadMs\", \"maxShotMs\", \"wideEvery\"] as const satisfies readonly CameraSwitchNumericSetting[])\n\n/** A setting as a whole number inside its range; undefined when unset. */\nexport function clampCameraSwitchSetting(key: CameraSwitchNumericSetting, value: unknown): number | undefined {\n if (typeof value !== \"number\" || !Number.isFinite(value)) return undefined\n const { min, max } = CAMERA_SWITCH_BOUNDS[key]\n return Math.min(max, Math.max(min, Math.round(value)))\n}\n\n/** Display names trimmed, empty ones dropped, each cut to\n * `CAMERA_SWITCH_NAME_MAX` characters. */\nexport function cleanSpeakerNames(raw: unknown): Record<string, string> {\n if (!raw || typeof raw !== \"object\" || Array.isArray(raw)) return {}\n const out: Record<string, string> = {}\n for (const [label, name] of Object.entries(raw as Record<string, unknown>)) {\n const trimmed = typeof name === \"string\" ? name.trim() : \"\"\n if (label && trimmed) out[label] = trimmed.slice(0, CAMERA_SWITCH_NAME_MAX)\n }\n return out\n}\n\n/** Why camera-switch would refuse this edit (the route's 400 `invalid_edl`),\n * or null. One edit (an object or its JSON string) on the master clock, with\n * sources and at least one segment of numeric inMs < outMs; a clip SET is\n * refused — on the canvas each clip fans out to its own run. */\nexport function cameraSwitchEdlProblem(edl: unknown): string | null {\n const v = parseMaybe(edl) as Record<string, unknown> | null | undefined\n if (!v || typeof v !== \"object\" || Array.isArray(v)) return \"camera-switch: `edl` must be one edit (an EDL object).\"\n if (Array.isArray(v.clips)) return \"camera-switch: `edl` is a clip set — pass one clip's EDL (a clip set fans out one run per clip on the canvas).\"\n if (!Array.isArray(v.sources) || !Array.isArray(v.segments)) return \"camera-switch: `edl` needs `sources` and `segments`.\"\n if (v.segments.length === 0) return \"camera-switch: `edl` has no segments.\"\n const num = (x: unknown) => (typeof x === \"number\" && Number.isFinite(x) ? x : undefined)\n for (const [i, row] of (v.segments as unknown[]).entries()) {\n const seg = row as { inMs?: unknown; outMs?: unknown } | null\n const inMs = num(seg?.inMs), outMs = num(seg?.outMs)\n if (inMs === undefined || outMs === undefined || !(outMs > inMs)) return `camera-switch: segment ${i} needs a numeric inMs < outMs.`\n }\n if (v.clock === \"output\") return \"camera-switch: the edit must be on the master clock (an edit-plan EDL), not a rendered output's.\"\n return null\n}\n\n/** The speaker table pre-filled by order (decided 2026-10-03): speaker 1 →\n * camera 1, speaker 2 → camera 2 … A speaker past the last camera stays\n * unmapped (the wide shows them, else any camera with picture). `existing`\n * entries are kept as the person set them — an explicit `\"\"` means \"no\n * camera of their own\" and is SENT as `\"\"`, so it also beats a source whose\n * `speakers` list names them. */\nexport function defaultSpeakerMap(\n labels: readonly string[],\n cameraIds: readonly string[],\n existing: Readonly<Record<string, string>> = {},\n): Record<string, string> {\n const out: Record<string, string> = {}\n labels.forEach((label, i) => {\n if (Object.prototype.hasOwnProperty.call(existing, label)) {\n const kept = existing[label]\n if (typeof kept === \"string\") out[label] = kept\n return\n }\n if (i < cameraIds.length) out[label] = cameraIds[i]!\n })\n return out\n}\n\n/** What a Camera Switch node sends besides its two inputs — ONE funnel for the\n * canvas executor and the orchestrator, so both send the same clamped\n * settings and the same pre-filled speaker table. */\nexport interface CameraSwitchNodeSettings {\n readonly speakerMap?: Readonly<Record<string, string>>\n /** Who is on which camera by ordinal — \"1\" the first voice heard → a camera\n * SOURCE id, \"\" none; what a use-case node's override writes (decided\n * 2026-10-17). A label in `speakerMap` beats it. */\n readonly speakerMapByOrder?: Readonly<Record<string, string>>\n readonly speakerNames?: Readonly<Record<string, string>>\n readonly minShotMs?: number\n readonly leadMs?: number\n readonly maxShotMs?: number\n readonly wideEvery?: number\n readonly layoutHints?: boolean\n}\n/**\n * Who is on which camera — the ONE merge of the speaker table's layers\n * (decided 2026-10-17). Per speaker, the first that names them wins: an\n * explicit label in `speakerMap`, the ordinal override `speakerMapByOrder`, a\n * wired Speaker Map result, then the order default (`defaultSpeakerMap`).\n * Each layer above the default is passed as `existing`, so its \"\" (no camera\n * of their own) is SENT as \"\" and is never re-filled by the order default; an\n * explicit entry that is not a string is ignored, so it never hides a layer\n * below it. `cameraSwitchSettingsPayload` sends this; the config panel's\n * \"What the run will use\" shows this — never a second copy of the order.\n */\nexport function cameraSwitchSpeakerMap(\n data: Pick<CameraSwitchNodeSettings, \"speakerMap\" | \"speakerMapByOrder\">,\n edl: unknown,\n transcript: unknown,\n wired?: { readonly speakerMap?: unknown },\n): Record<string, string> {\n const labels = transcriptSpeakerLabels(transcript)\n const explicit = data.speakerMap && typeof data.speakerMap === \"object\" && !Array.isArray(data.speakerMap)\n ? Object.fromEntries(Object.entries(data.speakerMap).filter(([, camera]) => typeof camera === \"string\"))\n : {}\n const existing = {\n ...(speakerMapResultOf(wired?.speakerMap)?.speakerMap ?? {}),\n ...speakerMapByOrdinal(labels, data.speakerMapByOrder),\n ...explicit,\n }\n return defaultSpeakerMap(labels, cameraSwitchCameras(edl).map((c) => c.id), existing)\n}\n\nexport function cameraSwitchSettingsPayload(\n data: CameraSwitchNodeSettings,\n edl: unknown,\n transcript: unknown,\n wired?: { readonly speakerMap?: unknown },\n): {\n speakerMap: Record<string, string>\n speakerNames: Record<string, string>\n minShotMs?: number\n leadMs?: number\n maxShotMs?: number\n wideEvery?: number\n layoutHints: boolean\n} {\n const out: ReturnType<typeof cameraSwitchSettingsPayload> = {\n speakerMap: cameraSwitchSpeakerMap(data, edl, transcript, wired),\n speakerNames: cleanSpeakerNames(data.speakerNames),\n layoutHints: data.layoutHints === true,\n }\n for (const key of CAMERA_SWITCH_NODE_SETTINGS) {\n const v = clampCameraSwitchSetting(key, data[key])\n if (v !== undefined) out[key] = v\n }\n return out\n}\n","/**\n * The edit-plan node's credit-id scheme and output unwrap — split out of\n * `edl.ts` (which keeps the EDL shape itself) so that module stays within the\n * file-size cap. Re-exported from the package index, so importers of\n * `@nodaro/shared` are unaffected.\n */\nimport { EDL_VERSION } from \"./edl.js\"\n\n// ─────────────────────────────────────────────────────────────────────────\n// edit-plan credit-id scheme (STRUCTURE only — the per-mode/tier/bucket credit\n// VALUES live app-side in backend/ee/billing/credits.ts + migration 432, since\n// they are probe-set placeholders and the DB row wins at runtime). Lives HERE\n// so BOTH core payload-builder and ee credits.ts read one id builder — core\n// may not import ee (check-ee-imports), the same reason buildVideoAnalysisCreditId\n// is shared. Mirrors the plugin's own (D13-local) pricing.ts scheme.\n// ─────────────────────────────────────────────────────────────────────────\n\n/** `trailer` (Track D1): one short teaser EDL built from the strongest moments,\n * priced like `clips` (the per-minute rate plus the clips flat). */\nexport type EditPlanMode = \"tighten\" | \"clips\" | \"chapters\" | \"trailer\"\nexport type EditPlanTier = \"economy\" | \"standard\" | \"premium\"\nexport const EDIT_PLAN_MODES: readonly EditPlanMode[] = [\"tighten\", \"clips\", \"chapters\", \"trailer\"]\nexport const EDIT_PLAN_TIERS: readonly EditPlanTier[] = [\"economy\", \"standard\", \"premium\"]\n/** The coarse duration ladder (MINUTES) a probed source duration rounds UP to;\n * the composite credit id carries the bucket. 4 modes × 3 tiers × 6 buckets =\n * 72 composites (+ the bare `edit-plan`). */\nexport const EDIT_PLAN_BUCKET_MINUTES: readonly number[] = [15, 30, 60, 90, 120, 180]\n/** Hard duration cap (design §7.4). */\nexport const EDIT_PLAN_MAX_MINUTES = 180\n/** `clips` mode: how many clips a plan returns when the caller names no count,\n * and the most it may be asked for. One source for the credit estimate, the\n * orchestrated payload clamp and the request schema. */\nexport const EDIT_PLAN_DEFAULT_CLIP_COUNT = 8\nexport const EDIT_PLAN_MAX_CLIP_COUNT = 50\n\n/** Clamp a requested clip count into `[1, EDIT_PLAN_MAX_CLIP_COUNT]`; `undefined`\n * for anything that is not a positive number (the planner then uses its default). */\nexport function clampEditPlanClipCount(count: unknown): number | undefined {\n if (typeof count !== \"number\" || !Number.isFinite(count) || count <= 0) return undefined\n return Math.min(EDIT_PLAN_MAX_CLIP_COUNT, Math.max(1, Math.floor(count)))\n}\n/** The bare estimator / DB-down fallback id. */\nexport const EDIT_PLAN_BASE_CREDIT_ID = \"edit-plan\"\n\n/** Round a source duration (seconds) UP to the smallest covering ladder bucket\n * (capped at the max), in minutes. `undefined` / non-finite → the ceiling\n * bucket (the safe over-reserve direction). */\nexport function editPlanBucketMinutes(durationSec: number | undefined): number {\n const secs = typeof durationSec === \"number\" && Number.isFinite(durationSec) ? durationSec : EDIT_PLAN_MAX_MINUTES * 60\n const mins = Math.max(1, Math.ceil(secs / 60))\n const capped = Math.min(mins, EDIT_PLAN_MAX_MINUTES)\n for (const b of EDIT_PLAN_BUCKET_MINUTES) if (capped <= b) return b\n return EDIT_PLAN_BUCKET_MINUTES[EDIT_PLAN_BUCKET_MINUTES.length - 1]!\n}\n\n/** `edit-plan:<mode>:<tier>:<bucket>m`. `durationSec` undefined → the ceiling\n * bucket. Single source of truth for the composite id shape. */\nexport function buildEditPlanCreditId(mode: EditPlanMode, tier: EditPlanTier, durationSec?: number): string {\n return editPlanMinutesCreditId(mode, tier, editPlanBucketMinutes(durationSec))\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// Per started minute (decided 2026-10-07). A plugin that declares\n// `supports().editPlanPerMinute` reserves `edit-plan:<mode>:<tier>:<N>m` with\n// N = the started minutes of the source (1..180), priced flat + rate × N from\n// ONE rate row and ONE flat row per mode × tier. The step ids above have the\n// same shape (N = a step), so one parser reads both, and the plugin's money\n// gate (`:(\\d+)m$`) accepts both.\n// ─────────────────────────────────────────────────────────────────────────\n\n/** Started minutes of a source (seconds): ceil(sec / 60), at least 1, capped at\n * the maximum. `undefined` / non-finite → the maximum (over-reserve direction). */\nexport function editPlanStartedMinutes(durationSec: number | undefined): number {\n const secs = typeof durationSec === \"number\" && Number.isFinite(durationSec) ? durationSec : EDIT_PLAN_MAX_MINUTES * 60\n return Math.min(EDIT_PLAN_MAX_MINUTES, Math.max(1, Math.ceil(secs / 60)))\n}\n\n/** `edit-plan:<mode>:<tier>:<N>m` for N minutes (a started-minute count or a step). */\nexport function editPlanMinutesCreditId(mode: EditPlanMode, tier: EditPlanTier, minutes: number): string {\n return `edit-plan:${mode}:${tier}:${minutes}m`\n}\n\n/** The id a run of this mode/tier on a source of `durationSec` reserves: per\n * started minute when the plugin charges that way (`perMinute`), else the step\n * the length rounds up to. An unknown length → the 180-minute maximum either way. */\nexport function editPlanReserveCreditId(\n mode: EditPlanMode,\n tier: EditPlanTier,\n durationSec: number | undefined,\n perMinute: boolean,\n): string {\n return perMinute\n ? editPlanMinutesCreditId(mode, tier, editPlanStartedMinutes(durationSec))\n : buildEditPlanCreditId(mode, tier, durationSec)\n}\n\n/** The rate row: credits per started source minute for a mode/tier. Never reserved. */\nexport function editPlanRateCreditId(mode: EditPlanMode, tier: EditPlanTier): string {\n return `edit-plan:${mode}:${tier}:per-minute`\n}\n\n/** The flat row: credits once per plan for a mode/tier (0 for tighten and chapters). Never reserved. */\nexport function editPlanFlatCreditId(mode: EditPlanMode, tier: EditPlanTier): string {\n return `edit-plan:${mode}:${tier}:flat`\n}\n\n/** The mode, tier and minutes of an `edit-plan:<mode>:<tier>:<N>m` id (1 ≤ N ≤\n * the maximum), or `undefined` for anything else (the bare id, a rate or flat\n * row, an unknown mode or tier). */\nexport function parseEditPlanMinutesCreditId(\n id: string,\n): { mode: EditPlanMode; tier: EditPlanTier; minutes: number } | undefined {\n const m = /^edit-plan:([a-z]+):([a-z]+):(\\d+)m$/.exec(id)\n if (!m) return undefined\n const mode = parseEditPlanMode(m[1])\n const tier = (EDIT_PLAN_TIERS as readonly string[]).includes(m[2]!) ? (m[2] as EditPlanTier) : undefined\n const minutes = Number(m[3])\n if (!mode || !tier || !Number.isInteger(minutes) || minutes < 1 || minutes > EDIT_PLAN_MAX_MINUTES) return undefined\n return { mode, tier, minutes }\n}\n\n/** flat + rate × N, rounded up, at least 1 credit — what an\n * `edit-plan:<mode>:<tier>:<N>m` id costs from its two rows (the plugin's formula). */\nexport function editPlanMinutesBaseCredits(flat: number, rate: number, minutes: number): number {\n return Math.max(1, Math.ceil(flat + rate * minutes))\n}\n\n/** Narrow an arbitrary value to a known edit-plan mode, defaulting to \"tighten\".\n * For display and estimates only: anything that DISPATCHES a plan must use\n * {@link parseEditPlanMode} and refuse an unknown mode, or that mode is planned\n * (and charged) as tighten. */\nexport function asEditPlanMode(v: unknown): EditPlanMode {\n return parseEditPlanMode(v) ?? \"tighten\"\n}\n\n/** The strict sibling of {@link asEditPlanMode}: the mode when `v` is exactly a\n * known edit-plan mode, otherwise `undefined` — never a substitute. */\nexport function parseEditPlanMode(v: unknown): EditPlanMode | undefined {\n return typeof v === \"string\" && (EDIT_PLAN_MODES as readonly string[]).includes(v) ? (v as EditPlanMode) : undefined\n}\n\n/** Narrow an arbitrary value to a known edit-plan tier, defaulting to \"standard\". */\nexport function asEditPlanTier(v: unknown): EditPlanTier {\n return v === \"economy\" || v === \"premium\" ? v : \"standard\"\n}\n\n/**\n * Unwrap an `edit-plan` job's `output_data` into the value stored on the node's\n * `data.generatedJson`, which every output extractor then reads. This is the ONE\n * place the modes are normalized (the same rule on both engines and every\n * result-application site, so audit-dag parity can't drift):\n * - `clips` → the BARE `Edl[]` (T5: the `list` fan-out reads `Array.isArray`\n * on `generatedJson`; each element becomes one JSON-stringified\n * item a downstream `edl` input `normalizeEdl`-parses).\n * - `chapters` → the `{ version, chapters }` object.\n * - `tighten` / `trailer` → the `Edl` object at top level.\n *\n * The cloud relay object-spreads `output_data` and adds `viaNodaroCloud: true`;\n * that key (and any other bookkeeping) is stripped here. The unwrap lives HERE —\n * NEVER in `output_data` — because a bare array written into `output_data` would\n * be corrupted into numeric keys by the relay's object-spread (see `EdlClipSet`).\n */\nexport function unwrapEditPlanOutput(outputData: unknown): unknown {\n if (!outputData || typeof outputData !== \"object\") return outputData\n const o = outputData as Record<string, unknown>\n // clips: EdlClipSet { version, clips: Edl[] } → the bare Edl[].\n if (Array.isArray(o.clips)) return o.clips\n // chapters: { version, chapters: [...] } → the object, minus bookkeeping.\n if (Array.isArray(o.chapters)) return { version: EDL_VERSION, chapters: o.chapters }\n // tighten / trailer: the Edl object at top level → drop the relay's viaNodaroCloud.\n const { viaNodaroCloud: _viaNodaroCloud, ...rest } = o\n return rest\n}\n"]}