import"./rolldown-runtime-DIIn1E2Q.js";import{A as e,Bt as t,D as n,G as r,K as i,O as a,R as o,Rt as s,_t as c,b as l,et as u,ft as d,j as f,k as p,kt as m,rt as h,ut as g,y as _}from"./vendor-vue-core-DO0afONr.js";import{j as v,nt as y,o as b}from"./vendor-vueuse-DUMtJaL2.js";import{n as x}from"./vendor-i18n-JbyM4Qz7.js";import{t as S}from"./src-NuWuoO1R.js";import{t as C}from"./Button-Ca3rDegY.js";var w={class:`relative my-0.25 min-w-[4ch] flex-1 py-1.5`},T=[`value`,`disabled`],E=o({__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(r){let{t:o}=x(),E=g(r,`modelValue`),D=d(`container`),O=d(`inputField`),k=d(`swipeElement`),A=m(!1);b(D,()=>{A.value&&=!1});function clamp(e){return Math.min(r.max,Math.max(r.min,e))}let j=n(()=>E.value>r.min&&!r.disabled),M=n(()=>E.value<r.max&&!r.disabled);function handleBlur(e){let t=e.target,n=t.value.trim(),i=r.parseValue?r.parseValue(n):n===``?void 0:Number(n);i!=null&&!isNaN(i)?E.value=clamp(i):t.value=r.displayValue??String(E.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}=v(k,{onSwipeEnd:()=>N=0});y(P,()=>{if(r.disabled)return;let e=(P.value-N)/10|0;N+=e*10,E.value=clamp(E.value-e*r.step)});function updateValueBy(e){E.value=Math.min(r.max,Math.max(r.min,E.value+e))}return(n,r)=>(u(),f(`div`,{ref_key:`container`,ref:D,class:`flex h-7 rounded-lg bg-component-node-widget-background text-xs text-component-node-foreground`},[h(n.$slots,`background`),n.hideButtons?e(``,!0):(u(),p(C,{key:0,"aria-label":s(o)(`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:r[0]||=e=>E.value=clamp(E.value-n.step)},{default:c(()=>r[6]||=[a(`i`,{class:`pi pi-minus`},null,-1)]),_:1},8,[`aria-label`,`disabled`])),a(`div`,w,[a(`input`,i({ref_key:`inputField`,ref:O},n.inputAttrs,{value:n.displayValue??E.value,disabled:n.disabled,class:s(S)(`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:[r[1]||=_(l(e=>updateValueBy(n.step),[`prevent`]),[`up`]),r[2]||=_(l(e=>updateValueBy(-n.step),[`prevent`]),[`down`]),r[3]||=_(l(e=>updateValueBy(10*n.step),[`prevent`]),[`page-up`]),r[4]||=_(l(e=>updateValueBy(-10*n.step),[`prevent`]),[`page-down`])]}),null,16,T),a(`div`,{ref_key:`swipeElement`,ref:k,class:t(s(S)(`absolute inset-0 z-10 cursor-ew-resize touch-pan-y`,A.value&&`pointer-events-none hidden`)),onPointerup:handlePointerUp},null,34)]),h(n.$slots,`default`),n.hideButtons?e(``,!0):(u(),p(C,{key:1,"aria-label":s(o)(`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:r[5]||=e=>E.value=clamp(E.value+n.step)},{default:c(()=>r[7]||=[a(`i`,{class:`pi pi-plus`},null,-1)]),_:1},8,[`aria-label`,`disabled`]))],512))}});export{E as t};
//# sourceMappingURL=ScrubableNumberInput-CRrR3VyE.js.map