@saas-ui/react 3.0.0-alpha.7 → 3.0.0-alpha.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,10 +1,8 @@
1
1
  'use client'
2
2
  "use strict";
3
- var __create = Object.create;
4
3
  var __defProp = Object.defineProperty;
5
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
7
  var __export = (target, all) => {
10
8
  for (var name in all)
@@ -18,14 +16,6 @@ var __copyProps = (to, from, except, desc) => {
18
16
  }
19
17
  return to;
20
18
  };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
19
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
20
 
31
21
  // src/components/loading-overlay/index.ts
@@ -43,1881 +33,39 @@ __export(loading_overlay_exports, {
43
33
  Spinner: () => LoadingOverlaySpinner,
44
34
  Text: () => LoadingOverlayText
45
35
  });
36
+ var import_presence = require("@ark-ui/react/presence");
37
+ var import_react4 = require("@chakra-ui/react");
46
38
 
47
- // ../../node_modules/@ark-ui/react/dist/components/presence/presence.js
48
- var import_jsx_runtime2 = require("react/jsx-runtime");
49
- var import_react6 = require("react");
50
-
51
- // ../../node_modules/@ark-ui/react/dist/utils/compose-refs.js
52
- function setRef(ref2, value) {
53
- if (typeof ref2 === "function") {
54
- ref2(value);
55
- } else if (ref2 !== null && ref2 !== void 0) {
56
- ref2.current = value;
57
- }
58
- }
59
- function composeRefs(...refs) {
60
- return (node) => {
61
- for (const ref2 of refs) {
62
- setRef(ref2, node);
63
- }
64
- };
65
- }
66
-
67
- // ../../node_modules/proxy-compare/dist/index.js
68
- var TRACK_MEMO_SYMBOL = Symbol();
69
- var GET_ORIGINAL_SYMBOL = Symbol();
70
- var AFFECTED_PROPERTY = "a";
71
- var IS_TARGET_COPIED_PROPERTY = "f";
72
- var PROXY_PROPERTY = "p";
73
- var PROXY_CACHE_PROPERTY = "c";
74
- var TARGET_CACHE_PROPERTY = "t";
75
- var NEXT_OBJECT_PROPERTY = "n";
76
- var CHANGED_PROPERTY = "g";
77
- var HAS_KEY_PROPERTY = "h";
78
- var ALL_OWN_KEYS_PROPERTY = "w";
79
- var HAS_OWN_KEY_PROPERTY = "o";
80
- var KEYS_PROPERTY = "k";
81
- var newProxy = (target, handler) => new Proxy(target, handler);
82
- var getProto = Object.getPrototypeOf;
83
- var objectsToTrack = /* @__PURE__ */ new WeakMap();
84
- var isObjectToTrack = (obj) => obj && (objectsToTrack.has(obj) ? objectsToTrack.get(obj) : getProto(obj) === Object.prototype || getProto(obj) === Array.prototype);
85
- var isObject = (x) => typeof x === "object" && x !== null;
86
- var needsToCopyTargetObject = (obj) => Object.values(Object.getOwnPropertyDescriptors(obj)).some((descriptor) => !descriptor.configurable && !descriptor.writable);
87
- var copyTargetObject = (obj) => {
88
- if (Array.isArray(obj)) {
89
- return Array.from(obj);
90
- }
91
- const descriptors = Object.getOwnPropertyDescriptors(obj);
92
- Object.values(descriptors).forEach((desc) => {
93
- desc.configurable = true;
94
- });
95
- return Object.create(getProto(obj), descriptors);
96
- };
97
- var createProxyHandler = (origObj, isTargetCopied) => {
98
- const state = {
99
- [IS_TARGET_COPIED_PROPERTY]: isTargetCopied
100
- };
101
- let trackObject = false;
102
- const recordUsage = (type, key) => {
103
- if (!trackObject) {
104
- let used = state[AFFECTED_PROPERTY].get(origObj);
105
- if (!used) {
106
- used = {};
107
- state[AFFECTED_PROPERTY].set(origObj, used);
108
- }
109
- if (type === ALL_OWN_KEYS_PROPERTY) {
110
- used[ALL_OWN_KEYS_PROPERTY] = true;
111
- } else {
112
- let set2 = used[type];
113
- if (!set2) {
114
- set2 = /* @__PURE__ */ new Set();
115
- used[type] = set2;
116
- }
117
- set2.add(key);
118
- }
119
- }
120
- };
121
- const recordObjectAsUsed = () => {
122
- trackObject = true;
123
- state[AFFECTED_PROPERTY].delete(origObj);
124
- };
125
- const handler = {
126
- get(target, key) {
127
- if (key === GET_ORIGINAL_SYMBOL) {
128
- return origObj;
129
- }
130
- recordUsage(KEYS_PROPERTY, key);
131
- return createProxy(Reflect.get(target, key), state[AFFECTED_PROPERTY], state[PROXY_CACHE_PROPERTY], state[TARGET_CACHE_PROPERTY]);
132
- },
133
- has(target, key) {
134
- if (key === TRACK_MEMO_SYMBOL) {
135
- recordObjectAsUsed();
136
- return true;
137
- }
138
- recordUsage(HAS_KEY_PROPERTY, key);
139
- return Reflect.has(target, key);
140
- },
141
- getOwnPropertyDescriptor(target, key) {
142
- recordUsage(HAS_OWN_KEY_PROPERTY, key);
143
- return Reflect.getOwnPropertyDescriptor(target, key);
144
- },
145
- ownKeys(target) {
146
- recordUsage(ALL_OWN_KEYS_PROPERTY);
147
- return Reflect.ownKeys(target);
148
- }
149
- };
150
- if (isTargetCopied) {
151
- handler.set = handler.deleteProperty = () => false;
152
- }
153
- return [handler, state];
154
- };
155
- var getOriginalObject = (obj) => (
156
- // unwrap proxy
157
- obj[GET_ORIGINAL_SYMBOL] || // otherwise
158
- obj
159
- );
160
- var createProxy = (obj, affected, proxyCache, targetCache2) => {
161
- if (!isObjectToTrack(obj))
162
- return obj;
163
- let targetAndCopied = targetCache2 && targetCache2.get(obj);
164
- if (!targetAndCopied) {
165
- const target2 = getOriginalObject(obj);
166
- if (needsToCopyTargetObject(target2)) {
167
- targetAndCopied = [target2, copyTargetObject(target2)];
168
- } else {
169
- targetAndCopied = [target2];
170
- }
171
- targetCache2 === null || targetCache2 === void 0 ? void 0 : targetCache2.set(obj, targetAndCopied);
172
- }
173
- const [target, copiedTarget] = targetAndCopied;
174
- let handlerAndState = proxyCache && proxyCache.get(target);
175
- if (!handlerAndState || handlerAndState[1][IS_TARGET_COPIED_PROPERTY] !== !!copiedTarget) {
176
- handlerAndState = createProxyHandler(target, !!copiedTarget);
177
- handlerAndState[1][PROXY_PROPERTY] = newProxy(copiedTarget || target, handlerAndState[0]);
178
- if (proxyCache) {
179
- proxyCache.set(target, handlerAndState);
180
- }
181
- }
182
- handlerAndState[1][AFFECTED_PROPERTY] = affected;
183
- handlerAndState[1][PROXY_CACHE_PROPERTY] = proxyCache;
184
- handlerAndState[1][TARGET_CACHE_PROPERTY] = targetCache2;
185
- return handlerAndState[1][PROXY_PROPERTY];
186
- };
187
- var isAllOwnKeysChanged = (prevObj, nextObj) => {
188
- const prevKeys = Reflect.ownKeys(prevObj);
189
- const nextKeys = Reflect.ownKeys(nextObj);
190
- return prevKeys.length !== nextKeys.length || prevKeys.some((k, i) => k !== nextKeys[i]);
191
- };
192
- var isChanged = (prevObj, nextObj, affected, cache, isEqual2 = Object.is) => {
193
- if (isEqual2(prevObj, nextObj)) {
194
- return false;
195
- }
196
- if (!isObject(prevObj) || !isObject(nextObj))
197
- return true;
198
- const used = affected.get(getOriginalObject(prevObj));
199
- if (!used)
200
- return true;
201
- if (cache) {
202
- const hit = cache.get(prevObj);
203
- if (hit && hit[NEXT_OBJECT_PROPERTY] === nextObj) {
204
- return hit[CHANGED_PROPERTY];
205
- }
206
- cache.set(prevObj, {
207
- [NEXT_OBJECT_PROPERTY]: nextObj,
208
- [CHANGED_PROPERTY]: false
209
- });
210
- }
211
- let changed = null;
212
- try {
213
- for (const key of used[HAS_KEY_PROPERTY] || []) {
214
- changed = Reflect.has(prevObj, key) !== Reflect.has(nextObj, key);
215
- if (changed)
216
- return changed;
217
- }
218
- if (used[ALL_OWN_KEYS_PROPERTY] === true) {
219
- changed = isAllOwnKeysChanged(prevObj, nextObj);
220
- if (changed)
221
- return changed;
222
- } else {
223
- for (const key of used[HAS_OWN_KEY_PROPERTY] || []) {
224
- const hasPrev = !!Reflect.getOwnPropertyDescriptor(prevObj, key);
225
- const hasNext = !!Reflect.getOwnPropertyDescriptor(nextObj, key);
226
- changed = hasPrev !== hasNext;
227
- if (changed)
228
- return changed;
229
- }
230
- }
231
- for (const key of used[KEYS_PROPERTY] || []) {
232
- changed = isChanged(prevObj[key], nextObj[key], affected, cache, isEqual2);
233
- if (changed)
234
- return changed;
235
- }
236
- if (changed === null)
237
- changed = true;
238
- return changed;
239
- } finally {
240
- if (cache) {
241
- cache.set(prevObj, {
242
- [NEXT_OBJECT_PROPERTY]: nextObj,
243
- [CHANGED_PROPERTY]: changed
244
- });
245
- }
246
- }
247
- };
248
- var getUntracked = (obj) => {
249
- if (isObjectToTrack(obj)) {
250
- return obj[GET_ORIGINAL_SYMBOL] || null;
251
- }
252
- return null;
253
- };
254
- var markToTrack = (obj, mark = true) => {
255
- objectsToTrack.set(obj, mark);
256
- };
257
-
258
- // ../../node_modules/@zag-js/store/dist/index.mjs
259
- function getGlobal() {
260
- if (typeof globalThis !== "undefined") return globalThis;
261
- if (typeof self !== "undefined") return self;
262
- if (typeof window !== "undefined") return window;
263
- if (typeof global !== "undefined") return global;
264
- }
265
- function makeGlobal(key, value) {
266
- const g = getGlobal();
267
- if (!g) return value();
268
- g[key] || (g[key] = value());
269
- return g[key];
270
- }
271
- var isDev = () => process.env.NODE_ENV !== "production";
272
- var isObject2 = (x) => typeof x === "object" && x !== null;
273
- var proxyStateMap = makeGlobal("__zag__proxyStateMap", () => /* @__PURE__ */ new WeakMap());
274
- var refSet = makeGlobal("__zag__refSet", () => /* @__PURE__ */ new WeakSet());
275
- var isReactElement = (x) => typeof x === "object" && x !== null && "$$typeof" in x;
276
- var isVueElement = (x) => typeof x === "object" && x !== null && "__v_isVNode" in x;
277
- var isDOMElement = (x) => typeof x === "object" && x !== null && "nodeType" in x && typeof x.nodeName === "string";
278
- var isElement = (x) => isReactElement(x) || isVueElement(x) || isDOMElement(x);
279
- var buildProxyFunction = (objectIs = Object.is, newProxy2 = (target, handler) => new Proxy(target, handler), canProxy = (x) => isObject2(x) && !refSet.has(x) && (Array.isArray(x) || !(Symbol.iterator in x)) && !isElement(x) && !(x instanceof WeakMap) && !(x instanceof WeakSet) && !(x instanceof Error) && !(x instanceof Number) && !(x instanceof Date) && !(x instanceof String) && !(x instanceof RegExp) && !(x instanceof ArrayBuffer), defaultHandlePromise = (promise) => {
280
- switch (promise.status) {
281
- case "fulfilled":
282
- return promise.value;
283
- case "rejected":
284
- throw promise.reason;
285
- default:
286
- throw promise;
287
- }
288
- }, snapCache = /* @__PURE__ */ new WeakMap(), createSnapshot = (target, version, handlePromise = defaultHandlePromise) => {
289
- const cache = snapCache.get(target);
290
- if ((cache == null ? void 0 : cache[0]) === version) {
291
- return cache[1];
292
- }
293
- const snap = Array.isArray(target) ? [] : Object.create(Object.getPrototypeOf(target));
294
- markToTrack(snap, true);
295
- snapCache.set(target, [version, snap]);
296
- Reflect.ownKeys(target).forEach((key) => {
297
- const value = Reflect.get(target, key);
298
- if (refSet.has(value)) {
299
- markToTrack(value, false);
300
- snap[key] = value;
301
- } else if (value instanceof Promise) {
302
- Object.defineProperty(snap, key, {
303
- get() {
304
- return handlePromise(value);
305
- }
306
- });
307
- } else if (proxyStateMap.has(value)) {
308
- snap[key] = snapshot(value, handlePromise);
309
- } else {
310
- snap[key] = value;
311
- }
312
- });
313
- return Object.freeze(snap);
314
- }, proxyCache = /* @__PURE__ */ new WeakMap(), versionHolder = [1, 1], proxyFunction2 = (initialObject) => {
315
- if (!isObject2(initialObject)) {
316
- throw new Error("object required");
317
- }
318
- const found = proxyCache.get(initialObject);
319
- if (found) {
320
- return found;
321
- }
322
- let version = versionHolder[0];
323
- const listeners = /* @__PURE__ */ new Set();
324
- const notifyUpdate = (op, nextVersion = ++versionHolder[0]) => {
325
- if (version !== nextVersion) {
326
- version = nextVersion;
327
- listeners.forEach((listener) => listener(op, nextVersion));
328
- }
329
- };
330
- let checkVersion = versionHolder[1];
331
- const ensureVersion = (nextCheckVersion = ++versionHolder[1]) => {
332
- if (checkVersion !== nextCheckVersion && !listeners.size) {
333
- checkVersion = nextCheckVersion;
334
- propProxyStates.forEach(([propProxyState]) => {
335
- const propVersion = propProxyState[1](nextCheckVersion);
336
- if (propVersion > version) {
337
- version = propVersion;
338
- }
339
- });
340
- }
341
- return version;
342
- };
343
- const createPropListener = (prop) => (op, nextVersion) => {
344
- const newOp = [...op];
345
- newOp[1] = [prop, ...newOp[1]];
346
- notifyUpdate(newOp, nextVersion);
347
- };
348
- const propProxyStates = /* @__PURE__ */ new Map();
349
- const addPropListener = (prop, propProxyState) => {
350
- if (isDev() && propProxyStates.has(prop)) {
351
- throw new Error("prop listener already exists");
352
- }
353
- if (listeners.size) {
354
- const remove = propProxyState[3](createPropListener(prop));
355
- propProxyStates.set(prop, [propProxyState, remove]);
356
- } else {
357
- propProxyStates.set(prop, [propProxyState]);
358
- }
359
- };
360
- const removePropListener = (prop) => {
361
- var _a;
362
- const entry = propProxyStates.get(prop);
363
- if (entry) {
364
- propProxyStates.delete(prop);
365
- (_a = entry[1]) == null ? void 0 : _a.call(entry);
366
- }
367
- };
368
- const addListener = (listener) => {
369
- listeners.add(listener);
370
- if (listeners.size === 1) {
371
- propProxyStates.forEach(([propProxyState, prevRemove], prop) => {
372
- if (isDev() && prevRemove) {
373
- throw new Error("remove already exists");
374
- }
375
- const remove = propProxyState[3](createPropListener(prop));
376
- propProxyStates.set(prop, [propProxyState, remove]);
377
- });
378
- }
379
- const removeListener = () => {
380
- listeners.delete(listener);
381
- if (listeners.size === 0) {
382
- propProxyStates.forEach(([propProxyState, remove], prop) => {
383
- if (remove) {
384
- remove();
385
- propProxyStates.set(prop, [propProxyState]);
386
- }
387
- });
388
- }
389
- };
390
- return removeListener;
391
- };
392
- const baseObject = Array.isArray(initialObject) ? [] : Object.create(Object.getPrototypeOf(initialObject));
393
- const handler = {
394
- deleteProperty(target, prop) {
395
- const prevValue = Reflect.get(target, prop);
396
- removePropListener(prop);
397
- const deleted = Reflect.deleteProperty(target, prop);
398
- if (deleted) {
399
- notifyUpdate(["delete", [prop], prevValue]);
400
- }
401
- return deleted;
402
- },
403
- set(target, prop, value, receiver) {
404
- var _a;
405
- const hasPrevValue = Reflect.has(target, prop);
406
- const prevValue = Reflect.get(target, prop, receiver);
407
- if (hasPrevValue && (objectIs(prevValue, value) || proxyCache.has(value) && objectIs(prevValue, proxyCache.get(value)))) {
408
- return true;
409
- }
410
- removePropListener(prop);
411
- if (isObject2(value)) {
412
- value = getUntracked(value) || value;
413
- }
414
- let nextValue = value;
415
- if ((_a = Object.getOwnPropertyDescriptor(target, prop)) == null ? void 0 : _a.set) ;
416
- else if (value instanceof Promise) {
417
- value.then((v) => {
418
- Object.assign(value, { status: "fulfilled", value: v });
419
- notifyUpdate(["resolve", [prop], v]);
420
- }).catch((e) => {
421
- Object.assign(value, { status: "rejected", reason: e });
422
- notifyUpdate(["reject", [prop], e]);
423
- });
424
- } else {
425
- if (!proxyStateMap.has(value) && canProxy(value)) {
426
- nextValue = proxy(value);
427
- }
428
- const childProxyState = !refSet.has(nextValue) && proxyStateMap.get(nextValue);
429
- if (childProxyState) {
430
- addPropListener(prop, childProxyState);
431
- }
432
- }
433
- Reflect.set(target, prop, nextValue, receiver);
434
- notifyUpdate(["set", [prop], value, prevValue]);
435
- return true;
436
- }
437
- };
438
- const proxyObject = newProxy2(baseObject, handler);
439
- proxyCache.set(initialObject, proxyObject);
440
- const proxyState = [baseObject, ensureVersion, createSnapshot, addListener];
441
- proxyStateMap.set(proxyObject, proxyState);
442
- Reflect.ownKeys(initialObject).forEach((key) => {
443
- const desc = Object.getOwnPropertyDescriptor(initialObject, key);
444
- if (desc.get || desc.set) {
445
- Object.defineProperty(baseObject, key, desc);
446
- } else {
447
- proxyObject[key] = initialObject[key];
448
- }
449
- });
450
- return proxyObject;
451
- }) => [
452
- // public functions
453
- proxyFunction2,
454
- // shared state
455
- proxyStateMap,
456
- refSet,
457
- // internal things
458
- objectIs,
459
- newProxy2,
460
- canProxy,
461
- defaultHandlePromise,
462
- snapCache,
463
- createSnapshot,
464
- proxyCache,
465
- versionHolder
466
- ];
467
- var [proxyFunction] = buildProxyFunction();
468
- function proxy(initialObject = {}) {
469
- return proxyFunction(initialObject);
470
- }
471
- function subscribe(proxyObject, callback, notifyInSync) {
472
- const proxyState = proxyStateMap.get(proxyObject);
473
- if (isDev() && !proxyState) {
474
- console.warn("Please use proxy object");
475
- }
476
- let promise;
477
- const ops = [];
478
- const addListener = proxyState[3];
479
- let isListenerActive = false;
480
- const listener = (op) => {
481
- ops.push(op);
482
- if (notifyInSync) {
483
- callback(ops.splice(0));
484
- return;
485
- }
486
- if (!promise) {
487
- promise = Promise.resolve().then(() => {
488
- promise = void 0;
489
- if (isListenerActive) {
490
- callback(ops.splice(0));
491
- }
492
- });
493
- }
494
- };
495
- const removeListener = addListener(listener);
496
- isListenerActive = true;
497
- return () => {
498
- isListenerActive = false;
499
- removeListener();
500
- };
501
- }
502
- function snapshot(proxyObject, handlePromise) {
503
- const proxyState = proxyStateMap.get(proxyObject);
504
- if (isDev() && !proxyState) {
505
- console.warn("Please use proxy object");
506
- }
507
- const [target, ensureVersion, createSnapshot] = proxyState;
508
- return createSnapshot(target, ensureVersion(), handlePromise);
509
- }
510
- function ref(obj) {
511
- refSet.add(obj);
512
- return obj;
513
- }
514
- function proxyWithComputed(initialObject, computedFns) {
515
- const keys = Object.keys(computedFns);
516
- keys.forEach((key) => {
517
- if (Object.getOwnPropertyDescriptor(initialObject, key)) {
518
- throw new Error("object property already defined");
519
- }
520
- const computedFn = computedFns[key];
521
- const { get, set: set2 } = typeof computedFn === "function" ? { get: computedFn } : computedFn;
522
- const desc = {};
523
- desc.get = () => get(snapshot(proxyObject));
524
- if (set2) {
525
- desc.set = (newValue) => set2(proxyObject, newValue);
526
- }
527
- Object.defineProperty(initialObject, key, desc);
528
- });
529
- const proxyObject = proxy(initialObject);
530
- return proxyObject;
531
- }
532
-
533
- // ../../node_modules/@zag-js/utils/dist/index.mjs
534
- function clear(v) {
535
- while (v.length > 0) v.pop();
536
- return v;
537
- }
538
- var runIfFn = (v, ...a) => {
539
- const res = typeof v === "function" ? v(...a) : v;
540
- return res != null ? res : void 0;
541
- };
542
- var cast = (v) => v;
543
- var noop = () => {
544
- };
545
- var callAll = (...fns) => (...a) => {
546
- fns.forEach(function(fn) {
547
- fn == null ? void 0 : fn(...a);
548
- });
549
- };
550
- var uuid = /* @__PURE__ */ (() => {
551
- let id = 0;
552
- return () => {
553
- id++;
554
- return id.toString(36);
555
- };
556
- })();
557
- var isDev2 = () => process.env.NODE_ENV !== "production";
558
- var isArray = (v) => Array.isArray(v);
559
- var isObjectLike = (v) => v != null && typeof v === "object";
560
- var isObject3 = (v) => isObjectLike(v) && !isArray(v);
561
- var isNumber = (v) => typeof v === "number" && !Number.isNaN(v);
562
- var isString = (v) => typeof v === "string";
563
- var isFunction = (v) => typeof v === "function";
564
- var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
565
- var baseGetTag = (v) => Object.prototype.toString.call(v);
566
- var fnToString = Function.prototype.toString;
567
- var objectCtorString = fnToString.call(Object);
568
- var isPlainObject = (v) => {
569
- if (!isObjectLike(v) || baseGetTag(v) != "[object Object]") return false;
570
- const proto = Object.getPrototypeOf(v);
571
- if (proto === null) return true;
572
- const Ctor = hasProp(proto, "constructor") && proto.constructor;
573
- return typeof Ctor == "function" && Ctor instanceof Ctor && fnToString.call(Ctor) == objectCtorString;
574
- };
575
- function compact(obj) {
576
- if (!isPlainObject2(obj) || obj === void 0) {
577
- return obj;
578
- }
579
- const keys = Reflect.ownKeys(obj).filter((key) => typeof key === "string");
580
- const filtered = {};
581
- for (const key of keys) {
582
- const value = obj[key];
583
- if (value !== void 0) {
584
- filtered[key] = compact(value);
585
- }
586
- }
587
- return filtered;
588
- }
589
- var isPlainObject2 = (value) => {
590
- return value && typeof value === "object" && value.constructor === Object;
591
- };
592
- function warn(...a) {
593
- const m = a.length === 1 ? a[0] : a[1];
594
- const c = a.length === 2 ? a[0] : true;
595
- if (c && process.env.NODE_ENV !== "production") {
596
- console.warn(m);
597
- }
598
- }
599
- function invariant(...a) {
600
- const m = a.length === 1 ? a[0] : a[1];
601
- const c = a.length === 2 ? a[0] : true;
602
- if (c && process.env.NODE_ENV !== "production") {
603
- throw new Error(m);
604
- }
605
- }
606
-
607
- // ../../node_modules/klona/full/index.mjs
608
- function set(obj, key, val) {
609
- if (typeof val.value === "object") val.value = klona(val.value);
610
- if (!val.enumerable || val.get || val.set || !val.configurable || !val.writable || key === "__proto__") {
611
- Object.defineProperty(obj, key, val);
612
- } else obj[key] = val.value;
613
- }
614
- function klona(x) {
615
- if (typeof x !== "object") return x;
616
- var i = 0, k, list, tmp, str = Object.prototype.toString.call(x);
617
- if (str === "[object Object]") {
618
- tmp = Object.create(x.__proto__ || null);
619
- } else if (str === "[object Array]") {
620
- tmp = Array(x.length);
621
- } else if (str === "[object Set]") {
622
- tmp = /* @__PURE__ */ new Set();
623
- x.forEach(function(val) {
624
- tmp.add(klona(val));
625
- });
626
- } else if (str === "[object Map]") {
627
- tmp = /* @__PURE__ */ new Map();
628
- x.forEach(function(val, key) {
629
- tmp.set(klona(key), klona(val));
630
- });
631
- } else if (str === "[object Date]") {
632
- tmp = /* @__PURE__ */ new Date(+x);
633
- } else if (str === "[object RegExp]") {
634
- tmp = new RegExp(x.source, x.flags);
635
- } else if (str === "[object DataView]") {
636
- tmp = new x.constructor(klona(x.buffer));
637
- } else if (str === "[object ArrayBuffer]") {
638
- tmp = x.slice(0);
639
- } else if (str.slice(-6) === "Array]") {
640
- tmp = new x.constructor(x);
641
- }
642
- if (tmp) {
643
- for (list = Object.getOwnPropertySymbols(x); i < list.length; i++) {
644
- set(tmp, list[i], Object.getOwnPropertyDescriptor(x, list[i]));
645
- }
646
- for (i = 0, list = Object.getOwnPropertyNames(x); i < list.length; i++) {
647
- if (Object.hasOwnProperty.call(tmp, k = list[i]) && tmp[k] === x[k]) continue;
648
- set(tmp, k, Object.getOwnPropertyDescriptor(x, k));
649
- }
650
- }
651
- return tmp || x;
652
- }
653
-
654
- // ../../node_modules/@zag-js/core/dist/index.mjs
655
- var __defProp2 = Object.defineProperty;
656
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
657
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
658
- function deepMerge(source, ...objects) {
659
- for (const obj of objects) {
660
- const target = compact(obj);
661
- for (const key in target) {
662
- if (isPlainObject(obj[key])) {
663
- if (!source[key]) {
664
- source[key] = {};
665
- }
666
- deepMerge(source[key], obj[key]);
667
- } else {
668
- source[key] = obj[key];
669
- }
670
- }
671
- }
672
- return source;
673
- }
674
- function structuredClone(v) {
675
- return klona(v);
676
- }
677
- function toEvent(event) {
678
- const obj = isString(event) ? { type: event } : event;
679
- return obj;
680
- }
681
- function toArray(value) {
682
- if (!value) return [];
683
- return isArray(value) ? value.slice() : [value];
684
- }
685
- function isGuardHelper(value) {
686
- return isObject3(value) && value.predicate != null;
687
- }
688
- var Truthy = () => true;
689
- function determineGuardFn(guard, guardMap) {
690
- guard = guard != null ? guard : Truthy;
691
- return (context, event, meta) => {
692
- if (isString(guard)) {
693
- const value = guardMap[guard];
694
- return isFunction(value) ? value(context, event, meta) : value;
695
- }
696
- if (isGuardHelper(guard)) {
697
- return guard.predicate(guardMap)(context, event, meta);
698
- }
699
- return guard == null ? void 0 : guard(context, event, meta);
700
- };
701
- }
702
- function determineActionsFn(values, guardMap) {
703
- return (context, event, meta) => {
704
- if (isGuardHelper(values)) {
705
- return values.predicate(guardMap)(context, event, meta);
706
- }
707
- return values;
708
- };
709
- }
710
- function createProxy2(config) {
711
- var _a, _b, _c, _d, _e;
712
- const computedContext = (_a = config.computed) != null ? _a : cast({});
713
- const initialContext = (_b = config.context) != null ? _b : cast({});
714
- const initialTags = config.initial ? (_d = (_c = config.states) == null ? void 0 : _c[config.initial]) == null ? void 0 : _d.tags : [];
715
- const state = proxy({
716
- value: (_e = config.initial) != null ? _e : "",
717
- previousValue: "",
718
- event: cast({}),
719
- previousEvent: cast({}),
720
- context: proxyWithComputed(initialContext, computedContext),
721
- done: false,
722
- tags: initialTags != null ? initialTags : [],
723
- hasTag(tag) {
724
- return this.tags.includes(tag);
725
- },
726
- matches(...value) {
727
- return value.includes(this.value);
728
- },
729
- can(event) {
730
- return cast(this).nextEvents.includes(event);
731
- },
732
- get nextEvents() {
733
- var _a2, _b2, _c2, _d2;
734
- const stateEvents = (_c2 = (_b2 = (_a2 = config.states) == null ? void 0 : _a2[this.value]) == null ? void 0 : _b2["on"]) != null ? _c2 : {};
735
- const globalEvents = (_d2 = config == null ? void 0 : config.on) != null ? _d2 : {};
736
- return Object.keys({ ...stateEvents, ...globalEvents });
737
- },
738
- get changed() {
739
- if (this.event.value === "machine.init" || !this.previousValue) return false;
740
- return this.value !== this.previousValue;
741
- }
742
- });
743
- return cast(state);
744
- }
745
- function determineDelayFn(delay, delaysMap) {
746
- return (context, event) => {
747
- if (isNumber(delay)) return delay;
748
- if (isFunction(delay)) {
749
- return delay(context, event);
750
- }
751
- if (isString(delay)) {
752
- const value = Number.parseFloat(delay);
753
- if (!Number.isNaN(value)) {
754
- return value;
755
- }
756
- if (delaysMap) {
757
- const valueOrFn = delaysMap == null ? void 0 : delaysMap[delay];
758
- invariant(
759
- valueOrFn == null,
760
- `[@zag-js/core > determine-delay] Cannot determine delay for \`${delay}\`. It doesn't exist in \`options.delays\``
761
- );
762
- return isFunction(valueOrFn) ? valueOrFn(context, event) : valueOrFn;
763
- }
764
- }
765
- };
766
- }
767
- function toTarget(target) {
768
- return isString(target) ? { target } : target;
769
- }
770
- function determineTransitionFn(transitions, guardMap) {
771
- return (context, event, meta) => {
772
- return toArray(transitions).map(toTarget).find((transition) => {
773
- var _a;
774
- const determineGuard = determineGuardFn(transition.guard, guardMap);
775
- const guard = determineGuard(context, event, meta);
776
- return (_a = guard != null ? guard : transition.target) != null ? _a : transition.actions;
777
- });
778
- };
779
- }
780
- var Machine = class {
781
- // Let's get started!
782
- constructor(config, options) {
783
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
784
- __publicField(
785
- this,
786
- "status",
787
- "Not Started"
788
- /* NotStarted */
789
- );
790
- __publicField(this, "state");
791
- __publicField(this, "initialState");
792
- __publicField(this, "initialContext");
793
- __publicField(this, "id");
794
- __publicField(
795
- this,
796
- "type",
797
- "machine"
798
- /* Machine */
799
- );
800
- __publicField(this, "activityEvents", /* @__PURE__ */ new Map());
801
- __publicField(this, "delayedEvents", /* @__PURE__ */ new Map());
802
- __publicField(this, "stateListeners", /* @__PURE__ */ new Set());
803
- __publicField(this, "doneListeners", /* @__PURE__ */ new Set());
804
- __publicField(this, "contextWatchers", /* @__PURE__ */ new Set());
805
- __publicField(this, "removeStateListener", noop);
806
- __publicField(this, "parent");
807
- __publicField(this, "children", /* @__PURE__ */ new Map());
808
- __publicField(this, "guardMap");
809
- __publicField(this, "actionMap");
810
- __publicField(this, "delayMap");
811
- __publicField(this, "activityMap");
812
- __publicField(this, "sync");
813
- __publicField(this, "options");
814
- __publicField(this, "config");
815
- __publicField(this, "_created", () => {
816
- var _a2;
817
- const event = toEvent(
818
- "machine.created"
819
- /* Created */
820
- );
821
- this.executeActions((_a2 = this.config) == null ? void 0 : _a2.created, event);
822
- });
823
- __publicField(this, "start", (init) => {
824
- this.state.value = "";
825
- this.state.tags = [];
826
- if (this.status === "Running") {
827
- return this;
828
- }
829
- this.status = "Running";
830
- this.removeStateListener = subscribe(
831
- this.state,
832
- () => {
833
- this.stateListeners.forEach((listener) => {
834
- listener(this.stateSnapshot);
835
- });
836
- },
837
- this.sync
838
- );
839
- this.setupContextWatchers();
840
- this.executeActivities(
841
- toEvent(
842
- "machine.start"
843
- /* Start */
844
- ),
845
- toArray(this.config.activities),
846
- "machine.start"
847
- /* Start */
848
- );
849
- this.executeActions(this.config.entry, toEvent(
850
- "machine.start"
851
- /* Start */
852
- ));
853
- const event = toEvent(
854
- "machine.init"
855
- /* Init */
856
- );
857
- const target = isObject3(init) ? init.value : init;
858
- const context = isObject3(init) ? init.context : void 0;
859
- if (context) {
860
- this.setContext(context);
861
- }
862
- const transition = {
863
- target: target != null ? target : this.config.initial
864
- };
865
- const next = this.getNextStateInfo(transition, event);
866
- this.initialState = next;
867
- this.performStateChangeEffects(this.state.value, next, event);
868
- return this;
869
- });
870
- __publicField(this, "setupContextWatchers", () => {
871
- const { watch } = this.config;
872
- if (!watch) return;
873
- let prev = snapshot(this.state.context);
874
- const cleanup = subscribe(this.state.context, () => {
875
- var _a2, _b2;
876
- const next = snapshot(this.state.context);
877
- for (const [key, fn] of Object.entries(watch)) {
878
- const isEqual2 = (_b2 = (_a2 = this.options.compareFns) == null ? void 0 : _a2[key]) != null ? _b2 : Object.is;
879
- if (isEqual2(prev[key], next[key])) continue;
880
- this.executeActions(fn, this.state.event);
881
- }
882
- prev = next;
883
- });
884
- this.contextWatchers.add(cleanup);
885
- });
886
- __publicField(this, "stop", () => {
887
- if (this.status === "Stopped") return;
888
- this.performExitEffects(this.state.value, toEvent(
889
- "machine.stop"
890
- /* Stop */
891
- ));
892
- this.executeActions(this.config.exit, toEvent(
893
- "machine.stop"
894
- /* Stop */
895
- ));
896
- this.setState("");
897
- this.setEvent(
898
- "machine.stop"
899
- /* Stop */
900
- );
901
- this.stopStateListeners();
902
- this.stopChildren();
903
- this.stopActivities();
904
- this.stopDelayedEvents();
905
- this.stopContextWatchers();
906
- this.status = "Stopped";
907
- return this;
908
- });
909
- __publicField(this, "stopStateListeners", () => {
910
- this.removeStateListener();
911
- this.stateListeners.clear();
912
- });
913
- __publicField(this, "stopContextWatchers", () => {
914
- this.contextWatchers.forEach((fn) => fn());
915
- this.contextWatchers.clear();
916
- });
917
- __publicField(this, "stopDelayedEvents", () => {
918
- this.delayedEvents.forEach((state) => {
919
- state.forEach((stop) => stop());
920
- });
921
- this.delayedEvents.clear();
922
- });
923
- __publicField(this, "stopActivities", (state) => {
924
- var _a2, _b2;
925
- if (state) {
926
- (_a2 = this.activityEvents.get(state)) == null ? void 0 : _a2.forEach((stop) => stop());
927
- (_b2 = this.activityEvents.get(state)) == null ? void 0 : _b2.clear();
928
- this.activityEvents.delete(state);
929
- } else {
930
- this.activityEvents.forEach((state2) => {
931
- state2.forEach((stop) => stop());
932
- state2.clear();
933
- });
934
- this.activityEvents.clear();
935
- }
936
- });
937
- __publicField(this, "sendChild", (evt, to) => {
938
- const event = toEvent(evt);
939
- const id = runIfFn(to, this.contextSnapshot);
940
- const child = this.children.get(id);
941
- if (!child) {
942
- invariant(`[@zag-js/core] Cannot send '${event.type}' event to unknown child`);
943
- }
944
- child.send(event);
945
- });
946
- __publicField(this, "stopChild", (id) => {
947
- if (!this.children.has(id)) {
948
- invariant(`[@zag-js/core > stop-child] Cannot stop unknown child ${id}`);
949
- }
950
- this.children.get(id).stop();
951
- this.children.delete(id);
952
- });
953
- __publicField(this, "removeChild", (id) => {
954
- this.children.delete(id);
955
- });
956
- __publicField(this, "stopChildren", () => {
957
- this.children.forEach((child) => child.stop());
958
- this.children.clear();
959
- });
960
- __publicField(this, "setParent", (parent) => {
961
- this.parent = parent;
962
- });
963
- __publicField(this, "spawn", (src, id) => {
964
- const actor = runIfFn(src);
965
- if (id) actor.id = id;
966
- actor.type = "machine.actor";
967
- actor.setParent(this);
968
- this.children.set(actor.id, cast(actor));
969
- actor.onDone(() => {
970
- this.removeChild(actor.id);
971
- }).start();
972
- return cast(ref(actor));
973
- });
974
- __publicField(this, "stopActivity", (key) => {
975
- var _a2;
976
- if (!this.state.value) return;
977
- const cleanups = this.activityEvents.get(this.state.value);
978
- (_a2 = cleanups == null ? void 0 : cleanups.get(key)) == null ? void 0 : _a2();
979
- cleanups == null ? void 0 : cleanups.delete(key);
980
- });
981
- __publicField(this, "addActivityCleanup", (state, key, cleanup) => {
982
- var _a2;
983
- if (!state) return;
984
- if (!this.activityEvents.has(state)) {
985
- this.activityEvents.set(state, /* @__PURE__ */ new Map([[key, cleanup]]));
986
- } else {
987
- (_a2 = this.activityEvents.get(state)) == null ? void 0 : _a2.set(key, cleanup);
988
- }
989
- });
990
- __publicField(this, "setState", (target) => {
991
- this.state.previousValue = this.state.value;
992
- this.state.value = target;
993
- const stateNode = this.getStateNode(target);
994
- if (target == null) {
995
- clear(this.state.tags);
996
- } else {
997
- this.state.tags = toArray(stateNode == null ? void 0 : stateNode.tags);
998
- }
999
- });
1000
- __publicField(this, "setContext", (context) => {
1001
- if (!context) return;
1002
- deepMerge(this.state.context, compact(context));
1003
- });
1004
- __publicField(this, "setOptions", (options2) => {
1005
- const opts = compact(options2);
1006
- this.actionMap = { ...this.actionMap, ...opts.actions };
1007
- this.delayMap = { ...this.delayMap, ...opts.delays };
1008
- this.activityMap = { ...this.activityMap, ...opts.activities };
1009
- this.guardMap = { ...this.guardMap, ...opts.guards };
1010
- });
1011
- __publicField(this, "getStateNode", (state) => {
1012
- var _a2;
1013
- if (!state) return;
1014
- return (_a2 = this.config.states) == null ? void 0 : _a2[state];
1015
- });
1016
- __publicField(this, "getNextStateInfo", (transitions, event) => {
1017
- var _a2;
1018
- const transition = this.determineTransition(transitions, event);
1019
- const isTargetless = !(transition == null ? void 0 : transition.target);
1020
- const target = (_a2 = transition == null ? void 0 : transition.target) != null ? _a2 : this.state.value;
1021
- const changed = this.state.value !== target;
1022
- const stateNode = this.getStateNode(target);
1023
- const reenter = !isTargetless && !changed && !(transition == null ? void 0 : transition.internal);
1024
- const info = {
1025
- reenter,
1026
- transition,
1027
- stateNode,
1028
- target,
1029
- changed
1030
- };
1031
- this.log("NextState:", `[${event.type}]`, this.state.value, "---->", info.target);
1032
- return info;
1033
- });
1034
- __publicField(this, "getAfterActions", (transition, delay) => {
1035
- let id;
1036
- const current = this.state.value;
1037
- return {
1038
- entry: () => {
1039
- id = globalThis.setTimeout(() => {
1040
- const next = this.getNextStateInfo(transition, this.state.event);
1041
- this.performStateChangeEffects(current, next, this.state.event);
1042
- }, delay);
1043
- },
1044
- exit: () => {
1045
- globalThis.clearTimeout(id);
1046
- }
1047
- };
1048
- });
1049
- __publicField(this, "getDelayedEventActions", (state) => {
1050
- const stateNode = this.getStateNode(state);
1051
- const event = this.state.event;
1052
- if (!stateNode || !stateNode.after) return;
1053
- const entries = [];
1054
- const exits = [];
1055
- if (isArray(stateNode.after)) {
1056
- const transition = this.determineTransition(stateNode.after, event);
1057
- if (!transition) return;
1058
- if (!hasProp(transition, "delay")) {
1059
- throw new Error(`[@zag-js/core > after] Delay is required for after transition: ${JSON.stringify(transition)}`);
1060
- }
1061
- const determineDelay = determineDelayFn(transition.delay, this.delayMap);
1062
- const __delay = determineDelay(this.contextSnapshot, event);
1063
- const actions = this.getAfterActions(transition, __delay);
1064
- entries.push(actions.entry);
1065
- exits.push(actions.exit);
1066
- return { entries, exits };
1067
- }
1068
- if (isObject3(stateNode.after)) {
1069
- for (const delay in stateNode.after) {
1070
- const transition = stateNode.after[delay];
1071
- const determineDelay = determineDelayFn(delay, this.delayMap);
1072
- const __delay = determineDelay(this.contextSnapshot, event);
1073
- const actions = this.getAfterActions(transition, __delay);
1074
- entries.push(actions.entry);
1075
- exits.push(actions.exit);
1076
- }
1077
- }
1078
- return { entries, exits };
1079
- });
1080
- __publicField(this, "executeActions", (actions, event) => {
1081
- var _a2;
1082
- const pickedActions = determineActionsFn(actions, this.guardMap)(this.contextSnapshot, event, this.guardMeta);
1083
- for (const action of toArray(pickedActions)) {
1084
- const fn = isString(action) ? (_a2 = this.actionMap) == null ? void 0 : _a2[action] : action;
1085
- warn(
1086
- isString(action) && !fn,
1087
- `[@zag-js/core > execute-actions] No implementation found for action: \`${action}\``
1088
- );
1089
- fn == null ? void 0 : fn(this.state.context, event, this.meta);
1090
- }
1091
- });
1092
- __publicField(this, "executeActivities", (event, activities, state) => {
1093
- var _a2;
1094
- for (const activity of activities) {
1095
- const fn = isString(activity) ? (_a2 = this.activityMap) == null ? void 0 : _a2[activity] : activity;
1096
- if (!fn) {
1097
- warn(`[@zag-js/core > execute-activity] No implementation found for activity: \`${activity}\``);
1098
- continue;
1099
- }
1100
- const cleanup = fn(this.state.context, event, this.meta);
1101
- if (cleanup) {
1102
- const key = isString(activity) ? activity : activity.name || uuid();
1103
- this.addActivityCleanup(state != null ? state : this.state.value, key, cleanup);
1104
- }
1105
- }
1106
- });
1107
- __publicField(this, "createEveryActivities", (every, callbackfn) => {
1108
- if (!every) return;
1109
- if (isArray(every)) {
1110
- const picked = toArray(every).find((transition) => {
1111
- const delayOrFn = transition.delay;
1112
- const determineDelay2 = determineDelayFn(delayOrFn, this.delayMap);
1113
- const delay2 = determineDelay2(this.contextSnapshot, this.state.event);
1114
- const determineGuard = determineGuardFn(transition.guard, this.guardMap);
1115
- const guard = determineGuard(this.contextSnapshot, this.state.event, this.guardMeta);
1116
- return guard != null ? guard : delay2 != null;
1117
- });
1118
- if (!picked) return;
1119
- const determineDelay = determineDelayFn(picked.delay, this.delayMap);
1120
- const delay = determineDelay(this.contextSnapshot, this.state.event);
1121
- const activity = () => {
1122
- const id = globalThis.setInterval(() => {
1123
- this.executeActions(picked.actions, this.state.event);
1124
- }, delay);
1125
- return () => {
1126
- globalThis.clearInterval(id);
1127
- };
1128
- };
1129
- callbackfn(activity);
1130
- } else {
1131
- for (const interval in every) {
1132
- const actions = every == null ? void 0 : every[interval];
1133
- const determineDelay = determineDelayFn(interval, this.delayMap);
1134
- const delay = determineDelay(this.contextSnapshot, this.state.event);
1135
- const activity = () => {
1136
- const id = globalThis.setInterval(() => {
1137
- this.executeActions(actions, this.state.event);
1138
- }, delay);
1139
- return () => {
1140
- globalThis.clearInterval(id);
1141
- };
1142
- };
1143
- callbackfn(activity);
1144
- }
1145
- }
1146
- });
1147
- __publicField(this, "setEvent", (event) => {
1148
- this.state.previousEvent = this.state.event;
1149
- this.state.event = ref(toEvent(event));
1150
- });
1151
- __publicField(this, "performExitEffects", (current, event) => {
1152
- const currentState = this.state.value;
1153
- if (currentState === "") return;
1154
- const stateNode = current ? this.getStateNode(current) : void 0;
1155
- this.stopActivities(currentState);
1156
- const _exit = determineActionsFn(stateNode == null ? void 0 : stateNode.exit, this.guardMap)(this.contextSnapshot, event, this.guardMeta);
1157
- const exitActions = toArray(_exit);
1158
- const afterExitActions = this.delayedEvents.get(currentState);
1159
- if (afterExitActions) {
1160
- exitActions.push(...afterExitActions);
1161
- }
1162
- this.executeActions(exitActions, event);
1163
- this.delayedEvents.delete(currentState);
1164
- });
1165
- __publicField(this, "performEntryEffects", (next, event) => {
1166
- const stateNode = this.getStateNode(next);
1167
- const activities = toArray(stateNode == null ? void 0 : stateNode.activities);
1168
- this.createEveryActivities(stateNode == null ? void 0 : stateNode.every, (activity) => {
1169
- activities.unshift(activity);
1170
- });
1171
- if (activities.length > 0) {
1172
- this.executeActivities(event, activities);
1173
- }
1174
- const pickedActions = determineActionsFn(stateNode == null ? void 0 : stateNode.entry, this.guardMap)(
1175
- this.contextSnapshot,
1176
- event,
1177
- this.guardMeta
1178
- );
1179
- const entryActions = toArray(pickedActions);
1180
- const afterActions = this.getDelayedEventActions(next);
1181
- if ((stateNode == null ? void 0 : stateNode.after) && afterActions) {
1182
- this.delayedEvents.set(next, afterActions == null ? void 0 : afterActions.exits);
1183
- entryActions.push(...afterActions.entries);
1184
- }
1185
- this.executeActions(entryActions, event);
1186
- if ((stateNode == null ? void 0 : stateNode.type) === "final") {
1187
- this.state.done = true;
1188
- this.doneListeners.forEach((listener) => {
1189
- listener(this.stateSnapshot);
1190
- });
1191
- this.stop();
1192
- }
1193
- });
1194
- __publicField(this, "performTransitionEffects", (transitions, event) => {
1195
- const transition = this.determineTransition(transitions, event);
1196
- this.executeActions(transition == null ? void 0 : transition.actions, event);
1197
- });
1198
- __publicField(this, "performStateChangeEffects", (current, next, event) => {
1199
- this.setEvent(event);
1200
- const changed = next.changed || next.reenter;
1201
- if (changed) {
1202
- this.performExitEffects(current, event);
1203
- }
1204
- this.performTransitionEffects(next.transition, event);
1205
- this.setState(next.target);
1206
- if (changed) {
1207
- this.performEntryEffects(next.target, event);
1208
- }
1209
- });
1210
- __publicField(this, "determineTransition", (transition, event) => {
1211
- const fn = determineTransitionFn(transition, this.guardMap);
1212
- return fn == null ? void 0 : fn(this.contextSnapshot, event, this.guardMeta);
1213
- });
1214
- __publicField(this, "sendParent", (evt) => {
1215
- var _a2;
1216
- if (!this.parent) {
1217
- invariant("[@zag-js/core > send-parent] Cannot send event to an unknown parent");
1218
- }
1219
- const event = toEvent(evt);
1220
- (_a2 = this.parent) == null ? void 0 : _a2.send(event);
1221
- });
1222
- __publicField(this, "log", (...args) => {
1223
- if (isDev2() && this.options.debug) {
1224
- console.log(...args);
1225
- }
1226
- });
1227
- __publicField(this, "send", (evt) => {
1228
- const event = toEvent(evt);
1229
- this.transition(this.state.value, event);
1230
- });
1231
- __publicField(this, "transition", (state, evt) => {
1232
- var _a2, _b2, _c2;
1233
- const stateNode = isString(state) ? this.getStateNode(state) : state == null ? void 0 : state.stateNode;
1234
- const event = toEvent(evt);
1235
- if (!stateNode && !this.config.on) {
1236
- const msg = this.status === "Stopped" ? "[@zag-js/core > transition] Cannot transition a stopped machine" : `[@zag-js/core > transition] State does not have a definition for \`state\`: ${state}, \`event\`: ${event.type}`;
1237
- warn(msg);
1238
- return;
1239
- }
1240
- const transitions = (
1241
- // @ts-expect-error - Fix this
1242
- (_c2 = (_a2 = stateNode == null ? void 0 : stateNode.on) == null ? void 0 : _a2[event.type]) != null ? _c2 : (_b2 = this.config.on) == null ? void 0 : _b2[event.type]
1243
- );
1244
- const next = this.getNextStateInfo(transitions, event);
1245
- this.performStateChangeEffects(this.state.value, next, event);
1246
- return next.stateNode;
1247
- });
1248
- __publicField(this, "subscribe", (listener) => {
1249
- this.stateListeners.add(listener);
1250
- if (this.status === "Running") {
1251
- listener(this.stateSnapshot);
1252
- }
1253
- return () => {
1254
- this.stateListeners.delete(listener);
1255
- };
1256
- });
1257
- __publicField(this, "onDone", (listener) => {
1258
- this.doneListeners.add(listener);
1259
- return this;
1260
- });
1261
- __publicField(this, "onTransition", (listener) => {
1262
- this.stateListeners.add(listener);
1263
- if (this.status === "Running") {
1264
- listener(this.stateSnapshot);
1265
- }
1266
- return this;
1267
- });
1268
- this.config = structuredClone(config);
1269
- this.options = structuredClone(options != null ? options : {});
1270
- this.id = (_a = this.config.id) != null ? _a : `machine-${uuid()}`;
1271
- this.guardMap = (_c = (_b = this.options) == null ? void 0 : _b.guards) != null ? _c : {};
1272
- this.actionMap = (_e = (_d = this.options) == null ? void 0 : _d.actions) != null ? _e : {};
1273
- this.delayMap = (_g = (_f = this.options) == null ? void 0 : _f.delays) != null ? _g : {};
1274
- this.activityMap = (_i = (_h = this.options) == null ? void 0 : _h.activities) != null ? _i : {};
1275
- this.sync = (_k = (_j = this.options) == null ? void 0 : _j.sync) != null ? _k : false;
1276
- this.state = createProxy2(this.config);
1277
- this.initialContext = snapshot(this.state.context);
1278
- }
1279
- // immutable state value
1280
- get stateSnapshot() {
1281
- return cast(snapshot(this.state));
1282
- }
1283
- getState() {
1284
- return this.stateSnapshot;
1285
- }
1286
- // immutable context value
1287
- get contextSnapshot() {
1288
- return this.stateSnapshot.context;
1289
- }
1290
- /**
1291
- * A reference to the instance methods of the machine.
1292
- * Useful when spawning child machines and managing the communication between them.
1293
- */
1294
- get self() {
1295
- const self2 = this;
1296
- return {
1297
- id: this.id,
1298
- send: this.send.bind(this),
1299
- sendParent: this.sendParent.bind(this),
1300
- sendChild: this.sendChild.bind(this),
1301
- stop: this.stop.bind(this),
1302
- stopChild: this.stopChild.bind(this),
1303
- spawn: this.spawn.bind(this),
1304
- stopActivity: this.stopActivity.bind(this),
1305
- get state() {
1306
- return self2.stateSnapshot;
1307
- },
1308
- get initialContext() {
1309
- return self2.initialContext;
1310
- },
1311
- get initialState() {
1312
- var _a, _b;
1313
- return (_b = (_a = self2.initialState) == null ? void 0 : _a.target) != null ? _b : "";
1314
- }
1315
- };
1316
- }
1317
- get meta() {
1318
- var _a, _b;
1319
- return {
1320
- state: this.stateSnapshot,
1321
- guards: this.guardMap,
1322
- send: this.send.bind(this),
1323
- self: this.self,
1324
- initialContext: this.initialContext,
1325
- initialState: (_b = (_a = this.initialState) == null ? void 0 : _a.target) != null ? _b : "",
1326
- getState: () => this.stateSnapshot,
1327
- getAction: (key) => this.actionMap[key],
1328
- getGuard: (key) => this.guardMap[key]
1329
- };
1330
- }
1331
- get guardMeta() {
1332
- return {
1333
- state: this.stateSnapshot
1334
- };
1335
- }
1336
- get [Symbol.toStringTag]() {
1337
- return "Machine";
1338
- }
1339
- getHydrationState() {
1340
- const state = this.getState();
1341
- return {
1342
- value: state.value,
1343
- tags: state.tags
1344
- };
1345
- }
1346
- };
1347
- var createMachine = (config, options) => new Machine(config, options);
1348
- var clsx = (...args) => args.map((str) => {
1349
- var _a;
1350
- return (_a = str == null ? void 0 : str.trim) == null ? void 0 : _a.call(str);
1351
- }).filter(Boolean).join(" ");
1352
- var CSS_REGEX = /((?:--)?(?:\w+-?)+)\s*:\s*([^;]*)/g;
1353
- var serialize = (style) => {
1354
- const res = {};
1355
- let match;
1356
- while (match = CSS_REGEX.exec(style)) {
1357
- res[match[1]] = match[2];
1358
- }
1359
- return res;
1360
- };
1361
- var css = (a, b) => {
1362
- if (isString(a)) {
1363
- if (isString(b)) return `${a};${b}`;
1364
- a = serialize(a);
1365
- } else if (isString(b)) {
1366
- b = serialize(b);
1367
- }
1368
- return Object.assign({}, a != null ? a : {}, b != null ? b : {});
1369
- };
1370
- function mergeProps(...args) {
1371
- let result = {};
1372
- for (let props2 of args) {
1373
- for (let key in result) {
1374
- if (key.startsWith("on") && typeof result[key] === "function" && typeof props2[key] === "function") {
1375
- result[key] = callAll(props2[key], result[key]);
1376
- continue;
1377
- }
1378
- if (key === "className" || key === "class") {
1379
- result[key] = clsx(result[key], props2[key]);
1380
- continue;
1381
- }
1382
- if (key === "style") {
1383
- result[key] = css(result[key], props2[key]);
1384
- continue;
1385
- }
1386
- result[key] = props2[key] !== void 0 ? props2[key] : result[key];
1387
- }
1388
- for (let key in props2) {
1389
- if (result[key] === void 0) {
1390
- result[key] = props2[key];
1391
- }
1392
- }
1393
- }
1394
- return result;
1395
- }
1396
-
1397
- // ../../node_modules/@ark-ui/react/dist/components/factory.js
39
+ // src/components/spinner/spinner.tsx
1398
40
  var import_react = require("react");
