import{r as e}from"./rolldown-runtime-DIIn1E2Q.js";import{A as t,D as n,G as r,K as i,Lt as a,O as o,Ot as s,R as c,_t as l,b as u,et as d,ft as f,j as p,k as m,rt as h,ut as g,y as _,zt as v}from"./vendor-vue-core-IZuWV8u3.js";import{a as y}from"./vendor-vueuse-ChbGLbpR.js";import{n as b}from"./vendor-i18n-NwyZMF0q.js";import{t as x}from"./src-B0kocU_l.js";import{t as S}from"./Button-uSZXZovG.js";var C={class:`relative min-w-[4ch] flex-1 py-1.5 my-0.25`},w=[`value`,`disabled`],T=c({__name:`ScrubableNumberInput`,props:r({min:{},max:{},step:{default:1},disabled:{type:Boolean,default:!1},hideButtons:{type:Boolean,default:!1},displayValue:{},parseValue:{type:Function},inputAttrs:{}},{modelValue:{default:0},modelModifiers:{}}),emits:[`update:modelValue`],setup(e){let{t:r}=b(),c=g(e,`modelValue`),T=f(`container`),E=f(`inputField`),D=s(!1);y(T,()=>{D.value&&=!1});function clamp(t){let n=e.min??-1/0,r=e.max??1/0;return Math.min(r,Math.max(n,t))}let O=n(()=>c.value>(e.min??-1/0)&&!e.disabled),k=n(()=>c.value<(e.max??1/0)&&!e.disabled),A=s(!1),j=s(0),M=s(!1);function handleBlur(t){let n=t.target,r=n.value.trim(),i=e.parseValue?e.parseValue(r):r===``?void 0:Number(r);i!=null&&!isNaN(i)?c.value=clamp(i):n.value=e.displayValue??String(c.value),D.value=!1}function handlePointerDown(t){t.button===0&&(e.disabled||(t.target.setPointerCapture(t.pointerId),A.value=!0,j.value=0,M.value=!1))}function handlePointerMove(t){if(!A.value)return;j.value+=t.movementX;let n=j.value/10|0;if(n===0)return;M.value=!0;let r=c.value+n*e.step;j.value%=10,c.value=clamp(r)}function handlePointerUp(){A.value&&(M.value||(D.value=!0,E.value?.focus(),E.value?.select()),resetDrag())}function resetDrag(){A.value=!1,j.value=0}return(e,n)=>(d(),p(`div`,{ref_key:`container`,ref:T,class:`flex h-7 rounded-lg bg-component-node-widget-background text-xs text-component-node-foreground`},[h(e.$slots,`background`),e.hideButtons?t(``,!0):(d(),m(S,{key:0,"aria-label":a(r)(`g.ariaLabel.decrement`),"data-testid":`decrement`,class:`h-full w-8 rounded-r-none hover:bg-base-foreground/20 disabled:opacity-30`,variant:`muted-textonly`,disabled:!O.value,tabindex:`-1`,onClick:n[0]||=t=>c.value=clamp(c.value-e.step)},{default:l(()=>n[3]||=[o(`i`,{class:`pi pi-minus`},null,-1)]),_:1},8,[`aria-label`,`disabled`])),o(`div`,C,[o(`input`,i({ref_key:`inputField`,ref:E},e.inputAttrs,{value:e.displayValue??c.value,disabled:e.disabled,class:a(x)(`bg-transparent border-0 focus:outline-0 p-1 truncate text-sm absolute inset-0`),inputmode:`decimal`,autocomplete:`off`,autocorrect:`off`,spellcheck:`false`,onBlur:handleBlur,onKeyup:_(handleBlur,[`enter`]),onDragstart:n[1]||=u(()=>{},[`prevent`])}),null,16,w),o(`div`,{class:v(a(x)(`absolute inset-0 z-10 cursor-ew-resize`,D.value&&`pointer-events-none hidden`)),onPointerdown:handlePointerDown,onPointermove:handlePointerMove,onPointerup:handlePointerUp,onPointercancel:resetDrag},null,34)]),h(e.$slots,`default`),e.hideButtons?t(``,!0):(d(),m(S,{key:1,"aria-label":a(r)(`g.ariaLabel.increment`),"data-testid":`increment`,class:`h-full w-8 rounded-l-none hover:bg-base-foreground/20 disabled:opacity-30`,variant:`muted-textonly`,disabled:!k.value,tabindex:`-1`,onClick:n[2]||=t=>c.value=clamp(c.value+e.step)},{default:l(()=>n[4]||=[o(`i`,{class:`pi pi-plus`},null,-1)]),_:1},8,[`aria-label`,`disabled`]))],512))}});export{T as t};
//# sourceMappingURL=ScrubableNumberInput-CWjM0uhi.js.map