@simple-builder/react 1.3.1 → 1.3.3

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