shared-features 0.0.1 → 0.0.2

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 (48) hide show
  1. package/README.md +84 -7
  2. package/dist/AdBanner-B9918Vst.cjs +1427 -0
  3. package/dist/AdBanner-B9918Vst.cjs.map +1 -0
  4. package/dist/AdBanner-z1osYgog.js +1428 -0
  5. package/dist/AdBanner-z1osYgog.js.map +1 -0
  6. package/dist/components/ads/AdBanner.d.ts +25 -0
  7. package/dist/components/ads/AdBanner.d.ts.map +1 -0
  8. package/dist/components/ads/AdModal.d.ts +27 -0
  9. package/dist/components/ads/AdModal.d.ts.map +1 -0
  10. package/dist/components/ads/AdSlider.d.ts +21 -0
  11. package/dist/components/ads/AdSlider.d.ts.map +1 -0
  12. package/dist/components/ads/AdUpdateModal.d.ts +27 -0
  13. package/dist/components/ads/AdUpdateModal.d.ts.map +1 -0
  14. package/dist/components/ads/index.d.ts +9 -0
  15. package/dist/components/ads/index.d.ts.map +1 -1
  16. package/dist/components/ads/variants/LargePanelVariants.d.ts +34 -0
  17. package/dist/components/ads/variants/LargePanelVariants.d.ts.map +1 -0
  18. package/dist/components/ads/variants/SmallPanelVariants.d.ts +34 -0
  19. package/dist/components/ads/variants/SmallPanelVariants.d.ts.map +1 -0
  20. package/dist/components/ads/variants/index.d.ts +12 -0
  21. package/dist/components/ads/variants/index.d.ts.map +1 -0
  22. package/dist/components/index.cjs +20 -2
  23. package/dist/components/index.cjs.map +1 -1
  24. package/dist/components/index.js +20 -2
  25. package/dist/hooks/index.cjs +3 -1
  26. package/dist/hooks/index.cjs.map +1 -1
  27. package/dist/hooks/index.d.ts +1 -1
  28. package/dist/hooks/index.d.ts.map +1 -1
  29. package/dist/hooks/index.js +4 -2
  30. package/dist/hooks/useCampaigns.d.ts +44 -0
  31. package/dist/hooks/useCampaigns.d.ts.map +1 -1
  32. package/dist/index.cjs +23 -3
  33. package/dist/index.cjs.map +1 -1
  34. package/dist/index.js +23 -3
  35. package/dist/types/campaigns.d.ts +20 -32
  36. package/dist/types/campaigns.d.ts.map +1 -1
  37. package/dist/types/index.cjs.map +1 -1
  38. package/dist/types/index.js.map +1 -1
  39. package/dist/{useCampaigns-BNOHpETm.cjs → useCampaigns-BKGqKAUo.cjs} +56 -1
  40. package/dist/useCampaigns-BKGqKAUo.cjs.map +1 -0
  41. package/dist/{useCampaigns-3NxODLLs.js → useCampaigns-osYDc6WC.js} +56 -1
  42. package/dist/{useCampaigns-3NxODLLs.js.map → useCampaigns-osYDc6WC.js.map} +1 -1
  43. package/package.json +3 -1
  44. package/dist/AdPanel-D0BiV6Xb.cjs +0 -88
  45. package/dist/AdPanel-D0BiV6Xb.cjs.map +0 -1
  46. package/dist/AdPanel-RGRBf4ub.js +0 -89
  47. package/dist/AdPanel-RGRBf4ub.js.map +0 -1
  48. package/dist/useCampaigns-BNOHpETm.cjs.map +0 -1
