@zag-js/number-input 0.0.0-dev-20220412162814 → 0.0.0-dev-20220413174154

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.js CHANGED
@@ -1,8 +1,1747 @@
1
- var T=Object.defineProperty;var oe=Object.getOwnPropertyDescriptor;var ie=Object.getOwnPropertyNames;var ae=Object.prototype.hasOwnProperty;var le=e=>T(e,"__esModule",{value:!0});var ue=(e,t)=>{for(var n in t)T(e,n,{get:t[n],enumerable:!0})},se=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ie(t))!ae.call(e,o)&&(n||o!=="default")&&T(e,o,{get:()=>t[o],enumerable:!(r=oe(t,o))||r.enumerable});return e};var ce=(e=>(t,n)=>e&&e.get(t)||(n=se(le({}),t,1),e&&e.set(t,n),n))(typeof WeakMap!="undefined"?new WeakMap:0);var Be={};ue(Be,{connect:()=>Q,machine:()=>ne});var h=e=>e?"":void 0;function P(e){let t=new Set;function n(r){let o=globalThis.requestAnimationFrame(r);t.add(()=>globalThis.cancelAnimationFrame(o))}return n(()=>n(e)),function(){t.forEach(function(r){r()})}}var O=()=>{};var He=(()=>{let e=0;return()=>(e++,e.toString(36))})();var E=new Map,b=new Map;function de(e,t,n,r){var o;if(!e)return O;let a=JSON.stringify({type:t,options:r}),u=E.get(e);if(E.has(e))(u==null?void 0:u.has(a))?(o=u==null?void 0:u.get(a))==null||o.add(n):u==null||u.set(a,new Set([n]));else{let s=new Map([[a,new Set([n])]]);E.set(e,s)}function c(s){var l,m;function d(f){var g;let x=E.get(s);(g=x==null?void 0:x.get(a))==null||g.forEach(re=>re(f))}if(!(b==null?void 0:b.has(s))){b.set(s,new Map([[a,d]])),s.addEventListener(t,d,r);return}((l=b==null?void 0:b.get(s))==null?void 0:l.has(a))||((m=b.get(s))==null||m.set(a,d),s.addEventListener(t,d,r))}return c(e),function(){var s,l,m,d;if(!E.has(e))return;let f=E.get(e);if((s=f==null?void 0:f.get(a))==null||s.delete(n),((l=f==null?void 0:f.get(a))==null?void 0:l.size)===0){let g=(m=b.get(e))==null?void 0:m.get(a);e.removeEventListener(t,g,r),f==null||f.delete(a),(d=b.get(e))==null||d.delete(a),(f==null?void 0:f.size)===0&&(E.delete(e),b.delete(e))}}}var N=e=>Object.prototype.toString.call(e).slice(8,-1),pe=e=>N(e)==="Object"&&"current"in e,me=e=>N(e)==="Function"?e():e;function C(e,t,n,r){let o=pe(e)?e.current:me(e);return de(o,t,n,r)}function L(e){var t;return(t=e.nativeEvent)!=null?t:e}var B=2147483647;var Ve=["input:not([disabled]):not([type=hidden])","select:not([disabled])","textarea:not([disabled])","button:not([disabled])","embed","iframe","object","a[href]","area[href]","[tabindex]","audio[controls]","video[controls]","*[tabindex]:not([aria-disabled])","[contenteditable]:not([contenteditable=false])","details > summary:first-of-type"].join(",");var fe=new Set(["PageUp","PageDown"]),ve=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]);function _(e){return e.ctrlKey||e.metaKey?.1:fe.has(e.key)||e.shiftKey&&ve.has(e.key)?10:1}function H(e,t,n){if(!e)return O;let r=Array.isArray(t)?t:[t],o=e.ownerDocument.defaultView||window,a=new o.MutationObserver(u=>{for(let c of u)c.type==="attributes"&&c.attributeName&&r.includes(c.attributeName)&&n(c)});return a.observe(e,{attributes:!0,attributeFilter:r}),()=>a.disconnect()}function ge(e,t){return e.addEventListener("webkitpointerlockchange",t,!1),e.addEventListener("mozpointerlockchange",t,!1),e.addEventListener("pointerlockchange",t,!1),function(){e.removeEventListener("mozpointerlockchange",t,!1),e.removeEventListener("pointerlockchange",t,!1)}}function he(e,t){return e.addEventListener("webkitpointerlockerror",t,!1),e.addEventListener("mozpointerlockerror",t,!1),e.addEventListener("pointerlockerror",t,!1),function(){e.removeEventListener("webkitpointerlockerror",t,!1),e.removeEventListener("mozpointerlockerror",t,!1),e.removeEventListener("pointerlockerror",t,!1)}}function be(e){return e.requestPointerLock||e.mozRequestPointerLock||e.webkitRequestPointerLock}function ye(e){return e.exitPointerLock||e.mozExitPointerLock||e.webkitExitPointerLock}function V(e,t={}){let{onPointerLock:n,onPointerUnlock:r}=t,o=e.body;function a(){return"pointerLockElement"in e||"mozPointerLockElement"in e||"webkitPointerLockElement"in e}function u(){return!!e.pointerLockElement}function c(){u()?n==null||n():r==null||r()}function s(x){u()&&(r==null||r()),console.error("PointerLock error occured:",x),l()}function l(){e.exitPointerLock=ye(e),e.exitPointerLock()}let m=new Set;function d(){m.add(ge(e,c)),m.add(he(e,s))}function f(){!a()||(m.forEach(x=>x()),m.clear(),l())}function g(){!a()||(o.requestPointerLock=be(o),o.requestPointerLock(),d())}return g(),f}var Ee=Object.defineProperty,we=Object.defineProperties,xe=Object.getOwnPropertyDescriptors,W=Object.getOwnPropertySymbols,Pe=Object.prototype.hasOwnProperty,Se=Object.prototype.propertyIsEnumerable,Ce=Math.pow,U=(e,t,n)=>t in e?Ee(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Le=(e,t)=>{for(var n in t||(t={}))Pe.call(t,n)&&U(e,n,t[n]);if(W)for(var n of W(t))Se.call(t,n)&&U(e,n,t[n]);return e},Me=(e,t)=>we(e,xe(t)),F=new Intl.NumberFormat("en-US",{style:"decimal"});function k(e){return parseFloat(F.format(e))}function j(e,t){return(e%t+t)%t}function Ie(e,t){let n=v(e),r=Ce(10,t!=null?t:10);return n=Math.round(n*r)/r,t?n.toFixed(t):e.toString()}function w(e){if(typeof window=="undefined")return Math.round(e);let t=window.devicePixelRatio;return Math.floor(e*t+.5)/t}function M(e,t){return Math.min(Math.max(v(e),t.min),t.max)}function Y(e){var t,n;return(n=(t=F.formatToParts(e).find(r=>r.type==="fraction"))==null?void 0:t.value.length)!=null?n:0}var X=(e,t)=>k(v(e)+t),z=(e,t)=>k(v(e)-t),K=(e,t)=>k(v(e)*t);function v(e){if(typeof e=="number")return e;let t=parseFloat(e.toString().replace(/[^\w.-]+/g,""));return Number.isNaN(t)?0:t}function Ae(e){var t;let n=Y(e.step),r=v(e.value),o=Number.isNaN(r)?n:Math.max(Y(r),n);return Math.max(o,(t=e.precision)!=null?t:0)}function S(e,t){return Ie(e,Ae(Me(Le({},t),{value:e})))}function q(e,t){return v(e)>=t.max}function $(e,t){return v(e)<=t.min}function G(e,t){let n=v(e);return n>=t.min&&n<=t.max}var Fe=(()=>{let e=0;return()=>(e++,e.toString(36))})(),Te=e=>Array.isArray(e),ke=e=>!(e==null||typeof e!="object"||Te(e)),Re=e=>ke(e)&&"touches"in e;var De={pageX:0,pageY:0,clientX:0,clientY:0};function Z(e,t="page"){let n=Re(e)?e.touches[0]||e.changedTouches[0]||De:e;return{x:n[`${t}X`],y:n[`${t}Y`]}}function Oe(e){return{button:e,label:e,input:e,output:e,element:e}}var J=Oe(e=>e);var i={getDoc:e=>{var t;return(t=e.doc)!=null?t:document},getWin:e=>{var t;return(t=i.getDoc(e).defaultView)!=null?t:window},getInputId:e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.input)!=null?n:`number-input-${e.uid}-input`},getIncButtonId:e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.incBtn)!=null?n:`number-input-${e.uid}-inc-btn`},getDecButtonId:e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.decBtn)!=null?n:`number-input-${e.uid}-dec-btn`},getScrubberId:e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.scrubber)!=null?n:`number-input-${e.uid}-scrubber`},getCursorId:e=>`number-input-${e.uid}-cursor`,getLabelId:e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.label)!=null?n:`number-input-${e.uid}-label`},getRootId:e=>{var t,n;return(n=(t=e.ids)==null?void 0:t.root)!=null?n:`number-input-${e.uid}-root`},getInputEl:e=>i.getDoc(e).getElementById(i.getInputId(e)),getIncButtonEl:e=>i.getDoc(e).getElementById(i.getIncButtonId(e)),getDecButtonEl:e=>i.getDoc(e).getElementById(i.getDecButtonId(e)),getScrubberEl:e=>i.getDoc(e).getElementById(i.getScrubberId(e)),getCursorEl:e=>i.getDoc(e).getElementById(i.getCursorId(e)),getMousementValue(e,t){let n=w(t.movementX),r=w(t.movementY),o=n>0?"increment":n<0?"decrement":null;e.isRtl&&o==="increment"&&(o="decrement"),e.isRtl&&o==="decrement"&&(o="increment");let a={x:e.scrubberCursorPoint.x+n,y:e.scrubberCursorPoint.y+r},c=i.getWin(e).innerWidth,s=w(7.5);return a.x=j(a.x+s,c)-s,{hint:o,point:a}},createVirtualCursor(e){let t=i.getDoc(e),n=t.createElement("div");n.className="scrubber--cursor",n.id=i.getCursorId(e),Object.assign(n.style,{width:"15px",height:"15px",position:"fixed",pointerEvents:"none",left:"0px",top:"0px",zIndex:B,transform:e.scrubberCursorPoint?`translate3d(${e.scrubberCursorPoint.x}px, ${e.scrubberCursorPoint.y}px, 0px)`:void 0,willChange:"transform"}),n.innerHTML=`
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
+ var __pow = Math.pow;
10
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
+ var __spreadValues = (a, b) => {
12
+ for (var prop in b || (b = {}))
13
+ if (__hasOwnProp.call(b, prop))
14
+ __defNormalProp(a, prop, b[prop]);
15
+ if (__getOwnPropSymbols)
16
+ for (var prop of __getOwnPropSymbols(b)) {
17
+ if (__propIsEnum.call(b, prop))
18
+ __defNormalProp(a, prop, b[prop]);
19
+ }
20
+ return a;
21
+ };
22
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
23
+ var __export = (target, all) => {
24
+ for (var name in all)
25
+ __defProp(target, name, { get: all[name], enumerable: true });
26
+ };
27
+ var __copyProps = (to, from, except, desc) => {
28
+ if (from && typeof from === "object" || typeof from === "function") {
29
+ for (let key of __getOwnPropNames(from))
30
+ if (!__hasOwnProp.call(to, key) && key !== except)
31
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
32
+ }
33
+ return to;
34
+ };
35
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
36
+
37
+ // src/index.ts
38
+ var src_exports = {};
39
+ __export(src_exports, {
40
+ connect: () => connect,
41
+ machine: () => machine
42
+ });
43
+ module.exports = __toCommonJS(src_exports);
44
+
45
+ // ../../utilities/dom/src/attrs.ts
46
+ var dataAttr = (guard) => {
47
+ return guard ? "" : void 0;
48
+ };
49
+
50
+ // ../../utilities/dom/src/next-tick.ts
51
+ function nextTick(fn) {
52
+ const set = /* @__PURE__ */ new Set();
53
+ function raf(fn2) {
54
+ const id = globalThis.requestAnimationFrame(fn2);
55
+ set.add(() => globalThis.cancelAnimationFrame(id));
56
+ }
57
+ raf(() => raf(fn));
58
+ return function cleanup() {
59
+ set.forEach(function(fn2) {
60
+ fn2();
61
+ });
62
+ };
63
+ }
64
+
65
+ // ../../utilities/core/src/array.ts
66
+ function clear(v) {
67
+ while (v.length > 0)
68
+ v.pop();
69
+ return v;
70
+ }
71
+
72
+ // ../../utilities/core/src/functions.ts
73
+ var runIfFn = (v, ...a) => {
74
+ const res = typeof v === "function" ? v(...a) : v;
75
+ return res != null ? res : void 0;
76
+ };
77
+ var cast = (v) => v;
78
+ var noop = () => {
79
+ };
80
+ var pipe = (...fns) => (v) => fns.reduce((a, b) => b(a), v);
81
+ var uuid = /* @__PURE__ */ (() => {
82
+ let id = 0;
83
+ return () => {
84
+ id++;
85
+ return id.toString(36);
86
+ };
87
+ })();
88
+
89
+ // ../../utilities/core/src/guard.ts
90
+ var ua = (v) => isDom() && v.test(navigator.userAgent);
91
+ var isDom = () => !!(typeof window !== "undefined");
92
+ var isSafari = () => ua(/^((?!chrome|android).)*safari/i);
93
+ var isArray = (v) => Array.isArray(v);
94
+ var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
95
+ var isNumber = (v) => typeof v === "number" && !Number.isNaN(v);
96
+ var isString = (v) => typeof v === "string";
97
+ var isFunction = (v) => typeof v === "function";
98
+ var supportsPointerEvent = () => isDom() && window.onpointerdown === null;
99
+ var isTouchEvent = (v) => isObject(v) && "touches" in v;
100
+
101
+ // ../../utilities/core/src/warning.ts
102
+ function warn(...a) {
103
+ const m = a.length === 1 ? a[0] : a[1];
104
+ const c = a.length === 2 ? a[0] : true;
105
+ if (c && void 0 !== "production") {
106
+ console.warn(m);
107
+ }
108
+ }
109
+ function invariant(...a) {
110
+ const m = a.length === 1 ? a[0] : a[1];
111
+ const c = a.length === 2 ? a[0] : true;
112
+ if (c && void 0 !== "production") {
113
+ throw new Error(m);
114
+ }
115
+ }
116
+
117
+ // ../../utilities/dom/src/event-bus.ts
118
+ var listenerElements = /* @__PURE__ */ new Map();
119
+ var listenerCache = /* @__PURE__ */ new Map();
120
+ function globalEventBus(node, type, handler, options) {
121
+ var _a;
122
+ if (!node)
123
+ return noop;
124
+ const hash = JSON.stringify({ type, options });
125
+ const group = listenerElements.get(node);
126
+ if (!listenerElements.has(node)) {
127
+ const group2 = /* @__PURE__ */ new Map([[hash, /* @__PURE__ */ new Set([handler])]]);
128
+ listenerElements.set(node, group2);
129
+ } else if (group == null ? void 0 : group.has(hash)) {
130
+ (_a = group == null ? void 0 : group.get(hash)) == null ? void 0 : _a.add(handler);
131
+ } else {
132
+ group == null ? void 0 : group.set(hash, /* @__PURE__ */ new Set([handler]));
133
+ }
134
+ function attach(node2) {
135
+ var _a2, _b;
136
+ function listener(event) {
137
+ var _a3;
138
+ const group2 = listenerElements.get(node2);
139
+ (_a3 = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _a3.forEach((fn) => fn(event));
140
+ }
141
+ if (!(listenerCache == null ? void 0 : listenerCache.has(node2))) {
142
+ listenerCache.set(node2, /* @__PURE__ */ new Map([[hash, listener]]));
143
+ node2.addEventListener(type, listener, options);
144
+ return;
145
+ }
146
+ if (!((_a2 = listenerCache == null ? void 0 : listenerCache.get(node2)) == null ? void 0 : _a2.has(hash))) {
147
+ (_b = listenerCache.get(node2)) == null ? void 0 : _b.set(hash, listener);
148
+ node2.addEventListener(type, listener, options);
149
+ }
150
+ }
151
+ attach(node);
152
+ return function remove() {
153
+ var _a2, _b, _c, _d;
154
+ if (!listenerElements.has(node))
155
+ return;
156
+ const group2 = listenerElements.get(node);
157
+ (_a2 = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _a2.delete(handler);
158
+ if (((_b = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _b.size) === 0) {
159
+ const listener = (_c = listenerCache.get(node)) == null ? void 0 : _c.get(hash);
160
+ node.removeEventListener(type, listener, options);
161
+ group2 == null ? void 0 : group2.delete(hash);
162
+ (_d = listenerCache.get(node)) == null ? void 0 : _d.delete(hash);
163
+ if ((group2 == null ? void 0 : group2.size) === 0) {
164
+ listenerElements.delete(node);
165
+ listenerCache.delete(node);
166
+ }
167
+ }
168
+ };
169
+ }
170
+
171
+ // ../../utilities/dom/src/listener.ts
172
+ var t = (v) => Object.prototype.toString.call(v).slice(8, -1);
173
+ var isRef = (v) => t(v) === "Object" && "current" in v;
174
+ var runIfFn2 = (fn) => t(fn) === "Function" ? fn() : fn;
175
+ function addDomEvent(target, event, listener, options) {
176
+ const node = isRef(target) ? target.current : runIfFn2(target);
177
+ return globalEventBus(node, event, listener, options);
178
+ }
179
+
180
+ // ../../utilities/dom/src/query.ts
181
+ function getNativeEvent(event) {
182
+ var _a;
183
+ return (_a = event.nativeEvent) != null ? _a : event;
184
+ }
185
+
186
+ // ../../utilities/dom/src/constants.ts
187
+ var MAX_Z_INDEX = 2147483647;
188
+
189
+ // ../../utilities/dom/src/keyboard-event.ts
190
+ var PAGE_KEYS = /* @__PURE__ */ new Set(["PageUp", "PageDown"]);
191
+ var ARROW_KEYS = /* @__PURE__ */ new Set(["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"]);
192
+ function getEventStep(event) {
193
+ if (event.ctrlKey || event.metaKey) {
194
+ return 0.1;
195
+ } else {
196
+ const isPageKey = PAGE_KEYS.has(event.key);
197
+ const isSkipKey = isPageKey || event.shiftKey && ARROW_KEYS.has(event.key);
198
+ return isSkipKey ? 10 : 1;
199
+ }
200
+ }
201
+
202
+ // ../../utilities/dom/src/mutation-observer.ts
203
+ function observeAttributes(node, attributes, fn) {
204
+ if (!node)
205
+ return noop;
206
+ const attrs = Array.isArray(attributes) ? attributes : [attributes];
207
+ const win = node.ownerDocument.defaultView || window;
208
+ const obs = new win.MutationObserver((changes) => {
209
+ for (const change of changes) {
210
+ if (change.type === "attributes" && change.attributeName && attrs.includes(change.attributeName)) {
211
+ fn(change);
212
+ }
213
+ }
214
+ });
215
+ obs.observe(node, { attributes: true, attributeFilter: attrs });
216
+ return () => obs.disconnect();
217
+ }
218
+
219
+ // ../../utilities/dom/src/pointerlock.ts
220
+ function addPointerlockChangeListener(doc, fn) {
221
+ return addDomEvent(doc, "pointerlockchange", fn, false);
222
+ }
223
+ function addPointerlockErrorListener(doc, fn) {
224
+ doc.addEventListener("pointerlockerror", fn, false);
225
+ return function cleanup() {
226
+ doc.removeEventListener("pointerlockerror", fn, false);
227
+ };
228
+ }
229
+ function requestPointerLock(doc, handlers = {}) {
230
+ const { onPointerLock, onPointerUnlock } = handlers;
231
+ const body = doc.body;
232
+ const supported = "pointerLockElement" in doc || "mozPointerLockElement" in doc;
233
+ const locked = !!doc.pointerLockElement;
234
+ function onPointerChange() {
235
+ if (locked)
236
+ onPointerLock == null ? void 0 : onPointerLock();
237
+ else
238
+ onPointerUnlock == null ? void 0 : onPointerUnlock();
239
+ }
240
+ function onPointerError(event) {
241
+ if (locked)
242
+ onPointerUnlock == null ? void 0 : onPointerUnlock();
243
+ console.error("PointerLock error occured:", event);
244
+ exit();
245
+ }
246
+ function exit() {
247
+ doc.exitPointerLock();
248
+ }
249
+ if (!supported)
250
+ return;
251
+ body.requestPointerLock();
252
+ const cleanup = pipe(addPointerlockChangeListener(doc, onPointerChange), addPointerlockErrorListener(doc, onPointerError));
253
+ return function dispose() {
254
+ if (!supported)
255
+ return;
256
+ cleanup();
257
+ exit();
258
+ };
259
+ }
260
+
261
+ // ../../utilities/number/src/number-format.ts
262
+ var nf = new Intl.NumberFormat("en-US", { style: "decimal" });
263
+ function formatter(n) {
264
+ return parseFloat(nf.format(n));
265
+ }
266
+
267
+ // ../../utilities/number/src/number.ts
268
+ function wrap(num, max) {
269
+ return (num % max + max) % max;
270
+ }
271
+ function round(v, t2) {
272
+ let num = valueOf(v);
273
+ const p = __pow(10, t2 != null ? t2 : 10);
274
+ num = Math.round(num * p) / p;
275
+ return t2 ? num.toFixed(t2) : v.toString();
276
+ }
277
+ function roundToPx(num) {
278
+ if (typeof window === "undefined")
279
+ return Math.round(num);
280
+ const dp = window.devicePixelRatio;
281
+ return Math.floor(num * dp + 0.5) / dp;
282
+ }
283
+ function clamp(v, o) {
284
+ return Math.min(Math.max(valueOf(v), o.min), o.max);
285
+ }
286
+ function countDecimals(v) {
287
+ var _a, _b;
288
+ return (_b = (_a = nf.formatToParts(v).find((p) => p.type === "fraction")) == null ? void 0 : _a.value.length) != null ? _b : 0;
289
+ }
290
+ var increment = (v, s) => formatter(valueOf(v) + s);
291
+ var decrement = (v, s) => formatter(valueOf(v) - s);
292
+ var multiply = (v, s) => formatter(valueOf(v) * s);
293
+ function valueOf(v) {
294
+ if (typeof v === "number")
295
+ return v;
296
+ const num = parseFloat(v.toString().replace(/[^\w.-]+/g, ""));
297
+ return !Number.isNaN(num) ? num : 0;
298
+ }
299
+ function getMaxPrecision(o) {
300
+ var _a;
301
+ const stepPrecision = countDecimals(o.step);
302
+ const val = valueOf(o.value);
303
+ const valuePrecision = Number.isNaN(val) ? stepPrecision : Math.max(countDecimals(val), stepPrecision);
304
+ return Math.max(valuePrecision, (_a = o.precision) != null ? _a : 0);
305
+ }
306
+ function roundToPrecision(v, o) {
307
+ return round(v, getMaxPrecision(__spreadProps(__spreadValues({}, o), { value: v })));
308
+ }
309
+ function isAtMax(v, o) {
310
+ const val = valueOf(v);
311
+ return val >= o.max;
312
+ }
313
+ function isAtMin(v, o) {
314
+ const val = valueOf(v);
315
+ return val <= o.min;
316
+ }
317
+ function isWithinRange(v, o) {
318
+ const val = valueOf(v);
319
+ return val >= o.min && val <= o.max;
320
+ }
321
+
322
+ // ../../utilities/rect/src/point.ts
323
+ var fallback = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 };
324
+ function getEventPoint(e, t2 = "page") {
325
+ const p = isTouchEvent(e) ? e.touches[0] || e.changedTouches[0] || fallback : e;
326
+ return { x: p[`${t2}X`], y: p[`${t2}Y`] };
327
+ }
328
+
329
+ // ../../types/src/prop-types.ts
330
+ function createNormalizer(fn) {
331
+ return { button: fn, label: fn, input: fn, output: fn, element: fn };
332
+ }
333
+ var normalizeProp = createNormalizer((v) => v);
334
+
335
+ // src/number-input.dom.ts
336
+ var dom = {
337
+ getDoc: (ctx) => {
338
+ var _a;
339
+ return (_a = ctx.doc) != null ? _a : document;
340
+ },
341
+ getWin: (ctx) => {
342
+ var _a;
343
+ return (_a = dom.getDoc(ctx).defaultView) != null ? _a : window;
344
+ },
345
+ getInputId: (ctx) => {
346
+ var _a, _b;
347
+ return (_b = (_a = ctx.ids) == null ? void 0 : _a.input) != null ? _b : `number-input-${ctx.uid}-input`;
348
+ },
349
+ getIncButtonId: (ctx) => {
350
+ var _a, _b;
351
+ return (_b = (_a = ctx.ids) == null ? void 0 : _a.incBtn) != null ? _b : `number-input-${ctx.uid}-inc-btn`;
352
+ },
353
+ getDecButtonId: (ctx) => {
354
+ var _a, _b;
355
+ return (_b = (_a = ctx.ids) == null ? void 0 : _a.decBtn) != null ? _b : `number-input-${ctx.uid}-dec-btn`;
356
+ },
357
+ getScrubberId: (ctx) => {
358
+ var _a, _b;
359
+ return (_b = (_a = ctx.ids) == null ? void 0 : _a.scrubber) != null ? _b : `number-input-${ctx.uid}-scrubber`;
360
+ },
361
+ getCursorId: (ctx) => `number-input-${ctx.uid}-cursor`,
362
+ getLabelId: (ctx) => {
363
+ var _a, _b;
364
+ return (_b = (_a = ctx.ids) == null ? void 0 : _a.label) != null ? _b : `number-input-${ctx.uid}-label`;
365
+ },
366
+ getRootId: (ctx) => {
367
+ var _a, _b;
368
+ return (_b = (_a = ctx.ids) == null ? void 0 : _a.root) != null ? _b : `number-input-${ctx.uid}-root`;
369
+ },
370
+ getInputEl: (ctx) => dom.getDoc(ctx).getElementById(dom.getInputId(ctx)),
371
+ getIncButtonEl: (ctx) => dom.getDoc(ctx).getElementById(dom.getIncButtonId(ctx)),
372
+ getDecButtonEl: (ctx) => dom.getDoc(ctx).getElementById(dom.getDecButtonId(ctx)),
373
+ getScrubberEl: (ctx) => dom.getDoc(ctx).getElementById(dom.getScrubberId(ctx)),
374
+ getCursorEl: (ctx) => dom.getDoc(ctx).getElementById(dom.getCursorId(ctx)),
375
+ getMousementValue(ctx, event) {
376
+ const x = roundToPx(event.movementX);
377
+ const y = roundToPx(event.movementY);
378
+ let hint = x > 0 ? "increment" : x < 0 ? "decrement" : null;
379
+ if (ctx.isRtl && hint === "increment")
380
+ hint = "decrement";
381
+ if (ctx.isRtl && hint === "decrement")
382
+ hint = "increment";
383
+ const point = {
384
+ x: ctx.scrubberCursorPoint.x + x,
385
+ y: ctx.scrubberCursorPoint.y + y
386
+ };
387
+ const win = dom.getWin(ctx);
388
+ const width = win.innerWidth;
389
+ const half = roundToPx(7.5);
390
+ point.x = wrap(point.x + half, width) - half;
391
+ return { hint, point };
392
+ },
393
+ createVirtualCursor(ctx) {
394
+ const doc = dom.getDoc(ctx);
395
+ const el = doc.createElement("div");
396
+ el.className = "scrubber--cursor";
397
+ el.id = dom.getCursorId(ctx);
398
+ Object.assign(el.style, {
399
+ width: "15px",
400
+ height: "15px",
401
+ position: "fixed",
402
+ pointerEvents: "none",
403
+ left: "0px",
404
+ top: "0px",
405
+ zIndex: MAX_Z_INDEX,
406
+ transform: ctx.scrubberCursorPoint ? `translate3d(${ctx.scrubberCursorPoint.x}px, ${ctx.scrubberCursorPoint.y}px, 0px)` : void 0,
407
+ willChange: "transform"
408
+ });
409
+ el.innerHTML = `
2
410
  <svg width="46" height="15" style="left: -15.5px; position: absolute; top: 0; filter: drop-shadow(rgba(0, 0, 0, 0.4) 0px 1px 1.1px);">
3
411
  <g transform="translate(2 3)">
4
412
  <path fill-rule="evenodd" d="M 15 4.5L 15 2L 11.5 5.5L 15 9L 15 6.5L 31 6.5L 31 9L 34.5 5.5L 31 2L 31 4.5Z" style="stroke-width: 2px; stroke: white;"></path>
5
413
  <path fill-rule="evenodd" d="M 15 4.5L 15 2L 11.5 5.5L 15 9L 15 6.5L 31 6.5L 31 9L 34.5 5.5L 31 2L 31 4.5Z"></path>
6
414
  </g>
7
- </svg>`,t.body.appendChild(n)}};var p={isValidNumericEvent:(e,t)=>{var o,a;if(t.key==null)return!0;let n=t.ctrlKey||t.altKey||t.metaKey,r=t.key.length===1;return n||!r?!0:(a=(o=e.validateCharacter)==null?void 0:o.call(e,t.key))!=null?a:p.isFloatingPoint(t.key)},isFloatingPoint:e=>/^[Ee0-9+\-.]$/.test(e),sanitize:(e,t)=>{var n;return t.split("").filter((n=e.validateCharacter)!=null?n:p.isFloatingPoint).join("")},increment:(e,t)=>{let n=X(e.value,t!=null?t:e.step);return n=M(n,e),S(n,e)},decrement:(e,t)=>{let n=z(e.value,t!=null?t:e.step);return n=M(n,e),S(n,e)},clamp:e=>{let t=M(e.value,e);return S(t,e)},parse:(e,t)=>{var n,r;return(r=(n=e.parse)==null?void 0:n.call(e,t))!=null?r:t},format:(e,t)=>{var r,o;let n=t.toString();return(o=(r=e.format)==null?void 0:r.call(e,n))!=null?o:n},round:e=>S(e.value,e)};function Q(e,t,n=J){let r=e.hasTag("focus"),o=e.context.isOutOfRange||!!e.context.invalid,a=!!e.context.disabled,u=a||!e.context.canIncrement,c=a||!e.context.canDecrement,s=e.context.messages;return{isFocused:r,isInvalid:o,value:e.context.formattedValue,valueAsNumber:e.context.valueAsNumber,setValue(l){t({type:"SET_VALUE",value:l.toString()})},clearValue(){t({type:"SET_VALUE",value:""})},increment(){t("INCREMENT")},decrement(){t("DECREMENT")},setToMax(){t({type:"SET_VALUE",value:e.context.max})},setToMin(){t({type:"SET_VALUE",value:e.context.min})},focus(){P(()=>{var l;(l=i.getInputEl(e.context))==null||l.focus()})},rootProps:n.element({id:i.getRootId(e.context),"data-part":"root","data-disabled":h(a)}),labelProps:n.label({"data-part":"label","data-disabled":h(a),"data-invalid":h(o),id:i.getLabelId(e.context),htmlFor:i.getInputId(e.context)}),inputProps:n.input({"data-part":"input",name:e.context.name,id:i.getInputId(e.context),role:"spinbutton",value:e.context.formattedValue,pattern:e.context.pattern,inputMode:e.context.inputMode,"aria-invalid":o||void 0,"data-invalid":h(o),disabled:a,"data-disabled":h(a),readOnly:!!e.context.readonly,autoComplete:"off",autoCorrect:"off",spellCheck:"false",type:"text","aria-roledescription":"number field","aria-valuemin":e.context.min,"aria-valuemax":e.context.max,"aria-valuenow":isNaN(e.context.valueAsNumber)?void 0:e.context.valueAsNumber,"aria-valuetext":e.context.valueText,onFocus(){t("FOCUS")},onBlur(){t("BLUR")},onChange(l){L(l).isComposing||t({type:"CHANGE",target:l.currentTarget,hint:"set"})},onKeyDown(l){if(L(l).isComposing)return;p.isValidNumericEvent(e.context,l)||l.preventDefault();let d=K(_(l),e.context.step),g={ArrowUp(){t({type:"ARROW_UP",step:d})},ArrowDown(){t({type:"ARROW_DOWN",step:d})},Home(){t("HOME")},End(){t("END")}}[l.key];g&&(g(l),l.preventDefault())}}),decrementButtonProps:n.button({"data-part":"spin-button",id:i.getDecButtonId(e.context),disabled:c,"data-disabled":h(c),"aria-label":s.decrementLabel,type:"button",tabIndex:-1,"aria-controls":i.getInputId(e.context),onPointerDown(l){c||(t({type:"PRESS_DOWN",hint:"decrement"}),l.preventDefault())},onPointerUp(){t({type:"PRESS_UP",hint:"decrement"})},onPointerLeave(){c||t({type:"PRESS_UP",hint:"decrement"})}}),incrementButtonProps:n.button({"data-part":"spin-button",id:i.getIncButtonId(e.context),disabled:u,"data-disabled":h(u),"aria-label":s.incrementLabel,type:"button",tabIndex:-1,"aria-controls":i.getInputId(e.context),onPointerDown(l){l.preventDefault(),!u&&t({type:"PRESS_DOWN",hint:"increment"})},onPointerUp(){t({type:"PRESS_UP",hint:"increment"})},onPointerLeave(){t({type:"PRESS_UP",hint:"increment"})}}),scrubberProps:n.element({"data-disabled":h(a),"data-part":"scrubber",id:i.getScrubberId(e.context),role:"presentation",onMouseDown(l){if(a)return;let m=L(l);l.preventDefault();let d=Z(m);d.x=d.x-w(7.5),d.y=d.y-w(7.5),t({type:"PRESS_DOWN_SCRUBBER",point:d})},style:{cursor:a?void 0:"ew-resize"}})}}var y=require("@zag-js/core");var ee=(...e)=>t=>e.reduce((n,r)=>r(n),t);var at=(()=>{let e=0;return()=>(e++,e.toString(36))})();var Ne=e=>te()&&e.test(navigator.userAgent);var te=()=>typeof window!="undefined";var I=()=>Ne(/^((?!chrome|android).)*safari/i);var A=()=>te()&&window.onpointerdown===null;var{not:R,and:D}=y.guards,ne=(0,y.createMachine)({id:"number-input",initial:"unknown",context:{uid:"",dir:"ltr",focusInputOnChange:!0,clampValueOnBlur:!0,allowOverflow:!1,inputMode:"decimal",pattern:"[0-9]*(.[0-9]+)?",hint:null,value:"",step:1,min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,precision:0,inputSelection:null,scrubberCursorPoint:null,invalid:!1,messages:{incrementLabel:"increment value",decrementLabel:"decrease value"}},computed:{isRtl:e=>e.dir==="rtl",valueAsNumber:e=>v(e.value),isAtMin:e=>$(e.value,e),isAtMax:e=>q(e.value,e),isOutOfRange:e=>!G(e.value,e),canIncrement:e=>e.allowOverflow||!e.isAtMax,canDecrement:e=>e.allowOverflow||!e.isAtMin,valueText:e=>{var t,n;return(n=(t=e.messages).valueText)==null?void 0:n.call(t,e.value)},formattedValue:e=>{var t,n;return(n=(t=e.format)==null?void 0:t.call(e,e.value).toString())!=null?n:e.value}},watch:{value:["invokeOnChange"],isOutOfRange:["invokeOnInvalid"]},entry:["syncInputValue"],on:{SET_VALUE:{actions:["setValue","setHintToSet"]},INCREMENT:{actions:["increment"]},DECREMENT:{actions:["decrement"]}},states:{unknown:{on:{SETUP:{target:"idle",actions:"setupDocument"}}},idle:{on:{PRESS_DOWN:{target:"before:spin",actions:["focusInput","setHint"]},PRESS_DOWN_SCRUBBER:{target:"scrubbing",actions:["focusInput","setHint","setCursorPoint"]},FOCUS:"focused"}},focused:{tags:["focus"],activities:"attachWheelListener",on:{PRESS_DOWN:{target:"before:spin",actions:["focusInput","setHint"]},PRESS_DOWN_SCRUBBER:{target:"scrubbing",actions:["focusInput","setHint","setCursorPoint"]},ARROW_UP:{actions:"increment"},ARROW_DOWN:{actions:"decrement"},HOME:{actions:"setToMin"},END:{actions:"setToMax"},CHANGE:{actions:["setValue","setSelectionRange","setHint"]},BLUR:[{guard:"isInvalidExponential",target:"idle",actions:["clearValue","clearHint"]},{guard:D("clampOnBlur",R("isInRange")),target:"idle",actions:["clampValue","clearHint"]},{actions:["roundValue"]}]}},"before:spin":{tags:["focus"],entry:(0,y.choose)([{guard:"isIncrementHint",actions:"increment"},{guard:"isDecrementHint",actions:"decrement"}]),after:{CHANGE_DELAY:{target:"spinning",guard:"isInRange"}},on:{PRESS_UP:{target:"focused",actions:["clearHint","restoreSelection"]}}},spinning:{tags:["focus"],activities:"trackButtonDisabled",every:[{delay:"CHANGE_INTERVAL",guard:D(R("isAtMin"),"isIncrementHint"),actions:"increment"},{delay:"CHANGE_INTERVAL",guard:D(R("isAtMax"),"isDecrementHint"),actions:"decrement"}],on:{PRESS_UP:{target:"focused",actions:["clearHint","restoreSelection"]}}},scrubbing:{tags:["focus"],entry:["addCustomCursor","disableTextSelection"],exit:["removeCustomCursor","restoreTextSelection"],activities:["activatePointerLock","trackMousemove"],on:{POINTER_UP_SCRUBBER:{target:"focused",actions:["clearCursorPoint"]},POINTER_MOVE_SCRUBBER:[{guard:"isIncrementHint",actions:["increment","setCursorPoint","updateCursor"]},{guard:"isDecrementHint",actions:["decrement","setCursorPoint","updateCursor"]}]}}}},{delays:{CHANGE_INTERVAL:50,CHANGE_DELAY:300},guards:{clampOnBlur:e=>!!e.clampValueOnBlur,isAtMin:e=>e.isAtMin,isAtMax:e=>e.isAtMax,isInRange:e=>!e.isOutOfRange,isDecrementHint:(e,t)=>{var n;return((n=t.hint)!=null?n:e.hint)==="decrement"},isIncrementHint:(e,t)=>{var n;return((n=t.hint)!=null?n:e.hint)==="increment"},isInvalidExponential:e=>e.value.toString().startsWith("e")},activities:{trackButtonDisabled(e,t,{send:n}){let r=null;return e.hint==="increment"&&(r=i.getIncButtonEl(e)),e.hint==="decrement"&&(r=i.getDecButtonEl(e)),H(r,"disabled",function(){n("PRESS_UP")})},attachWheelListener(e){let t=[];return t.push(P(()=>{let n=i.getInputEl(e);if(!n)return;function r(o){let a=i.getDoc(e).activeElement===n;if(!e.allowMouseWheel||!a)return;o.preventDefault();let u=Math.sign(o.deltaY)*-1;u===1?e.value=p.increment(e):u===-1&&(e.value=p.decrement(e))}t.push(C(n,"wheel",r,{passive:!1}))})),()=>t.forEach(n=>n())},activatePointerLock(e){if(!(I()||!A()))return V(i.getDoc(e))},trackMousemove(e,t,{send:n}){let r=i.getDoc(e);function o(u){if(!e.scrubberCursorPoint)return;let c=i.getMousementValue(e,u);!c.hint||n({type:"POINTER_MOVE_SCRUBBER",hint:c.hint,point:c.point})}function a(){n("POINTER_UP_SCRUBBER")}return ee(C(r,"mousemove",o,!1),C(r,"mouseup",a,!1))}},actions:{setupDocument:(e,t)=>{t.doc&&(e.doc=(0,y.ref)(t.doc)),e.uid=t.id},focusInput(e){if(!e.focusInputOnChange)return;let t=i.getInputEl(e);P(()=>t==null?void 0:t.focus())},increment(e,t){e.value=p.increment(e,t.step)},decrement(e,t){e.value=p.decrement(e,t.step)},clampValue(e){e.value=p.clamp(e)},roundValue(e){e.value=p.round(e)},setValue(e,t){var r,o;let n=(o=(r=t.target)==null?void 0:r.value)!=null?o:t.value;e.value=p.sanitize(e,p.parse(e,n))},clearValue(e){e.value=""},setToMax(e){e.value=e.max.toString()},setToMin(e){e.value=e.min.toString()},setHint(e,t){e.hint=t.hint},clearHint(e){e.hint=null},setHintToSet(e){e.hint="set"},setSelectionRange(e,t){e.inputSelection={start:t.target.selectionStart,end:t.target.selectionEnd}},restoreSelection(e){var n,r,o;let t=i.getInputEl(e);!t||!e.inputSelection||(t.selectionStart=(r=e.inputSelection.start)!=null?r:(n=t.value)==null?void 0:n.length,t.selectionEnd=(o=e.inputSelection.end)!=null?o:t.selectionStart)},invokeOnChange(e){var t;(t=e.onChange)==null||t.call(e,{value:e.value,valueAsNumber:e.valueAsNumber})},invokeOnInvalid(e){var n;if(!e.isOutOfRange)return;let t=e.valueAsNumber>e.max?"rangeOverflow":"rangeUnderflow";(n=e.onInvalid)==null||n.call(e,{reason:t,value:e.formattedValue,valueAsNumber:e.valueAsNumber})},syncInputValue(e){let t=i.getInputEl(e);if(!t||t.value==e.value)return;let n=p.parse(e,t.value);e.value=p.sanitize(e,n)},setCursorPoint(e,t){e.scrubberCursorPoint=t.point},clearCursorPoint(e){e.scrubberCursorPoint=null},updateCursor(e){let t=i.getCursorEl(e);!t||!e.scrubberCursorPoint||(t.style.transform=`translate3d(${e.scrubberCursorPoint.x}px, ${e.scrubberCursorPoint.y}px, 0px)`)},addCustomCursor(e){I()||!A()||i.createVirtualCursor(e)},removeCustomCursor(e){if(I()||!A())return;let n=i.getDoc(e).getElementById(i.getCursorId(e));n==null||n.remove()},disableTextSelection(e){let t=i.getDoc(e);t.body.style.pointerEvents="none",t.documentElement.style.userSelect="none",t.documentElement.style.cursor="ew-resize"},restoreTextSelection(e){let t=i.getDoc(e);t.body.style.pointerEvents="",t.documentElement.style.userSelect="",t.documentElement.style.cursor=""}}});module.exports=ce(Be);
415
+ </svg>`;
416
+ doc.body.appendChild(el);
417
+ }
418
+ };
419
+
420
+ // src/number-input.utils.ts
421
+ var utils = {
422
+ isValidNumericEvent: (ctx, event) => {
423
+ var _a, _b;
424
+ if (event.key == null)
425
+ return true;
426
+ const isModifierKey = event.ctrlKey || event.altKey || event.metaKey;
427
+ const isSingleCharacterKey = event.key.length === 1;
428
+ if (isModifierKey || !isSingleCharacterKey)
429
+ return true;
430
+ return (_b = (_a = ctx.validateCharacter) == null ? void 0 : _a.call(ctx, event.key)) != null ? _b : utils.isFloatingPoint(event.key);
431
+ },
432
+ isFloatingPoint: (v) => /^[Ee0-9+\-.]$/.test(v),
433
+ sanitize: (ctx, value) => {
434
+ var _a;
435
+ return value.split("").filter((_a = ctx.validateCharacter) != null ? _a : utils.isFloatingPoint).join("");
436
+ },
437
+ increment: (ctx, step) => {
438
+ let value = increment(ctx.value, step != null ? step : ctx.step);
439
+ value = clamp(value, ctx);
440
+ return roundToPrecision(value, ctx);
441
+ },
442
+ decrement: (ctx, step) => {
443
+ let value = decrement(ctx.value, step != null ? step : ctx.step);
444
+ value = clamp(value, ctx);
445
+ return roundToPrecision(value, ctx);
446
+ },
447
+ clamp: (ctx) => {
448
+ let value = clamp(ctx.value, ctx);
449
+ return roundToPrecision(value, ctx);
450
+ },
451
+ parse: (ctx, value) => {
452
+ var _a, _b;
453
+ return (_b = (_a = ctx.parse) == null ? void 0 : _a.call(ctx, value)) != null ? _b : value;
454
+ },
455
+ format: (ctx, value) => {
456
+ var _a, _b;
457
+ const _val = value.toString();
458
+ return (_b = (_a = ctx.format) == null ? void 0 : _a.call(ctx, _val)) != null ? _b : _val;
459
+ },
460
+ round: (ctx) => {
461
+ return roundToPrecision(ctx.value, ctx);
462
+ }
463
+ };
464
+
465
+ // src/number-input.connect.ts
466
+ function connect(state, send, normalize = normalizeProp) {
467
+ const isFocused = state.hasTag("focus");
468
+ const isInvalid = state.context.isOutOfRange || !!state.context.invalid;
469
+ const isDisabled = !!state.context.disabled;
470
+ const isIncrementDisabled = isDisabled || !state.context.canIncrement;
471
+ const isDecrementDisabled = isDisabled || !state.context.canDecrement;
472
+ const messages = state.context.messages;
473
+ return {
474
+ isFocused,
475
+ isInvalid,
476
+ value: state.context.formattedValue,
477
+ valueAsNumber: state.context.valueAsNumber,
478
+ setValue(value) {
479
+ send({ type: "SET_VALUE", value: value.toString() });
480
+ },
481
+ clearValue() {
482
+ send({ type: "SET_VALUE", value: "" });
483
+ },
484
+ increment() {
485
+ send("INCREMENT");
486
+ },
487
+ decrement() {
488
+ send("DECREMENT");
489
+ },
490
+ setToMax() {
491
+ send({ type: "SET_VALUE", value: state.context.max });
492
+ },
493
+ setToMin() {
494
+ send({ type: "SET_VALUE", value: state.context.min });
495
+ },
496
+ focus() {
497
+ nextTick(() => {
498
+ var _a;
499
+ (_a = dom.getInputEl(state.context)) == null ? void 0 : _a.focus();
500
+ });
501
+ },
502
+ rootProps: normalize.element({
503
+ id: dom.getRootId(state.context),
504
+ "data-part": "root",
505
+ "data-disabled": dataAttr(isDisabled)
506
+ }),
507
+ labelProps: normalize.label({
508
+ "data-part": "label",
509
+ "data-disabled": dataAttr(isDisabled),
510
+ "data-invalid": dataAttr(isInvalid),
511
+ id: dom.getLabelId(state.context),
512
+ htmlFor: dom.getInputId(state.context)
513
+ }),
514
+ inputProps: normalize.input({
515
+ "data-part": "input",
516
+ name: state.context.name,
517
+ id: dom.getInputId(state.context),
518
+ role: "spinbutton",
519
+ value: state.context.formattedValue,
520
+ pattern: state.context.pattern,
521
+ inputMode: state.context.inputMode,
522
+ "aria-invalid": isInvalid || void 0,
523
+ "data-invalid": dataAttr(isInvalid),
524
+ disabled: isDisabled,
525
+ "data-disabled": dataAttr(isDisabled),
526
+ readOnly: !!state.context.readonly,
527
+ autoComplete: "off",
528
+ autoCorrect: "off",
529
+ spellCheck: "false",
530
+ type: "text",
531
+ "aria-roledescription": "number field",
532
+ "aria-valuemin": state.context.min,
533
+ "aria-valuemax": state.context.max,
534
+ "aria-valuenow": isNaN(state.context.valueAsNumber) ? void 0 : state.context.valueAsNumber,
535
+ "aria-valuetext": state.context.valueText,
536
+ onFocus() {
537
+ send("FOCUS");
538
+ },
539
+ onBlur() {
540
+ send("BLUR");
541
+ },
542
+ onChange(event) {
543
+ const evt = getNativeEvent(event);
544
+ if (evt.isComposing)
545
+ return;
546
+ send({ type: "CHANGE", target: event.currentTarget, hint: "set" });
547
+ },
548
+ onKeyDown(event) {
549
+ const evt = getNativeEvent(event);
550
+ if (evt.isComposing)
551
+ return;
552
+ if (!utils.isValidNumericEvent(state.context, event)) {
553
+ event.preventDefault();
554
+ }
555
+ const step = multiply(getEventStep(event), state.context.step);
556
+ const keyMap = {
557
+ ArrowUp() {
558
+ send({ type: "ARROW_UP", step });
559
+ },
560
+ ArrowDown() {
561
+ send({ type: "ARROW_DOWN", step });
562
+ },
563
+ Home() {
564
+ send("HOME");
565
+ },
566
+ End() {
567
+ send("END");
568
+ }
569
+ };
570
+ const exec = keyMap[event.key];
571
+ if (exec) {
572
+ exec(event);
573
+ event.preventDefault();
574
+ }
575
+ }
576
+ }),
577
+ decrementButtonProps: normalize.button({
578
+ "data-part": "spin-button",
579
+ id: dom.getDecButtonId(state.context),
580
+ disabled: isDecrementDisabled,
581
+ "data-disabled": dataAttr(isDecrementDisabled),
582
+ "aria-label": messages.decrementLabel,
583
+ type: "button",
584
+ tabIndex: -1,
585
+ "aria-controls": dom.getInputId(state.context),
586
+ onPointerDown(event) {
587
+ if (isDecrementDisabled)
588
+ return;
589
+ send({ type: "PRESS_DOWN", hint: "decrement" });
590
+ event.preventDefault();
591
+ },
592
+ onPointerUp() {
593
+ send({ type: "PRESS_UP", hint: "decrement" });
594
+ },
595
+ onPointerLeave() {
596
+ if (isDecrementDisabled)
597
+ return;
598
+ send({ type: "PRESS_UP", hint: "decrement" });
599
+ }
600
+ }),
601
+ incrementButtonProps: normalize.button({
602
+ "data-part": "spin-button",
603
+ id: dom.getIncButtonId(state.context),
604
+ disabled: isIncrementDisabled,
605
+ "data-disabled": dataAttr(isIncrementDisabled),
606
+ "aria-label": messages.incrementLabel,
607
+ type: "button",
608
+ tabIndex: -1,
609
+ "aria-controls": dom.getInputId(state.context),
610
+ onPointerDown(event) {
611
+ event.preventDefault();
612
+ if (isIncrementDisabled)
613
+ return;
614
+ send({ type: "PRESS_DOWN", hint: "increment" });
615
+ },
616
+ onPointerUp() {
617
+ send({ type: "PRESS_UP", hint: "increment" });
618
+ },
619
+ onPointerLeave() {
620
+ send({ type: "PRESS_UP", hint: "increment" });
621
+ }
622
+ }),
623
+ scrubberProps: normalize.element({
624
+ "data-disabled": dataAttr(isDisabled),
625
+ "data-part": "scrubber",
626
+ id: dom.getScrubberId(state.context),
627
+ role: "presentation",
628
+ onMouseDown(event) {
629
+ if (isDisabled)
630
+ return;
631
+ const evt = getNativeEvent(event);
632
+ event.preventDefault();
633
+ const point = getEventPoint(evt);
634
+ point.x = point.x - roundToPx(7.5);
635
+ point.y = point.y - roundToPx(7.5);
636
+ send({ type: "PRESS_DOWN_SCRUBBER", point });
637
+ },
638
+ style: {
639
+ cursor: isDisabled ? void 0 : "ew-resize"
640
+ }
641
+ })
642
+ };
643
+ }
644
+
645
+ // ../../../node_modules/@zag-js/core/src/index.ts
646
+ var import_vanilla3 = require("valtio/vanilla");
647
+
648
+ // ../../core/src/action-utils.ts
649
+ function choose(actions) {
650
+ return {
651
+ predicate: (guardMap) => (ctx, event) => {
652
+ var _a;
653
+ return (_a = actions.find((def) => {
654
+ var _a2;
655
+ def.guard = def.guard || (() => true);
656
+ if (isString(def.guard)) {
657
+ return !!((_a2 = guardMap[def.guard]) == null ? void 0 : _a2.call(guardMap, ctx, event));
658
+ }
659
+ if (isGuardHelper(def.guard)) {
660
+ return def.guard.predicate(guardMap != null ? guardMap : {})(ctx, event);
661
+ }
662
+ return def.guard(ctx, event);
663
+ })) == null ? void 0 : _a.actions;
664
+ }
665
+ };
666
+ }
667
+ function isGuardHelper(value) {
668
+ return isObject(value) && value.predicate != null;
669
+ }
670
+ function determineActionsFn(values, guardMap) {
671
+ return (context, event) => {
672
+ if (isGuardHelper(values))
673
+ return values.predicate(guardMap != null ? guardMap : {})(context, event);
674
+ return values;
675
+ };
676
+ }
677
+
678
+ // ../../core/src/guard-utils.ts
679
+ function or(...conditions) {
680
+ return {
681
+ predicate: (guards2) => (ctx, event) => conditions.map((condition) => {
682
+ var _a;
683
+ if (isString(condition)) {
684
+ return !!((_a = guards2[condition]) == null ? void 0 : _a.call(guards2, ctx, event));
685
+ }
686
+ if (isFunction(condition)) {
687
+ return condition(ctx, event);
688
+ }
689
+ return condition.predicate(guards2)(ctx, event);
690
+ }).some(Boolean)
691
+ };
692
+ }
693
+ function and(...conditions) {
694
+ return {
695
+ predicate: (guards2) => (ctx, event) => conditions.map((condition) => {
696
+ var _a;
697
+ if (isString(condition)) {
698
+ return !!((_a = guards2[condition]) == null ? void 0 : _a.call(guards2, ctx, event));
699
+ }
700
+ if (isFunction(condition)) {
701
+ return condition(ctx, event);
702
+ }
703
+ return condition.predicate(guards2)(ctx, event);
704
+ }).every(Boolean)
705
+ };
706
+ }
707
+ function not(condition) {
708
+ return {
709
+ predicate: (guardMap) => (ctx, event) => {
710
+ var _a;
711
+ if (isString(condition)) {
712
+ return !((_a = guardMap[condition]) == null ? void 0 : _a.call(guardMap, ctx, event));
713
+ }
714
+ if (isFunction(condition)) {
715
+ return !condition(ctx, event);
716
+ }
717
+ return !condition.predicate(guardMap)(ctx, event);
718
+ }
719
+ };
720
+ }
721
+ var guards = { or, and, not };
722
+ function isGuardHelper2(value) {
723
+ return isObject(value) && value.predicate != null;
724
+ }
725
+ var TruthyGuard = () => true;
726
+ function determineGuardFn(guard, guardMap) {
727
+ guard = guard != null ? guard : TruthyGuard;
728
+ return (context, event) => {
729
+ if (isString(guard)) {
730
+ const value = guardMap == null ? void 0 : guardMap[guard];
731
+ return isFunction(value) ? value(context, event) : value;
732
+ }
733
+ if (isGuardHelper2(guard)) {
734
+ return guard.predicate(guardMap != null ? guardMap : {})(context, event);
735
+ }
736
+ return guard == null ? void 0 : guard(context, event);
737
+ };
738
+ }
739
+
740
+ // ../../../node_modules/klona/json/index.mjs
741
+ function klona(val) {
742
+ var k, out, tmp;
743
+ if (Array.isArray(val)) {
744
+ out = Array(k = val.length);
745
+ while (k--)
746
+ out[k] = (tmp = val[k]) && typeof tmp === "object" ? klona(tmp) : tmp;
747
+ return out;
748
+ }
749
+ if (Object.prototype.toString.call(val) === "[object Object]") {
750
+ out = {};
751
+ for (k in val) {
752
+ if (k === "__proto__") {
753
+ Object.defineProperty(out, k, {
754
+ value: klona(val[k]),
755
+ configurable: true,
756
+ enumerable: true,
757
+ writable: true
758
+ });
759
+ } else {
760
+ out[k] = (tmp = val[k]) && typeof tmp === "object" ? klona(tmp) : tmp;
761
+ }
762
+ }
763
+ return out;
764
+ }
765
+ return val;
766
+ }
767
+
768
+ // ../../core/src/machine.ts
769
+ var import_utils13 = require("valtio/utils");
770
+ var import_vanilla2 = require("valtio/vanilla");
771
+
772
+ // ../../core/src/create-proxy.ts
773
+ var import_vanilla = require("valtio/vanilla");
774
+ function createProxy(config) {
775
+ var _a;
776
+ const state = (0, import_vanilla.proxy)({
777
+ value: "",
778
+ previousValue: "",
779
+ event: cast({}),
780
+ context: (_a = config.context) != null ? _a : cast({}),
781
+ done: false,
782
+ tags: [],
783
+ hasTag(tag) {
784
+ return this.tags.includes(tag);
785
+ },
786
+ matches(...value) {
787
+ return value.includes(this.value);
788
+ },
789
+ can(event) {
790
+ return cast(this).nextEvents.includes(event);
791
+ },
792
+ get nextEvents() {
793
+ var _a2, _b, _c, _d;
794
+ const stateEvents = (_c = (_b = (_a2 = config.states) == null ? void 0 : _a2[this.value]) == null ? void 0 : _b["on"]) != null ? _c : {};
795
+ const globalEvents = (_d = config == null ? void 0 : config.on) != null ? _d : {};
796
+ return Object.keys(__spreadValues(__spreadValues({}, stateEvents), globalEvents));
797
+ },
798
+ get changed() {
799
+ if (this.event.value === "machine.init" /* Init */ || !this.previousValue)
800
+ return false;
801
+ return this.value !== this.previousValue;
802
+ }
803
+ });
804
+ return cast(state);
805
+ }
806
+
807
+ // ../../core/src/delay-utils.ts
808
+ function determineDelayFn(delay, delaysMap) {
809
+ return (context, event) => {
810
+ if (isNumber(delay))
811
+ return delay;
812
+ if (isFunction(delay)) {
813
+ return delay(context, event);
814
+ }
815
+ if (isString(delay)) {
816
+ const value = Number.parseFloat(delay);
817
+ if (!Number.isNaN(value)) {
818
+ return value;
819
+ }
820
+ if (delaysMap) {
821
+ const valueOrFn = delaysMap == null ? void 0 : delaysMap[delay];
822
+ if (valueOrFn == null) {
823
+ const msg = `[machine] Cannot determine delay for ${delay}. It doesn't exist in options.delays`;
824
+ throw new Error(msg);
825
+ }
826
+ return isFunction(valueOrFn) ? valueOrFn(context, event) : valueOrFn;
827
+ }
828
+ }
829
+ };
830
+ }
831
+
832
+ // ../../core/src/utils.ts
833
+ function toEvent(event) {
834
+ const obj = isString(event) ? { type: event } : event;
835
+ return obj;
836
+ }
837
+ function toArray(value) {
838
+ if (!value)
839
+ return [];
840
+ return isArray(value) ? value : [value];
841
+ }
842
+
843
+ // ../../core/src/transition-utils.ts
844
+ function toTarget(target) {
845
+ return isString(target) ? { target } : target;
846
+ }
847
+ function determineTransitionFn(transitions, guardMap) {
848
+ return (context, event) => {
849
+ return toArray(transitions).map(toTarget).find((transition) => {
850
+ var _a;
851
+ const determineGuard = determineGuardFn(transition.guard, guardMap);
852
+ const guard = determineGuard(context, event);
853
+ return (_a = guard != null ? guard : transition.target) != null ? _a : transition.actions;
854
+ });
855
+ };
856
+ }
857
+ function toTransition(transition, current) {
858
+ const _transition = isString(transition) ? toTarget(transition) : transition;
859
+ const fn = (t2) => {
860
+ const isTargetless = t2.actions && !t2.target;
861
+ if (isTargetless && current)
862
+ t2.target = current;
863
+ return t2;
864
+ };
865
+ if (isArray(_transition)) {
866
+ return _transition.map(fn);
867
+ }
868
+ if (isObject(_transition)) {
869
+ return fn(cast(_transition));
870
+ }
871
+ }
872
+
873
+ // ../../core/src/machine.ts
874
+ var Machine = class {
875
+ constructor(config, options) {
876
+ this.config = config;
877
+ this.status = "Not Started" /* NotStarted */;
878
+ this.type = "machine" /* Machine */;
879
+ this.activityEvents = /* @__PURE__ */ new Map();
880
+ this.delayedEvents = /* @__PURE__ */ new Map();
881
+ this.stateListeners = /* @__PURE__ */ new Set();
882
+ this.eventListeners = /* @__PURE__ */ new Set();
883
+ this.doneListeners = /* @__PURE__ */ new Set();
884
+ this.contextWatchers = /* @__PURE__ */ new Set();
885
+ this.removeStateListener = noop;
886
+ this.removeEventListener = noop;
887
+ this.children = /* @__PURE__ */ new Map();
888
+ this.start = (init) => {
889
+ if (this.status === "Running" /* Running */) {
890
+ return this;
891
+ }
892
+ this.status = "Running" /* Running */;
893
+ const event = toEvent("machine.init" /* Init */);
894
+ if (init) {
895
+ const resolved = isObject(init) ? init : { context: this.config.context, value: init };
896
+ this.setState(resolved.value);
897
+ this.setContext(resolved.context);
898
+ }
899
+ const transition = {
900
+ target: !!init ? void 0 : this.config.initial
901
+ };
902
+ const info = this.getNextStateInfo(transition, event);
903
+ info.target = cast(info.target || transition.target);
904
+ this.initialState = info;
905
+ this.performStateChangeEffects(info.target, info, event);
906
+ this.removeStateListener = (0, import_vanilla2.subscribe)(this.state, () => {
907
+ this.stateListeners.forEach((listener) => {
908
+ listener(this.stateSnapshot);
909
+ });
910
+ }, this.sync);
911
+ this.removeEventListener = (0, import_utils13.subscribeKey)(this.state, "event", (value) => {
912
+ if (this.config.onEvent) {
913
+ this.executeActions(this.config.onEvent, value);
914
+ }
915
+ for (const listener of this.eventListeners) {
916
+ listener(value);
917
+ }
918
+ });
919
+ this.setupContextWatchers();
920
+ this.executeActivities(toEvent("machine.start" /* Start */), toArray(this.config.activities), "machine.start" /* Start */);
921
+ this.executeActions(this.config.entry, toEvent("machine.start" /* Start */));
922
+ return this;
923
+ };
924
+ this.setupContextWatchers = () => {
925
+ var _a;
926
+ for (const [key, fn] of Object.entries((_a = this.config.watch) != null ? _a : {})) {
927
+ this.contextWatchers.add((0, import_utils13.subscribeKey)(this.state.context, key, () => {
928
+ this.executeActions(fn, this.state.event);
929
+ }));
930
+ }
931
+ };
932
+ this.setupComputed = () => {
933
+ var _a;
934
+ const computed = cast((_a = this.config.computed) != null ? _a : {});
935
+ const deriveFns = Object.fromEntries(Object.entries(computed).map(([key, fn]) => [key, (get) => fn(get(this.state.context))]));
936
+ (0, import_utils13.derive)(deriveFns, { proxy: this.state.context });
937
+ };
938
+ this.detachComputed = () => {
939
+ (0, import_utils13.underive)(this.state.context, { delete: true });
940
+ };
941
+ this.stop = () => {
942
+ if (this.status === "Stopped" /* Stopped */)
943
+ return;
944
+ this.setState(null);
945
+ this.setEvent("machine.stop" /* Stop */);
946
+ if (this.config.context) {
947
+ this.setContext(this.config.context);
948
+ }
949
+ this.stopStateListeners();
950
+ this.stopChildren();
951
+ this.stopActivities();
952
+ this.stopDelayedEvents();
953
+ this.stopContextWatchers();
954
+ this.stopEventListeners();
955
+ this.detachComputed();
956
+ this.status = "Stopped" /* Stopped */;
957
+ this.executeActions(this.config.exit, toEvent("machine.stop" /* Stop */));
958
+ return this;
959
+ };
960
+ this.stopEventListeners = () => {
961
+ this.eventListeners.clear();
962
+ this.removeEventListener();
963
+ };
964
+ this.stopStateListeners = () => {
965
+ this.removeStateListener();
966
+ this.stateListeners.clear();
967
+ };
968
+ this.stopContextWatchers = () => {
969
+ this.contextWatchers.forEach((fn) => fn());
970
+ this.contextWatchers.clear();
971
+ };
972
+ this.stopDelayedEvents = () => {
973
+ this.delayedEvents.forEach((state) => {
974
+ state.forEach((stop) => stop());
975
+ });
976
+ this.delayedEvents.clear();
977
+ };
978
+ this.stopActivities = (state) => {
979
+ var _a, _b;
980
+ if (state) {
981
+ (_a = this.activityEvents.get(state)) == null ? void 0 : _a.forEach((stop) => stop());
982
+ (_b = this.activityEvents.get(state)) == null ? void 0 : _b.clear();
983
+ this.activityEvents.delete(state);
984
+ } else {
985
+ this.activityEvents.forEach((state2) => {
986
+ state2.forEach((stop) => stop());
987
+ state2.clear();
988
+ });
989
+ this.activityEvents.clear();
990
+ }
991
+ };
992
+ this.sendChild = (evt, to) => {
993
+ const event = toEvent(evt);
994
+ const id = runIfFn(to, this.contextSnapshot);
995
+ const child = this.children.get(id);
996
+ if (!child) {
997
+ invariant(`[machine/send-child] Cannot send '${event.type}' event to unknown child`);
998
+ }
999
+ child.send(event);
1000
+ };
1001
+ this.stopChild = (id) => {
1002
+ if (!this.children.has(id)) {
1003
+ invariant("[machine/stop-child] Cannot stop unknown child");
1004
+ }
1005
+ this.children.get(id).stop();
1006
+ this.children.delete(id);
1007
+ };
1008
+ this.removeChild = (id) => {
1009
+ this.children.delete(id);
1010
+ };
1011
+ this.stopChildren = () => {
1012
+ this.children.forEach((child) => child.stop());
1013
+ this.children.clear();
1014
+ };
1015
+ this.setParent = (parent) => {
1016
+ this.parent = parent;
1017
+ };
1018
+ this.spawn = (src, id) => {
1019
+ const actor = runIfFn(src);
1020
+ if (id)
1021
+ actor.id = id;
1022
+ actor.type = "machine.actor" /* Actor */;
1023
+ actor.setParent(this);
1024
+ this.children.set(actor.id, cast(actor));
1025
+ actor.onDone(() => {
1026
+ this.removeChild(actor.id);
1027
+ }).start();
1028
+ return cast((0, import_vanilla2.ref)(actor));
1029
+ };
1030
+ this.addActivityCleanup = (state, cleanup) => {
1031
+ var _a;
1032
+ if (!state)
1033
+ return;
1034
+ if (!this.activityEvents.has(state)) {
1035
+ this.activityEvents.set(state, /* @__PURE__ */ new Set([cleanup]));
1036
+ } else {
1037
+ (_a = this.activityEvents.get(state)) == null ? void 0 : _a.add(cleanup);
1038
+ }
1039
+ };
1040
+ this.setState = (target) => {
1041
+ this.state.previousValue = this.state.value;
1042
+ this.state.value = target;
1043
+ const stateNode = this.getStateNode(target);
1044
+ if (target == null) {
1045
+ clear(this.state.tags);
1046
+ } else {
1047
+ this.state.tags = toArray(stateNode == null ? void 0 : stateNode.tags);
1048
+ }
1049
+ };
1050
+ this.setContext = (context) => {
1051
+ for (const key in context) {
1052
+ this.state.context[key] = context[key];
1053
+ }
1054
+ };
1055
+ this.withContext = (context) => {
1056
+ this.detachComputed();
1057
+ const newContext = __spreadValues(__spreadValues({}, this.config.context), context);
1058
+ return new Machine(__spreadProps(__spreadValues({}, this.config), { context: newContext }), this.options);
1059
+ };
1060
+ this.withOptions = (options) => {
1061
+ this.detachComputed();
1062
+ return new Machine(this.config, __spreadValues(__spreadValues({}, this.options), options));
1063
+ };
1064
+ this.setActions = (actions) => {
1065
+ this.actionMap = __spreadValues(__spreadValues({}, this.actionMap), actions);
1066
+ };
1067
+ this.clone = () => {
1068
+ this.detachComputed();
1069
+ return new Machine(this.config, this.options);
1070
+ };
1071
+ this.getStateNode = (state) => {
1072
+ var _a;
1073
+ if (!state)
1074
+ return;
1075
+ return (_a = this.config.states) == null ? void 0 : _a[state];
1076
+ };
1077
+ this.getNextStateInfo = (transitions, event) => {
1078
+ var _a;
1079
+ const transition = this.determineTransition(transitions, event);
1080
+ const target = (_a = transition == null ? void 0 : transition.target) != null ? _a : this.state.value;
1081
+ const stateNode = this.getStateNode(target);
1082
+ return {
1083
+ transition,
1084
+ stateNode,
1085
+ target
1086
+ };
1087
+ };
1088
+ this.getActionFromDelayedTransition = (transition) => {
1089
+ const event = toEvent("machine.after" /* After */);
1090
+ const determineDelay = determineDelayFn(transition.delay, this.delayMap);
1091
+ const delay = determineDelay(this.contextSnapshot, event);
1092
+ let id;
1093
+ return {
1094
+ entry: () => {
1095
+ id = globalThis.setTimeout(() => {
1096
+ const current = this.state.value;
1097
+ const next = this.getNextStateInfo(transition, event);
1098
+ this.performStateChangeEffects(current, next, event);
1099
+ }, delay);
1100
+ },
1101
+ exit: () => {
1102
+ globalThis.clearTimeout(id);
1103
+ }
1104
+ };
1105
+ };
1106
+ this.getDelayedEventActions = (state) => {
1107
+ const stateNode = this.getStateNode(state);
1108
+ const event = toEvent("machine.after" /* After */);
1109
+ if (!stateNode || !stateNode.after)
1110
+ return;
1111
+ const entries = [];
1112
+ const exits = [];
1113
+ if (isArray(stateNode.after)) {
1114
+ const transition = this.determineTransition(stateNode.after, event);
1115
+ if (!transition)
1116
+ return;
1117
+ const actions = this.getActionFromDelayedTransition(transition);
1118
+ entries.push(actions.entry);
1119
+ exits.push(actions.exit);
1120
+ } else if (isObject(stateNode.after)) {
1121
+ for (const delay in stateNode.after) {
1122
+ const transition = stateNode.after[delay];
1123
+ let resolvedTransition = {};
1124
+ if (isArray(transition)) {
1125
+ const picked = this.determineTransition(transition, event);
1126
+ if (picked)
1127
+ resolvedTransition = picked;
1128
+ } else if (isString(transition)) {
1129
+ resolvedTransition = { target: transition, delay };
1130
+ } else {
1131
+ resolvedTransition = __spreadProps(__spreadValues({}, transition), { delay });
1132
+ }
1133
+ const actions = this.getActionFromDelayedTransition(resolvedTransition);
1134
+ entries.push(actions.entry);
1135
+ exits.push(actions.exit);
1136
+ }
1137
+ }
1138
+ return { entries, exits };
1139
+ };
1140
+ this.executeActions = (actions, event) => {
1141
+ var _a;
1142
+ const _actions = determineActionsFn(actions, this.guardMap)(this.contextSnapshot, event);
1143
+ for (const action of toArray(_actions)) {
1144
+ const fn = isString(action) ? (_a = this.actionMap) == null ? void 0 : _a[action] : action;
1145
+ warn(isString(action) && !fn, `[machine/exec-action] No implementation found for action: \`${action}\``);
1146
+ fn == null ? void 0 : fn(this.state.context, event, this.meta);
1147
+ }
1148
+ };
1149
+ this.executeActivities = (event, activities, state) => {
1150
+ var _a;
1151
+ for (const activity of activities) {
1152
+ const fn = isString(activity) ? (_a = this.activityMap) == null ? void 0 : _a[activity] : activity;
1153
+ if (!fn) {
1154
+ warn(`[machine/exec-activity] No implementation found for activity: \`${activity}\``);
1155
+ continue;
1156
+ }
1157
+ const cleanup = fn(this.state.context, event, this.meta);
1158
+ if (cleanup) {
1159
+ this.addActivityCleanup(state != null ? state : this.state.value, cleanup);
1160
+ }
1161
+ }
1162
+ };
1163
+ this.createEveryActivities = (every, callbackfn) => {
1164
+ if (!every)
1165
+ return;
1166
+ const event = toEvent("machine.every" /* Every */);
1167
+ if (isArray(every)) {
1168
+ const picked = toArray(every).find((t2) => {
1169
+ const determineDelay2 = determineDelayFn(t2.delay, this.delayMap);
1170
+ t2.delay = determineDelay2(this.contextSnapshot, event);
1171
+ const determineGuard = determineGuardFn(t2.guard, this.guardMap);
1172
+ const guard = determineGuard(this.contextSnapshot, event);
1173
+ return guard != null ? guard : t2.delay;
1174
+ });
1175
+ if (!picked)
1176
+ return;
1177
+ const determineDelay = determineDelayFn(picked.delay, this.delayMap);
1178
+ const delay = determineDelay(this.contextSnapshot, event);
1179
+ const activity = () => {
1180
+ const id = globalThis.setInterval(() => {
1181
+ this.executeActions(picked.actions, event);
1182
+ }, delay);
1183
+ return () => {
1184
+ globalThis.clearInterval(id);
1185
+ };
1186
+ };
1187
+ callbackfn(activity);
1188
+ } else {
1189
+ for (const interval in every) {
1190
+ const actions = every == null ? void 0 : every[interval];
1191
+ const determineDelay = determineDelayFn(interval, this.delayMap);
1192
+ const delay = determineDelay(this.contextSnapshot, event);
1193
+ const activity = () => {
1194
+ const id = globalThis.setInterval(() => {
1195
+ this.executeActions(actions, event);
1196
+ }, delay);
1197
+ return () => {
1198
+ globalThis.clearInterval(id);
1199
+ };
1200
+ };
1201
+ callbackfn(activity);
1202
+ }
1203
+ }
1204
+ };
1205
+ this.setEvent = (event) => {
1206
+ this.state.event = (0, import_vanilla2.ref)(toEvent(event));
1207
+ };
1208
+ this.performExitEffects = (current, event) => {
1209
+ const currentState = this.state.value;
1210
+ const stateNode = current ? this.getStateNode(current) : void 0;
1211
+ this.stopActivities(currentState);
1212
+ const _exit = determineActionsFn(stateNode == null ? void 0 : stateNode.exit, this.guardMap)(this.contextSnapshot, event);
1213
+ const exitActions = toArray(_exit);
1214
+ const afterExitActions = this.delayedEvents.get(currentState);
1215
+ if (afterExitActions) {
1216
+ exitActions.push(...afterExitActions);
1217
+ }
1218
+ this.executeActions(exitActions, event);
1219
+ this.eventListeners.clear();
1220
+ };
1221
+ this.performEntryEffects = (next, event) => {
1222
+ const stateNode = this.getStateNode(next);
1223
+ const activities = toArray(stateNode == null ? void 0 : stateNode.activities);
1224
+ this.createEveryActivities(stateNode == null ? void 0 : stateNode.every, (activity) => {
1225
+ activities.unshift(activity);
1226
+ });
1227
+ if (activities.length > 0) {
1228
+ this.executeActivities(event, activities);
1229
+ }
1230
+ const _entry = determineActionsFn(stateNode == null ? void 0 : stateNode.entry, this.guardMap)(this.contextSnapshot, event);
1231
+ const entryActions = toArray(_entry);
1232
+ const afterActions = this.getDelayedEventActions(next);
1233
+ if ((stateNode == null ? void 0 : stateNode.after) && afterActions) {
1234
+ this.delayedEvents.set(next, afterActions == null ? void 0 : afterActions.exits);
1235
+ entryActions.push(...afterActions.entries);
1236
+ }
1237
+ this.executeActions(entryActions, event);
1238
+ if ((stateNode == null ? void 0 : stateNode.type) === "final") {
1239
+ this.state.done = true;
1240
+ this.doneListeners.forEach((listener) => {
1241
+ listener(this.stateSnapshot);
1242
+ });
1243
+ this.stop();
1244
+ }
1245
+ };
1246
+ this.performTransitionEffects = (transition, event) => {
1247
+ const t2 = this.determineTransition(transition, event);
1248
+ this.executeActions(t2 == null ? void 0 : t2.actions, event);
1249
+ };
1250
+ this.performStateChangeEffects = (current, next, event) => {
1251
+ var _a, _b;
1252
+ this.setEvent(event);
1253
+ next.target = (_b = (_a = next.target) != null ? _a : this.state.value) != null ? _b : void 0;
1254
+ const ok = next.target && next.target !== this.state.value;
1255
+ if (ok) {
1256
+ this.performExitEffects(current, event);
1257
+ }
1258
+ this.performTransitionEffects(next == null ? void 0 : next.transition, event);
1259
+ this.setState(next.target);
1260
+ if (ok) {
1261
+ this.performEntryEffects(next.target, event);
1262
+ }
1263
+ };
1264
+ this.determineTransition = (transition, event) => {
1265
+ const fn = determineTransitionFn(transition, this.guardMap);
1266
+ return fn == null ? void 0 : fn(this.contextSnapshot, event);
1267
+ };
1268
+ this.sendParent = (evt) => {
1269
+ var _a;
1270
+ if (!this.parent) {
1271
+ invariant("[machine/send-parent] Cannot send event to an unknown parent");
1272
+ }
1273
+ const event = toEvent(evt);
1274
+ (_a = this.parent) == null ? void 0 : _a.send(event);
1275
+ };
1276
+ this.send = (evt) => {
1277
+ const event = toEvent(evt);
1278
+ this.transition(this.state.value, event);
1279
+ };
1280
+ this.transition = (state, evt) => {
1281
+ var _a, _b, _c;
1282
+ const stateNode = isString(state) ? this.getStateNode(state) : state == null ? void 0 : state.stateNode;
1283
+ const event = toEvent(evt);
1284
+ if (!stateNode && !this.config.on) {
1285
+ const msg = this.status === "Stopped" /* Stopped */ ? "[machine/transition] Cannot transition a stopped machine" : "[machine/transition] State does not have a definition";
1286
+ warn(msg);
1287
+ return;
1288
+ }
1289
+ const transitionConfig = (_c = (_a = stateNode == null ? void 0 : stateNode.on) == null ? void 0 : _a[event.type]) != null ? _c : (_b = this.config.on) == null ? void 0 : _b[event.type];
1290
+ const transition = toTransition(transitionConfig, this.state.value);
1291
+ if (!transition)
1292
+ return;
1293
+ const info = this.getNextStateInfo(transition, event);
1294
+ this.performStateChangeEffects(this.state.value, info, event);
1295
+ return info.stateNode;
1296
+ };
1297
+ this.subscribe = (listener) => {
1298
+ this.stateListeners.add(listener);
1299
+ if (this.status === "Running" /* Running */) {
1300
+ listener(this.stateSnapshot);
1301
+ }
1302
+ return () => {
1303
+ this.stateListeners.delete(listener);
1304
+ };
1305
+ };
1306
+ this.onDone = (listener) => {
1307
+ this.doneListeners.add(listener);
1308
+ return this;
1309
+ };
1310
+ this.onTransition = (listener) => {
1311
+ this.stateListeners.add(listener);
1312
+ if (this.status === "Running" /* Running */) {
1313
+ listener(this.stateSnapshot);
1314
+ }
1315
+ return this;
1316
+ };
1317
+ this.onEvent = (listener) => {
1318
+ listener(this.state.event);
1319
+ this.eventListeners.add(listener);
1320
+ return this;
1321
+ };
1322
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
1323
+ this.options = klona(options);
1324
+ this.id = (_a = config.id) != null ? _a : `machine-${uuid()}`;
1325
+ this.guardMap = (_c = (_b = this.options) == null ? void 0 : _b.guards) != null ? _c : {};
1326
+ this.actionMap = (_e = (_d = this.options) == null ? void 0 : _d.actions) != null ? _e : {};
1327
+ this.delayMap = (_g = (_f = this.options) == null ? void 0 : _f.delays) != null ? _g : {};
1328
+ this.activityMap = (_i = (_h = this.options) == null ? void 0 : _h.activities) != null ? _i : {};
1329
+ this.sync = (_k = (_j = this.options) == null ? void 0 : _j.sync) != null ? _k : false;
1330
+ this.state = createProxy(klona(config));
1331
+ this.setupComputed();
1332
+ const event = toEvent("machine.created" /* Created */);
1333
+ this.executeActions(config == null ? void 0 : config.created, event);
1334
+ }
1335
+ get stateSnapshot() {
1336
+ return cast((0, import_vanilla2.snapshot)(this.state));
1337
+ }
1338
+ get contextSnapshot() {
1339
+ return this.stateSnapshot.context;
1340
+ }
1341
+ get self() {
1342
+ const _self = this;
1343
+ return {
1344
+ id: this.id,
1345
+ send: this.send.bind(this),
1346
+ sendParent: this.sendParent.bind(this),
1347
+ sendChild: this.sendChild.bind(this),
1348
+ stop: this.stop.bind(this),
1349
+ stopChild: this.stopChild.bind(this),
1350
+ spawn: this.spawn.bind(this),
1351
+ get state() {
1352
+ return _self.stateSnapshot;
1353
+ }
1354
+ };
1355
+ }
1356
+ get meta() {
1357
+ return {
1358
+ state: this.stateSnapshot,
1359
+ guards: this.guardMap,
1360
+ send: this.send.bind(this),
1361
+ listen: this.onEvent.bind(this),
1362
+ self: this.self,
1363
+ getState: () => this.stateSnapshot
1364
+ };
1365
+ }
1366
+ };
1367
+ var createMachine = (config, options) => new Machine(config, options);
1368
+
1369
+ // src/number-input.machine.ts
1370
+ var { not: not2, and: and2 } = guards;
1371
+ var machine = createMachine({
1372
+ id: "number-input",
1373
+ initial: "unknown",
1374
+ context: {
1375
+ uid: "",
1376
+ dir: "ltr",
1377
+ focusInputOnChange: true,
1378
+ clampValueOnBlur: true,
1379
+ allowOverflow: false,
1380
+ inputMode: "decimal",
1381
+ pattern: "[0-9]*(.[0-9]+)?",
1382
+ hint: null,
1383
+ value: "",
1384
+ step: 1,
1385
+ min: Number.MIN_SAFE_INTEGER,
1386
+ max: Number.MAX_SAFE_INTEGER,
1387
+ precision: 0,
1388
+ inputSelection: null,
1389
+ scrubberCursorPoint: null,
1390
+ invalid: false,
1391
+ messages: {
1392
+ incrementLabel: "increment value",
1393
+ decrementLabel: "decrease value"
1394
+ }
1395
+ },
1396
+ computed: {
1397
+ isRtl: (ctx) => ctx.dir === "rtl",
1398
+ valueAsNumber: (ctx) => valueOf(ctx.value),
1399
+ isAtMin: (ctx) => isAtMin(ctx.value, ctx),
1400
+ isAtMax: (ctx) => isAtMax(ctx.value, ctx),
1401
+ isOutOfRange: (ctx) => !isWithinRange(ctx.value, ctx),
1402
+ canIncrement: (ctx) => ctx.allowOverflow || !ctx.isAtMax,
1403
+ canDecrement: (ctx) => ctx.allowOverflow || !ctx.isAtMin,
1404
+ valueText: (ctx) => {
1405
+ var _a, _b;
1406
+ return (_b = (_a = ctx.messages).valueText) == null ? void 0 : _b.call(_a, ctx.value);
1407
+ },
1408
+ formattedValue: (ctx) => {
1409
+ var _a, _b;
1410
+ return (_b = (_a = ctx.format) == null ? void 0 : _a.call(ctx, ctx.value).toString()) != null ? _b : ctx.value;
1411
+ }
1412
+ },
1413
+ watch: {
1414
+ value: ["invokeOnChange"],
1415
+ isOutOfRange: ["invokeOnInvalid"]
1416
+ },
1417
+ entry: ["syncInputValue"],
1418
+ on: {
1419
+ SET_VALUE: {
1420
+ actions: ["setValue", "setHintToSet"]
1421
+ },
1422
+ INCREMENT: { actions: ["increment"] },
1423
+ DECREMENT: { actions: ["decrement"] }
1424
+ },
1425
+ states: {
1426
+ unknown: {
1427
+ on: {
1428
+ SETUP: {
1429
+ target: "idle",
1430
+ actions: "setupDocument"
1431
+ }
1432
+ }
1433
+ },
1434
+ idle: {
1435
+ on: {
1436
+ PRESS_DOWN: {
1437
+ target: "before:spin",
1438
+ actions: ["focusInput", "setHint"]
1439
+ },
1440
+ PRESS_DOWN_SCRUBBER: {
1441
+ target: "scrubbing",
1442
+ actions: ["focusInput", "setHint", "setCursorPoint"]
1443
+ },
1444
+ FOCUS: "focused"
1445
+ }
1446
+ },
1447
+ focused: {
1448
+ tags: ["focus"],
1449
+ activities: "attachWheelListener",
1450
+ on: {
1451
+ PRESS_DOWN: {
1452
+ target: "before:spin",
1453
+ actions: ["focusInput", "setHint"]
1454
+ },
1455
+ PRESS_DOWN_SCRUBBER: {
1456
+ target: "scrubbing",
1457
+ actions: ["focusInput", "setHint", "setCursorPoint"]
1458
+ },
1459
+ ARROW_UP: {
1460
+ actions: "increment"
1461
+ },
1462
+ ARROW_DOWN: {
1463
+ actions: "decrement"
1464
+ },
1465
+ HOME: {
1466
+ actions: "setToMin"
1467
+ },
1468
+ END: {
1469
+ actions: "setToMax"
1470
+ },
1471
+ CHANGE: {
1472
+ actions: ["setValue", "setSelectionRange", "setHint"]
1473
+ },
1474
+ BLUR: [
1475
+ {
1476
+ guard: "isInvalidExponential",
1477
+ target: "idle",
1478
+ actions: ["clearValue", "clearHint"]
1479
+ },
1480
+ {
1481
+ guard: and2("clampOnBlur", not2("isInRange")),
1482
+ target: "idle",
1483
+ actions: ["clampValue", "clearHint"]
1484
+ },
1485
+ {
1486
+ actions: ["roundValue"]
1487
+ }
1488
+ ]
1489
+ }
1490
+ },
1491
+ "before:spin": {
1492
+ tags: ["focus"],
1493
+ entry: choose([
1494
+ { guard: "isIncrementHint", actions: "increment" },
1495
+ { guard: "isDecrementHint", actions: "decrement" }
1496
+ ]),
1497
+ after: {
1498
+ CHANGE_DELAY: {
1499
+ target: "spinning",
1500
+ guard: "isInRange"
1501
+ }
1502
+ },
1503
+ on: {
1504
+ PRESS_UP: {
1505
+ target: "focused",
1506
+ actions: ["clearHint", "restoreSelection"]
1507
+ }
1508
+ }
1509
+ },
1510
+ spinning: {
1511
+ tags: ["focus"],
1512
+ activities: "trackButtonDisabled",
1513
+ every: [
1514
+ {
1515
+ delay: "CHANGE_INTERVAL",
1516
+ guard: and2(not2("isAtMin"), "isIncrementHint"),
1517
+ actions: "increment"
1518
+ },
1519
+ {
1520
+ delay: "CHANGE_INTERVAL",
1521
+ guard: and2(not2("isAtMax"), "isDecrementHint"),
1522
+ actions: "decrement"
1523
+ }
1524
+ ],
1525
+ on: {
1526
+ PRESS_UP: {
1527
+ target: "focused",
1528
+ actions: ["clearHint", "restoreSelection"]
1529
+ }
1530
+ }
1531
+ },
1532
+ scrubbing: {
1533
+ tags: ["focus"],
1534
+ entry: ["addCustomCursor", "disableTextSelection"],
1535
+ exit: ["removeCustomCursor", "restoreTextSelection"],
1536
+ activities: ["activatePointerLock", "trackMousemove"],
1537
+ on: {
1538
+ POINTER_UP_SCRUBBER: {
1539
+ target: "focused",
1540
+ actions: ["clearCursorPoint"]
1541
+ },
1542
+ POINTER_MOVE_SCRUBBER: [
1543
+ {
1544
+ guard: "isIncrementHint",
1545
+ actions: ["increment", "setCursorPoint", "updateCursor"]
1546
+ },
1547
+ {
1548
+ guard: "isDecrementHint",
1549
+ actions: ["decrement", "setCursorPoint", "updateCursor"]
1550
+ }
1551
+ ]
1552
+ }
1553
+ }
1554
+ }
1555
+ }, {
1556
+ delays: {
1557
+ CHANGE_INTERVAL: 50,
1558
+ CHANGE_DELAY: 300
1559
+ },
1560
+ guards: {
1561
+ clampOnBlur: (ctx) => !!ctx.clampValueOnBlur,
1562
+ isAtMin: (ctx) => ctx.isAtMin,
1563
+ isAtMax: (ctx) => ctx.isAtMax,
1564
+ isInRange: (ctx) => !ctx.isOutOfRange,
1565
+ isDecrementHint: (ctx, evt) => {
1566
+ var _a;
1567
+ return ((_a = evt.hint) != null ? _a : ctx.hint) === "decrement";
1568
+ },
1569
+ isIncrementHint: (ctx, evt) => {
1570
+ var _a;
1571
+ return ((_a = evt.hint) != null ? _a : ctx.hint) === "increment";
1572
+ },
1573
+ isInvalidExponential: (ctx) => ctx.value.toString().startsWith("e")
1574
+ },
1575
+ activities: {
1576
+ trackButtonDisabled(ctx, _evt, { send }) {
1577
+ let btnEl = null;
1578
+ if (ctx.hint === "increment") {
1579
+ btnEl = dom.getIncButtonEl(ctx);
1580
+ }
1581
+ if (ctx.hint === "decrement") {
1582
+ btnEl = dom.getDecButtonEl(ctx);
1583
+ }
1584
+ return observeAttributes(btnEl, "disabled", function onDisable() {
1585
+ send("PRESS_UP");
1586
+ });
1587
+ },
1588
+ attachWheelListener(ctx) {
1589
+ const cleanups = [];
1590
+ cleanups.push(nextTick(() => {
1591
+ const input = dom.getInputEl(ctx);
1592
+ if (!input)
1593
+ return;
1594
+ function onWheel(event) {
1595
+ const isInputFocused = dom.getDoc(ctx).activeElement === input;
1596
+ if (!ctx.allowMouseWheel || !isInputFocused)
1597
+ return;
1598
+ event.preventDefault();
1599
+ const dir = Math.sign(event.deltaY) * -1;
1600
+ if (dir === 1)
1601
+ ctx.value = utils.increment(ctx);
1602
+ else if (dir === -1)
1603
+ ctx.value = utils.decrement(ctx);
1604
+ }
1605
+ cleanups.push(addDomEvent(input, "wheel", onWheel, { passive: false }));
1606
+ }));
1607
+ return () => cleanups.forEach((c) => c());
1608
+ },
1609
+ activatePointerLock(ctx) {
1610
+ if (isSafari() || !supportsPointerEvent())
1611
+ return;
1612
+ return requestPointerLock(dom.getDoc(ctx));
1613
+ },
1614
+ trackMousemove(ctx, _evt, { send }) {
1615
+ const doc = dom.getDoc(ctx);
1616
+ function onMousemove(event) {
1617
+ if (!ctx.scrubberCursorPoint)
1618
+ return;
1619
+ const value = dom.getMousementValue(ctx, event);
1620
+ if (!value.hint)
1621
+ return;
1622
+ send({ type: "POINTER_MOVE_SCRUBBER", hint: value.hint, point: value.point });
1623
+ }
1624
+ function onMouseup() {
1625
+ send("POINTER_UP_SCRUBBER");
1626
+ }
1627
+ return pipe(addDomEvent(doc, "mousemove", onMousemove, false), addDomEvent(doc, "mouseup", onMouseup, false));
1628
+ }
1629
+ },
1630
+ actions: {
1631
+ setupDocument: (ctx, evt) => {
1632
+ if (evt.doc)
1633
+ ctx.doc = (0, import_vanilla3.ref)(evt.doc);
1634
+ ctx.uid = evt.id;
1635
+ },
1636
+ focusInput(ctx) {
1637
+ if (!ctx.focusInputOnChange)
1638
+ return;
1639
+ const input = dom.getInputEl(ctx);
1640
+ nextTick(() => input == null ? void 0 : input.focus());
1641
+ },
1642
+ increment(ctx, evt) {
1643
+ ctx.value = utils.increment(ctx, evt.step);
1644
+ },
1645
+ decrement(ctx, evt) {
1646
+ ctx.value = utils.decrement(ctx, evt.step);
1647
+ },
1648
+ clampValue(ctx) {
1649
+ ctx.value = utils.clamp(ctx);
1650
+ },
1651
+ roundValue(ctx) {
1652
+ ctx.value = utils.round(ctx);
1653
+ },
1654
+ setValue(ctx, evt) {
1655
+ var _a, _b;
1656
+ const value = (_b = (_a = evt.target) == null ? void 0 : _a.value) != null ? _b : evt.value;
1657
+ ctx.value = utils.sanitize(ctx, utils.parse(ctx, value));
1658
+ },
1659
+ clearValue(ctx) {
1660
+ ctx.value = "";
1661
+ },
1662
+ setToMax(ctx) {
1663
+ ctx.value = ctx.max.toString();
1664
+ },
1665
+ setToMin(ctx) {
1666
+ ctx.value = ctx.min.toString();
1667
+ },
1668
+ setHint(ctx, evt) {
1669
+ ctx.hint = evt.hint;
1670
+ },
1671
+ clearHint(ctx) {
1672
+ ctx.hint = null;
1673
+ },
1674
+ setHintToSet(ctx) {
1675
+ ctx.hint = "set";
1676
+ },
1677
+ setSelectionRange(ctx, evt) {
1678
+ ctx.inputSelection = {
1679
+ start: evt.target.selectionStart,
1680
+ end: evt.target.selectionEnd
1681
+ };
1682
+ },
1683
+ restoreSelection(ctx) {
1684
+ var _a, _b, _c;
1685
+ const input = dom.getInputEl(ctx);
1686
+ if (!input || !ctx.inputSelection)
1687
+ return;
1688
+ input.selectionStart = (_b = ctx.inputSelection.start) != null ? _b : (_a = input.value) == null ? void 0 : _a.length;
1689
+ input.selectionEnd = (_c = ctx.inputSelection.end) != null ? _c : input.selectionStart;
1690
+ },
1691
+ invokeOnChange(ctx) {
1692
+ var _a;
1693
+ (_a = ctx.onChange) == null ? void 0 : _a.call(ctx, { value: ctx.value, valueAsNumber: ctx.valueAsNumber });
1694
+ },
1695
+ invokeOnInvalid(ctx) {
1696
+ var _a;
1697
+ if (!ctx.isOutOfRange)
1698
+ return;
1699
+ const reason = ctx.valueAsNumber > ctx.max ? "rangeOverflow" : "rangeUnderflow";
1700
+ (_a = ctx.onInvalid) == null ? void 0 : _a.call(ctx, { reason, value: ctx.formattedValue, valueAsNumber: ctx.valueAsNumber });
1701
+ },
1702
+ syncInputValue(ctx) {
1703
+ const input = dom.getInputEl(ctx);
1704
+ if (!input || input.value == ctx.value)
1705
+ return;
1706
+ const value = utils.parse(ctx, input.value);
1707
+ ctx.value = utils.sanitize(ctx, value);
1708
+ },
1709
+ setCursorPoint(ctx, evt) {
1710
+ ctx.scrubberCursorPoint = evt.point;
1711
+ },
1712
+ clearCursorPoint(ctx) {
1713
+ ctx.scrubberCursorPoint = null;
1714
+ },
1715
+ updateCursor(ctx) {
1716
+ const cursor = dom.getCursorEl(ctx);
1717
+ if (!cursor || !ctx.scrubberCursorPoint)
1718
+ return;
1719
+ cursor.style.transform = `translate3d(${ctx.scrubberCursorPoint.x}px, ${ctx.scrubberCursorPoint.y}px, 0px)`;
1720
+ },
1721
+ addCustomCursor(ctx) {
1722
+ if (isSafari() || !supportsPointerEvent())
1723
+ return;
1724
+ dom.createVirtualCursor(ctx);
1725
+ },
1726
+ removeCustomCursor(ctx) {
1727
+ if (isSafari() || !supportsPointerEvent())
1728
+ return;
1729
+ const doc = dom.getDoc(ctx);
1730
+ const el = doc.getElementById(dom.getCursorId(ctx));
1731
+ el == null ? void 0 : el.remove();
1732
+ },
1733
+ disableTextSelection(ctx) {
1734
+ const doc = dom.getDoc(ctx);
1735
+ doc.body.style.pointerEvents = "none";
1736
+ doc.documentElement.style.userSelect = "none";
1737
+ doc.documentElement.style.cursor = "ew-resize";
1738
+ },
1739
+ restoreTextSelection(ctx) {
1740
+ const doc = dom.getDoc(ctx);
1741
+ doc.body.style.pointerEvents = "";
1742
+ doc.documentElement.style.userSelect = "";
1743
+ doc.documentElement.style.cursor = "";
1744
+ }
1745
+ }
1746
+ });
8
1747
  //# sourceMappingURL=index.js.map