import{m as J}from"./slider-B0ER1pJ5.js";import{u as $}from"./useFieldsExtraOptions-BAS3Fj_1.js";import{a as B,C as z,b as p,k as A,O as x,m as v,g as f,p as u,n as D,I as V,D as g,u as o,q as N,F as E,H as _,P as q}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 H={class:"slider-min-max"},I={class:"label"},L={class:"label"},R={class:"custom-marks"},U=["onClick"],Z=B({__name:"MultiPoint",props:{field:{},modelValue:{}},emits:["update:modelValue"],setup(S,{emit:P}){const m=S,{field:s}=z(m),{formatMinMax:C}=$(s),h=p(()=>s.value.jump?1:Number(s.value.step||1)),t=p(()=>Number(s.value.min)),i=p(()=>Number(s.value.max)),k=A(m.modelValue),b=p(()=>s.value.jump),r=P,F=e=>{r("update:modelValue",Array.isArray(e)?e:[e])},O=e=>{const l=e.toFixed(2);return parseFloat(l).toString()},n=p(()=>{var l;return(((l=s.value.scalePoints)==null?void 0:l.trim())||"").split(",").map(a=>Number(a.trim())).filter(a=>!isNaN(a)&&a>=t.value&&a<=i.value)}),j=e=>({left:`${(e-t.value)/(i.value-t.value)*100}%`});x(()=>m.modelValue,e=>{k.value=e});const M=e=>{b.value&&n.value.includes(e)&&r("update:modelValue",[k.value[0],e])},w=e=>{b.value&&n.value.includes(e)&&r("update:modelValue",[e,k.value[1]])};return x(k,e=>{if(b.value){const l=n.value.reduce((d,c)=>Math.abs(c-e[0])<Math.abs(d-e[0])?c:d,n.value[0]),a=n.value.reduce((d,c)=>Math.abs(c-e[1])<Math.abs(d-e[1])?c:d,n.value[0]),y=[l,a];JSON.stringify(y)!==JSON.stringify(m.modelValue)&&r("update:modelValue",y)}else JSON.stringify(e)!==JSON.stringify(m.modelValue)&&r("update:modelValue",e)}),(e,l)=>(f(),v("div",{class:V(["slider-wrapper ccb-multi-point-multi-range-field",{jump:o(s).jump}])},[u("div",H,[u("div",{class:V(["slider-min-max-item",{first:e.modelValue[0]==t.value}]),onClick:l[0]||(l[0]=a=>w(t.value))},[l[2]||(l[2]=u("span",{class:"tick"},null,-1)),u("span",I,g(o(C)(t.value)),1)],2),u("div",{class:V(["slider-min-max-item",{done:e.modelValue[0]>=i.value}]),onClick:l[1]||(l[1]=a=>M(i.value))},[l[3]||(l[3]=u("span",{class:"tick"},null,-1)),u("span",L,g(o(C)(i.value)),1)],2)]),D(o(J),{style:{margin:"10px 0"},format:O,min:o(s).min,max:o(s).max,step:h.value,disabled:o(s).disabled,modelValue:e.modelValue,"onUpdate:modelValue":F,"show-tooltip":"focus"},null,8,["min","max","step","disabled","modelValue"]),u("div",R,[o(s).scalePoints?(f(!0),v(E,{key:0},_(n.value,a=>(f(),v("div",{key:a,class:"mark",style:q(j(a))},[a!==t.value&&a!==i.value?(f(),v("div",{key:0,class:V(["tick",{"tick-passed":a>=e.modelValue[0]&&a<=e.modelValue[1]}])},null,2)):N("",!0),a!==t.value&&a!==i.value?(f(),v("div",{key:1,class:V(["label",{"label-passed":a<=e.modelValue[0]}]),onClick:y=>M(a)},g(a),11,U)):N("",!0)],4))),128)):N("",!0)])],2))}});export{Z as default};
//# sourceMappingURL=MultiPoint-BlRGdw3s.js.map
