@measured/puck 0.19.0-canary.84a836b → 0.19.0-canary.a281c342

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/rsc.js CHANGED
@@ -9,6 +9,9 @@ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
9
  var __getProtoOf = Object.getPrototypeOf;
10
10
  var __hasOwnProp = Object.prototype.hasOwnProperty;
11
11
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
+ var __typeError = (msg) => {
13
+ throw TypeError(msg);
14
+ };
12
15
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
16
  var __spreadValues = (a, b) => {
14
17
  for (var prop in b || (b = {}))
@@ -22,6 +25,24 @@ var __spreadValues = (a, b) => {
22
25
  return a;
23
26
  };
24
27
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
28
+ var __objRest = (source, exclude) => {
29
+ var target = {};
30
+ for (var prop in source)
31
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
32
+ target[prop] = source[prop];
33
+ if (source != null && __getOwnPropSymbols)
34
+ for (var prop of __getOwnPropSymbols(source)) {
35
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
36
+ target[prop] = source[prop];
37
+ }
38
+ return target;
39
+ };
40
+ var __esm = (fn, res) => function __init() {
41
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
42
+ };
43
+ var __commonJS = (cb, mod) => function __require() {
44
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
45
+ };
25
46
  var __export = (target, all) => {
26
47
  for (var name in all)
27
48
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -43,6 +64,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
43
64
  mod
44
65
  ));
