@zag-js/number-input 0.0.0-dev-20220412160604 → 0.0.0-dev-20220412212252

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/README.md CHANGED
@@ -12,10 +12,8 @@ npm i @zag-js/number-input
12
12
 
13
13
  ## Contribution
14
14
 
15
- Yes please! See the [contributing guidelines](https://github.com/chakra-ui/ui-machines/blob/main/CONTRIBUTING.md) for
16
- details.
15
+ Yes please! See the [contributing guidelines](https://github.com/chakra-ui/zag/blob/main/CONTRIBUTING.md) for details.
17
16
 
18
17
  ## Licence
19
18
 
20
- This project is licensed under the terms of the
21
- [MIT license](https://github.com/chakra-ui/ui-machines/blob/main/LICENSE).
19
+ This project is licensed under the terms of the [MIT license](https://github.com/chakra-ui/zag/blob/main/LICENSE).
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
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 nt=Object.defineProperty;var ee=Object.getOwnPropertyDescriptor;var ne=Object.getOwnPropertyNames;var re=Object.prototype.hasOwnProperty;var ie=(t,e)=>{for(var n in e)nt(t,n,{get:e[n],enumerable:!0})},oe=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ne(e))!re.call(t,o)&&o!==n&&nt(t,o,{get:()=>e[o],enumerable:!(i=ee(e,o))||i.enumerable});return t};var se=t=>oe(nt({},"__esModule",{value:!0}),t);var Ke={};ie(Ke,{connect:()=>kt,machine:()=>Qt});module.exports=se(Ke);var I=t=>t?"":void 0;function V(t){let e=new Set;function n(i){let o=globalThis.requestAnimationFrame(i);e.add(()=>globalThis.cancelAnimationFrame(o))}return n(()=>n(t)),function(){e.forEach(function(i){i()})}}var pt=()=>{};var $e=(()=>{let t=0;return()=>(t++,t.toString(36))})();var R=new Map,T=new Map;function ae(t,e,n,i){var o;if(!t)return pt;let l=JSON.stringify({type:e,options:i}),p=R.get(t);if(R.has(t))p!=null&&p.has(l)?(o=p?.get(l))==null||o.add(n):p?.set(l,new Set([n]));else{let y=new Map([[l,new Set([n])]]);R.set(t,y)}function g(y){var m,w;function E(c){var d;let r=R.get(y);(d=r?.get(l))==null||d.forEach(s=>s(c))}if(!(T!=null&&T.has(y))){T.set(y,new Map([[l,E]])),y.addEventListener(e,E,i);return}(m=T?.get(y))!=null&&m.has(l)||((w=T.get(y))==null||w.set(l,E),y.addEventListener(e,E,i))}return g(t),function(){var y,m,w,E;if(!R.has(t))return;let c=R.get(t);if((y=c?.get(l))==null||y.delete(n),((m=c?.get(l))==null?void 0:m.size)===0){let d=(w=T.get(t))==null?void 0:w.get(l);t.removeEventListener(e,d,i),c?.delete(l),(E=T.get(t))==null||E.delete(l),c?.size===0&&(R.delete(t),T.delete(t))}}}var mt=t=>Object.prototype.toString.call(t).slice(8,-1),le=t=>mt(t)==="Object"&&"current"in t,ue=t=>mt(t)==="Function"?t():t;function Y(t,e,n,i){let o=le(t)?t.current:ue(t);return ae(o,e,n,i)}function K(t){var e;return(e=t.nativeEvent)!=null?e:t}var vt=2147483647;var qe=["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 ce=new Set(["PageUp","PageDown"]),de=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"]);function gt(t){return t.ctrlKey||t.metaKey?.1:ce.has(t.key)||t.shiftKey&&de.has(t.key)?10:1}function yt(t,e,n){if(!t)return pt;let i=Array.isArray(e)?e:[e],o=t.ownerDocument.defaultView||window,l=new o.MutationObserver(p=>{for(let g of p)g.type==="attributes"&&g.attributeName&&i.includes(g.attributeName)&&n(g)});return l.observe(t,{attributes:!0,attributeFilter:i}),()=>l.disconnect()}function he(t,e){return t.addEventListener("webkitpointerlockchange",e,!1),t.addEventListener("mozpointerlockchange",e,!1),t.addEventListener("pointerlockchange",e,!1),function(){t.removeEventListener("mozpointerlockchange",e,!1),t.removeEventListener("pointerlockchange",e,!1)}}function fe(t,e){return t.addEventListener("webkitpointerlockerror",e,!1),t.addEventListener("mozpointerlockerror",e,!1),t.addEventListener("pointerlockerror",e,!1),function(){t.removeEventListener("webkitpointerlockerror",e,!1),t.removeEventListener("mozpointerlockerror",e,!1),t.removeEventListener("pointerlockerror",e,!1)}}function pe(t){return t.requestPointerLock||t.mozRequestPointerLock||t.webkitRequestPointerLock}function me(t){return t.exitPointerLock||t.mozExitPointerLock||t.webkitExitPointerLock}function bt(t,e={}){let{onPointerLock:n,onPointerUnlock:i}=e,o=t.body;function l(){return"pointerLockElement"in t||"mozPointerLockElement"in t||"webkitPointerLockElement"in t}function p(){return!!t.pointerLockElement}function g(){p()?n?.():i?.()}function y(r){p()&&i?.(),console.error("PointerLock error occured:",r),m()}function m(){t.exitPointerLock=me(t),t.exitPointerLock()}let w=new Set;function E(){w.add(he(t,g)),w.add(fe(t,y))}function c(){!l()||(w.forEach(r=>r()),w.clear(),m())}function d(){!l()||(o.requestPointerLock=pe(o),o.requestPointerLock(),E())}return d(),c}var wt=new Intl.NumberFormat("en-US",{style:"decimal"});function rt(t){return parseFloat(wt.format(t))}function xt(t,e){return(t%e+e)%e}function ve(t,e){let n=P(t),i=10**(e??10);return n=Math.round(n*i)/i,e?n.toFixed(e):t.toString()}function O(t){if(typeof window>"u")return Math.round(t);let e=window.devicePixelRatio;return Math.floor(t*e+.5)/e}function X(t,e){return Math.min(Math.max(P(t),e.min),e.max)}function Et(t){var e,n;return(n=(e=wt.formatToParts(t).find(i=>i.type==="fraction"))==null?void 0:e.value.length)!=null?n:0}var St=(t,e)=>rt(P(t)+e),Ct=(t,e)=>rt(P(t)-e),At=(t,e)=>rt(P(t)*e);function P(t){if(typeof t=="number")return t;let e=parseFloat(t.toString().replace(/[^\w.-]+/g,""));return Number.isNaN(e)?0:e}function ge(t){var e;let n=Et(t.step),i=P(t.value),o=Number.isNaN(i)?n:Math.max(Et(i),n);return Math.max(o,(e=t.precision)!=null?e:0)}function _(t,e){return ve(t,ge({...e,value:t}))}function Pt(t,e){return P(t)>=e.max}function Mt(t,e){return P(t)<=e.min}function Lt(t,e){let n=P(t);return n>=e.min&&n<=e.max}var Je=(()=>{let t=0;return()=>(t++,t.toString(36))})(),ye=t=>Array.isArray(t),be=t=>!(t==null||typeof t!="object"||ye(t)),Ee=t=>be(t)&&"touches"in t;var we={pageX:0,pageY:0,clientX:0,clientY:0};function Tt(t,e="page"){let n=Ee(t)?t.touches[0]||t.changedTouches[0]||we:t;return{x:n[`${e}X`],y:n[`${e}Y`]}}function xe(t){return{button:t,label:t,input:t,output:t,element:t}}var It=xe(t=>t);var v={getDoc:t=>{var e;return(e=t.doc)!=null?e:document},getWin:t=>{var e;return(e=v.getDoc(t).defaultView)!=null?e:window},getInputId:t=>{var e,n;return(n=(e=t.ids)==null?void 0:e.input)!=null?n:`number-input-${t.uid}-input`},getIncButtonId:t=>{var e,n;return(n=(e=t.ids)==null?void 0:e.incBtn)!=null?n:`number-input-${t.uid}-inc-btn`},getDecButtonId:t=>{var e,n;return(n=(e=t.ids)==null?void 0:e.decBtn)!=null?n:`number-input-${t.uid}-dec-btn`},getScrubberId:t=>{var e,n;return(n=(e=t.ids)==null?void 0:e.scrubber)!=null?n:`number-input-${t.uid}-scrubber`},getCursorId:t=>`number-input-${t.uid}-cursor`,getLabelId:t=>{var e,n;return(n=(e=t.ids)==null?void 0:e.label)!=null?n:`number-input-${t.uid}-label`},getRootId:t=>{var e,n;return(n=(e=t.ids)==null?void 0:e.root)!=null?n:`number-input-${t.uid}-root`},getInputEl:t=>v.getDoc(t).getElementById(v.getInputId(t)),getIncButtonEl:t=>v.getDoc(t).getElementById(v.getIncButtonId(t)),getDecButtonEl:t=>v.getDoc(t).getElementById(v.getDecButtonId(t)),getScrubberEl:t=>v.getDoc(t).getElementById(v.getScrubberId(t)),getCursorEl:t=>v.getDoc(t).getElementById(v.getCursorId(t)),getMousementValue(t,e){let n=O(e.movementX),i=O(e.movementY),o=n>0?"increment":n<0?"decrement":null;t.isRtl&&o==="increment"&&(o="decrement"),t.isRtl&&o==="decrement"&&(o="increment");let l={x:t.scrubberCursorPoint.x+n,y:t.scrubberCursorPoint.y+i},g=v.getWin(t).innerWidth,y=O(7.5);return l.x=xt(l.x+y,g)-y,{hint:o,point:l}},createVirtualCursor(t){let e=v.getDoc(t),n=e.createElement("div");n.className="scrubber--cursor",n.id=v.getCursorId(t),Object.assign(n.style,{width:"15px",height:"15px",position:"fixed",pointerEvents:"none",left:"0px",top:"0px",zIndex:vt,transform:t.scrubberCursorPoint?`translate3d(${t.scrubberCursorPoint.x}px, ${t.scrubberCursorPoint.y}px, 0px)`:void 0,willChange:"transform"}),n.innerHTML=`
2
2
  <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
3
  <g transform="translate(2 3)">
4
4
  <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
5
  <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
6
  </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);
7
+ </svg>`,e.body.appendChild(n)}};var x={isValidNumericEvent:(t,e)=>{var o,l;if(e.key==null)return!0;let n=e.ctrlKey||e.altKey||e.metaKey,i=e.key.length===1;return n||!i?!0:(l=(o=t.validateCharacter)==null?void 0:o.call(t,e.key))!=null?l:x.isFloatingPoint(e.key)},isFloatingPoint:t=>/^[Ee0-9+\-.]$/.test(t),sanitize:(t,e)=>{var n;return e.split("").filter((n=t.validateCharacter)!=null?n:x.isFloatingPoint).join("")},increment:(t,e)=>{let n=St(t.value,e!=null?e:t.step);return n=X(n,t),_(n,t)},decrement:(t,e)=>{let n=Ct(t.value,e!=null?e:t.step);return n=X(n,t),_(n,t)},clamp:t=>{let e=X(t.value,t);return _(e,t)},parse:(t,e)=>{var n,i;return(i=(n=t.parse)==null?void 0:n.call(t,e))!=null?i:e},format:(t,e)=>{var i,o;let n=e.toString();return(o=(i=t.format)==null?void 0:i.call(t,n))!=null?o:n},round:t=>_(t.value,t)};function kt(t,e,n=It){let i=t.hasTag("focus"),o=t.context.isOutOfRange||!!t.context.invalid,l=!!t.context.disabled,p=l||!t.context.canIncrement,g=l||!t.context.canDecrement,y=t.context.messages;return{isFocused:i,isInvalid:o,value:t.context.formattedValue,valueAsNumber:t.context.valueAsNumber,setValue(m){e({type:"SET_VALUE",value:m.toString()})},clearValue(){e({type:"SET_VALUE",value:""})},increment(){e("INCREMENT")},decrement(){e("DECREMENT")},setToMax(){e({type:"SET_VALUE",value:t.context.max})},setToMin(){e({type:"SET_VALUE",value:t.context.min})},focus(){V(()=>{var m;(m=v.getInputEl(t.context))==null||m.focus()})},rootProps:n.element({id:v.getRootId(t.context),"data-part":"root","data-disabled":I(l)}),labelProps:n.label({"data-part":"label","data-disabled":I(l),"data-invalid":I(o),id:v.getLabelId(t.context),htmlFor:v.getInputId(t.context)}),inputProps:n.input({"data-part":"input",name:t.context.name,id:v.getInputId(t.context),role:"spinbutton",value:t.context.formattedValue,pattern:t.context.pattern,inputMode:t.context.inputMode,"aria-invalid":o||void 0,"data-invalid":I(o),disabled:l,"data-disabled":I(l),readOnly:!!t.context.readonly,autoComplete:"off",autoCorrect:"off",spellCheck:"false",type:"text","aria-roledescription":"number field","aria-valuemin":t.context.min,"aria-valuemax":t.context.max,"aria-valuenow":isNaN(t.context.valueAsNumber)?void 0:t.context.valueAsNumber,"aria-valuetext":t.context.valueText,onFocus(){e("FOCUS")},onBlur(){e("BLUR")},onChange(m){K(m).isComposing||e({type:"CHANGE",target:m.currentTarget,hint:"set"})},onKeyDown(m){if(K(m).isComposing)return;x.isValidNumericEvent(t.context,m)||m.preventDefault();let E=At(gt(m),t.context.step),d={ArrowUp(){e({type:"ARROW_UP",step:E})},ArrowDown(){e({type:"ARROW_DOWN",step:E})},Home(){e("HOME")},End(){e("END")}}[m.key];d&&(d(m),m.preventDefault())}}),decrementButtonProps:n.button({"data-part":"spin-button",id:v.getDecButtonId(t.context),disabled:g,"data-disabled":I(g),"aria-label":y.decrementLabel,type:"button",tabIndex:-1,"aria-controls":v.getInputId(t.context),onPointerDown(m){g||(e({type:"PRESS_DOWN",hint:"decrement"}),m.preventDefault())},onPointerUp(){e({type:"PRESS_UP",hint:"decrement"})},onPointerLeave(){g||e({type:"PRESS_UP",hint:"decrement"})}}),incrementButtonProps:n.button({"data-part":"spin-button",id:v.getIncButtonId(t.context),disabled:p,"data-disabled":I(p),"aria-label":y.incrementLabel,type:"button",tabIndex:-1,"aria-controls":v.getInputId(t.context),onPointerDown(m){m.preventDefault(),!p&&e({type:"PRESS_DOWN",hint:"increment"})},onPointerUp(){e({type:"PRESS_UP",hint:"increment"})},onPointerLeave(){e({type:"PRESS_UP",hint:"increment"})}}),scrubberProps:n.element({"data-disabled":I(l),"data-part":"scrubber",id:v.getScrubberId(t.context),role:"presentation",onMouseDown(m){if(l)return;let w=K(m);m.preventDefault();let E=Tt(w);E.x=E.x-O(7.5),E.y=E.y-O(7.5),e({type:"PRESS_DOWN_SCRUBBER",point:E})},style:{cursor:l?void 0:"ew-resize"}})}}var Q={},gn=Symbol(),yn=Symbol(),Se=Symbol(),Rt=Object.getPrototypeOf,at=new WeakMap,Ce=t=>t&&(at.has(t)?at.get(t):Rt(t)===Object.prototype||Rt(t)===Array.prototype),Ae=t=>Ce(t)&&t[Se]||null,Ot=(t,e=!0)=>{at.set(t,e)},Ft=Symbol(),M=Symbol(),G=Symbol(),Pe=Symbol(),j=Symbol(),Nt=Symbol(),ut=new WeakSet;function Z(t){return ut.add(t),t}var J=t=>typeof t=="object"&&t!==null,Me=t=>J(t)&&!ut.has(t)&&(Array.isArray(t)||!(Symbol.iterator in t))&&!(t instanceof WeakMap)&&!(t instanceof WeakSet)&&!(t instanceof Error)&&!(t instanceof Number)&&!(t instanceof Date)&&!(t instanceof String)&&!(t instanceof RegExp)&&!(t instanceof ArrayBuffer),Dt=new WeakMap,Wt=1,Bt=new WeakMap;function ct(t={}){if(!J(t))throw new Error("object required");let e=Dt.get(t);if(e)return e;let n=Wt,i=new Set,o=(c,d=++Wt)=>{n!==d&&(n=d,i.forEach(r=>r(c,d)))},l=new Map,p=c=>{let d=l.get(c);return d||(d=(r,s)=>{let a=[...r];a[1]=[c,...a[1]],o(a,s)},l.set(c,d)),d},g=c=>{let d=l.get(c);return l.delete(c),d},y=(c,d)=>{let r=Bt.get(d);if(r?.[0]===n)return r[1];let s=Array.isArray(c)?[]:Object.create(Object.getPrototypeOf(c));return Ot(s,!0),Bt.set(d,[n,s]),Reflect.ownKeys(c).forEach(a=>{let u=Reflect.get(c,a,d);if(ut.has(u))Ot(u,!1),s[a]=u;else if(u instanceof Promise)if(j in u)s[a]=u[j];else{let f=u[Nt]||u;Object.defineProperty(s,a,{get(){if(j in u)return u[j];throw f}})}else u?.[M]?s[a]=u[G]:s[a]=u}),Object.freeze(s),s},m=Array.isArray(t)?[]:Object.create(Object.getPrototypeOf(t)),w={get(c,d,r){return d===Ft?n:d===M?i:d===G?y(c,r):d===Pe?w:Reflect.get(c,d,r)},deleteProperty(c,d){let r=Reflect.get(c,d),s=r?.[M];s&&s.delete(g(d));let a=Reflect.deleteProperty(c,d);return a&&o(["delete",[d],r]),a},is:Object.is,canProxy:Me,set(c,d,r,s){var a;let u=Reflect.get(c,d,s);if(this.is(u,r))return!0;let f=u?.[M];f&&f.delete(g(d)),J(r)&&(r=Ae(r)||r);let h;return(a=Object.getOwnPropertyDescriptor(c,d))!=null&&a.set?h=r:r instanceof Promise?h=r.then(b=>(h[j]=b,o(["resolve",[d],b]),b)).catch(b=>{h[Nt]=b,o(["reject",[d],b])}):r?.[M]?(h=r,h[M].add(p(d))):this.canProxy(r)?(h=ct(r),h[M].add(p(d))):h=r,Reflect.set(c,d,h,s),o(["set",[d],r,u]),!0}},E=new Proxy(m,w);return Dt.set(t,E),Reflect.ownKeys(t).forEach(c=>{let d=Object.getOwnPropertyDescriptor(t,c);d.get||d.set?Object.defineProperty(m,c,d):E[c]=t[c]}),E}function Ht(t){return J(t)?t[Ft]:void 0}function dt(t,e,n){(Q.env&&Q.env.MODE)!=="production"&&!t?.[M]&&console.warn("Please use proxy object");let i,o=[],l=p=>{if(o.push(p),n){e(o.splice(0));return}i||(i=Promise.resolve().then(()=>{i=void 0,e(o.splice(0))}))};return t[M].add(l),()=>{t[M].delete(l)}}function Le(t){return(Q.env&&Q.env.MODE)!=="production"&&!t?.[G]&&console.warn("Please use proxy object"),t[G]}function Te(t){for(;t.length>0;)t.pop();return t}var Vt=(t,...e)=>(typeof t=="function"?t(...e):t)??void 0,L=t=>t,_t=()=>{};var Ie=(()=>{let t=0;return()=>(t++,t.toString(36))})(),D=t=>Array.isArray(t),U=t=>!(t==null||typeof t!="object"||D(t)),ke=t=>typeof t=="number"&&!Number.isNaN(t),S=t=>typeof t=="string",W=t=>typeof t=="function";function it(...t){let e=t.length===1?t[0]:t[1],n=t.length===2?t[0]:!0}function ot(...t){let e=t.length===1?t[0]:t[1],n=t.length===2?t[0]:!0}function Ut(t){return{predicate:e=>(n,i)=>{var o;return(o=t.find(l=>{var p;return l.guard=l.guard||(()=>!0),S(l.guard)?!!((p=e[l.guard])!=null&&p.call(e,n,i)):zt(l.guard)?l.guard.predicate(e??{})(n,i):l.guard(n,i)}))==null?void 0:o.actions}}}function zt(t){return U(t)&&t.predicate!=null}function st(t,e){return(n,i)=>zt(t)?t.predicate(e??{})(n,i):t}function Re(...t){return{predicate:e=>(n,i)=>t.map(o=>{var l;return S(o)?!!((l=e[o])!=null&&l.call(e,n,i)):W(o)?o(n,i):o.predicate(e)(n,i)}).some(Boolean)}}function Oe(...t){return{predicate:e=>(n,i)=>t.map(o=>{var l;return S(o)?!!((l=e[o])!=null&&l.call(e,n,i)):W(o)?o(n,i):o.predicate(e)(n,i)}).every(Boolean)}}function Ne(t){return{predicate:e=>(n,i)=>{var o;return S(t)?!((o=e[t])!=null&&o.call(e,n,i)):W(t)?!t(n,i):!t.predicate(e)(n,i)}}}var Yt={or:Re,and:Oe,not:Ne};function De(t){return U(t)&&t.predicate!=null}var We=()=>!0;function Kt(t,e){return t=t??We,(n,i)=>{if(S(t)){let o=e?.[t];return W(o)?o(n,i):o}return De(t)?t.predicate(e??{})(n,i):t?.(n,i)}}function F(t){var e,n,i;if(Array.isArray(t)){for(n=Array(e=t.length);e--;)n[e]=(i=t[e])&&typeof i=="object"?F(i):i;return n}if(Object.prototype.toString.call(t)==="[object Object]"){n={};for(e in t)e==="__proto__"?Object.defineProperty(n,e,{value:F(t[e]),configurable:!0,enumerable:!0,writable:!0}):n[e]=(i=t[e])&&typeof i=="object"?F(i):i;return n}return t}function jt(t,e,n,i){return dt(t,o=>{o.some(l=>l[1][0]===e)&&n(t[e])},i)}var bn=Symbol(),N=new WeakMap,z=new WeakMap,Xt=(t,e)=>{let n=N.get(t);n&&(n[0].forEach(i=>{let{d:o}=i;t!==o&&Xt(o)}),++n[2],e&&n[3].add(e))},Be=(t,e)=>{let n=N.get(t);return n?.[2]?(n[3].add(e),!0):!1},lt=t=>{let e=N.get(t);e&&(--e[2],e[2]||(e[3].forEach(n=>n()),e[3].clear()),e[0].forEach(n=>{let{d:i}=n;t!==i&&lt(i)}))},He=t=>{let{s:e,d:n}=t,i=z.get(n);i||(i=[new Set],z.set(t.d,i)),i[0].add(t);let o=N.get(e);if(!o){let l=new Set,p=dt(e,g=>{l.forEach(y=>{let{d:m,c:w,n:E,i:c}=y;e===m&&g.every(d=>d[1].length===1&&c.includes(d[1][0]))||y.p||(Xt(e,w),E?lt(e):y.p=Promise.resolve().then(()=>{delete y.p,lt(e)}))})},!0);o=[l,p,0,new Set],N.set(e,o)}o[0].add(t)},$t=t=>{let{s:e,d:n}=t,i=z.get(n);i?.[0].delete(t),i?.[0].size===0&&z.delete(n);let o=N.get(e);if(o){let[l,p]=o;l.delete(t),l.size||(p(),N.delete(e))}},Ve=t=>{let e=z.get(t);return e?Array.from(e[0]):[]};function _e(t,e){let n=e?.proxy||ct({}),i=!!e?.sync,o=Object.keys(t);return o.forEach(l=>{if(Object.getOwnPropertyDescriptor(n,l))throw new Error("object property already defined");let p=t[l],g=null,y=()=>{if(g&&(Array.from(g).map(([c])=>Be(c,y)).some(c=>c)||Array.from(g).every(([c,d])=>Ht(c)===d.v)))return;let m=new Map,w=p(c=>(m.set(c,{v:Ht(c)}),c)),E=()=>{m.forEach((c,d)=>{var r;let s=(r=g?.get(d))==null?void 0:r.s;if(s)c.s=s;else{let a={s:d,d:n,k:l,c:y,n:i,i:o};He(a),c.s=a}}),g?.forEach((c,d)=>{!m.has(d)&&c.s&&$t(c.s)}),g=m};w instanceof Promise?w.finally(E):E(),n[l]=w};y()}),n}function je(t,e){let n=e?.delete?new Set:null;Ve(t).forEach(i=>{let{k:o}=i;(!e?.keys||e.keys.includes(o))&&($t(i),n&&n.add(o))}),n&&n.forEach(i=>{delete t[i]})}function Fe(t){var e;let n=ct({value:"",previousValue:"",event:L({}),context:(e=t.context)!=null?e:L({}),done:!1,tags:[],hasTag(i){return this.tags.includes(i)},matches(...i){return i.includes(this.value)},can(i){return L(this).nextEvents.includes(i)},get nextEvents(){var i,o,l,p;let g=(l=(o=(i=t.states)==null?void 0:i[this.value])==null?void 0:o.on)!=null?l:{},y=(p=t?.on)!=null?p:{};return Object.keys({...g,...y})},get changed(){return this.event.value==="machine.init"||!this.previousValue?!1:this.value!==this.previousValue}});return L(n)}function $(t,e){return(n,i)=>{if(ke(t))return t;if(W(t))return t(n,i);if(S(t)){let o=Number.parseFloat(t);if(!Number.isNaN(o))return o;if(e){let l=e?.[t];if(l==null){let p=`[machine] Cannot determine delay for ${t}. It doesn't exist in options.delays`;throw new Error(p)}return W(l)?l(n,i):l}}}}function A(t){return S(t)?{type:t}:t}function k(t){return t?D(t)?t:[t]:[]}function qt(t){return S(t)?{target:t}:t}function Ue(t,e){return(n,i)=>k(t).map(qt).find(o=>{var l;let p=Kt(o.guard,e)(n,i);return(l=p??o.target)!=null?l:o.actions})}function ze(t,e){let n=S(t)?qt(t):t,i=o=>(o.actions&&!o.target&&e&&(o.target=e),o);if(D(n))return n.map(i);if(U(n))return i(L(n))}var q=class{constructor(t,e){this.config=t,this.status="Not Started",this.type="machine",this.activityEvents=new Map,this.delayedEvents=new Map,this.stateListeners=new Set,this.eventListeners=new Set,this.doneListeners=new Set,this.contextWatchers=new Set,this.removeStateListener=_t,this.removeEventListener=_t,this.children=new Map,this.start=r=>{if(this.status==="Running")return this;this.status="Running";let s=A("machine.init");if(r){let f=U(r)?r:{context:this.config.context,value:r};this.setState(f.value),this.setContext(f.context)}let a={target:r?void 0:this.config.initial},u=this.getNextStateInfo(a,s);return u.target=L(u.target||a.target),this.initialState=u,this.performStateChangeEffects(u.target,u,s),this.removeStateListener=dt(this.state,()=>{this.stateListeners.forEach(f=>{f(this.stateSnapshot)})},this.sync),this.removeEventListener=jt(this.state,"event",f=>{this.config.onEvent&&this.executeActions(this.config.onEvent,f);for(let h of this.eventListeners)h(f)}),this.setupContextWatchers(),this.executeActivities(A("machine.start"),k(this.config.activities),"machine.start"),this.executeActions(this.config.entry,A("machine.start")),this},this.setupContextWatchers=()=>{var r;for(let[s,a]of Object.entries((r=this.config.watch)!=null?r:{}))this.contextWatchers.add(jt(this.state.context,s,()=>{this.executeActions(a,this.state.event)}))},this.setupComputed=()=>{var r;let s=L((r=this.config.computed)!=null?r:{}),a=Object.fromEntries(Object.entries(s).map(([u,f])=>[u,h=>f(h(this.state.context))]));_e(a,{proxy:this.state.context})},this.detachComputed=()=>{je(this.state.context,{delete:!0})},this.stop=()=>{if(this.status!=="Stopped")return this.setState(null),this.setEvent("machine.stop"),this.config.context&&this.setContext(this.config.context),this.stopStateListeners(),this.stopChildren(),this.stopActivities(),this.stopDelayedEvents(),this.stopContextWatchers(),this.stopEventListeners(),this.detachComputed(),this.status="Stopped",this.executeActions(this.config.exit,A("machine.stop")),this},this.stopEventListeners=()=>{this.eventListeners.clear(),this.removeEventListener()},this.stopStateListeners=()=>{this.removeStateListener(),this.stateListeners.clear()},this.stopContextWatchers=()=>{this.contextWatchers.forEach(r=>r()),this.contextWatchers.clear()},this.stopDelayedEvents=()=>{this.delayedEvents.forEach(r=>{r.forEach(s=>s())}),this.delayedEvents.clear()},this.stopActivities=r=>{var s,a;r?((s=this.activityEvents.get(r))==null||s.forEach(u=>u()),(a=this.activityEvents.get(r))==null||a.clear(),this.activityEvents.delete(r)):(this.activityEvents.forEach(u=>{u.forEach(f=>f()),u.clear()}),this.activityEvents.clear())},this.sendChild=(r,s)=>{let a=A(r),u=Vt(s,this.contextSnapshot),f=this.children.get(u);f||ot(`[machine/send-child] Cannot send '${a.type}' event to unknown child`),f.send(a)},this.stopChild=r=>{this.children.has(r)||ot("[machine/stop-child] Cannot stop unknown child"),this.children.get(r).stop(),this.children.delete(r)},this.removeChild=r=>{this.children.delete(r)},this.stopChildren=()=>{this.children.forEach(r=>r.stop()),this.children.clear()},this.setParent=r=>{this.parent=r},this.spawn=(r,s)=>{let a=Vt(r);return s&&(a.id=s),a.type="machine.actor",a.setParent(this),this.children.set(a.id,L(a)),a.onDone(()=>{this.removeChild(a.id)}).start(),L(Z(a))},this.addActivityCleanup=(r,s)=>{var a;!r||(this.activityEvents.has(r)?(a=this.activityEvents.get(r))==null||a.add(s):this.activityEvents.set(r,new Set([s])))},this.setState=r=>{this.state.previousValue=this.state.value,this.state.value=r;let s=this.getStateNode(r);r==null?Te(this.state.tags):this.state.tags=k(s?.tags)},this.setContext=r=>{for(let s in r)this.state.context[s]=r[s]},this.withContext=r=>{this.detachComputed();let s={...this.config.context,...r};return new q({...this.config,context:s},this.options)},this.withOptions=r=>(this.detachComputed(),new q(this.config,{...this.options,...r})),this.setActions=r=>{this.actionMap={...this.actionMap,...r}},this.clone=()=>(this.detachComputed(),new q(this.config,this.options)),this.getStateNode=r=>{var s;if(r)return(s=this.config.states)==null?void 0:s[r]},this.getNextStateInfo=(r,s)=>{var a;let u=this.determineTransition(r,s),f=(a=u?.target)!=null?a:this.state.value,h=this.getStateNode(f);return{transition:u,stateNode:h,target:f}},this.getActionFromDelayedTransition=r=>{let s=A("machine.after"),a=$(r.delay,this.delayMap)(this.contextSnapshot,s),u;return{entry:()=>{u=globalThis.setTimeout(()=>{let f=this.state.value,h=this.getNextStateInfo(r,s);this.performStateChangeEffects(f,h,s)},a)},exit:()=>{globalThis.clearTimeout(u)}}},this.getDelayedEventActions=r=>{let s=this.getStateNode(r),a=A("machine.after");if(!s||!s.after)return;let u=[],f=[];if(D(s.after)){let h=this.determineTransition(s.after,a);if(!h)return;let b=this.getActionFromDelayedTransition(h);u.push(b.entry),f.push(b.exit)}else if(U(s.after))for(let h in s.after){let b=s.after[h],C={};if(D(b)){let H=this.determineTransition(b,a);H&&(C=H)}else S(b)?C={target:b,delay:h}:C={...b,delay:h};let B=this.getActionFromDelayedTransition(C);u.push(B.entry),f.push(B.exit)}return{entries:u,exits:f}},this.executeActions=(r,s)=>{var a;let u=st(r,this.guardMap)(this.contextSnapshot,s);for(let f of k(u)){let h=S(f)?(a=this.actionMap)==null?void 0:a[f]:f;it(S(f)&&!h,`[machine/exec-action] No implementation found for action: \`${f}\``),h?.(this.state.context,s,this.meta)}},this.executeActivities=(r,s,a)=>{var u;for(let f of s){let h=S(f)?(u=this.activityMap)==null?void 0:u[f]:f;if(!h){it(`[machine/exec-activity] No implementation found for activity: \`${f}\``);continue}let b=h(this.state.context,r,this.meta);b&&this.addActivityCleanup(a??this.state.value,b)}},this.createEveryActivities=(r,s)=>{if(!r)return;let a=A("machine.every");if(D(r)){let u=k(r).find(h=>{let b=$(h.delay,this.delayMap);h.delay=b(this.contextSnapshot,a);let C=Kt(h.guard,this.guardMap)(this.contextSnapshot,a);return C??h.delay});if(!u)return;let f=$(u.delay,this.delayMap)(this.contextSnapshot,a);s(()=>{let h=globalThis.setInterval(()=>{this.executeActions(u.actions,a)},f);return()=>{globalThis.clearInterval(h)}})}else for(let u in r){let f=r?.[u],h=$(u,this.delayMap)(this.contextSnapshot,a);s(()=>{let b=globalThis.setInterval(()=>{this.executeActions(f,a)},h);return()=>{globalThis.clearInterval(b)}})}},this.setEvent=r=>{this.state.event=Z(A(r))},this.performExitEffects=(r,s)=>{let a=this.state.value,u=r?this.getStateNode(r):void 0;this.stopActivities(a);let f=st(u?.exit,this.guardMap)(this.contextSnapshot,s),h=k(f),b=this.delayedEvents.get(a);b&&h.push(...b),this.executeActions(h,s),this.eventListeners.clear()},this.performEntryEffects=(r,s)=>{let a=this.getStateNode(r),u=k(a?.activities);this.createEveryActivities(a?.every,C=>{u.unshift(C)}),u.length>0&&this.executeActivities(s,u);let f=st(a?.entry,this.guardMap)(this.contextSnapshot,s),h=k(f),b=this.getDelayedEventActions(r);a?.after&&b&&(this.delayedEvents.set(r,b?.exits),h.push(...b.entries)),this.executeActions(h,s),a?.type==="final"&&(this.state.done=!0,this.doneListeners.forEach(C=>{C(this.stateSnapshot)}),this.stop())},this.performTransitionEffects=(r,s)=>{let a=this.determineTransition(r,s);this.executeActions(a?.actions,s)},this.performStateChangeEffects=(r,s,a)=>{var u,f;this.setEvent(a),s.target=(f=(u=s.target)!=null?u:this.state.value)!=null?f:void 0;let h=s.target&&s.target!==this.state.value;h&&this.performExitEffects(r,a),this.performTransitionEffects(s?.transition,a),this.setState(s.target),h&&this.performEntryEffects(s.target,a)},this.determineTransition=(r,s)=>{let a=Ue(r,this.guardMap);return a?.(this.contextSnapshot,s)},this.sendParent=r=>{var s;this.parent||ot("[machine/send-parent] Cannot send event to an unknown parent");let a=A(r);(s=this.parent)==null||s.send(a)},this.send=r=>{let s=A(r);this.transition(this.state.value,s)},this.transition=(r,s)=>{var a,u,f;let h=S(r)?this.getStateNode(r):r?.stateNode,b=A(s);if(!h&&!this.config.on){let te=this.status==="Stopped"?"[machine/transition] Cannot transition a stopped machine":"[machine/transition] State does not have a definition";it(te);return}let C=(f=(a=h?.on)==null?void 0:a[b.type])!=null?f:(u=this.config.on)==null?void 0:u[b.type],B=ze(C,this.state.value);if(!B)return;let H=this.getNextStateInfo(B,b);return this.performStateChangeEffects(this.state.value,H,b),H.stateNode},this.subscribe=r=>(this.stateListeners.add(r),this.status==="Running"&&r(this.stateSnapshot),()=>{this.stateListeners.delete(r)}),this.onDone=r=>(this.doneListeners.add(r),this),this.onTransition=r=>(this.stateListeners.add(r),this.status==="Running"&&r(this.stateSnapshot),this),this.onEvent=r=>(r(this.state.event),this.eventListeners.add(r),this);var n,i,o,l,p,g,y,m,w,E,c;this.options=F(e),this.id=(n=t.id)!=null?n:`machine-${Ie()}`,this.guardMap=(o=(i=this.options)==null?void 0:i.guards)!=null?o:{},this.actionMap=(p=(l=this.options)==null?void 0:l.actions)!=null?p:{},this.delayMap=(y=(g=this.options)==null?void 0:g.delays)!=null?y:{},this.activityMap=(w=(m=this.options)==null?void 0:m.activities)!=null?w:{},this.sync=(c=(E=this.options)==null?void 0:E.sync)!=null?c:!1,this.state=Fe(F(t)),this.setupComputed();let d=A("machine.created");this.executeActions(t?.created,d)}get stateSnapshot(){return L(Le(this.state))}get contextSnapshot(){return this.stateSnapshot.context}get self(){let t=this;return{id:this.id,send:this.send.bind(this),sendParent:this.sendParent.bind(this),sendChild:this.sendChild.bind(this),stop:this.stop.bind(this),stopChild:this.stopChild.bind(this),spawn:this.spawn.bind(this),get state(){return t.stateSnapshot}}}get meta(){return{state:this.stateSnapshot,guards:this.guardMap,send:this.send.bind(this),listen:this.onEvent.bind(this),self:this.self,getState:()=>this.stateSnapshot}}},Gt=(t,e)=>new q(t,e);var Zt=(...t)=>e=>t.reduce((n,i)=>i(n),e);var xn=(()=>{let t=0;return()=>(t++,t.toString(36))})();var Ye=t=>Jt()&&t.test(navigator.userAgent);var Jt=()=>typeof window<"u";var tt=()=>Ye(/^((?!chrome|android).)*safari/i);var et=()=>Jt()&&window.onpointerdown===null;var{not:ht,and:ft}=Yt,Qt=Gt({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:t=>t.dir==="rtl",valueAsNumber:t=>P(t.value),isAtMin:t=>Mt(t.value,t),isAtMax:t=>Pt(t.value,t),isOutOfRange:t=>!Lt(t.value,t),canIncrement:t=>t.allowOverflow||!t.isAtMax,canDecrement:t=>t.allowOverflow||!t.isAtMin,valueText:t=>{var e,n;return(n=(e=t.messages).valueText)==null?void 0:n.call(e,t.value)},formattedValue:t=>{var e,n;return(n=(e=t.format)==null?void 0:e.call(t,t.value).toString())!=null?n:t.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:ft("clampOnBlur",ht("isInRange")),target:"idle",actions:["clampValue","clearHint"]},{actions:["roundValue"]}]}},"before:spin":{tags:["focus"],entry:Ut([{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:ft(ht("isAtMin"),"isIncrementHint"),actions:"increment"},{delay:"CHANGE_INTERVAL",guard:ft(ht("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:t=>!!t.clampValueOnBlur,isAtMin:t=>t.isAtMin,isAtMax:t=>t.isAtMax,isInRange:t=>!t.isOutOfRange,isDecrementHint:(t,e)=>{var n;return((n=e.hint)!=null?n:t.hint)==="decrement"},isIncrementHint:(t,e)=>{var n;return((n=e.hint)!=null?n:t.hint)==="increment"},isInvalidExponential:t=>t.value.toString().startsWith("e")},activities:{trackButtonDisabled(t,e,{send:n}){let i=null;return t.hint==="increment"&&(i=v.getIncButtonEl(t)),t.hint==="decrement"&&(i=v.getDecButtonEl(t)),yt(i,"disabled",function(){n("PRESS_UP")})},attachWheelListener(t){let e=[];return e.push(V(()=>{let n=v.getInputEl(t);if(!n)return;function i(o){let l=v.getDoc(t).activeElement===n;if(!t.allowMouseWheel||!l)return;o.preventDefault();let p=Math.sign(o.deltaY)*-1;p===1?t.value=x.increment(t):p===-1&&(t.value=x.decrement(t))}e.push(Y(n,"wheel",i,{passive:!1}))})),()=>e.forEach(n=>n())},activatePointerLock(t){if(!(tt()||!et()))return bt(v.getDoc(t))},trackMousemove(t,e,{send:n}){let i=v.getDoc(t);function o(p){if(!t.scrubberCursorPoint)return;let g=v.getMousementValue(t,p);!g.hint||n({type:"POINTER_MOVE_SCRUBBER",hint:g.hint,point:g.point})}function l(){n("POINTER_UP_SCRUBBER")}return Zt(Y(i,"mousemove",o,!1),Y(i,"mouseup",l,!1))}},actions:{setupDocument:(t,e)=>{e.doc&&(t.doc=Z(e.doc)),t.uid=e.id},focusInput(t){if(!t.focusInputOnChange)return;let e=v.getInputEl(t);V(()=>e==null?void 0:e.focus())},increment(t,e){t.value=x.increment(t,e.step)},decrement(t,e){t.value=x.decrement(t,e.step)},clampValue(t){t.value=x.clamp(t)},roundValue(t){t.value=x.round(t)},setValue(t,e){var i,o;let n=(o=(i=e.target)==null?void 0:i.value)!=null?o:e.value;t.value=x.sanitize(t,x.parse(t,n))},clearValue(t){t.value=""},setToMax(t){t.value=t.max.toString()},setToMin(t){t.value=t.min.toString()},setHint(t,e){t.hint=e.hint},clearHint(t){t.hint=null},setHintToSet(t){t.hint="set"},setSelectionRange(t,e){t.inputSelection={start:e.target.selectionStart,end:e.target.selectionEnd}},restoreSelection(t){var n,i,o;let e=v.getInputEl(t);!e||!t.inputSelection||(e.selectionStart=(i=t.inputSelection.start)!=null?i:(n=e.value)==null?void 0:n.length,e.selectionEnd=(o=t.inputSelection.end)!=null?o:e.selectionStart)},invokeOnChange(t){var e;(e=t.onChange)==null||e.call(t,{value:t.value,valueAsNumber:t.valueAsNumber})},invokeOnInvalid(t){var n;if(!t.isOutOfRange)return;let e=t.valueAsNumber>t.max?"rangeOverflow":"rangeUnderflow";(n=t.onInvalid)==null||n.call(t,{reason:e,value:t.formattedValue,valueAsNumber:t.valueAsNumber})},syncInputValue(t){let e=v.getInputEl(t);if(!e||e.value==t.value)return;let n=x.parse(t,e.value);t.value=x.sanitize(t,n)},setCursorPoint(t,e){t.scrubberCursorPoint=e.point},clearCursorPoint(t){t.scrubberCursorPoint=null},updateCursor(t){let e=v.getCursorEl(t);!e||!t.scrubberCursorPoint||(e.style.transform=`translate3d(${t.scrubberCursorPoint.x}px, ${t.scrubberCursorPoint.y}px, 0px)`)},addCustomCursor(t){tt()||!et()||v.createVirtualCursor(t)},removeCustomCursor(t){if(tt()||!et())return;let n=v.getDoc(t).getElementById(v.getCursorId(t));n==null||n.remove()},disableTextSelection(t){let e=v.getDoc(t);e.body.style.pointerEvents="none",e.documentElement.style.userSelect="none",e.documentElement.style.cursor="ew-resize"},restoreTextSelection(t){let e=v.getDoc(t);e.body.style.pointerEvents="",e.documentElement.style.userSelect="",e.documentElement.style.cursor=""}}});
8
8
  //# sourceMappingURL=index.js.map