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{j as y,nt as b,o as x}from"./vendor-vueuse-BE8A1jSL.js";import{n as S}from"./vendor-i18n-CpHGo1Sd.js";import{t as C}from"./src-B6n4nS3q.js";import{t as w}from"./Button-BonqIZfE.js";var T={class:`relative my-0.25 min-w-[4ch] flex-1 py-1.5`},E=[`value`,`disabled`],D=c({__name:`ScrubableNumberInput`,props:r({min:{default:()=>-Number.MAX_VALUE},max:{default:()=>Number.MAX_VALUE},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}=S(),c=g(e,`modelValue`),D=f(`container`),O=f(`inputField`),k=f(`swipeElement`),A=s(!1);x(D,()=>{A.value&&=!1});function clamp(t){return Math.min(e.max,Math.max(e.min,t))}let j=n(()=>c.value>e.min&&!e.disabled),M=n(()=>c.value<e.max&&!e.disabled);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),A.value=!1}let N=0;function handlePointerUp(){F.value||(A.value=!0,O.value?.focus(),O.value?.select())}let{distanceX:P,isSwiping:F}=y(k,{onSwipeEnd:()=>N=0});b(P,()=>{if(e.disabled)return;let t=(P.value-N)/10|0;N+=t*10,c.value=clamp(c.value-t*e.step)});function updateValueBy(t){c.value=Math.min(e.max,Math.max(e.min,c.value+t))}return(e,n)=>(d(),p(`div`,{ref_key:`container`,ref:D,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(w,{key:0,"aria-label":a(r)(`g.decrement`),"data-testid":`decrement`,class:`aspect-8/7 h-full rounded-r-none hover:bg-base-foreground/20 disabled:opacity-30`,variant:`muted-textonly`,disabled:!j.value,tabindex:`-1`,onClick:n[0]||=t=>c.value=clamp(c.value-e.step)},{default:l(()=>n[6]||=[o(`i`,{class:`pi pi-minus`},null,-1)]),_:1},8,[`aria-label`,`disabled`])),o(`div`,T,[o(`input`,i({ref_key:`inputField`,ref:O},e.inputAttrs,{value:e.displayValue??c.value,disabled:e.disabled,class:a(C)(`absolute inset-0 truncate border-0 bg-transparent p-1 text-sm focus:outline-0`),inputmode:`decimal`,autocomplete:`off`,autocorrect:`off`,spellcheck:`false`,onBlur:handleBlur,onKeyup:_(handleBlur,[`enter`]),onKeydown:[n[1]||=_(u(t=>updateValueBy(e.step),[`prevent`]),[`up`]),n[2]||=_(u(t=>updateValueBy(-e.step),[`prevent`]),[`down`]),n[3]||=_(u(t=>updateValueBy(10*e.step),[`prevent`]),[`page-up`]),n[4]||=_(u(t=>updateValueBy(-10*e.step),[`prevent`]),[`page-down`])]}),null,16,E),o(`div`,{ref_key:`swipeElement`,ref:k,class:v(a(C)(`absolute inset-0 z-10 cursor-ew-resize touch-pan-y`,A.value&&`pointer-events-none hidden`)),onPointerup:handlePointerUp},null,34)]),h(e.$slots,`default`),e.hideButtons?t(``,!0):(d(),m(w,{key:1,"aria-label":a(r)(`g.increment`),"data-testid":`increment`,class:`aspect-8/7 h-full rounded-l-none hover:bg-base-foreground/20 disabled:opacity-30`,variant:`muted-textonly`,disabled:!M.value,tabindex:`-1`,onClick:n[5]||=t=>c.value=clamp(c.value+e.step)},{default:l(()=>n[7]||=[o(`i`,{class:`pi pi-plus`},null,-1)]),_:1},8,[`aria-label`,`disabled`]))],512))}});export{D as t};
//# sourceMappingURL=ScrubableNumberInput-DcJ2a0TX.js.map