timepicker-ui 2.6.1 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,75 @@
1
+ var se=(a,e)=>({...e,...a}),re=()=>{let a=document.createElement("div");a.className="timepicker-ui-measure",document.body.appendChild(a);let e=a.getBoundingClientRect().width-a.clientWidth;return document.body.removeChild(a),e},ne=a=>a*(Math.PI/180),G=(a,e)=>{let{touches:t}=a,{clientX:i,clientY:s}=a;if(!e)return;let{left:r,top:o}=e.getBoundingClientRect(),n={x:0,y:0};if(t===void 0)n={x:i-r,y:s-o};else if(t!==void 0&&t.length>0&&Object.keys(t).length>0){let{clientX:c,clientY:u}=t[0];n={x:c-r,y:u-o}}if(!(Object.keys(n).length===0&&n.constructor===Object))return n},he=(a,e)=>Math.round(a/e)*e,p=(a,e)=>a?a.classList.contains(e):!1;var _=(a,e,t,i,s)=>{if(!a)return;let r=new CustomEvent(t,{detail:i,bubbles:!0,cancelable:!0});try{if(a.dispatchEvent(r)&&e!==t){let n=new CustomEvent(e,{detail:i,bubbles:!0,cancelable:!0});a.dispatchEvent(n)}}catch(o){console.warn(`TimepickerUI: Error dispatching event ${t}:`,o)}if(s&&typeof s=="function")try{s(i)}catch(o){console.warn(`TimepickerUI: Error in ${t} callback:`,o)}},oe=()=>/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),z=(a,e,t)=>he(a,e*t),ae=a=>{if(!a)return;let e=JSON.parse(JSON.stringify(a)),t=Object.keys(e);return Object.values(e).reduce((i,s,r)=>(Number(s)?i[t[r]]=Number(s):s==="true"||s==="false"?i[t[r]]=JSON.parse(s):i[t[r]]=s,i),{})},$=(a,e)=>Array.from({length:Number(e)-Number(a)+1},(t,i)=>Number(a)+i),j=(a,e)=>Array.from({length:Number(e)-Number(a)+1},(t,i)=>Number(e)-i).reverse(),D=a=>{a&&typeof a=="function"&&a()},K=(a="")=>{let e=a.replace(/(AM|PM|am|pm)/,r=>` ${r}`),t=new Date(`September 20, 2000 ${e}`),i=t.getHours().toString().padStart(2,"0"),s=t.getMinutes().toString().padStart(2,"0");return`${i}:${s}`},ce=()=>typeof window<"u"&&window.crypto&&typeof window.crypto.randomUUID=="function"?window.crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,a=>{let e=Math.random()*16|0;return(a==="x"?e:e&3|8).toString(16)});var y=(a,e,t,i)=>{let s={hour:"12",minutes:"00",type:e==="24h"?void 0:"PM"};if(!a)return s;let r=a.value.trim();if(!t&&r==="")return s;if(typeof t=="boolean"&&t){let l=new Date,[g,E]=l.toLocaleTimeString().split(":"),h=Number(g)<=9?`0${Number(g)}`:g;if(/[a-z]/i.test(E)&&e==="12h"){let[T,C]=E.split(" ");return{hour:h,minutes:T,type:C}}return{hour:h,minutes:E,type:void 0}}if(typeof t=="object"){let{time:l,locales:g,preventClockType:E}=t,h=l??new Date;if(E&&i){let[M,A]=new Date(h).toLocaleTimeString().split(":");if(/[a-z]/i.test(A)){let[X,de]=A.split(" ");return{hour:M,minutes:X,type:de}}return{hour:Number(M)<=9?`0${Number(M)}`:M,minutes:A,type:void 0}}let[T,C]=new Date(h).toLocaleTimeString(g,{timeStyle:"short"}).split(":"),I=Number(T)<=9?`0${Number(T)}`:T;if(/[a-z]/i.test(C)&&e==="12h"){let[M,A]=C.split(" ");return{hour:I,minutes:M,type:A}}if(e==="12h"){let[M,A]=new Date(`1970-01-01T${T}:${C}Z`).toLocaleTimeString("en-US",{timeZone:"UTC",hour12:!0,hour:"numeric",minute:"numeric"}).split(":"),[te,X]=A.split(" ");return{hour:Number(M)<=9?`0${Number(M)}`:M,minutes:te,type:X}}return{hour:I,minutes:C,type:void 0}}let[o,n]=r.split(" "),[c="",u=""]=o.split(":"),v=c.replace(/\D/g,""),d=u.replace(/\D/g,""),b={hour:v.padStart(2,"0"),minutes:d.padStart(2,"0"),type:e==="12h"?n:void 0};if(v.length>2||d.length>2)return{...b,error:"Invalid input: too many digits.",currentHour:c,currentMin:u};if(/[a-z]/i.test(o))return{...b,error:"Input contains invalid letters."};if(r.includes(" ")&&(!n||r.length>8||n!=="AM"&&n!=="PM"))return{...b,error:"Invalid AM/PM format or length.",currentLength:r.length,currentType:n};let f=Number(v),m=Number(d);if(e==="12h"){if(f<1||f>12||m<0||m>59||n!=="AM"&&n!=="PM")return{...b,error:"Invalid 12h time.",currentHour:f,currentMin:m,currentType:n}}else if(f<0||f>23||m<0||m>59)return{...b,error:"Invalid 24h time.",currentHour:f,currentMin:m};return b},L=(a,e,t)=>{let i=Number(a);if(Number.isNaN(i))return!1;switch(e){case"hour":return t==="24h"?i>=0&&i<=23:i>0&&i<=12;case"minutes":return i>=0&&i<=59;default:return}};var Q={amLabel:"AM",animation:!0,appendModalSelector:"",backdrop:!0,cancelLabel:"CANCEL",editable:!1,enableScrollbar:!1,enableSwitchIcon:!1,mobileTimeLabel:"Enter Time",focusInputAfterCloseModal:!1,hourMobileLabel:"Hour",iconTemplate:'<i class="material-icons timepicker-ui-keyboard-icon">keyboard</i>',iconTemplateMobile:'<i class="material-icons timepicker-ui-keyboard-icon">schedule</i>',incrementHours:1,incrementMinutes:1,minuteMobileLabel:"Minute",mobile:!1,okLabel:"OK",pmLabel:"PM",timeLabel:"Select Time",switchToMinutesAfterSelectHour:!1,theme:"basic",clockType:"12h",disabledTime:void 0,currentTime:void 0,focusTrap:!0,delayHandler:300,inline:void 0,cssClass:void 0};var ee="timepicker-ui",ke="mousedown mouseup mousemove mouseleave mouseover",ve="touchstart touchmove touchend",O=`${ke} ${ve}`,k="active";var Y=(a,e)=>{let t;return(...i)=>{clearTimeout(t),t=setTimeout(()=>{a(...i)},e)}};var Z=["00","13","14","15","16","17","18","19","20","21","22","23"],w=["12","1","2","3","4","5","6","7","8","9","10","11"],x=["00","05","10","15","20","25","30","35","40","45","50","55"],le=(a,e)=>{let{iconTemplate:t,timeLabel:i,amLabel:s,pmLabel:r,cancelLabel:o,okLabel:n,enableSwitchIcon:c,animation:u,clockType:v,editable:d,theme:b}=a;return`
2
+ <div class="timepicker-ui-modal normalize ${b}" role="dialog" data-owner-id="${e}" style='transition:${u?"opacity 0.15s linear":"none"}'>
3
+ <div class="timepicker-ui-wrapper" tabindex="0">
4
+ <div class="timepicker-ui-header">
5
+ <div class="timepicker-ui-select-time">${i}</div>
6
+ <div class="timepicker-ui-wrapper-time ${v==="24h"?"timepicker-ui-wrapper-time-24h":""}">
7
+ <input name="hour" ${d?"":"readonly"} class="timepicker-ui-hour" tabindex="0" type="number" min="0" max="${v==="12h"?"12":"23"}" />
8
+ <div class="timepicker-ui-dots">
9
+ <span></span>
10
+ <span></span>
11
+ </div>
12
+ <input name="minutes" ${d?"":"readonly"} class="timepicker-ui-minutes" tabindex="0" type="number" min="0" max="59" />
13
+ </div>
14
+ ${v!=="24h"?`
15
+ <div class="timepicker-ui-wrapper-type-time">
16
+ <div class="timepicker-ui-type-mode timepicker-ui-am" tabindex="0" role="button" data-type="AM">${s}</div>
17
+ <div class="timepicker-ui-type-mode timepicker-ui-pm" tabindex="0" role="button" data-type="PM">${r}</div>
18
+ </div>
19
+ `:""}
20
+ </div>
21
+ <div class="timepicker-ui-wrapper-landspace">
22
+ <div class="timepicker-ui-body">
23
+ <div class="timepicker-ui-clock-face">
24
+ <div class="timepicker-ui-dot"></div>
25
+ <div class="timepicker-ui-clock-hand">
26
+ <div class="timepicker-ui-circle-hand"></div>
27
+ </div>
28
+ <div class="timepicker-ui-tips-wrapper"></div>
29
+ ${v==="24h"?'<div class="timepicker-ui-tips-wrapper-24h"></div>':""}
30
+ </div>
31
+ </div>
32
+ <div class="timepicker-ui-footer">
33
+ ${c?`
34
+ <div class="timepicker-ui-keyboard-icon-wrapper" tabindex="0" role="button" aria-pressed="false" data-view="desktop">
35
+ ${t}
36
+ </div>`:""}
37
+ <div class="timepicker-ui-wrapper-btn" >
38
+ <div class="timepicker-ui-cancel-btn" tabindex="0" role="button" aria-pressed="false">${o}</div>
39
+ <div class="timepicker-ui-ok-btn" tabindex="0" role="button" aria-pressed="false">${n}</div>
40
+ </div>
41
+ </div>
42
+ </div>
43
+ </div>
44
+ </div>`},me=(a,e)=>{let{mobileTimeLabel:t,amLabel:i,pmLabel:s,cancelLabel:r,okLabel:o,iconTemplateMobile:n,minuteMobileLabel:c,hourMobileLabel:u,enableSwitchIcon:v,animation:d,clockType:b,theme:f}=a;return`
45
+ <div class="timepicker-ui-modal normalize mobile ${f}" role="dialog" data-owner-id="${e}" style='transition:${d?"opacity 0.15s linear":"none"}'>
46
+ <div class="timepicker-ui-wrapper mobile" tabindex="0">
47
+ <div class="timepicker-ui-header mobile">
48
+ <div class="timepicker-ui-select-time mobile">${t}</div>
49
+ <div class="timepicker-ui-wrapper-time mobile">
50
+ <input class="timepicker-ui-hour mobile" tabindex="0" type="number" min="0" max="${b==="12h"?"12":"23"}" />
51
+ <div class="timepicker-ui-hour-text mobile">${u}</div>
52
+ <div class="timepicker-ui-dots mobile">
53
+ <span></span>
54
+ <span></span>
55
+ </div>
56
+ <div class="timepicker-ui-minute-text mobile">${c}</div>
57
+ <input class="timepicker-ui-minutes mobile" tabindex="0" type="number" min="0" max="59" />
58
+ </div>
59
+ ${b!=="24h"?`<div class="timepicker-ui-wrapper-type-time mobile">
60
+ <div class="timepicker-ui-type-mode timepicker-ui-am mobile" data-type="AM" tabindex="0">${i}</div>
61
+ <div class="timepicker-ui-type-mode timepicker-ui-pm mobile" data-type="PM" tabindex="0">${s}</div>
62
+ </div>`:""}
63
+ </div>
64
+ <div class="timepicker-ui-footer mobile" data-view="mobile">
65
+ ${v?`
66
+ <div class="timepicker-ui-keyboard-icon-wrapper mobile" role="button" aria-pressed="false" data-view="desktop" tabindex="0">
67
+ ${n}
68
+ </div>`:""}
69
+ <div class="timepicker-ui-wrapper-btn mobile">
70
+ <div class="timepicker-ui-cancel-btn mobile" role="button" aria-pressed="false" tabindex="0">${r}</div>
71
+ <div class="timepicker-ui-ok-btn mobile" role="button" aria-pressed="false" tabindex="0">${o}</div>
72
+ </div>
73
+ </div>
74
+ </div>
75
+ </div>`};var H=class{array;classToAdd;clockFace;tipsWrapper;theme;clockType;disabledTime;hour;constructor(e){this.array=e?.array,this.classToAdd=e?.classToAdd,this.clockFace=e?.clockFace,this.tipsWrapper=e?.tipsWrapper,this.theme=e?.theme,this.clockType=e?.clockType,this.disabledTime=e?.disabledTime,this.hour=e?.hour}clean=()=>{let e=this.tipsWrapper?.querySelectorAll("span.timepicker-ui-hour-time-12"),t=this.tipsWrapper?.querySelectorAll("span.timepicker-ui-minutes-time");this._removeClasses(e),this._removeClasses(t)};create=()=>{if(!this.clockFace||!this.array||!this.classToAdd||!this.tipsWrapper)return;let e=(this.clockFace.offsetWidth-32)/2,t=(this.clockFace.offsetHeight-32)/2,i=e-9;this.tipsWrapper.innerHTML="",this.array?.forEach((s,r)=>{let o=ne(r*(360/this.array.length)),n=document.createElement("span"),c=document.createElement("span");c.innerHTML=s,this.disabledTime&&(Array.isArray(this.disabledTime)&&this.disabledTime?.includes(s)&&(c.classList.add("timepicker-ui-tips-disabled"),n.classList.add("timepicker-ui-tips-disabled")),this.hour===this.disabledTime.removedStartedHour&&this.disabledTime?.startMinutes?.includes(s)&&(c.classList.add("timepicker-ui-tips-disabled"),n.classList.add("timepicker-ui-tips-disabled"),c.tabIndex=-1),this.hour===this.disabledTime.removedEndHour&&this.disabledTime?.endMinutes?.includes(s)&&(c.classList.add("timepicker-ui-tips-disabled"),n.classList.add("timepicker-ui-tips-disabled"),c.tabIndex=-1)),this.clockType==="24h"?(c.classList.add("timepicker-ui-value-tips-24h"),p(c,"timepicker-ui-tips-disabled")||(c.tabIndex=0)):(c.classList.add("timepicker-ui-value-tips"),p(c,"timepicker-ui-tips-disabled")||(c.tabIndex=0)),n.classList.add(this.classToAdd),this.theme==="crane-straight"&&(n.classList.add("crane-straight"),c.classList.add("crane-straight")),this.theme==="m3"&&(n.classList.add("m3"),c.classList.add("m3")),this.theme==="dark"&&(n.classList.add("dark"),c.classList.add("dark")),this.theme==="glassmorphic"&&(n.classList.add("glassmorphic"),c.classList.add("glassmorphic")),this.theme==="pastel"&&(n.classList.add("pastel"),c.classList.add("pastel")),this.theme==="ai"&&(n.classList.add("ai"),c.classList.add("ai")),this.theme==="cyberpunk"&&(n.classList.add("cyberpunk"),c.classList.add("cyberpunk")),n.style.left=`${e+Math.sin(o)*i-n.offsetWidth}px`,n.style.bottom=`${t+Math.cos(o)*i-n.offsetHeight}px`,n.appendChild(c),this.tipsWrapper?.appendChild(n)})};updateDisable=e=>{let t=this.tipsWrapper?.querySelectorAll("span.timepicker-ui-hour-time-12"),i=this.tipsWrapper?.querySelectorAll("span.timepicker-ui-minutes-time");if(this._removeClasses(t),this._removeClasses(i),e?.hoursToUpdate&&t&&this._addClassesWithIncludes(t,e.hoursToUpdate),e?.minutesToUpdate&&i){let{actualHour:s,removedEndHour:r,removedStartedHour:o,startMinutes:n,endMinutes:c}=e.minutesToUpdate;r===s&&c.length>0?this._addClassesWithIncludes(i,c):Number(s)>Number(o)&&Number(s)<Number(r)&&this._addClasses(i),o===s&&n.length>0?this._addClassesWithIncludes(i,n):Number(s)>Number(o)&&Number(s)<Number(r)&&this._addClasses(i)}if(e){let{amHours:s,pmHours:r,activeMode:o,startMinutes:n,endMinutes:c,removedAmHour:u,removedPmHour:v,actualHour:d}=e.minutesToUpdate;if(!s||!r)return;t&&(s&&o==="AM"&&this._addClassesWithIncludes(t,s),r&&o==="PM"&&this._addClassesWithIncludes(t,r)),i&&n&&c&&(o==="AM"&&(c[0]==="00"&&c.length===1&&n.length===0&&Number(d)>=Number(s[0])&&this._addClasses(i),n.length===0&&c.length>1&&Number(d)>=Number(u)&&this._addClasses(i),n.length>0&&c.length>1&&c[0]==="00"&&(Number(u)===Number(d)?this._addClassesWithIncludes(i,n):Number(d)>Number(u)&&this._addClasses(i)),c[0]==="00"&&c.length===1&&n.length>0&&(Number(u)===Number(d)?this._addClassesWithIncludes(i,n):Number(d)>Number(u)&&this._addClasses(i))),o==="PM"&&(d<Number(v)&&this._addClasses(i),d===v&&this._addClassesWithIncludes(i,c),c.length>0&&Number(d)===v-1&&this._addClassesWithIncludes(i,c)))}};_removeClasses=e=>{e?.forEach(({classList:t,children:i})=>{t.remove("timepicker-ui-tips-disabled"),i[0].classList.remove("timepicker-ui-tips-disabled"),i[0].tabIndex=0})};_addClasses=e=>{e?.forEach(({classList:t,children:i})=>{t.add("timepicker-ui-tips-disabled"),i[0].classList.add("timepicker-ui-tips-disabled"),i[0].tabIndex=-1})};_addClassesWithIncludes=(e,t)=>{e?.forEach(({classList:i,children:s,textContent:r})=>{t?.includes(r)&&(i.add("timepicker-ui-tips-disabled"),s[0].classList.add("timepicker-ui-tips-disabled"),s[0].tabIndex=-1)})}};var pe=a=>{if(!a)return;let{disabledTime:e,clockType:t}=a;if(!e||Object.keys(e).length<=0||e.constructor.name!=="Object")return;let{hours:i,interval:s,minutes:r}=e;if(s){delete e.hours,delete e.minutes;let[o,n]=s.toString().split("-"),{hour:c,minutes:u,type:v}=y({value:o.trimEnd()},t),{hour:d,minutes:b,type:f}=y({value:n.trimEnd().trimStart()},t),m=$(c,d).map(h=>h==="00"||Number(h)===0?`0${Number(h)}`:`${Number(h)}`),l=[],g=Number(u),E=Number(b);if(f===v)return g>0&&E<=0?(l.push(m[0],m[m.length-1]),m=m.slice(1,-1)):E<59&&E>0&&g<=0?(l.push(void 0,m[m.length-1]),m=m.slice(0,-1)):E>0&&g>0?(l.push(m[0],m[m.length-1]),m=m.slice(1,-1)):E===0&&g===0&&(l.push(void 0,m[m.length-1]),m.pop()),{value:{removedStartedHour:Number(l[0])<=9?`0${l[0]}`:l[0],removedEndHour:Number(l[1])<=9?`0${l[1]}`:l[1],rangeArrHour:m,isInterval:!0,startMinutes:$(u,59).map(h=>Number(h)<=9?`0${h}`:`${h}`),endMinutes:j(0,b).map(h=>Number(h)<=9?`0${h}`:`${h}`),endType:f,startType:v}};{let h=$(c,12).map(String),T=j(1,d).map(String),C=[],I=[];return g>0&&E<=0?(C.push(T[T.length-1]),I.push(h[0]),T.splice(-1,1),h.splice(0,1)):E<59&&E>0&&g<=0?(I.push(h[0]),C.push(T[T.length-1]),T.splice(-1,1)):E>0&&g>0?(C.push(T[T.length-1]),I.push(h[0]),T.splice(-1,1),h.splice(0,1)):E===0&&g===0&&(C.push(T[T.length-1]),I.push(h[0]),T.pop()),{value:{isInterval:!0,endType:f,startType:v,pmHours:T,amHours:h,startMinutes:Number(u)===0?[]:$(u,59).map(M=>Number(M)<=9?`0${M}`:`${M}`),endMinutes:j(0,b).map(M=>Number(M)<=9?`0${M}`:`${M}`),removedAmHour:Number(I[0])<=9?`0${I[0]}`:I[0],removedPmHour:Number(C[0])<=9?`0${C[0]}`:C[0]}}}}else return i?.forEach(o=>{if(t==="12h"&&Number(o)>12)throw new Error("The disabled hours value has to be less than 13");if(t==="24h"&&Number(o)>23)throw new Error("The disabled hours value has to be less than 24")}),r?.forEach(o=>{if(Number(o)>59)throw new Error("The disabled minutes value has to be less than 60")}),{value:{hours:i?.map(o=>o==="00"||Number(o)===0?`0${Number(o)}`:`${Number(o)}`),minutes:r?.map(o=>Number(o)<=9?`0${o}`:`${o}`)}}},N=(a,e,t,i)=>{if(a){if(Array.isArray(a)&&a.length>0)return!a.map(r=>L(r,e,t)).some(r=>r===!1);if(typeof a=="string"||typeof a=="number"){let s=L(a,e,t),r=i?.map(Number).includes(Number(a));return!!(s&&!r)}}},ue=(a,e,t,i)=>{let s=t?K(`${a}:${e} ${t}`.trim()):`${a}:${e}`.trim(),r,o;if(t){let[n,c]=i.trim().split("-").map(u=>u.trim());r=K(n),o=K(c)}else{let[n,c]=i.trim().split("-"),u=v=>v.trim().split(":").map(d=>Number(d)<=9?`0${Number(d)}`:d).join(":");r=u(n),o=u(c)}return s<r||s>o};var U=class{timepicker;constructor(e){this.timepicker=e}handleOpenOnClick=()=>{this.timepicker.openElement.forEach(e=>e?.addEventListener("click",()=>this.timepicker._eventsBundle()))};handleOpenOnEnterFocus=()=>{this.timepicker.input.addEventListener("keydown",({target:e,key:t})=>{e.disabled||t==="Enter"&&this.timepicker.open()})};handleCancelButton=()=>{this.timepicker.cancelButton.addEventListener("click",()=>{let e=y(this.timepicker.input,this.timepicker._options.clockType);_(this.timepicker._element,"cancel","timepicker:cancel",{...e,hourNotAccepted:this.timepicker.hour.value,minutesNotAccepted:this.timepicker.minutes.value,type:this.timepicker.activeTypeMode?.dataset.type,degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes},this.timepicker._options.onCancel),this.timepicker.close()()})};handleOkButton=()=>{this.timepicker.okButton?.addEventListener("click",()=>{let{clockType:e,disabledTime:t}=this.timepicker._options,i=L(this.timepicker.hour.value,"hour",e),s=L(this.timepicker.minutes.value,"minutes",e),r,o=N(this.timepicker.hour.value,"hour",e,t?.hours),n=N(this.timepicker.minutes.value,"minutes",e,t?.minutes);if(t?.interval&&(r=ue(this.timepicker.hour.value,this.timepicker.minutes.value,this.timepicker.activeTypeMode?.textContent,t.interval)),r===!1||i===!1||s===!1||o===!1||n===!1){(r===!1||!s||!n)&&this.timepicker.minutes.classList.add("invalid-value"),(r===!1||!i||!o)&&this.timepicker.hour.classList.add("invalid-value");return}this.timepicker.input.value=`${this.timepicker.hour.value}:${this.timepicker.minutes.value} ${this.timepicker._options.clockType==="24h"?"":this.timepicker.activeTypeMode?.dataset.type}`.trimEnd(),_(this.timepicker._element,"accept","timepicker:confirm",{hour:this.timepicker.hour.value,minutes:this.timepicker.minutes.value,type:this.timepicker.activeTypeMode?.dataset.type,degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes},this.timepicker._options.onConfirm),this.timepicker.close()()})};handleBackdropClick=()=>{this.timepicker.modalElement?.addEventListener("click",e=>{let t=e.target;if(!p(t,"timepicker-ui-modal"))return;let i=y(this.timepicker.input,this.timepicker._options.clockType);_(this.timepicker._element,"cancel","timepicker:cancel",{...i,hourNotAccepted:this.timepicker.hour.value,minutesNotAccepted:this.timepicker.minutes.value,type:this.timepicker.activeTypeMode?.dataset.type,degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes},this.timepicker._options.onCancel),this.timepicker.close()()})};getDestructuringObj(e){let{endMinutes:t,removedEndHour:i,removedStartedHour:s,startMinutes:r,pmHours:o,amHours:n,removedAmHour:c,removedPmHour:u}=this.timepicker._disabledTime.value;return e?{minutesToUpdate:{actualHour:this.timepicker.hour.value,pmHours:o,amHours:n,activeMode:this.timepicker.activeTypeMode?.textContent,startMinutes:r,endMinutes:t,removedAmHour:c,removedPmHour:u}}:{minutesToUpdate:{endMinutes:t,removedEndHour:i,removedStartedHour:s,actualHour:this.timepicker.hour.value,startMinutes:r}}}handleAmClick=()=>{this.timepicker._clickTouchEvents.forEach(e=>{this.timepicker.AM.addEventListener(e,t=>{if(t.target.classList.add(k),this.timepicker.PM.classList.remove(k),this.timepicker._options.clockType==="12h"&&this.timepicker._options.disabledTime?.interval){let s=new H({clockFace:this.timepicker.clockFace,tipsWrapper:this.timepicker.tipsWrapper,array:p(this.timepicker.hour,k)?w:x});this.timepicker._disabledTime?.value.startType===this.timepicker._disabledTime?.value.endType?setTimeout(()=>{this.timepicker._disabledTime?.value.startType===this.timepicker.activeTypeMode?.textContent?s.updateDisable({hoursToUpdate:this.timepicker._disabledTime?.value?.rangeArrHour,...this.getDestructuringObj()}):s.clean()},300):setTimeout(()=>{s.updateDisable({...this.getDestructuringObj(!0)})},300),s.updateDisable()}_(this.timepicker._element,"selectamtypemode","timepicker:select-am",{hour:this.timepicker.hour.value,minutes:this.timepicker.minutes.value,type:this.timepicker.activeTypeMode?.dataset.type,degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes},this.timepicker._options.onSelectAM)})})};handlePmClick=()=>{this.timepicker._clickTouchEvents.forEach(e=>{this.timepicker.PM.addEventListener(e,t=>{if(t.target.classList.add(k),this.timepicker.AM.classList.remove(k),this.timepicker._options.clockType==="12h"&&this.timepicker._options.disabledTime?.interval){let s=new H({clockFace:this.timepicker.clockFace,tipsWrapper:this.timepicker.tipsWrapper,array:p(this.timepicker.hour,k)?w:x});this.timepicker._disabledTime?.value.startType===this.timepicker._disabledTime?.value.endType?setTimeout(()=>{this.timepicker._disabledTime?.value.startType===this.timepicker.activeTypeMode?.textContent?s.updateDisable({hoursToUpdate:this.timepicker._disabledTime?.value?.rangeArrHour,...this.getDestructuringObj()}):s.clean()},300):setTimeout(()=>{s.updateDisable({...this.getDestructuringObj(!0)})},300)}_(this.timepicker._element,"selectpmtypemode","timepicker:select-pm",{hour:this.timepicker.hour.value,minutes:this.timepicker.minutes.value,type:this.timepicker.activeTypeMode?.dataset.type,degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes},this.timepicker._options.onSelectPM)})})};handleClasses24h=(e,t)=>{let i=e.target;this.timepicker.hourTips&&this.timepicker._options.clockType==="24h"&&(Number(i.textContent)>12||Number(i.textContent)===0?this.timepicker.clockManager.setCircleClockClasses24h():this.timepicker.clockManager.removeCircleClockClasses24h(),this.timepicker._options.mobile||this.timepicker.tipsWrapperFor24h?.classList.remove("timepicker-ui-tips-wrapper-24h-disabled")),!(!i||!t)&&(t.value=i.value.replace(/\D+/g,""),t.click())};handleHourEvents=()=>{this.timepicker._inputEvents.forEach(e=>{this.timepicker.hour?.addEventListener(e,t=>{let i=t.target;if(this.timepicker.clockFace!==null&&this.timepicker.animationManager.handleAnimationSwitchTipsMode(),this.timepicker._options.clockType==="24h"&&this.timepicker.clockFace!==null&&(Number(this.timepicker.hour.value)>12||this.timepicker.hour.value==="00"?this.timepicker.clockManager.setCircleClockClasses24h():this.timepicker.clockManager.removeCircleClockClasses24h(),this.timepicker._options.mobile||this.timepicker.tipsWrapperFor24h?.classList.remove("timepicker-ui-tips-wrapper-24h-disabled")),this.timepicker.clockManager.setHoursToClock(i.value),this.timepicker.minutes.classList.remove(k),this.timepicker.hour.classList.add(k),this.timepicker._options.clockType==="12h"&&this.timepicker._options.disabledTime?.interval){let s=new H({clockFace:this.timepicker.clockFace,tipsWrapper:this.timepicker.tipsWrapper,array:p(this.timepicker.hour,k)?w:x});this.timepicker._disabledTime?.value.startType===this.timepicker._disabledTime?.value.endType?setTimeout(()=>{this.timepicker._disabledTime?.value.startType===this.timepicker.activeTypeMode?.textContent?s.updateDisable({hoursToUpdate:this.timepicker._disabledTime?.value?.rangeArrHour,...this.getDestructuringObj()}):s.clean()},300):setTimeout(()=>{s.updateDisable({...this.getDestructuringObj(!0)})},300)}_(this.timepicker._element,"selecthourmode","timepicker:select-hour",{hour:this.timepicker.hour.value,minutes:this.timepicker.minutes.value,type:this.timepicker.activeTypeMode?.dataset.type,degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes},this.timepicker._options.onSelectHour),this.timepicker.clockFace!==null&&this.timepicker.circle.classList.remove("small-circle")})}),this.timepicker.hour?.addEventListener("blur",e=>this.handleClasses24h(e,this.timepicker.hour)),this.timepicker.hour?.addEventListener("focus",e=>this.handleClasses24h(e,this.timepicker.hour))};handleMinutesEvents=()=>{this.timepicker._inputEvents.forEach(e=>{this.timepicker.minutes.addEventListener(e,t=>{let i=t.target;if(this.timepicker.clockFace!==null&&(this.timepicker.animationManager.handleAnimationSwitchTipsMode(),this.timepicker.clockManager.setMinutesToClock(i.value)),this.timepicker._options.clockType==="24h"&&(this.timepicker.clockManager.removeCircleClockClasses24h(),this.timepicker._options.mobile||this.timepicker.tipsWrapperFor24h?.classList.add("timepicker-ui-tips-wrapper-24h-disabled")),this.timepicker.hour.classList.remove(k),this.timepicker.minutes.classList.add(k),this.timepicker._options.clockType==="12h"&&this.timepicker._options.disabledTime?.interval){let s=new H({clockFace:this.timepicker.clockFace,tipsWrapper:this.timepicker.tipsWrapper,array:p(this.timepicker.hour,k)?w:x});this.timepicker._disabledTime?.value.startType===this.timepicker._disabledTime?.value.endType?setTimeout(()=>{this.timepicker._disabledTime?.value.startType===this.timepicker.activeTypeMode?.textContent?s.updateDisable({hoursToUpdate:this.timepicker._disabledTime?.value?.rangeArrHour,...this.getDestructuringObj()}):s.clean()},300):setTimeout(()=>{s.updateDisable({...this.getDestructuringObj(!0)})},300)}_(this.timepicker._element,"selectminutemode","timepicker:select-minute",{hour:this.timepicker.hour.value,minutes:this.timepicker.minutes.value,type:this.timepicker.activeTypeMode?.dataset.type,degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes},this.timepicker._options.onSelectMinute)})}),this.timepicker.minutes?.addEventListener("blur",e=>this.handleClasses24h(e,this.timepicker.minutes)),this.timepicker.minutes?.addEventListener("focus",e=>this.handleClasses24h(e,this.timepicker.minutes))};handleEventToMoveHand=e=>{let{target:t,type:i,touches:s}=e,r=t,{incrementMinutes:o,incrementHours:n,switchToMinutesAfterSelectHour:c}=this.timepicker._options;if(!G(e,this.timepicker.clockFace))return;let u=G(e,this.timepicker.clockFace),v=this.timepicker.clockFace.offsetWidth/2,d=u&&Math.atan2(u.y-v,u.x-v);if(i==="mouseup"||i==="touchend"){this.timepicker._isTouchMouseMove=!1,c&&(p(r,"timepicker-ui-value-tips")||p(r,"timepicker-ui-value-tips-24h")||p(r,"timepicker-ui-tips-wrapper"))&&this.timepicker.minutes.click();return}if((i==="mousedown"||i==="mousemove"||i==="touchmove"||i==="touchstart")&&(i==="mousedown"||i==="touchstart"||i==="touchmove")&&((p(r,"timepicker-ui-clock-face")||p(r,"timepicker-ui-circle-hand")||p(r,"timepicker-ui-hour-time-12")||p(r,"timepicker-ui-minutes-time")||p(r,"timepicker-ui-clock-hand")||p(r,"timepicker-ui-value-tips")||p(r,"timepicker-ui-value-tips-24h")||p(r,"timepicker-ui-tips-wrapper")||p(r,"timepicker-ui-tips-wrapper-24h"))&&!p(r,"timepicker-ui-tips-disabled")?(e.preventDefault(),this.timepicker._isTouchMouseMove=!0):this.timepicker._isTouchMouseMove=!1),!this.timepicker._isTouchMouseMove)return;if(this.timepicker.minutesTips!==null){this.timepicker.minutes.classList.add(k);let m=d&&z(Math.trunc(d*180/Math.PI)+90,o,6);if(m===void 0)return;let l;if(m<0?(l=Math.round(360+m/6)%60,m=360+Math.round(m/6)*6):(l=Math.round(m/6)%60,m=Math.round(m/6)*6),this.timepicker._disabledTime?.value.isInterval){if(this.timepicker._disabledTime?.value.endType===this.timepicker._disabledTime?.value.startType){if(this.timepicker._disabledTime?.value?.endMinutes?.includes(l<=9?`0${l}`:`${l}`)&&this.timepicker.hour.value===this.timepicker._disabledTime?.value?.removedEndHour&&this.timepicker._disabledTime?.value.endType===this.timepicker.activeTypeMode?.textContent||this.timepicker._disabledTime?.value?.startMinutes?.includes(l<=9?`0${l}`:`${l}`)&&this.timepicker.hour.value===this.timepicker._disabledTime?.value?.removedStartedHour&&this.timepicker._disabledTime?.value.startType===this.timepicker.activeTypeMode?.textContent)return}else if(this.timepicker.activeTypeMode?.textContent===this.timepicker._disabledTime?.value.endType&&(this.timepicker._disabledTime?.value?.endMinutes?.includes(l<=9?`0${l}`:`${l}`)&&this.timepicker._disabledTime?.value.removedPmHour===this.timepicker.hour.value||this.timepicker._disabledTime?.value.pmHours.map(Number).includes(Number(this.timepicker.hour.value)))||this.timepicker.activeTypeMode?.textContent===this.timepicker._disabledTime?.value.startType&&(this.timepicker._disabledTime?.value?.startMinutes?.includes(l<=9?`0${l}`:`${l}`)&&this.timepicker._disabledTime?.value.removedAmHour===this.timepicker.hour.value||this.timepicker._disabledTime?.value.amHours.map(Number).includes(Number(this.timepicker.hour.value))))return}else if(this.timepicker._disabledTime?.value?.minutes?.includes(l<=9?`0${l}`:`${l}`))return;this.timepicker.minutes.value=l>=10?`${l}`:`0${l}`,this.timepicker.clockHand.style.transform=`rotateZ(${m}deg)`,this.timepicker._degreesMinutes=m,this.timepicker.clockManager.toggleClassActiveToValueTips(this.timepicker.minutes.value),this.timepicker.clockManager.removeBgColorToCirleWithMinutesTips(),this.timepicker.clockManager.setBgColorToCircleWithMinutesTips(),_(this.timepicker._element,"update","timepicker:update",{...y(this.timepicker.input,this.timepicker._options.clockType),degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes,eventType:i,type:this.timepicker.activeTypeMode?.dataset.type},this.timepicker._options.onUpdate)}let b=s?s[0]:void 0,f=s&&b?document.elementFromPoint(b.clientX,b.clientY):null;if(this.timepicker.hourTips!==null){if(this.timepicker.hour?.classList.add(k),!p(f||r,"timepicker-ui-value-tips-24h")&&!p(f||r,"timepicker-ui-tips-disabled")&&(p(f||r,"timepicker-ui-value-tips")||p(f||r,"timepicker-ui-tips-wrapper"))){let m=d&&z(Math.trunc(d*180/Math.PI)+90,n,30);if(this.timepicker._degreesHours=m,m===void 0)return;let l;m<0?(l=Math.round(360+m/30)%12,m=360+m):(l=Math.round(m/30)%12,(l===0||l>12)&&(l=12));let g=this.timepicker._disabledTime?.value.isInterval?"rangeArrHour":"hours";if(this.timepicker._disabledTime?.value.endType===this.timepicker._disabledTime?.value?.startType){if(typeof this.timepicker._disabledTime?.value?.endType=="string"){if(this.timepicker._disabledTime?.value?.endType===this.timepicker.activeTypeMode?.textContent&&this.timepicker._disabledTime?.value?.startType===this.timepicker.activeTypeMode?.textContent&&this.timepicker._disabledTime?.value[g]?.includes(l.toString()))return}else if(this.timepicker._disabledTime?.value[g]?.includes(l.toString()))return}else if(this.timepicker._disabledTime?.value.startType===this.timepicker.activeTypeMode?.textContent&&this.timepicker._disabledTime?.value.amHours.includes(l.toString())||this.timepicker._disabledTime?.value.endType===this.timepicker.activeTypeMode?.textContent&&this.timepicker._disabledTime?.value.pmHours.includes(l.toString()))return;this.timepicker.clockHand.style.transform=`rotateZ(${m}deg)`,this.timepicker.hour.value=l>9?`${l}`:`0${l}`,this.timepicker.clockManager.removeCircleClockClasses24h(),this.timepicker.clockManager.toggleClassActiveToValueTips(l)}if((p(f||r,"timepicker-ui-value-tips-24h")||p(f||r,"timepicker-ui-tips-wrapper-24h"))&&!p(f||r,"timepicker-ui-tips-disabled")){let m=d&&z(Math.trunc(d*180/Math.PI)+90,n,30);this.timepicker._degreesHours=m;let l;if(m===void 0)return;m<0?(l=Math.round(360+m/30)%24,m=360+m):(l=Math.round(m/30)+12,l===12&&(l="00"));let g=this.timepicker._disabledTime?.value.isInterval?"rangeArrHour":"hours";if(this.timepicker._disabledTime?.value[g]?.includes(l.toString()))return;this.timepicker.clockManager.setCircleClockClasses24h(),this.timepicker.clockHand.style.transform=`rotateZ(${m}deg)`,this.timepicker.hour.value=`${l}`,this.timepicker.clockManager.toggleClassActiveToValueTips(l)}_(this.timepicker._element,"update","timepicker:update",{...y(this.timepicker.input,this.timepicker._options.clockType),degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes,eventType:i,type:this.timepicker.activeTypeMode?.dataset.type},this.timepicker._options.onUpdate)}};handleMoveHand=()=>{this.timepicker._options.mobile||this.timepicker._isMobileView||O.split(" ").forEach(e=>{e==="touchstart"||e==="touchmove"||e==="touchend"?document.addEventListener(e,this.timepicker._mutliEventsMoveHandler,{passive:!1}):document.addEventListener(e,this.timepicker._mutliEventsMoveHandler,!1)})};handleClickOnHourMobile=()=>{document.addEventListener("mousedown",this.timepicker._eventsClickMobileHandler),document.addEventListener("touchstart",this.timepicker._eventsClickMobileHandler)};handlerClickHourMinutes=async e=>{if(!this.timepicker.modalElement)return;let{clockType:t,editable:i}=this.timepicker._options,s=e.target,r=L(this.timepicker.hour.value,"hour",t),o=L(this.timepicker.minutes.value,"minutes",t);i&&(!p(s,"timepicker-ui-hour")&&!p(s,"timepicker-ui-minutes")?r===!0&&o===!0&&(o&&this.timepicker.minutes.classList.remove("invalid-value"),r&&this.timepicker.hour?.classList.remove("invalid-value")):(r===!1||o===!1)&&(o||this.timepicker.minutes.classList.add("invalid-value"),r||this.timepicker.hour?.classList.add("invalid-value")))};handleIconChangeView=async()=>{this.timepicker._options.enableSwitchIcon&&(oe()?this.timepicker.keyboardClockIcon.addEventListener("touchstart",this.timepicker.configManager.handlerViewChange()):this.timepicker.keyboardClockIcon.addEventListener("click",this.timepicker.configManager.handlerViewChange()))};handleKeyPress=e=>{if(e.key==="Escape"&&this.timepicker.modalElement){let t=y(this.timepicker.input,this.timepicker._options.clockType);_(this.timepicker._element,"cancel","timepicker:cancel",{...t,hourNotAccepted:this.timepicker.hour.value,minutesNotAccepted:this.timepicker.minutes.value,type:this.timepicker.activeTypeMode?.dataset.type,degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes},this.timepicker._options.onCancel),this.timepicker.close()()}};handleEscClick=()=>{document.addEventListener("keydown",this.handleKeyPress)};focusTrapHandler=()=>{setTimeout(()=>{let e=this.timepicker.wrapper?.querySelectorAll('div[tabindex="0"]:not([disabled])'),t=this.timepicker.wrapper?.querySelectorAll('input[tabindex="0"]:not([disabled])');if(!e||e.length<=0||t.length<=0)return;let i=[...t,...e],s=i[0],r=i[i.length-1];this.timepicker.wrapper.focus(),this.timepicker.wrapper.addEventListener("keydown",({key:o,shiftKey:n,target:c})=>{let u=c;o==="Tab"&&(n?document.activeElement===s&&r.focus():document.activeElement===r&&s.focus()),o==="Enter"&&(p(u,"timepicker-ui-minutes")&&this.timepicker.minutes.click(),p(u,"timepicker-ui-hour")&&this.timepicker.hour.click(),p(u,"timepicker-ui-am")&&this.timepicker.AM.click(),p(u,"timepicker-ui-pm")&&this.timepicker.PM.click(),p(u,"timepicker-ui-ok-btn")&&this.timepicker.okButton.click(),p(u,"timepicker-ui-cancel-btn")&&this.timepicker.cancelButton.click(),p(u,"timepicker-ui-keyboard-icon-wrapper")&&this.timepicker.keyboardClockIcon.click())})},100)};handleInlineAutoUpdate=()=>{if(!this.timepicker._options.inline?.enabled||this.timepicker._options.inline.autoUpdate===!1)return;let e=()=>{let i=this.timepicker.hour?.value,s=this.timepicker.minutes?.value,r=this.timepicker.activeTypeMode?.textContent;if(i&&s){let o="";if(this.timepicker._options.clockType==="24h"){let n=i.padStart(2,"0"),c=s.padStart(2,"0");o=`${n}:${c}`}else{let n=i,c=s.padStart(2,"0");o=`${n}:${c} ${r||"AM"}`}if(this.timepicker.input){this.timepicker.input.value=o;let n=new Event("change",{bubbles:!0});this.timepicker.input.dispatchEvent(n),_(this.timepicker._element,"accept","timepicker:confirm",{hour:i,minutes:s,type:r,degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes},this.timepicker._options.onConfirm)}}};["input","change"].forEach(i=>{this.timepicker.hour?.addEventListener(i,()=>{setTimeout(e,50)}),this.timepicker.minutes?.addEventListener(i,()=>{setTimeout(e,50)})}),this.timepicker._options.clockType!=="24h"&&this.timepicker._clickTouchEvents.forEach(i=>{this.timepicker.AM?.addEventListener(i,()=>{setTimeout(e,50)}),this.timepicker.PM?.addEventListener(i,()=>{setTimeout(e,50)})}),this.timepicker.clockFace?.addEventListener("click",()=>{setTimeout(e,100)})}};var F=class{timepicker;constructor(e){this.timepicker=e}setModalTemplate=()=>{if(!this.timepicker._options)return;if(this.timepicker._options.inline?.enabled){let t=document.getElementById(this.timepicker._options.inline.containerId);if(t){t.innerHTML="",t.insertAdjacentHTML("beforeend",this.timepicker.modalTemplate);let i=t.querySelector(".timepicker-ui-modal");if(i&&(i.classList.add("timepicker-ui--inline"),this.timepicker._options.inline.showButtons===!1||this.timepicker._options.inline.showButtons===void 0)){let s=i.querySelector(".timepicker-ui-wrapper-btn");s&&(s.style.display="none");let r=i.querySelector(".timepicker-ui-wrapper-btn.mobile");r&&(r.style.display="none")}}return}let{appendModalSelector:e}=this.timepicker._options;e===""||!e?document.body.insertAdjacentHTML("afterend",this.timepicker.modalTemplate):document?.querySelector(e)?.insertAdjacentHTML("beforeend",this.timepicker.modalTemplate)};setScrollbarOrNot=()=>{this.timepicker._options.inline?.enabled||(this.timepicker._options.enableScrollbar?setTimeout(()=>{document.body.style.overflowY="",document.body.style.paddingRight=""},400):(document.body.style.paddingRight=`${re()}px`,document.body.style.overflowY="hidden"))};removeBackdrop=()=>{this.timepicker._options.inline?.enabled||this.timepicker._options.backdrop||(this.timepicker.modalElement?.classList.add("removed"),this.timepicker.openElement.forEach(e=>e?.classList.add("disabled")))};setNormalizeClass=()=>{let e=this.timepicker.modalElement?.querySelectorAll("div");this.timepicker.modalElement?.classList.add("timepicker-ui-normalize"),e?.forEach(t=>t.classList.add("timepicker-ui-normalize"))};setShowClassToBackdrop=()=>{if(this.timepicker._options.inline?.enabled){this.timepicker.modalElement?.classList.add("show");return}this.timepicker._options.backdrop&&setTimeout(()=>{this.timepicker.modalElement.classList.add("show")},300)};setFlexEndToFooterIfNoKeyboardIcon=()=>{!this.timepicker._options.enableSwitchIcon&&this.timepicker.footer&&(this.timepicker.footer.style.justifyContent="flex-end")}};var W=class{timepicker;constructor(e){this.timepicker=e}setAnimationToOpen(){this.timepicker.modalElement?.classList.add("opacity"),this.timepicker._options.animation?setTimeout(()=>{this.timepicker.modalElement?.classList.add("show")},150):this.timepicker.modalElement?.classList.add("show")}removeAnimationToClose(){this.timepicker.modalElement&&(this.timepicker._options.animation?setTimeout(()=>{this.timepicker.modalElement?.classList.remove("show")},150):this.timepicker.modalElement?.classList.remove("show"))}handleAnimationClock(){this.timepicker._options.animation&&setTimeout(()=>{this.timepicker.clockFace?.classList.add("timepicker-ui-clock-animation"),setTimeout(()=>{this.timepicker.clockFace?.classList.remove("timepicker-ui-clock-animation")},600)},150)}handleAnimationSwitchTipsMode(){this.timepicker.clockHand.classList.add("timepicker-ui-tips-animation"),setTimeout(()=>{this.timepicker.clockHand?.classList.remove("timepicker-ui-tips-animation")},401)}};var V={cranepurple800:"#5c1349",cranepurple900:"#4e0d3a",cranepurple700:"#71135c",cranered400:"#f7363e",white:"#fff",purple:"#6200ee",redtovalid:"#d50000"},ie={"crane-straight":["crane-straight"],"crane-radius":["crane-straight","radius"],m3:["m3"],dark:["dark"],glassmorphic:["glassmorphic"],pastel:["pastel"],ai:["ai"],cyberpunk:["cyberpunk"]};var P=class{timepicker;constructor(e){this.timepicker=e}removeCircleClockClasses24h(){this.timepicker.circle?.classList.remove("timepicker-ui-circle-hand-24h"),this.timepicker.clockHand?.classList.remove("timepicker-ui-clock-hand-24h")}setCircleClockClasses24h(){this.timepicker.circle&&this.timepicker.circle?.classList.add("timepicker-ui-circle-hand-24h"),this.timepicker.clockHand&&this.timepicker.clockHand?.classList.add("timepicker-ui-clock-hand-24h")}setOnStartCSSClassesIfClockType24h(){if(this.timepicker._options.clockType==="24h"){let{hour:e}=this.timepicker.configManager.getInputValue(this.timepicker.input,this.timepicker._options.clockType,this.timepicker._options.currentTime);this.timepicker.input.value.length>0&&(e=this.timepicker.input.value.split(":")[0]),(Number(e)>12||Number(e)===0)&&this.setCircleClockClasses24h()}}setBgColorToCirleWithHourTips=()=>{if(!this.timepicker._options)return;let{mobile:e,theme:t}=this.timepicker._options;e||this.timepicker.circle===null||(t==="crane-straight"||t==="crane-radius"?this.timepicker.circle.style.backgroundColor=V.cranered400:this.timepicker.circle.style.backgroundColor=V.purple)};setBgColorToCircleWithMinutesTips=()=>{let{theme:e}=this.timepicker._options;this.timepicker.minutes.value&&x.includes(this.timepicker.minutes.value)&&(e==="crane-straight"||e==="crane-radius"?this.timepicker.circle.style.backgroundColor=V.cranered400:this.timepicker.circle.style.backgroundColor=V.purple,this.timepicker.circle.classList.remove("small-circle"))};removeBgColorToCirleWithMinutesTips=()=>{this.timepicker.minutes.value&&x.includes(this.timepicker.minutes.value)||(this.timepicker.circle.style.backgroundColor="",this.timepicker.circle.classList.add("small-circle"))};setClassActiveToHourOnOpen=()=>{this.timepicker._options.mobile||this.timepicker._isMobileView||this.timepicker.hour?.classList.add(k)};setMinutesToClock=e=>{this.timepicker.clockFace!==null&&this.setTransformToCircleWithSwitchesMinutes(e),this.removeBgColorToCirleWithMinutesTips();let t=this.timepicker._disabledTime?.value?.minutes?this.timepicker._disabledTime?.value?.minutes:this.timepicker._disabledTime?.value,i=new H({array:x,classToAdd:"timepicker-ui-minutes-time",clockFace:this.timepicker.clockFace,tipsWrapper:this.timepicker.tipsWrapper,theme:this.timepicker._options.theme,disabledTime:t,hour:this.timepicker.hour.value,clockType:this.timepicker._options.clockType});i.create(),this.timepicker._options.clockType==="12h"&&i.updateDisable(),this.toggleClassActiveToValueTips(e),this.timepicker._options.clockType==="24h"&&(this.timepicker.tipsWrapperFor24h.innerHTML="")};setHoursToClock=e=>{if(this.timepicker.clockFace!==null){this.setTransformToCircleWithSwitchesHour(e),this.setBgColorToCirleWithHourTips();let t=this.timepicker._disabledTime?.value?.isInterval?this.timepicker._disabledTime?.value.rangeArrHour:this.timepicker._disabledTime?.value?.hours,i=new H({array:w,classToAdd:"timepicker-ui-hour-time-12",clockFace:this.timepicker.clockFace,tipsWrapper:this.timepicker.tipsWrapper,theme:this.timepicker._options.theme,disabledTime:t,clockType:"12h",hour:this.timepicker.hour.value});i.create(),this.timepicker._options.clockType==="24h"?new H({array:Z,classToAdd:"timepicker-ui-hour-time-24",clockFace:this.timepicker.tipsWrapperFor24h,tipsWrapper:this.timepicker.tipsWrapperFor24h,theme:this.timepicker._options.theme,clockType:"24h",disabledTime:t,hour:this.timepicker.hour.value}).create():i.updateDisable(),this.toggleClassActiveToValueTips(e)}};setTransformToCircleWithSwitchesHour=e=>{if(!this.timepicker.clockHand)return;let t=Number(e),i=t>12?t*30-360:t*30;i===360&&(i=0),!(i>360)&&(this.timepicker.clockHand.style.transform=`rotateZ(${i}deg)`)};setTransformToCircleWithSwitchesMinutes=e=>{if(!this.timepicker.clockHand)return;let t=Number(e)*6;t>360||(this.timepicker.clockHand.style.transform=`rotateZ(${t}deg)`)};toggleClassActiveToValueTips=e=>{let t=this.timepicker.allValueTips.find(i=>Number(i.innerText)===Number(e));this.timepicker.allValueTips.map(i=>i.classList.remove(k)),t!==void 0&&t.classList.add(k)}};var B=class{timepicker;constructor(e){this.timepicker=e}setErrorHandler(){let{error:e,currentHour:t,currentMin:i,currentType:s,currentLength:r}=y(this.timepicker.input,this.timepicker._options.clockType);if(e){let o=document.createElement("div");throw this.timepicker.input?.classList.add("timepicker-ui-invalid-format"),o.classList.add("timepicker-ui-invalid-text"),o.innerHTML="<b>Invalid Time Format</b>",this.timepicker.input?.parentElement&&this.timepicker.input?.parentElement.querySelector(".timepicker-ui-invalid-text")===null&&this.timepicker.input?.after(o),_(this.timepicker._element,"geterror","timepicker:error",{error:e,currentHour:t,currentMin:i,currentType:s,currentLength:r},this.timepicker._options.onError),new Error(`Invalid Time Format: ${e}`)}}removeErrorHandler(){this.timepicker.input?.classList.remove("timepicker-ui-invalid-format");let e=this.timepicker._element?.querySelector(".timepicker-ui-invalid-text");e&&e.remove()}checkDisabledValuesOnStart(){if(!this.timepicker._options.disabledTime||this.timepicker._options.disabledTime.interval)return;let{disabledTime:{hours:e,minutes:t},clockType:i}=this.timepicker._options,s=e?N(e,"hour",i):!0,r=t?N(t,"minutes",i):!0;if(!s||!r)throw new Error("You set wrong hours or minutes in disabled option")}};var q=class{timepicker;constructor(e){this.timepicker=e}setTheme=()=>{let e=[...this.timepicker.modalElement?.querySelectorAll("input")??[],...this.timepicker.modalElement?.querySelectorAll("div")??[]],{theme:t}=this.timepicker._options??{};t&&ie[t]&&e.forEach(i=>i.classList.add(...ie[t]))};setInputClassToInputElement=()=>{p(this.timepicker.input,"timepicker-ui-input")||this.timepicker.input?.classList.add("timepicker-ui-input")};setDataOpenToInputIfDosentExistInWrapper=()=>{this.timepicker.openElementData===null&&this.timepicker.input?.setAttribute("data-open","timepicker-ui-input")};setClassTopOpenElement=()=>{this.timepicker.openElement.forEach(e=>e?.classList.add("timepicker-ui-open-element"))};setTimepickerClassToElement=()=>{this.timepicker._element?.classList.add(ee),this.timepicker._options.cssClass&&this.timepicker._options.cssClass!==ee&&this.timepicker._element?.classList.add(this.timepicker._options.cssClass)}};var R=class{timepicker;constructor(e){this.timepicker=e}preventClockTypeByCurrentTime=()=>{if(typeof this.timepicker._options?.currentTime!="boolean"&&this.timepicker._options?.currentTime?.preventClockType||typeof this.timepicker._options?.currentTime=="boolean"&&this.timepicker._options?.currentTime){let{currentTime:e,clockType:t}=this.timepicker._options,{type:i}=y(this.timepicker.input,t,e,!0);this.timepicker._options.clockType=i?"12h":"24h"}};updateInputValueWithCurrentTimeOnStart=()=>{if(typeof this.timepicker._options?.currentTime!="boolean"&&this.timepicker._options?.currentTime?.updateInput||typeof this.timepicker._options?.currentTime=="boolean"&&this.timepicker._options?.currentTime){let{hour:e,minutes:t,type:i}=y(this.timepicker.input,this.timepicker._options.clockType,this.timepicker._options.currentTime);this.timepicker.input.value=i?`${e}:${t} ${i}`:`${e}:${t}`}};checkMobileOption(){this.timepicker._isMobileView=!!this.timepicker._options.mobile,this.timepicker._options.mobile&&(this.timepicker._options.editable=!0)}getDisableTime(){this.timepicker._disabledTime=pe(this.timepicker._options)}getInputValueOnOpenAndSet=()=>{let e=y(this.timepicker.input,this.timepicker._options.clockType,this.timepicker._options.currentTime);if(e===void 0){this.timepicker.hour.value="12",this.timepicker.minutes.value="00",_(this.timepicker._element,"show","timepicker:open",{hour:this.timepicker.hour.value,minutes:this.timepicker.minutes.value,type:this.timepicker.activeTypeMode?.dataset.type,degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes},this.timepicker._options.onOpen),this.timepicker._options.clockType!=="24h"&&this.timepicker.AM.classList.add(k);return}let[t,i,s]=this.timepicker.input.value.split(":").join(" ").split(" ");this.timepicker.input.value.length===0&&(t=e.hour,i=e.minutes,s=e.type),this.timepicker.hour.value=t,this.timepicker.minutes.value=i;let r=this.timepicker.modalElement?.querySelector(`[data-type='${s}']`);this.timepicker._options.clockType!=="24h"&&r&&r.classList.add(k),_(this.timepicker._element,"show","timepicker:open",{...e,type:this.timepicker.activeTypeMode?.dataset.type,degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes},this.timepicker._options.onOpen)};handlerViewChange=()=>Y(()=>{let{clockType:e}=this.timepicker._options;if(this.timepicker.modalElement?.classList.contains("mobile")){let t=L(this.timepicker.hour.value,"hour",e),i=L(this.timepicker.minutes.value,"minutes",e);if(t===!1||i===!1){i||this.timepicker.minutes.classList.add("invalid-value"),t||this.timepicker.hour?.classList.add("invalid-value");return}t===!0&&i===!0&&(i&&this.timepicker.minutes.classList.remove("invalid-value"),t&&this.timepicker.hour?.classList.remove("invalid-value")),this.timepicker.close()(),this.timepicker._isMobileView=!1,this.timepicker._options.mobile=!1;let s=this.timepicker.hour.value,r=this.timepicker.minutes.value,o=this.timepicker.activeTypeMode?.dataset.type;setTimeout(()=>{this.timepicker.destroy(),this.timepicker.update({options:{mobile:!1}}),setTimeout(()=>{if(this.timepicker.open(),this.timepicker.hour.value=s,this.timepicker.minutes.value=r,this.timepicker._options.clockType==="12h"){let n=o==="PM"?"PM":"AM",c=o==="PM"?"AM":"PM";this.timepicker[n].classList.add(k),this.timepicker[c].classList.remove(k)}this.timepicker.clockManager.setTransformToCircleWithSwitchesHour(this.timepicker.hour.value),this.timepicker.clockManager.toggleClassActiveToValueTips(this.timepicker.hour.value),Number(this.timepicker.hour.value)>12||Number(this.timepicker.hour.value)===0?this.timepicker.clockManager.setCircleClockClasses24h():this.timepicker.clockManager.removeCircleClockClasses24h()},300)},300)}else{this.timepicker.close()(),this.timepicker._isMobileView=!0,this.timepicker._options.mobile=!0;let t=this.timepicker.hour.value,i=this.timepicker.minutes.value,s=this.timepicker.activeTypeMode?.dataset.type;setTimeout(()=>{this.timepicker.destroy(),this.timepicker.update({options:{mobile:!0}}),setTimeout(()=>{if(this.timepicker.open(),this.timepicker.hour.value=t,this.timepicker.minutes.value=i,this.timepicker._options.clockType==="12h"){let r=s==="PM"?"PM":"AM",o=s==="PM"?"AM":"PM";this.timepicker[r].classList.add(k),this.timepicker[o].classList.remove(k)}},300)},300)}},this.timepicker._options.delayHandler||300);getInputValue=y};var S=new Map,J=class{_degreesHours=null;_degreesMinutes=null;_options;_eventsClickMobile=()=>Promise.resolve();_eventsClickMobileHandler=()=>{};_mutliEventsMove=()=>{};_mutliEventsMoveHandler;_clickTouchEvents;_element;_instanceId;_isMobileView;_isTouchMouseMove;_disabledTime;_cloned;_inputEvents;_isModalRemove;_isInitialized=!1;_customId;_eventHandlersRegistered=!1;_isDestroyed=!1;eventManager;modalManager;animationManager;clockManager;validationManager;themeManager;configManager;constructor(e,t){if(typeof window>"u")throw new Error("TimepickerUI: Cannot initialize in non-browser environment (SSR/Node.js)");let i=t?.id;if(this._customId=i,this._instanceId=i||`timepicker-ui-${ce()}`,i&&S.has(i))throw new Error(`TimepickerUI: Instance with ID "${i}" already exists`);let s=null;if(typeof e=="string"){if(s=document.querySelector(e),!s)throw new Error(`TimepickerUI: Element with selector "${e}" not found`)}else if(e instanceof HTMLElement)s=e;else throw new Error("TimepickerUI: First parameter must be a string selector or HTMLElement");let r=null;if(s.tagName==="INPUT"?r=s:r=s.querySelector("input"),!r){let n=typeof e=="string"?`selector "${e}"`:"provided element";throw new Error(`TimepickerUI: No input element found for ${n}`)}if(s.tagName==="INPUT"){let n=document.createElement("div");n.className="timepicker-ui",s.parentNode?.insertBefore(n,s),n.appendChild(s),this._element=n}else this._element=s,this._element.classList.contains("timepicker-ui")||this._element.classList.add("timepicker-ui");this._cloned=null;let o=ae(this._element?.dataset);if(this._options={...se({...Q,...t,...o},Q)},this._options.inline?.enabled&&typeof t?.focusTrap>"u"&&(this._options.focusTrap=!1),this._isTouchMouseMove=!1,this._degreesHours=Number(y(this._element?.querySelector("input"),this._options.clockType).hour)*30,this._degreesMinutes=Number(y(this._element?.querySelector("input"),this._options.clockType).minutes)*6,this._isMobileView=!1,this._mutliEventsMove=n=>this.eventManager.handleEventToMoveHand(n),this._mutliEventsMoveHandler=this._mutliEventsMove.bind(this),this._eventsClickMobile=n=>this.eventManager.handlerClickHourMinutes(n),this._eventsClickMobileHandler=this._eventsClickMobile.bind(this),this.eventManager=new U(this),this.modalManager=new F(this),this.animationManager=new W(this),this.clockManager=new P(this),this.validationManager=new B(this),this.themeManager=new q(this),this.configManager=new R(this),this.configManager.checkMobileOption(),this._clickTouchEvents=["click","mousedown","touchstart"],this._inputEvents=["change",...this._clickTouchEvents],this._disabledTime=null,this.configManager.preventClockTypeByCurrentTime(),this._isModalRemove=!0,this._isInitialized=!1,this._options.inline?.enabled){if(!this._options.inline.containerId)throw console.error("TimepickerUI: containerId is required when inline mode is enabled"),new Error("TimepickerUI: containerId is required when inline mode is enabled");if(!document.getElementById(this._options.inline.containerId))throw console.error(`TimepickerUI: Container element with ID "${this._options.inline.containerId}" not found`),new Error(`TimepickerUI: Container element with ID "${this._options.inline.containerId}" not found`)}S.set(this._instanceId,this)}static getById(e){return S.get(e)}static getAllInstances(){return Array.from(S.values())}static isAvailable(e){return typeof window>"u"?!1:typeof e=="string"?document.querySelector(e)!==null:e instanceof HTMLElement?document.contains(e):!1}static destroyAll(){Array.from(S.values()).forEach(t=>t.destroy()),S.clear()}get modalTemplate(){return!this._options.mobile||!this._isMobileView?le(this._options,this._instanceId):me(this._options,this._instanceId)}get modalElement(){return document.querySelector(`[data-owner-id="${this._instanceId}"]`)}get clockFace(){return this.modalElement?.querySelector(".timepicker-ui-clock-face")}get input(){return this._element?.querySelector("input")}get clockHand(){return this.modalElement?.querySelector(".timepicker-ui-clock-hand")}get circle(){return this.modalElement?.querySelector(".timepicker-ui-circle-hand")}get tipsWrapper(){return this.modalElement?.querySelector(".timepicker-ui-tips-wrapper")}get tipsWrapperFor24h(){return this.modalElement?.querySelector(".timepicker-ui-tips-wrapper-24h")}get minutes(){return this.modalElement?.querySelector(".timepicker-ui-minutes")}get hour(){return this.modalElement?.querySelector(".timepicker-ui-hour")}get AM(){return this.modalElement?.querySelector(".timepicker-ui-am")}get PM(){return this.modalElement?.querySelector(".timepicker-ui-pm")}get minutesTips(){return this.modalElement?.querySelector(".timepicker-ui-minutes-time")}get hourTips(){return this.modalElement?.querySelector(".timepicker-ui-hour-time-12")}get allValueTips(){let e=this.modalElement;return e?[...e.querySelectorAll(".timepicker-ui-value-tips"),...e.querySelectorAll(".timepicker-ui-value-tips-24h")]:[]}get openElementData(){let e=this._element?.querySelectorAll("[data-open]");if(e?.length>0){let t=[];return e.forEach(({dataset:i})=>t.push(i.open??"")),[...new Set(t)]}return null}get openElement(){return this.openElementData===null?(this.input?.setAttribute("data-open","timepicker-ui-input"),[this.input]):this.openElementData.map(e=>this._element?.querySelectorAll(`[data-open='${e}']`))[0]??""}get cancelButton(){return this.modalElement?.querySelector(".timepicker-ui-cancel-btn")}get okButton(){return this.modalElement?.querySelector(".timepicker-ui-ok-btn")}get activeTypeMode(){return this.modalElement?.querySelector(".timepicker-ui-type-mode.active")}get keyboardClockIcon(){return this.modalElement?.querySelector(".timepicker-ui-keyboard-icon-wrapper")}get footer(){return this.modalElement?.querySelector(".timepicker-ui-footer")}get wrapper(){return this.modalElement?.querySelector(".timepicker-ui-wrapper")}getElement(){return this._element}create=()=>{if(this._isInitialized){console.warn("TimepickerUI: Instance is already initialized");return}this.configManager.updateInputValueWithCurrentTimeOnStart(),this.validationManager.checkDisabledValuesOnStart(),this.themeManager.setTimepickerClassToElement(),this.themeManager.setInputClassToInputElement(),this.themeManager.setDataOpenToInputIfDosentExistInWrapper(),this.themeManager.setClassTopOpenElement(),this._options.inline?.enabled?(this.eventManager.handleOpenOnEnterFocus(),this._eventsBundle()):(this.eventManager.handleOpenOnEnterFocus(),this.eventManager.handleOpenOnClick()),this.configManager.getDisableTime(),this._isInitialized=!0};open=e=>{this._isInitialized||this.create(),this._eventsBundle(),D(e)};close=()=>Y((...e)=>{if(e.length>2||!this.modalElement)return;let[t]=e.filter(s=>typeof s=="boolean"),[i]=e.filter(s=>typeof s=="function");t&&(this.eventManager.handleOkButton(),this.okButton?.click()),this._isTouchMouseMove=!1,O.split(" ").map(s=>document.removeEventListener(s,this._mutliEventsMoveHandler,!1)),document.removeEventListener("mousedown",this._eventsClickMobileHandler),document.removeEventListener("touchstart",this._eventsClickMobileHandler),document.removeEventListener("keypress",this.eventManager.handleEscClick),this.wrapper.removeEventListener("keydown",this.eventManager.focusTrapHandler),this._options.enableSwitchIcon&&(this.keyboardClockIcon.removeEventListener("touchstart",this.configManager.handlerViewChange()),this.keyboardClockIcon.removeEventListener("mousedown",this.configManager.handlerViewChange())),this.animationManager.removeAnimationToClose(),this.openElement.forEach(s=>s?.classList.remove("disabled")),setTimeout(()=>{document.body.style.overflowY="",document.body.style.paddingRight=""},400),this.openElement.forEach(s=>s?.classList.remove("disabled")),setTimeout(()=>{this._options.focusInputAfterCloseModal&&this.input?.focus(),this.modalElement!==null&&(this.modalElement.remove(),this._isModalRemove=!0)},300),D(i)},this._options.delayHandler||300);destroy=e=>{if(this._isDestroyed){console.warn("TimepickerUI: Instance is already destroyed");return}let t=typeof e=="function"?{callback:e}:e||{},{keepInputValue:i=!1,callback:s}=t,r=i?this.input?.value:null;O.split(" ").forEach(n=>{document.removeEventListener(n,this._mutliEventsMoveHandler,!1)}),document.removeEventListener("mousedown",this._eventsClickMobileHandler),document.removeEventListener("touchstart",this._eventsClickMobileHandler),document.removeEventListener("keypress",this.eventManager.handleEscClick),this._options.enableSwitchIcon&&this.keyboardClockIcon&&(this.keyboardClockIcon.removeEventListener("touchstart",this.configManager.handlerViewChange()),this.keyboardClockIcon.removeEventListener("mousedown",this.configManager.handlerViewChange())),this.input&&this._inputEvents.forEach(n=>{this.input.removeEventListener(n,()=>{})}),this.modalElement?.remove(),this.openElement?.forEach(n=>{n&&(n.classList.remove("disabled","active","timepicker-ui-open-element"),n.classList.remove("basic","crane-straight","crane-radius","m3"))}),this.input&&(this.input.classList.remove("timepicker-ui-invalid-format","invalid-value","error","active","timepicker-ui-input"),this.input.removeAttribute("data-open"),this.input.removeAttribute("data-owner-id"),i&&r!==null&&(this.input.value=r)),this._element&&(this._element.classList.remove("basic","crane-straight","crane-radius","m3"),this._element.classList.remove("error","active","disabled"),this._element.removeAttribute("data-owner-id"),this._element.removeAttribute("data-open"),this._options.cssClass&&this._element.classList.remove(this._options.cssClass)),this._element?.querySelectorAll(".timepicker-ui-invalid-text")?.forEach(n=>n.remove()),this._mutliEventsMoveHandler=null,this._eventsClickMobileHandler=null,this._mutliEventsMove=()=>{},this._eventsClickMobile=()=>Promise.resolve(),this._isModalRemove=!0,this._isTouchMouseMove=!1,this._disabledTime=null,this._cloned=null,this._degreesHours=null,this._degreesMinutes=null,this._isInitialized=!1,this._isDestroyed=!0,typeof document<"u"&&(document.body.style.overflowY="",document.body.style.paddingRight=""),S.delete(this._instanceId),D(s)};update=(e,t)=>{if(this._isDestroyed){console.warn("TimepickerUI: Instance is destroyed");return}this._options={...this._options,...e.options},this.configManager.checkMobileOption(),e.create&&this.create(),D(t)};getValue=()=>{if(this._isDestroyed)return console.warn("TimepickerUI: Instance is destroyed"),{hour:"",minutes:"",time:"",degreesHours:null,degreesMinutes:null};let e=this.hour?.value||"12",t=this.minutes?.value||"00",i=this._options.clockType==="24h"?void 0:this.activeTypeMode?.textContent||"AM",s="";return this._options.clockType==="24h"?s=`${e.padStart(2,"0")}:${t.padStart(2,"0")}`:s=`${e}:${t.padStart(2,"0")} ${i}`,{hour:e,minutes:t,type:i,time:s,degreesHours:this._degreesHours,degreesMinutes:this._degreesMinutes}};setValue=(e,t=!0)=>{if(this._isDestroyed){console.warn("TimepickerUI: Instance is destroyed");return}if(!e||typeof e!="string")throw new Error("TimepickerUI: setValue requires a valid time string");let i=e.trim(),s="12",r="00",o="AM";try{if(this._options.clockType==="24h"){let n=i.match(/^([0-1]?[0-9]|2[0-3]):([0-5][0-9])$/);if(!n)throw new Error("Invalid 24h format. Expected HH:MM");s=n[1].padStart(2,"0"),r=n[2]}else{let n=i.match(/^(1[0-2]|[1-9]):([0-5][0-9])\s*(AM|PM)$/i);if(!n)throw new Error("Invalid 12h format. Expected HH:MM AM/PM");s=n[1],r=n[2],o=n[3].toUpperCase()}this.hour&&(this.hour.value=s,this._degreesHours=Number(s)*30),this.minutes&&(this.minutes.value=r,this._degreesMinutes=Number(r)*6),this._options.clockType!=="24h"&&this.AM&&this.PM&&(o==="AM"?(this.AM.classList.add("active"),this.PM.classList.remove("active")):(this.PM.classList.add("active"),this.AM.classList.remove("active"))),t&&this.input&&(this.input.value=i),this.clockHand&&(this.clockHand.style.transform=`rotateZ(${this._degreesHours||0}deg)`)}catch(n){throw new Error(`TimepickerUI: ${n instanceof Error?n.message:"Invalid time format"}`)}};_eventsBundle=()=>{if(this._isDestroyed){console.warn("TimepickerUI: Instance is destroyed");return}if(this._isModalRemove){if(this._options.inline?.enabled||this.eventManager.handleEscClick(),this.validationManager.setErrorHandler(),this.validationManager.removeErrorHandler(),this._options.inline?.enabled||(this.openElement.forEach(e=>e?.classList.add("disabled")),this.input?.blur()),this.modalManager.setScrollbarOrNot(),this.modalManager.setModalTemplate(),this.modalManager.setNormalizeClass(),this.modalManager.removeBackdrop(),this.clockManager.setBgColorToCirleWithHourTips(),this.clockManager.setOnStartCSSClassesIfClockType24h(),this.clockManager.setClassActiveToHourOnOpen(),this.clockFace!==null){let e=new H({array:w,classToAdd:"timepicker-ui-hour-time-12",clockFace:this.clockFace,tipsWrapper:this.tipsWrapper,theme:this._options.theme,disabledTime:this._disabledTime?.value?.isInterval?this._disabledTime?.value.rangeArrHour:this._disabledTime?.value?.hours,clockType:"12h",hour:this.hour.value});e.create(),this._options.clockType==="24h"?new H({array:Z,classToAdd:"timepicker-ui-hour-time-24",clockFace:this.tipsWrapperFor24h,tipsWrapper:this.tipsWrapperFor24h,theme:this._options.theme,clockType:"24h",disabledTime:this._disabledTime?.value?.isInterval?this._disabledTime?.value.rangeArrHour:this._disabledTime?.value?.hours,hour:this.hour.value}).create():(this._disabledTime?.value.startType===this._disabledTime?.value.endType?setTimeout(()=>{this._disabledTime?.value.startType===this.activeTypeMode?.textContent&&e.updateDisable({hoursToUpdate:this._disabledTime?.value?.rangeArrHour,minutesToUpdate:{endMinutes:this._disabledTime?.value.endMinutes,removedEndHour:this._disabledTime?.value.removedEndHour,removedStartedHour:this._disabledTime?.value.removedStartedHour,actualHour:this.hour.value,startMinutes:this._disabledTime?.value.startMinutes}})},300):setTimeout(()=>{e.updateDisable({minutesToUpdate:{actualHour:this.hour.value,pmHours:this._disabledTime?.value.pmHours,amHours:this._disabledTime?.value.amHours,activeMode:this.activeTypeMode?.textContent}})},300),e.updateDisable())}this.modalManager.setFlexEndToFooterIfNoKeyboardIcon(),setTimeout(()=>{this.themeManager.setTheme()},0),this.animationManager.setAnimationToOpen(),this.configManager.getInputValueOnOpenAndSet(),this.clockManager.toggleClassActiveToValueTips(this.hour.value),this._isMobileView||(this.clockManager.setTransformToCircleWithSwitchesHour(this.hour.value),this.animationManager.handleAnimationClock()),this.eventManager.handleMinutesEvents(),this.eventManager.handleHourEvents(),this._options.clockType!=="24h"&&(this.eventManager.handleAmClick(),this.eventManager.handlePmClick()),this.clockFace&&this.eventManager.handleMoveHand(),this.eventManager.handleCancelButton(),this.eventManager.handleOkButton(),this.modalElement&&(this.modalManager.setShowClassToBackdrop(),this._options.inline?.enabled||this.eventManager.handleBackdropClick()),this.eventManager.handleIconChangeView(),this.eventManager.handleClickOnHourMobile(),this._options.focusTrap&&this.eventManager.focusTrapHandler(),this._options.inline?.enabled&&this._options.inline.autoUpdate!==!1&&this.eventManager.handleInlineAutoUpdate()}}};export{J as TimepickerUI};
@@ -0,0 +1 @@
1
+ !function(e,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i((e="undefined"!=typeof globalThis?globalThis:e||self).TimepickerUI={})}(this,function(e){"use strict";const i=(e,i)=>({...i,...e}),t=(e,i)=>{const{touches:t}=e,{clientX:s,clientY:r}=e;if(!i)return;const{left:n,top:c}=i.getBoundingClientRect();let o={x:0,y:0};if(void 0===t)o={x:s-n,y:r-c};else if(void 0!==t&&t.length>0&&Object.keys(t).length>0){const{clientX:e,clientY:i}=t[0];o={x:e-n,y:i-c}}return 0!==Object.keys(o).length||o.constructor!==Object?o:void 0},s=(e,i)=>!!e&&e.classList.contains(i),r=(e,i,t,s,r)=>{if(!e)return;const n=new CustomEvent(t,{detail:s,bubbles:!0,cancelable:!0});try{if(e.dispatchEvent(n)&&i!==t){const t=new CustomEvent(i,{detail:s,bubbles:!0,cancelable:!0});e.dispatchEvent(t)}}catch(e){console.warn(`TimepickerUI: Error dispatching event ${t}:`,e)}if(r&&"function"==typeof r)try{r(s)}catch(e){console.warn(`TimepickerUI: Error in ${t} callback:`,e)}},n=(e,i,t)=>((e,i)=>Math.round(e/i)*i)(e,i*t),c=(e,i)=>Array.from({length:Number(i)-Number(e)+1},(i,t)=>Number(e)+t),o=(e,i)=>Array.from({length:Number(i)-Number(e)+1},(e,t)=>Number(i)-t).reverse(),a=e=>{e&&"function"==typeof e&&e()},l=(e="")=>{const i=e.replace(/(AM|PM|am|pm)/,e=>` ${e}`),t=new Date(`September 20, 2000 ${i}`);return`${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}`},m=(e,i,t,s)=>{const r={hour:"12",minutes:"00",type:"24h"===i?void 0:"PM"};if(!e)return r;const n=e.value.trim();if(!t&&""===n)return r;if("boolean"==typeof t&&t){const e=new Date,[t,s]=e.toLocaleTimeString().split(":"),r=Number(t)<=9?`0${Number(t)}`:t;if(/[a-z]/i.test(s)&&"12h"===i){const[e,i]=s.split(" ");return{hour:r,minutes:e,type:i}}return{hour:r,minutes:s,type:void 0}}if("object"==typeof t){const{time:e,locales:r,preventClockType:n}=t,c=e??new Date;if(n&&s){const[e,i]=new Date(c).toLocaleTimeString().split(":");if(/[a-z]/i.test(i)){const[t,s]=i.split(" ");return{hour:e,minutes:t,type:s}}return{hour:Number(e)<=9?`0${Number(e)}`:e,minutes:i,type:void 0}}const[o,a]=new Date(c).toLocaleTimeString(r,{timeStyle:"short"}).split(":"),l=Number(o)<=9?`0${Number(o)}`:o;if(/[a-z]/i.test(a)&&"12h"===i){const[e,i]=a.split(" ");return{hour:l,minutes:e,type:i}}if("12h"===i){const[e,i]=new Date(`1970-01-01T${o}:${a}Z`).toLocaleTimeString("en-US",{timeZone:"UTC",hour12:!0,hour:"numeric",minute:"numeric"}).split(":"),[t,s]=i.split(" ");return{hour:Number(e)<=9?`0${Number(e)}`:e,minutes:t,type:s}}return{hour:l,minutes:a,type:void 0}}const[c,o]=n.split(" "),[a="",l=""]=c.split(":"),m=a.replace(/\D/g,""),p=l.replace(/\D/g,""),u={hour:m.padStart(2,"0"),minutes:p.padStart(2,"0"),type:"12h"===i?o:void 0};if(m.length>2||p.length>2)return{...u,error:"Invalid input: too many digits.",currentHour:a,currentMin:l};if(/[a-z]/i.test(c))return{...u,error:"Input contains invalid letters."};if(n.includes(" ")&&(!o||n.length>8||"AM"!==o&&"PM"!==o))return{...u,error:"Invalid AM/PM format or length.",currentLength:n.length,currentType:o};const h=Number(m),d=Number(p);if("12h"===i){if(h<1||h>12||d<0||d>59||"AM"!==o&&"PM"!==o)return{...u,error:"Invalid 12h time.",currentHour:h,currentMin:d,currentType:o}}else if(h<0||h>23||d<0||d>59)return{...u,error:"Invalid 24h time.",currentHour:h,currentMin:d};return u},p=(e,i,t)=>{const s=Number(e);if(Number.isNaN(s))return!1;switch(i){case"hour":return"24h"===t?s>=0&&s<=23:s>0&&s<=12;case"minutes":return s>=0&&s<=59;default:return}},u={amLabel:"AM",animation:!0,appendModalSelector:"",backdrop:!0,cancelLabel:"CANCEL",editable:!1,enableScrollbar:!1,enableSwitchIcon:!1,mobileTimeLabel:"Enter Time",focusInputAfterCloseModal:!1,hourMobileLabel:"Hour",iconTemplate:'<i class="material-icons timepicker-ui-keyboard-icon">keyboard</i>',iconTemplateMobile:'<i class="material-icons timepicker-ui-keyboard-icon">schedule</i>',incrementHours:1,incrementMinutes:1,minuteMobileLabel:"Minute",mobile:!1,okLabel:"OK",pmLabel:"PM",timeLabel:"Select Time",switchToMinutesAfterSelectHour:!1,theme:"basic",clockType:"12h",disabledTime:void 0,currentTime:void 0,focusTrap:!0,delayHandler:300,inline:void 0,cssClass:void 0},h="timepicker-ui",d="mousedown mouseup mousemove mouseleave mouseover touchstart touchmove touchend",k="active",v=(e,i)=>{let t;return(...s)=>{clearTimeout(t),t=setTimeout(()=>{e(...s)},i)}},b=["00","13","14","15","16","17","18","19","20","21","22","23"],T=["12","1","2","3","4","5","6","7","8","9","10","11"],y=["00","05","10","15","20","25","30","35","40","45","50","55"];class g{array;classToAdd;clockFace;tipsWrapper;theme;clockType;disabledTime;hour;constructor(e){this.array=e?.array,this.classToAdd=e?.classToAdd,this.clockFace=e?.clockFace,this.tipsWrapper=e?.tipsWrapper,this.theme=e?.theme,this.clockType=e?.clockType,this.disabledTime=e?.disabledTime,this.hour=e?.hour}clean=()=>{const e=this.tipsWrapper?.querySelectorAll("span.timepicker-ui-hour-time-12"),i=this.tipsWrapper?.querySelectorAll("span.timepicker-ui-minutes-time");this._removeClasses(e),this._removeClasses(i)};create=()=>{if(!(this.clockFace&&this.array&&this.classToAdd&&this.tipsWrapper))return;const e=(this.clockFace.offsetWidth-32)/2,i=(this.clockFace.offsetHeight-32)/2,t=e-9;this.tipsWrapper.innerHTML="",this.array?.forEach((r,n)=>{const c=n*(360/this.array.length)*(Math.PI/180);const o=document.createElement("span"),a=document.createElement("span");a.innerHTML=r,this.disabledTime&&(Array.isArray(this.disabledTime)&&this.disabledTime?.includes(r)&&(a.classList.add("timepicker-ui-tips-disabled"),o.classList.add("timepicker-ui-tips-disabled")),this.hour===this.disabledTime.removedStartedHour&&this.disabledTime?.startMinutes?.includes(r)&&(a.classList.add("timepicker-ui-tips-disabled"),o.classList.add("timepicker-ui-tips-disabled"),a.tabIndex=-1),this.hour===this.disabledTime.removedEndHour&&this.disabledTime?.endMinutes?.includes(r)&&(a.classList.add("timepicker-ui-tips-disabled"),o.classList.add("timepicker-ui-tips-disabled"),a.tabIndex=-1)),"24h"===this.clockType?(a.classList.add("timepicker-ui-value-tips-24h"),s(a,"timepicker-ui-tips-disabled")||(a.tabIndex=0)):(a.classList.add("timepicker-ui-value-tips"),s(a,"timepicker-ui-tips-disabled")||(a.tabIndex=0)),o.classList.add(this.classToAdd),"crane-straight"===this.theme&&(o.classList.add("crane-straight"),a.classList.add("crane-straight")),"m3"===this.theme&&(o.classList.add("m3"),a.classList.add("m3")),"dark"===this.theme&&(o.classList.add("dark"),a.classList.add("dark")),"glassmorphic"===this.theme&&(o.classList.add("glassmorphic"),a.classList.add("glassmorphic")),"pastel"===this.theme&&(o.classList.add("pastel"),a.classList.add("pastel")),"ai"===this.theme&&(o.classList.add("ai"),a.classList.add("ai")),"cyberpunk"===this.theme&&(o.classList.add("cyberpunk"),a.classList.add("cyberpunk")),o.style.left=e+Math.sin(c)*t-o.offsetWidth+"px",o.style.bottom=i+Math.cos(c)*t-o.offsetHeight+"px",o.appendChild(a),this.tipsWrapper?.appendChild(o)})};updateDisable=e=>{const i=this.tipsWrapper?.querySelectorAll("span.timepicker-ui-hour-time-12"),t=this.tipsWrapper?.querySelectorAll("span.timepicker-ui-minutes-time");if(this._removeClasses(i),this._removeClasses(t),e?.hoursToUpdate&&i&&this._addClassesWithIncludes(i,e.hoursToUpdate),e?.minutesToUpdate&&t){const{actualHour:i,removedEndHour:s,removedStartedHour:r,startMinutes:n,endMinutes:c}=e.minutesToUpdate;s===i&&c.length>0?this._addClassesWithIncludes(t,c):Number(i)>Number(r)&&Number(i)<Number(s)&&this._addClasses(t),r===i&&n.length>0?this._addClassesWithIncludes(t,n):Number(i)>Number(r)&&Number(i)<Number(s)&&this._addClasses(t)}if(e){const{amHours:s,pmHours:r,activeMode:n,startMinutes:c,endMinutes:o,removedAmHour:a,removedPmHour:l,actualHour:m}=e.minutesToUpdate;if(!s||!r)return;i&&(s&&"AM"===n&&this._addClassesWithIncludes(i,s),r&&"PM"===n&&this._addClassesWithIncludes(i,r)),t&&c&&o&&("AM"===n&&("00"===o[0]&&1===o.length&&0===c.length&&Number(m)>=Number(s[0])&&this._addClasses(t),0===c.length&&o.length>1&&Number(m)>=Number(a)&&this._addClasses(t),c.length>0&&o.length>1&&"00"===o[0]&&(Number(a)===Number(m)?this._addClassesWithIncludes(t,c):Number(m)>Number(a)&&this._addClasses(t)),"00"===o[0]&&1===o.length&&c.length>0&&(Number(a)===Number(m)?this._addClassesWithIncludes(t,c):Number(m)>Number(a)&&this._addClasses(t))),"PM"===n&&(m<Number(l)&&this._addClasses(t),m===l&&this._addClassesWithIncludes(t,o),o.length>0&&Number(m)===l-1&&this._addClassesWithIncludes(t,o)))}};_removeClasses=e=>{e?.forEach(({classList:e,children:i})=>{e.remove("timepicker-ui-tips-disabled"),i[0].classList.remove("timepicker-ui-tips-disabled"),i[0].tabIndex=0})};_addClasses=e=>{e?.forEach(({classList:e,children:i})=>{e.add("timepicker-ui-tips-disabled"),i[0].classList.add("timepicker-ui-tips-disabled"),i[0].tabIndex=-1})};_addClassesWithIncludes=(e,i)=>{e?.forEach(({classList:e,children:t,textContent:s})=>{i?.includes(s)&&(e.add("timepicker-ui-tips-disabled"),t[0].classList.add("timepicker-ui-tips-disabled"),t[0].tabIndex=-1)})}}const _=(e,i,t,s)=>{if(e){if(Array.isArray(e)&&e.length>0){return!e.map(e=>p(e,i,t)).some(e=>!1===e)}if("string"==typeof e||"number"==typeof e){const r=p(e,i,t),n=s?.map(Number).includes(Number(e));return!(!r||n)}}};class M{timepicker;constructor(e){this.timepicker=e}handleOpenOnClick=()=>{this.timepicker.openElement.forEach(e=>e?.addEventListener("click",()=>this.timepicker._eventsBundle()))};handleOpenOnEnterFocus=()=>{this.timepicker.input.addEventListener("keydown",({target:e,key:i})=>{e.disabled||"Enter"===i&&this.timepicker.open()})};handleCancelButton=()=>{this.timepicker.cancelButton.addEventListener("click",()=>{const e=m(this.timepicker.input,this.timepicker._options.clockType);r(this.timepicker._element,"cancel","timepicker:cancel",{...e,hourNotAccepted:this.timepicker.hour.value,minutesNotAccepted:this.timepicker.minutes.value,type:this.timepicker.activeTypeMode?.dataset.type,degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes},this.timepicker._options.onCancel),this.timepicker.close()()})};handleOkButton=()=>{this.timepicker.okButton?.addEventListener("click",()=>{const{clockType:e,disabledTime:i}=this.timepicker._options,t=p(this.timepicker.hour.value,"hour",e),s=p(this.timepicker.minutes.value,"minutes",e);let n;const c=_(this.timepicker.hour.value,"hour",e,i?.hours),o=_(this.timepicker.minutes.value,"minutes",e,i?.minutes);if(i?.interval&&(n=((e,i,t,s)=>{const r=t?l(`${e}:${i} ${t}`.trim()):`${e}:${i}`.trim();let n,c;if(t){const[e,i]=s.trim().split("-").map(e=>e.trim());n=l(e),c=l(i)}else{const[e,i]=s.trim().split("-"),t=e=>e.trim().split(":").map(e=>Number(e)<=9?`0${Number(e)}`:e).join(":");n=t(e),c=t(i)}return r<n||r>c})(this.timepicker.hour.value,this.timepicker.minutes.value,this.timepicker.activeTypeMode?.textContent,i.interval)),!1===n||!1===t||!1===s||!1===c||!1===o)return!1!==n&&s&&o||this.timepicker.minutes.classList.add("invalid-value"),void(!1!==n&&t&&c||this.timepicker.hour.classList.add("invalid-value"));this.timepicker.input.value=`${this.timepicker.hour.value}:${this.timepicker.minutes.value} ${"24h"===this.timepicker._options.clockType?"":this.timepicker.activeTypeMode?.dataset.type}`.trimEnd(),r(this.timepicker._element,"accept","timepicker:confirm",{hour:this.timepicker.hour.value,minutes:this.timepicker.minutes.value,type:this.timepicker.activeTypeMode?.dataset.type,degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes},this.timepicker._options.onConfirm),this.timepicker.close()()})};handleBackdropClick=()=>{this.timepicker.modalElement?.addEventListener("click",e=>{const i=e.target;if(!s(i,"timepicker-ui-modal"))return;const t=m(this.timepicker.input,this.timepicker._options.clockType);r(this.timepicker._element,"cancel","timepicker:cancel",{...t,hourNotAccepted:this.timepicker.hour.value,minutesNotAccepted:this.timepicker.minutes.value,type:this.timepicker.activeTypeMode?.dataset.type,degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes},this.timepicker._options.onCancel),this.timepicker.close()()})};getDestructuringObj(e){const{endMinutes:i,removedEndHour:t,removedStartedHour:s,startMinutes:r,pmHours:n,amHours:c,removedAmHour:o,removedPmHour:a}=this.timepicker._disabledTime.value;return e?{minutesToUpdate:{actualHour:this.timepicker.hour.value,pmHours:n,amHours:c,activeMode:this.timepicker.activeTypeMode?.textContent,startMinutes:r,endMinutes:i,removedAmHour:o,removedPmHour:a}}:{minutesToUpdate:{endMinutes:i,removedEndHour:t,removedStartedHour:s,actualHour:this.timepicker.hour.value,startMinutes:r}}}handleAmClick=()=>{this.timepicker._clickTouchEvents.forEach(e=>{this.timepicker.AM.addEventListener(e,e=>{if(e.target.classList.add(k),this.timepicker.PM.classList.remove(k),"12h"===this.timepicker._options.clockType&&this.timepicker._options.disabledTime?.interval){const e=new g({clockFace:this.timepicker.clockFace,tipsWrapper:this.timepicker.tipsWrapper,array:s(this.timepicker.hour,k)?T:y});this.timepicker._disabledTime?.value.startType===this.timepicker._disabledTime?.value.endType?setTimeout(()=>{this.timepicker._disabledTime?.value.startType===this.timepicker.activeTypeMode?.textContent?e.updateDisable({hoursToUpdate:this.timepicker._disabledTime?.value?.rangeArrHour,...this.getDestructuringObj()}):e.clean()},300):setTimeout(()=>{e.updateDisable({...this.getDestructuringObj(!0)})},300),e.updateDisable()}r(this.timepicker._element,"selectamtypemode","timepicker:select-am",{hour:this.timepicker.hour.value,minutes:this.timepicker.minutes.value,type:this.timepicker.activeTypeMode?.dataset.type,degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes},this.timepicker._options.onSelectAM)})})};handlePmClick=()=>{this.timepicker._clickTouchEvents.forEach(e=>{this.timepicker.PM.addEventListener(e,e=>{if(e.target.classList.add(k),this.timepicker.AM.classList.remove(k),"12h"===this.timepicker._options.clockType&&this.timepicker._options.disabledTime?.interval){const e=new g({clockFace:this.timepicker.clockFace,tipsWrapper:this.timepicker.tipsWrapper,array:s(this.timepicker.hour,k)?T:y});this.timepicker._disabledTime?.value.startType===this.timepicker._disabledTime?.value.endType?setTimeout(()=>{this.timepicker._disabledTime?.value.startType===this.timepicker.activeTypeMode?.textContent?e.updateDisable({hoursToUpdate:this.timepicker._disabledTime?.value?.rangeArrHour,...this.getDestructuringObj()}):e.clean()},300):setTimeout(()=>{e.updateDisable({...this.getDestructuringObj(!0)})},300)}r(this.timepicker._element,"selectpmtypemode","timepicker:select-pm",{hour:this.timepicker.hour.value,minutes:this.timepicker.minutes.value,type:this.timepicker.activeTypeMode?.dataset.type,degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes},this.timepicker._options.onSelectPM)})})};handleClasses24h=(e,i)=>{const t=e.target;this.timepicker.hourTips&&"24h"===this.timepicker._options.clockType&&(Number(t.textContent)>12||0===Number(t.textContent)?this.timepicker.clockManager.setCircleClockClasses24h():this.timepicker.clockManager.removeCircleClockClasses24h(),this.timepicker._options.mobile||this.timepicker.tipsWrapperFor24h?.classList.remove("timepicker-ui-tips-wrapper-24h-disabled")),t&&i&&(i.value=t.value.replace(/\D+/g,""),i.click())};handleHourEvents=()=>{this.timepicker._inputEvents.forEach(e=>{this.timepicker.hour?.addEventListener(e,e=>{const i=e.target;if(null!==this.timepicker.clockFace&&this.timepicker.animationManager.handleAnimationSwitchTipsMode(),"24h"===this.timepicker._options.clockType&&null!==this.timepicker.clockFace&&(Number(this.timepicker.hour.value)>12||"00"===this.timepicker.hour.value?this.timepicker.clockManager.setCircleClockClasses24h():this.timepicker.clockManager.removeCircleClockClasses24h(),this.timepicker._options.mobile||this.timepicker.tipsWrapperFor24h?.classList.remove("timepicker-ui-tips-wrapper-24h-disabled")),this.timepicker.clockManager.setHoursToClock(i.value),this.timepicker.minutes.classList.remove(k),this.timepicker.hour.classList.add(k),"12h"===this.timepicker._options.clockType&&this.timepicker._options.disabledTime?.interval){const e=new g({clockFace:this.timepicker.clockFace,tipsWrapper:this.timepicker.tipsWrapper,array:s(this.timepicker.hour,k)?T:y});this.timepicker._disabledTime?.value.startType===this.timepicker._disabledTime?.value.endType?setTimeout(()=>{this.timepicker._disabledTime?.value.startType===this.timepicker.activeTypeMode?.textContent?e.updateDisable({hoursToUpdate:this.timepicker._disabledTime?.value?.rangeArrHour,...this.getDestructuringObj()}):e.clean()},300):setTimeout(()=>{e.updateDisable({...this.getDestructuringObj(!0)})},300)}r(this.timepicker._element,"selecthourmode","timepicker:select-hour",{hour:this.timepicker.hour.value,minutes:this.timepicker.minutes.value,type:this.timepicker.activeTypeMode?.dataset.type,degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes},this.timepicker._options.onSelectHour),null!==this.timepicker.clockFace&&this.timepicker.circle.classList.remove("small-circle")})}),this.timepicker.hour?.addEventListener("blur",e=>this.handleClasses24h(e,this.timepicker.hour)),this.timepicker.hour?.addEventListener("focus",e=>this.handleClasses24h(e,this.timepicker.hour))};handleMinutesEvents=()=>{this.timepicker._inputEvents.forEach(e=>{this.timepicker.minutes.addEventListener(e,e=>{const i=e.target;if(null!==this.timepicker.clockFace&&(this.timepicker.animationManager.handleAnimationSwitchTipsMode(),this.timepicker.clockManager.setMinutesToClock(i.value)),"24h"===this.timepicker._options.clockType&&(this.timepicker.clockManager.removeCircleClockClasses24h(),this.timepicker._options.mobile||this.timepicker.tipsWrapperFor24h?.classList.add("timepicker-ui-tips-wrapper-24h-disabled")),this.timepicker.hour.classList.remove(k),this.timepicker.minutes.classList.add(k),"12h"===this.timepicker._options.clockType&&this.timepicker._options.disabledTime?.interval){const e=new g({clockFace:this.timepicker.clockFace,tipsWrapper:this.timepicker.tipsWrapper,array:s(this.timepicker.hour,k)?T:y});this.timepicker._disabledTime?.value.startType===this.timepicker._disabledTime?.value.endType?setTimeout(()=>{this.timepicker._disabledTime?.value.startType===this.timepicker.activeTypeMode?.textContent?e.updateDisable({hoursToUpdate:this.timepicker._disabledTime?.value?.rangeArrHour,...this.getDestructuringObj()}):e.clean()},300):setTimeout(()=>{e.updateDisable({...this.getDestructuringObj(!0)})},300)}r(this.timepicker._element,"selectminutemode","timepicker:select-minute",{hour:this.timepicker.hour.value,minutes:this.timepicker.minutes.value,type:this.timepicker.activeTypeMode?.dataset.type,degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes},this.timepicker._options.onSelectMinute)})}),this.timepicker.minutes?.addEventListener("blur",e=>this.handleClasses24h(e,this.timepicker.minutes)),this.timepicker.minutes?.addEventListener("focus",e=>this.handleClasses24h(e,this.timepicker.minutes))};handleEventToMoveHand=e=>{const{target:i,type:c,touches:o}=e,a=i,{incrementMinutes:l,incrementHours:p,switchToMinutesAfterSelectHour:u}=this.timepicker._options;if(!t(e,this.timepicker.clockFace))return;const h=t(e,this.timepicker.clockFace),d=this.timepicker.clockFace.offsetWidth/2,v=h&&Math.atan2(h.y-d,h.x-d);if("mouseup"===c||"touchend"===c)return this.timepicker._isTouchMouseMove=!1,void(u&&(s(a,"timepicker-ui-value-tips")||s(a,"timepicker-ui-value-tips-24h")||s(a,"timepicker-ui-tips-wrapper"))&&this.timepicker.minutes.click());if("mousedown"!==c&&"mousemove"!==c&&"touchmove"!==c&&"touchstart"!==c||"mousedown"!==c&&"touchstart"!==c&&"touchmove"!==c||((s(a,"timepicker-ui-clock-face")||s(a,"timepicker-ui-circle-hand")||s(a,"timepicker-ui-hour-time-12")||s(a,"timepicker-ui-minutes-time")||s(a,"timepicker-ui-clock-hand")||s(a,"timepicker-ui-value-tips")||s(a,"timepicker-ui-value-tips-24h")||s(a,"timepicker-ui-tips-wrapper")||s(a,"timepicker-ui-tips-wrapper-24h"))&&!s(a,"timepicker-ui-tips-disabled")?(e.preventDefault(),this.timepicker._isTouchMouseMove=!0):this.timepicker._isTouchMouseMove=!1),!this.timepicker._isTouchMouseMove)return;if(null!==this.timepicker.minutesTips){this.timepicker.minutes.classList.add(k);let e,i=v&&n(Math.trunc(180*v/Math.PI)+90,l,6);if(void 0===i)return;if(i<0?(e=Math.round(360+i/6)%60,i=360+6*Math.round(i/6)):(e=Math.round(i/6)%60,i=6*Math.round(i/6)),this.timepicker._disabledTime?.value.isInterval)if(this.timepicker._disabledTime?.value.endType===this.timepicker._disabledTime?.value.startType){if(this.timepicker._disabledTime?.value?.endMinutes?.includes(e<=9?`0${e}`:`${e}`)&&this.timepicker.hour.value===this.timepicker._disabledTime?.value?.removedEndHour&&this.timepicker._disabledTime?.value.endType===this.timepicker.activeTypeMode?.textContent)return;if(this.timepicker._disabledTime?.value?.startMinutes?.includes(e<=9?`0${e}`:`${e}`)&&this.timepicker.hour.value===this.timepicker._disabledTime?.value?.removedStartedHour&&this.timepicker._disabledTime?.value.startType===this.timepicker.activeTypeMode?.textContent)return}else{if(this.timepicker.activeTypeMode?.textContent===this.timepicker._disabledTime?.value.endType&&(this.timepicker._disabledTime?.value?.endMinutes?.includes(e<=9?`0${e}`:`${e}`)&&this.timepicker._disabledTime?.value.removedPmHour===this.timepicker.hour.value||this.timepicker._disabledTime?.value.pmHours.map(Number).includes(Number(this.timepicker.hour.value))))return;if(this.timepicker.activeTypeMode?.textContent===this.timepicker._disabledTime?.value.startType&&(this.timepicker._disabledTime?.value?.startMinutes?.includes(e<=9?`0${e}`:`${e}`)&&this.timepicker._disabledTime?.value.removedAmHour===this.timepicker.hour.value||this.timepicker._disabledTime?.value.amHours.map(Number).includes(Number(this.timepicker.hour.value))))return}else if(this.timepicker._disabledTime?.value?.minutes?.includes(e<=9?`0${e}`:`${e}`))return;this.timepicker.minutes.value=e>=10?`${e}`:`0${e}`,this.timepicker.clockHand.style.transform=`rotateZ(${i}deg)`,this.timepicker._degreesMinutes=i,this.timepicker.clockManager.toggleClassActiveToValueTips(this.timepicker.minutes.value),this.timepicker.clockManager.removeBgColorToCirleWithMinutesTips(),this.timepicker.clockManager.setBgColorToCircleWithMinutesTips(),r(this.timepicker._element,"update","timepicker:update",{...m(this.timepicker.input,this.timepicker._options.clockType),degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes,eventType:c,type:this.timepicker.activeTypeMode?.dataset.type},this.timepicker._options.onUpdate)}const b=o?o[0]:void 0,T=o&&b?document.elementFromPoint(b.clientX,b.clientY):null;if(null!==this.timepicker.hourTips){if(this.timepicker.hour?.classList.add(k),!s(T||a,"timepicker-ui-value-tips-24h")&&!s(T||a,"timepicker-ui-tips-disabled")&&(s(T||a,"timepicker-ui-value-tips")||s(T||a,"timepicker-ui-tips-wrapper"))){let e,i=v&&n(Math.trunc(180*v/Math.PI)+90,p,30);if(this.timepicker._degreesHours=i,void 0===i)return;i<0?(e=Math.round(360+i/30)%12,i=360+i):(e=Math.round(i/30)%12,(0===e||e>12)&&(e=12));const t=this.timepicker._disabledTime?.value.isInterval?"rangeArrHour":"hours";if(this.timepicker._disabledTime?.value.endType===this.timepicker._disabledTime?.value?.startType){if("string"==typeof this.timepicker._disabledTime?.value?.endType){if(this.timepicker._disabledTime?.value?.endType===this.timepicker.activeTypeMode?.textContent&&this.timepicker._disabledTime?.value?.startType===this.timepicker.activeTypeMode?.textContent&&this.timepicker._disabledTime?.value[t]?.includes(e.toString()))return}else if(this.timepicker._disabledTime?.value[t]?.includes(e.toString()))return}else{if(this.timepicker._disabledTime?.value.startType===this.timepicker.activeTypeMode?.textContent&&this.timepicker._disabledTime?.value.amHours.includes(e.toString()))return;if(this.timepicker._disabledTime?.value.endType===this.timepicker.activeTypeMode?.textContent&&this.timepicker._disabledTime?.value.pmHours.includes(e.toString()))return}this.timepicker.clockHand.style.transform=`rotateZ(${i}deg)`,this.timepicker.hour.value=e>9?`${e}`:`0${e}`,this.timepicker.clockManager.removeCircleClockClasses24h(),this.timepicker.clockManager.toggleClassActiveToValueTips(e)}if((s(T||a,"timepicker-ui-value-tips-24h")||s(T||a,"timepicker-ui-tips-wrapper-24h"))&&!s(T||a,"timepicker-ui-tips-disabled")){let e,i=v&&n(Math.trunc(180*v/Math.PI)+90,p,30);if(this.timepicker._degreesHours=i,void 0===i)return;i<0?(e=Math.round(360+i/30)%24,i=360+i):(e=Math.round(i/30)+12,12===e&&(e="00"));const t=this.timepicker._disabledTime?.value.isInterval?"rangeArrHour":"hours";if(this.timepicker._disabledTime?.value[t]?.includes(e.toString()))return;this.timepicker.clockManager.setCircleClockClasses24h(),this.timepicker.clockHand.style.transform=`rotateZ(${i}deg)`,this.timepicker.hour.value=`${e}`,this.timepicker.clockManager.toggleClassActiveToValueTips(e)}r(this.timepicker._element,"update","timepicker:update",{...m(this.timepicker.input,this.timepicker._options.clockType),degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes,eventType:c,type:this.timepicker.activeTypeMode?.dataset.type},this.timepicker._options.onUpdate)}};handleMoveHand=()=>{this.timepicker._options.mobile||this.timepicker._isMobileView||d.split(" ").forEach(e=>{"touchstart"===e||"touchmove"===e||"touchend"===e?document.addEventListener(e,this.timepicker._mutliEventsMoveHandler,{passive:!1}):document.addEventListener(e,this.timepicker._mutliEventsMoveHandler,!1)})};handleClickOnHourMobile=()=>{document.addEventListener("mousedown",this.timepicker._eventsClickMobileHandler),document.addEventListener("touchstart",this.timepicker._eventsClickMobileHandler)};handlerClickHourMinutes=async e=>{if(!this.timepicker.modalElement)return;const{clockType:i,editable:t}=this.timepicker._options,r=e.target,n=p(this.timepicker.hour.value,"hour",i),c=p(this.timepicker.minutes.value,"minutes",i);t&&(s(r,"timepicker-ui-hour")||s(r,"timepicker-ui-minutes")?!1!==n&&!1!==c||(c||this.timepicker.minutes.classList.add("invalid-value"),n||this.timepicker.hour?.classList.add("invalid-value")):!0===n&&!0===c&&(c&&this.timepicker.minutes.classList.remove("invalid-value"),n&&this.timepicker.hour?.classList.remove("invalid-value")))};handleIconChangeView=async()=>{this.timepicker._options.enableSwitchIcon&&(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)?this.timepicker.keyboardClockIcon.addEventListener("touchstart",this.timepicker.configManager.handlerViewChange()):this.timepicker.keyboardClockIcon.addEventListener("click",this.timepicker.configManager.handlerViewChange()))};handleKeyPress=e=>{if("Escape"===e.key&&this.timepicker.modalElement){const e=m(this.timepicker.input,this.timepicker._options.clockType);r(this.timepicker._element,"cancel","timepicker:cancel",{...e,hourNotAccepted:this.timepicker.hour.value,minutesNotAccepted:this.timepicker.minutes.value,type:this.timepicker.activeTypeMode?.dataset.type,degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes},this.timepicker._options.onCancel),this.timepicker.close()()}};handleEscClick=()=>{document.addEventListener("keydown",this.handleKeyPress)};focusTrapHandler=()=>{setTimeout(()=>{const e=this.timepicker.wrapper?.querySelectorAll('div[tabindex="0"]:not([disabled])'),i=this.timepicker.wrapper?.querySelectorAll('input[tabindex="0"]:not([disabled])');if(!e||e.length<=0||i.length<=0)return;const t=[...i,...e],r=t[0],n=t[t.length-1];this.timepicker.wrapper.focus(),this.timepicker.wrapper.addEventListener("keydown",({key:e,shiftKey:i,target:t})=>{const c=t;"Tab"===e&&(i?document.activeElement===r&&n.focus():document.activeElement===n&&r.focus()),"Enter"===e&&(s(c,"timepicker-ui-minutes")&&this.timepicker.minutes.click(),s(c,"timepicker-ui-hour")&&this.timepicker.hour.click(),s(c,"timepicker-ui-am")&&this.timepicker.AM.click(),s(c,"timepicker-ui-pm")&&this.timepicker.PM.click(),s(c,"timepicker-ui-ok-btn")&&this.timepicker.okButton.click(),s(c,"timepicker-ui-cancel-btn")&&this.timepicker.cancelButton.click(),s(c,"timepicker-ui-keyboard-icon-wrapper")&&this.timepicker.keyboardClockIcon.click())})},100)};handleInlineAutoUpdate=()=>{if(!this.timepicker._options.inline?.enabled||!1===this.timepicker._options.inline.autoUpdate)return;const e=()=>{const e=this.timepicker.hour?.value,i=this.timepicker.minutes?.value,t=this.timepicker.activeTypeMode?.textContent;if(e&&i){let s="";if("24h"===this.timepicker._options.clockType){s=`${e.padStart(2,"0")}:${i.padStart(2,"0")}`}else{s=`${e}:${i.padStart(2,"0")} ${t||"AM"}`}if(this.timepicker.input){this.timepicker.input.value=s;const n=new Event("change",{bubbles:!0});this.timepicker.input.dispatchEvent(n),r(this.timepicker._element,"accept","timepicker:confirm",{hour:e,minutes:i,type:t,degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes},this.timepicker._options.onConfirm)}}};["input","change"].forEach(i=>{this.timepicker.hour?.addEventListener(i,()=>{setTimeout(e,50)}),this.timepicker.minutes?.addEventListener(i,()=>{setTimeout(e,50)})}),"24h"!==this.timepicker._options.clockType&&this.timepicker._clickTouchEvents.forEach(i=>{this.timepicker.AM?.addEventListener(i,()=>{setTimeout(e,50)}),this.timepicker.PM?.addEventListener(i,()=>{setTimeout(e,50)})}),this.timepicker.clockFace?.addEventListener("click",()=>{setTimeout(e,100)})}}class f{timepicker;constructor(e){this.timepicker=e}setModalTemplate=()=>{if(!this.timepicker._options)return;if(this.timepicker._options.inline?.enabled){const e=document.getElementById(this.timepicker._options.inline.containerId);if(e){e.innerHTML="",e.insertAdjacentHTML("beforeend",this.timepicker.modalTemplate);const i=e.querySelector(".timepicker-ui-modal");if(i&&(i.classList.add("timepicker-ui--inline"),!1===this.timepicker._options.inline.showButtons||void 0===this.timepicker._options.inline.showButtons)){const e=i.querySelector(".timepicker-ui-wrapper-btn");e&&(e.style.display="none");const t=i.querySelector(".timepicker-ui-wrapper-btn.mobile");t&&(t.style.display="none")}}return}const{appendModalSelector:e}=this.timepicker._options;if(""!==e&&e){const i=document?.querySelector(e);i?.insertAdjacentHTML("beforeend",this.timepicker.modalTemplate)}else document.body.insertAdjacentHTML("afterend",this.timepicker.modalTemplate)};setScrollbarOrNot=()=>{this.timepicker._options.inline?.enabled||(this.timepicker._options.enableScrollbar?setTimeout(()=>{document.body.style.overflowY="",document.body.style.paddingRight=""},400):(document.body.style.paddingRight=`${(()=>{const e=document.createElement("div");e.className="timepicker-ui-measure",document.body.appendChild(e);const i=e.getBoundingClientRect().width-e.clientWidth;return document.body.removeChild(e),i})()}px`,document.body.style.overflowY="hidden"))};removeBackdrop=()=>{this.timepicker._options.inline?.enabled||this.timepicker._options.backdrop||(this.timepicker.modalElement?.classList.add("removed"),this.timepicker.openElement.forEach(e=>e?.classList.add("disabled")))};setNormalizeClass=()=>{const e=this.timepicker.modalElement?.querySelectorAll("div");this.timepicker.modalElement?.classList.add("timepicker-ui-normalize"),e?.forEach(e=>e.classList.add("timepicker-ui-normalize"))};setShowClassToBackdrop=()=>{this.timepicker._options.inline?.enabled?this.timepicker.modalElement?.classList.add("show"):this.timepicker._options.backdrop&&setTimeout(()=>{this.timepicker.modalElement.classList.add("show")},300)};setFlexEndToFooterIfNoKeyboardIcon=()=>{!this.timepicker._options.enableSwitchIcon&&this.timepicker.footer&&(this.timepicker.footer.style.justifyContent="flex-end")}}class C{timepicker;constructor(e){this.timepicker=e}setAnimationToOpen(){this.timepicker.modalElement?.classList.add("opacity"),this.timepicker._options.animation?setTimeout(()=>{this.timepicker.modalElement?.classList.add("show")},150):this.timepicker.modalElement?.classList.add("show")}removeAnimationToClose(){this.timepicker.modalElement&&(this.timepicker._options.animation?setTimeout(()=>{this.timepicker.modalElement?.classList.remove("show")},150):this.timepicker.modalElement?.classList.remove("show"))}handleAnimationClock(){this.timepicker._options.animation&&setTimeout(()=>{this.timepicker.clockFace?.classList.add("timepicker-ui-clock-animation"),setTimeout(()=>{this.timepicker.clockFace?.classList.remove("timepicker-ui-clock-animation")},600)},150)}handleAnimationSwitchTipsMode(){this.timepicker.clockHand.classList.add("timepicker-ui-tips-animation"),setTimeout(()=>{this.timepicker.clockHand?.classList.remove("timepicker-ui-tips-animation")},401)}}const E="#f7363e",w="#6200ee",L={"crane-straight":["crane-straight"],"crane-radius":["crane-straight","radius"],m3:["m3"],dark:["dark"],glassmorphic:["glassmorphic"],pastel:["pastel"],ai:["ai"],cyberpunk:["cyberpunk"]};class H{timepicker;constructor(e){this.timepicker=e}removeCircleClockClasses24h(){this.timepicker.circle?.classList.remove("timepicker-ui-circle-hand-24h"),this.timepicker.clockHand?.classList.remove("timepicker-ui-clock-hand-24h")}setCircleClockClasses24h(){this.timepicker.circle&&this.timepicker.circle?.classList.add("timepicker-ui-circle-hand-24h"),this.timepicker.clockHand&&this.timepicker.clockHand?.classList.add("timepicker-ui-clock-hand-24h")}setOnStartCSSClassesIfClockType24h(){if("24h"===this.timepicker._options.clockType){let{hour:e}=this.timepicker.configManager.getInputValue(this.timepicker.input,this.timepicker._options.clockType,this.timepicker._options.currentTime);this.timepicker.input.value.length>0&&(e=this.timepicker.input.value.split(":")[0]),(Number(e)>12||0===Number(e))&&this.setCircleClockClasses24h()}}setBgColorToCirleWithHourTips=()=>{if(!this.timepicker._options)return;const{mobile:e,theme:i}=this.timepicker._options;e||null===this.timepicker.circle||(this.timepicker.circle.style.backgroundColor="crane-straight"===i||"crane-radius"===i?E:w)};setBgColorToCircleWithMinutesTips=()=>{const{theme:e}=this.timepicker._options;this.timepicker.minutes.value&&y.includes(this.timepicker.minutes.value)&&(this.timepicker.circle.style.backgroundColor="crane-straight"===e||"crane-radius"===e?E:w,this.timepicker.circle.classList.remove("small-circle"))};removeBgColorToCirleWithMinutesTips=()=>{this.timepicker.minutes.value&&y.includes(this.timepicker.minutes.value)||(this.timepicker.circle.style.backgroundColor="",this.timepicker.circle.classList.add("small-circle"))};setClassActiveToHourOnOpen=()=>{this.timepicker._options.mobile||this.timepicker._isMobileView||this.timepicker.hour?.classList.add(k)};setMinutesToClock=e=>{null!==this.timepicker.clockFace&&this.setTransformToCircleWithSwitchesMinutes(e),this.removeBgColorToCirleWithMinutesTips();const i=this.timepicker._disabledTime?.value?.minutes?this.timepicker._disabledTime?.value?.minutes:this.timepicker._disabledTime?.value,t=new g({array:y,classToAdd:"timepicker-ui-minutes-time",clockFace:this.timepicker.clockFace,tipsWrapper:this.timepicker.tipsWrapper,theme:this.timepicker._options.theme,disabledTime:i,hour:this.timepicker.hour.value,clockType:this.timepicker._options.clockType});t.create(),"12h"===this.timepicker._options.clockType&&t.updateDisable(),this.toggleClassActiveToValueTips(e),"24h"===this.timepicker._options.clockType&&(this.timepicker.tipsWrapperFor24h.innerHTML="")};setHoursToClock=e=>{if(null!==this.timepicker.clockFace){this.setTransformToCircleWithSwitchesHour(e),this.setBgColorToCirleWithHourTips();const i=this.timepicker._disabledTime?.value?.isInterval?this.timepicker._disabledTime?.value.rangeArrHour:this.timepicker._disabledTime?.value?.hours,t=new g({array:T,classToAdd:"timepicker-ui-hour-time-12",clockFace:this.timepicker.clockFace,tipsWrapper:this.timepicker.tipsWrapper,theme:this.timepicker._options.theme,disabledTime:i,clockType:"12h",hour:this.timepicker.hour.value});t.create(),"24h"===this.timepicker._options.clockType?new g({array:b,classToAdd:"timepicker-ui-hour-time-24",clockFace:this.timepicker.tipsWrapperFor24h,tipsWrapper:this.timepicker.tipsWrapperFor24h,theme:this.timepicker._options.theme,clockType:"24h",disabledTime:i,hour:this.timepicker.hour.value}).create():t.updateDisable(),this.toggleClassActiveToValueTips(e)}};setTransformToCircleWithSwitchesHour=e=>{if(!this.timepicker.clockHand)return;const i=Number(e);let t=i>12?30*i-360:30*i;360===t&&(t=0),t>360||(this.timepicker.clockHand.style.transform=`rotateZ(${t}deg)`)};setTransformToCircleWithSwitchesMinutes=e=>{if(!this.timepicker.clockHand)return;const i=6*Number(e);i>360||(this.timepicker.clockHand.style.transform=`rotateZ(${i}deg)`)};toggleClassActiveToValueTips=e=>{const i=this.timepicker.allValueTips.find(i=>Number(i.innerText)===Number(e));this.timepicker.allValueTips.map(e=>e.classList.remove(k)),void 0!==i&&i.classList.add(k)}}class I{timepicker;constructor(e){this.timepicker=e}setErrorHandler(){const{error:e,currentHour:i,currentMin:t,currentType:s,currentLength:n}=m(this.timepicker.input,this.timepicker._options.clockType);if(e){const c=document.createElement("div");throw this.timepicker.input?.classList.add("timepicker-ui-invalid-format"),c.classList.add("timepicker-ui-invalid-text"),c.innerHTML="<b>Invalid Time Format</b>",this.timepicker.input?.parentElement&&null===this.timepicker.input?.parentElement.querySelector(".timepicker-ui-invalid-text")&&this.timepicker.input?.after(c),r(this.timepicker._element,"geterror","timepicker:error",{error:e,currentHour:i,currentMin:t,currentType:s,currentLength:n},this.timepicker._options.onError),new Error(`Invalid Time Format: ${e}`)}}removeErrorHandler(){this.timepicker.input?.classList.remove("timepicker-ui-invalid-format");const e=this.timepicker._element?.querySelector(".timepicker-ui-invalid-text");e&&e.remove()}checkDisabledValuesOnStart(){if(!this.timepicker._options.disabledTime||this.timepicker._options.disabledTime.interval)return;const{disabledTime:{hours:e,minutes:i},clockType:t}=this.timepicker._options,s=!e||_(e,"hour",t),r=!i||_(i,"minutes",t);if(!s||!r)throw new Error("You set wrong hours or minutes in disabled option")}}class S{timepicker;constructor(e){this.timepicker=e}setTheme=()=>{const e=[...this.timepicker.modalElement?.querySelectorAll("input")??[],...this.timepicker.modalElement?.querySelectorAll("div")??[]],{theme:i}=this.timepicker._options??{};i&&L[i]&&e.forEach(e=>e.classList.add(...L[i]))};setInputClassToInputElement=()=>{s(this.timepicker.input,"timepicker-ui-input")||this.timepicker.input?.classList.add("timepicker-ui-input")};setDataOpenToInputIfDosentExistInWrapper=()=>{null===this.timepicker.openElementData&&this.timepicker.input?.setAttribute("data-open","timepicker-ui-input")};setClassTopOpenElement=()=>{this.timepicker.openElement.forEach(e=>e?.classList.add("timepicker-ui-open-element"))};setTimepickerClassToElement=()=>{this.timepicker._element?.classList.add(h),this.timepicker._options.cssClass&&this.timepicker._options.cssClass!==h&&this.timepicker._element?.classList.add(this.timepicker._options.cssClass)}}class A{timepicker;constructor(e){this.timepicker=e}preventClockTypeByCurrentTime=()=>{if("boolean"!=typeof this.timepicker._options?.currentTime&&this.timepicker._options?.currentTime?.preventClockType||"boolean"==typeof this.timepicker._options?.currentTime&&this.timepicker._options?.currentTime){const{currentTime:e,clockType:i}=this.timepicker._options,{type:t}=m(this.timepicker.input,i,e,!0);this.timepicker._options.clockType=t?"12h":"24h"}};updateInputValueWithCurrentTimeOnStart=()=>{if("boolean"!=typeof this.timepicker._options?.currentTime&&this.timepicker._options?.currentTime?.updateInput||"boolean"==typeof this.timepicker._options?.currentTime&&this.timepicker._options?.currentTime){const{hour:e,minutes:i,type:t}=m(this.timepicker.input,this.timepicker._options.clockType,this.timepicker._options.currentTime);this.timepicker.input.value=t?`${e}:${i} ${t}`:`${e}:${i}`}};checkMobileOption(){this.timepicker._isMobileView=!!this.timepicker._options.mobile,this.timepicker._options.mobile&&(this.timepicker._options.editable=!0)}getDisableTime(){this.timepicker._disabledTime=(e=>{if(!e)return;const{disabledTime:i,clockType:t}=e;if(!i||Object.keys(i).length<=0||"Object"!==i.constructor.name)return;const{hours:s,interval:r,minutes:n}=i;if(r){delete i.hours,delete i.minutes;const[e,s]=r.toString().split("-"),{hour:n,minutes:a,type:l}=m({value:e.trimEnd()},t),{hour:p,minutes:u,type:h}=m({value:s.trimEnd().trimStart()},t);let d=c(n,p).map(e=>"00"===e||0===Number(e)?`0${Number(e)}`:`${Number(e)}`);const k=[],v=Number(a),b=Number(u);if(h===l)return v>0&&b<=0?(k.push(d[0],d[d.length-1]),d=d.slice(1,-1)):b<59&&b>0&&v<=0?(k.push(void 0,d[d.length-1]),d=d.slice(0,-1)):b>0&&v>0?(k.push(d[0],d[d.length-1]),d=d.slice(1,-1)):0===b&&0===v&&(k.push(void 0,d[d.length-1]),d.pop()),{value:{removedStartedHour:Number(k[0])<=9?`0${k[0]}`:k[0],removedEndHour:Number(k[1])<=9?`0${k[1]}`:k[1],rangeArrHour:d,isInterval:!0,startMinutes:c(a,59).map(e=>Number(e)<=9?`0${e}`:`${e}`),endMinutes:o(0,u).map(e=>Number(e)<=9?`0${e}`:`${e}`),endType:h,startType:l}};{const e=c(n,12).map(String),i=o(1,p).map(String),t=[],s=[];return v>0&&b<=0?(t.push(i[i.length-1]),s.push(e[0]),i.splice(-1,1),e.splice(0,1)):b<59&&b>0&&v<=0?(s.push(e[0]),t.push(i[i.length-1]),i.splice(-1,1)):b>0&&v>0?(t.push(i[i.length-1]),s.push(e[0]),i.splice(-1,1),e.splice(0,1)):0===b&&0===v&&(t.push(i[i.length-1]),s.push(e[0]),i.pop()),{value:{isInterval:!0,endType:h,startType:l,pmHours:i,amHours:e,startMinutes:0===Number(a)?[]:c(a,59).map(e=>Number(e)<=9?`0${e}`:`${e}`),endMinutes:o(0,u).map(e=>Number(e)<=9?`0${e}`:`${e}`),removedAmHour:Number(s[0])<=9?`0${s[0]}`:s[0],removedPmHour:Number(t[0])<=9?`0${t[0]}`:t[0]}}}}return s?.forEach(e=>{if("12h"===t&&Number(e)>12)throw new Error("The disabled hours value has to be less than 13");if("24h"===t&&Number(e)>23)throw new Error("The disabled hours value has to be less than 24")}),n?.forEach(e=>{if(Number(e)>59)throw new Error("The disabled minutes value has to be less than 60")}),{value:{hours:s?.map(e=>"00"===e||0===Number(e)?`0${Number(e)}`:`${Number(e)}`),minutes:n?.map(e=>Number(e)<=9?`0${e}`:`${e}`)}}})(this.timepicker._options)}getInputValueOnOpenAndSet=()=>{const e=m(this.timepicker.input,this.timepicker._options.clockType,this.timepicker._options.currentTime);if(void 0===e)return this.timepicker.hour.value="12",this.timepicker.minutes.value="00",r(this.timepicker._element,"show","timepicker:open",{hour:this.timepicker.hour.value,minutes:this.timepicker.minutes.value,type:this.timepicker.activeTypeMode?.dataset.type,degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes},this.timepicker._options.onOpen),void("24h"!==this.timepicker._options.clockType&&this.timepicker.AM.classList.add(k));let[i,t,s]=this.timepicker.input.value.split(":").join(" ").split(" ");0===this.timepicker.input.value.length&&(i=e.hour,t=e.minutes,s=e.type),this.timepicker.hour.value=i,this.timepicker.minutes.value=t;const n=this.timepicker.modalElement?.querySelector(`[data-type='${s}']`);"24h"!==this.timepicker._options.clockType&&n&&n.classList.add(k),r(this.timepicker._element,"show","timepicker:open",{...e,type:this.timepicker.activeTypeMode?.dataset.type,degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes},this.timepicker._options.onOpen)};handlerViewChange=()=>v(()=>{const{clockType:e}=this.timepicker._options;if(this.timepicker.modalElement?.classList.contains("mobile")){const i=p(this.timepicker.hour.value,"hour",e),t=p(this.timepicker.minutes.value,"minutes",e);if(!1===i||!1===t)return t||this.timepicker.minutes.classList.add("invalid-value"),void(i||this.timepicker.hour?.classList.add("invalid-value"));!0===i&&!0===t&&(t&&this.timepicker.minutes.classList.remove("invalid-value"),i&&this.timepicker.hour?.classList.remove("invalid-value")),this.timepicker.close()(),this.timepicker._isMobileView=!1,this.timepicker._options.mobile=!1;const s=this.timepicker.hour.value,r=this.timepicker.minutes.value,n=this.timepicker.activeTypeMode?.dataset.type;setTimeout(()=>{this.timepicker.destroy(),this.timepicker.update({options:{mobile:!1}}),setTimeout(()=>{if(this.timepicker.open(),this.timepicker.hour.value=s,this.timepicker.minutes.value=r,"12h"===this.timepicker._options.clockType){const e="PM"===n?"PM":"AM",i="PM"===n?"AM":"PM";this.timepicker[e].classList.add(k),this.timepicker[i].classList.remove(k)}this.timepicker.clockManager.setTransformToCircleWithSwitchesHour(this.timepicker.hour.value),this.timepicker.clockManager.toggleClassActiveToValueTips(this.timepicker.hour.value),Number(this.timepicker.hour.value)>12||0===Number(this.timepicker.hour.value)?this.timepicker.clockManager.setCircleClockClasses24h():this.timepicker.clockManager.removeCircleClockClasses24h()},300)},300)}else{this.timepicker.close()(),this.timepicker._isMobileView=!0,this.timepicker._options.mobile=!0;const e=this.timepicker.hour.value,i=this.timepicker.minutes.value,t=this.timepicker.activeTypeMode?.dataset.type;setTimeout(()=>{this.timepicker.destroy(),this.timepicker.update({options:{mobile:!0}}),setTimeout(()=>{if(this.timepicker.open(),this.timepicker.hour.value=e,this.timepicker.minutes.value=i,"12h"===this.timepicker._options.clockType){const e="PM"===t?"PM":"AM",i="PM"===t?"AM":"PM";this.timepicker[e].classList.add(k),this.timepicker[i].classList.remove(k)}},300)},300)}},this.timepicker._options.delayHandler||300);getInputValue=m}const $=new Map;e.TimepickerUI=class{_degreesHours=null;_degreesMinutes=null;_options;_eventsClickMobile=()=>Promise.resolve();_eventsClickMobileHandler=()=>{};_mutliEventsMove=()=>{};_mutliEventsMoveHandler;_clickTouchEvents;_element;_instanceId;_isMobileView;_isTouchMouseMove;_disabledTime;_cloned;_inputEvents;_isModalRemove;_isInitialized=!1;_customId;_eventHandlersRegistered=!1;_isDestroyed=!1;eventManager;modalManager;animationManager;clockManager;validationManager;themeManager;configManager;constructor(e,t){if("undefined"==typeof window)throw new Error("TimepickerUI: Cannot initialize in non-browser environment (SSR/Node.js)");const s=t?.id;if(this._customId=s,this._instanceId=s||`timepicker-ui-${"undefined"!=typeof window&&window.crypto&&"function"==typeof window.crypto.randomUUID?window.crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const i=16*Math.random()|0;return("x"===e?i:3&i|8).toString(16)})}`,s&&$.has(s))throw new Error(`TimepickerUI: Instance with ID "${s}" already exists`);let r=null;if("string"==typeof e){if(r=document.querySelector(e),!r)throw new Error(`TimepickerUI: Element with selector "${e}" not found`)}else{if(!(e instanceof HTMLElement))throw new Error("TimepickerUI: First parameter must be a string selector or HTMLElement");r=e}let n=null;if(n="INPUT"===r.tagName?r:r.querySelector("input"),!n){throw new Error(`TimepickerUI: No input element found for ${"string"==typeof e?`selector "${e}"`:"provided element"}`)}if("INPUT"===r.tagName){const e=document.createElement("div");e.className="timepicker-ui",r.parentNode?.insertBefore(e,r),e.appendChild(r),this._element=e}else this._element=r,this._element.classList.contains("timepicker-ui")||this._element.classList.add("timepicker-ui");this._cloned=null;const c=(e=>{if(!e)return;const i=JSON.parse(JSON.stringify(e)),t=Object.keys(i);return Object.values(i).reduce((e,i,s)=>(Number(i)?e[t[s]]=Number(i):e[t[s]]="true"===i||"false"===i?JSON.parse(i):i,e),{})})(this._element?.dataset);if(this._options={...i({...u,...t,...c},u)},this._options.inline?.enabled&&void 0===t?.focusTrap&&(this._options.focusTrap=!1),this._isTouchMouseMove=!1,this._degreesHours=30*Number(m(this._element?.querySelector("input"),this._options.clockType).hour),this._degreesMinutes=6*Number(m(this._element?.querySelector("input"),this._options.clockType).minutes),this._isMobileView=!1,this._mutliEventsMove=e=>this.eventManager.handleEventToMoveHand(e),this._mutliEventsMoveHandler=this._mutliEventsMove.bind(this),this._eventsClickMobile=e=>this.eventManager.handlerClickHourMinutes(e),this._eventsClickMobileHandler=this._eventsClickMobile.bind(this),this.eventManager=new M(this),this.modalManager=new f(this),this.animationManager=new C(this),this.clockManager=new H(this),this.validationManager=new I(this),this.themeManager=new S(this),this.configManager=new A(this),this.configManager.checkMobileOption(),this._clickTouchEvents=["click","mousedown","touchstart"],this._inputEvents=["change",...this._clickTouchEvents],this._disabledTime=null,this.configManager.preventClockTypeByCurrentTime(),this._isModalRemove=!0,this._isInitialized=!1,this._options.inline?.enabled){if(!this._options.inline.containerId)throw console.error("TimepickerUI: containerId is required when inline mode is enabled"),new Error("TimepickerUI: containerId is required when inline mode is enabled");if(!document.getElementById(this._options.inline.containerId))throw console.error(`TimepickerUI: Container element with ID "${this._options.inline.containerId}" not found`),new Error(`TimepickerUI: Container element with ID "${this._options.inline.containerId}" not found`)}$.set(this._instanceId,this)}static getById(e){return $.get(e)}static getAllInstances(){return Array.from($.values())}static isAvailable(e){return"undefined"!=typeof window&&("string"==typeof e?null!==document.querySelector(e):e instanceof HTMLElement&&document.contains(e))}static destroyAll(){Array.from($.values()).forEach(e=>e.destroy()),$.clear()}get modalTemplate(){return this._options.mobile&&this._isMobileView?((e,i)=>{const{mobileTimeLabel:t,amLabel:s,pmLabel:r,cancelLabel:n,okLabel:c,iconTemplateMobile:o,minuteMobileLabel:a,hourMobileLabel:l,enableSwitchIcon:m,animation:p,clockType:u,theme:h}=e;return`\n <div class="timepicker-ui-modal normalize mobile ${h}" role="dialog" data-owner-id="${i}" style='transition:${p?"opacity 0.15s linear":"none"}'>\n <div class="timepicker-ui-wrapper mobile" tabindex="0">\n <div class="timepicker-ui-header mobile">\n <div class="timepicker-ui-select-time mobile">${t}</div>\n <div class="timepicker-ui-wrapper-time mobile">\n <input class="timepicker-ui-hour mobile" tabindex="0" type="number" min="0" max="${"12h"===u?"12":"23"}" />\n <div class="timepicker-ui-hour-text mobile">${l}</div>\n <div class="timepicker-ui-dots mobile">\n <span></span>\n <span></span>\n </div> \n <div class="timepicker-ui-minute-text mobile">${a}</div>\n <input class="timepicker-ui-minutes mobile" tabindex="0" type="number" min="0" max="59" /> \n </div>\n ${"24h"!==u?`<div class="timepicker-ui-wrapper-type-time mobile">\n <div class="timepicker-ui-type-mode timepicker-ui-am mobile" data-type="AM" tabindex="0">${s}</div> \n <div class="timepicker-ui-type-mode timepicker-ui-pm mobile" data-type="PM" tabindex="0">${r}</div> \n </div>`:""}\n </div>\n <div class="timepicker-ui-footer mobile" data-view="mobile">\n ${m?`\n <div class="timepicker-ui-keyboard-icon-wrapper mobile" role="button" aria-pressed="false" data-view="desktop" tabindex="0">\n ${o}\n </div>`:""}\n <div class="timepicker-ui-wrapper-btn mobile">\n <div class="timepicker-ui-cancel-btn mobile" role="button" aria-pressed="false" tabindex="0">${n}</div>\n <div class="timepicker-ui-ok-btn mobile" role="button" aria-pressed="false" tabindex="0">${c}</div>\n </div>\n </div>\n </div> \n </div>`})(this._options,this._instanceId):((e,i)=>{const{iconTemplate:t,timeLabel:s,amLabel:r,pmLabel:n,cancelLabel:c,okLabel:o,enableSwitchIcon:a,animation:l,clockType:m,editable:p,theme:u}=e;return`\n <div class="timepicker-ui-modal normalize ${u}" role="dialog" data-owner-id="${i}" style='transition:${l?"opacity 0.15s linear":"none"}'>\n <div class="timepicker-ui-wrapper" tabindex="0">\n <div class="timepicker-ui-header">\n <div class="timepicker-ui-select-time">${s}</div>\n <div class="timepicker-ui-wrapper-time ${"24h"===m?"timepicker-ui-wrapper-time-24h":""}">\n <input name="hour" ${p?"":"readonly"} class="timepicker-ui-hour" tabindex="0" type="number" min="0" max="${"12h"===m?"12":"23"}" />\n <div class="timepicker-ui-dots"> \n <span></span>\n <span></span>\n </div> \n <input name="minutes" ${p?"":"readonly"} class="timepicker-ui-minutes" tabindex="0" type="number" min="0" max="59" /> \n </div>\n ${"24h"!==m?`\n <div class="timepicker-ui-wrapper-type-time">\n <div class="timepicker-ui-type-mode timepicker-ui-am" tabindex="0" role="button" data-type="AM">${r}</div> \n <div class="timepicker-ui-type-mode timepicker-ui-pm" tabindex="0" role="button" data-type="PM">${n}</div> \n </div>\n `:""}\n </div>\n <div class="timepicker-ui-wrapper-landspace">\n <div class="timepicker-ui-body">\n <div class="timepicker-ui-clock-face">\n <div class="timepicker-ui-dot"></div>\n <div class="timepicker-ui-clock-hand">\n <div class="timepicker-ui-circle-hand"></div>\n </div>\n <div class="timepicker-ui-tips-wrapper"></div>\n ${"24h"===m?'<div class="timepicker-ui-tips-wrapper-24h"></div>':""}\n </div>\n </div>\n <div class="timepicker-ui-footer">\n ${a?`\n <div class="timepicker-ui-keyboard-icon-wrapper" tabindex="0" role="button" aria-pressed="false" data-view="desktop">\n ${t}\n </div>`:""}\n <div class="timepicker-ui-wrapper-btn" >\n <div class="timepicker-ui-cancel-btn" tabindex="0" role="button" aria-pressed="false">${c}</div>\n <div class="timepicker-ui-ok-btn" tabindex="0" role="button" aria-pressed="false">${o}</div>\n </div>\n </div>\n </div>\n </div> \n </div>`})(this._options,this._instanceId)}get modalElement(){return document.querySelector(`[data-owner-id="${this._instanceId}"]`)}get clockFace(){return this.modalElement?.querySelector(".timepicker-ui-clock-face")}get input(){return this._element?.querySelector("input")}get clockHand(){return this.modalElement?.querySelector(".timepicker-ui-clock-hand")}get circle(){return this.modalElement?.querySelector(".timepicker-ui-circle-hand")}get tipsWrapper(){return this.modalElement?.querySelector(".timepicker-ui-tips-wrapper")}get tipsWrapperFor24h(){return this.modalElement?.querySelector(".timepicker-ui-tips-wrapper-24h")}get minutes(){return this.modalElement?.querySelector(".timepicker-ui-minutes")}get hour(){return this.modalElement?.querySelector(".timepicker-ui-hour")}get AM(){return this.modalElement?.querySelector(".timepicker-ui-am")}get PM(){return this.modalElement?.querySelector(".timepicker-ui-pm")}get minutesTips(){return this.modalElement?.querySelector(".timepicker-ui-minutes-time")}get hourTips(){return this.modalElement?.querySelector(".timepicker-ui-hour-time-12")}get allValueTips(){const e=this.modalElement;return e?[...e.querySelectorAll(".timepicker-ui-value-tips"),...e.querySelectorAll(".timepicker-ui-value-tips-24h")]:[]}get openElementData(){const e=this._element?.querySelectorAll("[data-open]");if(e?.length>0){const i=[];return e.forEach(({dataset:e})=>i.push(e.open??"")),[...new Set(i)]}return null}get openElement(){return null===this.openElementData?(this.input?.setAttribute("data-open","timepicker-ui-input"),[this.input]):this.openElementData.map(e=>this._element?.querySelectorAll(`[data-open='${e}']`))[0]??""}get cancelButton(){return this.modalElement?.querySelector(".timepicker-ui-cancel-btn")}get okButton(){return this.modalElement?.querySelector(".timepicker-ui-ok-btn")}get activeTypeMode(){return this.modalElement?.querySelector(".timepicker-ui-type-mode.active")}get keyboardClockIcon(){return this.modalElement?.querySelector(".timepicker-ui-keyboard-icon-wrapper")}get footer(){return this.modalElement?.querySelector(".timepicker-ui-footer")}get wrapper(){return this.modalElement?.querySelector(".timepicker-ui-wrapper")}getElement(){return this._element}create=()=>{this._isInitialized?console.warn("TimepickerUI: Instance is already initialized"):(this.configManager.updateInputValueWithCurrentTimeOnStart(),this.validationManager.checkDisabledValuesOnStart(),this.themeManager.setTimepickerClassToElement(),this.themeManager.setInputClassToInputElement(),this.themeManager.setDataOpenToInputIfDosentExistInWrapper(),this.themeManager.setClassTopOpenElement(),this._options.inline?.enabled?(this.eventManager.handleOpenOnEnterFocus(),this._eventsBundle()):(this.eventManager.handleOpenOnEnterFocus(),this.eventManager.handleOpenOnClick()),this.configManager.getDisableTime(),this._isInitialized=!0)};open=e=>{this._isInitialized||this.create(),this._eventsBundle(),a(e)};close=()=>v((...e)=>{if(e.length>2||!this.modalElement)return;const[i]=e.filter(e=>"boolean"==typeof e),[t]=e.filter(e=>"function"==typeof e);i&&(this.eventManager.handleOkButton(),this.okButton?.click()),this._isTouchMouseMove=!1,d.split(" ").map(e=>document.removeEventListener(e,this._mutliEventsMoveHandler,!1)),document.removeEventListener("mousedown",this._eventsClickMobileHandler),document.removeEventListener("touchstart",this._eventsClickMobileHandler),document.removeEventListener("keypress",this.eventManager.handleEscClick),this.wrapper.removeEventListener("keydown",this.eventManager.focusTrapHandler),this._options.enableSwitchIcon&&(this.keyboardClockIcon.removeEventListener("touchstart",this.configManager.handlerViewChange()),this.keyboardClockIcon.removeEventListener("mousedown",this.configManager.handlerViewChange())),this.animationManager.removeAnimationToClose(),this.openElement.forEach(e=>e?.classList.remove("disabled")),setTimeout(()=>{document.body.style.overflowY="",document.body.style.paddingRight=""},400),this.openElement.forEach(e=>e?.classList.remove("disabled")),setTimeout(()=>{this._options.focusInputAfterCloseModal&&this.input?.focus(),null!==this.modalElement&&(this.modalElement.remove(),this._isModalRemove=!0)},300),a(t)},this._options.delayHandler||300);destroy=e=>{if(this._isDestroyed)return void console.warn("TimepickerUI: Instance is already destroyed");const i="function"==typeof e?{callback:e}:e||{},{keepInputValue:t=!1,callback:s}=i,r=t?this.input?.value:null;d.split(" ").forEach(e=>{document.removeEventListener(e,this._mutliEventsMoveHandler,!1)}),document.removeEventListener("mousedown",this._eventsClickMobileHandler),document.removeEventListener("touchstart",this._eventsClickMobileHandler),document.removeEventListener("keypress",this.eventManager.handleEscClick),this._options.enableSwitchIcon&&this.keyboardClockIcon&&(this.keyboardClockIcon.removeEventListener("touchstart",this.configManager.handlerViewChange()),this.keyboardClockIcon.removeEventListener("mousedown",this.configManager.handlerViewChange())),this.input&&this._inputEvents.forEach(e=>{this.input.removeEventListener(e,()=>{})}),this.modalElement?.remove(),this.openElement?.forEach(e=>{e&&(e.classList.remove("disabled","active","timepicker-ui-open-element"),e.classList.remove("basic","crane-straight","crane-radius","m3"))}),this.input&&(this.input.classList.remove("timepicker-ui-invalid-format","invalid-value","error","active","timepicker-ui-input"),this.input.removeAttribute("data-open"),this.input.removeAttribute("data-owner-id"),t&&null!==r&&(this.input.value=r)),this._element&&(this._element.classList.remove("basic","crane-straight","crane-radius","m3"),this._element.classList.remove("error","active","disabled"),this._element.removeAttribute("data-owner-id"),this._element.removeAttribute("data-open"),this._options.cssClass&&this._element.classList.remove(this._options.cssClass));const n=this._element?.querySelectorAll(".timepicker-ui-invalid-text");n?.forEach(e=>e.remove()),this._mutliEventsMoveHandler=null,this._eventsClickMobileHandler=null,this._mutliEventsMove=()=>{},this._eventsClickMobile=()=>Promise.resolve(),this._isModalRemove=!0,this._isTouchMouseMove=!1,this._disabledTime=null,this._cloned=null,this._degreesHours=null,this._degreesMinutes=null,this._isInitialized=!1,this._isDestroyed=!0,"undefined"!=typeof document&&(document.body.style.overflowY="",document.body.style.paddingRight=""),$.delete(this._instanceId),a(s)};update=(e,i)=>{this._isDestroyed?console.warn("TimepickerUI: Instance is destroyed"):(this._options={...this._options,...e.options},this.configManager.checkMobileOption(),e.create&&this.create(),a(i))};getValue=()=>{if(this._isDestroyed)return console.warn("TimepickerUI: Instance is destroyed"),{hour:"",minutes:"",time:"",degreesHours:null,degreesMinutes:null};const e=this.hour?.value||"12",i=this.minutes?.value||"00",t="24h"===this._options.clockType?void 0:this.activeTypeMode?.textContent||"AM";let s="";return s="24h"===this._options.clockType?`${e.padStart(2,"0")}:${i.padStart(2,"0")}`:`${e}:${i.padStart(2,"0")} ${t}`,{hour:e,minutes:i,type:t,time:s,degreesHours:this._degreesHours,degreesMinutes:this._degreesMinutes}};setValue=(e,i=!0)=>{if(this._isDestroyed)return void console.warn("TimepickerUI: Instance is destroyed");if(!e||"string"!=typeof e)throw new Error("TimepickerUI: setValue requires a valid time string");const t=e.trim();let s="12",r="00",n="AM";try{if("24h"===this._options.clockType){const e=t.match(/^([0-1]?[0-9]|2[0-3]):([0-5][0-9])$/);if(!e)throw new Error("Invalid 24h format. Expected HH:MM");s=e[1].padStart(2,"0"),r=e[2]}else{const e=t.match(/^(1[0-2]|[1-9]):([0-5][0-9])\s*(AM|PM)$/i);if(!e)throw new Error("Invalid 12h format. Expected HH:MM AM/PM");s=e[1],r=e[2],n=e[3].toUpperCase()}this.hour&&(this.hour.value=s,this._degreesHours=30*Number(s)),this.minutes&&(this.minutes.value=r,this._degreesMinutes=6*Number(r)),"24h"!==this._options.clockType&&this.AM&&this.PM&&("AM"===n?(this.AM.classList.add("active"),this.PM.classList.remove("active")):(this.PM.classList.add("active"),this.AM.classList.remove("active"))),i&&this.input&&(this.input.value=t),this.clockHand&&(this.clockHand.style.transform=`rotateZ(${this._degreesHours||0}deg)`)}catch(e){throw new Error(`TimepickerUI: ${e instanceof Error?e.message:"Invalid time format"}`)}};_eventsBundle=()=>{if(this._isDestroyed)console.warn("TimepickerUI: Instance is destroyed");else if(this._isModalRemove){if(this._options.inline?.enabled||this.eventManager.handleEscClick(),this.validationManager.setErrorHandler(),this.validationManager.removeErrorHandler(),this._options.inline?.enabled||(this.openElement.forEach(e=>e?.classList.add("disabled")),this.input?.blur()),this.modalManager.setScrollbarOrNot(),this.modalManager.setModalTemplate(),this.modalManager.setNormalizeClass(),this.modalManager.removeBackdrop(),this.clockManager.setBgColorToCirleWithHourTips(),this.clockManager.setOnStartCSSClassesIfClockType24h(),this.clockManager.setClassActiveToHourOnOpen(),null!==this.clockFace){const e=new g({array:T,classToAdd:"timepicker-ui-hour-time-12",clockFace:this.clockFace,tipsWrapper:this.tipsWrapper,theme:this._options.theme,disabledTime:this._disabledTime?.value?.isInterval?this._disabledTime?.value.rangeArrHour:this._disabledTime?.value?.hours,clockType:"12h",hour:this.hour.value});if(e.create(),"24h"===this._options.clockType){new g({array:b,classToAdd:"timepicker-ui-hour-time-24",clockFace:this.tipsWrapperFor24h,tipsWrapper:this.tipsWrapperFor24h,theme:this._options.theme,clockType:"24h",disabledTime:this._disabledTime?.value?.isInterval?this._disabledTime?.value.rangeArrHour:this._disabledTime?.value?.hours,hour:this.hour.value}).create()}else this._disabledTime?.value.startType===this._disabledTime?.value.endType?setTimeout(()=>{this._disabledTime?.value.startType===this.activeTypeMode?.textContent&&e.updateDisable({hoursToUpdate:this._disabledTime?.value?.rangeArrHour,minutesToUpdate:{endMinutes:this._disabledTime?.value.endMinutes,removedEndHour:this._disabledTime?.value.removedEndHour,removedStartedHour:this._disabledTime?.value.removedStartedHour,actualHour:this.hour.value,startMinutes:this._disabledTime?.value.startMinutes}})},300):setTimeout(()=>{e.updateDisable({minutesToUpdate:{actualHour:this.hour.value,pmHours:this._disabledTime?.value.pmHours,amHours:this._disabledTime?.value.amHours,activeMode:this.activeTypeMode?.textContent}})},300),e.updateDisable()}this.modalManager.setFlexEndToFooterIfNoKeyboardIcon(),setTimeout(()=>{this.themeManager.setTheme()},0),this.animationManager.setAnimationToOpen(),this.configManager.getInputValueOnOpenAndSet(),this.clockManager.toggleClassActiveToValueTips(this.hour.value),this._isMobileView||(this.clockManager.setTransformToCircleWithSwitchesHour(this.hour.value),this.animationManager.handleAnimationClock()),this.eventManager.handleMinutesEvents(),this.eventManager.handleHourEvents(),"24h"!==this._options.clockType&&(this.eventManager.handleAmClick(),this.eventManager.handlePmClick()),this.clockFace&&this.eventManager.handleMoveHand(),this.eventManager.handleCancelButton(),this.eventManager.handleOkButton(),this.modalElement&&(this.modalManager.setShowClassToBackdrop(),this._options.inline?.enabled||this.eventManager.handleBackdropClick()),this.eventManager.handleIconChangeView(),this.eventManager.handleClickOnHourMobile(),this._options.focusTrap&&this.eventManager.focusTrapHandler(),this._options.inline?.enabled&&!1!==this._options.inline.autoUpdate&&this.eventManager.handleInlineAutoUpdate()}}}});
package/package.json CHANGED
@@ -1,14 +1,35 @@
1
1
  {
2
2
  "name": "timepicker-ui",
3
- "version": "2.6.1",
4
- "description": "timepicker-ui is an easy library with timepicker. Created with TypeScript based on Material Design from Google.",
5
- "main": "./dist/timepicker-ui.js",
6
- "module": "./dist/timepicker-ui.esm.js",
7
- "types": "./dist/types/index.d.ts",
3
+ "version": "3.0.0",
4
+ "description": "timepicker-ui is a customizable time picker library built with TypeScript, inspired by Google's Material Design. Lightweight, themeable, and easy to integrate.",
5
+ "main": "./dist/index.cjs",
6
+ "module": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "style": "./dist/css/index.css",
8
9
  "repository": {
9
10
  "type": "git",
10
11
  "url": "git+https://github.com/pglejzer/timepicker-ui.git"
11
12
  },
13
+ "files": [
14
+ "dist",
15
+ "README.md",
16
+ "LICENSE"
17
+ ],
18
+ "exports": {
19
+ ".": {
20
+ "import": "./dist/index.js",
21
+ "require": "./dist/index.js"
22
+ },
23
+ "./main.css": "./dist/css/main.css",
24
+ "./index.css": "./dist/css/index.css",
25
+ "./theme-crane.css": "./dist/css/themes/theme-crane.css",
26
+ "./theme-dark.css": "./dist/css/themes/theme-dark.css",
27
+ "./theme-m3.css": "./dist/css/themes/theme-m3.css",
28
+ "./theme-glassmorphic.css": "./dist/css/themes/theme-glassmorphic.css",
29
+ "./theme-pastel.css": "./dist/css/themes/theme-pastel.css",
30
+ "./theme-ai.css": "./dist/css/themes/theme-ai.css",
31
+ "./theme-cyberpunk.css": "./dist/css/themes/theme-cyberpunk.css"
32
+ },
12
33
  "keywords": [
13
34
  "material-design",
14
35
  "material",