@@ -0,0 +1,1428 @@
1
+ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
+ import { useRef, useEffect, useCallback, useState } from "react";
3
+ import { Box, IconButton, Flex, Text, Button, Card, Link, Badge, Dialog, Heading, Checkbox, Grid } from "@radix-ui/themes";
4
+ import { Cross2Icon } from "@radix-ui/react-icons";
5
+ import { a as useCampaign, b as useOneTimeAdModal, c as useUpdateAdModal, u as useCampaigns } from "./useCampaigns-osYDc6WC.js";
6
+ import { ExternalLink, X, Check, Sparkles, Gift, Quote, Play, ChevronLeft, ChevronRight } from "lucide-react";
7
+ import { d as getConfig } from "./analytics-Bbmodnm_.js";
8
+ function AdPanel({
9
+ placement,
10
+ variant: _variant = "small_panel_2",
11
+ className
12
+ }) {
13
+ const { campaign, loading, error, recordImpression, recordClick, recordClose } = useCampaign({ placement });
14
+ const hasRecordedImpression = useRef(false);
15
+ useEffect(() => {
16
+ if (campaign && !hasRecordedImpression.current) {
17
+ hasRecordedImpression.current = true;
18
+ recordImpression(campaign);
19
+ }
20
+ }, [campaign, recordImpression]);
21
+ if (loading || error || !campaign) {
22
+ return null;
23
+ }
24
+ const handleClick = () => {
25
+ recordClick(campaign);
26
+ const url = campaign.customCtaUrl || campaign.product.url;
27
+ window.open(url, "_blank", "noopener,noreferrer");
28
+ };
29
+ const handleClose = () => {
30
+ recordClose(campaign);
31
+ };
32
+ const title = campaign.customTitle || campaign.product.name;
33
+ const tagline = campaign.customTagline || campaign.product.tagline;
34
+ const ctaText = campaign.customCta || "Learn More";
35
+ const color = campaign.customProductColor || campaign.product.color;
36
+ return /* @__PURE__ */ jsxs(
37
+ Box,
38
+ {
39
+ className,
40
+ style: {
41
+ border: `1px solid ${color}`,
42
+ borderRadius: "8px",
43
+ padding: "12px",
44
+ backgroundColor: `${color}10`,
45
+ position: "relative"
46
+ },
47
+ children: [
48
+ /* @__PURE__ */ jsx(
49
+ IconButton,
50
+ {
51
+ size: "1",
52
+ variant: "ghost",
53
+ onClick: handleClose,
54
+ style: {
55
+ position: "absolute",
56
+ top: "4px",
57
+ right: "4px"
58
+ },
59
+ children: /* @__PURE__ */ jsx(Cross2Icon, {})
60
+ }
61
+ ),
62
+ /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: "2", children: [
63
+ /* @__PURE__ */ jsxs(Flex, { align: "center", gap: "2", children: [
64
+ campaign.product.icon64 && /* @__PURE__ */ jsx(
65
+ Box,
66
+ {
67
+ dangerouslySetInnerHTML: { __html: campaign.product.icon64 },
68
+ style: { width: 32, height: 32 }
69
+ }
70
+ ),
71
+ /* @__PURE__ */ jsx(Text, { weight: "bold", size: "3", style: { color }, children: title })
72
+ ] }),
73
+ /* @__PURE__ */ jsx(Text, { size: "2", color: "gray", children: tagline }),
74
+ /* @__PURE__ */ jsx(
75
+ Button,
76
+ {
77
+ size: "2",
78
+ onClick: handleClick,
79
+ style: { backgroundColor: color },
80
+ children: ctaText
81
+ }
82
+ )
83
+ ] })
84
+ ]
85
+ }
86
+ );
87
+ }
88
+ function getDisplayValues$1(campaign) {
89
+ const isCustomProduct = !campaign.product.icon64 && campaign.customIcon;
90
+ return {
91
+ displayTitle: campaign.customTitle || campaign.product.name,
92
+ displayTagline: campaign.customTagline || campaign.product.tagline,
93
+ displayCta: campaign.customCta || "Learn More",
94
+ displayUrl: campaign.customCtaUrl || campaign.product.url,
95
+ displayIcon: campaign.customIcon || campaign.product.icon64 || "",
96
+ displayColor: campaign.customProductColor || campaign.product.color || "#3B82F6",
97
+ displayFeatures: campaign.customFeatures || campaign.product.features || [],
98
+ isCustomProduct
99
+ };
100
+ }
101
+ function MinimalVariant({ campaign, onCTAClick, onClose }) {
102
+ const { displayTitle, displayCta, displayUrl, displayIcon, displayColor } = getDisplayValues$1(campaign);
103
+ return /* @__PURE__ */ jsx(Card, { size: "1", children: /* @__PURE__ */ jsxs(Flex, { align: "center", justify: "between", gap: "3", p: "2", children: [
104
+ /* @__PURE__ */ jsxs(Flex, { align: "center", gap: "3", children: [
105
+ /* @__PURE__ */ jsx(
106
+ Box,
107
+ {
108
+ style: {
109
+ width: 32,
110
+ height: 32,
111
+ borderRadius: "var(--radius-2)",
112
+ background: `color-mix(in srgb, ${displayColor} 15%, transparent)`,
113
+ display: "flex",
114
+ alignItems: "center",
115
+ justifyContent: "center"
116
+ },
117
+ dangerouslySetInnerHTML: { __html: displayIcon }
118
+ }
119
+ ),
120
+ /* @__PURE__ */ jsx(Text, { size: "2", weight: "medium", children: displayTitle })
121
+ ] }),
122
+ /* @__PURE__ */ jsxs(Flex, { align: "center", gap: "2", children: [
123
+ /* @__PURE__ */ jsx(
124
+ Link,
125
+ {
126
+ href: displayUrl,
127
+ target: "_blank",
128
+ onClick: onCTAClick,
129
+ style: { textDecoration: "none" },
130
+ children: /* @__PURE__ */ jsxs(Flex, { align: "center", gap: "1", children: [
131
+ /* @__PURE__ */ jsx(Text, { size: "2", color: "blue", children: displayCta }),
132
+ /* @__PURE__ */ jsx(ExternalLink, { size: 14 })
133
+ ] })
134
+ }
135
+ ),
136
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "1", color: "gray", onClick: onClose, children: /* @__PURE__ */ jsx(X, { size: 14 }) })
137
+ ] })
138
+ ] }) });
139
+ }
140
+ function TaglineVariant({ campaign, onCTAClick, onClose }) {
141
+ const { displayTitle, displayTagline, displayCta, displayUrl, displayIcon, displayColor } = getDisplayValues$1(campaign);
142
+ return /* @__PURE__ */ jsx(Card, { size: "1", children: /* @__PURE__ */ jsxs(Flex, { align: "center", justify: "between", gap: "3", p: "3", children: [
143
+ /* @__PURE__ */ jsxs(Flex, { align: "center", gap: "3", children: [
144
+ /* @__PURE__ */ jsx(
145
+ Box,
146
+ {
147
+ style: {
148
+ width: 40,
149
+ height: 40,
150
+ borderRadius: "var(--radius-2)",
151
+ background: `color-mix(in srgb, ${displayColor} 15%, transparent)`,
152
+ display: "flex",
153
+ alignItems: "center",
154
+ justifyContent: "center",
155
+ flexShrink: 0
156
+ },
157
+ dangerouslySetInnerHTML: { __html: displayIcon }
158
+ }
159
+ ),
160
+ /* @__PURE__ */ jsxs(Box, { children: [
161
+ /* @__PURE__ */ jsx(Text, { size: "2", weight: "bold", children: displayTitle }),
162
+ /* @__PURE__ */ jsx(Text, { size: "1", color: "gray", children: displayTagline })
163
+ ] })
164
+ ] }),
165
+ /* @__PURE__ */ jsxs(Flex, { align: "center", gap: "2", children: [
166
+ /* @__PURE__ */ jsx(
167
+ Button,
168
+ {
169
+ size: "1",
170
+ style: { background: displayColor },
171
+ onClick: () => {
172
+ onCTAClick?.();
173
+ window.open(displayUrl, "_blank");
174
+ },
175
+ children: displayCta
176
+ }
177
+ ),
178
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "1", color: "gray", onClick: onClose, children: /* @__PURE__ */ jsx(X, { size: 14 }) })
179
+ ] })
180
+ ] }) });
181
+ }
182
+ function FeaturesVariant({ campaign, onCTAClick, onClose }) {
183
+ const { displayTitle, displayCta, displayUrl, displayIcon, displayColor, displayFeatures } = getDisplayValues$1(campaign);
184
+ const features = displayFeatures.slice(0, 2);
185
+ return /* @__PURE__ */ jsx(Card, { size: "1", children: /* @__PURE__ */ jsxs(Flex, { align: "center", justify: "between", gap: "3", p: "3", children: [
186
+ /* @__PURE__ */ jsxs(Flex, { align: "center", gap: "3", children: [
187
+ /* @__PURE__ */ jsx(
188
+ Box,
189
+ {
190
+ style: {
191
+ width: 40,
192
+ height: 40,
193
+ borderRadius: "var(--radius-2)",
194
+ background: `color-mix(in srgb, ${displayColor} 15%, transparent)`,
195
+ display: "flex",
196
+ alignItems: "center",
197
+ justifyContent: "center",
198
+ flexShrink: 0
199
+ },
200
+ dangerouslySetInnerHTML: { __html: displayIcon }
201
+ }
202
+ ),
203
+ /* @__PURE__ */ jsxs(Box, { children: [
204
+ /* @__PURE__ */ jsx(Text, { size: "2", weight: "bold", mb: "1", children: displayTitle }),
205
+ /* @__PURE__ */ jsx(Flex, { gap: "1", wrap: "wrap", children: features.map((feature, i) => /* @__PURE__ */ jsxs(Badge, { size: "1", variant: "soft", color: "gray", children: [
206
+ /* @__PURE__ */ jsx(Check, { size: 10, style: { marginRight: 2 } }),
207
+ feature
208
+ ] }, i)) })
209
+ ] })
210
+ ] }),
211
+ /* @__PURE__ */ jsxs(Flex, { align: "center", gap: "2", children: [
212
+ /* @__PURE__ */ jsx(
213
+ Button,
214
+ {
215
+ size: "1",
216
+ style: { background: displayColor },
217
+ onClick: () => {
218
+ onCTAClick?.();
219
+ window.open(displayUrl, "_blank");
220
+ },
221
+ children: displayCta
222
+ }
223
+ ),
224
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "1", color: "gray", onClick: onClose, children: /* @__PURE__ */ jsx(X, { size: 14 }) })
225
+ ] })
226
+ ] }) });
227
+ }
228
+ function GradientVariant({ campaign, onCTAClick, onClose }) {
229
+ const { displayTitle, displayTagline, displayCta, displayUrl, displayIcon, displayColor } = getDisplayValues$1(campaign);
230
+ return /* @__PURE__ */ jsx(
231
+ Box,
232
+ {
233
+ style: {
234
+ background: `linear-gradient(135deg, ${displayColor} 0%, color-mix(in srgb, ${displayColor} 80%, black) 100%)`,
235
+ borderRadius: "var(--radius-3)",
236
+ padding: "var(--space-3)",
237
+ color: "white"
238
+ },
239
+ children: /* @__PURE__ */ jsxs(Flex, { align: "center", justify: "between", gap: "3", children: [
240
+ /* @__PURE__ */ jsxs(Flex, { align: "center", gap: "3", children: [
241
+ /* @__PURE__ */ jsx(
242
+ Box,
243
+ {
244
+ style: {
245
+ width: 40,
246
+ height: 40,
247
+ borderRadius: "var(--radius-2)",
248
+ background: "rgba(255, 255, 255, 0.2)",
249
+ display: "flex",
250
+ alignItems: "center",
251
+ justifyContent: "center",
252
+ flexShrink: 0
253
+ },
254
+ children: /* @__PURE__ */ jsx(
255
+ Box,
256
+ {
257
+ dangerouslySetInnerHTML: { __html: displayIcon },
258
+ style: {
259
+ color: "white"
260
+ }
261
+ }
262
+ )
263
+ }
264
+ ),
265
+ /* @__PURE__ */ jsxs(Box, { children: [
266
+ /* @__PURE__ */ jsx(Text, { size: "2", weight: "bold", style: { color: "white" }, children: displayTitle }),
267
+ /* @__PURE__ */ jsx(Text, { size: "1", style: { color: "rgba(255, 255, 255, 0.8)" }, children: displayTagline })
268
+ ] })
269
+ ] }),
270
+ /* @__PURE__ */ jsxs(Flex, { align: "center", gap: "2", children: [
271
+ /* @__PURE__ */ jsx(
272
+ Button,
273
+ {
274
+ size: "1",
275
+ variant: "soft",
276
+ style: {
277
+ background: "white",
278
+ color: displayColor
279
+ },
280
+ onClick: () => {
281
+ onCTAClick?.();
282
+ window.open(displayUrl, "_blank");
283
+ },
284
+ children: displayCta
285
+ }
286
+ ),
287
+ /* @__PURE__ */ jsx(
288
+ Button,
289
+ {
290
+ variant: "ghost",
291
+ size: "1",
292
+ onClick: onClose,
293
+ style: { color: "rgba(255, 255, 255, 0.8)" },
294
+ children: /* @__PURE__ */ jsx(X, { size: 14 })
295
+ }
296
+ )
297
+ ] })
298
+ ] })
299
+ }
300
+ );
301
+ }
302
+ function CardVariant({ campaign, onCTAClick, onClose }) {
303
+ const { displayTitle, displayTagline, displayCta, displayUrl, displayIcon, displayColor } = getDisplayValues$1(campaign);
304
+ return /* @__PURE__ */ jsx(
305
+ Card,
306
+ {
307
+ size: "2",
308
+ style: {
309
+ boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
310
+ transition: "all 0.2s ease",
311
+ border: `1px solid ${displayColor}20`
312
+ },
313
+ children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: "3", p: "1", children: [
314
+ /* @__PURE__ */ jsxs(Flex, { align: "center", justify: "between", children: [
315
+ /* @__PURE__ */ jsxs(Flex, { align: "center", gap: "1", children: [
316
+ /* @__PURE__ */ jsx(Sparkles, { size: 14, color: displayColor }),
317
+ /* @__PURE__ */ jsx(Text, { size: "1", color: "gray", weight: "medium", children: "RECOMMENDED" })
318
+ ] }),
319
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "1", color: "gray", onClick: onClose, children: /* @__PURE__ */ jsx(X, { size: 14 }) })
320
+ ] }),
321
+ /* @__PURE__ */ jsxs(Flex, { align: "center", gap: "3", children: [
322
+ /* @__PURE__ */ jsx(
323
+ Box,
324
+ {
325
+ style: {
326
+ width: 48,
327
+ height: 48,
328
+ borderRadius: "var(--radius-3)",
329
+ background: `color-mix(in srgb, ${displayColor} 15%, transparent)`,
330
+ display: "flex",
331
+ alignItems: "center",
332
+ justifyContent: "center",
333
+ flexShrink: 0
334
+ },
335
+ dangerouslySetInnerHTML: { __html: displayIcon }
336
+ }
337
+ ),
338
+ /* @__PURE__ */ jsxs(Box, { style: { flex: 1 }, children: [
339
+ /* @__PURE__ */ jsx(Text, { size: "2", weight: "bold", children: displayTitle }),
340
+ /* @__PURE__ */ jsx(Text, { size: "1", color: "gray", children: displayTagline })
341
+ ] })
342
+ ] }),
343
+ /* @__PURE__ */ jsxs(
344
+ Button,
345
+ {
346
+ size: "2",
347
+ style: { background: displayColor, width: "100%" },
348
+ onClick: () => {
349
+ onCTAClick?.();
350
+ window.open(displayUrl, "_blank");
351
+ },
352
+ children: [
353
+ displayCta,
354
+ /* @__PURE__ */ jsx(ExternalLink, { size: 14 })
355
+ ]
356
+ }
357
+ )
358
+ ] })
359
+ }
360
+ );
361
+ }
362
+ const SMALL_PANEL_VARIANTS = {
363
+ small_panel_1: MinimalVariant,
364
+ small_panel_2: TaglineVariant,
365
+ small_panel_3: FeaturesVariant,
366
+ small_panel_4: GradientVariant,
367
+ small_panel_5: CardVariant
368
+ };
369
+ function getSmallPanelVariant(variantName) {
370
+ return SMALL_PANEL_VARIANTS[variantName] || TaglineVariant;
371
+ }
372
+ function AdSlider({
373
+ placement = "footer_slider",
374
+ className,
375
+ style
376
+ }) {
377
+ const hasTrackedImpression = useRef(false);
378
+ const {
379
+ campaign,
380
+ loading,
381
+ recordImpression,
382
+ recordClick,
383
+ recordClose
384
+ } = useCampaign({ placement });
385
+ useEffect(() => {
386
+ if (campaign && !hasTrackedImpression.current) {
387
+ hasTrackedImpression.current = true;
388
+ recordImpression(campaign);
389
+ }
390
+ }, [campaign, recordImpression]);
391
+ const handleCTAClick = useCallback(() => {
392
+ if (!campaign) return;
393
+ recordClick(campaign);
394
+ }, [campaign, recordClick]);
395
+ const handleClose = useCallback(() => {
396
+ if (!campaign) return;
397
+ recordClose(campaign);
398
+ }, [campaign, recordClose]);
399
+ if (loading || !campaign) {
400
+ return null;
401
+ }
402
+ const variantName = campaign.variant || "small_panel_2";
403
+ const VariantComponent = getSmallPanelVariant(variantName);
404
+ return /* @__PURE__ */ jsx(Box, { className, style, children: /* @__PURE__ */ jsx(
405
+ VariantComponent,
406
+ {
407
+ campaign,
408
+ onCTAClick: handleCTAClick,
409
+ onClose: handleClose
410
+ }
411
+ ) });
412
+ }
413
+ function AdModal({
414
+ placement = "onetime_modal",
415
+ onClose,
416
+ welcomeTitle,
417
+ welcomeDescription
418
+ }) {
419
+ const [dontShowAgain, setDontShowAgain] = useState(false);
420
+ const hasTrackedImpression = useRef(false);
421
+ const config = getConfig();
422
+ const { shouldShow, markAsShown } = useOneTimeAdModal();
423
+ const {
424
+ campaign,
425
+ loading,
426
+ recordImpression,
427
+ recordClick,
428
+ recordClose
429
+ } = useCampaign({ placement });
430
+ useEffect(() => {
431
+ if (shouldShow && campaign && !hasTrackedImpression.current) {
432
+ hasTrackedImpression.current = true;
433
+ recordImpression(campaign);
434
+ }
435
+ }, [shouldShow, campaign, recordImpression]);
436
+ const handleCTAClick = useCallback(() => {
437
+ if (!campaign) return;
438
+ recordClick(campaign);
439
+ const targetUrl = campaign.customCtaUrl || campaign.product.url;
440
+ window.open(targetUrl, "_blank");
441
+ }, [campaign, recordClick]);
442
+ const handleClose = useCallback(() => {
443
+ if (campaign) {
444
+ recordClose(campaign);
445
+ }
446
+ markAsShown();
447
+ onClose?.();
448
+ }, [campaign, recordClose, markAsShown, onClose]);
449
+ if (!shouldShow || loading) {
450
+ return null;
451
+ }
452
+ if (!campaign) {
453
+ const defaultTitle = welcomeTitle || `Welcome to ${config.projectName}!`;
454
+ const defaultDesc = welcomeDescription || "Discover amazing features and tools at your fingertips.";
455
+ return /* @__PURE__ */ jsx(Dialog.Root, { open: true, onOpenChange: (open) => !open && handleClose(), children: /* @__PURE__ */ jsxs(Dialog.Content, { style: { maxWidth: 450 }, children: [
456
+ /* @__PURE__ */ jsx(Dialog.Title, { children: /* @__PURE__ */ jsxs(Flex, { align: "center", gap: "2", children: [
457
+ /* @__PURE__ */ jsx(Gift, { size: 24 }),
458
+ defaultTitle
459
+ ] }) }),
460
+ /* @__PURE__ */ jsx(Dialog.Description, { size: "2", mb: "4", children: defaultDesc }),
461
+ /* @__PURE__ */ jsx(Flex, { gap: "3", mt: "4", justify: "end", children: /* @__PURE__ */ jsx(Dialog.Close, { children: /* @__PURE__ */ jsx(Button, { variant: "soft", color: "gray", children: "Start Exploring" }) }) })
462
+ ] }) });
463
+ }
464
+ const { product } = campaign;
465
+ const displayTitle = campaign.customTitle || product.name;
466
+ const displayTagline = campaign.customTagline || product.tagline;
467
+ const displayDescription = campaign.customDescription || product.description;
468
+ const displayCta = campaign.customCta || "Learn More";
469
+ const displayIcon = campaign.customIcon || product.icon128 || product.icon64 || "";
470
+ const displayColor = campaign.customProductColor || product.color || "#3B82F6";
471
+ const displayFeatures = campaign.customFeatures || product.features || [];
472
+ return /* @__PURE__ */ jsx(Dialog.Root, { open: true, onOpenChange: (open) => !open && handleClose(), children: /* @__PURE__ */ jsxs(Dialog.Content, { style: { maxWidth: 500 }, children: [
473
+ /* @__PURE__ */ jsx(Flex, { justify: "end", mb: "2", children: /* @__PURE__ */ jsx(Dialog.Close, { children: /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "1", color: "gray", children: /* @__PURE__ */ jsx(X, { size: 16 }) }) }) }),
474
+ /* @__PURE__ */ jsxs(Flex, { direction: "column", align: "center", gap: "4", p: "4", style: { textAlign: "center" }, children: [
475
+ /* @__PURE__ */ jsx(
476
+ Box,
477
+ {
478
+ style: {
479
+ width: 96,
480
+ height: 96,
481
+ borderRadius: "var(--radius-4)",
482
+ background: `color-mix(in srgb, ${displayColor} 15%, transparent)`,
483
+ display: "flex",
484
+ alignItems: "center",
485
+ justifyContent: "center"
486
+ },
487
+ dangerouslySetInnerHTML: { __html: displayIcon }
488
+ }
489
+ ),
490
+ /* @__PURE__ */ jsxs(Box, { children: [
491
+ /* @__PURE__ */ jsx(Heading, { size: "5", weight: "bold", mb: "2", children: displayTitle }),
492
+ /* @__PURE__ */ jsx(Text, { size: "3", color: "gray", children: displayTagline })
493
+ ] }),
494
+ /* @__PURE__ */ jsx(Text, { size: "2", color: "gray", style: { maxWidth: 350, lineHeight: 1.6 }, children: displayDescription }),
495
+ /* @__PURE__ */ jsx(Flex, { wrap: "wrap", gap: "2", justify: "center", children: displayFeatures.slice(0, 4).map((feature, i) => /* @__PURE__ */ jsx(
496
+ Box,
497
+ {
498
+ style: {
499
+ padding: "var(--space-1) var(--space-2)",
500
+ borderRadius: "var(--radius-2)",
501
+ background: "var(--gray-a3)",
502
+ fontSize: "var(--font-size-1)"
503
+ },
504
+ children: feature
505
+ },
506
+ i
507
+ )) }),
508
+ /* @__PURE__ */ jsxs(
509
+ Button,
510
+ {
511
+ size: "3",
512
+ style: { background: displayColor, marginTop: "var(--space-2)" },
513
+ onClick: handleCTAClick,
514
+ children: [
515
+ displayCta,
516
+ /* @__PURE__ */ jsx(ExternalLink, { size: 16 })
517
+ ]
518
+ }
519
+ ),
520
+ /* @__PURE__ */ jsxs(Flex, { align: "center", gap: "2", mt: "2", children: [
521
+ /* @__PURE__ */ jsx(
522
+ Checkbox,
523
+ {
524
+ checked: dontShowAgain,
525
+ onCheckedChange: (checked) => setDontShowAgain(checked === true)
526
+ }
527
+ ),
528
+ /* @__PURE__ */ jsx(Text, { size: "1", color: "gray", children: "Don't show this again" })
529
+ ] })
530
+ ] })
531
+ ] }) });
532
+ }
533
+ function getDisplayValues(campaign) {
534
+ const isCustomProduct = !campaign.product.icon64 && campaign.customIcon;
535
+ return {
536
+ displayTitle: campaign.customTitle || campaign.product.name,
537
+ displayTagline: campaign.customTagline || campaign.product.tagline,
538
+ displayDescription: campaign.customDescription || campaign.product.description,
539
+ displayCta: campaign.customCta || "Learn More",
540
+ displayUrl: campaign.customCtaUrl || campaign.product.url,
541
+ displayIcon64: campaign.customIcon || campaign.product.icon64 || "",
542
+ displayIcon128: campaign.customIcon || campaign.product.icon128 || campaign.product.icon64 || "",
543
+ displayColor: campaign.customProductColor || campaign.product.color || "#3B82F6",
544
+ displayFeatures: campaign.customFeatures || campaign.product.features || [],
545
+ isCustomProduct
546
+ };
547
+ }
548
+ const DEFAULT_TESTIMONIALS = {
549
+ "video-controls-plus": '"Finally, I have complete control over video playback. The keyboard shortcuts save me so much time!"',
550
+ "ztools-web": '"300+ tools in one place. I use it daily for encoding, formatting, and data conversion tasks."',
551
+ "ztools-extension": '"Quick access to all my favorite tools right from the browser. Super convenient!"',
552
+ "pregnancy-pal-android": '"The weekly updates and kick counter are amazing. Best pregnancy tracking app!"',
553
+ "pregnancy-pal-web": '"Love being able to access my pregnancy data from any device. The sync is seamless."',
554
+ "lab-system-web": '"Streamlined our entire lab workflow. Sample tracking has never been easier."'
555
+ };
556
+ const DEFAULT_COMPARISONS = {
557
+ "video-controls-plus": {
558
+ before: ["Limited playback control", "No keyboard shortcuts", "Manual ad skipping", "No speed control"],
559
+ after: ["Full playback control", "Custom shortcuts", "Auto ad skip", "0.1x - 16x speed"]
560
+ },
561
+ "ztools-web": {
562
+ before: ["Multiple websites", "Scattered tools", "No offline access", "Ads everywhere"],
563
+ after: ["One destination", "300+ tools", "Works offline", "Ad-free experience"]
564
+ },
565
+ "ztools-extension": {
566
+ before: ["Open new tabs", "Search for tools", "Copy/paste repeatedly", "Time wasted"],
567
+ after: ["Instant access", "Quick search", "One-click actions", "Time saved"]
568
+ },
569
+ "pregnancy-pal-android": {
570
+ before: ["Paper tracking", "Forget updates", "Manual counting", "Scattered info"],
571
+ after: ["Digital diary", "Weekly reminders", "Auto tracking", "All in one app"]
572
+ },
573
+ "pregnancy-pal-web": {
574
+ before: ["Phone only", "No backup", "Limited access", "Data silos"],
575
+ after: ["Any device", "Cloud sync", "Always available", "Unified data"]
576
+ },
577
+ "lab-system-web": {
578
+ before: ["Paper records", "Manual tracking", "Error prone", "Slow reports"],
579
+ after: ["Digital records", "Auto tracking", "Accurate data", "Instant reports"]
580
+ }
581
+ };
582
+ function HeroVariant({
583
+ campaign,
584
+ onCTAClick,
585
+ showIndicator,
586
+ currentIndex,
587
+ totalCount
588
+ }) {
589
+ const { displayTitle, displayTagline, displayDescription, displayCta, displayUrl, displayIcon128, displayColor } = getDisplayValues(campaign);
590
+ return /* @__PURE__ */ jsxs(Flex, { direction: "column", align: "center", gap: "4", p: "5", style: { textAlign: "center" }, children: [
591
+ showIndicator && currentIndex !== void 0 && totalCount !== void 0 && /* @__PURE__ */ jsxs(Text, { size: "1", color: "gray", style: { position: "absolute", top: 16, right: 16 }, children: [
592
+ currentIndex + 1,
593
+ " / ",
594
+ totalCount
595
+ ] }),
596
+ /* @__PURE__ */ jsx(
597
+ Box,
598
+ {
599
+ style: {
600
+ width: 80,
601
+ height: 80,
602
+ borderRadius: "var(--radius-4)",
603
+ background: `color-mix(in srgb, ${displayColor} 15%, transparent)`,
604
+ display: "flex",
605
+ alignItems: "center",
606
+ justifyContent: "center"
607
+ },
608
+ dangerouslySetInnerHTML: { __html: displayIcon128 }
609
+ }
610
+ ),
611
+ /* @__PURE__ */ jsx(Heading, { size: "5", weight: "bold", children: displayTitle }),
612
+ /* @__PURE__ */ jsx(Text, { size: "3", color: "gray", children: displayTagline }),
613
+ /* @__PURE__ */ jsx(Text, { size: "2", color: "gray", style: { maxWidth: 300, lineHeight: 1.6 }, children: displayDescription }),
614
+ /* @__PURE__ */ jsxs(
615
+ Button,
616
+ {
617
+ size: "3",
618
+ style: { background: displayColor, marginTop: "var(--space-2)" },
619
+ onClick: () => {
620
+ onCTAClick?.();
621
+ window.open(displayUrl, "_blank");
622
+ },
623
+ children: [
624
+ displayCta,
625
+ /* @__PURE__ */ jsx(ExternalLink, { size: 16 })
626
+ ]
627
+ }
628
+ )
629
+ ] });
630
+ }
631
+ function FeatureGridVariant({
632
+ campaign,
633
+ onCTAClick,
634
+ showIndicator,
635
+ currentIndex,
636
+ totalCount
637
+ }) {
638
+ const { displayTitle, displayCta, displayUrl, displayIcon64, displayColor, displayFeatures } = getDisplayValues(campaign);
639
+ const features = displayFeatures.slice(0, 4);
640
+ return /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: "4", p: "5", children: [
641
+ showIndicator && currentIndex !== void 0 && totalCount !== void 0 && /* @__PURE__ */ jsxs(Text, { size: "1", color: "gray", style: { position: "absolute", top: 16, right: 16 }, children: [
642
+ currentIndex + 1,
643
+ " / ",
644
+ totalCount
645
+ ] }),
646
+ /* @__PURE__ */ jsxs(Flex, { align: "center", gap: "3", children: [
647
+ /* @__PURE__ */ jsx(
648
+ Box,
649
+ {
650
+ style: {
651
+ width: 48,
652
+ height: 48,
653
+ borderRadius: "var(--radius-3)",
654
+ background: `color-mix(in srgb, ${displayColor} 15%, transparent)`,
655
+ display: "flex",
656
+ alignItems: "center",
657
+ justifyContent: "center",
658
+ flexShrink: 0
659
+ },
660
+ dangerouslySetInnerHTML: { __html: displayIcon64 }
661
+ }
662
+ ),
663
+ /* @__PURE__ */ jsx(Heading, { size: "4", weight: "bold", children: displayTitle })
664
+ ] }),
665
+ /* @__PURE__ */ jsx(Grid, { columns: "2", gap: "3", children: features.map((feature, i) => /* @__PURE__ */ jsx(Card, { size: "1", style: { background: "var(--gray-a2)" }, children: /* @__PURE__ */ jsxs(Flex, { align: "center", gap: "2", p: "2", children: [
666
+ /* @__PURE__ */ jsx(
667
+ Flex,
668
+ {
669
+ align: "center",
670
+ justify: "center",
671
+ style: {
672
+ width: 24,
673
+ height: 24,
674
+ borderRadius: "50%",
675
+ background: displayColor,
676
+ color: "white",
677
+ fontSize: 12,
678
+ fontWeight: "bold",
679
+ flexShrink: 0
680
+ },
681
+ children: i + 1
682
+ }
683
+ ),
684
+ /* @__PURE__ */ jsx(Text, { size: "2", children: feature })
685
+ ] }) }, i)) }),
686
+ /* @__PURE__ */ jsxs(
687
+ Button,
688
+ {
689
+ size: "3",
690
+ style: { background: displayColor, width: "100%" },
691
+ onClick: () => {
692
+ onCTAClick?.();
693
+ window.open(displayUrl, "_blank");
694
+ },
695
+ children: [
696
+ displayCta,
697
+ /* @__PURE__ */ jsx(ExternalLink, { size: 16 })
698
+ ]
699
+ }
700
+ )
701
+ ] });
702
+ }
703
+ function TestimonialVariant({
704
+ campaign,
705
+ onCTAClick,
706
+ showIndicator,
707
+ currentIndex,
708
+ totalCount
709
+ }) {
710
+ const { product } = campaign;
711
+ const { displayTitle, displayTagline, displayCta, displayUrl, displayIcon64, displayColor } = getDisplayValues(campaign);
712
+ const quote = DEFAULT_TESTIMONIALS[product.id] || '"An amazing tool that makes my work easier every day."';
713
+ return /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: "4", p: "5", style: { background: "var(--gray-a2)", borderRadius: "var(--radius-3)" }, children: [
714
+ showIndicator && currentIndex !== void 0 && totalCount !== void 0 && /* @__PURE__ */ jsxs(Text, { size: "1", color: "gray", style: { position: "absolute", top: 16, right: 16 }, children: [
715
+ currentIndex + 1,
716
+ " / ",
717
+ totalCount
718
+ ] }),
719
+ /* @__PURE__ */ jsxs(Box, { style: { position: "relative", padding: "var(--space-3)" }, children: [
720
+ /* @__PURE__ */ jsx(
721
+ Quote,
722
+ {
723
+ size: 32,
724
+ style: {
725
+ position: "absolute",
726
+ top: 0,
727
+ left: "50%",
728
+ transform: "translateX(-50%)",
729
+ opacity: 0.15,
730
+ color: displayColor
731
+ }
732
+ }
733
+ ),
734
+ /* @__PURE__ */ jsx(Text, { size: "3", style: { fontStyle: "italic", textAlign: "center", lineHeight: 1.6 }, children: quote }),
735
+ /* @__PURE__ */ jsx(Text, { size: "2", color: "gray", style: { textAlign: "center", marginTop: "var(--space-2)" }, children: "— Happy User" })
736
+ ] }),
737
+ /* @__PURE__ */ jsx(Card, { size: "1", children: /* @__PURE__ */ jsxs(Flex, { align: "center", gap: "3", p: "3", children: [
738
+ /* @__PURE__ */ jsx(
739
+ Box,
740
+ {
741
+ style: {
742
+ width: 48,
743
+ height: 48,
744
+ borderRadius: "var(--radius-3)",
745
+ background: `color-mix(in srgb, ${displayColor} 15%, transparent)`,
746
+ display: "flex",
747
+ alignItems: "center",
748
+ justifyContent: "center",
749
+ flexShrink: 0
750
+ },
751
+ dangerouslySetInnerHTML: { __html: displayIcon64 }
752
+ }
753
+ ),
754
+ /* @__PURE__ */ jsxs(Box, { children: [
755
+ /* @__PURE__ */ jsx(Text, { size: "2", weight: "bold", children: displayTitle }),
756
+ /* @__PURE__ */ jsx(Text, { size: "1", color: "gray", children: displayTagline })
757
+ ] })
758
+ ] }) }),
759
+ /* @__PURE__ */ jsxs(
760
+ Button,
761
+ {
762
+ size: "3",
763
+ style: { background: displayColor, width: "100%" },
764
+ onClick: () => {
765
+ onCTAClick?.();
766
+ window.open(displayUrl, "_blank");
767
+ },
768
+ children: [
769
+ displayCta,
770
+ /* @__PURE__ */ jsx(ExternalLink, { size: 16 })
771
+ ]
772
+ }
773
+ )
774
+ ] });
775
+ }
776
+ function ComparisonVariant({
777
+ campaign,
778
+ onCTAClick,
779
+ showIndicator,
780
+ currentIndex,
781
+ totalCount
782
+ }) {
783
+ const { product } = campaign;
784
+ const { displayTitle, displayCta, displayUrl, displayIcon64, displayColor } = getDisplayValues(campaign);
785
+ const comparison = DEFAULT_COMPARISONS[product.id] || {
786
+ before: ["Old way", "Manual process", "Time consuming", "Limited features"],
787
+ after: ["Better way", "Automated", "Fast & easy", "Full features"]
788
+ };
789
+ return /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: "4", p: "5", children: [
790
+ showIndicator && currentIndex !== void 0 && totalCount !== void 0 && /* @__PURE__ */ jsxs(Text, { size: "1", color: "gray", style: { position: "absolute", top: 16, right: 16 }, children: [
791
+ currentIndex + 1,
792
+ " / ",
793
+ totalCount
794
+ ] }),
795
+ /* @__PURE__ */ jsxs(Flex, { align: "center", gap: "3", children: [
796
+ /* @__PURE__ */ jsx(
797
+ Box,
798
+ {
799
+ style: {
800
+ width: 48,
801
+ height: 48,
802
+ borderRadius: "var(--radius-3)",
803
+ background: `color-mix(in srgb, ${displayColor} 15%, transparent)`,
804
+ display: "flex",
805
+ alignItems: "center",
806
+ justifyContent: "center",
807
+ flexShrink: 0
808
+ },
809
+ dangerouslySetInnerHTML: { __html: displayIcon64 }
810
+ }
811
+ ),
812
+ /* @__PURE__ */ jsx(Heading, { size: "4", weight: "bold", children: displayTitle })
813
+ ] }),
814
+ /* @__PURE__ */ jsxs(Flex, { gap: "3", children: [
815
+ /* @__PURE__ */ jsxs(
816
+ Box,
817
+ {
818
+ style: {
819
+ flex: 1,
820
+ padding: "var(--space-3)",
821
+ borderRadius: "var(--radius-2)",
822
+ background: "rgba(239, 68, 68, 0.1)"
823
+ },
824
+ children: [
825
+ /* @__PURE__ */ jsx(Text, { size: "1", weight: "bold", color: "red", mb: "2", style: { textTransform: "uppercase" }, children: "Before" }),
826
+ comparison.before.map((item, i) => /* @__PURE__ */ jsxs(Flex, { align: "center", gap: "2", mb: "1", children: [
827
+ /* @__PURE__ */ jsx(X, { size: 12, color: "var(--red-9)" }),
828
+ /* @__PURE__ */ jsx(Text, { size: "1", children: item })
829
+ ] }, i))
830
+ ]
831
+ }
832
+ ),
833
+ /* @__PURE__ */ jsxs(
834
+ Box,
835
+ {
836
+ style: {
837
+ flex: 1,
838
+ padding: "var(--space-3)",
839
+ borderRadius: "var(--radius-2)",
840
+ background: "rgba(16, 185, 129, 0.1)"
841
+ },
842
+ children: [
843
+ /* @__PURE__ */ jsx(Text, { size: "1", weight: "bold", color: "green", mb: "2", style: { textTransform: "uppercase" }, children: "After" }),
844
+ comparison.after.map((item, i) => /* @__PURE__ */ jsxs(Flex, { align: "center", gap: "2", mb: "1", children: [
845
+ /* @__PURE__ */ jsx(Check, { size: 12, color: "var(--green-9)" }),
846
+ /* @__PURE__ */ jsx(Text, { size: "1", children: item })
847
+ ] }, i))
848
+ ]
849
+ }
850
+ )
851
+ ] }),
852
+ /* @__PURE__ */ jsxs(
853
+ Button,
854
+ {
855
+ size: "3",
856
+ style: { background: displayColor, width: "100%" },
857
+ onClick: () => {
858
+ onCTAClick?.();
859
+ window.open(displayUrl, "_blank");
860
+ },
861
+ children: [
862
+ displayCta,
863
+ /* @__PURE__ */ jsx(ExternalLink, { size: 16 })
864
+ ]
865
+ }
866
+ )
867
+ ] });
868
+ }
869
+ function VideoVariant({
870
+ campaign,
871
+ onCTAClick,
872
+ showIndicator,
873
+ currentIndex,
874
+ totalCount
875
+ }) {
876
+ const { displayTitle, displayTagline, displayCta, displayUrl, displayIcon128, displayColor } = getDisplayValues(campaign);
877
+ return /* @__PURE__ */ jsxs(Flex, { direction: "column", align: "center", gap: "4", p: "5", style: { textAlign: "center" }, children: [
878
+ showIndicator && currentIndex !== void 0 && totalCount !== void 0 && /* @__PURE__ */ jsxs(Text, { size: "1", color: "gray", style: { position: "absolute", top: 16, right: 16 }, children: [
879
+ currentIndex + 1,
880
+ " / ",
881
+ totalCount
882
+ ] }),
883
+ /* @__PURE__ */ jsxs(
884
+ Box,
885
+ {
886
+ style: {
887
+ position: "relative",
888
+ width: 140,
889
+ height: 140,
890
+ borderRadius: "var(--radius-4)",
891
+ background: `linear-gradient(135deg, color-mix(in srgb, ${displayColor} 20%, transparent), color-mix(in srgb, ${displayColor} 40%, transparent))`,
892
+ display: "flex",
893
+ alignItems: "center",
894
+ justifyContent: "center",
895
+ overflow: "hidden"
896
+ },
897
+ children: [
898
+ /* @__PURE__ */ jsx(
899
+ Box,
900
+ {
901
+ style: {
902
+ animation: "shared-features-pulse 2s ease-in-out infinite"
903
+ },
904
+ dangerouslySetInnerHTML: { __html: displayIcon128 }
905
+ }
906
+ ),
907
+ /* @__PURE__ */ jsx(
908
+ Flex,
909
+ {
910
+ align: "center",
911
+ justify: "center",
912
+ style: {
913
+ position: "absolute",
914
+ width: 56,
915
+ height: 56,
916
+ borderRadius: "50%",
917
+ background: "rgba(255, 255, 255, 0.95)",
918
+ boxShadow: "0 4px 12px rgba(0, 0, 0, 0.2)",
919
+ cursor: "pointer",
920
+ transition: "transform 0.2s ease"
921
+ },
922
+ onClick: () => {
923
+ onCTAClick?.();
924
+ window.open(displayUrl, "_blank");
925
+ },
926
+ children: /* @__PURE__ */ jsx(Play, { size: 24, fill: displayColor, color: displayColor })
927
+ }
928
+ )
929
+ ]
930
+ }
931
+ ),
932
+ /* @__PURE__ */ jsx(Heading, { size: "5", weight: "bold", children: displayTitle }),
933
+ /* @__PURE__ */ jsx(Text, { size: "2", color: "gray", children: displayTagline }),
934
+ /* @__PURE__ */ jsxs(
935
+ Button,
936
+ {
937
+ size: "3",
938
+ style: { background: displayColor, marginTop: "var(--space-2)" },
939
+ onClick: () => {
940
+ onCTAClick?.();
941
+ window.open(displayUrl, "_blank");
942
+ },
943
+ children: [
944
+ displayCta,
945
+ /* @__PURE__ */ jsx(ExternalLink, { size: 16 })
946
+ ]
947
+ }
948
+ ),
949
+ /* @__PURE__ */ jsx("style", { children: `
950
+ @keyframes shared-features-pulse {
951
+ 0%, 100% { transform: scale(1); }
952
+ 50% { transform: scale(1.1); }
953
+ }
954
+ ` })
955
+ ] });
956
+ }
957
+ const LARGE_PANEL_VARIANTS = {
958
+ large_slider_1: HeroVariant,
959
+ large_slider_2: FeatureGridVariant,
960
+ large_slider_3: TestimonialVariant,
961
+ large_slider_4: ComparisonVariant,
962
+ large_slider_5: VideoVariant
963
+ };
964
+ function getLargePanelVariant(variantName) {
965
+ return LARGE_PANEL_VARIANTS[variantName] || HeroVariant;
966
+ }
967
+ function AdUpdateModal({
968
+ placement = "update_modal",
969
+ maxCampaigns = 5,
970
+ autoAdvanceInterval = 5e3,
971
+ onClose
972
+ }) {
973
+ const [currentIndex, setCurrentIndex] = useState(0);
974
+ const autoAdvanceRef = useRef(null);
975
+ const trackedImpressions = useRef(/* @__PURE__ */ new Set());
976
+ const { shouldShow, currentVersion, markAsShown } = useUpdateAdModal();
977
+ const {
978
+ campaigns,
979
+ loading,
980
+ recordImpression,
981
+ recordClick,
982
+ recordClose
983
+ } = useCampaigns({ placement, maxCampaigns });
984
+ useEffect(() => {
985
+ if (shouldShow && campaigns.length > 0 && currentIndex < campaigns.length) {
986
+ const campaign = campaigns[currentIndex];
987
+ if (campaign && !trackedImpressions.current.has(campaign.id)) {
988
+ trackedImpressions.current.add(campaign.id);
989
+ recordImpression(campaign);
990
+ }
991
+ }
992
+ }, [shouldShow, campaigns, currentIndex, recordImpression]);
993
+ useEffect(() => {
994
+ if (!shouldShow || campaigns.length <= 1 || autoAdvanceInterval <= 0) return;
995
+ autoAdvanceRef.current = setInterval(() => {
996
+ setCurrentIndex((prev) => (prev + 1) % campaigns.length);
997
+ }, autoAdvanceInterval);
998
+ return () => {
999
+ if (autoAdvanceRef.current) {
1000
+ clearInterval(autoAdvanceRef.current);
1001
+ }
1002
+ };
1003
+ }, [shouldShow, campaigns.length, autoAdvanceInterval]);
1004
+ const resetAutoAdvance = useCallback(() => {
1005
+ if (autoAdvanceRef.current) {
1006
+ clearInterval(autoAdvanceRef.current);
1007
+ }
1008
+ if (autoAdvanceInterval > 0 && campaigns.length > 1) {
1009
+ autoAdvanceRef.current = setInterval(() => {
1010
+ setCurrentIndex((prev) => (prev + 1) % campaigns.length);
1011
+ }, autoAdvanceInterval);
1012
+ }
1013
+ }, [autoAdvanceInterval, campaigns.length]);
1014
+ const goToPrevious = useCallback(() => {
1015
+ setCurrentIndex((prev) => (prev - 1 + campaigns.length) % campaigns.length);
1016
+ resetAutoAdvance();
1017
+ }, [campaigns.length, resetAutoAdvance]);
1018
+ const goToNext = useCallback(() => {
1019
+ setCurrentIndex((prev) => (prev + 1) % campaigns.length);
1020
+ resetAutoAdvance();
1021
+ }, [campaigns.length, resetAutoAdvance]);
1022
+ const goToSlide = useCallback(
1023
+ (index) => {
1024
+ setCurrentIndex(index);
1025
+ resetAutoAdvance();
1026
+ },
1027
+ [resetAutoAdvance]
1028
+ );
1029
+ useEffect(() => {
1030
+ if (!shouldShow) return;
1031
+ const handleKeyDown = (e) => {
1032
+ if (e.key === "ArrowLeft") {
1033
+ goToPrevious();
1034
+ } else if (e.key === "ArrowRight") {
1035
+ goToNext();
1036
+ } else if (e.key === "Escape") {
1037
+ handleClose();
1038
+ }
1039
+ };
1040
+ window.addEventListener("keydown", handleKeyDown);
1041
+ return () => window.removeEventListener("keydown", handleKeyDown);
1042
+ }, [shouldShow, goToPrevious, goToNext]);
1043
+ const handleCTAClick = useCallback(() => {
1044
+ const campaign = campaigns[currentIndex];
1045
+ if (!campaign) return;
1046
+ recordClick(campaign);
1047
+ }, [campaigns, currentIndex, recordClick]);
1048
+ const handleClose = useCallback(() => {
1049
+ campaigns.forEach((campaign) => {
1050
+ recordClose(campaign);
1051
+ });
1052
+ markAsShown();
1053
+ onClose?.();
1054
+ }, [campaigns, recordClose, markAsShown, onClose]);
1055
+ if (!shouldShow || loading || campaigns.length === 0) {
1056
+ return null;
1057
+ }
1058
+ const currentCampaign = campaigns[currentIndex];
1059
+ if (!currentCampaign) return null;
1060
+ const variantName = currentCampaign.variant || "large_slider_1";
1061
+ const VariantComponent = getLargePanelVariant(variantName);
1062
+ return /* @__PURE__ */ jsx(Dialog.Root, { open: true, onOpenChange: (open) => !open && handleClose(), children: /* @__PURE__ */ jsxs(
1063
+ Dialog.Content,
1064
+ {
1065
+ style: {
1066
+ maxWidth: 550,
1067
+ padding: 0,
1068
+ overflow: "hidden"
1069
+ },
1070
+ children: [
1071
+ /* @__PURE__ */ jsxs(
1072
+ Flex,
1073
+ {
1074
+ align: "center",
1075
+ justify: "between",
1076
+ p: "3",
1077
+ style: {
1078
+ borderBottom: "1px solid var(--gray-a5)"
1079
+ },
1080
+ children: [
1081
+ /* @__PURE__ */ jsxs(Text, { size: "2", color: "gray", children: [
1082
+ "What's New in v",
1083
+ currentVersion
1084
+ ] }),
1085
+ /* @__PURE__ */ jsx(Dialog.Close, { children: /* @__PURE__ */ jsx(IconButton, { variant: "ghost", size: "1", color: "gray", children: /* @__PURE__ */ jsx(X, { size: 16 }) }) })
1086
+ ]
1087
+ }
1088
+ ),
1089
+ /* @__PURE__ */ jsxs(Box, { style: { position: "relative", minHeight: 350 }, children: [
1090
+ /* @__PURE__ */ jsx(
1091
+ VariantComponent,
1092
+ {
1093
+ campaign: currentCampaign,
1094
+ onCTAClick: handleCTAClick,
1095
+ showIndicator: campaigns.length > 1,
1096
+ currentIndex,
1097
+ totalCount: campaigns.length
1098
+ }
1099
+ ),
1100
+ campaigns.length > 1 && /* @__PURE__ */ jsxs(Fragment, { children: [
1101
+ /* @__PURE__ */ jsx(
1102
+ IconButton,
1103
+ {
1104
+ variant: "soft",
1105
+ size: "2",
1106
+ style: {
1107
+ position: "absolute",
1108
+ left: 8,
1109
+ top: "50%",
1110
+ transform: "translateY(-50%)",
1111
+ opacity: 0.8
1112
+ },
1113
+ onClick: goToPrevious,
1114
+ children: /* @__PURE__ */ jsx(ChevronLeft, { size: 20 })
1115
+ }
1116
+ ),
1117
+ /* @__PURE__ */ jsx(
1118
+ IconButton,
1119
+ {
1120
+ variant: "soft",
1121
+ size: "2",
1122
+ style: {
1123
+ position: "absolute",
1124
+ right: 8,
1125
+ top: "50%",
1126
+ transform: "translateY(-50%)",
1127
+ opacity: 0.8
1128
+ },
1129
+ onClick: goToNext,
1130
+ children: /* @__PURE__ */ jsx(ChevronRight, { size: 20 })
1131
+ }
1132
+ )
1133
+ ] })
1134
+ ] }),
1135
+ campaigns.length > 1 && /* @__PURE__ */ jsx(
1136
+ Flex,
1137
+ {
1138
+ align: "center",
1139
+ justify: "center",
1140
+ gap: "2",
1141
+ p: "3",
1142
+ style: {
1143
+ borderTop: "1px solid var(--gray-a5)"
1144
+ },
1145
+ children: campaigns.map((_, index) => /* @__PURE__ */ jsx(
1146
+ Box,
1147
+ {
1148
+ onClick: () => goToSlide(index),
1149
+ style: {
1150
+ width: 8,
1151
+ height: 8,
1152
+ borderRadius: "50%",
1153
+ background: index === currentIndex ? "var(--accent-9)" : "var(--gray-a6)",
1154
+ cursor: "pointer",
1155
+ transition: "all 0.2s ease"
1156
+ }
1157
+ },
1158
+ index
1159
+ ))
1160
+ }
1161
+ ),
1162
+ /* @__PURE__ */ jsx(Flex, { justify: "center", pb: "3", children: /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "1", color: "gray", onClick: handleClose, children: "Skip All" }) })
1163
+ ]
1164
+ }
1165
+ ) });
1166
+ }
1167
+ function AdBanner({
1168
+ placement = "home_banner",
1169
+ rotationInterval = 1e4,
1170
+ maxCampaigns = 5,
1171
+ className,
1172
+ style
1173
+ }) {
1174
+ const [currentIndex, setCurrentIndex] = useState(0);
1175
+ const [isAnimating, setIsAnimating] = useState(false);
1176
+ const [progress, setProgress] = useState(0);
1177
+ const trackedImpressions = useRef(/* @__PURE__ */ new Set());
1178
+ const {
1179
+ campaigns,
1180
+ loading,
1181
+ recordImpression,
1182
+ recordClick
1183
+ } = useCampaigns({ placement, maxCampaigns });
1184
+ useEffect(() => {
1185
+ if (campaigns.length === 0) return;
1186
+ const campaign2 = campaigns[currentIndex];
1187
+ if (!campaign2 || trackedImpressions.current.has(campaign2.id)) return;
1188
+ trackedImpressions.current.add(campaign2.id);
1189
+ recordImpression(campaign2);
1190
+ }, [currentIndex, campaigns, recordImpression]);
1191
+ useEffect(() => {
1192
+ if (campaigns.length <= 1) return;
1193
+ setProgress(0);
1194
+ const progressInterval = 50;
1195
+ const steps = rotationInterval / progressInterval;
1196
+ let currentStep = 0;
1197
+ const progressTimer = setInterval(() => {
1198
+ currentStep++;
1199
+ setProgress(currentStep / steps * 100);
1200
+ if (currentStep >= steps) {
1201
+ setIsAnimating(true);
1202
+ setTimeout(() => {
1203
+ setCurrentIndex((prev) => (prev + 1) % campaigns.length);
1204
+ setProgress(0);
1205
+ currentStep = 0;
1206
+ setTimeout(() => setIsAnimating(false), 50);
1207
+ }, 200);
1208
+ }
1209
+ }, progressInterval);
1210
+ return () => clearInterval(progressTimer);
1211
+ }, [campaigns.length, rotationInterval, currentIndex]);
1212
+ const handleClick = useCallback(
1213
+ (campaign2) => {
1214
+ recordClick(campaign2);
1215
+ const targetUrl = campaign2.customCtaUrl || campaign2.product.url;
1216
+ window.open(targetUrl, "_blank");
1217
+ },
1218
+ [recordClick]
1219
+ );
1220
+ const goToSlide = useCallback((index) => {
1221
+ if (index === currentIndex) return;
1222
+ setIsAnimating(true);
1223
+ setTimeout(() => {
1224
+ setCurrentIndex(index);
1225
+ setProgress(0);
1226
+ setTimeout(() => setIsAnimating(false), 50);
1227
+ }, 200);
1228
+ }, [currentIndex]);
1229
+ if (loading || campaigns.length === 0) return null;
1230
+ const campaign = campaigns[currentIndex];
1231
+ if (!campaign) return null;
1232
+ const { product } = campaign;
1233
+ const displayTitle = campaign.customTitle || product.name;
1234
+ const displayTagline = campaign.customTagline || product.tagline;
1235
+ const displayCta = campaign.customCta || "Learn More";
1236
+ const displayColor = campaign.customProductColor || product.color || "#3B82F6";
1237
+ const displayIcon = campaign.customIcon || product.icon64 || "";
1238
+ const displayFeatures = campaign.customFeatures || product.features || [];
1239
+ return /* @__PURE__ */ jsxs(
1240
+ Box,
1241
+ {
1242
+ className,
1243
+ style: {
1244
+ background: "var(--color-background)",
1245
+ borderBottom: "1px solid var(--gray-a4)",
1246
+ position: "relative",
1247
+ ...style
1248
+ },
1249
+ children: [
1250
+ /* @__PURE__ */ jsx(Box, { style: { height: 3, background: displayColor } }),
1251
+ /* @__PURE__ */ jsxs(
1252
+ Box,
1253
+ {
1254
+ style: {
1255
+ background: `linear-gradient(90deg, ${displayColor}08 0%, ${displayColor}12 50%, ${displayColor}08 100%)`
1256
+ },
1257
+ children: [
1258
+ /* @__PURE__ */ jsxs(Flex, { align: "center", justify: "center", gap: "2", py: "2", children: [
1259
+ /* @__PURE__ */ jsx(Sparkles, { size: 12, color: displayColor }),
1260
+ /* @__PURE__ */ jsx(
1261
+ Text,
1262
+ {
1263
+ size: "1",
1264
+ weight: "medium",
1265
+ style: {
1266
+ color: displayColor,
1267
+ fontSize: "11px",
1268
+ letterSpacing: "1.5px",
1269
+ textTransform: "uppercase"
1270
+ },
1271
+ children: "Discover Our Products"
1272
+ }
1273
+ ),
1274
+ /* @__PURE__ */ jsx(Sparkles, { size: 12, color: displayColor })
1275
+ ] }),
1276
+ /* @__PURE__ */ jsx(Box, { px: "4", py: "3", children: /* @__PURE__ */ jsxs(
1277
+ Flex,
1278
+ {
1279
+ direction: { initial: "column", sm: "row" },
1280
+ align: "center",
1281
+ justify: "between",
1282
+ gap: { initial: "3", sm: "4" },
1283
+ style: {
1284
+ opacity: isAnimating ? 0 : 1,
1285
+ transform: isAnimating ? "translateX(-10px)" : "translateX(0)",
1286
+ transition: "all 0.2s ease-out"
1287
+ },
1288
+ children: [
1289
+ /* @__PURE__ */ jsxs(Flex, { align: "center", gap: "3", style: { flex: 1, minWidth: 0 }, children: [
1290
+ /* @__PURE__ */ jsx(
1291
+ Box,
1292
+ {
1293
+ style: {
1294
+ width: 56,
1295
+ height: 56,
1296
+ borderRadius: 12,
1297
+ background: `${displayColor}15`,
1298
+ border: `1.5px solid ${displayColor}30`,
1299
+ display: "flex",
1300
+ alignItems: "center",
1301
+ justifyContent: "center",
1302
+ flexShrink: 0
1303
+ },
1304
+ dangerouslySetInnerHTML: { __html: displayIcon }
1305
+ }
1306
+ ),
1307
+ /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: "0", style: { minWidth: 0 }, children: [
1308
+ /* @__PURE__ */ jsxs(Flex, { align: "center", gap: "2", children: [
1309
+ /* @__PURE__ */ jsx(Text, { size: "3", weight: "bold", children: displayTitle }),
1310
+ /* @__PURE__ */ jsx(
1311
+ Badge,
1312
+ {
1313
+ size: "1",
1314
+ style: {
1315
+ background: `${displayColor}18`,
1316
+ color: displayColor,
1317
+ fontSize: "11px",
1318
+ fontWeight: 600,
1319
+ padding: "3px 8px"
1320
+ },
1321
+ children: product.type === "extension" ? "Extension" : product.type === "android" ? "App" : "Web"
1322
+ }
1323
+ )
1324
+ ] }),
1325
+ /* @__PURE__ */ jsx(
1326
+ Text,
1327
+ {
1328
+ size: "2",
1329
+ color: "gray",
1330
+ style: {
1331
+ marginTop: 4,
1332
+ display: "-webkit-box",
1333
+ WebkitLineClamp: 1,
1334
+ WebkitBoxOrient: "vertical",
1335
+ overflow: "hidden"
1336
+ },
1337
+ children: displayTagline
1338
+ }
1339
+ ),
1340
+ /* @__PURE__ */ jsx(Flex, { gap: "4", mt: "2", display: { initial: "none", md: "flex" }, children: displayFeatures.slice(0, 3).map((feature, i) => /* @__PURE__ */ jsxs(Flex, { align: "center", gap: "1", children: [
1341
+ /* @__PURE__ */ jsx(Check, { size: 12, color: displayColor, strokeWidth: 3 }),
1342
+ /* @__PURE__ */ jsx(Text, { size: "2", style: { color: "var(--gray-10)" }, children: feature })
1343
+ ] }, i)) })
1344
+ ] })
1345
+ ] }),
1346
+ /* @__PURE__ */ jsx(Flex, { align: "center", style: { flexShrink: 0 }, children: /* @__PURE__ */ jsxs(
1347
+ Button,
1348
+ {
1349
+ size: "2",
1350
+ onClick: () => handleClick(campaign),
1351
+ style: {
1352
+ background: displayColor,
1353
+ color: "white",
1354
+ fontWeight: 600,
1355
+ fontSize: "14px",
1356
+ padding: "0 20px",
1357
+ height: 38,
1358
+ boxShadow: `0 2px 8px ${displayColor}40`
1359
+ },
1360
+ children: [
1361
+ displayCta,
1362
+ /* @__PURE__ */ jsx(ExternalLink, { size: 14, style: { marginLeft: 6 } })
1363
+ ]
1364
+ }
1365
+ ) })
1366
+ ]
1367
+ }
1368
+ ) }),
1369
+ campaigns.length > 1 && /* @__PURE__ */ jsx(Flex, { justify: "center", align: "center", gap: "2", py: "3", children: campaigns.map((c, i) => /* @__PURE__ */ jsx(
1370
+ Box,
1371
+ {
1372
+ onClick: () => goToSlide(i),
1373
+ style: {
1374
+ width: 40,
1375
+ height: 4,
1376
+ borderRadius: 2,
1377
+ background: "var(--gray-a4)",
1378
+ cursor: "pointer",
1379
+ overflow: "hidden",
1380
+ position: "relative"
1381
+ },
1382
+ children: /* @__PURE__ */ jsx(
1383
+ Box,
1384
+ {
1385
+ style: {
1386
+ position: "absolute",
1387
+ top: 0,
1388
+ left: 0,
1389
+ height: "100%",
1390
+ width: i === currentIndex ? `${progress}%` : i < currentIndex ? "100%" : "0%",
1391
+ background: c.product?.color || displayColor,
1392
+ borderRadius: 2,
1393
+ transition: i === currentIndex ? "none" : "width 0.3s ease"
1394
+ }
1395
+ }
1396
+ )
1397
+ },
1398
+ i
1399
+ )) })
1400
+ ]
1401
+ }
1402
+ )
1403
+ ]
1404
+ }
1405
+ );
1406
+ }
1407
+ export {
1408
+ AdPanel as A,
1409
+ CardVariant as C,
1410
+ FeaturesVariant as F,
1411
+ GradientVariant as G,
1412
+ HeroVariant as H,
1413
+ LARGE_PANEL_VARIANTS as L,
1414
+ MinimalVariant as M,
1415
+ SMALL_PANEL_VARIANTS as S,
1416
+ TaglineVariant as T,
1417
+ VideoVariant as V,
1418
+ AdSlider as a,
1419
+ AdModal as b,
1420
+ AdUpdateModal as c,
1421
+ AdBanner as d,
1422
+ FeatureGridVariant as e,
1423
+ TestimonialVariant as f,
1424
+ getSmallPanelVariant as g,
1425
+ ComparisonVariant as h,
1426
+ getLargePanelVariant as i
1427
+ };
1428
+ //# sourceMappingURL=AdBanner-z1osYgog.js.map