1399
- function getRef(element) {
1400
- var _a, _b;
1401
- let getter = (_a = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a.get;
1402
- let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
1403
- if (mayWarn) {
1404
- return element.ref;
1405
- }
1406
- getter = (_b = Object.getOwnPropertyDescriptor(element, "ref")) == null ? void 0 : _b.get;
1407
- mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
1408
- if (mayWarn) {
1409
- return element.props.ref;
1410
- }
1411
- return element.props.ref || element.ref;
1412
- }
1413
- var withAsChild = (Component) => {
1414
- const Comp = (0, import_react.memo)(
1415
- (0, import_react.forwardRef)((props2, ref2) => {
1416
- const { asChild, children, ...restProps } = props2;
1417
- if (!asChild) {
1418
- return (0, import_react.createElement)(Component, { ...restProps, ref: ref2 }, children);
1419
- }
1420
- const onlyChild = import_react.Children.only(children);
1421
- if (!(0, import_react.isValidElement)(onlyChild)) {
1422
- return null;
1423
- }
1424
- const childRef = getRef(onlyChild);
1425
- return (0, import_react.cloneElement)(onlyChild, {
1426
- ...mergeProps(restProps, onlyChild.props),
1427
- ref: ref2 ? composeRefs(ref2, childRef) : childRef
1428
- });
1429
- })
1430
- );
1431
- Comp.displayName = Component.displayName || Component.name;
1432
- return Comp;
1433
- };
1434
- var jsxFactory = () => {
1435
- const cache = /* @__PURE__ */ new Map();
1436
- return new Proxy(withAsChild, {
1437
- apply(_target, _thisArg, argArray) {
1438
- return withAsChild(argArray[0]);
1439
- },
1440
- get(_, element) {
1441
- const asElement = element;
1442
- if (!cache.has(asElement)) {
1443
- cache.set(asElement, withAsChild(asElement));
1444
- }
1445
- return cache.get(asElement);
1446
- }
1447
- });
1448
- };
1449
- var ark = jsxFactory();
1450
-
1451
- // ../../node_modules/@ark-ui/react/dist/utils/create-split-props.js
1452
- var createSplitProps = () => (props2, keys) => keys.reduce(
1453
- (previousValue, currentValue) => {
1454
- const [target, source] = previousValue;
1455
- const key = currentValue;
1456
- if (source[key] !== void 0) {
1457
- target[key] = source[key];
1458
- }
1459
- delete source[key];
1460
- return [target, source];
1461
- },
1462
- [{}, { ...props2 }]
1463
- );
1464
-
1465
- // ../../node_modules/@ark-ui/react/dist/components/presence/split-presence-props.js
1466
- var splitPresenceProps = (props2) => createSplitProps()(props2, [
1467
- "immediate",
1468
- "lazyMount",
1469
- "onExitComplete",
1470
- "present",
1471
- "unmountOnExit"
1472
- ]);
1473
-
1474
- // ../../node_modules/@zag-js/types/dist/index.mjs
1475
- function createNormalizer(fn) {
1476
- return new Proxy({}, {
1477
- get() {
1478
- return fn;
1479
- }
1480
- });
1481
- }
1482
- var createProps = () => (props2) => Array.from(new Set(props2));
1483
-
1484
- // ../../node_modules/@zag-js/presence/dist/index.mjs
1485
- function connect(state, send, _normalize) {
1486
- const present = state.matches("mounted", "unmountSuspended");
1487
- return {
1488
- skip: !state.context.initial && present,
1489
- present,
1490
- setNode(node) {
1491
- if (!node) return;
1492
- send({ type: "NODE.SET", node });
1493
- },
1494
- unmount() {
1495
- send({ type: "UNMOUNT" });
1496
- }
1497
- };
1498
- }
1499
- function machine(ctx) {
1500
- return createMachine(
1501
- {
1502
- initial: ctx.present ? "mounted" : "unmounted",
1503
- context: {
1504
- node: null,
1505
- styles: null,
1506
- unmountAnimationName: null,
1507
- prevAnimationName: null,
1508
- present: false,
1509
- initial: false,
1510
- ...ctx
1511
- },
1512
- exit: ["clearInitial"],
1513
- watch: {
1514
- present: ["setInitial", "syncPresence"]
1515
- },
1516
- on: {
1517
- "NODE.SET": {
1518
- actions: ["setNode", "setStyles"]
1519
- }
1520
- },
1521
- states: {
1522
- mounted: {
1523
- on: {
1524
- UNMOUNT: {
1525
- target: "unmounted",
1526
- actions: ["invokeOnExitComplete"]
1527
- },
1528
- "UNMOUNT.SUSPEND": "unmountSuspended"
1529
- }
1530
- },
1531
- unmountSuspended: {
1532
- activities: ["trackAnimationEvents"],
1533
- after: {
1534
- // Fallback to timeout to ensure we exit this state even if the `animationend` event
1535
- // did not get trigger
1536
- ANIMATION_DURATION: {
1537
- target: "unmounted",
1538
- actions: ["invokeOnExitComplete"]
1539
- }
1540
- },
1541
- on: {
1542
- MOUNT: {
1543
- target: "mounted",
1544
- actions: ["setPrevAnimationName"]
1545
- },
1546
- UNMOUNT: {
1547
- target: "unmounted",
1548
- actions: ["invokeOnExitComplete"]
1549
- }
1550
- }
1551
- },
1552
- unmounted: {
1553
- entry: ["clearPrevAnimationName"],
1554
- on: {
1555
- MOUNT: {
1556
- target: "mounted",
1557
- actions: ["setPrevAnimationName"]
1558
- }
1559
- }
1560
- }
1561
- }
1562
- },
1563
- {
1564
- delays: {
1565
- ANIMATION_DURATION(ctx2) {
1566
- var _a, _b;
1567
- return parseMs((_a = ctx2.styles) == null ? void 0 : _a.animationDuration) + parseMs((_b = ctx2.styles) == null ? void 0 : _b.animationDelay) + ANIMATION_TIMEOUT_MARGIN;
1568
- }
1569
- },
1570
- actions: {
1571
- setInitial(ctx2) {
1572
- ctx2.initial = true;
1573
- },
1574
- clearInitial(ctx2) {
1575
- ctx2.initial = false;
1576
- },
1577
- invokeOnExitComplete(ctx2) {
1578
- var _a;
1579
- (_a = ctx2.onExitComplete) == null ? void 0 : _a.call(ctx2);
1580
- },
1581
- setNode(ctx2, evt) {
1582
- ctx2.node = ref(evt.node);
1583
- },
1584
- setStyles(ctx2, evt) {
1585
- const win = evt.node.ownerDocument.defaultView || window;
1586
- ctx2.styles = ref(win.getComputedStyle(evt.node));
1587
- },
1588
- syncPresence(ctx2, _evt, { send }) {
1589
- var _a;
1590
- if (ctx2.present) {
1591
- send({ type: "MOUNT", src: "presence.changed" });
1592
- return;
1593
- }
1594
- if (!ctx2.present && ((_a = ctx2.node) == null ? void 0 : _a.ownerDocument.visibilityState) === "hidden") {
1595
- send({ type: "UNMOUNT", src: "visibilitychange" });
1596
- return;
1597
- }
1598
- const animationName = getAnimationName(ctx2.styles);
1599
- const exec = ctx2.immediate ? queueMicrotask : requestAnimationFrame;
1600
- exec(() => {
1601
- var _a2, _b;
1602
- ctx2.unmountAnimationName = animationName;
1603
- if (animationName === "none" || animationName === ctx2.prevAnimationName || ((_a2 = ctx2.styles) == null ? void 0 : _a2.display) === "none" || ((_b = ctx2.styles) == null ? void 0 : _b.animationDuration) === "0s") {
1604
- send({ type: "UNMOUNT", src: "presence.changed" });
1605
- } else {
1606
- send({ type: "UNMOUNT.SUSPEND" });
1607
- }
1608
- });
1609
- },
1610
- setPrevAnimationName(ctx2) {
1611
- const exec = ctx2.immediate ? queueMicrotask : requestAnimationFrame;
1612
- exec(() => {
1613
- ctx2.prevAnimationName = getAnimationName(ctx2.styles);
1614
- });
1615
- },
1616
- clearPrevAnimationName(ctx2) {
1617
- ctx2.prevAnimationName = null;
1618
- }
1619
- },
1620
- activities: {
1621
- trackAnimationEvents(ctx2, _evt, { send }) {
1622
- const node = ctx2.node;
1623
- if (!node) return;
1624
- const onStart = (event) => {
1625
- var _a, _b, _c;
1626
- const target = (_c = (_b = (_a = event.composedPath) == null ? void 0 : _a.call(event)) == null ? void 0 : _b[0]) != null ? _c : event.target;
1627
- if (target === node) {
1628
- ctx2.prevAnimationName = getAnimationName(ctx2.styles);
1629
- }
1630
- };
1631
- const onEnd = (event) => {
1632
- var _a, _b, _c;
1633
- const animationName = getAnimationName(ctx2.styles);
1634
- const target = (_c = (_b = (_a = event.composedPath) == null ? void 0 : _a.call(event)) == null ? void 0 : _b[0]) != null ? _c : event.target;
1635
- if (target === node && animationName === ctx2.unmountAnimationName) {
1636
- send({ type: "UNMOUNT", src: "animationend" });
1637
- }
1638
- };
1639
- node.addEventListener("animationstart", onStart);
1640
- node.addEventListener("animationcancel", onEnd);
1641
- node.addEventListener("animationend", onEnd);
1642
- return () => {
1643
- node.removeEventListener("animationstart", onStart);
1644
- node.removeEventListener("animationcancel", onEnd);
1645
- node.removeEventListener("animationend", onEnd);
1646
- };
1647
- }
1648
- }
1649
- }
1650
- );
1651
- }
1652
- function getAnimationName(styles) {
1653
- return (styles == null ? void 0 : styles.animationName) || "none";
1654
- }
1655
- function parseMs(value) {
1656
- return parseFloat(value || "0") * 1e3;
1657
- }
1658
- var ANIMATION_TIMEOUT_MARGIN = 16.667;
1659
- var props = createProps()(["onExitComplete", "present", "immediate"]);
1660
-
1661
- // ../../node_modules/@zag-js/react/dist/index.mjs
1662
- var import_react2 = __toESM(require("react"), 1);
1663
- var import_react_dom = require("react-dom");
41
+ var import_react2 = require("@chakra-ui/react");
1664
42
  var import_jsx_runtime = require("react/jsx-runtime");
1665
- var normalizeProps = createNormalizer((v) => v);
1666
- var isArrayLike = (value) => (value == null ? void 0 : value.constructor.name) === "Array";
1667
- var isArrayEqual = (a, b) => {
1668
- if (a.length !== b.length) return false;
1669
- for (let i = 0; i < a.length; i++) {
1670
- if (!isEqual(a[i], b[i])) return false;
1671
- }
1672
- return true;
1673
- };
1674
- var isEqual = (a, b) => {
1675
- if (Object.is(a, b)) return true;
1676
- if (a == null && b != null || a != null && b == null) return false;
1677
- if (typeof (a == null ? void 0 : a.isEqual) === "function" && typeof (b == null ? void 0 : b.isEqual) === "function") {
1678
- return a.isEqual(b);
1679
- }
1680
- if (typeof a === "function" && typeof b === "function") {
1681
- return a.toString() === b.toString();
1682
- }
1683
- if (isArrayLike(a) && isArrayLike(b)) {
1684
- return isArrayEqual(Array.from(a), Array.from(b));
1685
- }
1686
- if (!(typeof a === "object") || !(typeof b === "object")) return false;
1687
- const keys = Object.keys(b != null ? b : /* @__PURE__ */ Object.create(null));
1688
- const length = keys.length;
1689
- for (let i = 0; i < length; i++) {
1690
- const hasKey = Reflect.has(a, keys[i]);
1691
- if (!hasKey) return false;
1692
- }
1693
- for (let i = 0; i < length; i++) {
1694
- const key = keys[i];
1695
- if (!isEqual(a[key], b[key])) return false;
1696
- }
1697
- return true;
1698
- };
1699
- var isDev3 = () => process.env.NODE_ENV !== "production";
1700
- var fnToString2 = Function.prototype.toString;
1701
- fnToString2.call(Object);
1702
- function compact2(obj) {
1703
- if (!isPlainObject3(obj) || obj === void 0) {
1704
- return obj;
1705
- }
1706
- const keys = Reflect.ownKeys(obj).filter((key) => typeof key === "string");
1707
- const filtered = {};
1708
- for (const key of keys) {
1709
- const value = obj[key];
1710
- if (value !== void 0) {
1711
- filtered[key] = compact2(value);
1712
- }
1713
- }
1714
- return filtered;
1715
- }
1716
- var isPlainObject3 = (value) => {
1717
- return value && typeof value === "object" && value.constructor === Object;
1718
- };
1719
- function useUpdateEffect(callback, deps) {
1720
- const render = (0, import_react2.useRef)(false);
1721
- const effect = (0, import_react2.useRef)(false);
1722
- (0, import_react2.useEffect)(() => {
1723
- const mounted = render.current;
1724
- const run = mounted && effect.current;
1725
- if (run) {
1726
- return callback();
1727
- }
1728
- effect.current = true;
1729
- }, deps);
1730
- (0, import_react2.useEffect)(() => {
1731
- render.current = true;
1732
- return () => {
1733
- render.current = false;
1734
- };
1735
- }, []);
1736
- }
1737
- var { use } = import_react2.default;
1738
- var targetCache = makeGlobal("__zag__targetCache", () => /* @__PURE__ */ new WeakMap());
1739
- function useSnapshot(service, options) {
1740
- const { actions, context, sync: notifyInSync } = options != null ? options : {};
1741
- const lastSnapshot = (0, import_react2.useRef)();
1742
- const lastAffected = (0, import_react2.useRef)();
1743
- const currSnapshot = (0, import_react2.useSyncExternalStore)(
1744
- (0, import_react2.useCallback)((callback) => subscribe(service.state, callback, notifyInSync), [notifyInSync]),
1745
- () => {
1746
- const nextSnapshot = snapshot(service.state, use);
1747
- try {
1748
- if (lastSnapshot.current && lastAffected.current && !isChanged(lastSnapshot.current, nextSnapshot, lastAffected.current, /* @__PURE__ */ new WeakMap())) {
1749
- return lastSnapshot.current;
1750
- }
1751
- } catch {
1752
- }
1753
- return nextSnapshot;
1754
- },
1755
- () => snapshot(service.state, use)
1756
- );
1757
- service.setOptions({ actions });
1758
- const ctx = (0, import_react2.useMemo)(() => compact2(context != null ? context : {}), [context]);
1759
- useUpdateEffect(() => {
1760
- var _a;
1761
- const entries = Object.entries(ctx);
1762
- const previousCtx = (_a = service.contextSnapshot) != null ? _a : {};
1763
- const equality = entries.map(([key, value]) => ({
1764
- key,
1765
- curr: value,
1766
- prev: previousCtx[key],
1767
- equal: isEqual(previousCtx[key], value)
1768
- }));
1769
- const allEqual = equality.every(({ equal }) => equal);
1770
- if (!allEqual) {
1771
- service.setContext(ctx);
1772
- }
1773
- }, [ctx]);
1774
- const currAffected = /* @__PURE__ */ new WeakMap();
1775
- (0, import_react2.useEffect)(() => {
1776
- lastSnapshot.current = currSnapshot;
1777
- lastAffected.current = currAffected;
1778
- });
1779
- const proxyCache = (0, import_react2.useMemo)(() => /* @__PURE__ */ new WeakMap(), []);
1780
- return createProxy(currSnapshot, currAffected, proxyCache, targetCache);
1781
- }
1782
- function useConstant(fn) {
1783
- const ref2 = (0, import_react2.useRef)();
1784
- if (!ref2.current) ref2.current = { v: fn() };
1785
- return ref2.current.v;
1786
- }
1787
- var useSafeLayoutEffect = typeof document !== "undefined" ? import_react2.useLayoutEffect : import_react2.useEffect;
1788
- function useService(machine2, options) {
1789
- const { state: hydratedState, context } = options != null ? options : {};
1790
- const service = useConstant(() => {
1791
- const instance = typeof machine2 === "function" ? machine2() : machine2;
1792
- if (context) instance.setContext(context);
1793
- instance._created();
1794
- return instance;
1795
- });
1796
- const snapshotRef = (0, import_react2.useRef)();
1797
- useSafeLayoutEffect(() => {
1798
- const stateInit = hydratedState != null ? hydratedState : snapshotRef.current;
1799
- service.start(stateInit);
1800
- return () => {
1801
- if (isDev3()) {
1802
- snapshotRef.current = service.getHydrationState();
1803
- }
1804
- service.stop();
1805
- };
1806
- }, []);
1807
- return service;
1808
- }
1809
- function useMachine(machine2, options) {
1810
- const service = useService(machine2, options);
1811
- const state = useSnapshot(service, options);
1812
- return [state, service.send, service];
1813
- }
1814
-
1815
- // ../../node_modules/@ark-ui/react/dist/components/presence/use-presence.js
1816
- var import_react5 = require("react");
1817
-
1818
- // ../../node_modules/@ark-ui/react/dist/utils/use-event.js
1819
- var import_react3 = require("react");
1820
- function useEvent(callback, opts = {}) {
1821
- const { sync = false } = opts;
1822
- const callbackRef = useLatestRef(callback);
1823
- return (0, import_react3.useCallback)(
1824
- // biome-ignore lint/suspicious/noExplicitAny: <explanation>
1825
- (...args) => {
1826
- var _a;
1827
- if (sync) return queueMicrotask(() => {
1828
- var _a2;
1829
- return (_a2 = callbackRef.current) == null ? void 0 : _a2.call(callbackRef, ...args);
1830
- });
1831
- return (_a = callbackRef.current) == null ? void 0 : _a.call(callbackRef, ...args);
1832
- },
1833
- [sync, callbackRef]
1834
- );
1835
- }
1836
- function useLatestRef(value) {
1837
- const ref2 = (0, import_react3.useRef)(value);
1838
- ref2.current = value;
1839
- return ref2;
1840
- }
1841
-
1842
- // ../../node_modules/@ark-ui/react/dist/components/presence/use-presence.js
1843
- var usePresence = (props2) => {
1844
- const { lazyMount, unmountOnExit, ...rest } = props2;
1845
- const wasEverPresent = (0, import_react5.useRef)(false);
1846
- const context = {
1847
- ...rest,
1848
- onExitComplete: useEvent(props2.onExitComplete)
1849
- };
1850
- const [state, send] = useMachine(machine(context), { context });
1851
- const api = connect(state, send, normalizeProps);
1852
- if (api.present) {
1853
- wasEverPresent.current = true;
1854
- }
1855
- const unmounted = !api.present && !wasEverPresent.current && lazyMount || unmountOnExit && !api.present && wasEverPresent.current;
1856
- const getPresenceProps = () => ({
1857
- "data-state": props2.present ? "open" : "closed",
1858
- hidden: !api.present
1859
- });
1860
- return {
1861
- ref: api.setNode,
1862
- getPresenceProps,
1863
- present: api.present,
1864
- unmounted
1865
- };
1866
- };
1867
-
1868
- // ../../node_modules/@ark-ui/react/dist/components/presence/presence.js
1869
- var Presence = (0, import_react6.forwardRef)((props2, ref2) => {
1870
- const [presenceProps, localProps] = splitPresenceProps(props2);
1871
- const presence = usePresence(presenceProps);
1872
- if (presence.unmounted) {
1873
- return null;
1874
- }
1875
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1876
- ark.div,
1877
- {
1878
- ...localProps,
1879
- ...presence.getPresenceProps(),
1880
- "data-scope": "presence",
1881
- "data-part": "root",
1882
- ref: composeRefs(presence.ref, ref2)
1883
- }
1884
- );
1885
- });
1886
- Presence.displayName = "Presence";
1887
-
1888
- // src/components/loading-overlay/loading-overlay.tsx
1889
- var import_react10 = require("@chakra-ui/react");
1890
-
1891
- // src/components/spinner/spinner.tsx
1892
- var import_react7 = require("react");
1893
- var import_react8 = require("@chakra-ui/react");
1894
- var import_jsx_runtime3 = require("react/jsx-runtime");
1895
- var Spinner = (0, import_react7.forwardRef)(
1896
- function Spinner2(props2, ref2) {
1897
- const { loading, children, ...rest } = props2;
43
+ var Spinner = (0, import_react.forwardRef)(
44
+ function Spinner2(props, ref) {
45
+ const { loading, children, ...rest } = props;
1898
46
  if (loading === false) {
1899
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_jsx_runtime3.Fragment, { children });
47
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children });
1900
48
  }
1901
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react8.Spinner, { ref: ref2, ...rest });
49
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react2.Spinner, { ref, ...rest });
1902
50
  }
