@simple-builder/react 1.4.0 → 1.4.1

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.
@@ -0,0 +1,2340 @@
1
+ 'use client';
2
+ 'use strict';
3
+
4
+ require('./chunk-JFWIO2AR.js');
5
+ var chunk7FWFM2TR_js = require('./chunk-7FWFM2TR.js');
6
+ var chunk63LNKQZD_js = require('./chunk-63LNKQZD.js');
7
+ var React25 = require('react');
8
+ var lucideReact = require('lucide-react');
9
+ var AlertDialogPrimitive = require('@radix-ui/react-alert-dialog');
10
+ var PopoverPrimitive = require('@radix-ui/react-popover');
11
+ var react = require('@tiptap/react');
12
+ var extensionColor = require('@tiptap/extension-color');
13
+ var extensionTextStyle = require('@tiptap/extension-text-style');
14
+ var extensionUnderline = require('@tiptap/extension-underline');
15
+ var starterKit = require('@tiptap/starter-kit');
16
+ var TiptapLink = require('@tiptap/extension-link');
17
+ var state = require('@tiptap/pm/state');
18
+ var DropdownMenuPrimitive = require('@radix-ui/react-dropdown-menu');
19
+ var SeparatorPrimitive = require('@radix-ui/react-separator');
20
+ var TogglePrimitive = require('@radix-ui/react-toggle');
21
+ var classVarianceAuthority = require('class-variance-authority');
22
+ var lu = require('react-icons/lu');
23
+ var ToggleGroupPrimitive = require('@radix-ui/react-toggle-group');
24
+ var DialogPrimitive = require('@radix-ui/react-dialog');
25
+ var reactSlot = require('@radix-ui/react-slot');
26
+ var reactHookForm = require('react-hook-form');
27
+ var LabelPrimitive = require('@radix-ui/react-label');
28
+ var SwitchPrimitives = require('@radix-ui/react-switch');
29
+ var zod$1 = require('@hookform/resolvers/zod');
30
+ var zod = require('zod');
31
+ var dateFns = require('date-fns');
32
+ var reactDayPicker = require('react-day-picker');
33
+ var SelectPrimitive = require('@radix-ui/react-select');
34
+ var TabsPrimitive = require('@radix-ui/react-tabs');
35
+ var ScrollAreaPrimitive = require('@radix-ui/react-scroll-area');
36
+
37
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
38
+
39
+ function _interopNamespace(e) {
40
+ if (e && e.__esModule) return e;
41
+ var n = Object.create(null);
42
+ if (e) {
43
+ Object.keys(e).forEach(function (k) {
44
+ if (k !== 'default') {
45
+ var d = Object.getOwnPropertyDescriptor(e, k);
46
+ Object.defineProperty(n, k, d.get ? d : {
47
+ enumerable: true,
48
+ get: function () { return e[k]; }
49
+ });
50
+ }
51
+ });
52
+ }
53
+ n.default = e;
54
+ return Object.freeze(n);
55
+ }
56
+
57
+ var React25__namespace = /*#__PURE__*/_interopNamespace(React25);
58
+ var AlertDialogPrimitive__namespace = /*#__PURE__*/_interopNamespace(AlertDialogPrimitive);
59
+ var PopoverPrimitive__namespace = /*#__PURE__*/_interopNamespace(PopoverPrimitive);
60
+ var TiptapLink__default = /*#__PURE__*/_interopDefault(TiptapLink);
61
+ var DropdownMenuPrimitive__namespace = /*#__PURE__*/_interopNamespace(DropdownMenuPrimitive);
62
+ var SeparatorPrimitive__namespace = /*#__PURE__*/_interopNamespace(SeparatorPrimitive);
63
+ var TogglePrimitive__namespace = /*#__PURE__*/_interopNamespace(TogglePrimitive);
64
+ var ToggleGroupPrimitive__namespace = /*#__PURE__*/_interopNamespace(ToggleGroupPrimitive);
65
+ var DialogPrimitive__namespace = /*#__PURE__*/_interopNamespace(DialogPrimitive);
66
+ var LabelPrimitive__namespace = /*#__PURE__*/_interopNamespace(LabelPrimitive);
67
+ var SwitchPrimitives__namespace = /*#__PURE__*/_interopNamespace(SwitchPrimitives);
68
+ var SelectPrimitive__namespace = /*#__PURE__*/_interopNamespace(SelectPrimitive);
69
+ var TabsPrimitive__namespace = /*#__PURE__*/_interopNamespace(TabsPrimitive);
70
+ var ScrollAreaPrimitive__namespace = /*#__PURE__*/_interopNamespace(ScrollAreaPrimitive);
71
+
72
+ var AlertDialog = AlertDialogPrimitive__namespace.Root;
73
+ var AlertDialogTrigger = AlertDialogPrimitive__namespace.Trigger;
74
+ var AlertDialogPortal = AlertDialogPrimitive__namespace.Portal;
75
+ var AlertDialogOverlay = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
76
+ AlertDialogPrimitive__namespace.Overlay,
77
+ {
78
+ className: chunk63LNKQZD_js.cn(
79
+ "sb:fixed sb:inset-0 sb:z-50 sb:bg-background/80 sb:backdrop-blur-sm data-[state=open]:sb-animate-in data-[state=closed]:sb-animate-out data-[state=closed]:sb-fade-out-0 data-[state=open]:sb-fade-in-0",
80
+ className
81
+ ),
82
+ ...props,
83
+ ref
84
+ }
85
+ ));
86
+ AlertDialogOverlay.displayName = AlertDialogPrimitive__namespace.Overlay.displayName;
87
+ var AlertDialogContent = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(AlertDialogPortal, null, /* @__PURE__ */ React25__namespace.createElement(AlertDialogOverlay, null), /* @__PURE__ */ React25__namespace.createElement(
88
+ AlertDialogPrimitive__namespace.Content,
89
+ {
90
+ ref,
91
+ className: chunk63LNKQZD_js.cn(
92
+ "sb:fixed sb:font-roboto sb:left-[50%] sb:top-[50%] sb:z-50 sb:grid sb:w-full sb:max-w-lg sb:translate-x-[-50%] sb:translate-y-[-50%] sb:gap-4 sb:border sb:bg-background sb:p-6 sb:shadow-lg sb:duration-200 data-[state=open]:sb-animate-in data-[state=closed]:sb-animate-out data-[state=closed]:sb-fade-out-0 data-[state=open]:sb-fade-in-0 data-[state=closed]:sb-zoom-out-95 data-[state=open]:sb-zoom-in-95 data-[state=closed]:sb-slide-out-to-left-1/2 data-[state=closed]:sb-slide-out-to-top-[48%] data-[state=open]:sb-slide-in-from-left-1/2 data-[state=open]:sb-slide-in-from-top-[48%] sb:sm:rounded-lg",
93
+ className
94
+ ),
95
+ ...props
96
+ }
97
+ )));
98
+ AlertDialogContent.displayName = AlertDialogPrimitive__namespace.Content.displayName;
99
+ var AlertDialogFooter = ({
100
+ className,
101
+ ...props
102
+ }) => /* @__PURE__ */ React25__namespace.createElement(
103
+ "div",
104
+ {
105
+ className: chunk63LNKQZD_js.cn(
106
+ "sb:flex sb:flex-col-reverse sb:sm:flex-row sb:sm:justify-end sb:sm:gap-2",
107
+ className
108
+ ),
109
+ ...props
110
+ }
111
+ );
112
+ AlertDialogFooter.displayName = "AlertDialogFooter";
113
+ var AlertDialogTitle = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
114
+ AlertDialogPrimitive__namespace.Title,
115
+ {
116
+ ref,
117
+ className: chunk63LNKQZD_js.cn("sb:text-lg sb:font-semibold", className),
118
+ ...props
119
+ }
120
+ ));
121
+ AlertDialogTitle.displayName = AlertDialogPrimitive__namespace.Title.displayName;
122
+ var AlertDialogDescription = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
123
+ AlertDialogPrimitive__namespace.Description,
124
+ {
125
+ ref,
126
+ className: chunk63LNKQZD_js.cn("sb:text-sm sb:text-muted-foreground", className),
127
+ ...props
128
+ }
129
+ ));
130
+ AlertDialogDescription.displayName = AlertDialogPrimitive__namespace.Description.displayName;
131
+ var AlertDialogAction = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
132
+ AlertDialogPrimitive__namespace.Action,
133
+ {
134
+ ref,
135
+ className: chunk63LNKQZD_js.cn(chunk7FWFM2TR_js.buttonVariants(), className),
136
+ ...props
137
+ }
138
+ ));
139
+ AlertDialogAction.displayName = AlertDialogPrimitive__namespace.Action.displayName;
140
+ var AlertDialogCancel = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
141
+ AlertDialogPrimitive__namespace.Cancel,
142
+ {
143
+ ref,
144
+ className: chunk63LNKQZD_js.cn(
145
+ chunk7FWFM2TR_js.buttonVariants({ variant: "outline" }),
146
+ "sb:mt-2 sb:sm:mt-0",
147
+ className
148
+ ),
149
+ ...props
150
+ }
151
+ ));
152
+ AlertDialogCancel.displayName = AlertDialogPrimitive__namespace.Cancel.displayName;
153
+ var Popover = PopoverPrimitive__namespace.Root;
154
+ var PopoverTrigger = PopoverPrimitive__namespace.Trigger;
155
+ var PopoverClose = PopoverPrimitive__namespace.Close;
156
+ var PopoverContent = React25__namespace.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(PopoverPrimitive__namespace.Portal, null, /* @__PURE__ */ React25__namespace.createElement(
157
+ PopoverPrimitive__namespace.Content,
158
+ {
159
+ ref,
160
+ align,
161
+ sideOffset,
162
+ className: chunk63LNKQZD_js.cn(
163
+ "sb:z-50 sb:w-72 sb:rounded-md sb:border sb:bg-popover sb:text-popover-foreground sb:shadow-md sb:outline-hidden data-[state=open]:sb-animate-in data-[state=closed]:sb-animate-out data-[state=closed]:sb-fade-out-0 data-[state=open]:sb-fade-in-0 data-[state=closed]:sb-zoom-out-95 data-[state=open]:sb-zoom-in-95 data-[side=bottom]:sb-slide-in-from-top-2 data-[side=left]:sb-slide-in-from-right-2 data-[side=right]:sb-slide-in-from-left-2 data-[side=top]:sb-slide-in-from-bottom-2 sb:origin-(--radix-popover-content-transform-origin)",
164
+ className
165
+ ),
166
+ ...props
167
+ }
168
+ )));
169
+ PopoverContent.displayName = PopoverPrimitive__namespace.Content.displayName;
170
+ var Link = TiptapLink__default.default.extend({
171
+ inclusive: false,
172
+ parseHTML() {
173
+ return [{ tag: 'a[href]:not([data-type="button"]):not([href *= "javascript:" i])' }];
174
+ },
175
+ renderHTML({ HTMLAttributes }) {
176
+ return ["a", react.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
177
+ },
178
+ addOptions() {
179
+ return {
180
+ ...this.parent?.(),
181
+ openOnClick: false
182
+ };
183
+ },
184
+ addProseMirrorPlugins() {
185
+ return [
186
+ ...this.parent?.() || [],
187
+ new state.Plugin({
188
+ props: {
189
+ handleClick(view, pos) {
190
+ const { schema: schema2, doc, tr } = view.state;
191
+ const range = react.getMarkRange(doc.resolve(pos), schema2.marks.link);
192
+ if (!range) {
193
+ return;
194
+ }
195
+ const { from, to } = range;
196
+ const start = Math.min(from, to);
197
+ const end = Math.max(from, to);
198
+ if (pos < start || pos > end) {
199
+ return;
200
+ }
201
+ const $start = doc.resolve(start);
202
+ const $end = doc.resolve(end);
203
+ const transaction = tr.setSelection(new state.TextSelection($start, $end));
204
+ view.dispatch(transaction);
205
+ }
206
+ }
207
+ })
208
+ ];
209
+ }
210
+ });
211
+
212
+ // src/features/rich-text-editor/utils/normalize-rich-text-colors.ts
213
+ var normalizeRichTextColors = (html) => html.replaceAll(/hsl\(var\((--[A-Za-z0-9-]+)\)\)/g, "var($1)");
214
+
215
+ // src/features/rich-text-editor/utils/get-output.ts
216
+ var getOutput = (editor, format2) => {
217
+ switch (format2) {
218
+ case "json":
219
+ return editor.getJSON();
220
+ case "html":
221
+ return editor.isEmpty ? "" : normalizeRichTextColors(editor.getHTML());
222
+ default:
223
+ return editor.getText();
224
+ }
225
+ };
226
+
227
+ // src/features/rich-text-editor/hooks/useRichTextEditor.ts
228
+ var useRichTextEditor = ({
229
+ value,
230
+ output = "html",
231
+ editorClassName,
232
+ onUpdate,
233
+ onBlur,
234
+ ...options
235
+ }) => {
236
+ const handleCreate = React25.useCallback(
237
+ (editor2) => {
238
+ console.count("useRichTextEditor:handleCreate");
239
+ if (value && editor2.isEmpty) {
240
+ editor2.commands.setContent(
241
+ typeof value === "string" ? normalizeRichTextColors(value) : value
242
+ );
243
+ }
244
+ },
245
+ [value]
246
+ );
247
+ const handleUpdate = React25.useCallback(
248
+ (editor2) => {
249
+ console.count("useRichTextEditor:handleUpdate");
250
+ onUpdate?.(getOutput(editor2, output));
251
+ },
252
+ [output, onUpdate]
253
+ );
254
+ const handleBlur = React25.useCallback(
255
+ (editor2) => {
256
+ console.count("useRichTextEditor:handleBlur");
257
+ onBlur?.(getOutput(editor2, output));
258
+ },
259
+ [output, onBlur]
260
+ );
261
+ const editor = react.useEditor({
262
+ extensions: [starterKit.StarterKit, extensionUnderline.Underline, extensionColor.Color, extensionTextStyle.TextStyle, Link],
263
+ editorProps: {
264
+ attributes: {
265
+ autocomplete: "off",
266
+ autocorrect: "off",
267
+ autocapitalize: "off",
268
+ class: chunk63LNKQZD_js.cn("sb-focus:outline-none", editorClassName)
269
+ }
270
+ },
271
+ onCreate: ({ editor: editor2 }) => handleCreate(editor2),
272
+ onUpdate: ({ editor: editor2 }) => handleUpdate(editor2),
273
+ onBlur: ({ editor: editor2 }) => handleBlur(editor2),
274
+ ...options
275
+ });
276
+ console.count("useRichTextEditor");
277
+ return editor;
278
+ };
279
+ var DropdownMenu = DropdownMenuPrimitive__namespace.Root;
280
+ var DropdownMenuTrigger = DropdownMenuPrimitive__namespace.Trigger;
281
+ var DropdownMenuSubTrigger = React25__namespace.forwardRef(({ className, inset, children, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
282
+ DropdownMenuPrimitive__namespace.SubTrigger,
283
+ {
284
+ ref,
285
+ className: chunk63LNKQZD_js.cn(
286
+ "sb:flex sb:cursor-default sb:select-none sb:items-center sb:gap-2 sb:rounded-sm sb:px-2 sb:py-1.5 sb:text-sm sb:outline-hidden sb:focus:bg-accent sb:data-[state=open]:bg-accent sb:[&_svg]:pointer-events-none sb:[&_svg]:size-4 sb:[&_svg]:shrink-0",
287
+ inset && "sb:pl-8",
288
+ className
289
+ ),
290
+ ...props
291
+ },
292
+ children,
293
+ /* @__PURE__ */ React25__namespace.createElement(lucideReact.ChevronRight, { className: "sb:ml-auto" })
294
+ ));
295
+ DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive__namespace.SubTrigger.displayName;
296
+ var DropdownMenuSubContent = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
297
+ DropdownMenuPrimitive__namespace.SubContent,
298
+ {
299
+ ref,
300
+ className: chunk63LNKQZD_js.cn(
301
+ "sb:z-50 sb:min-w-32 sb:overflow-hidden sb:rounded-md sb:border sb:bg-popover sb:p-1 sb:text-popover-foreground sb:shadow-lg data-[state=open]:sb-animate-in data-[state=closed]:sb-animate-out data-[state=closed]:sb-fade-out-0 data-[state=open]:sb-fade-in-0 data-[state=closed]:sb-zoom-out-95 data-[state=open]:sb-zoom-in-95 data-[side=bottom]:sb-slide-in-from-top-2 data-[side=left]:sb-slide-in-from-right-2 data-[side=right]:sb-slide-in-from-left-2 data-[side=top]:sb-slide-in-from-bottom-2 sb:origin-(--radix-dropdown-menu-content-transform-origin)",
302
+ className
303
+ ),
304
+ ...props
305
+ }
306
+ ));
307
+ DropdownMenuSubContent.displayName = DropdownMenuPrimitive__namespace.SubContent.displayName;
308
+ var DropdownMenuContent = React25__namespace.forwardRef(({ className, sideOffset = 4, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(DropdownMenuPrimitive__namespace.Portal, null, /* @__PURE__ */ React25__namespace.createElement(
309
+ DropdownMenuPrimitive__namespace.Content,
310
+ {
311
+ ref,
312
+ sideOffset,
313
+ className: chunk63LNKQZD_js.cn(
314
+ "sb:z-50 sb:max-h-(--radix-dropdown-menu-content-available-height) sb:min-w-32 sb:overflow-y-auto sb:overflow-x-hidden sb:rounded-md sb:border sb:bg-popover sb:p-1 sb:text-popover-foreground sb:shadow-md",
315
+ "data-[state=open]:sb-animate-in data-[state=closed]:sb-animate-out data-[state=closed]:sb-fade-out-0 data-[state=open]:sb-fade-in-0 data-[state=closed]:sb-zoom-out-95 data-[state=open]:sb-zoom-in-95 data-[side=bottom]:sb-slide-in-from-top-2 data-[side=left]:sb-slide-in-from-right-2 data-[side=right]:sb-slide-in-from-left-2 data-[side=top]:sb-slide-in-from-bottom-2 sb:origin-(--radix-dropdown-menu-content-transform-origin)",
316
+ className
317
+ ),
318
+ ...props
319
+ }
320
+ )));
321
+ DropdownMenuContent.displayName = DropdownMenuPrimitive__namespace.Content.displayName;
322
+ var DropdownMenuItem = React25__namespace.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
323
+ DropdownMenuPrimitive__namespace.Item,
324
+ {
325
+ ref,
326
+ className: chunk63LNKQZD_js.cn(
327
+ "sb:relative sb:flex sb:cursor-default sb:select-none sb:items-center sb:gap-2 sb:rounded-sm sb:px-2 sb:py-1.5 sb:text-sm sb:outline-hidden sb:transition-colors sb:focus:bg-accent sb:focus:text-accent-foreground sb:data-disabled:pointer-events-none sb:data-disabled:opacity-50 sb:[&>svg]:size-4 sb:[&>svg]:shrink-0",
328
+ inset && "sb:pl-8",
329
+ className
330
+ ),
331
+ ...props
332
+ }
333
+ ));
334
+ DropdownMenuItem.displayName = DropdownMenuPrimitive__namespace.Item.displayName;
335
+ var DropdownMenuCheckboxItem = React25__namespace.forwardRef(({ className, children, checked, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
336
+ DropdownMenuPrimitive__namespace.CheckboxItem,
337
+ {
338
+ ref,
339
+ className: chunk63LNKQZD_js.cn(
340
+ "sb:relative sb:flex sb:cursor-default sb:select-none sb:items-center sb:rounded-sm sb:py-1.5 sb:pl-8 sb:pr-2 sb:text-sm sb:outline-hidden sb:transition-colors sb:focus:bg-accent sb:focus:text-accent-foreground sb:data-disabled:pointer-events-none sb:data-disabled:opacity-50",
341
+ className
342
+ ),
343
+ checked,
344
+ ...props
345
+ },
346
+ /* @__PURE__ */ React25__namespace.createElement("span", { className: "sb:absolute sb:left-2 sb:flex sb:h-3.5 sb:w-3.5 sb:items-center sb:justify-center" }, /* @__PURE__ */ React25__namespace.createElement(DropdownMenuPrimitive__namespace.ItemIndicator, null, /* @__PURE__ */ React25__namespace.createElement(lucideReact.Check, { className: "sb:h-4 sb:w-4" }))),
347
+ children
348
+ ));
349
+ DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive__namespace.CheckboxItem.displayName;
350
+ var DropdownMenuRadioItem = React25__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
351
+ DropdownMenuPrimitive__namespace.RadioItem,
352
+ {
353
+ ref,
354
+ className: chunk63LNKQZD_js.cn(
355
+ "sb:relative sb:flex sb:cursor-default sb:select-none sb:items-center sb:rounded-sm sb:py-1.5 sb:pl-8 sb:pr-2 sb:text-sm sb:outline-hidden sb:transition-colors sb:focus:bg-accent sb:focus:text-accent-foreground sb:data-disabled:pointer-events-none sb:data-disabled:opacity-50",
356
+ className
357
+ ),
358
+ ...props
359
+ },
360
+ /* @__PURE__ */ React25__namespace.createElement("span", { className: "sb:absolute sb:left-2 sb:flex sb:h-3.5 sb:w-3.5 sb:items-center sb:justify-center" }, /* @__PURE__ */ React25__namespace.createElement(DropdownMenuPrimitive__namespace.ItemIndicator, null, /* @__PURE__ */ React25__namespace.createElement(lucideReact.Circle, { className: "sb:h-2 sb:w-2 sb:fill-current" }))),
361
+ children
362
+ ));
363
+ DropdownMenuRadioItem.displayName = DropdownMenuPrimitive__namespace.RadioItem.displayName;
364
+ var DropdownMenuLabel = React25__namespace.forwardRef(({ className, inset, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
365
+ DropdownMenuPrimitive__namespace.Label,
366
+ {
367
+ ref,
368
+ className: chunk63LNKQZD_js.cn(
369
+ "sb:px-2 sb:py-1.5 sb:text-sm sb:font-semibold",
370
+ inset && "sb:pl-8",
371
+ className
372
+ ),
373
+ ...props
374
+ }
375
+ ));
376
+ DropdownMenuLabel.displayName = DropdownMenuPrimitive__namespace.Label.displayName;
377
+ var DropdownMenuSeparator = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
378
+ DropdownMenuPrimitive__namespace.Separator,
379
+ {
380
+ ref,
381
+ className: chunk63LNKQZD_js.cn("sb:-mx-1 sb:my-1 sb:h-px sb:bg-muted", className),
382
+ ...props
383
+ }
384
+ ));
385
+ DropdownMenuSeparator.displayName = DropdownMenuPrimitive__namespace.Separator.displayName;
386
+ var Separator2 = React25__namespace.forwardRef(
387
+ ({ className, orientation = "horizontal", decorative = true, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
388
+ SeparatorPrimitive__namespace.Root,
389
+ {
390
+ ref,
391
+ decorative,
392
+ orientation,
393
+ className: chunk63LNKQZD_js.cn(
394
+ "sb:shrink-0 sb:bg-border",
395
+ orientation === "horizontal" ? "sb:h-px sb:w-full" : "sb:h-full sb:w-px",
396
+ className
397
+ ),
398
+ ...props
399
+ }
400
+ )
401
+ );
402
+ Separator2.displayName = SeparatorPrimitive__namespace.Root.displayName;
403
+ var toggleVariants = classVarianceAuthority.cva(
404
+ "sb:inline-flex sb:items-center sb:justify-center sb:gap-2 sb:rounded-md sb:text-sm sb:font-medium sb:transition-colors sb:hover:bg-muted sb:hover:text-muted-foreground sb:focus-visible:outline-hidden sb:focus-visible:ring-1 sb:focus-visible:ring-ring sb:disabled:pointer-events-none sb:disabled:opacity-50 sb:data-[state=on]:bg-accent sb:data-[state=on]:text-accent-foreground sb:[&_svg]:pointer-events-none sb:[&_svg]:size-4 sb:[&_svg]:shrink-0",
405
+ {
406
+ variants: {
407
+ variant: {
408
+ default: "sb:bg-transparent",
409
+ outline: "sb:border sb:border-input sb:bg-transparent sb:shadow-sm sb:hover:bg-accent sb:hover:text-accent-foreground"
410
+ },
411
+ size: {
412
+ default: "sb:h-9 sb:px-2 sb:min-w-9",
413
+ sm: "sb:h-8 sb:px-1.5 sb:min-w-8",
414
+ lg: "sb:h-10 sb:px-2.5 sb:min-w-10"
415
+ }
416
+ },
417
+ defaultVariants: {
418
+ variant: "default",
419
+ size: "default"
420
+ }
421
+ }
422
+ );
423
+ var Toggle = React25__namespace.forwardRef(({ className, variant, size, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
424
+ TogglePrimitive__namespace.Root,
425
+ {
426
+ ref,
427
+ className: chunk63LNKQZD_js.cn(toggleVariants({ variant, size, className })),
428
+ ...props
429
+ }
430
+ ));
431
+ Toggle.displayName = TogglePrimitive__namespace.Root.displayName;
432
+ var ToggleGroupContext = React25__namespace.createContext({
433
+ size: "default",
434
+ variant: "default"
435
+ });
436
+ var ToggleGroup = React25__namespace.forwardRef(({ className, variant, size, children, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
437
+ ToggleGroupPrimitive__namespace.Root,
438
+ {
439
+ ref,
440
+ className: chunk63LNKQZD_js.cn("sb:flex sb:items-center sb:justify-center sb:gap-1", className),
441
+ ...props
442
+ },
443
+ /* @__PURE__ */ React25__namespace.createElement(ToggleGroupContext.Provider, { value: { variant, size } }, children)
444
+ ));
445
+ ToggleGroup.displayName = ToggleGroupPrimitive__namespace.Root.displayName;
446
+ var ToggleGroupItem = React25__namespace.forwardRef(({ className, children, variant, size, ...props }, ref) => {
447
+ const context = React25__namespace.useContext(ToggleGroupContext);
448
+ return /* @__PURE__ */ React25__namespace.createElement(
449
+ ToggleGroupPrimitive__namespace.Item,
450
+ {
451
+ ref,
452
+ className: chunk63LNKQZD_js.cn(
453
+ toggleVariants({
454
+ variant: context.variant || variant,
455
+ size: context.size || size
456
+ }),
457
+ className
458
+ ),
459
+ ...props
460
+ },
461
+ children
462
+ );
463
+ });
464
+ ToggleGroupItem.displayName = ToggleGroupPrimitive__namespace.Item.displayName;
465
+ var PALETTES = [
466
+ {
467
+ inverse: "var(--background)",
468
+ colors: [
469
+ { cssVar: "var(--foreground)" },
470
+ { cssVar: "var(--primary-foreground)" },
471
+ { cssVar: "var(--secondary-foreground)" },
472
+ { cssVar: "var(--tertiary-foreground)" },
473
+ { cssVar: "var(--muted-foreground)" },
474
+ { cssVar: "var(--accent-foreground)" },
475
+ { cssVar: "var(--destructive-foreground)" }
476
+ ]
477
+ },
478
+ {
479
+ inverse: "var(--foreground)",
480
+ colors: [
481
+ { cssVar: "var(--background)" },
482
+ { cssVar: "var(--primary)" },
483
+ { cssVar: "var(--secondary)" },
484
+ { cssVar: "var(--tertiary)" },
485
+ { cssVar: "var(--muted)" },
486
+ { cssVar: "var(--accent)" },
487
+ { cssVar: "var(--destructive)" }
488
+ ]
489
+ }
490
+ ];
491
+ var ColorTool = ({ editor }) => {
492
+ const color = normalizeRichTextColors(
493
+ editor.getAttributes("textStyle")?.color || "var(--foreground)"
494
+ );
495
+ const [selectedColor, setSelectedColor] = React25__namespace.useState(color);
496
+ React25__namespace.useEffect(() => {
497
+ setSelectedColor(color);
498
+ }, [color]);
499
+ const handleColorChange = React25__namespace.useCallback(
500
+ (value) => {
501
+ setSelectedColor(value);
502
+ editor.chain().focus().setColor(value).run();
503
+ },
504
+ [editor]
505
+ );
506
+ return /* @__PURE__ */ React25__namespace.createElement(Popover, { modal: true }, /* @__PURE__ */ React25__namespace.createElement(PopoverTrigger, { asChild: true }, /* @__PURE__ */ React25__namespace.createElement(ToolbarButton, { className: "sb:w-12" }, /* @__PURE__ */ React25__namespace.createElement(
507
+ "svg",
508
+ {
509
+ xmlns: "http://www.w3.org/2000/svg",
510
+ width: "24",
511
+ height: "24",
512
+ viewBox: "0 0 24 24",
513
+ fill: "none",
514
+ stroke: "currentColor",
515
+ strokeWidth: "2",
516
+ strokeLinecap: "round",
517
+ strokeLinejoin: "round",
518
+ className: "sb:size-5",
519
+ style: { color: selectedColor }
520
+ },
521
+ /* @__PURE__ */ React25__namespace.createElement("path", { d: "M4 20h16" }),
522
+ /* @__PURE__ */ React25__namespace.createElement("path", { d: "m6 16 6-12 6 12" }),
523
+ /* @__PURE__ */ React25__namespace.createElement("path", { d: "M8 12h8" })
524
+ ), /* @__PURE__ */ React25__namespace.createElement(lu.LuChevronDown, { className: "sb:size-5" }))), /* @__PURE__ */ React25__namespace.createElement(PopoverContent, { align: "start", className: "sb:w-full" }, /* @__PURE__ */ React25__namespace.createElement(
525
+ ToggleGroup,
526
+ {
527
+ type: "single",
528
+ value: selectedColor,
529
+ onValueChange: handleColorChange,
530
+ className: "sb:flex-col sb:gap-1.5"
531
+ },
532
+ PALETTES.map((pallete, i) => /* @__PURE__ */ React25__namespace.createElement("div", { key: i, className: "sb:flex sb:gap-1.5" }, pallete.colors.map((color2, j) => /* @__PURE__ */ React25__namespace.createElement(
533
+ ToggleGroupItem,
534
+ {
535
+ tabIndex: 0,
536
+ key: j,
537
+ className: "sb:relative sb:size-7 sb:rounded-md sb:border sb:p-0",
538
+ value: color2.cssVar,
539
+ style: { backgroundColor: color2.cssVar }
540
+ },
541
+ normalizeRichTextColors(selectedColor) === color2.cssVar && /* @__PURE__ */ React25__namespace.createElement(
542
+ lu.LuCheck,
543
+ {
544
+ className: "sb:absolute sb:inset-0 sb:m-auto sb:size-6",
545
+ style: { color: pallete.inverse }
546
+ }
547
+ )
548
+ ))))
549
+ )));
550
+ };
551
+ var formatActions = [
552
+ {
553
+ label: "Normal Text",
554
+ element: "span",
555
+ className: "sb:grow"
556
+ },
557
+ {
558
+ label: "Heading 1",
559
+ element: "h1",
560
+ level: 1,
561
+ className: "sb:m-0 sb:grow sb:text-3xl sb:font-extrabold"
562
+ },
563
+ {
564
+ label: "Heading 2",
565
+ element: "h2",
566
+ level: 2,
567
+ className: "sb:m-0 sb:grow sb:text-xl sb:font-bold"
568
+ },
569
+ {
570
+ label: "Heading 3",
571
+ element: "h3",
572
+ level: 3,
573
+ className: "sb:m-0 sb:grow sb:text-lg sb:font-semibold"
574
+ },
575
+ {
576
+ label: "Heading 4",
577
+ element: "h4",
578
+ level: 4,
579
+ className: "sb:m-0 sb:grow sb:text-base sb:font-semibold"
580
+ }
581
+ ];
582
+ var ElementTool = ({ editor }) => {
583
+ const isActive = editor.isActive("heading");
584
+ const handleFormatChange = React25__namespace.useCallback(
585
+ (level) => {
586
+ if (level) {
587
+ editor.chain().focus().toggleHeading({ level }).run();
588
+ } else {
589
+ editor.chain().focus().setParagraph().run();
590
+ }
591
+ },
592
+ [editor]
593
+ );
594
+ return /* @__PURE__ */ React25__namespace.createElement(DropdownMenu, null, /* @__PURE__ */ React25__namespace.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React25__namespace.createElement(
595
+ ToolbarButton,
596
+ {
597
+ className: "sb:w-12 sb:data-[state=open]:bg-accent",
598
+ pressed: isActive
599
+ },
600
+ /* @__PURE__ */ React25__namespace.createElement(lu.LuHeading, { className: "sb:size-5" }),
601
+ /* @__PURE__ */ React25__namespace.createElement(lu.LuChevronDown, { className: "sb:size-5" })
602
+ )), /* @__PURE__ */ React25__namespace.createElement(DropdownMenuContent, { align: "start" }, formatActions.map(({ element: Element, ...action }) => /* @__PURE__ */ React25__namespace.createElement(
603
+ DropdownMenuItem,
604
+ {
605
+ key: action.label,
606
+ className: chunk63LNKQZD_js.cn({
607
+ "sb:bg-accent": action.level ? editor.isActive("heading", { level: action.level }) : editor.isActive("paragraph")
608
+ }),
609
+ onClick: () => handleFormatChange(action.level)
610
+ },
611
+ /* @__PURE__ */ React25__namespace.createElement(Element, { className: action.className }, action.label)
612
+ ))));
613
+ };
614
+ var actions = [
615
+ {
616
+ value: "bold",
617
+ label: "Bold",
618
+ icon: lu.LuBold,
619
+ action: (editor) => editor.chain().focus().toggleBold().run(),
620
+ isActive: (editor) => editor.isActive("bold"),
621
+ canExecute: (editor) => editor.can().chain().focus().toggleBold().run() && !editor.isActive("codeBlock")
622
+ },
623
+ {
624
+ value: "italic",
625
+ label: "Italic",
626
+ icon: lu.LuItalic,
627
+ action: (editor) => editor.chain().focus().toggleItalic().run(),
628
+ isActive: (editor) => editor.isActive("italic"),
629
+ canExecute: (editor) => editor.can().chain().focus().toggleItalic().run() && !editor.isActive("codeBlock")
630
+ },
631
+ {
632
+ value: "underline",
633
+ label: "Underline",
634
+ icon: lu.LuUnderline,
635
+ action: (editor) => editor.chain().focus().toggleUnderline().run(),
636
+ isActive: (editor) => editor.isActive("underline"),
637
+ canExecute: (editor) => editor.can().chain().focus().toggleUnderline().run() && !editor.isActive("codeBlock")
638
+ },
639
+ {
640
+ value: "strikethrough",
641
+ label: "Strikethrough",
642
+ icon: lu.LuStrikethrough,
643
+ action: (editor) => editor.chain().focus().toggleStrike().run(),
644
+ isActive: (editor) => editor.isActive("strike"),
645
+ canExecute: (editor) => editor.can().chain().focus().toggleStrike().run() && !editor.isActive("codeBlock")
646
+ },
647
+ {
648
+ value: "code",
649
+ label: "Code",
650
+ icon: lu.LuCode,
651
+ action: (editor) => editor.chain().focus().toggleCode().run(),
652
+ isActive: (editor) => editor.isActive("code"),
653
+ canExecute: (editor) => editor.can().chain().focus().toggleCode().run() && !editor.isActive("codeBlock")
654
+ },
655
+ {
656
+ value: "clearFormatting",
657
+ label: "Clear formatting",
658
+ icon: lu.LuRemoveFormatting,
659
+ action: (editor) => editor.chain().focus().unsetAllMarks().run(),
660
+ isActive: () => false,
661
+ canExecute: (editor) => editor.can().chain().focus().unsetAllMarks().run() && !editor.isActive("codeBlock")
662
+ }
663
+ ];
664
+ var FormatTool = ({ editor }) => {
665
+ return /* @__PURE__ */ React25__namespace.createElement(ToolbarSection, { editor, actions, mainActionCount: 1 });
666
+ };
667
+ var actions2 = [
668
+ {
669
+ value: "codeBlock",
670
+ label: "Code block",
671
+ icon: lu.LuCode,
672
+ action: (editor) => editor.chain().focus().toggleCodeBlock().run(),
673
+ isActive: (editor) => editor.isActive("codeBlock"),
674
+ canExecute: (editor) => editor.can().chain().focus().toggleCodeBlock().run()
675
+ },
676
+ {
677
+ value: "blockquote",
678
+ label: "Blockquote",
679
+ icon: lu.LuQuote,
680
+ action: (editor) => editor.chain().focus().toggleBlockquote().run(),
681
+ isActive: (editor) => editor.isActive("blockquote"),
682
+ canExecute: (editor) => editor.can().chain().focus().toggleBlockquote().run()
683
+ },
684
+ {
685
+ value: "horizontalRule",
686
+ label: "Divider",
687
+ icon: lu.LuMinus,
688
+ action: (editor) => editor.chain().focus().setHorizontalRule().run(),
689
+ isActive: () => false,
690
+ canExecute: (editor) => editor.can().chain().focus().setHorizontalRule().run()
691
+ }
692
+ ];
693
+ var InsertTool = ({ editor }) => {
694
+ return /* @__PURE__ */ React25__namespace.createElement(ToolbarSection, { editor, actions: actions2, mainActionCount: 0 });
695
+ };
696
+ var Dialog = DialogPrimitive__namespace.Root;
697
+ var DialogTrigger = DialogPrimitive__namespace.Trigger;
698
+ var DialogPortal = DialogPrimitive__namespace.Portal;
699
+ var DialogOverlay = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
700
+ DialogPrimitive__namespace.Overlay,
701
+ {
702
+ ref,
703
+ className: chunk63LNKQZD_js.cn(
704
+ "sb:fixed sb:inset-0 sb:z-50 sb:bg-black/80 sb- data-[state=open]:sb-animate-in data-[state=closed]:sb-animate-out data-[state=closed]:sb-fade-out-0 data-[state=open]:sb-fade-in-0",
705
+ className
706
+ ),
707
+ ...props
708
+ }
709
+ ));
710
+ DialogOverlay.displayName = DialogPrimitive__namespace.Overlay.displayName;
711
+ var DialogContent = React25__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(DialogPortal, null, /* @__PURE__ */ React25__namespace.createElement(DialogOverlay, null), /* @__PURE__ */ React25__namespace.createElement(
712
+ DialogPrimitive__namespace.Content,
713
+ {
714
+ ref,
715
+ className: chunk63LNKQZD_js.cn(
716
+ "sb:fixed sb:left-[50%] sb:top-[50%] sb:z-50 sb:grid sb:w-full sb:max-w-lg sb:translate-x-[-50%] sb:translate-y-[-50%] sb:gap-4 sb:border sb:bg-background sb:p-6 sb:shadow-lg sb:duration-200 data-[state=open]:sb-animate-in data-[state=closed]:sb-animate-out data-[state=closed]:sb-fade-out-0 data-[state=open]:sb-fade-in-0 data-[state=closed]:sb-zoom-out-95 data-[state=open]:sb-zoom-in-95 data-[state=closed]:sb-slide-out-to-left-1/2 data-[state=closed]:sb-slide-out-to-top-[48%] data-[state=open]:sb-slide-in-from-left-1/2 data-[state=open]:sb-slide-in-from-top-[48%] sb:sm:rounded-lg",
717
+ className
718
+ ),
719
+ ...props
720
+ },
721
+ children,
722
+ /* @__PURE__ */ React25__namespace.createElement(DialogPrimitive__namespace.Close, { className: "sb:absolute sb:right-4 sb:top-4 sb:rounded-sm sb:opacity-70 sb:ring-offset-background sb:transition-opacity sb:hover:opacity-100 sb:focus:outline-hidden sb:focus:ring-2 sb:focus:ring-ring sb:focus:ring-offset-2 sb:disabled:pointer-events-none sb:data-[state=open]:bg-accent sb:data-[state=open]:text-muted-foreground" }, /* @__PURE__ */ React25__namespace.createElement(lucideReact.X, { className: "sb:h-4 sb:w-4" }), /* @__PURE__ */ React25__namespace.createElement("span", { className: "sb:sr-only" }, "Close"))
723
+ )));
724
+ DialogContent.displayName = DialogPrimitive__namespace.Content.displayName;
725
+ var DialogHeader = ({
726
+ className,
727
+ ...props
728
+ }) => /* @__PURE__ */ React25__namespace.createElement(
729
+ "div",
730
+ {
731
+ className: chunk63LNKQZD_js.cn(
732
+ "sb:flex sb:flex-col sb:gap-1.5 sb:text-center sb:sm:text-left",
733
+ className
734
+ ),
735
+ ...props
736
+ }
737
+ );
738
+ DialogHeader.displayName = "DialogHeader";
739
+ var DialogTitle = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
740
+ DialogPrimitive__namespace.Title,
741
+ {
742
+ ref,
743
+ className: chunk63LNKQZD_js.cn(
744
+ "sb:text-lg sb:font-semibold sb:leading-none sb:tracking-tight",
745
+ className
746
+ ),
747
+ ...props
748
+ }
749
+ ));
750
+ DialogTitle.displayName = DialogPrimitive__namespace.Title.displayName;
751
+ var DialogDescription = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
752
+ DialogPrimitive__namespace.Description,
753
+ {
754
+ ref,
755
+ className: chunk63LNKQZD_js.cn("sb:text-sm sb:text-muted-foreground", className),
756
+ ...props
757
+ }
758
+ ));
759
+ DialogDescription.displayName = DialogPrimitive__namespace.Description.displayName;
760
+ var labelVariants = classVarianceAuthority.cva(
761
+ "sb:text-sm sb:font-medium sb:leading-none sb:peer-disabled:cursor-not-allowed sb:peer-disabled:opacity-70"
762
+ );
763
+ var Label2 = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
764
+ LabelPrimitive__namespace.Root,
765
+ {
766
+ ref,
767
+ className: chunk63LNKQZD_js.cn(labelVariants(), className),
768
+ ...props
769
+ }
770
+ ));
771
+ Label2.displayName = LabelPrimitive__namespace.Root.displayName;
772
+
773
+ // src/components/ui/form.tsx
774
+ var Form = reactHookForm.FormProvider;
775
+ var FormFieldContext = React25__namespace.createContext(
776
+ {}
777
+ );
778
+ var FormField = ({
779
+ ...props
780
+ }) => {
781
+ return /* @__PURE__ */ React25__namespace.createElement(FormFieldContext.Provider, { value: { name: props.name } }, /* @__PURE__ */ React25__namespace.createElement(reactHookForm.Controller, { ...props }));
782
+ };
783
+ var useFormField = () => {
784
+ const fieldContext = React25__namespace.useContext(FormFieldContext);
785
+ const itemContext = React25__namespace.useContext(FormItemContext);
786
+ const { getFieldState, formState } = reactHookForm.useFormContext();
787
+ const fieldState = getFieldState(fieldContext.name, formState);
788
+ if (!fieldContext) {
789
+ throw new Error("useFormField should be used within <FormField>");
790
+ }
791
+ const { id } = itemContext;
792
+ return {
793
+ id,
794
+ name: fieldContext.name,
795
+ formItemId: `${id}-form-item`,
796
+ formDescriptionId: `${id}-form-item-description`,
797
+ formMessageId: `${id}-form-item-message`,
798
+ ...fieldState
799
+ };
800
+ };
801
+ var FormItemContext = React25__namespace.createContext(
802
+ {}
803
+ );
804
+ var FormItem = React25__namespace.forwardRef(({ className, ...props }, ref) => {
805
+ const id = React25__namespace.useId();
806
+ return /* @__PURE__ */ React25__namespace.createElement(FormItemContext.Provider, { value: { id } }, /* @__PURE__ */ React25__namespace.createElement("div", { ref, className: chunk63LNKQZD_js.cn("sb:flex sb:flex-col sb:gap-2", className), ...props }));
807
+ });
808
+ FormItem.displayName = "FormItem";
809
+ var FormLabel = React25__namespace.forwardRef(({ className, ...props }, ref) => {
810
+ const { error, formItemId } = useFormField();
811
+ return /* @__PURE__ */ React25__namespace.createElement(
812
+ Label2,
813
+ {
814
+ ref,
815
+ className: chunk63LNKQZD_js.cn(error && "sb:text-destructive", className),
816
+ htmlFor: formItemId,
817
+ ...props
818
+ }
819
+ );
820
+ });
821
+ FormLabel.displayName = "FormLabel";
822
+ var FormControl = React25__namespace.forwardRef(({ ...props }, ref) => {
823
+ const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
824
+ return /* @__PURE__ */ React25__namespace.createElement(
825
+ reactSlot.Slot,
826
+ {
827
+ ref,
828
+ id: formItemId,
829
+ "aria-describedby": !error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`,
830
+ "aria-invalid": !!error,
831
+ ...props
832
+ }
833
+ );
834
+ });
835
+ FormControl.displayName = "FormControl";
836
+ var FormDescription = React25__namespace.forwardRef(({ className, ...props }, ref) => {
837
+ const { formDescriptionId } = useFormField();
838
+ return /* @__PURE__ */ React25__namespace.createElement(
839
+ "p",
840
+ {
841
+ ref,
842
+ id: formDescriptionId,
843
+ className: chunk63LNKQZD_js.cn("sb:text-[0.8rem] sb:text-muted-foreground", className),
844
+ ...props
845
+ }
846
+ );
847
+ });
848
+ FormDescription.displayName = "FormDescription";
849
+ var FormMessage = React25__namespace.forwardRef(({ className, children, ...props }, ref) => {
850
+ const { error, formMessageId } = useFormField();
851
+ const body = error ? String(error?.message ?? "") : children;
852
+ if (!body) {
853
+ return null;
854
+ }
855
+ return /* @__PURE__ */ React25__namespace.createElement(
856
+ "p",
857
+ {
858
+ ref,
859
+ id: formMessageId,
860
+ className: chunk63LNKQZD_js.cn("sb:text-[0.8rem] sb:font-medium sb:text-destructive", className),
861
+ ...props
862
+ },
863
+ body
864
+ );
865
+ });
866
+ FormMessage.displayName = "FormMessage";
867
+ var Input = React25__namespace.forwardRef(
868
+ ({ className, type, ...props }, ref) => {
869
+ return /* @__PURE__ */ React25__namespace.createElement(
870
+ "input",
871
+ {
872
+ type,
873
+ className: chunk63LNKQZD_js.cn(
874
+ "sb:flex sb:h-9 sb:w-full sb:rounded-md sb:border sb:border-input sb:bg-transparent sb:px-3 sb:py-1 sb:text-base sb:shadow-sm sb:transition-colors sb:file:border-0 sb:file:bg-transparent sb:file:text-sm sb:file:font-medium sb:file:text-foreground sb:placeholder:text-muted-foreground sb:focus-visible:outline-hidden sb:focus-visible:ring-1 sb:focus-visible:ring-ring sb:disabled:cursor-not-allowed sb:disabled:opacity-50 sb:md:text-sm",
875
+ className
876
+ ),
877
+ ref,
878
+ ...props
879
+ }
880
+ );
881
+ }
882
+ );
883
+ Input.displayName = "Input";
884
+ var AdvancedInput = React25__namespace.forwardRef(
885
+ ({ prepend, append, ...props }, ref) => {
886
+ return /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:relative" }, /* @__PURE__ */ React25__namespace.createElement(Input, { ref, className: "sb:pl-9 sb:pr-7 sb:text-right", ...props }), prepend && /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:absolute sb:font-roboto sb:top-1/2 sb:left-3 sb:-translate-y-1/2" }, prepend), append && /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:absolute sb:font-roboto sb:top-1/2 sb:right-3 sb:-translate-y-1/2" }, append));
887
+ }
888
+ );
889
+ AdvancedInput.displayName = "AdvancedInput";
890
+ var Switch = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
891
+ SwitchPrimitives__namespace.Root,
892
+ {
893
+ className: chunk63LNKQZD_js.cn(
894
+ "sb:peer sb:inline-flex sb:h-5 sb:w-9 sb:shrink-0 sb:cursor-pointer sb:items-center sb:rounded-full sb:border-2 sb:border-transparent sb:shadow-sm sb:transition-colors sb:focus-visible:outline-hidden sb:focus-visible:ring-2 sb:focus-visible:ring-ring sb:focus-visible:ring-offset-2 sb:focus-visible:ring-offset-background sb:disabled:cursor-not-allowed sb:disabled:opacity-50 sb:data-[state=checked]:bg-primary sb:data-[state=unchecked]:bg-input",
895
+ className
896
+ ),
897
+ ...props,
898
+ ref
899
+ },
900
+ /* @__PURE__ */ React25__namespace.createElement(
901
+ SwitchPrimitives__namespace.Thumb,
902
+ {
903
+ className: chunk63LNKQZD_js.cn(
904
+ "sb:pointer-events-none sb:block sb:h-4 sb:w-4 sb:rounded-full sb:bg-background sb:shadow-lg sb:ring-0 sb:transition-transform sb:data-[state=checked]:translate-x-4 sb:data-[state=unchecked]:translate-x-0"
905
+ )
906
+ }
907
+ )
908
+ ));
909
+ Switch.displayName = SwitchPrimitives__namespace.Root.displayName;
910
+ var LinkTool = ({ editor }) => {
911
+ const [open, setOpen] = React25__namespace.useState(false);
912
+ const { from, to } = editor.state.selection;
913
+ const text = editor.state.doc.textBetween(from, to, " ");
914
+ const handleSetLink = React25__namespace.useCallback(
915
+ (url, text2, openInNewTab) => {
916
+ editor.chain().focus().extendMarkRange("link").insertContent({
917
+ type: "text",
918
+ text: text2 || url,
919
+ marks: [
920
+ {
921
+ type: "link",
922
+ attrs: {
923
+ href: url,
924
+ target: openInNewTab ? "_blank" : ""
925
+ }
926
+ }
927
+ ]
928
+ }).setLink({ href: url }).run();
929
+ editor.commands.enter();
930
+ setOpen(false);
931
+ },
932
+ [editor]
933
+ );
934
+ return /* @__PURE__ */ React25__namespace.createElement(Dialog, { open, onOpenChange: setOpen }, /* @__PURE__ */ React25__namespace.createElement(DialogTrigger, { asChild: true }, /* @__PURE__ */ React25__namespace.createElement(
935
+ ToolbarButton,
936
+ {
937
+ pressed: editor.isActive("link"),
938
+ disabled: editor.isActive("codeBlock")
939
+ },
940
+ /* @__PURE__ */ React25__namespace.createElement(lu.LuLink2, { className: "sb:size-5" })
941
+ )), /* @__PURE__ */ React25__namespace.createElement(DialogContent, { className: "sb:w-full sb:min-w-80" }, /* @__PURE__ */ React25__namespace.createElement(LinkForm, { onSave: handleSetLink, defaultText: text })));
942
+ };
943
+ var schema = zod.z.object({
944
+ url: zod.z.string().min(0),
945
+ text: zod.z.string().optional(),
946
+ isNewTab: zod.z.boolean().optional()
947
+ });
948
+ var LinkForm = ({
949
+ onSave,
950
+ defaultIsNewTab,
951
+ defaultUrl,
952
+ defaultText
953
+ }) => {
954
+ const form = reactHookForm.useForm({
955
+ resolver: zod$1.zodResolver(schema),
956
+ defaultValues: {
957
+ url: defaultUrl || "",
958
+ text: defaultText || "",
959
+ isNewTab: defaultIsNewTab || false
960
+ }
961
+ });
962
+ const handleSubmit = (values) => {
963
+ onSave(values.url, values.text, values.isNewTab);
964
+ };
965
+ return /* @__PURE__ */ React25__namespace.createElement(Form, { ...form }, /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:flex sb:flex-col sb:gap-6" }, /* @__PURE__ */ React25__namespace.createElement(
966
+ FormField,
967
+ {
968
+ control: form.control,
969
+ name: "url",
970
+ render: ({ field }) => /* @__PURE__ */ React25__namespace.createElement(FormItem, null, /* @__PURE__ */ React25__namespace.createElement(FormLabel, null, "URL"), /* @__PURE__ */ React25__namespace.createElement(FormControl, null, /* @__PURE__ */ React25__namespace.createElement(Input, { type: "url", ...field, autoFocus: true })), /* @__PURE__ */ React25__namespace.createElement(FormMessage, null))
971
+ }
972
+ ), /* @__PURE__ */ React25__namespace.createElement(
973
+ FormField,
974
+ {
975
+ control: form.control,
976
+ name: "text",
977
+ render: ({ field }) => /* @__PURE__ */ React25__namespace.createElement(FormItem, null, /* @__PURE__ */ React25__namespace.createElement(FormLabel, null, "Text"), /* @__PURE__ */ React25__namespace.createElement(FormControl, null, /* @__PURE__ */ React25__namespace.createElement(Input, { ...field })), /* @__PURE__ */ React25__namespace.createElement(FormMessage, null))
978
+ }
979
+ ), /* @__PURE__ */ React25__namespace.createElement(
980
+ FormField,
981
+ {
982
+ control: form.control,
983
+ name: "isNewTab",
984
+ render: ({ field }) => /* @__PURE__ */ React25__namespace.createElement(FormItem, null, /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:flex sb:items-center sb:gap-2" }, /* @__PURE__ */ React25__namespace.createElement(FormControl, null, /* @__PURE__ */ React25__namespace.createElement(
985
+ Switch,
986
+ {
987
+ checked: field.value,
988
+ onCheckedChange: field.onChange
989
+ }
990
+ )), /* @__PURE__ */ React25__namespace.createElement(FormLabel, null, "Open in new tab")), /* @__PURE__ */ React25__namespace.createElement(FormMessage, null))
991
+ }
992
+ ), /* @__PURE__ */ React25__namespace.createElement(chunk7FWFM2TR_js.Button, { type: "button", onClick: form.handleSubmit(handleSubmit) }, "Save")));
993
+ };
994
+ var actions3 = [
995
+ {
996
+ value: "orderedList",
997
+ label: "Numbered list",
998
+ icon: lu.LuListOrdered,
999
+ action: (editor) => editor.chain().focus().toggleOrderedList().run(),
1000
+ isActive: (editor) => editor.isActive("orderedList"),
1001
+ canExecute: (editor) => editor.can().chain().focus().toggleOrderedList().run()
1002
+ },
1003
+ {
1004
+ value: "bulletList",
1005
+ label: "Bullet list",
1006
+ icon: lu.LuList,
1007
+ action: (editor) => editor.chain().focus().toggleBulletList().run(),
1008
+ isActive: (editor) => editor.isActive("bulletList"),
1009
+ canExecute: (editor) => editor.can().chain().focus().toggleBulletList().run()
1010
+ }
1011
+ ];
1012
+ var ListTool = ({ editor }) => {
1013
+ return /* @__PURE__ */ React25__namespace.createElement(ToolbarSection, { editor, actions: actions3, mainActionCount: 2 });
1014
+ };
1015
+
1016
+ // src/features/rich-text-editor/components/toolbar.tsx
1017
+ var Toolbar = ({ editor }) => {
1018
+ return /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:shrink-0 sb:overflow-x-auto sb:border-b sb:border-border sb:p-2" }, /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:flex sb:w-max sb:items-center sb:gap-px" }, /* @__PURE__ */ React25__namespace.createElement(ElementTool, { editor }), /* @__PURE__ */ React25__namespace.createElement(Separator2, { orientation: "vertical", className: "sb:mx-2 sb:h-7" }), /* @__PURE__ */ React25__namespace.createElement(FormatTool, { editor }), /* @__PURE__ */ React25__namespace.createElement(Separator2, { orientation: "vertical", className: "sb:mx-2 sb:h-7" }), /* @__PURE__ */ React25__namespace.createElement(ColorTool, { editor }), /* @__PURE__ */ React25__namespace.createElement(Separator2, { orientation: "vertical", className: "sb:mx-2 sb:h-7" }), /* @__PURE__ */ React25__namespace.createElement(ListTool, { editor }), /* @__PURE__ */ React25__namespace.createElement(Separator2, { orientation: "vertical", className: "sb:mx-2 sb:h-7" }), /* @__PURE__ */ React25__namespace.createElement(LinkTool, { editor }), /* @__PURE__ */ React25__namespace.createElement(InsertTool, { editor })));
1019
+ };
1020
+ var ToolbarSection = ({
1021
+ editor,
1022
+ actions: actions4,
1023
+ mainActionCount = 0
1024
+ }) => {
1025
+ const { mainActions, dropdownActions } = React25__namespace.useMemo(() => {
1026
+ return {
1027
+ mainActions: actions4.slice(0, mainActionCount),
1028
+ dropdownActions: actions4.slice(mainActionCount)
1029
+ };
1030
+ }, [actions4, mainActionCount]);
1031
+ const isDropdownActive = React25__namespace.useMemo(() => {
1032
+ return dropdownActions.some((action) => action.isActive(editor));
1033
+ }, [dropdownActions, editor]);
1034
+ return /* @__PURE__ */ React25__namespace.createElement(React25__namespace.Fragment, null, mainActions.map((action) => /* @__PURE__ */ React25__namespace.createElement(
1035
+ ToolbarButton,
1036
+ {
1037
+ key: action.label,
1038
+ onClick: () => action.action(editor),
1039
+ disabled: !action.canExecute(editor),
1040
+ pressed: action.isActive(editor)
1041
+ },
1042
+ /* @__PURE__ */ React25__namespace.createElement(action.icon, { className: "sb:size-5" })
1043
+ )), dropdownActions.length > 0 && /* @__PURE__ */ React25__namespace.createElement(DropdownMenu, null, /* @__PURE__ */ React25__namespace.createElement(DropdownMenuTrigger, { asChild: true }, /* @__PURE__ */ React25__namespace.createElement(ToolbarButton, { pressed: isDropdownActive }, /* @__PURE__ */ React25__namespace.createElement(lu.LuEllipsis, { className: "sb:size-5" }))), /* @__PURE__ */ React25__namespace.createElement(DropdownMenuContent, { align: "start" }, dropdownActions.map((action) => /* @__PURE__ */ React25__namespace.createElement(
1044
+ DropdownMenuItem,
1045
+ {
1046
+ key: action.label,
1047
+ className: chunk63LNKQZD_js.cn("sb:flex sb:flex-row sb:items-center sb:gap-2", {
1048
+ "sb:bg-accent": action.isActive(editor)
1049
+ }),
1050
+ onClick: () => action.action(editor),
1051
+ disabled: !action.canExecute(editor)
1052
+ },
1053
+ /* @__PURE__ */ React25__namespace.createElement(action.icon, { className: "sb:size-4" }),
1054
+ /* @__PURE__ */ React25__namespace.createElement("span", null, action.label)
1055
+ )))));
1056
+ };
1057
+ var ToolbarButton = React25__namespace.forwardRef(({ className, ...props }, ref) => {
1058
+ return /* @__PURE__ */ React25__namespace.createElement(
1059
+ Toggle,
1060
+ {
1061
+ size: "sm",
1062
+ className: chunk63LNKQZD_js.cn(
1063
+ "sb:size-8 sb:p-0 sb:data-[state=on]:bg-accent",
1064
+ { "sb:bg-accent": props.pressed },
1065
+ className
1066
+ ),
1067
+ ref,
1068
+ ...props
1069
+ }
1070
+ );
1071
+ });
1072
+ ToolbarButton.displayName = "ToolbarButton";
1073
+
1074
+ // src/features/rich-text-editor/components/rich-text-editor.tsx
1075
+ var RichTextEditor = ({
1076
+ value,
1077
+ onChange,
1078
+ className,
1079
+ editorClassName,
1080
+ editorContentClassName,
1081
+ ...props
1082
+ }) => {
1083
+ console.count("re-render RichTextEditor");
1084
+ const editor = useRichTextEditor({
1085
+ value,
1086
+ onUpdate: onChange,
1087
+ editorClassName: chunk63LNKQZD_js.cn("sb:flex-1 sb:px-3 sb:py-1", editorClassName),
1088
+ ...props
1089
+ });
1090
+ if (!editor) {
1091
+ return null;
1092
+ }
1093
+ return /* @__PURE__ */ React25__namespace.createElement(
1094
+ "div",
1095
+ {
1096
+ className: chunk63LNKQZD_js.cn(
1097
+ "sb:flex sb:h-auto sb:min-h-72 sb:w-full sb:flex-col sb:rounded-md sb:border sb:border-input sb:shadow-sm sb:focus-within:border-primary",
1098
+ className
1099
+ )
1100
+ },
1101
+ /* @__PURE__ */ React25__namespace.createElement(Toolbar, { editor }),
1102
+ /* @__PURE__ */ React25__namespace.createElement(
1103
+ react.EditorContent,
1104
+ {
1105
+ editor,
1106
+ className: chunk63LNKQZD_js.cn(
1107
+ "sb-editflow prose sb:flex sb:flex-1",
1108
+ editorContentClassName
1109
+ )
1110
+ }
1111
+ )
1112
+ );
1113
+ };
1114
+ function Calendar({
1115
+ className,
1116
+ classNames,
1117
+ showOutsideDays = true,
1118
+ ...props
1119
+ }) {
1120
+ return /* @__PURE__ */ React25__namespace.createElement(
1121
+ reactDayPicker.DayPicker,
1122
+ {
1123
+ showOutsideDays,
1124
+ className: chunk63LNKQZD_js.cn("sb:p-3 sb:font-roboto", className),
1125
+ classNames: {
1126
+ months: "sb:flex sb:flex-col sb:sm:flex-row sb:gap-y-4 sb:sm:gap-x-4 sb:sm:gap-y-0",
1127
+ month: "sb:gap-y-4",
1128
+ caption: "sb:flex sb:justify-center sb:pt-1 sb:relative sb:items-center",
1129
+ caption_label: "sb:text-sm sb:font-medium",
1130
+ nav: "sb:gap-x-1 sb:flex sb:items-center",
1131
+ nav_button: chunk63LNKQZD_js.cn(
1132
+ chunk7FWFM2TR_js.buttonVariants({ variant: "outline" }),
1133
+ "sb:h-7 sb:w-7 sb:bg-transparent sb:p-0 sb:opacity-50 sb:hover:opacity-100"
1134
+ ),
1135
+ nav_button_previous: "sb:absolute sb:left-1",
1136
+ nav_button_next: "sb:absolute sb:right-1",
1137
+ table: "sb:w-full sb:border-collapse sb:flex sb:flex-col sb:gap-y-1",
1138
+ head_row: "sb:flex",
1139
+ head_cell: "sb:text-muted-foreground sb:rounded-md sb:w-8 sb:font-normal sb:text-[0.8rem]",
1140
+ row: "sb:flex sb:w-full sb:mt-2",
1141
+ cell: chunk63LNKQZD_js.cn(
1142
+ "sb:relative sb:p-0 sb:text-center sb:text-sm sb:focus-within:relative sb:focus-within:z-20 sb:[&:has([aria-selected])]:bg-accent sb:[&:has([aria-selected].day-outside)]:bg-accent/50 sb:[&:has([aria-selected].day-range-end)]:rounded-r-md",
1143
+ props.mode === "range" ? "sb:[&:has(>.day-range-end)]:rounded-r-md sb:[&:has(>.day-range-start)]:rounded-l-md sb:first:[&:has([aria-selected])]:rounded-l-md sb:last:[&:has([aria-selected])]:rounded-r-md" : "sb:[&:has([aria-selected])]:rounded-md"
1144
+ ),
1145
+ day: chunk63LNKQZD_js.cn(
1146
+ chunk7FWFM2TR_js.buttonVariants({ variant: "ghost" }),
1147
+ "sb:h-8 sb:w-8 sb:p-0 sb:font-normal sb:aria-selected:opacity-100"
1148
+ ),
1149
+ day_range_start: "day-range-start",
1150
+ day_range_end: "day-range-end",
1151
+ day_selected: "sb:bg-primary sb:text-primary-foreground sb:hover:bg-primary sb:hover:text-primary-foreground sb:focus:bg-primary sb:focus:text-primary-foreground",
1152
+ day_today: "sb:bg-accent sb:text-accent-foreground",
1153
+ day_outside: "day-outside sb:text-muted-foreground sb:opacity-50 sb:aria-selected:bg-accent/50 sb:aria-selected:text-muted-foreground sb:aria-selected:opacity-30",
1154
+ day_disabled: "sb:text-muted-foreground sb:opacity-50",
1155
+ day_range_middle: "sb:aria-selected:bg-accent sb:aria-selected:text-accent-foreground",
1156
+ day_hidden: "invisible",
1157
+ ...classNames
1158
+ },
1159
+ components: {
1160
+ IconLeft: () => /* @__PURE__ */ React25__namespace.createElement(lucideReact.ChevronLeftIcon, { className: "sb:h-4 sb:w-4" }),
1161
+ IconRight: () => /* @__PURE__ */ React25__namespace.createElement(lucideReact.ChevronRightIcon, { className: "sb:h-4 sb:w-4" })
1162
+ },
1163
+ ...props
1164
+ }
1165
+ );
1166
+ }
1167
+ Calendar.displayName = "Calendar";
1168
+ var ColorPicker = (props) => {
1169
+ const { color, onColorChange, className } = props;
1170
+ const colors = props.colors ?? [
1171
+ "#000000",
1172
+ "#ffffff",
1173
+ "#0f172a",
1174
+ "#F1F5F9",
1175
+ "#64748B",
1176
+ "#E6007E",
1177
+ "#F8FAFC",
1178
+ "#009DD1",
1179
+ "#FF0000"
1180
+ ];
1181
+ return /* @__PURE__ */ React25__namespace.createElement(Popover, null, /* @__PURE__ */ React25__namespace.createElement(PopoverTrigger, { asChild: true }, /* @__PURE__ */ React25__namespace.createElement(
1182
+ chunk7FWFM2TR_js.Button,
1183
+ {
1184
+ variant: "outline",
1185
+ size: "sm",
1186
+ className: chunk63LNKQZD_js.cn(
1187
+ "sb:justify-start sb:text-left sb:font-normal sb:normal-case sb:w-full",
1188
+ !color && "sb:text-muted-foreground",
1189
+ className
1190
+ )
1191
+ },
1192
+ /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:w-full sb:flex sb:items-center sb:gap-2" }, color ? /* @__PURE__ */ React25__namespace.createElement(
1193
+ "div",
1194
+ {
1195
+ className: "sb:h-4 sb:w-4 sb:rounded sb:bg-center! sb:bg-cover! sb:transition-all sb:border",
1196
+ style: { background: color }
1197
+ }
1198
+ ) : /* @__PURE__ */ React25__namespace.createElement(lucideReact.PaintbrushIcon, { className: "sb:h-4 sb:w-4" }), /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:truncate sb:flex-1" }, color ? color : "Kies een kleur"))
1199
+ )), /* @__PURE__ */ React25__namespace.createElement(PopoverContent, { className: "sb:w-64 sb:p-4 sb:flex sb:flex-wrap sb:gap-1" }, colors.map((s) => /* @__PURE__ */ React25__namespace.createElement(
1200
+ "div",
1201
+ {
1202
+ key: s,
1203
+ style: { background: s },
1204
+ className: "sb:rounded-md sb:h-6 sb:w-6 sb:cursor-pointer sb:active:scale-105 sb:border",
1205
+ onClick: () => onColorChange(s)
1206
+ }
1207
+ ))));
1208
+ };
1209
+ var IMAGE_FILE_ACCEPT = ".png,.jpg,.jpeg,.webp,.gif,.svg";
1210
+ var MEDIA_FILE_ACCEPT = `${IMAGE_FILE_ACCEPT},.mp4,.webm,.mov,.ogg,.ogv,.m4v,video/*`;
1211
+ var VIDEO_EXTENSIONS = [".mp4", ".webm", ".mov", ".ogg", ".ogv", ".m4v"];
1212
+ var isVideoUrl = (src) => {
1213
+ const path = src.split("?")[0].split("#")[0].toLowerCase();
1214
+ return VIDEO_EXTENSIONS.some((ext) => path.endsWith(ext));
1215
+ };
1216
+ var isVideoFile = (file) => file.type.startsWith("video/") || isVideoUrl(file.name);
1217
+ var MediaInput = (props) => {
1218
+ const {
1219
+ onFilesChange,
1220
+ limit = 32,
1221
+ multiple = false,
1222
+ onError,
1223
+ accept = MEDIA_FILE_ACCEPT
1224
+ } = props;
1225
+ const id = React25__namespace.useId();
1226
+ const [queue, setQueue] = React25__namespace.useState([]);
1227
+ const [sources, setSources] = React25__namespace.useState(props.files ?? []);
1228
+ const [videoUrls, setVideoUrls] = React25__namespace.useState({});
1229
+ const maxConcurrentUploads = 3;
1230
+ const uploadingCountRef = React25__namespace.useRef(0);
1231
+ const handleFilesAdd = async (e) => {
1232
+ const files = e.target.files;
1233
+ if (!files || files.length === 0) {
1234
+ return;
1235
+ }
1236
+ if (files.length + sources.length > (multiple ? limit : 1)) {
1237
+ onError?.(
1238
+ new MediaInputError(
1239
+ `Maximaal ${limit} bestanden.`,
1240
+ `Je probeerde nu ${files.length + sources.length} bestanden toe te voegen, maar je mag er maximaal ${limit} toevoegen.`
1241
+ )
1242
+ );
1243
+ return;
1244
+ }
1245
+ const queue2 = Array.from(files);
1246
+ setQueue(queue2);
1247
+ for (const file of queue2) {
1248
+ try {
1249
+ while (uploadingCountRef.current >= maxConcurrentUploads && uploadingCountRef.current > 0) {
1250
+ await new Promise((resolve) => setTimeout(resolve, 300));
1251
+ }
1252
+ uploadingCountRef.current++;
1253
+ const formData = new FormData();
1254
+ formData.append("file", file);
1255
+ const res = await fetch("/api/simple-builder/file/upload", {
1256
+ method: "POST",
1257
+ body: formData
1258
+ });
1259
+ if (res === void 0 || !res.ok) {
1260
+ onError?.(
1261
+ new MediaInputError(
1262
+ "Bestand uploaden misulukt",
1263
+ `Bestand ${file.name} kon niet worden ge\xFCpload.`
1264
+ )
1265
+ );
1266
+ continue;
1267
+ }
1268
+ const { data: url } = await res.json();
1269
+ if (!url) {
1270
+ onError?.(
1271
+ new MediaInputError(
1272
+ "Bestand uploaden misulukt",
1273
+ `De URL van bestand ${file.name} kon niet worden opgehaald.`
1274
+ )
1275
+ );
1276
+ continue;
1277
+ }
1278
+ if (isVideoFile(file)) {
1279
+ setVideoUrls((prev) => ({ ...prev, [url]: true }));
1280
+ }
1281
+ setSources((prev) => [...prev, url]);
1282
+ onFilesChange?.([...sources, url]);
1283
+ } catch (e2) {
1284
+ onError?.(
1285
+ new MediaInputError(
1286
+ "Bestand uploaden misulukt",
1287
+ `Bestand ${file.name} kon niet worden ge\xFCpload.`
1288
+ )
1289
+ );
1290
+ } finally {
1291
+ setQueue((prev) => prev.filter((f) => f !== file));
1292
+ uploadingCountRef.current--;
1293
+ }
1294
+ }
1295
+ };
1296
+ const handleSourceDelete = async (src) => {
1297
+ setSources((prev) => prev.filter((s) => s !== src));
1298
+ onFilesChange?.(sources.filter((s) => s !== src));
1299
+ await fetch("/api/uploadthing/delete", {
1300
+ method: "POST",
1301
+ body: JSON.stringify({ src })
1302
+ });
1303
+ };
1304
+ return /* @__PURE__ */ React25__namespace.createElement("div", { className: chunk63LNKQZD_js.cn("flex flex-wrap gap-4", props.className) }, sources.map((src) => /* @__PURE__ */ React25__namespace.createElement(MediaInputItem, { key: src, className: chunk63LNKQZD_js.cn("group", props.itemClassName) }, /* @__PURE__ */ React25__namespace.createElement(
1305
+ MediaPreview,
1306
+ {
1307
+ src,
1308
+ isVideo: !!videoUrls[src] || isVideoUrl(src)
1309
+ }
1310
+ ), /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:absolute sb:right-1 sb:top-1 sb:z-30 sb:flex sb:items-center sb:justify-end sb:gap-3 sb:opacity-0 sb:transition-opacity sb:group-hover:opacity-100" }, /* @__PURE__ */ React25__namespace.createElement(
1311
+ "button",
1312
+ {
1313
+ className: "sb:flex sb:h-8 sb:w-8 sb:items-center sb:justify-center sb:rounded-full sb:border sb:bg-secondary sb:text-secondary-foreground sb:opacity-90 sb:shadow sb:transition-opacity sb:hover:opacity-100",
1314
+ onClick: () => handleSourceDelete(src)
1315
+ },
1316
+ /* @__PURE__ */ React25__namespace.createElement(lucideReact.Trash2Icon, { className: "sb:h-4 sb:w-4" })
1317
+ )))), queue.map((_, i) => /* @__PURE__ */ React25__namespace.createElement(
1318
+ MediaInputItem,
1319
+ {
1320
+ key: i,
1321
+ className: chunk63LNKQZD_js.cn(
1322
+ "sb:flex sb:h-28 sb:w-28 sb:items-center sb:justify-center",
1323
+ props.itemClassName
1324
+ )
1325
+ },
1326
+ /* @__PURE__ */ React25__namespace.createElement(lucideReact.Loader2Icon, { className: "sb:h-6 sb:w-6 sb:animate-spin" })
1327
+ )), multiple || !multiple && !sources.length && !queue.length ? /* @__PURE__ */ React25__namespace.createElement(
1328
+ "label",
1329
+ {
1330
+ htmlFor: id,
1331
+ className: chunk63LNKQZD_js.cn(
1332
+ "sb:flex sb:h-28 sb:w-28 sb:cursor-pointer sb:items-center sb:justify-center sb:rounded-lg sb:border",
1333
+ props.itemClassName
1334
+ )
1335
+ },
1336
+ /* @__PURE__ */ React25__namespace.createElement(lucideReact.PlusIcon, { className: "sb:h-6 sb:w-6" }),
1337
+ /* @__PURE__ */ React25__namespace.createElement(
1338
+ "input",
1339
+ {
1340
+ id,
1341
+ type: "file",
1342
+ onChange: handleFilesAdd,
1343
+ multiple,
1344
+ accept,
1345
+ className: "sb:hidden"
1346
+ }
1347
+ )
1348
+ ) : null);
1349
+ };
1350
+ var MediaInputItem = (props) => {
1351
+ return /* @__PURE__ */ React25__namespace.createElement(
1352
+ "div",
1353
+ {
1354
+ className: chunk63LNKQZD_js.cn(
1355
+ "sb:relative sb:h-28 sb:w-28 sb:overflow-hidden sb:rounded-lg sb:border",
1356
+ props.className
1357
+ )
1358
+ },
1359
+ props.children
1360
+ );
1361
+ };
1362
+ var MediaPreview = (props) => {
1363
+ const [kind, setKind] = React25__namespace.useState(
1364
+ props.isVideo ? "video" : "image"
1365
+ );
1366
+ if (kind === "video") {
1367
+ return /* @__PURE__ */ React25__namespace.createElement(
1368
+ "video",
1369
+ {
1370
+ src: props.src,
1371
+ muted: true,
1372
+ playsInline: true,
1373
+ preload: "metadata",
1374
+ className: "sb:absolute sb:inset-0 sb:h-full sb:w-full sb:object-cover sb:pointer-events-none"
1375
+ }
1376
+ );
1377
+ }
1378
+ return /* @__PURE__ */ React25__namespace.createElement(
1379
+ chunk63LNKQZD_js.Image,
1380
+ {
1381
+ src: props.src,
1382
+ alt: "",
1383
+ fill: true,
1384
+ className: "sb:absolute sb:inset-0 sb:object-cover sb:pointer-events-none",
1385
+ onError: () => setKind("video")
1386
+ }
1387
+ );
1388
+ };
1389
+ var MediaInputError = class extends Error {
1390
+ title;
1391
+ description;
1392
+ constructor(message, description) {
1393
+ super(message);
1394
+ this.title = message;
1395
+ this.description = description;
1396
+ }
1397
+ };
1398
+ var Select = SelectPrimitive__namespace.Root;
1399
+ var SelectValue = SelectPrimitive__namespace.Value;
1400
+ var SelectTrigger = React25__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
1401
+ SelectPrimitive__namespace.Trigger,
1402
+ {
1403
+ ref,
1404
+ className: chunk63LNKQZD_js.cn(
1405
+ "sb:flex sb:h-10 sb:w-full sb:items-center sb:justify-between sb:rounded-md sb:border sb:border-input sb:bg-background sb:px-3 sb:py-2 sb:text-sm sb:ring-offset-background sb:placeholder:text-muted-foreground sb:focus:outline-hidden sb:focus:ring-2 sb:focus:ring-ring sb:focus:ring-offset-2 sb:disabled:cursor-not-allowed sb:disabled:opacity-50 sb:[&>span]:line-clamp-1",
1406
+ className
1407
+ ),
1408
+ ...props
1409
+ },
1410
+ children,
1411
+ /* @__PURE__ */ React25__namespace.createElement(SelectPrimitive__namespace.Icon, { asChild: true }, /* @__PURE__ */ React25__namespace.createElement(lucideReact.ChevronDown, { className: "sb:h-4 sb:w-4 sb:opacity-50" }))
1412
+ ));
1413
+ SelectTrigger.displayName = SelectPrimitive__namespace.Trigger.displayName;
1414
+ var SelectScrollUpButton = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
1415
+ SelectPrimitive__namespace.ScrollUpButton,
1416
+ {
1417
+ ref,
1418
+ className: chunk63LNKQZD_js.cn(
1419
+ "sb:flex sb:cursor-default sb:items-center sb:justify-center sb:py-1",
1420
+ className
1421
+ ),
1422
+ ...props
1423
+ },
1424
+ /* @__PURE__ */ React25__namespace.createElement(lucideReact.ChevronUp, { className: "sb:h-4 sb:w-4" })
1425
+ ));
1426
+ SelectScrollUpButton.displayName = SelectPrimitive__namespace.ScrollUpButton.displayName;
1427
+ var SelectScrollDownButton = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
1428
+ SelectPrimitive__namespace.ScrollDownButton,
1429
+ {
1430
+ ref,
1431
+ className: chunk63LNKQZD_js.cn(
1432
+ "sb:flex sb:cursor-default sb:items-center sb:justify-center sb:py-1",
1433
+ className
1434
+ ),
1435
+ ...props
1436
+ },
1437
+ /* @__PURE__ */ React25__namespace.createElement(lucideReact.ChevronDown, { className: "sb:h-4 sb:w-4" })
1438
+ ));
1439
+ SelectScrollDownButton.displayName = SelectPrimitive__namespace.ScrollDownButton.displayName;
1440
+ var SelectContent = React25__namespace.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(SelectPrimitive__namespace.Portal, null, /* @__PURE__ */ React25__namespace.createElement(
1441
+ SelectPrimitive__namespace.Content,
1442
+ {
1443
+ ref,
1444
+ className: chunk63LNKQZD_js.cn(
1445
+ "sb:relative sb:z-50 sb:max-h-96 sb:min-w-32 sb:overflow-hidden sb:rounded-md sb:border sb:bg-popover sb:text-popover-foreground sb:shadow-md data-[state=open]:sb-animate-in data-[state=closed]:sb-animate-out data-[state=closed]:sb-fade-out-0 data-[state=open]:sb-fade-in-0 data-[state=closed]:sb-zoom-out-95 data-[state=open]:sb-zoom-in-95 data-[side=bottom]:sb-slide-in-from-top-2 data-[side=left]:sb-slide-in-from-right-2 data-[side=right]:sb-slide-in-from-left-2 data-[side=top]:sb-slide-in-from-bottom-2",
1446
+ position === "popper" && "sb:data-[side=bottom]:translate-y-1 sb:data-[side=left]:-translate-x-1 sb:data-[side=right]:translate-x-1 sb:data-[side=top]:-translate-y-1",
1447
+ className
1448
+ ),
1449
+ position,
1450
+ ...props
1451
+ },
1452
+ /* @__PURE__ */ React25__namespace.createElement(SelectScrollUpButton, null),
1453
+ /* @__PURE__ */ React25__namespace.createElement(
1454
+ SelectPrimitive__namespace.Viewport,
1455
+ {
1456
+ className: chunk63LNKQZD_js.cn(
1457
+ "sb:p-1",
1458
+ position === "popper" && "sb:h-(--radix-select-trigger-height) sb:w-full sb:min-w-(--radix-select-trigger-width)"
1459
+ )
1460
+ },
1461
+ children
1462
+ ),
1463
+ /* @__PURE__ */ React25__namespace.createElement(SelectScrollDownButton, null)
1464
+ )));
1465
+ SelectContent.displayName = SelectPrimitive__namespace.Content.displayName;
1466
+ var SelectLabel = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
1467
+ SelectPrimitive__namespace.Label,
1468
+ {
1469
+ ref,
1470
+ className: chunk63LNKQZD_js.cn(
1471
+ "sb:py-1.5 sb:pl-8 sb:pr-2 sb:text-sm sb:font-semibold",
1472
+ className
1473
+ ),
1474
+ ...props
1475
+ }
1476
+ ));
1477
+ SelectLabel.displayName = SelectPrimitive__namespace.Label.displayName;
1478
+ var SelectItem = React25__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
1479
+ SelectPrimitive__namespace.Item,
1480
+ {
1481
+ ref,
1482
+ className: chunk63LNKQZD_js.cn(
1483
+ "sb:relative sb:flex sb:w-full sb:cursor-default sb:select-none sb:items-center sb:rounded-sm sb:py-1.5 sb:pl-8 sb:pr-2 sb:text-sm sb:outline-hidden sb:focus:bg-accent sb:focus:text-accent-foreground sb:data-disabled:pointer-events-none sb:data-disabled:opacity-50",
1484
+ className
1485
+ ),
1486
+ ...props
1487
+ },
1488
+ /* @__PURE__ */ React25__namespace.createElement("span", { className: "sb:absolute sb:left-2 sb:flex sb:h-3.5 sb:w-3.5 sb:items-center sb:justify-center" }, /* @__PURE__ */ React25__namespace.createElement(SelectPrimitive__namespace.ItemIndicator, null, /* @__PURE__ */ React25__namespace.createElement(lucideReact.Check, { className: "sb:h-4 sb:w-4" }))),
1489
+ /* @__PURE__ */ React25__namespace.createElement(SelectPrimitive__namespace.ItemText, null, children)
1490
+ ));
1491
+ SelectItem.displayName = SelectPrimitive__namespace.Item.displayName;
1492
+ var SelectSeparator = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
1493
+ SelectPrimitive__namespace.Separator,
1494
+ {
1495
+ ref,
1496
+ className: chunk63LNKQZD_js.cn("sb:-mx-1 sb:my-1 sb:h-px sb:bg-muted", className),
1497
+ ...props
1498
+ }
1499
+ ));
1500
+ SelectSeparator.displayName = SelectPrimitive__namespace.Separator.displayName;
1501
+ var Textarea = React25__namespace.forwardRef(
1502
+ ({ className, ...props }, ref) => {
1503
+ return /* @__PURE__ */ React25__namespace.createElement(
1504
+ "textarea",
1505
+ {
1506
+ className: chunk63LNKQZD_js.cn(
1507
+ "sb:flex sb:min-h-[60px] sb:font-roboto sb:w-full sb:rounded-md sb:border sb:border-input sb:bg-transparent sb:px-3 sb:py-2 sb:text-sm sb:shadow-sm sb:placeholder:text-muted-foreground sb:focus-visible:outline-hidden sb:focus-visible:ring-1 sb:focus-visible:ring-ring sb:disabled:cursor-not-allowed sb:disabled:opacity-50",
1508
+ className
1509
+ ),
1510
+ ref,
1511
+ ...props
1512
+ }
1513
+ );
1514
+ }
1515
+ );
1516
+ Textarea.displayName = "Textarea";
1517
+
1518
+ // src/components/container-item-form.tsx
1519
+ var ContainerItemForm = (props) => {
1520
+ const { item } = props;
1521
+ const { patchItem } = chunk7FWFM2TR_js.useBuilder();
1522
+ const component = chunk63LNKQZD_js.builder.getComponent(item.component);
1523
+ if (!component) {
1524
+ throw new Error(
1525
+ `[simple-builder]: Component with id ${item.component} not found in container item form component`
1526
+ );
1527
+ }
1528
+ const form = reactHookForm.useForm({
1529
+ defaultValues: (component.inputs || []).reduce(
1530
+ (acc, input) => ({
1531
+ ...acc,
1532
+ [input.name]: item?.props?.[input.name] ?? input.defaultValue
1533
+ }),
1534
+ {}
1535
+ )
1536
+ });
1537
+ const onSubmit = React25__namespace.useCallback(
1538
+ (values) => {
1539
+ patchItem(item.id, {
1540
+ props: values
1541
+ });
1542
+ },
1543
+ [patchItem, item.id]
1544
+ );
1545
+ return /* @__PURE__ */ React25__namespace.createElement(Form, { ...form }, /* @__PURE__ */ React25__namespace.createElement("form", { onSubmit: form.handleSubmit(onSubmit) }, /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:flex sb:flex-col sb:gap-4 sb:p-4" }, (component.inputs || []).map((input) => /* @__PURE__ */ React25__namespace.createElement(
1546
+ RenderFormField,
1547
+ {
1548
+ key: input.name,
1549
+ type: input.type,
1550
+ input,
1551
+ form
1552
+ }
1553
+ )), /* @__PURE__ */ React25__namespace.createElement(chunk7FWFM2TR_js.Button, { type: "submit", className: "w-full" }, "Opslaan"))));
1554
+ };
1555
+ var RenderFormField = (props) => {
1556
+ const { type, input, form } = props;
1557
+ const fieldArray = reactHookForm.useFieldArray({
1558
+ control: form.control,
1559
+ name: input.name
1560
+ });
1561
+ if (input.multiple) {
1562
+ return /* @__PURE__ */ React25__namespace.createElement("fieldset", { className: "sb:flex sb:flex-col sb:gap-2" }, /* @__PURE__ */ React25__namespace.createElement(FormLabel, null, input.friendlyName || input.name), /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:flex sb:flex-col sb:gap-4" }, fieldArray.fields.map(
1563
+ (field, i) => type !== "grouped" ? /* @__PURE__ */ React25__namespace.createElement(
1564
+ FormField,
1565
+ {
1566
+ key: field.id,
1567
+ control: form.control,
1568
+ name: `${input.name}.${i}`,
1569
+ render: ({ field: field2 }) => /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:flex sb:items-center sb:gap-3" }, /* @__PURE__ */ React25__namespace.createElement(RenderInput, { field: field2, type: input.type }), /* @__PURE__ */ React25__namespace.createElement("button", { type: "button", onClick: () => fieldArray.remove(i) }, /* @__PURE__ */ React25__namespace.createElement(lucideReact.XIcon, { className: "sb:h-4 sb:w-4" })))
1570
+ }
1571
+ ) : /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:flex sb:items-center sb:relative" }, /* @__PURE__ */ React25__namespace.createElement(
1572
+ RenderFormField,
1573
+ {
1574
+ key: field.id,
1575
+ form,
1576
+ type,
1577
+ input: {
1578
+ ...input,
1579
+ name: `${input.name}.${i}`,
1580
+ multiple: false,
1581
+ friendlyName: ""
1582
+ }
1583
+ }
1584
+ ), /* @__PURE__ */ React25__namespace.createElement(
1585
+ "button",
1586
+ {
1587
+ type: "button",
1588
+ onClick: () => fieldArray.remove(i),
1589
+ className: "sb:absolute sb:top-2 sb:right-2 sb:text-foreground/70 sb:hover:text-foreground"
1590
+ },
1591
+ /* @__PURE__ */ React25__namespace.createElement(lucideReact.XIcon, { className: "sb:h-4 sb:w-4" })
1592
+ ))
1593
+ ), /* @__PURE__ */ React25__namespace.createElement(
1594
+ chunk7FWFM2TR_js.Button,
1595
+ {
1596
+ type: "button",
1597
+ variant: "outline",
1598
+ size: "sm",
1599
+ className: chunk63LNKQZD_js.cn(
1600
+ "sb:w-[89%] sb:border-2 sb:border-dashed sb:text-muted-foreground",
1601
+ type === "grouped" && "sb:w-full"
1602
+ ),
1603
+ onClick: () => fieldArray.append(void 0)
1604
+ },
1605
+ /* @__PURE__ */ React25__namespace.createElement(lucideReact.PlusCircleIcon, { className: "sb:h-4 sb:w-4" })
1606
+ )));
1607
+ }
1608
+ switch (type) {
1609
+ case "string":
1610
+ case "number":
1611
+ case "longText":
1612
+ case "color":
1613
+ case "date":
1614
+ case "file":
1615
+ return /* @__PURE__ */ React25__namespace.createElement(
1616
+ FormField,
1617
+ {
1618
+ key: input.name,
1619
+ control: form.control,
1620
+ name: input.name,
1621
+ render: ({ field }) => /* @__PURE__ */ React25__namespace.createElement(FormItem, null, /* @__PURE__ */ React25__namespace.createElement(FormLabel, null, input.friendlyName || input.name), /* @__PURE__ */ React25__namespace.createElement(FormControl, null, /* @__PURE__ */ React25__namespace.createElement(RenderInput, { type, field, options: input?.enum })), input.helperText && /* @__PURE__ */ React25__namespace.createElement(FormDescription, null, input.helperText), /* @__PURE__ */ React25__namespace.createElement(FormMessage, null))
1622
+ }
1623
+ );
1624
+ case "richText":
1625
+ return /* @__PURE__ */ React25__namespace.createElement(Dialog, null, /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:flex sb:flex-col sb:gap-2" }, /* @__PURE__ */ React25__namespace.createElement(FormLabel, null, input.friendlyName || input.name), /* @__PURE__ */ React25__namespace.createElement(DialogTrigger, { asChild: true }, /* @__PURE__ */ React25__namespace.createElement(chunk7FWFM2TR_js.Button, { variant: "outline", className: "sb:w-full", type: "button" }, input.friendlyName || input.name, " bewerken"))), /* @__PURE__ */ React25__namespace.createElement(DialogContent, { className: "sb:max-w-3xl sb:p-0" }, /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:flex sb:h-full sb:max-h-svh sb:w-full sb:flex-col sb:sm:max-h-[90svh]" }, /* @__PURE__ */ React25__namespace.createElement(DialogHeader, { className: "sb:flex-none sb:border-b sb:p-6" }, /* @__PURE__ */ React25__namespace.createElement(DialogTitle, null, input.friendlyName || input.name, " editor")), /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:flex-1 sb:overflow-y-auto" }, /* @__PURE__ */ React25__namespace.createElement(
1626
+ FormField,
1627
+ {
1628
+ key: input.name,
1629
+ control: form.control,
1630
+ name: input.name,
1631
+ render: ({ field }) => /* @__PURE__ */ React25__namespace.createElement(FormItem, null, /* @__PURE__ */ React25__namespace.createElement(FormControl, null, /* @__PURE__ */ React25__namespace.createElement(RenderInput, { type, field })), input.helperText && /* @__PURE__ */ React25__namespace.createElement(FormDescription, null, input.helperText), /* @__PURE__ */ React25__namespace.createElement(FormMessage, null))
1632
+ }
1633
+ )))));
1634
+ case "boolean":
1635
+ return /* @__PURE__ */ React25__namespace.createElement(
1636
+ FormField,
1637
+ {
1638
+ key: input.name,
1639
+ control: form.control,
1640
+ name: input.name,
1641
+ render: ({ field }) => /* @__PURE__ */ React25__namespace.createElement(FormItem, { className: "sb:flex sb:flex-row sb:items-center sb:justify-between sb:space-y-0" }, /* @__PURE__ */ React25__namespace.createElement(FormLabel, null, input.friendlyName || input.name), /* @__PURE__ */ React25__namespace.createElement(FormControl, null, /* @__PURE__ */ React25__namespace.createElement(RenderInput, { type, field })), input.helperText && /* @__PURE__ */ React25__namespace.createElement(FormDescription, null, input.helperText), /* @__PURE__ */ React25__namespace.createElement(FormMessage, null))
1642
+ }
1643
+ );
1644
+ case "grouped":
1645
+ return /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:flex sb:flex-col sb:gap-2 sb:w-full" }, input.friendlyName !== "" && /* @__PURE__ */ React25__namespace.createElement(FormLabel, null, input.friendlyName || input.name), /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:flex sb:flex-col sb:gap-2 sb:p-3 sb:w-full sb:border sb:rounded-lg" }, input.inputs.map((sub) => /* @__PURE__ */ React25__namespace.createElement(
1646
+ RenderFormField,
1647
+ {
1648
+ key: `${input.name}.${sub.name}`,
1649
+ type: sub.type,
1650
+ input: {
1651
+ ...sub,
1652
+ name: `${input.name}.${sub.name}`
1653
+ },
1654
+ form
1655
+ }
1656
+ ))));
1657
+ default:
1658
+ throw new Error(
1659
+ `[simple-builder]: Input type "${props.type}" not supported in render form field.`
1660
+ );
1661
+ }
1662
+ };
1663
+ var RenderInput = (props) => {
1664
+ const { type, options, field } = props;
1665
+ switch (type) {
1666
+ case "string":
1667
+ if (!options)
1668
+ return /* @__PURE__ */ React25__namespace.createElement(Input, { ...field });
1669
+ return /* @__PURE__ */ React25__namespace.createElement(Select, { onValueChange: field.onChange, defaultValue: field.value }, /* @__PURE__ */ React25__namespace.createElement(SelectTrigger, null, /* @__PURE__ */ React25__namespace.createElement(SelectValue, null)), /* @__PURE__ */ React25__namespace.createElement(SelectContent, null, options.map((option) => /* @__PURE__ */ React25__namespace.createElement(SelectItem, { key: option, value: option }, option))));
1670
+ case "longText":
1671
+ return /* @__PURE__ */ React25__namespace.createElement(Textarea, { ...field });
1672
+ case "richText":
1673
+ return /* @__PURE__ */ React25__namespace.createElement(RichTextEditor, { ...field });
1674
+ case "number":
1675
+ return /* @__PURE__ */ React25__namespace.createElement(Input, { type: "number", ...field });
1676
+ case "color":
1677
+ return /* @__PURE__ */ React25__namespace.createElement(ColorPicker, { color: field.value, onColorChange: field.onChange });
1678
+ case "date":
1679
+ return /* @__PURE__ */ React25__namespace.createElement(Popover, null, /* @__PURE__ */ React25__namespace.createElement(PopoverTrigger, { asChild: true }, /* @__PURE__ */ React25__namespace.createElement(
1680
+ chunk7FWFM2TR_js.Button,
1681
+ {
1682
+ variant: "outline",
1683
+ size: "sm",
1684
+ className: chunk63LNKQZD_js.cn(
1685
+ "sb:w-full sb:flex sb:justify-start sb:text-left sb:font-normal",
1686
+ !field.value && "sb:text-muted-foreground"
1687
+ )
1688
+ },
1689
+ /* @__PURE__ */ React25__namespace.createElement(lucideReact.CalendarIcon, { className: "sb:mr-2 sb:h-4 sb:w-4" }),
1690
+ field.value && !Array.isArray(field.value) ? dateFns.format(field.value, "PPP") : /* @__PURE__ */ React25__namespace.createElement("span", null, "Pick a date")
1691
+ )), /* @__PURE__ */ React25__namespace.createElement(PopoverContent, { className: "sb:w-auto sb:p-0", align: "start" }, /* @__PURE__ */ React25__namespace.createElement(
1692
+ Calendar,
1693
+ {
1694
+ mode: "single",
1695
+ selected: field.value,
1696
+ onSelect: field.onChange,
1697
+ initialFocus: true
1698
+ }
1699
+ )));
1700
+ case "boolean":
1701
+ return /* @__PURE__ */ React25__namespace.createElement(Switch, { checked: field.value, onCheckedChange: field.onChange });
1702
+ case "file":
1703
+ return /* @__PURE__ */ React25__namespace.createElement(
1704
+ MediaInput,
1705
+ {
1706
+ className: "sb:grid sb:grid-cols-2 sb:gap-1",
1707
+ itemClassName: "sb:aspect-video sb:h-auto sb:w-full",
1708
+ multiple: false,
1709
+ files: field.value ? [field.value] : [],
1710
+ onFilesChange: (files) => field.onChange(files[0]),
1711
+ onError: (e) => console.error(
1712
+ "[media-input]: Title: " + e?.title,
1713
+ "media-input: Error: " + e?.description
1714
+ )
1715
+ }
1716
+ );
1717
+ default:
1718
+ throw new Error(
1719
+ `[simple-builder]: Input type "${props.type}" not supported in render input.`
1720
+ );
1721
+ }
1722
+ };
1723
+ var Tabs = TabsPrimitive__namespace.Root;
1724
+ var tabsListVariants = chunk63LNKQZD_js.tv({
1725
+ variants: {
1726
+ variant: {
1727
+ contained: "sb:inline-flex sb:h-10 sb:items-center sb:justify-center sb:rounded-md sb:bg-muted sb:p-1 sb:text-muted-foreground",
1728
+ text: "sb:flex sb:items-center sb:border-b sb:px-4 sb:gap-6"
1729
+ }
1730
+ },
1731
+ defaultVariants: {
1732
+ variant: "contained"
1733
+ }
1734
+ });
1735
+ var TabsList = React25__namespace.forwardRef(({ variant, className, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
1736
+ TabsPrimitive__namespace.List,
1737
+ {
1738
+ ref,
1739
+ className: tabsListVariants({ variant, className }),
1740
+ ...props
1741
+ }
1742
+ ));
1743
+ TabsList.displayName = TabsPrimitive__namespace.List.displayName;
1744
+ var tabsTriggerVariants = chunk63LNKQZD_js.tv({
1745
+ variants: {
1746
+ variant: {
1747
+ contained: "sb:inline-flex sb:items-center sb:justify-center sb:whitespace-nowrap sb:rounded-sm sb:px-3 sb:py-1.5 sb:text-sm sb:font-medium sb:ring-offset-background sb:transition-all sb:focus-visible:outline-hidden sb:focus-visible:ring-2 sb:focus-visible:ring-ring sb:focus-visible:ring-offset-2 sb:disabled:pointer-events-none sb:disabled:opacity-50 sb:data-[state=active]:bg-background sb:data-[state=active]:text-foreground sb:data-[state=active]:shadow-sm",
1748
+ text: "sb:inline-flex sb:font-roboto sb:items-center sb:justify-center sb:whitespace-nowrap sb:py-3 sb:text-sm sb:font-medium sb:transition-all sb:focus-visible:outline-hidden sb:disabled:pointer-events-none sb:disabled:opacity-50 sb:data-[state=active]:border-black sb:border-b-2 sb:border-transparent sb:data-[state=active]:text-foreground sb:text-muted-foreground"
1749
+ }
1750
+ },
1751
+ defaultVariants: {
1752
+ variant: "contained"
1753
+ }
1754
+ });
1755
+ var TabsTrigger = React25__namespace.forwardRef(({ variant, className, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
1756
+ TabsPrimitive__namespace.Trigger,
1757
+ {
1758
+ ref,
1759
+ className: tabsTriggerVariants({ variant, className }),
1760
+ ...props
1761
+ }
1762
+ ));
1763
+ TabsTrigger.displayName = TabsPrimitive__namespace.Trigger.displayName;
1764
+ var TabsContent = React25__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
1765
+ TabsPrimitive__namespace.Content,
1766
+ {
1767
+ ref,
1768
+ className: chunk63LNKQZD_js.cn(
1769
+ "sb:ring-offset-background sb:font-roboto sb:focus-visible:outline-hidden sb:focus-visible:ring-2 sb:focus-visible:ring-ring sb:focus-visible:ring-offset-2",
1770
+ className
1771
+ ),
1772
+ ...props
1773
+ }
1774
+ ));
1775
+ TabsContent.displayName = TabsPrimitive__namespace.Content.displayName;
1776
+
1777
+ // src/components/ui/background-picker.tsx
1778
+ var BackgroundPicker = (props) => {
1779
+ const { background, onBackgroundChange, className } = props;
1780
+ const solids = props.solids ?? [
1781
+ "#000000",
1782
+ "#ffffff",
1783
+ "#0f172a",
1784
+ "#F1F5F9",
1785
+ "#64748B",
1786
+ "#E6007E",
1787
+ "#F8FAFC",
1788
+ "#009DD1",
1789
+ "#FF0000"
1790
+ ];
1791
+ const gradients = props.gradients ?? [
1792
+ "linear-gradient(to top left,#accbee,#e7f0fd)",
1793
+ "linear-gradient(to top left,#d5d4d0,#d5d4d0,#eeeeec)"
1794
+ ];
1795
+ const images = props.images ?? [
1796
+ "url(https://images.unsplash.com/photo-1688822863426-8c5f9b257090?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=2532&q=90)",
1797
+ "url(https://images.unsplash.com/photo-1691225850735-6e4e51834cad?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=2532&q=90)"
1798
+ ];
1799
+ const defaultTab = React25__namespace.useMemo(() => {
1800
+ if (background.includes("url"))
1801
+ return "image";
1802
+ if (background.includes("gradient"))
1803
+ return "gradient";
1804
+ return "solid";
1805
+ }, [background]);
1806
+ return /* @__PURE__ */ React25__namespace.createElement(Popover, null, /* @__PURE__ */ React25__namespace.createElement(PopoverTrigger, { asChild: true }, /* @__PURE__ */ React25__namespace.createElement(
1807
+ chunk7FWFM2TR_js.Button,
1808
+ {
1809
+ variant: "outline",
1810
+ size: "sm",
1811
+ className: chunk63LNKQZD_js.cn(
1812
+ "sb:justify-start sb:text-left sb:font-normal sb:normal-case sb:w-full",
1813
+ !background && "sb:text-muted-foreground",
1814
+ className
1815
+ )
1816
+ },
1817
+ /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:w-full sb:flex sb:items-center sb:gap-2" }, background ? /* @__PURE__ */ React25__namespace.createElement(
1818
+ "div",
1819
+ {
1820
+ className: "sb:h-4 sb:w-4 sb:rounded sb:bg-center! sb:bg-cover! sb:transition-all sb:border",
1821
+ style: { background }
1822
+ }
1823
+ ) : /* @__PURE__ */ React25__namespace.createElement(lucideReact.PaintbrushIcon, { className: "sb:h-4 sb:w-4" }), /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:truncate sb:flex-1" }, background ? background : "Kies een achtergrond"))
1824
+ )), /* @__PURE__ */ React25__namespace.createElement(PopoverContent, { className: "sb:w-64 sb:p-0" }, /* @__PURE__ */ React25__namespace.createElement(Tabs, { defaultValue: defaultTab }, /* @__PURE__ */ React25__namespace.createElement(TabsList, { className: "sb:w-full" }, /* @__PURE__ */ React25__namespace.createElement(TabsTrigger, { className: "sb:flex-1", value: "solid" }, "Solid"), /* @__PURE__ */ React25__namespace.createElement(TabsTrigger, { className: "sb:flex-1", value: "gradient" }, "Gradient"), /* @__PURE__ */ React25__namespace.createElement(TabsTrigger, { className: "sb:flex-1", value: "image" }, "Image")), /* @__PURE__ */ React25__namespace.createElement(
1825
+ TabsContent,
1826
+ {
1827
+ value: "solid",
1828
+ className: "sb:data-[state=active]:flex sb:flex-wrap sb:gap-1 sb:p-4"
1829
+ },
1830
+ solids.map((s) => /* @__PURE__ */ React25__namespace.createElement(
1831
+ "div",
1832
+ {
1833
+ key: s,
1834
+ style: { background: s },
1835
+ className: "sb:rounded-md sb:h-6 sb:w-6 sb:cursor-pointer sb:active:scale-105 sb:border",
1836
+ onClick: () => onBackgroundChange(s)
1837
+ }
1838
+ ))
1839
+ ), /* @__PURE__ */ React25__namespace.createElement(
1840
+ TabsContent,
1841
+ {
1842
+ value: "gradient",
1843
+ className: "sb:data-[state=active]:flex sb:flex-wrap sb:gap-1 sb:p-4"
1844
+ },
1845
+ gradients.map((s) => /* @__PURE__ */ React25__namespace.createElement(
1846
+ "div",
1847
+ {
1848
+ key: s,
1849
+ style: { background: s },
1850
+ className: "rounded-md h-6 w-6 cursor-pointer active:scale-105 border",
1851
+ onClick: () => onBackgroundChange(s)
1852
+ }
1853
+ ))
1854
+ ), /* @__PURE__ */ React25__namespace.createElement(TabsContent, { value: "image" }, /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:p-4 sb:border-b" }, /* @__PURE__ */ React25__namespace.createElement(
1855
+ MediaInput,
1856
+ {
1857
+ className: "sb:grid sb:grid-cols-2 sb:gap-1",
1858
+ itemClassName: "sb:aspect-video sb:h-auto sb:w-full",
1859
+ multiple: false,
1860
+ accept: IMAGE_FILE_ACCEPT,
1861
+ onFilesChange: (files) => {
1862
+ if (!files.length)
1863
+ return;
1864
+ onBackgroundChange(`url(${files[0]})`);
1865
+ },
1866
+ onError: (e) => console.error(
1867
+ "[media-input]: Title: " + e?.title,
1868
+ "media-input: Error: " + e?.description
1869
+ )
1870
+ }
1871
+ )), /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:grid sb:grid-cols-2 sb:gap-1 sb:p-4" }, images.map((s) => /* @__PURE__ */ React25__namespace.createElement(
1872
+ "div",
1873
+ {
1874
+ key: s,
1875
+ style: { backgroundImage: s },
1876
+ className: "sb:rounded-md sb:bg-cover sb:bg-center sb:aspect-video sb:w-full sb:cursor-pointer sb:border sb:active:scale-105",
1877
+ onClick: () => onBackgroundChange(s)
1878
+ }
1879
+ )))))));
1880
+ };
1881
+ var SpacingInput = (props) => {
1882
+ const [value, setValue] = React25__namespace.useState(parse(props.value || "0px"));
1883
+ const [indipendent, setIndipendent] = React25__namespace.useState(
1884
+ isIndipendent(parse(props.value || "0px"))
1885
+ );
1886
+ React25__namespace.useEffect(() => {
1887
+ if (!props.onChange)
1888
+ return;
1889
+ props.onChange(stringify(value));
1890
+ }, [value, props.onChange]);
1891
+ return /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:grid sb:grid-cols-[1fr_auto] sb:gap-3" }, /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:grid sb:grid-cols-2 sb:items-center sb:gap-3" }, !indipendent ? /* @__PURE__ */ React25__namespace.createElement(React25__namespace.Fragment, null, /* @__PURE__ */ React25__namespace.createElement(
1892
+ AdvancedInput,
1893
+ {
1894
+ value: value.left,
1895
+ pattern: "\\d+",
1896
+ onChange: ({ target: { value: value2 } }) => setValue((prev) => ({ ...prev, left: +value2, right: +value2 })),
1897
+ prepend: /* @__PURE__ */ React25__namespace.createElement(lucideReact.AlignHorizontalSpaceAroundIcon, { className: "sb:h-4 sb:w-4" }),
1898
+ append: /* @__PURE__ */ React25__namespace.createElement("span", { className: "sb:text-muted-foreground" }, "px")
1899
+ }
1900
+ ), /* @__PURE__ */ React25__namespace.createElement(
1901
+ AdvancedInput,
1902
+ {
1903
+ value: value.top,
1904
+ pattern: "\\d+",
1905
+ onChange: ({ target: { value: value2 } }) => setValue((prev) => ({ ...prev, top: +value2, bottom: +value2 })),
1906
+ prepend: /* @__PURE__ */ React25__namespace.createElement(lucideReact.AlignHorizontalSpaceAroundIcon, { className: "sb:h-4 sb:w-4 sb:rotate-90" }),
1907
+ append: /* @__PURE__ */ React25__namespace.createElement("span", { className: "sb:text-muted-foreground" }, "px")
1908
+ }
1909
+ )) : /* @__PURE__ */ React25__namespace.createElement(React25__namespace.Fragment, null, /* @__PURE__ */ React25__namespace.createElement(
1910
+ AdvancedInput,
1911
+ {
1912
+ value: value.left,
1913
+ pattern: "\\d+",
1914
+ onChange: ({ target: { value: value2 } }) => setValue((prev) => ({ ...prev, left: +value2 })),
1915
+ prepend: /* @__PURE__ */ React25__namespace.createElement(lucideReact.AlignHorizontalJustifyStartIcon, { className: "sb:h-4 sb:w-4" }),
1916
+ append: /* @__PURE__ */ React25__namespace.createElement("span", { className: "sb:text-muted-foreground" }, "px")
1917
+ }
1918
+ ), /* @__PURE__ */ React25__namespace.createElement(
1919
+ AdvancedInput,
1920
+ {
1921
+ value: value.top,
1922
+ pattern: "\\d+",
1923
+ onChange: ({ target: { value: value2 } }) => setValue((prev) => ({ ...prev, top: +value2 })),
1924
+ prepend: /* @__PURE__ */ React25__namespace.createElement(lucideReact.AlignHorizontalJustifyStartIcon, { className: "sb:h-4 sb:w-4 sb:rotate-90" }),
1925
+ append: /* @__PURE__ */ React25__namespace.createElement("span", { className: "sb:text-muted-foreground" }, "px")
1926
+ }
1927
+ ), /* @__PURE__ */ React25__namespace.createElement(
1928
+ AdvancedInput,
1929
+ {
1930
+ value: value.right,
1931
+ pattern: "\\d+",
1932
+ onChange: ({ target: { value: value2 } }) => setValue((prev) => ({ ...prev, right: +value2 })),
1933
+ prepend: /* @__PURE__ */ React25__namespace.createElement(lucideReact.AlignHorizontalJustifyStartIcon, { className: "sb:h-4 sb:w-4 sb:rotate-180" }),
1934
+ append: /* @__PURE__ */ React25__namespace.createElement("span", { className: "sb:text-muted-foreground" }, "px")
1935
+ }
1936
+ ), /* @__PURE__ */ React25__namespace.createElement(
1937
+ AdvancedInput,
1938
+ {
1939
+ value: value.bottom,
1940
+ pattern: "\\d+",
1941
+ onChange: ({ target: { value: value2 } }) => setValue((prev) => ({ ...prev, bottom: +value2 })),
1942
+ prepend: /* @__PURE__ */ React25__namespace.createElement(lucideReact.AlignHorizontalJustifyStartIcon, { className: "sb:h-4 sb:w-4 sb:-rotate-90" }),
1943
+ append: /* @__PURE__ */ React25__namespace.createElement("span", { className: "sb:text-muted-foreground" }, "px")
1944
+ }
1945
+ ))), /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:shrink-0" }, /* @__PURE__ */ React25__namespace.createElement(
1946
+ Toggle,
1947
+ {
1948
+ className: "sb:shrink-0 sb:flex sb:w-8 sb:h-8 sb:p-0",
1949
+ variant: "outline",
1950
+ size: "sm",
1951
+ pressed: indipendent,
1952
+ onPressedChange: setIndipendent
1953
+ },
1954
+ /* @__PURE__ */ React25__namespace.createElement(lucideReact.ScanIcon, { className: "sb:h-4 sb:w-4" })
1955
+ )));
1956
+ };
1957
+ var isIndipendent = (value) => {
1958
+ const { top, right, bottom, left } = value;
1959
+ return top !== bottom || right !== left;
1960
+ };
1961
+ var parse = (value) => {
1962
+ const matches = value.match(/(\d+)/gm);
1963
+ const [top = 0, right = 0, bottom = 0, left = 0] = matches?.map((match) => +match) || [];
1964
+ switch (matches?.length) {
1965
+ case 1:
1966
+ return { top, right: top, bottom: top, left: top };
1967
+ case 2:
1968
+ return { top, bottom: top, left: right, right };
1969
+ case 3:
1970
+ return { top, right, left: right, bottom };
1971
+ default:
1972
+ return { top, right, bottom, left };
1973
+ }
1974
+ };
1975
+ var stringify = (value) => {
1976
+ const { top, right, bottom, left } = value;
1977
+ if (top === right && top === bottom && top === left) {
1978
+ return `${top}px`;
1979
+ }
1980
+ if (top === bottom && right === left) {
1981
+ return `${top}px ${right}px`;
1982
+ }
1983
+ if (right === left) {
1984
+ return `${top}px ${right}px ${bottom}px`;
1985
+ }
1986
+ return `${top}px ${right}px ${bottom}px ${left}px`;
1987
+ };
1988
+
1989
+ // src/components/item-design-form.tsx
1990
+ var designSchema = zod.z.object({
1991
+ container: zod.z.coerce.boolean(),
1992
+ hidden: zod.z.enum(["always", "mobile", "desktop", "never"]),
1993
+ desktop: zod.z.object({
1994
+ background: zod.z.string(),
1995
+ color: zod.z.string(),
1996
+ padding: zod.z.string(),
1997
+ margin: zod.z.string()
1998
+ }),
1999
+ mobile: zod.z.object({
2000
+ background: zod.z.string(),
2001
+ color: zod.z.string(),
2002
+ padding: zod.z.string(),
2003
+ margin: zod.z.string()
2004
+ })
2005
+ });
2006
+ var ItemDesignForm = (props) => {
2007
+ const { item } = props;
2008
+ const component = chunk63LNKQZD_js.builder.getComponent(item.component);
2009
+ if (!component) {
2010
+ throw new Error(
2011
+ `[simple-builder]: Component "${item.component}" not found`
2012
+ );
2013
+ }
2014
+ const getDefaultDeviceValue = (params) => {
2015
+ const { device: device2 = "desktop", key, fallback = "" } = params;
2016
+ if (item.styles?.[device2]?.[key] !== void 0) {
2017
+ return item.styles[device2][key];
2018
+ }
2019
+ if (component.defaultStyles?.[device2]?.[key] !== void 0) {
2020
+ return component.defaultStyles[device2][key];
2021
+ }
2022
+ if (device2 === "mobile") {
2023
+ const desktopValue = getDefaultDeviceValue({
2024
+ ...params,
2025
+ device: "desktop"
2026
+ });
2027
+ if (desktopValue !== void 0) {
2028
+ return desktopValue;
2029
+ }
2030
+ }
2031
+ return fallback;
2032
+ };
2033
+ const getDefaultDeviceValues = (device2) => {
2034
+ return {
2035
+ background: getDefaultDeviceValue({ device: device2, key: "background" }),
2036
+ color: getDefaultDeviceValue({ device: device2, key: "color" }),
2037
+ padding: getDefaultDeviceValue({ device: device2, key: "padding" }),
2038
+ margin: getDefaultDeviceValue({ device: device2, key: "margin" })
2039
+ };
2040
+ };
2041
+ const form = reactHookForm.useForm({
2042
+ resolver: zod$1.zodResolver(designSchema),
2043
+ values: {
2044
+ container: item.styles?.container ?? true,
2045
+ hidden: item.styles?.hidden ?? "never",
2046
+ desktop: getDefaultDeviceValues("desktop"),
2047
+ mobile: getDefaultDeviceValues("mobile")
2048
+ }
2049
+ });
2050
+ const { patchItem } = chunk7FWFM2TR_js.useBuilder();
2051
+ const onSubmit = React25__namespace.useCallback(
2052
+ (values) => {
2053
+ const { container, hidden, desktop, mobile } = values;
2054
+ const dirtyFields = form.formState.dirtyFields;
2055
+ const desktopPatch = Object.entries(desktop).reduce(
2056
+ (acc, [key, value]) => ({
2057
+ ...acc,
2058
+ ...value && { [key]: value }
2059
+ }),
2060
+ { ...item.styles?.desktop }
2061
+ );
2062
+ const mobilePatch = Object.entries(mobile).reduce(
2063
+ (acc, [key, value]) => {
2064
+ const desktopValue = desktop[key];
2065
+ const isDirty = dirtyFields.desktop?.[key];
2066
+ if (value === desktopValue || isDirty) {
2067
+ return acc;
2068
+ }
2069
+ if (["padding", "margin"].includes(key)) {
2070
+ if (value === "0px" && desktopValue === "0px") {
2071
+ return acc;
2072
+ }
2073
+ }
2074
+ return {
2075
+ ...acc,
2076
+ ...value && { [key]: value }
2077
+ };
2078
+ },
2079
+ { ...item.styles?.mobile }
2080
+ );
2081
+ patchItem(item.id, {
2082
+ styles: {
2083
+ ...container === false && { container },
2084
+ ...hidden !== "never" && { hidden },
2085
+ ...Object.keys(desktopPatch).length && { desktop: desktopPatch },
2086
+ ...Object.keys(mobilePatch).length && { mobile: mobilePatch }
2087
+ }
2088
+ });
2089
+ },
2090
+ [patchItem, item.id, form.formState.dirtyFields]
2091
+ );
2092
+ const [device, setDevice] = React25__namespace.useState("desktop");
2093
+ return /* @__PURE__ */ React25__namespace.createElement(Form, { ...form }, /* @__PURE__ */ React25__namespace.createElement("form", { onSubmit: form.handleSubmit(onSubmit) }, /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:flex sb:flex-col sb:gap-4 sb:p-4" }, /* @__PURE__ */ React25__namespace.createElement(
2094
+ Tabs,
2095
+ {
2096
+ defaultValue: device,
2097
+ onValueChange: (device2) => setDevice(device2)
2098
+ },
2099
+ /* @__PURE__ */ React25__namespace.createElement(TabsList, { className: "sb:h-9 sb:grid sb:w-full sb:grid-cols-2" }, /* @__PURE__ */ React25__namespace.createElement(TabsTrigger, { value: "desktop", className: "sb:text-xs" }, /* @__PURE__ */ React25__namespace.createElement(lucideReact.MonitorIcon, { className: "sb:h-4 sb:w-4 sb:mr-2" }), /* @__PURE__ */ React25__namespace.createElement("span", null, "Desktop")), /* @__PURE__ */ React25__namespace.createElement(TabsTrigger, { value: "mobile", className: "sb:text-xs" }, /* @__PURE__ */ React25__namespace.createElement(lucideReact.SmartphoneIcon, { className: "sb:h-4 sb:w-4 sb:mr-2" }), /* @__PURE__ */ React25__namespace.createElement("span", null, "Mobiel")))
2100
+ ), /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:flex sb:flex-col sb:gap-4" }, /* @__PURE__ */ React25__namespace.createElement(
2101
+ FormField,
2102
+ {
2103
+ control: form.control,
2104
+ key: `${device}.background`,
2105
+ name: `${device}.background`,
2106
+ render: ({ field }) => /* @__PURE__ */ React25__namespace.createElement(FormItem, null, /* @__PURE__ */ React25__namespace.createElement(FormLabel, null, "Achtergrond"), /* @__PURE__ */ React25__namespace.createElement(FormControl, null, /* @__PURE__ */ React25__namespace.createElement(
2107
+ BackgroundPicker,
2108
+ {
2109
+ background: field.value,
2110
+ onBackgroundChange: field.onChange
2111
+ }
2112
+ )), /* @__PURE__ */ React25__namespace.createElement(FormMessage, null))
2113
+ }
2114
+ ), /* @__PURE__ */ React25__namespace.createElement(
2115
+ FormField,
2116
+ {
2117
+ control: form.control,
2118
+ key: `${device}.color`,
2119
+ name: `${device}.color`,
2120
+ render: ({ field }) => /* @__PURE__ */ React25__namespace.createElement(FormItem, null, /* @__PURE__ */ React25__namespace.createElement(FormLabel, null, "Inhoud kleur"), /* @__PURE__ */ React25__namespace.createElement(FormControl, null, /* @__PURE__ */ React25__namespace.createElement(
2121
+ ColorPicker,
2122
+ {
2123
+ color: field.value,
2124
+ onColorChange: field.onChange
2125
+ }
2126
+ )), /* @__PURE__ */ React25__namespace.createElement(FormMessage, null))
2127
+ }
2128
+ ), /* @__PURE__ */ React25__namespace.createElement("hr", null), /* @__PURE__ */ React25__namespace.createElement(
2129
+ FormField,
2130
+ {
2131
+ control: form.control,
2132
+ name: "hidden",
2133
+ render: ({ field }) => /* @__PURE__ */ React25__namespace.createElement(FormItem, null, /* @__PURE__ */ React25__namespace.createElement(FormLabel, null, "Verbergen"), /* @__PURE__ */ React25__namespace.createElement(FormControl, null, /* @__PURE__ */ React25__namespace.createElement(Select, { value: field.value, onValueChange: field.onChange }, /* @__PURE__ */ React25__namespace.createElement(SelectTrigger, null, /* @__PURE__ */ React25__namespace.createElement(SelectValue, null)), /* @__PURE__ */ React25__namespace.createElement(SelectContent, null, /* @__PURE__ */ React25__namespace.createElement(SelectItem, { value: "never" }, "Nooit"), /* @__PURE__ */ React25__namespace.createElement(SelectItem, { value: "desktop" }, "Op desktop"), /* @__PURE__ */ React25__namespace.createElement(SelectItem, { value: "mobile" }, "Op mobiel"), /* @__PURE__ */ React25__namespace.createElement(SelectItem, { value: "always" }, "Altijd")))), /* @__PURE__ */ React25__namespace.createElement(FormMessage, null))
2134
+ }
2135
+ ), /* @__PURE__ */ React25__namespace.createElement("hr", null), /* @__PURE__ */ React25__namespace.createElement(
2136
+ FormField,
2137
+ {
2138
+ control: form.control,
2139
+ name: "container",
2140
+ render: ({ field }) => /* @__PURE__ */ React25__namespace.createElement(FormItem, { className: "sb:flex sb:flex-row sb:items-center sb:justify-between sb:space-y-0" }, /* @__PURE__ */ React25__namespace.createElement(FormLabel, null, "Volledige breedte"), /* @__PURE__ */ React25__namespace.createElement(FormControl, null, /* @__PURE__ */ React25__namespace.createElement(
2141
+ Switch,
2142
+ {
2143
+ checked: !field.value,
2144
+ onCheckedChange: (v) => field.onChange(!v)
2145
+ }
2146
+ )), /* @__PURE__ */ React25__namespace.createElement(FormMessage, null))
2147
+ }
2148
+ ), /* @__PURE__ */ React25__namespace.createElement("hr", null), /* @__PURE__ */ React25__namespace.createElement(
2149
+ FormField,
2150
+ {
2151
+ control: form.control,
2152
+ key: `${device}.padding`,
2153
+ name: `${device}.padding`,
2154
+ render: ({ field }) => /* @__PURE__ */ React25__namespace.createElement(FormItem, null, /* @__PURE__ */ React25__namespace.createElement(FormLabel, null, "Padding"), /* @__PURE__ */ React25__namespace.createElement(FormControl, null, /* @__PURE__ */ React25__namespace.createElement(
2155
+ SpacingInput,
2156
+ {
2157
+ value: field.value,
2158
+ onChange: field.onChange
2159
+ }
2160
+ )), /* @__PURE__ */ React25__namespace.createElement(FormMessage, null))
2161
+ }
2162
+ ), /* @__PURE__ */ React25__namespace.createElement(
2163
+ FormField,
2164
+ {
2165
+ control: form.control,
2166
+ key: `${device}.margin`,
2167
+ name: `${device}.margin`,
2168
+ render: ({ field }) => /* @__PURE__ */ React25__namespace.createElement(FormItem, null, /* @__PURE__ */ React25__namespace.createElement(FormLabel, null, "Margin"), /* @__PURE__ */ React25__namespace.createElement(FormControl, null, /* @__PURE__ */ React25__namespace.createElement(
2169
+ SpacingInput,
2170
+ {
2171
+ value: field.value,
2172
+ onChange: field.onChange
2173
+ }
2174
+ )), /* @__PURE__ */ React25__namespace.createElement(FormMessage, null))
2175
+ }
2176
+ )), /* @__PURE__ */ React25__namespace.createElement(chunk7FWFM2TR_js.Button, { type: "submit", className: "w-full" }, "Opslaan"))));
2177
+ };
2178
+ var ScrollArea = React25__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
2179
+ ScrollAreaPrimitive__namespace.Root,
2180
+ {
2181
+ ref,
2182
+ className: chunk63LNKQZD_js.cn("sb:relative sb:overflow-hidden", className),
2183
+ ...props
2184
+ },
2185
+ /* @__PURE__ */ React25__namespace.createElement(ScrollAreaPrimitive__namespace.Viewport, { className: "sb:h-full sb:max-h-[80vh] sb:w-full sb:rounded-[inherit]" }, children),
2186
+ /* @__PURE__ */ React25__namespace.createElement(ScrollBar, null),
2187
+ /* @__PURE__ */ React25__namespace.createElement(ScrollAreaPrimitive__namespace.Corner, null)
2188
+ ));
2189
+ ScrollArea.displayName = ScrollAreaPrimitive__namespace.Root.displayName;
2190
+ var ScrollBar = React25__namespace.forwardRef(({ className, orientation = "vertical", ...props }, ref) => /* @__PURE__ */ React25__namespace.createElement(
2191
+ ScrollAreaPrimitive__namespace.ScrollAreaScrollbar,
2192
+ {
2193
+ ref,
2194
+ orientation,
2195
+ className: chunk63LNKQZD_js.cn(
2196
+ "sb:flex sb:touch-none sb:select-none sb:transition-colors",
2197
+ orientation === "vertical" && "sb:h-full sb:w-2.5 sb:border-l sb:border-l-transparent sb:p-px",
2198
+ orientation === "horizontal" && "sb:h-2.5 sb:flex-col sb:border-t sb:border-t-transparent sb:p-px",
2199
+ className
2200
+ ),
2201
+ ...props
2202
+ },
2203
+ /* @__PURE__ */ React25__namespace.createElement(ScrollAreaPrimitive__namespace.ScrollAreaThumb, { className: "sb:relative sb:flex-1 sb:rounded-full sb:bg-border" })
2204
+ ));
2205
+ ScrollBar.displayName = ScrollAreaPrimitive__namespace.ScrollAreaScrollbar.displayName;
2206
+
2207
+ // src/components/container-item-toolbar.tsx
2208
+ var ContainerItemToolbar = (props) => {
2209
+ const { contentId, canBringUp = false, canBringDown = false } = props;
2210
+ const { bringUp, bringDown } = chunk7FWFM2TR_js.useBuilder();
2211
+ return /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:absolute sb:z-20 sb:top-1 sb:right-1 sb:rounded-md sb:shadow sb:flex sb:flex-col sb:gap-1 sb:p-1 sb:bg-card sb:text-card-foreground sb-item-toolbar sb:opacity-0 sb:transition-opacity" }, /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:h-10 sb:p-1 sb:border sb:border-input sb:bg-background sb:rounded-md sb:text-sm sb:font-medium sb:flex sb:gap-1 sb:items-center sb:justify-start" }, /* @__PURE__ */ React25__namespace.createElement(EditButton, { id: contentId }), /* @__PURE__ */ React25__namespace.createElement(
2212
+ chunk7FWFM2TR_js.Button,
2213
+ {
2214
+ variant: "ghost",
2215
+ className: "sb:w-8 sb:h-8 sb:p-0",
2216
+ onClick: () => bringUp(contentId),
2217
+ disabled: !canBringUp
2218
+ },
2219
+ /* @__PURE__ */ React25__namespace.createElement(lucideReact.ArrowUp, { className: "sb:h-5 sb:w-5" })
2220
+ ), /* @__PURE__ */ React25__namespace.createElement(
2221
+ chunk7FWFM2TR_js.Button,
2222
+ {
2223
+ variant: "ghost",
2224
+ className: "sb:w-8 sb:h-8 sb:p-0",
2225
+ onClick: () => bringDown(contentId),
2226
+ disabled: !canBringDown
2227
+ },
2228
+ /* @__PURE__ */ React25__namespace.createElement(lucideReact.ArrowDown, { className: "sb:h-5 sb:w-5" })
2229
+ ), /* @__PURE__ */ React25__namespace.createElement(DeleteButton, { contentId })));
2230
+ };
2231
+ var EditButton = ({ id }) => {
2232
+ return /* @__PURE__ */ React25__namespace.createElement(Popover, { modal: true }, /* @__PURE__ */ React25__namespace.createElement(PopoverTrigger, { asChild: true }, /* @__PURE__ */ React25__namespace.createElement(chunk7FWFM2TR_js.Button, { variant: "ghost", className: "sb:w-8 sb:h-8 sb:p-0" }, /* @__PURE__ */ React25__namespace.createElement(lucideReact.Edit2Icon, { className: "sb:h-5 sb:w-5" }))), /* @__PURE__ */ React25__namespace.createElement(
2233
+ PopoverContent,
2234
+ {
2235
+ side: "left",
2236
+ align: "start",
2237
+ sideOffset: 16,
2238
+ alignOffset: -8,
2239
+ className: "sb:p-0 sb:relative",
2240
+ collisionPadding: 16
2241
+ },
2242
+ /* @__PURE__ */ React25__namespace.createElement(EditPopoverInner, { id })
2243
+ ));
2244
+ };
2245
+ var EditPopoverInner = (props) => {
2246
+ const { id } = props;
2247
+ const { getItem } = chunk7FWFM2TR_js.useBuilder();
2248
+ const item = getItem(id);
2249
+ if (!item) {
2250
+ throw new Error(
2251
+ `[simple-builder]: Item with id ${id} not found in container item form component`
2252
+ );
2253
+ }
2254
+ return /* @__PURE__ */ React25__namespace.createElement(Tabs, null, /* @__PURE__ */ React25__namespace.createElement(TabsList, { variant: "text", defaultValue: "content" }, /* @__PURE__ */ React25__namespace.createElement(TabsTrigger, { variant: "text", value: "content" }, "Inhoud"), /* @__PURE__ */ React25__namespace.createElement(TabsTrigger, { variant: "text", value: "design" }, "Design")), /* @__PURE__ */ React25__namespace.createElement(TabsContent, { value: "content" }, /* @__PURE__ */ React25__namespace.createElement(ScrollArea, null, /* @__PURE__ */ React25__namespace.createElement(ContainerItemForm, { item }))), /* @__PURE__ */ React25__namespace.createElement(TabsContent, { value: "design" }, /* @__PURE__ */ React25__namespace.createElement(ItemDesignForm, { item })));
2255
+ };
2256
+ var DeleteButton = ({ contentId }) => {
2257
+ const { deleteContent } = chunk7FWFM2TR_js.useBuilder();
2258
+ return /* @__PURE__ */ React25__namespace.createElement(AlertDialog, null, /* @__PURE__ */ React25__namespace.createElement(AlertDialogTrigger, { asChild: true }, /* @__PURE__ */ React25__namespace.createElement(
2259
+ chunk7FWFM2TR_js.Button,
2260
+ {
2261
+ variant: "ghost",
2262
+ className: "sb:w-8 sb:h-8 sb:p-0 sb:text-destructive"
2263
+ },
2264
+ /* @__PURE__ */ React25__namespace.createElement(lucideReact.Trash2Icon, { className: "sb:h-5 sb:w-5" })
2265
+ )), /* @__PURE__ */ React25__namespace.createElement(AlertDialogContent, null, /* @__PURE__ */ React25__namespace.createElement(AlertDialogDescription, null, "Weet je zeker dat je dit blok wilt verwijderen?"), /* @__PURE__ */ React25__namespace.createElement(AlertDialogFooter, null, /* @__PURE__ */ React25__namespace.createElement(AlertDialogCancel, null, "Annuleren"), /* @__PURE__ */ React25__namespace.createElement(
2266
+ AlertDialogAction,
2267
+ {
2268
+ className: chunk7FWFM2TR_js.buttonVariants({ variant: "destructive" }),
2269
+ onClick: () => deleteContent(contentId)
2270
+ },
2271
+ "Verwijderen"
2272
+ ))));
2273
+ };
2274
+
2275
+ // src/components/build-container-client.tsx
2276
+ var BuildContainerInner = (props) => {
2277
+ const { id, name, content, multiple = false } = props;
2278
+ const items = Array.isArray(content) ? content : content?.[name] || [];
2279
+ if (!multiple && items.length > 1) {
2280
+ console.error(
2281
+ "[simple-builder]: Multiple content blocks detected when using property multiple false."
2282
+ );
2283
+ }
2284
+ return /* @__PURE__ */ React25__namespace.createElement("div", null, items.length <= 0 ? /* @__PURE__ */ React25__namespace.createElement(AddContentPlaceholder, { parent: id, container: name, index: 0 }) : multiple && /* @__PURE__ */ React25__namespace.createElement(AddContentDividerButton, { parent: id, container: name, index: 0 }), items.map((item, i) => /* @__PURE__ */ React25__namespace.createElement(React25__namespace.Fragment, { key: item.id }, /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:relative sb-container-item" }, /* @__PURE__ */ React25__namespace.createElement(chunk63LNKQZD_js.DesignWrapper, { building: true, styles: item.styles }, chunk63LNKQZD_js.builder.bindComponent(item, true)), /* @__PURE__ */ React25__namespace.createElement(
2285
+ ContainerItemToolbar,
2286
+ {
2287
+ contentId: item.id,
2288
+ canBringUp: i > 0,
2289
+ canBringDown: i < items.length - 1
2290
+ }
2291
+ )), multiple && /* @__PURE__ */ React25__namespace.createElement(
2292
+ AddContentDividerButton,
2293
+ {
2294
+ parent: id,
2295
+ container: name,
2296
+ index: i + 1
2297
+ }
2298
+ ))));
2299
+ };
2300
+ var build_container_client_default = BuildContainerInner;
2301
+ var AddContentButton = (props) => {
2302
+ const components = chunk63LNKQZD_js.builder.getComponents();
2303
+ const { addContent } = chunk7FWFM2TR_js.useBuilder();
2304
+ return /* @__PURE__ */ React25__namespace.createElement(Popover, null, /* @__PURE__ */ React25__namespace.createElement(PopoverTrigger, { asChild: true }, props.children), /* @__PURE__ */ React25__namespace.createElement(PopoverContent, { className: "sb:p-1" }, /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:grid sb:grid-cols-2 sb:gap-2" }, components.map((component) => {
2305
+ const Icon2 = component.icon ?? lucideReact.ImageIcon;
2306
+ return /* @__PURE__ */ React25__namespace.createElement(PopoverClose, { key: component.name, asChild: true }, /* @__PURE__ */ React25__namespace.createElement(
2307
+ chunk7FWFM2TR_js.Button,
2308
+ {
2309
+ variant: "ghost",
2310
+ className: "sb:justify-start",
2311
+ onClick: () => {
2312
+ addContent(
2313
+ component.name,
2314
+ props.container,
2315
+ props.parent,
2316
+ props.index
2317
+ );
2318
+ }
2319
+ },
2320
+ /* @__PURE__ */ React25__namespace.createElement(Icon2, { className: "sb:mr-2 sb:h-4 sb:w-4 sb:shrink-0" }),
2321
+ component.friendlyName ?? component.name
2322
+ ));
2323
+ }))));
2324
+ };
2325
+ var AddContentPlaceholder = (props) => {
2326
+ return /* @__PURE__ */ React25__namespace.createElement(AddContentButton, { ...props }, /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:flex sb:justify-center sb:bg-primary/50 p-4" }, /* @__PURE__ */ React25__namespace.createElement(chunk7FWFM2TR_js.Button, { size: "sm" }, /* @__PURE__ */ React25__namespace.createElement(lucideReact.PlusIcon, { className: "sb:mr-2 sb:h-4 sb:w-4" }), "Blok Toevoegen")));
2327
+ };
2328
+ var AddContentDividerButton = (props) => {
2329
+ return /* @__PURE__ */ React25__namespace.createElement(AddContentButton, { ...props }, /* @__PURE__ */ React25__namespace.createElement("div", { className: "sb:w-full sb:h-1 sb:-my-[2px] sb:bg-primary sb:relative sb:z-20 sb:opacity-0 add-content-divider-button sb:transition-opacity" }, /* @__PURE__ */ React25__namespace.createElement(
2330
+ chunk7FWFM2TR_js.Button,
2331
+ {
2332
+ size: "sm",
2333
+ className: "sb:absolute sb:left-1/2 sb:top-1/2 sb:-translate-y-1/2 sb:-translate-x-1/2 sb:shadow"
2334
+ },
2335
+ /* @__PURE__ */ React25__namespace.createElement(lucideReact.PlusIcon, { className: "sb:mr-2 sb:h-4 sb:w-4" }),
2336
+ "Blok Toevoegen"
2337
+ )));
2338
+ };
2339
+
2340
+ module.exports = build_container_client_default;