import{Q as g}from"./vue-datepicker-DJOolBJW.js";/* empty css             */import{m as _}from"./widget-BUAABBRb.js";import{a as H,k as h,o as P,O as F,m as B,g as C,p as m,n as k,w as D,u as M}from"./convert-case-to-camel-case.utils-DDUpNI96.js";import"./_commonjsHelpers-Cpj98o6Y.js";import"./_commonjs-dynamic-modules-TDtrdbi3.js";import"./translationsStore-DBJu9sBR.js";const U={class:"ccb-range-timePicker"},y={class:"ccb-range-timePicker__from"},N={class:"ccb-range-timePicker__to"},E=H({__name:"RangeTime",props:{format:{type:Boolean},minInterval:{},modelValue:{}},emits:["update:modelValue"],setup(V,{emit:b}){var f,v;const I=_(),r=V,w=b,c=t=>{const e=t.match(/(\d+)h/),s=t.match(/(\d+)m/),n=e?parseInt(e[1])*60:0,i=s?parseInt(s[1]):0;return n+i},o=h(((f=r.modelValue)==null?void 0:f.from)||new Date),a=h(((v=r.modelValue)==null?void 0:v.to)||new Date);P(()=>{if(r.minInterval){const t=o.value instanceof Date?{hours:o.value.getHours(),minutes:o.value.getMinutes(),seconds:0}:o.value;p(t)}});const d=t=>{const[e,s]=t.toLowerCase().split(" "),[n,i]=e.split(":").map(Number);let u=n;return s==="pm"&&n!==12?u=n+12:s==="am"&&n===12&&(u=0),{hours:u,minutes:i,seconds:0}};I.add("updateRangeTimePicker",t=>{o.value=d(t.start),a.value=d(t.end)});const l=t=>{const e=new Date;return e.setHours(t.hours),e.setMinutes(t.minutes),e.setSeconds(t.seconds||0),e},p=t=>{o.value=t;const e=l(t);if(r.minInterval){const s=c(r.minInterval);if("hours"in a.value){const i=l(a.value),u=Math.abs(e.getTime()-i.getTime())/1e3/60;if(s<u)return}const n=new Date(e);n.setMinutes(n.getMinutes()+s),a.value={hours:n.getHours(),minutes:n.getMinutes(),seconds:0}}},T=t=>{a.value=t;const e=l(t);if(r.minInterval){const s=c(r.minInterval);if("hours"in o.value){const i=l(o.value),u=(e.getTime()-i.getTime())/1e3/60;if(s<u)return}const n=new Date(e);n.setMinutes(n.getMinutes()-s),o.value={hours:n.getHours(),minutes:n.getMinutes(),seconds:0}}};return F([o,a],t=>{if(!Array.isArray(t))return;const e=t.map(s=>s instanceof Date?{hours:s.getHours(),minutes:s.getMinutes(),seconds:0}:s);w("update:modelValue",e)}),(t,e)=>(C(),B("div",U,[m("div",y,[k(M(g),{modelValue:o.value,"onUpdate:modelValue":[e[0]||(e[0]=s=>o.value=s),p],"time-picker":"","is-24":t.format,"minutes-grid-increment":"5"},{"input-icon":D(()=>e[2]||(e[2]=[m("i",{class:"ccb-icon-timepicker-light-clock"},null,-1)])),_:1},8,["modelValue","is-24"])]),e[4]||(e[4]=m("div",{class:"ccb-range-timePicker__separator"},[m("span",null,"to")],-1)),m("div",N,[k(M(g),{modelValue:a.value,"onUpdate:modelValue":[e[1]||(e[1]=s=>a.value=s),T],"time-picker":"","is-24":t.format,"minutes-grid-increment":"5"},{"input-icon":D(()=>e[3]||(e[3]=[m("i",{class:"ccb-icon-timepicker-light-clock"},null,-1)])),_:1},8,["modelValue","is-24"])])]))}});export{E as default};
//# sourceMappingURL=RangeTime-BCW7m-3x.js.map
