import{G as U,ac as c,I as g,H as h,d as X,V as D,X as f,a3 as F,bg as Y,a4 as w,bh as J,j as v,a7 as I,aG as y,a9 as R,aV as k,aP as z,N as A,Y as Z,aQ as p,ar as N,aD as ee,bi as te,P as ae}from"./ResizeObserver.es.62ab429c.js";const[ne,S]=U("stepper"),le=200,ie=600,P=(t,u)=>String(t)===String(u),ue={min:c(1),max:c(1/0),name:c(""),step:c(1),theme:String,integer:Boolean,disabled:Boolean,showPlus:g,showMinus:g,showInput:g,longPress:g,allowEmpty:Boolean,modelValue:h,inputWidth:h,buttonSize:h,placeholder:String,disablePlus:Boolean,disableMinus:Boolean,disableInput:Boolean,beforeChange:Function,defaultValue:c(1),decimalLength:h};var se=X({name:ne,props:ue,emits:["plus","blur","minus","focus","change","overlimit","update:modelValue"],setup(t,{emit:u}){const o=e=>{const{min:a,max:i,allowEmpty:b,decimalLength:l}=t;return b&&e===""||(e=z(String(e),!t.integer),e=e===""?0:+e,e=Number.isNaN(e)?+a:e,e=Math.max(Math.min(+i,e),+a),A(l)&&(e=e.toFixed(+l))),e},G=()=>{var e;const a=(e=t.modelValue)!=null?e:t.defaultValue,i=o(a);return P(i,t.modelValue)||u("update:modelValue",i),i};let s;const x=D(),n=D(G()),d=f(()=>t.disabled||t.disableMinus||n.value<=+t.min),r=f(()=>t.disabled||t.disablePlus||n.value>=+t.max),H=f(()=>({width:F(t.inputWidth),height:F(t.buttonSize)})),C=f(()=>Y(t.buttonSize)),O=()=>{const e=o(n.value);P(e,n.value)||(n.value=e)},E=e=>{t.beforeChange?ee(t.beforeChange,{args:[e],done(){n.value=e}}):n.value=e},V=()=>{if(s==="plus"&&r.value||s==="minus"&&d.value){u("overlimit",s);return}const e=s==="minus"?-t.step:+t.step,a=o(te(+n.value,e));E(a),u(s)},W=e=>{const a=e.target,{value:i}=a,{decimalLength:b}=t;let l=z(String(i),!t.integer);if(A(b)&&l.includes(".")){const _=l.split(".");l=`${_[0]}.${_[1].slice(0,+b)}`}t.beforeChange?a.value=String(n.value):P(i,l)||(a.value=l);const Q=l===String(+l);E(Q?+l:l)},$=e=>{var a;t.disableInput?(a=x.value)==null||a.blur():u("focus",e)},j=e=>{const a=e.target,i=o(a.value);a.value=String(i),n.value=i,Z(()=>{u("blur",e),p()})};let T,m;const B=()=>{m=setTimeout(()=>{V(),B()},le)},q=()=>{t.longPress&&(T=!1,clearTimeout(m),m=setTimeout(()=>{T=!0,V(),B()},ie))},L=e=>{t.longPress&&(clearTimeout(m),T&&N(e))},K=e=>{t.disableInput&&N(e)},M=e=>({onClick:a=>{N(a),s=e,V()},onTouchstart:()=>{s=e,q()},onTouchend:L,onTouchcancel:L});return w(()=>[t.max,t.min,t.integer,t.decimalLength],O),w(()=>t.modelValue,e=>{P(e,n.value)||(n.value=o(e))}),w(n,e=>{u("update:modelValue",e),u("change",e,{name:t.name})}),J(()=>t.modelValue),()=>v("div",{role:"group",class:S([t.theme])},[I(v("button",R({type:"button",style:C.value,class:[S("minus",{disabled:d.value}),{[k]:!d.value}],"aria-disabled":d.value||void 0},M("minus")),null),[[y,t.showMinus]]),I(v("input",{ref:x,type:t.integer?"tel":"text",role:"spinbutton",class:S("input"),value:n.value,style:H.value,disabled:t.disabled,readonly:t.disableInput,inputmode:t.integer?"numeric":"decimal",placeholder:t.placeholder,"aria-valuemax":t.max,"aria-valuemin":t.min,"aria-valuenow":n.value,onBlur:j,onInput:W,onFocus:$,onMousedown:K},null),[[y,t.showInput]]),I(v("button",R({type:"button",style:C.value,class:[S("plus",{disabled:r.value}),{[k]:!r.value}],"aria-disabled":r.value||void 0},M("plus")),null),[[y,t.showPlus]])])}});const ce=ae(se);export{ce as S};
