@vanillaskyai/video 0.1.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 (162) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/LICENSE +201 -0
  3. package/PUBLIC-API.md +276 -0
  4. package/README.md +152 -0
  5. package/SECURITY.md +22 -0
  6. package/SUPPORT.md +28 -0
  7. package/bin/vanillasky.js +3 -0
  8. package/dist/bg-confetti-WNQXS7ZS.js +89 -0
  9. package/dist/bg-emoji-ETI47GLS.js +150 -0
  10. package/dist/bg-media-SVUZAMGX.js +99 -0
  11. package/dist/brand-message-F3RD4P3P.js +253 -0
  12. package/dist/builtin-server-F7YXRVCH.js +8 -0
  13. package/dist/catalog-types-BIhSpOWK.d.ts +74 -0
  14. package/dist/chart-bar-CNSC7BNK.js +304 -0
  15. package/dist/chart-counter-MCRHKN77.js +299 -0
  16. package/dist/chart-progress-ring-RMI4A7ZK.js +296 -0
  17. package/dist/check-runtime.d.ts +15 -0
  18. package/dist/check-runtime.js +102 -0
  19. package/dist/chunk-2E6T633S.js +27 -0
  20. package/dist/chunk-352ZZCET.js +83 -0
  21. package/dist/chunk-73NTSFFI.js +81 -0
  22. package/dist/chunk-A2X45FET.js +46 -0
  23. package/dist/chunk-ABPKM4GK.js +187 -0
  24. package/dist/chunk-ABZACD4G.js +216 -0
  25. package/dist/chunk-BCRUUJ6A.js +756 -0
  26. package/dist/chunk-CHLGW22F.js +3551 -0
  27. package/dist/chunk-CJ7F2CE6.js +104 -0
  28. package/dist/chunk-CR7FE7BW.js +109 -0
  29. package/dist/chunk-E7CL7UPB.js +109 -0
  30. package/dist/chunk-EE6PK6XC.js +18 -0
  31. package/dist/chunk-ERY4S6QV.js +385 -0
  32. package/dist/chunk-EVG2ZYIY.js +125 -0
  33. package/dist/chunk-FNAEQ7QO.js +155 -0
  34. package/dist/chunk-FQ47WXAJ.js +38 -0
  35. package/dist/chunk-FSG2PYWG.js +336 -0
  36. package/dist/chunk-GHJEAP4O.js +504 -0
  37. package/dist/chunk-GRMUV7QY.js +262 -0
  38. package/dist/chunk-IFOW65Z6.js +205 -0
  39. package/dist/chunk-IXCUY3B3.js +786 -0
  40. package/dist/chunk-L5BTTCZV.js +97 -0
  41. package/dist/chunk-LMG3GHLL.js +107 -0
  42. package/dist/chunk-OOPIETLW.js +101 -0
  43. package/dist/chunk-P22HHFDK.js +43 -0
  44. package/dist/chunk-QAAO7OAY.js +19 -0
  45. package/dist/chunk-S7HFLYNN.js +35 -0
  46. package/dist/chunk-SPVTJH3F.js +24 -0
  47. package/dist/chunk-W2XJKG6C.js +3177 -0
  48. package/dist/chunk-XB7LH4J2.js +301 -0
  49. package/dist/chunk-XGRA2MUV.js +242 -0
  50. package/dist/chunk-XTOXFMLM.js +105 -0
  51. package/dist/chunk-YC5MFXA5.js +132 -0
  52. package/dist/cli.d.ts +1 -0
  53. package/dist/cli.js +1681 -0
  54. package/dist/compose-video-CN3VSWST.js +13 -0
  55. package/dist/cta-logo-SVA5GP2A.js +209 -0
  56. package/dist/cta-media-E7VLLK42.js +215 -0
  57. package/dist/events-_wfjbmEp.d.ts +81 -0
  58. package/dist/incoming-call-62MFZL3Z.js +320 -0
  59. package/dist/index.d.ts +15 -0
  60. package/dist/index.js +14 -0
  61. package/dist/infographic-before-after-AXCDAWND.js +460 -0
  62. package/dist/infographic-feature-list-GW5GUE6O.js +266 -0
  63. package/dist/infographic-problem-solution-7NURJANA.js +340 -0
  64. package/dist/infographic-stat-row-J7IZR6ZN.js +241 -0
  65. package/dist/infographic-steps-VSZM6F5M.js +400 -0
  66. package/dist/kit-BMNcHqa9.d.ts +79 -0
  67. package/dist/prompt-input-LOUCRXCY.js +236 -0
  68. package/dist/react.d.ts +81 -0
  69. package/dist/react.js +835 -0
  70. package/dist/reaction-QG4CYZLQ.js +119 -0
  71. package/dist/server.d.ts +141 -0
  72. package/dist/server.js +498 -0
  73. package/dist/showcase-code-RUTFZR3H.js +351 -0
  74. package/dist/showcase-phone-6CP6XEU5.js +272 -0
  75. package/dist/showcase-terminal-MGAEQWPR.js +306 -0
  76. package/dist/showcase-web-Y4W2HVRJ.js +390 -0
  77. package/dist/social-conversation-75SD2637.js +695 -0
  78. package/dist/social-milestone-XI2QE5BO.js +292 -0
  79. package/dist/social-notification-2UOHQCUY.js +244 -0
  80. package/dist/social-review-stack-FDYZGZTJ.js +239 -0
  81. package/dist/social-testimonial-OQ7N52GJ.js +284 -0
  82. package/dist/social-tweet-5OLCNPPC.js +295 -0
  83. package/dist/state-DZcKuS32.d.ts +3 -0
  84. package/dist/system-prompt-A6UXNTPK.js +8 -0
  85. package/dist/template-catalog.d.ts +24 -0
  86. package/dist/template-catalog.js +6 -0
  87. package/dist/templates.d.ts +25 -0
  88. package/dist/templates.js +19 -0
  89. package/dist/test.d.ts +149 -0
  90. package/dist/test.js +272 -0
  91. package/dist/text-stream-6XHC7J47.js +10 -0
  92. package/dist/types-B-PZR6G_.d.ts +208 -0
  93. package/dist/validate-T7GBU2YF.js +8 -0
  94. package/docs/agent-integration.md +39 -0
  95. package/docs/architecture.md +84 -0
  96. package/docs/branding-and-personalization.md +87 -0
  97. package/docs/concepts.md +106 -0
  98. package/docs/custom-templates.md +329 -0
  99. package/docs/customization.md +141 -0
  100. package/docs/errors.md +70 -0
  101. package/docs/getting-started.md +111 -0
  102. package/docs/input-and-first-scene.md +41 -0
  103. package/docs/integrate-nextjs.md +79 -0
  104. package/docs/media-and-audio.md +69 -0
  105. package/docs/motion-and-effects.md +107 -0
  106. package/docs/persistence.md +95 -0
  107. package/docs/production.md +122 -0
  108. package/docs/prompt-and-input.md +185 -0
  109. package/docs/provider-integration.md +115 -0
  110. package/docs/reference/protocol.md +96 -0
  111. package/docs/reference/provider-adapters.md +158 -0
  112. package/docs/responsive-orientation.md +37 -0
  113. package/docs/security.md +38 -0
  114. package/docs/streaming-protocol.md +15 -0
  115. package/docs/testing.md +137 -0
  116. package/docs/use-cases.md +59 -0
  117. package/examples/custom-template/README.md +19 -0
  118. package/examples/custom-template/minimal-text.tsx +82 -0
  119. package/examples/custom-template/structured-data.tsx +104 -0
  120. package/examples/custom-template/supplied-media.tsx +92 -0
  121. package/examples/nextjs-quickstart/.env.example +2 -0
  122. package/examples/nextjs-quickstart/README.md +22 -0
  123. package/examples/nextjs-quickstart/next-env.d.ts +4 -0
  124. package/examples/nextjs-quickstart/package.json +24 -0
  125. package/examples/nextjs-quickstart/src/app/api/video/route.ts +22 -0
  126. package/examples/nextjs-quickstart/src/app/layout.tsx +5 -0
  127. package/examples/nextjs-quickstart/src/app/page.tsx +31 -0
  128. package/examples/nextjs-quickstart/tsconfig.json +26 -0
  129. package/package.json +167 -0
  130. package/registry/items/backgrounds.json +52 -0
  131. package/registry/items/barChart.json +237 -0
  132. package/registry/items/beforeAfter.json +180 -0
  133. package/registry/items/bigNumber.json +225 -0
  134. package/registry/items/brandMessage.json +158 -0
  135. package/registry/items/cardList.json +206 -0
  136. package/registry/items/chatMessenger.json +151 -0
  137. package/registry/items/chatWhatsapp.json +151 -0
  138. package/registry/items/codeEditor.json +184 -0
  139. package/registry/items/confetti.json +107 -0
  140. package/registry/items/ctaLogo.json +160 -0
  141. package/registry/items/ctaMedia.json +193 -0
  142. package/registry/items/emojiBurst.json +101 -0
  143. package/registry/items/incomingCall.json +170 -0
  144. package/registry/items/media.json +179 -0
  145. package/registry/items/milestone.json +205 -0
  146. package/registry/items/motion.json +45 -0
  147. package/registry/items/notification.json +182 -0
  148. package/registry/items/phoneMockup.json +254 -0
  149. package/registry/items/problemSolution.json +186 -0
  150. package/registry/items/progressRing.json +199 -0
  151. package/registry/items/promptInput.json +148 -0
  152. package/registry/items/reaction.json +170 -0
  153. package/registry/items/reviewStack.json +224 -0
  154. package/registry/items/steps.json +207 -0
  155. package/registry/items/template-context.json +31 -0
  156. package/registry/items/terminal.json +212 -0
  157. package/registry/items/testimonial.json +164 -0
  158. package/registry/items/theme.json +47 -0
  159. package/registry/items/tripleStats.json +228 -0
  160. package/registry/items/tweet.json +203 -0
  161. package/registry/items/typography.json +47 -0
  162. package/registry/items/webMockup.json +273 -0
