@skyphusion-labs/vivijure-core 0.9.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 (267) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +87 -0
  3. package/dist/audio-routing.d.ts +2 -0
  4. package/dist/audio-routing.d.ts.map +1 -0
  5. package/dist/audio-routing.js +4 -0
  6. package/dist/audio-routing.js.map +1 -0
  7. package/dist/audio-stage.d.ts +4 -0
  8. package/dist/audio-stage.d.ts.map +1 -0
  9. package/dist/audio-stage.js +25 -0
  10. package/dist/audio-stage.js.map +1 -0
  11. package/dist/beat-analyze.d.ts +22 -0
  12. package/dist/beat-analyze.d.ts.map +1 -0
  13. package/dist/beat-analyze.js +111 -0
  14. package/dist/beat-analyze.js.map +1 -0
  15. package/dist/beat-sync-types.d.ts +33 -0
  16. package/dist/beat-sync-types.d.ts.map +1 -0
  17. package/dist/beat-sync-types.js +4 -0
  18. package/dist/beat-sync-types.js.map +1 -0
  19. package/dist/bundle-assembler.d.ts +54 -0
  20. package/dist/bundle-assembler.d.ts.map +1 -0
  21. package/dist/bundle-assembler.js +376 -0
  22. package/dist/bundle-assembler.js.map +1 -0
  23. package/dist/bundle-durations.d.ts +5 -0
  24. package/dist/bundle-durations.d.ts.map +1 -0
  25. package/dist/bundle-durations.js +68 -0
  26. package/dist/bundle-durations.js.map +1 -0
  27. package/dist/bundle-storyboard.d.ts +11 -0
  28. package/dist/bundle-storyboard.d.ts.map +1 -0
  29. package/dist/bundle-storyboard.js +82 -0
  30. package/dist/bundle-storyboard.js.map +1 -0
  31. package/dist/captions.d.ts +25 -0
  32. package/dist/captions.d.ts.map +1 -0
  33. package/dist/captions.js +56 -0
  34. package/dist/captions.js.map +1 -0
  35. package/dist/cast-db.d.ts +61 -0
  36. package/dist/cast-db.d.ts.map +1 -0
  37. package/dist/cast-db.js +324 -0
  38. package/dist/cast-db.js.map +1 -0
  39. package/dist/cast-lora-train.d.ts +18 -0
  40. package/dist/cast-lora-train.d.ts.map +1 -0
  41. package/dist/cast-lora-train.js +215 -0
  42. package/dist/cast-lora-train.js.map +1 -0
  43. package/dist/cast-loras.d.ts +21 -0
  44. package/dist/cast-loras.d.ts.map +1 -0
  45. package/dist/cast-loras.js +69 -0
  46. package/dist/cast-loras.js.map +1 -0
  47. package/dist/clip-content-validate.d.ts +43 -0
  48. package/dist/clip-content-validate.d.ts.map +1 -0
  49. package/dist/clip-content-validate.js +115 -0
  50. package/dist/clip-content-validate.js.map +1 -0
  51. package/dist/clip-job-model.d.ts +42 -0
  52. package/dist/clip-job-model.d.ts.map +1 -0
  53. package/dist/clip-job-model.js +8 -0
  54. package/dist/clip-job-model.js.map +1 -0
  55. package/dist/clip-validate.d.ts +33 -0
  56. package/dist/clip-validate.d.ts.map +1 -0
  57. package/dist/clip-validate.js +247 -0
  58. package/dist/clip-validate.js.map +1 -0
  59. package/dist/d1-retry.d.ts +20 -0
  60. package/dist/d1-retry.d.ts.map +1 -0
  61. package/dist/d1-retry.js +67 -0
  62. package/dist/d1-retry.js.map +1 -0
  63. package/dist/db-env.d.ts +6 -0
  64. package/dist/db-env.d.ts.map +1 -0
  65. package/dist/db-env.js +2 -0
  66. package/dist/db-env.js.map +1 -0
  67. package/dist/dialogue-lines.d.ts +23 -0
  68. package/dist/dialogue-lines.d.ts.map +1 -0
  69. package/dist/dialogue-lines.js +84 -0
  70. package/dist/dialogue-lines.js.map +1 -0
  71. package/dist/film-advance-lease.d.ts +9 -0
  72. package/dist/film-advance-lease.d.ts.map +1 -0
  73. package/dist/film-advance-lease.js +19 -0
  74. package/dist/film-advance-lease.js.map +1 -0
  75. package/dist/film-model.d.ts +415 -0
  76. package/dist/film-model.d.ts.map +1 -0
  77. package/dist/film-model.js +541 -0
  78. package/dist/film-model.js.map +1 -0
  79. package/dist/film-orchestrator.d.ts +216 -0
  80. package/dist/film-orchestrator.d.ts.map +1 -0
  81. package/dist/film-orchestrator.js +2204 -0
  82. package/dist/film-orchestrator.js.map +1 -0
  83. package/dist/film-render-bridge.d.ts +26 -0
  84. package/dist/film-render-bridge.d.ts.map +1 -0
  85. package/dist/film-render-bridge.js +176 -0
  86. package/dist/film-render-bridge.js.map +1 -0
  87. package/dist/finish-hash.d.ts +10 -0
  88. package/dist/finish-hash.d.ts.map +1 -0
  89. package/dist/finish-hash.js +60 -0
  90. package/dist/finish-hash.js.map +1 -0
  91. package/dist/index.d.ts +48 -0
  92. package/dist/index.d.ts.map +1 -0
  93. package/dist/index.js +45 -0
  94. package/dist/index.js.map +1 -0
  95. package/dist/key-safety.d.ts +5 -0
  96. package/dist/key-safety.d.ts.map +1 -0
  97. package/dist/key-safety.js +23 -0
  98. package/dist/key-safety.js.map +1 -0
  99. package/dist/lora-bundle.d.ts +19 -0
  100. package/dist/lora-bundle.d.ts.map +1 -0
  101. package/dist/lora-bundle.js +75 -0
  102. package/dist/lora-bundle.js.map +1 -0
  103. package/dist/lora-keys.d.ts +2 -0
  104. package/dist/lora-keys.d.ts.map +1 -0
  105. package/dist/lora-keys.js +4 -0
  106. package/dist/lora-keys.js.map +1 -0
  107. package/dist/modules/conformance.d.ts +58 -0
  108. package/dist/modules/conformance.d.ts.map +1 -0
  109. package/dist/modules/conformance.js +369 -0
  110. package/dist/modules/conformance.js.map +1 -0
  111. package/dist/modules/manifest-validate.d.ts +5 -0
  112. package/dist/modules/manifest-validate.d.ts.map +1 -0
  113. package/dist/modules/manifest-validate.js +60 -0
  114. package/dist/modules/manifest-validate.js.map +1 -0
  115. package/dist/modules/registry.d.ts +184 -0
  116. package/dist/modules/registry.d.ts.map +1 -0
  117. package/dist/modules/registry.js +653 -0
  118. package/dist/modules/registry.js.map +1 -0
  119. package/dist/modules/render-pipeline.d.ts +38 -0
  120. package/dist/modules/render-pipeline.d.ts.map +1 -0
  121. package/dist/modules/render-pipeline.js +40 -0
  122. package/dist/modules/render-pipeline.js.map +1 -0
  123. package/dist/modules/types.d.ts +544 -0
  124. package/dist/modules/types.d.ts.map +1 -0
  125. package/dist/modules/types.js +57 -0
  126. package/dist/modules/types.js.map +1 -0
  127. package/dist/operator-config.d.ts +20 -0
  128. package/dist/operator-config.d.ts.map +1 -0
  129. package/dist/operator-config.js +85 -0
  130. package/dist/operator-config.js.map +1 -0
  131. package/dist/output-extract.d.ts +8 -0
  132. package/dist/output-extract.d.ts.map +1 -0
  133. package/dist/output-extract.js +129 -0
  134. package/dist/output-extract.js.map +1 -0
  135. package/dist/planner-prompt.d.ts +12 -0
  136. package/dist/planner-prompt.d.ts.map +1 -0
  137. package/dist/planner-prompt.js +337 -0
  138. package/dist/planner-prompt.js.map +1 -0
  139. package/dist/planner-yaml.d.ts +15 -0
  140. package/dist/planner-yaml.d.ts.map +1 -0
  141. package/dist/planner-yaml.js +157 -0
  142. package/dist/planner-yaml.js.map +1 -0
  143. package/dist/platform/fetcher.d.ts +3 -0
  144. package/dist/platform/fetcher.d.ts.map +1 -0
  145. package/dist/platform/fetcher.js +7 -0
  146. package/dist/platform/fetcher.js.map +1 -0
  147. package/dist/platform/index.d.ts +6 -0
  148. package/dist/platform/index.d.ts.map +1 -0
  149. package/dist/platform/index.js +5 -0
  150. package/dist/platform/index.js.map +1 -0
  151. package/dist/platform/object-store-r2.d.ts +26 -0
  152. package/dist/platform/object-store-r2.d.ts.map +1 -0
  153. package/dist/platform/object-store-r2.js +74 -0
  154. package/dist/platform/object-store-r2.js.map +1 -0
  155. package/dist/platform/orchestrator-context.d.ts +20 -0
  156. package/dist/platform/orchestrator-context.d.ts.map +1 -0
  157. package/dist/platform/orchestrator-context.js +28 -0
  158. package/dist/platform/orchestrator-context.js.map +1 -0
  159. package/dist/platform/r2-types.d.ts +41 -0
  160. package/dist/platform/r2-types.d.ts.map +1 -0
  161. package/dist/platform/r2-types.js +3 -0
  162. package/dist/platform/r2-types.js.map +1 -0
  163. package/dist/platform/types.d.ts +90 -0
  164. package/dist/platform/types.d.ts.map +1 -0
  165. package/dist/platform/types.js +23 -0
  166. package/dist/platform/types.js.map +1 -0
  167. package/dist/preflight.d.ts +57 -0
  168. package/dist/preflight.d.ts.map +1 -0
  169. package/dist/preflight.js +243 -0
  170. package/dist/preflight.js.map +1 -0
  171. package/dist/presign.d.ts +5 -0
  172. package/dist/presign.d.ts.map +1 -0
  173. package/dist/presign.js +24 -0
  174. package/dist/presign.js.map +1 -0
  175. package/dist/public-id.d.ts +8 -0
  176. package/dist/public-id.d.ts.map +1 -0
  177. package/dist/public-id.js +25 -0
  178. package/dist/public-id.js.map +1 -0
  179. package/dist/render-adopt.d.ts +3 -0
  180. package/dist/render-adopt.d.ts.map +1 -0
  181. package/dist/render-adopt.js +92 -0
  182. package/dist/render-adopt.js.map +1 -0
  183. package/dist/render-log.d.ts +25 -0
  184. package/dist/render-log.d.ts.map +1 -0
  185. package/dist/render-log.js +139 -0
  186. package/dist/render-log.js.map +1 -0
  187. package/dist/render-module-config.d.ts +28 -0
  188. package/dist/render-module-config.d.ts.map +1 -0
  189. package/dist/render-module-config.js +124 -0
  190. package/dist/render-module-config.js.map +1 -0
  191. package/dist/render-mux.d.ts +18 -0
  192. package/dist/render-mux.d.ts.map +1 -0
  193. package/dist/render-mux.js +69 -0
  194. package/dist/render-mux.js.map +1 -0
  195. package/dist/render-orchestrator.d.ts +71 -0
  196. package/dist/render-orchestrator.d.ts.map +1 -0
  197. package/dist/render-orchestrator.js +376 -0
  198. package/dist/render-orchestrator.js.map +1 -0
  199. package/dist/render-sweep.d.ts +5 -0
  200. package/dist/render-sweep.d.ts.map +1 -0
  201. package/dist/render-sweep.js +62 -0
  202. package/dist/render-sweep.js.map +1 -0
  203. package/dist/renders-db.d.ts +129 -0
  204. package/dist/renders-db.d.ts.map +1 -0
  205. package/dist/renders-db.js +752 -0
  206. package/dist/renders-db.js.map +1 -0
  207. package/dist/runpod-submit.d.ts +151 -0
  208. package/dist/runpod-submit.d.ts.map +1 -0
  209. package/dist/runpod-submit.js +469 -0
  210. package/dist/runpod-submit.js.map +1 -0
  211. package/dist/runpod-types.d.ts +2 -0
  212. package/dist/runpod-types.d.ts.map +1 -0
  213. package/dist/runpod-types.js +4 -0
  214. package/dist/runpod-types.js.map +1 -0
  215. package/dist/scatter-notify.d.ts +4 -0
  216. package/dist/scatter-notify.d.ts.map +1 -0
  217. package/dist/scatter-notify.js +43 -0
  218. package/dist/scatter-notify.js.map +1 -0
  219. package/dist/scatter-orchestrator-types.d.ts +56 -0
  220. package/dist/scatter-orchestrator-types.d.ts.map +1 -0
  221. package/dist/scatter-orchestrator-types.js +3 -0
  222. package/dist/scatter-orchestrator-types.js.map +1 -0
  223. package/dist/scatter-orchestrator.d.ts +70 -0
  224. package/dist/scatter-orchestrator.d.ts.map +1 -0
  225. package/dist/scatter-orchestrator.js +614 -0
  226. package/dist/scatter-orchestrator.js.map +1 -0
  227. package/dist/scatter.d.ts +35 -0
  228. package/dist/scatter.d.ts.map +1 -0
  229. package/dist/scatter.js +171 -0
  230. package/dist/scatter.js.map +1 -0
  231. package/dist/secret-store.d.ts +5 -0
  232. package/dist/secret-store.d.ts.map +1 -0
  233. package/dist/secret-store.js +19 -0
  234. package/dist/secret-store.js.map +1 -0
  235. package/dist/shot-durations-parse.d.ts +3 -0
  236. package/dist/shot-durations-parse.d.ts.map +1 -0
  237. package/dist/shot-durations-parse.js +43 -0
  238. package/dist/shot-durations-parse.js.map +1 -0
  239. package/dist/srt.d.ts +11 -0
  240. package/dist/srt.d.ts.map +1 -0
  241. package/dist/srt.js +54 -0
  242. package/dist/srt.js.map +1 -0
  243. package/dist/storyboard-ids.d.ts +2 -0
  244. package/dist/storyboard-ids.d.ts.map +1 -0
  245. package/dist/storyboard-ids.js +12 -0
  246. package/dist/storyboard-ids.js.map +1 -0
  247. package/dist/storyboard-projects-db.d.ts +31 -0
  248. package/dist/storyboard-projects-db.d.ts.map +1 -0
  249. package/dist/storyboard-projects-db.js +153 -0
  250. package/dist/storyboard-projects-db.js.map +1 -0
  251. package/dist/storyboard-validate.d.ts +72 -0
  252. package/dist/storyboard-validate.d.ts.map +1 -0
  253. package/dist/storyboard-validate.js +595 -0
  254. package/dist/storyboard-validate.js.map +1 -0
  255. package/dist/structured-events.d.ts +6 -0
  256. package/dist/structured-events.d.ts.map +1 -0
  257. package/dist/structured-events.js +15 -0
  258. package/dist/structured-events.js.map +1 -0
  259. package/dist/tar.d.ts +9 -0
  260. package/dist/tar.d.ts.map +1 -0
  261. package/dist/tar.js +151 -0
  262. package/dist/tar.js.map +1 -0
  263. package/dist/voices.d.ts +12 -0
  264. package/dist/voices.d.ts.map +1 -0
  265. package/dist/voices.js +37 -0
  266. package/dist/voices.js.map +1 -0
  267. package/package.json +71 -0
