@fragmentsx/render-web 0.0.1 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.cjs.js +1406 -684
  2. package/dist/index.es.js +1406 -684
  3. package/package.json +9 -6
package/dist/index.es.js CHANGED
@@ -1,221 +1,622 @@
1
1
  var isBrowser_default$2 = typeof window !== "undefined";
2
- var r$3 = (e2) => !e2 && e2 == null, y$4 = (e2) => !r$3(e2), a$3 = (e2) => typeof e2 == "object" && !Array.isArray(e2) && y$4(e2), f$3 = (e2) => typeof Node == "object" ? e2 instanceof Node : e2 && typeof e2 == "object" && typeof e2.nodeType == "number" && typeof e2.nodeName == "string", i$2 = (e2) => typeof e2 == "string" || t$2(e2), t$2 = (e2) => typeof e2 == "object" && typeof e2._type == "string", s$3 = (e2) => typeof e2 == "string" && e2.split(":").length >= 2, l$2 = (e2) => typeof e2 != "object" && typeof e2 != "function" || e2 === null, g$2 = (e2) => typeof e2 == "string" ? /<\/?[a-z][\s\S]*>/i.test(e2) : false, u$2 = (e2) => (n2) => {
2
+ var r$3 = (e2) => !e2 && e2 == null, y$4 = (e2) => !r$3(e2), a$3 = (e2) => typeof e2 == "object" && !Array.isArray(e2) && y$4(e2), f$3 = (e2) => typeof Node == "object" ? e2 instanceof Node : e2 && typeof e2 == "object" && typeof e2.nodeType == "number" && typeof e2.nodeName == "string", i$2 = (e2) => typeof e2 == "string" || t$2(e2), t$2 = (e2) => typeof e2 == "object" && typeof e2._type == "string", s$2 = (e2) => typeof e2 == "string" && e2.split(":").length >= 2, l$2 = (e2) => typeof e2 != "object" && typeof e2 != "function" || e2 === null, g$2 = (e2) => typeof e2 == "string" ? /<\/?[a-z][\s\S]*>/i.test(e2) : false, u$2 = (e2) => (n2) => {
3
3
  var _a;
4
4
  if (!n2) return false;
5
5
  let o2 = null;
6
- return s$3(n2) && (o2 = (_a = n2.split(":")) == null ? void 0 : _a[0]), t$2(n2) && (o2 = n2._type), o2 ? !e2.includes(o2) : false;
7
- };
8
- var G$2 = (e2) => s$3(e2), re = (e2) => i$2(e2), se = (e2) => t$2(e2), O$2 = (e2) => a$3(e2), ie = (e2, r2) => {
9
- if (e2 === r2) return true;
10
- if (Array.isArray(e2) && Array.isArray(r2)) return e2.length === r2.length && e2.every((c2, i2) => r2[i2] === c2);
11
- if (!O$2(e2) || !O$2(r2)) return false;
12
- let u2 = Object.keys(e2), p2 = Object.keys(r2);
13
- if (u2.length !== p2.length) return false;
14
- for (let c2 of u2) {
15
- if (!p2.includes(c2)) return false;
16
- let i2 = e2[c2], E2 = r2[c2];
17
- if (l$2(i2) && l$2(E2) && i2 !== E2) return false;
6
+ return s$2(n2) && (o2 = (_a = n2.split(":")) == null ? void 0 : _a[0]), t$2(n2) && (o2 = n2._type), o2 ? !e2.includes(o2) : false;
7
+ };
8
+ var isLinkKey = (input) => s$2(input);
9
+ var isGraphOrKey = (input) => i$2(input);
10
+ var isGraph = (input) => t$2(input);
11
+ var isObject$1$1 = (input) => a$3(input);
12
+ var shallowEqual = (a2, b) => {
13
+ if (a2 === b)
14
+ return true;
15
+ if (Array.isArray(a2) && Array.isArray(b)) {
16
+ return a2.length === b.length && a2.every((val, index2) => b[index2] === val);
17
+ }
18
+ if (!isObject$1$1(a2) || !isObject$1$1(b))
19
+ return false;
20
+ const keysA = Object.keys(a2);
21
+ const keysB = Object.keys(b);
22
+ if (keysA.length !== keysB.length)
23
+ return false;
24
+ for (const key of keysA) {
25
+ if (!keysB.includes(key))
26
+ return false;
27
+ const aValue = a2[key];
28
+ const bValue = b[key];
29
+ if (l$2(aValue) && l$2(bValue) && aValue !== bValue)
30
+ return false;
18
31
  }
19
32
  return true;
20
- }, W$1 = (e2, r2) => {
21
- if (e2 === r2) return true;
22
- if (Array.isArray(e2) && Array.isArray(r2)) return e2.length === r2.length && e2.every((c2, i2) => W$1(c2, r2[i2]));
23
- if (!O$2(r2) || !O$2(e2)) return e2 === r2;
24
- let u2 = Object.keys(e2), p2 = Object.keys(r2);
25
- if (u2.length !== p2.length) return false;
26
- for (let c2 of u2) if (!p2.includes(c2) || !W$1(e2[c2], r2[c2])) return false;
33
+ };
34
+ var deepEqual = (a2, b) => {
35
+ if (a2 === b)
36
+ return true;
37
+ if (Array.isArray(a2) && Array.isArray(b)) {
38
+ return a2.length === b.length && a2.every((val, i2) => deepEqual(val, b[i2]));
39
+ }
40
+ if (!isObject$1$1(b) || !isObject$1$1(a2))
41
+ return a2 === b;
42
+ const keysA = Object.keys(a2);
43
+ const keysB = Object.keys(b);
44
+ if (keysA.length !== keysB.length)
45
+ return false;
46
+ for (const key of keysA) {
47
+ if (!keysB.includes(key))
48
+ return false;
49
+ if (!deepEqual(a2[key], b[key]))
50
+ return false;
51
+ }
27
52
  return true;
28
53
  };
29
- var Y = (...e2) => Array.from(new Set(e2)), oe = (...e2) => e2.filter((r2, u2, p2) => s$3(r2) ? p2.indexOf(r2) === u2 : true);
30
- var M$1 = (e2) => e2 && e2.split(".").length > 1, J$1 = (e2, r2) => {
31
- if (!e2 || !r2) return false;
32
- if (typeof e2 != "string" || typeof r2 != "string") return null;
33
- let [u2, p2] = e2.split(":"), [c2, i2] = r2.split(":");
34
- return u2 !== c2 ? false : p2.startsWith(i2);
35
- }, ae = (e2) => G$2(e2) && M$1(e2) ? e2.split(".")[0] : e2;
36
- var ce = () => {
37
- let e2 = /* @__PURE__ */ new Map(), r2 = /* @__PURE__ */ new Map(), u2 = /* @__PURE__ */ new Map(), p2 = /* @__PURE__ */ new Map(), c2 = /* @__PURE__ */ new Map(), i2 = /* @__PURE__ */ new Map(), E2 = /* @__PURE__ */ new Set([]), V2 = (n2, d2) => {
54
+ var unique = (...values) => Array.from(new Set(values));
55
+ var uniqueLinks = (...values) => values.filter((item, index2, arr) => s$2(item) ? arr.indexOf(item) === index2 : true);
56
+ var isPartialKey = (key) => key && key.split(".").length > 1;
57
+ var isPartialGraph = (entity) => {
58
+ if (isObject$1$1(entity) && "_id" in entity && typeof entity._id === "string") {
59
+ return entity._id.includes(".");
60
+ }
61
+ return false;
62
+ };
63
+ var isPartOfGraph = (entityKey, graphKey) => {
64
+ if (!entityKey || !graphKey)
65
+ return false;
66
+ if (typeof entityKey !== "string" || typeof graphKey !== "string")
67
+ return null;
68
+ const [entityType, entityId] = entityKey.split(":");
69
+ const [graphType, graphId] = graphKey.split(":");
70
+ if (entityType !== graphType)
71
+ return false;
72
+ return entityId.startsWith(graphId);
73
+ };
74
+ var getGraphLink = (input) => {
75
+ if (isLinkKey(input)) {
76
+ if (isPartialKey(input)) {
77
+ return input.split(".")[0];
78
+ }
79
+ }
80
+ return input;
81
+ };
82
+ var createCache = () => {
83
+ const listeners = /* @__PURE__ */ new Map();
84
+ const types2 = /* @__PURE__ */ new Map();
85
+ const links = /* @__PURE__ */ new Map();
86
+ const parentRefs = /* @__PURE__ */ new Map();
87
+ const childrenRefs = /* @__PURE__ */ new Map();
88
+ const refCount = /* @__PURE__ */ new Map();
89
+ const gbLinks = /* @__PURE__ */ new Set([]);
90
+ const addRefs = (targetKey, depKey) => {
38
91
  var _a;
39
- p2.set(n2, Y(...p2.get(n2) || [], d2)), c2.set(d2, Y(...c2.get(d2) ?? [], n2)), R(n2, ((_a = p2.get(n2)) == null ? void 0 : _a.length) || 0);
40
- }, D2 = (n2, d2) => {
92
+ parentRefs.set(targetKey, unique(...parentRefs.get(targetKey) || [], depKey));
93
+ childrenRefs.set(depKey, unique(...childrenRefs.get(depKey) ?? [], targetKey));
94
+ updateRefCountForLink(targetKey, ((_a = parentRefs.get(targetKey)) == null ? void 0 : _a.length) || 0);
95
+ };
96
+ const removeRefs = (targetKey, depKey) => {
41
97
  var _a;
42
- p2.set(d2, (p2.get(d2) || []).filter((k2) => k2 !== n2)), c2.set(n2, (c2.get(n2) ?? []).filter((k2) => k2 !== d2)), R(d2, ((_a = p2.get(d2)) == null ? void 0 : _a.length) || 0);
43
- }, I2 = (n2, d2 = []) => {
44
- let k2 = p2.get(n2) || [];
45
- d2.push(...k2);
46
- let g2 = k2.map((C2) => I2(C2, d2)).flat();
47
- return d2.push(...g2), Array.from(new Set(d2).values());
48
- }, w2 = (n2) => {
49
- R(n2, 0), P2();
50
- }, S2 = (n2) => n2 ? u2.get(n2) : null, j2 = (n2, d2, k2) => {
98
+ parentRefs.set(
99
+ depKey,
100
+ (parentRefs.get(depKey) || []).filter((key) => key !== targetKey)
101
+ );
102
+ childrenRefs.set(
103
+ targetKey,
104
+ (childrenRefs.get(targetKey) ?? []).filter((key) => key !== depKey)
105
+ );
106
+ updateRefCountForLink(depKey, ((_a = parentRefs.get(depKey)) == null ? void 0 : _a.length) || 0);
107
+ };
108
+ const getLinkedRefs = (key, stack = []) => {
109
+ const deps = parentRefs.get(key) || [];
110
+ stack.push(...deps);
111
+ const deepDeps = deps.map((ref) => getLinkedRefs(ref, stack)).flat();
112
+ stack.push(...deepDeps);
113
+ return Array.from(new Set(stack).values());
114
+ };
115
+ const invalidate = (key) => {
116
+ updateRefCountForLink(key, 0);
117
+ runGarbageCollector();
118
+ };
119
+ const readLink = (key) => {
120
+ if (key) {
121
+ return links.get(key);
122
+ }
123
+ return null;
124
+ };
125
+ const writeLink = (key, value, depKey) => {
51
126
  var _a;
52
- if (typeof n2 == "string") {
53
- u2.set(n2, d2);
54
- let [g2] = n2.split(":");
55
- M$1(n2) || (r2.has(g2) ? (_a = r2.get(g2)) == null ? void 0 : _a.add(n2) : r2.set(g2, /* @__PURE__ */ new Set([n2])));
56
- }
57
- k2 && n2 && n2 !== k2 && V2(n2, k2);
58
- }, H2 = (n2) => n2 ? u2.has(n2) : false, R = (n2, d2) => {
59
- if (Array.isArray(n2)) n2.forEach((k2, g2) => R(k2, g2));
60
- else {
61
- let k2 = i2.get(n2);
62
- i2.set(n2, d2), d2 ? !k2 && d2 && E2.delete(n2) : E2.add(n2);
127
+ if (typeof key === "string") {
128
+ links.set(key, value);
129
+ const [type] = key.split(":");
130
+ if (!isPartialKey(key)) {
131
+ if (!types2.has(type)) {
132
+ types2.set(type, /* @__PURE__ */ new Set([key]));
133
+ } else {
134
+ (_a = types2.get(type)) == null ? void 0 : _a.add(key);
135
+ }
136
+ }
137
+ }
138
+ if (depKey && key && key !== depKey) {
139
+ addRefs(key, depKey);
140
+ }
141
+ };
142
+ const hasLink = (key) => {
143
+ if (key) {
144
+ return links.has(key);
145
+ }
146
+ return false;
147
+ };
148
+ const updateRefCountForLink = (link, count) => {
149
+ if (Array.isArray(link)) {
150
+ link.forEach((link2, index2) => updateRefCountForLink(link2, index2));
151
+ } else {
152
+ const prevCount = refCount.get(link);
153
+ refCount.set(link, count);
154
+ if (!count) {
155
+ gbLinks.add(link);
156
+ } else if (!prevCount && count) {
157
+ gbLinks.delete(link);
158
+ }
63
159
  }
64
- }, $2 = () => Array.from(u2.entries()), N2 = (n2) => i2.get(n2) ?? 0, P2 = () => {
160
+ };
161
+ const getLinkEntries = () => Array.from(links.entries());
162
+ const getRefCount = (link) => refCount.get(link) ?? 0;
163
+ const runGarbageCollector = () => {
65
164
  var _a, _b;
66
- for (let n2 of E2.keys()) {
67
- if (N2(n2) > 0) continue;
68
- let k2 = u2.get(n2);
69
- E2.delete(n2), u2.delete(n2), i2.delete(n2);
70
- let g2 = p2.get(n2) ?? [], C2 = c2.get(n2) ?? [];
71
- g2.forEach((x2) => {
165
+ for (const link of gbLinks.keys()) {
166
+ const count = getRefCount(link);
167
+ if (count > 0)
168
+ continue;
169
+ const currentValue = links.get(link);
170
+ gbLinks.delete(link);
171
+ links.delete(link);
172
+ refCount.delete(link);
173
+ const parents = parentRefs.get(link) ?? [];
174
+ const children = childrenRefs.get(link) ?? [];
175
+ parents.forEach((parentKey) => {
72
176
  var _a2, _b2;
73
- c2.set(x2, ((_b2 = (_a2 = c2.get(x2)) == null ? void 0 : _a2.filter) == null ? void 0 : _b2.call(_a2, (z2) => z2 !== n2)) ?? []);
74
- }), C2.forEach((x2) => {
75
- R(x2, N2(x2) - 1);
177
+ childrenRefs.set(parentKey, ((_b2 = (_a2 = childrenRefs.get(parentKey)) == null ? void 0 : _a2.filter) == null ? void 0 : _b2.call(_a2, (childLink) => childLink !== link)) ?? []);
178
+ });
179
+ children.forEach((childKey) => {
180
+ updateRefCountForLink(childKey, getRefCount(childKey) - 1);
76
181
  });
77
- let [_2] = n2.split(":");
78
- M$1(n2) || ((_a = r2.get(_2)) == null ? void 0 : _a.delete(n2), ((_b = r2.get(_2)) == null ? void 0 : _b.size) || r2.delete(_2)), p2.delete(n2), (e2.get("onRemoveLink") ?? []).forEach((x2) => x2(n2, k2 ?? null));
182
+ const [type] = link.split(":");
183
+ if (!isPartialKey(link)) {
184
+ (_a = types2.get(type)) == null ? void 0 : _a.delete(link);
185
+ if (!((_b = types2.get(type)) == null ? void 0 : _b.size)) {
186
+ types2.delete(type);
187
+ }
188
+ }
189
+ parentRefs.delete(link);
190
+ (listeners.get("onRemoveLink") ?? []).forEach((listener) => listener(link, currentValue ?? null));
79
191
  }
80
192
  };
81
- return { readLink: S2, writeLink: j2, hasLink: H2, getLinkEntries: $2, parentRefs: p2, childrenRefs: c2, addRefs: V2, removeRefs: D2, getChildren: (n2) => c2.get(n2), getParents: (n2) => p2.get(n2), getLinkedRefs: I2, invalidate: w2, links: u2, types: r2, refCount: i2, runGarbageCollector: P2, onRemoveLink: (n2) => e2.set("onRemoveLink", [...(e2 == null ? void 0 : e2.get("onRemoveLink")) ?? [], n2]) };
193
+ return {
194
+ readLink,
195
+ writeLink,
196
+ hasLink,
197
+ getLinkEntries,
198
+ parentRefs,
199
+ childrenRefs,
200
+ addRefs,
201
+ removeRefs,
202
+ getChildren: (key) => childrenRefs.get(key),
203
+ getParents: (key) => parentRefs.get(key),
204
+ getLinkedRefs,
205
+ invalidate,
206
+ links,
207
+ types: types2,
208
+ refCount,
209
+ runGarbageCollector,
210
+ onRemoveLink: (callback) => listeners.set("onRemoveLink", [...(listeners == null ? void 0 : listeners.get("onRemoveLink")) ?? [], callback])
211
+ };
82
212
  };
83
- var Q$1 = (...e2) => {
213
+ var joinKeys = (...keys) => {
84
214
  var _a;
85
- return (_a = e2 == null ? void 0 : e2.filter(Boolean)) == null ? void 0 : _a.join(".");
86
- };
87
- var fe = (e2 = []) => {
88
- let r2 = [], u2 = (c2) => {
89
- r2.push(c2);
90
- }, p2 = (c2) => r2.reduce((i2, E2) => E2(i2) ?? i2, c2);
91
- return e2.forEach(u2), { use: u2, runPlugins: p2 };
92
- };
93
- var ue = (e2) => e2 && O$2(e2) ? ["_id", "_type", "key", "mutate", "resolve"].every((u2) => u2 in e2) : false;
94
- var le = () => {
95
- let e2 = /* @__PURE__ */ new Set();
96
- return { debug: (p2) => {
97
- e2.forEach((c2) => {
98
- c2({ ...p2, timestamp: Date.now() });
99
- });
100
- }, onDebugEvent: (p2) => {
101
- e2.add(p2);
102
- } };
103
- };
104
- var ye = /* @__PURE__ */ new Set(), Se = (e2) => `[GraphState]: ${e2}`;
105
- function X$1(e2) {
106
- ye.has(e2) || (console.warn(Se(e2)), ye.add(e2));
107
- }
108
- var q$4 = (e2) => {
109
- if (typeof e2 == "string") return B$4(e2) ? e2 : null;
110
- if (!(e2 == null ? void 0 : e2._type)) return null;
111
- let r2 = null;
112
- return (y$4(e2.id) || y$4(e2._id)) && (r2 = `${e2.id ?? e2._id}`), r2 && `${e2._type}:${r2}`;
113
- };
114
- var B$4 = (e2) => {
115
- if (O$2(e2) && (e2 == null ? void 0 : e2._type) && q$4(e2)) return e2;
116
- if (!e2 || typeof e2 != "string") return null;
117
- let [r2, ...u2] = e2.split(":");
118
- return !r2 || u2.length < 1 ? null : { _type: r2, _id: u2.join(":") };
119
- };
120
- var he = 0, Ae = 100, Ke = "State", me = "$EACH:ROOT$", mt = (e2) => {
121
- let r2 = (e2 == null ? void 0 : e2._id) ?? `${he++}`, u2 = (e2 == null ? void 0 : e2._type) ?? Ke, p2 = `${u2}:${r2}`, c2 = [ue, ...(e2 == null ? void 0 : e2.skip) ?? []], i2 = ce(), E2 = le(), V2 = fe(e2 == null ? void 0 : e2.plugins), D2 = /* @__PURE__ */ new Map(), I2 = 0, w2 = (t2) => c2.some((s2) => s2(t2)), S2 = (t2, s2) => {
122
- let a2 = (s2 == null ? void 0 : s2.deep) ?? false, o2 = (s2 == null ? void 0 : s2.safe) ?? false, l2 = (s2 == null ? void 0 : s2.keepLinks) ?? false, { selector: m2, ...h3 } = s2 || {}, y$12 = y$4(t2) ? g2(t2) : null;
123
- E2.debug({ type: "resolve", entity: t2, options: s2 });
124
- let f2 = y$12 ? i2.readLink(y$12) : null;
125
- return w2(f2) ? f2 : ((O$2(f2) || Array.isArray(f2)) && (f2 = Object.entries(f2).reduce((L2, [A2, v2]) => {
126
- let K2 = v2;
127
- return w2(K2) || (Array.isArray(v2) ? (K2 = v2.map((T2) => w2(T2) ? T2 : G$2(T2) && !o2 && !i2.hasLink(T2) ? null : J$1(T2, y$12) && !l2 || a2 ? j2(T2, h3) : T2), o2 || (K2 = K2.filter(y$4))) : G$2(v2) && !o2 && !i2.hasLink(v2) ? K2 = null : (J$1(g2(v2), y$12) && !l2 || a2) && (K2 = j2(v2, h3))), L2[A2] = K2, L2;
128
- }, {})), f2 ? m2 ? m2({ ...f2 }) : { ...f2 } : o2 ? t2 : null);
129
- }, j2 = (t2, s2) => S2(t2, s2) ?? t2, H2 = (t2) => {
130
- let s2 = g2(t2);
131
- s2 && (i2.getChildren(s2) || []).forEach((o2) => {
132
- M$1(o2) || i2.removeRefs(s2, o2);
215
+ return (_a = keys == null ? void 0 : keys.filter(Boolean)) == null ? void 0 : _a.join(".");
216
+ };
217
+ var createPluginsState = (initialPlugins = []) => {
218
+ const plugins = [];
219
+ const use = (plugin) => {
220
+ plugins.push(plugin);
221
+ };
222
+ const runPlugins = (state) => {
223
+ return plugins.reduce((graphState, plugin) => plugin(graphState) ?? graphState, state);
224
+ };
225
+ initialPlugins.forEach(use);
226
+ return {
227
+ use,
228
+ runPlugins
229
+ };
230
+ };
231
+ var isGraphState = (input) => {
232
+ if (!input)
233
+ return false;
234
+ if (isObject$1$1(input)) {
235
+ const fields = ["_id", "_type", "key", "mutate", "resolve"];
236
+ return fields.every((field) => field in input);
237
+ }
238
+ return false;
239
+ };
240
+ var createDebugState = () => {
241
+ const listeners = /* @__PURE__ */ new Set();
242
+ const onDebugEvent = (callback) => {
243
+ listeners.add(callback);
244
+ };
245
+ const debug = (event) => {
246
+ listeners.forEach((callback) => {
247
+ callback({ ...event, timestamp: Date.now() });
133
248
  });
134
- }, R = (t2, s2, a2) => {
249
+ };
250
+ return {
251
+ debug,
252
+ onDebugEvent
253
+ };
254
+ };
255
+ var cache = /* @__PURE__ */ new Set();
256
+ var wrapMessage = (message) => `[GraphState]: ${message}`;
257
+ function warn(message) {
258
+ if (!cache.has(message)) {
259
+ console.warn(wrapMessage(message));
260
+ cache.add(message);
261
+ }
262
+ }
263
+ var keyOfEntity$1 = (entity) => {
264
+ if (typeof entity === "string") {
265
+ return entityOfKey$1(entity) ? entity : null;
266
+ }
267
+ if (!(entity == null ? void 0 : entity._type)) {
268
+ return null;
269
+ }
270
+ let entityId = null;
271
+ if (y$4(entity.id) || y$4(entity._id)) {
272
+ entityId = `${entity.id ?? entity._id}`;
273
+ }
274
+ return !entityId ? entityId : `${entity._type}:${entityId}`;
275
+ };
276
+ var entityOfKey$1 = (entity) => {
277
+ if (isObject$1$1(entity) && (entity == null ? void 0 : entity._type) && keyOfEntity$1(entity)) {
278
+ return entity;
279
+ }
280
+ if (!entity || typeof entity !== "string")
281
+ return null;
282
+ const [typeName, ...restTypes] = entity.split(":");
283
+ if (!typeName || restTypes.length < 1)
284
+ return null;
285
+ return {
286
+ _type: typeName,
287
+ _id: restTypes.join(":")
288
+ };
289
+ };
290
+ function omit$1(obj, ...props) {
291
+ const result = { ...obj };
292
+ props.forEach((prop) => {
293
+ delete result[prop];
294
+ });
295
+ return result;
296
+ }
297
+ var ID = 0;
298
+ var DEEP_LIMIT = 100;
299
+ var STATE_TYPE = "State";
300
+ var EACH_UPDATED = "$EACH:ROOT$";
301
+ var createState = (options) => {
302
+ const id = (options == null ? void 0 : options._id) ?? `${ID++}`;
303
+ const type = (options == null ? void 0 : options._type) ?? STATE_TYPE;
304
+ const stateKey = `${type}:${id}`;
305
+ const skipPredictors = [isGraphState, ...(options == null ? void 0 : options.skip) ?? []];
306
+ const cache2 = createCache();
307
+ const debugState = createDebugState();
308
+ const pluginsStore = createPluginsState(options == null ? void 0 : options.plugins);
309
+ const subscribers = /* @__PURE__ */ new Map();
310
+ let deepIndex = 0;
311
+ const isSkipped = (entity) => {
312
+ return skipPredictors.some((predictor) => predictor(entity));
313
+ };
314
+ const getReferences = (entity, options2) => {
315
+ const withPartialKeys = (options2 == null ? void 0 : options2.withPartialKeys) ?? false;
316
+ const key = keyOfEntity2(entity);
317
+ if (!key)
318
+ return [];
319
+ const values = cache2.getParents(key) ?? [];
320
+ return values.filter((v2) => withPartialKeys ? !isPartialKey(v2) : v2);
321
+ };
322
+ const resolve = (input, options2) => {
323
+ const isDeep = (options2 == null ? void 0 : options2.deep) ?? false;
324
+ const isSafe = (options2 == null ? void 0 : options2.safe) ?? false;
325
+ const keepLinks = (options2 == null ? void 0 : options2.keepLinks) ?? false;
326
+ const removeLinkFromSubGraph = (options2 == null ? void 0 : options2.removeLinkFromSubGraph) ?? true;
327
+ const { selector, ...coreOptions } = options2 || {};
328
+ const inputKey = y$4(input) ? keyOfEntity2(input) : null;
329
+ debugState.debug({ type: "resolve", entity: input, options: options2 });
330
+ let value = inputKey ? cache2.readLink(inputKey) : null;
331
+ if (isSkipped(value))
332
+ return value;
333
+ if (isObject$1$1(value) || Array.isArray(value)) {
334
+ value = Object.entries(value).reduce((acc, [key, value2]) => {
335
+ let resultValue = value2;
336
+ if (!isSkipped(resultValue)) {
337
+ if (Array.isArray(value2)) {
338
+ resultValue = value2.map((v2) => {
339
+ if (isSkipped(v2))
340
+ return v2;
341
+ if (isLinkKey(v2) && !isSafe && !cache2.hasLink(v2)) {
342
+ return null;
343
+ }
344
+ return isPartOfGraph(v2, inputKey) && !keepLinks || isDeep ? safeResolve(v2, coreOptions) : v2;
345
+ });
346
+ if (!isSafe) {
347
+ resultValue = resultValue.filter(y$4);
348
+ }
349
+ } else {
350
+ if (isLinkKey(value2) && !isSafe && !cache2.hasLink(value2)) {
351
+ resultValue = null;
352
+ } else if (isPartOfGraph(keyOfEntity2(value2), inputKey) && !keepLinks || isDeep) {
353
+ resultValue = safeResolve(value2, coreOptions);
354
+ }
355
+ }
356
+ }
357
+ acc[key] = isPartialGraph(resultValue) && removeLinkFromSubGraph ? omit$1(resultValue, "_type", "_id") : resultValue;
358
+ return acc;
359
+ }, {});
360
+ }
361
+ return value ? selector ? selector({ ...value }) : { ...value } : isSafe ? input : null;
362
+ };
363
+ const safeResolve = (input, options2) => resolve(input, options2) ?? input;
364
+ const unlinkGraph = (entity) => {
365
+ const graphKey = keyOfEntity2(entity);
366
+ if (graphKey) {
367
+ const deps = cache2.getChildren(graphKey) || [];
368
+ deps.forEach((depLink) => {
369
+ if (!isPartialKey(depLink)) {
370
+ cache2.removeRefs(graphKey, depLink);
371
+ }
372
+ });
373
+ }
374
+ };
375
+ const mutateField = (input, parentFieldKey, options2) => {
135
376
  var _a, _b, _c, _d;
136
- if ((!t2 || l$2(t2)) && !G$2(t2) || w2(t2)) return t2;
137
- let o2 = re(t2) ? g2(t2) : t2;
138
- if (G$2(o2)) {
139
- let y2 = ae(s2) ?? "", f2 = ((_a = a2 == null ? void 0 : a2.internal) == null ? void 0 : _a.visitors.get(y2)) ?? [], L2 = ((_b = a2 == null ? void 0 : a2.internal) == null ? void 0 : _b.visitors.get(o2)) ?? [];
140
- if (f2.includes(o2) || o2 === y2) return null;
141
- (_d = (_c = a2 == null ? void 0 : a2.internal) == null ? void 0 : _c.visitors) == null ? void 0 : _d.set(o2, [...L2, y2]);
142
- }
143
- if (Array.isArray(t2)) return t2.map((y2) => {
144
- let f2 = s2 ? Q$1(s2, `${he++}`) : void 0;
145
- return R(y2, f2, a2);
146
- });
147
- let m2 = (G$2(t2) ? t2 : se(t2) ? g2(t2) : null) ?? s2;
148
- return ((a2 == null ? void 0 : a2.overrideMutateMethod) || $2)(m2, t2, a2);
149
- }, $2 = (t2, ...s2) => {
150
- let { graphKey: a2, options: o2, data: l2 } = _2(t2, ...s2);
151
- E2.debug({ type: "beforeMutate", entity: a2, data: l2, options: o2 });
152
- let m2 = G$2(l2) ? C2(l2) : l2, h3 = a2 ?? p2, y2 = M$1 == null ? void 0 : M$1(h3), f2 = o2 == null ? void 0 : o2.parent, L2 = S2(h3 ?? ""), A2 = (o2 == null ? void 0 : o2.internal) || { hasChange: false, visitors: /* @__PURE__ */ new Map([]) }, v2 = { ...m2, ...C2(h3) }, K2 = !(o2 == null ? void 0 : o2.parent), T2 = (o2 == null ? void 0 : o2.replace) ? typeof (o2 == null ? void 0 : o2.replace) == "function" ? o2.replace(v2) : (o2 == null ? void 0 : o2.replace) === "deep" ? true : K2 || y2 : false;
153
- if (w2(m2)) return i2.writeLink(h3, m2, f2), h3;
154
- !T2 && O$2(L2) && O$2(v2) && (v2 = { ...L2, ...v2 }), T2 && H2(h3);
155
- let Z = Object.entries(v2).reduce((ee, [U2, Ee]) => {
156
- let te = Q$1(h3, U2), b2 = Ee, F2 = L2 == null ? void 0 : L2[U2], be = O$2(m2) && U2 in m2;
157
- w2(b2) || (!T2 && be && Array.isArray(b2) && Array.isArray(F2) && (b2 = [...F2, ...b2]), (O$2(b2) || Array.isArray(b2) || G$2(b2)) && (b2 = R(b2, te, { ...o2, parent: h3, internal: A2 })), Array.isArray(b2) && (o2 == null ? void 0 : o2.dedup) !== false && (b2 = oe(...b2)));
158
- let ve = ie(F2, te === b2 ? j2(b2) : b2);
159
- return A2.hasChange = A2.hasChange || !ve, !T2 && G$2(F2) && F2 !== b2 && i2.removeRefs(h3, F2), ee[U2] = b2, ee;
377
+ if ((!input || l$2(input)) && !isLinkKey(input) || isSkipped(input)) {
378
+ return input;
379
+ }
380
+ const inputLinkKey = isGraphOrKey(input) ? keyOfEntity2(input) : input;
381
+ if (isLinkKey(inputLinkKey)) {
382
+ const parentGraph = getGraphLink(parentFieldKey) ?? "";
383
+ const parentPaths = ((_a = options2 == null ? void 0 : options2.internal) == null ? void 0 : _a.visitors.get(parentGraph)) ?? [];
384
+ const visitorsPaths = ((_b = options2 == null ? void 0 : options2.internal) == null ? void 0 : _b.visitors.get(inputLinkKey)) ?? [];
385
+ if (parentPaths.includes(inputLinkKey) || inputLinkKey === parentGraph) {
386
+ return null;
387
+ }
388
+ (_d = (_c = options2 == null ? void 0 : options2.internal) == null ? void 0 : _c.visitors) == null ? void 0 : _d.set(inputLinkKey, [...visitorsPaths, parentGraph]);
389
+ }
390
+ if (Array.isArray(input)) {
391
+ return input.map((item) => {
392
+ const indexKey = parentFieldKey ? joinKeys(parentFieldKey, `${ID++}`) : void 0;
393
+ return mutateField(item, indexKey, options2);
394
+ });
395
+ }
396
+ const entityKey = isLinkKey(input) ? input : isGraph(input) ? keyOfEntity2(input) : null;
397
+ const childKey = entityKey ?? parentFieldKey;
398
+ const mutateMethod = (options2 == null ? void 0 : options2.overrideMutateMethod) || mutate;
399
+ return mutateMethod(childKey, input, options2);
400
+ };
401
+ const mutate = (entity, ...args) => {
402
+ const { graphKey: entityGraphKey, options: options2, data: rawData } = getArgumentsForMutate(entity, ...args);
403
+ debugState.debug({ type: "beforeMutate", entity: entityGraphKey, data: rawData, options: options2 });
404
+ const data = isLinkKey(rawData) ? entityOfKey2(rawData) : rawData;
405
+ const graphKey = entityGraphKey ?? stateKey;
406
+ const partialKey = isPartialKey == null ? void 0 : isPartialKey(graphKey);
407
+ const parentKey = options2 == null ? void 0 : options2.parent;
408
+ const prevGraph = resolve(graphKey ?? "", { removeLinkFromSubGraph: false });
409
+ const internal = (options2 == null ? void 0 : options2.internal) || { hasChange: false, visitors: /* @__PURE__ */ new Map([]) };
410
+ let graphData = {
411
+ ...data,
412
+ ...entityOfKey2(graphKey)
413
+ };
414
+ const isTopLevelGraph = !(options2 == null ? void 0 : options2.parent);
415
+ const isReplace = (options2 == null ? void 0 : options2.replace) ? typeof (options2 == null ? void 0 : options2.replace) === "function" ? options2.replace(graphData) : (options2 == null ? void 0 : options2.replace) === "deep" ? true : isTopLevelGraph || partialKey : false;
416
+ if (isSkipped(data)) {
417
+ cache2.writeLink(graphKey, data, parentKey);
418
+ return graphKey;
419
+ }
420
+ if (!isReplace && isObject$1$1(prevGraph) && isObject$1$1(graphData)) {
421
+ graphData = {
422
+ ...prevGraph,
423
+ ...graphData
424
+ };
425
+ }
426
+ if (isReplace) {
427
+ unlinkGraph(graphKey);
428
+ }
429
+ const nextGraph = Object.entries(graphData).reduce((acc, [key, value]) => {
430
+ const fieldKey = joinKeys(graphKey, key);
431
+ let fieldValue = value;
432
+ const prevValue = prevGraph == null ? void 0 : prevGraph[key];
433
+ const isUpdateField = isObject$1$1(data) && key in data;
434
+ if (!isSkipped(fieldValue)) {
435
+ if (!isReplace && isUpdateField && Array.isArray(fieldValue) && Array.isArray(prevValue)) {
436
+ fieldValue = [...prevValue, ...fieldValue];
437
+ }
438
+ if (isObject$1$1(fieldValue) || Array.isArray(fieldValue) || isLinkKey(fieldValue)) {
439
+ fieldValue = mutateField(fieldValue, fieldKey, {
440
+ ...options2,
441
+ parent: graphKey,
442
+ internal
443
+ });
444
+ }
445
+ if (Array.isArray(fieldValue) && (options2 == null ? void 0 : options2.dedup) !== false) {
446
+ fieldValue = uniqueLinks(...fieldValue);
447
+ }
448
+ }
449
+ const isEqual = shallowEqual(prevValue, fieldKey === fieldValue ? safeResolve(fieldValue) : fieldValue);
450
+ internal.hasChange = internal.hasChange || !isEqual;
451
+ if (!isReplace && isLinkKey(prevValue) && prevValue !== fieldValue) {
452
+ cache2.removeRefs(graphKey, prevValue);
453
+ }
454
+ acc[key] = fieldValue;
455
+ return acc;
160
456
  }, {});
161
- return i2.writeLink(h3, Z, f2), f2 || i2.runGarbageCollector(), (A2.hasChange || T2) && P2(h3, L2), E2.debug({ type: "afterMutate", entity: a2, data: l2, nextData: Z, options: o2, hasChange: A2.hasChange }), h3;
162
- }, N2 = (t2) => {
163
- let s2 = g2(t2);
164
- if (E2.debug({ type: "invalidate", entity: s2 }), s2) {
165
- let a2 = i2.getParents(s2) || [];
166
- i2.invalidate(s2), a2.forEach((o2) => {
167
- let l2 = i2.readLink(o2), m2 = S2(o2, { safe: false, keepLinks: true });
168
- i2.writeLink(o2, m2), P2(o2, l2);
457
+ cache2.writeLink(graphKey, nextGraph, parentKey);
458
+ if (!parentKey) {
459
+ cache2.runGarbageCollector();
460
+ }
461
+ if ((internal.hasChange || isReplace) && !parentKey) {
462
+ notify(graphKey, prevGraph);
463
+ }
464
+ debugState.debug({
465
+ type: "afterMutate",
466
+ entity: entityGraphKey,
467
+ data: rawData,
468
+ nextData: nextGraph,
469
+ options: options2,
470
+ hasChange: internal.hasChange
471
+ });
472
+ return graphKey;
473
+ };
474
+ const invalidate = (entity) => {
475
+ const key = keyOfEntity2(entity);
476
+ debugState.debug({ type: "invalidate", entity: key });
477
+ if (key) {
478
+ const parents = cache2.getParents(key) || [];
479
+ cache2.invalidate(key);
480
+ parents.forEach((parentKey) => {
481
+ const prevParent = cache2.readLink(parentKey);
482
+ const freshParent = resolve(parentKey, { safe: false, keepLinks: true, removeLinkFromSubGraph: false });
483
+ cache2.writeLink(parentKey, freshParent);
484
+ notify(parentKey, prevParent);
169
485
  });
170
486
  }
171
- }, P2 = (t2, s2) => {
172
- if (I2 > Ae) throw new Error("Too deep notify.");
173
- let a2 = g2(t2);
174
- if (E2.debug({ type: "notify", entity: a2 }), a2) {
175
- I2++;
176
- let o2 = [...D2.get(a2) || [], ...D2.get(me) || []], l2 = i2.getChildren(a2) || [], m2 = S2(a2), h3 = (y2) => {
177
- let f2 = m2 && (y2 == null ? void 0 : y2(m2)), L2 = s2 && (y2 == null ? void 0 : y2(s2));
178
- return { next: f2, prev: L2, hasChange: !W$1(f2, L2) };
487
+ };
488
+ const notify = (entity, prevState, _internal) => {
489
+ if (deepIndex > DEEP_LIMIT) {
490
+ throw new Error("Too deep notify.");
491
+ }
492
+ const depth = (_internal == null ? void 0 : _internal.depth) ?? 0;
493
+ const key = keyOfEntity2(entity);
494
+ debugState.debug({ type: "notify", entity: key });
495
+ if (key) {
496
+ deepIndex++;
497
+ const subs = [...subscribers.get(key) || [], ...subscribers.get(EACH_UPDATED) || []];
498
+ const deps = cache2.getChildren(key) || [];
499
+ const nextResult = resolve(key);
500
+ const getSelectedValues = (selector) => {
501
+ const next = nextResult && (selector == null ? void 0 : selector(nextResult));
502
+ const prev = prevState && (selector == null ? void 0 : selector(prevState));
503
+ return { next, prev, hasChange: !deepEqual(next, prev) };
179
504
  };
180
- o2.forEach(({ callback: y2, selector: f2 }) => {
181
- if (f2) {
182
- let { next: L2, prev: A2, hasChange: v2 } = h3(f2);
183
- v2 && y2(L2, A2);
184
- } else y2(m2, s2);
185
- }), l2.forEach((y2) => P2(y2, s2));
186
- }
187
- I2 = 0;
188
- }, n2 = (...t2) => {
189
- let s2 = typeof t2[0] == "function" ? me : t2[0], a2 = typeof t2[0] == "function" ? t2[0] : t2[1], o2 = typeof t2[0] == "function" ? t2[1] : t2[2], l2 = g2(s2), m2 = o2 == null ? void 0 : o2.selector;
190
- l2 && (D2.has(l2) ? D2.set(l2, [...Array.from(D2.get(l2) || []), { callback: a2, selector: m2 }]) : D2.set(l2, [{ callback: a2, selector: m2 }]), i2.onRemoveLink((y2, f2) => {
191
- y2 === l2 && P2(l2, f2);
192
- }));
193
- let h3 = () => {
194
- if (l2) {
195
- let y2 = (D2.get(l2) || []).findIndex((f2) => f2.callback === a2);
196
- if (y2 !== -1) {
197
- let f2 = D2.get(l2) || [];
198
- f2.splice(y2, 1), D2.set(l2, f2);
505
+ subs.forEach(({ callback, options: options2 }) => {
506
+ const selector = options2 == null ? void 0 : options2.selector;
507
+ const directChangesOnly = (options2 == null ? void 0 : options2.directChangesOnly) ?? false;
508
+ if (directChangesOnly && depth > 0) {
509
+ return;
510
+ }
511
+ if (selector) {
512
+ const { next, prev, hasChange } = getSelectedValues(selector);
513
+ if (hasChange)
514
+ callback(next, prev);
515
+ } else {
516
+ callback(nextResult, prevState);
517
+ }
518
+ });
519
+ deps.forEach(
520
+ (dep) => notify(dep, prevState, {
521
+ depth: depth + 1
522
+ })
523
+ );
524
+ }
525
+ deepIndex = 0;
526
+ };
527
+ const subscribe = (...args) => {
528
+ const input = typeof args[0] === "function" ? EACH_UPDATED : args[0];
529
+ const callback = typeof args[0] === "function" ? args[0] : args[1];
530
+ const options2 = typeof args[0] === "function" ? args[1] : args[2];
531
+ const key = keyOfEntity2(input);
532
+ if (key) {
533
+ if (subscribers.has(key)) {
534
+ subscribers.set(key, [...Array.from(subscribers.get(key) || []), { callback, options: options2 }]);
535
+ } else {
536
+ subscribers.set(key, [{ callback, options: options2 }]);
537
+ }
538
+ cache2.onRemoveLink((link, prevValue) => {
539
+ if (link === key) {
540
+ notify(key, prevValue);
541
+ }
542
+ });
543
+ }
544
+ const unsubscribe = () => {
545
+ if (key) {
546
+ const subIndex = (subscribers.get(key) || []).findIndex((sub) => sub.callback === callback);
547
+ if (subIndex !== -1) {
548
+ const nextSubscribers = subscribers.get(key) || [];
549
+ nextSubscribers.splice(subIndex, 1);
550
+ subscribers.set(key, nextSubscribers);
199
551
  }
200
552
  }
201
553
  };
202
- return (o2 == null ? void 0 : o2.signal) && o2.signal.addEventListener("abort", h3, { once: true }), h3;
203
- }, d2 = (t2) => [...i2.types.get(t2) ?? []], k2 = (t2) => {
204
- let s2 = (typeof t2 == "string" ? t2 : g2(t2)) || "";
205
- return (i2.getParents(s2) ?? []).map((o2) => S2(o2));
206
- }, g2 = (t2) => (X$1("Instance keyOfEntity is deprecated. Use static method keyOfEntity."), q$4(t2)), C2 = (t2) => (X$1("Instance entityOfKey is deprecated. Use static method entityOfKey."), B$4(t2)), _2 = (t2, ...s2) => {
207
- let a2 = typeof t2 == "string" ? s2[0] : t2;
208
- return typeof a2 == "function" ? a2 = a2(S2(t2)) : G$2(a2) && (a2 = C2(a2)), { graphKey: typeof t2 == "string" ? t2 : g2(t2), options: typeof t2 == "string" ? s2[1] : s2[0], data: a2 };
209
- };
210
- function x2(t2) {
211
- V2.use(t2), t2(this);
554
+ if (options2 == null ? void 0 : options2.signal) {
555
+ options2.signal.addEventListener("abort", unsubscribe, { once: true });
556
+ }
557
+ return unsubscribe;
558
+ };
559
+ const inspectFields = (graphType) => [...cache2.types.get(graphType) ?? []];
560
+ const resolveParents = (field) => {
561
+ const key = (typeof field === "string" ? field : keyOfEntity2(field)) || "";
562
+ const refs = cache2.getParents(key) ?? [];
563
+ return refs.map((ref) => resolve(ref));
564
+ };
565
+ const keyOfEntity2 = (entity) => {
566
+ warn("Instance keyOfEntity is deprecated. Use static method keyOfEntity.");
567
+ return keyOfEntity$1(entity);
568
+ };
569
+ const entityOfKey2 = (entity) => {
570
+ warn("Instance entityOfKey is deprecated. Use static method entityOfKey.");
571
+ return entityOfKey$1(entity);
572
+ };
573
+ const getArgumentsForMutate = (entity, ...args) => {
574
+ let data = typeof entity === "string" ? args[0] : entity;
575
+ if (typeof data === "function") {
576
+ data = data(resolve(entity));
577
+ } else if (isLinkKey(data)) {
578
+ data = entityOfKey2(data);
579
+ }
580
+ return {
581
+ graphKey: typeof entity === "string" ? entity : keyOfEntity2(entity),
582
+ options: typeof entity === "string" ? args[1] : args[0],
583
+ data
584
+ };
585
+ };
586
+ function use(plugin) {
587
+ pluginsStore.use(plugin);
588
+ plugin(this);
212
589
  }
213
- let z2 = (t2) => {
214
- c2.push(t2);
590
+ const addSkip = (predictor) => {
591
+ skipPredictors.push(predictor);
215
592
  };
216
- (e2 == null ? void 0 : e2.initialState) && $2(e2.initialState, { replace: true });
217
- let ke = { _type: u2, _id: r2, key: p2, mutate: $2, subscribe: n2, resolve: S2, safeResolve: j2, resolveParents: k2, inspectFields: d2, invalidate: N2, keyOfEntity: g2, entityOfKey: C2, getArgumentsForMutate: _2, types: i2.types, cache: i2, use: x2, addSkip: z2, subscribers: void 0, onDebugEvent: E2.onDebugEvent };
218
- return i2.onRemoveLink((t2, s2) => E2.debug({ type: "garbageRemove", entity: t2, prevValue: s2 })), V2.runPlugins(ke);
593
+ if (options == null ? void 0 : options.initialState) {
594
+ mutate(options.initialState, { replace: "deep" });
595
+ }
596
+ const graphState = {
597
+ _type: type,
598
+ _id: id,
599
+ key: stateKey,
600
+ getReferences,
601
+ mutate,
602
+ subscribe,
603
+ resolve,
604
+ safeResolve,
605
+ resolveParents,
606
+ inspectFields,
607
+ invalidate,
608
+ keyOfEntity: keyOfEntity2,
609
+ entityOfKey: entityOfKey2,
610
+ getArgumentsForMutate,
611
+ types: cache2.types,
612
+ cache: cache2,
613
+ use,
614
+ addSkip,
615
+ subscribers: void 0,
616
+ onDebugEvent: debugState.onDebugEvent
617
+ };
618
+ cache2.onRemoveLink((link, prevValue) => debugState.debug({ type: "garbageRemove", entity: link, prevValue }));
619
+ return pluginsStore.runPlugins(graphState);
219
620
  };
220
621
  const createConstants$1 = (...constants) => {
221
622
  return constants.reduce((acc, constant) => {
@@ -329,12 +730,13 @@ const variableTransforms$1 = createConstants$1(
329
730
  );
330
731
  const renderTarget$1 = createConstants$1("canvas", "document");
331
732
  const renderMode$1 = createConstants$1("viewport", "parent", "fixed");
332
- const interactions$1 = createConstants$1("click", "mouseover");
333
- const eventMode$1 = createConstants$1("goal", "callback");
733
+ const interactions$1 = createConstants$1("click", "mouseover", "appear");
734
+ const eventMode$1 = createConstants$1("goal", "callback", "tracker");
334
735
  const scopeTypes$1 = createConstants$1(
335
736
  "InstanceScope",
336
737
  "FragmentScope",
337
- "CollectionScope"
738
+ "CollectionScope",
739
+ "CollectionItemScope"
338
740
  );
339
741
  const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
340
742
  __proto__: null,
@@ -1145,8 +1547,28 @@ const PositionSchema$1 = /* @__PURE__ */ object$1({
1145
1547
  position: layerField$1(/* @__PURE__ */ enum_$1(Object.keys(positionType$1)), {
1146
1548
  fallback: positionType$1.absolute
1147
1549
  }),
1148
- top: layerField$1(/* @__PURE__ */ number$1(), { fallback: 0, transform: Math.ceil }),
1149
- left: layerField$1(/* @__PURE__ */ number$1(), { fallback: 0, transform: Math.ceil })
1550
+ top: layerField$1(/* @__PURE__ */ nullable$1(/* @__PURE__ */ number$1()), {
1551
+ fallback: null,
1552
+ transform: (value) => typeof value === "number" ? Math.ceil(value) : value
1553
+ }),
1554
+ left: layerField$1(/* @__PURE__ */ nullable$1(/* @__PURE__ */ number$1()), {
1555
+ fallback: null,
1556
+ transform: (value) => typeof value === "number" ? Math.ceil(value) : value
1557
+ }),
1558
+ right: layerField$1(/* @__PURE__ */ nullable$1(/* @__PURE__ */ number$1()), {
1559
+ fallback: null,
1560
+ transform: (value) => typeof value === "number" ? Math.ceil(value) : value
1561
+ }),
1562
+ bottom: layerField$1(/* @__PURE__ */ nullable$1(/* @__PURE__ */ number$1()), {
1563
+ fallback: null,
1564
+ transform: (value) => typeof value === "number" ? Math.ceil(value) : value
1565
+ }),
1566
+ centerAnchorX: layerField$1(/* @__PURE__ */ number$1(), {
1567
+ fallback: 0.5
1568
+ }),
1569
+ centerAnchorY: layerField$1(/* @__PURE__ */ number$1(), {
1570
+ fallback: 0.5
1571
+ })
1150
1572
  });
1151
1573
  const SceneSchema$1 = /* @__PURE__ */ object$1({
1152
1574
  opacity: layerField$1(/* @__PURE__ */ pipe$1(/* @__PURE__ */ number$1(), /* @__PURE__ */ minValue$1(0), /* @__PURE__ */ maxValue$1(1)), {
@@ -1154,6 +1576,7 @@ const SceneSchema$1 = /* @__PURE__ */ object$1({
1154
1576
  variable: true
1155
1577
  }),
1156
1578
  visible: layerField$1(/* @__PURE__ */ boolean$1(), { fallback: true, variable: true }),
1579
+ rotate: layerField$1(/* @__PURE__ */ number$1(), { fallback: null }),
1157
1580
  zIndex: layerField$1(/* @__PURE__ */ number$1(), { fallback: -1 })
1158
1581
  });
1159
1582
  const FillSchema$1 = /* @__PURE__ */ object$1({
@@ -1303,33 +1726,22 @@ const LinkSchema$1 = /* @__PURE__ */ object$1({
1303
1726
  whiteSpace: layerField$1(/* @__PURE__ */ enum_$1(Object.keys(whiteSpace$1)), {
1304
1727
  fallback: whiteSpace$1.pre
1305
1728
  }),
1306
- variableContent: layerField$1(/* @__PURE__ */ string$1(), { fallback: null, variable: true }),
1729
+ textAlign: layerField$1(/* @__PURE__ */ string$1(), { fallback: "left" }),
1307
1730
  parent: layerField$1(/* @__PURE__ */ nullable$1(/* @__PURE__ */ string$1()), { overridable: false }),
1308
- attributes: /* @__PURE__ */ optional$1(
1309
- /* @__PURE__ */ object$1({
1310
- fontSize: layerField$1(/* @__PURE__ */ string$1(), { fallback: "14px" }),
1311
- color: layerField$1(/* @__PURE__ */ string$1(), { fallback: "#000", variable: true }),
1312
- lineHeight: layerField$1(/* @__PURE__ */ string$1(), { fallback: "14px" }),
1313
- fontWeight: layerField$1(/* @__PURE__ */ string$1(), { fallback: "normal" }),
1314
- letterSpacing: layerField$1(/* @__PURE__ */ string$1(), { fallback: "0px" }),
1315
- textTransform: layerField$1(/* @__PURE__ */ string$1(), { fallback: "none" }),
1316
- textDecoration: layerField$1(/* @__PURE__ */ string$1(), { fallback: "none" }),
1317
- whiteSpace: layerField$1(/* @__PURE__ */ string$1(), { fallback: "pre" }),
1318
- textAlign: layerField$1(/* @__PURE__ */ string$1(), { fallback: "left" })
1319
- })
1320
- ),
1321
1731
  ...GraphFieldSchema$1.entries,
1322
1732
  ...OverridesSchema$1.entries,
1323
1733
  ...CssOverrideSchema$1.entries,
1324
1734
  ...PositionSchema$1.entries,
1325
1735
  ...SceneSchema$1.entries,
1326
- ...SizeSchema$1.entries
1736
+ ...SizeSchema$1.entries,
1737
+ ...InteractionsSchema$1.entries,
1738
+ ...LinkSchema$1.entries
1327
1739
  });
1328
1740
  /* @__PURE__ */ object$1({
1329
1741
  name: layerField$1(/* @__PURE__ */ string$1(), { fallback: "Fragment", overridable: false }),
1330
1742
  parent: layerField$1(/* @__PURE__ */ nullable$1(/* @__PURE__ */ string$1()), { overridable: false }),
1331
1743
  horizontalGrow: layerField$1(/* @__PURE__ */ enum_$1(Object.keys(fragmentGrowingMode$1)), {
1332
- fallback: fragmentGrowingMode$1.auto,
1744
+ fallback: fragmentGrowingMode$1.fill,
1333
1745
  overridable: false
1334
1746
  }),
1335
1747
  verticalGrow: layerField$1(/* @__PURE__ */ enum_$1(Object.keys(fragmentGrowingMode$1)), {
@@ -1370,6 +1782,7 @@ const LinkSchema$1 = /* @__PURE__ */ object$1({
1370
1782
  ...PositionSchema$1.entries,
1371
1783
  ...SizeSchema$1.entries,
1372
1784
  ...SceneSchema$1.entries,
1785
+ ...InteractionsSchema$1.entries,
1373
1786
  ...LinkSchema$1.entries
1374
1787
  });
1375
1788
  /* @__PURE__ */ object$1({
@@ -1554,7 +1967,7 @@ const LinkSchema$1 = /* @__PURE__ */ object$1({
1554
1967
  }),
1555
1968
  parent: layerField$1(/* @__PURE__ */ nullable$1(/* @__PURE__ */ string$1()), { overridable: false }),
1556
1969
  defaultValue: layerField$1(/* @__PURE__ */ array$1(/* @__PURE__ */ any$1()), { fallback: [] }),
1557
- definition: layerField$1(/* @__PURE__ */ nullable$1(linkValidator$1), { fallback: null }),
1970
+ definition: layerField$1(linkValidator$1, { fallback: null }),
1558
1971
  required: layerField$1(/* @__PURE__ */ boolean$1(), { fallback: false }),
1559
1972
  ...GraphFieldSchema$1.entries
1560
1973
  });
@@ -1562,13 +1975,13 @@ const BASE_HEADERS = {
1562
1975
  "Content-Type": "application/json"
1563
1976
  };
1564
1977
  const createFetcher = (baseUrl, defaultHeaders = {}) => {
1565
- const cache = /* @__PURE__ */ new Map();
1978
+ const cache2 = /* @__PURE__ */ new Map();
1566
1979
  const inflightRequests = /* @__PURE__ */ new Map();
1567
1980
  const getCacheKey = (query2, variables, options) => JSON.stringify({ query: query2, variables, options });
1568
1981
  const query = async (query2, variables = {}, options = {}) => {
1569
1982
  const cacheKey = getCacheKey(query2, variables, options);
1570
- if (cache.has(cacheKey)) {
1571
- return cache.get(cacheKey);
1983
+ if (cache2.has(cacheKey)) {
1984
+ return cache2.get(cacheKey);
1572
1985
  }
1573
1986
  if (inflightRequests.has(cacheKey)) {
1574
1987
  return inflightRequests.get(cacheKey);
@@ -1587,7 +2000,7 @@ const createFetcher = (baseUrl, defaultHeaders = {}) => {
1587
2000
  if (!res.ok) throw new Error(`Fetch error: ${res.status}`);
1588
2001
  const data = await res.json();
1589
2002
  if (!query2.includes("mutation")) {
1590
- cache.set(cacheKey, data);
2003
+ cache2.set(cacheKey, data);
1591
2004
  }
1592
2005
  return data;
1593
2006
  }).finally(() => {
@@ -1597,9 +2010,9 @@ const createFetcher = (baseUrl, defaultHeaders = {}) => {
1597
2010
  return request;
1598
2011
  };
1599
2012
  const invalidate = (endpoint, options) => {
1600
- cache.delete(getCacheKey(endpoint, options));
2013
+ cache2.delete(getCacheKey(endpoint, options));
1601
2014
  };
1602
- const clearCache = () => cache.clear();
2015
+ const clearCache = () => cache2.clear();
1603
2016
  return { query, invalidate, clearCache };
1604
2017
  };
1605
2018
  const getFragmentQuery = (fragmentId, isSelf) => {
@@ -1665,10 +2078,10 @@ const fetchBeacon = (baseUrl) => {
1665
2078
  sendBeacon
1666
2079
  };
1667
2080
  };
1668
- const getAreaQuery = (areaCode) => {
2081
+ const getAreaListQuery = (areaCodes) => {
1669
2082
  return {
1670
- query: `query($areaCode: String!) {
1671
- clientArea(areaCode: $areaCode) {
2083
+ query: `query($areaCodes: [String!]!) {
2084
+ clientAreas(areaCodes: $areaCodes) {
1672
2085
  variant {
1673
2086
  fragment {
1674
2087
  props
@@ -1685,18 +2098,23 @@ const getAreaQuery = (areaCode) => {
1685
2098
  }
1686
2099
  }`,
1687
2100
  variables: {
1688
- areaCode
2101
+ areaCodes
1689
2102
  }
1690
2103
  };
1691
2104
  };
1692
2105
  const fetchPlugin = (state) => {
1693
- var _a, _b, _c;
2106
+ var _a, _b, _c, _d;
1694
2107
  const isSelf = ((_a = state == null ? void 0 : state.env) == null ? void 0 : _a.isSelf) ?? false;
1695
2108
  const url = (_b = state == null ? void 0 : state.env) == null ? void 0 : _b.backendEndpoint;
1696
2109
  const apiToken = (_c = state == null ? void 0 : state.env) == null ? void 0 : _c.apiToken;
1697
- const fetcher = createFetcher(url, {
2110
+ const referer = (_d = state == null ? void 0 : state.env) == null ? void 0 : _d.referer;
2111
+ let headers = {
1698
2112
  Authorization: `Bearer ${apiToken}`
1699
- });
2113
+ };
2114
+ if (referer) {
2115
+ headers.Referer = referer;
2116
+ }
2117
+ const fetcher = createFetcher(url, headers);
1700
2118
  const beaconFetcher = fetchBeacon();
1701
2119
  const queryFragment = async (fragmentId) => {
1702
2120
  var _a2;
@@ -1707,7 +2125,8 @@ const fetchPlugin = (state) => {
1707
2125
  const fragmentQuery = getFragmentQuery(fragmentId, isSelf);
1708
2126
  const response = await fetcher.query(
1709
2127
  fragmentQuery.query,
1710
- fragmentQuery.variables
2128
+ fragmentQuery.variables,
2129
+ { referrerPolicy: "unsafe-url" }
1711
2130
  );
1712
2131
  let fragment2 = null;
1713
2132
  if (!!(response == null ? void 0 : response.data) && "clientFragment" in response.data) {
@@ -1736,36 +2155,46 @@ const fetchPlugin = (state) => {
1736
2155
  return null;
1737
2156
  };
1738
2157
  const queryArea = async (areaCode) => {
2158
+ return queryAreaList([areaCode]).then((res) => res == null ? void 0 : res.at(0));
2159
+ };
2160
+ const queryAreaList = async (areaCodes) => {
1739
2161
  var _a2;
1740
- if (!apiToken || !areaCode) return null;
1741
- if (state.$fetch.cacheAreaDocuments.has(areaCode)) {
1742
- return state.$fetch.cacheAreaDocuments.get(areaCode);
2162
+ if (!apiToken || !areaCodes) return null;
2163
+ const nonLoadedAreas = areaCodes.filter(
2164
+ (code) => !state.$fetch.cacheAreaDocuments.has(code)
2165
+ );
2166
+ if (!nonLoadedAreas.length) {
2167
+ return areaCodes.map(state.$fetch.cacheAreaDocuments.get);
1743
2168
  }
1744
- const areaQuery = getAreaQuery(areaCode);
2169
+ const areaQuery = getAreaListQuery(areaCodes);
1745
2170
  const response = await fetcher.query(
1746
2171
  areaQuery.query,
1747
- areaQuery.variables
2172
+ areaQuery.variables,
2173
+ { referrerPolicy: "unsafe-url" }
1748
2174
  );
1749
- const area = (_a2 = response == null ? void 0 : response.data) == null ? void 0 : _a2.clientArea;
1750
- if (area) {
1751
- state.$fetch.cacheDocuments.set(
1752
- area.variant.fragment.fragment.id,
1753
- area.variant.fragment.fragment.document
1754
- );
1755
- if (Array.isArray(area.variant.fragment.fragment.linkedFragments)) {
1756
- area.variant.fragment.fragment.linkedFragments.forEach(
1757
- (linkedFragment) => state.$fetch.cacheDocuments.set(
1758
- linkedFragment.id,
1759
- linkedFragment.document
1760
- )
2175
+ const areas = (_a2 = response == null ? void 0 : response.data) == null ? void 0 : _a2.clientAreas;
2176
+ if (areas) {
2177
+ areas.forEach((area, index2) => {
2178
+ const areaCode = areaCodes == null ? void 0 : areaCodes.at(index2);
2179
+ state.$fetch.cacheDocuments.set(
2180
+ area.variant.fragment.fragment.id,
2181
+ area.variant.fragment.fragment.document
1761
2182
  );
1762
- }
1763
- const entity = {
1764
- fragmentId: area.variant.fragment.fragment.id,
1765
- props: area.variant.fragment.props
1766
- };
1767
- state.$fetch.cacheAreaDocuments.set(areaCode, entity);
1768
- return entity;
2183
+ if (Array.isArray(area.variant.fragment.fragment.linkedFragments)) {
2184
+ area.variant.fragment.fragment.linkedFragments.forEach(
2185
+ (linkedFragment) => state.$fetch.cacheDocuments.set(
2186
+ linkedFragment.id,
2187
+ linkedFragment.document
2188
+ )
2189
+ );
2190
+ }
2191
+ const entity = {
2192
+ fragmentId: area.variant.fragment.fragment.id,
2193
+ props: area.variant.fragment.props
2194
+ };
2195
+ state.$fetch.cacheAreaDocuments.set(areaCode, entity);
2196
+ });
2197
+ return areaCodes.map((code) => state.$fetch.cacheAreaDocuments.get(code));
1769
2198
  }
1770
2199
  return null;
1771
2200
  };
@@ -1774,6 +2203,7 @@ const fetchPlugin = (state) => {
1774
2203
  cacheAreaDocuments: /* @__PURE__ */ new Map(),
1775
2204
  queryFragment,
1776
2205
  queryArea,
2206
+ queryAreaList,
1777
2207
  query: fetcher.query,
1778
2208
  sendBeacon: beaconFetcher.sendBeacon,
1779
2209
  readFragment: (fragmentId) => state.$fetch.cacheDocuments.get(fragmentId) ?? null,
@@ -1784,11 +2214,11 @@ const getAllChildren = (layerResolver, layerKey, acc = []) => {
1784
2214
  var _a;
1785
2215
  const layer = layerResolver(layerKey) ?? {};
1786
2216
  if (acc.length === 0) {
1787
- acc.push(layerKey);
2217
+ acc.push(keyOfEntity$1(layerKey));
1788
2218
  }
1789
2219
  (_a = layer == null ? void 0 : layer.children) == null ? void 0 : _a.forEach((child) => {
1790
2220
  if (child) {
1791
- acc.push(child);
2221
+ acc.push(keyOfEntity$1(child));
1792
2222
  getAllChildren(layerResolver, child, acc);
1793
2223
  }
1794
2224
  });
@@ -1810,8 +2240,8 @@ const findGroups = (styles2, layerResolver) => {
1810
2240
  const primaryBreakpoint = breakpoints.find(
1811
2241
  (breakpoint) => breakpoint == null ? void 0 : breakpoint.isPrimary
1812
2242
  );
1813
- const smaller = breakpoints.filter((f2) => !!f2 && (f2 == null ? void 0 : f2.width) < (primaryBreakpoint == null ? void 0 : primaryBreakpoint.width)).sort((a2, b2) => b2.width - a2.width);
1814
- const larger = breakpoints.filter((f2) => !!f2 && (f2 == null ? void 0 : f2.width) > (primaryBreakpoint == null ? void 0 : primaryBreakpoint.width)).sort((a2, b2) => a2.width - b2.width);
2243
+ const smaller = breakpoints.filter((f2) => !!f2 && (f2 == null ? void 0 : f2.width) < (primaryBreakpoint == null ? void 0 : primaryBreakpoint.width)).sort((a2, b) => b.width - a2.width);
2244
+ const larger = breakpoints.filter((f2) => !!f2 && (f2 == null ? void 0 : f2.width) > (primaryBreakpoint == null ? void 0 : primaryBreakpoint.width)).sort((a2, b) => a2.width - b.width);
1815
2245
  return {
1816
2246
  fragmentLayerKey,
1817
2247
  fragment: rootLayer,
@@ -1847,27 +2277,59 @@ const makeCss = (styles2, layerResolver) => (layerKey) => {
1847
2277
  const cssOverride = (cacheLayer == null ? void 0 : cacheLayer.cssOverride) ?? "";
1848
2278
  return {
1849
2279
  hash: layerHash,
1850
- css: cssOverride + toCSS(resultCssRules)
2280
+ css: toCSS(resultCssRules) + cssOverride
1851
2281
  };
1852
2282
  };
1853
2283
  const autoInjector = (key, state, graphKey, transformStyles) => {
2284
+ const removeStyle = () => {
2285
+ if (!isBrowser_default$1) return;
2286
+ const el = document.getElementById(key);
2287
+ if (el) el.remove();
2288
+ };
1854
2289
  const injectStyle = (styles2) => {
1855
- if (isBrowser_default$1 && styles2) {
1856
- if (document.getElementById(key)) {
1857
- const el = document.getElementById(key);
1858
- if (el) el.remove();
2290
+ if (!isBrowser_default$1) return;
2291
+ if (!styles2) {
2292
+ removeStyle();
2293
+ return;
2294
+ }
2295
+ const existing = document.getElementById(key);
2296
+ if (existing && existing.tagName === "STYLE") {
2297
+ existing.textContent = styles2;
2298
+ return;
2299
+ }
2300
+ if (existing) existing.remove();
2301
+ const style = document.createElement("style");
2302
+ style.id = key;
2303
+ style.textContent = styles2;
2304
+ document.head.appendChild(style);
2305
+ };
2306
+ let isMounted = false;
2307
+ let pendingStyles = "";
2308
+ state.subscribe(
2309
+ graphKey,
2310
+ (next) => {
2311
+ const styles2 = (transformStyles == null ? void 0 : transformStyles(next)) ?? (next == null ? void 0 : next.styles) ?? [];
2312
+ const resultStyle = styles2.join("\n");
2313
+ pendingStyles = resultStyle;
2314
+ if (isMounted) {
2315
+ injectStyle(resultStyle);
1859
2316
  }
1860
- const style = document.createElement("style");
1861
- style.id = key;
1862
- style.textContent = styles2;
1863
- document.head.appendChild(style);
2317
+ },
2318
+ { directChangesOnly: true }
2319
+ );
2320
+ const mount = () => {
2321
+ isMounted = true;
2322
+ if (pendingStyles) {
2323
+ injectStyle(pendingStyles);
2324
+ } else {
2325
+ removeStyle();
1864
2326
  }
1865
2327
  };
1866
- state.subscribe(graphKey, (next) => {
1867
- const styles2 = (transformStyles == null ? void 0 : transformStyles(next)) ?? (next == null ? void 0 : next.styles) ?? [];
1868
- const resultStyle = styles2.join("\n");
1869
- injectStyle(resultStyle);
1870
- });
2328
+ const unmount = () => {
2329
+ isMounted = false;
2330
+ removeStyle();
2331
+ };
2332
+ return { mount, unmount };
1871
2333
  };
1872
2334
  function generatePrimaryCssBlocks(layerResolver, group, cssMaker) {
1873
2335
  const children = getAllChildren(layerResolver, group.primary);
@@ -1929,12 +2391,24 @@ const fragmentStylesheetPlugin = (state) => {
1929
2391
  state.mutate(KEY, {
1930
2392
  styles: {}
1931
2393
  });
1932
- autoInjector(state.key, state, KEY, (graph) => {
2394
+ const fragmentStyleInjector = autoInjector(state.key, state, KEY, (graph) => {
1933
2395
  return extractStyleSheet(graph.styles, state.resolve);
1934
2396
  });
2397
+ const destroyStyles = () => {
2398
+ state.mutate(
2399
+ KEY,
2400
+ {
2401
+ styles: {}
2402
+ },
2403
+ { replace: true }
2404
+ );
2405
+ fragmentStyleInjector.unmount();
2406
+ };
1935
2407
  state.$styleSheet = {
1936
2408
  key: KEY,
1937
2409
  addStyle,
2410
+ mount: fragmentStyleInjector.mount,
2411
+ unmount: destroyStyles,
1938
2412
  extract: (withTag) => {
1939
2413
  var _a;
1940
2414
  const graph = state.resolve(KEY);
@@ -1949,7 +2423,7 @@ const fragmentStylesheetPlugin = (state) => {
1949
2423
  };
1950
2424
  return state;
1951
2425
  };
1952
- const globalCss = '[data-key^="Fragment"] {\n [data-key^="Text"] {\n p {\n margin: 0;\n }\n }\n\n /* 1. Use a more-intuitive box-sizing model */\n\n *, *::before, *::after {\n box-sizing: border-box;\n }\n\n /* 2. Remove default margin */\n\n * {\n margin: 0;\n }\n\n /* 3. Enable keyword animations */\n @media (prefers-reduced-motion: no-preference) {\n html {\n interpolate-size: allow-keywords;\n }\n }\n\n body {\n /* 4. Add accessible line-height */\n line-height: 1.5;\n /* 5. Improve text rendering */\n -webkit-font-smoothing: antialiased;\n }\n\n /* 6. Improve media defaults */\n\n img, picture, video, canvas, svg {\n display: block;\n max-width: 100%;\n }\n\n /* 7. Inherit fonts for form controls */\n\n input, button, textarea, select {\n font: inherit;\n }\n\n /* 8. Avoid text overflows */\n\n p, h1, h2, h3, h4, h5, h6 {\n overflow-wrap: break-word;\n }\n\n /*\n 10. Create a root stacking context\n */\n\n #root, #__next {\n isolation: isolate;\n }\n\n a {\n text-decoration: none;\n }\n}\n';
2426
+ const globalCss = '[data-key^="Fragment"] {\n [data-key^="Text"] {\n p {\n margin: 0;\n font-size: 14px;\n color: #000;\n font-weight: 400;\n }\n }\n\n /* 1. Use a more-intuitive box-sizing model */\n\n *, *::before, *::after {\n box-sizing: border-box;\n }\n\n /* 2. Remove default margin */\n\n * {\n margin: 0;\n }\n\n /* 3. Enable keyword animations */\n @media (prefers-reduced-motion: no-preference) {\n html {\n interpolate-size: allow-keywords;\n }\n }\n\n body {\n /* 4. Add accessible line-height */\n line-height: 1.5;\n /* 5. Improve text rendering */\n -webkit-font-smoothing: antialiased;\n }\n\n /* 6. Improve media defaults */\n\n img, picture, video, canvas, svg {\n display: block;\n max-width: 100%;\n }\n\n /* 7. Inherit fonts for form controls */\n\n input, button, textarea, select {\n font: inherit;\n }\n\n /* 8. Avoid text overflows */\n\n p, h1, h2, h3, h4, h5, h6 {\n overflow-wrap: break-word;\n }\n\n /*\n 10. Create a root stacking context\n */\n\n #root, #__next {\n isolation: isolate;\n }\n\n a {\n text-decoration: none;\n }\n}\n';
1953
2427
  const globalStylesheetPlugin = (state) => {
1954
2428
  if (!("$fragments" in state)) {
1955
2429
  throw new Error("GlobalStylesheetPlugin need $fragments plugin");
@@ -1965,10 +2439,12 @@ const globalStylesheetPlugin = (state) => {
1965
2439
  _id: "root",
1966
2440
  styles: []
1967
2441
  });
1968
- autoInjector("global", state, KEY);
2442
+ const globalStyleInjector = autoInjector("global", state, KEY);
1969
2443
  state.$globalStylesheet = {
1970
2444
  key: KEY,
1971
2445
  addStyle,
2446
+ mount: globalStyleInjector.mount,
2447
+ unmount: globalStyleInjector.unmount,
1972
2448
  extractStyles: () => {
1973
2449
  const allFragments = state.$fragments.getManagers();
1974
2450
  const styles2 = Object.entries(allFragments).filter(([, value]) => !!(value == null ? void 0 : value.resolve)).map(([, manager]) => manager.$styleSheet.extract(true));
@@ -1976,6 +2452,7 @@ const globalStylesheetPlugin = (state) => {
1976
2452
  }
1977
2453
  };
1978
2454
  addStyle(globalCss);
2455
+ globalStyleInjector.mount();
1979
2456
  return state;
1980
2457
  };
1981
2458
  const scopesPlugin = (state) => {
@@ -1989,7 +2466,8 @@ const scopesPlugin = (state) => {
1989
2466
  };
1990
2467
  return state;
1991
2468
  };
1992
- const fragmentsPlugin = (state) => {
2469
+ const fragmentsPlugin = (options) => (state) => {
2470
+ const plugins = (options == null ? void 0 : options.plugins) ?? [];
1993
2471
  const createFragmentManager = (fragmentId, initialDocument = {}) => {
1994
2472
  var _a, _b;
1995
2473
  if (!fragmentId || !initialDocument) return null;
@@ -2010,7 +2488,7 @@ const fragmentsPlugin = (state) => {
2010
2488
  _type: "Spring",
2011
2489
  _id: "root"
2012
2490
  };
2013
- const manager = mt({
2491
+ const manager = createState({
2014
2492
  _type: "FragmentManager",
2015
2493
  _id: fragmentId,
2016
2494
  initialState: initialDocument,
@@ -2023,7 +2501,8 @@ const fragmentsPlugin = (state) => {
2023
2501
  },
2024
2502
  // cssPlugin,
2025
2503
  fragmentStylesheetPlugin,
2026
- scopesPlugin
2504
+ scopesPlugin,
2505
+ ...plugins
2027
2506
  ],
2028
2507
  skip: [
2029
2508
  g$2,
@@ -2069,34 +2548,94 @@ const fragmentsPlugin = (state) => {
2069
2548
  const addClientMetric = `mutation AddClientMetric($type: ClientMetricType!, $value: String) {
2070
2549
  addClientMetric(metric: {metricType: $type, metricValue: $value})
2071
2550
  }`;
2551
+ const pendingPixels = /* @__PURE__ */ new Set();
2552
+ const sendWithImage = (url) => {
2553
+ try {
2554
+ const pixel = new Image();
2555
+ pixel.referrerPolicy = "no-referrer";
2556
+ const handleCleanup = () => {
2557
+ pixel.removeEventListener("load", handleCleanup);
2558
+ pixel.removeEventListener("error", handleCleanup);
2559
+ pendingPixels.delete(pixel);
2560
+ };
2561
+ pixel.addEventListener("load", handleCleanup, { once: true });
2562
+ pixel.addEventListener("error", handleCleanup, { once: true });
2563
+ pendingPixels.add(pixel);
2564
+ pixel.src = url;
2565
+ } catch {
2566
+ }
2567
+ };
2568
+ const sendWithFetch = (url) => {
2569
+ if (typeof fetch !== "function") {
2570
+ return false;
2571
+ }
2572
+ try {
2573
+ fetch(url, {
2574
+ method: "GET",
2575
+ mode: "no-cors",
2576
+ keepalive: true
2577
+ }).catch(() => void 0);
2578
+ return true;
2579
+ } catch {
2580
+ return false;
2581
+ }
2582
+ };
2583
+ const sendWithNavigatorBeacon = (url) => {
2584
+ if (typeof navigator === "undefined" || typeof navigator.sendBeacon !== "function") {
2585
+ return false;
2586
+ }
2587
+ try {
2588
+ return navigator.sendBeacon(url);
2589
+ } catch {
2590
+ return false;
2591
+ }
2592
+ };
2593
+ const trackAdPixel = (pixelUrl, customBeacon) => {
2594
+ if (!isBrowser_default$1) {
2595
+ return;
2596
+ }
2597
+ const url = pixelUrl == null ? void 0 : pixelUrl.trim();
2598
+ if (!url) {
2599
+ return;
2600
+ }
2601
+ if (typeof customBeacon === "function") {
2602
+ try {
2603
+ const result = customBeacon(url);
2604
+ if (result === true) {
2605
+ return;
2606
+ }
2607
+ } catch {
2608
+ }
2609
+ }
2610
+ if (sendWithNavigatorBeacon(url)) {
2611
+ return;
2612
+ }
2613
+ if (sendWithFetch(url)) {
2614
+ return;
2615
+ }
2616
+ sendWithImage(url);
2617
+ };
2072
2618
  const types = createConstants$2(
2073
2619
  "INIT_SESSION",
2074
2620
  "RELEASE_SESSION",
2075
2621
  "REACH_PROJECT_GOAL"
2076
2622
  );
2077
2623
  const globalMetricsPlugin = (state) => {
2078
- var _a;
2079
- const history = /* @__PURE__ */ new Set([]);
2080
2624
  const sendMetric = async (type, value) => {
2081
- var _a2;
2082
- if ([types.INIT_SESSION, types.RELEASE_SESSION].some((v2) => history.has(v2))) {
2083
- return;
2084
- }
2085
- const query = (_a2 = state == null ? void 0 : state.$fetch) == null ? void 0 : _a2.query;
2625
+ var _a;
2626
+ const query = (_a = state == null ? void 0 : state.$fetch) == null ? void 0 : _a.query;
2086
2627
  await query(addClientMetric, { type, value });
2087
- history.add(type);
2088
2628
  };
2089
2629
  const reachGoal = (goal) => {
2090
2630
  sendMetric(types.REACH_PROJECT_GOAL, goal);
2091
2631
  };
2092
- if (isBrowser_default$1 && !((_a = state == null ? void 0 : state.env) == null ? void 0 : _a.isSelf)) {
2093
- sendMetric(types.INIT_SESSION);
2094
- window.addEventListener("beforeunload", () => {
2095
- sendMetric(types.RELEASE_SESSION);
2096
- });
2097
- }
2632
+ const sendAdPixel = (pixelUrl) => {
2633
+ var _a;
2634
+ trackAdPixel(pixelUrl, (_a = state == null ? void 0 : state.$fetch) == null ? void 0 : _a.sendBeacon);
2635
+ };
2098
2636
  state.$metrics = {
2099
- reachGoal
2637
+ reachGoal,
2638
+ trackAdPixel: sendAdPixel
2100
2639
  };
2101
2640
  };
2102
2641
  const loadPlugin = (state) => {
@@ -2160,6 +2699,7 @@ const loadPlugin = (state) => {
2160
2699
  const loader = async () => {
2161
2700
  var _a2;
2162
2701
  const areaEntity = await ((_a2 = state == null ? void 0 : state.$fetch) == null ? void 0 : _a2.queryArea(areaCode));
2702
+ console.log(areaEntity);
2163
2703
  await loadFragment(areaEntity == null ? void 0 : areaEntity.fragmentId, {
2164
2704
  suspense: false
2165
2705
  });
@@ -2187,7 +2727,7 @@ const PLUGIN_TYPES = createConstants$2(
2187
2727
  );
2188
2728
  const createFragmentsClient = (options) => {
2189
2729
  const BACKEND_TARGET = (options == null ? void 0 : options.isSelf) ? "/graphql" : "http://85.192.29.65/graphql";
2190
- return mt({
2730
+ return createState({
2191
2731
  _type: "GlobalManager",
2192
2732
  initialState: {},
2193
2733
  skip: [
@@ -2200,19 +2740,22 @@ const createFragmentsClient = (options) => {
2200
2740
  (state) => {
2201
2741
  state.env = {
2202
2742
  isSelf: (options == null ? void 0 : options.isSelf) ?? false,
2203
- backendEndpoint: BACKEND_TARGET,
2204
- apiToken: options == null ? void 0 : options.apiToken
2743
+ backendEndpoint: (options == null ? void 0 : options.backendEndpoint) ?? BACKEND_TARGET,
2744
+ apiToken: options == null ? void 0 : options.apiToken,
2745
+ referer: options == null ? void 0 : options.referer
2205
2746
  };
2206
2747
  },
2207
2748
  fetchPlugin,
2208
- fragmentsPlugin,
2749
+ fragmentsPlugin({
2750
+ plugins: options == null ? void 0 : options.fragmentPlugins
2751
+ }),
2209
2752
  loadPlugin,
2210
2753
  globalMetricsPlugin,
2211
2754
  globalStylesheetPlugin
2212
2755
  ]
2213
2756
  });
2214
2757
  };
2215
- var n, l$1, t$1, i$1, r$2, o$1, e$1, f$2, c$1, s$2, a$2, h$1, p$1 = {}, v$1 = [], y$3 = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, d$1 = Array.isArray;
2758
+ var n, l$1, t$1, i$1, r$2, o$1, e$1, f$2, c$1, s$1, a$2, h$1, p$1 = {}, v$1 = [], y$3 = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, d$1 = Array.isArray;
2216
2759
  function w$1(n2, l2) {
2217
2760
  for (var t2 in l2) n2[t2] = l2[t2];
2218
2761
  return n2;
@@ -2233,7 +2776,7 @@ function m$1(n2, u2, i2, r2, o2) {
2233
2776
  function k$1(n2) {
2234
2777
  return n2.children;
2235
2778
  }
2236
- function x$2(n2, l2) {
2779
+ function x$3(n2, l2) {
2237
2780
  this.props = n2, this.context = l2;
2238
2781
  }
2239
2782
  function S$1(n2, l2) {
@@ -2255,18 +2798,18 @@ function M(n2) {
2255
2798
  (!n2.__d && (n2.__d = true) && i$1.push(n2) && !$.__r++ || r$2 !== l$1.debounceRendering) && ((r$2 = l$1.debounceRendering) || o$1)($);
2256
2799
  }
2257
2800
  function $() {
2258
- for (var n2, t2, u2, r2, o2, f2, c2, s2 = 1; i$1.length; ) i$1.length > s2 && i$1.sort(e$1), n2 = i$1.shift(), s2 = i$1.length, n2.__d && (u2 = void 0, o2 = (r2 = (t2 = n2).__v).__e, f2 = [], c2 = [], t2.__P && ((u2 = w$1({}, r2)).__v = r2.__v + 1, l$1.vnode && l$1.vnode(u2), O$1(t2.__P, u2, r2, t2.__n, t2.__P.namespaceURI, 32 & r2.__u ? [o2] : null, f2, null == o2 ? S$1(r2) : o2, !!(32 & r2.__u), c2), u2.__v = r2.__v, u2.__.__k[u2.__i] = u2, z$1(f2, u2, c2), u2.__e != o2 && C$2(u2)));
2801
+ for (var n2, t2, u2, r2, o2, f2, c2, s2 = 1; i$1.length; ) i$1.length > s2 && i$1.sort(e$1), n2 = i$1.shift(), s2 = i$1.length, n2.__d && (u2 = void 0, o2 = (r2 = (t2 = n2).__v).__e, f2 = [], c2 = [], t2.__P && ((u2 = w$1({}, r2)).__v = r2.__v + 1, l$1.vnode && l$1.vnode(u2), O(t2.__P, u2, r2, t2.__n, t2.__P.namespaceURI, 32 & r2.__u ? [o2] : null, f2, null == o2 ? S$1(r2) : o2, !!(32 & r2.__u), c2), u2.__v = r2.__v, u2.__.__k[u2.__i] = u2, z$1(f2, u2, c2), u2.__e != o2 && C$2(u2)));
2259
2802
  $.__r = 0;
2260
2803
  }
2261
2804
  function I(n2, l2, t2, u2, i2, r2, o2, e2, f2, c2, s2) {
2262
- var a2, h3, y2, d2, w2, g2, _2 = u2 && u2.__k || v$1, m2 = l2.length;
2263
- for (f2 = P$2(t2, l2, _2, f2, m2), a2 = 0; a2 < m2; a2++) null != (y2 = t2.__k[a2]) && (h3 = -1 === y2.__i ? p$1 : _2[y2.__i] || p$1, y2.__i = a2, g2 = O$1(n2, y2, h3, i2, r2, o2, e2, f2, c2, s2), d2 = y2.__e, y2.ref && h3.ref != y2.ref && (h3.ref && q$3(h3.ref, null, y2), s2.push(y2.ref, y2.__c || d2, y2)), null == w2 && null != d2 && (w2 = d2), 4 & y2.__u || h3.__k === y2.__k ? f2 = A$1(y2, f2, n2) : "function" == typeof y2.type && void 0 !== g2 ? f2 = g2 : d2 && (f2 = d2.nextSibling), y2.__u &= -7);
2805
+ var a2, h2, y2, d2, w2, g2, _2 = u2 && u2.__k || v$1, m2 = l2.length;
2806
+ for (f2 = P$2(t2, l2, _2, f2, m2), a2 = 0; a2 < m2; a2++) null != (y2 = t2.__k[a2]) && (h2 = -1 === y2.__i ? p$1 : _2[y2.__i] || p$1, y2.__i = a2, g2 = O(n2, y2, h2, i2, r2, o2, e2, f2, c2, s2), d2 = y2.__e, y2.ref && h2.ref != y2.ref && (h2.ref && q$2(h2.ref, null, y2), s2.push(y2.ref, y2.__c || d2, y2)), null == w2 && null != d2 && (w2 = d2), 4 & y2.__u || h2.__k === y2.__k ? f2 = A$1(y2, f2, n2) : "function" == typeof y2.type && void 0 !== g2 ? f2 = g2 : d2 && (f2 = d2.nextSibling), y2.__u &= -7);
2264
2807
  return t2.__e = w2, f2;
2265
2808
  }
2266
2809
  function P$2(n2, l2, t2, u2, i2) {
2267
- var r2, o2, e2, f2, c2, s2 = t2.length, a2 = s2, h3 = 0;
2268
- for (n2.__k = new Array(i2), r2 = 0; r2 < i2; r2++) null != (o2 = l2[r2]) && "boolean" != typeof o2 && "function" != typeof o2 ? (f2 = r2 + h3, (o2 = n2.__k[r2] = "string" == typeof o2 || "number" == typeof o2 || "bigint" == typeof o2 || o2.constructor == String ? m$1(null, o2, null, null, null) : d$1(o2) ? m$1(k$1, { children: o2 }, null, null, null) : void 0 === o2.constructor && o2.__b > 0 ? m$1(o2.type, o2.props, o2.key, o2.ref ? o2.ref : null, o2.__v) : o2).__ = n2, o2.__b = n2.__b + 1, e2 = null, -1 !== (c2 = o2.__i = L(o2, t2, f2, a2)) && (a2--, (e2 = t2[c2]) && (e2.__u |= 2)), null == e2 || null === e2.__v ? (-1 == c2 && (i2 > s2 ? h3-- : i2 < s2 && h3++), "function" != typeof o2.type && (o2.__u |= 4)) : c2 != f2 && (c2 == f2 - 1 ? h3-- : c2 == f2 + 1 ? h3++ : (c2 > f2 ? h3-- : h3++, o2.__u |= 4))) : n2.__k[r2] = null;
2269
- if (a2) for (r2 = 0; r2 < s2; r2++) null != (e2 = t2[r2]) && 0 == (2 & e2.__u) && (e2.__e == u2 && (u2 = S$1(e2)), B$3(e2, e2));
2810
+ var r2, o2, e2, f2, c2, s2 = t2.length, a2 = s2, h2 = 0;
2811
+ for (n2.__k = new Array(i2), r2 = 0; r2 < i2; r2++) null != (o2 = l2[r2]) && "boolean" != typeof o2 && "function" != typeof o2 ? (f2 = r2 + h2, (o2 = n2.__k[r2] = "string" == typeof o2 || "number" == typeof o2 || "bigint" == typeof o2 || o2.constructor == String ? m$1(null, o2, null, null, null) : d$1(o2) ? m$1(k$1, { children: o2 }, null, null, null) : void 0 === o2.constructor && o2.__b > 0 ? m$1(o2.type, o2.props, o2.key, o2.ref ? o2.ref : null, o2.__v) : o2).__ = n2, o2.__b = n2.__b + 1, e2 = null, -1 !== (c2 = o2.__i = L(o2, t2, f2, a2)) && (a2--, (e2 = t2[c2]) && (e2.__u |= 2)), null == e2 || null === e2.__v ? (-1 == c2 && (i2 > s2 ? h2-- : i2 < s2 && h2++), "function" != typeof o2.type && (o2.__u |= 4)) : c2 != f2 && (c2 == f2 - 1 ? h2-- : c2 == f2 + 1 ? h2++ : (c2 > f2 ? h2-- : h2++, o2.__u |= 4))) : n2.__k[r2] = null;
2812
+ if (a2) for (r2 = 0; r2 < s2; r2++) null != (e2 = t2[r2]) && 0 == (2 & e2.__u) && (e2.__e == u2 && (u2 = S$1(e2)), B$2(e2, e2));
2270
2813
  return u2;
2271
2814
  }
2272
2815
  function A$1(n2, l2, t2) {
@@ -2311,7 +2854,7 @@ function j$2(n2, l2, t2, u2, i2) {
2311
2854
  if ("string" == typeof u2 && (n2.style.cssText = u2 = ""), u2) for (l2 in u2) t2 && l2 in t2 || T$2(n2.style, l2, "");
2312
2855
  if (t2) for (l2 in t2) u2 && t2[l2] === u2[l2] || T$2(n2.style, l2, t2[l2]);
2313
2856
  }
2314
- else if ("o" == l2[0] && "n" == l2[1]) r2 = l2 != (l2 = l2.replace(f$2, "$1")), l2 = l2.toLowerCase() in n2 || "onFocusOut" == l2 || "onFocusIn" == l2 ? l2.toLowerCase().slice(2) : l2.slice(2), n2.l || (n2.l = {}), n2.l[l2 + r2] = t2, t2 ? u2 ? t2.t = u2.t : (t2.t = c$1, n2.addEventListener(l2, r2 ? a$2 : s$2, r2)) : n2.removeEventListener(l2, r2 ? a$2 : s$2, r2);
2857
+ else if ("o" == l2[0] && "n" == l2[1]) r2 = l2 != (l2 = l2.replace(f$2, "$1")), l2 = l2.toLowerCase() in n2 || "onFocusOut" == l2 || "onFocusIn" == l2 ? l2.toLowerCase().slice(2) : l2.slice(2), n2.l || (n2.l = {}), n2.l[l2 + r2] = t2, t2 ? u2 ? t2.t = u2.t : (t2.t = c$1, n2.addEventListener(l2, r2 ? a$2 : s$1, r2)) : n2.removeEventListener(l2, r2 ? a$2 : s$1, r2);
2315
2858
  else {
2316
2859
  if ("http://www.w3.org/2000/svg" == i2) l2 = l2.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
2317
2860
  else if ("width" != l2 && "height" != l2 && "href" != l2 && "list" != l2 && "form" != l2 && "tabIndex" != l2 && "download" != l2 && "rowSpan" != l2 && "colSpan" != l2 && "role" != l2 && "popover" != l2 && l2 in n2) try {
@@ -2332,31 +2875,31 @@ function F$1(n2) {
2332
2875
  }
2333
2876
  };
2334
2877
  }
2335
- function O$1(n2, t2, u2, i2, r2, o2, e2, f2, c2, s2) {
2336
- var a2, h3, p2, v2, y2, _2, m2, b2, S2, C2, M2, $2, P2, A2, H2, L2, T2, j2 = t2.type;
2878
+ function O(n2, t2, u2, i2, r2, o2, e2, f2, c2, s2) {
2879
+ var a2, h2, p2, v2, y2, _2, m2, b, S2, C2, M2, $2, P2, A2, H2, L2, T2, j2 = t2.type;
2337
2880
  if (void 0 !== t2.constructor) return null;
2338
2881
  128 & u2.__u && (c2 = !!(32 & u2.__u), o2 = [f2 = t2.__e = u2.__e]), (a2 = l$1.__b) && a2(t2);
2339
2882
  n: if ("function" == typeof j2) try {
2340
- if (b2 = t2.props, S2 = "prototype" in j2 && j2.prototype.render, C2 = (a2 = j2.contextType) && i2[a2.__c], M2 = a2 ? C2 ? C2.props.value : a2.__ : i2, u2.__c ? m2 = (h3 = t2.__c = u2.__c).__ = h3.__E : (S2 ? t2.__c = h3 = new j2(b2, M2) : (t2.__c = h3 = new x$2(b2, M2), h3.constructor = j2, h3.render = D$1), C2 && C2.sub(h3), h3.props = b2, h3.state || (h3.state = {}), h3.context = M2, h3.__n = i2, p2 = h3.__d = true, h3.__h = [], h3._sb = []), S2 && null == h3.__s && (h3.__s = h3.state), S2 && null != j2.getDerivedStateFromProps && (h3.__s == h3.state && (h3.__s = w$1({}, h3.__s)), w$1(h3.__s, j2.getDerivedStateFromProps(b2, h3.__s))), v2 = h3.props, y2 = h3.state, h3.__v = t2, p2) S2 && null == j2.getDerivedStateFromProps && null != h3.componentWillMount && h3.componentWillMount(), S2 && null != h3.componentDidMount && h3.__h.push(h3.componentDidMount);
2883
+ if (b = t2.props, S2 = "prototype" in j2 && j2.prototype.render, C2 = (a2 = j2.contextType) && i2[a2.__c], M2 = a2 ? C2 ? C2.props.value : a2.__ : i2, u2.__c ? m2 = (h2 = t2.__c = u2.__c).__ = h2.__E : (S2 ? t2.__c = h2 = new j2(b, M2) : (t2.__c = h2 = new x$3(b, M2), h2.constructor = j2, h2.render = D$1), C2 && C2.sub(h2), h2.props = b, h2.state || (h2.state = {}), h2.context = M2, h2.__n = i2, p2 = h2.__d = true, h2.__h = [], h2._sb = []), S2 && null == h2.__s && (h2.__s = h2.state), S2 && null != j2.getDerivedStateFromProps && (h2.__s == h2.state && (h2.__s = w$1({}, h2.__s)), w$1(h2.__s, j2.getDerivedStateFromProps(b, h2.__s))), v2 = h2.props, y2 = h2.state, h2.__v = t2, p2) S2 && null == j2.getDerivedStateFromProps && null != h2.componentWillMount && h2.componentWillMount(), S2 && null != h2.componentDidMount && h2.__h.push(h2.componentDidMount);
2341
2884
  else {
2342
- if (S2 && null == j2.getDerivedStateFromProps && b2 !== v2 && null != h3.componentWillReceiveProps && h3.componentWillReceiveProps(b2, M2), !h3.__e && (null != h3.shouldComponentUpdate && false === h3.shouldComponentUpdate(b2, h3.__s, M2) || t2.__v == u2.__v)) {
2343
- for (t2.__v != u2.__v && (h3.props = b2, h3.state = h3.__s, h3.__d = false), t2.__e = u2.__e, t2.__k = u2.__k, t2.__k.some(function(n3) {
2885
+ if (S2 && null == j2.getDerivedStateFromProps && b !== v2 && null != h2.componentWillReceiveProps && h2.componentWillReceiveProps(b, M2), !h2.__e && (null != h2.shouldComponentUpdate && false === h2.shouldComponentUpdate(b, h2.__s, M2) || t2.__v == u2.__v)) {
2886
+ for (t2.__v != u2.__v && (h2.props = b, h2.state = h2.__s, h2.__d = false), t2.__e = u2.__e, t2.__k = u2.__k, t2.__k.some(function(n3) {
2344
2887
  n3 && (n3.__ = t2);
2345
- }), $2 = 0; $2 < h3._sb.length; $2++) h3.__h.push(h3._sb[$2]);
2346
- h3._sb = [], h3.__h.length && e2.push(h3);
2888
+ }), $2 = 0; $2 < h2._sb.length; $2++) h2.__h.push(h2._sb[$2]);
2889
+ h2._sb = [], h2.__h.length && e2.push(h2);
2347
2890
  break n;
2348
2891
  }
2349
- null != h3.componentWillUpdate && h3.componentWillUpdate(b2, h3.__s, M2), S2 && null != h3.componentDidUpdate && h3.__h.push(function() {
2350
- h3.componentDidUpdate(v2, y2, _2);
2892
+ null != h2.componentWillUpdate && h2.componentWillUpdate(b, h2.__s, M2), S2 && null != h2.componentDidUpdate && h2.__h.push(function() {
2893
+ h2.componentDidUpdate(v2, y2, _2);
2351
2894
  });
2352
2895
  }
2353
- if (h3.context = M2, h3.props = b2, h3.__P = n2, h3.__e = false, P2 = l$1.__r, A2 = 0, S2) {
2354
- for (h3.state = h3.__s, h3.__d = false, P2 && P2(t2), a2 = h3.render(h3.props, h3.state, h3.context), H2 = 0; H2 < h3._sb.length; H2++) h3.__h.push(h3._sb[H2]);
2355
- h3._sb = [];
2896
+ if (h2.context = M2, h2.props = b, h2.__P = n2, h2.__e = false, P2 = l$1.__r, A2 = 0, S2) {
2897
+ for (h2.state = h2.__s, h2.__d = false, P2 && P2(t2), a2 = h2.render(h2.props, h2.state, h2.context), H2 = 0; H2 < h2._sb.length; H2++) h2.__h.push(h2._sb[H2]);
2898
+ h2._sb = [];
2356
2899
  } else do {
2357
- h3.__d = false, P2 && P2(t2), a2 = h3.render(h3.props, h3.state, h3.context), h3.state = h3.__s;
2358
- } while (h3.__d && ++A2 < 25);
2359
- h3.state = h3.__s, null != h3.getChildContext && (i2 = w$1(w$1({}, i2), h3.getChildContext())), S2 && !p2 && null != h3.getSnapshotBeforeUpdate && (_2 = h3.getSnapshotBeforeUpdate(v2, y2)), L2 = a2, null != a2 && a2.type === k$1 && null == a2.key && (L2 = N$1(a2.props.children)), f2 = I(n2, d$1(L2) ? L2 : [L2], t2, u2, i2, r2, o2, e2, f2, c2, s2), h3.base = t2.__e, t2.__u &= -161, h3.__h.length && e2.push(h3), m2 && (h3.__E = h3.__ = null);
2900
+ h2.__d = false, P2 && P2(t2), a2 = h2.render(h2.props, h2.state, h2.context), h2.state = h2.__s;
2901
+ } while (h2.__d && ++A2 < 25);
2902
+ h2.state = h2.__s, null != h2.getChildContext && (i2 = w$1(w$1({}, i2), h2.getChildContext())), S2 && !p2 && null != h2.getSnapshotBeforeUpdate && (_2 = h2.getSnapshotBeforeUpdate(v2, y2)), L2 = a2, null != a2 && a2.type === k$1 && null == a2.key && (L2 = N$1(a2.props.children)), f2 = I(n2, d$1(L2) ? L2 : [L2], t2, u2, i2, r2, o2, e2, f2, c2, s2), h2.base = t2.__e, t2.__u &= -161, h2.__h.length && e2.push(h2), m2 && (h2.__E = h2.__ = null);
2360
2903
  } catch (n3) {
2361
2904
  if (t2.__v = null, c2 || null != o2) if (n3.then) {
2362
2905
  for (t2.__u |= c2 ? 160 : 128; f2 && 8 == f2.nodeType && f2.nextSibling; ) f2 = f2.nextSibling;
@@ -2369,7 +2912,7 @@ function O$1(n2, t2, u2, i2, r2, o2, e2, f2, c2, s2) {
2369
2912
  return (a2 = l$1.diffed) && a2(t2), 128 & t2.__u ? void 0 : f2;
2370
2913
  }
2371
2914
  function z$1(n2, t2, u2) {
2372
- for (var i2 = 0; i2 < u2.length; i2++) q$3(u2[i2], u2[++i2], u2[++i2]);
2915
+ for (var i2 = 0; i2 < u2.length; i2++) q$2(u2[i2], u2[++i2], u2[++i2]);
2373
2916
  l$1.__c && l$1.__c(t2, n2), n2.some(function(t3) {
2374
2917
  try {
2375
2918
  n2 = t3.__h, t3.__h = [], n2.some(function(n3) {
@@ -2384,7 +2927,7 @@ function N$1(n2) {
2384
2927
  return "object" != typeof n2 || null == n2 ? n2 : d$1(n2) ? n2.map(N$1) : w$1({}, n2);
2385
2928
  }
2386
2929
  function V$1(t2, u2, i2, r2, o2, e2, f2, c2, s2) {
2387
- var a2, h3, v2, y2, w2, _2, m2, b2 = i2.props, k2 = u2.props, x2 = u2.type;
2930
+ var a2, h2, v2, y2, w2, _2, m2, b = i2.props, k2 = u2.props, x2 = u2.type;
2388
2931
  if ("svg" == x2 ? o2 = "http://www.w3.org/2000/svg" : "math" == x2 ? o2 = "http://www.w3.org/1998/Math/MathML" : o2 || (o2 = "http://www.w3.org/1999/xhtml"), null != e2) {
2389
2932
  for (a2 = 0; a2 < e2.length; a2++) if ((w2 = e2[a2]) && "setAttribute" in w2 == !!x2 && (x2 ? w2.localName == x2 : 3 == w2.nodeType)) {
2390
2933
  t2 = w2, e2[a2] = null;
@@ -2395,23 +2938,23 @@ function V$1(t2, u2, i2, r2, o2, e2, f2, c2, s2) {
2395
2938
  if (null == x2) return document.createTextNode(k2);
2396
2939
  t2 = document.createElementNS(o2, x2, k2.is && k2), c2 && (l$1.__m && l$1.__m(u2, e2), c2 = false), e2 = null;
2397
2940
  }
2398
- if (null === x2) b2 === k2 || c2 && t2.data === k2 || (t2.data = k2);
2941
+ if (null === x2) b === k2 || c2 && t2.data === k2 || (t2.data = k2);
2399
2942
  else {
2400
- if (e2 = e2 && n.call(t2.childNodes), b2 = i2.props || p$1, !c2 && null != e2) for (b2 = {}, a2 = 0; a2 < t2.attributes.length; a2++) b2[(w2 = t2.attributes[a2]).name] = w2.value;
2401
- for (a2 in b2) if (w2 = b2[a2], "children" == a2) ;
2943
+ if (e2 = e2 && n.call(t2.childNodes), b = i2.props || p$1, !c2 && null != e2) for (b = {}, a2 = 0; a2 < t2.attributes.length; a2++) b[(w2 = t2.attributes[a2]).name] = w2.value;
2944
+ for (a2 in b) if (w2 = b[a2], "children" == a2) ;
2402
2945
  else if ("dangerouslySetInnerHTML" == a2) v2 = w2;
2403
2946
  else if (!(a2 in k2)) {
2404
2947
  if ("value" == a2 && "defaultValue" in k2 || "checked" == a2 && "defaultChecked" in k2) continue;
2405
2948
  j$2(t2, a2, null, w2, o2);
2406
2949
  }
2407
- for (a2 in k2) w2 = k2[a2], "children" == a2 ? y2 = w2 : "dangerouslySetInnerHTML" == a2 ? h3 = w2 : "value" == a2 ? _2 = w2 : "checked" == a2 ? m2 = w2 : c2 && "function" != typeof w2 || b2[a2] === w2 || j$2(t2, a2, w2, b2[a2], o2);
2408
- if (h3) c2 || v2 && (h3.__html === v2.__html || h3.__html === t2.innerHTML) || (t2.innerHTML = h3.__html), u2.__k = [];
2950
+ for (a2 in k2) w2 = k2[a2], "children" == a2 ? y2 = w2 : "dangerouslySetInnerHTML" == a2 ? h2 = w2 : "value" == a2 ? _2 = w2 : "checked" == a2 ? m2 = w2 : c2 && "function" != typeof w2 || b[a2] === w2 || j$2(t2, a2, w2, b[a2], o2);
2951
+ if (h2) c2 || v2 && (h2.__html === v2.__html || h2.__html === t2.innerHTML) || (t2.innerHTML = h2.__html), u2.__k = [];
2409
2952
  else if (v2 && (t2.innerHTML = ""), I("template" === u2.type ? t2.content : t2, d$1(y2) ? y2 : [y2], u2, i2, r2, "foreignObject" == x2 ? "http://www.w3.org/1999/xhtml" : o2, e2, f2, e2 ? e2[0] : i2.__k && S$1(i2, 0), c2, s2), null != e2) for (a2 = e2.length; a2--; ) g$1(e2[a2]);
2410
- c2 || (a2 = "value", "progress" == x2 && null == _2 ? t2.removeAttribute("value") : void 0 !== _2 && (_2 !== t2[a2] || "progress" == x2 && !_2 || "option" == x2 && _2 !== b2[a2]) && j$2(t2, a2, _2, b2[a2], o2), a2 = "checked", void 0 !== m2 && m2 !== t2[a2] && j$2(t2, a2, m2, b2[a2], o2));
2953
+ c2 || (a2 = "value", "progress" == x2 && null == _2 ? t2.removeAttribute("value") : void 0 !== _2 && (_2 !== t2[a2] || "progress" == x2 && !_2 || "option" == x2 && _2 !== b[a2]) && j$2(t2, a2, _2, b[a2], o2), a2 = "checked", void 0 !== m2 && m2 !== t2[a2] && j$2(t2, a2, m2, b[a2], o2));
2411
2954
  }
2412
2955
  return t2;
2413
2956
  }
2414
- function q$3(n2, t2, u2) {
2957
+ function q$2(n2, t2, u2) {
2415
2958
  try {
2416
2959
  if ("function" == typeof n2) {
2417
2960
  var i2 = "function" == typeof n2.__u;
@@ -2421,9 +2964,9 @@ function q$3(n2, t2, u2) {
2421
2964
  l$1.__e(n3, u2);
2422
2965
  }
2423
2966
  }
2424
- function B$3(n2, t2, u2) {
2967
+ function B$2(n2, t2, u2) {
2425
2968
  var i2, r2;
2426
- if (l$1.unmount && l$1.unmount(n2), (i2 = n2.ref) && (i2.current && i2.current !== n2.__e || q$3(i2, null, t2)), null != (i2 = n2.__c)) {
2969
+ if (l$1.unmount && l$1.unmount(n2), (i2 = n2.ref) && (i2.current && i2.current !== n2.__e || q$2(i2, null, t2)), null != (i2 = n2.__c)) {
2427
2970
  if (i2.componentWillUnmount) try {
2428
2971
  i2.componentWillUnmount();
2429
2972
  } catch (n3) {
@@ -2431,7 +2974,7 @@ function B$3(n2, t2, u2) {
2431
2974
  }
2432
2975
  i2.base = i2.__P = null;
2433
2976
  }
2434
- if (i2 = n2.__k) for (r2 = 0; r2 < i2.length; r2++) i2[r2] && B$3(i2[r2], t2, u2 || "function" != typeof n2.type);
2977
+ if (i2 = n2.__k) for (r2 = 0; r2 < i2.length; r2++) i2[r2] && B$2(i2[r2], t2, u2 || "function" != typeof n2.type);
2435
2978
  u2 || g$1(n2.__e), n2.__c = n2.__ = n2.__e = void 0;
2436
2979
  }
2437
2980
  function D$1(n2, l2, t2) {
@@ -2439,7 +2982,7 @@ function D$1(n2, l2, t2) {
2439
2982
  }
2440
2983
  function E$1(t2, u2, i2) {
2441
2984
  var r2, o2, e2, f2;
2442
- u2 == document && (u2 = document.documentElement), l$1.__ && l$1.__(t2, u2), o2 = (r2 = false) ? null : u2.__k, e2 = [], f2 = [], O$1(u2, t2 = u2.__k = _$1(k$1, null, [t2]), o2 || p$1, p$1, u2.namespaceURI, o2 ? null : u2.firstChild ? n.call(u2.childNodes) : null, e2, o2 ? o2.__e : u2.firstChild, r2, f2), z$1(e2, t2, f2);
2985
+ u2 == document && (u2 = document.documentElement), l$1.__ && l$1.__(t2, u2), o2 = (r2 = false) ? null : u2.__k, e2 = [], f2 = [], O(u2, t2 = u2.__k = _$1(k$1, null, [t2]), o2 || p$1, p$1, u2.namespaceURI, o2 ? null : u2.firstChild ? n.call(u2.childNodes) : null, e2, o2 ? o2.__e : u2.firstChild, r2, f2), z$1(e2, t2, f2);
2443
2986
  }
2444
2987
  function K$1(n2) {
2445
2988
  function l2(n3) {
@@ -2471,15 +3014,15 @@ n = v$1.slice, l$1 = { __e: function(n2, l2, t2, u2) {
2471
3014
  n2 = l3;
2472
3015
  }
2473
3016
  throw n2;
2474
- } }, t$1 = 0, x$2.prototype.setState = function(n2, l2) {
3017
+ } }, t$1 = 0, x$3.prototype.setState = function(n2, l2) {
2475
3018
  var t2;
2476
3019
  t2 = null != this.__s && this.__s !== this.state ? this.__s : this.__s = w$1({}, this.state), "function" == typeof n2 && (n2 = n2(w$1({}, t2), this.props)), n2 && w$1(t2, n2), null != n2 && this.__v && (l2 && this._sb.push(l2), M(this));
2477
- }, x$2.prototype.forceUpdate = function(n2) {
3020
+ }, x$3.prototype.forceUpdate = function(n2) {
2478
3021
  this.__v && (this.__e = true, n2 && this.__h.push(n2), M(this));
2479
- }, x$2.prototype.render = k$1, i$1 = [], o$1 = "function" == typeof Promise ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, e$1 = function(n2, l2) {
3022
+ }, x$3.prototype.render = k$1, i$1 = [], o$1 = "function" == typeof Promise ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, e$1 = function(n2, l2) {
2480
3023
  return n2.__v.__b - l2.__v.__b;
2481
- }, $.__r = 0, f$2 = /(PointerCapture)$|Capture$/i, c$1 = 0, s$2 = F$1(false), a$2 = F$1(true), h$1 = 0;
2482
- var t, r$1, u$1, i, o = 0, f$1 = [], c = l$1, e = c.__b, a$1 = c.__r, v = c.diffed, l = c.__c, m = c.unmount, s$1 = c.__;
3024
+ }, $.__r = 0, f$2 = /(PointerCapture)$|Capture$/i, c$1 = 0, s$1 = F$1(false), a$2 = F$1(true), h$1 = 0;
3025
+ var t, r$1, u$1, i, o = 0, f$1 = [], c = l$1, e = c.__b, a$1 = c.__r, v = c.diffed, l = c.__c, m = c.unmount, s = c.__;
2483
3026
  function p(n2, t2) {
2484
3027
  c.__h && c.__h(r$1, n2, o || t2), o = 0;
2485
3028
  var u2 = r$1.__H || (r$1.__H = { __: [], __h: [] });
@@ -2539,12 +3082,12 @@ function T$1(n2, r2) {
2539
3082
  var u2 = p(t++, 7);
2540
3083
  return C$1(u2.__H, r2) && (u2.__ = n2(), u2.__H = r2, u2.__h = n2), u2.__;
2541
3084
  }
2542
- function q$2(n2, t2) {
3085
+ function q$1(n2, t2) {
2543
3086
  return o = 8, T$1(function() {
2544
3087
  return n2;
2545
3088
  }, t2);
2546
3089
  }
2547
- function x$1(n2) {
3090
+ function x$2(n2) {
2548
3091
  var u2 = r$1.context[n2.__c], i2 = p(t++, 9);
2549
3092
  return i2.c = n2, u2 ? (null == i2.__ && (i2.__ = true, u2.sub(r$1)), u2.props.value) : n2.__;
2550
3093
  }
@@ -2553,7 +3096,7 @@ function P$1(n2, t2) {
2553
3096
  }
2554
3097
  function j$1() {
2555
3098
  for (var n2; n2 = f$1.shift(); ) if (n2.__P && n2.__H) try {
2556
- n2.__H.__h.forEach(z), n2.__H.__h.forEach(B$2), n2.__H.__h = [];
3099
+ n2.__H.__h.forEach(z), n2.__H.__h.forEach(B$1), n2.__H.__h = [];
2557
3100
  } catch (t2) {
2558
3101
  n2.__H.__h = [], c.__e(t2, n2.__v);
2559
3102
  }
@@ -2561,13 +3104,13 @@ function j$1() {
2561
3104
  c.__b = function(n2) {
2562
3105
  r$1 = null, e && e(n2);
2563
3106
  }, c.__ = function(n2, t2) {
2564
- n2 && t2.__k && t2.__k.__m && (n2.__m = t2.__k.__m), s$1 && s$1(n2, t2);
3107
+ n2 && t2.__k && t2.__k.__m && (n2.__m = t2.__k.__m), s && s(n2, t2);
2565
3108
  }, c.__r = function(n2) {
2566
3109
  a$1 && a$1(n2), t = 0;
2567
3110
  var i2 = (r$1 = n2.__c).__H;
2568
3111
  i2 && (u$1 === r$1 ? (i2.__h = [], r$1.__h = [], i2.__.forEach(function(n3) {
2569
3112
  n3.__N && (n3.__ = n3.__N), n3.u = n3.__N = void 0;
2570
- })) : (i2.__h.forEach(z), i2.__h.forEach(B$2), i2.__h = [], t = 0)), u$1 = r$1;
3113
+ })) : (i2.__h.forEach(z), i2.__h.forEach(B$1), i2.__h = [], t = 0)), u$1 = r$1;
2571
3114
  }, c.diffed = function(n2) {
2572
3115
  v && v(n2);
2573
3116
  var t2 = n2.__c;
@@ -2578,7 +3121,7 @@ c.__b = function(n2) {
2578
3121
  t2.some(function(n3) {
2579
3122
  try {
2580
3123
  n3.__h.forEach(z), n3.__h = n3.__h.filter(function(n4) {
2581
- return !n4.__ || B$2(n4);
3124
+ return !n4.__ || B$1(n4);
2582
3125
  });
2583
3126
  } catch (r2) {
2584
3127
  t2.some(function(n4) {
@@ -2608,7 +3151,7 @@ function z(n2) {
2608
3151
  var t2 = r$1, u2 = n2.__c;
2609
3152
  "function" == typeof u2 && (n2.__c = void 0, u2()), r$1 = t2;
2610
3153
  }
2611
- function B$2(n2) {
3154
+ function B$1(n2) {
2612
3155
  var t2 = r$1;
2613
3156
  n2.__c = n2.__(), r$1 = t2;
2614
3157
  }
@@ -2632,14 +3175,14 @@ function E(n2, t2) {
2632
3175
  function C(n2, t2) {
2633
3176
  var e2 = t2(), r2 = d({ t: { __: e2, u: t2 } }), u2 = r2[0].t, o2 = r2[1];
2634
3177
  return _(function() {
2635
- u2.__ = e2, u2.u = t2, x(u2) && o2({ t: u2 });
3178
+ u2.__ = e2, u2.u = t2, x$1(u2) && o2({ t: u2 });
2636
3179
  }, [n2, e2, t2]), y$2(function() {
2637
- return x(u2) && o2({ t: u2 }), n2(function() {
2638
- x(u2) && o2({ t: u2 });
3180
+ return x$1(u2) && o2({ t: u2 }), n2(function() {
3181
+ x$1(u2) && o2({ t: u2 });
2639
3182
  });
2640
3183
  }, [n2]), e2;
2641
3184
  }
2642
- function x(n2) {
3185
+ function x$1(n2) {
2643
3186
  var t2, e2, r2 = n2.u, u2 = n2.__;
2644
3187
  try {
2645
3188
  var o2 = r2();
@@ -2651,7 +3194,7 @@ function x(n2) {
2651
3194
  function N(n2, t2) {
2652
3195
  this.props = n2, this.context = t2;
2653
3196
  }
2654
- (N.prototype = new x$2()).isPureReactComponent = true, N.prototype.shouldComponentUpdate = function(n2, t2) {
3197
+ (N.prototype = new x$3()).isPureReactComponent = true, N.prototype.shouldComponentUpdate = function(n2, t2) {
2655
3198
  return E(this.props, n2) || E(this.state, t2);
2656
3199
  };
2657
3200
  var T = l$1.__b;
@@ -2685,13 +3228,13 @@ function j(n2) {
2685
3228
  var t2 = n2.__.__c;
2686
3229
  return t2 && t2.__a && t2.__a(n2);
2687
3230
  }
2688
- function B$1() {
3231
+ function B() {
2689
3232
  this.i = null, this.l = null;
2690
3233
  }
2691
3234
  l$1.unmount = function(n2) {
2692
3235
  var t2 = n2.__c;
2693
3236
  t2 && t2.__R && t2.__R(), t2 && 32 & n2.__u && (n2.type = null), U && U(n2);
2694
- }, (P.prototype = new x$2()).__c = function(n2, t2) {
3237
+ }, (P.prototype = new x$3()).__c = function(n2, t2) {
2695
3238
  var e2 = t2.__c, r2 = this;
2696
3239
  null == r2.o && (r2.o = []), r2.o.push(e2);
2697
3240
  var u2 = j(r2.__v), o2 = false, i2 = function() {
@@ -2729,7 +3272,7 @@ var H = function(n2, t2, e2) {
2729
3272
  n2.i = e2 = e2[2];
2730
3273
  }
2731
3274
  };
2732
- (B$1.prototype = new x$2()).__a = function(n2) {
3275
+ (B.prototype = new x$3()).__a = function(n2) {
2733
3276
  var t2 = this, e2 = j(t2.__v), r2 = t2.l.get(n2);
2734
3277
  return r2[0]++, function(u2) {
2735
3278
  var o2 = function() {
@@ -2737,23 +3280,23 @@ var H = function(n2, t2, e2) {
2737
3280
  };
2738
3281
  e2 ? e2(o2) : o2();
2739
3282
  };
2740
- }, B$1.prototype.render = function(n2) {
3283
+ }, B.prototype.render = function(n2) {
2741
3284
  this.i = null, this.l = /* @__PURE__ */ new Map();
2742
3285
  var t2 = H$1(n2.children);
2743
3286
  n2.revealOrder && "b" === n2.revealOrder[0] && t2.reverse();
2744
3287
  for (var e2 = t2.length; e2--; ) this.l.set(t2[e2], this.i = [1, 0, this.i]);
2745
3288
  return n2.children;
2746
- }, B$1.prototype.componentDidUpdate = B$1.prototype.componentDidMount = function() {
3289
+ }, B.prototype.componentDidUpdate = B.prototype.componentDidMount = function() {
2747
3290
  var n2 = this;
2748
3291
  this.l.forEach(function(t2, e2) {
2749
3292
  H(n2, e2, t2);
2750
3293
  });
2751
3294
  };
2752
- var q$1 = "undefined" != typeof Symbol && Symbol.for && Symbol.for("react.element") || 60103, G$1 = /^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/, J = /^on(Ani|Tra|Tou|BeforeInp|Compo)/, K = /[A-Z0-9]/g, Q = "undefined" != typeof document, X = function(n2) {
3295
+ var q = "undefined" != typeof Symbol && Symbol.for && Symbol.for("react.element") || 60103, G = /^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/, J = /^on(Ani|Tra|Tou|BeforeInp|Compo)/, K = /[A-Z0-9]/g, Q = "undefined" != typeof document, X = function(n2) {
2753
3296
  return ("undefined" != typeof Symbol && "symbol" == typeof Symbol() ? /fil|che|rad/ : /fil|che|ra/).test(n2);
2754
3297
  };
2755
- x$2.prototype.isReactComponent = {}, ["componentWillMount", "componentWillReceiveProps", "componentWillUpdate"].forEach(function(t2) {
2756
- Object.defineProperty(x$2.prototype, t2, { configurable: true, get: function() {
3298
+ x$3.prototype.isReactComponent = {}, ["componentWillMount", "componentWillReceiveProps", "componentWillUpdate"].forEach(function(t2) {
3299
+ Object.defineProperty(x$3.prototype, t2, { configurable: true, get: function() {
2757
3300
  return this["UNSAFE_" + t2];
2758
3301
  }, set: function(n2) {
2759
3302
  Object.defineProperty(this, t2, { configurable: true, writable: true, value: n2 });
@@ -2781,7 +3324,7 @@ l$1.vnode = function(n2) {
2781
3324
  var c2 = t2[i2];
2782
3325
  if (!("value" === i2 && "defaultValue" in t2 && null == c2 || Q && "children" === i2 && "noscript" === e2 || "class" === i2 || "className" === i2)) {
2783
3326
  var l2 = i2.toLowerCase();
2784
- "defaultValue" === i2 && "value" in t2 && null == t2.value ? i2 = "value" : "download" === i2 && true === c2 ? c2 = "" : "translate" === l2 && "no" === c2 ? c2 = false : "o" === l2[0] && "n" === l2[1] ? "ondoubleclick" === l2 ? i2 = "ondblclick" : "onchange" !== l2 || "input" !== e2 && "textarea" !== e2 || X(t2.type) ? "onfocus" === l2 ? i2 = "onfocusin" : "onblur" === l2 ? i2 = "onfocusout" : J.test(i2) && (i2 = l2) : l2 = i2 = "oninput" : o2 && G$1.test(i2) ? i2 = i2.replace(K, "-$&").toLowerCase() : null === c2 && (c2 = void 0), "oninput" === l2 && u2[i2 = l2] && (i2 = "oninputCapture"), u2[i2] = c2;
3327
+ "defaultValue" === i2 && "value" in t2 && null == t2.value ? i2 = "value" : "download" === i2 && true === c2 ? c2 = "" : "translate" === l2 && "no" === c2 ? c2 = false : "o" === l2[0] && "n" === l2[1] ? "ondoubleclick" === l2 ? i2 = "ondblclick" : "onchange" !== l2 || "input" !== e2 && "textarea" !== e2 || X(t2.type) ? "onfocus" === l2 ? i2 = "onfocusin" : "onblur" === l2 ? i2 = "onfocusout" : J.test(i2) && (i2 = l2) : l2 = i2 = "oninput" : o2 && G.test(i2) ? i2 = i2.replace(K, "-$&").toLowerCase() : null === c2 && (c2 = void 0), "oninput" === l2 && u2[i2 = l2] && (i2 = "oninputCapture"), u2[i2] = c2;
2785
3328
  }
2786
3329
  }
2787
3330
  "select" == e2 && u2.multiple && Array.isArray(u2.value) && (u2.value = H$1(t2.children).forEach(function(n4) {
@@ -2789,7 +3332,7 @@ l$1.vnode = function(n2) {
2789
3332
  })), "select" == e2 && null != u2.defaultValue && (u2.value = H$1(t2.children).forEach(function(n4) {
2790
3333
  n4.props.selected = u2.multiple ? -1 != u2.defaultValue.indexOf(n4.props.value) : u2.defaultValue == n4.props.value;
2791
3334
  })), t2.class && !t2.className ? (u2.class = t2.class, Object.defineProperty(u2, "className", ln)) : (t2.className && !t2.class || t2.class && t2.className) && (u2.class = u2.className = t2.className), n3.props = u2;
2792
- }(n2), n2.$$typeof = q$1, fn && fn(n2);
3335
+ }(n2), n2.$$typeof = q, fn && fn(n2);
2793
3336
  };
2794
3337
  var an = l$1.__r;
2795
3338
  l$1.__r = function(n2) {
@@ -2802,19 +3345,34 @@ l$1.diffed = function(n2) {
2802
3345
  null != e2 && "textarea" === n2.type && "value" in t2 && t2.value !== e2.value && (e2.value = null == t2.value ? "" : t2.value);
2803
3346
  };
2804
3347
  var Rn = { useState: d, useEffect: y$2, useLayoutEffect: _, useSyncExternalStore: C, useRef: A, useMemo: T$1, useDebugValue: P$1 };
2805
- var r = (e2) => !e2 && e2 == null, y$1 = (e2) => !r(e2), a = (e2) => typeof e2 == "object" && !Array.isArray(e2) && y$1(e2), s = (e2) => typeof e2 == "string" && e2.split(":").length >= 2;
2806
- var G = (e2) => s(e2), O = (e2) => a(e2);
2807
- var q = (e2) => {
2808
- if (typeof e2 == "string") return B(e2) ? e2 : null;
2809
- if (!(e2 == null ? void 0 : e2._type)) return null;
2810
- let r2 = null;
2811
- return (y$1(e2.id) || y$1(e2._id)) && (r2 = `${e2.id ?? e2._id}`), r2 && `${e2._type}:${r2}`;
2812
- };
2813
- var B = (e2) => {
2814
- if (O(e2) && (e2 == null ? void 0 : e2._type) && q(e2)) return e2;
2815
- if (!e2 || typeof e2 != "string") return null;
2816
- let [r2, ...u2] = e2.split(":");
2817
- return !r2 || u2.length < 1 ? null : { _type: r2, _id: u2.join(":") };
3348
+ var r = (e2) => !e2 && e2 == null, y$1 = (e2) => !r(e2), a = (e2) => typeof e2 == "object" && !Array.isArray(e2) && y$1(e2);
3349
+ var isObject$2 = (input) => a(input);
3350
+ var keyOfEntity = (entity) => {
3351
+ if (typeof entity === "string") {
3352
+ return entityOfKey(entity) ? entity : null;
3353
+ }
3354
+ if (!(entity == null ? void 0 : entity._type)) {
3355
+ return null;
3356
+ }
3357
+ let entityId = null;
3358
+ if (y$1(entity.id) || y$1(entity._id)) {
3359
+ entityId = `${entity.id ?? entity._id}`;
3360
+ }
3361
+ return !entityId ? entityId : `${entity._type}:${entityId}`;
3362
+ };
3363
+ var entityOfKey = (entity) => {
3364
+ if (isObject$2(entity) && (entity == null ? void 0 : entity._type) && keyOfEntity(entity)) {
3365
+ return entity;
3366
+ }
3367
+ if (!entity || typeof entity !== "string")
3368
+ return null;
3369
+ const [typeName, ...restTypes] = entity.split(":");
3370
+ if (!typeName || restTypes.length < 1)
3371
+ return null;
3372
+ return {
3373
+ _type: typeName,
3374
+ _id: restTypes.join(":")
3375
+ };
2818
3376
  };
2819
3377
  (function() {
2820
3378
  try {
@@ -2948,12 +3506,13 @@ const variableTransforms = createConstants(
2948
3506
  );
2949
3507
  const renderTarget = createConstants("canvas", "document");
2950
3508
  const renderMode = createConstants("viewport", "parent", "fixed");
2951
- const interactions = createConstants("click", "mouseover");
2952
- const eventMode = createConstants("goal", "callback");
3509
+ const interactions = createConstants("click", "mouseover", "appear");
3510
+ const eventMode = createConstants("goal", "callback", "tracker");
2953
3511
  const scopeTypes = createConstants(
2954
3512
  "InstanceScope",
2955
3513
  "FragmentScope",
2956
- "CollectionScope"
3514
+ "CollectionScope",
3515
+ "CollectionItemScope"
2957
3516
  );
2958
3517
  const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2959
3518
  __proto__: null,
@@ -3810,8 +4369,28 @@ const PositionSchema = /* @__PURE__ */ object({
3810
4369
  position: layerField(/* @__PURE__ */ enum_(Object.keys(positionType)), {
3811
4370
  fallback: positionType.absolute
3812
4371
  }),
3813
- top: layerField(/* @__PURE__ */ number(), { fallback: 0, transform: Math.ceil }),
3814
- left: layerField(/* @__PURE__ */ number(), { fallback: 0, transform: Math.ceil })
4372
+ top: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ number()), {
4373
+ fallback: null,
4374
+ transform: (value) => typeof value === "number" ? Math.ceil(value) : value
4375
+ }),
4376
+ left: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ number()), {
4377
+ fallback: null,
4378
+ transform: (value) => typeof value === "number" ? Math.ceil(value) : value
4379
+ }),
4380
+ right: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ number()), {
4381
+ fallback: null,
4382
+ transform: (value) => typeof value === "number" ? Math.ceil(value) : value
4383
+ }),
4384
+ bottom: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ number()), {
4385
+ fallback: null,
4386
+ transform: (value) => typeof value === "number" ? Math.ceil(value) : value
4387
+ }),
4388
+ centerAnchorX: layerField(/* @__PURE__ */ number(), {
4389
+ fallback: 0.5
4390
+ }),
4391
+ centerAnchorY: layerField(/* @__PURE__ */ number(), {
4392
+ fallback: 0.5
4393
+ })
3815
4394
  });
3816
4395
  const SceneSchema = /* @__PURE__ */ object({
3817
4396
  opacity: layerField(/* @__PURE__ */ pipe(/* @__PURE__ */ number(), /* @__PURE__ */ minValue(0), /* @__PURE__ */ maxValue(1)), {
@@ -3819,6 +4398,7 @@ const SceneSchema = /* @__PURE__ */ object({
3819
4398
  variable: true
3820
4399
  }),
3821
4400
  visible: layerField(/* @__PURE__ */ boolean(), { fallback: true, variable: true }),
4401
+ rotate: layerField(/* @__PURE__ */ number(), { fallback: null }),
3822
4402
  zIndex: layerField(/* @__PURE__ */ number(), { fallback: -1 })
3823
4403
  });
3824
4404
  const FillSchema = /* @__PURE__ */ object({
@@ -3968,33 +4548,22 @@ const TextSchema = /* @__PURE__ */ object({
3968
4548
  whiteSpace: layerField(/* @__PURE__ */ enum_(Object.keys(whiteSpace)), {
3969
4549
  fallback: whiteSpace.pre
3970
4550
  }),
3971
- variableContent: layerField(/* @__PURE__ */ string(), { fallback: null, variable: true }),
4551
+ textAlign: layerField(/* @__PURE__ */ string(), { fallback: "left" }),
3972
4552
  parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
3973
- attributes: /* @__PURE__ */ optional(
3974
- /* @__PURE__ */ object({
3975
- fontSize: layerField(/* @__PURE__ */ string(), { fallback: "14px" }),
3976
- color: layerField(/* @__PURE__ */ string(), { fallback: "#000", variable: true }),
3977
- lineHeight: layerField(/* @__PURE__ */ string(), { fallback: "14px" }),
3978
- fontWeight: layerField(/* @__PURE__ */ string(), { fallback: "normal" }),
3979
- letterSpacing: layerField(/* @__PURE__ */ string(), { fallback: "0px" }),
3980
- textTransform: layerField(/* @__PURE__ */ string(), { fallback: "none" }),
3981
- textDecoration: layerField(/* @__PURE__ */ string(), { fallback: "none" }),
3982
- whiteSpace: layerField(/* @__PURE__ */ string(), { fallback: "pre" }),
3983
- textAlign: layerField(/* @__PURE__ */ string(), { fallback: "left" })
3984
- })
3985
- ),
3986
4553
  ...GraphFieldSchema.entries,
3987
4554
  ...OverridesSchema.entries,
3988
4555
  ...CssOverrideSchema.entries,
3989
4556
  ...PositionSchema.entries,
3990
4557
  ...SceneSchema.entries,
3991
- ...SizeSchema.entries
4558
+ ...SizeSchema.entries,
4559
+ ...InteractionsSchema.entries,
4560
+ ...LinkSchema.entries
3992
4561
  });
3993
4562
  const FragmentSchema = /* @__PURE__ */ object({
3994
4563
  name: layerField(/* @__PURE__ */ string(), { fallback: "Fragment", overridable: false }),
3995
4564
  parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
3996
4565
  horizontalGrow: layerField(/* @__PURE__ */ enum_(Object.keys(fragmentGrowingMode)), {
3997
- fallback: fragmentGrowingMode.auto,
4566
+ fallback: fragmentGrowingMode.fill,
3998
4567
  overridable: false
3999
4568
  }),
4000
4569
  verticalGrow: layerField(/* @__PURE__ */ enum_(Object.keys(fragmentGrowingMode)), {
@@ -4035,6 +4604,7 @@ const InstanceSchema = /* @__PURE__ */ object({
4035
4604
  ...PositionSchema.entries,
4036
4605
  ...SizeSchema.entries,
4037
4606
  ...SceneSchema.entries,
4607
+ ...InteractionsSchema.entries,
4038
4608
  ...LinkSchema.entries
4039
4609
  });
4040
4610
  const NumberVariableSchema = /* @__PURE__ */ object({
@@ -4219,7 +4789,7 @@ const ArrayVariableSchema = /* @__PURE__ */ object({
4219
4789
  }),
4220
4790
  parent: layerField(/* @__PURE__ */ nullable(/* @__PURE__ */ string()), { overridable: false }),
4221
4791
  defaultValue: layerField(/* @__PURE__ */ array(/* @__PURE__ */ any()), { fallback: [] }),
4222
- definition: layerField(/* @__PURE__ */ nullable(linkValidator), { fallback: null }),
4792
+ definition: layerField(linkValidator, { fallback: null }),
4223
4793
  required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
4224
4794
  ...GraphFieldSchema.entries
4225
4795
  });
@@ -4251,7 +4821,7 @@ const getLayerSchema = (layer) => {
4251
4821
  const isObject$1 = (x2) => !!x2 && typeof x2 === "object" && !Array.isArray(x2);
4252
4822
  const normalizeLayer = (schema, rawLayer, options2) => {
4253
4823
  try {
4254
- if (!rawLayer) return null;
4824
+ if (!rawLayer || !schema.entries) return null;
4255
4825
  const withFallback = (options2 == null ? void 0 : options2.withFallback) ?? true;
4256
4826
  const overrideTarget = options2 == null ? void 0 : options2.overrideTarget;
4257
4827
  const parsedLayer = parse(schema, rawLayer);
@@ -4264,6 +4834,13 @@ const normalizeLayer = (schema, rawLayer, options2) => {
4264
4834
  if (isObject$1(layerValue) && isObject$1(overrideValue)) {
4265
4835
  layerValue = { ...overrideValue, ...layerValue };
4266
4836
  }
4837
+ if (schemaEntity && "wrapped" in schemaEntity && "entries" in schemaEntity.wrapped && isObject$1(schemaEntity.wrapped.entries)) {
4838
+ layerValue = normalizeLayer(
4839
+ schemaEntity.wrapped,
4840
+ layerValue,
4841
+ options2
4842
+ );
4843
+ }
4267
4844
  const resultValue = layerValue ?? overrideValue ?? fallback;
4268
4845
  return [key, resultValue];
4269
4846
  })
@@ -4273,12 +4850,13 @@ const normalizeLayer = (schema, rawLayer, options2) => {
4273
4850
  return null;
4274
4851
  }
4275
4852
  };
4276
- const getNormalizeLayer$1 = (layer, overrider) => {
4853
+ const getNormalizeLayer$1 = (layer, overrider, withFallback) => {
4277
4854
  if (!layer) return null;
4278
4855
  const schema = getLayerSchema(layer);
4279
4856
  if (!schema) return null;
4280
4857
  return normalizeLayer(schema, layer, {
4281
- overrideTarget: overrider
4858
+ overrideTarget: overrider,
4859
+ withFallback
4282
4860
  });
4283
4861
  };
4284
4862
  function findSchemaByPath(schema, path) {
@@ -4309,7 +4887,7 @@ const RenderTargetContext = K$1(
4309
4887
  );
4310
4888
  RenderTargetContext.Provider;
4311
4889
  const useRenderTarget = () => {
4312
- const renderTarget2 = x$1(RenderTargetContext);
4890
+ const renderTarget2 = x$2(RenderTargetContext);
4313
4891
  return {
4314
4892
  renderTarget: renderTarget2,
4315
4893
  isCanvas: renderTarget2 === index.renderTarget.canvas,
@@ -4467,35 +5045,37 @@ function requireWithSelector() {
4467
5045
  return withSelector.exports;
4468
5046
  }
4469
5047
  var withSelectorExports = requireWithSelector();
4470
- var b = (t2) => t2, y = (t2, e2, n2) => {
5048
+ var x = (t2) => t2, y = (t2, e2, n2) => {
4471
5049
  var _a, _b;
4472
- let r2 = A((_a = t2 == null ? void 0 : t2.resolve) == null ? void 0 : _a.call(t2, e2, n2)), o2 = ((_b = t2 == null ? void 0 : t2.keyOfEntity) == null ? void 0 : _b.call(t2, e2)) ?? e2, p2 = q$2((s2) => {
5050
+ let r2 = A((_a = t2 == null ? void 0 : t2.resolve) == null ? void 0 : _a.call(t2, e2, n2)), s2 = ((_b = t2 == null ? void 0 : t2.keyOfEntity) == null ? void 0 : _b.call(t2, e2)) ?? e2, o2 = q$1((p2) => {
4473
5051
  var _a2, _b2;
4474
- return o2 ? (r2.current = (_a2 = t2 == null ? void 0 : t2.resolve) == null ? void 0 : _a2.call(t2, o2, n2), s2(), (_b2 = t2 == null ? void 0 : t2.subscribe) == null ? void 0 : _b2.call(t2, o2, () => {
5052
+ return s2 ? (r2.current = (_a2 = t2 == null ? void 0 : t2.resolve) == null ? void 0 : _a2.call(t2, s2, n2), p2(), (_b2 = t2 == null ? void 0 : t2.subscribe) == null ? void 0 : _b2.call(t2, s2, () => {
4475
5053
  var _a3;
4476
- return r2.current = (_a3 = t2 == null ? void 0 : t2.resolve) == null ? void 0 : _a3.call(t2, o2, n2), s2();
5054
+ return r2.current = (_a3 = t2 == null ? void 0 : t2.resolve) == null ? void 0 : _a3.call(t2, s2, n2), p2();
4477
5055
  }, n2)) : () => {
4478
5056
  };
4479
- }, [t2, o2]), i2 = q$2((s2, u2) => {
4480
- let c2 = typeof e2 == "string" ? e2 : t2.keyOfEntity(e2);
4481
- e2 && c2 && t2.mutate(c2, s2, u2);
4482
- }, [t2, e2]), a2 = () => r2.current;
4483
- return [withSelectorExports.useSyncExternalStoreWithSelector(p2, a2, a2, b), i2];
4484
- };
4485
- var h2 = (t2) => t2, S = (t2, e2, n2) => {
4486
- let r2 = q$2((s2) => s2.map((u2) => t2.resolve(u2, n2)).filter(Boolean), [t2, n2]), o2 = T$1(() => e2.map((s2) => t2.keyOfEntity(s2) || s2).join(), [e2]), p2 = A(r2(e2)), i2 = q$2((s2) => {
5057
+ }, [t2, s2]), a2 = q$1((p2, c2) => {
5058
+ let u2 = typeof e2 == "string" ? e2 : keyOfEntity(e2);
5059
+ e2 && u2 && t2.mutate(u2, p2, c2);
5060
+ }, [t2, e2]), i2 = () => (n2 == null ? void 0 : n2.pause) ? null : r2.current;
5061
+ return [withSelectorExports.useSyncExternalStoreWithSelector(o2, i2, i2, x), a2];
5062
+ };
5063
+ var R = (t2) => t2, S = (t2, e2, n2) => {
5064
+ let r2 = q$1((c2) => c2.map((u2) => t2.resolve(u2, n2)).filter(Boolean), [t2, n2]), s2 = T$1(() => e2.map((c2) => t2.keyOfEntity(c2) || c2).join(), [e2]), o2 = A(r2(e2));
5065
+ A([]);
5066
+ let i2 = q$1((c2) => {
4487
5067
  if (e2) {
4488
5068
  let u2 = () => {
4489
- p2.current = r2(e2), s2();
4490
- }, c2 = new AbortController();
4491
- return e2.forEach((l2) => {
4492
- l2 && t2.subscribe(l2, u2, { signal: c2.signal, ...n2 });
4493
- }), u2(), () => c2.abort("unsubscribe");
5069
+ o2.current = r2(e2), c2();
5070
+ }, l2 = new AbortController();
5071
+ return e2.forEach((f2) => {
5072
+ f2 && t2.subscribe(f2, u2, { signal: l2.signal, ...n2 });
5073
+ }), u2(), () => l2.abort("unsubscribe");
4494
5074
  }
4495
5075
  return () => {
4496
5076
  };
4497
- }, [t2, o2]), a2 = () => p2.current;
4498
- return withSelectorExports.useSyncExternalStoreWithSelector(i2, a2, a2, h2);
5077
+ }, [t2, s2]), p2 = () => o2.current;
5078
+ return withSelectorExports.useSyncExternalStoreWithSelector(i2, p2, p2, R);
4499
5079
  };
4500
5080
  const GlobalManager = K$1(null);
4501
5081
  var __defProp = Object.defineProperty;
@@ -4503,14 +5083,14 @@ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
4503
5083
  var __hasOwnProp = Object.prototype.hasOwnProperty;
4504
5084
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
4505
5085
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4506
- var __spreadValues = (a2, b2) => {
4507
- for (var prop in b2 || (b2 = {}))
4508
- if (__hasOwnProp.call(b2, prop))
4509
- __defNormalProp(a2, prop, b2[prop]);
5086
+ var __spreadValues = (a2, b) => {
5087
+ for (var prop in b || (b = {}))
5088
+ if (__hasOwnProp.call(b, prop))
5089
+ __defNormalProp(a2, prop, b[prop]);
4510
5090
  if (__getOwnPropSymbols)
4511
- for (var prop of __getOwnPropSymbols(b2)) {
4512
- if (__propIsEnum.call(b2, prop))
4513
- __defNormalProp(a2, prop, b2[prop]);
5091
+ for (var prop of __getOwnPropSymbols(b)) {
5092
+ if (__propIsEnum.call(b, prop))
5093
+ __defNormalProp(a2, prop, b[prop]);
4514
5094
  }
4515
5095
  return a2;
4516
5096
  };
@@ -4537,7 +5117,7 @@ var set = (obj, path, value) => {
4537
5117
  return acc[key];
4538
5118
  }, obj);
4539
5119
  };
4540
- var toKebabCase = (value) => value.replace(/[A-Z]+(?![a-z])|[A-Z]/g, ($2, ofs) => (ofs ? "-" : "") + $2.toLowerCase());
5120
+ var isPrimitive = (value) => typeof value !== "object" && typeof value !== "function" || value === null;
4541
5121
  var noop = () => void 0;
4542
5122
  var pick = (obj, ...props) => {
4543
5123
  return props.reduce((result, prop) => {
@@ -4552,7 +5132,28 @@ function omit(obj, ...props) {
4552
5132
  });
4553
5133
  return result;
4554
5134
  }
5135
+ var cleanGraph = (input) => isObject(input) ? omit(input, "_type", "_id") : input;
4555
5136
  var isBrowser_default = typeof window !== "undefined";
5137
+ var flattenObject = (obj) => {
5138
+ const result = {};
5139
+ function flatten(current) {
5140
+ for (let key in current) {
5141
+ if (current.hasOwnProperty(key)) {
5142
+ const value = current[key];
5143
+ if (value && typeof value === "object" && !Array.isArray(value)) {
5144
+ flatten(value);
5145
+ } else {
5146
+ result[key] = value;
5147
+ }
5148
+ }
5149
+ }
5150
+ }
5151
+ flatten(obj);
5152
+ return result;
5153
+ };
5154
+ function isFiniteNumber(value) {
5155
+ return typeof value === "number" && isFinite(value);
5156
+ }
4556
5157
  function hashGenerator(layerKey) {
4557
5158
  let hash = 0;
4558
5159
  for (let i2 = 0; i2 < layerKey.length; i2++) {
@@ -4564,7 +5165,7 @@ function hashGenerator(layerKey) {
4564
5165
  }
4565
5166
  const useGlobalManager = (globalManager) => {
4566
5167
  var _a, _b;
4567
- const currentGlobalManager = x$1(GlobalManager);
5168
+ const currentGlobalManager = x$2(GlobalManager);
4568
5169
  const resultManager = globalManager ?? currentGlobalManager;
4569
5170
  const [fragmentsGraph] = y(
4570
5171
  resultManager,
@@ -4656,58 +5257,189 @@ const isInheritField = (manager, layerEntity, field) => {
4656
5257
  }
4657
5258
  return false;
4658
5259
  };
4659
- const getLayer = (manager, layer) => {
5260
+ const isVariableLink = (value) => {
5261
+ var _a;
5262
+ return isLink(value) && ((_a = value == null ? void 0 : value.split(":")) == null ? void 0 : _a.at(0)) === index.nodes.Variable;
5263
+ };
5264
+ const isLink = (value) => {
5265
+ var _a, _b;
5266
+ return value && ((_b = (_a = value == null ? void 0 : value.split) == null ? void 0 : _a.call(value, ":")) == null ? void 0 : _b.length) === 2;
5267
+ };
5268
+ const getCssVariables = (props) => {
5269
+ return Object.entries(cleanGraph(flattenObject(props))).reduce(
5270
+ (acc, [key, value]) => {
5271
+ var _a;
5272
+ if (isVariableLink(value)) {
5273
+ const nestedVariableId = (_a = entityOfKey(value)) == null ? void 0 : _a._id;
5274
+ value = `var(--${nestedVariableId})`;
5275
+ }
5276
+ acc[`--${key}`] = value;
5277
+ return acc;
5278
+ },
5279
+ {}
5280
+ );
5281
+ };
5282
+ const layerFieldSetter = (manager, layerKey, fieldKey, currentValue) => (value, options2) => {
5283
+ var _a;
5284
+ const { success, output } = parseLayerField(
5285
+ manager.resolve(layerKey),
5286
+ fieldKey,
5287
+ value
5288
+ );
5289
+ if (success) {
5290
+ if (isVariableLink$1(value)) {
5291
+ manager.mutate((_a = manager == null ? void 0 : manager.$fragment) == null ? void 0 : _a.temp, {
5292
+ [layerKey]: {
5293
+ [fieldKey]: currentValue
5294
+ }
5295
+ });
5296
+ }
5297
+ manager.mutate(
5298
+ layerKey,
5299
+ (prev) => {
5300
+ set(prev, fieldKey, output);
5301
+ return prev;
5302
+ },
5303
+ options2
5304
+ );
5305
+ }
5306
+ };
5307
+ const getLayer = (manager, layer, options2) => {
4660
5308
  if (!manager || !layer) return null;
4661
5309
  const layerKey = manager.keyOfEntity(layer);
4662
5310
  const layerData = manager.resolve(layerKey);
4663
5311
  const overrider = getOverrider(manager, layerKey);
4664
- return getNormalizeLayer$1(layerData, overrider);
5312
+ return getNormalizeLayer$1(layerData, overrider, options2 == null ? void 0 : options2.withFallback);
4665
5313
  };
4666
- const getNormalizeLayer = (layerKey, manager) => {
5314
+ const getNormalizeLayer = (layerKey, manager, options2) => {
4667
5315
  const layer = manager == null ? void 0 : manager.resolve(layerKey);
4668
- const parsedLayer = getLayer(manager, layerKey);
5316
+ const parsedLayer = getLayer(manager, layerKey, options2);
4669
5317
  return {
4670
5318
  rawLayer: layer,
4671
5319
  layer: parsedLayer
4672
5320
  };
4673
5321
  };
4674
- const useNormalizeLayer = (layerKey, manager) => {
4675
- const { manager: fragmentManager } = x$1(FragmentContext);
5322
+ const useNormalizeLayer = (layerKey, manager, options2) => {
5323
+ const { manager: fragmentManager } = x$2(FragmentContext);
4676
5324
  const resultManager = manager ?? fragmentManager;
4677
- return getNormalizeLayer(layerKey, resultManager);
5325
+ return getNormalizeLayer(layerKey, resultManager, options2);
4678
5326
  };
4679
5327
  const ScopeContext = K$1([]);
4680
- const useReadVariable = (variableKey) => {
4681
- var _a;
4682
- const scopes = x$1(ScopeContext);
4683
- const variableId = (_a = B(variableKey)) == null ? void 0 : _a._id;
4684
- const readVariable = (variableKey2) => {
4685
- var _a2, _b, _c;
4686
- const isVariable = isVariableLink$1(variableKey2);
4687
- const instanceProp = (_b = (_a2 = scopes.findLast(
4688
- (scope) => (scope == null ? void 0 : scope.type) === index.scopeTypes.InstanceScope
4689
- )) == null ? void 0 : _a2.props) == null ? void 0 : _b[variableId];
4690
- const fragmentDefinition = scopes.findLast(
4691
- (scope) => {
4692
- var _a3;
4693
- return scope.type === index.scopeTypes.FragmentScope && ((_a3 = scope == null ? void 0 : scope.definitions) == null ? void 0 : _a3.find((def) => def === variableKey2));
5328
+ const extractVariableValue = (input, variableId) => {
5329
+ if (isObject(input)) {
5330
+ if (variableId in input) {
5331
+ return input[variableId];
5332
+ }
5333
+ for (let key in input) {
5334
+ if (input.hasOwnProperty(key)) {
5335
+ const result = extractVariableValue(input[key], variableId);
5336
+ if (result !== void 0) {
5337
+ return result;
5338
+ }
4694
5339
  }
5340
+ }
5341
+ }
5342
+ return void 0;
5343
+ };
5344
+ function deepMerge(a2, b) {
5345
+ if (!isObject(a2) || !isObject(b)) return a2;
5346
+ const result = { ...b };
5347
+ for (const [key, value] of Object.entries(a2)) {
5348
+ if (key in result && typeof result[key] === "object" && typeof value === "object") {
5349
+ result[key] = deepMerge(value, result[key]);
5350
+ } else {
5351
+ result[key] = value;
5352
+ }
5353
+ }
5354
+ return result;
5355
+ }
5356
+ const useReadVariable = (variableKey) => {
5357
+ const scopes = x$2(ScopeContext);
5358
+ const extractVariableDefaultValue = (manager, variableEntity) => {
5359
+ const variableLayer = manager.resolve(variableEntity);
5360
+ if ((variableLayer == null ? void 0 : variableLayer.type) !== index.variableType.Object)
5361
+ return variableLayer == null ? void 0 : variableLayer.defaultValue;
5362
+ return Object.values((variableLayer == null ? void 0 : variableLayer.fields) ?? {}).reduce(
5363
+ (acc, fieldLink) => {
5364
+ var _a;
5365
+ if (!!fieldLink && isVariableLink$1(fieldLink)) {
5366
+ const _id = (_a = entityOfKey(fieldLink)) == null ? void 0 : _a._id;
5367
+ if (_id) {
5368
+ acc[_id] = extractVariableDefaultValue(manager, fieldLink);
5369
+ }
5370
+ }
5371
+ return acc;
5372
+ },
5373
+ {}
4695
5374
  );
4696
- if (!isVariable) {
5375
+ };
5376
+ const resolveVariableLayer = (manager, variableLink, customProps) => {
5377
+ var _a;
5378
+ const variableLayer = manager == null ? void 0 : manager.resolve(variableLink);
5379
+ if (!variableLayer) return null;
5380
+ if ((variableLayer == null ? void 0 : variableLayer.type) === index.variableType.Array) {
5381
+ const definitionLayer = manager.resolve(variableLayer == null ? void 0 : variableLayer.definition);
5382
+ if (!((_a = variableLayer == null ? void 0 : variableLayer.defaultValue) == null ? void 0 : _a.length) || (definitionLayer == null ? void 0 : definitionLayer.type) !== index.variableType.Object)
5383
+ return variableLayer;
5384
+ const definitionDefaultValue = extractVariableDefaultValue(
5385
+ manager,
5386
+ definitionLayer
5387
+ );
5388
+ const customValue = customProps == null ? void 0 : customProps[variableLayer == null ? void 0 : variableLayer._id];
5389
+ return {
5390
+ ...variableLayer,
5391
+ defaultValue: (variableLayer == null ? void 0 : variableLayer.defaultValue).map((item, index2) => {
5392
+ const customItemValue = Array.isArray(customValue) ? customValue.at(index2) : null;
5393
+ return deepMerge(
5394
+ customItemValue ? { ...item, ...customItemValue } : item,
5395
+ definitionDefaultValue
5396
+ );
5397
+ })
5398
+ };
5399
+ }
5400
+ return variableLayer;
5401
+ };
5402
+ const readVariable = (variableKey2) => {
5403
+ var _a, _b, _c;
5404
+ const variableId = (_a = entityOfKey(variableKey2)) == null ? void 0 : _a._id;
5405
+ if (!isVariableLink$1(variableKey2)) {
4697
5406
  return {
4698
5407
  value: null,
4699
5408
  layer: null
4700
5409
  };
4701
5410
  }
4702
- const variableLayer = pick(
4703
- ((_c = fragmentDefinition == null ? void 0 : fragmentDefinition.manager) == null ? void 0 : _c.resolve(variableKey2)) ?? {},
4704
- "defaultValue",
4705
- "required"
5411
+ const instanceScope = scopes.findLast(
5412
+ (scope) => {
5413
+ var _a2;
5414
+ return (scope == null ? void 0 : scope.type) === index.scopeTypes.InstanceScope && !!((_a2 = scope.documentManager) == null ? void 0 : _a2.resolve(variableKey2));
5415
+ }
4706
5416
  );
4707
- const currentValue = variableKey2 === instanceProp ? null : instanceProp ?? null;
5417
+ const variableLayer = resolveVariableLayer(
5418
+ instanceScope == null ? void 0 : instanceScope.documentManager,
5419
+ variableKey2
5420
+ );
5421
+ let instanceProp = (_b = instanceScope == null ? void 0 : instanceScope.props) == null ? void 0 : _b[variableId];
5422
+ if (Array.isArray(instanceProp)) {
5423
+ instanceProp = instanceProp.map(
5424
+ (rawProp, index2) => {
5425
+ var _a2;
5426
+ return deepMerge(rawProp, (_a2 = variableLayer == null ? void 0 : variableLayer.defaultValue) == null ? void 0 : _a2.at(index2));
5427
+ }
5428
+ );
5429
+ }
5430
+ const lastCollectionItem = scopes.findLast(
5431
+ (scope) => (scope == null ? void 0 : scope.type) === index.scopeTypes.CollectionItemScope
5432
+ );
5433
+ resolveVariableLayer(
5434
+ lastCollectionItem == null ? void 0 : lastCollectionItem.manager,
5435
+ lastCollectionItem == null ? void 0 : lastCollectionItem.sourceDefinition,
5436
+ lastCollectionItem == null ? void 0 : lastCollectionItem.value
5437
+ );
5438
+ const collectionItemProp = isPrimitive(lastCollectionItem == null ? void 0 : lastCollectionItem.value) && ((_c = entityOfKey(lastCollectionItem == null ? void 0 : lastCollectionItem.sourceDefinition)) == null ? void 0 : _c._id) === variableId ? lastCollectionItem == null ? void 0 : lastCollectionItem.value : extractVariableValue(lastCollectionItem == null ? void 0 : lastCollectionItem.value, variableId);
5439
+ const currentValue = variableKey2 === instanceProp ? null : collectionItemProp ?? instanceProp ?? null;
4708
5440
  const required = (variableLayer == null ? void 0 : variableLayer.required) ?? false;
4709
5441
  const defaultValue = (variableLayer == null ? void 0 : variableLayer.defaultValue) ?? null;
4710
- const resultValue = required ? currentValue : currentValue ?? defaultValue;
5442
+ const resultValue = required ? currentValue : currentValue ?? collectionItemProp ?? defaultValue;
4711
5443
  if (isVariableLink$1(resultValue)) {
4712
5444
  return readVariable(resultValue);
4713
5445
  }
@@ -4724,7 +5456,7 @@ const useReadVariable = (variableKey) => {
4724
5456
  };
4725
5457
  };
4726
5458
  const useLayerCssVariable = (inputValue) => {
4727
- const { manager } = x$1(FragmentContext);
5459
+ const { manager } = x$2(FragmentContext);
4728
5460
  const isVariable = isVariableLink$1(inputValue);
4729
5461
  const [variableValue] = y(isVariable ? manager : null, inputValue, {
4730
5462
  selector: (graph) => pick(graph, "defaultValue", "_id")
@@ -4733,22 +5465,27 @@ const useLayerCssVariable = (inputValue) => {
4733
5465
  value: isVariable ? `var(--${variableValue == null ? void 0 : variableValue._id}, ${variableValue == null ? void 0 : variableValue.defaultValue})` : null
4734
5466
  };
4735
5467
  };
4736
- const useLayerValue = (layerKey, fieldKey, manager) => {
4737
- const resultManager = manager;
4738
- const key = layerKey;
5468
+ const useLayerValue = (layerKey, fieldKey, options2) => {
5469
+ const { manager: fragmentManager } = x$2(FragmentContext);
5470
+ const resultManager = (options2 == null ? void 0 : options2.manager) ?? fragmentManager;
5471
+ if (!resultManager) {
5472
+ return [null, noop, {}];
5473
+ }
5474
+ const key = keyOfEntity(layerKey);
4739
5475
  const [, updateLayerData] = y(resultManager, key, {
4740
- selector: (data) => data ? pick(data, fieldKey) : data
5476
+ // selector: (data) => (data ? pick(data, fieldKey) : data),
4741
5477
  });
4742
- const { layer, rawLayer } = useNormalizeLayer(key, resultManager);
5478
+ const { layer, rawLayer } = useNormalizeLayer(key, resultManager, options2);
4743
5479
  const rawValue = get(rawLayer, fieldKey);
4744
5480
  const layerValue = get(layer, fieldKey);
4745
5481
  const { value: variableValue } = useReadVariable(layerValue);
4746
5482
  const currentValue = variableValue ?? layerValue;
4747
5483
  const isInherit = isInheritField(resultManager, key, fieldKey);
4748
5484
  const isOverride = !isInherit && !isPartOfPrimary(resultManager, key);
4749
- const resetOverride = q$2(() => {
5485
+ const setter = layerFieldSetter(resultManager, key, fieldKey, currentValue);
5486
+ const resetOverride = q$1(() => {
4750
5487
  resultManager.mutate(
4751
- layerKey,
5488
+ key,
4752
5489
  (prev) => {
4753
5490
  const r2 = omit(prev, fieldKey);
4754
5491
  return r2;
@@ -4756,34 +5493,20 @@ const useLayerValue = (layerKey, fieldKey, manager) => {
4756
5493
  { replace: true }
4757
5494
  );
4758
5495
  }, [updateLayerData]);
4759
- const restore = q$2(
5496
+ const restore = q$1(
4760
5497
  (fallbackValue) => {
4761
5498
  var _a, _b, _c;
4762
- const tempValue = (_c = (_b = resultManager.resolve((_a = resultManager == null ? void 0 : resultManager.$fragment) == null ? void 0 : _a.temp)) == null ? void 0 : _b[layerKey]) == null ? void 0 : _c[fieldKey];
4763
- updateLayerData({ [fieldKey]: tempValue ?? fallbackValue });
5499
+ const tempValue = ((_c = (_b = resultManager.resolve((_a = resultManager == null ? void 0 : resultManager.$fragment) == null ? void 0 : _a.temp)) == null ? void 0 : _b[key]) == null ? void 0 : _c[fieldKey]) ?? fallbackValue;
5500
+ updateLayerData({ [fieldKey]: tempValue });
5501
+ return tempValue;
4764
5502
  },
4765
5503
  [updateLayerData, resultManager]
4766
5504
  );
4767
- const updateValue = q$2(
4768
- (value, options2) => {
4769
- var _a, _b;
4770
- const { success, output } = parseLayerField(layer, fieldKey, value);
4771
- if (success) {
4772
- if (isVariableLink$1(value)) {
4773
- resultManager.mutate((_a = resultManager == null ? void 0 : resultManager.$fragment) == null ? void 0 : _a.temp, {
4774
- [layerKey]: {
4775
- [fieldKey]: currentValue
4776
- }
4777
- });
4778
- resultManager.resolve((_b = resultManager == null ? void 0 : resultManager.$fragment) == null ? void 0 : _b.temp);
4779
- }
4780
- updateLayerData((prev) => {
4781
- set(prev, fieldKey, output);
4782
- return prev;
4783
- }, options2);
4784
- }
5505
+ const updateValue = q$1(
5506
+ (value, options22) => {
5507
+ setter(value, options22);
4785
5508
  },
4786
- [layer, fieldKey, updateLayerData, resultManager, layerKey, currentValue]
5509
+ [setter]
4787
5510
  );
4788
5511
  const { value: cssValue } = useLayerCssVariable(rawValue ?? layerValue);
4789
5512
  return [
@@ -4800,14 +5523,48 @@ const useLayerValue = (layerKey, fieldKey, manager) => {
4800
5523
  }
4801
5524
  ];
4802
5525
  };
5526
+ const processOptionalSize = (value, type) => {
5527
+ if (value === -1) return "";
5528
+ if (type === index.sizing.Fixed) return toPx(value);
5529
+ if (type === index.sizing.Relative) return `${value}%`;
5530
+ return "";
5531
+ };
5532
+ const useOptionalSize = (type, layerKey) => {
5533
+ const { manager: fragmentManager } = x$2(FragmentContext);
5534
+ const [value] = useLayerValue(layerKey, type, fragmentManager);
5535
+ const [valueType] = useLayerValue(layerKey, `${type}Type`, fragmentManager);
5536
+ return T$1(
5537
+ () => processOptionalSize(value, valueType),
5538
+ [valueType, value]
5539
+ );
5540
+ };
5541
+ const useLayerSize = (layerKey) => {
5542
+ const { manager } = x$2(FragmentContext);
5543
+ const minWidth = useOptionalSize("minWidth", layerKey);
5544
+ const minHeight = useOptionalSize("minHeight", layerKey);
5545
+ const maxWidth = useOptionalSize("maxWidth", layerKey);
5546
+ const maxHeight = useOptionalSize("maxHeight", layerKey);
5547
+ return {
5548
+ // width: widthCalc(widthValue),
5549
+ // height: heightCalc(heightValue),
5550
+ minWidth,
5551
+ minHeight,
5552
+ maxWidth,
5553
+ maxHeight
5554
+ };
5555
+ };
4803
5556
  const autoSizes = [index.sizing.Hug];
4804
5557
  const useLayerSizeValue = (layerKey, sizeType) => {
4805
- const { manager: fragmentManager } = x$1(FragmentContext);
4806
- const { layerKey: instanceLayerKey } = x$1(InstanceContext);
5558
+ const { manager: fragmentManager } = x$2(FragmentContext);
5559
+ const { layerKey: instanceLayerKey } = x$2(InstanceContext);
4807
5560
  const { isDocument } = useRenderTarget();
4808
5561
  const isTop = isTopLevel(fragmentManager, layerKey);
4809
5562
  const isPartOfInstance = !!instanceLayerKey;
4810
5563
  const layerParent = getParent(fragmentManager, layerKey);
5564
+ const { layer: normalizeParentLayer } = useNormalizeLayer(
5565
+ layerParent,
5566
+ fragmentManager
5567
+ );
4811
5568
  const layerNode = fragmentManager.resolve(layerKey);
4812
5569
  const [instanceType] = useLayerValue(
4813
5570
  instanceLayerKey,
@@ -4820,9 +5577,9 @@ const useLayerSizeValue = (layerKey, sizeType) => {
4820
5577
  fragmentManager
4821
5578
  );
4822
5579
  const growType = sizeType === "width" ? "horizontalGrow" : "verticalGrow";
4823
- return q$2(
5580
+ return q$1(
4824
5581
  (value) => {
4825
- if (isTop && isDocument && (layerParent == null ? void 0 : layerParent[growType]) === index.fragmentGrowingMode.fill) {
5582
+ if (isTop && isDocument && (normalizeParentLayer == null ? void 0 : normalizeParentLayer[growType]) === index.fragmentGrowingMode.fill) {
4826
5583
  return "100%";
4827
5584
  }
4828
5585
  if (isTop && isPartOfInstance && !autoSizes.includes(instanceType)) {
@@ -4851,67 +5608,63 @@ const useLayerSizeValue = (layerKey, sizeType) => {
4851
5608
  ]
4852
5609
  );
4853
5610
  };
4854
- const processOptionalSize = (value, type) => {
4855
- if (value === -1) return "";
4856
- if (type === index.sizing.Fixed) return toPx(value);
4857
- if (type === index.sizing.Relative) return `${value}%`;
4858
- return "";
4859
- };
4860
- const useOptionalSize = (type, layerKey) => {
4861
- const { manager: fragmentManager } = x$1(FragmentContext);
4862
- const [value] = useLayerValue(layerKey, type, fragmentManager);
4863
- const [valueType] = useLayerValue(layerKey, `${type}Type`, fragmentManager);
4864
- return T$1(
4865
- () => processOptionalSize(value, valueType),
4866
- [valueType, value]
4867
- );
4868
- };
4869
- const useLayerSize = (layerKey) => {
4870
- const { manager } = x$1(FragmentContext);
4871
- const [widthValue] = useLayerValue(layerKey, "width", manager);
4872
- const [heightValue] = useLayerValue(layerKey, "height", manager);
4873
- const widthCalc = useLayerSizeValue(layerKey, "width");
4874
- const heightCalc = useLayerSizeValue(layerKey, "height");
4875
- const minWidth = useOptionalSize("minWidth", layerKey);
4876
- const minHeight = useOptionalSize("minHeight", layerKey);
4877
- const maxWidth = useOptionalSize("maxWidth", layerKey);
4878
- const maxHeight = useOptionalSize("maxHeight", layerKey);
4879
- return {
4880
- width: widthCalc(widthValue),
4881
- height: heightCalc(heightValue),
4882
- minWidth,
4883
- minHeight,
4884
- maxWidth,
4885
- maxHeight
4886
- };
4887
- };
4888
5611
  const useLayerPosition = (layerKey) => {
4889
- const { layerKey: instanceLayerKey } = x$1(InstanceContext);
4890
- const { manager: fragmentManager } = x$1(FragmentContext);
5612
+ const { layerKey: instanceLayerKey } = x$2(InstanceContext);
5613
+ const { manager: fragmentManager } = x$2(FragmentContext);
4891
5614
  const { isDocument } = useRenderTarget();
4892
5615
  const isTop = isTopLevel(fragmentManager, layerKey);
5616
+ const [width] = useLayerValue(layerKey, "width");
5617
+ const [height] = useLayerValue(layerKey, "height");
5618
+ const widthCalc = useLayerSizeValue(layerKey, "width")(width);
5619
+ const heightCalc = useLayerSizeValue(layerKey, "height")(height);
5620
+ const [position] = useLayerValue(layerKey, "position");
5621
+ const [centerAnchorX] = useLayerValue(layerKey, "centerAnchorX");
5622
+ const [centerAnchorY] = useLayerValue(layerKey, "centerAnchorY");
5623
+ const [top] = useLayerValue(layerKey, "top");
5624
+ const [left] = useLayerValue(layerKey, "left");
5625
+ const [right] = useLayerValue(layerKey, "right");
5626
+ const [bottom] = useLayerValue(layerKey, "bottom");
4893
5627
  const skipPosition = isTop && isDocument || !!instanceLayerKey && isTop;
4894
- const [position] = useLayerValue(layerKey, "position", fragmentManager);
4895
- const [top] = useLayerValue(layerKey, "top", fragmentManager);
4896
- const [left] = useLayerValue(layerKey, "left", fragmentManager);
4897
- return T$1(
4898
- () => ({
4899
- position: skipPosition ? index.positionType.relative : position,
4900
- top: position === index.positionType.absolute && !skipPosition ? toPx(top) : null,
4901
- left: position === index.positionType.absolute && !skipPosition ? toPx(left) : null
4902
- }),
4903
- [skipPosition, position, top]
4904
- );
5628
+ if (isTop && !skipPosition) {
5629
+ return {
5630
+ position: index.positionType.absolute,
5631
+ top: toPx(top),
5632
+ left: toPx(left),
5633
+ width,
5634
+ height
5635
+ };
5636
+ }
5637
+ if (position === index.positionType.relative || skipPosition) {
5638
+ return {
5639
+ position: index.positionType.relative,
5640
+ width: widthCalc,
5641
+ height: heightCalc
5642
+ };
5643
+ }
5644
+ const hasConstrainX = isFiniteNumber(left) && isFiniteNumber(right);
5645
+ const hasConstrainY = isFiniteNumber(top) && isFiniteNumber(bottom);
5646
+ const hasAnyConstrainX = isFiniteNumber(left) || isFiniteNumber(right);
5647
+ const hasAnyConstrainY = isFiniteNumber(top) || isFiniteNumber(bottom);
5648
+ return {
5649
+ position,
5650
+ left: isFiniteNumber(left) ? toPx(left) : !isFiniteNumber(right) ? `${centerAnchorX * 100}%` : null,
5651
+ top: isFiniteNumber(top) ? toPx(top) : !isFiniteNumber(bottom) ? `${centerAnchorY * 100}%` : null,
5652
+ right: isFiniteNumber(right) ? toPx(right) : null,
5653
+ bottom: isFiniteNumber(bottom) ? toPx(bottom) : null,
5654
+ width: hasConstrainX ? null : widthCalc,
5655
+ height: hasConstrainY ? null : heightCalc,
5656
+ transform: !hasAnyConstrainX || !hasAnyConstrainY ? `translate3d(${!hasAnyConstrainX ? "-50%" : 0}, ${!hasAnyConstrainY ? "-50%" : 0}, 0px)` : null
5657
+ };
4905
5658
  };
4906
5659
  const useLayerBackground = (layerKey) => {
4907
- const { manager: fragmentManager } = x$1(FragmentContext);
5660
+ const { manager: fragmentManager } = x$2(FragmentContext);
4908
5661
  const [fillType] = useLayerValue(layerKey, "fillType", fragmentManager);
4909
5662
  const [, , { cssVariableValue: cssSolidFill }] = useLayerValue(
4910
5663
  layerKey,
4911
5664
  "solidFill",
4912
5665
  fragmentManager
4913
5666
  );
4914
- const [, , { cssVariableValue: cssImageFill }] = useLayerValue(
5667
+ const [imageFill, , { cssVariableValue: cssImageFill }] = useLayerValue(
4915
5668
  layerKey,
4916
5669
  "imageFill",
4917
5670
  fragmentManager
@@ -4929,7 +5682,7 @@ const useLayerBackground = (layerKey) => {
4929
5682
  }
4930
5683
  if (fillType === index.paintMode.Image && cssImageFill) {
4931
5684
  return {
4932
- background: `url(${cssImageFill})`,
5685
+ background: `url(${imageFill})`,
4933
5686
  backgroundSize: cssImageSize == null ? void 0 : cssImageSize.toLowerCase(),
4934
5687
  backgroundRepeat: "no-repeat"
4935
5688
  };
@@ -4940,7 +5693,7 @@ const useLayerBackground = (layerKey) => {
4940
5693
  }, [fillType, cssImageFill, cssSolidFill]);
4941
5694
  };
4942
5695
  const useLayerDisplay = (layerKey) => {
4943
- const { manager } = x$1(FragmentContext);
5696
+ const { manager } = x$2(FragmentContext);
4944
5697
  const [layerModeValue] = useLayerValue(layerKey, "layerMode", manager);
4945
5698
  const [visible] = useLayerValue(layerKey, "visible", manager);
4946
5699
  return T$1(() => {
@@ -4951,7 +5704,7 @@ const useLayerDisplay = (layerKey) => {
4951
5704
  }, [layerModeValue, visible]);
4952
5705
  };
4953
5706
  const useCalcLayerBorder = (layerKey) => {
4954
- const { manager: fragmentManager } = x$1(FragmentContext);
5707
+ const { manager: fragmentManager } = x$2(FragmentContext);
4955
5708
  const [borderTypeValue] = useLayerValue(
4956
5709
  layerKey,
4957
5710
  "borderType",
@@ -4988,7 +5741,7 @@ const useCalcLayerBorder = (layerKey) => {
4988
5741
  };
4989
5742
  };
4990
5743
  const useLayerBorder = (layerKey) => {
4991
- const { manager: fragmentManager } = x$1(FragmentContext);
5744
+ const { manager: fragmentManager } = x$2(FragmentContext);
4992
5745
  const [borderWidth] = useLayerValue(layerKey, "borderWidth", fragmentManager);
4993
5746
  const [borderColor] = useLayerValue(layerKey, "borderColor", fragmentManager);
4994
5747
  const calcBorder = useCalcLayerBorder(layerKey);
@@ -4998,7 +5751,7 @@ const useLayerBorder = (layerKey) => {
4998
5751
  );
4999
5752
  };
5000
5753
  const useLayerLayout = (layerKey) => {
5001
- const { manager: fragmentManager } = x$1(FragmentContext);
5754
+ const { manager: fragmentManager } = x$2(FragmentContext);
5002
5755
  const [layerModeValue] = useLayerValue(
5003
5756
  layerKey,
5004
5757
  "layerMode",
@@ -5040,7 +5793,7 @@ const useLayerLayout = (layerKey) => {
5040
5793
  );
5041
5794
  };
5042
5795
  const useLayerTextStyles = (layerKey) => {
5043
- const { manager: fragmentManager } = x$1(FragmentContext);
5796
+ const { manager: fragmentManager } = x$2(FragmentContext);
5044
5797
  const [attributes] = useLayerValue(layerKey, "attributes", fragmentManager);
5045
5798
  const [color] = useLayerValue(layerKey, "attributes.color", fragmentManager);
5046
5799
  const cleanAttributes = omit(attributes, "_id", "_type");
@@ -5054,15 +5807,16 @@ const useLayerStyles = (layerKey) => {
5054
5807
  if (!layerKey) {
5055
5808
  throw new Error("Empty layer key");
5056
5809
  }
5057
- const { manager: fragmentManager } = x$1(FragmentContext);
5810
+ const { manager: fragmentManager } = x$2(FragmentContext);
5058
5811
  const [opacity] = useLayerValue(layerKey, "opacity", fragmentManager);
5059
5812
  const layerSize = useLayerSize(layerKey);
5060
- const { position, top, left } = useLayerPosition(layerKey);
5813
+ const position = useLayerPosition(layerKey);
5061
5814
  const display = useLayerDisplay(layerKey);
5062
5815
  const background = useLayerBackground(layerKey);
5063
5816
  const border = useLayerBorder(layerKey);
5064
5817
  const layout = useLayerLayout(layerKey);
5065
5818
  const [zIndex] = useLayerValue(layerKey, "zIndex", fragmentManager);
5819
+ const [rotate] = useLayerValue(layerKey, "rotate", fragmentManager);
5066
5820
  const [borderRadius] = useLayerValue(
5067
5821
  layerKey,
5068
5822
  "borderRadius",
@@ -5074,10 +5828,9 @@ const useLayerStyles = (layerKey) => {
5074
5828
  // ...(props ?? {}),
5075
5829
  ...border,
5076
5830
  ...background,
5077
- position,
5078
- top,
5079
- left,
5831
+ ...position,
5080
5832
  opacity,
5833
+ rotate: isValue(rotate) ? `${rotate}deg` : null,
5081
5834
  "border-radius": borderRadius,
5082
5835
  "white-space": whiteSpace2,
5083
5836
  "z-index": zIndex !== -1 ? zIndex : null,
@@ -5089,7 +5842,6 @@ const useLayerStyles = (layerKey) => {
5089
5842
  // ...cssOverride,
5090
5843
  };
5091
5844
  } catch (e2) {
5092
- console.debug(e2);
5093
5845
  return {};
5094
5846
  }
5095
5847
  };
@@ -5098,7 +5850,7 @@ const useFragmentProperties = (fragmentId) => {
5098
5850
  const { manager } = useFragmentManager(fragmentId);
5099
5851
  const [instanceFragment] = y(manager, (_a = manager == null ? void 0 : manager.$fragment) == null ? void 0 : _a.root);
5100
5852
  return {
5101
- properties: (instanceFragment == null ? void 0 : instanceFragment.properties) ?? [],
5853
+ properties: ((instanceFragment == null ? void 0 : instanceFragment.properties) ?? []).map((manager == null ? void 0 : manager.resolve) ?? noop).filter((prop) => !(prop == null ? void 0 : prop.parent)).map(keyOfEntity),
5102
5854
  manager
5103
5855
  };
5104
5856
  };
@@ -5108,24 +5860,15 @@ const useHash = (layerKey, manager) => {
5108
5860
  const overrideFrom = getKey(layer == null ? void 0 : layer.overrideFrom);
5109
5861
  return hashGenerator(overrideFrom ?? layerKey);
5110
5862
  };
5111
- const isVariableLink = (value) => {
5112
- var _a;
5113
- return isLink(value) && ((_a = value == null ? void 0 : value.split(":")) == null ? void 0 : _a.at(0)) === index.nodes.Variable;
5114
- };
5115
- const isLink = (value) => {
5116
- var _a, _b;
5117
- return value && ((_b = (_a = value == null ? void 0 : value.split) == null ? void 0 : _a.call(value, ":")) == null ? void 0 : _b.length) === 2;
5118
- };
5119
5863
  const useInstanceProps = (instanceProps) => {
5120
5864
  const isTopInstance = !(instanceProps == null ? void 0 : instanceProps.layerKey);
5121
5865
  const { manager: loadedManager } = useFragmentManager(
5122
5866
  isTopInstance ? instanceProps == null ? void 0 : instanceProps.fragmentId : null
5123
5867
  );
5124
- const { manager: fragmentContextManager } = x$1(FragmentContext);
5868
+ const { manager: fragmentContextManager } = x$2(FragmentContext);
5125
5869
  const { properties: definitions, manager: innerFragmentManager } = useFragmentProperties(instanceProps == null ? void 0 : instanceProps.fragmentId);
5126
5870
  const definitionsData = S(innerFragmentManager, definitions);
5127
5871
  const fragmentManager = isTopInstance ? loadedManager : fragmentContextManager;
5128
- useReadVariable(null);
5129
5872
  const [instanceLayer] = y(fragmentManager, instanceProps.layerKey);
5130
5873
  const instanceLayerProps = (instanceLayer == null ? void 0 : instanceLayer.props) ?? {};
5131
5874
  const mergedProps = T$1(() => {
@@ -5145,30 +5888,59 @@ const useInstanceProps = (instanceProps) => {
5145
5888
  }
5146
5889
  return omit(base, "_type", "_id");
5147
5890
  }, [isTopInstance, fragmentManager, instanceLayerProps, definitionsData]);
5148
- const drilledProps = Object.values(mergedProps).filter(isVariableLink);
5149
- const resolveDrilledProps = S(fragmentManager, drilledProps);
5150
- const resultProps = T$1(() => {
5151
- const props = { ...mergedProps };
5152
- return props;
5153
- }, [resolveDrilledProps, mergedProps]);
5154
- const cssProps = Object.entries(resultProps).reduce((acc, [key, value]) => {
5155
- var _a;
5156
- if (isVariableLink(value)) {
5157
- const nestedVariableId = (_a = fragmentManager.entityOfKey(value)) == null ? void 0 : _a._id;
5158
- value = `var(--${nestedVariableId})`;
5159
- }
5160
- acc[`--${key}`] = value;
5161
- return acc;
5162
- }, {});
5163
5891
  return {
5164
- props: resultProps,
5165
- cssProps
5892
+ props: mergedProps,
5893
+ cssProps: getCssVariables(mergedProps)
5166
5894
  };
5167
5895
  };
5896
+ const useLayerInteractions = (layerKey, options2) => {
5897
+ const pause = (options2 == null ? void 0 : options2.pauseInteractions) ?? false;
5898
+ const { manager: globalManager } = useGlobalManager();
5899
+ const { manager: fragmentManager } = x$2(FragmentContext);
5900
+ const [interactions2] = useLayerValue(
5901
+ layerKey,
5902
+ "interactions",
5903
+ fragmentManager
5904
+ );
5905
+ const { readVariable } = useReadVariable();
5906
+ const fireEvent = q$1(
5907
+ (eventLink) => {
5908
+ var _a, _b, _c, _d;
5909
+ const event = fragmentManager.resolve(eventLink);
5910
+ const { value: eventValue } = readVariable(eventLink);
5911
+ if ((event == null ? void 0 : event.mode) === index.eventMode.goal && (eventValue == null ? void 0 : eventValue.code)) {
5912
+ (_b = (_a = globalManager == null ? void 0 : globalManager.$metrics) == null ? void 0 : _a.reachGoal) == null ? void 0 : _b.call(_a, eventValue == null ? void 0 : eventValue.code);
5913
+ }
5914
+ if ((event == null ? void 0 : event.mode) === index.eventMode.tracker && eventValue) {
5915
+ (_d = (_c = globalManager == null ? void 0 : globalManager.$metrics) == null ? void 0 : _c.trackAdPixel) == null ? void 0 : _d.call(_c, eventValue);
5916
+ }
5917
+ if ((event == null ? void 0 : event.mode) === index.eventMode.callback && typeof eventValue === "function") {
5918
+ eventValue();
5919
+ }
5920
+ },
5921
+ [globalManager, fragmentManager]
5922
+ );
5923
+ y$2(() => {
5924
+ if (!pause && Array.isArray(interactions2)) {
5925
+ interactions2 == null ? void 0 : interactions2.filter((el) => (el == null ? void 0 : el.on) === index.interactions.appear).map((el) => el.event).forEach(fireEvent);
5926
+ }
5927
+ }, [pause]);
5928
+ return T$1(() => {
5929
+ if (!pause && !interactions2 || !Array.isArray(interactions2)) return {};
5930
+ if (pause) return {};
5931
+ const clickEvents = interactions2 == null ? void 0 : interactions2.filter((el) => (el == null ? void 0 : el.on) === index.interactions.click).map((el) => el.event);
5932
+ return {
5933
+ onClick: () => {
5934
+ clickEvents.map(fireEvent);
5935
+ }
5936
+ };
5937
+ }, [interactions2, fireEvent, pause]);
5938
+ };
5168
5939
  const useInstance = (instanceProps) => {
5169
- const { manager: parentManager } = x$1(FragmentContext);
5940
+ const { manager: parentManager } = x$2(FragmentContext);
5170
5941
  const [instanceLayer] = y(parentManager, instanceProps.layerKey);
5171
5942
  const styles2 = useLayerStyles(instanceProps.layerKey);
5943
+ const events = useLayerInteractions(instanceProps.layerKey, instanceProps);
5172
5944
  const { manager: resultGlobalManager } = useGlobalManager(
5173
5945
  instanceProps == null ? void 0 : instanceProps.globalManager
5174
5946
  );
@@ -5179,6 +5951,7 @@ const useInstance = (instanceProps) => {
5179
5951
  return {
5180
5952
  hash,
5181
5953
  styles: styles2,
5954
+ events,
5182
5955
  definitions,
5183
5956
  props,
5184
5957
  cssProps,
@@ -5195,7 +5968,7 @@ const Scope = ({
5195
5968
  layerKey
5196
5969
  }) => {
5197
5970
  var _a, _b;
5198
- const currentScope = x$1(ScopeContext) ?? [];
5971
+ const currentScope = x$2(ScopeContext) ?? [];
5199
5972
  const nextScope = [...currentScope, value];
5200
5973
  (_b = (_a = fragmentManager == null ? void 0 : fragmentManager.$scopes) == null ? void 0 : _a.registerScope) == null ? void 0 : _b.call(_a, layerKey, nextScope);
5201
5974
  return /* @__PURE__ */ u(ScopeContext.Provider, { value: nextScope, children });
@@ -5269,20 +6042,20 @@ const Instance = (props) => {
5269
6042
  return "globalManager" in props ? /* @__PURE__ */ u(GlobalManager, { value: props.globalManager, children: /* @__PURE__ */ u(InstanceInitial, { ...props }) }) : /* @__PURE__ */ u(InstanceInitial, { ...props });
5270
6043
  };
5271
6044
  const useLayerChildren = (layerKey, customManager) => {
5272
- const { manager: fragmentManager } = x$1(FragmentContext);
6045
+ const { manager: fragmentManager } = x$2(FragmentContext);
5273
6046
  const [layerData] = y(customManager ?? fragmentManager, layerKey, {
5274
6047
  selector: (data) => pick(data, "children")
5275
6048
  });
5276
6049
  return (layerData == null ? void 0 : layerData.children) ?? [];
5277
6050
  };
5278
6051
  const useFragmentChildren = (fragmentId) => {
5279
- const { layerKey: instanceLayerKey } = x$1(InstanceContext);
6052
+ const { layerKey: instanceLayerKey } = x$2(InstanceContext);
5280
6053
  const { manager, fragmentLayerKey } = useFragmentManager(fragmentId);
5281
6054
  const children = useLayerChildren(fragmentLayerKey, manager);
5282
6055
  const { isDocument } = useRenderTarget();
5283
6056
  const [resizeChildren, setResizeChildren] = d(null);
5284
6057
  A();
5285
- const setRef = q$2(
6058
+ const setRef = q$1(
5286
6059
  (node) => {
5287
6060
  },
5288
6061
  [isDocument, instanceLayerKey, manager, children]
@@ -5301,56 +6074,26 @@ const useFragmentChildren = (fragmentId) => {
5301
6074
  setRef
5302
6075
  };
5303
6076
  };
5304
- const getStylesheetKey = (fragmentKey) => {
5305
- const isLink2 = G(fragmentKey);
5306
- if (isLink2) {
5307
- const [type, id] = fragmentKey.split(":");
5308
- return `stylesheet-${id}`;
5309
- }
5310
- return `stylesheet-${fragmentKey ?? "unknown"}`;
5311
- };
5312
- function useInjectedStyle() {
5313
- const { manager } = x$1(FragmentContext);
5314
- const injectStyle = () => {
5315
- var _a, _b;
5316
- const styles2 = (_b = (_a = manager == null ? void 0 : manager.$styleSheet.extract()) == null ? void 0 : _a.at(0)) == null ? void 0 : _b.styles;
5317
- if (isBrowser_default && styles2) {
5318
- const stylesheetKey = getStylesheetKey(manager == null ? void 0 : manager.key);
5319
- if (document.getElementById(stylesheetKey)) {
5320
- const el = document.getElementById(stylesheetKey);
5321
- if (el) el.remove();
5322
- }
5323
- const style = document.createElement("style");
5324
- style.id = stylesheetKey;
5325
- style.textContent = styles2.join("");
5326
- document.head.appendChild(style);
5327
- }
5328
- };
5329
- return {
5330
- injectStyle
5331
- };
5332
- }
5333
6077
  const useStyleSheet = (manager) => {
5334
- const { injectStyle } = useInjectedStyle();
5335
- const addLayerStyle = q$2(
6078
+ var _a, _b;
6079
+ const addLayerStyle = q$1(
5336
6080
  (layerKey, styles2, layer) => {
5337
- var _a, _b;
6081
+ var _a2, _b2;
5338
6082
  if (!!(manager == null ? void 0 : manager.$styleSheet) && manager && "addStyle" in (manager == null ? void 0 : manager.$styleSheet)) {
5339
- (_b = (_a = manager == null ? void 0 : manager.$styleSheet) == null ? void 0 : _a.addStyle) == null ? void 0 : _b.call(_a, layerKey, styles2, layer);
5340
- if (isBrowser_default) {
5341
- injectStyle();
5342
- }
6083
+ (_b2 = (_a2 = manager == null ? void 0 : manager.$styleSheet) == null ? void 0 : _a2.addStyle) == null ? void 0 : _b2.call(_a2, layerKey, styles2, layer);
5343
6084
  }
5344
6085
  },
5345
6086
  [manager]
5346
6087
  );
5347
6088
  return {
5348
- addLayerStyle
6089
+ addLayerStyle,
6090
+ mount: ((_a = manager == null ? void 0 : manager.$styleSheet) == null ? void 0 : _a.mount) ?? noop,
6091
+ unmount: ((_b = manager == null ? void 0 : manager.$styleSheet) == null ? void 0 : _b.unmount) ?? noop
5349
6092
  };
5350
6093
  };
5351
6094
  const useFragment = (fragmentId, globalManager) => {
5352
6095
  var _a, _b;
5353
- const instanceContext = x$1(InstanceContext);
6096
+ const instanceContext = x$2(InstanceContext);
5354
6097
  const fragmentContext = useFragmentManager(fragmentId);
5355
6098
  const { isDocument } = useRenderTarget();
5356
6099
  const { setRef, children, isResize } = useFragmentChildren(fragmentId);
@@ -5359,9 +6102,11 @@ const useFragment = (fragmentId, globalManager) => {
5359
6102
  fragmentContext.manager
5360
6103
  );
5361
6104
  const { properties: definitions } = useFragmentProperties(fragmentId);
5362
- const scopes = x$1(ScopeContext);
6105
+ const scopes = x$2(ScopeContext);
5363
6106
  !(scopes == null ? void 0 : scopes.length);
5364
- const { addLayerStyle } = useStyleSheet(fragmentContext.manager);
6107
+ const { addLayerStyle, mount, unmount } = useStyleSheet(
6108
+ fragmentContext.manager
6109
+ );
5365
6110
  if (fragmentContext.manager) {
5366
6111
  addLayerStyle(
5367
6112
  fragmentContext.fragmentLayerKey,
@@ -5373,7 +6118,13 @@ const useFragment = (fragmentId, globalManager) => {
5373
6118
  (_a = fragmentContext.manager) == null ? void 0 : _a.resolve(fragmentContext.fragmentLayerKey),
5374
6119
  (_b = fragmentContext.manager) == null ? void 0 : _b.key
5375
6120
  );
6121
+ mount();
5376
6122
  }
6123
+ y$2(() => {
6124
+ return () => {
6125
+ unmount();
6126
+ };
6127
+ }, []);
5377
6128
  return {
5378
6129
  hash,
5379
6130
  isDocument,
@@ -5390,41 +6141,8 @@ const fragment = "_fragment_1c708_1";
5390
6141
  const styles = {
5391
6142
  fragment
5392
6143
  };
5393
- const useLayerInteractions = (layerKey) => {
5394
- const { manager: globalManager } = useGlobalManager();
5395
- const { manager: fragmentManager } = x$1(FragmentContext);
5396
- const [interactions2] = useLayerValue(
5397
- layerKey,
5398
- "interactions",
5399
- fragmentManager
5400
- );
5401
- const { readVariable } = useReadVariable();
5402
- const fireEvent = q$2(
5403
- (eventLink) => {
5404
- var _a, _b;
5405
- const event = fragmentManager.resolve(eventLink);
5406
- const { value: eventValue } = readVariable(eventLink);
5407
- if ((event == null ? void 0 : event.mode) === index.eventMode.goal && (eventValue == null ? void 0 : eventValue.code)) {
5408
- (_b = (_a = globalManager == null ? void 0 : globalManager.$metrics) == null ? void 0 : _a.reachGoal) == null ? void 0 : _b.call(_a, eventValue == null ? void 0 : eventValue.code);
5409
- }
5410
- if ((event == null ? void 0 : event.mode) === index.eventMode.callback && typeof eventValue === "function") {
5411
- eventValue();
5412
- }
5413
- },
5414
- [globalManager, fragmentManager]
5415
- );
5416
- return T$1(() => {
5417
- if (!interactions2 || !Array.isArray(interactions2)) return {};
5418
- const clickEvents = interactions2 == null ? void 0 : interactions2.filter((el) => (el == null ? void 0 : el.on) === index.interactions.click).map((el) => el.event);
5419
- return {
5420
- onClick: () => {
5421
- clickEvents.map(fireEvent);
5422
- }
5423
- };
5424
- }, [interactions2, fireEvent]);
5425
- };
5426
6144
  const useLayerLink = (layerKey) => {
5427
- const { manager: fragmentManager } = x$1(FragmentContext);
6145
+ const { manager: fragmentManager } = x$2(FragmentContext);
5428
6146
  const [href] = useLayerValue(layerKey, "href", fragmentManager);
5429
6147
  const [hrefNewTab] = useLayerValue(layerKey, "hrefNewTab", fragmentManager);
5430
6148
  const isLink2 = isValue(href) && typeof href === "string" && !!(href == null ? void 0 : href.length);
@@ -5446,13 +6164,13 @@ const useLayerLink = (layerKey) => {
5446
6164
  };
5447
6165
  };
5448
6166
  const useFrame = (layerKey, options2) => {
5449
- const { manager: fragmentManager } = x$1(FragmentContext);
6167
+ const { manager: fragmentManager } = x$2(FragmentContext);
5450
6168
  const layer = fragmentManager.entityOfKey(layerKey);
5451
6169
  const styles2 = useLayerStyles(layerKey);
5452
6170
  const children = useLayerChildren(layerKey);
5453
6171
  const hash = useHash(layerKey, fragmentManager);
5454
6172
  const { addLayerStyle } = useStyleSheet(fragmentManager);
5455
- const events = useLayerInteractions(layerKey);
6173
+ const events = useLayerInteractions(layerKey, options2);
5456
6174
  const link = useLayerLink(layerKey);
5457
6175
  {
5458
6176
  addLayerStyle(layerKey, styles2, fragmentManager.resolve(layerKey));
@@ -5472,44 +6190,48 @@ const text = "_text_1liuf_1";
5472
6190
  const cssStyles = {
5473
6191
  text
5474
6192
  };
5475
- const allowAttributes = [
5476
- "fontSize",
5477
- "fontWeight",
5478
- "color",
5479
- "lineHeight",
5480
- "letterSpacing",
5481
- "textTransform",
5482
- "textDecoration",
5483
- "textAlign"
5484
- ];
5485
- const wrapTextInParagraphWithAttributes = (text2, attributes) => {
5486
- if (text2.startsWith("<p")) return text2;
5487
- const style = Object.entries(attributes).filter(
5488
- ([key, value]) => isValue(value) && allowAttributes.includes(key) && typeof value === "string" && !!value.length
5489
- ).map(([key, value]) => `${toKebabCase(key)}: ${value}`).join("; ");
5490
- return `<p style="${style}">${text2}</p>`;
5491
- };
6193
+ function extractVariablesFromHtml(html) {
6194
+ if (!html) return [];
6195
+ const regex = /<span(?=\s)(?=(?:[^>]*?\s)?class="[^"]*variable[^"]*")(?=(?:[^>]*?\s)?data-type="mention")(?=(?:[^>]*?\s)?data-id="([^"]+)")[^>]*>.*?<\/span>/gi;
6196
+ const mentions = [];
6197
+ let match;
6198
+ while ((match = regex.exec(html)) !== null) {
6199
+ mentions.push({
6200
+ fullMatch: match[0],
6201
+ dataId: match[1],
6202
+ variableKey: keyOfEntity({
6203
+ _type: index.nodes.Variable,
6204
+ _id: match[1]
6205
+ }),
6206
+ position: match.index
6207
+ });
6208
+ }
6209
+ return mentions;
6210
+ }
5492
6211
  const useTextContent = (layerKey, manager) => {
5493
- const { manager: fragmentManager } = x$1(FragmentContext);
6212
+ const { manager: fragmentManager } = x$2(FragmentContext);
5494
6213
  const [content, , contentInfo] = useLayerValue(
5495
6214
  layerKey,
5496
6215
  "content",
5497
6216
  fragmentManager
5498
6217
  );
5499
- const [attributes] = useLayerValue(layerKey, "attributes", fragmentManager);
5500
- const resultAttributes = {
5501
- ...attributes,
5502
- color: (attributes == null ? void 0 : attributes.color) ?? "rgb(0, 0, 0)"
5503
- };
5504
- return T$1(() => {
5505
- if (typeof content === "string" && isValue(attributes)) {
5506
- return wrapTextInParagraphWithAttributes(content, resultAttributes);
5507
- }
5508
- return content;
5509
- }, [contentInfo, content, attributes]);
6218
+ const variables = extractVariablesFromHtml(content);
6219
+ const { readVariable } = useReadVariable();
6220
+ S(
6221
+ fragmentManager,
6222
+ variables.map((variable) => variable.variableKey)
6223
+ );
6224
+ let nextContent = content;
6225
+ variables.forEach((variable) => {
6226
+ nextContent = nextContent.replace(
6227
+ variable.fullMatch,
6228
+ readVariable(variable.variableKey).value
6229
+ );
6230
+ });
6231
+ return nextContent;
5510
6232
  };
5511
6233
  const useTextAttributes = (layerKey, options2) => {
5512
- const { manager: fragmentManager } = x$1(FragmentContext);
6234
+ const { manager: fragmentManager } = x$2(FragmentContext);
5513
6235
  const styles2 = useLayerStyles(layerKey);
5514
6236
  const content = useTextContent(layerKey);
5515
6237
  const hash = useHash(layerKey, fragmentManager);