@@ -0,0 +1,695 @@
1
+ import {
2
+ stripPipe
3
+ } from "./chunk-S7HFLYNN.js";
4
+ import {
5
+ renderWithEmoji
6
+ } from "./chunk-L5BTTCZV.js";
7
+ import {
8
+ interpolate
9
+ } from "./chunk-XTOXFMLM.js";
10
+
11
+ // src/visual-system/scene-templates/normalize-var.ts
12
+ function normalizeTextVar(raw) {
13
+ if (typeof raw === "string") {
14
+ const trimmed = raw.trim();
15
+ if (trimmed.startsWith("{")) {
16
+ try {
17
+ const obj = JSON.parse(trimmed);
18
+ if (typeof obj === "object" && obj !== null) {
19
+ return extractTextFromObject(obj);
20
+ }
21
+ } catch {
22
+ }
23
+ }
24
+ return raw;
25
+ }
26
+ if (typeof raw === "object" && raw !== null) {
27
+ return extractTextFromObject(raw);
28
+ }
29
+ return String(raw || "");
30
+ }
31
+ function extractTextFromObject(obj) {
32
+ const text = String(
33
+ obj.text || obj.message || obj.body || obj.content || ""
34
+ );
35
+ const side = String(obj.side || obj.direction || "").toLowerCase();
36
+ if (side === "in" || side === "left" || side === "incoming" || side === "received") {
37
+ return text + "|in";
38
+ }
39
+ if (side === "out" || side === "right" || side === "outgoing" || side === "sent") {
40
+ return text + "|out";
41
+ }
42
+ return text;
43
+ }
44
+
45
+ // src/visual-system/primitives/social/ConversationThread.tsx
46
+ import * as React from "react";
47
+ import { jsx, jsxs } from "react/jsx-runtime";
48
+ var CLAMP = {
49
+ extrapolateLeft: "clamp",
50
+ extrapolateRight: "clamp"
51
+ };
52
+ var REF_DURATION = 16;
53
+ function easeOutBack(t) {
54
+ const c1 = 1.70158;
55
+ const c3 = c1 + 1;
56
+ return 1 + c3 * Math.pow(t - 1, 3) + c1 * Math.pow(t - 1, 2);
57
+ }
58
+ var WA = {
59
+ bg: "#EFE7DC",
60
+ incomingBubble: "#FFFFFF",
61
+ outgoingBubble: "#D9F4C7",
62
+ text: "#0E0E0E",
63
+ textMuted: "#6E6E73",
64
+ accent: "#0A8F76",
65
+ chipBg: "#F1E9D8",
66
+ chipText: "#3C342A",
67
+ navBg: "#F1E9DA",
68
+ inputBg: "#FFFFFF",
69
+ inputBorder: "rgba(0,0,0,0.06)",
70
+ outgoingTime: "#5C6B4E"
71
+ };
72
+ var IM = {
73
+ bg: "#ffffff",
74
+ bubbleOut: "#007AFF",
75
+ bubbleIn: "#E9E9EB",
76
+ textOut: "#ffffff",
77
+ textIn: "#000000",
78
+ dotsColor: "#8E8E93"
79
+ };
80
+ var WA_TIMING_5 = [
81
+ { typingStart: 0.6, bubbleStart: 1.4, time: "21:54" },
82
+ { typingStart: 2.2, bubbleStart: 3, time: "21:55" },
83
+ { typingStart: 3.8, bubbleStart: 4.8, time: "21:56" },
84
+ { typingStart: 6.2, bubbleStart: 7.2, time: "12:35" },
85
+ { typingStart: 10, bubbleStart: 11, time: "11:17" }
86
+ ];
87
+ function timingForCount(count) {
88
+ if (count >= 5) return WA_TIMING_5.slice(0, count);
89
+ const slot = 12 / count;
90
+ const out = [];
91
+ for (let i = 0; i < count; i++) {
92
+ const start = 0.6 + i * slot;
93
+ out.push({
94
+ typingStart: start,
95
+ bubbleStart: start + slot * 0.5,
96
+ time: WA_TIMING_5[Math.min(i, 4)].time
97
+ });
98
+ }
99
+ return out;
100
+ }
101
+ function tickStateAt(refTimeSinceSent) {
102
+ if (refTimeSinceSent < 0.5) return "clock";
103
+ if (refTimeSinceSent < 1.1) return "sent";
104
+ if (refTimeSinceSent < 1.8) return "delivered";
105
+ return "read";
106
+ }
107
+ var ClockIcon = ({ s }) => /* @__PURE__ */ jsxs("svg", { width: 12 * s, height: 12 * s, viewBox: "0 0 12 12", style: { marginLeft: 4 * s }, children: [
108
+ /* @__PURE__ */ jsx("circle", { cx: "6", cy: "6", r: "5", fill: "none", stroke: "#8C8C92", strokeWidth: "1.2" }),
109
+ /* @__PURE__ */ jsx("path", { d: "M6 3 v3.5 l2 1", stroke: "#8C8C92", strokeWidth: "1.2", fill: "none", strokeLinecap: "round" })
110
+ ] });
111
+ var Ticks = ({ state, s }) => {
112
+ if (state === "clock") return /* @__PURE__ */ jsx(ClockIcon, { s });
113
+ const color = state === "read" ? "#53BDEB" : "#8C8C92";
114
+ return /* @__PURE__ */ jsxs("svg", { width: 16 * s, height: 11 * s, viewBox: "0 0 16 11", style: { marginLeft: 4 * s }, children: [
115
+ /* @__PURE__ */ jsx(
116
+ "path",
117
+ {
118
+ d: "M1 6 l3 3 l6 -7",
119
+ stroke: color,
120
+ strokeWidth: 1.3,
121
+ fill: "none",
122
+ strokeLinecap: "round",
123
+ strokeLinejoin: "round",
124
+ opacity: state === "sent" ? 0 : 1
125
+ }
126
+ ),
127
+ /* @__PURE__ */ jsx(
128
+ "path",
129
+ {
130
+ d: "M5 6 l3 3 l7 -8",
131
+ stroke: color,
132
+ strokeWidth: 1.3,
133
+ fill: "none",
134
+ strokeLinecap: "round",
135
+ strokeLinejoin: "round"
136
+ }
137
+ )
138
+ ] });
139
+ };
140
+ var ComposeBar = ({ s }) => {
141
+ const stroke = "#1A1A1A";
142
+ return /* @__PURE__ */ jsxs(
143
+ "div",
144
+ {
145
+ style: {
146
+ background: WA.navBg,
147
+ borderTop: "1px solid rgba(0,0,0,0.05)",
148
+ padding: `${10 * s}px ${14 * s}px ${12 * s}px`,
149
+ display: "flex",
150
+ alignItems: "center",
151
+ gap: 14 * s
152
+ },
153
+ children: [
154
+ /* @__PURE__ */ jsx("svg", { width: 30 * s, height: 30 * s, viewBox: "0 0 30 30", style: { flexShrink: 0 }, children: /* @__PURE__ */ jsx("path", { d: "M15 5 v20 M5 15 h20", stroke, strokeWidth: "1.8", strokeLinecap: "round" }) }),
155
+ /* @__PURE__ */ jsx(
156
+ "div",
157
+ {
158
+ style: {
159
+ flex: 1,
160
+ height: 40 * s,
161
+ background: WA.inputBg,
162
+ borderRadius: 22 * s,
163
+ position: "relative",
164
+ border: `0.5px solid ${WA.inputBorder}`
165
+ },
166
+ children: /* @__PURE__ */ jsx(
167
+ "div",
168
+ {
169
+ style: {
170
+ position: "absolute",
171
+ right: 12 * s,
172
+ top: "50%",
173
+ transform: "translateY(-50%)",
174
+ display: "flex",
175
+ alignItems: "center",
176
+ justifyContent: "center"
177
+ },
178
+ children: /* @__PURE__ */ jsx("svg", { width: 28 * s, height: 28 * s, viewBox: "0 0 24 24", fill: "none", style: { display: "block" }, children: /* @__PURE__ */ jsx(
179
+ "path",
180
+ {
181
+ d: "M3 5 a2 2 0 0 1 2 -2 h10 a2 2 0 0 1 2 2 v6 l-6 6 h-6 a2 2 0 0 1 -2 -2 z M17 11 a4 4 0 0 0 -4 4 v2",
182
+ stroke: "#555",
183
+ strokeWidth: "1.5",
184
+ fill: "none",
185
+ strokeLinejoin: "round",
186
+ strokeLinecap: "round"
187
+ }
188
+ ) })
189
+ }
190
+ )
191
+ }
192
+ ),
193
+ /* @__PURE__ */ jsxs("svg", { width: 28 * s, height: 24 * s, viewBox: "0 0 28 24", fill: "none", style: { flexShrink: 0 }, children: [
194
+ /* @__PURE__ */ jsx(
195
+ "path",
196
+ {
197
+ d: "M3 6 h5 l2 -3 h8 l2 3 h5 a1 1 0 0 1 1 1 v14 a1 1 0 0 1 -1 1 h-22 a1 1 0 0 1 -1 -1 v-14 a1 1 0 0 1 1 -1 z",
198
+ stroke,
199
+ strokeWidth: "1.6",
200
+ fill: "none",
201
+ strokeLinejoin: "round"
202
+ }
203
+ ),
204
+ /* @__PURE__ */ jsx("circle", { cx: "14", cy: "14", r: "4.5", stroke, strokeWidth: "1.6", fill: "none" })
205
+ ] }),
206
+ /* @__PURE__ */ jsxs("svg", { width: 20 * s, height: 26 * s, viewBox: "0 0 20 26", fill: "none", style: { flexShrink: 0 }, children: [
207
+ /* @__PURE__ */ jsx("rect", { x: "7", y: "2", width: "6", height: "13", rx: "3", stroke, strokeWidth: "1.6", fill: "none" }),
208
+ /* @__PURE__ */ jsx(
209
+ "path",
210
+ {
211
+ d: "M3 12 a7 7 0 0 0 14 0 M10 19 v4 M7 23 h6",
212
+ stroke,
213
+ strokeWidth: "1.6",
214
+ fill: "none",
215
+ strokeLinecap: "round"
216
+ }
217
+ )
218
+ ] })
219
+ ]
220
+ }
221
+ );
222
+ };
223
+ var TypingBubble = ({ side, pop, realTimeSeconds, s, theme }) => {
224
+ if (pop <= 0) return null;
225
+ const isOut = side === "right";
226
+ const isWA = theme === "whatsapp";
227
+ const dotColor = isWA ? isOut ? "#6B8A55" : "#8C8C92" : IM.dotsColor;
228
+ const bg = isWA ? isOut ? WA.outgoingBubble : WA.incomingBubble : isOut ? IM.bubbleOut : IM.bubbleIn;
229
+ return /* @__PURE__ */ jsx(
230
+ "div",
231
+ {
232
+ style: {
233
+ display: "flex",
234
+ justifyContent: isOut ? "flex-end" : "flex-start",
235
+ padding: `${2 * s}px ${(isWA ? 10 : 14) * s}px`,
236
+ opacity: pop,
237
+ transform: `scale(${0.9 + 0.1 * pop})`,
238
+ transformOrigin: isOut ? "right bottom" : "left bottom"
239
+ },
240
+ children: /* @__PURE__ */ jsx(
241
+ "div",
242
+ {
243
+ style: {
244
+ background: bg,
245
+ borderRadius: (isWA ? 14 : 18) * s,
246
+ ...isWA ? {
247
+ borderTopLeftRadius: isOut ? 14 * s : 2 * s,
248
+ borderTopRightRadius: isOut ? 2 * s : 14 * s
249
+ } : {},
250
+ padding: `${(isWA ? 10 : 12) * s}px ${(isWA ? 12 : 16) * s}px`,
251
+ display: "flex",
252
+ gap: 5 * s,
253
+ alignItems: "center",
254
+ ...isWA ? { boxShadow: `0 ${1 * s}px ${1 * s}px rgba(0,0,0,0.06)` } : {}
255
+ },
256
+ children: [0, 1, 2].map((i) => {
257
+ const phase = (realTimeSeconds * 1.6 + i * 0.2) % 1;
258
+ const y = Math.sin(phase * Math.PI * 2) * 2.5 * s;
259
+ const op = 0.45 + 0.55 * Math.max(0, Math.sin(phase * Math.PI));
260
+ const dotSize = isWA ? 6 * s : 7 * s;
261
+ return /* @__PURE__ */ jsx(
262
+ "div",
263
+ {
264
+ style: {
265
+ width: dotSize,
266
+ height: dotSize,
267
+ borderRadius: dotSize / 2,
268
+ background: dotColor,
269
+ transform: `translateY(${-y}px)`,
270
+ opacity: op
271
+ }
272
+ },
273
+ i
274
+ );
275
+ })
276
+ }
277
+ )
278
+ }
279
+ );
280
+ };
281
+ var DateChip = ({
282
+ label,
283
+ chipProgress,
284
+ s
285
+ }) => {
286
+ if (chipProgress <= 0) return null;
287
+ return /* @__PURE__ */ jsx(
288
+ "div",
289
+ {
290
+ style: {
291
+ display: "flex",
292
+ justifyContent: "center",
293
+ margin: `${12 * s}px 0 ${8 * s}px`,
294
+ opacity: chipProgress,
295
+ transform: `scale(${0.88 + 0.12 * chipProgress})`
296
+ },
297
+ children: /* @__PURE__ */ jsx(
298
+ "div",
299
+ {
300
+ style: {
301
+ background: WA.chipBg,
302
+ color: WA.chipText,
303
+ padding: `${7 * s}px ${16 * s}px`,
304
+ borderRadius: 9 * s,
305
+ fontSize: 17 * s,
306
+ fontWeight: 600,
307
+ boxShadow: `0 ${1 * s}px ${1.5 * s}px rgba(0,0,0,0.05)`
308
+ },
309
+ children: label
310
+ }
311
+ )
312
+ }
313
+ );
314
+ };
315
+ var IncomingBubble = ({ children, time, pop, s }) => /* @__PURE__ */ jsx(
316
+ "div",
317
+ {
318
+ style: {
319
+ display: "flex",
320
+ justifyContent: "flex-start",
321
+ padding: `${2 * s}px ${10 * s}px`,
322
+ opacity: pop,
323
+ transform: `translateY(${(1 - pop) * 6 * s}px) scale(${0.97 + 0.03 * pop})`,
324
+ transformOrigin: "left bottom"
325
+ },
326
+ children: /* @__PURE__ */ jsxs(
327
+ "div",
328
+ {
329
+ style: {
330
+ maxWidth: "82%",
331
+ background: WA.incomingBubble,
332
+ borderRadius: 10 * s,
333
+ borderTopLeftRadius: 2 * s,
334
+ padding: `${12 * s}px ${16 * s}px ${11 * s}px`,
335
+ fontSize: 23 * s,
336
+ lineHeight: `${29 * s}px`,
337
+ color: WA.text,
338
+ boxShadow: `0 ${1 * s}px ${1 * s}px rgba(0,0,0,0.06)`,
339
+ position: "relative"
340
+ },
341
+ children: [
342
+ /* @__PURE__ */ jsx("div", { style: { paddingRight: 64 * s }, children }),
343
+ /* @__PURE__ */ jsx(
344
+ "div",
345
+ {
346
+ style: {
347
+ position: "absolute",
348
+ right: 14 * s,
349
+ bottom: 8 * s,
350
+ fontSize: 15 * s,
351
+ color: WA.textMuted
352
+ },
353
+ children: time
354
+ }
355
+ )
356
+ ]
357
+ }
358
+ )
359
+ }
360
+ );
361
+ var OutgoingBubble = ({ children, time, tickState, pop, s }) => /* @__PURE__ */ jsx(
362
+ "div",
363
+ {
364
+ style: {
365
+ display: "flex",
366
+ justifyContent: "flex-end",
367
+ padding: `${2 * s}px ${10 * s}px`,
368
+ opacity: pop,
369
+ transform: `translateY(${(1 - pop) * 8 * s}px) scale(${0.96 + 0.04 * pop})`,
370
+ transformOrigin: "right bottom"
371
+ },
372
+ children: /* @__PURE__ */ jsxs(
373
+ "div",
374
+ {
375
+ style: {
376
+ maxWidth: "82%",
377
+ background: WA.outgoingBubble,
378
+ borderRadius: 10 * s,
379
+ borderTopRightRadius: 2 * s,
380
+ padding: `${12 * s}px ${16 * s}px ${11 * s}px`,
381
+ fontSize: 23 * s,
382
+ lineHeight: `${29 * s}px`,
383
+ color: WA.text,
384
+ boxShadow: `0 ${1 * s}px ${1 * s}px rgba(0,0,0,0.06)`,
385
+ position: "relative"
386
+ },
387
+ children: [
388
+ /* @__PURE__ */ jsx("div", { style: { paddingRight: 88 * s }, children }),
389
+ /* @__PURE__ */ jsxs(
390
+ "div",
391
+ {
392
+ style: {
393
+ position: "absolute",
394
+ right: 14 * s,
395
+ bottom: 8 * s,
396
+ fontSize: 15 * s,
397
+ color: WA.outgoingTime,
398
+ display: "flex",
399
+ alignItems: "center"
400
+ },
401
+ children: [
402
+ time,
403
+ /* @__PURE__ */ jsx(Ticks, { state: tickState, s })
404
+ ]
405
+ }
406
+ )
407
+ ]
408
+ }
409
+ )
410
+ }
411
+ );
412
+ var CHIP_TIMING = {
413
+ monday: { start: 5.8, end: 6.2 },
414
+ yesterday: { start: 9.6, end: 10 }
415
+ };
416
+ var ConversationThread = ({
417
+ progress,
418
+ width,
419
+ height,
420
+ sceneDuration,
421
+ messages: rawMessages,
422
+ theme = "whatsapp",
423
+ dateChip1 = "",
424
+ dateChip2 = "",
425
+ safeZoneTop
426
+ }) => {
427
+ const isLandscape = width > height;
428
+ const colWidth = isLandscape ? width * 0.72 : width;
429
+ const colLeft = (width - colWidth) / 2;
430
+ const s = Math.min(width, height) / 534;
431
+ const isWhatsApp = theme === "whatsapp";
432
+ const sanitized = rawMessages.map((m) => ({ ...m, text: stripPipe(m.text || "").trim() })).filter((m) => m.text.length > 0);
433
+ const timing = timingForCount(Math.max(1, sanitized.length));
434
+ const messages = sanitized.map((m, i) => ({
435
+ side: m.side,
436
+ text: m.text,
437
+ author: m.author,
438
+ typingStart: timing[i].typingStart,
439
+ bubbleStart: timing[i].bubbleStart,
440
+ time: timing[i].time
441
+ }));
442
+ const realTimeSeconds = progress * sceneDuration;
443
+ const refT = progress * REF_DURATION;
444
+ const topPad = safeZoneTop != null ? safeZoneTop : height * 0.08;
445
+ const chip1Label = stripPipe(dateChip1 || "").trim();
446
+ const chip2Label = stripPipe(dateChip2 || "").trim();
447
+ const popIn = (t, start, dur = 0.4) => {
448
+ if (t <= start) return 0;
449
+ if (t >= start + dur) return 1;
450
+ return easeOutBack((t - start) / dur);
451
+ };
452
+ const ramp = (t, start, end) => {
453
+ if (t <= start) return 0;
454
+ if (t >= end) return 1;
455
+ return (t - start) / (end - start);
456
+ };
457
+ if (isWhatsApp) {
458
+ return /* @__PURE__ */ jsx(
459
+ "div",
460
+ {
461
+ style: {
462
+ position: "absolute",
463
+ inset: 0,
464
+ background: WA.bg,
465
+ overflow: "hidden",
466
+ fontFamily: '-apple-system, "SF Pro Text", system-ui'
467
+ },
468
+ children: /* @__PURE__ */ jsxs(
469
+ "div",
470
+ {
471
+ style: {
472
+ position: "absolute",
473
+ left: colLeft,
474
+ width: colWidth,
475
+ top: 0,
476
+ height,
477
+ display: "flex",
478
+ flexDirection: "column"
479
+ },
480
+ children: [
481
+ /* @__PURE__ */ jsx("div", { style: { flex: 1, position: "relative", overflow: "hidden" }, children: /* @__PURE__ */ jsxs(
482
+ "div",
483
+ {
484
+ style: {
485
+ position: "absolute",
486
+ left: 0,
487
+ right: 0,
488
+ top: 0,
489
+ display: "flex",
490
+ flexDirection: "column",
491
+ gap: 2 * s,
492
+ padding: `${topPad}px 0 ${10 * s}px`
493
+ },
494
+ children: [
495
+ messages.map((msg, i) => {
496
+ const typingPop = popIn(refT, msg.typingStart, 0.25);
497
+ const typingFade = interpolate(
498
+ refT,
499
+ [msg.bubbleStart - 0.1, msg.bubbleStart],
500
+ [1, 0],
501
+ CLAMP
502
+ );
503
+ const showTyping = refT >= msg.typingStart && refT < msg.bubbleStart;
504
+ const bubblePop = popIn(refT, msg.bubbleStart, 0.4);
505
+ const showBubble = refT >= msg.bubbleStart;
506
+ const isOut = msg.side === "right";
507
+ const refSinceSent = refT - msg.bubbleStart - 0.4;
508
+ const tickState = isOut ? tickStateAt(Math.max(0, refSinceSent)) : "read";
509
+ const chipBeforeThis = (() => {
510
+ if (i === 3 && chip1Label) {
511
+ return {
512
+ label: chip1Label,
513
+ progress: ramp(refT, CHIP_TIMING.monday.start, CHIP_TIMING.monday.end)
514
+ };
515
+ }
516
+ if (i === 4 && chip2Label) {
517
+ return {
518
+ label: chip2Label,
519
+ progress: ramp(refT, CHIP_TIMING.yesterday.start, CHIP_TIMING.yesterday.end)
520
+ };
521
+ }
522
+ return null;
523
+ })();
524
+ return /* @__PURE__ */ jsxs(React.Fragment, { children: [
525
+ chipBeforeThis && /* @__PURE__ */ jsx(
526
+ DateChip,
527
+ {
528
+ label: chipBeforeThis.label,
529
+ chipProgress: chipBeforeThis.progress,
530
+ s
531
+ }
532
+ ),
533
+ showTyping && /* @__PURE__ */ jsx("div", { style: { opacity: typingPop * typingFade }, children: /* @__PURE__ */ jsx(
534
+ TypingBubble,
535
+ {
536
+ side: msg.side,
537
+ pop: typingPop,
538
+ realTimeSeconds,
539
+ s,
540
+ theme: "whatsapp"
541
+ }
542
+ ) }),
543
+ showBubble && (isOut ? /* @__PURE__ */ jsx(OutgoingBubble, { pop: bubblePop, time: msg.time, tickState, s, children: renderWithEmoji(msg.text, 23 * s) }) : /* @__PURE__ */ jsx(IncomingBubble, { pop: bubblePop, time: msg.time, s, children: renderWithEmoji(msg.text, 23 * s) }))
544
+ ] }, i);
545
+ }),
546
+ /* @__PURE__ */ jsx("div", { style: { height: 12 * s } })
547
+ ]
548
+ }
549
+ ) }),
550
+ /* @__PURE__ */ jsx(ComposeBar, { s })
551
+ ]
552
+ }
553
+ )
554
+ }
555
+ );
556
+ }
557
+ return /* @__PURE__ */ jsx(
558
+ "div",
559
+ {
560
+ style: {
561
+ position: "absolute",
562
+ inset: 0,
563
+ background: IM.bg,
564
+ overflow: "hidden",
565
+ fontFamily: "-apple-system, 'SF Pro', 'Helvetica Neue', Helvetica, Arial, sans-serif"
566
+ },
567
+ children: /* @__PURE__ */ jsx(
568
+ "div",
569
+ {
570
+ style: {
571
+ position: "absolute",
572
+ left: colLeft,
573
+ width: colWidth,
574
+ top: 0,
575
+ height,
576
+ padding: `${topPad}px 0 ${20 * s}px`,
577
+ display: "flex",
578
+ flexDirection: "column",
579
+ gap: 4 * s
580
+ },
581
+ children: messages.map((msg, i) => {
582
+ const typingPop = popIn(refT, msg.typingStart, 0.25);
583
+ const typingFade = interpolate(
584
+ refT,
585
+ [msg.bubbleStart - 0.1, msg.bubbleStart],
586
+ [1, 0],
587
+ CLAMP
588
+ );
589
+ const showTyping = refT >= msg.typingStart && refT < msg.bubbleStart;
590
+ const bubblePop = popIn(refT, msg.bubbleStart, 0.4);
591
+ const showBubble = refT >= msg.bubbleStart;
592
+ const isOut = msg.side === "right";
593
+ return /* @__PURE__ */ jsxs(React.Fragment, { children: [
594
+ showTyping && /* @__PURE__ */ jsx("div", { style: { opacity: typingPop * typingFade }, children: /* @__PURE__ */ jsx(
595
+ TypingBubble,
596
+ {
597
+ side: msg.side,
598
+ pop: typingPop,
599
+ realTimeSeconds,
600
+ s,
601
+ theme: "messenger"
602
+ }
603
+ ) }),
604
+ showBubble && /* @__PURE__ */ jsx(
605
+ "div",
606
+ {
607
+ style: {
608
+ display: "flex",
609
+ justifyContent: isOut ? "flex-end" : "flex-start",
610
+ padding: `${2 * s}px ${14 * s}px`,
611
+ opacity: bubblePop,
612
+ transform: `translateY(${(1 - bubblePop) * 8 * s}px) scale(${0.96 + 0.04 * bubblePop})`,
613
+ transformOrigin: isOut ? "right bottom" : "left bottom"
614
+ },
615
+ children: /* @__PURE__ */ jsx(
616
+ "div",
617
+ {
618
+ style: {
619
+ maxWidth: "75%",
620
+ background: isOut ? IM.bubbleOut : IM.bubbleIn,
621
+ color: isOut ? IM.textOut : IM.textIn,
622
+ borderRadius: 22 * s,
623
+ padding: `${12 * s}px ${18 * s}px`,
624
+ fontSize: 23 * s,
625
+ lineHeight: `${29 * s}px`
626
+ },
627
+ children: renderWithEmoji(msg.text, 23 * s)
628
+ }
629
+ )
630
+ }
631
+ )
632
+ ] }, i);
633
+ })
634
+ }
635
+ )
636
+ }
637
+ );
638
+ };
639
+
640
+ // src/visual-system/scene-templates/social-conversation.tsx
641
+ import { jsx as jsx2 } from "react/jsx-runtime";
642
+ var DEFAULT_SIDES = {
643
+ 1: "left",
644
+ 2: "right",
645
+ 3: "left",
646
+ 4: "right",
647
+ 5: "right"
648
+ };
649
+ function buildConversationMessages(variables) {
650
+ const messages = [];
651
+ for (let index = 1; index <= 5; index += 1) {
652
+ let text = normalizeTextVar(variables[`msg${index}`]).trim();
653
+ if (!text) continue;
654
+ let side = DEFAULT_SIDES[index] ?? (index % 2 === 1 ? "left" : "right");
655
+ if (text.endsWith("|in")) {
656
+ side = "left";
657
+ text = text.slice(0, -3).trim();
658
+ } else if (text.endsWith("|out")) {
659
+ side = "right";
660
+ text = text.slice(0, -4).trim();
661
+ }
662
+ messages.push({ author: side === "left" ? "Customer" : "You", text, side });
663
+ }
664
+ return messages;
665
+ }
666
+ var SocialConversationTemplate = ({
667
+ variables,
668
+ progress,
669
+ beatIntensity,
670
+ width,
671
+ height,
672
+ sceneDuration,
673
+ safeZone
674
+ }) => {
675
+ const theme = String(variables.theme || "messenger").toLowerCase() === "whatsapp" ? "whatsapp" : "messenger";
676
+ return /* @__PURE__ */ jsx2("div", { style: { width, height, position: "relative", overflow: "hidden", backgroundColor: theme === "whatsapp" ? "#EFE7DC" : "#ffffff" }, children: /* @__PURE__ */ jsx2(
677
+ ConversationThread,
678
+ {
679
+ progress,
680
+ width,
681
+ height,
682
+ sceneDuration: sceneDuration ?? 8,
683
+ messages: buildConversationMessages(variables),
684
+ theme,
685
+ dateChip1: String(variables.dateChip1 || ""),
686
+ dateChip2: String(variables.dateChip2 || ""),
687
+ safeZoneTop: Math.max(safeZone.top, height * 0.08),
688
+ beatIntensity
689
+ }
690
+ ) });
691
+ };
692
+ export {
693
+ SocialConversationTemplate,
694
+ buildConversationMessages
695
+ };