@@ -0,0 +1,56 @@
1
+ // Caption cue timing for the film.finish subtitle module.
2
+ //
3
+ // Captions MUST sync to the audio, so the only honestly-timed text today is per-shot DIALOGUE: each
4
+ // speaking shot's TTS audio is baked into that shot's clip (job.dialogue_audio[shot_id]), so the line
5
+ // is spoken DURING that shot's window in the assembled film. We time each line to its shot's
6
+ // [start, end) window, where start = the cumulative duration of every preceding shot. The per-shot
7
+ // durations are the REAL ones the hybrid assembler beat-trims each clip to (readShotDurationsFromBundle's
8
+ // target_seconds), falling back to the authored scene seconds when the bundle carries no target.
9
+ //
10
+ // Narration is deliberately NOT captioned here: narration-gen emits a single film-level voiceover
11
+ // track with NO per-line timestamps, so shot-aligned narration cues would be guessed, not synced --
12
+ // which the "pull the REAL timing, do not guess" rule forbids. When narration grows real per-line
13
+ // timings, add them as cues alongside these; never fake them.
14
+ // Never emit a zero/negative-length cue (a shot with a line but no known duration still shows briefly).
15
+ const MIN_CUE_SECONDS = 0.2;
16
+ /** Resolve a shot's real duration: the bundle's beat-trimmed target_seconds (preferred), else the
17
+ * authored scene seconds, else 0 (an unknown-length shot contributes no time but still anchors a cue). */
18
+ function shotDuration(scene, durations) {
19
+ const fromBundle = durations[scene.shot_id];
20
+ if (typeof fromBundle === "number" && Number.isFinite(fromBundle) && fromBundle > 0)
21
+ return fromBundle;
22
+ if (typeof scene.seconds === "number" && Number.isFinite(scene.seconds) && scene.seconds > 0)
23
+ return scene.seconds;
24
+ return 0;
25
+ }
26
+ /** Build time-synced dialogue cues for the assembled film. `scenes` are in PLAY order; `durations`
27
+ * maps shot_id -> the real beat-trimmed seconds (a scene's authored `seconds` is the fallback). Only
28
+ * shots with a non-empty dialogue line produce a cue, timed to that shot's cumulative [start, end)
29
+ * window. Returns cues in play order; an empty array when nothing is spoken (the module then no-ops).
30
+ * A shot may carry at most one line; a later line for the same shot wins (last-write), matching how
31
+ * the dialogue stage resolves one line per speaking shot. */
32
+ export function buildCaptionCues(scenes, lines, durations = {}) {
33
+ const textByShot = new Map();
34
+ for (const l of lines ?? []) {
35
+ if (!l || typeof l.shot_id !== "string")
36
+ continue;
37
+ const text = typeof l.text === "string" ? l.text.trim() : "";
38
+ if (text)
39
+ textByShot.set(l.shot_id, text);
40
+ }
41
+ const cues = [];
42
+ let cursor = 0;
43
+ for (const scene of scenes ?? []) {
44
+ if (!scene || typeof scene.shot_id !== "string")
45
+ continue;
46
+ const start = cursor;
47
+ cursor += shotDuration(scene, durations);
48
+ const text = textByShot.get(scene.shot_id);
49
+ if (!text)
50
+ continue; // a silent shot advances time but adds no caption
51
+ const end = Math.max(start + MIN_CUE_SECONDS, cursor);
52
+ cues.push({ start, end, text });
53
+ }
54
+ return cues;
55
+ }
56
+ //# sourceMappingURL=captions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"captions.js","sourceRoot":"","sources":["../src/captions.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,EAAE;AACF,oGAAoG;AACpG,sGAAsG;AACtG,6FAA6F;AAC7F,mGAAmG;AACnG,0GAA0G;AAC1G,iGAAiG;AACjG,EAAE;AACF,kGAAkG;AAClG,oGAAoG;AACpG,kGAAkG;AAClG,8DAA8D;AAsB9D,wGAAwG;AACxG,MAAM,eAAe,GAAG,GAAG,CAAC;AAE5B;2GAC2G;AAC3G,SAAS,YAAY,CAAC,KAAmB,EAAE,SAAiC;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AK,EAAE,SAAS,CAAC,CAAC;QACzC,MAAM,IAAI,GAAG,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC3C,IAAI,CAAC,IAAI;YAAE,SAAS,CAAC,kDAAkD;QACvE,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,eAAe,EAAE,MAAM,CAAC,CAAC;QACtD,IAAI,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,61 @@
1
+ import type { DbEnv } from "./db-env.js";
2
+ export interface CastRefImage {
3
+ key: string;
4
+ mime: string;
5
+ }
6
+ export type LoraStatus = "idle" | "training" | "ready" | "failed";
7
+ export interface CastMember {
8
+ id: number;
9
+ public_id: string;
10
+ slug: string;
11
+ name: string;
12
+ bible: string | null;
13
+ portrait_key: string | null;
14
+ portrait_mime: string | null;
15
+ ref_keys: CastRefImage[];
16
+ source_keys: CastRefImage[];
17
+ created_at: string;
18
+ updated_at: string;
19
+ lora_key: string | null;
20
+ lora_status: LoraStatus;
21
+ lora_job_id: string | null;
22
+ lora_error: string | null;
23
+ lora_trained_at: string | null;
24
+ voice_id: string | null;
25
+ }
26
+ export type PublicCastMember = Omit<CastMember, "id" | "public_id"> & {
27
+ id: string;
28
+ };
29
+ export declare function toPublicCast(row: CastMember): PublicCastMember;
30
+ export declare function slugifyCharacter(name: string): string;
31
+ export declare function allocateCastSlug(env: DbEnv, base: string): Promise<string>;
32
+ export declare function listCast(env: DbEnv): Promise<CastMember[]>;
33
+ export declare function getCastIdByPublicId(env: DbEnv, publicId: string): Promise<number | null>;
34
+ export declare function getCastById(env: DbEnv, id: number): Promise<CastMember | null>;
35
+ export declare function createCast(env: DbEnv, input: {
36
+ name: string;
37
+ bible?: string | null;
38
+ }): Promise<CastMember>;
39
+ export declare function updateCast(env: DbEnv, id: number, patch: {
40
+ name?: string;
41
+ bible?: string | null;
42
+ voice_id?: string | null;
43
+ }): Promise<CastMember | null>;
44
+ export declare function deleteCast(env: DbEnv, id: number): Promise<CastMember | null>;
45
+ export declare function setPortrait(env: DbEnv, id: number, key: string, mime: string): Promise<CastMember | null>;
46
+ export declare function clearPortrait(env: DbEnv, id: number): Promise<CastMember | null>;
47
+ export declare function addRef(env: DbEnv, id: number, ref: CastRefImage): Promise<CastMember | null>;
48
+ export declare function addRefs(env: DbEnv, id: number, refs: CastRefImage[]): Promise<CastMember | null>;
49
+ export declare function removeRef(env: DbEnv, id: number, refKey: string): Promise<{
50
+ row: CastMember | null;
51
+ removedKey: string | null;
52
+ }>;
53
+ export declare function addSource(env: DbEnv, id: number, src: CastRefImage): Promise<CastMember | null>;
54
+ export declare function removeSource(env: DbEnv, id: number, srcKey: string): Promise<{
55
+ row: CastMember | null;
56
+ removedKey: string | null;
57
+ }>;
58
+ export declare function setLoraJob(env: DbEnv, id: number, jobId: string): Promise<CastMember | null>;
59
+ export declare function markLoraReady(env: DbEnv, id: number, loraKey: string): Promise<CastMember | null>;
60
+ export declare function markLoraFailed(env: DbEnv, id: number, errorMessage: string): Promise<CastMember | null>;
61
+ //# sourceMappingURL=cast-db.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cast-db.d.ts","sourceRoot":"","sources":["../src/cast-db.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAGzC,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,UAAU,GAAG,OAAO,GAAG,QAAQ,CAAC;AAElE,MAAM,WAAW,UAAU;IAEzB,EAAE,EAAE,MAAM,CAAC;IAEX,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,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AAE,GAAG,EAAE,UAAU,GAAG,IAAI,CAAC;IAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC,CAUhE;AAMD,wBAAsB,SAAS,CAC7B,GAAG,EAAE,KAAK,EACV,EAAE,EAAE,MAAM,EACV,GAAG,EAAE,YAAY,GAChB,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAM5B;AAED,wBAAsB,YAAY,CAChC,GAAG,EAAE,KAAK,EACV,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,MAAM,GACb,OAAO,CAAC;IAAE,GAAG,EAAE,UAAU,GAAG,IAAI,CAAC;IAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC,CAUhE;AAQD,wBAAsB,UAAU,CAC9B,GAAG,EAAE,KAAK,EACV,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAe5B;AAED,wBAAsB,aAAa,CACjC,GAAG,EAAE,KAAK,EACV,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAiB5B;AAED,wBAAsB,cAAc,CAClC,GAAG,EAAE,KAAK,EACV,EAAE,EAAE,MAAM,EACV,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAe5B"}
@@ -0,0 +1,324 @@
1
+ // D1 helpers for the persisted cast (v0.46.0). One row per character;
2
+ // survives across storyboards / renders so a character drawn once is
3
+ // reusable in every project.
4
+ //
5
+ // The studio is single-operator, so rows are scoped on the cast id (the primary key) alone;
6
+ // there is no per-user tenancy. The legacy identity column was removed in the identity strip
7
+ // (memory: vivijure-user-email-strip); slugs are globally unique.
8
+ import { newPublicId } from "./public-id.js";
9
+ // Shared parser for the two JSON-array image-key columns (ref_keys_json
10
+ // and source_keys_json). They have the identical {key, mime}[] shape.
11
+ function parseImageKeyList(raw) {
12
+ if (!raw)
13
+ return [];
14
+ try {
15
+ const parsed = JSON.parse(raw);
16
+ if (!Array.isArray(parsed))
17
+ return [];
18
+ return parsed
19
+ .filter((r) => r && typeof r === "object" && typeof r.key === "string" && typeof r.mime === "string")
20
+ .map((r) => ({ key: r.key, mime: r.mime }));
21
+ }
22
+ catch {
23
+ return [];
24
+ }
25
+ }
26
+ function normalizeLoraStatus(raw) {
27
+ if (raw === "training" || raw === "ready" || raw === "failed")
28
+ return raw;
29
+ return "idle";
30
+ }
31
+ function rowToCast(row) {
32
+ return {
33
+ id: row.id,
34
+ public_id: row.public_id,
35
+ slug: row.slug,
36
+ name: row.name,
37
+ bible: row.bible,
38
+ portrait_key: row.portrait_key,
39
+ portrait_mime: row.portrait_mime,
40
+ ref_keys: parseImageKeyList(row.ref_keys_json),
41
+ source_keys: parseImageKeyList(row.source_keys_json),
42
+ created_at: row.created_at,
43
+ updated_at: row.updated_at,
44
+ lora_key: row.lora_key,
45
+ lora_status: normalizeLoraStatus(row.lora_status),
46
+ lora_job_id: row.lora_job_id,
47
+ lora_error: row.lora_error,
48
+ lora_trained_at: row.lora_trained_at,
49
+ voice_id: row.voice_id,
50
+ };
51
+ }
52
+ export function toPublicCast(row) {
53
+ const { id: _internalId, public_id, ...rest } = row;
54
+ return { ...rest, id: public_id };
55
+ }
56
+ // URL-safe slug from a display name. Mirrors the projects-side slugify
57
+ // in src/index.ts. Empty / all-punctuation input falls back to "character".
58
+ export function slugifyCharacter(name) {
59
+ const s = name
60
+ .toLowerCase()
61
+ .normalize("NFKD")
62
+ .replace(/[^a-z0-9\s-]+/g, "")
63
+ .trim()
64
+ .replace(/[\s-]+/g, "-")
65
+ .replace(/^-+|-+$/g, "");
66
+ return s || "character";
67
+ }
68
+ // Allocate a slug unused by any other cast member. Bounded at 200 to surface
69
+ // pathological state instead of looping forever.
70
+ export async function allocateCastSlug(env, base) {
71
+ let candidate = base;
72
+ let suffix = 2;
73
+ while (suffix < 200) {
74
+ const existing = await env.DB.prepare(`SELECT id FROM cast_members WHERE slug = ? LIMIT 1`)
75
+ .bind(candidate)
76
+ .first();
77
+ if (!existing)
78
+ return candidate;
79
+ candidate = `${base}-${suffix}`;
80
+ suffix++;
81
+ }
82
+ throw new Error(`Could not allocate cast slug after 200 attempts (base='${base}')`);
83
+ }
84
+ // Bound the cast list so it can never scan unboundedly (issue #12). Generous -- well past any
85
+ // realistic cast size -- so the newest-first list is effectively complete while the query stays capped.
86
+ const CAST_LIST_LIMIT = 500;
87
+ export async function listCast(env) {
88
+ const result = await env.DB.prepare(`SELECT id, public_id, slug, name, bible, portrait_key, portrait_mime,
89
+ ref_keys_json, source_keys_json, created_at, updated_at,
90
+ lora_key, lora_status, lora_job_id, lora_error, lora_trained_at, voice_id
91
+ FROM cast_members
92
+ ORDER BY created_at DESC
93
+ LIMIT ?`)
94
+ .bind(CAST_LIST_LIMIT)
95
+ .all();
96
+ return (result.results || []).map(rowToCast);
97
+ }
98
+ // Resolve an opaque public id to the internal integer PK (the :id route boundary). Returns null
99
+ // when no cast member carries that public_id -- a bare sequential integer matches nothing, so the
100
+ // route 404s and enumeration is dead. INDEX-backed (idx_cast_public_id) unique lookup.
101
+ export async function getCastIdByPublicId(env, publicId) {
102
+ const row = await env.DB.prepare(`SELECT id FROM cast_members WHERE public_id = ? LIMIT 1`)
103
+ .bind(publicId)
104
+ .first();
105
+ return row ? Number(row.id) : null;
106
+ }
107
+ export async function getCastById(env, id) {
108
+ const row = await env.DB.prepare(`SELECT id, public_id, slug, name, bible, portrait_key, portrait_mime,
109
+ ref_keys_json, source_keys_json, created_at, updated_at,
110
+ lora_key, lora_status, lora_job_id, lora_error, lora_trained_at, voice_id
111
+ FROM cast_members
112
+ WHERE id = ?
113
+ LIMIT 1`)
114
+ .bind(id)
115
+ .first();
116
+ return row ? rowToCast(row) : null;
117
+ }
118
+ export async function createCast(env, input) {
119
+ const baseSlug = slugifyCharacter(input.name);
120
+ const slug = await allocateCastSlug(env, baseSlug);
121
+ // Slugs are globally unique (idx_cast_slug) -- single operator, no per-user namespace.
122
+ const result = await env.DB.prepare(`INSERT INTO cast_members (public_id, slug, name, bible)
123
+ VALUES (?, ?, ?, ?)
124
+ RETURNING id, public_id, slug, name, bible, portrait_key, portrait_mime,
125
+ ref_keys_json, source_keys_json, created_at, updated_at,
126
+ lora_key, lora_status, lora_job_id, lora_error, lora_trained_at, voice_id`)
127
+ .bind(newPublicId(), slug, input.name, input.bible ?? null)
128
+ .first();
129
+ if (!result)
130
+ throw new Error("createCast: INSERT...RETURNING produced no row");
131
+ return rowToCast(result);
132
+ }
133
+ export async function updateCast(env, id, patch) {
134
+ const fields = [];
135
+ const values = [];
136
+ if (patch.name !== undefined) {
137
+ fields.push("name = ?");
138
+ values.push(patch.name);
139
+ }
140
+ if (patch.bible !== undefined) {
141
+ fields.push("bible = ?");
142
+ values.push(patch.bible);
143
+ }
144
+ if (patch.voice_id !== undefined) {
145
+ fields.push("voice_id = ?");
146
+ values.push(patch.voice_id);
147
+ }
148
+ if (fields.length === 0) {
149
+ return getCastById(env, id);
150
+ }
151
+ fields.push("updated_at = datetime('now')");
152
+ values.push(id);
153
+ const result = await env.DB.prepare(`UPDATE cast_members SET ${fields.join(", ")}
154
+ WHERE id = ?
155
+ RETURNING id, public_id, slug, name, bible, portrait_key, portrait_mime,
156
+ ref_keys_json, source_keys_json, created_at, updated_at,
157
+ lora_key, lora_status, lora_job_id, lora_error, lora_trained_at, voice_id`)
158
+ .bind(...values)
159
+ .first();
160
+ return result ? rowToCast(result) : null;
161
+ }
162
+ export async function deleteCast(env, id) {
163
+ // Caller is responsible for R2 cleanup of the row's artifacts (portrait_key, ref_keys,
164
+ // source_keys, lora_key); we return the row so the route handler can reclaim them after the
165
+ // D1 delete. See deleteCastArtifacts in cast-media.ts (issue #298).
166
+ const row = await getCastById(env, id);
167
+ if (!row)
168
+ return null;
169
+ await env.DB.prepare(`DELETE FROM cast_members WHERE id = ?`)
170
+ .bind(id)
171
+ .run();
172
+ return row;
173
+ }
174
+ export async function setPortrait(env, id, key, mime) {
175
+ const result = await env.DB.prepare(`UPDATE cast_members
176
+ SET portrait_key = ?, portrait_mime = ?, updated_at = datetime('now')
177
+ WHERE id = ?
178
+ RETURNING id, public_id, slug, name, bible, portrait_key, portrait_mime,
179
+ ref_keys_json, source_keys_json, created_at, updated_at,
180
+ lora_key, lora_status, lora_job_id, lora_error, lora_trained_at, voice_id`)
181
+ .bind(key, mime, id)
182
+ .first();
183
+ return result ? rowToCast(result) : null;
184
+ }
185
+ export async function clearPortrait(env, id) {
186
+ const result = await env.DB.prepare(`UPDATE cast_members
187
+ SET portrait_key = NULL, portrait_mime = NULL, updated_at = datetime('now')
188
+ WHERE id = ?
189
+ RETURNING id, public_id, slug, name, bible, portrait_key, portrait_mime,
190
+ ref_keys_json, source_keys_json, created_at, updated_at,
191
+ lora_key, lora_status, lora_job_id, lora_error, lora_trained_at, voice_id`)
192
+ .bind(id)
193
+ .first();
194
+ return result ? rowToCast(result) : null;
195
+ }
196
+ // Full cast row column list returned by the CAS array-mutation helper (matches getCastById).
197
+ const CAST_ROW_COLUMNS = `id, public_id, slug, name, bible, portrait_key, portrait_mime,
198
+ ref_keys_json, source_keys_json, created_at, updated_at,
199
+ lora_key, lora_status, lora_job_id, lora_error, lora_trained_at, voice_id`;
200
+ async function casUpdateImageList(env, column, id, mutate, maxAttempts = 6) {
201
+ for (let attempt = 0; attempt < maxAttempts; attempt++) {
202
+ const cur = await env.DB.prepare(`SELECT ${column} AS raw FROM cast_members WHERE id = ?`)
203
+ .bind(id)
204
+ .first();
205
+ if (!cur)
206
+ return { row: null, changed: false, notFound: true };
207
+ const { next, changed } = mutate(parseImageKeyList(cur.raw));
208
+ if (!changed) {
209
+ // Nothing to write (e.g. removing a key that is not present). Return the current row.
210
+ const row = await getCastById(env, id);
211
+ return { row, changed: false, notFound: row === null };
212
+ }
213
+ // Value-CAS: apply only if the column is byte-for-byte what we read. `col IS ?` is null-safe,
214
+ // so a legacy NULL column matches a NULL guard. A concurrent writer changes the text -> 0 rows.
215
+ const updated = await env.DB.prepare(`UPDATE cast_members
216
+ SET ${column} = ?, updated_at = datetime('now')
217
+ WHERE id = ? AND ${column} IS ?
218
+ RETURNING ${CAST_ROW_COLUMNS}`)
219
+ .bind(JSON.stringify(next), id, cur.raw)
220
+ .first();
221
+ if (updated)
222
+ return { row: rowToCast(updated), changed: true, notFound: false };
223
+ // CAS miss: the column changed under us between read and write -> re-read and retry.
224
+ }
225
+ console.warn(`cast ${column} update for id ${id} gave up after ${maxAttempts} CAS attempts under contention`);
226
+ return { row: await getCastById(env, id), changed: false, notFound: false };
227
+ }
228
+ export async function addRef(env, id, ref) {
229
+ const { row } = await casUpdateImageList(env, "ref_keys_json", id, (cur) => ({
230
+ next: [...cur, ref],
231
+ changed: true,
232
+ }));
233
+ return row;
234
+ }
235
+ // Append a batch of refs in one CAS update (not per ref). Used by the cast-image orchestrator to
236
+ // register a whole generated training set at the end of a run -- ten sequential addRef round-trips
237
+ // would be ten writes; one batch is one CAS write that cannot lose a concurrent append.
238
+ export async function addRefs(env, id, refs) {
239
+ if (refs.length === 0)
240
+ return getCastById(env, id);
241
+ const { row } = await casUpdateImageList(env, "ref_keys_json", id, (cur) => ({
242
+ next: [...cur, ...refs],
243
+ changed: true,
244
+ }));
245
+ return row;
246
+ }
247
+ export async function removeRef(env, id, refKey) {
248
+ const { row, changed, notFound } = await casUpdateImageList(env, "ref_keys_json", id, (cur) => {
249
+ const next = cur.filter((r) => r.key !== refKey);
250
+ return { next, changed: next.length !== cur.length };
251
+ });
252
+ if (notFound)
253
+ return { row: null, removedKey: null };
254
+ return { row, removedKey: changed ? refKey : null };
255
+ }
256
+ // v0.90.0: persisted source/reference photos. Mirror the addRef /
257
+ // removeRef shape but write to source_keys_json. Used by the cast
258
+ // portrait + training-set generators as FLUX.2 multi-reference inputs.
259
+ export async function addSource(env, id, src) {
260
+ const { row } = await casUpdateImageList(env, "source_keys_json", id, (cur) => ({
261
+ next: [...cur, src],
262
+ changed: true,
263
+ }));
264
+ return row;
265
+ }
266
+ export async function removeSource(env, id, srcKey) {
267
+ const { row, changed, notFound } = await casUpdateImageList(env, "source_keys_json", id, (cur) => {
268
+ const next = cur.filter((s) => s.key !== srcKey);
269
+ return { next, changed: next.length !== cur.length };
270
+ });
271
+ if (notFound)
272
+ return { row: null, removedKey: null };
273
+ return { row, removedKey: changed ? srcKey : null };
274
+ }
275
+ // v0.57.0: standalone LoRA training fields. setLoraJob is called when
276
+ // the user clicks "Train LoRA" on /cast (status -> 'training', job_id
277
+ // stored). markLoraReady is called by the poll route on COMPLETED
278
+ // (status -> 'ready', lora_key stored, trained_at set). markLoraFailed
279
+ // is called on FAILED / errored polls.
280
+ export async function setLoraJob(env, id, jobId) {
281
+ const result = await env.DB.prepare(`UPDATE cast_members
282
+ SET lora_status = 'training',
283
+ lora_job_id = ?,
284
+ lora_error = NULL,
285
+ updated_at = datetime('now')
286
+ WHERE id = ?
287
+ RETURNING id, public_id, slug, name, bible, portrait_key, portrait_mime,
288
+ ref_keys_json, source_keys_json, created_at, updated_at,
289
+ lora_key, lora_status, lora_job_id, lora_error, lora_trained_at, voice_id`)
290
+ .bind(jobId, id)
291
+ .first();
292
+ return result ? rowToCast(result) : null;
293
+ }
294
+ export async function markLoraReady(env, id, loraKey) {
295
+ const result = await env.DB.prepare(`UPDATE cast_members
296
+ SET lora_status = 'ready',
297
+ lora_key = ?,
298
+ lora_trained_at = datetime('now'),
299
+ lora_job_id = NULL,
300
+ lora_error = NULL,
301
+ updated_at = datetime('now')
302
+ WHERE id = ?
303
+ RETURNING id, public_id, slug, name, bible, portrait_key, portrait_mime,
304
+ ref_keys_json, source_keys_json, created_at, updated_at,
305
+ lora_key, lora_status, lora_job_id, lora_error, lora_trained_at, voice_id`)
306
+ .bind(loraKey, id)
307
+ .first();
308
+ return result ? rowToCast(result) : null;
309
+ }
310
+ export async function markLoraFailed(env, id, errorMessage) {
311
+ const result = await env.DB.prepare(`UPDATE cast_members
312
+ SET lora_status = 'failed',
313
+ lora_error = ?,
314
+ lora_job_id = NULL,
315
+ updated_at = datetime('now')
316
+ WHERE id = ?
317
+ RETURNING id, public_id, slug, name, bible, portrait_key, portrait_mime,
318
+ ref_keys_json, source_keys_json, created_at, updated_at,
319
+ lora_key, lora_status, lora_job_id, lora_error, lora_trained_at, voice_id`)
320
+ .bind(errorMessage.slice(0, 4000), id)
321
+ .first();
322
+ return result ? rowToCast(result) : null;
323
+ }
324
+ //# sourceMappingURL=cast-db.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cast-db.js","sourceRoot":"","sources":["../src/cast-db.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,qEAAqE;AACrE,6BAA6B;AAC7B,EAAE;AACF,4FAA4F;AAC5F,6FAA6F;AAC7F,kEAAkE;AAGlE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AA4D7C,wEAAwE;AACxE,sEAAsE;AACtE,SAAS,iBAAiB,CAAC,GAAkB;IAC3C,IAAI,CAAC,GAAG;QAAE,OAAO,EAAE,CAAC;IACpB,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC/B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;YAAE,OAAO,EAAE,CAAC;QACtC,OAAO,MAAM;aACV,MAAM,CAAC,CAAC,CAAC,EAAqB,EAAE,CAC/B,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,CAAC,GAAG,KAAK,QAAQ,IAAI,OAAO,CAAC,CAAC,IAAI,KAAK,QAAQ,CACtF;aACA,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAChD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ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AI,EAAE,CAAC;AACtD,CAAC;AAED,sEAAsE;AACtE,sEAAsE;AACtE,kEAAkE;AAClE,uEAAuE;AACvE,uCAAuC;AAEvC,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,GAAU,EACV,EAAU,EACV,KAAa;IAEb,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,EAAE,CAAC,OAAO,CACjC;;;;;;;;yFAQqF,CACtF;SACE,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC;SACf,KAAK,EAAW,CAAC;IACpB,OAAO,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC3C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,GAAU,EACV,EAAU,EACV,OAAe;IAEf,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,EAAE,CAAC,OAAO,CACjC;;;;;;;;;;yFAUqF,CACtF;SACE,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;SACjB,KAAK,EAAW,CAAC;IACpB,OAAO,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC3C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,GAAU,EACV,EAAU,EACV,YAAoB;IAEpB,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,EAAE,CAAC,OAAO,CACjC;;;;;;;;yFAQqF,CACtF;SACE,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC;SACrC,KAAK,EAAW,CAAC;IACpB,OAAO,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { Env } from "./platform/orchestrator-context.js";
2
+ import { type CastMember } from "./cast-db.js";
3
+ export declare const LORA_TRAIN_404_GRACE_SECONDS = 120;
4
+ export declare const LORA_TRAIN_MAX_AGE_SECONDS: number;
5
+ export interface StuckTrainingDecision {
6
+ reconcile: boolean;
7
+ reason?: string;
8
+ }
9
+ export declare function sqliteUtcToMs(s: string | null | undefined): number | null;
10
+ export declare function trainingAgeSeconds(cast: CastMember, now: number): number | null;
11
+ export declare function decideStuckTraining(poll: {
12
+ ok: boolean;
13
+ status?: number;
14
+ }, ageSeconds: number | null): StuckTrainingDecision;
15
+ export declare function refreshTrainingLora(env: Env, cast: CastMember | null, now?: number): Promise<CastMember | null>;
16
+ export declare function handleCastTrainLora(request: Request, env: Env, id: number): Promise<Response>;
17
+ export declare function handleCastLoraStatus(env: Env, id: number): Promise<Response>;
18
+ //# sourceMappingURL=cast-lora-train.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cast-lora-train.d.ts","sourceRoot":"","sources":["../src/cast-lora-train.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,oCAAoC,CAAC;AAC9D,OAAO,EAML,KAAK,UAAU,EAChB,MAAM,cAAc,CAAC;AAsBtB,eAAO,MAAM,4BAA4B,MAAM,CAAC;AAGhD,eAAO,MAAM,0BAA0B,QAAU,CAAC;AAElD,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAKD,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAMzE;AAID,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAI/E;AAMD,wBAAgB,mBAAmB,CACjC,IAAI,EAAE;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,EACtC,UAAU,EAAE,MAAM,GAAG,IAAI,GACxB,qBAAqB,CAoBvB;AAED,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,UAAU,GAAG,IAAI,EACvB,GAAG,GAAE,MAAmB,GACvB,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CA4C5B;AAED,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,GAAG,EACR,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,QAAQ,CAAC,CAiFnB;AAED,wBAAsB,oBAAoB,CACxC,GAAG,EAAE,GAAG,EACR,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,QAAQ,CAAC,CAiDnB"}