@measured/puck-plugin-heading-analyzer 0.20.0-canary.755737e8 → 0.20.0-canary.77cef35d

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/index.mjs CHANGED
@@ -55,6 +55,26 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
55
55
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
56
56
  mod
57
57
  ));
58
+ var __async = (__this, __arguments, generator) => {
59
+ return new Promise((resolve, reject) => {
60
+ var fulfilled = (value) => {
61
+ try {
62
+ step(generator.next(value));
63
+ } catch (e) {
64
+ reject(e);
65
+ }
66
+ };
67
+ var rejected = (value) => {
68
+ try {
69
+ step(generator.throw(value));
70
+ } catch (e) {
71
+ reject(e);
72
+ }
73
+ };
74
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
75
+ step((generator = generator.apply(__this, __arguments)).next());
76
+ });
77
+ };
58
78
 
59
79
  // ../tsup-config/react-import.js
60
80
  import React from "react";
@@ -126,12 +146,162 @@ var require_classnames = __commonJS({
126
146
  }
127
147
  });
128
148
 
149
+ // ../../node_modules/flat/index.js
150
+ var require_flat = __commonJS({
151
+ "../../node_modules/flat/index.js"(exports, module) {
152
+ "use strict";
153
+ init_react_import();
154
+ module.exports = flatten3;
155
+ flatten3.flatten = flatten3;
156
+ flatten3.unflatten = unflatten2;
157
+ function isBuffer(obj) {
158
+ return obj && obj.constructor && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj);
159
+ }
160
+ function keyIdentity(key) {
161
+ return key;
162
+ }
163
+ function flatten3(target, opts) {
164
+ opts = opts || {};
165
+ const delimiter = opts.delimiter || ".";
166
+ const maxDepth = opts.maxDepth;
167
+ const transformKey = opts.transformKey || keyIdentity;
168
+ const output = {};
169
+ function step(object, prev, currentDepth) {
170
+ currentDepth = currentDepth || 1;
171
+ Object.keys(object).forEach(function(key) {
172
+ const value = object[key];
173
+ const isarray = opts.safe && Array.isArray(value);
174
+ const type = Object.prototype.toString.call(value);
175
+ const isbuffer = isBuffer(value);
176
+ const isobject = type === "[object Object]" || type === "[object Array]";
177
+ const newKey = prev ? prev + delimiter + transformKey(key) : transformKey(key);
178
+ if (!isarray && !isbuffer && isobject && Object.keys(value).length && (!opts.maxDepth || currentDepth < maxDepth)) {
179
+ return step(value, newKey, currentDepth + 1);
180
+ }
181
+ output[newKey] = value;
182
+ });
183
+ }
184
+ step(target);
185
+ return output;
186
+ }
187
+ function unflatten2(target, opts) {
188
+ opts = opts || {};
189
+ const delimiter = opts.delimiter || ".";
190
+ const overwrite = opts.overwrite || false;
191
+ const transformKey = opts.transformKey || keyIdentity;
192
+ const result = {};
193
+ const isbuffer = isBuffer(target);
194
+ if (isbuffer || Object.prototype.toString.call(target) !== "[object Object]") {
195
+ return target;
196
+ }
197
+ function getkey(key) {
198
+ const parsedKey = Number(key);
199
+ return isNaN(parsedKey) || key.indexOf(".") !== -1 || opts.object ? key : parsedKey;
200
+ }
201
+ function addKeys(keyPrefix, recipient, target2) {
202
+ return Object.keys(target2).reduce(function(result2, key) {
203
+ result2[keyPrefix + delimiter + key] = target2[key];
204
+ return result2;
205
+ }, recipient);
206
+ }
207
+ function isEmpty(val) {
208
+ const type = Object.prototype.toString.call(val);
209
+ const isArray = type === "[object Array]";
210
+ const isObject = type === "[object Object]";
211
+ if (!val) {
212
+ return true;
213
+ } else if (isArray) {
214
+ return !val.length;
215
+ } else if (isObject) {
216
+ return !Object.keys(val).length;
217
+ }
218
+ }
219
+ target = Object.keys(target).reduce(function(result2, key) {
220
+ const type = Object.prototype.toString.call(target[key]);
221
+ const isObject = type === "[object Object]" || type === "[object Array]";
222
+ if (!isObject || isEmpty(target[key])) {
223
+ result2[key] = target[key];
224
+ return result2;
225
+ } else {
226
+ return addKeys(
227
+ key,
228
+ result2,
229
+ flatten3(target[key], opts)
230
+ );
231
+ }
232
+ }, {});
233
+ Object.keys(target).forEach(function(key) {
234
+ const split = key.split(delimiter).map(transformKey);
235
+ let key1 = getkey(split.shift());
236
+ let key2 = getkey(split[0]);
237
+ let recipient = result;
238
+ while (key2 !== void 0) {
239
+ if (key1 === "__proto__") {
240
+ return;
241
+ }
242
+ const type = Object.prototype.toString.call(recipient[key1]);
243
+ const isobject = type === "[object Object]" || type === "[object Array]";
244
+ if (!overwrite && !isobject && typeof recipient[key1] !== "undefined") {
245
+ return;
246
+ }
247
+ if (overwrite && !isobject || !overwrite && recipient[key1] == null) {
248
+ recipient[key1] = typeof key2 === "number" && !opts.object ? [] : {};
249
+ }
250
+ recipient = recipient[key1];
251
+ if (split.length > 0) {
252
+ key1 = getkey(split.shift());
253
+ key2 = getkey(split[0]);
254
+ }
255
+ }
256
+ recipient[key1] = unflatten2(target[key], opts);
257
+ });
258
+ return result;
259
+ }
260
+ }
261
+ });
262
+
263
+ // ../../node_modules/fast-deep-equal/index.js
264
+ var require_fast_deep_equal = __commonJS({
265
+ "../../node_modules/fast-deep-equal/index.js"(exports, module) {
266
+ "use strict";
267
+ init_react_import();
268
+ module.exports = function equal(a, b) {
269
+ if (a === b) return true;
270
+ if (a && b && typeof a == "object" && typeof b == "object") {
271
+ if (a.constructor !== b.constructor) return false;
272
+ var length, i, keys;
273
+ if (Array.isArray(a)) {
274
+ length = a.length;
275
+ if (length != b.length) return false;
276
+ for (i = length; i-- !== 0; )
277
+ if (!equal(a[i], b[i])) return false;
278
+ return true;
279
+ }
280
+ if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
281
+ if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
282
+ if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
283
+ keys = Object.keys(a);
284
+ length = keys.length;
285
+ if (length !== Object.keys(b).length) return false;
286
+ for (i = length; i-- !== 0; )
287
+ if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
288
+ for (i = length; i-- !== 0; ) {
289
+ var key = keys[i];
290
+ if (!equal(a[key], b[key])) return false;
291
+ }
292
+ return true;
293
+ }
294
+ return a !== a && b !== b;
295
+ };
296
+ }
297
+ });
298
+
129
299
  // index.ts
130
300
  init_react_import();
131
301
 
132
302
  // src/HeadingAnalyzer.tsx
133
303
  init_react_import();
134
- import { useEffect, useState } from "react";
304
+ import { useEffect as useEffect5, useState } from "react";
135
305
 
136
306
  // css-module:/home/runner/work/puck/puck/packages/plugin-heading-analyzer/src/HeadingAnalyzer.module.css#css-module
137
307
  init_react_import();
@@ -326,6 +496,1652 @@ init_react_import();
326
496
  // ../core/lib/data/replace.ts
327
497
  init_react_import();
328
498
 
