import{m as J}from"./vendor-vueform-slider-CCH9_7pb.js";import{u as $}from"./useFieldsExtraOptions-BNwbfzEK.js";import{d as B,e as p,w as M,f as v,i as f,x as u,j as z,t as g,F as A,r as E}from"./vendor-vue-runtime-core-DwK6Ry68.js";import{t as _,r as D,u as o}from"./vendor-vue-reactivity-CheHbvBM.js";import{a as V,t as N,b as L}from"./vendor-vue-shared-DrzsEcag.js";import"./settingsStore-8bwiLMEn.js";import"./vendor-pinia-BSPefQhS.js";import"./convert-case-to-camel-case.utils-CK5dBN7n.js";const R={class:"slider-min-max"},U={class:"label"},q={class:"label"},G={class:"custom-marks"},H=["onClick"],ee=B({__name:"MultiPoint",props:{field:{},modelValue:{}},emits:["update:modelValue"],setup(S,{emit:h}){const m=S,{field:s}=_(m),{formatMinMax:x}=$(s),j=p(()=>s.value.jump?1:Number(s.value.step||1)),t=p(()=>Number(s.value.min)),i=p(()=>Number(s.value.max)),k=D(m.modelValue),b=p(()=>s.value.jump),r=h,w=e=>{r("update:modelValue",Array.isArray(e)?e:[e])},F=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)}),P=e=>({left:`${(e-t.value)/(i.value-t.value)*100}%`});M(()=>m.modelValue,e=>{k.value=e});const C=e=>{s.value.disabled||b.value&&n.value.includes(e)&&r("update:modelValue",[k.value[0],e])},O=e=>{b.value&&n.value.includes(e)&&r("update:modelValue",[e,k.value[1]])};return M(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",R,[u("div",{class:V(["slider-min-max-item",{first:e.modelValue[0]==t.value}]),onClick:l[0]||(l[0]=a=>O(t.value))},[l[2]||(l[2]=u("span",{class:"tick"},null,-1)),u("span",U,N(o(x)(t.value)),1)],2),u("div",{class:V(["slider-min-max-item",{done:e.modelValue[0]>=i.value}]),onClick:l[1]||(l[1]=a=>C(i.value))},[l[3]||(l[3]=u("span",{class:"tick"},null,-1)),u("span",q,N(o(x)(i.value)),1)],2)]),z(o(J),{style:{margin:"10px 0"},format:F,min:o(s).min,max:o(s).max,step:j.value,disabled:o(s).disabled,modelValue:e.modelValue,"onUpdate:modelValue":w,"show-tooltip":"focus"},null,8,["min","max","step","disabled","modelValue"]),u("div",G,[o(s).scalePoints?(f(!0),v(A,{key:0},E(n.value,a=>(f(),v("div",{key:a,class:"mark",style:L(P(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)):g("",!0),a!==t.value&&a!==i.value?(f(),v("div",{key:1,class:V(["label",{"label-passed":a<=e.modelValue[0]}]),onClick:y=>C(a)},N(a),11,H)):g("",!0)],4))),128)):g("",!0)])],2))}});export{ee as default};
//# sourceMappingURL=MultiPoint-Dn6qekQh.js.map
