@fragmentsx/render-react 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -1,3439 +1,13 @@
1
- import { options, Component, createElement, Fragment as Fragment$2, toChildArray, createContext, createRef, render, hydrate, cloneElement } from "preact";
2
- import require$$0$1, { createContext as createContext$1, useContext, useRef, useCallback, useState, useEffect } from "react";
1
+ import { render, createElement, Instance as Instance$1, Fragment as Fragment$1 } from "@fragmentsx/render-core";
2
+ import require$$0, { createContext, useContext, useRef, useCallback, useState, useEffect } from "react";
3
3
  import "react/jsx-runtime";
4
- (function() {
5
- try {
6
- if (typeof document != "undefined") {
7
- var elementStyle = document.createElement("style");
8
- elementStyle.appendChild(document.createTextNode("._fragment_wbfy9_1 {\n width: 100%;\n height: 100%;\n}\n._text_1liuf_1 {\n white-space: pre;\n :where(p) {\n margin: 0;\n }\n}"));
9
- document.head.appendChild(elementStyle);
10
- }
11
- } catch (e2) {
12
- console.error("vite-plugin-css-injected-by-js", e2);
13
- }
14
- })();
15
- var f$1 = 0;
16
- function u$1(e2, t2, n2, o2, i2, u2) {
17
- t2 || (t2 = {});
18
- var a2, c2, p2 = t2;
19
- if ("ref" in p2) for (c2 in p2 = {}, t2) "ref" == c2 ? a2 = t2[c2] : p2[c2] = t2[c2];
20
- var l2 = { type: e2, props: p2, key: n2, ref: a2, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --f$1, __i: -1, __u: 0, __source: i2, __self: u2 };
21
- if ("function" == typeof e2 && (a2 = e2.defaultProps)) for (c2 in a2) void 0 === p2[c2] && (p2[c2] = a2[c2]);
22
- return options.vnode && options.vnode(l2), l2;
23
- }
24
- var t$1, r$1, u, i$1, o = 0, f = [], c = options, e = c.__b, a$1 = c.__r, v = c.diffed, l = c.__c, m = c.unmount, s$1 = c.__;
25
- function p$1(n2, t2) {
26
- c.__h && c.__h(r$1, n2, o || t2), o = 0;
27
- var u2 = r$1.__H || (r$1.__H = { __: [], __h: [] });
28
- return n2 >= u2.__.length && u2.__.push({}), u2.__[n2];
29
- }
30
- function d(n2) {
31
- return o = 1, h(D$2, n2);
32
- }
33
- function h(n2, u2, i2) {
34
- var o2 = p$1(t$1++, 2);
35
- if (o2.t = n2, !o2.__c && (o2.__ = [i2 ? i2(u2) : D$2(void 0, u2), function(n3) {
36
- var t2 = o2.__N ? o2.__N[0] : o2.__[0], r2 = o2.t(t2, n3);
37
- t2 !== r2 && (o2.__N = [r2, o2.__[1]], o2.__c.setState({}));
38
- }], o2.__c = r$1, !r$1.__f)) {
39
- var f2 = function(n3, t2, r2) {
40
- if (!o2.__c.__H) return true;
41
- var u3 = o2.__c.__H.__.filter(function(n4) {
42
- return !!n4.__c;
43
- });
44
- if (u3.every(function(n4) {
45
- return !n4.__N;
46
- })) return !c2 || c2.call(this, n3, t2, r2);
47
- var i3 = o2.__c.props !== n3;
48
- return u3.forEach(function(n4) {
49
- if (n4.__N) {
50
- var t3 = n4.__[0];
51
- n4.__ = n4.__N, n4.__N = void 0, t3 !== n4.__[0] && (i3 = true);
52
- }
53
- }), c2 && c2.call(this, n3, t2, r2) || i3;
54
- };
55
- r$1.__f = true;
56
- var c2 = r$1.shouldComponentUpdate, e2 = r$1.componentWillUpdate;
57
- r$1.componentWillUpdate = function(n3, t2, r2) {
58
- if (this.__e) {
59
- var u3 = c2;
60
- c2 = void 0, f2(n3, t2, r2), c2 = u3;
61
- }
62
- e2 && e2.call(this, n3, t2, r2);
63
- }, r$1.shouldComponentUpdate = f2;
64
- }
65
- return o2.__N || o2.__;
66
- }
67
- function y$2(n2, u2) {
68
- var i2 = p$1(t$1++, 3);
69
- !c.__s && C$1(i2.__H, u2) && (i2.__ = n2, i2.u = u2, r$1.__H.__h.push(i2));
70
- }
71
- function _(n2, u2) {
72
- var i2 = p$1(t$1++, 4);
73
- !c.__s && C$1(i2.__H, u2) && (i2.__ = n2, i2.u = u2, r$1.__h.push(i2));
74
- }
75
- function A$1(n2) {
76
- return o = 5, T$1(function() {
77
- return { current: n2 };
78
- }, []);
79
- }
80
- function F$1(n2, t2, r2) {
81
- o = 6, _(function() {
82
- if ("function" == typeof n2) {
83
- var r3 = n2(t2());
84
- return function() {
85
- n2(null), r3 && "function" == typeof r3 && r3();
86
- };
87
- }
88
- if (n2) return n2.current = t2(), function() {
89
- return n2.current = null;
90
- };
91
- }, null == r2 ? r2 : r2.concat(n2));
92
- }
93
- function T$1(n2, r2) {
94
- var u2 = p$1(t$1++, 7);
95
- return C$1(u2.__H, r2) && (u2.__ = n2(), u2.__H = r2, u2.__h = n2), u2.__;
96
- }
97
- function q$1(n2, t2) {
98
- return o = 8, T$1(function() {
99
- return n2;
100
- }, t2);
101
- }
102
- function x$1(n2) {
103
- var u2 = r$1.context[n2.__c], i2 = p$1(t$1++, 9);
104
- return i2.c = n2, u2 ? (null == i2.__ && (i2.__ = true, u2.sub(r$1)), u2.props.value) : n2.__;
105
- }
106
- function P$1(n2, t2) {
107
- c.useDebugValue && c.useDebugValue(t2 ? t2(n2) : n2);
108
- }
109
- function b$1(n2) {
110
- var u2 = p$1(t$1++, 10), i2 = d();
111
- return u2.__ = n2, r$1.componentDidCatch || (r$1.componentDidCatch = function(n3, t2) {
112
- u2.__ && u2.__(n3, t2), i2[1](n3);
113
- }), [i2[0], function() {
114
- i2[1](void 0);
115
- }];
116
- }
117
- function g$2() {
118
- var n2 = p$1(t$1++, 11);
119
- if (!n2.__) {
120
- for (var u2 = r$1.__v; null !== u2 && !u2.__m && null !== u2.__; ) u2 = u2.__;
121
- var i2 = u2.__m || (u2.__m = [0, 0]);
122
- n2.__ = "P" + i2[0] + "-" + i2[1]++;
123
- }
124
- return n2.__;
125
- }
126
- function j$2() {
127
- for (var n2; n2 = f.shift(); ) if (n2.__P && n2.__H) try {
128
- n2.__H.__h.forEach(z$1), n2.__H.__h.forEach(B$1), n2.__H.__h = [];
129
- } catch (t2) {
130
- n2.__H.__h = [], c.__e(t2, n2.__v);
131
- }
132
- }
133
- c.__b = function(n2) {
134
- r$1 = null, e && e(n2);
135
- }, c.__ = function(n2, t2) {
136
- n2 && t2.__k && t2.__k.__m && (n2.__m = t2.__k.__m), s$1 && s$1(n2, t2);
137
- }, c.__r = function(n2) {
138
- a$1 && a$1(n2), t$1 = 0;
139
- var i2 = (r$1 = n2.__c).__H;
140
- i2 && (u === r$1 ? (i2.__h = [], r$1.__h = [], i2.__.forEach(function(n3) {
141
- n3.__N && (n3.__ = n3.__N), n3.u = n3.__N = void 0;
142
- })) : (i2.__h.forEach(z$1), i2.__h.forEach(B$1), i2.__h = [], t$1 = 0)), u = r$1;
143
- }, c.diffed = function(n2) {
144
- v && v(n2);
145
- var t2 = n2.__c;
146
- t2 && t2.__H && (t2.__H.__h.length && (1 !== f.push(t2) && i$1 === c.requestAnimationFrame || ((i$1 = c.requestAnimationFrame) || w$1)(j$2)), t2.__H.__.forEach(function(n3) {
147
- n3.u && (n3.__H = n3.u), n3.u = void 0;
148
- })), u = r$1 = null;
149
- }, c.__c = function(n2, t2) {
150
- t2.some(function(n3) {
151
- try {
152
- n3.__h.forEach(z$1), n3.__h = n3.__h.filter(function(n4) {
153
- return !n4.__ || B$1(n4);
154
- });
155
- } catch (r2) {
156
- t2.some(function(n4) {
157
- n4.__h && (n4.__h = []);
158
- }), t2 = [], c.__e(r2, n3.__v);
159
- }
160
- }), l && l(n2, t2);
161
- }, c.unmount = function(n2) {
162
- m && m(n2);
163
- var t2, r2 = n2.__c;
164
- r2 && r2.__H && (r2.__H.__.forEach(function(n3) {
165
- try {
166
- z$1(n3);
167
- } catch (n4) {
168
- t2 = n4;
169
- }
170
- }), r2.__H = void 0, t2 && c.__e(t2, r2.__v));
171
- };
172
- var k$2 = "function" == typeof requestAnimationFrame;
173
- function w$1(n2) {
174
- var t2, r2 = function() {
175
- clearTimeout(u2), k$2 && cancelAnimationFrame(t2), setTimeout(n2);
176
- }, u2 = setTimeout(r2, 100);
177
- k$2 && (t2 = requestAnimationFrame(r2));
178
- }
179
- function z$1(n2) {
180
- var t2 = r$1, u2 = n2.__c;
181
- "function" == typeof u2 && (n2.__c = void 0, u2()), r$1 = t2;
182
- }
183
- function B$1(n2) {
184
- var t2 = r$1;
185
- n2.__c = n2.__(), r$1 = t2;
186
- }
187
- function C$1(n2, t2) {
188
- return !n2 || n2.length !== t2.length || t2.some(function(t3, r2) {
189
- return t3 !== n2[r2];
190
- });
191
- }
192
- function D$2(n2, t2) {
193
- return "function" == typeof t2 ? t2(n2) : t2;
194
- }
195
- function g$1(n2, t2) {
196
- for (var e2 in t2) n2[e2] = t2[e2];
197
- return n2;
198
- }
199
- function E$1(n2, t2) {
200
- for (var e2 in n2) if ("__source" !== e2 && !(e2 in t2)) return true;
201
- for (var r2 in t2) if ("__source" !== r2 && n2[r2] !== t2[r2]) return true;
202
- return false;
203
- }
204
- function C(n2, t2) {
205
- var e2 = t2(), r2 = d({ t: { __: e2, u: t2 } }), u2 = r2[0].t, o2 = r2[1];
206
- return _(function() {
207
- u2.__ = e2, u2.u = t2, x(u2) && o2({ t: u2 });
208
- }, [n2, e2, t2]), y$2(function() {
209
- return x(u2) && o2({ t: u2 }), n2(function() {
210
- x(u2) && o2({ t: u2 });
211
- });
212
- }, [n2]), e2;
213
- }
214
- function x(n2) {
215
- var t2, e2, r2 = n2.u, u2 = n2.__;
216
- try {
217
- var o2 = r2();
218
- return !((t2 = u2) === (e2 = o2) && (0 !== t2 || 1 / t2 == 1 / e2) || t2 != t2 && e2 != e2);
219
- } catch (n3) {
220
- return true;
221
- }
222
- }
223
- function R(n2) {
224
- n2();
225
- }
226
- function w(n2) {
227
- return n2;
228
- }
229
- function k$1() {
230
- return [false, R];
231
- }
232
- var I = _;
233
- function N(n2, t2) {
234
- this.props = n2, this.context = t2;
235
- }
236
- function M(n2, e2) {
237
- function r2(n3) {
238
- var t2 = this.props.ref, r3 = t2 == n3.ref;
239
- return !r3 && t2 && (t2.call ? t2(null) : t2.current = null), e2 ? !e2(this.props, n3) || !r3 : E$1(this.props, n3);
240
- }
241
- function u2(e3) {
242
- return this.shouldComponentUpdate = r2, createElement(n2, e3);
243
- }
244
- return u2.displayName = "Memo(" + (n2.displayName || n2.name) + ")", u2.prototype.isReactComponent = true, u2.__f = true, u2;
245
- }
246
- (N.prototype = new Component()).isPureReactComponent = true, N.prototype.shouldComponentUpdate = function(n2, t2) {
247
- return E$1(this.props, n2) || E$1(this.state, t2);
248
- };
249
- var T = options.__b;
250
- options.__b = function(n2) {
251
- n2.type && n2.type.__f && n2.ref && (n2.props.ref = n2.ref, n2.ref = null), T && T(n2);
252
- };
253
- var A = "undefined" != typeof Symbol && Symbol.for && Symbol.for("react.forward_ref") || 3911;
254
- function D$1(n2) {
255
- function t2(t3) {
256
- var e2 = g$1({}, t3);
257
- return delete e2.ref, n2(e2, t3.ref || null);
258
- }
259
- return t2.$$typeof = A, t2.render = t2, t2.prototype.isReactComponent = t2.__f = true, t2.displayName = "ForwardRef(" + (n2.displayName || n2.name) + ")", t2;
260
- }
261
- var L = function(n2, t2) {
262
- return null == n2 ? null : toChildArray(toChildArray(n2).map(t2));
263
- }, O = { map: L, forEach: L, count: function(n2) {
264
- return n2 ? toChildArray(n2).length : 0;
265
- }, only: function(n2) {
266
- var t2 = toChildArray(n2);
267
- if (1 !== t2.length) throw "Children.only";
268
- return t2[0];
269
- }, toArray: toChildArray }, F = options.__e;
270
- options.__e = function(n2, t2, e2, r2) {
271
- if (n2.then) {
272
- for (var u2, o2 = t2; o2 = o2.__; ) if ((u2 = o2.__c) && u2.__c) return null == t2.__e && (t2.__e = e2.__e, t2.__k = e2.__k), u2.__c(n2, t2);
273
- }
274
- F(n2, t2, e2, r2);
275
- };
276
- var U = options.unmount;
277
- function V(n2, t2, e2) {
278
- return n2 && (n2.__c && n2.__c.__H && (n2.__c.__H.__.forEach(function(n3) {
279
- "function" == typeof n3.__c && n3.__c();
280
- }), n2.__c.__H = null), null != (n2 = g$1({}, n2)).__c && (n2.__c.__P === e2 && (n2.__c.__P = t2), n2.__c = null), n2.__k = n2.__k && n2.__k.map(function(n3) {
281
- return V(n3, t2, e2);
282
- })), n2;
283
- }
284
- function W$1(n2, t2, e2) {
285
- return n2 && e2 && (n2.__v = null, n2.__k = n2.__k && n2.__k.map(function(n3) {
286
- return W$1(n3, t2, e2);
287
- }), n2.__c && n2.__c.__P === t2 && (n2.__e && e2.appendChild(n2.__e), n2.__c.__e = true, n2.__c.__P = e2)), n2;
288
- }
289
- function P() {
290
- this.__u = 0, this.o = null, this.__b = null;
291
- }
292
- function j$1(n2) {
293
- var t2 = n2.__.__c;
294
- return t2 && t2.__a && t2.__a(n2);
295
- }
296
- function z(n2) {
297
- var e2, r2, u2;
298
- function o2(o3) {
299
- if (e2 || (e2 = n2()).then(function(n3) {
300
- r2 = n3.default || n3;
301
- }, function(n3) {
302
- u2 = n3;
303
- }), u2) throw u2;
304
- if (!r2) throw e2;
305
- return createElement(r2, o3);
306
- }
307
- return o2.displayName = "Lazy", o2.__f = true, o2;
308
- }
309
- function B() {
310
- this.i = null, this.l = null;
311
- }
312
- options.unmount = function(n2) {
313
- var t2 = n2.__c;
314
- t2 && t2.__R && t2.__R(), t2 && 32 & n2.__u && (n2.type = null), U && U(n2);
315
- }, (P.prototype = new Component()).__c = function(n2, t2) {
316
- var e2 = t2.__c, r2 = this;
317
- null == r2.o && (r2.o = []), r2.o.push(e2);
318
- var u2 = j$1(r2.__v), o2 = false, i2 = function() {
319
- o2 || (o2 = true, e2.__R = null, u2 ? u2(c2) : c2());
320
- };
321
- e2.__R = i2;
322
- var c2 = function() {
323
- if (!--r2.__u) {
324
- if (r2.state.__a) {
325
- var n3 = r2.state.__a;
326
- r2.__v.__k[0] = W$1(n3, n3.__c.__P, n3.__c.__O);
327
- }
328
- var t3;
329
- for (r2.setState({ __a: r2.__b = null }); t3 = r2.o.pop(); ) t3.forceUpdate();
330
- }
331
- };
332
- r2.__u++ || 32 & t2.__u || r2.setState({ __a: r2.__b = r2.__v.__k[0] }), n2.then(i2, i2);
333
- }, P.prototype.componentWillUnmount = function() {
334
- this.o = [];
335
- }, P.prototype.render = function(n2, e2) {
336
- if (this.__b) {
337
- if (this.__v.__k) {
338
- var r2 = document.createElement("div"), o2 = this.__v.__k[0].__c;
339
- this.__v.__k[0] = V(this.__b, r2, o2.__O = o2.__P);
340
- }
341
- this.__b = null;
342
- }
343
- var i2 = e2.__a && createElement(Fragment$2, null, n2.fallback);
344
- return i2 && (i2.__u &= -33), [createElement(Fragment$2, null, e2.__a ? null : n2.children), i2];
345
- };
346
- var H = function(n2, t2, e2) {
347
- if (++e2[1] === e2[0] && n2.l.delete(t2), n2.props.revealOrder && ("t" !== n2.props.revealOrder[0] || !n2.l.size)) for (e2 = n2.i; e2; ) {
348
- for (; e2.length > 3; ) e2.pop()();
349
- if (e2[1] < e2[0]) break;
350
- n2.i = e2 = e2[2];
351
- }
352
- };
353
- function Z(n2) {
354
- return this.getChildContext = function() {
355
- return n2.context;
356
- }, n2.children;
357
- }
358
- function Y(n2) {
359
- var e2 = this, r2 = n2.h;
360
- e2.componentWillUnmount = function() {
361
- render(null, e2.v), e2.v = null, e2.h = null;
362
- }, e2.h && e2.h !== r2 && e2.componentWillUnmount(), e2.v || (e2.h = r2, e2.v = { nodeType: 1, parentNode: r2, childNodes: [], contains: function() {
363
- return true;
364
- }, appendChild: function(n3) {
365
- this.childNodes.push(n3), e2.h.appendChild(n3);
366
- }, insertBefore: function(n3, t2) {
367
- this.childNodes.push(n3), e2.h.insertBefore(n3, t2);
368
- }, removeChild: function(n3) {
369
- this.childNodes.splice(this.childNodes.indexOf(n3) >>> 1, 1), e2.h.removeChild(n3);
370
- } }), render(createElement(Z, { context: e2.context }, n2.__v), e2.v);
371
- }
372
- function $(n2, e2) {
373
- var r2 = createElement(Y, { __v: n2, h: e2 });
374
- return r2.containerInfo = e2, r2;
375
- }
376
- (B.prototype = new Component()).__a = function(n2) {
377
- var t2 = this, e2 = j$1(t2.__v), r2 = t2.l.get(n2);
378
- return r2[0]++, function(u2) {
379
- var o2 = function() {
380
- t2.props.revealOrder ? (r2.push(u2), H(t2, n2, r2)) : u2();
381
- };
382
- e2 ? e2(o2) : o2();
383
- };
384
- }, B.prototype.render = function(n2) {
385
- this.i = null, this.l = /* @__PURE__ */ new Map();
386
- var t2 = toChildArray(n2.children);
387
- n2.revealOrder && "b" === n2.revealOrder[0] && t2.reverse();
388
- for (var e2 = t2.length; e2--; ) this.l.set(t2[e2], this.i = [1, 0, this.i]);
389
- return n2.children;
390
- }, B.prototype.componentDidUpdate = B.prototype.componentDidMount = function() {
391
- var n2 = this;
392
- this.l.forEach(function(t2, e2) {
393
- H(n2, e2, t2);
394
- });
395
- };
396
- 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$1 = function(n2) {
397
- return ("undefined" != typeof Symbol && "symbol" == typeof Symbol() ? /fil|che|rad/ : /fil|che|ra/).test(n2);
398
- };
399
- function nn(n2, t2, e2) {
400
- return null == t2.__k && (t2.textContent = ""), render(n2, t2), "function" == typeof e2 && e2(), n2 ? n2.__c : null;
401
- }
402
- function tn(n2, t2, e2) {
403
- return hydrate(n2, t2), "function" == typeof e2 && e2(), n2 ? n2.__c : null;
404
- }
405
- Component.prototype.isReactComponent = {}, ["componentWillMount", "componentWillReceiveProps", "componentWillUpdate"].forEach(function(t2) {
406
- Object.defineProperty(Component.prototype, t2, { configurable: true, get: function() {
407
- return this["UNSAFE_" + t2];
408
- }, set: function(n2) {
409
- Object.defineProperty(this, t2, { configurable: true, writable: true, value: n2 });
410
- } });
411
- });
412
- var en = options.event;
413
- function rn() {
414
- }
415
- function un() {
416
- return this.cancelBubble;
417
- }
418
- function on() {
419
- return this.defaultPrevented;
420
- }
421
- options.event = function(n2) {
422
- return en && (n2 = en(n2)), n2.persist = rn, n2.isPropagationStopped = un, n2.isDefaultPrevented = on, n2.nativeEvent = n2;
423
- };
424
- var cn, ln = { enumerable: false, configurable: true, get: function() {
425
- return this.class;
426
- } }, fn = options.vnode;
427
- options.vnode = function(n2) {
428
- "string" == typeof n2.type && function(n3) {
429
- var t2 = n3.props, e2 = n3.type, u2 = {}, o2 = -1 === e2.indexOf("-");
430
- for (var i2 in t2) {
431
- var c2 = t2[i2];
432
- if (!("value" === i2 && "defaultValue" in t2 && null == c2 || Q && "children" === i2 && "noscript" === e2 || "class" === i2 || "className" === i2)) {
433
- var l2 = i2.toLowerCase();
434
- "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$1(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;
435
- }
436
- }
437
- "select" == e2 && u2.multiple && Array.isArray(u2.value) && (u2.value = toChildArray(t2.children).forEach(function(n4) {
438
- n4.props.selected = -1 != u2.value.indexOf(n4.props.value);
439
- })), "select" == e2 && null != u2.defaultValue && (u2.value = toChildArray(t2.children).forEach(function(n4) {
440
- n4.props.selected = u2.multiple ? -1 != u2.defaultValue.indexOf(n4.props.value) : u2.defaultValue == n4.props.value;
441
- })), 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;
442
- }(n2), n2.$$typeof = q, fn && fn(n2);
443
- };
444
- var an = options.__r;
445
- options.__r = function(n2) {
446
- an && an(n2), cn = n2.__c;
447
- };
448
- var sn = options.diffed;
449
- options.diffed = function(n2) {
450
- sn && sn(n2);
451
- var t2 = n2.props, e2 = n2.__e;
452
- null != e2 && "textarea" === n2.type && "value" in t2 && t2.value !== e2.value && (e2.value = null == t2.value ? "" : t2.value), cn = null;
453
- };
454
- var hn = { ReactCurrentDispatcher: { current: { readContext: function(n2) {
455
- return cn.__n[n2.__c].props.value;
456
- }, useCallback: q$1, useContext: x$1, useDebugValue: P$1, useDeferredValue: w, useEffect: y$2, useId: g$2, useImperativeHandle: F$1, useInsertionEffect: I, useLayoutEffect: _, useMemo: T$1, useReducer: h, useRef: A$1, useState: d, useSyncExternalStore: C, useTransition: k$1 } } }, vn = "18.3.1";
457
- function dn(n2) {
458
- return createElement.bind(null, n2);
459
- }
460
- function pn(n2) {
461
- return !!n2 && n2.$$typeof === q;
462
- }
463
- function mn(n2) {
464
- return pn(n2) && n2.type === Fragment$2;
465
- }
466
- function yn(n2) {
467
- return !!n2 && !!n2.displayName && ("string" == typeof n2.displayName || n2.displayName instanceof String) && n2.displayName.startsWith("Memo(");
468
- }
469
- function _n(n2) {
470
- return pn(n2) ? cloneElement.apply(null, arguments) : n2;
471
- }
472
- function bn(n2) {
473
- return !!n2.__k && (render(null, n2), true);
474
- }
475
- function Sn(n2) {
476
- return n2 && (n2.base || 1 === n2.nodeType && n2) || null;
477
- }
478
- var gn = function(n2, t2) {
479
- return n2(t2);
480
- }, En = function(n2, t2) {
481
- return n2(t2);
482
- }, Cn = Fragment$2, xn = pn, Rn = { useState: d, useId: g$2, useReducer: h, useEffect: y$2, useLayoutEffect: _, useInsertionEffect: I, useTransition: k$1, useDeferredValue: w, useSyncExternalStore: C, startTransition: R, useRef: A$1, useImperativeHandle: F$1, useMemo: T$1, useCallback: q$1, useContext: x$1, useDebugValue: P$1, version: "18.3.1", Children: O, render: nn, hydrate: tn, unmountComponentAtNode: bn, createPortal: $, createElement, createContext, createFactory: dn, cloneElement: _n, createRef, Fragment: Fragment$2, isValidElement: pn, isElement: xn, isFragment: mn, isMemo: yn, findDOMNode: Sn, Component, PureComponent: N, memo: M, forwardRef: D$1, flushSync: En, unstable_batchedUpdates: gn, StrictMode: Cn, Suspense: P, SuspenseList: B, lazy: z, __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: hn };
483
- const compat_module = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
484
- __proto__: null,
485
- Children: O,
486
- Component,
487
- Fragment: Fragment$2,
488
- PureComponent: N,
489
- StrictMode: Cn,
490
- Suspense: P,
491
- SuspenseList: B,
492
- __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: hn,
493
- cloneElement: _n,
494
- createContext,
495
- createElement,
496
- createFactory: dn,
497
- createPortal: $,
498
- createRef,
499
- default: Rn,
500
- findDOMNode: Sn,
501
- flushSync: En,
502
- forwardRef: D$1,
503
- hydrate: tn,
504
- isElement: xn,
505
- isFragment: mn,
506
- isMemo: yn,
507
- isValidElement: pn,
508
- lazy: z,
509
- memo: M,
510
- render: nn,
511
- startTransition: R,
512
- unmountComponentAtNode: bn,
513
- unstable_batchedUpdates: gn,
514
- useCallback: q$1,
515
- useContext: x$1,
516
- useDebugValue: P$1,
517
- useDeferredValue: w,
518
- useEffect: y$2,
519
- useErrorBoundary: b$1,
520
- useId: g$2,
521
- useImperativeHandle: F$1,
522
- useInsertionEffect: I,
523
- useLayoutEffect: _,
524
- useMemo: T$1,
525
- useReducer: h,
526
- useRef: A$1,
527
- useState: d,
528
- useSyncExternalStore: C,
529
- useTransition: k$1,
530
- version: vn
531
- }, Symbol.toStringTag, { value: "Module" }));
532
- function g(n2, t2) {
533
- let o2;
534
- return (...i2) => {
535
- window.clearTimeout(o2), o2 = window.setTimeout(() => n2(...i2), t2);
536
- };
537
- }
538
- function j({ debounce: n2, scroll: t2, polyfill: o2, offsetSize: i2 } = { debounce: 0, scroll: false, offsetSize: false }) {
539
- const a2 = o2 || (typeof window == "undefined" ? class {
540
- } : window.ResizeObserver);
541
- if (!a2) throw new Error("This browser does not support ResizeObserver out of the box. See: https://github.com/react-spring/react-use-measure/#resize-observer-polyfills");
542
- const [c2, h2] = d({ left: 0, top: 0, width: 0, height: 0, bottom: 0, right: 0, x: 0, y: 0 }), e2 = A$1({ element: null, scrollContainers: null, resizeObserver: null, lastBounds: c2, orientationHandler: null }), d$1 = n2 ? typeof n2 == "number" ? n2 : n2.scroll : null, f2 = n2 ? typeof n2 == "number" ? n2 : n2.resize : null, w2 = A$1(false);
543
- y$2(() => (w2.current = true, () => void (w2.current = false)));
544
- const [z2, m2, s2] = T$1(() => {
545
- const r2 = () => {
546
- if (!e2.current.element) return;
547
- const { left: y2, top: C2, width: H2, height: O2, bottom: S, right: x2, x: B2, y: R2 } = e2.current.element.getBoundingClientRect(), l2 = { left: y2, top: C2, width: H2, height: O2, bottom: S, right: x2, x: B2, y: R2 };
548
- e2.current.element instanceof HTMLElement && i2 && (l2.height = e2.current.element.offsetHeight, l2.width = e2.current.element.offsetWidth), Object.freeze(l2), w2.current && !D(e2.current.lastBounds, l2) && h2(e2.current.lastBounds = l2);
549
- };
550
- return [r2, f2 ? g(r2, f2) : r2, d$1 ? g(r2, d$1) : r2];
551
- }, [h2, i2, d$1, f2]);
552
- function v2() {
553
- e2.current.scrollContainers && (e2.current.scrollContainers.forEach((r2) => r2.removeEventListener("scroll", s2, true)), e2.current.scrollContainers = null), e2.current.resizeObserver && (e2.current.resizeObserver.disconnect(), e2.current.resizeObserver = null), e2.current.orientationHandler && ("orientation" in screen && "removeEventListener" in screen.orientation ? screen.orientation.removeEventListener("change", e2.current.orientationHandler) : "onorientationchange" in window && window.removeEventListener("orientationchange", e2.current.orientationHandler));
554
- }
555
- function b2() {
556
- e2.current.element && (e2.current.resizeObserver = new a2(s2), e2.current.resizeObserver.observe(e2.current.element), t2 && e2.current.scrollContainers && e2.current.scrollContainers.forEach((r2) => r2.addEventListener("scroll", s2, { capture: true, passive: true })), e2.current.orientationHandler = () => {
557
- s2();
558
- }, "orientation" in screen && "addEventListener" in screen.orientation ? screen.orientation.addEventListener("change", e2.current.orientationHandler) : "onorientationchange" in window && window.addEventListener("orientationchange", e2.current.orientationHandler));
559
- }
560
- const L2 = (r2) => {
561
- !r2 || r2 === e2.current.element || (v2(), e2.current.element = r2, e2.current.scrollContainers = E(r2), b2());
562
- };
563
- return X(s2, !!t2), W(m2), y$2(() => {
564
- v2(), b2();
565
- }, [t2, s2, m2]), y$2(() => v2, []), [L2, c2, z2];
566
- }
567
- function W(n2) {
568
- y$2(() => {
569
- const t2 = n2;
570
- return window.addEventListener("resize", t2), () => void window.removeEventListener("resize", t2);
571
- }, [n2]);
572
- }
573
- function X(n2, t2) {
574
- y$2(() => {
575
- if (t2) {
576
- const o2 = n2;
577
- return window.addEventListener("scroll", o2, { capture: true, passive: true }), () => void window.removeEventListener("scroll", o2, true);
578
- }
579
- }, [n2, t2]);
580
- }
581
- function E(n2) {
582
- const t2 = [];
583
- if (!n2 || n2 === document.body) return t2;
584
- const { overflow: o2, overflowX: i2, overflowY: a2 } = window.getComputedStyle(n2);
585
- return [o2, i2, a2].some((c2) => c2 === "auto" || c2 === "scroll") && t2.push(n2), [...t2, ...E(n2.parentElement)];
586
- }
587
- const k = ["x", "y", "top", "bottom", "left", "right", "width", "height"], D = (n2, t2) => k.every((o2) => n2[o2] === t2[o2]);
588
- function getAugmentedNamespace(n2) {
589
- if (n2.__esModule) return n2;
590
- var f2 = n2.default;
591
- if (typeof f2 == "function") {
592
- var a2 = function a3() {
593
- if (this instanceof a3) {
594
- return Reflect.construct(f2, arguments, this.constructor);
595
- }
596
- return f2.apply(this, arguments);
597
- };
598
- a2.prototype = f2.prototype;
599
- } else a2 = {};
600
- Object.defineProperty(a2, "__esModule", { value: true });
601
- Object.keys(n2).forEach(function(k2) {
602
- var d2 = Object.getOwnPropertyDescriptor(n2, k2);
603
- Object.defineProperty(a2, k2, d2.get ? d2 : {
604
- enumerable: true,
605
- get: function() {
606
- return n2[k2];
607
- }
608
- });
609
- });
610
- return a2;
611
- }
612
- var shim$1 = { exports: {} };
613
- var useSyncExternalStoreShim_production_min$1 = {};
614
- const require$$0 = /* @__PURE__ */ getAugmentedNamespace(compat_module);
615
- /**
616
- * @license React
617
- * use-sync-external-store-shim.production.min.js
618
- *
619
- * Copyright (c) Facebook, Inc. and its affiliates.
620
- *
621
- * This source code is licensed under the MIT license found in the
622
- * LICENSE file in the root directory of this source tree.
623
- */
624
- var hasRequiredUseSyncExternalStoreShim_production_min$1;
625
- function requireUseSyncExternalStoreShim_production_min$1() {
626
- if (hasRequiredUseSyncExternalStoreShim_production_min$1) return useSyncExternalStoreShim_production_min$1;
627
- hasRequiredUseSyncExternalStoreShim_production_min$1 = 1;
628
- var e2 = require$$0;
629
- function h2(a2, b2) {
630
- return a2 === b2 && (0 !== a2 || 1 / a2 === 1 / b2) || a2 !== a2 && b2 !== b2;
631
- }
632
- var k2 = "function" === typeof Object.is ? Object.is : h2, l2 = e2.useState, m2 = e2.useEffect, n2 = e2.useLayoutEffect, p2 = e2.useDebugValue;
633
- function q2(a2, b2) {
634
- var d2 = b2(), f2 = l2({ inst: { value: d2, getSnapshot: b2 } }), c2 = f2[0].inst, g2 = f2[1];
635
- n2(function() {
636
- c2.value = d2;
637
- c2.getSnapshot = b2;
638
- r2(c2) && g2({ inst: c2 });
639
- }, [a2, d2, b2]);
640
- m2(function() {
641
- r2(c2) && g2({ inst: c2 });
642
- return a2(function() {
643
- r2(c2) && g2({ inst: c2 });
644
- });
645
- }, [a2]);
646
- p2(d2);
647
- return d2;
648
- }
649
- function r2(a2) {
650
- var b2 = a2.getSnapshot;
651
- a2 = a2.value;
652
- try {
653
- var d2 = b2();
654
- return !k2(a2, d2);
655
- } catch (f2) {
656
- return true;
657
- }
658
- }
659
- function t2(a2, b2) {
660
- return b2();
661
- }
662
- var u2 = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? t2 : q2;
663
- useSyncExternalStoreShim_production_min$1.useSyncExternalStore = void 0 !== e2.useSyncExternalStore ? e2.useSyncExternalStore : u2;
664
- return useSyncExternalStoreShim_production_min$1;
665
- }
666
- var useSyncExternalStoreShim_development$1 = {};
667
- /**
668
- * @license React
669
- * use-sync-external-store-shim.development.js
670
- *
671
- * Copyright (c) Facebook, Inc. and its affiliates.
672
- *
673
- * This source code is licensed under the MIT license found in the
674
- * LICENSE file in the root directory of this source tree.
675
- */
676
- var hasRequiredUseSyncExternalStoreShim_development$1;
677
- function requireUseSyncExternalStoreShim_development$1() {
678
- if (hasRequiredUseSyncExternalStoreShim_development$1) return useSyncExternalStoreShim_development$1;
679
- hasRequiredUseSyncExternalStoreShim_development$1 = 1;
680
- if (process.env.NODE_ENV !== "production") {
681
- (function() {
682
- if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function") {
683
- __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
684
- }
685
- var React = require$$0;
686
- var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
687
- function error(format) {
688
- {
689
- {
690
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
691
- args[_key2 - 1] = arguments[_key2];
692
- }
693
- printWarning("error", format, args);
694
- }
695
- }
696
- }
697
- function printWarning(level, format, args) {
698
- {
699
- var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
700
- var stack = ReactDebugCurrentFrame.getStackAddendum();
701
- if (stack !== "") {
702
- format += "%s";
703
- args = args.concat([stack]);
704
- }
705
- var argsWithFormat = args.map(function(item) {
706
- return String(item);
707
- });
708
- argsWithFormat.unshift("Warning: " + format);
709
- Function.prototype.apply.call(console[level], console, argsWithFormat);
710
- }
711
- }
712
- function is(x2, y2) {
713
- return x2 === y2 && (x2 !== 0 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
714
- }
715
- var objectIs = typeof Object.is === "function" ? Object.is : is;
716
- var useState2 = React.useState, useEffect2 = React.useEffect, useLayoutEffect = React.useLayoutEffect, useDebugValue = React.useDebugValue;
717
- var didWarnOld18Alpha = false;
718
- var didWarnUncachedGetSnapshot = false;
719
- function useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
720
- {
721
- if (!didWarnOld18Alpha) {
722
- if (React.startTransition !== void 0) {
723
- didWarnOld18Alpha = true;
724
- error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release.");
725
- }
726
- }
727
- }
728
- var value = getSnapshot();
729
- {
730
- if (!didWarnUncachedGetSnapshot) {
731
- var cachedValue = getSnapshot();
732
- if (!objectIs(value, cachedValue)) {
733
- error("The result of getSnapshot should be cached to avoid an infinite loop");
734
- didWarnUncachedGetSnapshot = true;
735
- }
736
- }
737
- }
738
- var _useState = useState2({
739
- inst: {
740
- value,
741
- getSnapshot
742
- }
743
- }), inst = _useState[0].inst, forceUpdate = _useState[1];
744
- useLayoutEffect(function() {
745
- inst.value = value;
746
- inst.getSnapshot = getSnapshot;
747
- if (checkIfSnapshotChanged(inst)) {
748
- forceUpdate({
749
- inst
750
- });
751
- }
752
- }, [subscribe, value, getSnapshot]);
753
- useEffect2(function() {
754
- if (checkIfSnapshotChanged(inst)) {
755
- forceUpdate({
756
- inst
757
- });
758
- }
759
- var handleStoreChange = function() {
760
- if (checkIfSnapshotChanged(inst)) {
761
- forceUpdate({
762
- inst
763
- });
764
- }
765
- };
766
- return subscribe(handleStoreChange);
767
- }, [subscribe]);
768
- useDebugValue(value);
769
- return value;
770
- }
771
- function checkIfSnapshotChanged(inst) {
772
- var latestGetSnapshot = inst.getSnapshot;
773
- var prevValue = inst.value;
774
- try {
775
- var nextValue = latestGetSnapshot();
776
- return !objectIs(prevValue, nextValue);
777
- } catch (error2) {
778
- return true;
779
- }
780
- }
781
- function useSyncExternalStore$1(subscribe, getSnapshot, getServerSnapshot) {
782
- return getSnapshot();
783
- }
784
- var canUseDOM = !!(typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined");
785
- var isServerEnvironment = !canUseDOM;
786
- var shim2 = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore;
787
- var useSyncExternalStore$2 = React.useSyncExternalStore !== void 0 ? React.useSyncExternalStore : shim2;
788
- useSyncExternalStoreShim_development$1.useSyncExternalStore = useSyncExternalStore$2;
789
- if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop === "function") {
790
- __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
791
- }
792
- })();
793
- }
794
- return useSyncExternalStoreShim_development$1;
795
- }
796
- var hasRequiredShim$1;
797
- function requireShim$1() {
798
- if (hasRequiredShim$1) return shim$1.exports;
799
- hasRequiredShim$1 = 1;
800
- if (process.env.NODE_ENV === "production") {
801
- shim$1.exports = requireUseSyncExternalStoreShim_production_min$1();
802
- } else {
803
- shim$1.exports = requireUseSyncExternalStoreShim_development$1();
804
- }
805
- return shim$1.exports;
806
- }
807
- var shimExports$1 = requireShim$1();
808
- var withSelector$1 = { exports: {} };
809
- var withSelector_production_min$1 = {};
810
- /**
811
- * @license React
812
- * use-sync-external-store-shim/with-selector.production.min.js
813
- *
814
- * Copyright (c) Facebook, Inc. and its affiliates.
815
- *
816
- * This source code is licensed under the MIT license found in the
817
- * LICENSE file in the root directory of this source tree.
818
- */
819
- var hasRequiredWithSelector_production_min$1;
820
- function requireWithSelector_production_min$1() {
821
- if (hasRequiredWithSelector_production_min$1) return withSelector_production_min$1;
822
- hasRequiredWithSelector_production_min$1 = 1;
823
- var h2 = require$$0, n2 = requireShim$1();
824
- function p2(a2, b2) {
825
- return a2 === b2 && (0 !== a2 || 1 / a2 === 1 / b2) || a2 !== a2 && b2 !== b2;
826
- }
827
- var q2 = "function" === typeof Object.is ? Object.is : p2, r2 = n2.useSyncExternalStore, t2 = h2.useRef, u2 = h2.useEffect, v2 = h2.useMemo, w2 = h2.useDebugValue;
828
- withSelector_production_min$1.useSyncExternalStoreWithSelector = function(a2, b2, e2, l2, g2) {
829
- var c2 = t2(null);
830
- if (null === c2.current) {
831
- var f2 = { hasValue: false, value: null };
832
- c2.current = f2;
833
- } else f2 = c2.current;
834
- c2 = v2(function() {
835
- function a3(a4) {
836
- if (!c3) {
837
- c3 = true;
838
- d3 = a4;
839
- a4 = l2(a4);
840
- if (void 0 !== g2 && f2.hasValue) {
841
- var b3 = f2.value;
842
- if (g2(b3, a4)) return k2 = b3;
843
- }
844
- return k2 = a4;
845
- }
846
- b3 = k2;
847
- if (q2(d3, a4)) return b3;
848
- var e3 = l2(a4);
849
- if (void 0 !== g2 && g2(b3, e3)) return b3;
850
- d3 = a4;
851
- return k2 = e3;
852
- }
853
- var c3 = false, d3, k2, m2 = void 0 === e2 ? null : e2;
854
- return [function() {
855
- return a3(b2());
856
- }, null === m2 ? void 0 : function() {
857
- return a3(m2());
858
- }];
859
- }, [b2, e2, l2, g2]);
860
- var d2 = r2(a2, c2[0], c2[1]);
861
- u2(function() {
862
- f2.hasValue = true;
863
- f2.value = d2;
864
- }, [d2]);
865
- w2(d2);
866
- return d2;
867
- };
868
- return withSelector_production_min$1;
869
- }
870
- var withSelector_development$1 = {};
871
- /**
872
- * @license React
873
- * use-sync-external-store-shim/with-selector.development.js
874
- *
875
- * Copyright (c) Facebook, Inc. and its affiliates.
876
- *
877
- * This source code is licensed under the MIT license found in the
878
- * LICENSE file in the root directory of this source tree.
879
- */
880
- var hasRequiredWithSelector_development$1;
881
- function requireWithSelector_development$1() {
882
- if (hasRequiredWithSelector_development$1) return withSelector_development$1;
883
- hasRequiredWithSelector_development$1 = 1;
884
- if (process.env.NODE_ENV !== "production") {
885
- (function() {
886
- if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function") {
887
- __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
888
- }
889
- var React = require$$0;
890
- var shim2 = requireShim$1();
891
- function is(x2, y2) {
892
- return x2 === y2 && (x2 !== 0 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
893
- }
894
- var objectIs = typeof Object.is === "function" ? Object.is : is;
895
- var useSyncExternalStore = shim2.useSyncExternalStore;
896
- var useRef2 = React.useRef, useEffect2 = React.useEffect, useMemo = React.useMemo, useDebugValue = React.useDebugValue;
897
- function useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
898
- var instRef = useRef2(null);
899
- var inst;
900
- if (instRef.current === null) {
901
- inst = {
902
- hasValue: false,
903
- value: null
904
- };
905
- instRef.current = inst;
906
- } else {
907
- inst = instRef.current;
908
- }
909
- var _useMemo = useMemo(function() {
910
- var hasMemo = false;
911
- var memoizedSnapshot;
912
- var memoizedSelection;
913
- var memoizedSelector = function(nextSnapshot) {
914
- if (!hasMemo) {
915
- hasMemo = true;
916
- memoizedSnapshot = nextSnapshot;
917
- var _nextSelection = selector(nextSnapshot);
918
- if (isEqual !== void 0) {
919
- if (inst.hasValue) {
920
- var currentSelection = inst.value;
921
- if (isEqual(currentSelection, _nextSelection)) {
922
- memoizedSelection = currentSelection;
923
- return currentSelection;
924
- }
925
- }
926
- }
927
- memoizedSelection = _nextSelection;
928
- return _nextSelection;
929
- }
930
- var prevSnapshot = memoizedSnapshot;
931
- var prevSelection = memoizedSelection;
932
- if (objectIs(prevSnapshot, nextSnapshot)) {
933
- return prevSelection;
934
- }
935
- var nextSelection = selector(nextSnapshot);
936
- if (isEqual !== void 0 && isEqual(prevSelection, nextSelection)) {
937
- return prevSelection;
938
- }
939
- memoizedSnapshot = nextSnapshot;
940
- memoizedSelection = nextSelection;
941
- return nextSelection;
942
- };
943
- var maybeGetServerSnapshot = getServerSnapshot === void 0 ? null : getServerSnapshot;
944
- var getSnapshotWithSelector = function() {
945
- return memoizedSelector(getSnapshot());
946
- };
947
- var getServerSnapshotWithSelector = maybeGetServerSnapshot === null ? void 0 : function() {
948
- return memoizedSelector(maybeGetServerSnapshot());
949
- };
950
- return [getSnapshotWithSelector, getServerSnapshotWithSelector];
951
- }, [getSnapshot, getServerSnapshot, selector, isEqual]), getSelection = _useMemo[0], getServerSelection = _useMemo[1];
952
- var value = useSyncExternalStore(subscribe, getSelection, getServerSelection);
953
- useEffect2(function() {
954
- inst.hasValue = true;
955
- inst.value = value;
956
- }, [value]);
957
- useDebugValue(value);
958
- return value;
959
- }
960
- withSelector_development$1.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector;
961
- if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop === "function") {
962
- __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
963
- }
964
- })();
965
- }
966
- return withSelector_development$1;
967
- }
968
- var hasRequiredWithSelector$1;
969
- function requireWithSelector$1() {
970
- if (hasRequiredWithSelector$1) return withSelector$1.exports;
971
- hasRequiredWithSelector$1 = 1;
972
- if (process.env.NODE_ENV === "production") {
973
- withSelector$1.exports = requireWithSelector_production_min$1();
974
- } else {
975
- withSelector$1.exports = requireWithSelector_development$1();
976
- }
977
- return withSelector$1.exports;
978
- }
979
- requireWithSelector$1();
980
- var y$1 = (t2, e2, n2) => {
981
- var _a, _b;
982
- let r2 = A$1((_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, u2 = q$1((o2) => {
983
- var _a2, _b2;
984
- return s2 ? (r2.current = (_a2 = t2 == null ? void 0 : t2.resolve) == null ? void 0 : _a2.call(t2, s2, n2), o2(), (_b2 = t2 == null ? void 0 : t2.subscribe) == null ? void 0 : _b2.call(t2, s2, () => {
985
- var _a3;
986
- return r2.current = (_a3 = t2 == null ? void 0 : t2.resolve) == null ? void 0 : _a3.call(t2, s2, n2), o2();
987
- }, n2)) : () => {
988
- };
989
- }, [t2, s2]), i2 = q$1((o2) => {
990
- let p2 = typeof e2 == "string" ? e2 : t2.keyOfEntity(e2);
991
- e2 && p2 && t2.mutate(p2, o2);
992
- }, [t2, e2]), a2 = () => r2.current;
993
- return [shimExports$1.useSyncExternalStore(u2, a2, a2), i2];
994
- };
995
- const FragmentContext = createContext({
996
- manager: null
997
- });
998
- const FragmentProvider = ({ children, manager }) => {
999
- return /* @__PURE__ */ u$1(FragmentContext.Provider, { value: { manager }, children });
1000
- };
1001
- const useLayerChildren = (layerKey, customManager) => {
1002
- const { manager: fragmentManager } = x$1(FragmentContext);
1003
- const [layerData] = y$1(customManager ?? fragmentManager, layerKey);
1004
- return (layerData == null ? void 0 : layerData.children) ?? [];
1005
- };
1006
- var toPx = (val) => typeof val === "string" || typeof val === "number" ? `${val}px` : "0px";
1007
- var isEmptyValue = (value) => !value && (value === null || value === void 0);
1008
- var isValue = (value) => !isEmptyValue(value);
1009
- var createConstants$1 = (...constants) => {
1010
- return constants.reduce((acc, constant) => {
1011
- acc[constant] = constant;
1012
- return acc;
1013
- }, {});
1014
- };
1015
- var toKebabCase = (value) => value.replace(/[A-Z]+(?![a-z])|[A-Z]/g, ($2, ofs) => (ofs ? "-" : "") + $2.toLowerCase());
1016
- var pick = (obj, ...props) => {
1017
- return props.reduce((result, prop) => {
1018
- result[prop] = obj[prop];
1019
- return result;
1020
- }, {});
1021
- };
1022
- var generateId = () => Math.random().toString(16).slice(2);
1023
- const nodes$1 = createConstants$1(
1024
- "Fragment",
1025
- "FragmentInstance",
1026
- "Instance",
1027
- "Breakpoint",
1028
- "Frame",
1029
- "Image",
1030
- "Text",
1031
- "SolidPaintStyle",
1032
- "CssLink",
1033
- "Variable",
1034
- "ComputedValue",
1035
- "TransformValue"
1036
- );
1037
- const fragmentGrowingMode$1 = createConstants$1("auto", "fill");
1038
- const borderType$1 = createConstants$1("None", "Solid", "Dashed", "Dotted");
1039
- createConstants$1("_blank");
1040
- const paintMode$1 = createConstants$1("None", "Solid", "Image");
1041
- createConstants$1(
1042
- "Fill",
1043
- "Fit",
1044
- "Crop",
1045
- "Tile"
1046
- );
1047
- createConstants$1(
1048
- "Min",
1049
- "Center",
1050
- "Max",
1051
- "Stretch",
1052
- "Scale"
1053
- );
1054
- const positionType$1 = createConstants$1("absolute", "relative");
1055
- const sizing$1 = createConstants$1("Fixed", "Hug", "Fill", "Relative");
1056
- const layerMode$1 = createConstants$1("none", "flex");
1057
- const layerDirection$1 = createConstants$1("vertical", "horizontal");
1058
- createConstants$1("start", "center", "end");
1059
- createConstants$1(
1060
- "start",
1061
- "center",
1062
- "end",
1063
- "space-between",
1064
- "space-around"
1065
- );
1066
- createConstants$1(
1067
- "none",
1068
- "uppercase",
1069
- "lowercase",
1070
- "capitalize"
1071
- );
1072
- createConstants$1(
1073
- "none",
1074
- "underline",
1075
- "line-through"
1076
- );
1077
- createConstants$1("loop", "appear", "hover", "tap");
1078
- createConstants$1(
1079
- "fade",
1080
- "slide",
1081
- "bounce",
1082
- "wiggle",
1083
- "increase"
1084
- );
1085
- createConstants$1(
1086
- "String",
1087
- "Boolean",
1088
- "Array",
1089
- "Color",
1090
- "ComponentInstance",
1091
- "Date",
1092
- "Enum",
1093
- "Number",
1094
- "Object"
1095
- );
1096
- createConstants$1(
1097
- "normal",
1098
- "nowrap",
1099
- "pre",
1100
- "pre-wrap",
1101
- "pre-line",
1102
- "break-spaces"
1103
- );
1104
- createConstants$1("visible", "hidden", "scroll");
1105
- createConstants$1(
1106
- "convert",
1107
- "exists",
1108
- "equals",
1109
- "startWith",
1110
- "endWith",
1111
- "contains",
1112
- "dateBefore",
1113
- "dateAfter",
1114
- "dateBetween",
1115
- "feature",
1116
- "notFeature",
1117
- "gt",
1118
- // Greater than
1119
- "gte",
1120
- // Greater than or equals
1121
- "lt",
1122
- // Less than
1123
- "lte",
1124
- // Less than or equals,
1125
- "convertFromBoolean",
1126
- "negative"
1127
- );
1128
- const renderTarget$1 = createConstants$1("canvas", "document");
1129
- createConstants$1("viewport", "parent", "fixed");
1130
- var t = (e2) => !e2 && e2 == null, s = (e2) => !t(e2), y$3 = (e2) => typeof e2 == "object" && !Array.isArray(e2) && s(e2), a = (e2) => typeof Node == "object" ? e2 instanceof Node : e2 && typeof e2 == "object" && typeof e2.nodeType == "number" && typeof e2.nodeName == "string", p = (e2) => typeof e2 == "string" || n(e2), n = (e2) => typeof e2 == "object" && typeof e2._type == "string", r = (e2) => typeof e2 == "string" && e2.split(":").length >= 2, i = (e2) => typeof e2 != "object" && typeof e2 != "function" || e2 === null, b = (e2) => typeof e2 == "string" ? /<\/?[a-z][\s\S]*>/i.test(e2) : false;
1131
- var isLinkKey = (input) => r(input);
1132
- var isGraphOrKey = (input) => p(input);
1133
- var isGraph = (input) => n(input);
1134
- var isObject = (input) => y$3(input);
1135
- var shallowEqual = (a2, b2) => {
1136
- if (a2 === b2)
1137
- return true;
1138
- if (Array.isArray(a2) && Array.isArray(b2)) {
1139
- return a2.length === b2.length && a2.every((val, index2) => b2[index2] === val);
1140
- }
1141
- if (!isObject(a2) || !isObject(b2))
1142
- return false;
1143
- const keysA = Object.keys(a2);
1144
- const keysB = Object.keys(b2);
1145
- if (keysA.length !== keysB.length)
1146
- return false;
1147
- for (const key of keysA) {
1148
- if (!keysB.includes(key))
1149
- return false;
1150
- }
1151
- return true;
1152
- };
1153
- var unique = (...values) => Array.from(new Set(values));
1154
- var uniqueLinks = (...values) => values.filter((item, index2, arr) => r(item) ? arr.indexOf(item) === index2 : true);
1155
- var isPartialKey = (key) => key && key.split(".").length > 1;
1156
- var isPartOfGraph = (entityKey, graphKey) => {
1157
- if (!entityKey || !graphKey)
1158
- return false;
1159
- if (typeof entityKey !== "string" || typeof graphKey !== "string")
1160
- return null;
1161
- const [entityType, entityId] = entityKey.split(":");
1162
- const [graphType, graphId] = graphKey.split(":");
1163
- if (entityType !== graphType)
1164
- return false;
1165
- return entityId.startsWith(graphId);
1166
- };
1167
- var getGraphLink = (input) => {
1168
- if (isLinkKey(input)) {
1169
- if (isPartialKey(input)) {
1170
- return input.split(".")[0];
1171
- }
1172
- }
1173
- return input;
1174
- };
1175
- var createCache = () => {
1176
- const listeners = /* @__PURE__ */ new Map();
1177
- const types = /* @__PURE__ */ new Map();
1178
- const links = /* @__PURE__ */ new Map();
1179
- const parentRefs = /* @__PURE__ */ new Map();
1180
- const childrenRefs = /* @__PURE__ */ new Map();
1181
- const refCount = /* @__PURE__ */ new Map();
1182
- const gbLinks = /* @__PURE__ */ new Set([]);
1183
- const addRefs = (targetKey, depKey) => {
1184
- var _a;
1185
- parentRefs.set(targetKey, unique(...parentRefs.get(targetKey) || [], depKey));
1186
- childrenRefs.set(depKey, unique(...childrenRefs.get(depKey) ?? [], targetKey));
1187
- updateRefCountForLink(targetKey, ((_a = parentRefs.get(targetKey)) == null ? void 0 : _a.length) || 0);
1188
- };
1189
- const removeRefs = (targetKey, depKey) => {
1190
- var _a;
1191
- parentRefs.set(
1192
- depKey,
1193
- (parentRefs.get(depKey) || []).filter((key) => key !== targetKey)
1194
- );
1195
- childrenRefs.set(
1196
- targetKey,
1197
- (childrenRefs.get(targetKey) ?? []).filter((key) => key !== depKey)
1198
- );
1199
- updateRefCountForLink(depKey, ((_a = parentRefs.get(depKey)) == null ? void 0 : _a.length) || 0);
1200
- };
1201
- const getLinkedRefs = (key, stack = []) => {
1202
- const deps = parentRefs.get(key) || [];
1203
- stack.push(...deps);
1204
- const deepDeps = deps.map((ref) => getLinkedRefs(ref, stack)).flat();
1205
- stack.push(...deepDeps);
1206
- return Array.from(new Set(stack).values());
1207
- };
1208
- const invalidate = (key) => {
1209
- updateRefCountForLink(key, 0);
1210
- runGarbageCollector();
1211
- };
1212
- const readLink = (key) => {
1213
- if (key) {
1214
- return links.get(key);
1215
- }
1216
- return null;
1217
- };
1218
- const writeLink = (key, value, depKey) => {
1219
- var _a;
1220
- if (typeof key === "string") {
1221
- links.set(key, value);
1222
- const [type] = key.split(":");
1223
- if (!isPartialKey(key)) {
1224
- if (!types.has(type)) {
1225
- types.set(type, /* @__PURE__ */ new Set([key]));
1226
- } else {
1227
- (_a = types.get(type)) == null ? void 0 : _a.add(key);
1228
- }
1229
- }
1230
- }
1231
- if (depKey && key && key !== depKey) {
1232
- addRefs(key, depKey);
1233
- }
1234
- };
1235
- const hasLink = (key) => {
1236
- if (key) {
1237
- return links.has(key);
1238
- }
1239
- return false;
1240
- };
1241
- const updateRefCountForLink = (link, count) => {
1242
- if (Array.isArray(link)) {
1243
- link.forEach((link2, index2) => updateRefCountForLink(link2, index2));
1244
- } else {
1245
- const prevCount = refCount.get(link);
1246
- refCount.set(link, count);
1247
- if (!count) {
1248
- gbLinks.add(link);
1249
- } else if (!prevCount && count) {
1250
- gbLinks.delete(link);
1251
- }
1252
- }
1253
- };
1254
- const getLinkEntries = () => Array.from(links.entries());
1255
- const getRefCount = (link) => refCount.get(link) ?? 0;
1256
- const runGarbageCollector = () => {
1257
- var _a, _b;
1258
- for (const link of gbLinks.keys()) {
1259
- const count = getRefCount(link);
1260
- if (count > 0)
1261
- continue;
1262
- const currentValue = links.get(link);
1263
- gbLinks.delete(link);
1264
- links.delete(link);
1265
- refCount.delete(link);
1266
- const parents = parentRefs.get(link) ?? [];
1267
- const children = childrenRefs.get(link) ?? [];
1268
- parents.forEach((parentKey) => {
1269
- var _a2, _b2;
1270
- childrenRefs.set(parentKey, ((_b2 = (_a2 = childrenRefs.get(parentKey)) == null ? void 0 : _a2.filter) == null ? void 0 : _b2.call(_a2, (childLink) => childLink !== link)) ?? []);
1271
- });
1272
- children.forEach((childKey) => {
1273
- updateRefCountForLink(childKey, getRefCount(childKey) - 1);
1274
- });
1275
- const [type] = link.split(":");
1276
- if (!isPartialKey(link)) {
1277
- (_a = types.get(type)) == null ? void 0 : _a.delete(link);
1278
- if (!((_b = types.get(type)) == null ? void 0 : _b.size)) {
1279
- types.delete(type);
1280
- }
1281
- }
1282
- parentRefs.delete(link);
1283
- (listeners.get("onRemoveLink") ?? []).forEach((listener) => listener(link, currentValue ?? null));
1284
- }
1285
- };
1286
- return {
1287
- readLink,
1288
- writeLink,
1289
- hasLink,
1290
- getLinkEntries,
1291
- parentRefs,
1292
- childrenRefs,
1293
- addRefs,
1294
- removeRefs,
1295
- getChildren: (key) => childrenRefs.get(key),
1296
- getParents: (key) => parentRefs.get(key),
1297
- getLinkedRefs,
1298
- invalidate,
1299
- links,
1300
- types,
1301
- refCount,
1302
- runGarbageCollector,
1303
- onRemoveLink: (callback) => listeners.set("onRemoveLink", [...(listeners == null ? void 0 : listeners.get("onRemoveLink")) ?? [], callback])
1304
- };
1305
- };
1306
- var joinKeys = (...keys) => {
1307
- var _a;
1308
- return (_a = keys == null ? void 0 : keys.filter(Boolean)) == null ? void 0 : _a.join(".");
1309
- };
1310
- var isDev = process.env.NODE_ENV !== "production";
1311
- var createPluginsState = (initialPlugins = []) => {
1312
- const plugins = [];
1313
- const use = (plugin) => {
1314
- plugins.push(plugin);
1315
- };
1316
- const runPlugins = (state) => {
1317
- return plugins.reduce((graphState, plugin) => plugin(graphState) ?? graphState, state);
1318
- };
1319
- initialPlugins.forEach(use);
1320
- return {
1321
- use,
1322
- runPlugins
1323
- };
1324
- };
1325
- var isGraphState = (input) => {
1326
- if (!input)
1327
- return false;
1328
- if (isObject(input)) {
1329
- const fields = ["_id", "_type", "key", "mutate", "resolve"];
1330
- return fields.every((field) => field in input);
1331
- }
1332
- return false;
1333
- };
1334
- var createDebugState = () => {
1335
- const listeners = /* @__PURE__ */ new Set();
1336
- const onDebugEvent = (callback) => {
1337
- listeners.add(callback);
1338
- };
1339
- const debug = (event) => {
1340
- listeners.forEach((callback) => {
1341
- callback({ ...event, timestamp: Date.now() });
1342
- });
1343
- };
1344
- return {
1345
- debug,
1346
- onDebugEvent
1347
- };
1348
- };
1349
- var ID = 0;
1350
- var DEEP_LIMIT = 100;
1351
- var STATE_TYPE = "State";
1352
- var EACH_UPDATED = "$EACH:ROOT$";
1353
- var createState = (options2) => {
1354
- const id = (options2 == null ? void 0 : options2._id) ?? `${ID++}`;
1355
- const type = (options2 == null ? void 0 : options2._type) ?? STATE_TYPE;
1356
- const keys = (options2 == null ? void 0 : options2.keys) ?? {};
1357
- const stateKey = `${type}:${id}`;
1358
- const skipPredictors = [isGraphState, ...(options2 == null ? void 0 : options2.skip) ?? []];
1359
- const cache = createCache();
1360
- const debugState = createDebugState();
1361
- const pluginsStore = createPluginsState(options2 == null ? void 0 : options2.plugins);
1362
- const subscribers = /* @__PURE__ */ new Map();
1363
- let deepIndex = 0;
1364
- const isSkipped = (entity) => {
1365
- return skipPredictors.some((predictor) => predictor(entity));
1366
- };
1367
- const resolve = (input, options22) => {
1368
- const isDeep = (options22 == null ? void 0 : options22.deep) ?? false;
1369
- const isSafe = (options22 == null ? void 0 : options22.safe) ?? false;
1370
- const { selector, ...coreOptions } = options22 || {};
1371
- const inputKey = s(input) ? keyOfEntity(input) : null;
1372
- debugState.debug({ type: "resolve", entity: input, options: options22 });
1373
- let value = inputKey ? cache.readLink(inputKey) : null;
1374
- if (isSkipped(value))
1375
- return value;
1376
- if (isObject(value) || Array.isArray(value)) {
1377
- value = Object.entries(value).reduce((acc, [key, value2]) => {
1378
- let resultValue = value2;
1379
- if (!isSkipped(resultValue)) {
1380
- if (Array.isArray(value2)) {
1381
- resultValue = value2.map((v2) => {
1382
- if (isSkipped(v2))
1383
- return v2;
1384
- if (isLinkKey(v2) && !isSafe && !cache.hasLink(v2)) {
1385
- return null;
1386
- }
1387
- return isPartOfGraph(v2, inputKey) || isDeep ? safeResolve(v2, coreOptions) : v2;
1388
- });
1389
- if (!isSafe) {
1390
- resultValue = resultValue.filter(s);
1391
- }
1392
- } else {
1393
- if (isLinkKey(value2) && !isSafe && !cache.hasLink(value2)) {
1394
- resultValue = null;
1395
- } else if (isPartOfGraph(keyOfEntity(value2), inputKey) || isDeep) {
1396
- resultValue = safeResolve(value2, coreOptions);
1397
- }
1398
- }
1399
- }
1400
- acc[key] = resultValue;
1401
- return acc;
1402
- }, {});
1403
- }
1404
- return value ? selector ? selector({ ...value }) : { ...value } : isSafe ? input : null;
1405
- };
1406
- const safeResolve = (input, options22) => resolve(input, options22) ?? input;
1407
- const unlinkGraph = (entity) => {
1408
- const graphKey = keyOfEntity(entity);
1409
- if (graphKey) {
1410
- const deps = cache.getChildren(graphKey) || [];
1411
- deps.forEach((depLink) => {
1412
- if (!isPartialKey(depLink)) {
1413
- cache.removeRefs(graphKey, depLink);
1414
- }
1415
- });
1416
- }
1417
- };
1418
- const mutateField = (input, parentFieldKey, options22) => {
1419
- var _a, _b, _c, _d;
1420
- if ((!input || i(input)) && !isLinkKey(input) || isSkipped(input)) {
1421
- return input;
1422
- }
1423
- const inputLinkKey = isGraphOrKey(input) ? keyOfEntity(input) : input;
1424
- if (isLinkKey(inputLinkKey)) {
1425
- const parentGraph = getGraphLink(parentFieldKey) ?? "";
1426
- const parentPaths = ((_a = options22 == null ? void 0 : options22.internal) == null ? void 0 : _a.visitors.get(parentGraph)) ?? [];
1427
- const visitorsPaths = ((_b = options22 == null ? void 0 : options22.internal) == null ? void 0 : _b.visitors.get(inputLinkKey)) ?? [];
1428
- if (parentPaths.includes(inputLinkKey) || inputLinkKey === parentGraph) {
1429
- return null;
1430
- }
1431
- (_d = (_c = options22 == null ? void 0 : options22.internal) == null ? void 0 : _c.visitors) == null ? void 0 : _d.set(inputLinkKey, [...visitorsPaths, parentGraph]);
1432
- }
1433
- if (Array.isArray(input)) {
1434
- return input.map((item, index2) => {
1435
- const indexKey = parentFieldKey ? joinKeys(parentFieldKey, `${index2}`) : void 0;
1436
- return mutateField(item, indexKey, options22);
1437
- });
1438
- }
1439
- const entityKey = isLinkKey(input) ? input : isGraph(input) ? keyOfEntity(input) : null;
1440
- const childKey = entityKey ?? parentFieldKey;
1441
- const mutateMethod = (options22 == null ? void 0 : options22.overrideMutateMethod) || mutate;
1442
- return mutateMethod(childKey, input, options22);
1443
- };
1444
- const mutate = (entity, ...args) => {
1445
- const { graphKey: entityGraphKey, options: options22, data: rawData } = getArgumentsForMutate(entity, ...args);
1446
- debugState.debug({ type: "beforeMutate", entity: entityGraphKey, data: rawData, options: options22 });
1447
- const data = isLinkKey(rawData) ? entityOfKey(rawData) : rawData;
1448
- const graphKey = entityGraphKey ?? stateKey;
1449
- const partialKey = isPartialKey == null ? void 0 : isPartialKey(graphKey);
1450
- const parentKey = options22 == null ? void 0 : options22.parent;
1451
- const prevGraph = resolve(graphKey ?? "");
1452
- const internal = (options22 == null ? void 0 : options22.internal) || { hasChange: false, visitors: /* @__PURE__ */ new Map([]), updatedFields: [] };
1453
- let graphData = {
1454
- ...data,
1455
- ...entityOfKey(graphKey)
1456
- };
1457
- const isTopLevelGraph = !(options22 == null ? void 0 : options22.parent);
1458
- const isReplace = (options22 == null ? void 0 : options22.replace) ? typeof (options22 == null ? void 0 : options22.replace) === "function" ? options22.replace(graphData) : (options22 == null ? void 0 : options22.replace) === "deep" ? true : isTopLevelGraph || partialKey : false;
1459
- if (isSkipped(data)) {
1460
- cache.writeLink(graphKey, data, parentKey);
1461
- return graphKey;
1462
- }
1463
- if (!isReplace && isObject(prevGraph) && isObject(graphData)) {
1464
- graphData = {
1465
- ...prevGraph,
1466
- ...graphData
1467
- };
1468
- }
1469
- if (isReplace) {
1470
- unlinkGraph(graphKey);
1471
- }
1472
- const nextGraph = Object.entries(graphData).reduce((acc, [key, value]) => {
1473
- const fieldKey = joinKeys(graphKey, key);
1474
- let fieldValue = value;
1475
- const prevValue = prevGraph == null ? void 0 : prevGraph[key];
1476
- if (!isSkipped(fieldValue)) {
1477
- if (isObject(fieldValue) || Array.isArray(fieldValue) || isLinkKey(fieldValue)) {
1478
- fieldValue = mutateField(fieldValue, fieldKey, {
1479
- ...options22,
1480
- parent: graphKey,
1481
- internal
1482
- });
1483
- }
1484
- if (!isReplace && Array.isArray(fieldValue) && Array.isArray(prevValue)) {
1485
- fieldValue = [...prevValue, ...fieldValue];
1486
- }
1487
- if (Array.isArray(fieldValue) && (options22 == null ? void 0 : options22.dedup) !== false) {
1488
- fieldValue = uniqueLinks(...fieldValue);
1489
- }
1490
- }
1491
- const isEqual = shallowEqual(prevValue, fieldKey === fieldValue ? safeResolve(fieldValue) : fieldValue);
1492
- internal.hasChange = internal.hasChange || !isEqual;
1493
- if ((!parentKey || partialKey) && !isEqual) {
1494
- internal.updatedFields.push(partialKey ? graphKey : key);
1495
- }
1496
- if (!isReplace && isLinkKey(prevValue) && prevValue !== fieldValue) {
1497
- cache.removeRefs(graphKey, prevValue);
1498
- }
1499
- acc[key] = fieldValue;
1500
- return acc;
1501
- }, {});
1502
- cache.writeLink(graphKey, nextGraph, parentKey);
1503
- if (!parentKey) {
1504
- cache.runGarbageCollector();
1505
- }
1506
- if (internal.hasChange) {
1507
- notify(graphKey, prevGraph, internal.updatedFields);
1508
- }
1509
- debugState.debug({
1510
- type: "afterMutate",
1511
- entity: entityGraphKey,
1512
- data: rawData,
1513
- nextData: nextGraph,
1514
- options: options22,
1515
- hasChange: internal.hasChange
1516
- });
1517
- return graphKey;
1518
- };
1519
- const invalidate = (entity) => {
1520
- const key = keyOfEntity(entity);
1521
- debugState.debug({ type: "invalidate", entity: key });
1522
- if (key) {
1523
- const parents = cache.getParents(key) || [];
1524
- cache.invalidate(key);
1525
- parents.forEach((parentKey) => {
1526
- const prevParent = cache.readLink(parentKey);
1527
- const freshParent = resolve(parentKey, { safe: false });
1528
- cache.writeLink(parentKey, freshParent);
1529
- notify(parentKey, prevParent);
1530
- });
1531
- }
1532
- };
1533
- const notify = (entity, prevState, updatedFields = []) => {
1534
- var _a;
1535
- if (deepIndex > DEEP_LIMIT) {
1536
- throw new Error("Too deep notify.");
1537
- }
1538
- const key = keyOfEntity(entity);
1539
- debugState.debug({ type: "notify", entity: key });
1540
- if (key) {
1541
- deepIndex++;
1542
- const subs = subscribers.get(key) || [];
1543
- const deps = cache.getChildren(key) || [];
1544
- const nextResult = resolve(key);
1545
- const getSelectedValues = (selector) => {
1546
- const next = nextResult && (selector == null ? void 0 : selector(nextResult));
1547
- const prev = prevState && (selector == null ? void 0 : selector(prevState));
1548
- const hasChange = !!next !== !!prev || updatedFields.some((key2) => key2 in next);
1549
- return { next, prev, hasChange };
1550
- };
1551
- (_a = subscribers.get(EACH_UPDATED)) == null ? void 0 : _a.forEach(({ callback, selector }) => {
1552
- if (selector) {
1553
- const { next, prev, hasChange } = getSelectedValues(selector);
1554
- if (hasChange)
1555
- callback(next, prev);
1556
- } else {
1557
- callback(nextResult, prevState);
1558
- }
1559
- });
1560
- subs.forEach(({ callback, selector }) => {
1561
- if (selector) {
1562
- const { next, prev, hasChange } = getSelectedValues(selector);
1563
- if (hasChange)
1564
- callback(next, prev);
1565
- } else {
1566
- callback(nextResult, prevState);
1567
- }
1568
- });
1569
- deps.forEach((dep) => notify(dep, prevState));
1570
- }
1571
- deepIndex = 0;
1572
- };
1573
- const subscribe = (...args) => {
1574
- const input = typeof args[0] === "function" ? EACH_UPDATED : args[0];
1575
- const callback = typeof args[0] === "function" ? args[0] : args[1];
1576
- const options22 = typeof args[0] === "function" ? args[1] : args[2];
1577
- const key = keyOfEntity(input);
1578
- const selector = options22 == null ? void 0 : options22.selector;
1579
- if (key) {
1580
- if (subscribers.has(key)) {
1581
- subscribers.set(key, [...Array.from(subscribers.get(key) || []), { callback, selector }]);
1582
- } else {
1583
- subscribers.set(key, [{ callback, selector }]);
1584
- }
1585
- cache.onRemoveLink((link, prevValue) => {
1586
- if (link === key) {
1587
- notify(key, prevValue);
1588
- }
1589
- });
1590
- }
1591
- const unsubscribe = () => {
1592
- if (key) {
1593
- const subIndex = (subscribers.get(key) || []).findIndex((sub) => sub.callback === callback);
1594
- if (subIndex !== -1) {
1595
- const nextSubscribers = subscribers.get(key) || [];
1596
- nextSubscribers.splice(subIndex, 1);
1597
- subscribers.set(key, nextSubscribers);
1598
- }
1599
- }
1600
- };
1601
- if (options22 == null ? void 0 : options22.signal) {
1602
- options22.signal.addEventListener("abort", unsubscribe, { once: true });
1603
- }
1604
- return unsubscribe;
1605
- };
1606
- const inspectFields = (graphType) => [...cache.types.get(graphType) ?? []];
1607
- const resolveParents = (field) => {
1608
- const key = (typeof field === "string" ? field : keyOfEntity(field)) || "";
1609
- const refs = cache.getParents(key) ?? [];
1610
- return refs.map((ref) => resolve(ref));
1611
- };
1612
- const keyOfEntity = (entity) => {
1613
- var _a;
1614
- if (typeof entity === "string") {
1615
- return entityOfKey(entity) ? entity : null;
1616
- }
1617
- if (!(entity == null ? void 0 : entity._type)) {
1618
- return null;
1619
- }
1620
- let entityId = null;
1621
- if (entity._type in keys) {
1622
- entityId = ((_a = keys[entity._type]) == null ? void 0 : _a.call(keys, entity)) ?? null;
1623
- } else if (s(entity.id) || s(entity._id)) {
1624
- entityId = `${entity.id ?? entity._id}`;
1625
- }
1626
- return !entityId ? entityId : `${entity._type}:${entityId}`;
1627
- };
1628
- const entityOfKey = (entity) => {
1629
- if (isObject(entity) && (entity == null ? void 0 : entity._type) && keyOfEntity(entity)) {
1630
- return entity;
1631
- }
1632
- if (!entity || typeof entity !== "string")
1633
- return null;
1634
- const [typeName, ...restTypes] = entity.split(":");
1635
- if (!typeName || restTypes.length < 1)
1636
- return null;
1637
- return {
1638
- _type: typeName,
1639
- _id: restTypes.join(":")
1640
- };
1641
- };
1642
- const getArgumentsForMutate = (entity, ...args) => {
1643
- let data = typeof entity === "string" ? args[0] : entity;
1644
- if (typeof data === "function") {
1645
- data = data(resolve(entity));
1646
- } else if (isLinkKey(data)) {
1647
- data = entityOfKey(data);
1648
- }
1649
- return {
1650
- graphKey: typeof entity === "string" ? entity : keyOfEntity(entity),
1651
- options: typeof entity === "string" ? args[1] : args[0],
1652
- data
1653
- };
1654
- };
1655
- if (options2 == null ? void 0 : options2.initialState) {
1656
- mutate(options2.initialState, { replace: true });
1657
- }
1658
- const graphState = {
1659
- _type: type,
1660
- _id: id,
1661
- key: stateKey,
1662
- mutate,
1663
- subscribe,
1664
- resolve,
1665
- safeResolve,
1666
- resolveParents,
1667
- inspectFields,
1668
- invalidate,
1669
- keyOfEntity,
1670
- entityOfKey,
1671
- getArgumentsForMutate,
1672
- types: cache.types,
1673
- cache,
1674
- subscribers: isDev ? subscribers : void 0,
1675
- onDebugEvent: debugState.onDebugEvent
1676
- };
1677
- cache.onRemoveLink((link, prevValue) => debugState.debug({ type: "garbageRemove", entity: link, prevValue }));
1678
- return pluginsStore.runPlugins(graphState);
1679
- };
1680
- const createManager = (fragmentKey, initialDocument = {}) => {
1681
- const tempGraph = {
1682
- _type: "Temp",
1683
- _id: "root"
1684
- };
1685
- const springGraph = {
1686
- _type: "Spring",
1687
- _id: "root"
1688
- };
1689
- const manager = createState({
1690
- _type: "FragmentManager",
1691
- initialState: initialDocument,
1692
- plugins: [
1693
- (state) => {
1694
- state.$fragment = {
1695
- root: fragmentKey,
1696
- temp: "Temp:root"
1697
- };
1698
- }
1699
- ],
1700
- skip: [b, a]
1701
- });
1702
- manager.mutate(tempGraph);
1703
- manager.mutate(springGraph);
1704
- return manager;
1705
- };
1706
- const getFragmentQuery = (isSelf) => `
1707
- query FragmentDocument($fragmentSlug: Int!) {
1708
- ${isSelf ? "fragment" : "fragmentClient"}(fragmentIds: [$fragmentSlug]) {
1709
- id
1710
- document
1711
- linkedFragments {
1712
- id
1713
- document
1714
- }
1715
- }
1716
- }
1717
- `;
1718
- const getEmptyFragment = (fragmentId) => {
1719
- const layerId = generateId();
1720
- return {
1721
- [`Fragment:${fragmentId}`]: {
1722
- _type: "Fragment",
1723
- _id: fragmentId,
1724
- children: [`Frame:${layerId}`],
1725
- layoutSizingHorizontal: "Fixed",
1726
- layoutSizingVertical: "Fixed",
1727
- horizontalGrow: "auto",
1728
- verticalGrow: "auto",
1729
- renderMode: "parent",
1730
- opacity: 1,
1731
- visible: true,
1732
- overflow: "hidden",
1733
- overrides: [],
1734
- properties: ["Variable:62218c840bd111"]
1735
- },
1736
- [`Frame:${layerId}`]: {
1737
- _type: "Frame",
1738
- _id: layerId,
1739
- opacity: 1,
1740
- visible: true,
1741
- overflow: "visible",
1742
- children: [],
1743
- width: 320,
1744
- height: 200,
1745
- layoutSizingHorizontal: "Fixed",
1746
- layoutSizingVertical: "Fixed",
1747
- fillType: "Solid",
1748
- positionType: "absolute",
1749
- solidFill: "rgba(255, 255, 255, 1)",
1750
- name: "Frame",
1751
- isPrimary: true,
1752
- threshold: 320
1753
- }
1754
- };
1755
- };
1756
- const BASE_HEADERS = {
1757
- "Content-Type": "application/json"
1758
- };
1759
- const createFetcher = (baseUrl, defaultHeaders = {}) => {
1760
- const cache = /* @__PURE__ */ new Map();
1761
- const inflightRequests = /* @__PURE__ */ new Map();
1762
- const getCacheKey = (query2, variables, options2) => JSON.stringify({ query: query2, variables, options: options2 });
1763
- const query = async (query2, variables = {}, options2 = {}) => {
1764
- const cacheKey = getCacheKey(query2, variables, options2);
1765
- if (cache.has(cacheKey)) {
1766
- return cache.get(cacheKey);
1767
- }
1768
- if (inflightRequests.has(cacheKey)) {
1769
- return inflightRequests.get(cacheKey);
1770
- }
1771
- const request = fetch(baseUrl, {
1772
- ...options2,
1773
- method: "POST",
1774
- body: JSON.stringify({ query: query2, variables }),
1775
- headers: {
1776
- ...BASE_HEADERS,
1777
- ...defaultHeaders,
1778
- ...options2.headers
1779
- }
1780
- }).then(async (res) => {
1781
- if (!res.ok) throw new Error(`Fetch error: ${res.status}`);
1782
- const data = await res.json();
1783
- cache.set(cacheKey, data);
1784
- return data;
1785
- }).finally(() => {
1786
- inflightRequests.delete(cacheKey);
1787
- });
1788
- inflightRequests.set(cacheKey, request);
1789
- return request;
1790
- };
1791
- const invalidate = (endpoint, options2) => {
1792
- cache.delete(getCacheKey(endpoint, options2));
1793
- };
1794
- const clearCache = () => cache.clear();
1795
- return { query, invalidate, clearCache };
1796
- };
1797
- const createFetchManager = (apiToken, isSelf) => {
1798
- const fetcher = createFetcher("http://localhost/graphql", {
1799
- Authorization: `Bearer ${apiToken}`
1800
- });
1801
- return createState({
1802
- initialState: {},
1803
- plugins: [
1804
- (state) => {
1805
- state.cacheDocuments = /* @__PURE__ */ new Map();
1806
- state.queryFragment = async (fragmentId) => {
1807
- var _a, _b;
1808
- if (state.cacheDocuments.has(fragmentId)) {
1809
- return state.cacheDocuments.get(fragmentId);
1810
- }
1811
- const response = await fetcher.query(getFragmentQuery(isSelf), {
1812
- fragmentSlug: fragmentId
1813
- });
1814
- const fragment2 = (_b = (_a = response == null ? void 0 : response.data) == null ? void 0 : _a.fragment) == null ? void 0 : _b[0];
1815
- let fragmentDocument = fragment2 == null ? void 0 : fragment2.document;
1816
- if (typeof fragmentDocument === "string") {
1817
- try {
1818
- if (Object.keys(JSON.parse(fragmentDocument)).length === 0) {
1819
- fragmentDocument = getEmptyFragment(fragmentId);
1820
- }
1821
- } catch (e2) {
1822
- console.error(e2);
1823
- }
1824
- }
1825
- if (fragment2) {
1826
- state.cacheDocuments.set(fragmentId, fragmentDocument);
1827
- if (Array.isArray(fragment2.linkedFragments)) {
1828
- fragment2.linkedFragments.forEach(
1829
- (linkedFragment) => state.cacheDocuments.set(
1830
- linkedFragment.id,
1831
- linkedFragment.document
1832
- )
1833
- );
1834
- }
1835
- return state.cacheDocuments.get(fragmentId);
1836
- }
1837
- return null;
1838
- };
1839
- }
1840
- ]
1841
- });
1842
- };
1843
- const createGlobalManager = ({ apiToken, isSelf } = {}) => createState({
1844
- _type: "GlobalManager",
1845
- initialState: {
1846
- fetchManager: createFetchManager(apiToken, isSelf),
1847
- fragmentsManagers: {},
1848
- renderTarget: renderTarget$1.canvas
1849
- },
1850
- plugins: [
1851
- (state) => {
1852
- state.createFragmentManager = (fragmentId, document2) => {
1853
- var _a, _b;
1854
- const currentManager = (_b = (_a = state.resolve(state.key)) == null ? void 0 : _a.fragmentsManagers) == null ? void 0 : _b[fragmentId];
1855
- if (currentManager) {
1856
- return currentManager;
1857
- }
1858
- const manager = createManager(
1859
- `${nodes$1.Fragment}:${fragmentId}`,
1860
- document2
1861
- );
1862
- state.mutate(state.key, {
1863
- fragmentsManagers: {
1864
- [fragmentId]: manager
1865
- }
1866
- });
1867
- return manager;
1868
- };
1869
- state.setRenderTarget = (value) => {
1870
- state.mutate(state.key, {
1871
- renderTarget: value
1872
- });
1873
- };
1874
- }
1875
- ]
1876
- });
1877
- let GLOBAL_MANAGER = createGlobalManager();
1878
- const getGlobalManager = () => GLOBAL_MANAGER;
1879
- const GlobalManager$1 = createContext(getGlobalManager());
1880
- const useGlobalManager$1 = (globalManager) => {
1881
- const currentGlobalManager = x$1(GlobalManager$1);
1882
- const resultManager = globalManager ?? currentGlobalManager;
1883
- const [globalManagerGraph] = y$1(resultManager, resultManager == null ? void 0 : resultManager.key);
1884
- const getFragmentManager = async (id) => {
1885
- const fragmentDocument = await globalManagerGraph.fetchManager.queryFragment(id);
1886
- return resultManager.createFragmentManager(id, fragmentDocument);
1887
- };
1888
- const setRenderTarget = (value) => {
1889
- resultManager == null ? void 0 : resultManager.setRenderTarget(value);
1890
- };
1891
- return {
1892
- globalManagerGraph,
1893
- manager: resultManager,
1894
- getFragmentManager,
1895
- setRenderTarget
1896
- };
1897
- };
1898
- const useRenderTarget$1 = (globalManager) => {
1899
- const { globalManagerGraph, setRenderTarget } = useGlobalManager$1(globalManager);
1900
- const renderTargetValue = (globalManagerGraph == null ? void 0 : globalManagerGraph.renderTarget) ?? renderTarget$1.canvas;
1901
- return {
1902
- renderTarget: renderTargetValue,
1903
- isCanvas: renderTargetValue === renderTarget$1.canvas,
1904
- isDocument: renderTargetValue === renderTarget$1.document,
1905
- setRenderTarget: (target) => {
1906
- setRenderTarget(target);
1907
- }
1908
- };
1909
- };
1910
- const findBreakpoint = (breakpoints = [], width) => {
1911
- if (!(breakpoints == null ? void 0 : breakpoints.length)) return null;
1912
- const sortBreakpoints = breakpoints.toSorted(
1913
- (a2, b2) => a2.threshold - b2.threshold
1914
- );
1915
- return sortBreakpoints.reduce(
1916
- (prev, curr) => width >= curr.threshold ? curr : prev
1917
- );
1918
- };
1919
- const useFragmentManager$1 = (fragmentId, globalContext) => {
1920
- const { globalManagerGraph, manager } = useGlobalManager$1(globalContext);
1921
- if (!globalManagerGraph) {
1922
- throw new Error("Need declare global context");
1923
- }
1924
- const [loading, setLoading] = d(false);
1925
- const getFragmentManager = (id) => {
1926
- var _a;
1927
- return (_a = globalManagerGraph == null ? void 0 : globalManagerGraph.fragmentsManagers) == null ? void 0 : _a[id];
1928
- };
1929
- const loadFragmentManager = async (id) => {
1930
- setLoading(true);
1931
- const fragmentDocument = await globalManagerGraph.fetchManager.queryFragment(id);
1932
- const res = manager == null ? void 0 : manager.createFragmentManager(id, fragmentDocument);
1933
- setLoading(false);
1934
- return res;
1935
- };
1936
- y$2(() => {
1937
- loadFragmentManager(fragmentId);
1938
- }, [fragmentId]);
1939
- return {
1940
- loading,
1941
- manager: getFragmentManager(fragmentId)
1942
- };
1943
- };
1944
- const useFragment = (fragmentId, globalManager) => {
1945
- const { manager } = useFragmentManager$1(fragmentId, globalManager);
1946
- const layerKey = `${nodes$1.Fragment}:${fragmentId}`;
1947
- const [ref, fragmentRect] = j();
1948
- const children = useLayerChildren(layerKey, manager);
1949
- const { isDocument } = useRenderTarget$1(globalManager);
1950
- const resultChildren = T$1(() => {
1951
- if (isDocument && manager) {
1952
- const breakpoints = children == null ? void 0 : children.map(manager.resolve);
1953
- const activeBreakpoint = findBreakpoint(breakpoints, fragmentRect.width);
1954
- return activeBreakpoint ? [manager.keyOfEntity(activeBreakpoint)] : [];
1955
- }
1956
- return children;
1957
- }, [children, manager, fragmentRect.width]);
1958
- return {
1959
- manager,
1960
- ref,
1961
- children: resultChildren
1962
- };
1963
- };
1964
- const fragment = "_fragment_wbfy9_1";
1965
- const styles = {
1966
- fragment
1967
- };
1968
- const isVariableLink = (value) => {
1969
- var _a;
1970
- return isLink(value) && ((_a = value == null ? void 0 : value.split(":")) == null ? void 0 : _a.at(0)) === nodes$1.Variable;
1971
- };
1972
- const isLink = (value) => {
1973
- var _a, _b;
1974
- return value && ((_b = (_a = value == null ? void 0 : value.split) == null ? void 0 : _a.call(value, ":")) == null ? void 0 : _b.length) === 2;
1975
- };
1976
- const useFragmentProperties$1 = (fragmentId) => {
1977
- var _a;
1978
- const { manager } = useFragmentManager$1(fragmentId);
1979
- const [instanceFragment] = y$1(manager, (_a = manager == null ? void 0 : manager.$fragment) == null ? void 0 : _a.root);
1980
- return {
1981
- properties: (instanceFragment == null ? void 0 : instanceFragment.properties) ?? [],
1982
- manager
1983
- };
1984
- };
1985
- const useInstance = (instanceProps) => {
1986
- const { manager: parentManager } = x$1(FragmentContext);
1987
- const [instanceLayer] = y$1(parentManager, instanceProps.layerKey);
1988
- const instanceLayerProps = (instanceLayer == null ? void 0 : instanceLayer.props) ?? {};
1989
- const styles2 = useLayerStyles(instanceProps.layerKey);
1990
- const { manager: resultGlobalManager } = useGlobalManager$1(
1991
- instanceProps == null ? void 0 : instanceProps.globalManager
1992
- );
1993
- const resultProps = { ...instanceLayerProps, ...instanceProps.props ?? {} };
1994
- const resultFragmentId = (instanceProps == null ? void 0 : instanceProps.fragmentId) ?? (instanceLayer == null ? void 0 : instanceLayer.fragment);
1995
- const { properties: definitions2, manager: innerFragmentManager } = useFragmentProperties$1(resultFragmentId);
1996
- return {
1997
- styles: styles2,
1998
- definitions: definitions2,
1999
- props: resultProps,
2000
- parentManager,
2001
- innerManager: innerFragmentManager,
2002
- fragmentId: resultFragmentId,
2003
- globalManager: resultGlobalManager
2004
- };
2005
- };
2006
- const InstanceContext = createContext({
2007
- layerKey: null,
2008
- parentManager: null,
2009
- innerManager: null,
2010
- props: {},
2011
- definitions: []
2012
- });
2013
- const Instance$1 = (instanceProps) => {
2014
- const {
2015
- styles: styles2,
2016
- fragmentId,
2017
- parentManager,
2018
- props,
2019
- innerManager,
2020
- definitions: definitions2,
2021
- globalManager
2022
- } = useInstance(instanceProps);
2023
- return /* @__PURE__ */ u$1(
2024
- InstanceContext,
2025
- {
2026
- value: {
2027
- layerKey: instanceProps.layerKey,
2028
- definitions: definitions2,
2029
- innerManager,
2030
- parentManager,
2031
- props
2032
- },
2033
- children: parentManager ? /* @__PURE__ */ u$1("div", { "data-key": instanceProps.layerKey, style: styles2, children: /* @__PURE__ */ u$1(Fragment$1, { fragmentId, globalManager }) }) : /* @__PURE__ */ u$1(Fragment$1, { fragmentId, globalManager })
2034
- }
2035
- );
2036
- };
2037
- const useReadVariable = (variableKey) => {
2038
- const isVariable = isVariableLink(variableKey);
2039
- const { manager: fragmentManager } = x$1(FragmentContext);
2040
- const { props, innerManager, layerKey } = x$1(InstanceContext);
2041
- const resultManager = fragmentManager;
2042
- const { _id: propertyId } = (resultManager == null ? void 0 : resultManager.entityOfKey(variableKey)) ?? {};
2043
- const [variableLayer] = y$1(
2044
- isVariable ? fragmentManager : null,
2045
- variableKey,
2046
- {
2047
- selector: (graph) => graph ? pick(graph, "defaultValue", "required") : graph
2048
- }
2049
- );
2050
- const currentValue = (props == null ? void 0 : props[propertyId]) ?? null;
2051
- const required = (variableLayer == null ? void 0 : variableLayer.required) ?? false;
2052
- const defaultValue = (variableLayer == null ? void 0 : variableLayer.defaultValue) ?? null;
2053
- const resultValue = required ? currentValue : currentValue ?? defaultValue;
2054
- return {
2055
- value: resultValue,
2056
- layer: variableLayer
2057
- };
2058
- };
2059
- const getParent = (manager, layerKey) => {
2060
- var _a;
2061
- const parents = ((_a = manager == null ? void 0 : manager.resolveParents) == null ? void 0 : _a.call(manager, layerKey)) ?? [];
2062
- return parents == null ? void 0 : parents.find((parent) => {
2063
- var _a2;
2064
- return (_a2 = parent == null ? void 0 : parent.children) == null ? void 0 : _a2.includes(layerKey);
2065
- });
2066
- };
2067
- const isTopLevel = (manager, layerKey) => {
2068
- var _a;
2069
- return ((_a = getParent(manager, layerKey)) == null ? void 0 : _a._type) === nodes$1.Fragment;
2070
- };
2071
- const getAllParents = (manager, layerKey, stack = []) => {
2072
- const parent = getParent(manager, layerKey);
2073
- if (parent) {
2074
- stack.push(parent);
2075
- getAllParents(manager, manager.keyOfEntity(parent), stack);
2076
- }
2077
- return stack;
2078
- };
2079
- const isPartOfPrimary = (manager, layerKey) => {
2080
- var _a;
2081
- const allParents = getAllParents(manager, manager.keyOfEntity(layerKey));
2082
- const layer = manager.resolve(layerKey);
2083
- return (layer == null ? void 0 : layer.isPrimary) ?? !!((_a = allParents == null ? void 0 : allParents.find) == null ? void 0 : _a.call(allParents, (parent) => !!(parent == null ? void 0 : parent.isPrimary)));
2084
- };
2085
- const getOverrider = (manager, layer) => {
2086
- const layerKey = manager.keyOfEntity(layer);
2087
- const layerParents = manager.resolveParents(layerKey);
2088
- const isPartialPrimary = isPartOfPrimary(manager, layerKey);
2089
- return isPartialPrimary ? manager.resolve(layerKey) : layerParents == null ? void 0 : layerParents.find((parent) => {
2090
- var _a;
2091
- return (_a = parent == null ? void 0 : parent.overrides) == null ? void 0 : _a.includes(layerKey);
2092
- });
2093
- };
2094
- const createConstants$2 = (...constants) => {
2095
- return constants.reduce((acc, constant) => {
2096
- acc[constant] = constant;
2097
- return acc;
2098
- }, {});
2099
- };
2100
- const nodes$2 = createConstants$2(
2101
- "Fragment",
2102
- "FragmentInstance",
2103
- "Instance",
2104
- "Breakpoint",
2105
- "Frame",
2106
- "Image",
2107
- "Text",
2108
- "SolidPaintStyle",
2109
- "CssLink",
2110
- "Variable",
2111
- "ComputedValue",
2112
- "TransformValue"
2113
- );
2114
- const fragmentGrowingMode$2 = createConstants$2("auto", "fill");
2115
- const borderType$2 = createConstants$2("None", "Solid", "Dashed", "Dotted");
2116
- createConstants$2("_blank");
2117
- const paintMode$2 = createConstants$2("None", "Solid", "Image");
2118
- createConstants$2(
2119
- "Fill",
2120
- "Fit",
2121
- "Crop",
2122
- "Tile"
2123
- );
2124
- createConstants$2(
2125
- "Min",
2126
- "Center",
2127
- "Max",
2128
- "Stretch",
2129
- "Scale"
2130
- );
2131
- const positionType$2 = createConstants$2("absolute", "relative");
2132
- const sizing$2 = createConstants$2("Fixed", "Hug", "Fill", "Relative");
2133
- const layerMode$2 = createConstants$2("none", "flex");
2134
- const layerDirection$2 = createConstants$2("vertical", "horizontal");
2135
- const layerAlign$1 = createConstants$2("start", "center", "end");
2136
- const layerDistribute$1 = createConstants$2(
2137
- "start",
2138
- "center",
2139
- "end",
2140
- "space-between",
2141
- "space-around"
2142
- );
2143
- createConstants$2(
2144
- "none",
2145
- "uppercase",
2146
- "lowercase",
2147
- "capitalize"
2148
- );
2149
- createConstants$2(
2150
- "none",
2151
- "underline",
2152
- "line-through"
2153
- );
2154
- createConstants$2("loop", "appear", "hover", "tap");
2155
- createConstants$2(
2156
- "fade",
2157
- "slide",
2158
- "bounce",
2159
- "wiggle",
2160
- "increase"
2161
- );
2162
- const variableType$1 = createConstants$2(
2163
- "String",
2164
- "Boolean",
2165
- "Array",
2166
- "Color",
2167
- "ComponentInstance",
2168
- "Date",
2169
- "Enum",
2170
- "Number",
2171
- "Object"
2172
- );
2173
- createConstants$2(
2174
- "normal",
2175
- "nowrap",
2176
- "pre",
2177
- "pre-wrap",
2178
- "pre-line",
2179
- "break-spaces"
2180
- );
2181
- const overflow$1 = createConstants$2("visible", "hidden", "scroll");
2182
- createConstants$2(
2183
- "convert",
2184
- "exists",
2185
- "equals",
2186
- "startWith",
2187
- "endWith",
2188
- "contains",
2189
- "dateBefore",
2190
- "dateAfter",
2191
- "dateBetween",
2192
- "feature",
2193
- "notFeature",
2194
- "gt",
2195
- // Greater than
2196
- "gte",
2197
- // Greater than or equals
2198
- "lt",
2199
- // Less than
2200
- "lte",
2201
- // Less than or equals,
2202
- "convertFromBoolean",
2203
- "negative"
2204
- );
2205
- createConstants$2("canvas", "document");
2206
- createConstants$2("viewport", "parent", "fixed");
2207
- // @__NO_SIDE_EFFECTS__
2208
- function getGlobalConfig$1(config2) {
2209
- return {
2210
- lang: (config2 == null ? void 0 : config2.lang) ?? void 0,
2211
- message: config2 == null ? void 0 : config2.message,
2212
- abortEarly: (config2 == null ? void 0 : config2.abortEarly) ?? void 0,
2213
- abortPipeEarly: (config2 == null ? void 0 : config2.abortPipeEarly) ?? void 0
2214
- };
2215
- }
2216
- // @__NO_SIDE_EFFECTS__
2217
- function getGlobalMessage$1(lang) {
2218
- return void 0;
2219
- }
2220
- // @__NO_SIDE_EFFECTS__
2221
- function getSchemaMessage$1(lang) {
2222
- return void 0;
2223
- }
2224
- // @__NO_SIDE_EFFECTS__
2225
- function getSpecificMessage$1(reference, lang) {
2226
- var _a;
2227
- return (_a = void 0) == null ? void 0 : _a.get(lang);
2228
- }
2229
- // @__NO_SIDE_EFFECTS__
2230
- function _stringify$1(input) {
2231
- var _a, _b;
2232
- const type = typeof input;
2233
- if (type === "string") {
2234
- return `"${input}"`;
2235
- }
2236
- if (type === "number" || type === "bigint" || type === "boolean") {
2237
- return `${input}`;
2238
- }
2239
- if (type === "object" || type === "function") {
2240
- return (input && ((_b = (_a = Object.getPrototypeOf(input)) == null ? void 0 : _a.constructor) == null ? void 0 : _b.name)) ?? "null";
2241
- }
2242
- return type;
2243
- }
2244
- function _addIssue$1(context, label, dataset, config2, other) {
2245
- const input = other && "input" in other ? other.input : dataset.value;
2246
- const expected = (other == null ? void 0 : other.expected) ?? context.expects ?? null;
2247
- const received = (other == null ? void 0 : other.received) ?? /* @__PURE__ */ _stringify$1(input);
2248
- const issue = {
2249
- kind: context.kind,
2250
- type: context.type,
2251
- input,
2252
- expected,
2253
- received,
2254
- message: `Invalid ${label}: ${expected ? `Expected ${expected} but r` : "R"}eceived ${received}`,
2255
- requirement: context.requirement,
2256
- path: other == null ? void 0 : other.path,
2257
- issues: other == null ? void 0 : other.issues,
2258
- lang: config2.lang,
2259
- abortEarly: config2.abortEarly,
2260
- abortPipeEarly: config2.abortPipeEarly
2261
- };
2262
- const isSchema = context.kind === "schema";
2263
- const message = (other == null ? void 0 : other.message) ?? context.message ?? /* @__PURE__ */ getSpecificMessage$1(context.reference, issue.lang) ?? (isSchema ? /* @__PURE__ */ getSchemaMessage$1(issue.lang) : null) ?? config2.message ?? /* @__PURE__ */ getGlobalMessage$1(issue.lang);
2264
- if (message !== void 0) {
2265
- issue.message = typeof message === "function" ? (
2266
- // @ts-expect-error
2267
- message(issue)
2268
- ) : message;
2269
- }
2270
- if (isSchema) {
2271
- dataset.typed = false;
2272
- }
2273
- if (dataset.issues) {
2274
- dataset.issues.push(issue);
2275
- } else {
2276
- dataset.issues = [issue];
2277
- }
2278
- }
2279
- // @__NO_SIDE_EFFECTS__
2280
- function _getStandardProps$1(context) {
2281
- return {
2282
- version: 1,
2283
- vendor: "valibot",
2284
- validate(value2) {
2285
- return context["~run"]({ value: value2 }, /* @__PURE__ */ getGlobalConfig$1());
2286
- }
2287
- };
2288
- }
2289
- // @__NO_SIDE_EFFECTS__
2290
- function _isValidObjectKey$1(object2, key) {
2291
- return Object.hasOwn(object2, key) && key !== "__proto__" && key !== "prototype" && key !== "constructor";
2292
- }
2293
- // @__NO_SIDE_EFFECTS__
2294
- function _joinExpects$1(values2, separator) {
2295
- const list = [...new Set(values2)];
2296
- if (list.length > 1) {
2297
- return `(${list.join(` ${separator} `)})`;
2298
- }
2299
- return list[0] ?? "never";
2300
- }
2301
- // @__NO_SIDE_EFFECTS__
2302
- function isOfKind(kind, object2) {
2303
- return object2.kind === kind;
2304
- }
2305
- var ValiError = class extends Error {
2306
- /**
2307
- * Creates a Valibot error with useful information.
2308
- *
2309
- * @param issues The error issues.
2310
- */
2311
- constructor(issues) {
2312
- super(issues[0].message);
2313
- this.name = "ValiError";
2314
- this.issues = issues;
2315
- }
2316
- };
2317
- // @__NO_SIDE_EFFECTS__
2318
- function check$1(requirement, message) {
2319
- return {
2320
- kind: "validation",
2321
- type: "check",
2322
- reference: check$1,
2323
- async: false,
2324
- expects: null,
2325
- requirement,
2326
- message,
2327
- "~run"(dataset, config2) {
2328
- if (dataset.typed && !this.requirement(dataset.value)) {
2329
- _addIssue$1(this, "input", dataset, config2);
2330
- }
2331
- return dataset;
2332
- }
2333
- };
2334
- }
2335
- // @__NO_SIDE_EFFECTS__
2336
- function maxValue$1(requirement, message) {
2337
- return {
2338
- kind: "validation",
2339
- type: "max_value",
2340
- reference: maxValue$1,
2341
- async: false,
2342
- expects: `<=${requirement instanceof Date ? requirement.toJSON() : /* @__PURE__ */ _stringify$1(requirement)}`,
2343
- requirement,
2344
- message,
2345
- "~run"(dataset, config2) {
2346
- if (dataset.typed && !(dataset.value <= this.requirement)) {
2347
- _addIssue$1(this, "value", dataset, config2, {
2348
- received: dataset.value instanceof Date ? dataset.value.toJSON() : /* @__PURE__ */ _stringify$1(dataset.value)
2349
- });
2350
- }
2351
- return dataset;
2352
- }
2353
- };
2354
- }
2355
- // @__NO_SIDE_EFFECTS__
2356
- function metadata$1(metadata_) {
2357
- return {
2358
- kind: "metadata",
2359
- type: "metadata",
2360
- reference: metadata$1,
2361
- metadata: metadata_
2362
- };
2363
- }
2364
- // @__NO_SIDE_EFFECTS__
2365
- function minValue$1(requirement, message) {
2366
- return {
2367
- kind: "validation",
2368
- type: "min_value",
2369
- reference: minValue$1,
2370
- async: false,
2371
- expects: `>=${requirement instanceof Date ? requirement.toJSON() : /* @__PURE__ */ _stringify$1(requirement)}`,
2372
- requirement,
2373
- message,
2374
- "~run"(dataset, config2) {
2375
- if (dataset.typed && !(dataset.value >= this.requirement)) {
2376
- _addIssue$1(this, "value", dataset, config2, {
2377
- received: dataset.value instanceof Date ? dataset.value.toJSON() : /* @__PURE__ */ _stringify$1(dataset.value)
2378
- });
2379
- }
2380
- return dataset;
2381
- }
2382
- };
2383
- }
2384
- // @__NO_SIDE_EFFECTS__
2385
- function getFallback$1(schema, dataset, config2) {
2386
- return typeof schema.fallback === "function" ? (
2387
- // @ts-expect-error
2388
- schema.fallback(dataset, config2)
2389
- ) : (
2390
- // @ts-expect-error
2391
- schema.fallback
2392
- );
2393
- }
2394
- // @__NO_SIDE_EFFECTS__
2395
- function getDefault$1(schema, dataset, config2) {
2396
- return typeof schema.default === "function" ? (
2397
- // @ts-expect-error
2398
- schema.default(dataset, config2)
2399
- ) : (
2400
- // @ts-expect-error
2401
- schema.default
2402
- );
2403
- }
2404
- // @__NO_SIDE_EFFECTS__
2405
- function array$1(item, message) {
2406
- return {
2407
- kind: "schema",
2408
- type: "array",
2409
- reference: array$1,
2410
- expects: "Array",
2411
- async: false,
2412
- item,
2413
- message,
2414
- get "~standard"() {
2415
- return /* @__PURE__ */ _getStandardProps$1(this);
2416
- },
2417
- "~run"(dataset, config2) {
2418
- var _a;
2419
- const input = dataset.value;
2420
- if (Array.isArray(input)) {
2421
- dataset.typed = true;
2422
- dataset.value = [];
2423
- for (let key = 0; key < input.length; key++) {
2424
- const value2 = input[key];
2425
- const itemDataset = this.item["~run"]({ value: value2 }, config2);
2426
- if (itemDataset.issues) {
2427
- const pathItem = {
2428
- type: "array",
2429
- origin: "value",
2430
- input,
2431
- key,
2432
- value: value2
2433
- };
2434
- for (const issue of itemDataset.issues) {
2435
- if (issue.path) {
2436
- issue.path.unshift(pathItem);
2437
- } else {
2438
- issue.path = [pathItem];
2439
- }
2440
- (_a = dataset.issues) == null ? void 0 : _a.push(issue);
2441
- }
2442
- if (!dataset.issues) {
2443
- dataset.issues = itemDataset.issues;
2444
- }
2445
- if (config2.abortEarly) {
2446
- dataset.typed = false;
2447
- break;
2448
- }
2449
- }
2450
- if (!itemDataset.typed) {
2451
- dataset.typed = false;
2452
- }
2453
- dataset.value.push(itemDataset.value);
2454
- }
2455
- } else {
2456
- _addIssue$1(this, "type", dataset, config2);
2457
- }
2458
- return dataset;
2459
- }
2460
- };
2461
- }
2462
- // @__NO_SIDE_EFFECTS__
2463
- function boolean$1(message) {
2464
- return {
2465
- kind: "schema",
2466
- type: "boolean",
2467
- reference: boolean$1,
2468
- expects: "boolean",
2469
- async: false,
2470
- message,
2471
- get "~standard"() {
2472
- return /* @__PURE__ */ _getStandardProps$1(this);
2473
- },
2474
- "~run"(dataset, config2) {
2475
- if (typeof dataset.value === "boolean") {
2476
- dataset.typed = true;
2477
- } else {
2478
- _addIssue$1(this, "type", dataset, config2);
2479
- }
2480
- return dataset;
2481
- }
2482
- };
2483
- }
2484
- // @__NO_SIDE_EFFECTS__
2485
- function enum_$1(enum__, message) {
2486
- const options2 = [];
2487
- for (const key in enum__) {
2488
- if (`${+key}` !== key || typeof enum__[key] !== "string" || !Object.is(enum__[enum__[key]], +key)) {
2489
- options2.push(enum__[key]);
2490
- }
2491
- }
2492
- return {
2493
- kind: "schema",
2494
- type: "enum",
2495
- reference: enum_$1,
2496
- expects: /* @__PURE__ */ _joinExpects$1(options2.map(_stringify$1), "|"),
2497
- async: false,
2498
- enum: enum__,
2499
- options: options2,
2500
- message,
2501
- get "~standard"() {
2502
- return /* @__PURE__ */ _getStandardProps$1(this);
2503
- },
2504
- "~run"(dataset, config2) {
2505
- if (this.options.includes(dataset.value)) {
2506
- dataset.typed = true;
2507
- } else {
2508
- _addIssue$1(this, "type", dataset, config2);
2509
- }
2510
- return dataset;
2511
- }
2512
- };
2513
- }
2514
- // @__NO_SIDE_EFFECTS__
2515
- function literal$1(literal_, message) {
2516
- return {
2517
- kind: "schema",
2518
- type: "literal",
2519
- reference: literal$1,
2520
- expects: /* @__PURE__ */ _stringify$1(literal_),
2521
- async: false,
2522
- literal: literal_,
2523
- message,
2524
- get "~standard"() {
2525
- return /* @__PURE__ */ _getStandardProps$1(this);
2526
- },
2527
- "~run"(dataset, config2) {
2528
- if (dataset.value === this.literal) {
2529
- dataset.typed = true;
2530
- } else {
2531
- _addIssue$1(this, "type", dataset, config2);
2532
- }
2533
- return dataset;
2534
- }
2535
- };
2536
- }
2537
- // @__NO_SIDE_EFFECTS__
2538
- function number$1(message) {
2539
- return {
2540
- kind: "schema",
2541
- type: "number",
2542
- reference: number$1,
2543
- expects: "number",
2544
- async: false,
2545
- message,
2546
- get "~standard"() {
2547
- return /* @__PURE__ */ _getStandardProps$1(this);
2548
- },
2549
- "~run"(dataset, config2) {
2550
- if (typeof dataset.value === "number" && !isNaN(dataset.value)) {
2551
- dataset.typed = true;
2552
- } else {
2553
- _addIssue$1(this, "type", dataset, config2);
2554
- }
2555
- return dataset;
2556
- }
2557
- };
2558
- }
2559
- // @__NO_SIDE_EFFECTS__
2560
- function object$1(entries, message) {
2561
- return {
2562
- kind: "schema",
2563
- type: "object",
2564
- reference: object$1,
2565
- expects: "Object",
2566
- async: false,
2567
- entries,
2568
- message,
2569
- get "~standard"() {
2570
- return /* @__PURE__ */ _getStandardProps$1(this);
2571
- },
2572
- "~run"(dataset, config2) {
2573
- var _a;
2574
- const input = dataset.value;
2575
- if (input && typeof input === "object") {
2576
- dataset.typed = true;
2577
- dataset.value = {};
2578
- for (const key in this.entries) {
2579
- const valueSchema = this.entries[key];
2580
- if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && // @ts-expect-error
2581
- valueSchema.default !== void 0) {
2582
- const value2 = key in input ? (
2583
- // @ts-expect-error
2584
- input[key]
2585
- ) : /* @__PURE__ */ getDefault$1(valueSchema);
2586
- const valueDataset = valueSchema["~run"]({ value: value2 }, config2);
2587
- if (valueDataset.issues) {
2588
- const pathItem = {
2589
- type: "object",
2590
- origin: "value",
2591
- input,
2592
- key,
2593
- value: value2
2594
- };
2595
- for (const issue of valueDataset.issues) {
2596
- if (issue.path) {
2597
- issue.path.unshift(pathItem);
2598
- } else {
2599
- issue.path = [pathItem];
2600
- }
2601
- (_a = dataset.issues) == null ? void 0 : _a.push(issue);
2602
- }
2603
- if (!dataset.issues) {
2604
- dataset.issues = valueDataset.issues;
2605
- }
2606
- if (config2.abortEarly) {
2607
- dataset.typed = false;
2608
- break;
2609
- }
2610
- }
2611
- if (!valueDataset.typed) {
2612
- dataset.typed = false;
2613
- }
2614
- dataset.value[key] = valueDataset.value;
2615
- } else if (valueSchema.fallback !== void 0) {
2616
- dataset.value[key] = /* @__PURE__ */ getFallback$1(valueSchema);
2617
- } else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
2618
- _addIssue$1(this, "key", dataset, config2, {
2619
- input: void 0,
2620
- expected: `"${key}"`,
2621
- path: [
2622
- {
2623
- type: "object",
2624
- origin: "key",
2625
- input,
2626
- key,
2627
- // @ts-expect-error
2628
- value: input[key]
2629
- }
2630
- ]
2631
- });
2632
- if (config2.abortEarly) {
2633
- break;
2634
- }
2635
- }
2636
- }
2637
- } else {
2638
- _addIssue$1(this, "type", dataset, config2);
2639
- }
2640
- return dataset;
2641
- }
2642
- };
2643
- }
2644
- // @__NO_SIDE_EFFECTS__
2645
- function optional$1(wrapped, default_) {
2646
- return {
2647
- kind: "schema",
2648
- type: "optional",
2649
- reference: optional$1,
2650
- expects: `(${wrapped.expects} | undefined)`,
2651
- async: false,
2652
- wrapped,
2653
- default: default_,
2654
- get "~standard"() {
2655
- return /* @__PURE__ */ _getStandardProps$1(this);
2656
- },
2657
- "~run"(dataset, config2) {
2658
- if (dataset.value === void 0) {
2659
- if (this.default !== void 0) {
2660
- dataset.value = /* @__PURE__ */ getDefault$1(this, dataset, config2);
2661
- }
2662
- if (dataset.value === void 0) {
2663
- dataset.typed = true;
2664
- return dataset;
2665
- }
2666
- }
2667
- return this.wrapped["~run"](dataset, config2);
2668
- }
2669
- };
2670
- }
2671
- // @__NO_SIDE_EFFECTS__
2672
- function picklist$1(options2, message) {
2673
- return {
2674
- kind: "schema",
2675
- type: "picklist",
2676
- reference: picklist$1,
2677
- expects: /* @__PURE__ */ _joinExpects$1(options2.map(_stringify$1), "|"),
2678
- async: false,
2679
- options: options2,
2680
- message,
2681
- get "~standard"() {
2682
- return /* @__PURE__ */ _getStandardProps$1(this);
2683
- },
2684
- "~run"(dataset, config2) {
2685
- if (this.options.includes(dataset.value)) {
2686
- dataset.typed = true;
2687
- } else {
2688
- _addIssue$1(this, "type", dataset, config2);
2689
- }
2690
- return dataset;
2691
- }
2692
- };
2693
- }
2694
- // @__NO_SIDE_EFFECTS__
2695
- function record$1(key, value2, message) {
2696
- return {
2697
- kind: "schema",
2698
- type: "record",
2699
- reference: record$1,
2700
- expects: "Object",
2701
- async: false,
2702
- key,
2703
- value: value2,
2704
- message,
2705
- get "~standard"() {
2706
- return /* @__PURE__ */ _getStandardProps$1(this);
2707
- },
2708
- "~run"(dataset, config2) {
2709
- var _a, _b;
2710
- const input = dataset.value;
2711
- if (input && typeof input === "object") {
2712
- dataset.typed = true;
2713
- dataset.value = {};
2714
- for (const entryKey in input) {
2715
- if (/* @__PURE__ */ _isValidObjectKey$1(input, entryKey)) {
2716
- const entryValue = input[entryKey];
2717
- const keyDataset = this.key["~run"]({ value: entryKey }, config2);
2718
- if (keyDataset.issues) {
2719
- const pathItem = {
2720
- type: "object",
2721
- origin: "key",
2722
- input,
2723
- key: entryKey,
2724
- value: entryValue
2725
- };
2726
- for (const issue of keyDataset.issues) {
2727
- issue.path = [pathItem];
2728
- (_a = dataset.issues) == null ? void 0 : _a.push(issue);
2729
- }
2730
- if (!dataset.issues) {
2731
- dataset.issues = keyDataset.issues;
2732
- }
2733
- if (config2.abortEarly) {
2734
- dataset.typed = false;
2735
- break;
2736
- }
2737
- }
2738
- const valueDataset = this.value["~run"](
2739
- { value: entryValue },
2740
- config2
2741
- );
2742
- if (valueDataset.issues) {
2743
- const pathItem = {
2744
- type: "object",
2745
- origin: "value",
2746
- input,
2747
- key: entryKey,
2748
- value: entryValue
2749
- };
2750
- for (const issue of valueDataset.issues) {
2751
- if (issue.path) {
2752
- issue.path.unshift(pathItem);
2753
- } else {
2754
- issue.path = [pathItem];
2755
- }
2756
- (_b = dataset.issues) == null ? void 0 : _b.push(issue);
2757
- }
2758
- if (!dataset.issues) {
2759
- dataset.issues = valueDataset.issues;
2760
- }
2761
- if (config2.abortEarly) {
2762
- dataset.typed = false;
2763
- break;
2764
- }
2765
- }
2766
- if (!keyDataset.typed || !valueDataset.typed) {
2767
- dataset.typed = false;
2768
- }
2769
- if (keyDataset.typed) {
2770
- dataset.value[keyDataset.value] = valueDataset.value;
2771
- }
2772
- }
2773
- }
2774
- } else {
2775
- _addIssue$1(this, "type", dataset, config2);
2776
- }
2777
- return dataset;
2778
- }
2779
- };
2780
- }
2781
- // @__NO_SIDE_EFFECTS__
2782
- function string$1(message) {
2783
- return {
2784
- kind: "schema",
2785
- type: "string",
2786
- reference: string$1,
2787
- expects: "string",
2788
- async: false,
2789
- message,
2790
- get "~standard"() {
2791
- return /* @__PURE__ */ _getStandardProps$1(this);
2792
- },
2793
- "~run"(dataset, config2) {
2794
- if (typeof dataset.value === "string") {
2795
- dataset.typed = true;
2796
- } else {
2797
- _addIssue$1(this, "type", dataset, config2);
2798
- }
2799
- return dataset;
2800
- }
2801
- };
2802
- }
2803
- // @__NO_SIDE_EFFECTS__
2804
- function _subIssues$1(datasets) {
2805
- let issues;
2806
- if (datasets) {
2807
- for (const dataset of datasets) {
2808
- if (issues) {
2809
- issues.push(...dataset.issues);
2810
- } else {
2811
- issues = dataset.issues;
2812
- }
2813
- }
2814
- }
2815
- return issues;
2816
- }
2817
- // @__NO_SIDE_EFFECTS__
2818
- function union$1(options2, message) {
2819
- return {
2820
- kind: "schema",
2821
- type: "union",
2822
- reference: union$1,
2823
- expects: /* @__PURE__ */ _joinExpects$1(
2824
- options2.map((option) => option.expects),
2825
- "|"
2826
- ),
2827
- async: false,
2828
- options: options2,
2829
- message,
2830
- get "~standard"() {
2831
- return /* @__PURE__ */ _getStandardProps$1(this);
2832
- },
2833
- "~run"(dataset, config2) {
2834
- let validDataset;
2835
- let typedDatasets;
2836
- let untypedDatasets;
2837
- for (const schema of this.options) {
2838
- const optionDataset = schema["~run"]({ value: dataset.value }, config2);
2839
- if (optionDataset.typed) {
2840
- if (optionDataset.issues) {
2841
- if (typedDatasets) {
2842
- typedDatasets.push(optionDataset);
2843
- } else {
2844
- typedDatasets = [optionDataset];
2845
- }
2846
- } else {
2847
- validDataset = optionDataset;
2848
- break;
2849
- }
2850
- } else {
2851
- if (untypedDatasets) {
2852
- untypedDatasets.push(optionDataset);
2853
- } else {
2854
- untypedDatasets = [optionDataset];
2855
- }
2856
- }
2857
- }
2858
- if (validDataset) {
2859
- return validDataset;
2860
- }
2861
- if (typedDatasets) {
2862
- if (typedDatasets.length === 1) {
2863
- return typedDatasets[0];
2864
- }
2865
- _addIssue$1(this, "type", dataset, config2, {
2866
- issues: /* @__PURE__ */ _subIssues$1(typedDatasets)
2867
- });
2868
- dataset.typed = true;
2869
- } else if ((untypedDatasets == null ? void 0 : untypedDatasets.length) === 1) {
2870
- return untypedDatasets[0];
2871
- } else {
2872
- _addIssue$1(this, "type", dataset, config2, {
2873
- issues: /* @__PURE__ */ _subIssues$1(untypedDatasets)
2874
- });
2875
- }
2876
- return dataset;
2877
- }
2878
- };
2879
- }
2880
- function parse(schema, input, config2) {
2881
- const dataset = schema["~run"]({ value: input }, /* @__PURE__ */ getGlobalConfig$1(config2));
2882
- if (dataset.issues) {
2883
- throw new ValiError(dataset.issues);
2884
- }
2885
- return dataset.value;
2886
- }
2887
- // @__NO_SIDE_EFFECTS__
2888
- function pipe$1(...pipe2) {
2889
- return {
2890
- ...pipe2[0],
2891
- pipe: pipe2,
2892
- get "~standard"() {
2893
- return /* @__PURE__ */ _getStandardProps$1(this);
2894
- },
2895
- "~run"(dataset, config2) {
2896
- for (const item of pipe2) {
2897
- if (item.kind !== "metadata") {
2898
- if (dataset.issues && (item.kind === "schema" || item.kind === "transformation")) {
2899
- dataset.typed = false;
2900
- break;
2901
- }
2902
- if (!dataset.issues || !config2.abortEarly && !config2.abortPipeEarly) {
2903
- dataset = item["~run"](dataset, config2);
2904
- }
2905
- }
2906
- }
2907
- return dataset;
2908
- }
2909
- };
2910
- }
2911
- const linkValidator$1 = /* @__PURE__ */ check$1(
2912
- (value) => {
2913
- var _a, _b;
2914
- return !!value && ((_b = (_a = value == null ? void 0 : value.split) == null ? void 0 : _a.call(value, ":")) == null ? void 0 : _b.length) === 2;
2915
- }
2916
- );
2917
- const getMetadata = (schema) => {
2918
- var _a;
2919
- const pipelines = (schema == null ? void 0 : schema.pipe) ?? [];
2920
- return ((_a = pipelines == null ? void 0 : pipelines.find((pipe2) => /* @__PURE__ */ isOfKind("metadata", pipe2))) == null ? void 0 : _a.metadata) ?? null;
2921
- };
2922
- const layerField$1 = (schema, meta) => {
2923
- const modifiedSchema = (meta == null ? void 0 : meta.variable) ? /* @__PURE__ */ union$1([schema, /* @__PURE__ */ pipe$1(/* @__PURE__ */ string$1(), linkValidator$1)]) : schema;
2924
- return /* @__PURE__ */ pipe$1(/* @__PURE__ */ optional$1(modifiedSchema), /* @__PURE__ */ metadata$1(meta ?? {}));
2925
- };
2926
- const ChildrenSchema$1 = /* @__PURE__ */ object$1({
2927
- children: layerField$1(/* @__PURE__ */ array$1(/* @__PURE__ */ string$1()), {
2928
- fallback: [],
2929
- overridable: false
2930
- })
2931
- });
2932
- const GraphFieldSchema$1 = /* @__PURE__ */ object$1({
2933
- _id: /* @__PURE__ */ union$1([/* @__PURE__ */ string$1(), /* @__PURE__ */ number$1()]),
2934
- _type: /* @__PURE__ */ picklist$1(Object.keys(nodes$2))
2935
- });
2936
- const OverridesSchema$1 = /* @__PURE__ */ object$1({
2937
- overrides: layerField$1(/* @__PURE__ */ array$1(/* @__PURE__ */ string$1()), { overridable: false })
2938
- });
2939
- const PositionSchema$1 = /* @__PURE__ */ object$1({
2940
- position: layerField$1(/* @__PURE__ */ enum_$1(Object.keys(positionType$2)), {
2941
- fallback: positionType$2.absolute
2942
- }),
2943
- top: layerField$1(/* @__PURE__ */ number$1(), { fallback: 0 }),
2944
- left: layerField$1(/* @__PURE__ */ number$1(), { fallback: 0 })
2945
- });
2946
- const SceneSchema$1 = /* @__PURE__ */ object$1({
2947
- opacity: layerField$1(/* @__PURE__ */ pipe$1(/* @__PURE__ */ number$1(), /* @__PURE__ */ minValue$1(0), /* @__PURE__ */ maxValue$1(1)), {
2948
- fallback: 1,
2949
- variable: true
2950
- }),
2951
- visible: layerField$1(/* @__PURE__ */ boolean$1(), { fallback: true, variable: true }),
2952
- zIndex: layerField$1(/* @__PURE__ */ number$1(), { fallback: -1 }),
2953
- borderRadius: layerField$1(/* @__PURE__ */ string$1(), { fallback: "0px" }),
2954
- overflow: layerField$1(/* @__PURE__ */ picklist$1(Object.keys(overflow$1)), {
2955
- fallback: overflow$1.hidden
2956
- })
2957
- });
2958
- const FillSchema$1 = /* @__PURE__ */ object$1({
2959
- fillType: layerField$1(/* @__PURE__ */ picklist$1(Object.keys(paintMode$2)), {
2960
- fallback: paintMode$2.None
2961
- }),
2962
- solidFill: layerField$1(/* @__PURE__ */ string$1(), { fallback: "#fff" })
2963
- });
2964
- const BorderSchema$1 = /* @__PURE__ */ object$1({
2965
- borderType: layerField$1(/* @__PURE__ */ picklist$1(Object.keys(borderType$2)), {
2966
- fallback: borderType$2.None
2967
- }),
2968
- borderWidth: layerField$1(/* @__PURE__ */ pipe$1(/* @__PURE__ */ number$1(), /* @__PURE__ */ minValue$1(0)), { fallback: 0 }),
2969
- borderColor: layerField$1(/* @__PURE__ */ string$1(), { fallback: "#fff" })
2970
- });
2971
- const SizeSchema$1 = /* @__PURE__ */ object$1({
2972
- widthType: layerField$1(/* @__PURE__ */ picklist$1(Object.keys(sizing$2)), {
2973
- fallback: sizing$2.Fixed
2974
- }),
2975
- heightType: layerField$1(/* @__PURE__ */ picklist$1(Object.keys(sizing$2)), {
2976
- fallback: sizing$2.Fixed
2977
- }),
2978
- width: layerField$1(/* @__PURE__ */ pipe$1(/* @__PURE__ */ number$1(), /* @__PURE__ */ minValue$1(0)), { fallback: 0 }),
2979
- height: layerField$1(/* @__PURE__ */ pipe$1(/* @__PURE__ */ number$1(), /* @__PURE__ */ minValue$1(0)), { fallback: 0 }),
2980
- aspectRatio: layerField$1(/* @__PURE__ */ number$1(), { fallback: -1 })
2981
- });
2982
- const LayerSchema$1 = /* @__PURE__ */ object$1({
2983
- layerMode: layerField$1(/* @__PURE__ */ picklist$1(Object.keys(layerMode$2)), {
2984
- fallback: layerMode$2.none
2985
- }),
2986
- layerAlign: layerField$1(/* @__PURE__ */ picklist$1(Object.keys(layerAlign$1)), {
2987
- fallback: layerAlign$1.start
2988
- }),
2989
- layerDirection: layerField$1(/* @__PURE__ */ picklist$1(Object.keys(layerDirection$2)), {
2990
- fallback: layerDirection$2.horizontal
2991
- }),
2992
- layerDistribute: layerField$1(/* @__PURE__ */ picklist$1(Object.keys(layerDistribute$1)), {
2993
- fallback: layerDistribute$1.start
2994
- }),
2995
- layerWrap: layerField$1(/* @__PURE__ */ boolean$1(), { fallback: false }),
2996
- layerGap: layerField$1(/* @__PURE__ */ pipe$1(/* @__PURE__ */ number$1(), /* @__PURE__ */ minValue$1(0)), { fallback: 0 }),
2997
- padding: layerField$1(/* @__PURE__ */ string$1(), { fallback: "0px" })
2998
- });
2999
- const FrameSchema = /* @__PURE__ */ pipe$1(
3000
- /* @__PURE__ */ object$1({
3001
- name: layerField$1(/* @__PURE__ */ string$1(), { fallback: "Frame", overridable: false }),
3002
- isBreakpoint: layerField$1(/* @__PURE__ */ boolean$1(), {
3003
- fallback: false,
3004
- overridable: false
3005
- }),
3006
- isPrimary: layerField$1(/* @__PURE__ */ boolean$1(), { fallback: false, overridable: false }),
3007
- threshold: layerField$1(/* @__PURE__ */ pipe$1(/* @__PURE__ */ number$1(), /* @__PURE__ */ minValue$1(0)), {
3008
- fallback: 320,
3009
- overridable: false
3010
- }),
3011
- ...ChildrenSchema$1.entries,
3012
- ...GraphFieldSchema$1.entries,
3013
- ...OverridesSchema$1.entries,
3014
- ...PositionSchema$1.entries,
3015
- ...SceneSchema$1.entries,
3016
- ...FillSchema$1.entries,
3017
- ...BorderSchema$1.entries,
3018
- ...SizeSchema$1.entries,
3019
- ...LayerSchema$1.entries
3020
- })
3021
- );
3022
- const TextSchema = /* @__PURE__ */ object$1({
3023
- name: layerField$1(/* @__PURE__ */ string$1(), { fallback: "Text", overridable: false }),
3024
- content: layerField$1(/* @__PURE__ */ string$1(), {
3025
- fallback: ""
3026
- }),
3027
- variableContent: layerField$1(/* @__PURE__ */ string$1(), { fallback: null, variable: true }),
3028
- attributes: layerField$1(
3029
- /* @__PURE__ */ object$1({
3030
- fontSize: layerField$1(/* @__PURE__ */ string$1(), { fallback: "14px" }),
3031
- color: layerField$1(/* @__PURE__ */ string$1(), { fallback: "#000" }),
3032
- lineHeight: layerField$1(/* @__PURE__ */ string$1(), { fallback: "14px" })
3033
- }),
3034
- { fallback: {} }
3035
- ),
3036
- ...GraphFieldSchema$1.entries,
3037
- ...OverridesSchema$1.entries,
3038
- ...PositionSchema$1.entries,
3039
- ...SceneSchema$1.entries,
3040
- ...SizeSchema$1.entries
3041
- });
3042
- const FragmentSchema = /* @__PURE__ */ object$1({
3043
- name: layerField$1(/* @__PURE__ */ string$1(), { fallback: "Fragment", overridable: false }),
3044
- horizontalGrow: layerField$1(/* @__PURE__ */ enum_$1(Object.keys(fragmentGrowingMode$2)), {
3045
- fallback: fragmentGrowingMode$2.auto,
3046
- overridable: false
3047
- }),
3048
- verticalGrow: layerField$1(/* @__PURE__ */ enum_$1(Object.keys(fragmentGrowingMode$2)), {
3049
- fallback: fragmentGrowingMode$2.auto,
3050
- overridable: false
3051
- }),
3052
- properties: layerField$1(/* @__PURE__ */ array$1(/* @__PURE__ */ string$1()), {
3053
- fallback: [],
3054
- overridable: false
3055
- }),
3056
- ...GraphFieldSchema$1.entries,
3057
- ...ChildrenSchema$1.entries
3058
- });
3059
- const InstanceSchema = /* @__PURE__ */ object$1({
3060
- name: layerField$1(/* @__PURE__ */ string$1(), { fallback: "Instance", overridable: false }),
3061
- fragment: layerField$1(/* @__PURE__ */ string$1()),
3062
- props: layerField$1(
3063
- /* @__PURE__ */ record$1(/* @__PURE__ */ string$1(), /* @__PURE__ */ union$1([/* @__PURE__ */ string$1(), /* @__PURE__ */ number$1(), /* @__PURE__ */ boolean$1()])),
3064
- {
3065
- fallback: {}
3066
- }
3067
- ),
3068
- ...GraphFieldSchema$1.entries,
3069
- ...OverridesSchema$1.entries,
3070
- ...PositionSchema$1.entries,
3071
- ...SizeSchema$1.entries,
3072
- ...SceneSchema$1.entries
3073
- });
3074
- const NumberVariableSchema = /* @__PURE__ */ object$1({
3075
- name: layerField$1(/* @__PURE__ */ string$1(), {
3076
- fallback: "Number",
3077
- overridable: false
3078
- }),
3079
- type: layerField$1(/* @__PURE__ */ literal$1(variableType$1.Number), {
3080
- fallback: variableType$1.Number
3081
- }),
3082
- defaultValue: layerField$1(/* @__PURE__ */ number$1(), { fallback: 0 }),
3083
- required: layerField$1(/* @__PURE__ */ boolean$1(), { fallback: false }),
3084
- min: layerField$1(/* @__PURE__ */ number$1(), { fallback: 1 }),
3085
- max: layerField$1(/* @__PURE__ */ number$1(), { fallback: 100 }),
3086
- step: layerField$1(/* @__PURE__ */ number$1(), { fallback: 1 }),
3087
- displayStepper: layerField$1(/* @__PURE__ */ boolean$1(), { fallback: true }),
3088
- ...GraphFieldSchema$1.entries
3089
- });
3090
- const BooleanVariableSchema = /* @__PURE__ */ object$1({
3091
- name: layerField$1(/* @__PURE__ */ string$1(), {
3092
- fallback: "Boolean",
3093
- overridable: false
3094
- }),
3095
- type: layerField$1(/* @__PURE__ */ literal$1(variableType$1.Boolean), {
3096
- fallback: variableType$1.Boolean
3097
- }),
3098
- defaultValue: layerField$1(/* @__PURE__ */ boolean$1(), { fallback: false }),
3099
- required: layerField$1(/* @__PURE__ */ boolean$1(), { fallback: false }),
3100
- ...GraphFieldSchema$1.entries
3101
- });
3102
- const ColorVariableSchema = /* @__PURE__ */ object$1({
3103
- name: layerField$1(/* @__PURE__ */ string$1(), {
3104
- fallback: "String",
3105
- overridable: false
3106
- }),
3107
- type: layerField$1(/* @__PURE__ */ literal$1(variableType$1.Color), {
3108
- fallback: variableType$1.Color
3109
- }),
3110
- // TODO Add color validator
3111
- defaultValue: layerField$1(/* @__PURE__ */ string$1(), { fallback: "#000" }),
3112
- required: layerField$1(/* @__PURE__ */ boolean$1(), { fallback: false }),
3113
- ...GraphFieldSchema$1.entries
3114
- });
3115
- const StringVariableSchema = /* @__PURE__ */ object$1({
3116
- name: layerField$1(/* @__PURE__ */ string$1(), {
3117
- fallback: "String",
3118
- overridable: false
3119
- }),
3120
- type: layerField$1(/* @__PURE__ */ literal$1(variableType$1.String), {
3121
- fallback: variableType$1.String
3122
- }),
3123
- defaultValue: layerField$1(/* @__PURE__ */ string$1(), { fallback: "" }),
3124
- required: layerField$1(/* @__PURE__ */ boolean$1(), { fallback: false }),
3125
- placeholder: layerField$1(/* @__PURE__ */ string$1(), { fallback: "" }),
3126
- isTextarea: layerField$1(/* @__PURE__ */ boolean$1(), { fallback: false }),
3127
- ...GraphFieldSchema$1.entries
3128
- });
3129
- const getLayerSchema = (layer) => {
3130
- if (!(layer == null ? void 0 : layer._type)) return null;
3131
- if ((layer == null ? void 0 : layer._type) === nodes$2.Frame) return FrameSchema;
3132
- if ((layer == null ? void 0 : layer._type) === nodes$2.Text) return TextSchema;
3133
- if ((layer == null ? void 0 : layer._type) === nodes$2.Fragment) return FragmentSchema;
3134
- if ((layer == null ? void 0 : layer._type) === nodes$2.Instance) return InstanceSchema;
3135
- if (layer._type === nodes$2.Variable) {
3136
- const types = {
3137
- [variableType$1.Number]: NumberVariableSchema,
3138
- [variableType$1.Boolean]: BooleanVariableSchema,
3139
- [variableType$1.String]: StringVariableSchema,
3140
- [variableType$1.Color]: ColorVariableSchema
3141
- };
3142
- if (layer.type in types) {
3143
- return types[layer.type];
3144
- }
3145
- }
3146
- };
3147
- const normalizeLayer = (schema, rawLayer, options2) => {
3148
- try {
3149
- if (!rawLayer) return null;
3150
- const withFallback = (options2 == null ? void 0 : options2.withFallback) ?? true;
3151
- const overrideTarget = options2 == null ? void 0 : options2.overrideTarget;
3152
- const parsedLayer = parse(schema, rawLayer);
3153
- return Object.fromEntries(
3154
- Object.entries(schema.entries).map(([key, schemaEntity]) => {
3155
- const schemaMeta = getMetadata(schemaEntity);
3156
- const fallback = withFallback ? schemaMeta == null ? void 0 : schemaMeta.fallback : null;
3157
- const overrideValue = (schemaMeta == null ? void 0 : schemaMeta.overridable) !== false && overrideTarget ? overrideTarget == null ? void 0 : overrideTarget[key] : null;
3158
- return [key, parsedLayer[key] ?? overrideValue ?? fallback];
3159
- })
3160
- );
3161
- } catch (e2) {
3162
- console.error(e2);
3163
- return null;
3164
- }
3165
- };
3166
- const getNormalizeLayer = (layer, overrider) => {
3167
- if (!layer) return null;
3168
- const schema = getLayerSchema(layer);
3169
- if (!schema) return null;
3170
- return normalizeLayer(schema, layer, {
3171
- overrideTarget: overrider
3172
- });
3173
- };
3174
- const useNormalizeLayer = (layerKey) => {
3175
- const { manager: fragmentManager } = x$1(FragmentContext);
3176
- const layerData = fragmentManager.resolve(layerKey);
3177
- const overrider = getOverrider(fragmentManager, layerKey);
3178
- const parsedLayer = getNormalizeLayer(layerData, overrider);
3179
- return {
3180
- rawLayer: layerData,
3181
- layer: parsedLayer
3182
- };
3183
- };
3184
- const useLayerValue = (layerKey, fieldKey) => {
3185
- const { manager: fragmentManager } = x$1(FragmentContext);
3186
- const resultManager = fragmentManager;
3187
- const { layer: normalizeLayer2 } = useNormalizeLayer(layerKey);
3188
- const [layerData, updateLayerData] = y$1(resultManager, layerKey, {
3189
- selector: (data) => data ? pick(data, fieldKey) : data
3190
- });
3191
- let currentValue = normalizeLayer2 == null ? void 0 : normalizeLayer2[fieldKey];
3192
- const rawValue = layerData == null ? void 0 : layerData[fieldKey];
3193
- const { value: variableValue } = useReadVariable(rawValue);
3194
- const updateValue = q$1(
3195
- (value) => {
3196
- updateLayerData({ [fieldKey]: value });
3197
- },
3198
- [updateLayerData, fieldKey, currentValue]
3199
- );
3200
- currentValue = variableValue ?? currentValue;
3201
- return [
3202
- currentValue,
3203
- updateValue,
3204
- {
3205
- isVariable: false
3206
- }
3207
- ];
3208
- };
3209
- const autoSizes = [sizing$1.Hug];
3210
- const useLayerSize = (layerKey) => {
3211
- const { manager: fragmentManager } = x$1(FragmentContext);
3212
- const { layerKey: instanceLayerKey, parentManager: instanceManager } = x$1(InstanceContext);
3213
- const { isDocument } = useRenderTarget$1(fragmentManager);
3214
- const isTop = isTopLevel(fragmentManager, layerKey);
3215
- //!!instanceLayerKey;
3216
- const layerParent = getParent(fragmentManager, layerKey);
3217
- useLayerValue(instanceLayerKey, "widthType");
3218
- useLayerValue(instanceLayerKey, "heightType");
3219
- const [width] = useLayerValue(layerKey, "width");
3220
- const [height] = useLayerValue(layerKey, "height");
3221
- const [widthType] = useLayerValue(layerKey, "widthType");
3222
- const [heightType] = useLayerValue(layerKey, "heightType");
3223
- const toValue = (type, value, instanceType) => {
3224
- if (autoSizes.includes(type)) {
3225
- return "min-content";
3226
- }
3227
- if (type === sizing$1.Relative) {
3228
- return `${value}%`;
3229
- }
3230
- if (type === sizing$1.Fill) {
3231
- return `100%`;
3232
- }
3233
- return value;
3234
- };
3235
- return T$1(
3236
- () => ({
3237
- width: isTop && isDocument && (layerParent == null ? void 0 : layerParent.horizontalGrow) === fragmentGrowingMode$1.fill ? "100%" : toValue(widthType, width),
3238
- height: isTop && isDocument && (layerParent == null ? void 0 : layerParent.horizontalGrow) === fragmentGrowingMode$1.fill ? "100%" : toValue(heightType, height)
3239
- }),
3240
- [isTop, isDocument, width, height, heightType, heightType]
3241
- );
3242
- };
3243
- const useLayerPosition = (layerKey) => {
3244
- const { layerKey: instanceLayerKey } = x$1(InstanceContext);
3245
- const { manager: fragmentManager } = x$1(FragmentContext);
3246
- const { isDocument } = useRenderTarget$1();
3247
- const isTop = isTopLevel(fragmentManager, layerKey);
3248
- const skipPosition = isTop && isDocument || !!instanceLayerKey && isTop;
3249
- const [position] = useLayerValue(layerKey, "position");
3250
- const [top] = useLayerValue(layerKey, "top");
3251
- const [left] = useLayerValue(layerKey, "left");
3252
- return T$1(
3253
- () => ({
3254
- position: skipPosition ? positionType$1.relative : position,
3255
- top: position === positionType$1.absolute && !skipPosition ? top : null,
3256
- left: position === positionType$1.absolute && !skipPosition ? left : null
3257
- }),
3258
- [skipPosition, position, top]
3259
- );
3260
- };
3261
- const useLayerBackground = (layerKey) => {
3262
- const [fillType] = useLayerValue(layerKey, "fillType");
3263
- const [solidFill] = useLayerValue(layerKey, "solidFill");
3264
- return T$1(
3265
- () => ({
3266
- background: fillType === paintMode$1.Solid ? solidFill : "transparent"
3267
- }),
3268
- [fillType, solidFill]
3269
- );
3270
- };
3271
- const useLayerDisplay = (layerKey) => {
3272
- const [layerModeValue] = useLayerValue(layerKey, "layerMode");
3273
- const [visible] = useLayerValue(layerKey, "visible");
3274
- return T$1(() => {
3275
- if (!visible) {
3276
- return "none";
3277
- }
3278
- return layerModeValue === layerMode$1.flex ? "flex" : null;
3279
- }, [layerModeValue, visible]);
3280
- };
3281
- const useLayerBorder = (layerKey) => {
3282
- const [borderTypeValue] = useLayerValue(layerKey, "borderType");
3283
- const [borderWidth] = useLayerValue(layerKey, "borderWidth");
3284
- const [borderColor] = useLayerValue(layerKey, "borderColor");
3285
- return T$1(() => {
3286
- let value = "";
3287
- if (typeof borderTypeValue === "string" && borderTypeValue !== borderType$1.None) {
3288
- value = `${toPx(
3289
- borderWidth
3290
- )} ${borderTypeValue.toLowerCase()} ${borderColor}`;
3291
- }
3292
- return {
3293
- border: value
3294
- };
3295
- }, [borderTypeValue, borderWidth, borderColor]);
3296
- };
3297
- const useLayerLayout = (layerKey) => {
3298
- const [layerModeValue] = useLayerValue(layerKey, "layerMode");
3299
- const [layerGap] = useLayerValue(layerKey, "layerGap");
3300
- const [layerWrap] = useLayerValue(layerKey, "layerWrap");
3301
- const [layerDistribute2] = useLayerValue(layerKey, "layerDistribute");
3302
- const [layerDirectionValue] = useLayerValue(layerKey, "layerDirection");
3303
- const [layerAlign2] = useLayerValue(layerKey, "layerAlign");
3304
- const [padding] = useLayerValue(layerKey, "padding");
3305
- const isFlex = layerModeValue === layerMode$1.flex;
3306
- return {
3307
- gap: isFlex ? layerGap : null,
3308
- flexWrap: isFlex ? layerWrap : null,
3309
- justifyContent: isFlex ? layerDistribute2 : null,
3310
- flexDirection: isFlex ? layerDirectionValue === layerDirection$1.vertical ? "column" : "row" : null,
3311
- alignItems: isFlex ? layerAlign2 : null,
3312
- padding: isFlex ? padding : null
3313
- };
3314
- };
3315
- const useLayerStyles = (layerKey) => {
3316
- try {
3317
- if (!layerKey) {
3318
- throw new Error("Empty layer key");
3319
- }
3320
- const [opacity] = useLayerValue(layerKey, "opacity");
3321
- const { width, height } = useLayerSize(layerKey);
3322
- const { position, top, left } = useLayerPosition(layerKey);
3323
- const display = useLayerDisplay(layerKey);
3324
- const { background } = useLayerBackground(layerKey);
3325
- const { border } = useLayerBorder(layerKey);
3326
- const layout = useLayerLayout(layerKey);
3327
- const [zIndex] = useLayerValue(layerKey, "zIndex");
3328
- const [borderRadius] = useLayerValue(layerKey, "borderRadius");
3329
- return {
3330
- display,
3331
- border,
3332
- background,
3333
- position,
3334
- top,
3335
- left,
3336
- width,
3337
- height,
3338
- opacity,
3339
- borderRadius,
3340
- zIndex: zIndex !== -1 ? zIndex : null,
3341
- ...layout,
3342
- userSelect: "none"
3343
- };
3344
- } catch (e2) {
3345
- return {};
3346
- }
3347
- };
3348
- const useFrame = (layerKey) => {
3349
- const { manager: fragmentManager } = x$1(FragmentContext);
3350
- const layer = fragmentManager.entityOfKey(layerKey);
3351
- const styles2 = useLayerStyles(layerKey);
3352
- const children = useLayerChildren(layerKey);
3353
- return {
3354
- type: layer._type,
3355
- styles: styles2,
3356
- children
3357
- };
3358
- };
3359
- const text = "_text_1liuf_1";
3360
- const cssStyles = {
3361
- text
3362
- };
3363
- const allowAttributes = [
3364
- "fontSize",
3365
- "fontWeight",
3366
- "color",
3367
- "lineHeight",
3368
- "letterSpacing",
3369
- "textTransform",
3370
- "textDecoration",
3371
- "textAlign"
3372
- ];
3373
- const wrapTextInParagraphWithAttributes = (text2, attributes) => {
3374
- if (text2.startsWith("<p")) return text2;
3375
- const style = Object.entries(attributes).filter(
3376
- ([key, value]) => isValue(value) && allowAttributes.includes(key) && typeof value === "string" && !!value.length
3377
- ).map(([key, value]) => `${toKebabCase(key)}: ${value}`).join("; ");
3378
- return `<p style="${style}">${text2}</p>`;
3379
- };
3380
- const useTextContent = (layerKey, manager) => {
3381
- const [content, _2, contentInfo] = useLayerValue(layerKey, "content");
3382
- const [attributes] = useLayerValue(layerKey, "attributes");
3383
- return T$1(() => {
3384
- if (contentInfo.isVariable && isValue(attributes)) {
3385
- return wrapTextInParagraphWithAttributes(content, attributes);
3386
- }
3387
- return content;
3388
- }, [contentInfo, content, attributes]);
3389
- };
3390
- const useTextAttributes = (layerKey) => {
3391
- const styles2 = useLayerStyles(layerKey);
3392
- const content = useTextContent(layerKey);
3393
- return {
3394
- styles: styles2,
3395
- content
3396
- };
3397
- };
3398
- const Text = ({ layerKey }) => {
3399
- const { styles: styles2, content } = useTextAttributes(layerKey);
3400
- return /* @__PURE__ */ u$1("div", { style: styles2, "data-key": layerKey, children: /* @__PURE__ */ u$1(
3401
- "div",
3402
- {
3403
- className: cssStyles.text,
3404
- dangerouslySetInnerHTML: { __html: content }
3405
- }
3406
- ) });
3407
- };
3408
- const Frame = ({ layerKey }) => {
3409
- const { styles: styles2, children, type } = useFrame(layerKey);
3410
- if (type === nodes$1.Text) {
3411
- return /* @__PURE__ */ u$1(Text, { layerKey });
3412
- }
3413
- if (type === nodes$1.Instance) {
3414
- return /* @__PURE__ */ u$1(Instance$1, { layerKey });
3415
- }
3416
- return /* @__PURE__ */ u$1("div", { style: styles2, "data-key": layerKey, children: children.map((childLink) => /* @__PURE__ */ u$1(Frame, { layerKey: childLink }, childLink)) });
3417
- };
3418
- const Fragment$1 = ({ fragmentId, globalManager }) => {
3419
- const { manager: resultGlobalManager } = useGlobalManager$1(globalManager);
3420
- const { ref, children, manager } = useFragment(fragmentId, globalManager);
3421
- return /* @__PURE__ */ u$1(GlobalManager$1, { value: resultGlobalManager, children: /* @__PURE__ */ u$1(FragmentProvider, { manager, children: /* @__PURE__ */ u$1(
3422
- "div",
3423
- {
3424
- ref,
3425
- "data-key": `${nodes$1.Fragment}:${fragmentId}`,
3426
- className: styles.fragment,
3427
- children: children.map((childLink) => /* @__PURE__ */ u$1(Frame, { layerKey: childLink }, childLink))
3428
- }
3429
- ) }) });
3430
- };
3431
- const GlobalManager = createContext$1(null);
4
+ import { definition } from "@fragmentsx/definition";
5
+ const GlobalManager = createContext(null);
3432
6
  function createReactComponent(PreactComponent) {
3433
7
  return function ReactWrapper(props) {
3434
8
  const globalManager = useContext(GlobalManager);
3435
- const containerRef = require$$0$1.useRef(null);
3436
- require$$0$1.useEffect(() => {
9
+ const containerRef = require$$0.useRef(null);
10
+ require$$0.useEffect(() => {
3437
11
  if (containerRef.current) {
3438
12
  render(
3439
13
  createElement(PreactComponent, {
@@ -3449,7 +23,7 @@ function createReactComponent(PreactComponent) {
3449
23
  }
3450
24
  };
3451
25
  }, [props, globalManager]);
3452
- return require$$0$1.createElement("div", { ref: containerRef });
26
+ return require$$0.createElement("div", { ref: containerRef });
3453
27
  };
3454
28
  }
3455
29
  const useGlobalManager = () => useContext(GlobalManager);
@@ -3468,42 +42,42 @@ var hasRequiredUseSyncExternalStoreShim_production_min;
3468
42
  function requireUseSyncExternalStoreShim_production_min() {
3469
43
  if (hasRequiredUseSyncExternalStoreShim_production_min) return useSyncExternalStoreShim_production_min;
3470
44
  hasRequiredUseSyncExternalStoreShim_production_min = 1;
3471
- var e2 = require$$0$1;
3472
- function h2(a2, b2) {
3473
- return a2 === b2 && (0 !== a2 || 1 / a2 === 1 / b2) || a2 !== a2 && b2 !== b2;
3474
- }
3475
- var k2 = "function" === typeof Object.is ? Object.is : h2, l2 = e2.useState, m2 = e2.useEffect, n2 = e2.useLayoutEffect, p2 = e2.useDebugValue;
3476
- function q2(a2, b2) {
3477
- var d2 = b2(), f2 = l2({ inst: { value: d2, getSnapshot: b2 } }), c2 = f2[0].inst, g2 = f2[1];
3478
- n2(function() {
3479
- c2.value = d2;
3480
- c2.getSnapshot = b2;
3481
- r2(c2) && g2({ inst: c2 });
3482
- }, [a2, d2, b2]);
3483
- m2(function() {
3484
- r2(c2) && g2({ inst: c2 });
3485
- return a2(function() {
3486
- r2(c2) && g2({ inst: c2 });
45
+ var e = require$$0;
46
+ function h(a, b) {
47
+ return a === b && (0 !== a || 1 / a === 1 / b) || a !== a && b !== b;
48
+ }
49
+ var k = "function" === typeof Object.is ? Object.is : h, l = e.useState, m = e.useEffect, n = e.useLayoutEffect, p = e.useDebugValue;
50
+ function q(a, b) {
51
+ var d = b(), f = l({ inst: { value: d, getSnapshot: b } }), c = f[0].inst, g = f[1];
52
+ n(function() {
53
+ c.value = d;
54
+ c.getSnapshot = b;
55
+ r(c) && g({ inst: c });
56
+ }, [a, d, b]);
57
+ m(function() {
58
+ r(c) && g({ inst: c });
59
+ return a(function() {
60
+ r(c) && g({ inst: c });
3487
61
  });
3488
- }, [a2]);
3489
- p2(d2);
3490
- return d2;
62
+ }, [a]);
63
+ p(d);
64
+ return d;
3491
65
  }
3492
- function r2(a2) {
3493
- var b2 = a2.getSnapshot;
3494
- a2 = a2.value;
66
+ function r(a) {
67
+ var b = a.getSnapshot;
68
+ a = a.value;
3495
69
  try {
3496
- var d2 = b2();
3497
- return !k2(a2, d2);
3498
- } catch (f2) {
70
+ var d = b();
71
+ return !k(a, d);
72
+ } catch (f) {
3499
73
  return true;
3500
74
  }
3501
75
  }
3502
- function t2(a2, b2) {
3503
- return b2();
76
+ function t(a, b) {
77
+ return b();
3504
78
  }
3505
- var u2 = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? t2 : q2;
3506
- useSyncExternalStoreShim_production_min.useSyncExternalStore = void 0 !== e2.useSyncExternalStore ? e2.useSyncExternalStore : u2;
79
+ var u = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? t : q;
80
+ useSyncExternalStoreShim_production_min.useSyncExternalStore = void 0 !== e.useSyncExternalStore ? e.useSyncExternalStore : u;
3507
81
  return useSyncExternalStoreShim_production_min;
3508
82
  }
3509
83
  var useSyncExternalStoreShim_development = {};
@@ -3525,7 +99,7 @@ function requireUseSyncExternalStoreShim_development() {
3525
99
  if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function") {
3526
100
  __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
3527
101
  }
3528
- var React = require$$0$1;
102
+ var React = require$$0;
3529
103
  var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
3530
104
  function error(format) {
3531
105
  {
@@ -3552,8 +126,8 @@ function requireUseSyncExternalStoreShim_development() {
3552
126
  Function.prototype.apply.call(console[level], console, argsWithFormat);
3553
127
  }
3554
128
  }
3555
- function is(x2, y2) {
3556
- return x2 === y2 && (x2 !== 0 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
129
+ function is(x, y2) {
130
+ return x === y2 && (x !== 0 || 1 / x === 1 / y2) || x !== x && y2 !== y2;
3557
131
  }
3558
132
  var objectIs = typeof Object.is === "function" ? Object.is : is;
3559
133
  var useState2 = React.useState, useEffect2 = React.useEffect, useLayoutEffect = React.useLayoutEffect, useDebugValue = React.useDebugValue;
@@ -3663,50 +237,50 @@ var hasRequiredWithSelector_production_min;
3663
237
  function requireWithSelector_production_min() {
3664
238
  if (hasRequiredWithSelector_production_min) return withSelector_production_min;
3665
239
  hasRequiredWithSelector_production_min = 1;
3666
- var h2 = require$$0$1, n2 = requireShim();
3667
- function p2(a2, b2) {
3668
- return a2 === b2 && (0 !== a2 || 1 / a2 === 1 / b2) || a2 !== a2 && b2 !== b2;
3669
- }
3670
- var q2 = "function" === typeof Object.is ? Object.is : p2, r2 = n2.useSyncExternalStore, t2 = h2.useRef, u2 = h2.useEffect, v2 = h2.useMemo, w2 = h2.useDebugValue;
3671
- withSelector_production_min.useSyncExternalStoreWithSelector = function(a2, b2, e2, l2, g2) {
3672
- var c2 = t2(null);
3673
- if (null === c2.current) {
3674
- var f2 = { hasValue: false, value: null };
3675
- c2.current = f2;
3676
- } else f2 = c2.current;
3677
- c2 = v2(function() {
3678
- function a3(a4) {
3679
- if (!c3) {
3680
- c3 = true;
3681
- d3 = a4;
3682
- a4 = l2(a4);
3683
- if (void 0 !== g2 && f2.hasValue) {
3684
- var b3 = f2.value;
3685
- if (g2(b3, a4)) return k2 = b3;
3686
- }
3687
- return k2 = a4;
3688
- }
3689
- b3 = k2;
3690
- if (q2(d3, a4)) return b3;
3691
- var e3 = l2(a4);
3692
- if (void 0 !== g2 && g2(b3, e3)) return b3;
3693
- d3 = a4;
3694
- return k2 = e3;
3695
- }
3696
- var c3 = false, d3, k2, m2 = void 0 === e2 ? null : e2;
240
+ var h = require$$0, n = requireShim();
241
+ function p(a, b) {
242
+ return a === b && (0 !== a || 1 / a === 1 / b) || a !== a && b !== b;
243
+ }
244
+ var q = "function" === typeof Object.is ? Object.is : p, r = n.useSyncExternalStore, t = h.useRef, u = h.useEffect, v = h.useMemo, w = h.useDebugValue;
245
+ withSelector_production_min.useSyncExternalStoreWithSelector = function(a, b, e, l, g) {
246
+ var c = t(null);
247
+ if (null === c.current) {
248
+ var f = { hasValue: false, value: null };
249
+ c.current = f;
250
+ } else f = c.current;
251
+ c = v(function() {
252
+ function a2(a3) {
253
+ if (!c2) {
254
+ c2 = true;
255
+ d2 = a3;
256
+ a3 = l(a3);
257
+ if (void 0 !== g && f.hasValue) {
258
+ var b2 = f.value;
259
+ if (g(b2, a3)) return k = b2;
260
+ }
261
+ return k = a3;
262
+ }
263
+ b2 = k;
264
+ if (q(d2, a3)) return b2;
265
+ var e2 = l(a3);
266
+ if (void 0 !== g && g(b2, e2)) return b2;
267
+ d2 = a3;
268
+ return k = e2;
269
+ }
270
+ var c2 = false, d2, k, m = void 0 === e ? null : e;
3697
271
  return [function() {
3698
- return a3(b2());
3699
- }, null === m2 ? void 0 : function() {
3700
- return a3(m2());
272
+ return a2(b());
273
+ }, null === m ? void 0 : function() {
274
+ return a2(m());
3701
275
  }];
3702
- }, [b2, e2, l2, g2]);
3703
- var d2 = r2(a2, c2[0], c2[1]);
3704
- u2(function() {
3705
- f2.hasValue = true;
3706
- f2.value = d2;
3707
- }, [d2]);
3708
- w2(d2);
3709
- return d2;
276
+ }, [b, e, l, g]);
277
+ var d = r(a, c[0], c[1]);
278
+ u(function() {
279
+ f.hasValue = true;
280
+ f.value = d;
281
+ }, [d]);
282
+ w(d);
283
+ return d;
3710
284
  };
3711
285
  return withSelector_production_min;
3712
286
  }
@@ -3729,10 +303,10 @@ function requireWithSelector_development() {
3729
303
  if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function") {
3730
304
  __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
3731
305
  }
3732
- var React = require$$0$1;
306
+ var React = require$$0;
3733
307
  var shim2 = requireShim();
3734
- function is(x2, y2) {
3735
- return x2 === y2 && (x2 !== 0 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
308
+ function is(x, y2) {
309
+ return x === y2 && (x !== 0 || 1 / x === 1 / y2) || x !== x && y2 !== y2;
3736
310
  }
3737
311
  var objectIs = typeof Object.is === "function" ? Object.is : is;
3738
312
  var useSyncExternalStore = shim2.useSyncExternalStore;
@@ -3820,20 +394,20 @@ function requireWithSelector() {
3820
394
  return withSelector.exports;
3821
395
  }
3822
396
  requireWithSelector();
3823
- var y = (t2, e2, n2) => {
397
+ var y = (t, e, n) => {
3824
398
  var _a, _b;
3825
- let r2 = useRef((_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, u2 = useCallback((o2) => {
399
+ let r = useRef((_a = t == null ? void 0 : t.resolve) == null ? void 0 : _a.call(t, e, n)), s = ((_b = t == null ? void 0 : t.keyOfEntity) == null ? void 0 : _b.call(t, e)) ?? e, u = useCallback((o) => {
3826
400
  var _a2, _b2;
3827
- return s2 ? (r2.current = (_a2 = t2 == null ? void 0 : t2.resolve) == null ? void 0 : _a2.call(t2, s2, n2), o2(), (_b2 = t2 == null ? void 0 : t2.subscribe) == null ? void 0 : _b2.call(t2, s2, () => {
401
+ return s ? (r.current = (_a2 = t == null ? void 0 : t.resolve) == null ? void 0 : _a2.call(t, s, n), o(), (_b2 = t == null ? void 0 : t.subscribe) == null ? void 0 : _b2.call(t, s, () => {
3828
402
  var _a3;
3829
- return r2.current = (_a3 = t2 == null ? void 0 : t2.resolve) == null ? void 0 : _a3.call(t2, s2, n2), o2();
3830
- }, n2)) : () => {
403
+ return r.current = (_a3 = t == null ? void 0 : t.resolve) == null ? void 0 : _a3.call(t, s, n), o();
404
+ }, n)) : () => {
3831
405
  };
3832
- }, [t2, s2]), i2 = useCallback((o2) => {
3833
- let p2 = typeof e2 == "string" ? e2 : t2.keyOfEntity(e2);
3834
- e2 && p2 && t2.mutate(p2, o2);
3835
- }, [t2, e2]), a2 = () => r2.current;
3836
- return [shimExports.useSyncExternalStore(u2, a2, a2), i2];
406
+ }, [t, s]), i = useCallback((o) => {
407
+ let p = typeof e == "string" ? e : t.keyOfEntity(e);
408
+ e && p && t.mutate(p, o);
409
+ }, [t, e]), a = () => r.current;
410
+ return [shimExports.useSyncExternalStore(u, a, a), i];
3837
411
  };
3838
412
  const useFragmentManager = (fragmentId) => {
3839
413
  const globalManager = useGlobalManager();
@@ -3864,1048 +438,14 @@ const useFragmentProperties = (fragmentId) => {
3864
438
  const [instanceFragment] = y(manager, (_a = manager == null ? void 0 : manager.$fragment) == null ? void 0 : _a.root);
3865
439
  return (instanceFragment == null ? void 0 : instanceFragment.properties) ?? [];
3866
440
  };
3867
- const createConstants = (...constants) => {
3868
- return constants.reduce((acc, constant) => {
3869
- acc[constant] = constant;
3870
- return acc;
3871
- }, {});
3872
- };
3873
- const nodes = createConstants(
3874
- "Fragment",
3875
- "FragmentInstance",
3876
- "Instance",
3877
- "Breakpoint",
3878
- "Frame",
3879
- "Image",
3880
- "Text",
3881
- "SolidPaintStyle",
3882
- "CssLink",
3883
- "Variable",
3884
- "ComputedValue",
3885
- "TransformValue"
3886
- );
3887
- const fragmentGrowingMode = createConstants("auto", "fill");
3888
- const borderType = createConstants("None", "Solid", "Dashed", "Dotted");
3889
- const linkTarget = createConstants("_blank");
3890
- const paintMode = createConstants("None", "Solid", "Image");
3891
- const imagePaintScaleModes = createConstants(
3892
- "Fill",
3893
- "Fit",
3894
- "Crop",
3895
- "Tile"
3896
- );
3897
- const constrain = createConstants(
3898
- "Min",
3899
- "Center",
3900
- "Max",
3901
- "Stretch",
3902
- "Scale"
3903
- );
3904
- const positionType = createConstants("absolute", "relative");
3905
- const sizing = createConstants("Fixed", "Hug", "Fill", "Relative");
3906
- const layerMode = createConstants("none", "flex");
3907
- const layerDirection = createConstants("vertical", "horizontal");
3908
- const layerAlign = createConstants("start", "center", "end");
3909
- const layerDistribute = createConstants(
3910
- "start",
3911
- "center",
3912
- "end",
3913
- "space-between",
3914
- "space-around"
3915
- );
3916
- const textTransform = createConstants(
3917
- "none",
3918
- "uppercase",
3919
- "lowercase",
3920
- "capitalize"
3921
- );
3922
- const textDecorations = createConstants(
3923
- "none",
3924
- "underline",
3925
- "line-through"
3926
- );
3927
- const effectType = createConstants("loop", "appear", "hover", "tap");
3928
- const effectName = createConstants(
3929
- "fade",
3930
- "slide",
3931
- "bounce",
3932
- "wiggle",
3933
- "increase"
3934
- );
3935
- const variableType = createConstants(
3936
- "String",
3937
- "Boolean",
3938
- "Array",
3939
- "Color",
3940
- "ComponentInstance",
3941
- "Date",
3942
- "Enum",
3943
- "Number",
3944
- "Object"
3945
- );
3946
- const whiteSpace = createConstants(
3947
- "normal",
3948
- "nowrap",
3949
- "pre",
3950
- "pre-wrap",
3951
- "pre-line",
3952
- "break-spaces"
3953
- );
3954
- const overflow = createConstants("visible", "hidden", "scroll");
3955
- const variableTransforms = createConstants(
3956
- "convert",
3957
- "exists",
3958
- "equals",
3959
- "startWith",
3960
- "endWith",
3961
- "contains",
3962
- "dateBefore",
3963
- "dateAfter",
3964
- "dateBetween",
3965
- "feature",
3966
- "notFeature",
3967
- "gt",
3968
- // Greater than
3969
- "gte",
3970
- // Greater than or equals
3971
- "lt",
3972
- // Less than
3973
- "lte",
3974
- // Less than or equals,
3975
- "convertFromBoolean",
3976
- "negative"
3977
- );
3978
- const renderTarget = createConstants("canvas", "document");
3979
- const renderMode = createConstants("viewport", "parent", "fixed");
3980
- const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3981
- __proto__: null,
3982
- borderType,
3983
- constrain,
3984
- createConstants,
3985
- effectName,
3986
- effectType,
3987
- fragmentGrowingMode,
3988
- imagePaintScaleModes,
3989
- layerAlign,
3990
- layerDirection,
3991
- layerDistribute,
3992
- layerMode,
3993
- linkTarget,
3994
- nodes,
3995
- overflow,
3996
- paintMode,
3997
- positionType,
3998
- renderMode,
3999
- renderTarget,
4000
- sizing,
4001
- textDecorations,
4002
- textTransform,
4003
- variableTransforms,
4004
- variableType,
4005
- whiteSpace
4006
- }, Symbol.toStringTag, { value: "Module" }));
4007
- // @__NO_SIDE_EFFECTS__
4008
- function getGlobalConfig(config2) {
4009
- return {
4010
- lang: (config2 == null ? void 0 : config2.lang) ?? void 0,
4011
- message: config2 == null ? void 0 : config2.message,
4012
- abortEarly: (config2 == null ? void 0 : config2.abortEarly) ?? void 0,
4013
- abortPipeEarly: (config2 == null ? void 0 : config2.abortPipeEarly) ?? void 0
4014
- };
4015
- }
4016
- // @__NO_SIDE_EFFECTS__
4017
- function getGlobalMessage(lang) {
4018
- return void 0;
4019
- }
4020
- // @__NO_SIDE_EFFECTS__
4021
- function getSchemaMessage(lang) {
4022
- return void 0;
4023
- }
4024
- // @__NO_SIDE_EFFECTS__
4025
- function getSpecificMessage(reference, lang) {
4026
- var _a;
4027
- return (_a = void 0) == null ? void 0 : _a.get(lang);
4028
- }
4029
- // @__NO_SIDE_EFFECTS__
4030
- function _stringify(input) {
4031
- var _a, _b;
4032
- const type = typeof input;
4033
- if (type === "string") {
4034
- return `"${input}"`;
4035
- }
4036
- if (type === "number" || type === "bigint" || type === "boolean") {
4037
- return `${input}`;
4038
- }
4039
- if (type === "object" || type === "function") {
4040
- return (input && ((_b = (_a = Object.getPrototypeOf(input)) == null ? void 0 : _a.constructor) == null ? void 0 : _b.name)) ?? "null";
4041
- }
4042
- return type;
4043
- }
4044
- function _addIssue(context, label, dataset, config2, other) {
4045
- const input = other && "input" in other ? other.input : dataset.value;
4046
- const expected = (other == null ? void 0 : other.expected) ?? context.expects ?? null;
4047
- const received = (other == null ? void 0 : other.received) ?? /* @__PURE__ */ _stringify(input);
4048
- const issue = {
4049
- kind: context.kind,
4050
- type: context.type,
4051
- input,
4052
- expected,
4053
- received,
4054
- message: `Invalid ${label}: ${expected ? `Expected ${expected} but r` : "R"}eceived ${received}`,
4055
- requirement: context.requirement,
4056
- path: other == null ? void 0 : other.path,
4057
- issues: other == null ? void 0 : other.issues,
4058
- lang: config2.lang,
4059
- abortEarly: config2.abortEarly,
4060
- abortPipeEarly: config2.abortPipeEarly
4061
- };
4062
- const isSchema = context.kind === "schema";
4063
- const message = (other == null ? void 0 : other.message) ?? context.message ?? /* @__PURE__ */ getSpecificMessage(context.reference, issue.lang) ?? (isSchema ? /* @__PURE__ */ getSchemaMessage(issue.lang) : null) ?? config2.message ?? /* @__PURE__ */ getGlobalMessage(issue.lang);
4064
- if (message !== void 0) {
4065
- issue.message = typeof message === "function" ? (
4066
- // @ts-expect-error
4067
- message(issue)
4068
- ) : message;
4069
- }
4070
- if (isSchema) {
4071
- dataset.typed = false;
4072
- }
4073
- if (dataset.issues) {
4074
- dataset.issues.push(issue);
4075
- } else {
4076
- dataset.issues = [issue];
4077
- }
4078
- }
4079
- // @__NO_SIDE_EFFECTS__
4080
- function _getStandardProps(context) {
4081
- return {
4082
- version: 1,
4083
- vendor: "valibot",
4084
- validate(value2) {
4085
- return context["~run"]({ value: value2 }, /* @__PURE__ */ getGlobalConfig());
4086
- }
4087
- };
4088
- }
4089
- // @__NO_SIDE_EFFECTS__
4090
- function _isValidObjectKey(object2, key) {
4091
- return Object.hasOwn(object2, key) && key !== "__proto__" && key !== "prototype" && key !== "constructor";
4092
- }
4093
- // @__NO_SIDE_EFFECTS__
4094
- function _joinExpects(values2, separator) {
4095
- const list = [...new Set(values2)];
4096
- if (list.length > 1) {
4097
- return `(${list.join(` ${separator} `)})`;
4098
- }
4099
- return list[0] ?? "never";
4100
- }
4101
- // @__NO_SIDE_EFFECTS__
4102
- function check(requirement, message) {
4103
- return {
4104
- kind: "validation",
4105
- type: "check",
4106
- reference: check,
4107
- async: false,
4108
- expects: null,
4109
- requirement,
4110
- message,
4111
- "~run"(dataset, config2) {
4112
- if (dataset.typed && !this.requirement(dataset.value)) {
4113
- _addIssue(this, "input", dataset, config2);
4114
- }
4115
- return dataset;
4116
- }
4117
- };
4118
- }
4119
- // @__NO_SIDE_EFFECTS__
4120
- function maxValue(requirement, message) {
4121
- return {
4122
- kind: "validation",
4123
- type: "max_value",
4124
- reference: maxValue,
4125
- async: false,
4126
- expects: `<=${requirement instanceof Date ? requirement.toJSON() : /* @__PURE__ */ _stringify(requirement)}`,
4127
- requirement,
4128
- message,
4129
- "~run"(dataset, config2) {
4130
- if (dataset.typed && !(dataset.value <= this.requirement)) {
4131
- _addIssue(this, "value", dataset, config2, {
4132
- received: dataset.value instanceof Date ? dataset.value.toJSON() : /* @__PURE__ */ _stringify(dataset.value)
4133
- });
4134
- }
4135
- return dataset;
4136
- }
4137
- };
4138
- }
4139
- // @__NO_SIDE_EFFECTS__
4140
- function metadata(metadata_) {
4141
- return {
4142
- kind: "metadata",
4143
- type: "metadata",
4144
- reference: metadata,
4145
- metadata: metadata_
4146
- };
4147
- }
4148
- // @__NO_SIDE_EFFECTS__
4149
- function minValue(requirement, message) {
4150
- return {
4151
- kind: "validation",
4152
- type: "min_value",
4153
- reference: minValue,
4154
- async: false,
4155
- expects: `>=${requirement instanceof Date ? requirement.toJSON() : /* @__PURE__ */ _stringify(requirement)}`,
4156
- requirement,
4157
- message,
4158
- "~run"(dataset, config2) {
4159
- if (dataset.typed && !(dataset.value >= this.requirement)) {
4160
- _addIssue(this, "value", dataset, config2, {
4161
- received: dataset.value instanceof Date ? dataset.value.toJSON() : /* @__PURE__ */ _stringify(dataset.value)
4162
- });
4163
- }
4164
- return dataset;
4165
- }
4166
- };
4167
- }
4168
- // @__NO_SIDE_EFFECTS__
4169
- function getFallback(schema, dataset, config2) {
4170
- return typeof schema.fallback === "function" ? (
4171
- // @ts-expect-error
4172
- schema.fallback(dataset, config2)
4173
- ) : (
4174
- // @ts-expect-error
4175
- schema.fallback
4176
- );
4177
- }
4178
- // @__NO_SIDE_EFFECTS__
4179
- function getDefault(schema, dataset, config2) {
4180
- return typeof schema.default === "function" ? (
4181
- // @ts-expect-error
4182
- schema.default(dataset, config2)
4183
- ) : (
4184
- // @ts-expect-error
4185
- schema.default
4186
- );
4187
- }
4188
- // @__NO_SIDE_EFFECTS__
4189
- function array(item, message) {
4190
- return {
4191
- kind: "schema",
4192
- type: "array",
4193
- reference: array,
4194
- expects: "Array",
4195
- async: false,
4196
- item,
4197
- message,
4198
- get "~standard"() {
4199
- return /* @__PURE__ */ _getStandardProps(this);
4200
- },
4201
- "~run"(dataset, config2) {
4202
- var _a;
4203
- const input = dataset.value;
4204
- if (Array.isArray(input)) {
4205
- dataset.typed = true;
4206
- dataset.value = [];
4207
- for (let key = 0; key < input.length; key++) {
4208
- const value2 = input[key];
4209
- const itemDataset = this.item["~run"]({ value: value2 }, config2);
4210
- if (itemDataset.issues) {
4211
- const pathItem = {
4212
- type: "array",
4213
- origin: "value",
4214
- input,
4215
- key,
4216
- value: value2
4217
- };
4218
- for (const issue of itemDataset.issues) {
4219
- if (issue.path) {
4220
- issue.path.unshift(pathItem);
4221
- } else {
4222
- issue.path = [pathItem];
4223
- }
4224
- (_a = dataset.issues) == null ? void 0 : _a.push(issue);
4225
- }
4226
- if (!dataset.issues) {
4227
- dataset.issues = itemDataset.issues;
4228
- }
4229
- if (config2.abortEarly) {
4230
- dataset.typed = false;
4231
- break;
4232
- }
4233
- }
4234
- if (!itemDataset.typed) {
4235
- dataset.typed = false;
4236
- }
4237
- dataset.value.push(itemDataset.value);
4238
- }
4239
- } else {
4240
- _addIssue(this, "type", dataset, config2);
4241
- }
4242
- return dataset;
4243
- }
4244
- };
4245
- }
4246
- // @__NO_SIDE_EFFECTS__
4247
- function boolean(message) {
4248
- return {
4249
- kind: "schema",
4250
- type: "boolean",
4251
- reference: boolean,
4252
- expects: "boolean",
4253
- async: false,
4254
- message,
4255
- get "~standard"() {
4256
- return /* @__PURE__ */ _getStandardProps(this);
4257
- },
4258
- "~run"(dataset, config2) {
4259
- if (typeof dataset.value === "boolean") {
4260
- dataset.typed = true;
4261
- } else {
4262
- _addIssue(this, "type", dataset, config2);
4263
- }
4264
- return dataset;
4265
- }
4266
- };
4267
- }
4268
- // @__NO_SIDE_EFFECTS__
4269
- function enum_(enum__, message) {
4270
- const options2 = [];
4271
- for (const key in enum__) {
4272
- if (`${+key}` !== key || typeof enum__[key] !== "string" || !Object.is(enum__[enum__[key]], +key)) {
4273
- options2.push(enum__[key]);
4274
- }
4275
- }
4276
- return {
4277
- kind: "schema",
4278
- type: "enum",
4279
- reference: enum_,
4280
- expects: /* @__PURE__ */ _joinExpects(options2.map(_stringify), "|"),
4281
- async: false,
4282
- enum: enum__,
4283
- options: options2,
4284
- message,
4285
- get "~standard"() {
4286
- return /* @__PURE__ */ _getStandardProps(this);
4287
- },
4288
- "~run"(dataset, config2) {
4289
- if (this.options.includes(dataset.value)) {
4290
- dataset.typed = true;
4291
- } else {
4292
- _addIssue(this, "type", dataset, config2);
4293
- }
4294
- return dataset;
4295
- }
4296
- };
4297
- }
4298
- // @__NO_SIDE_EFFECTS__
4299
- function literal(literal_, message) {
4300
- return {
4301
- kind: "schema",
4302
- type: "literal",
4303
- reference: literal,
4304
- expects: /* @__PURE__ */ _stringify(literal_),
4305
- async: false,
4306
- literal: literal_,
4307
- message,
4308
- get "~standard"() {
4309
- return /* @__PURE__ */ _getStandardProps(this);
4310
- },
4311
- "~run"(dataset, config2) {
4312
- if (dataset.value === this.literal) {
4313
- dataset.typed = true;
4314
- } else {
4315
- _addIssue(this, "type", dataset, config2);
4316
- }
4317
- return dataset;
4318
- }
4319
- };
4320
- }
4321
- // @__NO_SIDE_EFFECTS__
4322
- function number(message) {
4323
- return {
4324
- kind: "schema",
4325
- type: "number",
4326
- reference: number,
4327
- expects: "number",
4328
- async: false,
4329
- message,
4330
- get "~standard"() {
4331
- return /* @__PURE__ */ _getStandardProps(this);
4332
- },
4333
- "~run"(dataset, config2) {
4334
- if (typeof dataset.value === "number" && !isNaN(dataset.value)) {
4335
- dataset.typed = true;
4336
- } else {
4337
- _addIssue(this, "type", dataset, config2);
4338
- }
4339
- return dataset;
4340
- }
4341
- };
4342
- }
4343
- // @__NO_SIDE_EFFECTS__
4344
- function object(entries, message) {
4345
- return {
4346
- kind: "schema",
4347
- type: "object",
4348
- reference: object,
4349
- expects: "Object",
4350
- async: false,
4351
- entries,
4352
- message,
4353
- get "~standard"() {
4354
- return /* @__PURE__ */ _getStandardProps(this);
4355
- },
4356
- "~run"(dataset, config2) {
4357
- var _a;
4358
- const input = dataset.value;
4359
- if (input && typeof input === "object") {
4360
- dataset.typed = true;
4361
- dataset.value = {};
4362
- for (const key in this.entries) {
4363
- const valueSchema = this.entries[key];
4364
- if (key in input || (valueSchema.type === "exact_optional" || valueSchema.type === "optional" || valueSchema.type === "nullish") && // @ts-expect-error
4365
- valueSchema.default !== void 0) {
4366
- const value2 = key in input ? (
4367
- // @ts-expect-error
4368
- input[key]
4369
- ) : /* @__PURE__ */ getDefault(valueSchema);
4370
- const valueDataset = valueSchema["~run"]({ value: value2 }, config2);
4371
- if (valueDataset.issues) {
4372
- const pathItem = {
4373
- type: "object",
4374
- origin: "value",
4375
- input,
4376
- key,
4377
- value: value2
4378
- };
4379
- for (const issue of valueDataset.issues) {
4380
- if (issue.path) {
4381
- issue.path.unshift(pathItem);
4382
- } else {
4383
- issue.path = [pathItem];
4384
- }
4385
- (_a = dataset.issues) == null ? void 0 : _a.push(issue);
4386
- }
4387
- if (!dataset.issues) {
4388
- dataset.issues = valueDataset.issues;
4389
- }
4390
- if (config2.abortEarly) {
4391
- dataset.typed = false;
4392
- break;
4393
- }
4394
- }
4395
- if (!valueDataset.typed) {
4396
- dataset.typed = false;
4397
- }
4398
- dataset.value[key] = valueDataset.value;
4399
- } else if (valueSchema.fallback !== void 0) {
4400
- dataset.value[key] = /* @__PURE__ */ getFallback(valueSchema);
4401
- } else if (valueSchema.type !== "exact_optional" && valueSchema.type !== "optional" && valueSchema.type !== "nullish") {
4402
- _addIssue(this, "key", dataset, config2, {
4403
- input: void 0,
4404
- expected: `"${key}"`,
4405
- path: [
4406
- {
4407
- type: "object",
4408
- origin: "key",
4409
- input,
4410
- key,
4411
- // @ts-expect-error
4412
- value: input[key]
4413
- }
4414
- ]
4415
- });
4416
- if (config2.abortEarly) {
4417
- break;
4418
- }
4419
- }
4420
- }
4421
- } else {
4422
- _addIssue(this, "type", dataset, config2);
4423
- }
4424
- return dataset;
4425
- }
4426
- };
4427
- }
4428
- // @__NO_SIDE_EFFECTS__
4429
- function optional(wrapped, default_) {
4430
- return {
4431
- kind: "schema",
4432
- type: "optional",
4433
- reference: optional,
4434
- expects: `(${wrapped.expects} | undefined)`,
4435
- async: false,
4436
- wrapped,
4437
- default: default_,
4438
- get "~standard"() {
4439
- return /* @__PURE__ */ _getStandardProps(this);
4440
- },
4441
- "~run"(dataset, config2) {
4442
- if (dataset.value === void 0) {
4443
- if (this.default !== void 0) {
4444
- dataset.value = /* @__PURE__ */ getDefault(this, dataset, config2);
4445
- }
4446
- if (dataset.value === void 0) {
4447
- dataset.typed = true;
4448
- return dataset;
4449
- }
4450
- }
4451
- return this.wrapped["~run"](dataset, config2);
4452
- }
4453
- };
4454
- }
4455
- // @__NO_SIDE_EFFECTS__
4456
- function picklist(options2, message) {
4457
- return {
4458
- kind: "schema",
4459
- type: "picklist",
4460
- reference: picklist,
4461
- expects: /* @__PURE__ */ _joinExpects(options2.map(_stringify), "|"),
4462
- async: false,
4463
- options: options2,
4464
- message,
4465
- get "~standard"() {
4466
- return /* @__PURE__ */ _getStandardProps(this);
4467
- },
4468
- "~run"(dataset, config2) {
4469
- if (this.options.includes(dataset.value)) {
4470
- dataset.typed = true;
4471
- } else {
4472
- _addIssue(this, "type", dataset, config2);
4473
- }
4474
- return dataset;
4475
- }
4476
- };
4477
- }
4478
- // @__NO_SIDE_EFFECTS__
4479
- function record(key, value2, message) {
4480
- return {
4481
- kind: "schema",
4482
- type: "record",
4483
- reference: record,
4484
- expects: "Object",
4485
- async: false,
4486
- key,
4487
- value: value2,
4488
- message,
4489
- get "~standard"() {
4490
- return /* @__PURE__ */ _getStandardProps(this);
4491
- },
4492
- "~run"(dataset, config2) {
4493
- var _a, _b;
4494
- const input = dataset.value;
4495
- if (input && typeof input === "object") {
4496
- dataset.typed = true;
4497
- dataset.value = {};
4498
- for (const entryKey in input) {
4499
- if (/* @__PURE__ */ _isValidObjectKey(input, entryKey)) {
4500
- const entryValue = input[entryKey];
4501
- const keyDataset = this.key["~run"]({ value: entryKey }, config2);
4502
- if (keyDataset.issues) {
4503
- const pathItem = {
4504
- type: "object",
4505
- origin: "key",
4506
- input,
4507
- key: entryKey,
4508
- value: entryValue
4509
- };
4510
- for (const issue of keyDataset.issues) {
4511
- issue.path = [pathItem];
4512
- (_a = dataset.issues) == null ? void 0 : _a.push(issue);
4513
- }
4514
- if (!dataset.issues) {
4515
- dataset.issues = keyDataset.issues;
4516
- }
4517
- if (config2.abortEarly) {
4518
- dataset.typed = false;
4519
- break;
4520
- }
4521
- }
4522
- const valueDataset = this.value["~run"](
4523
- { value: entryValue },
4524
- config2
4525
- );
4526
- if (valueDataset.issues) {
4527
- const pathItem = {
4528
- type: "object",
4529
- origin: "value",
4530
- input,
4531
- key: entryKey,
4532
- value: entryValue
4533
- };
4534
- for (const issue of valueDataset.issues) {
4535
- if (issue.path) {
4536
- issue.path.unshift(pathItem);
4537
- } else {
4538
- issue.path = [pathItem];
4539
- }
4540
- (_b = dataset.issues) == null ? void 0 : _b.push(issue);
4541
- }
4542
- if (!dataset.issues) {
4543
- dataset.issues = valueDataset.issues;
4544
- }
4545
- if (config2.abortEarly) {
4546
- dataset.typed = false;
4547
- break;
4548
- }
4549
- }
4550
- if (!keyDataset.typed || !valueDataset.typed) {
4551
- dataset.typed = false;
4552
- }
4553
- if (keyDataset.typed) {
4554
- dataset.value[keyDataset.value] = valueDataset.value;
4555
- }
4556
- }
4557
- }
4558
- } else {
4559
- _addIssue(this, "type", dataset, config2);
4560
- }
4561
- return dataset;
4562
- }
4563
- };
4564
- }
4565
- // @__NO_SIDE_EFFECTS__
4566
- function string(message) {
4567
- return {
4568
- kind: "schema",
4569
- type: "string",
4570
- reference: string,
4571
- expects: "string",
4572
- async: false,
4573
- message,
4574
- get "~standard"() {
4575
- return /* @__PURE__ */ _getStandardProps(this);
4576
- },
4577
- "~run"(dataset, config2) {
4578
- if (typeof dataset.value === "string") {
4579
- dataset.typed = true;
4580
- } else {
4581
- _addIssue(this, "type", dataset, config2);
4582
- }
4583
- return dataset;
4584
- }
4585
- };
4586
- }
4587
- // @__NO_SIDE_EFFECTS__
4588
- function _subIssues(datasets) {
4589
- let issues;
4590
- if (datasets) {
4591
- for (const dataset of datasets) {
4592
- if (issues) {
4593
- issues.push(...dataset.issues);
4594
- } else {
4595
- issues = dataset.issues;
4596
- }
4597
- }
4598
- }
4599
- return issues;
4600
- }
4601
- // @__NO_SIDE_EFFECTS__
4602
- function union(options2, message) {
4603
- return {
4604
- kind: "schema",
4605
- type: "union",
4606
- reference: union,
4607
- expects: /* @__PURE__ */ _joinExpects(
4608
- options2.map((option) => option.expects),
4609
- "|"
4610
- ),
4611
- async: false,
4612
- options: options2,
4613
- message,
4614
- get "~standard"() {
4615
- return /* @__PURE__ */ _getStandardProps(this);
4616
- },
4617
- "~run"(dataset, config2) {
4618
- let validDataset;
4619
- let typedDatasets;
4620
- let untypedDatasets;
4621
- for (const schema of this.options) {
4622
- const optionDataset = schema["~run"]({ value: dataset.value }, config2);
4623
- if (optionDataset.typed) {
4624
- if (optionDataset.issues) {
4625
- if (typedDatasets) {
4626
- typedDatasets.push(optionDataset);
4627
- } else {
4628
- typedDatasets = [optionDataset];
4629
- }
4630
- } else {
4631
- validDataset = optionDataset;
4632
- break;
4633
- }
4634
- } else {
4635
- if (untypedDatasets) {
4636
- untypedDatasets.push(optionDataset);
4637
- } else {
4638
- untypedDatasets = [optionDataset];
4639
- }
4640
- }
4641
- }
4642
- if (validDataset) {
4643
- return validDataset;
4644
- }
4645
- if (typedDatasets) {
4646
- if (typedDatasets.length === 1) {
4647
- return typedDatasets[0];
4648
- }
4649
- _addIssue(this, "type", dataset, config2, {
4650
- issues: /* @__PURE__ */ _subIssues(typedDatasets)
4651
- });
4652
- dataset.typed = true;
4653
- } else if ((untypedDatasets == null ? void 0 : untypedDatasets.length) === 1) {
4654
- return untypedDatasets[0];
4655
- } else {
4656
- _addIssue(this, "type", dataset, config2, {
4657
- issues: /* @__PURE__ */ _subIssues(untypedDatasets)
4658
- });
4659
- }
4660
- return dataset;
4661
- }
4662
- };
4663
- }
4664
- // @__NO_SIDE_EFFECTS__
4665
- function pipe(...pipe2) {
4666
- return {
4667
- ...pipe2[0],
4668
- pipe: pipe2,
4669
- get "~standard"() {
4670
- return /* @__PURE__ */ _getStandardProps(this);
4671
- },
4672
- "~run"(dataset, config2) {
4673
- for (const item of pipe2) {
4674
- if (item.kind !== "metadata") {
4675
- if (dataset.issues && (item.kind === "schema" || item.kind === "transformation")) {
4676
- dataset.typed = false;
4677
- break;
4678
- }
4679
- if (!dataset.issues || !config2.abortEarly && !config2.abortPipeEarly) {
4680
- dataset = item["~run"](dataset, config2);
4681
- }
4682
- }
4683
- }
4684
- return dataset;
4685
- }
4686
- };
4687
- }
4688
- const linkValidator = /* @__PURE__ */ check(
4689
- (value) => {
4690
- var _a, _b;
4691
- return !!value && ((_b = (_a = value == null ? void 0 : value.split) == null ? void 0 : _a.call(value, ":")) == null ? void 0 : _b.length) === 2;
4692
- }
4693
- );
4694
- const layerField = (schema, meta) => {
4695
- const modifiedSchema = (meta == null ? void 0 : meta.variable) ? /* @__PURE__ */ union([schema, /* @__PURE__ */ pipe(/* @__PURE__ */ string(), linkValidator)]) : schema;
4696
- return /* @__PURE__ */ pipe(/* @__PURE__ */ optional(modifiedSchema), /* @__PURE__ */ metadata(meta ?? {}));
4697
- };
4698
- const ChildrenSchema = /* @__PURE__ */ object({
4699
- children: layerField(/* @__PURE__ */ array(/* @__PURE__ */ string()), {
4700
- fallback: [],
4701
- overridable: false
4702
- })
4703
- });
4704
- const GraphFieldSchema = /* @__PURE__ */ object({
4705
- _id: /* @__PURE__ */ union([/* @__PURE__ */ string(), /* @__PURE__ */ number()]),
4706
- _type: /* @__PURE__ */ picklist(Object.keys(nodes))
4707
- });
4708
- const OverridesSchema = /* @__PURE__ */ object({
4709
- overrides: layerField(/* @__PURE__ */ array(/* @__PURE__ */ string()), { overridable: false })
4710
- });
4711
- const PositionSchema = /* @__PURE__ */ object({
4712
- position: layerField(/* @__PURE__ */ enum_(Object.keys(positionType)), {
4713
- fallback: positionType.absolute
4714
- }),
4715
- top: layerField(/* @__PURE__ */ number(), { fallback: 0 }),
4716
- left: layerField(/* @__PURE__ */ number(), { fallback: 0 })
4717
- });
4718
- const SceneSchema = /* @__PURE__ */ object({
4719
- opacity: layerField(/* @__PURE__ */ pipe(/* @__PURE__ */ number(), /* @__PURE__ */ minValue(0), /* @__PURE__ */ maxValue(1)), {
4720
- fallback: 1,
4721
- variable: true
4722
- }),
4723
- visible: layerField(/* @__PURE__ */ boolean(), { fallback: true, variable: true }),
4724
- zIndex: layerField(/* @__PURE__ */ number(), { fallback: -1 }),
4725
- borderRadius: layerField(/* @__PURE__ */ string(), { fallback: "0px" }),
4726
- overflow: layerField(/* @__PURE__ */ picklist(Object.keys(overflow)), {
4727
- fallback: overflow.hidden
4728
- })
4729
- });
4730
- const FillSchema = /* @__PURE__ */ object({
4731
- fillType: layerField(/* @__PURE__ */ picklist(Object.keys(paintMode)), {
4732
- fallback: paintMode.None
4733
- }),
4734
- solidFill: layerField(/* @__PURE__ */ string(), { fallback: "#fff" })
4735
- });
4736
- const BorderSchema = /* @__PURE__ */ object({
4737
- borderType: layerField(/* @__PURE__ */ picklist(Object.keys(borderType)), {
4738
- fallback: borderType.None
4739
- }),
4740
- borderWidth: layerField(/* @__PURE__ */ pipe(/* @__PURE__ */ number(), /* @__PURE__ */ minValue(0)), { fallback: 0 }),
4741
- borderColor: layerField(/* @__PURE__ */ string(), { fallback: "#fff" })
4742
- });
4743
- const SizeSchema = /* @__PURE__ */ object({
4744
- widthType: layerField(/* @__PURE__ */ picklist(Object.keys(sizing)), {
4745
- fallback: sizing.Fixed
4746
- }),
4747
- heightType: layerField(/* @__PURE__ */ picklist(Object.keys(sizing)), {
4748
- fallback: sizing.Fixed
4749
- }),
4750
- width: layerField(/* @__PURE__ */ pipe(/* @__PURE__ */ number(), /* @__PURE__ */ minValue(0)), { fallback: 0 }),
4751
- height: layerField(/* @__PURE__ */ pipe(/* @__PURE__ */ number(), /* @__PURE__ */ minValue(0)), { fallback: 0 }),
4752
- aspectRatio: layerField(/* @__PURE__ */ number(), { fallback: -1 })
4753
- });
4754
- const LayerSchema = /* @__PURE__ */ object({
4755
- layerMode: layerField(/* @__PURE__ */ picklist(Object.keys(layerMode)), {
4756
- fallback: layerMode.none
4757
- }),
4758
- layerAlign: layerField(/* @__PURE__ */ picklist(Object.keys(layerAlign)), {
4759
- fallback: layerAlign.start
4760
- }),
4761
- layerDirection: layerField(/* @__PURE__ */ picklist(Object.keys(layerDirection)), {
4762
- fallback: layerDirection.horizontal
4763
- }),
4764
- layerDistribute: layerField(/* @__PURE__ */ picklist(Object.keys(layerDistribute)), {
4765
- fallback: layerDistribute.start
4766
- }),
4767
- layerWrap: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
4768
- layerGap: layerField(/* @__PURE__ */ pipe(/* @__PURE__ */ number(), /* @__PURE__ */ minValue(0)), { fallback: 0 }),
4769
- padding: layerField(/* @__PURE__ */ string(), { fallback: "0px" })
4770
- });
4771
- /* @__PURE__ */ pipe(
4772
- /* @__PURE__ */ object({
4773
- name: layerField(/* @__PURE__ */ string(), { fallback: "Frame", overridable: false }),
4774
- isBreakpoint: layerField(/* @__PURE__ */ boolean(), {
4775
- fallback: false,
4776
- overridable: false
4777
- }),
4778
- isPrimary: layerField(/* @__PURE__ */ boolean(), { fallback: false, overridable: false }),
4779
- threshold: layerField(/* @__PURE__ */ pipe(/* @__PURE__ */ number(), /* @__PURE__ */ minValue(0)), {
4780
- fallback: 320,
4781
- overridable: false
4782
- }),
4783
- ...ChildrenSchema.entries,
4784
- ...GraphFieldSchema.entries,
4785
- ...OverridesSchema.entries,
4786
- ...PositionSchema.entries,
4787
- ...SceneSchema.entries,
4788
- ...FillSchema.entries,
4789
- ...BorderSchema.entries,
4790
- ...SizeSchema.entries,
4791
- ...LayerSchema.entries
4792
- })
4793
- );
4794
- /* @__PURE__ */ object({
4795
- name: layerField(/* @__PURE__ */ string(), { fallback: "Text", overridable: false }),
4796
- content: layerField(/* @__PURE__ */ string(), {
4797
- fallback: ""
4798
- }),
4799
- variableContent: layerField(/* @__PURE__ */ string(), { fallback: null, variable: true }),
4800
- attributes: layerField(
4801
- /* @__PURE__ */ object({
4802
- fontSize: layerField(/* @__PURE__ */ string(), { fallback: "14px" }),
4803
- color: layerField(/* @__PURE__ */ string(), { fallback: "#000" }),
4804
- lineHeight: layerField(/* @__PURE__ */ string(), { fallback: "14px" })
4805
- }),
4806
- { fallback: {} }
4807
- ),
4808
- ...GraphFieldSchema.entries,
4809
- ...OverridesSchema.entries,
4810
- ...PositionSchema.entries,
4811
- ...SceneSchema.entries,
4812
- ...SizeSchema.entries
4813
- });
4814
- /* @__PURE__ */ object({
4815
- name: layerField(/* @__PURE__ */ string(), { fallback: "Fragment", overridable: false }),
4816
- horizontalGrow: layerField(/* @__PURE__ */ enum_(Object.keys(fragmentGrowingMode)), {
4817
- fallback: fragmentGrowingMode.auto,
4818
- overridable: false
4819
- }),
4820
- verticalGrow: layerField(/* @__PURE__ */ enum_(Object.keys(fragmentGrowingMode)), {
4821
- fallback: fragmentGrowingMode.auto,
4822
- overridable: false
4823
- }),
4824
- properties: layerField(/* @__PURE__ */ array(/* @__PURE__ */ string()), {
4825
- fallback: [],
4826
- overridable: false
4827
- }),
4828
- ...GraphFieldSchema.entries,
4829
- ...ChildrenSchema.entries
4830
- });
4831
- /* @__PURE__ */ object({
4832
- name: layerField(/* @__PURE__ */ string(), { fallback: "Instance", overridable: false }),
4833
- fragment: layerField(/* @__PURE__ */ string()),
4834
- props: layerField(
4835
- /* @__PURE__ */ record(/* @__PURE__ */ string(), /* @__PURE__ */ union([/* @__PURE__ */ string(), /* @__PURE__ */ number(), /* @__PURE__ */ boolean()])),
4836
- {
4837
- fallback: {}
4838
- }
4839
- ),
4840
- ...GraphFieldSchema.entries,
4841
- ...OverridesSchema.entries,
4842
- ...PositionSchema.entries,
4843
- ...SizeSchema.entries,
4844
- ...SceneSchema.entries
4845
- });
4846
- /* @__PURE__ */ object({
4847
- name: layerField(/* @__PURE__ */ string(), {
4848
- fallback: "Number",
4849
- overridable: false
4850
- }),
4851
- type: layerField(/* @__PURE__ */ literal(variableType.Number), {
4852
- fallback: variableType.Number
4853
- }),
4854
- defaultValue: layerField(/* @__PURE__ */ number(), { fallback: 0 }),
4855
- required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
4856
- min: layerField(/* @__PURE__ */ number(), { fallback: 1 }),
4857
- max: layerField(/* @__PURE__ */ number(), { fallback: 100 }),
4858
- step: layerField(/* @__PURE__ */ number(), { fallback: 1 }),
4859
- displayStepper: layerField(/* @__PURE__ */ boolean(), { fallback: true }),
4860
- ...GraphFieldSchema.entries
4861
- });
4862
- /* @__PURE__ */ object({
4863
- name: layerField(/* @__PURE__ */ string(), {
4864
- fallback: "Boolean",
4865
- overridable: false
4866
- }),
4867
- type: layerField(/* @__PURE__ */ literal(variableType.Boolean), {
4868
- fallback: variableType.Boolean
4869
- }),
4870
- defaultValue: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
4871
- required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
4872
- ...GraphFieldSchema.entries
4873
- });
4874
- /* @__PURE__ */ object({
4875
- name: layerField(/* @__PURE__ */ string(), {
4876
- fallback: "String",
4877
- overridable: false
4878
- }),
4879
- type: layerField(/* @__PURE__ */ literal(variableType.Color), {
4880
- fallback: variableType.Color
4881
- }),
4882
- // TODO Add color validator
4883
- defaultValue: layerField(/* @__PURE__ */ string(), { fallback: "#000" }),
4884
- required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
4885
- ...GraphFieldSchema.entries
4886
- });
4887
- /* @__PURE__ */ object({
4888
- name: layerField(/* @__PURE__ */ string(), {
4889
- fallback: "String",
4890
- overridable: false
4891
- }),
4892
- type: layerField(/* @__PURE__ */ literal(variableType.String), {
4893
- fallback: variableType.String
4894
- }),
4895
- defaultValue: layerField(/* @__PURE__ */ string(), { fallback: "" }),
4896
- required: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
4897
- placeholder: layerField(/* @__PURE__ */ string(), { fallback: "" }),
4898
- isTextarea: layerField(/* @__PURE__ */ boolean(), { fallback: false }),
4899
- ...GraphFieldSchema.entries
4900
- });
4901
441
  const useRenderTarget = () => {
4902
442
  const globalManager = useGlobalManager();
4903
443
  const [globalManagerGraph] = y(globalManager, globalManager == null ? void 0 : globalManager.key);
4904
- const renderTargetValue = (globalManagerGraph == null ? void 0 : globalManagerGraph.renderTarget) ?? index.renderTarget.canvas;
444
+ const renderTargetValue = (globalManagerGraph == null ? void 0 : globalManagerGraph.renderTarget) ?? definition.renderTarget.canvas;
4905
445
  return {
4906
446
  renderTarget: renderTargetValue,
4907
- isCanvas: renderTargetValue === index.renderTarget.canvas,
4908
- isDocument: renderTargetValue === index.renderTarget.document,
447
+ isCanvas: renderTargetValue === definition.renderTarget.canvas,
448
+ isDocument: renderTargetValue === definition.renderTarget.document,
4909
449
  setRenderTarget: (target) => {
4910
450
  globalManager == null ? void 0 : globalManager.setRenderTarget(target);
4911
451
  }