499
+ // ../core/lib/use-reset-auto-zoom.ts
500
+ init_react_import();
501
+
502
+ // ../core/store/index.ts
503
+ init_react_import();
504
+
505
+ // ../core/reducer/index.ts
506
+ init_react_import();
507
+
508
+ // ../core/reducer/actions/set.ts
509
+ init_react_import();
510
+
511
+ // ../core/lib/data/walk-app-state.ts
512
+ init_react_import();
513
+
514
+ // ../core/lib/data/for-related-zones.ts
515
+ init_react_import();
516
+
517
+ // ../core/lib/get-zone-id.ts
518
+ init_react_import();
519
+
520
+ // ../core/lib/root-droppable-id.ts
521
+ init_react_import();
522
+ var rootAreaId = "root";
523
+ var rootZone = "default-zone";
524
+ var rootDroppableId = `${rootAreaId}:${rootZone}`;
525
+
526
+ // ../core/lib/get-zone-id.ts
527
+ var getZoneId = (zoneCompound) => {
528
+ if (!zoneCompound) {
529
+ return [];
530
+ }
531
+ if (zoneCompound && zoneCompound.indexOf(":") > -1) {
532
+ return zoneCompound.split(":");
533
+ }
534
+ return [rootDroppableId, zoneCompound];
535
+ };
536
+
537
+ // ../core/lib/data/for-related-zones.ts
538
+ function forRelatedZones(item, data, cb, path = []) {
539
+ Object.entries(data.zones || {}).forEach(([zoneCompound, content]) => {
540
+ const [parentId] = getZoneId(zoneCompound);
541
+ if (parentId === item.props.id) {
542
+ cb(path, zoneCompound, content);
543
+ }
544
+ });
545
+ }
546
+
547
+ // ../core/lib/data/map-fields.ts
548
+ init_react_import();
549
+
550
+ // ../core/lib/data/default-slots.ts
551
+ init_react_import();
552
+ var defaultSlots = (value, fields) => Object.keys(fields).reduce(
553
+ (acc, fieldName) => fields[fieldName].type === "slot" ? __spreadValues({ [fieldName]: [] }, acc) : acc,
554
+ value
555
+ );
556
+
557
+ // ../core/lib/data/map-fields.ts
558
+ var isPromise = (v) => !!v && typeof v.then === "function";
559
+ var flatten = (values) => values.reduce((acc, item) => __spreadValues(__spreadValues({}, acc), item), {});
560
+ var containsPromise = (arr) => arr.some(isPromise);
561
+ var walkField = ({
562
+ value,
563
+ fields,
564
+ mappers,
565
+ propKey = "",
566
+ propPath = "",
567
+ id = "",
568
+ config,
569
+ recurseSlots = false
570
+ }) => {
571
+ var _a, _b, _c;
572
+ const fieldType = (_a = fields[propKey]) == null ? void 0 : _a.type;
573
+ const map = mappers[fieldType];
574
+ if (map && fieldType === "slot") {
575
+ const content = value || [];
576
+ const mappedContent = recurseSlots ? content.map((el) => {
577
+ var _a2;
578
+ const componentConfig = config.components[el.type];
579
+ if (!componentConfig) {
580
+ throw new Error(`Could not find component config for ${el.type}`);
581
+ }
582
+ const fields2 = (_a2 = componentConfig.fields) != null ? _a2 : {};
583
+ return walkField({
584
+ value: __spreadProps(__spreadValues({}, el), { props: defaultSlots(el.props, fields2) }),
585
+ fields: fields2,
586
+ mappers,
587
+ id: el.props.id,
588
+ config,
589
+ recurseSlots
590
+ });
591
+ }) : content;
592
+ if (containsPromise(mappedContent)) {
593
+ return Promise.all(mappedContent);
594
+ }
595
+ return map({
596
+ value: mappedContent,
597
+ parentId: id,
598
+ propName: propKey,
599
+ field: fields[propKey],
600
+ propPath
601
+ });
602
+ } else if (map && fields[propKey]) {
603
+ return map({
604
+ value,
605
+ parentId: id,
606
+ propName: propKey,
607
+ field: fields[propKey],
608
+ propPath
609
+ });
610
+ }
611
+ if (value && typeof value === "object") {
612
+ if (Array.isArray(value)) {
613
+ const arrayFields = ((_b = fields[propKey]) == null ? void 0 : _b.type) === "array" ? fields[propKey].arrayFields : null;
614
+ if (!arrayFields) return value;
615
+ const newValue = value.map(
616
+ (el, idx) => walkField({
617
+ value: el,
618
+ fields: arrayFields,
619
+ mappers,
620
+ propKey,
621
+ propPath: `${propPath}[${idx}]`,
622
+ id,
623
+ config,
624
+ recurseSlots
625
+ })
626
+ );
627
+ if (containsPromise(newValue)) {
628
+ return Promise.all(newValue);
629
+ }
630
+ return newValue;
631
+ } else if ("$$typeof" in value) {
632
+ return value;
633
+ } else {
634
+ const objectFields = ((_c = fields[propKey]) == null ? void 0 : _c.type) === "object" ? fields[propKey].objectFields : fields;
635
+ return walkObject({
636
+ value,
637
+ fields: objectFields,
638
+ mappers,
639
+ id,
640
+ getPropPath: (k) => `${propPath}.${k}`,
641
+ config,
642
+ recurseSlots
643
+ });
644
+ }
645
+ }
646
+ return value;
647
+ };
648
+ var walkObject = ({
649
+ value,
650
+ fields,
651
+ mappers,
652
+ id,
653
+ getPropPath,
654
+ config,
655
+ recurseSlots
656
+ }) => {
657
+ const newProps = Object.entries(value).map(([k, v]) => {
658
+ const opts = {
659
+ value: v,
660
+ fields,
661
+ mappers,
662
+ propKey: k,
663
+ propPath: getPropPath(k),
664
+ id,
665
+ config,
666
+ recurseSlots
667
+ };
668
+ const newValue = walkField(opts);
669
+ if (isPromise(newValue)) {
670
+ return newValue.then((resolvedValue) => ({
671
+ [k]: resolvedValue
672
+ }));
673
+ }
674
+ return {
675
+ [k]: newValue
676
+ };
677
+ }, {});
678
+ if (containsPromise(newProps)) {
679
+ return Promise.all(newProps).then(flatten);
680
+ }
681
+ return flatten(newProps);
682
+ };
683
+ function mapFields(item, mappers, config, recurseSlots = false) {
684
+ var _a, _b, _c, _d, _e;
685
+ const itemType = "type" in item ? item.type : "root";
686
+ const componentConfig = itemType === "root" ? config.root : (_a = config.components) == null ? void 0 : _a[itemType];
687
+ const newProps = walkObject({
688
+ value: defaultSlots((_b = item.props) != null ? _b : {}, (_c = componentConfig == null ? void 0 : componentConfig.fields) != null ? _c : {}),
689
+ fields: (_d = componentConfig == null ? void 0 : componentConfig.fields) != null ? _d : {},
690
+ mappers,
691
+ id: item.props ? (_e = item.props.id) != null ? _e : "root" : "root",
692
+ getPropPath: (k) => k,
693
+ config,
694
+ recurseSlots
695
+ });
696
+ if (isPromise(newProps)) {
697
+ return newProps.then((resolvedProps) => __spreadProps(__spreadValues({}, item), {
698
+ props: resolvedProps
699
+ }));
700
+ }
701
+ return __spreadProps(__spreadValues({}, item), {
702
+ props: newProps
703
+ });
704
+ }
705
+
706
+ // ../core/lib/data/flatten-node.ts
707
+ init_react_import();
708
+ var import_flat = __toESM(require_flat());
709
+
710
+ // ../core/lib/data/strip-slots.ts
711
+ init_react_import();
712
+ var stripSlots = (data, config) => {
713
+ return mapFields(data, { slot: () => null }, config);
714
+ };
715
+
716
+ // ../core/lib/data/flatten-node.ts
717
+ var { flatten: flatten2, unflatten } = import_flat.default;
718
+ var flattenNode = (node, config) => {
719
+ return __spreadProps(__spreadValues({}, node), {
720
+ props: flatten2(stripSlots(node, config).props)
721
+ });
722
+ };
723
+
724
+ // ../core/lib/data/walk-app-state.ts
725
+ function walkAppState(state, config, mapContent = (content) => content, mapNodeOrSkip = (item) => item) {
726
+ var _a;
727
+ let newZones = {};
728
+ const newZoneIndex = {};
729
+ const newNodeIndex = {};
730
+ const processContent = (path, zoneCompound, content, zoneType, newId) => {
731
+ var _a2;
732
+ const [parentId] = zoneCompound.split(":");
733
+ const mappedContent = ((_a2 = mapContent(content, zoneCompound, zoneType)) != null ? _a2 : content) || [];
734
+ const [_2, zone] = zoneCompound.split(":");
735
+ const newZoneCompound = `${newId || parentId}:${zone}`;
736
+ const newContent2 = mappedContent.map(
737
+ (zoneChild, index) => processItem(zoneChild, [...path, newZoneCompound], index)
738
+ );
739
+ newZoneIndex[newZoneCompound] = {
740
+ contentIds: newContent2.map((item) => item.props.id),
741
+ type: zoneType
742
+ };
743
+ return [newZoneCompound, newContent2];
744
+ };
745
+ const processRelatedZones = (item, newId, initialPath) => {
746
+ forRelatedZones(
747
+ item,
748
+ state.data,
749
+ (relatedPath, relatedZoneCompound, relatedContent) => {
750
+ const [zoneCompound, newContent2] = processContent(
751
+ relatedPath,
752
+ relatedZoneCompound,
753
+ relatedContent,
754
+ "dropzone",
755
+ newId
756
+ );
757
+ newZones[zoneCompound] = newContent2;
758
+ },
759
+ initialPath
760
+ );
761
+ };
762
+ const processItem = (item, path, index) => {
763
+ const mappedItem = mapNodeOrSkip(item, path, index);
764
+ if (!mappedItem) return item;
765
+ const id = mappedItem.props.id;
766
+ const newProps = __spreadProps(__spreadValues({}, mapFields(
767
+ mappedItem,
768
+ {
769
+ slot: ({ value, parentId: parentId2, propPath }) => {
770
+ const content = value;
771
+ const zoneCompound = `${parentId2}:${propPath}`;
772
+ const [_2, newContent2] = processContent(
773
+ path,
774
+ zoneCompound,
775
+ content,
776
+ "slot",
777
+ parentId2
778
+ );
779
+ return newContent2;
780
+ }
781
+ },
782
+ config
783
+ ).props), {
784
+ id
785
+ });
786
+ processRelatedZones(item, id, path);
787
+ const newItem = __spreadProps(__spreadValues({}, item), { props: newProps });
788
+ const thisZoneCompound = path[path.length - 1];
789
+ const [parentId, zone] = thisZoneCompound ? thisZoneCompound.split(":") : [null, ""];
790
+ newNodeIndex[id] = {
791
+ data: newItem,
792
+ flatData: flattenNode(newItem, config),
793
+ path,
794
+ parentId,
795
+ zone
796
+ };
797
+ const finalData = __spreadProps(__spreadValues({}, newItem), { props: __spreadValues({}, newItem.props) });
798
+ if (newProps.id === "root") {
799
+ delete finalData["type"];
800
+ delete finalData.props["id"];
801
+ }
802
+ return finalData;
803
+ };
804
+ const zones = state.data.zones || {};
805
+ const [_, newContent] = processContent(
806
+ [],
807
+ rootDroppableId,
808
+ state.data.content,
809
+ "root"
810
+ );
811
+ const processedContent = newContent;
812
+ const zonesAlreadyProcessed = Object.keys(newZones);
813
+ Object.keys(zones || {}).forEach((zoneCompound) => {
814
+ const [parentId] = zoneCompound.split(":");
815
+ if (zonesAlreadyProcessed.includes(zoneCompound)) {
816
+ return;
817
+ }
818
+ const [_2, newContent2] = processContent(
819
+ [rootDroppableId],
820
+ zoneCompound,
821
+ zones[zoneCompound],
822
+ "dropzone",
823
+ parentId
824
+ );
825
+ newZones[zoneCompound] = newContent2;
826
+ }, newZones);
827
+ const processedRoot = processItem(
828
+ {
829
+ type: "root",
830
+ props: __spreadProps(__spreadValues({}, (_a = state.data.root.props) != null ? _a : state.data.root), { id: "root" })
831
+ },
832
+ [],
833
+ -1
834
+ );
835
+ const root = __spreadProps(__spreadValues({}, state.data.root), {
836
+ props: processedRoot.props
837
+ });
838
+ return __spreadProps(__spreadValues({}, state), {
839
+ data: {
840
+ root,
841
+ content: processedContent,
842
+ zones: __spreadValues(__spreadValues({}, state.data.zones), newZones)
843
+ },
844
+ indexes: {
845
+ nodes: __spreadValues(__spreadValues({}, state.indexes.nodes), newNodeIndex),
846
+ zones: __spreadValues(__spreadValues({}, state.indexes.zones), newZoneIndex)
847
+ }
848
+ });
849
+ }
850
+
851
+ // ../core/reducer/actions/set.ts
852
+ var setAction = (state, action, appStore) => {
853
+ if (typeof action.state === "object") {
854
+ const newState = __spreadValues(__spreadValues({}, state), action.state);
855
+ if (action.state.indexes) {
856
+ return newState;
857
+ }
858
+ console.warn(
859
+ "`set` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
860
+ );
861
+ return walkAppState(newState, appStore.config);
862
+ }
863
+ return __spreadValues(__spreadValues({}, state), action.state(state));
864
+ };
865
+
866
+ // ../core/reducer/actions/insert.ts
867
+ init_react_import();
868
+
869
+ // ../core/lib/data/insert.ts
870
+ init_react_import();
871
+ var insert = (list, index, item) => {
872
+ const result = Array.from(list || []);
873
+ result.splice(index, 0, item);
874
+ return result;
875
+ };
876
+
877
+ // ../core/lib/generate-id.ts
878
+ init_react_import();
879
+
880
+ // ../../node_modules/uuid/dist/esm-node/index.js
881
+ init_react_import();
882
+
883
+ // ../../node_modules/uuid/dist/esm-node/rng.js
884
+ init_react_import();
885
+ import crypto from "crypto";
886
+ var rnds8Pool = new Uint8Array(256);
887
+ var poolPtr = rnds8Pool.length;
888
+ function rng() {
889
+ if (poolPtr > rnds8Pool.length - 16) {
890
+ crypto.randomFillSync(rnds8Pool);
891
+ poolPtr = 0;
892
+ }
893
+ return rnds8Pool.slice(poolPtr, poolPtr += 16);
894
+ }
895
+
896
+ // ../../node_modules/uuid/dist/esm-node/stringify.js
897
+ init_react_import();
898
+ var byteToHex = [];
899
+ for (let i = 0; i < 256; ++i) {
900
+ byteToHex.push((i + 256).toString(16).slice(1));
901
+ }
902
+ function unsafeStringify(arr, offset = 0) {
903
+ return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
904
+ }
905
+
906
+ // ../../node_modules/uuid/dist/esm-node/v4.js
907
+ init_react_import();
908
+
909
+ // ../../node_modules/uuid/dist/esm-node/native.js
910
+ init_react_import();
911
+ import crypto2 from "crypto";
912
+ var native_default = {
913
+ randomUUID: crypto2.randomUUID
914
+ };
915
+
916
+ // ../../node_modules/uuid/dist/esm-node/v4.js
917
+ function v4(options, buf, offset) {
918
+ if (native_default.randomUUID && !buf && !options) {
919
+ return native_default.randomUUID();
920
+ }
921
+ options = options || {};
922
+ const rnds = options.random || (options.rng || rng)();
923
+ rnds[6] = rnds[6] & 15 | 64;
924
+ rnds[8] = rnds[8] & 63 | 128;
925
+ if (buf) {
926
+ offset = offset || 0;
927
+ for (let i = 0; i < 16; ++i) {
928
+ buf[offset + i] = rnds[i];
929
+ }
930
+ return buf;
931
+ }
932
+ return unsafeStringify(rnds);
933
+ }
934
+ var v4_default = v4;
935
+
936
+ // ../core/lib/generate-id.ts
937
+ var generateId = (type) => type ? `${type}-${v4_default()}` : v4_default();
938
+
939
+ // ../core/lib/data/get-ids-for-parent.ts
940
+ init_react_import();
941
+ var getIdsForParent = (zoneCompound, state) => {
942
+ const [parentId] = zoneCompound.split(":");
943
+ const node = state.indexes.nodes[parentId];
944
+ return ((node == null ? void 0 : node.path) || []).map((p) => p.split(":")[0]);
945
+ };
946
+
947
+ // ../core/lib/data/populate-ids.ts
948
+ init_react_import();
949
+
950
+ // ../core/lib/data/walk-tree.ts
951
+ init_react_import();
952
+ function walkTree(data, config, callbackFn) {
953
+ var _a, _b;
954
+ const walkItem = (item) => {
955
+ return mapFields(
956
+ item,
957
+ {
958
+ slot: ({ value, parentId, propName }) => {
959
+ var _a2;
960
+ const content = value;
961
+ return (_a2 = callbackFn(content, { parentId, propName })) != null ? _a2 : content;
962
+ }
963
+ },
964
+ config,
965
+ true
966
+ );
967
+ };
968
+ if ("props" in data) {
969
+ return walkItem(data);
970
+ }
971
+ const _data = data;
972
+ const zones = (_a = _data.zones) != null ? _a : {};
973
+ const mappedContent = _data.content.map(walkItem);
974
+ return {
975
+ root: walkItem(_data.root),
976
+ content: (_b = callbackFn(mappedContent, {
977
+ parentId: "root",
978
+ propName: "default-zone"
979
+ })) != null ? _b : mappedContent,
980
+ zones: Object.keys(zones).reduce(
981
+ (acc, zoneCompound) => __spreadProps(__spreadValues({}, acc), {
982
+ [zoneCompound]: zones[zoneCompound].map(walkItem)
983
+ }),
984
+ {}
985
+ )
986
+ };
987
+ }
988
+
989
+ // ../core/lib/data/populate-ids.ts
990
+ var populateIds = (data, config, override = false) => {
991
+ const id = generateId(data.type);
992
+ return walkTree(
993
+ __spreadProps(__spreadValues({}, data), {
994
+ props: override ? __spreadProps(__spreadValues({}, data.props), { id }) : __spreadValues({}, data.props)
995
+ }),
996
+ config,
997
+ (contents) => contents.map((item) => {
998
+ const id2 = generateId(item.type);
999
+ return __spreadProps(__spreadValues({}, item), {
1000
+ props: override ? __spreadProps(__spreadValues({}, item.props), { id: id2 }) : __spreadValues({ id: id2 }, item.props)
1001
+ });
1002
+ })
1003
+ );
1004
+ };
1005
+
1006
+ // ../core/reducer/actions/insert.ts
1007
+ function insertAction(state, action, appStore) {
1008
+ const id = action.id || generateId(action.componentType);
1009
+ const emptyComponentData = populateIds(
1010
+ {
1011
+ type: action.componentType,
1012
+ props: __spreadProps(__spreadValues({}, appStore.config.components[action.componentType].defaultProps || {}), {
1013
+ id
1014
+ })
1015
+ },
1016
+ appStore.config
1017
+ );
1018
+ const [parentId] = action.destinationZone.split(":");
1019
+ const idsInPath = getIdsForParent(action.destinationZone, state);
1020
+ return walkAppState(
1021
+ state,
1022
+ appStore.config,
1023
+ (content, zoneCompound) => {
1024
+ if (zoneCompound === action.destinationZone) {
1025
+ return insert(
1026
+ content || [],
1027
+ action.destinationIndex,
1028
+ emptyComponentData
1029
+ );
1030
+ }
1031
+ return content;
1032
+ },
1033
+ (childItem, path) => {
1034
+ if (childItem.props.id === id || childItem.props.id === parentId) {
1035
+ return childItem;
1036
+ } else if (idsInPath.includes(childItem.props.id)) {
1037
+ return childItem;
1038
+ } else if (path.includes(action.destinationZone)) {
1039
+ return childItem;
1040
+ }
1041
+ return null;
1042
+ }
1043
+ );
1044
+ }
1045
+
1046
+ // ../core/reducer/actions/replace.ts
1047
+ init_react_import();
1048
+ var replaceAction = (state, action, appStore) => {
1049
+ const [parentId] = action.destinationZone.split(":");
1050
+ const idsInPath = getIdsForParent(action.destinationZone, state);
1051
+ const originalId = state.indexes.zones[action.destinationZone].contentIds[action.destinationIndex];
1052
+ const idChanged = originalId !== action.data.props.id;
1053
+ if (idChanged) {
1054
+ throw new Error(
1055
+ `Can't change the id during a replace action. Please us "remove" and "insert" to define a new node.`
1056
+ );
1057
+ }
1058
+ const newSlotIds = [];
1059
+ const data = walkTree(action.data, appStore.config, (contents, opts) => {
1060
+ newSlotIds.push(`${opts.parentId}:${opts.propName}`);
1061
+ return contents.map((item) => {
1062
+ const id = generateId(item.type);
1063
+ return __spreadProps(__spreadValues({}, item), {
1064
+ props: __spreadValues({ id }, item.props)
1065
+ });
1066
+ });
1067
+ });
1068
+ const stateWithDeepSlotsRemoved = __spreadValues({}, state);
1069
+ Object.keys(state.indexes.zones).forEach((zoneCompound) => {
1070
+ const id = zoneCompound.split(":")[0];
1071
+ if (id === originalId) {
1072
+ if (!newSlotIds.includes(zoneCompound)) {
1073
+ delete stateWithDeepSlotsRemoved.indexes.zones[zoneCompound];
1074
+ }
1075
+ }
1076
+ });
1077
+ return walkAppState(
1078
+ stateWithDeepSlotsRemoved,
1079
+ appStore.config,
1080
+ (content, zoneCompound) => {
1081
+ const newContent = [...content];
1082
+ if (zoneCompound === action.destinationZone) {
1083
+ newContent[action.destinationIndex] = data;
1084
+ }
1085
+ return newContent;
1086
+ },
1087
+ (childItem, path) => {
1088
+ const pathIds = path.map((p) => p.split(":")[0]);
1089
+ if (childItem.props.id === data.props.id) {
1090
+ return data;
1091
+ } else if (childItem.props.id === parentId) {
1092
+ return childItem;
1093
+ } else if (idsInPath.indexOf(childItem.props.id) > -1) {
1094
+ return childItem;
1095
+ } else if (pathIds.indexOf(data.props.id) > -1) {
1096
+ return childItem;
1097
+ }
1098
+ return null;
1099
+ }
1100
+ );
1101
+ };
1102
+
1103
+ // ../core/reducer/actions/replace-root.ts
1104
+ init_react_import();
1105
+ var replaceRootAction = (state, action, appStore) => {
1106
+ return walkAppState(
1107
+ state,
1108
+ appStore.config,
1109
+ (content) => content,
1110
+ (childItem) => {
1111
+ if (childItem.props.id === "root") {
1112
+ return __spreadProps(__spreadValues({}, childItem), {
1113
+ props: __spreadValues(__spreadValues({}, childItem.props), action.root.props),
1114
+ readOnly: action.root.readOnly
1115
+ });
1116
+ }
1117
+ return childItem;
1118
+ }
1119
+ );
1120
+ };
1121
+
1122
+ // ../core/reducer/actions/duplicate.ts
1123
+ init_react_import();
1124
+
1125
+ // ../core/lib/data/get-item.ts
1126
+ init_react_import();
1127
+ function getItem(selector, state) {
1128
+ var _a, _b;
1129
+ const zone = (_a = state.indexes.zones) == null ? void 0 : _a[selector.zone || rootDroppableId];
1130
+ return zone ? (_b = state.indexes.nodes[zone.contentIds[selector.index]]) == null ? void 0 : _b.data : void 0;
1131
+ }
1132
+
1133
+ // ../core/reducer/actions/duplicate.ts
1134
+ function duplicateAction(state, action, appStore) {
1135
+ const item = getItem(
1136
+ { index: action.sourceIndex, zone: action.sourceZone },
1137
+ state
1138
+ );
1139
+ const idsInPath = getIdsForParent(action.sourceZone, state);
1140
+ const newItem = __spreadProps(__spreadValues({}, item), {
1141
+ props: __spreadProps(__spreadValues({}, item.props), {
1142
+ id: generateId(item.type)
1143
+ })
1144
+ });
1145
+ const modified = walkAppState(
1146
+ state,
1147
+ appStore.config,
1148
+ (content, zoneCompound) => {
1149
+ if (zoneCompound === action.sourceZone) {
1150
+ return insert(content, action.sourceIndex + 1, item);
1151
+ }
1152
+ return content;
1153
+ },
1154
+ (childItem, path, index) => {
1155
+ const zoneCompound = path[path.length - 1];
1156
+ const parents = path.map((p) => p.split(":")[0]);
1157
+ if (parents.indexOf(newItem.props.id) > -1) {
1158
+ return __spreadProps(__spreadValues({}, childItem), {
1159
+ props: __spreadProps(__spreadValues({}, childItem.props), {
1160
+ id: generateId(childItem.type)
1161
+ })
1162
+ });
1163
+ }
1164
+ if (zoneCompound === action.sourceZone && index === action.sourceIndex + 1) {
1165
+ return newItem;
1166
+ }
1167
+ const [sourceZoneParent] = action.sourceZone.split(":");
1168
+ if (sourceZoneParent === childItem.props.id || idsInPath.indexOf(childItem.props.id) > -1) {
1169
+ return childItem;
1170
+ }
1171
+ return null;
1172
+ }
1173
+ );
1174
+ return __spreadProps(__spreadValues({}, modified), {
1175
+ ui: __spreadProps(__spreadValues({}, modified.ui), {
1176
+ itemSelector: {
1177
+ index: action.sourceIndex + 1,
1178
+ zone: action.sourceZone
1179
+ }
1180
+ })
1181
+ });
1182
+ }
1183
+
1184
+ // ../core/reducer/actions/reorder.ts
1185
+ init_react_import();
1186
+
1187
+ // ../core/reducer/actions/move.ts
1188
+ init_react_import();
1189
+
1190
+ // ../core/lib/data/remove.ts
1191
+ init_react_import();
1192
+ var remove = (list, index) => {
1193
+ const result = Array.from(list);
1194
+ result.splice(index, 1);
1195
+ return result;
1196
+ };
1197
+
1198
+ // ../core/reducer/actions/move.ts
1199
+ var moveAction = (state, action, appStore) => {
1200
+ if (action.sourceZone === action.destinationZone && action.sourceIndex === action.destinationIndex) {
1201
+ return state;
1202
+ }
1203
+ const item = getItem(
1204
+ { zone: action.sourceZone, index: action.sourceIndex },
1205
+ state
1206
+ );
1207
+ if (!item) return state;
1208
+ const idsInSourcePath = getIdsForParent(action.sourceZone, state);
1209
+ const idsInDestinationPath = getIdsForParent(action.destinationZone, state);
1210
+ return walkAppState(
1211
+ state,
1212
+ appStore.config,
1213
+ (content, zoneCompound) => {
1214
+ if (zoneCompound === action.sourceZone && zoneCompound === action.destinationZone) {
1215
+ return insert(
1216
+ remove(content, action.sourceIndex),
1217
+ action.destinationIndex,
1218
+ item
1219
+ );
1220
+ } else if (zoneCompound === action.sourceZone) {
1221
+ return remove(content, action.sourceIndex);
1222
+ } else if (zoneCompound === action.destinationZone) {
1223
+ return insert(content, action.destinationIndex, item);
1224
+ }
1225
+ return content;
1226
+ },
1227
+ (childItem, path) => {
1228
+ const [sourceZoneParent] = action.sourceZone.split(":");
1229
+ const [destinationZoneParent] = action.destinationZone.split(":");
1230
+ const childId = childItem.props.id;
1231
+ if (sourceZoneParent === childId || destinationZoneParent === childId || item.props.id === childId || idsInSourcePath.indexOf(childId) > -1 || idsInDestinationPath.indexOf(childId) > -1 || path.includes(action.destinationZone)) {
1232
+ return childItem;
1233
+ }
1234
+ return null;
1235
+ }
1236
+ );
1237
+ };
1238
+
1239
+ // ../core/reducer/actions/reorder.ts
1240
+ var reorderAction = (state, action, appStore) => {
1241
+ return moveAction(
1242
+ state,
1243
+ {
1244
+ type: "move",
1245
+ sourceIndex: action.sourceIndex,
1246
+ sourceZone: action.destinationZone,
1247
+ destinationIndex: action.destinationIndex,
1248
+ destinationZone: action.destinationZone
1249
+ },
1250
+ appStore
1251
+ );
1252
+ };
1253
+
1254
+ // ../core/reducer/actions/remove.ts
1255
+ init_react_import();
1256
+ var removeAction = (state, action, appStore) => {
1257
+ const item = getItem({ index: action.index, zone: action.zone }, state);
1258
+ const nodesToDelete = Object.entries(state.indexes.nodes).reduce(
1259
+ (acc, [nodeId, nodeData]) => {
1260
+ const pathIds = nodeData.path.map((p) => p.split(":")[0]);
1261
+ if (pathIds.includes(item.props.id)) {
1262
+ return [...acc, nodeId];
1263
+ }
1264
+ return acc;
1265
+ },
1266
+ [item.props.id]
1267
+ );
1268
+ const newState = walkAppState(
1269
+ state,
1270
+ appStore.config,
1271
+ (content, zoneCompound) => {
1272
+ if (zoneCompound === action.zone) {
1273
+ return remove(content, action.index);
1274
+ }
1275
+ return content;
1276
+ }
1277
+ );
1278
+ Object.keys(newState.data.zones || {}).forEach((zoneCompound) => {
1279
+ const parentId = zoneCompound.split(":")[0];
1280
+ if (nodesToDelete.includes(parentId) && newState.data.zones) {
1281
+ delete newState.data.zones[zoneCompound];
1282
+ }
1283
+ });
1284
+ Object.keys(newState.indexes.zones).forEach((zoneCompound) => {
1285
+ const parentId = zoneCompound.split(":")[0];
1286
+ if (nodesToDelete.includes(parentId)) {
1287
+ delete newState.indexes.zones[zoneCompound];
1288
+ }
1289
+ });
1290
+ nodesToDelete.forEach((id) => {
1291
+ delete newState.indexes.nodes[id];
1292
+ });
1293
+ return newState;
1294
+ };
1295
+
1296
+ // ../core/reducer/actions/register-zone.ts
1297
+ init_react_import();
1298
+
1299
+ // ../core/lib/data/setup-zone.ts
1300
+ init_react_import();
1301
+ var setupZone = (data, zoneKey) => {
1302
+ if (zoneKey === rootDroppableId) {
1303
+ return data;
1304
+ }
1305
+ const newData = __spreadProps(__spreadValues({}, data), {
1306
+ zones: data.zones ? __spreadValues({}, data.zones) : {}
1307
+ });
1308
+ newData.zones[zoneKey] = newData.zones[zoneKey] || [];
1309
+ return newData;
1310
+ };
1311
+
1312
+ // ../core/reducer/actions/register-zone.ts
1313
+ var zoneCache = {};
1314
+ function registerZoneAction(state, action) {
1315
+ if (zoneCache[action.zone]) {
1316
+ return __spreadProps(__spreadValues({}, state), {
1317
+ data: __spreadProps(__spreadValues({}, state.data), {
1318
+ zones: __spreadProps(__spreadValues({}, state.data.zones), {
1319
+ [action.zone]: zoneCache[action.zone]
1320
+ })
1321
+ }),
1322
+ indexes: __spreadProps(__spreadValues({}, state.indexes), {
1323
+ zones: __spreadProps(__spreadValues({}, state.indexes.zones), {
1324
+ [action.zone]: __spreadProps(__spreadValues({}, state.indexes.zones[action.zone]), {
1325
+ contentIds: zoneCache[action.zone].map((item) => item.props.id),
1326
+ type: "dropzone"
1327
+ })
1328
+ })
1329
+ })
1330
+ });
1331
+ }
1332
+ return __spreadProps(__spreadValues({}, state), { data: setupZone(state.data, action.zone) });
1333
+ }
1334
+ function unregisterZoneAction(state, action) {
1335
+ const _zones = __spreadValues({}, state.data.zones || {});
1336
+ const zoneIndex = __spreadValues({}, state.indexes.zones || {});
1337
+ if (_zones[action.zone]) {
1338
+ zoneCache[action.zone] = _zones[action.zone];
1339
+ delete _zones[action.zone];
1340
+ }
1341
+ delete zoneIndex[action.zone];
1342
+ return __spreadProps(__spreadValues({}, state), {
1343
+ data: __spreadProps(__spreadValues({}, state.data), {
1344
+ zones: _zones
1345
+ }),
1346
+ indexes: __spreadProps(__spreadValues({}, state.indexes), {
1347
+ zones: zoneIndex
1348
+ })
1349
+ });
1350
+ }
1351
+
1352
+ // ../core/reducer/actions/set-data.ts
1353
+ init_react_import();
1354
+ var setDataAction = (state, action, appStore) => {
1355
+ if (typeof action.data === "object") {
1356
+ console.warn(
1357
+ "`setData` is expensive and may cause unnecessary re-renders. Consider using a more atomic action instead."
1358
+ );
1359
+ return walkAppState(
1360
+ __spreadProps(__spreadValues({}, state), {
1361
+ data: __spreadValues(__spreadValues({}, state.data), action.data)
1362
+ }),
1363
+ appStore.config
1364
+ );
1365
+ }
1366
+ return walkAppState(
1367
+ __spreadProps(__spreadValues({}, state), {
1368
+ data: __spreadValues(__spreadValues({}, state.data), action.data(state.data))
1369
+ }),
1370
+ appStore.config
1371
+ );
1372
+ };
1373
+
1374
+ // ../core/reducer/actions/set-ui.ts
1375
+ init_react_import();
1376
+ var setUiAction = (state, action) => {
1377
+ if (typeof action.ui === "object") {
1378
+ return __spreadProps(__spreadValues({}, state), {
1379
+ ui: __spreadValues(__spreadValues({}, state.ui), action.ui)
1380
+ });
1381
+ }
1382
+ return __spreadProps(__spreadValues({}, state), {
1383
+ ui: __spreadValues(__spreadValues({}, state.ui), action.ui(state.ui))
1384
+ });
1385
+ };
1386
+
1387
+ // ../core/lib/data/make-state-public.ts
1388
+ init_react_import();
1389
+ var makeStatePublic = (state) => {
1390
+ const { data, ui } = state;
1391
+ return { data, ui };
1392
+ };
1393
+
1394
+ // ../core/reducer/actions.tsx
1395
+ init_react_import();
1396
+
1397
+ // ../core/reducer/index.ts
1398
+ function storeInterceptor(reducer, record, onAction) {
1399
+ return (state, action) => {
1400
+ const newAppState = reducer(state, action);
1401
+ const isValidType = ![
1402
+ "registerZone",
1403
+ "unregisterZone",
1404
+ "setData",
1405
+ "setUi",
1406
+ "set"
1407
+ ].includes(action.type);
1408
+ if (typeof action.recordHistory !== "undefined" ? action.recordHistory : isValidType) {
1409
+ if (record) record(newAppState);
1410
+ }
1411
+ onAction == null ? void 0 : onAction(action, makeStatePublic(newAppState), makeStatePublic(state));
1412
+ return newAppState;
1413
+ };
1414
+ }
1415
+ function createReducer({
1416
+ record,
1417
+ onAction,
1418
+ appStore
1419
+ }) {
1420
+ return storeInterceptor(
1421
+ (state, action) => {
1422
+ if (action.type === "set") {
1423
+ return setAction(state, action, appStore);
1424
+ }
1425
+ if (action.type === "insert") {
1426
+ return insertAction(state, action, appStore);
1427
+ }
1428
+ if (action.type === "replace") {
1429
+ return replaceAction(state, action, appStore);
1430
+ }
1431
+ if (action.type === "replaceRoot") {
1432
+ return replaceRootAction(state, action, appStore);
1433
+ }
1434
+ if (action.type === "duplicate") {
1435
+ return duplicateAction(state, action, appStore);
1436
+ }
1437
+ if (action.type === "reorder") {
1438
+ return reorderAction(state, action, appStore);
1439
+ }
1440
+ if (action.type === "move") {
1441
+ return moveAction(state, action, appStore);
1442
+ }
1443
+ if (action.type === "remove") {
1444
+ return removeAction(state, action, appStore);
1445
+ }
1446
+ if (action.type === "registerZone") {
1447
+ return registerZoneAction(state, action);
1448
+ }
1449
+ if (action.type === "unregisterZone") {
1450
+ return unregisterZoneAction(state, action);
1451
+ }
1452
+ if (action.type === "setData") {
1453
+ return setDataAction(state, action, appStore);
1454
+ }
1455
+ if (action.type === "setUi") {
1456
+ return setUiAction(state, action);
1457
+ }
1458
+ return state;
1459
+ },
1460
+ record,
1461
+ onAction
1462
+ );
1463
+ }
1464
+
1465
+ // ../core/components/ViewportControls/default-viewports.ts
1466
+ init_react_import();
1467
+ var defaultViewports = [
1468
+ { width: 360, height: "auto", icon: "Smartphone", label: "Small" },
1469
+ { width: 768, height: "auto", icon: "Tablet", label: "Medium" },
1470
+ { width: 1280, height: "auto", icon: "Monitor", label: "Large" }
1471
+ ];
1472
+
1473
+ // ../../node_modules/zustand/esm/vanilla.mjs
1474
+ init_react_import();
1475
+ var createStoreImpl = (createState) => {
1476
+ let state;
1477
+ const listeners = /* @__PURE__ */ new Set();
1478
+ const setState = (partial, replace) => {
1479
+ const nextState = typeof partial === "function" ? partial(state) : partial;
1480
+ if (!Object.is(nextState, state)) {
1481
+ const previousState = state;
1482
+ state = (replace != null ? replace : typeof nextState !== "object" || nextState === null) ? nextState : Object.assign({}, state, nextState);
1483
+ listeners.forEach((listener) => listener(state, previousState));
1484
+ }
1485
+ };
1486
+ const getState = () => state;
1487
+ const getInitialState = () => initialState;
1488
+ const subscribe = (listener) => {
1489
+ listeners.add(listener);
1490
+ return () => listeners.delete(listener);
1491
+ };
1492
+ const api = { setState, getState, getInitialState, subscribe };
1493
+ const initialState = state = createState(setState, getState, api);
1494
+ return api;
1495
+ };
1496
+ var createStore = (createState) => createState ? createStoreImpl(createState) : createStoreImpl;
1497
+
1498
+ // ../../node_modules/zustand/esm/react.mjs
1499
+ init_react_import();
1500
+ import React2 from "react";
1501
+ var identity = (arg) => arg;
1502
+ function useStore(api, selector = identity) {
1503
+ const slice = React2.useSyncExternalStore(
1504
+ api.subscribe,
1505
+ () => selector(api.getState()),
1506
+ () => selector(api.getInitialState())
1507
+ );
1508
+ React2.useDebugValue(slice);
1509
+ return slice;
1510
+ }
1511
+ var createImpl = (createState) => {
1512
+ const api = createStore(createState);
1513
+ const useBoundStore = (selector) => useStore(api, selector);
1514
+ Object.assign(useBoundStore, api);
1515
+ return useBoundStore;
1516
+ };
1517
+ var create = (createState) => createState ? createImpl(createState) : createImpl;
1518
+
1519
+ // ../../node_modules/zustand/esm/middleware.mjs
1520
+ init_react_import();
1521
+ var subscribeWithSelectorImpl = (fn) => (set, get, api) => {
1522
+ const origSubscribe = api.subscribe;
1523
+ api.subscribe = (selector, optListener, options) => {
1524
+ let listener = selector;
1525
+ if (optListener) {
1526
+ const equalityFn = (options == null ? void 0 : options.equalityFn) || Object.is;
1527
+ let currentSlice = selector(api.getState());
1528
+ listener = (state) => {
1529
+ const nextSlice = selector(state);
1530
+ if (!equalityFn(currentSlice, nextSlice)) {
1531
+ const previousSlice = currentSlice;
1532
+ optListener(currentSlice = nextSlice, previousSlice);
1533
+ }
1534
+ };
1535
+ if (options == null ? void 0 : options.fireImmediately) {
1536
+ optListener(currentSlice, currentSlice);
1537
+ }
1538
+ }
1539
+ return origSubscribe(listener);
1540
+ };
1541
+ const initialState = fn(set, get, api);
1542
+ return initialState;
1543
+ };
1544
+ var subscribeWithSelector = subscribeWithSelectorImpl;
1545
+
1546
+ // ../core/store/index.ts
1547
+ import { createContext, useContext } from "react";
1548
+
1549
+ // ../core/store/slices/history.ts
1550
+ init_react_import();
1551
+ import { useEffect as useEffect2 } from "react";
1552
+
1553
+ // ../core/lib/use-hotkey.ts
1554
+ init_react_import();
1555
+ import { useEffect } from "react";
1556
+ var useHotkeyStore = create()(
1557
+ subscribeWithSelector((set) => ({
1558
+ held: {},
1559
+ hold: (key) => set((s) => s.held[key] ? s : { held: __spreadProps(__spreadValues({}, s.held), { [key]: true }) }),
1560
+ release: (key) => set((s) => s.held[key] ? { held: __spreadProps(__spreadValues({}, s.held), { [key]: false }) } : s),
1561
+ reset: (held = {}) => set(() => ({ held })),
1562
+ triggers: {}
1563
+ }))
1564
+ );
1565
+
1566
+ // ../core/store/slices/history.ts
1567
+ var EMPTY_HISTORY_INDEX = 0;
1568
+ function debounce(func, timeout = 300) {
1569
+ let timer;
1570
+ return (...args) => {
1571
+ clearTimeout(timer);
1572
+ timer = setTimeout(() => {
1573
+ func(...args);
1574
+ }, timeout);
1575
+ };
1576
+ }
1577
+ var tidyState = (state) => {
1578
+ return __spreadProps(__spreadValues({}, state), {
1579
+ ui: __spreadProps(__spreadValues({}, state.ui), {
1580
+ field: {
1581
+ focus: null
1582
+ }
1583
+ })
1584
+ });
1585
+ };
1586
+ var createHistorySlice = (set, get) => {
1587
+ const record = debounce((state) => {
1588
+ const { histories, index } = get().history;
1589
+ const history = {
1590
+ state,
1591
+ id: generateId("history")
1592
+ };
1593
+ const newHistories = [...histories.slice(0, index + 1), history];
1594
+ set({
1595
+ history: __spreadProps(__spreadValues({}, get().history), {
1596
+ histories: newHistories,
1597
+ index: newHistories.length - 1
1598
+ })
1599
+ });
1600
+ }, 250);
1601
+ return {
1602
+ initialAppState: {},
1603
+ index: EMPTY_HISTORY_INDEX,
1604
+ histories: [],
1605
+ hasPast: () => get().history.index > EMPTY_HISTORY_INDEX,
1606
+ hasFuture: () => get().history.index < get().history.histories.length - 1,
1607
+ prevHistory: () => {
1608
+ const { history } = get();
1609
+ return history.hasPast() ? history.histories[history.index - 1] : null;
1610
+ },
1611
+ nextHistory: () => {
1612
+ const s = get().history;
1613
+ return s.hasFuture() ? s.histories[s.index + 1] : null;
1614
+ },
1615
+ currentHistory: () => get().history.histories[get().history.index],
1616
+ back: () => {
1617
+ var _a;
1618
+ const { history, dispatch } = get();
1619
+ if (history.hasPast()) {
1620
+ const state = tidyState(
1621
+ ((_a = history.prevHistory()) == null ? void 0 : _a.state) || history.initialAppState
1622
+ );
1623
+ dispatch({
1624
+ type: "set",
1625
+ state
1626
+ });
1627
+ set({ history: __spreadProps(__spreadValues({}, history), { index: history.index - 1 }) });
1628
+ }
1629
+ },
1630
+ forward: () => {
1631
+ var _a;
1632
+ const { history, dispatch } = get();
1633
+ if (history.hasFuture()) {
1634
+ const state = (_a = history.nextHistory()) == null ? void 0 : _a.state;
1635
+ dispatch({ type: "set", state: state ? tidyState(state) : {} });
1636
+ set({ history: __spreadProps(__spreadValues({}, history), { index: history.index + 1 }) });
1637
+ }
1638
+ },
1639
+ setHistories: (histories) => {
1640
+ var _a;
1641
+ const { dispatch, history } = get();
1642
+ dispatch({
1643
+ type: "set",
1644
+ state: ((_a = histories[histories.length - 1]) == null ? void 0 : _a.state) || history.initialAppState
1645
+ });
1646
+ set({ history: __spreadProps(__spreadValues({}, history), { histories, index: histories.length - 1 }) });
1647
+ },
1648
+ setHistoryIndex: (index) => {
1649
+ var _a;
1650
+ const { dispatch, history } = get();
1651
+ dispatch({
1652
+ type: "set",
1653
+ state: ((_a = history.histories[index]) == null ? void 0 : _a.state) || history.initialAppState
1654
+ });
1655
+ set({ history: __spreadProps(__spreadValues({}, history), { index }) });
1656
+ },
1657
+ record
1658
+ };
1659
+ };
1660
+
1661
+ // ../core/store/slices/nodes.ts
1662
+ init_react_import();
1663
+ var createNodesSlice = (set, get) => ({
1664
+ nodes: {},
1665
+ registerNode: (id, node) => {
1666
+ const s = get().nodes;
1667
+ const emptyNode = {
1668
+ id,
1669
+ methods: {
1670
+ sync: () => null,
1671
+ hideOverlay: () => null,
1672
+ showOverlay: () => null
1673
+ },
1674
+ element: null
1675
+ };
1676
+ const existingNode = s.nodes[id];
1677
+ set({
1678
+ nodes: __spreadProps(__spreadValues({}, s), {
1679
+ nodes: __spreadProps(__spreadValues({}, s.nodes), {
1680
+ [id]: __spreadProps(__spreadValues(__spreadValues(__spreadValues({}, emptyNode), existingNode), node), {
1681
+ id
1682
+ })
1683
+ })
1684
+ })
1685
+ });
1686
+ },
1687
+ unregisterNode: (id) => {
1688
+ const s = get().nodes;
1689
+ const existingNode = s.nodes[id];
1690
+ if (existingNode) {
1691
+ const newNodes = __spreadValues({}, s.nodes);
1692
+ delete newNodes[id];
1693
+ set({
1694
+ nodes: __spreadProps(__spreadValues({}, s), {
1695
+ nodes: newNodes
1696
+ })
1697
+ });
1698
+ }
1699
+ }
1700
+ });
1701
+
1702
+ // ../core/store/slices/permissions.ts
1703
+ init_react_import();
1704
+ import { useEffect as useEffect3 } from "react";
1705
+
1706
+ // ../core/lib/data/flatten-data.ts
1707
+ init_react_import();
1708
+ var flattenData = (state, config) => {
1709
+ const data = [];
1710
+ walkAppState(
1711
+ state,
1712
+ config,
1713
+ (content) => content,
1714
+ (item) => {
1715
+ data.push(item);
1716
+ return null;
1717
+ }
1718
+ );
1719
+ return data;
1720
+ };
1721
+
1722
+ // ../core/lib/get-changed.ts
1723
+ init_react_import();
1724
+ var import_fast_deep_equal = __toESM(require_fast_deep_equal());
1725
+ var getChanged = (newItem, oldItem) => {
1726
+ return newItem ? Object.keys(newItem.props || {}).reduce((acc, item) => {
1727
+ const newItemProps = (newItem == null ? void 0 : newItem.props) || {};
1728
+ const oldItemProps = (oldItem == null ? void 0 : oldItem.props) || {};
1729
+ return __spreadProps(__spreadValues({}, acc), {
1730
+ [item]: !(0, import_fast_deep_equal.default)(oldItemProps[item], newItemProps[item])
1731
+ });
1732
+ }, {}) : {};
1733
+ };
1734
+
1735
+ // ../core/store/slices/permissions.ts
1736
+ var createPermissionsSlice = (set, get) => {
1737
+ const resolvePermissions = (..._0) => __async(void 0, [..._0], function* (params = {}, force) {
1738
+ const { state, permissions, config } = get();
1739
+ const { cache: cache2, globalPermissions } = permissions;
1740
+ const resolveDataForItem = (item2, force2 = false) => __async(void 0, null, function* () {
1741
+ var _a, _b, _c;
1742
+ const { config: config2, state: appState, setComponentLoading } = get();
1743
+ const componentConfig = item2.type === "root" ? config2.root : config2.components[item2.type];
1744
+ if (!componentConfig) {
1745
+ return;
1746
+ }
1747
+ const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig.permissions);
1748
+ if (componentConfig.resolvePermissions) {
1749
+ const changed = getChanged(item2, (_a = cache2[item2.props.id]) == null ? void 0 : _a.lastData);
1750
+ if (Object.values(changed).some((el) => el === true) || force2) {
1751
+ const clearTimeout2 = setComponentLoading(item2.props.id, true, 50);
1752
+ const resolvedPermissions = yield componentConfig.resolvePermissions(
1753
+ item2,
1754
+ {
1755
+ changed,
1756
+ lastPermissions: ((_b = cache2[item2.props.id]) == null ? void 0 : _b.lastPermissions) || null,
1757
+ permissions: initialPermissions,
1758
+ appState: makeStatePublic(appState),
1759
+ lastData: ((_c = cache2[item2.props.id]) == null ? void 0 : _c.lastData) || null
1760
+ }
1761
+ );
1762
+ const latest = get().permissions;
1763
+ set({
1764
+ permissions: __spreadProps(__spreadValues({}, latest), {
1765
+ cache: __spreadProps(__spreadValues({}, latest.cache), {
1766
+ [item2.props.id]: {
1767
+ lastData: item2,
1768
+ lastPermissions: resolvedPermissions
1769
+ }
1770
+ }),
1771
+ resolvedPermissions: __spreadProps(__spreadValues({}, latest.resolvedPermissions), {
1772
+ [item2.props.id]: resolvedPermissions
1773
+ })
1774
+ })
1775
+ });
1776
+ clearTimeout2();
1777
+ }
1778
+ }
1779
+ });
1780
+ const resolveDataForRoot = (force2 = false) => {
1781
+ const { state: appState } = get();
1782
+ resolveDataForItem(
1783
+ // Shim the root data in by conforming to component data shape
1784
+ {
1785
+ type: "root",
1786
+ props: __spreadProps(__spreadValues({}, appState.data.root.props), { id: "root" })
1787
+ },
1788
+ force2
1789
+ );
1790
+ };
1791
+ const { item, type, root } = params;
1792
+ if (item) {
1793
+ yield resolveDataForItem(item, force);
1794
+ } else if (type) {
1795
+ flattenData(state, config).filter((item2) => item2.type === type).map((item2) => __async(void 0, null, function* () {
1796
+ yield resolveDataForItem(item2, force);
1797
+ }));
1798
+ } else if (root) {
1799
+ resolveDataForRoot(force);
1800
+ } else {
1801
+ flattenData(state, config).map((item2) => __async(void 0, null, function* () {
1802
+ yield resolveDataForItem(item2, force);
1803
+ }));
1804
+ }
1805
+ });
1806
+ const refreshPermissions = (params) => resolvePermissions(params, true);
1807
+ return {
1808
+ cache: {},
1809
+ globalPermissions: {
1810
+ drag: true,
1811
+ edit: true,
1812
+ delete: true,
1813
+ duplicate: true,
1814
+ insert: true
1815
+ },
1816
+ resolvedPermissions: {},
1817
+ getPermissions: ({ item, type, root } = {}) => {
1818
+ const { config, permissions } = get();
1819
+ const { globalPermissions, resolvedPermissions } = permissions;
1820
+ if (item) {
1821
+ const componentConfig = config.components[item.type];
1822
+ const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), componentConfig == null ? void 0 : componentConfig.permissions);
1823
+ const resolvedForItem = resolvedPermissions[item.props.id];
1824
+ return resolvedForItem ? __spreadValues(__spreadValues({}, globalPermissions), resolvedForItem) : initialPermissions;
1825
+ } else if (type) {
1826
+ const componentConfig = config.components[type];
1827
+ return __spreadValues(__spreadValues({}, globalPermissions), componentConfig == null ? void 0 : componentConfig.permissions);
1828
+ } else if (root) {
1829
+ const rootConfig = config.root;
1830
+ const initialPermissions = __spreadValues(__spreadValues({}, globalPermissions), rootConfig == null ? void 0 : rootConfig.permissions);
1831
+ const resolvedForItem = resolvedPermissions["root"];
1832
+ return resolvedForItem ? __spreadValues(__spreadValues({}, globalPermissions), resolvedForItem) : initialPermissions;
1833
+ }
1834
+ return globalPermissions;
1835
+ },
1836
+ resolvePermissions,
1837
+ refreshPermissions
1838
+ };
1839
+ };
1840
+
1841
+ // ../core/store/slices/fields.ts
1842
+ init_react_import();
1843
+ import { useCallback, useEffect as useEffect4 } from "react";
1844
+ var createFieldsSlice = (_set, _get) => {
1845
+ return {
1846
+ fields: {},
1847
+ loading: false,
1848
+ lastResolvedData: {},
1849
+ id: void 0
1850
+ };
1851
+ };
1852
+
1853
+ // ../core/lib/resolve-component-data.ts
1854
+ init_react_import();
1855
+ var import_fast_deep_equal2 = __toESM(require_fast_deep_equal());
1856
+ var cache = { lastChange: {} };
1857
+ var resolveComponentData = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (item, config, metadata = {}, onResolveStart, onResolveEnd, trigger = "replace") {
1858
+ const configForItem = "type" in item && item.type !== "root" ? config.components[item.type] : config.root;
1859
+ const resolvedItem = __spreadValues({}, item);
1860
+ const shouldRunResolver = (configForItem == null ? void 0 : configForItem.resolveData) && item.props;
1861
+ const id = "id" in item.props ? item.props.id : "root";
1862
+ if (shouldRunResolver) {
1863
+ const { item: oldItem = null, resolved = {} } = cache.lastChange[id] || {};
1864
+ if (item && (0, import_fast_deep_equal2.default)(item, oldItem)) {
1865
+ return { node: resolved, didChange: false };
1866
+ }
1867
+ const changed = getChanged(item, oldItem);
1868
+ if (onResolveStart) {
1869
+ onResolveStart(item);
1870
+ }
1871
+ const { props: resolvedProps, readOnly = {} } = yield configForItem.resolveData(item, {
1872
+ changed,
1873
+ lastData: oldItem,
1874
+ metadata: __spreadValues(__spreadValues({}, metadata), configForItem.metadata),
1875
+ trigger
1876
+ });
1877
+ resolvedItem.props = __spreadValues(__spreadValues({}, item.props), resolvedProps);
1878
+ if (Object.keys(readOnly).length) {
1879
+ resolvedItem.readOnly = readOnly;
1880
+ }
1881
+ }
1882
+ let itemWithResolvedChildren = yield mapFields(
1883
+ resolvedItem,
1884
+ {
1885
+ slot: (_02) => __async(void 0, [_02], function* ({ value }) {
1886
+ const content = value;
1887
+ return yield Promise.all(
1888
+ content.map(
1889
+ (childItem) => __async(void 0, null, function* () {
1890
+ return (yield resolveComponentData(
1891
+ childItem,
1892
+ config,
1893
+ metadata,
1894
+ onResolveStart,
1895
+ onResolveEnd,
1896
+ trigger
1897
+ )).node;
1898
+ })
1899
+ )
1900
+ );
1901
+ })
1902
+ },
1903
+ config
1904
+ );
1905
+ if (shouldRunResolver && onResolveEnd) {
1906
+ onResolveEnd(resolvedItem);
1907
+ }
1908
+ cache.lastChange[id] = {
1909
+ item,
1910
+ resolved: itemWithResolvedChildren
1911
+ };
1912
+ return {
1913
+ node: itemWithResolvedChildren,
1914
+ didChange: !(0, import_fast_deep_equal2.default)(item, itemWithResolvedChildren)
1915
+ };
1916
+ });
1917
+
1918
+ // ../core/lib/data/to-root.ts
1919
+ init_react_import();
1920
+ var toRoot = (item) => {
1921
+ if ("type" in item && item.type !== "root") {
1922
+ throw new Error("Converting non-root item to root.");
1923
+ }
1924
+ const { readOnly } = item;
1925
+ if (item.props) {
1926
+ if ("id" in item.props) {
1927
+ const _a = item.props, { id } = _a, props = __objRest(_a, ["id"]);
1928
+ return { props, readOnly };
1929
+ }
1930
+ return { props: item.props, readOnly };
1931
+ }
1932
+ return { props: {}, readOnly };
1933
+ };
1934
+
1935
+ // ../core/store/default-app-state.ts
1936
+ init_react_import();
1937
+ var defaultAppState = {
1938
+ data: { content: [], root: {}, zones: {} },
1939
+ ui: {
1940
+ leftSideBarVisible: true,
1941
+ rightSideBarVisible: true,
1942
+ arrayState: {},
1943
+ itemSelector: null,
1944
+ componentList: {},
1945
+ isDragging: false,
1946
+ previewMode: "edit",
1947
+ viewports: {
1948
+ current: {
1949
+ width: defaultViewports[0].width,
1950
+ height: defaultViewports[0].height || "auto"
1951
+ },
1952
+ options: [],
1953
+ controlsVisible: true
1954
+ },
1955
+ field: { focus: null }
1956
+ },
1957
+ indexes: {
1958
+ nodes: {},
1959
+ zones: {}
1960
+ }
1961
+ };
1962
+
1963
+ // ../core/store/index.ts
1964
+ var defaultPageFields = {
1965
+ title: { type: "text" }
1966
+ };
1967
+ var createAppStore = (initialAppStore) => create()(
1968
+ subscribeWithSelector((set, get) => {
1969
+ var _a, _b;
1970
+ return __spreadProps(__spreadValues({
1971
+ state: defaultAppState,
1972
+ config: { components: {} },
1973
+ componentState: {},
1974
+ plugins: [],
1975
+ overrides: {},
1976
+ viewports: defaultViewports,
1977
+ zoomConfig: {
1978
+ autoZoom: 1,
1979
+ rootHeight: 0,
1980
+ zoom: 1
1981
+ },
1982
+ status: "LOADING",
1983
+ iframe: {},
1984
+ metadata: {},
1985
+ fieldTransforms: {}
1986
+ }, initialAppStore), {
1987
+ fields: createFieldsSlice(set, get),
1988
+ history: createHistorySlice(set, get),
1989
+ nodes: createNodesSlice(set, get),
1990
+ permissions: createPermissionsSlice(set, get),
1991
+ getComponentConfig: (type) => {
1992
+ var _a2;
1993
+ const { config, selectedItem } = get();
1994
+ const rootFields = ((_a2 = config.root) == null ? void 0 : _a2.fields) || defaultPageFields;
1995
+ return type && type !== "root" ? config.components[type] : selectedItem ? config.components[selectedItem.type] : __spreadProps(__spreadValues({}, config.root), { fields: rootFields });
1996
+ },
1997
+ selectedItem: ((_a = initialAppStore == null ? void 0 : initialAppStore.state) == null ? void 0 : _a.ui.itemSelector) ? getItem(
1998
+ (_b = initialAppStore == null ? void 0 : initialAppStore.state) == null ? void 0 : _b.ui.itemSelector,
1999
+ initialAppStore.state
2000
+ ) : null,
2001
+ dispatch: (action) => set((s) => {
2002
+ var _a2, _b2;
2003
+ const { record } = get().history;
2004
+ const dispatch = createReducer({
2005
+ record,
2006
+ appStore: s
2007
+ });
2008
+ const state = dispatch(s.state, action);
2009
+ const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
2010
+ (_b2 = (_a2 = get()).onAction) == null ? void 0 : _b2.call(_a2, action, state, get().state);
2011
+ return __spreadProps(__spreadValues({}, s), { state, selectedItem });
2012
+ }),
2013
+ setZoomConfig: (zoomConfig) => set({ zoomConfig }),
2014
+ setStatus: (status) => set({ status }),
2015
+ setComponentState: (componentState) => set({ componentState }),
2016
+ pendingLoadTimeouts: {},
2017
+ setComponentLoading: (id, loading = true, defer = 0) => {
2018
+ const { setComponentState, pendingLoadTimeouts } = get();
2019
+ const loadId = generateId();
2020
+ const setLoading = () => {
2021
+ var _a2;
2022
+ const { componentState } = get();
2023
+ setComponentState(__spreadProps(__spreadValues({}, componentState), {
2024
+ [id]: __spreadProps(__spreadValues({}, componentState[id]), {
2025
+ loadingCount: (((_a2 = componentState[id]) == null ? void 0 : _a2.loadingCount) || 0) + 1
2026
+ })
2027
+ }));
2028
+ };
2029
+ const unsetLoading = () => {
2030
+ var _a2;
2031
+ const { componentState } = get();
2032
+ clearTimeout(timeout);
2033
+ delete pendingLoadTimeouts[loadId];
2034
+ set({ pendingLoadTimeouts });
2035
+ setComponentState(__spreadProps(__spreadValues({}, componentState), {
2036
+ [id]: __spreadProps(__spreadValues({}, componentState[id]), {
2037
+ loadingCount: Math.max(
2038
+ (((_a2 = componentState[id]) == null ? void 0 : _a2.loadingCount) || 0) - 1,
2039
+ 0
2040
+ )
2041
+ })
2042
+ }));
2043
+ };
2044
+ const timeout = setTimeout(() => {
2045
+ if (loading) {
2046
+ setLoading();
2047
+ } else {
2048
+ unsetLoading();
2049
+ }
2050
+ delete pendingLoadTimeouts[loadId];
2051
+ set({ pendingLoadTimeouts });
2052
+ }, defer);
2053
+ set({
2054
+ pendingLoadTimeouts: __spreadProps(__spreadValues({}, pendingLoadTimeouts), {
2055
+ [id]: timeout
2056
+ })
2057
+ });
2058
+ return unsetLoading;
2059
+ },
2060
+ unsetComponentLoading: (id) => {
2061
+ const { setComponentLoading } = get();
2062
+ setComponentLoading(id, false);
2063
+ },
2064
+ // Helper
2065
+ setUi: (ui, recordHistory) => set((s) => {
2066
+ const dispatch = createReducer({
2067
+ record: () => {
2068
+ },
2069
+ appStore: s
2070
+ });
2071
+ const state = dispatch(s.state, {
2072
+ type: "setUi",
2073
+ ui,
2074
+ recordHistory
2075
+ });
2076
+ const selectedItem = state.ui.itemSelector ? getItem(state.ui.itemSelector, state) : null;
2077
+ return __spreadProps(__spreadValues({}, s), { state, selectedItem });
2078
+ }),
2079
+ resolveComponentData: (componentData, trigger) => __async(void 0, null, function* () {
2080
+ const { config, metadata, setComponentLoading, permissions } = get();
2081
+ const timeouts = {};
2082
+ return yield resolveComponentData(
2083
+ componentData,
2084
+ config,
2085
+ metadata,
2086
+ (item) => {
2087
+ const id = "id" in item.props ? item.props.id : "root";
2088
+ timeouts[id] = setComponentLoading(id, true, 50);
2089
+ },
2090
+ (item) => __async(void 0, null, function* () {
2091
+ const id = "id" in item.props ? item.props.id : "root";
2092
+ if ("type" in item) {
2093
+ yield permissions.refreshPermissions({ item });
2094
+ } else {
2095
+ yield permissions.refreshPermissions({ root: true });
2096
+ }
2097
+ timeouts[id]();
2098
+ }),
2099
+ trigger
2100
+ );
2101
+ }),
2102
+ resolveAndCommitData: () => __async(void 0, null, function* () {
2103
+ const { config, state, dispatch, resolveComponentData: resolveComponentData2 } = get();
2104
+ walkAppState(
2105
+ state,
2106
+ config,
2107
+ (content) => content,
2108
+ (childItem) => {
2109
+ resolveComponentData2(childItem, "load").then((resolved) => {
2110
+ const { state: state2 } = get();
2111
+ const node = state2.indexes.nodes[resolved.node.props.id];
2112
+ if (node && resolved.didChange) {
2113
+ if (resolved.node.props.id === "root") {
2114
+ dispatch({
2115
+ type: "replaceRoot",
2116
+ root: toRoot(resolved.node)
2117
+ });
2118
+ } else {
2119
+ const zoneCompound = `${node.parentId}:${node.zone}`;
2120
+ const parentZone = state2.indexes.zones[zoneCompound];
2121
+ const index = parentZone.contentIds.indexOf(
2122
+ resolved.node.props.id
2123
+ );
2124
+ dispatch({
2125
+ type: "replace",
2126
+ data: resolved.node,
2127
+ destinationIndex: index,
2128
+ destinationZone: zoneCompound
2129
+ });
2130
+ }
2131
+ }
2132
+ });
2133
+ return childItem;
2134
+ }
2135
+ );
2136
+ })
2137
+ });
2138
+ })
2139
+ );
2140
+ var appStoreContext = createContext(createAppStore());
2141
+
2142
+ // ../core/lib/get-zoom-config.ts
2143
+ init_react_import();
2144
+
329
2145
  // src/HeadingAnalyzer.tsx
330
2146
  import ReactFromJSONModule from "react-from-json";
331
2147
  import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
@@ -385,7 +2201,7 @@ var usePuck = createUsePuck();
385
2201
  var HeadingAnalyzer = () => {
386
2202
  const data = usePuck((s) => s.appState.data);
387
2203
  const [hierarchy, setHierarchy] = useState([]);
388
- useEffect(() => {
2204
+ useEffect5(() => {
389
2205
  const frame = getFrame();
390
2206
  let entry = frame == null ? void 0 : frame.querySelector(`[data-puck-entry]`);
391
2207
  const createHierarchy = () => {