1903
51
  );
1904
52
 
1905
53
  // src/components/loading-overlay/loading-overlay.context.ts
1906
- var import_react9 = require("@chakra-ui/react");
54
+ var import_react3 = require("@chakra-ui/react");
1907
55
  var {
1908
56
  useStyles: useLoadingOverlayStyles,
1909
57
  withContext,
1910
58
  withProvider
1911
- } = (0, import_react9.createSlotRecipeContext)({
59
+ } = (0, import_react3.createSlotRecipeContext)({
1912
60
  key: "suiLoadingOverlay"
1913
61
  });
1914
62
 
1915
63
  // src/components/loading-overlay/loading-overlay.tsx
1916
- var import_jsx_runtime4 = require("react/jsx-runtime");
1917
- var LoadingOverlay = (props2) => {
1918
- const { children, loading = true, ...rest } = props2;
1919
- const [presenceProps, rootProps] = splitPresenceProps(rest);
1920
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Presence, { present: loading, ...presenceProps, asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react10.chakra.div, { ...rootProps, children }) });
64
+ var import_jsx_runtime2 = require("react/jsx-runtime");
65
+ var LoadingOverlay = (props) => {
66
+ const { children, loading = true, ...rest } = props;
67
+ const [presenceProps, rootProps] = (0, import_presence.splitPresenceProps)(rest);
68
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_presence.Presence, { present: loading, ...presenceProps, asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react4.chakra.div, { ...rootProps, children }) });
1921
69
  };
1922
70
  var LoadingOverlayRoot = withProvider(
1923
71
  LoadingOverlay,