import{m as M}from"./slider-B0ER1pJ5.js";import{u as P}from"./useFieldsExtraOptions-BAS3Fj_1.js";import{a as S,k as $,C as B,b as u,O as C,m as v,g as p,p as m,n as z,D as b,u as n,I as k,q as N,F as D,H as E,P as O}from"./convert-case-to-camel-case.utils-DDUpNI96.js";import"./widget-BUAABBRb.js";import"./_commonjsHelpers-Cpj98o6Y.js";import"./_commonjs-dynamic-modules-TDtrdbi3.js";import"./translationsStore-DBJu9sBR.js";const q={class:"slider-min-max"},H={class:"label"},I={class:"label"},L={class:"custom-marks"},R=["onClick"],W=S({__name:"Flat",props:{field:{},modelValue:{}},emits:["update:modelValue"],setup(y,{emit:F}){const r=y,i=F,x=$(r.modelValue),{field:s}=B(r),{formatMinMax:g}=P(s),d=u({get:()=>r.modelValue,set:a=>i("update:modelValue",a)}),t=u(()=>Number(s.value.min)),o=u(()=>Number(s.value.max)),h=u(()=>s.value.jump?1:Number(s.value.step||1)),_=u(()=>s.value.jump),c=u(()=>{var l;return(((l=s.value.scalePoints)==null?void 0:l.trim())||"").split(",").map(e=>Number(e.trim())).filter(e=>!isNaN(e)&&e>=t.value&&e<=o.value)}),j=a=>({left:`${(a-t.value)/(o.value-t.value)*100}%`}),f=a=>{_.value&&c.value.includes(a)&&i("update:modelValue",a)},w=a=>{const l=a.toFixed(2);return parseFloat(l).toString()};return C(()=>r.modelValue,a=>{x.value=a}),C(x,a=>{if(_.value){const l=c.value.reduce((e,V)=>Math.abs(V-a)<Math.abs(e-a)?V:e,c.value[0]);i("update:modelValue",l)}else i("update:modelValue",a)}),(a,l)=>(p(),v("div",{class:k(["slider-wrapper ccb-flat-range-field",{jump:n(s).jump}])},[m("div",q,[m("div",{class:"slider-min-max-item first",onClick:l[0]||(l[0]=e=>f(t.value))},[m("span",H,b(n(g)(t.value)),1)]),m("div",{class:k(["slider-min-max-item",{done:d.value>=o.value}]),onClick:l[1]||(l[1]=e=>f(o.value))},[m("span",I,b(n(g)(o.value)),1)],2)]),z(n(M),{modelValue:d.value,"onUpdate:modelValue":l[2]||(l[2]=e=>d.value=e),min:t.value,max:o.value,step:h.value,disabled:n(s).disabled,"show-tooltip":"focus",class:"custom-slider",format:w},null,8,["modelValue","min","max","step","disabled"]),m("div",L,[n(s).scalePoints?(p(!0),v(D,{key:0},E(c.value,e=>(p(),v("div",{key:e,class:"mark",style:O(j(e))},[e!==t.value&&e!==o.value?(p(),v("div",{key:0,class:k(["label",{"label-passed":e<=d.value}]),onClick:V=>f(e)},b(e),11,R)):N("",!0)],4))),128)):N("",!0)])],2))}});export{W as default};
//# sourceMappingURL=Flat-BPchhFEX.js.map
