@simple-builder/react 1.2.5 → 1.2.6

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