45
66
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
67
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
68
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
69
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
70
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
46
71
  var __async = (__this, __arguments, generator) => {
47
72
  return new Promise((resolve, reject) => {
48
73
  var fulfilled = (value) => {
@@ -64,23 +89,98 @@ var __async = (__this, __arguments, generator) => {
64
89
  });
65
90
  };
66
91
 
92
+ // ../tsup-config/react-import.js
93
+ var import_react;
94
+ var init_react_import = __esm({
95
+ "../tsup-config/react-import.js"() {
96
+ "use strict";
97
+ import_react = __toESM(require("react"));
98
+ }
99
+ });
100
+
101
+ // ../../node_modules/classnames/index.js
102
+ var require_classnames = __commonJS({
103
+ "../../node_modules/classnames/index.js"(exports2, module2) {
104
+ "use strict";
105
+ init_react_import();
106
+ (function() {
107
+ "use strict";
108
+ var hasOwn = {}.hasOwnProperty;
109
+ function classNames() {
110
+ var classes = "";
111
+ for (var i = 0; i < arguments.length; i++) {
112
+ var arg = arguments[i];
113
+ if (arg) {
114
+ classes = appendClass(classes, parseValue(arg));
115
+ }
116
+ }
117
+ return classes;
118
+ }
119
+ function parseValue(arg) {
120
+ if (typeof arg === "string" || typeof arg === "number") {
121
+ return arg;
122
+ }
123
+ if (typeof arg !== "object") {
124
+ return "";
125
+ }
126
+ if (Array.isArray(arg)) {
127
+ return classNames.apply(null, arg);
128
+ }
129
+ if (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes("[native code]")) {
130
+ return arg.toString();
131
+ }
132
+ var classes = "";
133
+ for (var key in arg) {
134
+ if (hasOwn.call(arg, key) && arg[key]) {
135
+ classes = appendClass(classes, key);
136
+ }
137
+ }
138
+ return classes;
139
+ }
140
+ function appendClass(value, newClass) {
141
+ if (!newClass) {
142
+ return value;
143
+ }
144
+ if (value) {
145
+ return value + " " + newClass;
146
+ }
147
+ return value + newClass;
148
+ }
149
+ if (typeof module2 !== "undefined" && module2.exports) {
150
+ classNames.default = classNames;
151
+ module2.exports = classNames;
152
+ } else if (typeof define === "function" && typeof define.amd === "object" && define.amd) {
153
+ define("classnames", [], function() {
154
+ return classNames;
155
+ });
156
+ } else {
157
+ window.classNames = classNames;
158
+ }
159
+ })();
160
+ }
161
+ });
162
+
67
163
  // rsc.tsx
68
164
  var rsc_exports = {};
69
165
  __export(rsc_exports, {
70
166
  Render: () => Render,
71
- resolveAllData: () => resolveAllData
167
+ resolveAllData: () => resolveAllData,
168
+ transformProps: () => transformProps
72
169
  });
73
170
  module.exports = __toCommonJS(rsc_exports);
171
+ init_react_import();
74
172
 
75
- // ../tsup-config/react-import.js
76
- var import_react = __toESM(require("react"));
173
+ // components/ServerRender/index.tsx
174
+ init_react_import();
77
175
 
78
176
  // lib/root-droppable-id.ts
177
+ init_react_import();
79
178
  var rootAreaId = "root";
80
179
  var rootZone = "default-zone";
81
180
  var rootDroppableId = `${rootAreaId}:${rootZone}`;
82
181
 
83
182
  // lib/setup-zone.ts
183
+ init_react_import();
84
184
  var setupZone = (data, zoneKey) => {
85
185
  if (zoneKey === rootDroppableId) {
86
186
  return data;
@@ -92,232 +192,3701 @@ var setupZone = (data, zoneKey) => {
92
192
  return newData;
93
193
  };
94
194
 
95
- // components/ServerRender/index.tsx
96
- var import_jsx_runtime = require("react/jsx-runtime");
97
- function DropZoneRender({
98
- zone,
99
- data,
100
- areaId = "root",
101
- config,
102
- metadata = {}
103
- }) {
104
- let zoneCompound = rootDroppableId;
105
- let content = (data == null ? void 0 : data.content) || [];
106
- if (!data || !config) {
107
- return null;
195
+ // lib/use-slots.ts
196
+ init_react_import();
197
+ var import_react2 = require("react");
198
+ function useSlots(config, props, renderSlot) {
199
+ return (0, import_react2.useMemo)(() => {
200
+ if (!(config == null ? void 0 : config.fields)) return props;
201
+ const newProps = __spreadValues({}, props);
202
+ const fieldKeys = Object.keys(config.fields);
203
+ for (let i = 0; i < fieldKeys.length; i++) {
204
+ const fieldKey = fieldKeys[i];
205
+ const field = config.fields[fieldKey];
206
+ if ((field == null ? void 0 : field.type) === "slot") {
207
+ newProps[fieldKey] = (dzProps) => renderSlot(__spreadProps(__spreadValues({}, dzProps), {
208
+ zone: fieldKey,
209
+ content: props[fieldKey] || []
210
+ }));
211
+ }
212
+ }
213
+ return newProps;
214
+ }, [config, props]);
215
+ }
216
+
217
+ // components/SlotRender/index.tsx
218
+ init_react_import();
219
+ var import_react26 = require("react");
220
+
221
+ // components/DropZone/index.tsx
222
+ init_react_import();
223
+ var import_react25 = require("react");
224
+
225
+ // components/DraggableComponent/index.tsx
226
+ init_react_import();
227
+ var import_react13 = require("react");
228
+
229
+ // css-module:/home/runner/work/puck/puck/packages/core/components/DraggableComponent/styles.module.css#css-module
230
+ init_react_import();
231
+ var styles_module_default = { "DraggableComponent": "_DraggableComponent_1ukn8_1", "DraggableComponent-overlay": "_DraggableComponent-overlay_1ukn8_12", "DraggableComponent-loadingOverlay": "_DraggableComponent-loadingOverlay_1ukn8_29", "DraggableComponent--hover": "_DraggableComponent--hover_1ukn8_45", "DraggableComponent--isLocked": "_DraggableComponent--isLocked_1ukn8_45", "DraggableComponent--isSelected": "_DraggableComponent--isSelected_1ukn8_54", "DraggableComponent-actionsOverlay": "_DraggableComponent-actionsOverlay_1ukn8_66", "DraggableComponent-actions": "_DraggableComponent-actions_1ukn8_66" };
232
+
233
+ // lib/get-class-name-factory.ts
234
+ init_react_import();
235
+ var import_classnames = __toESM(require_classnames());
236
+ var getClassNameFactory = (rootClass, styles, config = { baseClass: "" }) => (options = {}) => {
237
+ if (typeof options === "string") {
238
+ const descendant = options;
239
+ const style = styles[`${rootClass}-${descendant}`];
240
+ if (style) {
241
+ return config.baseClass + styles[`${rootClass}-${descendant}`] || "";
242
+ }
243
+ return "";
244
+ } else if (typeof options === "object") {
245
+ const modifiers = options;
246
+ const prefixedModifiers = {};
247
+ for (let modifier in modifiers) {
248
+ prefixedModifiers[styles[`${rootClass}--${modifier}`]] = modifiers[modifier];
249
+ }
250
+ const c = styles[rootClass];
251
+ return config.baseClass + (0, import_classnames.default)(__spreadValues({
252
+ [c]: !!c
253
+ }, prefixedModifiers));
254
+ } else {
255
+ return config.baseClass + styles[rootClass] || "";
108
256
  }
109
- if (areaId !== rootAreaId && zone !== rootZone) {
110
- zoneCompound = `${areaId}:${zone}`;
111
- content = setupZone(data, zoneCompound).zones[zoneCompound];
257
+ };
258
+ var get_class_name_factory_default = getClassNameFactory;
259
+
260
+ // ../../node_modules/lucide-react/dist/esm/lucide-react.js
261
+ init_react_import();
262
+
263
+ // ../../node_modules/lucide-react/dist/esm/createLucideIcon.js
264
+ init_react_import();
265
+ var import_react4 = require("react");
266
+
267
+ // ../../node_modules/lucide-react/dist/esm/shared/src/utils.js
268
+ init_react_import();
269
+ var toKebabCase = (string) => string.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
270
+ var mergeClasses = (...classes) => classes.filter((className, index, array) => {
271
+ return Boolean(className) && className.trim() !== "" && array.indexOf(className) === index;
272
+ }).join(" ").trim();
273
+
274
+ // ../../node_modules/lucide-react/dist/esm/Icon.js
275
+ init_react_import();
276
+ var import_react3 = require("react");
277
+
278
+ // ../../node_modules/lucide-react/dist/esm/defaultAttributes.js
279
+ init_react_import();
280
+ var defaultAttributes = {
281
+ xmlns: "http://www.w3.org/2000/svg",
282
+ width: 24,
283
+ height: 24,
284
+ viewBox: "0 0 24 24",
285
+ fill: "none",
286
+ stroke: "currentColor",
287
+ strokeWidth: 2,
288
+ strokeLinecap: "round",
289
+ strokeLinejoin: "round"
290
+ };
291
+
292
+ // ../../node_modules/lucide-react/dist/esm/Icon.js
293
+ var Icon = (0, import_react3.forwardRef)(
294
+ (_a, ref) => {
295
+ var _b = _a, {
296
+ color = "currentColor",
297
+ size = 24,
298
+ strokeWidth = 2,
299
+ absoluteStrokeWidth,
300
+ className = "",
301
+ children,
302
+ iconNode
303
+ } = _b, rest = __objRest(_b, [
304
+ "color",
305
+ "size",
306
+ "strokeWidth",
307
+ "absoluteStrokeWidth",
308
+ "className",
309
+ "children",
310
+ "iconNode"
311
+ ]);
312
+ return (0, import_react3.createElement)(
313
+ "svg",
314
+ __spreadValues(__spreadProps(__spreadValues({
315
+ ref
316
+ }, defaultAttributes), {
317
+ width: size,
318
+ height: size,
319
+ stroke: color,
320
+ strokeWidth: absoluteStrokeWidth ? Number(strokeWidth) * 24 / Number(size) : strokeWidth,
321
+ className: mergeClasses("lucide", className)
322
+ }), rest),
323
+ [
324
+ ...iconNode.map(([tag, attrs]) => (0, import_react3.createElement)(tag, attrs)),
325
+ ...Array.isArray(children) ? children : [children]
326
+ ]
327
+ );
112
328
  }
113
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: content.map((item) => {
114
- const Component = config.components[item.type];
115
- if (Component) {
116
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
117
- Component.render,
118
- __spreadProps(__spreadValues({}, item.props), {
119
- puck: {
120
- renderDropZone: ({ zone: zone2 }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
121
- DropZoneRender,
122
- {
123
- zone: zone2,
124
- data,
125
- areaId: item.props.id,
126
- config,
127
- metadata
128
- }
129
- ),
130
- metadata
131
- }
132
- }),
133
- item.props.id
134
- );
329
+ );
330
+
331
+ // ../../node_modules/lucide-react/dist/esm/createLucideIcon.js
332
+ var createLucideIcon = (iconName, iconNode) => {
333
+ const Component = (0, import_react4.forwardRef)(
334
+ (_a, ref) => {
335
+ var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
336
+ return (0, import_react4.createElement)(Icon, __spreadValues({
337
+ ref,
338
+ iconNode,
339
+ className: mergeClasses(`lucide-${toKebabCase(iconName)}`, className)
340
+ }, props));
135
341
  }
136
- return null;
137
- }) });
342
+ );
343
+ Component.displayName = `${iconName}`;
344
+ return Component;
345
+ };
346
+
347
+ // ../../node_modules/lucide-react/dist/esm/icons/copy.js
348
+ init_react_import();
349
+ var Copy = createLucideIcon("Copy", [
350
+ ["rect", { width: "14", height: "14", x: "8", y: "8", rx: "2", ry: "2", key: "17jyea" }],
351
+ ["path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2", key: "zix9uf" }]
352
+ ]);
353
+
354
+ // ../../node_modules/lucide-react/dist/esm/icons/corner-left-up.js
355
+ init_react_import();
356
+ var CornerLeftUp = createLucideIcon("CornerLeftUp", [
357
+ ["polyline", { points: "14 9 9 4 4 9", key: "m9oyvo" }],
358
+ ["path", { d: "M20 20h-7a4 4 0 0 1-4-4V4", key: "1blwi3" }]
359
+ ]);
360
+
361
+ // ../../node_modules/lucide-react/dist/esm/icons/trash.js
362
+ init_react_import();
363
+ var Trash = createLucideIcon("Trash", [
364
+ ["path", { d: "M3 6h18", key: "d0wm0j" }],
365
+ ["path", { d: "M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6", key: "4alrt4" }],
366
+ ["path", { d: "M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2", key: "v07s0e" }]
367
+ ]);
368
+
369
+ // store/index.ts
370
+ init_react_import();
371
+
372
+ // reducer/index.ts
373
+ init_react_import();
374
+
375
+ // reducer/reduce.ts
376
+ init_react_import();
377
+
378
+ // lib/insert.ts
379
+ init_react_import();
380
+ var insert = (list, index, item) => {
381
+ const result = Array.from(list || []);
382
+ result.splice(index, 0, item);
383
+ return result;
384
+ };
385
+
386
+ // lib/remove.ts
387
+ init_react_import();
388
+ var remove = (list, index) => {
389
+ const result = Array.from(list);
390
+ result.splice(index, 1);
391
+ return result;
392
+ };
393
+
394
+ // lib/get-item.ts
395
+ init_react_import();
396
+ function getItem(selector, state) {
397
+ var _a, _b;
398
+ const zone = (_a = state.indexes.zones) == null ? void 0 : _a[selector.zone || rootDroppableId];
399
+ return zone ? (_b = state.indexes.nodes[zone.contentIds[selector.index]]) == null ? void 0 : _b.data : void 0;
138
400
  }
139
- function Render({
140
- config,
141
- data,
142
- metadata
143
- }) {
401
+
402
+ // lib/generate-id.ts
403
+ init_react_import();
404
+ var import_uuid = require("uuid");
405
+ var generateId = (type) => type ? `${type}-${(0, import_uuid.v4)()}` : (0, import_uuid.v4)();
406
+
407
+ // lib/walk-tree.ts
408
+ init_react_import();
409
+
410
+ // lib/for-each-slot.ts
411
+ init_react_import();
412
+
413
+ // lib/is-slot.ts
414
+ init_react_import();
415
+ var isSlot = (prop) => {
416
+ var _a, _b;
417
+ return Array.isArray(prop) && typeof ((_a = prop[0]) == null ? void 0 : _a.type) === "string" && typeof ((_b = prop[0]) == null ? void 0 : _b.props) === "object";
418
+ };
419
+ var createIsSlotConfig = (config) => (itemType, propName, propValue) => {
420
+ var _a, _b;
421
+ const configForComponent = itemType === "root" ? config == null ? void 0 : config.root : config == null ? void 0 : config.components[itemType];
422
+ if (!configForComponent) return isSlot(propValue);
423
+ return ((_b = (_a = configForComponent.fields) == null ? void 0 : _a[propName]) == null ? void 0 : _b.type) === "slot";
424
+ };
425
+
426
+ // lib/for-each-slot.ts
427
+ var forEachSlot = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, cb, recursive = false, isSlot2 = isSlot) {
428
+ const props = item.props || {};
429
+ const propKeys = Object.keys(props);
430
+ for (let i = 0; i < propKeys.length; i++) {
431
+ const propKey = propKeys[i];
432
+ const itemType = "type" in item ? item.type : "root";
433
+ if (isSlot2(itemType, propKey, props[propKey])) {
434
+ const content = props[propKey];
435
+ yield cb(props.id, propKey, content);
436
+ if (recursive) {
437
+ content.forEach(
438
+ (childItem) => __async(void 0, null, function* () {
439
+ return yield forEachSlot(childItem, cb, true, isSlot2);
440
+ })
441
+ );
442
+ }
443
+ }
444
+ }
445
+ });
446
+
447
+ // lib/for-related-zones.ts
448
+ init_react_import();
449
+
450
+ // lib/get-zone-id.ts
451
+ init_react_import();
452
+ var getZoneId = (zoneCompound) => {
453
+ if (!zoneCompound) {
454
+ return [];
455
+ }
456
+ if (zoneCompound && zoneCompound.indexOf(":") > -1) {
457
+ return zoneCompound.split(":");
458
+ }
459
+ return [rootDroppableId, zoneCompound];
460
+ };
461
+
462
+ // lib/for-related-zones.ts
463
+ function forRelatedZones(item, data, cb, path = []) {
464
+ Object.entries(data.zones || {}).forEach(([zoneCompound, content]) => {
465
+ const [parentId] = getZoneId(zoneCompound);
466
+ if (parentId === item.props.id) {
467
+ const newPath = [...path, zoneCompound];
468
+ content.forEach((item2) => forRelatedZones(item2, data, cb, newPath));
469
+ cb(path, zoneCompound, content);
470
+ }
471
+ });
472
+ }
473
+
474
+ // lib/strip-slots.ts
475
+ init_react_import();
476
+ var stripSlots = (data) => {
477
+ return __spreadProps(__spreadValues({}, data), {
478
+ props: Object.entries(data.props).reduce(
479
+ (acc, [propKey, propVal]) => {
480
+ if (isSlot(propVal)) {
481
+ return acc;
482
+ }
483
+ return __spreadProps(__spreadValues({}, acc), { [propKey]: propVal });
484
+ },
485
+ { id: data.props.id }
486
+ )
487
+ });
488
+ };
489
+
490
+ // lib/walk-tree.ts
491
+ function walkTree(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
144
492
  var _a;
145
- if ((_a = config.root) == null ? void 0 : _a.render) {
146
- const rootProps = data.root.props || data.root;
147
- const title = rootProps.title || "";
148
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
149
- config.root.render,
150
- __spreadProps(__spreadValues({}, rootProps), {
151
- puck: {
152
- renderDropZone: ({ zone }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
153
- DropZoneRender,
154
- {
155
- zone,
156
- data,
157
- config,
158
- metadata
159
- }
160
- ),
161
- isEditing: false,
162
- dragRef: null
163
- },
164
- title,
165
- editMode: false,
166
- id: "puck-root",
167
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
168
- DropZoneRender,
169
- {
170
- config,
171
- data,
172
- zone: rootZone,
173
- metadata
174
- }
175
- )
176
- })
493
+ let newZones = {};
494
+ const newZoneIndex = {};
495
+ const newNodeIndex = {};
496
+ const processContent = (path, zoneCompound, content, zoneType, newId) => {
497
+ var _a2;
498
+ const [parentId] = zoneCompound.split(":");
499
+ const mappedContent = ((_a2 = mapContent(content, zoneCompound, zoneType)) != null ? _a2 : content) || [];
500
+ const [_2, zone] = zoneCompound.split(":");
501
+ const newZoneCompound = `${newId || parentId}:${zone}`;
502
+ const newContent2 = mappedContent.map(
503
+ (zoneChild, index) => processItem(zoneChild, [...path, newZoneCompound], index)
177
504
  );
178
- }
179
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
180
- DropZoneRender,
181
- {
182
- config,
183
- data,
184
- zone: rootZone,
185
- metadata
505
+ newZoneIndex[newZoneCompound] = {
506
+ contentIds: newContent2.map((item) => item.props.id),
507
+ type: zoneType
508
+ };
509
+ return [newZoneCompound, newContent2];
510
+ };
511
+ const processRelatedZones = (item, newId, initialPath) => {
512
+ forRelatedZones(
513
+ item,
514
+ state.data,
515
+ (relatedPath, relatedZoneCompound, relatedContent) => {
516
+ const [zoneCompound, newContent2] = processContent(
517
+ relatedPath,
518
+ relatedZoneCompound,
519
+ relatedContent,
520
+ "dropzone",
521
+ newId
522
+ );
523
+ newZones[zoneCompound] = newContent2;
524
+ },
525
+ initialPath
526
+ );
527
+ };
528
+ const processItem = (item, path, index) => {
529
+ const mappedItem = mapNodeOrSkip(item, path, index);
530
+ if (!mappedItem) return item;
531
+ const id = mappedItem.props.id;
532
+ processRelatedZones(item, id, path);
533
+ const newProps = __spreadValues({}, mappedItem.props);
534
+ forEachSlot(
535
+ mappedItem,
536
+ (parentId2, slotId, content) => {
537
+ const zoneCompound = `${parentId2}:${slotId}`;
538
+ const [_2, newContent2] = processContent(
539
+ path,
540
+ zoneCompound,
541
+ content,
542
+ "slot",
543
+ parentId2
544
+ );
545
+ newProps[slotId] = newContent2;
546
+ },
547
+ false,
548
+ createIsSlotConfig(config)
549
+ );
550
+ const newItem = __spreadProps(__spreadValues({}, item), { props: newProps });
551
+ const thisZoneCompound = path[path.length - 1];
552
+ const [parentId, zone] = thisZoneCompound ? thisZoneCompound.split(":") : [null, ""];
553
+ newNodeIndex[id] = {
554
+ data: newItem,
555
+ flatData: stripSlots(newItem),
556
+ path,
557
+ parentId,
558
+ zone
559
+ };
560
+ const finalData = __spreadProps(__spreadValues({}, newItem), { props: __spreadValues({}, newItem.props) });
561
+ if (newProps.id === "root") {
562
+ delete finalData["type"];
563
+ delete finalData.props["id"];
186
564
  }
565
+ return finalData;
566
+ };
567
+ const zones = state.data.zones || {};
568
+ const [_, newContent] = processContent(
569
+ [],
570
+ rootDroppableId,
571
+ state.data.content,
572
+ "root"
187
573
  );
574
+ const processedContent = newContent;
575
+ const zonesAlreadyProcessed = Object.keys(newZones);
576
+ Object.keys(zones || {}).forEach((zoneCompound) => {
577
+ const [parentId] = zoneCompound.split(":");
578
+ if (zonesAlreadyProcessed.includes(zoneCompound)) {
579
+ return;
580
+ }
581
+ const [_2, newContent2] = processContent(
582
+ [rootDroppableId],
583
+ zoneCompound,
584
+ zones[zoneCompound],
585
+ "dropzone",
586
+ parentId
587
+ );
588
+ newZones[zoneCompound] = newContent2;
589
+ }, newZones);
590
+ const processedRoot = processItem(
591
+ {
592
+ type: "root",
593
+ props: __spreadProps(__spreadValues({}, (_a = state.data.root.props) != null ? _a : state.data.root), { id: "root" })
594
+ },
595
+ [],
596
+ -1
597
+ );
598
+ const root = __spreadProps(__spreadValues({}, state.data.root), {
599
+ props: processedRoot.props
600
+ });
601
+ return __spreadProps(__spreadValues({}, state), {
602
+ data: {
603
+ root,
604
+ // root: state.data.root, // TODO changing root causes it's entire subtree to re-render. Let's keep this disabled until the performance issues are resolved in #644.
605
+ content: processedContent,
606
+ zones: __spreadValues(__spreadValues({}, state.data.zones), newZones)
607
+ },
608
+ indexes: {
609
+ nodes: __spreadValues(__spreadValues({}, state.indexes.nodes), newNodeIndex),
610
+ zones: __spreadValues(__spreadValues({}, state.indexes.zones), newZoneIndex)
611
+ }
612
+ });
188
613
  }
189
614
 
190
- // lib/get-changed.ts
191
- var getChanged = (newItem, oldItem) => {
192
- return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
193
- const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
194
- const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
195
- return __spreadProps(__spreadValues({}, acc), {
196
- [item]: oldItemProps[item] !== newItemProps[item]
197
- });
198
- }, {}) : {};
615
+ // reducer/reduce.ts
616
+ var zoneCache = {};
617
+ var getIdsForParent = (zoneCompound, state) => {
618
+ const [parentId] = zoneCompound.split(":");
619
+ const node = state.indexes.nodes[parentId];
620
+ return ((node == null ? void 0 : node.path) || []).map((p) => p.split(":")[0]);
199
621
  };
200
-
201
- // lib/resolve-component-data.ts
202
- var cache = { lastChange: {} };
203
- var resolveAllComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (content, config, metadata = {}, onResolveStart, onResolveEnd) {
204
- return yield Promise.all(
205
- content.map((item) => __async(void 0, null, function* () {
206
- return yield resolveComponentData(
207
- item,
208
- config,
209
- metadata,
210
- onResolveStart,
211
- onResolveEnd
622
+ function insertAction(state, action, config) {
623
+ const id = action.id || generateId(action.componentType);
624
+ const emptyComponentData = {
625
+ type: action.componentType,
626
+ props: __spreadProps(__spreadValues({}, config.components[action.componentType].defaultProps || {}), {
627
+ id
628
+ })
629
+ };
630
+ const [parentId] = action.destinationZone.split(":");
631
+ const idsInPath = getIdsForParent(action.destinationZone, state);
632
+ return walkTree(
633
+ state,
634
+ config,
635
+ (content, zoneCompound) => {
636
+ if (zoneCompound === action.destinationZone) {
637
+ return insert(
638
+ content || [],
639
+ action.destinationIndex,
640
+ emptyComponentData
641
+ );
642
+ }
643
+ return content;
644
+ },
645
+ (childItem, path) => {
646
+ if (childItem.props.id === id || childItem.props.id === parentId) {
647
+ return childItem;
648
+ } else if (idsInPath.includes(childItem.props.id)) {
649
+ return childItem;
650
+ } else if (path.includes(action.destinationZone)) {
651
+ return childItem;
652
+ }
653
+ return null;
654
+ }
655
+ );
656
+ }
657
+ var moveAction = (state, action, appStore) => {
658
+ if (action.sourceZone === action.destinationZone && action.sourceIndex === action.destinationIndex) {
659
+ return state;
660
+ }
661
+ const item = getItem(
662
+ { zone: action.sourceZone, index: action.sourceIndex },
663
+ state
664
+ );
665
+ if (!item) return state;
666
+ const idsInSourcePath = getIdsForParent(action.sourceZone, state);
667
+ const idsInDestinationPath = getIdsForParent(action.destinationZone, state);
668
+ return walkTree(
669
+ state,
670
+ appStore.config,
671
+ (content, zoneCompound) => {
672
+ if (zoneCompound === action.sourceZone && zoneCompound === action.destinationZone) {
673
+ return insert(
674
+ remove(content, action.sourceIndex),
675
+ action.destinationIndex,
676
+ item
677
+ );
678
+ } else if (zoneCompound === action.sourceZone) {
679
+ return remove(content, action.sourceIndex);
680
+ } else if (zoneCompound === action.destinationZone) {
681
+ return insert(content, action.destinationIndex, item);
682
+ }
683
+ return content;
684
+ },
685
+ (childItem, path) => {
686
+ const [sourceZoneParent] = action.sourceZone.split(":");
687
+ const [destinationZoneParent] = action.destinationZone.split(":");
688
+ const childId = childItem.props.id;
689
+ if (sourceZoneParent === childId || destinationZoneParent === childId || item.props.id === childId || idsInSourcePath.indexOf(childId) > -1 || idsInDestinationPath.indexOf(childId) > -1 || path.includes(action.destinationZone)) {
690
+ return childItem;
691
+ }
692
+ return null;
693
+ }
694
+ );
695
+ };
696
+ var replaceAction = (state, action, appStore) => {
697
+ const [parentId] = action.destinationZone.split(":");
698
+ const idsInPath = getIdsForParent(action.destinationZone, state);
699
+ const originalId = state.indexes.zones[action.destinationZone].contentIds[action.destinationIndex];
700
+ const idChanged = originalId !== action.data.props.id;
701
+ if (idChanged) {
702
+ throw new Error(
703
+ `Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
704
+ );
705
+ }
706
+ return walkTree(
707
+ state,
708
+ appStore.config,
709
+ (content, zoneCompound) => {
710
+ const newContent = [...content];
711
+ if (zoneCompound === action.destinationZone) {
712
+ newContent[action.destinationIndex] = action.data;
713
+ }
714
+ return newContent;
715
+ },
716
+ (childItem, path) => {
717
+ const pathIds = path.map((p) => p.split(":")[0]);
718
+ if (childItem.props.id === action.data.props.id) {
719
+ return action.data;
720
+ } else if (childItem.props.id === parentId) {
721
+ return childItem;
722
+ } else if (idsInPath.indexOf(childItem.props.id) > -1) {
723
+ return childItem;
724
+ } else if (pathIds.indexOf(action.data.props.id) > -1) {
725
+ return childItem;
726
+ }
727
+ return null;
728
+ }
729
+ );
730
+ };
731
+ var setAction = (state, action, appStore) => {
732
+ if (typeof action.state === "object") {
733
+ const newState = __spreadValues(__spreadValues({}, state), action.state);
734
+ if (action.state.indexes) {
735
+ console.warn(
736
+ "`set` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
212
737
  );
213
- }))
738
+ return newState;
739
+ }
740
+ return walkTree(newState, appStore.config);
741
+ }
742
+ return __spreadValues(__spreadValues({}, state), action.state(state));
743
+ };
744
+ var removeAction = (state, action, appStore) => {
745
+ const item = getItem({ index: action.index, zone: action.zone }, state);
746
+ const [parentId] = action.zone.split(":");
747
+ const nodesToDelete = Object.entries(state.indexes.nodes).reduce(
748
+ (acc, [nodeId, nodeData]) => {
749
+ const pathIds = nodeData.path.map((p) => p.split(":")[0]);
750
+ if (pathIds.includes(item.props.id)) {
751
+ return [...acc, nodeId];
752
+ }
753
+ return acc;
754
+ },
755
+ [item.props.id]
214
756
  );
215
- });
216
- var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd) {
217
- const configForItem = config.components[item.type];
218
- if (configForItem.resolveData) {
219
- const { item: oldItem = null, resolved = {} } = cache.lastChange[item.props.id] || {};
220
- if (item && item === oldItem) {
221
- return resolved;
757
+ const newState = walkTree(
758
+ state,
759
+ appStore.config,
760
+ (content, zoneCompound) => {
761
+ if (zoneCompound === action.zone) {
762
+ return remove(content, action.index);
763
+ }
764
+ return content;
765
+ },
766
+ (childItem, path) => {
767
+ const parentIds = path.map((p) => p.split(":")[0]);
768
+ if (childItem.props.id === parentId || childItem.props.id === item.props.id || parentIds.indexOf(item.props.id) > -1) {
769
+ return childItem;
770
+ }
771
+ return null;
222
772
  }
223
- const changed = getChanged(item, oldItem);
224
- if (onResolveStart) {
225
- onResolveStart(item);
773
+ );
774
+ Object.keys(newState.data.zones || {}).forEach((zoneCompound) => {
775
+ const parentId2 = zoneCompound.split(":")[0];
776
+ if (nodesToDelete.includes(parentId2) && newState.data.zones) {
777
+ delete newState.data.zones[zoneCompound];
226
778
  }
227
- const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
228
- changed,
229
- lastData: oldItem,
230
- metadata
779
+ });
780
+ Object.keys(newState.indexes.zones).forEach((zoneCompound) => {
781
+ const parentId2 = zoneCompound.split(":")[0];
782
+ if (nodesToDelete.includes(parentId2)) {
783
+ delete newState.indexes.zones[zoneCompound];
784
+ }
785
+ });
786
+ nodesToDelete.forEach((id) => {
787
+ delete newState.indexes.nodes[id];
788
+ });
789
+ return newState;
790
+ };
791
+ function reduce(state, action, appStore) {
792
+ if (action.type === "set") {
793
+ return setAction(state, action, appStore);
794
+ }
795
+ if (action.type === "insert") {
796
+ return insertAction(state, action, appStore.config);
797
+ }
798
+ if (action.type === "replace") {
799
+ return replaceAction(state, action, appStore);
800
+ }
801
+ if (action.type === "replaceRoot") {
802
+ return walkTree(
803
+ state,
804
+ appStore.config,
805
+ (content) => content,
806
+ (childItem) => {
807
+ if (childItem.props.id === "root") {
808
+ return __spreadProps(__spreadValues({}, childItem), {
809
+ props: __spreadValues(__spreadValues({}, childItem.props), action.root.props),
810
+ readOnly: action.root.readOnly
811
+ });
812
+ }
813
+ return childItem;
814
+ }
815
+ );
816
+ }
817
+ if (action.type === "duplicate") {
818
+ const item = getItem(
819
+ { index: action.sourceIndex, zone: action.sourceZone },
820
+ state
821
+ );
822
+ const idsInPath = getIdsForParent(action.sourceZone, state);
823
+ const newItem = __spreadProps(__spreadValues({}, item), {
824
+ props: __spreadProps(__spreadValues({}, item.props), {
825
+ id: generateId(item.type)
826
+ })
231
827
  });
232
- const resolvedItem = __spreadProps(__spreadValues({}, item), {
233
- props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
828
+ const modified = walkTree(
829
+ state,
830
+ appStore.config,
831
+ (content, zoneCompound) => {
832
+ if (zoneCompound === action.sourceZone) {
833
+ return insert(content, action.sourceIndex + 1, item);
834
+ }
835
+ return content;
836
+ },
837
+ (childItem, path, index) => {
838
+ const zoneCompound = path[path.length - 1];
839
+ const parents = path.map((p) => p.split(":")[0]);
840
+ if (parents.indexOf(newItem.props.id) > -1) {
841
+ return __spreadProps(__spreadValues({}, childItem), {
842
+ props: __spreadProps(__spreadValues({}, childItem.props), {
843
+ id: generateId(childItem.type)
844
+ })
845
+ });
846
+ }
847
+ if (zoneCompound === action.sourceZone && index === action.sourceIndex + 1) {
848
+ return newItem;
849
+ }
850
+ const [sourceZoneParent] = action.sourceZone.split(":");
851
+ if (sourceZoneParent === childItem.props.id || idsInPath.indexOf(childItem.props.id) > -1) {
852
+ return childItem;
853
+ }
854
+ return null;
855
+ }
856
+ );
857
+ return __spreadProps(__spreadValues({}, modified), {
858
+ ui: __spreadProps(__spreadValues({}, modified.ui), {
859
+ itemSelector: {
860
+ index: action.sourceIndex + 1,
861
+ zone: action.sourceZone
862
+ }
863
+ })
234
864
  });
235
- if (Object.keys(readOnly).length) {
236
- resolvedItem.readOnly = readOnly;
865
+ }
866
+ if (action.type === "reorder") {
867
+ return moveAction(
868
+ state,
869
+ {
870
+ type: "move",
871
+ sourceIndex: action.sourceIndex,
872
+ sourceZone: action.destinationZone,
873
+ destinationIndex: action.destinationIndex,
874
+ destinationZone: action.destinationZone
875
+ },
876
+ appStore
877
+ );
878
+ }
879
+ if (action.type === "move") {
880
+ return moveAction(state, action, appStore);
881
+ }
882
+ if (action.type === "remove") {
883
+ return removeAction(state, action, appStore);
884
+ }
885
+ if (action.type === "registerZone") {
886
+ if (zoneCache[action.zone]) {
887
+ return __spreadProps(__spreadValues({}, state), {
888
+ data: __spreadProps(__spreadValues({}, state.data), {
889
+ zones: __spreadProps(__spreadValues({}, state.data.zones), {
890
+ [action.zone]: zoneCache[action.zone]
891
+ })
892
+ }),
893
+ indexes: __spreadProps(__spreadValues({}, state.indexes), {
894
+ zones: __spreadProps(__spreadValues({}, state.indexes.zones), {
895
+ [action.zone]: __spreadProps(__spreadValues({}, state.indexes.zones[action.zone]), {
896
+ contentIds: zoneCache[action.zone].map((item) => item.props.id),
897
+ type: "dropzone"
898
+ })
899
+ })
900
+ })
901
+ });
237
902
  }
238
- cache.lastChange[item.props.id] = {
239
- item,
240
- resolved: resolvedItem
241
- };
242
- if (onResolveEnd) {
243
- onResolveEnd(resolvedItem);
903
+ return __spreadProps(__spreadValues({}, state), { data: setupZone(state.data, action.zone) });
904
+ }
905
+ if (action.type === "unregisterZone") {
906
+ const _zones = __spreadValues({}, state.data.zones || {});
907
+ const zoneIndex = __spreadValues({}, state.indexes.zones || {});
908
+ if (_zones[action.zone]) {
909
+ zoneCache[action.zone] = _zones[action.zone];
910
+ delete _zones[action.zone];
244
911
  }
245
- return resolvedItem;
912
+ delete zoneIndex[action.zone];
913
+ return __spreadProps(__spreadValues({}, state), {
914
+ data: __spreadProps(__spreadValues({}, state.data), {
915
+ zones: _zones
916
+ }),
917
+ indexes: __spreadProps(__spreadValues({}, state.indexes), {
918
+ zones: zoneIndex
919
+ })
920
+ });
246
921
  }
247
- return item;
248
- });
249
-
250
- // lib/resolve-root-data.ts
251
- var cache2 = {};
252
- function resolveRootData(data, config, metadata) {
253
- return __async(this, null, function* () {
254
- var _a, _b, _c, _d, _e;
255
- if (((_a = config.root) == null ? void 0 : _a.resolveData) && data.root.props) {
256
- if (((_b = cache2.lastChange) == null ? void 0 : _b.original) === data.root) {
257
- return cache2.lastChange.resolved;
258
- }
259
- const changed = getChanged(data.root, (_c = cache2.lastChange) == null ? void 0 : _c.original);
260
- const rootWithProps = data.root;
261
- const resolvedRoot = yield (_e = config.root) == null ? void 0 : _e.resolveData(rootWithProps, {
262
- changed,
263
- lastData: ((_d = cache2.lastChange) == null ? void 0 : _d.original) || {},
264
- metadata: metadata || {}
265
- });
266
- cache2.lastChange = {
267
- original: data.root,
268
- resolved: resolvedRoot
269
- };
270
- return __spreadProps(__spreadValues(__spreadValues({}, data.root), resolvedRoot), {
271
- props: __spreadValues(__spreadValues({}, data.root.props), resolvedRoot.props)
922
+ if (action.type === "setData") {
923
+ if (typeof action.data === "object") {
924
+ console.warn(
925
+ "`setData` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
926
+ );
927
+ return walkTree(
928
+ __spreadProps(__spreadValues({}, state), {
929
+ data: __spreadValues(__spreadValues({}, state.data), action.data)
930
+ }),
931
+ appStore.config
932
+ );
933
+ }
934
+ return walkTree(
935
+ __spreadProps(__spreadValues({}, state), {
936
+ data: __spreadValues(__spreadValues({}, state.data), action.data(state.data))
937
+ }),
938
+ appStore.config
939
+ );
940
+ }
941
+ if (action.type === "setUi") {
942
+ if (typeof action.ui === "object") {
943
+ return __spreadProps(__spreadValues({}, state), {
944
+ ui: __spreadValues(__spreadValues({}, state.ui), action.ui)
272
945
  });
273
946
  }
274
- return data.root;
275
- });
947
+ return __spreadProps(__spreadValues({}, state), {
948
+ ui: __spreadValues(__spreadValues({}, state.ui), action.ui(state.ui))
949
+ });
950
+ }
951
+ return state;
276
952
  }
277
953
 
278
- // lib/default-data.ts
279
- var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
280
- root: data.root || {},
281
- content: data.content || []
282
- });
954
+ // reducer/actions.tsx
955
+ init_react_import();
283
956
 
284
- // lib/resolve-all-data.ts
285
- function resolveAllData(_0, _1) {
286
- return __async(this, arguments, function* (data, config, metadata = {}, onResolveStart, onResolveEnd) {
287
- const defaultedData = defaultData(data);
288
- const dynamicRoot = yield resolveRootData(
289
- defaultedData,
290
- config,
291
- metadata
292
- );
293
- const { zones = {} } = data;
294
- const zoneKeys = Object.keys(zones);
295
- const resolvedZones = {};
296
- for (let i = 0; i < zoneKeys.length; i++) {
297
- const zoneKey = zoneKeys[i];
298
- resolvedZones[zoneKey] = yield resolveAllComponentData(
299
- zones[zoneKey],
300
- config,
301
- metadata,
302
- onResolveStart,
303
- onResolveEnd
304
- );
957
+ // reducer/index.ts
958
+ function storeInterceptor(reducer, record, onAction) {
959
+ return (state, action) => {
960
+ const newAppState = reducer(state, action);
961
+ const isValidType = ![
962
+ "registerZone",
963
+ "unregisterZone",
964
+ "setData",
965
+ "setUi",
966
+ "set"
967
+ ].includes(action.type);
968
+ if (typeof action.recordHistory !== "undefined" ? action.recordHistory : isValidType) {
969
+ if (record) record(newAppState);
305
970
  }
306
- return __spreadProps(__spreadValues({}, defaultedData), {
307
- root: dynamicRoot,
308
- content: yield resolveAllComponentData(
309
- defaultedData.content,
310
- config,
311
- metadata,
312
- onResolveStart,
313
- onResolveEnd
314
- ),
315
- zones: resolvedZones
316
- });
317
- });
971
+ onAction == null ? void 0 : onAction(action, newAppState, state);
972
+ return newAppState;
973
+ };
318
974
  }
319
- // Annotate the CommonJS export names for ESM import in node:
320
- 0 && (module.exports = {
321
- Render,
322
- resolveAllData
323
- });
975
+ function createReducer({
976
+ record,
977
+ onAction,
978
+ appStore
979
+ }) {
980
+ return storeInterceptor(
981
+ (state, action) => {
982
+ const result = reduce(state, action, appStore);
983
+ return result;
984
+ },
985
+ record,
986
+ onAction
987
+ );
988
+ }
989
+
990
+ // components/ViewportControls/default-viewports.ts
991
+ init_react_import();
992
+ var defaultViewports = [
993
+ { width: 360, height: "auto", icon: "Smartphone", label: "Small" },
994
+ { width: 768, height: "auto", icon: "Tablet", label: "Medium" },
995
+ { width: 1280, height: "auto", icon: "Monitor", label: "Large" }
996
+ ];
997
+
998
+ // store/index.ts
999
+ var import_zustand2 = require("zustand");
1000
+ var import_middleware2 = require("zustand/middleware");
1001
+ var import_react9 = require("react");
1002
+
1003
+ // store/slices/history.ts
1004
+ init_react_import();
1005
+ var import_react6 = require("react");
1006
+
1007
+ // lib/use-hotkey.ts
1008
+ init_react_import();
1009
+ var import_react5 = require("react");
1010
+ var import_zustand = require("zustand");
1011
+ var import_middleware = require("zustand/middleware");
1012
+ var useHotkeyStore = (0, import_zustand.create)()(
1013
+ (0, import_middleware.subscribeWithSelector)((set) => ({
1014
+ held: {},
1015
+ hold: (key) => set((s) => s.held[key] ? s : { held: __spreadProps(__spreadValues({}, s.held), { [key]: true }) }),
1016
+ release: (key) => set((s) => s.held[key] ? { held: __spreadProps(__spreadValues({}, s.held), { [key]: false }) } : s),
1017
+ reset: (held = {}) => set(() => ({ held })),
1018
+ triggers: {}
1019
+ }))
1020
+ );
1021
+
1022
+ // store/slices/history.ts
1023
+ var EMPTY_HISTORY_INDEX = 0;
1024
+ function debounce(func, timeout2 = 300) {
1025
+ let timer;
1026
+ return (...args) => {
1027
+ clearTimeout(timer);
1028
+ timer = setTimeout(() => {
1029
+ func(...args);
1030
+ }, timeout2);
1031
+ };
1032
+ }
1033
+ var tidyState = (state) => {
1034
+ return __spreadProps(__spreadValues({}, state), {
1035
+ ui: __spreadProps(__spreadValues({}, state.ui), {
1036
+ field: {
1037
+ focus: null
1038
+ }
1039
+ })
1040
+ });
1041
+ };
1042
+ var createHistorySlice = (set, get) => {
1043
+ const record = debounce((state) => {
1044
+ const { histories, index } = get().history;
1045
+ const history = {
1046
+ state,
1047
+ id: generateId("history")
1048
+ };
1049
+ const newHistories = [...histories.slice(0, index + 1), history];
1050
+ set({
1051
+ history: __spreadProps(__spreadValues({}, get().history), {
1052
+ histories: newHistories,
1053
+ index: newHistories.length - 1
1054
+ })
1055
+ });
1056
+ }, 250);
1057
+ return {
1058
+ initialAppState: {},
1059
+ index: EMPTY_HISTORY_INDEX,
1060
+ histories: [],
1061
+ hasPast: () => get().history.index > EMPTY_HISTORY_INDEX,
1062
+ hasFuture: () => get().history.index < get().history.histories.length - 1,
1063
+ prevHistory: () => {
1064
+ const { history } = get();
1065
+ return history.hasPast() ? history.histories[history.index - 1] : null;
1066
+ },
1067
+ nextHistory: () => {
1068
+ const s = get().history;
1069
+ return s.hasFuture() ? s.histories[s.index + 1] : null;
1070
+ },
1071
+ currentHistory: () => get().history.histories[get().history.index],
1072
+ back: () => {
1073
+ var _a;
1074
+ const { history, dispatch } = get();
1075
+ if (history.hasPast()) {
1076
+ const state = tidyState(
1077
+ ((_a = history.prevHistory()) == null ? void 0 : _a.state) || history.initialAppState
1078
+ );
1079
+ dispatch({
1080
+ type: "set",
1081
+ state
1082
+ });
1083
+ set({ history: __spreadProps(__spreadValues({}, history), { index: history.index - 1 }) });
1084
+ }
1085
+ },
1086
+ forward: () => {
1087
+ var _a;
1088
+ const { history, dispatch } = get();
1089
+ if (history.hasFuture()) {
1090
+ const state = (_a = history.nextHistory()) == null ? void 0 : _a.state;
1091
+ dispatch({ type: "set", state: state ? tidyState(state) : {} });
1092
+ set({ history: __spreadProps(__spreadValues({}, history), { index: history.index + 1 }) });
1093
+ }
1094
+ },
1095
+ setHistories: (histories) => {
1096
+ var _a;
1097
+ const { dispatch, history } = get();
1098
+ dispatch({
1099
+ type: "set",
1100
+ state: ((_a = history.histories[history.histories.length - 1]) == null ? void 0 : _a.state) || history.initialAppState
1101
+ });
1102
+ set({ history: __spreadProps(__spreadValues({}, history), { histories, index: histories.length - 1 }) });
1103
+ },
1104
+ setHistoryIndex: (index) => {
1105
+ var _a;
1106
+ const { dispatch, history } = get();
1107
+ dispatch({
1108
+ type: "set",
1109
+ state: ((_a = history.histories[history.index]) == null ? void 0 : _a.state) || history.initialAppState
1110
+ });
1111
+ set({ history: __spreadProps(__spreadValues({}, history), { index }) });
1112
+ },
1113
+ record
1114
+ };
1115
+ };
1116
+
1117
+ // store/slices/nodes.ts
1118
+ init_react_import();
1119
+ var createNodesSlice = (set, get) => ({
1120
+ nodes: {},
1121
+ registerNode: (id, node) => {
1122
+ const s = get().nodes;
1123
+ const emptyNode = {
1124
+ id,
1125
+ methods: { sync: () => null },
1126
+ element: null
1127
+ };
1128
+ const existingNode = s.nodes[id];
1129
+ set({
1130
+ nodes: __spreadProps(__spreadValues({}, s), {
1131
+ nodes: __spreadProps(__spreadValues({}, s.nodes), {
1132
+ [id]: __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, emptyNode), existingNode), node), {
1133
+ id
1134
+ })
1135
+ })
1136
+ })
1137
+ });
1138
+ },
1139
+ unregisterNode: (id) => {
1140
+ const s = get().nodes;
1141
+ const existingNode = s.nodes[id];
1142
+ if (existingNode) {
1143
+ const newNodes = __spreadValues({}, s.nodes);
1144
+ delete newNodes[id];
1145
+ set({
1146
+ nodes: __spreadProps(__spreadValues({}, s), {
1147
+ nodes: newNodes
1148
+ })
1149
+ });
1150
+ }
1151
+ }
1152
+ });
1153
+
1154
+ // store/slices/permissions.ts
1155
+ init_react_import();
1156
+ var import_react7 = require("react");
1157
+
1158
+ // lib/flatten-data.ts
1159
+ init_react_import();
1160
+ var flattenData = (state, config) => {
1161
+ const data = [];
1162
+ walkTree(
1163
+ state,
1164
+ config,
1165
+ (content) => content,
1166
+ (item) => {
1167
+ data.push(item);
1168
+ return null;
1169
+ }
1170
+ );
1171
+ return data;
1172
+ };
1173
+
1174
+ // lib/get-changed.ts
1175
+ init_react_import();
1176
+ var getChanged = (newItem, oldItem) => {
1177
+ return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
1178
+ const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
1179
+ const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
1180
+ return __spreadProps(__spreadValues({}, acc), {
1181
+ [item]: oldItemProps[item] !== newItemProps[item]
1182
+ });
1183
+ }, {}) : {};
1184
+ };
1185
+
1186
+ // store/slices/permissions.ts
1187
+ var createPermissionsSlice = (set, get) => {
1188
+ const resolvePermissions = (..._0) => __async(void 0, [..._0], function* (params = {}, force) {
1189
+ const { state, permissions, config } = get();
1190
+ const { cache: cache2, globalPermissions } = permissions;
1191
+ const resolveDataForItem = (item2, force2 = false) => __async(void 0, null, function* () {
1192
+ var _a, _b, _c;
1193
+ const {
1194
+ config: config2,
1195
+ state: appState,
1196
+ setComponentLoading,
1197
+ unsetComponentLoading
1198
+ } = get();
1199
+ const componentConfig = item2.type === "root" ? config2.root : config2.components[item2.type];
1200
+ if (!componentConfig) {
1201
+ return;
1202
+ }
1203
+ const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig.permissions);
1204
+ if (componentConfig.resolvePermissions) {
1205
+ const changed = getChanged(item2, (_a = cache2[item2.props.id]) == null ? void 0 : _a.lastData);
1206
+ if (Object.values(changed).some((el) => el === true) || force2) {
1207
+ setComponentLoading(item2.props.id);
1208
+ const resolvedPermissions = yield componentConfig.resolvePermissions(
1209
+ item2,
1210
+ {
1211
+ changed,
1212
+ lastPermissions: ((_b = cache2[item2.props.id]) == null ? void 0 : _b.lastPermissions) || null,
1213
+ permissions: initialPermissions,
1214
+ appState,
1215
+ lastData: ((_c = cache2[item2.props.id]) == null ? void 0 : _c.lastData) || null
1216
+ }
1217
+ );
1218
+ const latest = get().permissions;
1219
+ set({
1220
+ permissions: __spreadProps(__spreadValues({}, latest), {
1221
+ cache: __spreadProps(__spreadValues({}, latest.cache), {
1222
+ [item2.props.id]: {
1223
+ lastData: item2,
1224
+ lastPermissions: resolvedPermissions
1225
+ }
1226
+ }),
1227
+ resolvedPermissions: __spreadProps(__spreadValues({}, latest.resolvedPermissions), {
1228
+ [item2.props.id]: resolvedPermissions
1229
+ })
1230
+ })
1231
+ });
1232
+ unsetComponentLoading(item2.props.id);
1233
+ }
1234
+ }
1235
+ });
1236
+ const resolveDataForRoot = (force2 = false) => {
1237
+ const { state: appState } = get();
1238
+ resolveDataForItem(
1239
+ // Shim the root data in by conforming to component data shape
1240
+ {
1241
+ type: "root",
1242
+ props: __spreadProps(__spreadValues({}, appState.data.root.props), { id: "puck-root" })
1243
+ },
1244
+ force2
1245
+ );
1246
+ };
1247
+ const { item, type, root } = params;
1248
+ if (item) {
1249
+ yield resolveDataForItem(item, force);
1250
+ } else if (type) {
1251
+ flattenData(state, config).filter((item2) => item2.type === type).map((item2) => __async(void 0, null, function* () {
1252
+ yield resolveDataForItem(item2, force);
1253
+ }));
1254
+ } else if (root) {
1255
+ resolveDataForRoot(force);
1256
+ } else {
1257
+ resolveDataForRoot(force);
1258
+ flattenData(state, config).map((item2) => __async(void 0, null, function* () {
1259
+ yield resolveDataForItem(item2, force);
1260
+ }));
1261
+ }
1262
+ });
1263
+ const refreshPermissions = (params) => resolvePermissions(params, true);
1264
+ return {
1265
+ cache: {},
1266
+ globalPermissions: {
1267
+ drag: true,
1268
+ edit: true,
1269
+ delete: true,
1270
+ duplicate: true,
1271
+ insert: true
1272
+ },
1273
+ resolvedPermissions: {},
1274
+ getPermissions: ({ item, type, root } = {}) => {
1275
+ const { config, permissions } = get();
1276
+ const { globalPermissions, resolvedPermissions } = permissions;
1277
+ if (item) {
1278
+ const componentConfig = config.components[item.type];
1279
+ const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig == null ? void 0 : componentConfig.permissions);
1280
+ const resolvedForItem = resolvedPermissions[item.props.id];
1281
+ return resolvedForItem ? __spreadValues(__spreadValues({}, globalPermissions), resolvedForItem) : initialPermissions;
1282
+ } else if (type) {
1283
+ const componentConfig = config.components[type];
1284
+ return __spreadValues(__spreadValues({}, globalPermissions), componentConfig == null ? void 0 : componentConfig.permissions);
1285
+ } else if (root) {
1286
+ const rootConfig = config.root;
1287
+ const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), rootConfig == null ? void 0 : rootConfig.permissions);
1288
+ const resolvedForItem = resolvedPermissions["puck-root"];
1289
+ return resolvedForItem ? __spreadValues(__spreadValues({}, globalPermissions), resolvedForItem) : initialPermissions;
1290
+ }
1291
+ return globalPermissions;
1292
+ },
1293
+ resolvePermissions,
1294
+ refreshPermissions
1295
+ };
1296
+ };
1297
+
1298
+ // store/slices/fields.ts
1299
+ init_react_import();
1300
+ var import_react8 = require("react");
1301
+ var createFieldsSlice = (_set, _get) => {
1302
+ return {
1303
+ fields: {},
1304
+ loading: false,
1305
+ lastResolvedData: {}
1306
+ };
1307
+ };
1308
+
1309
+ // lib/resolve-component-data.ts
1310
+ init_react_import();
1311
+
1312
+ // lib/map-slots.ts
1313
+ init_react_import();
1314
+ function mapSlots(item, map, recursive = true, isSlot2) {
1315
+ return __async(this, null, function* () {
1316
+ const props = __spreadValues({}, item.props);
1317
+ yield forEachSlot(
1318
+ item,
1319
+ (_parentId, propName, content) => __async(this, null, function* () {
1320
+ const mappedContent = recursive ? yield Promise.all(
1321
+ content.map((item2) => __async(this, null, function* () {
1322
+ return yield mapSlots(item2, map, recursive, isSlot2);
1323
+ }))
1324
+ ) : content;
1325
+ props[propName] = yield map(mappedContent, propName);
1326
+ }),
1327
+ false,
1328
+ isSlot2
1329
+ );
1330
+ return __spreadProps(__spreadValues({}, item), { props });
1331
+ });
1332
+ }
1333
+
1334
+ // lib/resolve-component-data.ts
1335
+ var import_fast_deep_equal = __toESM(require("fast-deep-equal"));
1336
+ var cache = { lastChange: {} };
1337
+ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace", recursive = true) {
1338
+ const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
1339
+ if ((configForItem == null ? void 0 : configForItem.resolveData) && item.props) {
1340
+ const id = "id" in item.props ? item.props.id : "root";
1341
+ const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
1342
+ if (item && (0, import_fast_deep_equal.default)(item, oldItem)) {
1343
+ return { node: resolved, didChange: false };
1344
+ }
1345
+ const changed = getChanged(item, oldItem);
1346
+ if (onResolveStart) {
1347
+ onResolveStart(item);
1348
+ }
1349
+ const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
1350
+ changed,
1351
+ lastData: oldItem,
1352
+ metadata,
1353
+ trigger
1354
+ });
1355
+ let resolvedItem = __spreadProps(__spreadValues({}, item), {
1356
+ props: __spreadValues(__spreadValues({}, item.props), resolvedProps)
1357
+ });
1358
+ if (recursive) {
1359
+ resolvedItem = yield mapSlots(
1360
+ resolvedItem,
1361
+ (content) => __async(void 0, null, function* () {
1362
+ return Promise.all(
1363
+ content.map(
1364
+ (childItem) => __async(void 0, null, function* () {
1365
+ return (yield resolveComponentData(
1366
+ childItem,
1367
+ config,
1368
+ metadata,
1369
+ onResolveStart,
1370
+ onResolveEnd,
1371
+ trigger,
1372
+ false
1373
+ )).node;
1374
+ })
1375
+ )
1376
+ );
1377
+ }),
1378
+ false,
1379
+ createIsSlotConfig(config)
1380
+ );
1381
+ }
1382
+ if (Object.keys(readOnly).length) {
1383
+ resolvedItem.readOnly = readOnly;
1384
+ }
1385
+ cache.lastChange[id] = {
1386
+ item,
1387
+ resolved: resolvedItem
1388
+ };
1389
+ if (onResolveEnd) {
1390
+ onResolveEnd(resolvedItem);
1391
+ }
1392
+ return { node: resolvedItem, didChange: !(0, import_fast_deep_equal.default)(item, resolvedItem) };
1393
+ }
1394
+ return { node: item, didChange: false };
1395
+ });
1396
+
1397
+ // lib/to-root.ts
1398
+ init_react_import();
1399
+ var toRoot = (item) => {
1400
+ if ("type" in item && item.type !== "root") {
1401
+ throw new Error("Converting non-root item to root.");
1402
+ }
1403
+ const { readOnly } = item;
1404
+ if (item.props) {
1405
+ if ("id" in item.props) {
1406
+ const _a = item.props, { id } = _a, props = __objRest(_a, ["id"]);
1407
+ return { props, readOnly };
1408
+ }
1409
+ return { props: item.props, readOnly };
1410
+ }
1411
+ return { props: {}, readOnly };
1412
+ };
1413
+
1414
+ // store/index.ts
1415
+ var defaultAppState = {
1416
+ data: { content: [], root: {}, zones: {} },
1417
+ ui: {
1418
+ leftSideBarVisible: true,
1419
+ rightSideBarVisible: true,
1420
+ arrayState: {},
1421
+ itemSelector: null,
1422
+ componentList: {},
1423
+ isDragging: false,
1424
+ previewMode: "edit",
1425
+ viewports: {
1426
+ current: {
1427
+ width: defaultViewports[0].width,
1428
+ height: defaultViewports[0].height || "auto"
1429
+ },
1430
+ options: [],
1431
+ controlsVisible: true
1432
+ },
1433
+ field: { focus: null }
1434
+ },
1435
+ indexes: {
1436
+ nodes: {},
1437
+ zones: {}
1438
+ }
1439
+ };
1440
+ var defaultPageFields = {
1441
+ title: { type: "text" }
1442
+ };
1443
+ var createAppStore = (initialAppStore) => (0, import_zustand2.create)()(
1444
+ (0, import_middleware2.subscribeWithSelector)((set, get) => __spreadProps(__spreadValues({
1445
+ state: defaultAppState,
1446
+ config: { components: {} },
1447
+ componentState: {},
1448
+ plugins: [],
1449
+ overrides: {},
1450
+ viewports: defaultViewports,
1451
+ zoomConfig: {
1452
+ autoZoom: 1,
1453
+ rootHeight: 0,
1454
+ zoom: 1
1455
+ },
1456
+ status: "LOADING",
1457
+ iframe: {},
1458
+ metadata: {}
1459
+ }, initialAppStore), {
1460
+ fields: createFieldsSlice(set, get),
1461
+ history: createHistorySlice(set, get),
1462
+ nodes: createNodesSlice(set, get),
1463
+ permissions: createPermissionsSlice(set, get),
1464
+ getComponentConfig: (type) => {
1465
+ var _a;
1466
+ const { config, selectedItem } = get();
1467
+ const rootFields = ((_a = config.root) == null ? void 0 : _a.fields) || defaultPageFields;
1468
+ return type && type !== "root" ? config.components[type] : selectedItem ? config.components[selectedItem.type] : __spreadProps(__spreadValues({}, config.root), { fields: rootFields });
1469
+ },
1470
+ dispatch: (action) => set((s) => {
1471
+ var _a, _b;
1472
+ const { record } = get().history;
1473
+ const dispatch = createReducer({
1474
+ record,
1475
+ appStore: s
1476
+ });
1477
+ const state = dispatch(s.state, action);
1478
+ const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
1479
+ (_b = (_a = get()).onAction) == null ? void 0 : _b.call(_a, action, state, get().state);
1480
+ return __spreadProps(__spreadValues({}, s), { state, selectedItem });
1481
+ }),
1482
+ setZoomConfig: (zoomConfig) => set({ zoomConfig }),
1483
+ setStatus: (status) => set({ status }),
1484
+ setComponentState: (componentState) => set({ componentState }),
1485
+ pendingComponentLoads: {},
1486
+ setComponentLoading: (id, loading = true, defer = 0) => {
1487
+ const { setComponentState, pendingComponentLoads } = get();
1488
+ const thisPendingComponentLoads = __spreadValues({}, pendingComponentLoads);
1489
+ const setLoading = () => {
1490
+ var _a;
1491
+ const { componentState } = get();
1492
+ setComponentState(__spreadProps(__spreadValues({}, componentState), {
1493
+ [id]: __spreadProps(__spreadValues({}, componentState[id]), {
1494
+ loadingCount: (((_a = componentState[id]) == null ? void 0 : _a.loadingCount) || 0) + 1
1495
+ })
1496
+ }));
1497
+ };
1498
+ const unsetLoading = () => {
1499
+ var _a;
1500
+ const { componentState } = get();
1501
+ setComponentState(__spreadProps(__spreadValues({}, componentState), {
1502
+ [id]: __spreadProps(__spreadValues({}, componentState[id]), {
1503
+ loadingCount: Math.max(
1504
+ (((_a = componentState[id]) == null ? void 0 : _a.loadingCount) || 0) - 1,
1505
+ 0
1506
+ )
1507
+ })
1508
+ }));
1509
+ };
1510
+ if (thisPendingComponentLoads[id]) {
1511
+ clearTimeout(thisPendingComponentLoads[id]);
1512
+ delete thisPendingComponentLoads[id];
1513
+ set({ pendingComponentLoads: thisPendingComponentLoads });
1514
+ }
1515
+ const timeout2 = setTimeout(() => {
1516
+ if (loading) {
1517
+ setLoading();
1518
+ } else {
1519
+ unsetLoading();
1520
+ }
1521
+ delete thisPendingComponentLoads[id];
1522
+ set({ pendingComponentLoads: thisPendingComponentLoads });
1523
+ }, defer);
1524
+ set({
1525
+ pendingComponentLoads: __spreadProps(__spreadValues({}, thisPendingComponentLoads), {
1526
+ [id]: timeout2
1527
+ })
1528
+ });
1529
+ },
1530
+ unsetComponentLoading: (id) => {
1531
+ const { setComponentLoading } = get();
1532
+ setComponentLoading(id, false);
1533
+ },
1534
+ // Helper
1535
+ setUi: (ui, recordHistory) => set((s) => {
1536
+ const dispatch = createReducer({
1537
+ record: () => {
1538
+ },
1539
+ appStore: s
1540
+ });
1541
+ const state = dispatch(s.state, {
1542
+ type: "setUi",
1543
+ ui,
1544
+ recordHistory
1545
+ });
1546
+ const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
1547
+ return __spreadProps(__spreadValues({}, s), { state, selectedItem });
1548
+ }),
1549
+ resolveComponentData: (componentData, trigger) => __async(void 0, null, function* () {
1550
+ const { config, metadata, setComponentLoading } = get();
1551
+ return yield resolveComponentData(
1552
+ componentData,
1553
+ config,
1554
+ metadata,
1555
+ (item) => setComponentLoading(
1556
+ "id" in item.props ? item.props.id : "root",
1557
+ true,
1558
+ 50
1559
+ ),
1560
+ (item) => setComponentLoading(
1561
+ "id" in item.props ? item.props.id : "root",
1562
+ false,
1563
+ 0
1564
+ ),
1565
+ trigger
1566
+ );
1567
+ }),
1568
+ resolveAndCommitData: () => __async(void 0, null, function* () {
1569
+ const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
1570
+ walkTree(
1571
+ state,
1572
+ config,
1573
+ (content) => content,
1574
+ (childItem) => {
1575
+ resolveComponentData2(childItem, "load").then((resolved) => {
1576
+ const { state: state2 } = get();
1577
+ const node = state2.indexes.nodes[resolved.node.props.id];
1578
+ if (node && resolved.didChange) {
1579
+ if (resolved.node.props.id === "root") {
1580
+ dispatch({
1581
+ type: "replaceRoot",
1582
+ root: toRoot(resolved.node)
1583
+ });
1584
+ } else {
1585
+ const zoneCompound = `${node.parentId}:${node.zone}`;
1586
+ const parentZone = state2.indexes.zones[zoneCompound];
1587
+ const index = parentZone.contentIds.indexOf(
1588
+ resolved.node.props.id
1589
+ );
1590
+ dispatch({
1591
+ type: "replace",
1592
+ data: resolved.node,
1593
+ destinationIndex: index,
1594
+ destinationZone: zoneCompound
1595
+ });
1596
+ }
1597
+ }
1598
+ });
1599
+ return childItem;
1600
+ }
1601
+ );
1602
+ })
1603
+ }))
1604
+ );
1605
+ var appStoreContext = (0, import_react9.createContext)(createAppStore());
1606
+ function useAppStore(selector) {
1607
+ const context = (0, import_react9.useContext)(appStoreContext);
1608
+ return (0, import_zustand2.useStore)(context, selector);
1609
+ }
1610
+ function useAppStoreApi() {
1611
+ return (0, import_react9.useContext)(appStoreContext);
1612
+ }
1613
+
1614
+ // components/Loader/index.tsx
1615
+ init_react_import();
1616
+
1617
+ // lib/index.ts
1618
+ init_react_import();
1619
+
1620
+ // lib/filter.ts
1621
+ init_react_import();
1622
+
1623
+ // lib/reorder.ts
1624
+ init_react_import();
1625
+
1626
+ // lib/replace.ts
1627
+ init_react_import();
1628
+
1629
+ // css-module:/home/runner/work/puck/puck/packages/core/components/Loader/styles.module.css#css-module
1630
+ init_react_import();
1631
+ var styles_module_default2 = { "Loader": "_Loader_nacdm_13", "loader-animation": "_loader-animation_nacdm_1" };
1632
+
1633
+ // components/Loader/index.tsx
1634
+ var import_jsx_runtime = require("react/jsx-runtime");
1635
+ var getClassName = get_class_name_factory_default("Loader", styles_module_default2);
1636
+ var Loader = (_a) => {
1637
+ var _b = _a, {
1638
+ color,
1639
+ size = 16
1640
+ } = _b, props = __objRest(_b, [
1641
+ "color",
1642
+ "size"
1643
+ ]);
1644
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1645
+ "span",
1646
+ __spreadValues({
1647
+ className: getClassName(),
1648
+ style: {
1649
+ width: size,
1650
+ height: size,
1651
+ color
1652
+ },
1653
+ "aria-label": "loading"
1654
+ }, props)
1655
+ );
1656
+ };
1657
+
1658
+ // components/ActionBar/index.tsx
1659
+ init_react_import();
1660
+
1661
+ // css-module:/home/runner/work/puck/puck/packages/core/components/ActionBar/styles.module.css#css-module
1662
+ init_react_import();
1663
+ var styles_module_default3 = { "ActionBar": "_ActionBar_rvadt_1", "ActionBar-label": "_ActionBar-label_rvadt_18", "ActionBar-action": "_ActionBar-action_rvadt_30", "ActionBar-group": "_ActionBar-group_rvadt_38" };
1664
+
1665
+ // components/ActionBar/index.tsx
1666
+ var import_jsx_runtime2 = require("react/jsx-runtime");
1667
+ var getClassName2 = get_class_name_factory_default("ActionBar", styles_module_default3);
1668
+ var ActionBar = ({
1669
+ label,
1670
+ children
1671
+ }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
1672
+ "div",
1673
+ {
1674
+ className: getClassName2(),
1675
+ onClick: (e) => {
1676
+ e.stopPropagation();
1677
+ },
1678
+ children: [
1679
+ label && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ActionBar.Group, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: getClassName2("label"), children: label }) }),
1680
+ children
1681
+ ]
1682
+ }
1683
+ );
1684
+ var Action = ({
1685
+ children,
1686
+ label,
1687
+ onClick
1688
+ }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1689
+ "button",
1690
+ {
1691
+ type: "button",
1692
+ className: getClassName2("action"),
1693
+ onClick,
1694
+ title: label,
1695
+ children
1696
+ }
1697
+ );
1698
+ var Group = ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: getClassName2("group"), children });
1699
+ var Label = ({ label }) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: getClassName2("label"), children: label });
1700
+ ActionBar.Action = Action;
1701
+ ActionBar.Label = Label;
1702
+ ActionBar.Group = Group;
1703
+
1704
+ // components/DraggableComponent/index.tsx
1705
+ var import_react_dom = require("react-dom");
1706
+
1707
+ // lib/dnd/collision/dynamic/index.ts
1708
+ init_react_import();
1709
+ var import_abstract8 = require("@dnd-kit/abstract");
1710
+
1711
+ // lib/dnd/collision/directional/index.ts
1712
+ init_react_import();
1713
+ var import_abstract = require("@dnd-kit/abstract");
1714
+
1715
+ // lib/dnd/collision/collision-debug.ts
1716
+ init_react_import();
1717
+ var DEBUG = false;
1718
+ var debugElements = {};
1719
+ var timeout;
1720
+ var collisionDebug = (a, b, id, color, label) => {
1721
+ if (!DEBUG) return;
1722
+ const debugId = `${id}-debug`;
1723
+ clearTimeout(timeout);
1724
+ timeout = setTimeout(() => {
1725
+ Object.entries(debugElements).forEach(([id2, { svg }]) => {
1726
+ svg.remove();
1727
+ delete debugElements[id2];
1728
+ });
1729
+ }, 1e3);
1730
+ requestAnimationFrame(() => {
1731
+ var _a, _b;
1732
+ const existingEl = debugElements[debugId];
1733
+ let line = (_a = debugElements[debugId]) == null ? void 0 : _a.line;
1734
+ let text = (_b = debugElements[debugId]) == null ? void 0 : _b.text;
1735
+ if (!existingEl) {
1736
+ const svgNs = "http://www.w3.org/2000/svg";
1737
+ const svg = document.createElementNS(svgNs, "svg");
1738
+ line = document.createElementNS(svgNs, "line");
1739
+ text = document.createElementNS(svgNs, "text");
1740
+ svg.setAttribute("id", debugId);
1741
+ svg.setAttribute(
1742
+ "style",
1743
+ "position: fixed; height: 100%; width: 100%; pointer-events: none; top: 0px; left: 0px;"
1744
+ );
1745
+ svg.appendChild(line);
1746
+ svg.appendChild(text);
1747
+ text.setAttribute("fill", `black`);
1748
+ document.body.appendChild(svg);
1749
+ debugElements[debugId] = { svg, line, text };
1750
+ }
1751
+ line.setAttribute("x1", a.x.toString());
1752
+ line.setAttribute("x2", b.x.toString());
1753
+ line.setAttribute("y1", a.y.toString());
1754
+ line.setAttribute("y2", b.y.toString());
1755
+ line.setAttribute("style", `stroke:${color};stroke-width:2`);
1756
+ text.setAttribute("x", (a.x - (a.x - b.x) / 2).toString());
1757
+ text.setAttribute("y", (a.y - (a.y - b.y) / 2).toString());
1758
+ if (label) {
1759
+ text.innerHTML = label;
1760
+ }
1761
+ });
1762
+ };
1763
+
1764
+ // lib/dnd/collision/directional/index.ts
1765
+ var distanceChange = "increasing";
1766
+ var directionalCollision = (input, previous) => {
1767
+ var _a;
1768
+ const { dragOperation, droppable } = input;
1769
+ const { shape: dropShape } = droppable;
1770
+ const { position } = dragOperation;
1771
+ const dragShape = (_a = dragOperation.shape) == null ? void 0 : _a.current;
1772
+ if (!dragShape || !dropShape) return null;
1773
+ const dropCenter = dropShape.center;
1774
+ const distanceToPrevious = Math.sqrt(
1775
+ Math.pow(dropCenter.x - previous.x, 2) + Math.pow(dropCenter.y - previous.y, 2)
1776
+ );
1777
+ const distanceToCurrent = Math.sqrt(
1778
+ Math.pow(dropCenter.x - position.current.x, 2) + Math.pow(dropCenter.y - position.current.y, 2)
1779
+ );
1780
+ distanceChange = distanceToCurrent === distanceToPrevious ? distanceChange : distanceToCurrent < distanceToPrevious ? "decreasing" : "increasing";
1781
+ collisionDebug(
1782
+ dragShape.center,
1783
+ dropCenter,
1784
+ droppable.id.toString(),
1785
+ "rebeccapurple"
1786
+ );
1787
+ if (distanceChange === "decreasing") {
1788
+ return {
1789
+ id: droppable.id,
1790
+ value: 1,
1791
+ type: import_abstract.CollisionType.Collision
1792
+ };
1793
+ }
1794
+ return null;
1795
+ };
1796
+
1797
+ // lib/dnd/collision/dynamic/get-direction.ts
1798
+ init_react_import();
1799
+ var getDirection = (dragAxis, delta) => {
1800
+ if (dragAxis === "dynamic") {
1801
+ if (Math.abs(delta.y) > Math.abs(delta.x)) {
1802
+ return delta.y === 0 ? null : delta.y > 0 ? "down" : "up";
1803
+ } else {
1804
+ return delta.x === 0 ? null : delta.x > 0 ? "right" : "left";
1805
+ }
1806
+ } else if (dragAxis === "x") {
1807
+ return delta.x === 0 ? null : delta.x > 0 ? "right" : "left";
1808
+ }
1809
+ return delta.y === 0 ? null : delta.y > 0 ? "down" : "up";
1810
+ };
1811
+
1812
+ // lib/dnd/collision/dynamic/get-midpoint-impact.ts
1813
+ init_react_import();
1814
+ var getMidpointImpact = (dragShape, dropShape, direction, offsetMultiplier = 0) => {
1815
+ const dragRect = dragShape.boundingRectangle;
1816
+ const dropCenter = dropShape.center;
1817
+ if (direction === "down") {
1818
+ const offset2 = offsetMultiplier * dropShape.boundingRectangle.height;
1819
+ return dragRect.bottom >= dropCenter.y + offset2;
1820
+ } else if (direction === "up") {
1821
+ const offset2 = offsetMultiplier * dropShape.boundingRectangle.height;
1822
+ return dragRect.top < dropCenter.y - offset2;
1823
+ } else if (direction === "left") {
1824
+ const offset2 = offsetMultiplier * dropShape.boundingRectangle.width;
1825
+ return dropCenter.x - offset2 >= dragRect.left;
1826
+ }
1827
+ const offset = offsetMultiplier * dropShape.boundingRectangle.width;
1828
+ return dragRect.right - offset >= dropCenter.x;
1829
+ };
1830
+
1831
+ // lib/dnd/collision/dynamic/track-movement-interval.ts
1832
+ init_react_import();
1833
+ var import_geometry = require("@dnd-kit/geometry");
1834
+ var INTERVAL_SENSITIVITY = 10;
1835
+ var intervalCache = {
1836
+ current: { x: 0, y: 0 },
1837
+ delta: { x: 0, y: 0 },
1838
+ previous: { x: 0, y: 0 },
1839
+ direction: null
1840
+ };
1841
+ var trackMovementInterval = (point, dragAxis = "dynamic") => {
1842
+ intervalCache.current = point;
1843
+ intervalCache.delta = {
1844
+ x: point.x - intervalCache.previous.x,
1845
+ y: point.y - intervalCache.previous.y
1846
+ };
1847
+ intervalCache.direction = getDirection(dragAxis, intervalCache.delta) || intervalCache.direction;
1848
+ if (Math.abs(intervalCache.delta.x) > INTERVAL_SENSITIVITY || Math.abs(intervalCache.delta.y) > INTERVAL_SENSITIVITY) {
1849
+ intervalCache.previous = import_geometry.Point.from(point);
1850
+ }
1851
+ return intervalCache;
1852
+ };
1853
+
1854
+ // ../../node_modules/@dnd-kit/collision/dist/index.js
1855
+ init_react_import();
1856
+ var import_abstract2 = require("@dnd-kit/abstract");
1857
+ var import_geometry2 = require("@dnd-kit/geometry");
1858
+ var import_abstract3 = require("@dnd-kit/abstract");
1859
+ var import_geometry3 = require("@dnd-kit/geometry");
1860
+ var import_abstract4 = require("@dnd-kit/abstract");
1861
+ var import_geometry4 = require("@dnd-kit/geometry");
1862
+ var import_abstract5 = require("@dnd-kit/abstract");
1863
+ var import_geometry5 = require("@dnd-kit/geometry");
1864
+ var import_abstract6 = require("@dnd-kit/abstract");
1865
+ var import_geometry6 = require("@dnd-kit/geometry");
1866
+ var import_abstract7 = require("@dnd-kit/abstract");
1867
+ var import_geometry7 = require("@dnd-kit/geometry");
1868
+ var pointerIntersection = ({
1869
+ dragOperation,
1870
+ droppable
1871
+ }) => {
1872
+ const pointerCoordinates = dragOperation.position.current;
1873
+ if (!pointerCoordinates) {
1874
+ return null;
1875
+ }
1876
+ const { id } = droppable;
1877
+ if (!droppable.shape) {
1878
+ return null;
1879
+ }
1880
+ if (droppable.shape.containsPoint(pointerCoordinates)) {
1881
+ const distance = import_geometry2.Point.distance(droppable.shape.center, pointerCoordinates);
1882
+ return {
1883
+ id,
1884
+ value: 1 / distance,
1885
+ type: import_abstract2.CollisionType.PointerIntersection,
1886
+ priority: import_abstract2.CollisionPriority.High
1887
+ };
1888
+ }
1889
+ return null;
1890
+ };
1891
+ var closestCorners = (input) => {
1892
+ const { dragOperation, droppable } = input;
1893
+ const { shape, position } = dragOperation;
1894
+ if (!droppable.shape) {
1895
+ return null;
1896
+ }
1897
+ const { left, top, right, bottom } = droppable.shape.boundingRectangle;
1898
+ const corners = [
1899
+ {
1900
+ x: left,
1901
+ y: top
1902
+ },
1903
+ {
1904
+ x: right,
1905
+ y: top
1906
+ },
1907
+ {
1908
+ x: left,
1909
+ y: bottom
1910
+ },
1911
+ {
1912
+ x: right,
1913
+ y: bottom
1914
+ }
1915
+ ];
1916
+ const distance = corners.reduce(
1917
+ (acc, corner) => {
1918
+ var _a;
1919
+ return acc + import_geometry4.Point.distance(
1920
+ import_geometry4.Point.from(corner),
1921
+ (_a = shape == null ? void 0 : shape.current.center) != null ? _a : position.current
1922
+ );
1923
+ },
1924
+ 0
1925
+ );
1926
+ const value = distance / 4;
1927
+ return {
1928
+ id: droppable.id,
1929
+ value: 1 / value,
1930
+ type: import_abstract4.CollisionType.Collision,
1931
+ priority: import_abstract4.CollisionPriority.Normal
1932
+ };
1933
+ };
1934
+
1935
+ // lib/dnd/collision/dynamic/store.ts
1936
+ init_react_import();
1937
+ var import_vanilla = require("zustand/vanilla");
1938
+ var collisionStore = (0, import_vanilla.createStore)(() => ({
1939
+ fallbackEnabled: false
1940
+ }));
1941
+
1942
+ // lib/dnd/collision/dynamic/index.ts
1943
+ var flushNext = "";
1944
+ var createDynamicCollisionDetector = (dragAxis, midpointOffset = 0.05) => (input) => {
1945
+ var _a, _b, _c, _d, _e;
1946
+ const { dragOperation, droppable } = input;
1947
+ const { position } = dragOperation;
1948
+ const dragShape = (_a = dragOperation.shape) == null ? void 0 : _a.current;
1949
+ const { shape: dropShape } = droppable;
1950
+ if (!dragShape || !dropShape) {
1951
+ return null;
1952
+ }
1953
+ const { center: dragCenter } = dragShape;
1954
+ const { fallbackEnabled } = collisionStore.getState();
1955
+ const interval = trackMovementInterval(position.current, dragAxis);
1956
+ dragOperation.data = __spreadProps(__spreadValues({}, dragOperation.data), {
1957
+ direction: interval.direction
1958
+ });
1959
+ const collisionMap = dragOperation.data.collisionMap || {};
1960
+ dragOperation.data.collisionMap = collisionMap;
1961
+ collisionMap[droppable.id] = {
1962
+ direction: interval.direction
1963
+ };
1964
+ const { center: dropCenter } = dropShape;
1965
+ const overMidpoint = getMidpointImpact(
1966
+ dragShape,
1967
+ dropShape,
1968
+ interval.direction,
1969
+ midpointOffset
1970
+ );
1971
+ if (((_b = dragOperation.source) == null ? void 0 : _b.id) === droppable.id) {
1972
+ const collision = directionalCollision(input, interval.previous);
1973
+ collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "yellow");
1974
+ if (collision) {
1975
+ return __spreadProps(__spreadValues({}, collision), {
1976
+ priority: import_abstract8.CollisionPriority.Highest
1977
+ });
1978
+ }
1979
+ }
1980
+ const intersectionArea = dragShape.intersectionArea(dropShape);
1981
+ const intersectionRatio = intersectionArea / dropShape.area;
1982
+ if (intersectionArea && overMidpoint) {
1983
+ collisionDebug(
1984
+ dragCenter,
1985
+ dropCenter,
1986
+ droppable.id.toString(),
1987
+ "green",
1988
+ interval.direction
1989
+ );
1990
+ const collision = {
1991
+ id: droppable.id,
1992
+ value: intersectionRatio,
1993
+ priority: import_abstract8.CollisionPriority.High,
1994
+ type: import_abstract8.CollisionType.Collision
1995
+ };
1996
+ const shouldFlushId = flushNext === droppable.id;
1997
+ flushNext = "";
1998
+ return __spreadProps(__spreadValues({}, collision), { id: shouldFlushId ? "flush" : collision.id });
1999
+ }
2000
+ if (fallbackEnabled && ((_c = dragOperation.source) == null ? void 0 : _c.id) !== droppable.id) {
2001
+ const xAxisIntersection = dropShape.boundingRectangle.right > dragShape.boundingRectangle.left && dropShape.boundingRectangle.left < dragShape.boundingRectangle.right;
2002
+ const yAxisIntersection = dropShape.boundingRectangle.bottom > dragShape.boundingRectangle.top && dropShape.boundingRectangle.top < dragShape.boundingRectangle.bottom;
2003
+ if (dragAxis === "y" && xAxisIntersection || yAxisIntersection) {
2004
+ const fallbackCollision = closestCorners(input);
2005
+ if (fallbackCollision) {
2006
+ const direction = getDirection(dragAxis, {
2007
+ x: dragShape.center.x - (((_d = droppable.shape) == null ? void 0 : _d.center.x) || 0),
2008
+ y: dragShape.center.y - (((_e = droppable.shape) == null ? void 0 : _e.center.y) || 0)
2009
+ });
2010
+ collisionMap[droppable.id] = {
2011
+ direction
2012
+ };
2013
+ if (intersectionArea) {
2014
+ collisionDebug(
2015
+ dragCenter,
2016
+ dropCenter,
2017
+ droppable.id.toString(),
2018
+ "red",
2019
+ direction || ""
2020
+ );
2021
+ flushNext = droppable.id;
2022
+ return __spreadProps(__spreadValues({}, fallbackCollision), {
2023
+ priority: import_abstract8.CollisionPriority.Low
2024
+ });
2025
+ }
2026
+ collisionDebug(
2027
+ dragCenter,
2028
+ dropCenter,
2029
+ droppable.id.toString(),
2030
+ "orange",
2031
+ direction || ""
2032
+ );
2033
+ return __spreadProps(__spreadValues({}, fallbackCollision), { priority: import_abstract8.CollisionPriority.Lowest });
2034
+ }
2035
+ }
2036
+ }
2037
+ collisionDebug(dragCenter, dropCenter, droppable.id.toString(), "hotpink");
2038
+ delete collisionMap[droppable.id];
2039
+ return null;
2040
+ };
2041
+
2042
+ // lib/dnd/dnd-kit/safe.ts
2043
+ init_react_import();
2044
+ var import_react10 = require("@dnd-kit/react");
2045
+ var import_sortable = require("@dnd-kit/react/sortable");
2046
+ function useDroppableSafe(input) {
2047
+ if (typeof window === "undefined") {
2048
+ return { ref: () => {
2049
+ } };
2050
+ }
2051
+ return (0, import_react10.useDroppable)(input);
2052
+ }
2053
+ function useDraggableSafe(input) {
2054
+ if (typeof window === "undefined") {
2055
+ return { ref: () => {
2056
+ } };
2057
+ }
2058
+ return (0, import_react10.useDraggable)(input);
2059
+ }
2060
+ function useSortableSafe(input) {
2061
+ if (typeof window === "undefined") {
2062
+ return { ref: () => {
2063
+ }, status: "idle", handleRef: () => {
2064
+ } };
2065
+ }
2066
+ return (0, import_sortable.useSortable)(input);
2067
+ }
2068
+
2069
+ // lib/get-deep-scroll-position.ts
2070
+ init_react_import();
2071
+ function getDeepScrollPosition(element) {
2072
+ let totalScroll = {
2073
+ x: 0,
2074
+ y: 0
2075
+ };
2076
+ let current = element;
2077
+ while (current && current !== document.documentElement) {
2078
+ const parent = current.parentElement;
2079
+ if (parent) {
2080
+ totalScroll.x += parent.scrollLeft;
2081
+ totalScroll.y += parent.scrollTop;
2082
+ }
2083
+ current = parent;
2084
+ }
2085
+ return totalScroll;
2086
+ }
2087
+
2088
+ // components/DropZone/context.tsx
2089
+ init_react_import();
2090
+ var import_react11 = require("react");
2091
+ var import_zustand3 = require("zustand");
2092
+ var import_jsx_runtime3 = require("react/jsx-runtime");
2093
+ var dropZoneContext = (0, import_react11.createContext)(null);
2094
+ var ZoneStoreContext = (0, import_react11.createContext)(
2095
+ (0, import_zustand3.createStore)(() => ({
2096
+ zoneDepthIndex: {},
2097
+ nextZoneDepthIndex: {},
2098
+ areaDepthIndex: {},
2099
+ nextAreaDepthIndex: {},
2100
+ draggedItem: null,
2101
+ previewIndex: {}
2102
+ }))
2103
+ );
2104
+ var DropZoneProvider = ({
2105
+ children,
2106
+ value
2107
+ }) => {
2108
+ const [hoveringComponent, setHoveringComponent] = (0, import_react11.useState)();
2109
+ const [activeZones, setActiveZones] = (0, import_react11.useState)({});
2110
+ const dispatch = useAppStore((s) => s.dispatch);
2111
+ const registerZone = (0, import_react11.useCallback)(
2112
+ (zoneCompound) => {
2113
+ dispatch({
2114
+ type: "registerZone",
2115
+ zone: zoneCompound
2116
+ });
2117
+ },
2118
+ [setActiveZones, dispatch]
2119
+ );
2120
+ const unregisterZone = (0, import_react11.useCallback)(
2121
+ (zoneCompound) => {
2122
+ dispatch({
2123
+ type: "unregisterZone",
2124
+ zone: zoneCompound
2125
+ });
2126
+ },
2127
+ [setActiveZones, dispatch]
2128
+ );
2129
+ const memoValue = (0, import_react11.useMemo)(
2130
+ () => __spreadValues({
2131
+ hoveringComponent,
2132
+ setHoveringComponent,
2133
+ registerZone,
2134
+ unregisterZone,
2135
+ activeZones
2136
+ }, value),
2137
+ [value, hoveringComponent, activeZones]
2138
+ );
2139
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children: memoValue && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(dropZoneContext.Provider, { value: memoValue, children }) });
2140
+ };
2141
+
2142
+ // lib/use-context-store.ts
2143
+ init_react_import();
2144
+ var import_react12 = require("react");
2145
+ var import_zustand4 = require("zustand");
2146
+ var import_shallow = require("zustand/react/shallow");
2147
+ function useContextStore(context, selector) {
2148
+ const store = (0, import_react12.useContext)(context);
2149
+ if (!store) {
2150
+ throw new Error("useContextStore must be used inside context");
2151
+ }
2152
+ return (0, import_zustand4.useStore)(store, (0, import_shallow.useShallow)(selector));
2153
+ }
2154
+
2155
+ // components/DraggableComponent/index.tsx
2156
+ var import_shallow2 = require("zustand/react/shallow");
2157
+ var import_jsx_runtime4 = require("react/jsx-runtime");
2158
+ var getClassName3 = get_class_name_factory_default("DraggableComponent", styles_module_default);
2159
+ var DEBUG2 = false;
2160
+ var space = 8;
2161
+ var actionsOverlayTop = space * 6.5;
2162
+ var actionsTop = -(actionsOverlayTop - 8);
2163
+ var actionsSide = space;
2164
+ var DefaultActionBar = ({
2165
+ label,
2166
+ children,
2167
+ parentAction
2168
+ }) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(ActionBar, { children: [
2169
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(ActionBar.Group, { children: [
2170
+ parentAction,
2171
+ label && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ActionBar.Label, { label })
2172
+ ] }),
2173
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ActionBar.Group, { children })
2174
+ ] });
2175
+ var DraggableComponent = ({
2176
+ children,
2177
+ depth,
2178
+ componentType,
2179
+ id,
2180
+ index,
2181
+ zoneCompound,
2182
+ isLoading = false,
2183
+ isSelected = false,
2184
+ debug,
2185
+ label,
2186
+ isEnabled,
2187
+ autoDragAxis,
2188
+ userDragAxis,
2189
+ inDroppableZone = true
2190
+ }) => {
2191
+ const zoom = useAppStore(
2192
+ (s) => {
2193
+ var _a;
2194
+ return ((_a = s.selectedItem) == null ? void 0 : _a.props.id) === id ? s.zoomConfig.zoom : 1;
2195
+ }
2196
+ );
2197
+ const overrides = useAppStore((s) => s.overrides);
2198
+ const dispatch = useAppStore((s) => s.dispatch);
2199
+ const iframe = useAppStore((s) => s.iframe);
2200
+ const ctx = (0, import_react13.useContext)(dropZoneContext);
2201
+ const [localZones, setLocalZones] = (0, import_react13.useState)({});
2202
+ const registerLocalZone = (0, import_react13.useCallback)(
2203
+ (zoneCompound2, active) => {
2204
+ var _a;
2205
+ (_a = ctx == null ? void 0 : ctx.registerLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2, active);
2206
+ setLocalZones((obj) => __spreadProps(__spreadValues({}, obj), {
2207
+ [zoneCompound2]: active
2208
+ }));
2209
+ },
2210
+ [setLocalZones]
2211
+ );
2212
+ const unregisterLocalZone = (0, import_react13.useCallback)(
2213
+ (zoneCompound2) => {
2214
+ var _a;
2215
+ (_a = ctx == null ? void 0 : ctx.unregisterLocalZone) == null ? void 0 : _a.call(ctx, zoneCompound2);
2216
+ setLocalZones((obj) => {
2217
+ const newLocalZones = __spreadValues({}, obj);
2218
+ delete newLocalZones[zoneCompound2];
2219
+ return newLocalZones;
2220
+ });
2221
+ },
2222
+ [setLocalZones]
2223
+ );
2224
+ const containsActiveZone = Object.values(localZones).filter(Boolean).length > 0;
2225
+ const path = useAppStore((0, import_shallow2.useShallow)((s) => {
2226
+ var _a;
2227
+ return (_a = s.state.indexes.nodes[id]) == null ? void 0 : _a.path;
2228
+ }));
2229
+ const permissions = useAppStore(
2230
+ (0, import_shallow2.useShallow)((s) => s.permissions.getPermissions())
2231
+ // TODO call using id
2232
+ );
2233
+ const userIsDragging = useContextStore(
2234
+ ZoneStoreContext,
2235
+ (s) => !!s.draggedItem
2236
+ );
2237
+ const canCollide = permissions.drag || userIsDragging;
2238
+ const disabled = !isEnabled || !canCollide;
2239
+ const [dragAxis, setDragAxis] = (0, import_react13.useState)(userDragAxis || autoDragAxis);
2240
+ const { ref: sortableRef, status } = useSortableSafe({
2241
+ id,
2242
+ index,
2243
+ group: zoneCompound,
2244
+ type: "component",
2245
+ data: {
2246
+ areaId: ctx == null ? void 0 : ctx.areaId,
2247
+ zone: zoneCompound,
2248
+ index,
2249
+ componentType,
2250
+ containsActiveZone,
2251
+ depth,
2252
+ path: path || [],
2253
+ inDroppableZone
2254
+ },
2255
+ collisionPriority: isEnabled ? depth : 0,
2256
+ collisionDetector: createDynamicCollisionDetector(dragAxis),
2257
+ disabled,
2258
+ // "Out of the way" transition from react-beautiful-dnd
2259
+ transition: {
2260
+ duration: 200,
2261
+ easing: "cubic-bezier(0.2, 0, 0, 1)"
2262
+ }
2263
+ });
2264
+ const thisIsDragging = status === "dragging";
2265
+ const ref = (0, import_react13.useRef)(null);
2266
+ const refSetter = (0, import_react13.useCallback)(
2267
+ (el) => {
2268
+ sortableRef(el);
2269
+ if (el) {
2270
+ ref.current = el;
2271
+ }
2272
+ },
2273
+ [sortableRef]
2274
+ );
2275
+ const [portalEl, setPortalEl] = (0, import_react13.useState)();
2276
+ (0, import_react13.useEffect)(() => {
2277
+ var _a, _b, _c;
2278
+ setPortalEl(
2279
+ iframe.enabled ? (_a = ref.current) == null ? void 0 : _a.ownerDocument.body : (_c = (_b = ref.current) == null ? void 0 : _b.closest("[data-puck-preview]")) != null ? _c : document.body
2280
+ );
2281
+ }, [iframe.enabled, ref.current]);
2282
+ const getStyle = (0, import_react13.useCallback)(() => {
2283
+ var _a, _b, _c;
2284
+ if (!ref.current) return;
2285
+ const rect = ref.current.getBoundingClientRect();
2286
+ const deepScrollPosition = getDeepScrollPosition(ref.current);
2287
+ const portalContainerEl = iframe.enabled ? null : (_a = ref.current) == null ? void 0 : _a.closest("[data-puck-preview]");
2288
+ const portalContainerRect = portalContainerEl == null ? void 0 : portalContainerEl.getBoundingClientRect();
2289
+ const portalScroll = portalContainerEl ? getDeepScrollPosition(portalContainerEl) : { x: 0, y: 0 };
2290
+ const scroll = {
2291
+ x: deepScrollPosition.x - portalScroll.x - ((_b = portalContainerRect == null ? void 0 : portalContainerRect.left) != null ? _b : 0),
2292
+ y: deepScrollPosition.y - portalScroll.y - ((_c = portalContainerRect == null ? void 0 : portalContainerRect.top) != null ? _c : 0)
2293
+ };
2294
+ const style2 = {
2295
+ left: `${rect.left + scroll.x}px`,
2296
+ top: `${rect.top + scroll.y}px`,
2297
+ height: `${rect.height}px`,
2298
+ width: `${rect.width}px`
2299
+ };
2300
+ return style2;
2301
+ }, [ref.current]);
2302
+ const [style, setStyle] = (0, import_react13.useState)();
2303
+ const sync = (0, import_react13.useCallback)(() => {
2304
+ setStyle(getStyle());
2305
+ }, [ref.current, iframe]);
2306
+ (0, import_react13.useEffect)(() => {
2307
+ if (ref.current && !userIsDragging) {
2308
+ const observer = new ResizeObserver(sync);
2309
+ observer.observe(ref.current);
2310
+ return () => {
2311
+ observer.disconnect();
2312
+ };
2313
+ }
2314
+ }, [ref.current, userIsDragging]);
2315
+ const registerNode = useAppStore((s) => s.nodes.registerNode);
2316
+ (0, import_react13.useEffect)(() => {
2317
+ var _a;
2318
+ registerNode(id, { methods: { sync }, element: (_a = ref.current) != null ? _a : null });
2319
+ return () => {
2320
+ registerNode(id, { methods: { sync: () => null }, element: null });
2321
+ };
2322
+ }, [id, zoneCompound, index, componentType, sync]);
2323
+ const CustomActionBar = (0, import_react13.useMemo)(
2324
+ () => overrides.actionBar || DefaultActionBar,
2325
+ [overrides.actionBar]
2326
+ );
2327
+ const onClick = (0, import_react13.useCallback)(
2328
+ (e) => {
2329
+ e.stopPropagation();
2330
+ dispatch({
2331
+ type: "setUi",
2332
+ ui: {
2333
+ itemSelector: { index, zone: zoneCompound }
2334
+ }
2335
+ });
2336
+ },
2337
+ [index, zoneCompound, id]
2338
+ );
2339
+ const appStore = useAppStoreApi();
2340
+ const onSelectParent = (0, import_react13.useCallback)(() => {
2341
+ const { nodes, zones } = appStore.getState().state.indexes;
2342
+ const node = nodes[id];
2343
+ const parentNode = (node == null ? void 0 : node.parentId) ? nodes[node == null ? void 0 : node.parentId] : null;
2344
+ if (!parentNode || !node.parentId) {
2345
+ return;
2346
+ }
2347
+ const parentZoneCompound = `${parentNode.parentId}:${parentNode.zone}`;
2348
+ const parentIndex = zones[parentZoneCompound].contentIds.indexOf(
2349
+ node.parentId
2350
+ );
2351
+ dispatch({
2352
+ type: "setUi",
2353
+ ui: {
2354
+ itemSelector: {
2355
+ zone: parentZoneCompound,
2356
+ index: parentIndex
2357
+ }
2358
+ }
2359
+ });
2360
+ }, [ctx, path]);
2361
+ const onDuplicate = (0, import_react13.useCallback)(() => {
2362
+ dispatch({
2363
+ type: "duplicate",
2364
+ sourceIndex: index,
2365
+ sourceZone: zoneCompound
2366
+ });
2367
+ }, [index, zoneCompound]);
2368
+ const onDelete = (0, import_react13.useCallback)(() => {
2369
+ dispatch({
2370
+ type: "remove",
2371
+ index,
2372
+ zone: zoneCompound
2373
+ });
2374
+ }, [index, zoneCompound]);
2375
+ const [hover, setHover] = (0, import_react13.useState)(false);
2376
+ const indicativeHover = (ctx == null ? void 0 : ctx.hoveringComponent) === id;
2377
+ (0, import_react13.useEffect)(() => {
2378
+ if (!ref.current) {
2379
+ return;
2380
+ }
2381
+ const el = ref.current;
2382
+ const _onMouseOver = (e) => {
2383
+ if (userIsDragging) {
2384
+ if (thisIsDragging) {
2385
+ setHover(true);
2386
+ } else {
2387
+ setHover(false);
2388
+ }
2389
+ } else {
2390
+ setHover(true);
2391
+ }
2392
+ e.stopPropagation();
2393
+ };
2394
+ const _onMouseOut = (e) => {
2395
+ e.stopPropagation();
2396
+ setHover(false);
2397
+ };
2398
+ el.setAttribute("data-puck-component", id);
2399
+ el.setAttribute("data-puck-dnd", id);
2400
+ el.style.position = "relative";
2401
+ el.addEventListener("click", onClick);
2402
+ el.addEventListener("mouseover", _onMouseOver);
2403
+ el.addEventListener("mouseout", _onMouseOut);
2404
+ if (thisIsDragging) {
2405
+ el.setAttribute("data-puck-dragging", "");
2406
+ } else {
2407
+ el.removeAttribute("data-puck-dragging");
2408
+ }
2409
+ return () => {
2410
+ el.removeAttribute("data-puck-component");
2411
+ el.removeAttribute("data-puck-dnd");
2412
+ el.removeEventListener("click", onClick);
2413
+ el.removeEventListener("mouseover", _onMouseOver);
2414
+ el.removeEventListener("mouseout", _onMouseOut);
2415
+ el.removeAttribute("data-puck-dragging");
2416
+ };
2417
+ }, [
2418
+ ref,
2419
+ onClick,
2420
+ containsActiveZone,
2421
+ zoneCompound,
2422
+ id,
2423
+ userIsDragging,
2424
+ thisIsDragging,
2425
+ inDroppableZone
2426
+ ]);
2427
+ (0, import_react13.useEffect)(() => {
2428
+ if (ref.current && disabled) {
2429
+ ref.current.setAttribute("data-puck-disabled", "");
2430
+ return () => {
2431
+ var _a;
2432
+ (_a = ref.current) == null ? void 0 : _a.removeAttribute("data-puck-disabled");
2433
+ };
2434
+ }
2435
+ }, [disabled, ref]);
2436
+ const [isVisible, setIsVisible] = (0, import_react13.useState)(false);
2437
+ (0, import_react13.useEffect)(() => {
2438
+ sync();
2439
+ if ((isSelected || hover || indicativeHover) && !userIsDragging) {
2440
+ setIsVisible(true);
2441
+ } else {
2442
+ setIsVisible(false);
2443
+ }
2444
+ }, [isSelected, hover, indicativeHover, iframe, userIsDragging]);
2445
+ const syncActionsPosition = (0, import_react13.useCallback)(
2446
+ (el) => {
2447
+ if (el) {
2448
+ const view = el.ownerDocument.defaultView;
2449
+ if (view) {
2450
+ const rect = el.getBoundingClientRect();
2451
+ const diffLeft = rect.x;
2452
+ const exceedsBoundsLeft = diffLeft < 0;
2453
+ const diffTop = rect.y;
2454
+ const exceedsBoundsTop = diffTop < 0;
2455
+ if (exceedsBoundsLeft) {
2456
+ el.style.transformOrigin = "left top";
2457
+ el.style.left = "0px";
2458
+ }
2459
+ if (exceedsBoundsTop) {
2460
+ el.style.top = "12px";
2461
+ if (!exceedsBoundsLeft) {
2462
+ el.style.transformOrigin = "right top";
2463
+ }
2464
+ }
2465
+ }
2466
+ }
2467
+ },
2468
+ [zoom]
2469
+ );
2470
+ (0, import_react13.useEffect)(() => {
2471
+ if (userDragAxis) {
2472
+ setDragAxis(userDragAxis);
2473
+ return;
2474
+ }
2475
+ if (ref.current) {
2476
+ const computedStyle = window.getComputedStyle(ref.current);
2477
+ if (computedStyle.display === "inline" || computedStyle.display === "inline-block") {
2478
+ setDragAxis("x");
2479
+ return;
2480
+ }
2481
+ }
2482
+ setDragAxis(autoDragAxis);
2483
+ }, [ref, userDragAxis, autoDragAxis]);
2484
+ const parentAction = (ctx == null ? void 0 : ctx.areaId) && (ctx == null ? void 0 : ctx.areaId) !== "root" && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ActionBar.Action, { onClick: onSelectParent, label: "Select parent", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CornerLeftUp, { size: 16 }) });
2485
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
2486
+ DropZoneProvider,
2487
+ {
2488
+ value: __spreadProps(__spreadValues({}, ctx), {
2489
+ areaId: id,
2490
+ zoneCompound,
2491
+ index,
2492
+ depth: depth + 1,
2493
+ registerLocalZone,
2494
+ unregisterLocalZone
2495
+ }),
2496
+ children: [
2497
+ isVisible && (0, import_react_dom.createPortal)(
2498
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
2499
+ "div",
2500
+ {
2501
+ className: getClassName3({
2502
+ isSelected,
2503
+ isDragging: thisIsDragging,
2504
+ hover: hover || indicativeHover
2505
+ }),
2506
+ style: __spreadValues({}, style),
2507
+ "data-puck-overlay": true,
2508
+ children: [
2509
+ debug,
2510
+ isLoading && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: getClassName3("loadingOverlay"), children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Loader, {}) }),
2511
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
2512
+ "div",
2513
+ {
2514
+ className: getClassName3("actionsOverlay"),
2515
+ style: {
2516
+ top: actionsOverlayTop / zoom
2517
+ },
2518
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
2519
+ "div",
2520
+ {
2521
+ className: getClassName3("actions"),
2522
+ style: {
2523
+ transform: `scale(${1 / zoom}`,
2524
+ top: actionsTop / zoom,
2525
+ right: 0,
2526
+ paddingLeft: actionsSide,
2527
+ paddingRight: actionsSide
2528
+ },
2529
+ ref: syncActionsPosition,
2530
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
2531
+ CustomActionBar,
2532
+ {
2533
+ parentAction,
2534
+ label: DEBUG2 ? id : label,
2535
+ children: [
2536
+ permissions.duplicate && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ActionBar.Action, { onClick: onDuplicate, label: "Duplicate", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Copy, { size: 16 }) }),
2537
+ permissions.delete && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ActionBar.Action, { onClick: onDelete, label: "Delete", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Trash, { size: 16 }) })
2538
+ ]
2539
+ }
2540
+ )
2541
+ }
2542
+ )
2543
+ }
2544
+ ),
2545
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: getClassName3("overlay") })
2546
+ ]
2547
+ }
2548
+ ),
2549
+ portalEl || document.body
2550
+ ),
2551
+ children(refSetter)
2552
+ ]
2553
+ }
2554
+ );
2555
+ };
2556
+
2557
+ // css-module:/home/runner/work/puck/puck/packages/core/components/DropZone/styles.module.css#css-module
2558
+ init_react_import();
2559
+ var styles_module_default4 = { "DropZone": "_DropZone_3dmev_1", "DropZone--hasChildren": "_DropZone--hasChildren_3dmev_11", "DropZone--userIsDragging": "_DropZone--userIsDragging_3dmev_19", "DropZone--isAreaSelected": "_DropZone--isAreaSelected_3dmev_23", "DropZone--hoveringOverArea": "_DropZone--hoveringOverArea_3dmev_24", "DropZone--isRootZone": "_DropZone--isRootZone_3dmev_24", "DropZone--isDestination": "_DropZone--isDestination_3dmev_34", "DropZone-item": "_DropZone-item_3dmev_46", "DropZone-hitbox": "_DropZone-hitbox_3dmev_50", "DropZone--isEnabled": "_DropZone--isEnabled_3dmev_58", "DropZone--isAnimating": "_DropZone--isAnimating_3dmev_67" };
2560
+
2561
+ // components/Drawer/index.tsx
2562
+ init_react_import();
2563
+
2564
+ // css-module:/home/runner/work/puck/puck/packages/core/components/Drawer/styles.module.css#css-module
2565
+ init_react_import();
2566
+ var styles_module_default5 = { "Drawer": "_Drawer_fkqfo_1", "Drawer-draggable": "_Drawer-draggable_fkqfo_8", "Drawer-draggableBg": "_Drawer-draggableBg_fkqfo_12", "Drawer-draggableFg": "_Drawer-draggableFg_fkqfo_21", "DrawerItem-draggable": "_DrawerItem-draggable_fkqfo_25", "DrawerItem--disabled": "_DrawerItem--disabled_fkqfo_38", "DrawerItem": "_DrawerItem_fkqfo_25", "Drawer--isDraggingFrom": "_Drawer--isDraggingFrom_fkqfo_48", "DrawerItem-name": "_DrawerItem-name_fkqfo_66" };
2567
+
2568
+ // components/DragIcon/index.tsx
2569
+ init_react_import();
2570
+
2571
+ // css-module:/home/runner/work/puck/puck/packages/core/components/DragIcon/styles.module.css#css-module
2572
+ init_react_import();
2573
+ var styles_module_default6 = { "DragIcon": "_DragIcon_17p8x_1", "DragIcon--disabled": "_DragIcon--disabled_17p8x_8" };
2574
+
2575
+ // components/DragIcon/index.tsx
2576
+ var import_jsx_runtime5 = require("react/jsx-runtime");
2577
+ var getClassName4 = get_class_name_factory_default("DragIcon", styles_module_default6);
2578
+ var DragIcon = ({ isDragDisabled }) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: getClassName4({ disabled: isDragDisabled }), children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { viewBox: "0 0 20 20", width: "12", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M7 2a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 2zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 8zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 7 14zm6-8a2 2 0 1 0-.001-4.001A2 2 0 0 0 13 6zm0 2a2 2 0 1 0 .001 4.001A2 2 0 0 0 13 8zm0 6a2 2 0 1 0 .001 4.001A2 2 0 0 0 13 14z" }) }) });
2579
+
2580
+ // components/Drawer/index.tsx
2581
+ var import_react18 = require("react");
2582
+
2583
+ // components/DragDropContext/index.tsx
2584
+ init_react_import();
2585
+ var import_react16 = require("@dnd-kit/react");
2586
+ var import_react17 = require("react");
2587
+ var import_dom = require("@dnd-kit/dom");
2588
+
2589
+ // lib/dnd/NestedDroppablePlugin.ts
2590
+ init_react_import();
2591
+ var import_abstract9 = require("@dnd-kit/abstract");
2592
+ var import_state = require("@dnd-kit/state");
2593
+
2594
+ // lib/throttle.ts
2595
+ init_react_import();
2596
+
2597
+ // lib/get-frame.ts
2598
+ init_react_import();
2599
+
2600
+ // lib/global-position.ts
2601
+ init_react_import();
2602
+
2603
+ // lib/bubble-pointer-event.ts
2604
+ init_react_import();
2605
+
2606
+ // lib/insert-component.ts
2607
+ init_react_import();
2608
+
2609
+ // components/DragDropContext/index.tsx
2610
+ var import_use_debounce = require("use-debounce");
2611
+ var import_zustand5 = require("zustand");
2612
+
2613
+ // lib/get-deep-dir.ts
2614
+ init_react_import();
2615
+
2616
+ // lib/dnd/use-sensors.ts
2617
+ init_react_import();
2618
+ var import_react14 = require("react");
2619
+
2620
+ // lib/dnd/PointerSensor.ts
2621
+ init_react_import();
2622
+ var import_state2 = require("@dnd-kit/state");
2623
+ var import_abstract10 = require("@dnd-kit/abstract");
2624
+ var import_geometry8 = require("@dnd-kit/geometry");
2625
+ var import_utilities = require("@dnd-kit/dom/utilities");
2626
+ var _clearTimeout;
2627
+ var _PointerSensor = class _PointerSensor extends import_abstract10.Sensor {
2628
+ constructor(manager, options) {
2629
+ super(manager);
2630
+ this.manager = manager;
2631
+ this.options = options;
2632
+ this.listeners = new import_utilities.Listeners();
2633
+ this.cleanup = /* @__PURE__ */ new Set();
2634
+ this.source = void 0;
2635
+ this.started = false;
2636
+ __privateAdd(this, _clearTimeout);
2637
+ this.handleCancel = this.handleCancel.bind(this);
2638
+ this.handlePointerUp = this.handlePointerUp.bind(this);
2639
+ this.handleKeyDown = this.handleKeyDown.bind(this);
2640
+ (0, import_state2.effect)(() => {
2641
+ const unbindGlobal = this.bindGlobal(options != null ? options : {});
2642
+ return () => {
2643
+ unbindGlobal();
2644
+ };
2645
+ });
2646
+ }
2647
+ bind(source, options = this.options) {
2648
+ const unbind = (0, import_state2.effect)(() => {
2649
+ var _a;
2650
+ const target = (_a = source.handle) != null ? _a : source.element;
2651
+ const listener = (event) => {
2652
+ if ((0, import_utilities.isPointerEvent)(event)) {
2653
+ this.handlePointerDown(event, source, options);
2654
+ }
2655
+ };
2656
+ if (target) {
2657
+ patchWindow(target.ownerDocument.defaultView);
2658
+ target.addEventListener("pointerdown", listener);
2659
+ return () => {
2660
+ target.removeEventListener("pointerdown", listener);
2661
+ };
2662
+ }
2663
+ });
2664
+ return unbind;
2665
+ }
2666
+ bindGlobal(options) {
2667
+ const documents = /* @__PURE__ */ new Set();
2668
+ for (const draggable of this.manager.registry.draggables.value) {
2669
+ if (draggable.element) {
2670
+ documents.add((0, import_utilities.getDocument)(draggable.element));
2671
+ }
2672
+ }
2673
+ for (const droppable of this.manager.registry.droppables.value) {
2674
+ if (droppable.element) {
2675
+ documents.add((0, import_utilities.getDocument)(droppable.element));
2676
+ }
2677
+ }
2678
+ const unbindFns = Array.from(documents).map(
2679
+ (doc) => this.listeners.bind(doc, [
2680
+ {
2681
+ type: "pointermove",
2682
+ listener: (event) => this.handlePointerMove(event, doc, options)
2683
+ },
2684
+ {
2685
+ type: "pointerup",
2686
+ listener: this.handlePointerUp,
2687
+ options: {
2688
+ capture: true
2689
+ }
2690
+ },
2691
+ {
2692
+ // Cancel activation if there is a competing Drag and Drop interaction
2693
+ type: "dragstart",
2694
+ listener: this.handleDragStart
2695
+ }
2696
+ ])
2697
+ );
2698
+ return () => {
2699
+ unbindFns.forEach((unbind) => unbind());
2700
+ };
2701
+ }
2702
+ handlePointerDown(event, source, options = {}) {
2703
+ if (this.disabled || !event.isPrimary || event.button !== 0 || !(0, import_utilities.isElement)(event.target) || source.disabled) {
2704
+ return;
2705
+ }
2706
+ const offset = (0, import_utilities.getFrameTransform)(source.element);
2707
+ this.initialCoordinates = {
2708
+ x: event.clientX * offset.scaleX + offset.x,
2709
+ y: event.clientY * offset.scaleY + offset.y
2710
+ };
2711
+ this.source = source;
2712
+ const { activationConstraints } = options;
2713
+ const constraints = typeof activationConstraints === "function" ? activationConstraints(event, source) : activationConstraints;
2714
+ event.stopImmediatePropagation();
2715
+ if (!(constraints == null ? void 0 : constraints.delay) && !(constraints == null ? void 0 : constraints.distance)) {
2716
+ this.handleStart(source, event);
2717
+ } else {
2718
+ const { delay } = constraints;
2719
+ if (delay) {
2720
+ const timeout2 = setTimeout(
2721
+ () => this.handleStart(source, event),
2722
+ delay.value
2723
+ );
2724
+ __privateSet(this, _clearTimeout, () => {
2725
+ clearTimeout(timeout2);
2726
+ __privateSet(this, _clearTimeout, void 0);
2727
+ });
2728
+ }
2729
+ }
2730
+ const cleanup = () => {
2731
+ var _a;
2732
+ (_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
2733
+ this.initialCoordinates = void 0;
2734
+ this.source = void 0;
2735
+ };
2736
+ this.cleanup.add(cleanup);
2737
+ }
2738
+ handlePointerMove(event, doc, options) {
2739
+ if (!this.source) {
2740
+ return;
2741
+ }
2742
+ const ownerDocument = this.source.element && (0, import_utilities.getDocument)(this.source.element);
2743
+ if (doc !== ownerDocument) {
2744
+ return;
2745
+ }
2746
+ const coordinates = {
2747
+ x: event.clientX,
2748
+ y: event.clientY
2749
+ };
2750
+ const offset = (0, import_utilities.getFrameTransform)(this.source.element);
2751
+ coordinates.x = coordinates.x * offset.scaleX + offset.x;
2752
+ coordinates.y = coordinates.y * offset.scaleY + offset.y;
2753
+ if (this.manager.dragOperation.status.dragging) {
2754
+ event.preventDefault();
2755
+ event.stopPropagation();
2756
+ this.manager.actions.move({ to: coordinates });
2757
+ return;
2758
+ }
2759
+ if (!this.initialCoordinates) {
2760
+ return;
2761
+ }
2762
+ const delta = {
2763
+ x: coordinates.x - this.initialCoordinates.x,
2764
+ y: coordinates.y - this.initialCoordinates.y
2765
+ };
2766
+ const { activationConstraints } = options;
2767
+ const constraints = typeof activationConstraints === "function" ? activationConstraints(event, this.source) : activationConstraints;
2768
+ const { distance, delay } = constraints != null ? constraints : {};
2769
+ if (distance) {
2770
+ if (distance.tolerance != null && (0, import_geometry8.exceedsDistance)(delta, distance.tolerance)) {
2771
+ return this.handleCancel();
2772
+ }
2773
+ if ((0, import_geometry8.exceedsDistance)(delta, distance.value)) {
2774
+ return this.handleStart(this.source, event);
2775
+ }
2776
+ }
2777
+ if (delay) {
2778
+ if ((0, import_geometry8.exceedsDistance)(delta, delay.tolerance)) {
2779
+ return this.handleCancel();
2780
+ }
2781
+ }
2782
+ }
2783
+ handlePointerUp(event) {
2784
+ if (!this.source) {
2785
+ return;
2786
+ }
2787
+ event.preventDefault();
2788
+ event.stopPropagation();
2789
+ const { status } = this.manager.dragOperation;
2790
+ if (!status.idle) {
2791
+ const canceled = !status.initialized;
2792
+ this.manager.actions.stop({ canceled });
2793
+ } else if (this.started) {
2794
+ setTimeout(() => {
2795
+ if (!this.manager.dragOperation.status.idle) {
2796
+ this.manager.actions.stop({ canceled: false });
2797
+ }
2798
+ }, 10);
2799
+ }
2800
+ this.cleanup.forEach((cleanup) => cleanup());
2801
+ this.cleanup.clear();
2802
+ }
2803
+ handleKeyDown(event) {
2804
+ if (event.key === "Escape") {
2805
+ event.preventDefault();
2806
+ this.handleCancel();
2807
+ }
2808
+ }
2809
+ handleStart(source, event) {
2810
+ var _a;
2811
+ const { manager, initialCoordinates } = this;
2812
+ (_a = __privateGet(this, _clearTimeout)) == null ? void 0 : _a.call(this);
2813
+ if (!initialCoordinates || manager.dragOperation.status.initialized || this.started) {
2814
+ return;
2815
+ }
2816
+ if (event.defaultPrevented) {
2817
+ return;
2818
+ }
2819
+ this.started = true;
2820
+ event.preventDefault();
2821
+ (0, import_state2.batch)(() => {
2822
+ manager.actions.setDragSource(source.id);
2823
+ manager.actions.start({ coordinates: initialCoordinates, event });
2824
+ });
2825
+ const ownerDocument = (0, import_utilities.getDocument)(event.target);
2826
+ const unbind = this.listeners.bind(ownerDocument, [
2827
+ {
2828
+ // Prevent scrolling on touch devices
2829
+ type: "touchmove",
2830
+ listener: preventDefault,
2831
+ options: {
2832
+ passive: false
2833
+ }
2834
+ },
2835
+ {
2836
+ // Prevent click events
2837
+ type: "click",
2838
+ listener: preventDefault
2839
+ },
2840
+ {
2841
+ type: "keydown",
2842
+ listener: this.handleKeyDown
2843
+ }
2844
+ ]);
2845
+ ownerDocument.body.setPointerCapture(event.pointerId);
2846
+ this.cleanup.add(unbind);
2847
+ this.cleanup.add(() => {
2848
+ this.started = false;
2849
+ });
2850
+ }
2851
+ handleDragStart(event) {
2852
+ const { target } = event;
2853
+ if (!(0, import_utilities.isElement)(target)) {
2854
+ return;
2855
+ }
2856
+ const isNativeDraggable = (0, import_utilities.isHTMLElement)(target) && target.draggable && target.getAttribute("draggable") === "true";
2857
+ if (isNativeDraggable) {
2858
+ this.handleCancel();
2859
+ } else {
2860
+ preventDefault(event);
2861
+ }
2862
+ }
2863
+ handleCancel() {
2864
+ const { dragOperation } = this.manager;
2865
+ if (dragOperation.status.initialized) {
2866
+ this.manager.actions.stop({ canceled: true });
2867
+ }
2868
+ this.cleanup.forEach((cleanup) => cleanup());
2869
+ this.cleanup.clear();
2870
+ }
2871
+ destroy() {
2872
+ this.listeners.clear();
2873
+ }
2874
+ };
2875
+ _clearTimeout = new WeakMap();
2876
+ _PointerSensor.configure = (0, import_abstract10.configurator)(_PointerSensor);
2877
+ var PointerSensor = _PointerSensor;
2878
+ function preventDefault(event) {
2879
+ event.preventDefault();
2880
+ }
2881
+ function noop() {
2882
+ }
2883
+ var windows = /* @__PURE__ */ new WeakSet();
2884
+ function patchWindow(window2) {
2885
+ if (!window2 || windows.has(window2)) {
2886
+ return;
2887
+ }
2888
+ window2.addEventListener("touchmove", noop, {
2889
+ capture: false,
2890
+ passive: false
2891
+ });
2892
+ windows.add(window2);
2893
+ }
2894
+
2895
+ // lib/dnd/use-sensors.ts
2896
+ var import_utilities2 = require("@dnd-kit/dom/utilities");
2897
+
2898
+ // lib/use-safe-id.ts
2899
+ init_react_import();
2900
+ var import_react15 = __toESM(require("react"));
2901
+ var useSafeId = () => {
2902
+ if (typeof import_react15.default.useId !== "undefined") {
2903
+ return import_react15.default.useId();
2904
+ }
2905
+ const [id] = (0, import_react15.useState)(generateId());
2906
+ return id;
2907
+ };
2908
+
2909
+ // components/DragDropContext/index.tsx
2910
+ var import_jsx_runtime6 = require("react/jsx-runtime");
2911
+ var dragListenerContext = (0, import_react17.createContext)({
2912
+ dragListeners: {}
2913
+ });
2914
+ function useDragListener(type, fn, deps = []) {
2915
+ const { setDragListeners } = (0, import_react17.useContext)(dragListenerContext);
2916
+ (0, import_react17.useEffect)(() => {
2917
+ if (setDragListeners) {
2918
+ setDragListeners((old) => __spreadProps(__spreadValues({}, old), {
2919
+ [type]: [...old[type] || [], fn]
2920
+ }));
2921
+ }
2922
+ }, deps);
2923
+ }
2924
+
2925
+ // components/Drawer/index.tsx
2926
+ var import_jsx_runtime7 = require("react/jsx-runtime");
2927
+ var getClassName5 = get_class_name_factory_default("Drawer", styles_module_default5);
2928
+ var getClassNameItem = get_class_name_factory_default("DrawerItem", styles_module_default5);
2929
+ var DrawerItemInner = ({
2930
+ children,
2931
+ name,
2932
+ label,
2933
+ dragRef,
2934
+ isDragDisabled
2935
+ }) => {
2936
+ const CustomInner = (0, import_react18.useMemo)(
2937
+ () => children || (({ children: children2 }) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassNameItem("default"), children: children2 })),
2938
+ [children]
2939
+ );
2940
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2941
+ "div",
2942
+ {
2943
+ className: getClassNameItem({ disabled: isDragDisabled }),
2944
+ ref: dragRef,
2945
+ onMouseDown: (e) => e.preventDefault(),
2946
+ "data-testid": dragRef ? `drawer-item:${name}` : "",
2947
+ "data-puck-drawer-item": true,
2948
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CustomInner, { name, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassNameItem("draggableWrapper"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: getClassNameItem("draggable"), children: [
2949
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassNameItem("name"), children: label != null ? label : name }),
2950
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassNameItem("icon"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DragIcon, {}) })
2951
+ ] }) }) })
2952
+ }
2953
+ );
2954
+ };
2955
+ var DrawerItemDraggable = ({
2956
+ children,
2957
+ name,
2958
+ label,
2959
+ id,
2960
+ isDragDisabled
2961
+ }) => {
2962
+ const { ref } = useDraggableSafe({
2963
+ id,
2964
+ data: { type: "drawer", componentType: name },
2965
+ disabled: isDragDisabled
2966
+ });
2967
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: getClassName5("draggable"), children: [
2968
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassName5("draggableBg"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DrawerItemInner, { name, label, children }) }),
2969
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: getClassName5("draggableFg"), children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2970
+ DrawerItemInner,
2971
+ {
2972
+ name,
2973
+ label,
2974
+ dragRef: ref,
2975
+ isDragDisabled,
2976
+ children
2977
+ }
2978
+ ) })
2979
+ ] });
2980
+ };
2981
+ var DrawerItem = ({
2982
+ name,
2983
+ children,
2984
+ id,
2985
+ label,
2986
+ index,
2987
+ isDragDisabled
2988
+ }) => {
2989
+ const resolvedId = id || name;
2990
+ const [dynamicId, setDynamicId] = (0, import_react18.useState)(generateId(resolvedId));
2991
+ if (typeof index !== "undefined") {
2992
+ console.error(
2993
+ "Warning: The `index` prop on Drawer.Item is deprecated and no longer required."
2994
+ );
2995
+ }
2996
+ useDragListener(
2997
+ "dragend",
2998
+ () => {
2999
+ setDynamicId(generateId(resolvedId));
3000
+ },
3001
+ [resolvedId]
3002
+ );
3003
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3004
+ DrawerItemDraggable,
3005
+ {
3006
+ name,
3007
+ label,
3008
+ id: dynamicId,
3009
+ isDragDisabled,
3010
+ children
3011
+ }
3012
+ ) }, dynamicId);
3013
+ };
3014
+ var Drawer = ({
3015
+ children,
3016
+ droppableId,
3017
+ direction
3018
+ }) => {
3019
+ if (droppableId) {
3020
+ console.error(
3021
+ "Warning: The `droppableId` prop on Drawer is deprecated and no longer required."
3022
+ );
3023
+ }
3024
+ if (direction) {
3025
+ console.error(
3026
+ "Warning: The `direction` prop on Drawer is deprecated and no longer required to achieve multi-directional dragging."
3027
+ );
3028
+ }
3029
+ const id = useSafeId();
3030
+ const { ref } = useDroppableSafe({
3031
+ id,
3032
+ type: "void",
3033
+ collisionPriority: 0
3034
+ // Never collide with this, but we use it so NestedDroppablePlugin respects the Drawer
3035
+ });
3036
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3037
+ "div",
3038
+ {
3039
+ className: getClassName5(),
3040
+ ref,
3041
+ "data-puck-dnd": id,
3042
+ "data-puck-drawer": true,
3043
+ children
3044
+ }
3045
+ );
3046
+ };
3047
+ Drawer.Item = DrawerItem;
3048
+
3049
+ // components/DropZone/lib/use-min-empty-height.ts
3050
+ init_react_import();
3051
+ var import_react19 = require("react");
3052
+ var useMinEmptyHeight = ({
3053
+ zoneCompound,
3054
+ userMinEmptyHeight,
3055
+ ref
3056
+ }) => {
3057
+ const appStore = useAppStoreApi();
3058
+ const [prevHeight, setPrevHeight] = (0, import_react19.useState)(0);
3059
+ const [isAnimating, setIsAnimating] = (0, import_react19.useState)(false);
3060
+ const { draggedItem, isZone } = useContextStore(ZoneStoreContext, (s) => {
3061
+ var _a, _b;
3062
+ return {
3063
+ draggedItem: ((_a = s.draggedItem) == null ? void 0 : _a.data.zone) === zoneCompound ? s.draggedItem : null,
3064
+ isZone: ((_b = s.draggedItem) == null ? void 0 : _b.data.zone) === zoneCompound
3065
+ };
3066
+ });
3067
+ (0, import_react19.useEffect)(() => {
3068
+ if (draggedItem && ref.current) {
3069
+ if (isZone) {
3070
+ const rect = ref.current.getBoundingClientRect();
3071
+ setPrevHeight(rect.height);
3072
+ setIsAnimating(true);
3073
+ return;
3074
+ }
3075
+ }
3076
+ setPrevHeight(0);
3077
+ setTimeout(() => {
3078
+ var _a, _b;
3079
+ const zones = appStore.getState().state.indexes.zones;
3080
+ const nodes = appStore.getState().nodes;
3081
+ const selectedItem = appStore.getState().selectedItem;
3082
+ const contentIds = ((_a = zones[zoneCompound]) == null ? void 0 : _a.contentIds) || [];
3083
+ contentIds.forEach((contentId) => {
3084
+ const node = nodes.nodes[contentId];
3085
+ node == null ? void 0 : node.methods.sync();
3086
+ });
3087
+ if (selectedItem) {
3088
+ (_b = nodes.nodes[selectedItem.props.id]) == null ? void 0 : _b.methods.sync();
3089
+ }
3090
+ setIsAnimating(false);
3091
+ }, 400);
3092
+ }, [ref.current, draggedItem, zoneCompound]);
3093
+ return [prevHeight || userMinEmptyHeight, isAnimating];
3094
+ };
3095
+
3096
+ // lib/assign-refs.ts
3097
+ init_react_import();
3098
+ function assignRef(ref, node) {
3099
+ if (typeof ref === "function") {
3100
+ ref(node);
3101
+ } else if (ref && typeof ref === "object" && "current" in ref) {
3102
+ ref.current = node;
3103
+ }
3104
+ }
3105
+ function assignRefs(refs, node) {
3106
+ refs.forEach((ref) => {
3107
+ assignRef(ref, node);
3108
+ });
3109
+ }
3110
+
3111
+ // components/DropZone/lib/use-content-with-preview.ts
3112
+ init_react_import();
3113
+ var import_react22 = require("react");
3114
+
3115
+ // lib/dnd/use-rendered-callback.ts
3116
+ init_react_import();
3117
+ var import_react20 = require("@dnd-kit/react");
3118
+ var import_react21 = require("react");
3119
+ function useRenderedCallback(callback, deps) {
3120
+ const manager = (0, import_react20.useDragDropManager)();
3121
+ return (0, import_react21.useCallback)(
3122
+ (...args) => __async(this, null, function* () {
3123
+ yield manager == null ? void 0 : manager.renderer.rendering;
3124
+ return callback(...args);
3125
+ }),
3126
+ [...deps, manager]
3127
+ );
3128
+ }
3129
+
3130
+ // components/DropZone/lib/use-content-with-preview.ts
3131
+ var useContentIdsWithPreview = (contentIds, zoneCompound) => {
3132
+ const { draggedItemId, preview, previewExists } = useContextStore(
3133
+ ZoneStoreContext,
3134
+ (s) => {
3135
+ var _a;
3136
+ return {
3137
+ draggedItemId: (_a = s.draggedItem) == null ? void 0 : _a.id,
3138
+ preview: s.previewIndex[zoneCompound],
3139
+ previewExists: Object.keys(s.previewIndex || {}).length > 0
3140
+ };
3141
+ }
3142
+ );
3143
+ const isDragging = useAppStore((s) => s.state.ui.isDragging);
3144
+ const [contentIdsWithPreview, setContentIdsWithPreview] = (0, import_react22.useState)(contentIds);
3145
+ const [localPreview, setLocalPreview] = (0, import_react22.useState)(
3146
+ preview
3147
+ );
3148
+ const updateContent = useRenderedCallback(
3149
+ (contentIds2, preview2, isDragging2) => {
3150
+ if (isDragging2 && !previewExists) {
3151
+ return;
3152
+ }
3153
+ if (preview2) {
3154
+ if (preview2.type === "insert") {
3155
+ setContentIdsWithPreview(
3156
+ insert(
3157
+ contentIds2.filter((id) => id !== preview2.props.id),
3158
+ preview2.index,
3159
+ preview2.props.id
3160
+ )
3161
+ );
3162
+ } else {
3163
+ setContentIdsWithPreview(
3164
+ insert(
3165
+ contentIds2.filter((id) => id !== preview2.props.id),
3166
+ preview2.index,
3167
+ preview2.props.id
3168
+ )
3169
+ );
3170
+ }
3171
+ } else {
3172
+ setContentIdsWithPreview(
3173
+ previewExists ? contentIds2.filter((id) => id !== draggedItemId) : contentIds2
3174
+ );
3175
+ }
3176
+ setLocalPreview(preview2);
3177
+ },
3178
+ [draggedItemId, previewExists]
3179
+ );
3180
+ (0, import_react22.useEffect)(() => {
3181
+ updateContent(contentIds, preview, isDragging);
3182
+ }, [contentIds, preview, isDragging]);
3183
+ return [contentIdsWithPreview, localPreview];
3184
+ };
3185
+
3186
+ // components/DropZone/lib/use-drag-axis.ts
3187
+ init_react_import();
3188
+ var import_react23 = require("react");
3189
+ var GRID_DRAG_AXIS = "dynamic";
3190
+ var FLEX_ROW_DRAG_AXIS = "x";
3191
+ var DEFAULT_DRAG_AXIS = "y";
3192
+ var useDragAxis = (ref, collisionAxis) => {
3193
+ const status = useAppStore((s) => s.status);
3194
+ const [dragAxis, setDragAxis] = (0, import_react23.useState)(
3195
+ collisionAxis || DEFAULT_DRAG_AXIS
3196
+ );
3197
+ const calculateDragAxis = (0, import_react23.useCallback)(() => {
3198
+ if (ref.current) {
3199
+ const computedStyle = window.getComputedStyle(ref.current);
3200
+ if (computedStyle.display === "grid") {
3201
+ setDragAxis(GRID_DRAG_AXIS);
3202
+ } else if (computedStyle.display === "flex" && computedStyle.flexDirection === "row") {
3203
+ setDragAxis(FLEX_ROW_DRAG_AXIS);
3204
+ } else {
3205
+ setDragAxis(DEFAULT_DRAG_AXIS);
3206
+ }
3207
+ }
3208
+ }, [ref.current]);
3209
+ (0, import_react23.useEffect)(() => {
3210
+ const onViewportChange = () => {
3211
+ calculateDragAxis();
3212
+ };
3213
+ window.addEventListener("viewportchange", onViewportChange);
3214
+ return () => {
3215
+ window.removeEventListener("viewportchange", onViewportChange);
3216
+ };
3217
+ }, []);
3218
+ (0, import_react23.useEffect)(calculateDragAxis, [status, collisionAxis]);
3219
+ return [dragAxis, calculateDragAxis];
3220
+ };
3221
+
3222
+ // components/DropZone/index.tsx
3223
+ var import_shallow3 = require("zustand/react/shallow");
3224
+
3225
+ // components/Render/index.tsx
3226
+ init_react_import();
3227
+ var import_react24 = __toESM(require("react"));
3228
+ var import_jsx_runtime8 = require("react/jsx-runtime");
3229
+ var renderContext = import_react24.default.createContext({
3230
+ config: { components: {} },
3231
+ data: { root: {}, content: [] },
3232
+ metadata: {}
3233
+ });
3234
+
3235
+ // components/DropZone/index.tsx
3236
+ var import_jsx_runtime9 = require("react/jsx-runtime");
3237
+ var getClassName6 = get_class_name_factory_default("DropZone", styles_module_default4);
3238
+ var getRandomColor = () => `#${Math.floor(Math.random() * 16777215).toString(16)}`;
3239
+ var RENDER_DEBUG = false;
3240
+ var DropZoneEditPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(DropZoneEdit, __spreadValues({}, props));
3241
+ var DropZoneChild = ({
3242
+ zoneCompound,
3243
+ componentId,
3244
+ preview,
3245
+ index,
3246
+ isEnabled,
3247
+ dragAxis,
3248
+ collisionAxis,
3249
+ inDroppableZone
3250
+ }) => {
3251
+ var _a, _b;
3252
+ const metadata = useAppStore((s) => s.metadata);
3253
+ const puckProps = {
3254
+ renderDropZone: DropZoneEditPure,
3255
+ isEditing: true,
3256
+ dragRef: null,
3257
+ metadata
3258
+ };
3259
+ const ctx = (0, import_react25.useContext)(dropZoneContext);
3260
+ const { depth } = ctx;
3261
+ const nodeProps = useAppStore(
3262
+ (0, import_shallow3.useShallow)((s) => {
3263
+ var _a2;
3264
+ return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.flatData.props;
3265
+ })
3266
+ );
3267
+ const nodeType = useAppStore(
3268
+ (s) => {
3269
+ var _a2;
3270
+ return (_a2 = s.state.indexes.nodes[componentId]) == null ? void 0 : _a2.data.type;
3271
+ }
3272
+ );
3273
+ const node = { type: nodeType, props: nodeProps };
3274
+ const item = nodeProps ? node : (preview == null ? void 0 : preview.componentType) ? { type: preview.componentType, props: preview.props } : null;
3275
+ const componentConfig = useAppStore(
3276
+ (s) => (item == null ? void 0 : item.type) ? s.config.components[item.type] : null
3277
+ );
3278
+ const overrides = useAppStore((s) => s.overrides);
3279
+ const isLoading = useAppStore(
3280
+ (s) => {
3281
+ var _a2;
3282
+ return ((_a2 = s.componentState[componentId]) == null ? void 0 : _a2.loadingCount) > 0;
3283
+ }
3284
+ );
3285
+ const isSelected = useAppStore(
3286
+ (s) => {
3287
+ var _a2;
3288
+ return ((_a2 = s.selectedItem) == null ? void 0 : _a2.props.id) === componentId || false;
3289
+ }
3290
+ );
3291
+ let label = (_b = (_a = componentConfig == null ? void 0 : componentConfig.label) != null ? _a : item == null ? void 0 : item.type.toString()) != null ? _b : "Component";
3292
+ const renderPreview = (0, import_react25.useMemo)(
3293
+ () => function Preview3() {
3294
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(DrawerItemInner, { name: label, children: overrides.componentItem });
3295
+ },
3296
+ [componentId, label, overrides]
3297
+ );
3298
+ const defaultsProps = (0, import_react25.useMemo)(
3299
+ () => __spreadProps(__spreadValues(__spreadValues({}, componentConfig == null ? void 0 : componentConfig.defaultProps), item == null ? void 0 : item.props), {
3300
+ puck: puckProps,
3301
+ editMode: true
3302
+ // DEPRECATED
3303
+ }),
3304
+ [componentConfig == null ? void 0 : componentConfig.defaultProps, item == null ? void 0 : item.props, puckProps]
3305
+ );
3306
+ const defaultedPropsWithSlots = useSlots(
3307
+ componentConfig,
3308
+ defaultsProps,
3309
+ DropZoneEditPure
3310
+ );
3311
+ if (!item) return;
3312
+ let Render2 = componentConfig ? componentConfig.render : () => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { style: { padding: 48, textAlign: "center" }, children: [
3313
+ "No configuration for ",
3314
+ item.type
3315
+ ] });
3316
+ let componentType = item.type;
3317
+ const isPreview = componentId === (preview == null ? void 0 : preview.props.id) && preview.type === "insert";
3318
+ if (isPreview) {
3319
+ Render2 = renderPreview;
3320
+ }
3321
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3322
+ DraggableComponent,
3323
+ {
3324
+ id: componentId,
3325
+ componentType,
3326
+ zoneCompound,
3327
+ depth: depth + 1,
3328
+ index,
3329
+ isLoading,
3330
+ isSelected,
3331
+ label,
3332
+ isEnabled,
3333
+ autoDragAxis: dragAxis,
3334
+ userDragAxis: collisionAxis,
3335
+ inDroppableZone,
3336
+ children: (dragRef) => (componentConfig == null ? void 0 : componentConfig.inline) && !isPreview ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3337
+ Render2,
3338
+ __spreadProps(__spreadValues({}, defaultedPropsWithSlots), {
3339
+ puck: __spreadProps(__spreadValues({}, defaultedPropsWithSlots.puck), {
3340
+ dragRef
3341
+ })
3342
+ })
3343
+ ) }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { ref: dragRef, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Render2, __spreadValues({}, defaultedPropsWithSlots)) })
3344
+ }
3345
+ );
3346
+ };
3347
+ var DropZoneEdit = (0, import_react25.forwardRef)(
3348
+ function DropZoneEditInternal({
3349
+ zone,
3350
+ allow,
3351
+ disallow,
3352
+ style,
3353
+ className,
3354
+ minEmptyHeight: userMinEmptyHeight = 128,
3355
+ collisionAxis
3356
+ }, userRef) {
3357
+ const ctx = (0, import_react25.useContext)(dropZoneContext);
3358
+ const {
3359
+ // These all need setting via context
3360
+ areaId,
3361
+ depth,
3362
+ registerLocalZone,
3363
+ unregisterLocalZone
3364
+ } = ctx;
3365
+ const path = useAppStore(
3366
+ (0, import_shallow3.useShallow)((s) => {
3367
+ var _a;
3368
+ return areaId ? (_a = s.state.indexes.nodes[areaId]) == null ? void 0 : _a.path : null;
3369
+ })
3370
+ );
3371
+ let zoneCompound = rootDroppableId;
3372
+ if (areaId) {
3373
+ if (zone !== rootDroppableId) {
3374
+ zoneCompound = `${areaId}:${zone}`;
3375
+ }
3376
+ }
3377
+ const isRootZone = zoneCompound === rootDroppableId || zone === rootDroppableId || areaId === "root";
3378
+ const {
3379
+ isDeepestZone,
3380
+ inNextDeepestArea,
3381
+ draggedComponentType,
3382
+ userIsDragging
3383
+ } = useContextStore(ZoneStoreContext, (s) => {
3384
+ var _a, _b;
3385
+ return {
3386
+ isDeepestZone: (_a = s.zoneDepthIndex[zoneCompound]) != null ? _a : false,
3387
+ inNextDeepestArea: s.nextAreaDepthIndex[areaId || ""],
3388
+ draggedComponentType: (_b = s.draggedItem) == null ? void 0 : _b.data.componentType,
3389
+ userIsDragging: !!s.draggedItem
3390
+ };
3391
+ });
3392
+ const zoneContentIds = useAppStore(
3393
+ (0, import_shallow3.useShallow)((s) => {
3394
+ var _a;
3395
+ return (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.contentIds;
3396
+ })
3397
+ );
3398
+ const zoneType = useAppStore(
3399
+ (0, import_shallow3.useShallow)((s) => {
3400
+ var _a;
3401
+ return (_a = s.state.indexes.zones[zoneCompound]) == null ? void 0 : _a.type;
3402
+ })
3403
+ );
3404
+ (0, import_react25.useEffect)(() => {
3405
+ if (!zoneType || zoneType === "dropzone") {
3406
+ if (ctx == null ? void 0 : ctx.registerZone) {
3407
+ ctx == null ? void 0 : ctx.registerZone(zoneCompound);
3408
+ }
3409
+ return () => {
3410
+ if (ctx == null ? void 0 : ctx.unregisterZone) {
3411
+ ctx == null ? void 0 : ctx.unregisterZone(zoneCompound);
3412
+ }
3413
+ };
3414
+ }
3415
+ }, [zoneType]);
3416
+ const contentIds = (0, import_react25.useMemo)(() => {
3417
+ return zoneContentIds || [];
3418
+ }, [zoneContentIds]);
3419
+ const ref = (0, import_react25.useRef)(null);
3420
+ const acceptsTarget = (0, import_react25.useCallback)(
3421
+ (componentType) => {
3422
+ if (!componentType) {
3423
+ return true;
3424
+ }
3425
+ if (disallow) {
3426
+ const defaultedAllow = allow || [];
3427
+ const filteredDisallow = (disallow || []).filter(
3428
+ (item) => defaultedAllow.indexOf(item) === -1
3429
+ );
3430
+ if (filteredDisallow.indexOf(componentType) !== -1) {
3431
+ return false;
3432
+ }
3433
+ } else if (allow) {
3434
+ if (allow.indexOf(componentType) === -1) {
3435
+ return false;
3436
+ }
3437
+ }
3438
+ return true;
3439
+ },
3440
+ [allow, disallow]
3441
+ );
3442
+ (0, import_react25.useEffect)(() => {
3443
+ if (registerLocalZone) {
3444
+ registerLocalZone(zoneCompound, acceptsTarget(draggedComponentType));
3445
+ }
3446
+ return () => {
3447
+ if (unregisterLocalZone) {
3448
+ unregisterLocalZone(zoneCompound);
3449
+ }
3450
+ };
3451
+ }, [draggedComponentType, zoneCompound]);
3452
+ const hoveringOverArea = inNextDeepestArea || isRootZone;
3453
+ let isEnabled = true;
3454
+ if (userIsDragging) {
3455
+ isEnabled = isDeepestZone;
3456
+ }
3457
+ if (isEnabled) {
3458
+ isEnabled = acceptsTarget(draggedComponentType);
3459
+ }
3460
+ const [contentIdsWithPreview, preview] = useContentIdsWithPreview(
3461
+ contentIds,
3462
+ zoneCompound
3463
+ );
3464
+ const isDropEnabled = isEnabled && (preview ? contentIdsWithPreview.length === 1 : contentIdsWithPreview.length === 0);
3465
+ const droppableConfig = {
3466
+ id: zoneCompound,
3467
+ collisionPriority: isEnabled ? depth : 0,
3468
+ disabled: !isDropEnabled,
3469
+ collisionDetector: pointerIntersection,
3470
+ type: "dropzone",
3471
+ data: {
3472
+ areaId,
3473
+ depth,
3474
+ isDroppableTarget: acceptsTarget(draggedComponentType),
3475
+ path: path || []
3476
+ }
3477
+ };
3478
+ const { ref: dropRef } = useDroppableSafe(droppableConfig);
3479
+ const isAreaSelected = useAppStore(
3480
+ (s) => (s == null ? void 0 : s.selectedItem) && areaId === (s == null ? void 0 : s.selectedItem.props.id)
3481
+ );
3482
+ const [dragAxis] = useDragAxis(ref, collisionAxis);
3483
+ const [minEmptyHeight, isAnimating] = useMinEmptyHeight({
3484
+ zoneCompound,
3485
+ userMinEmptyHeight,
3486
+ ref
3487
+ });
3488
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3489
+ "div",
3490
+ {
3491
+ className: `${getClassName6({
3492
+ isRootZone,
3493
+ userIsDragging,
3494
+ hoveringOverArea,
3495
+ isEnabled,
3496
+ isAreaSelected,
3497
+ hasChildren: contentIds.length > 0,
3498
+ isAnimating
3499
+ })}${className ? ` ${className}` : ""}`,
3500
+ ref: (node) => {
3501
+ assignRefs([ref, dropRef, userRef], node);
3502
+ },
3503
+ "data-testid": `dropzone:${zoneCompound}`,
3504
+ "data-puck-dropzone": zoneCompound,
3505
+ style: __spreadProps(__spreadValues({}, style), {
3506
+ "--min-empty-height": `${minEmptyHeight}px`,
3507
+ backgroundColor: RENDER_DEBUG ? getRandomColor() : style == null ? void 0 : style.backgroundColor
3508
+ }),
3509
+ children: contentIdsWithPreview.map((componentId, i) => {
3510
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3511
+ DropZoneChild,
3512
+ {
3513
+ zoneCompound,
3514
+ componentId,
3515
+ preview,
3516
+ dragAxis,
3517
+ isEnabled,
3518
+ index: i,
3519
+ collisionAxis,
3520
+ inDroppableZone: acceptsTarget(draggedComponentType)
3521
+ },
3522
+ componentId
3523
+ );
3524
+ })
3525
+ }
3526
+ );
3527
+ }
3528
+ );
3529
+ var DropZoneRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(DropZoneRender, __spreadValues({}, props));
3530
+ var DropZoneRender = (0, import_react25.forwardRef)(
3531
+ function DropZoneRenderInternal({ className, style, zone }, ref) {
3532
+ const ctx = (0, import_react25.useContext)(dropZoneContext);
3533
+ const { areaId = "root" } = ctx || {};
3534
+ const { config, data, metadata } = (0, import_react25.useContext)(renderContext);
3535
+ let zoneCompound = rootDroppableId;
3536
+ let content = (data == null ? void 0 : data.content) || [];
3537
+ (0, import_react25.useEffect)(() => {
3538
+ if (!content) {
3539
+ if (ctx == null ? void 0 : ctx.registerZone) {
3540
+ ctx == null ? void 0 : ctx.registerZone(zoneCompound);
3541
+ }
3542
+ return () => {
3543
+ if (ctx == null ? void 0 : ctx.unregisterZone) {
3544
+ ctx == null ? void 0 : ctx.unregisterZone(zoneCompound);
3545
+ }
3546
+ };
3547
+ }
3548
+ }, [content]);
3549
+ if (!data || !config) {
3550
+ return null;
3551
+ }
3552
+ if (areaId !== rootAreaId && zone !== rootZone) {
3553
+ zoneCompound = `${areaId}:${zone}`;
3554
+ content = setupZone(data, zoneCompound).zones[zoneCompound];
3555
+ }
3556
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className, style, ref, children: content.map((item) => {
3557
+ const Component = config.components[item.type];
3558
+ if (Component) {
3559
+ const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3560
+ SlotRenderPure,
3561
+ __spreadProps(__spreadValues({}, slotProps), {
3562
+ config,
3563
+ metadata
3564
+ })
3565
+ ));
3566
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3567
+ DropZoneProvider,
3568
+ {
3569
+ value: {
3570
+ areaId: props.id,
3571
+ depth: 1
3572
+ },
3573
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
3574
+ Component.render,
3575
+ __spreadProps(__spreadValues({}, props), {
3576
+ puck: {
3577
+ renderDropZone: DropZoneRenderPure,
3578
+ metadata: metadata || {}
3579
+ }
3580
+ })
3581
+ )
3582
+ },
3583
+ props.id
3584
+ );
3585
+ }
3586
+ return null;
3587
+ }) });
3588
+ }
3589
+ );
3590
+ var DropZone = (0, import_react25.forwardRef)(
3591
+ function DropZone2(props, ref) {
3592
+ const ctx = (0, import_react25.useContext)(dropZoneContext);
3593
+ if ((ctx == null ? void 0 : ctx.mode) === "edit") {
3594
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(DropZoneEdit, __spreadProps(__spreadValues({}, props), { ref })) });
3595
+ }
3596
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(DropZoneRender, __spreadProps(__spreadValues({}, props), { ref })) });
3597
+ }
3598
+ );
3599
+
3600
+ // components/SlotRender/index.tsx
3601
+ var import_jsx_runtime10 = require("react/jsx-runtime");
3602
+ var SlotRenderPure = (props) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(SlotRender, __spreadValues({}, props));
3603
+ var SlotRender = (0, import_react26.forwardRef)(
3604
+ function SlotRenderInternal({ className, style, content, config, metadata }, ref) {
3605
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className, style, ref, children: content.map((item) => {
3606
+ const Component = config.components[item.type];
3607
+ if (Component) {
3608
+ const props = useSlots(Component, item.props, (slotProps) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
3609
+ SlotRenderPure,
3610
+ __spreadProps(__spreadValues({}, slotProps), {
3611
+ config,
3612
+ metadata
3613
+ })
3614
+ ));
3615
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
3616
+ Component.render,
3617
+ __spreadProps(__spreadValues({}, props), {
3618
+ puck: {
3619
+ renderDropZone: DropZoneRenderPure,
3620
+ metadata: metadata || {}
3621
+ }
3622
+ }),
3623
+ props.id
3624
+ );
3625
+ }
3626
+ return null;
3627
+ }) });
3628
+ }
3629
+ );
3630
+
3631
+ // components/ServerRender/index.tsx
3632
+ var import_jsx_runtime11 = require("react/jsx-runtime");
3633
+ function DropZoneRender2({
3634
+ zone,
3635
+ data,
3636
+ areaId = "root",
3637
+ config,
3638
+ metadata = {}
3639
+ }) {
3640
+ let zoneCompound = rootDroppableId;
3641
+ let content = (data == null ? void 0 : data.content) || [];
3642
+ if (!data || !config) {
3643
+ return null;
3644
+ }
3645
+ if (areaId !== rootAreaId && zone !== rootZone) {
3646
+ zoneCompound = `${areaId}:${zone}`;
3647
+ content = setupZone(data, zoneCompound).zones[zoneCompound];
3648
+ }
3649
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_jsx_runtime11.Fragment, { children: content.map((item) => {
3650
+ const Component = config.components[item.type];
3651
+ const props = __spreadProps(__spreadValues({}, item.props), {
3652
+ puck: {
3653
+ renderDropZone: ({ zone: zone2 }) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
3654
+ DropZoneRender2,
3655
+ {
3656
+ zone: zone2,
3657
+ data,
3658
+ areaId: item.props.id,
3659
+ config,
3660
+ metadata
3661
+ }
3662
+ ),
3663
+ metadata
3664
+ }
3665
+ });
3666
+ const propsWithSlots = useSlots(config.root, props, (props2) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, props2), { config, metadata })));
3667
+ if (Component) {
3668
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Component.render, __spreadValues({}, propsWithSlots), item.props.id);
3669
+ }
3670
+ return null;
3671
+ }) });
3672
+ }
3673
+ function Render({
3674
+ config,
3675
+ data,
3676
+ metadata = {}
3677
+ }) {
3678
+ var _a;
3679
+ const rootProps = data.root.props || data.root;
3680
+ const title = rootProps.title || "";
3681
+ const props = __spreadProps(__spreadValues({}, rootProps), {
3682
+ puck: {
3683
+ renderDropZone: ({ zone }) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
3684
+ DropZoneRender2,
3685
+ {
3686
+ zone,
3687
+ data,
3688
+ config,
3689
+ metadata
3690
+ }
3691
+ ),
3692
+ isEditing: false,
3693
+ dragRef: null,
3694
+ metadata
3695
+ },
3696
+ title,
3697
+ editMode: false,
3698
+ id: "puck-root"
3699
+ });
3700
+ const propsWithSlots = useSlots(config.root, props, (props2) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(SlotRenderPure, __spreadProps(__spreadValues({}, props2), { config, metadata })));
3701
+ if ((_a = config.root) == null ? void 0 : _a.render) {
3702
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(config.root.render, __spreadProps(__spreadValues({}, propsWithSlots), { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
3703
+ DropZoneRender2,
3704
+ {
3705
+ config,
3706
+ data,
3707
+ zone: rootZone,
3708
+ metadata
3709
+ }
3710
+ ) }));
3711
+ }
3712
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
3713
+ DropZoneRender2,
3714
+ {
3715
+ config,
3716
+ data,
3717
+ zone: rootZone,
3718
+ metadata
3719
+ }
3720
+ );
3721
+ }
3722
+
3723
+ // lib/resolve-all-data.ts
3724
+ init_react_import();
3725
+
3726
+ // lib/default-data.ts
3727
+ init_react_import();
3728
+ var defaultData = (data) => __spreadProps(__spreadValues({}, data), {
3729
+ root: data.root || {},
3730
+ content: data.content || []
3731
+ });
3732
+
3733
+ // lib/to-component.ts
3734
+ init_react_import();
3735
+ var toComponent = (item) => {
3736
+ return "type" in item ? item : __spreadProps(__spreadValues({}, item), {
3737
+ props: __spreadProps(__spreadValues({}, item.props), { id: "root" }),
3738
+ type: "root"
3739
+ });
3740
+ };
3741
+
3742
+ // lib/resolve-all-data.ts
3743
+ function resolveAllData(_0, _1) {
3744
+ return __async(this, arguments, function* (data, config, metadata = {}, onResolveStart, onResolveEnd) {
3745
+ var _a;
3746
+ const defaultedData = defaultData(data);
3747
+ const resolveNode = (_node) => __async(this, null, function* () {
3748
+ const node = toComponent(_node);
3749
+ onResolveStart == null ? void 0 : onResolveStart(node);
3750
+ const resolved = (yield resolveComponentData(
3751
+ node,
3752
+ config,
3753
+ metadata,
3754
+ () => {
3755
+ },
3756
+ () => {
3757
+ },
3758
+ "force",
3759
+ false
3760
+ )).node;
3761
+ const resolvedDeep = yield mapSlots(resolved, processContent, false);
3762
+ onResolveEnd == null ? void 0 : onResolveEnd(toComponent(resolvedDeep));
3763
+ return resolvedDeep;
3764
+ });
3765
+ const processContent = (content) => __async(this, null, function* () {
3766
+ return Promise.all(content.map(resolveNode));
3767
+ });
3768
+ const dynamic = {
3769
+ root: yield resolveNode(defaultedData.root),
3770
+ content: yield processContent(defaultedData.content),
3771
+ zones: {}
3772
+ };
3773
+ Object.keys((_a = defaultedData.zones) != null ? _a : {}).forEach((zoneKey) => __async(this, null, function* () {
3774
+ const content = defaultedData.zones[zoneKey];
3775
+ dynamic.zones[zoneKey] = yield processContent(content);
3776
+ }), {});
3777
+ return dynamic;
3778
+ });
3779
+ }
3780
+
3781
+ // lib/transform-props.ts
3782
+ init_react_import();
3783
+ function transformProps(data, propTransforms) {
3784
+ const mapItem = (item) => {
3785
+ if (propTransforms[item.type]) {
3786
+ return __spreadProps(__spreadValues({}, item), {
3787
+ props: propTransforms[item.type](item.props)
3788
+ });
3789
+ }
3790
+ return item;
3791
+ };
3792
+ const defaultedData = defaultData(data);
3793
+ const rootProps = defaultedData.root.props || defaultedData.root;
3794
+ let newRoot = __spreadValues({}, defaultedData.root);
3795
+ if (propTransforms["root"]) {
3796
+ if (defaultedData.root.props) {
3797
+ newRoot.props = propTransforms["root"](rootProps);
3798
+ } else {
3799
+ newRoot = propTransforms["root"](rootProps);
3800
+ }
3801
+ }
3802
+ const afterPropTransforms = __spreadProps(__spreadValues({}, defaultedData), {
3803
+ root: newRoot,
3804
+ content: defaultedData.content.map(mapItem),
3805
+ zones: Object.keys(data.zones || {}).reduce(
3806
+ (acc, zoneKey) => __spreadProps(__spreadValues({}, acc), {
3807
+ [zoneKey]: data.zones[zoneKey].map(mapItem)
3808
+ }),
3809
+ {}
3810
+ )
3811
+ });
3812
+ return afterPropTransforms;
3813
+ }
3814
+ // Annotate the CommonJS export names for ESM import in node:
3815
+ 0 && (module.exports = {
3816
+ Render,
3817
+ resolveAllData,
3818
+ transformProps
3819
+ });
3820
+ /*! Bundled license information:
3821
+
3822
+ classnames/index.js:
3823
+ (*!
3824
+ Copyright (c) 2018 Jed Watson.
3825
+ Licensed under the MIT License (MIT), see
3826
+ http://jedwatson.github.io/classnames
3827
+ *)
3828
+
3829
+ lucide-react/dist/esm/shared/src/utils.js:
3830
+ (**
3831
+ * @license lucide-react v0.468.0 - ISC
3832
+ *
3833
+ * This source code is licensed under the ISC license.
3834
+ * See the LICENSE file in the root directory of this source tree.
3835
+ *)
3836
+
3837
+ lucide-react/dist/esm/defaultAttributes.js:
3838
+ (**
3839
+ * @license lucide-react v0.468.0 - ISC
3840
+ *
3841
+ * This source code is licensed under the ISC license.
3842
+ * See the LICENSE file in the root directory of this source tree.
3843
+ *)
3844
+
3845
+ lucide-react/dist/esm/Icon.js:
3846
+ (**
3847
+ * @license lucide-react v0.468.0 - ISC
3848
+ *
3849
+ * This source code is licensed under the ISC license.
3850
+ * See the LICENSE file in the root directory of this source tree.
3851
+ *)
3852
+
3853
+ lucide-react/dist/esm/createLucideIcon.js:
3854
+ (**
3855
+ * @license lucide-react v0.468.0 - ISC
3856
+ *
3857
+ * This source code is licensed under the ISC license.
3858
+ * See the LICENSE file in the root directory of this source tree.
3859
+ *)
3860
+
3861
+ lucide-react/dist/esm/icons/copy.js:
3862
+ (**
3863
+ * @license lucide-react v0.468.0 - ISC
3864
+ *
3865
+ * This source code is licensed under the ISC license.
3866
+ * See the LICENSE file in the root directory of this source tree.
3867
+ *)
3868
+
3869
+ lucide-react/dist/esm/icons/corner-left-up.js:
3870
+ (**
3871
+ * @license lucide-react v0.468.0 - ISC
3872
+ *
3873
+ * This source code is licensed under the ISC license.
3874
+ * See the LICENSE file in the root directory of this source tree.
3875
+ *)
3876
+
3877
+ lucide-react/dist/esm/icons/trash.js:
3878
+ (**
3879
+ * @license lucide-react v0.468.0 - ISC
3880
+ *
3881
+ * This source code is licensed under the ISC license.
3882
+ * See the LICENSE file in the root directory of this source tree.
3883
+ *)
3884
+
3885
+ lucide-react/dist/esm/lucide-react.js:
3886
+ (**
3887
+ * @license lucide-react v0.468.0 - ISC
3888
+ *
3889
+ * This source code is licensed under the ISC license.
3890
+ * See the LICENSE file in the root directory of this source tree.
3891
+ *)
3892
+ */