@adhese/sdk-devtools 0.6.3 → 0.6.5
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/devtools-B63USM72.js +842 -0
- package/dist/devtools-B63USM72.js.map +1 -0
- package/dist/devtools-BULOIqZ6.cjs +861 -0
- package/dist/devtools-BULOIqZ6.cjs.map +1 -0
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -2
- package/package.json +8 -4
- package/dist/devtools-B0YPZFCG.js +0 -1940
- package/dist/devtools-B0YPZFCG.js.map +0 -1
- package/dist/devtools-DpvEjrOq.cjs +0 -1959
- package/dist/devtools-DpvEjrOq.cjs.map +0 -1
|
@@ -0,0 +1,861 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
3
|
+
const client = require("react-dom/client");
|
|
4
|
+
const react = require("react");
|
|
5
|
+
const reactDom = require("react-dom");
|
|
6
|
+
const upperFirst = require("lodash/upperFirst");
|
|
7
|
+
const clsx = require("clsx");
|
|
8
|
+
const tailwindMerge = require("tailwind-merge");
|
|
9
|
+
const classVarianceAuthority = require("class-variance-authority");
|
|
10
|
+
const reactSlot = require("@radix-ui/react-slot");
|
|
11
|
+
const SheetPrimitive = require("@radix-ui/react-dialog");
|
|
12
|
+
const reactIcons = require("@radix-ui/react-icons");
|
|
13
|
+
const TabsPrimitive = require("@radix-ui/react-tabs");
|
|
14
|
+
const SwitchPrimitives = require("@radix-ui/react-switch");
|
|
15
|
+
const LabelPrimitive = require("@radix-ui/react-label");
|
|
16
|
+
function _interopNamespaceDefault(e) {
|
|
17
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
18
|
+
if (e) {
|
|
19
|
+
for (const k in e) {
|
|
20
|
+
if (k !== "default") {
|
|
21
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
22
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: () => e[k]
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
n.default = e;
|
|
30
|
+
return Object.freeze(n);
|
|
31
|
+
}
|
|
32
|
+
const SheetPrimitive__namespace = /* @__PURE__ */ _interopNamespaceDefault(SheetPrimitive);
|
|
33
|
+
const TabsPrimitive__namespace = /* @__PURE__ */ _interopNamespaceDefault(TabsPrimitive);
|
|
34
|
+
const SwitchPrimitives__namespace = /* @__PURE__ */ _interopNamespaceDefault(SwitchPrimitives);
|
|
35
|
+
const LabelPrimitive__namespace = /* @__PURE__ */ _interopNamespaceDefault(LabelPrimitive);
|
|
36
|
+
function cn(...inputs) {
|
|
37
|
+
return tailwindMerge.twMerge(clsx.clsx(inputs));
|
|
38
|
+
}
|
|
39
|
+
function setCooke({
|
|
40
|
+
key,
|
|
41
|
+
value,
|
|
42
|
+
expires,
|
|
43
|
+
path,
|
|
44
|
+
samesite,
|
|
45
|
+
secure
|
|
46
|
+
}) {
|
|
47
|
+
document.cookie = `${key}=${value}; ${expires ? `expires=${expires.toString()};` : ""} ${path ? `path=${path};` : ""} ${samesite ? `samesite=${samesite};` : ""} ${secure ? `secure=${secure};` : ""}`;
|
|
48
|
+
}
|
|
49
|
+
function deleteCookie(key) {
|
|
50
|
+
document.cookie = `${key}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`;
|
|
51
|
+
}
|
|
52
|
+
function getCookie(key) {
|
|
53
|
+
const cookies = document.cookie.split(";");
|
|
54
|
+
for (const cookie of cookies) {
|
|
55
|
+
const [cookieKey2, cookieValue] = cookie.split("=");
|
|
56
|
+
if (cookieKey2.trim() === key)
|
|
57
|
+
return cookieValue;
|
|
58
|
+
}
|
|
59
|
+
return "";
|
|
60
|
+
}
|
|
61
|
+
function hasCookie(key) {
|
|
62
|
+
return document.cookie.includes(`${key}=`);
|
|
63
|
+
}
|
|
64
|
+
const Table = react.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative w-full overflow-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
65
|
+
"table",
|
|
66
|
+
{
|
|
67
|
+
ref,
|
|
68
|
+
className: cn("w-full caption-bottom text-sm", className),
|
|
69
|
+
...props
|
|
70
|
+
}
|
|
71
|
+
) }));
|
|
72
|
+
Table.displayName = "Table";
|
|
73
|
+
const TableHeader = react.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("thead", { ref, className: cn("[&_tr]:border-b", className), ...props }));
|
|
74
|
+
TableHeader.displayName = "TableHeader";
|
|
75
|
+
const TableBody = react.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
76
|
+
"tbody",
|
|
77
|
+
{
|
|
78
|
+
ref,
|
|
79
|
+
className: cn("[&_tr:last-child]:border-0", className),
|
|
80
|
+
...props
|
|
81
|
+
}
|
|
82
|
+
));
|
|
83
|
+
TableBody.displayName = "TableBody";
|
|
84
|
+
const TableFooter = react.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
85
|
+
"tfoot",
|
|
86
|
+
{
|
|
87
|
+
ref,
|
|
88
|
+
className: cn(
|
|
89
|
+
"border-t bg-muted/50 font-medium [&>tr]:last:border-b-0",
|
|
90
|
+
className
|
|
91
|
+
),
|
|
92
|
+
...props
|
|
93
|
+
}
|
|
94
|
+
));
|
|
95
|
+
TableFooter.displayName = "TableFooter";
|
|
96
|
+
const TableRow = react.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
97
|
+
"tr",
|
|
98
|
+
{
|
|
99
|
+
ref,
|
|
100
|
+
className: cn(
|
|
101
|
+
"border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted",
|
|
102
|
+
className
|
|
103
|
+
),
|
|
104
|
+
...props
|
|
105
|
+
}
|
|
106
|
+
));
|
|
107
|
+
TableRow.displayName = "TableRow";
|
|
108
|
+
const TableHead = react.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
109
|
+
"th",
|
|
110
|
+
{
|
|
111
|
+
ref,
|
|
112
|
+
className: cn(
|
|
113
|
+
"h-10 px-2 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
|
|
114
|
+
className
|
|
115
|
+
),
|
|
116
|
+
...props
|
|
117
|
+
}
|
|
118
|
+
));
|
|
119
|
+
TableHead.displayName = "TableHead";
|
|
120
|
+
const TableCell = react.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
121
|
+
"td",
|
|
122
|
+
{
|
|
123
|
+
ref,
|
|
124
|
+
className: cn(
|
|
125
|
+
"p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
|
|
126
|
+
className
|
|
127
|
+
),
|
|
128
|
+
...props
|
|
129
|
+
}
|
|
130
|
+
));
|
|
131
|
+
TableCell.displayName = "TableCell";
|
|
132
|
+
const TableCaption = react.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
133
|
+
"caption",
|
|
134
|
+
{
|
|
135
|
+
ref,
|
|
136
|
+
className: cn("mt-4 text-sm text-muted-foreground", className),
|
|
137
|
+
...props
|
|
138
|
+
}
|
|
139
|
+
));
|
|
140
|
+
TableCaption.displayName = "TableCaption";
|
|
141
|
+
const badgeVariants = classVarianceAuthority.cva(
|
|
142
|
+
"inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
143
|
+
{
|
|
144
|
+
variants: {
|
|
145
|
+
variant: {
|
|
146
|
+
default: "border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",
|
|
147
|
+
secondary: "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
148
|
+
destructive: "border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",
|
|
149
|
+
outline: "text-foreground"
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
defaultVariants: {
|
|
153
|
+
variant: "default"
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
);
|
|
157
|
+
function Badge({ className, variant, ...props }) {
|
|
158
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(badgeVariants({ variant }), className), ...props });
|
|
159
|
+
}
|
|
160
|
+
const buttonVariants = classVarianceAuthority.cva(
|
|
161
|
+
"inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",
|
|
162
|
+
{
|
|
163
|
+
variants: {
|
|
164
|
+
variant: {
|
|
165
|
+
default: "bg-primary text-primary-foreground shadow hover:bg-primary/90",
|
|
166
|
+
destructive: "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
|
|
167
|
+
outline: "border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
|
|
168
|
+
secondary: "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
|
|
169
|
+
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
170
|
+
link: "text-primary underline-offset-4 hover:underline"
|
|
171
|
+
},
|
|
172
|
+
size: {
|
|
173
|
+
default: "h-9 px-4 py-2",
|
|
174
|
+
sm: "h-6 rounded-md px-3 text-xs",
|
|
175
|
+
lg: "h-10 rounded-md px-8",
|
|
176
|
+
icon: "h-9 w-9"
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
defaultVariants: {
|
|
180
|
+
variant: "default",
|
|
181
|
+
size: "default"
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
);
|
|
185
|
+
const Button = react.forwardRef(
|
|
186
|
+
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
187
|
+
const Component = asChild ? reactSlot.Slot : "button";
|
|
188
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
189
|
+
Component,
|
|
190
|
+
{
|
|
191
|
+
className: cn(buttonVariants({ variant, size, className })),
|
|
192
|
+
ref,
|
|
193
|
+
...props
|
|
194
|
+
}
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
);
|
|
198
|
+
Button.displayName = "Button";
|
|
199
|
+
const Sheet = SheetPrimitive__namespace.Root;
|
|
200
|
+
const SheetTrigger = SheetPrimitive__namespace.Trigger;
|
|
201
|
+
const SheetPortal = SheetPrimitive__namespace.Portal;
|
|
202
|
+
const SheetOverlay = react.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
203
|
+
SheetPrimitive__namespace.Overlay,
|
|
204
|
+
{
|
|
205
|
+
className: cn(
|
|
206
|
+
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
207
|
+
className
|
|
208
|
+
),
|
|
209
|
+
...props,
|
|
210
|
+
ref
|
|
211
|
+
}
|
|
212
|
+
));
|
|
213
|
+
SheetOverlay.displayName = SheetPrimitive__namespace.Overlay.displayName;
|
|
214
|
+
const sheetVariants = classVarianceAuthority.cva(
|
|
215
|
+
"fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:duration-500",
|
|
216
|
+
{
|
|
217
|
+
variants: {
|
|
218
|
+
side: {
|
|
219
|
+
top: "inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",
|
|
220
|
+
bottom: "inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",
|
|
221
|
+
left: "inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",
|
|
222
|
+
right: "inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-[calc(100vw-16rem)]"
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
defaultVariants: {
|
|
226
|
+
side: "right"
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
);
|
|
230
|
+
const SheetContent = react.forwardRef(({ side = "right", className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(SheetPortal, { children: [
|
|
231
|
+
/* @__PURE__ */ jsxRuntime.jsx(SheetOverlay, {}),
|
|
232
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
233
|
+
SheetPrimitive__namespace.Content,
|
|
234
|
+
{
|
|
235
|
+
ref,
|
|
236
|
+
className: cn(sheetVariants({ side }), className),
|
|
237
|
+
...props,
|
|
238
|
+
children: [
|
|
239
|
+
children,
|
|
240
|
+
/* @__PURE__ */ jsxRuntime.jsxs(SheetPrimitive__namespace.Close, { className: "absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary", children: [
|
|
241
|
+
/* @__PURE__ */ jsxRuntime.jsx(reactIcons.Cross2Icon, { className: "h-4 w-4" }),
|
|
242
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Close" })
|
|
243
|
+
] })
|
|
244
|
+
]
|
|
245
|
+
}
|
|
246
|
+
)
|
|
247
|
+
] }));
|
|
248
|
+
SheetContent.displayName = SheetPrimitive__namespace.Content.displayName;
|
|
249
|
+
function SheetHeader({
|
|
250
|
+
className,
|
|
251
|
+
...props
|
|
252
|
+
}) {
|
|
253
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
254
|
+
"div",
|
|
255
|
+
{
|
|
256
|
+
className: cn(
|
|
257
|
+
"flex flex-col space-y-2 text-center sm:text-left",
|
|
258
|
+
className
|
|
259
|
+
),
|
|
260
|
+
...props
|
|
261
|
+
}
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
SheetHeader.displayName = "SheetHeader";
|
|
265
|
+
const SheetTitle = react.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
266
|
+
SheetPrimitive__namespace.Title,
|
|
267
|
+
{
|
|
268
|
+
ref,
|
|
269
|
+
className: cn("text-lg font-semibold text-foreground", className),
|
|
270
|
+
...props
|
|
271
|
+
}
|
|
272
|
+
));
|
|
273
|
+
SheetTitle.displayName = SheetPrimitive__namespace.Title.displayName;
|
|
274
|
+
const SheetDescription = react.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
275
|
+
SheetPrimitive__namespace.Description,
|
|
276
|
+
{
|
|
277
|
+
ref,
|
|
278
|
+
className: cn("text-sm text-muted-foreground", className),
|
|
279
|
+
...props
|
|
280
|
+
}
|
|
281
|
+
));
|
|
282
|
+
SheetDescription.displayName = SheetPrimitive__namespace.Description.displayName;
|
|
283
|
+
const slotStatus = {
|
|
284
|
+
unloaded: "Waiting to load",
|
|
285
|
+
loaded: "Ready to render",
|
|
286
|
+
rendered: "Rendered"
|
|
287
|
+
};
|
|
288
|
+
const slotIndexBadgeClasses = [
|
|
289
|
+
"bg-blue-500 hover:bg-blue-500",
|
|
290
|
+
"bg-amber-500 hover:bg-amber-500",
|
|
291
|
+
"bg-green-500 hover:bg-green-500",
|
|
292
|
+
"bg-red-500 hover:bg-red-500",
|
|
293
|
+
"bg-purple-500 hover:bg-purple-500",
|
|
294
|
+
"bg-cyan-500 hover:bg-cyan-500",
|
|
295
|
+
"bg-pink-500 hover:bg-pink-500"
|
|
296
|
+
];
|
|
297
|
+
function SlotsTable({ adheseContext }) {
|
|
298
|
+
const [slots, setSlots] = react.useState([]);
|
|
299
|
+
react.useEffect(() => {
|
|
300
|
+
var _a, _b;
|
|
301
|
+
function onSlotsChange(newSlots) {
|
|
302
|
+
setSlots(newSlots);
|
|
303
|
+
}
|
|
304
|
+
(_a = adheseContext.events) == null ? void 0 : _a.changeSlots.addListener(onSlotsChange);
|
|
305
|
+
onSlotsChange(((_b = adheseContext.getAll) == null ? void 0 : _b.call(adheseContext)) ?? []);
|
|
306
|
+
return () => {
|
|
307
|
+
var _a2;
|
|
308
|
+
(_a2 = adheseContext.events) == null ? void 0 : _a2.changeSlots.removeListener(onSlotsChange);
|
|
309
|
+
};
|
|
310
|
+
}, []);
|
|
311
|
+
const formattedSlots = react.useMemo(() => slots.map((slot) => {
|
|
312
|
+
const ad = slot.ad.value;
|
|
313
|
+
const iframe = slot.getElement();
|
|
314
|
+
let status = "unloaded";
|
|
315
|
+
if (iframe)
|
|
316
|
+
status = "rendered";
|
|
317
|
+
else if (ad)
|
|
318
|
+
status = "loaded";
|
|
319
|
+
return {
|
|
320
|
+
...slot,
|
|
321
|
+
name: slot.name.value,
|
|
322
|
+
ad,
|
|
323
|
+
status,
|
|
324
|
+
format: slot.format.value,
|
|
325
|
+
iframe,
|
|
326
|
+
parameters: Array.from(slot.parameters.entries())
|
|
327
|
+
};
|
|
328
|
+
}), [slots]);
|
|
329
|
+
const slotParametersExist = formattedSlots.some((formattedSlot) => formattedSlot.parameters.length > 0);
|
|
330
|
+
const previewExist = formattedSlots.some((formattedSlot) => {
|
|
331
|
+
var _a;
|
|
332
|
+
return (_a = formattedSlot.ad) == null ? void 0 : _a.preview;
|
|
333
|
+
});
|
|
334
|
+
const origins = react.useMemo(() => {
|
|
335
|
+
const set = /* @__PURE__ */ new Set();
|
|
336
|
+
for (const slot of formattedSlots) {
|
|
337
|
+
const { ad } = slot;
|
|
338
|
+
if (ad)
|
|
339
|
+
set.add(ad.origin);
|
|
340
|
+
}
|
|
341
|
+
return Array.from(set);
|
|
342
|
+
}, [formattedSlots]);
|
|
343
|
+
return formattedSlots.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs(Table, { children: [
|
|
344
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableHeader, { children: /* @__PURE__ */ jsxRuntime.jsxs(TableRow, { children: [
|
|
345
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableHead, { children: "Name" }),
|
|
346
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableHead, { children: "Format" }),
|
|
347
|
+
origins.length > 1 && /* @__PURE__ */ jsxRuntime.jsx(TableHead, { children: "Origin" }),
|
|
348
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableHead, { children: "Location" }),
|
|
349
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableHead, { children: "Render Status" }),
|
|
350
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableHead, { children: "Campaign ID" }),
|
|
351
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableHead, { children: "Booking ID" }),
|
|
352
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableHead, { children: "Creative ID" }),
|
|
353
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableHead, { children: "Traffic ID" }),
|
|
354
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableHead, { children: "Creative type" }),
|
|
355
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableHead, { children: "Viewability tracked" }),
|
|
356
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableHead, { children: "Impression tracked" }),
|
|
357
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableHead, { children: "Element" }),
|
|
358
|
+
slotParametersExist && /* @__PURE__ */ jsxRuntime.jsx(TableHead, { children: "Parameters" }),
|
|
359
|
+
previewExist && /* @__PURE__ */ jsxRuntime.jsx(TableHead, { children: "Preview" })
|
|
360
|
+
] }) }),
|
|
361
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableBody, { children: formattedSlots.map(({
|
|
362
|
+
ad,
|
|
363
|
+
name,
|
|
364
|
+
format,
|
|
365
|
+
location,
|
|
366
|
+
status,
|
|
367
|
+
isViewabilityTracked,
|
|
368
|
+
isImpressionTracked,
|
|
369
|
+
iframe,
|
|
370
|
+
parameters
|
|
371
|
+
}, index) => /* @__PURE__ */ jsxRuntime.jsxs(react.Fragment, { children: [
|
|
372
|
+
/* @__PURE__ */ jsxRuntime.jsxs(TableRow, { id: name, children: [
|
|
373
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableCell, { className: "font-medium", children: /* @__PURE__ */ jsxRuntime.jsx(Badge, { className: cn(slotIndexBadgeClasses[index % slotIndexBadgeClasses.length], "text-white"), children: name }) }),
|
|
374
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableCell, { children: !(ad == null ? void 0 : ad.adFormat) || (ad == null ? void 0 : ad.adFormat) === format ? format : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
375
|
+
/* @__PURE__ */ jsxRuntime.jsx("del", { className: "text-red-300 italic", children: format }),
|
|
376
|
+
/* @__PURE__ */ jsxRuntime.jsx("ins", { className: "no-underline text-green-700", children: ad == null ? void 0 : ad.adFormat })
|
|
377
|
+
] }) }),
|
|
378
|
+
origins.length > 1 && /* @__PURE__ */ jsxRuntime.jsx(TableCell, { children: (ad == null ? void 0 : ad.origin) && /* @__PURE__ */ jsxRuntime.jsx(Badge, { className: cn(slotIndexBadgeClasses[origins.indexOf(ad.origin) % slotIndexBadgeClasses.length], "text-white"), children: upperFirst(ad.origin.toLowerCase()) }) }),
|
|
379
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableCell, { children: location }),
|
|
380
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableCell, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
381
|
+
Badge,
|
|
382
|
+
{
|
|
383
|
+
className: cn({
|
|
384
|
+
unloaded: "bg-secondary text-secondary-foreground hover:bg-secondary",
|
|
385
|
+
loaded: "bg-blue-100 text-blue-900 hover:bg-blue-100",
|
|
386
|
+
rendered: "bg-green-100 text-green-900 hover:bg-green-100"
|
|
387
|
+
}[status]),
|
|
388
|
+
children: slotStatus[status]
|
|
389
|
+
}
|
|
390
|
+
) }),
|
|
391
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableCell, { children: (ad == null ? void 0 : ad.orderId) && (ad == null ? void 0 : ad.orderId) !== "0" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
392
|
+
"a",
|
|
393
|
+
{
|
|
394
|
+
href: `https://${adheseContext.options.account}.adhese.org/campaigns.html#campaignDetail/editCampaign/${ad.orderId}`,
|
|
395
|
+
target: "_blank",
|
|
396
|
+
referrerPolicy: "no-referrer",
|
|
397
|
+
className: cn(buttonVariants({
|
|
398
|
+
variant: "ghost",
|
|
399
|
+
size: "sm"
|
|
400
|
+
})),
|
|
401
|
+
children: ad.orderId
|
|
402
|
+
}
|
|
403
|
+
) : "-" }),
|
|
404
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableCell, { children: (ad == null ? void 0 : ad.adspaceId) && (ad == null ? void 0 : ad.adspaceId) !== "0" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
405
|
+
"a",
|
|
406
|
+
{
|
|
407
|
+
href: `https://${adheseContext.options.account}.adhese.org/campaigns.html#campaignDetail/bookingDetail/${ad.adspaceId}/${ad.orderId}`,
|
|
408
|
+
target: "_blank",
|
|
409
|
+
referrerPolicy: "no-referrer",
|
|
410
|
+
className: cn(buttonVariants({
|
|
411
|
+
variant: "ghost",
|
|
412
|
+
size: "sm"
|
|
413
|
+
})),
|
|
414
|
+
children: ad.adspaceId
|
|
415
|
+
}
|
|
416
|
+
) : "-" }),
|
|
417
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableCell, { children: (ad == null ? void 0 : ad.libId) && (ad == null ? void 0 : ad.orderId) !== "0" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
418
|
+
"a",
|
|
419
|
+
{
|
|
420
|
+
href: `https://${adheseContext.options.account}.adhese.org/campaigns.html#campaignDetail/creativeDetail/${ad.libId}/${ad.orderId}`,
|
|
421
|
+
target: "_blank",
|
|
422
|
+
referrerPolicy: "no-referrer",
|
|
423
|
+
className: cn(buttonVariants({
|
|
424
|
+
variant: "ghost",
|
|
425
|
+
size: "sm"
|
|
426
|
+
})),
|
|
427
|
+
children: ad.libId
|
|
428
|
+
}
|
|
429
|
+
) : "-" }),
|
|
430
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableCell, { children: (ad == null ? void 0 : ad.id) ?? "-" }),
|
|
431
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableCell, { children: (ad == null ? void 0 : ad.ext) ? /* @__PURE__ */ jsxRuntime.jsx(Badge, { variant: "outline", children: ad.ext }) : "-" }),
|
|
432
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableCell, { children: isViewabilityTracked.value ? /* @__PURE__ */ jsxRuntime.jsx(Badge, { className: "bg-green-100 text-green-900 hover:bg-green-100", children: "Yes" }) : /* @__PURE__ */ jsxRuntime.jsx(Badge, { variant: "secondary", children: "No" }) }),
|
|
433
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableCell, { children: isImpressionTracked.value ? /* @__PURE__ */ jsxRuntime.jsx(Badge, { className: "bg-green-100 text-green-900 hover:bg-green-100", children: "Yes" }) : /* @__PURE__ */ jsxRuntime.jsx(Badge, { variant: "secondary", children: "No" }) }),
|
|
434
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableCell, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
435
|
+
Button,
|
|
436
|
+
{
|
|
437
|
+
variant: "secondary",
|
|
438
|
+
size: "sm",
|
|
439
|
+
disabled: !iframe,
|
|
440
|
+
onClick: () => {
|
|
441
|
+
if (iframe) {
|
|
442
|
+
iframe.scrollIntoView();
|
|
443
|
+
iframe.style.outline = "solid 5px red";
|
|
444
|
+
setTimeout(() => {
|
|
445
|
+
iframe.style.outline = "";
|
|
446
|
+
}, 1e3);
|
|
447
|
+
}
|
|
448
|
+
},
|
|
449
|
+
children: "Go to element"
|
|
450
|
+
}
|
|
451
|
+
) }),
|
|
452
|
+
slotParametersExist && /* @__PURE__ */ jsxRuntime.jsx(TableCell, { children: parameters.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(Sheet, { children: [
|
|
453
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
454
|
+
SheetTrigger,
|
|
455
|
+
{
|
|
456
|
+
className: buttonVariants({
|
|
457
|
+
variant: "secondary",
|
|
458
|
+
size: "sm"
|
|
459
|
+
}),
|
|
460
|
+
children: "Show"
|
|
461
|
+
}
|
|
462
|
+
),
|
|
463
|
+
/* @__PURE__ */ jsxRuntime.jsxs(SheetContent, { className: "bg-white flex flex-col gap-4", children: [
|
|
464
|
+
/* @__PURE__ */ jsxRuntime.jsx(SheetHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(SheetTitle, { children: "Parameters" }) }),
|
|
465
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Table, { children: [
|
|
466
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableHeader, { children: /* @__PURE__ */ jsxRuntime.jsxs(TableRow, { children: [
|
|
467
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableHead, { children: "Key" }),
|
|
468
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableHead, { children: "Value" })
|
|
469
|
+
] }) }),
|
|
470
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableBody, { children: parameters.map(([parameterName, value]) => /* @__PURE__ */ jsxRuntime.jsxs(TableRow, { children: [
|
|
471
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableCell, { children: /* @__PURE__ */ jsxRuntime.jsx(Badge, { variant: "outline", children: parameterName }) }),
|
|
472
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableCell, { children: Array.isArray(value) ? /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "flex gap-1", children: value.map((item, paramIndex) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: /* @__PURE__ */ jsxRuntime.jsx(Badge, { variant: "outline", children: item }) }, paramIndex)) }) : /* @__PURE__ */ jsxRuntime.jsx(Badge, { variant: "outline", children: value }) })
|
|
473
|
+
] }, parameterName)) })
|
|
474
|
+
] })
|
|
475
|
+
] })
|
|
476
|
+
] }) }),
|
|
477
|
+
previewExist && /* @__PURE__ */ jsxRuntime.jsx(TableCell, { children: (ad == null ? void 0 : ad.preview) && /* @__PURE__ */ jsxRuntime.jsx(Badge, { className: "bg-amber-400 text-amber-950 hover:bg-amber-400", children: "PREVIEW" }) })
|
|
478
|
+
] }),
|
|
479
|
+
(iframe == null ? void 0 : iframe.parentElement) && reactDom.createPortal(
|
|
480
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "absolute inset-1 flex gap-2 items-start", children: [
|
|
481
|
+
/* @__PURE__ */ jsxRuntime.jsx(Badge, { className: cn(slotIndexBadgeClasses[index % slotIndexBadgeClasses.length], "text-white"), children: name }),
|
|
482
|
+
(ad == null ? void 0 : ad.preview) && /* @__PURE__ */ jsxRuntime.jsx(Badge, { className: "bg-amber-400 text-amber-950 hover:bg-amber-400", children: "PREVIEW" })
|
|
483
|
+
] }),
|
|
484
|
+
iframe.parentElement
|
|
485
|
+
)
|
|
486
|
+
] }, name)) })
|
|
487
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx("p", { children: "No slots available" });
|
|
488
|
+
}
|
|
489
|
+
const Tabs = TabsPrimitive__namespace.Root;
|
|
490
|
+
const TabsList = react.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
491
|
+
TabsPrimitive__namespace.List,
|
|
492
|
+
{
|
|
493
|
+
ref,
|
|
494
|
+
className: cn(
|
|
495
|
+
"inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",
|
|
496
|
+
className
|
|
497
|
+
),
|
|
498
|
+
...props
|
|
499
|
+
}
|
|
500
|
+
));
|
|
501
|
+
TabsList.displayName = TabsPrimitive__namespace.List.displayName;
|
|
502
|
+
const TabsTrigger = react.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
503
|
+
TabsPrimitive__namespace.Trigger,
|
|
504
|
+
{
|
|
505
|
+
ref,
|
|
506
|
+
className: cn(
|
|
507
|
+
"inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",
|
|
508
|
+
className
|
|
509
|
+
),
|
|
510
|
+
...props
|
|
511
|
+
}
|
|
512
|
+
));
|
|
513
|
+
TabsTrigger.displayName = TabsPrimitive__namespace.Trigger.displayName;
|
|
514
|
+
const TabsContent = react.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
515
|
+
TabsPrimitive__namespace.Content,
|
|
516
|
+
{
|
|
517
|
+
ref,
|
|
518
|
+
className: cn(
|
|
519
|
+
"mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
520
|
+
className
|
|
521
|
+
),
|
|
522
|
+
...props
|
|
523
|
+
}
|
|
524
|
+
));
|
|
525
|
+
TabsContent.displayName = TabsPrimitive__namespace.Content.displayName;
|
|
526
|
+
const dateFormatter = new Intl.DateTimeFormat("en-US", {
|
|
527
|
+
hour: "numeric",
|
|
528
|
+
minute: "numeric",
|
|
529
|
+
second: "numeric",
|
|
530
|
+
fractionalSecondDigits: 3,
|
|
531
|
+
hour12: false
|
|
532
|
+
});
|
|
533
|
+
const logTableRowClasses = {
|
|
534
|
+
error: "bg-red-100 text-red-900",
|
|
535
|
+
warn: "bg-amber-100 text-amber-900"
|
|
536
|
+
};
|
|
537
|
+
const logBadgeClasses = {
|
|
538
|
+
error: "bg-red-500 text-white",
|
|
539
|
+
warn: "bg-amber-500 text-white",
|
|
540
|
+
info: "bg-blue-500 text-white"
|
|
541
|
+
};
|
|
542
|
+
function LogTable({
|
|
543
|
+
adheseContext
|
|
544
|
+
}) {
|
|
545
|
+
const [logs, setLogs] = react.useState([]);
|
|
546
|
+
react.useEffect(() => {
|
|
547
|
+
function onLogsChange() {
|
|
548
|
+
setLogs(
|
|
549
|
+
adheseContext.logger.getLogs().toSorted(
|
|
550
|
+
(a, b) => b.timestamp - a.timestamp
|
|
551
|
+
)
|
|
552
|
+
);
|
|
553
|
+
}
|
|
554
|
+
adheseContext.logger.events.log.addListener(onLogsChange);
|
|
555
|
+
onLogsChange();
|
|
556
|
+
return () => {
|
|
557
|
+
adheseContext.logger.events.log.removeListener(onLogsChange);
|
|
558
|
+
};
|
|
559
|
+
}, []);
|
|
560
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Table, { children: [
|
|
561
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableHeader, { children: /* @__PURE__ */ jsxRuntime.jsxs(TableRow, { children: [
|
|
562
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableHead, { children: "Time" }),
|
|
563
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableHead, { children: "Scope" }),
|
|
564
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableHead, { children: "Level" }),
|
|
565
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableHead, { children: "Message" }),
|
|
566
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableHead, { children: "Attributes" })
|
|
567
|
+
] }) }),
|
|
568
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableBody, { children: logs.map((log) => /* @__PURE__ */ jsxRuntime.jsxs(TableRow, { className: logTableRowClasses[log.level] ?? "", children: [
|
|
569
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableCell, { children: dateFormatter.format(new Date(log.timestamp)) }),
|
|
570
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableCell, { children: log.scope }),
|
|
571
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableCell, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
572
|
+
Badge,
|
|
573
|
+
{
|
|
574
|
+
variant: "secondary",
|
|
575
|
+
className: logBadgeClasses[log.level] ?? "",
|
|
576
|
+
children: upperFirst(log.level)
|
|
577
|
+
}
|
|
578
|
+
) }),
|
|
579
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableCell, { children: log.message }),
|
|
580
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableCell, { children: Boolean(log.attributes) && /* @__PURE__ */ jsxRuntime.jsxs(Sheet, { children: [
|
|
581
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
582
|
+
SheetTrigger,
|
|
583
|
+
{
|
|
584
|
+
className: buttonVariants({
|
|
585
|
+
variant: "secondary",
|
|
586
|
+
size: "sm"
|
|
587
|
+
}),
|
|
588
|
+
children: "Show"
|
|
589
|
+
}
|
|
590
|
+
),
|
|
591
|
+
/* @__PURE__ */ jsxRuntime.jsxs(SheetContent, { className: "bg-white flex flex-col gap-4", children: [
|
|
592
|
+
/* @__PURE__ */ jsxRuntime.jsx(SheetHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(SheetTitle, { children: "Attributes" }) }),
|
|
593
|
+
/* @__PURE__ */ jsxRuntime.jsx("pre", { className: "p-4 bg-accent overflow-auto max-h-full text-sm rounded-md", children: JSON.stringify(log.attributes, null, 2) })
|
|
594
|
+
] })
|
|
595
|
+
] }) })
|
|
596
|
+
] }, log.id)) })
|
|
597
|
+
] });
|
|
598
|
+
}
|
|
599
|
+
function ParametersTable({
|
|
600
|
+
adheseContext
|
|
601
|
+
}) {
|
|
602
|
+
const [parameters, setParameters] = react.useState([]);
|
|
603
|
+
react.useEffect(() => {
|
|
604
|
+
var _a;
|
|
605
|
+
function onParametersChange() {
|
|
606
|
+
var _a2;
|
|
607
|
+
setParameters(Array.from(((_a2 = adheseContext.parameters) == null ? void 0 : _a2.entries()) ?? []).map(([name, value]) => ({
|
|
608
|
+
name,
|
|
609
|
+
value
|
|
610
|
+
})).toSorted((a, b) => a.name.localeCompare(b.name)));
|
|
611
|
+
}
|
|
612
|
+
(_a = adheseContext.events) == null ? void 0 : _a.parametersChange.addListener(onParametersChange);
|
|
613
|
+
onParametersChange();
|
|
614
|
+
return () => {
|
|
615
|
+
var _a2;
|
|
616
|
+
(_a2 = adheseContext.events) == null ? void 0 : _a2.parametersChange.removeListener(onParametersChange);
|
|
617
|
+
};
|
|
618
|
+
}, []);
|
|
619
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Table, { children: [
|
|
620
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableHeader, { children: /* @__PURE__ */ jsxRuntime.jsxs(TableRow, { children: [
|
|
621
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableHead, { children: "Parameter" }),
|
|
622
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableHead, { children: "Value" })
|
|
623
|
+
] }) }),
|
|
624
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableBody, { children: parameters.map((parameter) => /* @__PURE__ */ jsxRuntime.jsxs(TableRow, { children: [
|
|
625
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableCell, { children: /* @__PURE__ */ jsxRuntime.jsx(Badge, { variant: "outline", children: parameter.name }) }),
|
|
626
|
+
/* @__PURE__ */ jsxRuntime.jsx(TableCell, { children: Array.isArray(parameter.value) ? /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "flex gap-1", children: parameter.value.map((item, index) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: /* @__PURE__ */ jsxRuntime.jsx(Badge, { variant: "outline", children: item }) }, index)) }) : /* @__PURE__ */ jsxRuntime.jsx(Badge, { variant: "outline", children: parameter.value }) })
|
|
627
|
+
] }, parameter.name)) })
|
|
628
|
+
] });
|
|
629
|
+
}
|
|
630
|
+
const Switch = react.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
631
|
+
SwitchPrimitives__namespace.Root,
|
|
632
|
+
{
|
|
633
|
+
className: cn(
|
|
634
|
+
"peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",
|
|
635
|
+
className
|
|
636
|
+
),
|
|
637
|
+
...props,
|
|
638
|
+
ref,
|
|
639
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
640
|
+
SwitchPrimitives__namespace.Thumb,
|
|
641
|
+
{
|
|
642
|
+
className: cn(
|
|
643
|
+
"pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0"
|
|
644
|
+
)
|
|
645
|
+
}
|
|
646
|
+
)
|
|
647
|
+
}
|
|
648
|
+
));
|
|
649
|
+
Switch.displayName = SwitchPrimitives__namespace.Root.displayName;
|
|
650
|
+
const labelVariants = classVarianceAuthority.cva(
|
|
651
|
+
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
652
|
+
);
|
|
653
|
+
const Label = react.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
654
|
+
LabelPrimitive__namespace.Root,
|
|
655
|
+
{
|
|
656
|
+
ref,
|
|
657
|
+
className: cn(labelVariants(), className),
|
|
658
|
+
...props
|
|
659
|
+
}
|
|
660
|
+
));
|
|
661
|
+
Label.displayName = LabelPrimitive__namespace.Root.displayName;
|
|
662
|
+
const Input = react.forwardRef(
|
|
663
|
+
({ className, type, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
664
|
+
"input",
|
|
665
|
+
{
|
|
666
|
+
type,
|
|
667
|
+
className: cn(
|
|
668
|
+
"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
|
|
669
|
+
className
|
|
670
|
+
),
|
|
671
|
+
ref,
|
|
672
|
+
...props
|
|
673
|
+
}
|
|
674
|
+
)
|
|
675
|
+
);
|
|
676
|
+
Input.displayName = "Input";
|
|
677
|
+
const cookieKey = "debugKey";
|
|
678
|
+
function setDebugCookie(value) {
|
|
679
|
+
setCooke({
|
|
680
|
+
key: cookieKey,
|
|
681
|
+
value,
|
|
682
|
+
expires: new Date(Date.now() + 24 * 60 * 60 * 1e3)
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
function simpleStringify(value) {
|
|
686
|
+
if (typeof value === "object")
|
|
687
|
+
return Object.values(value).map((nestedValue) => `${simpleStringify(nestedValue)}`).join("");
|
|
688
|
+
if (typeof value === "boolean")
|
|
689
|
+
return value ? "1" : "0";
|
|
690
|
+
return String(value);
|
|
691
|
+
}
|
|
692
|
+
function FronttailSettings({
|
|
693
|
+
adheseContext,
|
|
694
|
+
className,
|
|
695
|
+
"aria-labelledby": ariaLabelledBy,
|
|
696
|
+
...props
|
|
697
|
+
}) {
|
|
698
|
+
const autoGeneratedKey = react.useMemo(() => `adhese-${adheseContext.options.account}-${btoa(simpleStringify(adheseContext.options)).slice(0, 20)}`, [adheseContext.options]);
|
|
699
|
+
const [fronttailDebugKey, setFronttailDebugKey] = react.useState(hasCookie(cookieKey) ? getCookie(cookieKey) : autoGeneratedKey);
|
|
700
|
+
const [isFronttailEnabled, setIsFronttailEnabled] = react.useState(hasCookie(cookieKey));
|
|
701
|
+
const onFronttailDebugKeyChange = react.useCallback((event) => {
|
|
702
|
+
const { value } = event.target;
|
|
703
|
+
setFronttailDebugKey(value);
|
|
704
|
+
if (isFronttailEnabled && value.length > 4)
|
|
705
|
+
setDebugCookie(value);
|
|
706
|
+
}, [setDebugCookie, isFronttailEnabled]);
|
|
707
|
+
const onFrontailEnabledChange = react.useCallback(() => {
|
|
708
|
+
setIsFronttailEnabled((value) => {
|
|
709
|
+
if (value)
|
|
710
|
+
deleteCookie(cookieKey);
|
|
711
|
+
else
|
|
712
|
+
setDebugCookie(fronttailDebugKey);
|
|
713
|
+
return !value;
|
|
714
|
+
});
|
|
715
|
+
}, [setDebugCookie, fronttailDebugKey]);
|
|
716
|
+
const id = react.useId();
|
|
717
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("section", { className: cn("flex flex-col gap-6", className), "aria-labelledby": ariaLabelledBy ?? `fronttailHeading${id}`, ...props, children: [
|
|
718
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-lg font-semibold", id: `fronttailHeading${id}`, children: "Fronttail settings" }),
|
|
719
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-4", children: [
|
|
720
|
+
/* @__PURE__ */ jsxRuntime.jsx(Switch, { checked: isFronttailEnabled, onCheckedChange: onFrontailEnabledChange, id: `fronttailSwitch${id}` }),
|
|
721
|
+
/* @__PURE__ */ jsxRuntime.jsxs(Label, { htmlFor: `fronttailSwitch${id}`, children: [
|
|
722
|
+
"Enable Fronttail debugging",
|
|
723
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-gray-400 font-normal", children: " – Cookie will expire automatically in 1 day" })
|
|
724
|
+
] })
|
|
725
|
+
] }),
|
|
726
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
727
|
+
/* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: `fronttailDebugKey${id}`, children: "Debug key" }),
|
|
728
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-4", children: [
|
|
729
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
730
|
+
Input,
|
|
731
|
+
{
|
|
732
|
+
id: `fronttailDebugKey${id}`,
|
|
733
|
+
value: fronttailDebugKey,
|
|
734
|
+
onChange: onFronttailDebugKeyChange,
|
|
735
|
+
className: cn("max-w-60", {
|
|
736
|
+
// eslint-disable-next-line ts/naming-convention
|
|
737
|
+
"border-destructive": fronttailDebugKey.length < 4
|
|
738
|
+
})
|
|
739
|
+
}
|
|
740
|
+
),
|
|
741
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
742
|
+
Button,
|
|
743
|
+
{
|
|
744
|
+
variant: "outline",
|
|
745
|
+
onClick: () => {
|
|
746
|
+
setFronttailDebugKey(autoGeneratedKey);
|
|
747
|
+
if (isFronttailEnabled)
|
|
748
|
+
setDebugCookie(autoGeneratedKey);
|
|
749
|
+
},
|
|
750
|
+
children: "Auto generate key"
|
|
751
|
+
}
|
|
752
|
+
)
|
|
753
|
+
] }),
|
|
754
|
+
fronttailDebugKey.length < 4 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-destructive", children: "Debug key must contain at least 4 characters" })
|
|
755
|
+
] })
|
|
756
|
+
] });
|
|
757
|
+
}
|
|
758
|
+
const settingClasses = "border-solid border-b-2 border-accent pb-8 mb-8 last:mb-0 last:pb-0 last:border-0";
|
|
759
|
+
function Settings({
|
|
760
|
+
adheseContext
|
|
761
|
+
}) {
|
|
762
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(FronttailSettings, { adheseContext, className: settingClasses }) });
|
|
763
|
+
}
|
|
764
|
+
function PreviewButton() {
|
|
765
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: window.location.search.includes("adhesePreviewCreativeId") && /* @__PURE__ */ jsxRuntime.jsx(
|
|
766
|
+
Button,
|
|
767
|
+
{
|
|
768
|
+
onClick: () => {
|
|
769
|
+
const currentUrl = new URL(window.location.href);
|
|
770
|
+
window.location.replace(`${currentUrl.origin}${currentUrl.pathname === "/" ? "" : currentUrl.pathname}`);
|
|
771
|
+
},
|
|
772
|
+
variant: "secondary",
|
|
773
|
+
children: "Disable preview mode"
|
|
774
|
+
}
|
|
775
|
+
) });
|
|
776
|
+
}
|
|
777
|
+
function Devtools({ adheseContext }) {
|
|
778
|
+
const [spacing, setSpacing] = react.useState(0);
|
|
779
|
+
const appRef = react.useRef(null);
|
|
780
|
+
const [isOpen, setIsOpen] = react.useState(false);
|
|
781
|
+
react.useEffect(() => {
|
|
782
|
+
let resizeObserver;
|
|
783
|
+
if (isOpen) {
|
|
784
|
+
resizeObserver = new ResizeObserver(
|
|
785
|
+
([entry]) => {
|
|
786
|
+
setSpacing(entry.target.getBoundingClientRect().height);
|
|
787
|
+
}
|
|
788
|
+
);
|
|
789
|
+
if (appRef.current)
|
|
790
|
+
resizeObserver.observe(appRef.current);
|
|
791
|
+
}
|
|
792
|
+
return () => {
|
|
793
|
+
resizeObserver == null ? void 0 : resizeObserver.disconnect();
|
|
794
|
+
};
|
|
795
|
+
}, [isOpen]);
|
|
796
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "adhese-devtools", children: isOpen ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
797
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
798
|
+
"section",
|
|
799
|
+
{
|
|
800
|
+
className: "fixed bottom-0 w-full border-t-2 border-t-accent bg-background shadow-lg overflow-auto",
|
|
801
|
+
ref: appRef,
|
|
802
|
+
"aria-label": "Adhese Devtools",
|
|
803
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(Tabs, { defaultValue: "slots", children: [
|
|
804
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between p-4", children: [
|
|
805
|
+
/* @__PURE__ */ jsxRuntime.jsxs(TabsList, { children: [
|
|
806
|
+
/* @__PURE__ */ jsxRuntime.jsx(TabsTrigger, { value: "slots", children: "Slots" }),
|
|
807
|
+
/* @__PURE__ */ jsxRuntime.jsx(TabsTrigger, { value: "logs", children: "Logs" }),
|
|
808
|
+
/* @__PURE__ */ jsxRuntime.jsx(TabsTrigger, { value: "parameters", children: "Parameters" }),
|
|
809
|
+
/* @__PURE__ */ jsxRuntime.jsx(TabsTrigger, { value: "settings", children: "Settings" })
|
|
810
|
+
] }),
|
|
811
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
812
|
+
/* @__PURE__ */ jsxRuntime.jsx(PreviewButton, {}),
|
|
813
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
814
|
+
Button,
|
|
815
|
+
{
|
|
816
|
+
onClick: setIsOpen.bind(null, false),
|
|
817
|
+
children: "Close"
|
|
818
|
+
}
|
|
819
|
+
)
|
|
820
|
+
] })
|
|
821
|
+
] }),
|
|
822
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "overflow-auto max-h-96 border-t-2 border-t-accent p-4", children: [
|
|
823
|
+
/* @__PURE__ */ jsxRuntime.jsx(TabsContent, { value: "slots", children: /* @__PURE__ */ jsxRuntime.jsx(SlotsTable, { adheseContext }) }),
|
|
824
|
+
/* @__PURE__ */ jsxRuntime.jsx(TabsContent, { value: "logs", children: /* @__PURE__ */ jsxRuntime.jsx(LogTable, { adheseContext }) }),
|
|
825
|
+
/* @__PURE__ */ jsxRuntime.jsx(TabsContent, { value: "parameters", children: /* @__PURE__ */ jsxRuntime.jsx(ParametersTable, { adheseContext }) }),
|
|
826
|
+
/* @__PURE__ */ jsxRuntime.jsx(TabsContent, { value: "settings", children: /* @__PURE__ */ jsxRuntime.jsx(Settings, { adheseContext }) })
|
|
827
|
+
] })
|
|
828
|
+
] })
|
|
829
|
+
}
|
|
830
|
+
),
|
|
831
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
832
|
+
"div",
|
|
833
|
+
{
|
|
834
|
+
style: {
|
|
835
|
+
height: spacing
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
)
|
|
839
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "fixed bottom-4 right-4 flex flex-col gap-2", children: [
|
|
840
|
+
/* @__PURE__ */ jsxRuntime.jsx(Button, { onClick: setIsOpen.bind(null, true), children: "Open Adhese Devtools" }),
|
|
841
|
+
/* @__PURE__ */ jsxRuntime.jsx(PreviewButton, {})
|
|
842
|
+
] }) });
|
|
843
|
+
}
|
|
844
|
+
const Devtools$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
845
|
+
__proto__: null,
|
|
846
|
+
Devtools
|
|
847
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
848
|
+
function createAdheseDevtools(element, context) {
|
|
849
|
+
const root = client.createRoot(element);
|
|
850
|
+
root.render(/* @__PURE__ */ jsxRuntime.jsx(Devtools, { adheseContext: context }));
|
|
851
|
+
return () => {
|
|
852
|
+
root.unmount();
|
|
853
|
+
};
|
|
854
|
+
}
|
|
855
|
+
const main = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
856
|
+
__proto__: null,
|
|
857
|
+
createAdheseDevtools
|
|
858
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
859
|
+
exports.Devtools = Devtools$1;
|
|
860
|
+
exports.main = main;
|
|
861
|
+
//# sourceMappingURL=devtools-BULOIqZ6.cjs.map
|