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