daply-ui 0.0.0 → 1.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.
package/dist/daply-ui.js CHANGED
@@ -1,5 +1,1062 @@
1
- import { jsx as o } from "react/jsx-runtime";
2
- const n = ({ children: t }) => /* @__PURE__ */ o("button", { children: t });
1
+ import { jsxs as d, jsx as e, Fragment as A } from "react/jsx-runtime";
2
+ import { useState as C } from "react";
3
+ const ne = {
4
+ small: {
5
+ fontSize: "14px",
6
+ padding: "8px 16px"
7
+ },
8
+ default: {
9
+ fontSize: "16px",
10
+ padding: "12px 24px"
11
+ },
12
+ large: {
13
+ fontSize: "18px",
14
+ padding: "16px 32px"
15
+ }
16
+ }, ye = ({
17
+ label: o,
18
+ disabled: i = !1,
19
+ color: s = "blue-900",
20
+ icon: r,
21
+ className: L = "",
22
+ style: I = {},
23
+ type: h = "button",
24
+ iconPosition: m = "right",
25
+ isNoLabelForSm: j = !1,
26
+ size: S = "default",
27
+ onClick: F = () => {
28
+ },
29
+ children: c,
30
+ variant: w = "primary",
31
+ theme: M = "auto"
32
+ }) => {
33
+ const g = M === "dark" || M === "auto" && typeof window < "u" && window.matchMedia("(prefers-color-scheme: dark)").matches, v = ne[S] || ne.default, B = c || /* @__PURE__ */ d(A, { children: [
34
+ m === "left" && r && /* @__PURE__ */ e("span", { style: { display: "flex", alignItems: "center" }, children: r }),
35
+ !j && o && /* @__PURE__ */ e("span", { style: { display: "flex", alignItems: "center" }, children: o }),
36
+ m === "right" && r && /* @__PURE__ */ e("span", { style: { display: "flex", alignItems: "center" }, children: r })
37
+ ] }), k = w === "primary" || s.includes("blue-700") || s.includes("blue-600") || s.includes("blue-500"), p = w === "secondary", u = {
38
+ position: "relative",
39
+ display: "inline-block",
40
+ width: "100%"
41
+ }, z = {
42
+ position: "absolute",
43
+ inset: 0,
44
+ backgroundColor: i ? "#374151" : k ? "#1d4ed8" : p ? g ? "#1f2937" : "#e5e7eb" : "#1e3a8a",
45
+ borderRadius: "8px",
46
+ transform: "translateY(4px)",
47
+ transition: "all 0.3s ease"
48
+ }, W = {
49
+ ...v,
50
+ color: p ? g ? "#ffffff" : "#1f2937" : "#ffffff",
51
+ borderRadius: "8px",
52
+ backgroundColor: p ? g ? "#000000" : "#f3f4f6" : k ? "#3b82f6" : "#000000",
53
+ position: "relative",
54
+ border: p ? g ? "1px solid #1e3a8a" : "1px solid #e5e7eb" : k ? "1px solid #1e3a8a" : i ? "1px solid #374151" : "1px solid #1e3a8a",
55
+ display: "flex",
56
+ width: "100%",
57
+ justifyContent: "center",
58
+ alignItems: "center",
59
+ fontWeight: "800",
60
+ gap: "8px",
61
+ transition: "all 0.3s ease",
62
+ cursor: i ? "not-allowed" : "pointer",
63
+ opacity: i ? 0.5 : 1,
64
+ outline: "none",
65
+ fontFamily: "inherit",
66
+ ...I
67
+ }, [D, y] = C(!1), b = () => {
68
+ i || y(!0);
69
+ }, H = () => {
70
+ y(!1);
71
+ };
72
+ return /* @__PURE__ */ d("div", { style: u, className: L, children: [
73
+ /* @__PURE__ */ e("div", { style: z }),
74
+ /* @__PURE__ */ e(
75
+ "button",
76
+ {
77
+ type: h,
78
+ style: { ...W, ...D && !i ? {
79
+ transform: "translateY(4px)",
80
+ color: p ? g ? "#ffffff" : "#1f2937" : "#93c5fd",
81
+ backgroundColor: p ? g ? "#111827" : "#e5e7eb" : void 0
82
+ } : {} },
83
+ disabled: i,
84
+ onClick: F,
85
+ onMouseEnter: b,
86
+ onMouseLeave: H,
87
+ children: B
88
+ }
89
+ )
90
+ ] });
91
+ }, re = ({ name: o, value: i, onChange: s, error: r, schema: L, theme: I = "auto" }) => {
92
+ const {
93
+ type: h = "text",
94
+ required: m = !1,
95
+ placeholder: j = "",
96
+ label: S,
97
+ className: F = ""
98
+ } = L, c = I === "dark" || I === "auto" && typeof window < "u" && window.matchMedia("(prefers-color-scheme: dark)").matches, w = {
99
+ width: "100%",
100
+ boxSizing: "border-box",
101
+ // 👈 CRITICAL
102
+ padding: "16px",
103
+ borderRadius: "8px",
104
+ outline: "none",
105
+ transition: "all 0.2s ease",
106
+ fontSize: "16px",
107
+ fontFamily: "inherit",
108
+ border: r ? `2px solid ${c ? "#f87171" : "#ef4444"}` : `1px solid ${c ? "#374151" : "#d1d5db"}`,
109
+ backgroundColor: r ? c ? "rgba(153, 27, 27, 0.1)" : "rgba(254, 226, 226, 1)" : c ? "#2a2a2a" : "#ffffff",
110
+ color: c ? "#ffffff" : "#111827"
111
+ }, M = {
112
+ ...w,
113
+ borderColor: r ? c ? "#f87171" : "#ef4444" : "#3b82f6",
114
+ boxShadow: r ? `0 0 0 3px ${c ? "rgba(248, 113, 113, 0.2)" : "rgba(239, 68, 68, 0.2)"}` : "0 0 0 3px rgba(59, 130, 246, 0.2)"
115
+ }, g = {
116
+ display: "block",
117
+ fontWeight: "500",
118
+ marginBottom: "8px",
119
+ color: c ? "#ffffff" : "#111827",
120
+ fontSize: "14px"
121
+ }, v = {
122
+ marginTop: "4px",
123
+ fontSize: "14px",
124
+ color: c ? "#f87171" : "#dc2626"
125
+ }, B = {
126
+ color: c ? "#f87171" : "#ef4444",
127
+ marginLeft: "4px"
128
+ }, k = {
129
+ marginBottom: "24px",
130
+ display: "flex",
131
+ flexDirection: "column",
132
+ alignItems: "flex-start",
133
+ width: "100%"
134
+ }, p = c ? "#6b7280" : "#9ca3af";
135
+ return h === "textarea" ? /* @__PURE__ */ d("div", { style: k, children: [
136
+ S ? /* @__PURE__ */ d("label", { htmlFor: o, style: g, children: [
137
+ S,
138
+ m ? /* @__PURE__ */ e("span", { style: B, children: "*" }) : null
139
+ ] }) : null,
140
+ /* @__PURE__ */ e(
141
+ "textarea",
142
+ {
143
+ id: o,
144
+ name: o,
145
+ value: i,
146
+ onChange: s,
147
+ required: m,
148
+ placeholder: j,
149
+ rows: L.rows || 4,
150
+ style: w,
151
+ onFocus: (u) => {
152
+ Object.assign(u.target.style, M);
153
+ },
154
+ onBlur: (u) => {
155
+ Object.assign(u.target.style, w);
156
+ },
157
+ className: F
158
+ }
159
+ ),
160
+ r ? /* @__PURE__ */ e("p", { style: v, children: r }) : null,
161
+ /* @__PURE__ */ e("style", { children: `
162
+ textarea::placeholder { color: ${p}; }
163
+ ` })
164
+ ] }) : /* @__PURE__ */ d("div", { style: k, children: [
165
+ S ? /* @__PURE__ */ d("label", { htmlFor: o, style: g, children: [
166
+ S,
167
+ m ? /* @__PURE__ */ e("span", { style: B, children: "*" }) : null
168
+ ] }) : null,
169
+ /* @__PURE__ */ e(
170
+ "input",
171
+ {
172
+ id: o,
173
+ name: o,
174
+ type: h,
175
+ value: i,
176
+ onChange: s,
177
+ required: m,
178
+ placeholder: j,
179
+ style: w,
180
+ onFocus: (u) => {
181
+ Object.assign(u.target.style, M);
182
+ },
183
+ onBlur: (u) => {
184
+ Object.assign(u.target.style, w);
185
+ },
186
+ className: F
187
+ }
188
+ ),
189
+ r ? /* @__PURE__ */ e("p", { style: v, children: r }) : null,
190
+ /* @__PURE__ */ e("style", { children: `
191
+ input::placeholder { color: ${p}; }
192
+ ` })
193
+ ] });
194
+ }, xe = (o) => {
195
+ const {
196
+ formId: i,
197
+ siteId: s,
198
+ fields: r,
199
+ baseUrl: L,
200
+ apiToken: I,
201
+ encryptedDbName: h,
202
+ pageUrl: m,
203
+ pageId: j,
204
+ sessionId: S,
205
+ metadata: F,
206
+ onSuccess: c,
207
+ onError: w,
208
+ submitButtonText: M = "Submit",
209
+ submitButtonClassName: g = "",
210
+ formClassName: v = "",
211
+ loadingText: B = "Submitting...",
212
+ theme: k = "auto"
213
+ } = o, p = r.reduce((t, n) => (t[n.name] = n.defaultValue || "", t), {}), [u, z] = C(p), [W, D] = C({}), [y, b] = C(!1), [H, P] = C(!1), N = k === "dark" || k === "auto" && typeof window < "u" && window.matchMedia("(prefers-color-scheme: dark)").matches, J = (t) => {
214
+ const { name: n, value: $ } = t.target;
215
+ z((f) => ({
216
+ ...f,
217
+ [n]: $
218
+ })), W[n] && D((f) => {
219
+ const R = { ...f };
220
+ return delete R[n], R;
221
+ });
222
+ }, _ = () => {
223
+ const t = {};
224
+ return r.forEach((n) => {
225
+ const $ = u[n.name], f = String($ || "");
226
+ if (n.required && !f.trim()) {
227
+ t[n.name] = `${n.label || n.name} is required`;
228
+ return;
229
+ }
230
+ if (n.type === "email" && f && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(f)) {
231
+ t[n.name] = "Please enter a valid email address";
232
+ return;
233
+ }
234
+ if (n.type === "url" && f)
235
+ try {
236
+ new URL(f);
237
+ } catch {
238
+ t[n.name] = "Please enter a valid URL";
239
+ return;
240
+ }
241
+ if (n.validation && f) {
242
+ const R = n.validation(f);
243
+ if (R) {
244
+ t[n.name] = R;
245
+ return;
246
+ }
247
+ }
248
+ }), D(t), Object.keys(t).length === 0;
249
+ }, E = async (t) => {
250
+ if (t.preventDefault(), !!_()) {
251
+ b(!0);
252
+ try {
253
+ const n = r.reduce((O, Y) => (O[Y.name] = {
254
+ type: Y.type,
255
+ required: Y.required
256
+ }, O), {}), $ = {
257
+ formId: i,
258
+ siteId: s,
259
+ formData: u,
260
+ formSchema: n,
261
+ ...m && { pageUrl: m },
262
+ ...j && { pageId: j },
263
+ ...S && { sessionId: S },
264
+ ...F && { metadata: F }
265
+ }, f = await fetch(`${L}/api/v1/form-submissions`, {
266
+ method: "POST",
267
+ headers: {
268
+ "Content-Type": "application/json",
269
+ Authorization: `Bearer ${I}`,
270
+ "x-encrypted-db-name": h
271
+ },
272
+ body: JSON.stringify($)
273
+ });
274
+ if (!f.ok) {
275
+ const O = await f.json().catch(() => ({}));
276
+ throw new Error(O.message || `HTTP error! status: ${f.status}`);
277
+ }
278
+ const R = await f.json();
279
+ z(p), D({}), c && c(R);
280
+ } catch (n) {
281
+ console.error("Form submission error:", n), w && w(n);
282
+ } finally {
283
+ b(!1);
284
+ }
285
+ }
286
+ }, X = {
287
+ maxWidth: "612px",
288
+ margin: "0 auto",
289
+ padding: "32px",
290
+ backgroundColor: N ? "#1a1a1a" : "#ffffff",
291
+ borderRadius: "12px",
292
+ boxShadow: N ? "0 25px 50px -12px rgba(0, 0, 0, 0.5)" : "0 10px 15px -3px rgba(0, 0, 0, 0.1)",
293
+ border: `1px solid ${N ? "#1f2937" : "#e5e7eb"}`
294
+ }, V = {
295
+ width: "100%",
296
+ padding: "16px 24px",
297
+ background: y ? "linear-gradient(to right, #4b5563, #4b5563)" : H ? "linear-gradient(to right, #1d4ed8, #1e40af)" : "linear-gradient(to right, #2563eb, #1d4ed8)",
298
+ color: "#ffffff",
299
+ fontWeight: "bold",
300
+ fontSize: "18px",
301
+ textTransform: "uppercase",
302
+ letterSpacing: "0.05em",
303
+ borderRadius: "8px",
304
+ border: "none",
305
+ cursor: y ? "not-allowed" : "pointer",
306
+ opacity: y ? 0.5 : 1,
307
+ transition: "all 0.2s ease",
308
+ outline: "none",
309
+ fontFamily: "inherit"
310
+ };
311
+ return /* @__PURE__ */ d(
312
+ "form",
313
+ {
314
+ onSubmit: E,
315
+ style: X,
316
+ className: v,
317
+ children: [
318
+ r.map((t) => /* @__PURE__ */ e(
319
+ re,
320
+ {
321
+ name: t.name,
322
+ value: String(u[t.name] || ""),
323
+ onChange: J,
324
+ error: W[t.name],
325
+ schema: t,
326
+ theme: k
327
+ },
328
+ t.name
329
+ )),
330
+ /* @__PURE__ */ e(
331
+ "button",
332
+ {
333
+ type: "submit",
334
+ disabled: y,
335
+ style: V,
336
+ onMouseEnter: () => !y && P(!0),
337
+ onMouseLeave: () => P(!1),
338
+ onFocus: (t) => {
339
+ y || (t.target.style.boxShadow = "0 0 0 3px rgba(59, 130, 246, 0.3)");
340
+ },
341
+ onBlur: (t) => {
342
+ t.target.style.boxShadow = "none";
343
+ },
344
+ className: g,
345
+ children: y ? B : M
346
+ }
347
+ )
348
+ ]
349
+ }
350
+ );
351
+ }, Se = ({
352
+ steps: o,
353
+ formId: i,
354
+ siteId: s,
355
+ baseUrl: r,
356
+ apiToken: L,
357
+ encryptedDbName: I,
358
+ pageUrl: h,
359
+ pageId: m,
360
+ sessionId: j,
361
+ metadata: S,
362
+ onSuccess: F,
363
+ onError: c,
364
+ submitButtonText: w = "Submit",
365
+ submitButtonClassName: M = "",
366
+ formClassName: g = "",
367
+ loadingText: v = "Submitting...",
368
+ theme: B = "auto",
369
+ showStepIndicator: k = !0
370
+ }) => {
371
+ const [p, u] = C(0), [z, W] = C({}), [D, y] = C({}), [b, H] = C(!1), [P, N] = C(!1), [J, _] = C(!1), E = o[p], X = p === 0, V = p === o.length - 1, t = B === "dark" || B === "auto" && typeof window < "u" && window.matchMedia("(prefers-color-scheme: dark)").matches, n = (a) => {
372
+ const { name: l, value: Z } = a.target;
373
+ W((x) => ({
374
+ ...x,
375
+ [l]: Z
376
+ })), D[l] && y((x) => {
377
+ const q = { ...x };
378
+ return delete q[l], q;
379
+ });
380
+ }, $ = () => {
381
+ const a = {};
382
+ return E.fields.forEach((l) => {
383
+ const Z = z[l.name], x = String(Z || "");
384
+ if (l.required && !x.trim()) {
385
+ a[l.name] = `${l.label || l.name} is required`;
386
+ return;
387
+ }
388
+ if (l.type === "email" && x && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(x)) {
389
+ a[l.name] = "Please enter a valid email address";
390
+ return;
391
+ }
392
+ if (l.type === "url" && x)
393
+ try {
394
+ new URL(x);
395
+ } catch {
396
+ a[l.name] = "Please enter a valid URL";
397
+ return;
398
+ }
399
+ if (l.validation && x) {
400
+ const q = l.validation(x);
401
+ if (q) {
402
+ a[l.name] = q;
403
+ return;
404
+ }
405
+ }
406
+ }), y(a), Object.keys(a).length === 0;
407
+ }, f = () => {
408
+ $() && (u((a) => Math.min(a + 1, o.length - 1)), window.scrollTo({ top: 0, behavior: "smooth" }));
409
+ }, R = () => {
410
+ u((a) => Math.max(a - 1, 0)), window.scrollTo({ top: 0, behavior: "smooth" });
411
+ }, O = async (a) => {
412
+ if (a.preventDefault(), !V) {
413
+ f();
414
+ return;
415
+ }
416
+ if ($()) {
417
+ H(!0);
418
+ try {
419
+ const l = o.reduce((K, ce) => (ce.fields.forEach((te) => {
420
+ K[te.name] = {
421
+ type: te.type,
422
+ required: te.required
423
+ };
424
+ }), K), {}), Z = {
425
+ formId: i,
426
+ siteId: s,
427
+ formData: z,
428
+ formSchema: l,
429
+ ...h && { pageUrl: h },
430
+ ...m && { pageId: m },
431
+ ...j && { sessionId: j },
432
+ ...S && { metadata: S }
433
+ }, x = await fetch(`${r}/api/v1/form-submissions`, {
434
+ method: "POST",
435
+ headers: {
436
+ "Content-Type": "application/json",
437
+ Authorization: `Bearer ${L}`,
438
+ "x-encrypted-db-name": I
439
+ },
440
+ body: JSON.stringify(Z)
441
+ });
442
+ if (!x.ok) {
443
+ const K = await x.json().catch(() => ({}));
444
+ throw new Error(
445
+ K.message || `HTTP error! status: ${x.status}`
446
+ );
447
+ }
448
+ const q = await x.json();
449
+ W({}), y({}), u(0), F && F(q);
450
+ } catch (l) {
451
+ console.error("Form submission error:", l), c && c(l);
452
+ } finally {
453
+ H(!1);
454
+ }
455
+ }
456
+ }, Y = {
457
+ maxWidth: "612px",
458
+ margin: "0 auto",
459
+ padding: "32px",
460
+ backgroundColor: t ? "#1a1a1a" : "#ffffff",
461
+ borderRadius: "12px",
462
+ boxShadow: t ? "0 25px 50px -12px rgba(0, 0, 0, 0.5)" : "0 10px 15px -3px rgba(0, 0, 0, 0.1)",
463
+ border: `1px solid ${t ? "#1f2937" : "#e5e7eb"}`
464
+ }, G = {
465
+ display: "flex",
466
+ justifyContent: "space-between",
467
+ alignItems: "center",
468
+ marginBottom: "32px",
469
+ gap: "8px"
470
+ }, Q = (a) => ({
471
+ flex: 1,
472
+ height: "4px",
473
+ borderRadius: "2px",
474
+ backgroundColor: a <= p ? "#2563eb" : t ? "#374151" : "#e5e7eb",
475
+ transition: "background-color 0.3s ease"
476
+ }), U = {
477
+ fontSize: "24px",
478
+ fontWeight: "bold",
479
+ color: t ? "#ffffff" : "#111827",
480
+ marginBottom: "8px"
481
+ }, ee = {
482
+ fontSize: "14px",
483
+ color: t ? "#9ca3af" : "#6b7280",
484
+ marginBottom: "24px"
485
+ }, T = {
486
+ fontSize: "14px",
487
+ fontWeight: "500",
488
+ color: t ? "#9ca3af" : "#6b7280",
489
+ marginBottom: "16px"
490
+ }, ae = {
491
+ position: "fixed",
492
+ bottom: "1rem",
493
+ left: "50%",
494
+ transform: "translateX(-50%)",
495
+ width: "calc(100% - 2rem)",
496
+ maxWidth: "500px",
497
+ zIndex: 50
498
+ }, ie = {
499
+ background: t ? "rgba(255, 255, 255, 0.1)" : "rgba(0, 0, 0, 0.05)",
500
+ backdropFilter: "blur(20px) saturate(120%)",
501
+ WebkitBackdropFilter: "blur(20px) saturate(120%)",
502
+ border: t ? "1px solid rgba(255, 255, 255, 0.2)" : "1px solid rgba(0, 0, 0, 0.1)",
503
+ borderRadius: "16px",
504
+ padding: "16px",
505
+ boxShadow: t ? "0 25px 50px -12px rgba(0, 0, 0, 0.8)" : "0 25px 50px -12px rgba(0, 0, 0, 0.25)",
506
+ display: "flex",
507
+ justifyContent: "space-between",
508
+ alignItems: "center",
509
+ gap: "16px",
510
+ transition: "all 0.3s ease-in-out"
511
+ }, se = {
512
+ width: "64px",
513
+ minWidth: "64px",
514
+ height: "64px",
515
+ padding: "0",
516
+ background: t ? "#e2e8f0" : "#f1f5f9",
517
+ color: t ? "#111827" : "#475569",
518
+ borderRadius: "12px",
519
+ border: "none",
520
+ cursor: "pointer",
521
+ transition: "all 0.3s ease",
522
+ outline: "none",
523
+ fontFamily: "inherit",
524
+ display: "flex",
525
+ alignItems: "center",
526
+ justifyContent: "center",
527
+ boxShadow: "0 4px 6px -1px rgba(0, 0, 0, 0.1)",
528
+ transform: J ? "scale(1.03)" : "scale(1)"
529
+ }, oe = {
530
+ flex: 1,
531
+ height: "64px",
532
+ padding: "16px 24px",
533
+ background: b ? t ? "#4b5563" : "#94a3b8" : P ? t ? "#1e40af" : "#1d4ed8" : t ? "#2563eb" : "#3b82f6",
534
+ color: "#ffffff",
535
+ fontWeight: "bold",
536
+ fontSize: "20px",
537
+ textTransform: "uppercase",
538
+ letterSpacing: "0.05em",
539
+ borderRadius: "12px",
540
+ border: "none",
541
+ cursor: b ? "not-allowed" : "pointer",
542
+ opacity: b ? 0.5 : 1,
543
+ transition: "all 0.3s ease",
544
+ outline: "none",
545
+ fontFamily: "inherit",
546
+ display: "flex",
547
+ alignItems: "center",
548
+ justifyContent: "center",
549
+ gap: "8px",
550
+ boxShadow: "0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",
551
+ transform: P && !b ? "scale(1.03)" : "scale(1)"
552
+ }, le = {
553
+ ...oe,
554
+ background: b ? "#4b5563" : P ? "#15803d" : "#16a34a"
555
+ }, de = {
556
+ marginBottom: "160px"
557
+ // Space for floating navigation
558
+ };
559
+ return /* @__PURE__ */ d("form", { onSubmit: O, style: Y, className: g, children: [
560
+ k && /* @__PURE__ */ d(A, { children: [
561
+ /* @__PURE__ */ d("div", { style: T, children: [
562
+ "Step ",
563
+ p + 1,
564
+ " of ",
565
+ o.length
566
+ ] }),
567
+ /* @__PURE__ */ e("div", { style: G, children: o.map((a, l) => /* @__PURE__ */ e("div", { style: Q(l) }, l)) })
568
+ ] }),
569
+ E.title && /* @__PURE__ */ e("h2", { style: U, children: E.title }),
570
+ E.description && /* @__PURE__ */ e("p", { style: ee, children: E.description }),
571
+ /* @__PURE__ */ e("div", { style: de, children: E.fields.map((a) => /* @__PURE__ */ e(
572
+ re,
573
+ {
574
+ name: a.name,
575
+ value: String(z[a.name] || ""),
576
+ onChange: n,
577
+ error: D[a.name],
578
+ schema: a,
579
+ theme: B
580
+ },
581
+ a.name
582
+ )) }),
583
+ /* @__PURE__ */ e("div", { style: ae, children: /* @__PURE__ */ d("div", { style: ie, children: [
584
+ !X && /* @__PURE__ */ e(
585
+ "button",
586
+ {
587
+ type: "button",
588
+ onClick: R,
589
+ style: se,
590
+ onMouseEnter: () => _(!0),
591
+ onMouseLeave: () => _(!1),
592
+ disabled: b,
593
+ "aria-label": "Previous step",
594
+ children: /* @__PURE__ */ e(
595
+ "svg",
596
+ {
597
+ width: "24",
598
+ height: "24",
599
+ viewBox: "0 0 24 24",
600
+ fill: "none",
601
+ stroke: "currentColor",
602
+ strokeWidth: "2",
603
+ strokeLinecap: "round",
604
+ strokeLinejoin: "round",
605
+ children: /* @__PURE__ */ e("path", { d: "m15 18-6-6 6-6" })
606
+ }
607
+ )
608
+ }
609
+ ),
610
+ /* @__PURE__ */ e(
611
+ "button",
612
+ {
613
+ type: "submit",
614
+ disabled: b,
615
+ style: V ? le : oe,
616
+ onMouseEnter: () => !b && N(!0),
617
+ onMouseLeave: () => N(!1),
618
+ onFocus: (a) => {
619
+ b || (a.target.style.boxShadow = "0 0 0 3px rgba(59, 130, 246, 0.3)");
620
+ },
621
+ onBlur: (a) => {
622
+ a.target.style.boxShadow = "0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)";
623
+ },
624
+ className: M,
625
+ children: b ? /* @__PURE__ */ d(A, { children: [
626
+ /* @__PURE__ */ e(
627
+ "svg",
628
+ {
629
+ width: "20",
630
+ height: "20",
631
+ viewBox: "0 0 24 24",
632
+ fill: "none",
633
+ stroke: "currentColor",
634
+ strokeWidth: "2",
635
+ strokeLinecap: "round",
636
+ strokeLinejoin: "round",
637
+ style: {
638
+ animation: "spin 1s linear infinite"
639
+ },
640
+ children: /* @__PURE__ */ e("path", { d: "M21 12a9 9 0 1 1-6.219-8.56" })
641
+ }
642
+ ),
643
+ /* @__PURE__ */ e("style", { children: `
644
+ @keyframes spin {
645
+ from { transform: rotate(0deg); }
646
+ to { transform: rotate(360deg); }
647
+ }
648
+ ` }),
649
+ v
650
+ ] }) : V ? /* @__PURE__ */ d(A, { children: [
651
+ w,
652
+ /* @__PURE__ */ d(
653
+ "svg",
654
+ {
655
+ width: "20",
656
+ height: "20",
657
+ viewBox: "0 0 24 24",
658
+ fill: "none",
659
+ stroke: "currentColor",
660
+ strokeWidth: "2",
661
+ strokeLinecap: "round",
662
+ strokeLinejoin: "round",
663
+ children: [
664
+ /* @__PURE__ */ e("path", { d: "m22 2-7 20-4-9-9-4Z" }),
665
+ /* @__PURE__ */ e("path", { d: "M22 2 11 13" })
666
+ ]
667
+ }
668
+ )
669
+ ] }) : /* @__PURE__ */ d(A, { children: [
670
+ "Next",
671
+ /* @__PURE__ */ e(
672
+ "svg",
673
+ {
674
+ width: "20",
675
+ height: "20",
676
+ viewBox: "0 0 24 24",
677
+ fill: "none",
678
+ stroke: "currentColor",
679
+ strokeWidth: "2",
680
+ strokeLinecap: "round",
681
+ strokeLinejoin: "round",
682
+ children: /* @__PURE__ */ e("path", { d: "m9 18 6-6-6-6" })
683
+ }
684
+ )
685
+ ] })
686
+ }
687
+ )
688
+ ] }) })
689
+ ] });
690
+ }, pe = (o) => {
691
+ const i = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/, s = o.match(i);
692
+ return s && s[2].length === 11 ? s[2] : null;
693
+ }, ue = (o, i = !0) => {
694
+ const s = pe(o);
695
+ if (!s) return o;
696
+ const r = new URLSearchParams({
697
+ autoplay: i ? "1" : "0",
698
+ rel: "0",
699
+ // Don't show related videos
700
+ modestbranding: "1",
701
+ // Minimal YouTube branding
702
+ showinfo: "0",
703
+ // Don't show video info
704
+ fs: "1",
705
+ // Allow fullscreen
706
+ enablejsapi: "1",
707
+ // Enable JS API
708
+ playsinline: "1",
709
+ // Play inline on mobile
710
+ controls: "1",
711
+ // Show controls
712
+ disablekb: "0",
713
+ // Enable keyboard controls
714
+ iv_load_policy: "3",
715
+ // Don't show annotations
716
+ cc_load_policy: "0",
717
+ // Don't show captions by default
718
+ start: "0",
719
+ // Start from beginning
720
+ origin: typeof window < "u" ? window.location.origin : ""
721
+ });
722
+ return `https://www.youtube.com/embed/${s}?${r.toString()}`;
723
+ }, fe = (o, i, s, r, L) => {
724
+ const I = "https://app.daply.ai/embed/video", h = new URLSearchParams({
725
+ src: o,
726
+ title: i,
727
+ author: s || "",
728
+ date: r || (/* @__PURE__ */ new Date()).toISOString()
729
+ });
730
+ return L && h.append("autoplay", "1"), `${I}?${h.toString()}`;
731
+ }, he = (o) => o.includes("storage.googleapis.com/daply-transcoder-storage") && o.includes("manifest.m3u8"), ge = (o) => o.includes(".m3u8") || o.includes("/manifest.m3u8"), we = ({
732
+ videoUrl: o,
733
+ youtubeUrl: i,
734
+ title: s,
735
+ author: r = "Daply",
736
+ date: L = (/* @__PURE__ */ new Date()).toISOString(),
737
+ thumbnailUrl: I,
738
+ autoplay: h = !1,
739
+ className: m = "",
740
+ onVideoClick: j,
741
+ theme: S = "auto"
742
+ }) => {
743
+ const [F, c] = C(h), [w, M] = C(!h), [g, v] = C(!1), B = S === "dark" || S === "auto" && typeof window < "u" && window.matchMedia("(prefers-color-scheme: dark)").matches, k = !!i, p = o && he(o), u = o && ge(o), z = !!(o || i), W = () => {
744
+ v(!0), c(!0), M(!1), j && j(), setTimeout(() => v(!1), 1e3);
745
+ }, D = () => {
746
+ const T = i || o;
747
+ T && window.open(T, "_blank");
748
+ }, y = {
749
+ position: "relative",
750
+ aspectRatio: "16 / 9",
751
+ backgroundColor: "#000000",
752
+ borderRadius: "8px",
753
+ overflow: "hidden"
754
+ }, b = {
755
+ position: "relative",
756
+ width: "100%",
757
+ height: "100%"
758
+ }, H = {
759
+ width: "100%",
760
+ height: "100%",
761
+ objectFit: "cover"
762
+ }, P = {
763
+ width: "100%",
764
+ height: "100%",
765
+ background: "linear-gradient(135deg, #1f2937 0%, #111827 100%)",
766
+ display: "flex",
767
+ alignItems: "center",
768
+ justifyContent: "center"
769
+ }, N = {
770
+ position: "absolute",
771
+ inset: 0,
772
+ backgroundColor: "rgba(0, 0, 0, 0.4)"
773
+ }, J = {
774
+ position: "absolute",
775
+ inset: 0,
776
+ display: "flex",
777
+ alignItems: "center",
778
+ justifyContent: "center"
779
+ }, _ = {
780
+ width: "64px",
781
+ height: "64px",
782
+ borderRadius: "50%",
783
+ backgroundColor: "rgba(255, 255, 255, 0.2)",
784
+ backdropFilter: "blur(10px)",
785
+ border: "2px solid rgba(255, 255, 255, 0.2)",
786
+ cursor: "pointer",
787
+ display: "flex",
788
+ alignItems: "center",
789
+ justifyContent: "center",
790
+ transition: "all 0.3s ease"
791
+ }, E = {
792
+ position: "absolute",
793
+ bottom: 0,
794
+ left: 0,
795
+ right: 0,
796
+ background: "linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent)",
797
+ padding: "16px"
798
+ }, X = {
799
+ display: "flex",
800
+ alignItems: "center",
801
+ justifyContent: "space-between"
802
+ }, V = {
803
+ flex: 1
804
+ }, t = {
805
+ color: "#ffffff",
806
+ fontWeight: "500",
807
+ fontSize: "14px",
808
+ overflow: "hidden",
809
+ textOverflow: "ellipsis",
810
+ whiteSpace: "nowrap"
811
+ }, n = {
812
+ color: "rgba(255, 255, 255, 0.8)",
813
+ fontSize: "12px"
814
+ }, $ = {
815
+ position: "absolute",
816
+ top: "12px",
817
+ right: "12px",
818
+ padding: "4px 8px",
819
+ backgroundColor: "rgba(0, 0, 0, 0.6)",
820
+ backdropFilter: "blur(10px)",
821
+ borderRadius: "9999px",
822
+ fontSize: "12px",
823
+ color: "#ffffff"
824
+ }, f = {
825
+ width: "32px",
826
+ height: "32px",
827
+ padding: 0,
828
+ backgroundColor: "rgba(255, 255, 255, 0.2)",
829
+ backdropFilter: "blur(10px)",
830
+ borderRadius: "4px",
831
+ border: "none",
832
+ cursor: "pointer",
833
+ display: "flex",
834
+ alignItems: "center",
835
+ justifyContent: "center",
836
+ transition: "background-color 0.3s ease"
837
+ }, R = {
838
+ position: "absolute",
839
+ inset: 0,
840
+ backgroundColor: "rgba(0, 0, 0, 0.7)",
841
+ display: "flex",
842
+ alignItems: "center",
843
+ justifyContent: "center",
844
+ zIndex: 10
845
+ }, O = {
846
+ width: "32px",
847
+ height: "32px",
848
+ border: "2px solid transparent",
849
+ borderTopColor: "rgba(255, 255, 255, 0.8)",
850
+ borderRadius: "50%",
851
+ animation: "spin 1s linear infinite"
852
+ }, Y = {
853
+ width: "100%",
854
+ height: "100%",
855
+ position: "relative"
856
+ }, G = {
857
+ width: "100%",
858
+ height: "100%",
859
+ borderRadius: "8px",
860
+ backgroundColor: "#000000"
861
+ }, Q = {
862
+ width: "100%",
863
+ height: "100%",
864
+ objectFit: "cover",
865
+ borderRadius: "8px",
866
+ backgroundColor: "#000000"
867
+ }, U = {
868
+ aspectRatio: "16 / 9",
869
+ backgroundColor: B ? "#111827" : "#f3f4f6",
870
+ borderRadius: "8px",
871
+ display: "flex",
872
+ alignItems: "center",
873
+ justifyContent: "center"
874
+ }, ee = {
875
+ textAlign: "center",
876
+ color: B ? "#9ca3af" : "#6b7280"
877
+ };
878
+ return z ? /* @__PURE__ */ d(A, { children: [
879
+ /* @__PURE__ */ e("style", { children: `
880
+ @keyframes spin {
881
+ from { transform: rotate(0deg); }
882
+ to { transform: rotate(360deg); }
883
+ }
884
+ ` }),
885
+ /* @__PURE__ */ e("div", { style: y, className: m, children: w && !F ? /* @__PURE__ */ d("div", { style: b, children: [
886
+ I ? /* @__PURE__ */ e("img", { src: I, alt: s, style: H, loading: "lazy" }) : /* @__PURE__ */ e("div", { style: P, children: /* @__PURE__ */ d("div", { style: { textAlign: "center", color: "#ffffff" }, children: [
887
+ /* @__PURE__ */ e(
888
+ "div",
889
+ {
890
+ style: {
891
+ width: "48px",
892
+ height: "48px",
893
+ backgroundColor: "rgba(255, 255, 255, 0.2)",
894
+ borderRadius: "50%",
895
+ display: "flex",
896
+ alignItems: "center",
897
+ justifyContent: "center",
898
+ margin: "0 auto",
899
+ backdropFilter: "blur(10px)"
900
+ },
901
+ children: /* @__PURE__ */ e(
902
+ "svg",
903
+ {
904
+ style: { width: "24px", height: "24px", marginLeft: "4px" },
905
+ fill: "currentColor",
906
+ viewBox: "0 0 24 24",
907
+ children: /* @__PURE__ */ e("path", { d: "M8 5v14l11-7z" })
908
+ }
909
+ )
910
+ }
911
+ ),
912
+ /* @__PURE__ */ e("p", { style: { fontSize: "14px", fontWeight: "500", marginTop: "8px" }, children: s })
913
+ ] }) }),
914
+ /* @__PURE__ */ e("div", { style: N }),
915
+ /* @__PURE__ */ e("div", { style: J, children: /* @__PURE__ */ e(
916
+ "button",
917
+ {
918
+ onClick: W,
919
+ style: _,
920
+ onMouseEnter: (T) => {
921
+ T.currentTarget.style.backgroundColor = "rgba(255, 255, 255, 0.3)";
922
+ },
923
+ onMouseLeave: (T) => {
924
+ T.currentTarget.style.backgroundColor = "rgba(255, 255, 255, 0.2)";
925
+ },
926
+ children: /* @__PURE__ */ e(
927
+ "svg",
928
+ {
929
+ style: { width: "32px", height: "32px", color: "#ffffff", marginLeft: "4px" },
930
+ fill: "currentColor",
931
+ viewBox: "0 0 24 24",
932
+ children: /* @__PURE__ */ e("path", { d: "M8 5v14l11-7z" })
933
+ }
934
+ )
935
+ }
936
+ ) }),
937
+ /* @__PURE__ */ e("div", { style: E, children: /* @__PURE__ */ d("div", { style: X, children: [
938
+ /* @__PURE__ */ d("div", { style: V, children: [
939
+ /* @__PURE__ */ e("h4", { style: t, children: s }),
940
+ /* @__PURE__ */ d("p", { style: n, children: [
941
+ r,
942
+ " • ",
943
+ new Date(L).toLocaleDateString()
944
+ ] })
945
+ ] }),
946
+ /* @__PURE__ */ e("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: /* @__PURE__ */ e(
947
+ "button",
948
+ {
949
+ onClick: D,
950
+ style: f,
951
+ onMouseEnter: (T) => {
952
+ T.currentTarget.style.backgroundColor = "rgba(255, 255, 255, 0.3)";
953
+ },
954
+ onMouseLeave: (T) => {
955
+ T.currentTarget.style.backgroundColor = "rgba(255, 255, 255, 0.2)";
956
+ },
957
+ children: /* @__PURE__ */ e(
958
+ "svg",
959
+ {
960
+ style: { width: "16px", height: "16px", color: "#ffffff" },
961
+ fill: "none",
962
+ stroke: "currentColor",
963
+ viewBox: "0 0 24 24",
964
+ children: /* @__PURE__ */ e(
965
+ "path",
966
+ {
967
+ strokeLinecap: "round",
968
+ strokeLinejoin: "round",
969
+ strokeWidth: 2,
970
+ d: "M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"
971
+ }
972
+ )
973
+ }
974
+ )
975
+ }
976
+ ) })
977
+ ] }) }),
978
+ /* @__PURE__ */ e("div", { style: $, children: k ? "YouTube" : p ? "HLS Stream" : u ? "Live Stream" : "Video" })
979
+ ] }) : /* @__PURE__ */ d("div", { style: Y, children: [
980
+ g && /* @__PURE__ */ e("div", { style: R, children: /* @__PURE__ */ e("div", { style: O }) }),
981
+ k && i ? /* @__PURE__ */ e(
982
+ "iframe",
983
+ {
984
+ src: ue(i, h),
985
+ width: "100%",
986
+ height: "100%",
987
+ frameBorder: "0",
988
+ allowFullScreen: !0,
989
+ allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",
990
+ title: s,
991
+ style: G,
992
+ loading: "lazy",
993
+ onLoad: () => v(!1),
994
+ onError: () => v(!1)
995
+ }
996
+ ) : p || u ? /* @__PURE__ */ e(
997
+ "iframe",
998
+ {
999
+ src: fe(o, s, r, L, h),
1000
+ width: "100%",
1001
+ height: "100%",
1002
+ frameBorder: "0",
1003
+ allowFullScreen: !0,
1004
+ allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",
1005
+ title: `${s} - Video Player`,
1006
+ style: G,
1007
+ onLoad: () => v(!1)
1008
+ }
1009
+ ) : /* @__PURE__ */ e(
1010
+ "video",
1011
+ {
1012
+ src: o ?? void 0,
1013
+ controls: !0,
1014
+ autoPlay: h,
1015
+ preload: "metadata",
1016
+ controlsList: "nodownload",
1017
+ style: Q,
1018
+ onLoadStart: () => v(!1),
1019
+ children: "Your browser does not support the video tag."
1020
+ }
1021
+ )
1022
+ ] }) })
1023
+ ] }) : /* @__PURE__ */ e("div", { style: U, className: m, children: /* @__PURE__ */ d("div", { style: ee, children: [
1024
+ /* @__PURE__ */ d(
1025
+ "svg",
1026
+ {
1027
+ style: { width: "48px", height: "48px", margin: "0 auto 8px", opacity: 0.5 },
1028
+ fill: "none",
1029
+ stroke: "currentColor",
1030
+ viewBox: "0 0 24 24",
1031
+ children: [
1032
+ /* @__PURE__ */ e(
1033
+ "path",
1034
+ {
1035
+ strokeLinecap: "round",
1036
+ strokeLinejoin: "round",
1037
+ strokeWidth: 2,
1038
+ d: "M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z"
1039
+ }
1040
+ ),
1041
+ /* @__PURE__ */ e(
1042
+ "path",
1043
+ {
1044
+ strokeLinecap: "round",
1045
+ strokeLinejoin: "round",
1046
+ strokeWidth: 2,
1047
+ d: "M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
1048
+ }
1049
+ )
1050
+ ]
1051
+ }
1052
+ ),
1053
+ /* @__PURE__ */ e("p", { children: "No video available" })
1054
+ ] }) });
1055
+ };
3
1056
  export {
4
- n as Button
1057
+ ye as Button,
1058
+ xe as Form,
1059
+ re as InputField,
1060
+ Se as MultiStepForm,
1061
+ we as VideoPlayer
5
1062
  };