timepicker-ui 3.1.3 → 4.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.umd.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).TimepickerUI={})}(this,function(e){"use strict";const t=(e,t)=>({...t,...e}),i=(e,t)=>{const{touches:i}=e,{clientX:s,clientY:r}=e;if(!t)return;const{left:n,top:o}=t.getBoundingClientRect();let c={x:0,y:0};if(void 0===i)c={x:s-n,y:r-o};else if(void 0!==i&&i.length>0&&Object.keys(i).length>0){const{clientX:e,clientY:t}=i[0];c={x:e-n,y:t-o}}return 0!==Object.keys(c).length||c.constructor!==Object?c:void 0},s=(e,t)=>!!e&&e.classList.contains(t),r=(e,t,i,s,r,n)=>{if(!e)return;const o=new CustomEvent(i,{detail:s,bubbles:!0,cancelable:!0});try{if(e.dispatchEvent(o)&&t!==i){const i=new CustomEvent(t,{detail:s,bubbles:!0,cancelable:!0});e.dispatchEvent(i)}if(n&&"emit"in n&&"function"==typeof n.emit){const e=i.replace("timepicker:","").replace(/-/g,":");n.emit(e,s)}}catch(e){console.warn(`TimepickerUI: Error dispatching event ${i}:`,e)}if(r&&"function"==typeof r)try{r(s)}catch(e){console.warn(`TimepickerUI: Error in ${i} callback:`,e)}},n=(e,t,i)=>((e,t)=>Math.round(e/t)*t)(e,t*i),o=(e,t)=>Array.from({length:Number(t)-Number(e)+1},(t,i)=>Number(e)+i),c=(e,t)=>Array.from({length:Number(t)-Number(e)+1},(e,i)=>Number(t)-i).reverse(),a=e=>{e&&"function"==typeof e&&e()},l=(e="")=>{const t=e.replace(/(AM|PM|am|pm)/,e=>` ${e}`),i=new Date(`September 20, 2000 ${t}`);return`${i.getHours().toString().padStart(2,"0")}:${i.getMinutes().toString().padStart(2,"0")}`},m=e=>{const[t,i]=e.split(":"),s=Number(t),r=Number(i);return`${s<=9?"0"+s:s}:${r<=9?"0"+r:r}`},p=(e,t)=>{if(e.length<2)return!1;const i=e.map(e=>{const[i,s]=e.trim().split("-");let r,n;if("12h"===t){if(!/\s?(AM|PM|am|pm)\s?$/.test(i.trim())||!/\s?(AM|PM|am|pm)\s?$/.test(s.trim()))throw new Error(`Invalid 12h format in interval: "${e}". AM/PM is required for 12h clock type.`);r=l(i.trim()),n=l(s.trim())}else{if(/\s?(AM|PM|am|pm)\s?/.test(i.trim())||/\s?(AM|PM|am|pm)\s?/.test(s.trim()))throw new Error(`Invalid 24h format in interval: "${e}". AM/PM is not allowed for 24h clock type.`);r=m(i.trim()),n=m(s.trim())}return{start:r,end:n,original:e}});for(let e=0;e<i.length;e++)for(let t=e+1;t<i.length;t++){const s=i[e],r=i[t];if(s.start<=r.end&&s.end>=r.start||r.start<=s.end&&r.end>=s.start)throw new Error(`Overlapping time intervals detected: "${s.original}" overlaps with "${r.original}"`)}return!1},h=e=>e.replace(/[^0-9:APMapm\s]/g,""),u=(e,t)=>{let i;return(...s)=>{clearTimeout(i),i=setTimeout(()=>{e(...s)},t)}},d="timepicker-ui",k="mousedown mouseup mousemove mouseleave mouseover touchstart touchmove touchend",v="active",g=["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"],M=(e,t,i,s)=>{const r={hour:"12",minutes:"00",type:"24h"===t?void 0:"PM"};if(!e)return r;const n=e.value.trim();if(!i&&""===n)return r;if("boolean"==typeof i&&i){const e=new Date,[i,s]=e.toLocaleTimeString().split(":"),r=Number(i)<=9?`0${Number(i)}`:i;if(/[a-z]/i.test(s)&&"12h"===t){const[e,t]=s.split(" ");return{hour:r,minutes:e,type:t}}return{hour:r,minutes:s,type:void 0}}if("object"==typeof i){const{time:e,locales:r,preventClockType:n}=i,o=e??new Date;if(n&&s){const[e,t]=new Date(o).toLocaleTimeString().split(":");if(/[a-z]/i.test(t)){const[i,s]=t.split(" ");return{hour:e,minutes:i,type:s}}return{hour:Number(e)<=9?`0${Number(e)}`:e,minutes:t,type:void 0}}const[c,a]=new Date(o).toLocaleTimeString(r,{timeStyle:"short"}).split(":"),l=Number(c)<=9?`0${Number(c)}`:c;if(/[a-z]/i.test(a)&&"12h"===t){const[e,t]=a.split(" ");return{hour:l,minutes:e,type:t}}if("12h"===t){const[e,t]=new Date(`1970-01-01T${c}:${a}Z`).toLocaleTimeString("en-US",{timeZone:"UTC",hour12:!0,hour:"numeric",minute:"numeric"}).split(":"),[i,s]=t.split(" ");return{hour:Number(e)<=9?`0${Number(e)}`:e,minutes:i,type:s}}return{hour:l,minutes:a,type:void 0}}const[o,c]=n.split(" "),[a="",l=""]=o.split(":"),m=a.replace(/\D/g,""),p=l.replace(/\D/g,""),h={hour:m.padStart(2,"0"),minutes:p.padStart(2,"0"),type:"12h"===t?c:void 0};if(m.length>2||p.length>2)return{...h,error:"Invalid input: too many digits.",currentHour:a,currentMin:l};if(/[a-z]/i.test(o))return{...h,error:"Input contains invalid letters."};if(n.includes(" ")&&(!c||n.length>8||"AM"!==c&&"PM"!==c))return{...h,error:"Invalid AM/PM format or length.",currentLength:n.length,currentType:c};const u=Number(m),d=Number(p);if("12h"===t){if(u<1||u>12||d<0||d>59||"AM"!==c&&"PM"!==c)return{...h,error:"Invalid 12h time.",currentHour:u,currentMin:d,currentType:c}}else if(u<0||u>23||d<0||d>59)return{...h,error:"Invalid 24h time.",currentHour:u,currentMin:d};return h},_=(e,t,i)=>{const s=Number(e);if(Number.isNaN(s))return!1;switch(t){case"hour":return"24h"===i?s>=0&&s<=23:s>0&&s<=12;case"minutes":return s>=0&&s<=59;default:return}},b={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},f=(e,t,i,s)=>{if(e){if(Array.isArray(e)&&e.length>0){return!e.map(e=>_(e,t,i)).some(e=>!1===e)}if("string"==typeof e||"number"==typeof e){const r=_(e,t,i),n=s?.map(Number).includes(Number(e));return!(!r||n)}}},E=(e,t,i,s,r)=>{if(!(e&&t&&s&&r))return!1;const n="12h"===r?l(`${e}:${t} ${i||""}`.trim()):m(`${e}:${t}`),o=Array.isArray(s)?s:[s];for(const e of o){const[t,i]=e.trim().split("-");let s,o;if("12h"===r){const r=t.trim(),n=i.trim();if(!/\s?(AM|PM|am|pm)\s?$/.test(r)||!/\s?(AM|PM|am|pm)\s?$/.test(n)){console.warn(`Invalid 12h format in interval: "${e}". AM/PM is required for 12h clock type.`);continue}s=l(r),o=l(n)}else{const r=t.trim(),n=i.trim();if(/\s?(AM|PM|am|pm)\s?/.test(r)||/\s?(AM|PM|am|pm)\s?/.test(n)){console.warn(`Invalid 24h format in interval: "${e}". AM/PM is not allowed for 24h clock type.`);continue}s=m(r),o=m(n)}if(n>=s&&n<=o)return!1}return!0};class C{array;classToAdd;clockFace;tipsWrapper;theme;clockType;disabledTime;hour;activeTypeMode;_tipsCache=new Map;constructor(e){Object.assign(this,e)}clean=()=>{const 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;const e=(this.clockFace.offsetWidth-32)/2,t=(this.clockFace.offsetHeight-32)/2,i=e-9,s=new Set(this._tipsCache.keys()),r=document.createDocumentFragment();this.array.forEach((n,o,c)=>{const a=`${this.classToAdd}-${n}-${this.theme||"default"}`;s.delete(a);let l=this._tipsCache.get(a);l||(l=this._createTip(n),this._tipsCache.set(a,l));const{wrapper:m,tip:p}=l;this._updateTipState(m,p,n);const h=o*(360/c.length)*(Math.PI/180);m.style.left=`${e+Math.sin(h)*i}px`,m.style.bottom=`${t+Math.cos(h)*i}px`,r.appendChild(m)}),s.forEach(e=>this._tipsCache.delete(e)),this.tipsWrapper.innerHTML="",this.tipsWrapper.appendChild(r)};_createTip(e){const t=document.createElement("span"),i=document.createElement("span");i.innerHTML=e,i.setAttribute("role","option"),i.setAttribute("aria-selected","false"),i.tabIndex=0;const s="24h"===this.clockType?"timepicker-ui-value-tips-24h":"timepicker-ui-value-tips";return i.classList.add(s),t.classList.add(this.classToAdd||""),this.theme&&(t.classList.add(this.theme),i.classList.add(this.theme)),t.appendChild(i),{wrapper:t,tip:i}}_updateTipState(e,t,i){if(e.classList.remove("timepicker-ui-tips-disabled"),t.classList.remove("timepicker-ui-tips-disabled"),t.removeAttribute("aria-disabled"),t.tabIndex=0,this.disabledTime&&(Array.isArray(this.disabledTime)&&this.disabledTime.includes(i)&&(t.classList.add("timepicker-ui-tips-disabled"),e.classList.add("timepicker-ui-tips-disabled"),t.setAttribute("aria-disabled","true")),this.disabledTime.isInterval&&this.disabledTime.clockType)){const s=this.classToAdd?.includes("minutes"),r=this.classToAdd?.includes("hour");if(s&&this.hour){!E(this.hour,i,this.activeTypeMode||"",this.disabledTime.intervals||[],this.disabledTime.clockType)&&(t.classList.add("timepicker-ui-tips-disabled"),e.classList.add("timepicker-ui-tips-disabled"),t.tabIndex=-1,t.setAttribute("aria-disabled","true"))}else if(r){let s=!0;for(let e=0;e<60;e++){const t=e.toString().padStart(2,"0");if(E(i,t,this.activeTypeMode||"",this.disabledTime.intervals||[],this.disabledTime.clockType)){s=!1;break}}s&&(t.classList.add("timepicker-ui-tips-disabled"),e.classList.add("timepicker-ui-tips-disabled"),t.tabIndex=-1,t.setAttribute("aria-disabled","true"))}}}updateDisable=(e,t)=>{const i=this.tipsWrapper?.querySelectorAll("span.timepicker-ui-hour-time-12"),s=this.tipsWrapper?.querySelectorAll("span.timepicker-ui-minutes-time");if(this._removeClasses(i),this._removeClasses(s),!this.disabledTime?.isInterval||!this.disabledTime?.intervals)return;const r=this.disabledTime.intervals,n=this.disabledTime.clockType,o=t||this.activeTypeMode||"";i?.forEach(e=>{const t=e.querySelector(".timepicker-ui-value-tips");if(!t)return;const i=t.innerHTML;let s=!0;for(let e=0;e<60;e++){const t=e.toString().padStart(2,"0");if(E(i,t,o,r,n)){s=!1;break}}s&&(e.classList.add("timepicker-ui-tips-disabled"),t.classList.add("timepicker-ui-tips-disabled"),t.setAttribute("aria-disabled","true"),t.tabIndex=-1)}),s&&e&&s.forEach(t=>{const i=t.querySelector(".timepicker-ui-value-tips");if(!i)return;const s=i.innerHTML;!E(e,s,o,r,n)&&(t.classList.add("timepicker-ui-tips-disabled"),i.classList.add("timepicker-ui-tips-disabled"),i.setAttribute("aria-disabled","true"),i.tabIndex=-1)})};_removeClasses=e=>{e?.forEach(e=>{const t=e.children[0];e.classList.remove("timepicker-ui-tips-disabled"),t&&(t.classList.remove("timepicker-ui-tips-disabled"),t.removeAttribute("aria-disabled"),t.tabIndex=0)})};destroy(){this.tipsWrapper&&(this.tipsWrapper.innerHTML=""),this._tipsCache.clear(),this.array=this.classToAdd=this.theme=this.clockType=void 0,this.disabledTime=this.hour=this.activeTypeMode=void 0,this.clockFace=this.tipsWrapper=void 0}}class w{pool=[];maxSize=5;acquire(e){const t=this.pool.pop();return t?(Object.assign(t,e),t):new C(e)}release(e){this.pool.length<this.maxSize&&this.pool.push(e)}clear(){this.pool=[]}}class H{timepicker;cleanupHandlers;constructor(e,t){this.timepicker=e,this.cleanupHandlers=t}handleCancelButton=()=>{const e=()=>{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),this.timepicker.close()()};this.timepicker.cancelButton.addEventListener("click",e),this.cleanupHandlers.push(()=>{this.timepicker.cancelButton?.removeEventListener("click",e)})};handleOkButton=()=>{const e=()=>{const{clockType:e,disabledTime:t}=this.timepicker._options,i=_(this.timepicker.hour.value,"hour",e),s=_(this.timepicker.minutes.value,"minutes",e);let n;const o=f(this.timepicker.hour.value,"hour",e,t?.hours),c=f(this.timepicker.minutes.value,"minutes",e,t?.minutes);if(t?.interval&&(n=E(this.timepicker.hour.value,this.timepicker.minutes.value,this.timepicker.activeTypeMode?.textContent||"",t.interval,e)),!1===n||!1===i||!1===s||!1===o||!1===c)return!1!==n&&s&&c||this.timepicker.minutes.classList.add("invalid-value"),void(!1!==n&&i&&o||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,"","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),this.timepicker.close()()};this.timepicker.okButton?.addEventListener("click",e),this.cleanupHandlers.push(()=>{this.timepicker.okButton?.removeEventListener("click",e)})};handleBackdropClick=()=>{const e=e=>{const t=e.target;if(!s(t,"timepicker-ui-modal"))return;const i=M(this.timepicker.input,this.timepicker._options.clockType);r(this.timepicker._element,"","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),this.timepicker.close()()};this.timepicker.modalElement?.addEventListener("click",e),this.cleanupHandlers.push(()=>{this.timepicker.modalElement?.removeEventListener("click",e)})}}class L{timepicker;_isDragging=!1;_animationFrameId=null;_pendingUpdate=!1;updateHandPosition;constructor(e,t){this.timepicker=e,this.updateHandPosition=t}get isDragging(){return this._isDragging}get animationFrameId(){return this._animationFrameId}cleanup(){document.removeEventListener("mousedown",this._onDragStart,!1),document.removeEventListener("touchstart",this._onDragStart),document.removeEventListener("mousemove",this._onDragMove,!1),document.removeEventListener("mouseup",this._onDragEnd,!1),document.removeEventListener("touchmove",this._onDragMove),document.removeEventListener("touchend",this._onDragEnd,!1),document.removeEventListener("mouseleave",this._onDragEnd,!1),this._animationFrameId&&(cancelAnimationFrame(this._animationFrameId),this._animationFrameId=null),this._isDragging=!1,this._pendingUpdate=!1}_onDragStart=e=>{const t=e.target;(s(t,"timepicker-ui-clock-face")||s(t,"timepicker-ui-circle-hand")||s(t,"timepicker-ui-hour-time-12")||s(t,"timepicker-ui-minutes-time")||s(t,"timepicker-ui-clock-hand")||s(t,"timepicker-ui-value-tips")||s(t,"timepicker-ui-value-tips-24h")||s(t,"timepicker-ui-tips-wrapper")||s(t,"timepicker-ui-tips-wrapper-24h"))&&!s(t,"timepicker-ui-tips-disabled")&&(e.preventDefault(),this._isDragging=!0,this.timepicker._isTouchMouseMove=!0,document.addEventListener("mousemove",this._onDragMove,!1),document.addEventListener("mouseup",this._onDragEnd,!1),document.addEventListener("touchmove",this._onDragMove,{passive:!1}),document.addEventListener("touchend",this._onDragEnd,!1),document.addEventListener("mouseleave",this._onDragEnd,!1),this._scheduleUpdate(e))};_onDragMove=e=>{this._isDragging&&(e.preventDefault(),this._scheduleUpdate(e))};_onDragEnd=e=>{if(!this._isDragging)return;this._isDragging=!1,this.timepicker._isTouchMouseMove=!1,document.removeEventListener("mousemove",this._onDragMove,!1),document.removeEventListener("mouseup",this._onDragEnd,!1),document.removeEventListener("touchmove",this._onDragMove),document.removeEventListener("touchend",this._onDragEnd,!1),document.removeEventListener("mouseleave",this._onDragEnd,!1),this._animationFrameId&&(cancelAnimationFrame(this._animationFrameId),this._animationFrameId=null,this._pendingUpdate=!1);const t=e.target,{switchToMinutesAfterSelectHour:i}=this.timepicker._options;i&&(s(t,"timepicker-ui-value-tips")||s(t,"timepicker-ui-value-tips-24h")||s(t,"timepicker-ui-tips-wrapper"))&&this.timepicker.minutes.click()};_scheduleUpdate=e=>{this._pendingUpdate||(this._pendingUpdate=!0,this._animationFrameId=requestAnimationFrame(()=>{this._pendingUpdate=!1,this.updateHandPosition(e)}))};handleEventToMoveHand=e=>{const{type:t}=e;"mousedown"===t||"touchstart"===t?this._onDragStart(e):"mouseup"===t||"touchend"===t?this._onDragEnd(e):"mousemove"!==t&&"touchmove"!==t||!this._isDragging||this._onDragMove(e)};handleMoveHand=()=>{this.timepicker._options.mobile||this.timepicker._isMobileView||(document.addEventListener("mousedown",this._onDragStart,!1),document.addEventListener("touchstart",this._onDragStart,{passive:!1}))}}const A=(e,t)=>{if(!e)return;const i=e.querySelector(".timepicker-announcer");i&&(i.textContent="",setTimeout(()=>{i.textContent=t},100))},I=(e,t)=>{e&&e.setAttribute("aria-pressed",String(t))};class S{timepicker;cleanupHandlers;constructor(e,t){this.timepicker=e,this.cleanupHandlers=t}handleAmClick=()=>{this.timepicker._clickTouchEvents.forEach(e=>{const t=e=>{const t=e.target;t.classList.add(v),this.timepicker.PM.classList.remove(v),I(t,!0),I(this.timepicker.PM,!1),A(this.timepicker.modalElement,"AM selected"),"12h"===this.timepicker._options.clockType&&this.timepicker._options.disabledTime?.interval&&setTimeout(()=>{const e=this.timepicker.clockFacePool.acquire({clockFace:this.timepicker.clockFace,tipsWrapper:this.timepicker.tipsWrapper,disabledTime:this.timepicker._disabledTime?.value,clockType:this.timepicker._options.clockType,activeTypeMode:"AM"});e.updateDisable(this.timepicker.hour.value,"AM"),this.timepicker.clockFacePool.release(e)},300),r(this.timepicker._element,"","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,this.timepicker)};this.timepicker.AM.addEventListener(e,t),this.cleanupHandlers.push(()=>{this.timepicker.AM?.removeEventListener(e,t)})})};handlePmClick=()=>{this.timepicker._clickTouchEvents.forEach(e=>{const t=e=>{const t=e.target;t.classList.add(v),this.timepicker.AM.classList.remove(v),I(t,!0),I(this.timepicker.AM,!1),A(this.timepicker.modalElement,"PM selected"),"12h"===this.timepicker._options.clockType&&this.timepicker._options.disabledTime?.interval&&setTimeout(()=>{const e=this.timepicker.clockFacePool.acquire({clockFace:this.timepicker.clockFace,tipsWrapper:this.timepicker.tipsWrapper,disabledTime:this.timepicker._disabledTime?.value,clockType:this.timepicker._options.clockType,activeTypeMode:"PM"});e.updateDisable(this.timepicker.hour.value,"PM"),this.timepicker.clockFacePool.release(e)},300),r(this.timepicker._element,"","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,this.timepicker)};this.timepicker.PM.addEventListener(e,t),this.cleanupHandlers.push(()=>{this.timepicker.PM?.removeEventListener(e,t)})})}}class D{timepicker;cleanupHandlers;constructor(e,t){this.timepicker=e,this.cleanupHandlers=t}handleClasses24h=(e,t,i=!1)=>{const s=e.target,r=e.relatedTarget;if(this.timepicker.hourTips&&"24h"===this.timepicker._options.clockType&&(Number(s.textContent)>12||0===Number(s.textContent)?this.timepicker.clockManager&&this.timepicker.clockManager.setCircleClockClasses24h():this.timepicker.clockManager&&this.timepicker.clockManager.removeCircleClockClasses24h(),this.timepicker._options.mobile||this.timepicker.tipsWrapperFor24h?.classList.remove("timepicker-ui-tips-wrapper-24h-disabled")),s&&t)if(t.value=h(s.value.replace(/\D+/g,"")),i&&r){r.classList.contains("timepicker-ui-am")||r.classList.contains("timepicker-ui-pm")||t.click()}else i&&t.click()};handleHourEvents=()=>{this.timepicker._inputEvents.forEach(e=>{const t=e=>{const t=e.target;null!==this.timepicker.clockFace&&this.timepicker.animationManager&&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&&this.timepicker.clockManager.setCircleClockClasses24h():this.timepicker.clockManager&&this.timepicker.clockManager.removeCircleClockClasses24h(),this.timepicker._options.mobile||this.timepicker.tipsWrapperFor24h?.classList.remove("timepicker-ui-tips-wrapper-24h-disabled")),this.timepicker.clockManager&&this.timepicker.clockManager.setHoursToClock(t.value),this.timepicker.minutes.classList.remove(v),this.timepicker.hour.classList.add(v),"12h"===this.timepicker._options.clockType&&this.timepicker._options.disabledTime?.interval&&setTimeout(()=>{const e=this.timepicker.clockFacePool.acquire({clockFace:this.timepicker.clockFace,tipsWrapper:this.timepicker.tipsWrapper,disabledTime:this.timepicker._disabledTime?.value,clockType:this.timepicker._options.clockType,activeTypeMode:this.timepicker.activeTypeMode?.textContent||""});e.updateDisable(this.timepicker.hour.value,this.timepicker.activeTypeMode?.textContent||""),this.timepicker.clockFacePool.release(e)},300),r(this.timepicker._element,"","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),null!==this.timepicker.clockFace&&this.timepicker.circle.classList.remove("small-circle")};this.timepicker.hour?.addEventListener(e,t),this.cleanupHandlers.push(()=>{this.timepicker.hour?.removeEventListener(e,t)})});const e=e=>this.handleClasses24h(e,this.timepicker.hour,!0),t=e=>this.handleClasses24h(e,this.timepicker.hour,!1);this.timepicker.hour?.addEventListener("blur",e),this.timepicker.hour?.addEventListener("focus",t),this.cleanupHandlers.push(()=>{this.timepicker.hour?.removeEventListener("blur",e),this.timepicker.hour?.removeEventListener("focus",t)})};handleMinutesEvents=()=>{this.timepicker._inputEvents.forEach(e=>{const t=e=>{const t=e.target;null!==this.timepicker.clockFace&&(this.timepicker.animationManager&&this.timepicker.animationManager.handleAnimationSwitchTipsMode(),this.timepicker.clockManager&&this.timepicker.clockManager.setMinutesToClock(t.value)),"24h"===this.timepicker._options.clockType&&(this.timepicker.clockManager&&this.timepicker.clockManager.removeCircleClockClasses24h(),this.timepicker._options.mobile||this.timepicker.tipsWrapperFor24h?.classList.add("timepicker-ui-tips-wrapper-24h-disabled")),this.timepicker.hour.classList.remove(v),this.timepicker.minutes.classList.add(v),"12h"===this.timepicker._options.clockType&&this.timepicker._options.disabledTime?.interval&&setTimeout(()=>{const e=this.timepicker.clockFacePool.acquire({clockFace:this.timepicker.clockFace,tipsWrapper:this.timepicker.tipsWrapper,disabledTime:this.timepicker._disabledTime?.value,clockType:this.timepicker._options.clockType,activeTypeMode:this.timepicker.activeTypeMode?.textContent||""});e.updateDisable(this.timepicker.hour.value,this.timepicker.activeTypeMode?.textContent||""),this.timepicker.clockFacePool.release(e)},300),r(this.timepicker._element,"","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)};this.timepicker.minutes.addEventListener(e,t),this.cleanupHandlers.push(()=>{this.timepicker.minutes?.removeEventListener(e,t)})});const e=e=>this.handleClasses24h(e,this.timepicker.minutes,!0),t=e=>this.handleClasses24h(e,this.timepicker.minutes,!1);this.timepicker.minutes?.addEventListener("blur",e),this.timepicker.minutes?.addEventListener("focus",t),this.cleanupHandlers.push(()=>{this.timepicker.minutes?.removeEventListener("blur",e),this.timepicker.minutes?.removeEventListener("focus",t)})}}class ${timepicker;constructor(e){this.timepicker=e}updateHandPosition=e=>{const{target:t,type:o}=e,c=t,{incrementMinutes:a,incrementHours:l}=this.timepicker._options;if(!i(e,this.timepicker.clockFace))return;const m=i(e,this.timepicker.clockFace),p=this.timepicker.clockFace.offsetWidth/2,h=m&&Math.atan2(m.y-p,m.x-p);if(null!==this.timepicker.minutesTips){this.timepicker.minutes.classList.add(v);let e,t=h&&n(Math.trunc(180*h/Math.PI)+90,a??1,6);if(void 0===t)return;if(t<0?(e=Math.round(360+t/6)%60,t=360+6*Math.round(t/6)):(e=Math.round(t/6)%60,t=6*Math.round(t/6)),this.timepicker?._disabledTime?.value?.isInterval){const t=e<=9?`0${e}`:`${e}`,i=this.timepicker.hour.value,s=this.timepicker.activeTypeMode?.textContent||"";if(!E(i,t,s,this.timepicker._disabledTime.value.intervals,this.timepicker._options.clockType))return}else{const t=this.timepicker._disabledTime?.value?.minutes;if(t&&Array.isArray(t)&&t.includes(e<=9?`0${e}`:`${e}`))return}this.timepicker.minutes.value=e>=10?`${e}`:`0${e}`,this.timepicker.domBatcher.schedule(()=>{this.timepicker.minutes.setAttribute("aria-valuenow",this.timepicker.minutes.value),this.timepicker.clockHand.style.transform=`rotateZ(${t}deg)`}),this.timepicker._degreesMinutes=t,this.timepicker.clockManager&&(this.timepicker.clockManager.toggleClassActiveToValueTips(this.timepicker.minutes.value),this.timepicker.clockManager.removeBgColorToCirleWithMinutesTips(),this.timepicker.clockManager.setBgColorToCircleWithMinutesTips()),A(this.timepicker.modalElement,`Minute ${this.timepicker.minutes.value}`),r(this.timepicker._element,"update","timepicker:update",{...M(this.timepicker.input,this.timepicker._options.clockType),degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes,eventType:o,type:this.timepicker.activeTypeMode?.dataset.type},this.timepicker._options.onUpdate,this.timepicker)}const u=e.touches,d=u?u[0]:void 0,k=u&&d?document.elementFromPoint(d.clientX,d.clientY):null;if(null!==this.timepicker.hourTips){this.timepicker.hour?.classList.add(v);const e="24h"===this.timepicker._options.clockType;let t=!1;if(e){const e=this.timepicker.clockFace.offsetWidth/2;t=(m?Math.sqrt(Math.pow(m.x-e,2)+Math.pow(m.y-e,2)):0)<.6*e}if(!s(k||c,"timepicker-ui-tips-disabled")&&(!e||!t)&&(s(k||c,"timepicker-ui-value-tips")||s(k||c,"timepicker-ui-tips-wrapper")||s(k||c,"timepicker-ui-value-tips-24h")||s(k||c,"timepicker-ui-tips-wrapper-24h"))){let e,t=h&&n(Math.trunc(180*h/Math.PI)+90,l??1,30);if(this.timepicker._degreesHours=t,void 0===t)return;if(t<0?(e=Math.round(360+t/30)%12,t=360+t):(e=Math.round(t/30)%12,(0===e||e>12)&&(e=12)),this.timepicker._disabledTime?.value?.isInterval){const t=e>9?`${e}`:`0${e}`,i=this.timepicker.activeTypeMode?.textContent||"";let s=!0;for(let e=0;e<60;e++){if(E(t,e<=9?`0${e}`:`${e}`,i,this.timepicker._disabledTime.value.intervals,this.timepicker._options.clockType)){s=!1;break}}if(s)return}else{const t=this.timepicker._disabledTime?.value?.hours;if(t&&Array.isArray(t)&&t.includes(e.toString()))return}this.timepicker.clockHand.style.transform=`rotateZ(${t}deg)`,this.timepicker.hour.value=e>9?`${e}`:`0${e}`,this.timepicker.hour.setAttribute("aria-valuenow",this.timepicker.hour.value),this.timepicker.clockManager&&(this.timepicker.clockManager.removeCircleClockClasses24h(),this.timepicker.clockManager.toggleClassActiveToValueTips(e)),A(this.timepicker.modalElement,`Hour ${this.timepicker.hour.value}`)}if(e&&!s(k||c,"timepicker-ui-tips-disabled")&&t&&(s(k||c,"timepicker-ui-value-tips-24h")||s(k||c,"timepicker-ui-tips-wrapper-24h")||s(k||c,"timepicker-ui-value-tips")||s(k||c,"timepicker-ui-tips-wrapper"))){let e,t=h&&n(Math.trunc(180*h/Math.PI)+90,l??1,30);if(this.timepicker._degreesHours=t,void 0===t)return;if(t<0?(e=Math.round(360+t/30)%24,t=360+t):(e=Math.round(t/30)+12,12===e&&(e="00")),this.timepicker._disabledTime?.value?.isInterval){const t="number"==typeof e?e<=9?`0${e}`:`${e}`:e;let i=!0;for(let e=0;e<60;e++){if(E(t,e<=9?`0${e}`:`${e}`,"",this.timepicker._disabledTime.value.intervals,this.timepicker._options.clockType)){i=!1;break}}if(i)return}else{const t=this.timepicker._disabledTime?.value?.hours;if(t&&Array.isArray(t)&&t.includes(e.toString()))return}this.timepicker.clockManager&&this.timepicker.clockManager.setCircleClockClasses24h(),this.timepicker.clockHand.style.transform=`rotateZ(${t}deg)`,this.timepicker.hour.value=`${e}`,this.timepicker.hour.setAttribute("aria-valuenow",this.timepicker.hour.value),this.timepicker.clockManager&&this.timepicker.clockManager.toggleClassActiveToValueTips(e),A(this.timepicker.modalElement,`Hour ${this.timepicker.hour.value}`)}r(this.timepicker._element,"","timepicker:update",{...M(this.timepicker.input,this.timepicker._options.clockType),degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes,eventType:o,type:this.timepicker.activeTypeMode?.dataset.type},this.timepicker._options.onUpdate,this.timepicker)}}}class F{timepicker;cleanupHandlers;constructor(e,t){this.timepicker=e,this.cleanupHandlers=t}handleOpenOnClick=()=>{this.timepicker.openElement.forEach(e=>{const t=()=>this.timepicker._eventsBundle();e?.addEventListener("click",t),this.cleanupHandlers.push(()=>{e?.removeEventListener("click",t)})})};handleOpenOnEnterFocus=()=>{const e=({target:e,key:t})=>{e.disabled||"Enter"===t&&this.timepicker.open()};this.timepicker.input.addEventListener("keydown",e),this.cleanupHandlers.push(()=>{this.timepicker.input.removeEventListener("keydown",e)})};handleClickOnHourMobile=()=>{document.addEventListener("mousedown",this.timepicker._eventsClickMobileHandler),document.addEventListener("touchstart",this.timepicker._eventsClickMobileHandler),this.cleanupHandlers.push(()=>{document.removeEventListener("mousedown",this.timepicker._eventsClickMobileHandler),document.removeEventListener("touchstart",this.timepicker._eventsClickMobileHandler)})};handlerClickHourMinutes=async e=>{if(!this.timepicker.modalElement)return;const{clockType:t,editable:i}=this.timepicker._options,r=e.target,n=_(this.timepicker.hour.value,"hour",t),o=_(this.timepicker.minutes.value,"minutes",t);i&&(s(r,"timepicker-ui-hour")||s(r,"timepicker-ui-minutes")?!1!==n&&!1!==o||(o||this.timepicker.minutes.classList.add("invalid-value"),n||this.timepicker.hour?.classList.add("invalid-value")):!0===n&&!0===o&&(o&&this.timepicker.minutes.classList.remove("invalid-value"),n&&this.timepicker.hour?.classList.remove("invalid-value")))};handleIconChangeView=async()=>{if(this.timepicker._options.enableSwitchIcon&&this.timepicker.configManager){const e=this.timepicker.configManager.handlerViewChange();/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)?(this.timepicker.keyboardClockIcon.addEventListener("touchstart",e),this.cleanupHandlers.push(()=>{this.timepicker.keyboardClockIcon?.removeEventListener("touchstart",e)})):(this.timepicker.keyboardClockIcon.addEventListener("click",e),this.cleanupHandlers.push(()=>{this.timepicker.keyboardClockIcon?.removeEventListener("click",e)}))}};handleKeyPress=e=>{if("Escape"===e.key&&this.timepicker.modalElement){const e=M(this.timepicker.input,this.timepicker._options.clockType);r(this.timepicker._element,"","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),this.timepicker.close()()}};handleEscClick=()=>{document.addEventListener("keydown",this.handleKeyPress),this.cleanupHandlers.push(()=>{document.removeEventListener("keydown",this.handleKeyPress)})};focusTrapHandler=()=>{setTimeout(()=>{const 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;const i=[...t,...e],r=i[0],n=i[i.length-1];this.timepicker.wrapper.focus();const o=e=>{const{key:t,shiftKey:i,target:o}=e,c=o;if("Tab"===t&&(i?document.activeElement===r&&(n.focus(),e.preventDefault()):document.activeElement===n&&(r.focus(),e.preventDefault())),"ArrowUp"===t||"ArrowDown"===t||"ArrowLeft"===t||"ArrowRight"===t){const e=s(c,"timepicker-ui-value-tips")||s(c,"timepicker-ui-value-tips-24h"),i=s(c,"timepicker-ui-hour"),r=s(c,"timepicker-ui-minutes");if(e){const e=c.parentElement,i=s(e,"timepicker-ui-minutes-time"),r=s(e,"timepicker-ui-hour-time-12")||s(e,"timepicker-ui-hour-time-24");if(i){const e=parseInt(this.timepicker.minutes.value||"0");let i=e;"ArrowUp"===t||"ArrowRight"===t?i=e>=59?0:e+1:"ArrowDown"!==t&&"ArrowLeft"!==t||(i=e<=0?59:e-1);const s=i<10?`0${i}`:`${i}`,r=this.timepicker.hour.value,n=this.timepicker.activeTypeMode?.textContent||"";if(this.timepicker._disabledTime?.value?.isInterval&&this.timepicker._disabledTime?.value?.intervals){if(!E(r,s,n,this.timepicker._disabledTime.value.intervals,this.timepicker._options.clockType))return}this.timepicker.minutes.value=s,this.timepicker.minutes.setAttribute("aria-valuenow",this.timepicker.minutes.value),this.timepicker.clockManager&&(this.timepicker.clockManager.setTransformToCircleWithSwitchesMinutes(this.timepicker.minutes.value),this.timepicker.clockManager.toggleClassActiveToValueTips(i))}else if(r){const e=parseInt(this.timepicker.hour.value||"0"),i="24h"===this.timepicker._options.clockType,s=i?23:12,r=i?0:1;let n=e;"ArrowUp"===t||"ArrowRight"===t?n=e>=s?r:e+1:"ArrowDown"!==t&&"ArrowLeft"!==t||(n=e<=r?s:e-1);const o=n<10?`0${n}`:`${n}`,c=this.timepicker.activeTypeMode?.textContent||"";if(this.timepicker._disabledTime?.value?.isInterval&&this.timepicker._disabledTime?.value?.intervals){let e=!0;for(let t=0;t<60;t++){const i=t.toString().padStart(2,"0");if(E(o,i,c,this.timepicker._disabledTime.value.intervals,this.timepicker._options.clockType)){e=!1;break}}if(e)return}this.timepicker.hour.value=o,this.timepicker.hour.setAttribute("aria-valuenow",this.timepicker.hour.value),this.timepicker.clockManager&&(this.timepicker.clockManager.setTransformToCircleWithSwitchesHour(this.timepicker.hour.value),this.timepicker.clockManager.toggleClassActiveToValueTips(n))}}if(i||r){const e=parseInt(c.value)||0,s=i,r=s?"12h"===this.timepicker._options.clockType?12:23:59,n=s&&"12h"===this.timepicker._options.clockType?1:0;let o=e;"ArrowUp"===t?o=e>=r?n:e+1:"ArrowDown"===t&&(o=e<=n?r:e-1),c.value=o<10?`0${o}`:`${o}`,c.setAttribute("aria-valuenow",c.value)}}"a"!==t&&"A"!==t||!this.timepicker.AM||s(c,"timepicker-ui-hour")||s(c,"timepicker-ui-minutes")||this.timepicker.AM.click(),"p"!==t&&"P"!==t||!this.timepicker.PM||s(c,"timepicker-ui-hour")||s(c,"timepicker-ui-minutes")||this.timepicker.PM.click(),"Enter"===t&&(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())};this.timepicker.wrapper.addEventListener("keydown",o),this.cleanupHandlers.push(()=>{this.timepicker.wrapper?.removeEventListener("keydown",o)})},100)}}class P{timepicker;cleanupHandlers;constructor(e,t){this.timepicker=e,this.cleanupHandlers=t}handleInlineAutoUpdate=()=>{if(!this.timepicker._options.inline?.enabled||!1===this.timepicker._options.inline.autoUpdate)return;const e=()=>{const e=this.timepicker.hour?.value,t=this.timepicker.minutes?.value,i=this.timepicker.activeTypeMode?.textContent;if(e&&t){let s="";if("24h"===this.timepicker._options.clockType){s=`${e.padStart(2,"0")}:${t.padStart(2,"0")}`}else{s=`${e}:${t.padStart(2,"0")} ${i||"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,"","timepicker:confirm",{hour:e,minutes:t,type:i,degreesHours:this.timepicker._degreesHours,degreesMinutes:this.timepicker._degreesMinutes},this.timepicker._options.onConfirm,this.timepicker)}}};["input","change"].forEach(t=>{const i=()=>setTimeout(e,50),s=()=>setTimeout(e,50);this.timepicker.hour?.addEventListener(t,i),this.timepicker.minutes?.addEventListener(t,s),this.cleanupHandlers.push(()=>{this.timepicker.hour?.removeEventListener(t,i),this.timepicker.minutes?.removeEventListener(t,s)})}),"24h"!==this.timepicker._options.clockType&&this.timepicker._clickTouchEvents.forEach(t=>{const i=()=>setTimeout(e,50),s=()=>setTimeout(e,50);this.timepicker.AM?.addEventListener(t,i),this.timepicker.PM?.addEventListener(t,s),this.cleanupHandlers.push(()=>{this.timepicker.AM?.removeEventListener(t,i),this.timepicker.PM?.removeEventListener(t,s)})});const t=()=>setTimeout(e,100);this.timepicker.clockFace?.addEventListener("click",t),this.cleanupHandlers.push(()=>{this.timepicker.clockFace?.removeEventListener("click",t)})}}class x{_cleanupHandlers=[];buttonHandlers;dragHandlers;typeModeHandlers;inputHandlers;clockHandPositionUpdater;miscHandlers;inlineHandlers;constructor(e){this.clockHandPositionUpdater=new $(e),this.dragHandlers=new L(e,this.clockHandPositionUpdater.updateHandPosition),this.buttonHandlers=new H(e,this._cleanupHandlers),this.typeModeHandlers=new S(e,this._cleanupHandlers),this.inputHandlers=new D(e,this._cleanupHandlers),this.miscHandlers=new F(e,this._cleanupHandlers),this.inlineHandlers=new P(e,this._cleanupHandlers)}destroy(){this._cleanupHandlers.forEach(e=>{try{e()}catch(e){console.error("EventManager cleanup error:",e)}}),this._cleanupHandlers=[],this.dragHandlers.cleanup()}handleOpenOnClick=()=>this.miscHandlers.handleOpenOnClick();handleOpenOnEnterFocus=()=>this.miscHandlers.handleOpenOnEnterFocus();handleCancelButton=()=>this.buttonHandlers.handleCancelButton();handleOkButton=()=>this.buttonHandlers.handleOkButton();handleBackdropClick=()=>this.buttonHandlers.handleBackdropClick();handleAmClick=()=>this.typeModeHandlers.handleAmClick();handlePmClick=()=>this.typeModeHandlers.handlePmClick();handleHourEvents=()=>this.inputHandlers.handleHourEvents();handleMinutesEvents=()=>this.inputHandlers.handleMinutesEvents();handleEventToMoveHand=e=>this.dragHandlers.handleEventToMoveHand(e);handleMoveHand=()=>this.dragHandlers.handleMoveHand();handleClickOnHourMobile=()=>this.miscHandlers.handleClickOnHourMobile();handlerClickHourMinutes=e=>this.miscHandlers.handlerClickHourMinutes(e);handleIconChangeView=()=>this.miscHandlers.handleIconChangeView();handleEscClick=()=>this.miscHandlers.handleEscClick();focusTrapHandler=()=>this.miscHandlers.focusTrapHandler();handleInlineAutoUpdate=()=>this.inlineHandlers.handleInlineAutoUpdate();get _isDragging(){return this.dragHandlers.isDragging}get _animationFrameId(){return this.dragHandlers.animationFrameId}_onDragStart=e=>this.dragHandlers._onDragStart(e);_onDragMove=e=>this.dragHandlers._onDragMove(e);_onDragEnd=e=>this.dragHandlers._onDragEnd(e)}class N{timepicker;timeouts=[];originalOverflow;originalPaddingRight;constructor(e){this.timepicker=e}runWithTimeout(e,t=300){const i=setTimeout(e,t);this.timeouts.push(i)}clearAllTimeouts(){this.timeouts.forEach(clearTimeout),this.timeouts=[]}clearExistingModal(){const e=document.querySelector(".timepicker-ui-modal");e&&e.remove()}setModalTemplate=()=>{if(!this.timepicker._options)return;if(this.clearExistingModal(),this.timepicker._options.inline?.enabled){const e=document.getElementById(this.timepicker._options.inline.containerId);if(!e)return;e.innerHTML="",e.insertAdjacentHTML("beforeend",this.timepicker.modalTemplate);const t=e.querySelector(".timepicker-ui-modal");if(t){t.classList.add("timepicker-ui--inline");const{showButtons:e}=this.timepicker._options.inline;!1!==e&&void 0!==e||t.querySelectorAll(".timepicker-ui-wrapper-btn, .timepicker-ui-wrapper-btn.mobile").forEach(e=>e.style.display="none")}return}const{appendModalSelector:e}=this.timepicker._options;if(e){const t=document.querySelector(e);t?.insertAdjacentHTML("beforeend",this.timepicker.modalTemplate)}else document.body.insertAdjacentHTML("beforeend",this.timepicker.modalTemplate)};setScrollbarOrNot=()=>{this.timepicker._options.inline?.enabled||(this.timepicker._options.enableScrollbar?this.runWithTimeout(()=>{document.body.style.overflowY=this.originalOverflow||"",document.body.style.paddingRight=this.originalPaddingRight||""},400):(this.originalOverflow=document.body.style.overflowY,this.originalPaddingRight=document.body.style.paddingRight,document.body.style.paddingRight=`${(()=>{const e=document.createElement("div");e.className="timepicker-ui-measure",document.body.appendChild(e);const t=e.getBoundingClientRect().width-e.clientWidth;return document.body.removeChild(e),t})()}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;if(!e)return;e.classList.add("timepicker-ui-normalize");e.querySelectorAll(":scope > div").forEach(e=>e.classList.add("timepicker-ui-normalize"))};setShowClassToBackdrop=()=>{this.timepicker._options.inline?.enabled?this.timepicker.modalElement?.classList.add("show"):this.timepicker._options.backdrop&&this.runWithTimeout(()=>{this.timepicker.modalElement?.classList.add("show")},300)};setFlexEndToFooterIfNoKeyboardIcon=()=>{!this.timepicker._options.enableSwitchIcon&&this.timepicker.footer&&(this.timepicker.footer.style.justifyContent="flex-end")};destroy(){this.clearAllTimeouts(),this.timepicker._options.inline?.enabled||(document.body.style.overflowY=this.originalOverflow||"",document.body.style.paddingRight=this.originalPaddingRight||""),this.clearExistingModal()}}const O=150,W=600,q=401;class U{timepicker;timeouts=[];constructor(e){this.timepicker=e}runWithAnimation(e,t=O){if(this.timepicker._options.animation){const i=setTimeout(e,t);this.timeouts.push(i)}else e()}clearAllTimeouts(){this.timeouts.forEach(clearTimeout),this.timeouts=[]}setAnimationToOpen(){this.clearAllTimeouts(),this.timepicker.modalElement?.classList.add("opacity"),this.runWithAnimation(()=>{this.timepicker.modalElement?.classList.add("show")})}removeAnimationToClose(){this.clearAllTimeouts(),this.timepicker.modalElement&&this.runWithAnimation(()=>{this.timepicker.modalElement?.classList.remove("show"),this.timepicker.modalElement?.classList.remove("opacity")})}handleAnimationClock(){this.timepicker._options.animation&&this.runWithAnimation(()=>{this.timepicker.clockFace?.classList.add("timepicker-ui-clock-animation");const e=setTimeout(()=>{this.timepicker.clockFace?.classList.remove("timepicker-ui-clock-animation")},W);this.timeouts.push(e)})}handleAnimationSwitchTipsMode(){const{clockHand:e}=this.timepicker;if(!e)return;e.classList.add("timepicker-ui-tips-animation");const t=setTimeout(()=>{e.classList.remove("timepicker-ui-tips-animation")},q);this.timeouts.push(t)}destroy(){this.clearAllTimeouts()}}class B{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){const e=this.timepicker?.configManager?.getInputValue(this.timepicker.input,this.timepicker._options.clockType,this.timepicker._options.currentTime);let t=e?.hour;this.timepicker.input.value.length>0&&(t=this.timepicker.input.value.split(":")[0]),(Number(t)>12||0===Number(t))&&this.setCircleClockClasses24h()}}setBgColorToCircleWithMinutesTips=()=>{if(this.timepicker.minutes.value&&y.includes(this.timepicker.minutes.value)){const e=getComputedStyle(this.timepicker.circle).getPropertyValue("--timepicker-primary").trim();e&&(this.timepicker.circle.style.backgroundColor=e),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(v)};setMinutesToClock=e=>{null!==this.timepicker.clockFace&&this.setTransformToCircleWithSwitchesMinutes(e),this.removeBgColorToCirleWithMinutesTips();const t=this.timepicker._disabledTime?.value||null,i=this.timepicker.clockFacePool.acquire({array:y,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(),"12h"===this.timepicker._options.clockType&&i.updateDisable(),this.timepicker.clockFacePool.release(i),this.toggleClassActiveToValueTips(e),"24h"===this.timepicker._options.clockType&&(this.timepicker.tipsWrapperFor24h.innerHTML="")};setHoursToClock=e=>{if(null!==this.timepicker.clockFace){this.setTransformToCircleWithSwitchesHour(e);const t=this.timepicker._disabledTime?.value||null,i=this.timepicker.clockFacePool.acquire({array:T,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});if(i.create(),"24h"===this.timepicker._options.clockType){const e=this.timepicker.clockFacePool.acquire({array:g,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});e.create(),this.timepicker.clockFacePool.release(e)}else i.updateDisable();this.timepicker.clockFacePool.release(i),this.toggleClassActiveToValueTips(e)}};setTransformToCircleWithSwitchesHour=e=>{if(!this.timepicker.clockHand)return;const t=Number(e);let i=t>12?30*t-360:30*t;360===i&&(i=0),i>360||(this.timepicker.clockHand.style.transform=`rotateZ(${i}deg)`)};setTransformToCircleWithSwitchesMinutes=e=>{if(!this.timepicker.clockHand)return;const t=6*Number(e);t>360||(this.timepicker.clockHand.style.transform=`rotateZ(${t}deg)`)};toggleClassActiveToValueTips=e=>{const t=this.timepicker.allValueTips.find(t=>Number(t.innerText)===Number(e));this.timepicker.allValueTips.map(e=>{e.classList.remove(v),e.setAttribute("aria-selected","false")}),void 0!==t&&(t.classList.add(v),t.setAttribute("aria-selected","true"))}}class V{timepicker;constructor(e){this.timepicker=e}setErrorHandler(){const e=this.timepicker.input;if(!e)return;const{error:t,currentHour:i,currentMin:s,currentType:n,currentLength:o}=M(e,this.timepicker._options.clockType);if(this.removeErrorHandler(),t){const c=document.createElement("div");return c.classList.add("timepicker-ui-invalid-text"),c.innerHTML="<b>Invalid Time Format</b>",e.classList.add("timepicker-ui-invalid-format"),e.nextElementSibling?.classList.contains("timepicker-ui-invalid-text")||e.after(c),r(this.timepicker._element,"","timepicker:error",{error:t,currentHour:i,currentMin:s,currentType:n,currentLength:o},this.timepicker._options.onError,this.timepicker),console.error(`Invalid Time Format: ${t}`),!1}return!0}removeErrorHandler(){const e=this.timepicker.input;if(!e)return;e.classList.remove("timepicker-ui-invalid-format");const t=e.nextElementSibling;t?.classList.contains("timepicker-ui-invalid-text")&&t.remove()}checkDisabledValuesOnStart(){if(!this.timepicker._options.disabledTime)return;const{disabledTime:e,clockType:t}=this.timepicker._options;if(e.interval){if(!t)throw new Error("clockType is required when using disabledTime.interval");const i=Array.isArray(e.interval)?e.interval:[e.interval];try{p(i,t)}catch(e){throw new Error(`Invalid disabledTime.interval: ${e.message}`)}return}const{hours:i,minutes:s}=e,r=!i||f(i,"hour",t),n=!s||f(s,"minutes",t);if(!r||!n)throw new Error("You set wrong hours or minutes in disabled option")}destroy(){this.removeErrorHandler()}}const z={"crane-straight":["crane-straight"],"crane-radius":["crane-straight","radius"],m3:["m3"],dark:["dark"],glassmorphic:["glassmorphic"],pastel:["pastel"],ai:["ai"],cyberpunk:["cyberpunk"],custom:["custom"]};class R{timepicker;constructor(e){this.timepicker=e}setTheme=()=>{const e=this.timepicker.modalElement;if(!e||!this.timepicker._options)return;const{theme:t}=this.timepicker._options;if(!t||!z[t])return;e.querySelectorAll("input, div").forEach(e=>{Object.values(z).forEach(t=>e.classList.remove(...t)),e.classList.add(...z[t])})};setInputClassToInputElement=()=>{const e=this.timepicker.input;e&&(s(e,"timepicker-ui-input")||e.classList.add("timepicker-ui-input"))};setDataOpenToInputIfDoesntExistInWrapper=()=>{null===this.timepicker.openElementData&&this.timepicker.input&&this.timepicker.input.setAttribute("data-open","timepicker-ui-input")};setClassTopOpenElement=()=>{for(const e of this.timepicker.openElement)e&&e.classList.add("timepicker-ui-open-element")};setTimepickerClassToElement=()=>{const e=this.timepicker._element;if(!e)return;e.classList.add(d);const t=this.timepicker._options?.cssClass;t&&t!==d&&e.classList.add(t)};destroy(){const e=this.timepicker.modalElement;if(!e)return;e.querySelectorAll("input, div").forEach(e=>{Object.values(z).forEach(t=>e.classList.remove(...t))})}}class j{timepicker;timeouts=[];debouncedHandler;constructor(e){this.timepicker=e}clearAllTimeouts(){this.timeouts.forEach(clearTimeout),this.timeouts=[]}runWithTimeout(e,t){const i=setTimeout(e,t);this.timeouts.push(i)}isCurrentTimeEnabled(e){const t=this.timepicker._options?.currentTime;return"boolean"==typeof t?t:!!t?.[e]}preventClockTypeByCurrentTime=()=>{if(!this.isCurrentTimeEnabled("preventClockType"))return;const{currentTime:e,clockType:t}=this.timepicker._options,{type:i}=M(this.timepicker.input,t,e,!0);this.timepicker._options.clockType=i?"12h":"24h"};updateInputValueWithCurrentTimeOnStart=()=>{if(!this.isCurrentTimeEnabled("updateInput"))return;const{hour:e,minutes:t,type:i}=M(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(){const e=(e=>{if(!e)return;const{disabledTime:t,clockType:i}=e;if(!t||Object.keys(t).length<=0||"Object"!==t.constructor.name)return;const{hours:s,minutes:r,interval:n}=t;if(n){delete t.hours,delete t.minutes;const e=Array.isArray(n)?n:[n];if(!i)throw new Error("clockType is required when using disabledTime.interval");try{p(e,i)}catch(e){throw e}return{value:e.map(e=>{const[t,s]=e.trim().split("-"),{hour:r,minutes:n,type:a}=M({value:t.trim()},i),{hour:l,minutes:m,type:p}=M({value:s.trim()},i);let h=o(r,l).map(e=>"00"===e||0===Number(e)?`0${Number(e)}`:`${Number(e)}`);const u=[],d=Number(n),k=Number(m);if(p===a)return d>0&&k<=0?(u.push(h[0],h[h.length-1]),h=h.slice(1,-1)):k<59&&k>0&&d<=0?(u.push(void 0,h[h.length-1]),h=h.slice(0,-1)):k>0&&d>0?(u.push(h[0],h[h.length-1]),h=h.slice(1,-1)):0===k&&0===d&&(u.push(void 0,h[h.length-1]),h.pop()),{removedStartedHour:void 0!==u[0]&&Number(u[0])<=9?`0${u[0]}`:u[0],removedEndHour:void 0!==u[1]&&Number(u[1])<=9?`0${u[1]}`:u[1],rangeArrHour:h,startMinutes:o(n,59).map(e=>Number(e)<=9?`0${e}`:`${e}`),endMinutes:c(0,m).map(e=>Number(e)<=9?`0${e}`:`${e}`),startType:a,endType:p};{const e=o(r,12).map(String),t=c(1,l).map(String),i=[],s=[];return d>0&&k<=0?(s.push(t[t.length-1]),i.push(e[0]),t.pop(),e.shift()):k<59&&k>0&&d<=0?(i.push(e[0]),s.push(t[t.length-1]),t.pop()):k>0&&d>0?(s.push(t[t.length-1]),i.push(e[0]),t.pop(),e.shift()):0===k&&0===d&&(s.push(t[t.length-1]),i.push(e[0]),t.pop()),{startType:a,endType:p,amHours:e,pmHours:t,removedAmHour:i[0]&&Number(i[0])<=9?`0${i[0]}`:i[0],removedPmHour:s[0]&&Number(s[0])<=9?`0${s[0]}`:s[0],startMinutes:0===Number(n)?[]:o(n,59).map(e=>Number(e)<=9?`0${e}`:`${e}`),endMinutes:c(0,m).map(e=>Number(e)<=9?`0${e}`:`${e}`)}}}).reduce((e,t)=>(Object.entries(t).forEach(([t,i])=>{Array.isArray(i)?e[t]=Array.isArray(e[t])?[...e[t],...i]:[...i]:e[t]=i}),e),{isInterval:!0,clockType:i,intervals:e})}}return s?.forEach(e=>{if("12h"===i&&Number(e)>12)throw new Error("The disabled hours value has to be less than 13");if("24h"===i&&Number(e)>23)throw new Error("The disabled hours value has to be less than 24")}),r?.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:r?.map(e=>Number(e)<=9?`0${e}`:`${e}`)}}})(this.timepicker._options);this.timepicker._disabledTime=e||null}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(v));let[t,i,s]=this.timepicker.input.value.split(":").join(" ").split(" ");0===this.timepicker.input.value.length&&(t=e.hour,i=e.minutes,s=e.type),this.timepicker.hour.value=t,this.timepicker.minutes.value=i;const n=this.timepicker.modalElement?.querySelector(`[data-type='${s}']`);"24h"!==this.timepicker._options.clockType&&n&&n.classList.add(v),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)};handleModeSwitch(e){this.clearAllTimeouts();const t=this.timepicker.hour.value,i=this.timepicker.minutes.value,s=this.timepicker.activeTypeMode?.dataset.type;this.timepicker.close()(),this.timepicker._isMobileView=e,this.timepicker._options.mobile=e,this.runWithTimeout(()=>{this.timepicker.update({options:{mobile:e}}),this.runWithTimeout(()=>{if(this.timepicker.open(),this.timepicker.hour.value=t,this.timepicker.minutes.value=i,"12h"===this.timepicker._options.clockType){const e="PM"===s?"PM":"AM",t="PM"===s?"AM":"PM";this.timepicker[e].classList.add(v),this.timepicker[t].classList.remove(v)}this.timepicker.clockManager&&(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)}handlerViewChange=()=>{const e=this.timepicker._options.delayHandler||300;return this.debouncedHandler=u(()=>{const{clockType:e}=this.timepicker._options;if(this.timepicker.modalElement?.classList.contains("mobile")){const t=_(this.timepicker.hour.value,"hour",e),i=_(this.timepicker.minutes.value,"minutes",e);if(!t||!i)return i||this.timepicker.minutes.classList.add("invalid-value"),void(t||this.timepicker.hour.classList.add("invalid-value"));this.timepicker.minutes.classList.remove("invalid-value"),this.timepicker.hour.classList.remove("invalid-value"),this.handleModeSwitch(!1)}else this.handleModeSwitch(!0)},e),this.debouncedHandler};getInputValue=M;destroy(){this.clearAllTimeouts(),this.debouncedHandler&&"cancel"in this.debouncedHandler&&this.debouncedHandler.cancel?.()}}class Y{events=new Map;on(e,t){this.events.has(e)||this.events.set(e,new Set),this.events.get(e).add(t)}once(e,t){const i=s=>{t(s),this.off(e,i)};this.on(e,i)}off(e,t){t?this.events.get(e)?.delete(t):this.events.delete(e)}emit(e,t){this.events.get(e)?.forEach(i=>{try{i(t)}catch(t){console.error(`EventEmitter: Error in handler for "${String(e)}":`,t)}})}clear(){this.events.clear()}hasListeners(e){return(this.events.get(e)?.size??0)>0}}class Z{updates=[];rafId=null;schedule(e){this.updates.push(e),this.rafId||(this.rafId=requestAnimationFrame(()=>this.flush()))}flush(){this.updates.forEach(e=>e()),this.updates=[],this.rafId=null}destroy(){this.rafId&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.updates=[]}}class K{_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;_pendingThemeConfig;clockFacePool;eventManager;modalManager;animationManager;clockManager;validationManager;themeManager;configManager;domBatcher;_eventEmitter;constructor(e,i){if("undefined"==typeof window)throw new Error("TimepickerUI: Cannot initialize in non-browser environment (SSR/Node.js)");this._eventEmitter=new Y,this.domBatcher=new Z;const s=i?.id;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 t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}`;let r=null;if("string"==typeof e){if(r=document.querySelector(e),!r)return console.error(`TimepickerUI: Element with selector "${e}" not found`),void(this._isDestroyed=!0)}else{if(!(e instanceof HTMLElement))return console.error("TimepickerUI: First parameter must be a string selector or HTMLElement"),void(this._isDestroyed=!0);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 o=(e=>{if(!e)return;const t=JSON.parse(JSON.stringify(e)),i=Object.keys(t);return Object.values(t).reduce((e,t,s)=>(Number(t)?e[i[s]]=Number(t):"true"===t||"false"===t?e[i[s]]=JSON.parse(t):"string"!=typeof t&&"number"!=typeof t&&"boolean"!=typeof t||(e[i[s]]=t),e),{})})(this._element?.dataset);if(this._options={...t({...b,...i,...o},b)},this._options.inline?.enabled&&void 0===i?.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.clockFacePool=new w,this.eventManager=new x(this),this.modalManager=new N(this),this.animationManager=new U(this),this.clockManager=new B(this),this.validationManager=new V(this),this.themeManager=new R(this),this.configManager=new j(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`)}}get modalTemplate(){const{getMobileModalTemplate:e,getModalTemplate:t}=require("../utils/template");return this._options.mobile&&this._isMobileView?e(this._options,this._instanceId):t(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 t=[];return e.forEach(({dataset:e})=>t.push(e.open??"")),[...new Set(t)]}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}on(e,t){this._isDestroyed?console.warn("TimepickerUI: Cannot add event listener - instance failed to initialize"):this._eventEmitter.on(e,t)}once(e,t){this._isDestroyed?console.warn("TimepickerUI: Cannot add event listener - instance failed to initialize"):this._eventEmitter.once(e,t)}off(e,t){this._isDestroyed?console.warn("TimepickerUI: Cannot remove event listener - instance failed to initialize"):this._eventEmitter.off(e,t)}emit(e,t){this._eventEmitter.emit(e,t)}_applyThemeToWrapper(e){if(!this._pendingThemeConfig)return;const t={primaryColor:"--timepicker-primary",backgroundColor:"--timepicker-bg",surfaceColor:"--timepicker-surface",surfaceHoverColor:"--timepicker-surface-hover",textColor:"--timepicker-text",secondaryTextColor:"--timepicker-secondary-text",disabledTextColor:"--timepicker-disabled-text",onPrimaryColor:"--timepicker-on-primary",borderColor:"--timepicker-border",shadow:"--timepicker-shadow",borderRadius:"--timepicker-border-radius",fontFamily:"--timepicker-font-family"};Object.entries(this._pendingThemeConfig).forEach(([i,s])=>{s&&t[i]&&e.style.setProperty(t[i],s)})}}class J extends K{create=()=>{this._isDestroyed?console.warn("TimepickerUI: Cannot create - instance failed to initialize"):this._isInitialized?console.warn("TimepickerUI: Instance is already initialized"):(this.configManager.updateInputValueWithCurrentTimeOnStart(),this.validationManager.checkDisabledValuesOnStart(),this.themeManager.setTimepickerClassToElement(),this.themeManager.setInputClassToInputElement(),this.themeManager.setDataOpenToInputIfDoesntExistInWrapper(),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._isDestroyed?console.warn("TimepickerUI: Cannot open - instance failed to initialize"):(this._isInitialized||this.create(),this._eventsBundle(),a(e))};close=()=>u((...e)=>{if(e.length>2||!this.modalElement)return;const[t]=e.filter(e=>"boolean"==typeof e),[i]=e.filter(e=>"function"==typeof e);t&&(this.eventManager.handleOkButton(),this.okButton?.click()),this._isTouchMouseMove=!1,document.removeEventListener("mousedown",this.eventManager._onDragStart,!1),document.removeEventListener("touchstart",this.eventManager._onDragStart),document.removeEventListener("mousemove",this.eventManager._onDragMove,!1),document.removeEventListener("mouseup",this.eventManager._onDragEnd,!1),document.removeEventListener("touchmove",this.eventManager._onDragMove),document.removeEventListener("touchend",this.eventManager._onDragEnd,!1),document.removeEventListener("mouseleave",this.eventManager._onDragEnd,!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(i)},this._options.delayHandler||300);destroy=e=>{if(this._isDestroyed)return void console.warn("TimepickerUI: Instance is already destroyed");const t="function"==typeof e?{callback:e}:e||{},{keepInputValue:i=!1,callback:s}=t,r=i?this.input?.value:null;this.clockFacePool.clear(),this.domBatcher.destroy(),k.split(" ").forEach(e=>{document.removeEventListener(e,this._mutliEventsMoveHandler,!1)}),document.removeEventListener("mousedown",this.eventManager._onDragStart,!1),document.removeEventListener("touchstart",this.eventManager._onDragStart),document.removeEventListener("mousemove",this.eventManager._onDragMove,!1),document.removeEventListener("mouseup",this.eventManager._onDragEnd,!1),document.removeEventListener("touchmove",this.eventManager._onDragMove),document.removeEventListener("touchend",this.eventManager._onDragEnd,!1),document.removeEventListener("mouseleave",this.eventManager._onDragEnd,!1),document.removeEventListener("mousedown",this._eventsClickMobileHandler),document.removeEventListener("touchstart",this._eventsClickMobileHandler),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"),i&&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=()=>{},this._eventsClickMobileHandler=()=>{},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=""),this.onDestroy?.(),a(s)};onDestroy;_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.setOnStartCSSClassesIfClockType24h(),this.clockManager.setClassActiveToHourOnOpen(),null!==this.clockFace){const e=this.clockFacePool.acquire({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:this._disabledTime?.value?.hours,clockType:this._options.clockType,hour:this.hour.value,activeTypeMode:this.activeTypeMode?.textContent||""});if(e.create(),"24h"===this._options.clockType){const e=this.clockFacePool.acquire({array:g,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:this._disabledTime?.value?.hours,hour:this.hour.value});e.create(),this.clockFacePool.release(e)}else"12h"===this._options.clockType&&this._disabledTime?.value?.isInterval&&setTimeout(()=>{e.updateDisable(this.hour.value,this.activeTypeMode?.textContent||"")},300);this.clockFacePool.release(e)}this.modalManager.setFlexEndToFooterIfNoKeyboardIcon(),setTimeout(()=>{this.themeManager.setTheme();const e=this.modalElement?.querySelector(".timepicker-ui-wrapper");e&&(this._options.cssClass&&e.classList.add(this._options.cssClass),this._pendingThemeConfig&&this._applyThemeToWrapper(e))},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()}}}class X extends J{getValue=()=>{if(this._isDestroyed)return console.warn("TimepickerUI: Instance is destroyed"),{hour:"",minutes:"",time:"",degreesHours:null,degreesMinutes:null};const e=this.hour?.value||"12",t=this.minutes?.value||"00",i="24h"===this._options.clockType?void 0:this.activeTypeMode?.textContent||"AM";let s="";return s="24h"===this._options.clockType?`${e.padStart(2,"0")}:${t.padStart(2,"0")}`:`${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)return void console.warn("TimepickerUI: Instance is destroyed");if(!e||"string"!=typeof e)throw new Error("TimepickerUI: setValue requires a valid time string");const i=h(e.trim());let s="12",r="00",n="AM";try{if("24h"===this._options.clockType){const e=i.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=i.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.hour.setAttribute("aria-valuenow",s),this._degreesHours=30*Number(s)),this.minutes&&(this.minutes.value=r,this.minutes.setAttribute("aria-valuenow",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"))),t&&this.input&&(this.input.value=i),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"}`)}};update=(e,t)=>{this._isDestroyed?console.warn("TimepickerUI: Instance is destroyed"):(this._options={...this._options,...e.options},this.configManager.checkMobileOption(),e.create&&this.create(),a(t))};setTheme(e){if(this._isDestroyed)return void console.warn("TimepickerUI: Cannot set theme on destroyed instance");this._pendingThemeConfig=e;const t=this.modalElement?.querySelector(".timepicker-ui-wrapper");t&&this._applyThemeToWrapper(t)}}const G=new Map;class Q extends X{constructor(e,t){if(super(e,t),this._isDestroyed)return;const i=t?.id;if(i&&G.has(i))return console.error(`TimepickerUI: Instance with ID "${i}" already exists`),void(this._isDestroyed=!0);G.set(this._instanceId,this),this.onDestroy=()=>{G.delete(this._instanceId)}}static getById(e){return G.get(e)}static getAllInstances(){return Array.from(G.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(G.values()).forEach(e=>e.destroy()),G.clear()}}e.EventEmitter=Y,e.TimepickerUI=Q,e.default=Q,Object.defineProperty(e,"__esModule",{value:!0})});
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).TimepickerUI=t()}(this,function(){"use strict";const e=()=>"undefined"==typeof window,t=()=>"undefined"!=typeof document;class i{state;constructor(e,t,i,s){this.state={degreesHours:null,degreesMinutes:null,options:t,element:e,instanceId:i,isMobileView:!1,isTouchMouseMove:!1,disabledTime:null,cloned:null,isModalRemove:!0,isInitialized:!1,customId:s,eventHandlersRegistered:!1,isDestroyed:!1}}get degreesHours(){return this.state.degreesHours}get degreesMinutes(){return this.state.degreesMinutes}get options(){return this.state.options}get element(){return this.state.element}get instanceId(){return this.state.instanceId}get isMobileView(){return this.state.isMobileView}get isTouchMouseMove(){return this.state.isTouchMouseMove}get disabledTime(){return this.state.disabledTime}get cloned(){return this.state.cloned}get isModalRemove(){return this.state.isModalRemove}get isInitialized(){return this.state.isInitialized}get customId(){return this.state.customId}get eventHandlersRegistered(){return this.state.eventHandlersRegistered}get isDestroyed(){return this.state.isDestroyed}setDegreesHours(e){this.state={...this.state,degreesHours:e}}setDegreesMinutes(e){this.state={...this.state,degreesMinutes:e}}setOptions(e){this.state={...this.state,options:e}}setIsMobileView(e){this.state={...this.state,isMobileView:e}}setIsTouchMouseMove(e){this.state={...this.state,isTouchMouseMove:e}}setDisabledTime(e){this.state={...this.state,disabledTime:e}}setCloned(e){this.state={...this.state,cloned:e}}setIsModalRemove(e){this.state={...this.state,isModalRemove:e}}setIsInitialized(e){this.state={...this.state,isInitialized:e}}setEventHandlersRegistered(e){this.state={...this.state,eventHandlersRegistered:e}}setIsDestroyed(e){this.state={...this.state,isDestroyed:e}}updateOptions(e){this.state={...this.state,options:{...this.state.options,clock:{...this.state.options.clock,...e.clock||{}},ui:{...this.state.options.ui,...e.ui||{}},labels:{...this.state.options.labels,...e.labels||{}},behavior:{...this.state.options.behavior,...e.behavior||{}},callbacks:{...this.state.options.callbacks,...e.callbacks||{}}}}}reset(){this.state={...this.state,degreesHours:null,degreesMinutes:null,isTouchMouseMove:!1,disabledTime:null,cloned:null,isModalRemove:!0,isInitialized:!1,isDestroyed:!0,eventHandlersRegistered:!1}}getModalElement(){return!1===t()?null:document.querySelector(`[data-owner-id="${this.state.instanceId}"]`)}getInput(){return this.state.element?.querySelector("input")}getClockFace(){const e=this.getModalElement();return e?this.state.isMobileView?e.querySelector(".tp-ui-clock-face.mobile"):e.querySelector(".tp-ui-clock-face:not(.mobile)"):null}getClockHand(){const e=this.getModalElement();return e?this.state.isMobileView?e.querySelector(".tp-ui-mobile-clock-wrapper .tp-ui-clock-hand"):e.querySelector(".tp-ui-clock-hand:not(.mobile)"):null}getCircle(){const e=this.getModalElement();return e?this.state.isMobileView?e.querySelector(".tp-ui-mobile-clock-wrapper .tp-ui-circle-hand"):e.querySelector(".tp-ui-circle-hand:not(.mobile)"):null}getTipsWrapper(){const e=this.getModalElement();return e?this.state.isMobileView?e.querySelector(".tp-ui-mobile-clock-wrapper .tp-ui-tips-wrapper"):e.querySelector(".tp-ui-tips-wrapper:not(.mobile)"):null}getTipsWrapperFor24h(){const e=this.getModalElement();return e?this.state.isMobileView?e.querySelector(".tp-ui-mobile-clock-wrapper .tp-ui-tips-wrapper-24h"):e.querySelector(".tp-ui-tips-wrapper-24h:not(.mobile)"):null}getMinutes(){const e=this.getModalElement();return e?.querySelector(".tp-ui-minutes")||null}getHour(){const e=this.getModalElement();return e?.querySelector(".tp-ui-hour")||null}getAM(){const e=this.getModalElement();return e?.querySelector(".tp-ui-am")||null}getPM(){const e=this.getModalElement();return e?.querySelector(".tp-ui-pm")||null}getHourText(){const e=this.getModalElement();return e?.querySelector(".tp-ui-hour-text")||null}getMinutesText(){const e=this.getModalElement();return e?.querySelector(".tp-ui-minute-text")||null}getHeader(){const e=this.getModalElement();return e?.querySelector(".tp-ui-header")||null}getInputWrappers(){const e=this.getModalElement();return e?.querySelectorAll(".tp-ui-input-wrapper")||null}getDots(){const e=this.getModalElement();return e?.querySelector(".tp-ui-dots")||null}getMinutesTips(){const e=this.getModalElement();return e?.querySelector(".tp-ui-minutes-time")||null}getHourTips(){const e=this.getModalElement();return e?.querySelector(".tp-ui-hour-time-12")||null}getAllValueTips(){const e=this.getModalElement();return e?[...e.querySelectorAll(".tp-ui-value-tips"),...e.querySelectorAll(".tp-ui-value-tips-24h")]:[]}getOpenElementData(){const e=this.state.element?.querySelectorAll("[data-open]");if(e?.length>0){const t=[];return e.forEach(({dataset:e})=>t.push(e.open??"")),[...new Set(t)]}return null}getOpenElement(){const e=this.getInput(),t=this.getOpenElementData();return null===t?(e?.setAttribute("data-open","tp-ui-input"),[e]):t.map(e=>this.state.element?.querySelectorAll(`[data-open='${e}']`))[0]??""}getCancelButton(){const e=this.getModalElement();return e?.querySelector(".tp-ui-cancel-btn")||null}getOkButton(){const e=this.getModalElement();return e?.querySelector(".tp-ui-ok-btn")||null}getActiveTypeMode(){const e=this.getModalElement();return e?.querySelector(".tp-ui-type-mode.active")||null}getKeyboardClockIcon(){const e=this.getModalElement();return e?.querySelector(".tp-ui-keyboard-icon-wrapper")||null}getFooter(){const e=this.getModalElement();return e?.querySelector(".tp-ui-footer")||null}getWrapper(){const e=this.getModalElement();return e?.querySelector(".tp-ui-wrapper")||null}}const s=300,r=150,n=400,o=300,a=600,c=401,l=450,u=150;class h{core;emitter;timeouts=[];constructor(e,t){this.core=e,this.emitter=t,this.setupEventListeners()}setupEventListeners(){this.emitter.on("animation:clock",()=>{this.handleAnimationSwitchTipsMode()})}runWithAnimation(e,t=r){if(this.core.options.ui.animation){const i=setTimeout(e,t);this.timeouts.push(i)}else e()}clearAllTimeouts(){this.timeouts.forEach(clearTimeout),this.timeouts=[]}setAnimationToOpen(){this.clearAllTimeouts();const e=this.core.getModalElement();e?.classList.add("opacity"),this.runWithAnimation(()=>{this.core.getModalElement()?.classList.add("show")})}removeAnimationToClose(){this.clearAllTimeouts();this.core.getModalElement()&&this.runWithAnimation(()=>{const e=this.core.getModalElement();e?.classList.remove("show"),e?.classList.remove("opacity")})}handleAnimationClock(){this.core.options.ui.animation&&this.runWithAnimation(()=>{const e=this.core.getClockFace();e?.classList.add("tp-ui-clock-animation");const t=setTimeout(()=>{this.core.getClockFace()?.classList.remove("tp-ui-clock-animation")},a);this.timeouts.push(t)})}handleAnimationSwitchTipsMode(){const e=this.core.getClockHand();if(!e)return;e.classList.add("tp-ui-tips-animation");const t=setTimeout(()=>{this.core.getClockHand()?.classList.remove("tp-ui-tips-animation")},c);this.timeouts.push(t)}destroy(){this.clearAllTimeouts()}}const d=(e,t)=>Array.from({length:Number(t)-Number(e)+1},(t,i)=>Number(e)+i),m=(e,t)=>Array.from({length:Number(t)-Number(e)+1},(e,i)=>Number(t)-i).reverse(),p=(e="")=>{const t=e.replace(/(AM|PM|am|pm)/,e=>` ${e}`),i=new Date(`September 20, 2000 ${t}`);return`${i.getHours().toString().padStart(2,"0")}:${i.getMinutes().toString().padStart(2,"0")}`},v=e=>{const[t,i]=e.split(":");return`${t.padStart(2,"0")}:${i.padStart(2,"0")}`},g=(e,t)=>{if(e.length<2)return!1;const i=e.map(e=>{const[i,s]=e.trim().split("-");let r,n;if("12h"===t){if(!/\s?(AM|PM|am|pm)\s?$/.test(i.trim())||!/\s?(AM|PM|am|pm)\s?$/.test(s.trim()))throw new Error(`Invalid 12h format: "${e}"`);r=p(i.trim()),n=p(s.trim())}else{if(/\s?(AM|PM|am|pm)\s?/.test(i.trim())||/\s?(AM|PM|am|pm)\s?/.test(s.trim()))throw new Error(`Invalid 24h format: "${e}"`);r=v(i.trim()),n=v(s.trim())}return{start:r,end:n,original:e}});for(let e=0;e<i.length;e++)for(let t=e+1;t<i.length;t++){const s=i[e],r=i[t];if(s.start<=r.end&&s.end>=r.start||r.start<=s.end&&r.end>=s.start)throw new Error(`Overlapping intervals: "${s.original}" and "${r.original}"`)}return!1};const f=["00","13","14","15","16","17","18","19","20","21","22","23"],y=["12","1","2","3","4","5","6","7","8","9","10","11"],b=["00","05","10","15","20","25","30","35","40","45","50","55"];class T{core;emitter;timeouts=[];originalOverflow;originalPaddingRight;constructor(e,t){this.core=e,this.emitter=t}runWithTimeout(e,t=s){const i=setTimeout(e,t);this.timeouts.push(i)}clearAllTimeouts(){this.timeouts.forEach(clearTimeout),this.timeouts=[]}clearExistingModal(){if(!1===t())return;const e=document.querySelector(".tp-ui-modal");e&&e.remove()}setModalTemplate(){if(!1===t())return;this.clearExistingModal();const e=((e,t)=>{const{ui:{iconTemplate:i,enableSwitchIcon:s,animation:r,theme:n,mobile:o,editable:a,iconTemplateMobile:c},labels:{time:l,mobileTime:u,am:h,pm:d,cancel:m,ok:p,mobileMinute:v,mobileHour:g},clock:{type:f}}=e,y=o?"mobile":"";return`<div class="tp-ui-modal normalize ${y}" data-theme="${n}" role="dialog" aria-modal="true" aria-labelledby="tp-ui-label-${t}" data-owner-id="${t}" style='transition:${r?"opacity 0.15s linear":"none"}'><div class="tp-ui-wrapper ${y}" tabindex="0"><div class="tp-ui-select-time ${y}" id="tp-ui-label-${t}">${y?u:l}</div><div class="tp-ui-header ${y}"><div class="tp-ui-wrapper-time ${y} ${"24h"===f?"tp-ui-wrapper-time-24h":""}" role="group" aria-label="${y?u:l}"><div class="tp-ui-input-wrapper ${y}"><div class="tp-ui-input-ripple-wrapper ${y}" data-md3-ripple><input name="hour" ${a||y?"":"readonly"} class="tp-ui-hour ${y}" tabindex="0" type="number" min="0" max="${"12h"===f?"12":"23"}" aria-label="${y?g:"Hour"}" role="spinbutton" aria-valuenow="12"></div><div class="tp-ui-hour-text ${y}">${g}</div></div><div class="tp-ui-dots ${y}" aria-hidden="true"><span></span><span></span></div><div class="tp-ui-input-wrapper ${y}"><div class="tp-ui-input-ripple-wrapper ${y}" data-md3-ripple><input name="minutes" ${a||y?"":"readonly"} class="tp-ui-minutes ${y}" tabindex="0" type="number" min="0" max="59" aria-label="${y?v:"Minute"}" role="spinbutton" aria-valuenow="0"></div><div class="tp-ui-minute-text ${y}">${v}</div></div></div>${"24h"!==f?`<div class="tp-ui-wrapper-type-time ${y}" role="group" aria-label="Period"><div class="tp-ui-type-mode tp-ui-am ${y?"mobile":"tp-ui-ripple"}" data-md3-ripple tabindex="0" role="button" aria-label="${h}" aria-pressed="false" data-type="AM">${h}</div><div class="tp-ui-type-mode tp-ui-pm ${y?"mobile":"tp-ui-ripple"}" data-md3-ripple tabindex="0" role="button" aria-label="${d}" aria-pressed="false" data-type="PM">${d}</div></div>`:""}</div><div class="tp-ui-mobile-clock-wrapper ${y}"><div class="tp-ui-body ${y}"><div class="tp-ui-clock-face ${y}" role="group" aria-label="Clock"><div class="tp-ui-dot ${y}" aria-hidden="true"></div><div class="tp-ui-clock-hand ${y}" aria-hidden="true"><div class="tp-ui-circle-hand ${y}"></div></div><div class="tp-ui-tips-wrapper ${y}" role="listbox" aria-label="Time"></div>${"24h"===f?`<div class="tp-ui-tips-wrapper-24h ${y}" role="listbox" aria-label="24h"></div>`:""}</div></div></div><div class="tp-ui-footer ${y}" ${y?'data-view="mobile"':""}>${s?`<div class="tp-ui-keyboard-icon-wrapper ${y}" tabindex="0" role="button" aria-pressed="false" aria-label="Toggle" data-view="desktop">${y?c||`<button aria-label="Clock" type="button" class="tp-ui-keyboard-icon">${c||'<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e3e3e3"><path d="m612-292 56-56-148-148v-184h-80v216l172 172ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 320q133 0 226.5-93.5T800-480q0-133-93.5-226.5T480-800q-133 0-226.5 93.5T160-480q0 133 93.5 226.5T480-160Z"/></svg>'}</button>`:`<button aria-label="Keyboard" type="button" class="tp-ui-keyboard-icon">${i||'<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#e3e3e3"><path d="M160-200q-33 0-56.5-23.5T80-280v-400q0-33 23.5-56.5T160-760h640q33 0 56.5 23.5T880-680v400q0 33-23.5 56.5T800-200H160Zm0-80h640v-400H160v400Zm160-40h320v-80H320v80ZM200-440h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80ZM200-560h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80ZM160-280v-400 400Z"/></svg>'}</button>`}</div>`:""}<div class="tp-ui-wrapper-btn ${y}"><div class="tp-ui-cancel-btn ${y}" data-md3-ripple tabindex="0" role="button" aria-pressed="false" aria-label="${m}">${m}</div><div class="tp-ui-ok-btn ${y}" data-md3-ripple tabindex="0" role="button" aria-pressed="false" aria-label="${p}">${p}</div></div></div></div><div class="timepicker-announcer sr-only" role="status" aria-live="polite" aria-atomic="true"></div></div>`})(this.core.options,this.core.instanceId);if(this.core.options.ui.inline?.enabled){const t=document.getElementById(this.core.options.ui.inline.containerId);if(!t)return;t.innerHTML="",t.insertAdjacentHTML("beforeend",e);const i=t.querySelector(".tp-ui-modal");if(i){i.classList.add("tp-ui--inline");const{showButtons:e}=this.core.options.ui.inline;!1!==e&&void 0!==e||i.querySelectorAll(".tp-ui-wrapper-btn, .tp-ui-wrapper-btn.mobile").forEach(e=>e.style.display="none")}return}const{appendModalSelector:i}=this.core.options.ui;if(i){const t=document.querySelector(i);t?.insertAdjacentHTML("beforeend",e)}else document.body.insertAdjacentHTML("beforeend",e)}setScrollbarOrNot(){!1!==t()&&(this.core.options.ui.inline?.enabled||(this.core.options.ui.enableScrollbar?this.runWithTimeout(()=>{e()||this.runWithTimeout(()=>{"undefined"!=typeof document&&(document.body.style.overflowY=this.originalOverflow||"",document.body.style.paddingRight=this.originalPaddingRight||"")},n)},400):(this.originalOverflow=document.body.style.overflowY,this.originalPaddingRight=document.body.style.paddingRight,document.body.style.paddingRight=`${(()=>{if(!1===t())return 0;const e=document.createElement("div");e.className="tp-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(){if(this.core.options.ui.inline?.enabled||this.core.options.ui.backdrop)return;const e=this.core.getModalElement(),t=this.core.getOpenElement();e?.classList.add("removed"),t.forEach(e=>e?.classList.add("disabled"))}setNormalizeClass(){const e=this.core.getModalElement();if(!e)return;e.classList.add("tp-ui-normalize");e.querySelectorAll(":scope > div").forEach(e=>e.classList.add("tp-ui-normalize"))}setShowClassToBackdrop(){if(this.core.options.ui.inline?.enabled)return this.core.getModalElement()?.classList.add("show"),void this.setInitialFocus();this.core.options.ui.backdrop&&this.runWithTimeout(()=>{this.core.getModalElement()?.classList.add("show"),this.setInitialFocus()},r)}setInitialFocus(){if(!this.core.options.behavior.focusTrap)return;const e=this.core.getWrapper();e&&"undefined"!=typeof requestAnimationFrame&&requestAnimationFrame(()=>{e.focus()})}setFlexEndToFooterIfNoKeyboardIcon(){const e=this.core.getFooter();!this.core.options.ui.enableSwitchIcon&&e&&(e.style.justifyContent="flex-end")}destroy(){this.clearAllTimeouts(),e()||this.core.options.ui.inline?.enabled||(document.body.style.overflowY=this.originalOverflow||"",document.body.style.paddingRight=this.originalPaddingRight||""),this.clearExistingModal()}}const M=(e,t,i,s)=>{const r={hour:"12",minutes:"00",type:"24h"===t?void 0:"PM"};if(!e)return r;const n=e.value.trim();if(!i&&!n)return r;if("boolean"==typeof i&&i){const e=new Date,[i,s]=e.toLocaleTimeString().split(":"),r=i.padStart(2,"0");if(/[a-z]/i.test(s)&&"12h"===t){const[e,t]=s.split(" ");return{hour:r,minutes:e,type:t}}return{hour:r,minutes:s,type:void 0}}if("object"==typeof i){const{time:e,locales:r,preventClockType:n}=i,o=e??new Date;if(n&&s){const[e,t]=new Date(o).toLocaleTimeString().split(":");if(/[a-z]/i.test(t)){const[i,s]=t.split(" ");return{hour:e,minutes:i,type:s}}return{hour:e.padStart(2,"0"),minutes:t,type:void 0}}const a=new Date(o).toLocaleTimeString(r||"en-US",{hour:"2-digit",minute:"2-digit",hour12:"12h"===t}),[c,l]=a.split(":");if("12h"===t&&/[a-z]/i.test(l)){const e=l.trim().split(" ");return{hour:c,minutes:e[0],type:e[1]||"AM"}}return{hour:c,minutes:l.replace(/\D/g,""),type:void 0}}const[o,a]=n.split(" "),[c="",l=""]=o.split(":"),u=c.replace(/\D/g,""),h=l.replace(/\D/g,""),d={hour:u.padStart(2,"0"),minutes:h.padStart(2,"0"),type:"12h"===t?a:void 0};if(u.length>2||h.length>2)return{...d,error:"Invalid input: too many digits.",currentHour:c,currentMin:l};if(/[a-z]/i.test(o))return{...d,error:"Input contains invalid letters."};if(n.includes(" ")&&(!a||n.length>8||"AM"!==a&&"PM"!==a))return{...d,error:"Invalid AM/PM format or length.",currentLength:n.length,currentType:a};const m=Number(u),p=Number(h);if("12h"===t){if(m<1||m>12||p<0||p>59||"AM"!==a&&"PM"!==a)return{...d,error:"Invalid 12h time.",currentHour:m,currentMin:p,currentType:a}}else if(m<0||m>23||p<0||p>59)return{...d,error:"Invalid 24h time.",currentHour:m,currentMin:p};return d},k=(e,t,i)=>{const s=Number(e);if(Number.isNaN(s))return!1;switch(t){case"hour":return"24h"===i?s>=0&&s<=23:s>0&&s<=12;case"minutes":return s>=0&&s<=59;default:return}},w=(e,t,i,s)=>{if(e){if(Array.isArray(e)&&e.length>0){return!e.map(e=>k(e,t,i)).some(e=>!1===e)}if("string"==typeof e||"number"==typeof e){return!!k(e,t,i)}}},A="tp-ui",E="mousedown mouseup mousemove mouseleave mouseover touchstart touchmove touchend",L="active";class C{core;emitter;isAnimating=!1;constructor(e,t){this.core=e,this.emitter=t,this.setupEventListeners()}setupEventListeners(){this.emitter.on("switch:view",()=>{this.toggleMobileClockFace()})}isCurrentTimeEnabled(e){const t=this.core.options.clock.currentTime;return"boolean"==typeof t?t:!!t?.[e]}preventClockTypeByCurrentTime(){if(!this.isCurrentTimeEnabled("preventClockType"))return;const e=this.core.getInput();if(!e)return;const{currentTime:t,clockType:i}={currentTime:this.core.options.clock.currentTime,clockType:this.core.options.clock.type},{type:s}=M(e,i,t,!0);this.core.updateOptions({clock:{type:s?"12h":"24h"}})}updateInputValueWithCurrentTimeOnStart(){if(!this.isCurrentTimeEnabled("updateInput"))return;const e=this.core.getInput();if(!e)return;const{hour:t,minutes:i,type:s}=M(e,this.core.options.clock.type,this.core.options.clock.currentTime);e.value=s?`${t}:${i} ${s}`:`${t}:${i}`}checkMobileOption(){this.core.setIsMobileView(!!this.core.options.ui.mobile),this.core.options.ui.mobile&&this.core.updateOptions({ui:{editable:!0}})}getDisableTime(){const e=(e=>{if(!e)return;const{disabledTime:t,type:i}=e.clock;if(!t||!Object.keys(t).length)return;const{hours:s,minutes:r,interval:n}=t;if(n){delete t.hours,delete t.minutes;const e=Array.isArray(n)?n:[n];if(!i)throw new Error("clockType required for interval");return g(e,i),{value:e.map(e=>{const[t,s]=e.trim().split("-"),{hour:r,minutes:n,type:o}=M({value:t.trim()},i),{hour:a,minutes:c,type:l}=M({value:s.trim()},i);let u=d(r,a).map(e=>0===Number(e)?"00":String(Number(e)));const h=[],p=Number(n),v=Number(c);if(l===o)return p>0&&v<=0?(h.push(u[0],u[u.length-1]),u=u.slice(1,-1)):v<59&&v>0&&p<=0?(h.push(void 0,u[u.length-1]),u=u.slice(0,-1)):v>0&&p>0?(h.push(u[0],u[u.length-1]),u=u.slice(1,-1)):0===v&&0===p&&(h.push(void 0,u[u.length-1]),u.pop()),{removedStartedHour:void 0!==h[0]&&Number(h[0])<=9?`0${h[0]}`:h[0],removedEndHour:void 0!==h[1]&&Number(h[1])<=9?`0${h[1]}`:h[1],rangeArrHour:u,startMinutes:d(n,59).map(e=>Number(e)<=9?`0${e}`:`${e}`),endMinutes:m(0,c).map(e=>Number(e)<=9?`0${e}`:`${e}`),startType:o,endType:l};{const e=d(r,12).map(String),t=m(1,a).map(String),i=[],s=[];return p>0&&v<=0?(s.push(t[t.length-1]),i.push(e[0]),t.pop(),e.shift()):v<59&&v>0&&p<=0?(i.push(e[0]),s.push(t[t.length-1]),t.pop()):v>0&&p>0?(s.push(t[t.length-1]),i.push(e[0]),t.pop(),e.shift()):0===v&&0===p&&(s.push(t[t.length-1]),i.push(e[0]),t.pop()),{startType:o,endType:l,amHours:e,pmHours:t,removedAmHour:i[0]&&Number(i[0])<=9?`0${i[0]}`:i[0],removedPmHour:s[0]&&Number(s[0])<=9?`0${s[0]}`:s[0],startMinutes:0===Number(n)?[]:d(n,59).map(e=>Number(e)<=9?`0${e}`:`${e}`),endMinutes:m(0,c).map(e=>Number(e)<=9?`0${e}`:`${e}`)}}}).reduce((e,t)=>(Object.entries(t).forEach(([t,i])=>{Array.isArray(i)?e[t]=Array.isArray(e[t])?[...e[t],...i]:[...i]:e[t]=i}),e),{isInterval:!0,clockType:i,intervals:e})}}return s?.forEach(e=>{if("12h"===i&&Number(e)>12)throw new Error("The disabled hours value has to be less than 13");if("24h"===i&&Number(e)>23)throw new Error("The disabled hours value has to be less than 24")}),r?.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:r?.map(e=>Number(e)<=9?`0${e}`:`${e}`)}}})(this.core.options);this.core.setDisabledTime(e||null)}getInputValueOnOpenAndSet(){const e=this.core.getInput();if(!e)return;const t=M(e,this.core.options.clock.type,this.core.options.clock.currentTime),i=this.core.getHour(),s=this.core.getMinutes(),r=this.core.getActiveTypeMode(),n=this.core.getAM();if(void 0===t){i&&(i.value="12"),s&&(s.value="00");const e={hour:i?.value||"12",minutes:s?.value||"00",type:r?.dataset.type,degreesHours:this.core.degreesHours,degreesMinutes:this.core.degreesMinutes};return this.emitter.emit("open",e),void("24h"!==this.core.options.clock.type&&n&&n.classList.add(L))}let[o,a,c]=e.value.split(":").join(" ").split(" ");0===e.value.length&&(o=t.hour,a=t.minutes,c=t.type),i&&(i.value=o.padStart(2,"0")),s&&(s.value=a.padStart(2,"0"));const l=this.core.getModalElement(),u=l?.querySelector(`[data-type='${c}']`);"24h"!==this.core.options.clock.type&&u&&u.classList.add(L);const h={...t,type:r?.dataset.type,degreesHours:this.core.degreesHours,degreesMinutes:this.core.degreesMinutes};this.emitter.emit("open",h)}getInputValue(e,t,i){return M(e,t,i)}toggleMobileClockFace(){if(this.isAnimating)return;const e=this.core.getModalElement();if(!e)return;const t=e.querySelector(".tp-ui-wrapper"),i=this.core.getKeyboardClockIcon(),s=e.querySelector(".tp-ui-mobile-clock-wrapper"),r=e.querySelectorAll("*"),n=e.querySelector(".tp-ui-select-time"),o=this.core.getHour(),a=this.core.getMinutes(),c=this.core.getClockFace();if(!t)return;const l=t.classList.contains("expanded"),u=this.core.isMobileView;l?this.collapseClockFace(t,s,r,i,n,o,a,c,u):this.expandClockFace(t,s,r,i,n,o,a,c)}collapseClockFace(e,t,i,s,r,n,o,a,c){this.isAnimating=!0,this.switchView(r,s,n,o,!0),i.forEach(i=>{i!==t&&i!==e&&i!==r&&(i.classList.remove("expanded"),c&&i.classList.add("mobile"))}),r&&(r.classList.remove("expanded"),c&&r.classList.add("mobile")),"undefined"!=typeof requestAnimationFrame?requestAnimationFrame(()=>{t?.classList.remove("expanded"),c&&t?.classList.add("mobile"),e?.classList.remove("expanded"),c&&e?.classList.add("mobile"),c?a?.classList.remove("scale-in"):a?.classList.add("scale-in"),setTimeout(()=>{this.isAnimating=!1},l)}):this.isAnimating=!1,s?.setAttribute("aria-label","Show clock face"),s?.setAttribute("aria-pressed","false")}expandClockFace(e,t,i,s,r,n,o,a){this.isAnimating=!0;const c=o?.classList.contains("active");c&&o?this.emitter.emit("select:minute",{minutes:o.value}):n&&this.emitter.emit("select:hour",{hour:n.value}),i.forEach(i=>{i!==t&&i!==e&&i!==r&&(i.classList.remove("mobile"),i.classList.add("expanded"))}),r&&(r.classList.remove("mobile"),r.classList.add("expanded")),this.switchView(r,s,n,o,!1),"undefined"!=typeof requestAnimationFrame?requestAnimationFrame(()=>{e.classList.remove("mobile"),e.classList.add("expanded"),requestAnimationFrame(()=>{t&&(t.classList.remove("mobile"),t.classList.add("expanded")),a&&a.classList.remove("scale-in"),setTimeout(()=>{a&&a.classList.add("scale-in")},u),setTimeout(()=>{this.isAnimating=!1},l)})}):this.isAnimating=!1,s?.setAttribute("aria-label","Hide clock face"),s?.setAttribute("aria-pressed","true")}switchView(e,t,i,s,r){r?(e?.classList.remove("mobile"),t?.classList.remove("mobile"),i?.classList.remove("mobile"),s?.classList.remove("mobile"),this.updateClockFaceAccessibility(!1)):(e?.classList.add("mobile"),t?.classList.add("mobile"),i?.classList.add("mobile"),s?.classList.add("mobile"),this.updateClockFaceAccessibility(!0))}updateClockFaceAccessibility(e){const t=this.core.getClockFace();if(!t)return;const i=t.querySelector(".tp-ui-tips-wrapper"),s=t.querySelector(".tp-ui-tips-wrapper-24h"),r=t.querySelectorAll(".tp-ui-tip");e?(t.setAttribute("aria-hidden","true"),i?.setAttribute("aria-hidden","true"),s?.setAttribute("aria-hidden","true"),r.forEach(e=>{e.setAttribute("tabindex","-1"),e.setAttribute("aria-hidden","true")})):(t.removeAttribute("aria-hidden"),i?.removeAttribute("aria-hidden"),s?.removeAttribute("aria-hidden"),r.forEach(e=>{e.setAttribute("tabindex","0"),e.removeAttribute("aria-hidden")}))}destroy(){}}class S{core;emitter;constructor(e,t){this.core=e,this.emitter=t}setTheme(){const e=this.core.getModalElement();if(!e)return;const{theme:t}=this.core.options.ui;t&&e.setAttribute("data-theme",t)}setInputClassToInputElement(){const e=this.core.getInput();var t,i;e&&(i="tp-ui-input",(t=e)&&t.classList.contains(i)||e.classList.add("tp-ui-input"))}setDataOpenToInputIfDoesntExistInWrapper(){const e=this.core.getOpenElementData(),t=this.core.getInput();null===e&&t&&t.setAttribute("data-open","tp-ui-input")}setClassTopOpenElement(){const e=this.core.getOpenElement();for(const t of e)t&&t.classList.add("tp-ui-open-element")}setTimepickerClassToElement(){const e=this.core.element;if(!e)return;e.classList.add(A);const t=this.core.options.ui.cssClass;t&&t!==A&&e.classList.add(t)}destroy(){const e=this.core.getModalElement();e&&e.removeAttribute("data-theme")}}class H extends Error{code;constructor(e,t){super(`[TimepickerUI] ${e}`),this.code=t,this.name="TimepickerError",Object.setPrototypeOf(this,H.prototype)}}const I="INVALID_PARAMETER";class x{core;emitter;constructor(e,t){this.core=e,this.emitter=t}setErrorHandler(){const e=this.core.getInput();if(!e)return!0;const{error:i,currentHour:s,currentMin:r,currentType:n,currentLength:o}=M(e,this.core.options.clock.type);if(this.removeErrorHandler(),i){if(!1===t())return!1;const a=document.createElement("div");a.classList.add("tp-ui-invalid-text"),a.innerHTML="<b>Invalid Time Format</b>",e.classList.add("tp-ui-invalid-format"),e.nextElementSibling?.classList.contains("tp-ui-invalid-text")||e.after(a);const c={error:i,rejectedHour:void 0,rejectedMinute:void 0,inputHour:s,inputMinute:r,inputType:n,inputLength:o};return this.emitter.emit("error",c),!1}return!0}removeErrorHandler(){const e=this.core.getInput();if(!e)return;e.classList.remove("tp-ui-invalid-format");const t=e.nextElementSibling;t?.classList.contains("tp-ui-invalid-text")&&t.remove()}checkDisabledValuesOnStart(){if(!this.core.options.clock.disabledTime)return;const{disabledTime:e,type:t}=this.core.options.clock;if(e.interval){if(!t)throw new H("clockType is required when using disabledTime.interval",I);const i=Array.isArray(e.interval)?e.interval:[e.interval];try{g(i,t)}catch(e){throw new H(`Invalid disabledTime.interval: ${e.message}`,I)}return}const{hours:i,minutes:s}=e,r=!i||w(i,"hour",t),n=!s||w(s,"minutes",t);if(!r||!n)throw new H("Invalid hours or minutes in disabledTime option",I)}destroy(){this.removeErrorHandler()}}class ${core;emitter;cleanupHandlers=[];constructor(e,t){this.core=e,this.emitter=t}handleOpenOnClick(){const e=this.core.getOpenElement();if(!e)return;const t=()=>{this.core.isDestroyed||this.emitter.emit("show",{})};e.forEach(e=>{e.addEventListener("click",t),this.cleanupHandlers.push(()=>e.removeEventListener("click",t))})}handleOpenOnEnterFocus(){const e=this.core.getInput();if(!e)return;const t=e=>{"Enter"!==e.key||this.core.isDestroyed||this.emitter.emit("show",{})};e.addEventListener("keydown",t),this.cleanupHandlers.push(()=>e.removeEventListener("keydown",t))}handleCancelButton(){const e=this.core.getCancelButton();if(!e)return;const t=()=>{this.core.isDestroyed||this.emitter.emit("cancel",{})};e.addEventListener("click",t),this.cleanupHandlers.push(()=>e.removeEventListener("click",t))}handleOkButton(){const e=this.core.getOkButton();if(!e)return;const t=()=>{if(this.core.isDestroyed)return;const e=this.core.getHour(),t=this.core.getMinutes(),i=this.core.getActiveTypeMode();this.emitter.emit("confirm",{hour:e?.value,minutes:t?.value,type:i?.textContent||void 0})};e.addEventListener("click",t),this.cleanupHandlers.push(()=>e.removeEventListener("click",t))}handleBackdropClick(){const e=this.core.getModalElement();if(!e)return;const t=t=>{this.core.isDestroyed||t.target===e&&this.emitter.emit("cancel",{})};e.addEventListener("click",t),this.cleanupHandlers.push(()=>e.removeEventListener("click",t))}handleEscClick(){if(!1===t())return;const e=e=>{this.core.isDestroyed||"Escape"===e.key&&this.emitter.emit("cancel",{})};document.addEventListener("keydown",e),this.cleanupHandlers.push(()=>document.removeEventListener("keydown",e))}handleAmClick(){const e=this.core.getAM();if(!e)return;const t=()=>{if(this.core.isDestroyed)return;const t=this.core.getPM();e.classList.add("active"),t?.classList.remove("active"),this.emitter.emit("select:am",{})};e.addEventListener("click",t),this.cleanupHandlers.push(()=>e.removeEventListener("click",t))}handlePmClick(){const e=this.core.getPM();if(!e)return;const t=()=>{if(this.core.isDestroyed)return;const t=this.core.getAM();e.classList.add("active"),t?.classList.remove("active"),this.emitter.emit("select:pm",{})};e.addEventListener("click",t),this.cleanupHandlers.push(()=>e.removeEventListener("click",t))}handleHourEvents(){const e=this.core.getHour();if(!e)return;const t=()=>{if(this.core.isDestroyed)return;e.classList.add("active");const t=this.core.getMinutes();t?.classList.remove("active"),this.emitter.emit("select:hour",{hour:e.value})};if(e.addEventListener("click",t),this.cleanupHandlers.push(()=>e.removeEventListener("click",t)),this.core.options.ui.editable){let t=e.value;const i=()=>{this.core.isDestroyed||e.value!==t&&(t=e.value,this.emitter.emit("animation:clock",{}),this.emitter.emit("select:hour",{hour:e.value}))};e.addEventListener("blur",i),this.cleanupHandlers.push(()=>e.removeEventListener("blur",i))}}handleMinutesEvents(){const e=this.core.getMinutes();if(!e)return;const t=()=>{if(this.core.isDestroyed)return;e.classList.add("active");const t=this.core.getHour();t?.classList.remove("active"),this.emitter.emit("select:minute",{minutes:e.value})};e.addEventListener("click",t),this.cleanupHandlers.push(()=>e.removeEventListener("click",t))}handleKeyboardInput(){const e=this.core.getHour(),t=this.core.getMinutes();if(e){const t=t=>{if(this.core.isDestroyed)return;if("ArrowUp"!==t.key&&"ArrowDown"!==t.key)return;t.preventDefault();const i=parseInt(e.value)||0,s=parseInt(e.getAttribute("max")||"23");parseInt(e.getAttribute("min")||"0");const r="12h"===this.core.options.clock.type;let n;n="ArrowUp"===t.key?r?i>=12?1:i+1:i>=s?0:i+1:r?i<=1?12:i-1:i<=0?s:i-1,e.value=n.toString().padStart(2,"0"),this.emitter.emit("animation:clock",{}),this.emitter.emit("select:hour",{hour:e.value})};e.addEventListener("keydown",t),this.cleanupHandlers.push(()=>e.removeEventListener("keydown",t))}if(t){const e=e=>{if(this.core.isDestroyed)return;if("ArrowUp"!==e.key&&"ArrowDown"!==e.key)return;e.preventDefault();const i=parseInt(t.value)||0;let s;s="ArrowUp"===e.key?i>=59?0:i+1:i<=0?59:i-1,t.value=s.toString().padStart(2,"0"),this.emitter.emit("animation:clock",{}),this.emitter.emit("select:minute",{minutes:t.value})};t.addEventListener("keydown",e),this.cleanupHandlers.push(()=>t.removeEventListener("keydown",e))}}focusTrapHandler(){if(!1===t())return;const e=this.core.getWrapper();if(!e)return;const i=t=>{if(this.core.isDestroyed)return;if("Tab"!==t.key)return;const i=e.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),s=i[0],r=i[i.length-1];t.shiftKey&&document.activeElement===s?(r?.focus(),t.preventDefault()):t.shiftKey||document.activeElement!==r||(s?.focus(),t.preventDefault())};e.addEventListener("keydown",i),this.cleanupHandlers.push(()=>e.removeEventListener("keydown",i))}handleMoveHand(){if(!1===t())return;const e=e=>{this.core.isDestroyed||e.preventDefault()};document.addEventListener("mousedown",e,!1),document.addEventListener("touchstart",e,{passive:!1}),this.cleanupHandlers.push(()=>{document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)})}handleSwitchViewButton(){const e=this.core.getKeyboardClockIcon();if(!e)return;const t=()=>{this.core.isDestroyed||this.emitter.emit("switch:view",{})};e.addEventListener("click",t),this.cleanupHandlers.push(()=>e.removeEventListener("click",t))}destroy(){this.cleanupHandlers.forEach(e=>e()),this.cleanupHandlers=[]}}class D{static angleToIndex(e,t,i){const s=Math.round(e/30)%12;if("24h"===t){if(i){const e=s+12;return 12===e?0:e}return 0===s?12:s}return 0===s?12:s}static indexToValue(e,t,i){if("24h"===t)return e.toString().padStart(2,"0");let s=e;return 0===s&&(s=12),s>12&&(s-=12),s.toString().padStart(2,"0")}static indexToAngle(e,t){if("24h"===t)return e>=12?(e-12)%12*30:e%12*30;return(0===e?12:e)%12*30}static isDisabled(e,t,i){return!!i&&(i.isInterval&&i.intervals&&i.clockType?this.isDisabledByInterval(e,t,i):!!i.hours&&i.hours.some(t=>String(t)===e||Number(t)===Number(e)||t===e))}static isDisabledByInterval(e,t,i){if(!i.intervals)return!1;for(let s=0;s<60;s++){const r=s.toString().padStart(2,"0");if(!this.isTimeInIntervals(e,r,t,i.intervals,i.clockType))return!1}return!0}static isTimeInIntervals(e,t,i,s,r){const n="12h"===r?`${e}:${t} ${i}`:`${e}:${t}`;for(const e of s){const[t,i]=e.split("-").map(e=>e.trim());if(this.isTimeBetween(n,t,i,r))return!0}return!1}static isTimeBetween(e,t,i,s){const r=this.timeToMinutes(e,s),n=this.timeToMinutes(t,s),o=this.timeToMinutes(i,s);return r>=n&&r<=o}static timeToMinutes(e,t){if("12h"===t){const t=e.match(/(\d{1,2}):(\d{2})\s*(AM|PM)/i);if(!t)return 0;let i=parseInt(t[1]);const s=parseInt(t[2]),r=t[3].toUpperCase();return"PM"===r&&12!==i&&(i+=12),"AM"===r&&12===i&&(i=0),60*i+s}{const[t,i]=e.split(":").map(Number);return 60*t+i}}static findNearestValid(e,t,i,s,r){const n="24h"===t?23:12;for(let r=0;r<=n;r++){const o=0===r?[e]:[e+r,e-r];for(const e of o){let r=e;r<0&&(r+=n+1),r>n&&(r%=n+1);const o=this.indexToValue(r,t,i);if(!this.isDisabled(o,i,s))return r}}return e}}class P{static angleToIndex(e){return Math.round(e/6)%60}static indexToValue(e){return e.toString().padStart(2,"0")}static indexToAngle(e){return e%60*6}static isDisabled(e,t,i,s,r){return!!s&&(s.isInterval&&s.intervals?this.isDisabledByInterval(e,t,i,s,r):!!s.minutes&&s.minutes.some(t=>String(t)===e||Number(t)===Number(e)||t===e))}static isDisabledByInterval(e,t,i,s,r){if(!s.intervals)return!1;const n="12h"===r?`${t}:${e} ${i}`:`${t}:${e}`;for(const e of s.intervals){const[t,i]=e.split("-").map(e=>e.trim());if(this.isTimeBetween(n,t,i,r))return!0}return!1}static isTimeBetween(e,t,i,s){const r=this.timeToMinutes(e,s),n=this.timeToMinutes(t,s),o=this.timeToMinutes(i,s);return r>=n&&r<=o}static timeToMinutes(e,t){if("12h"===t){const t=e.match(/(\d{1,2}):(\d{2})\s*(AM|PM)/i);if(!t)return 0;let i=parseInt(t[1]);const s=parseInt(t[2]),r=t[3].toUpperCase();return"PM"===r&&12!==i&&(i+=12),"AM"===r&&12===i&&(i=0),60*i+s}{const[t,i]=e.split(":").map(Number);return 60*t+i}}static findNearestValid(e,t,i,s,r){for(let n=0;n<60;n++){const o=0===n?[e]:[e+n,e-n];for(const e of o){let n=e;n<0&&(n+=60),n>=60&&(n%=60);const o=this.indexToValue(n);if(!this.isDisabled(o,t,i,s,r))return n}}return e}}class q{static normalizeAngle(e){let t=e%360;return t<0&&(t+=360),t}static calculateRawAngle(e,t){const i=e.x-t.x,s=e.y-t.y,r=180*Math.atan2(s,i)/Math.PI+90;return this.normalizeAngle(r)}static snapToIncrement(e,t){const i=Math.round(e/t)*t;return this.normalizeAngle(i)}static calculateDistance(e,t){const i=e.x-t.x,s=e.y-t.y;return Math.sqrt(i*i+s*s)}static isInnerCircle(e,t){return e<.6*t}static calculateShortestPath(e,t){const i=this.normalizeAngle(e),s=this.normalizeAngle(t)-i,r=s>=0?s:s+360,n=s<=0?s:s-360;return e+(Math.abs(r)<Math.abs(n)?r:n)}}class F{config;currentAngle=0;tipsCache=new Map;cachedDimensions=new Map;constructor(e){this.config=e}getCachedDimensions(e){let t=this.cachedDimensions.get(e);if(!t){const i=(e.offsetWidth-32)/2;t={width:i,height:(e.offsetHeight-32)/2,radius:i-9},this.cachedDimensions.set(e,t)}return t}setHandAngle(e){if(Math.abs(this.currentAngle-e)<.1)return;const t=q.calculateShortestPath(this.currentAngle,e);this.currentAngle=t,this.config.clockHand.style.transform=`rotateZ(${t}deg)`}setActiveValue(e){const t=[this.config.tipsWrapper];this.config.tipsWrapperFor24h&&t.push(this.config.tipsWrapperFor24h),t.forEach(t=>{t.querySelectorAll(".tp-ui-value-tips, .tp-ui-value-tips-24h").forEach(t=>{const i=t;i.textContent===e||Number(i.textContent)===Number(e)?(i.classList.add("active"),i.setAttribute("aria-selected","true")):(i.classList.remove("active"),i.setAttribute("aria-selected","false"))})})}renderTips(e,i,s,r,n,o=!0,a,c="",l="12"){if(!1===t())return;const u=a||this.config.tipsWrapper;o&&(u.innerHTML="",this.tipsCache.clear());const{width:h,height:d,radius:m}=this.getCachedDimensions(u),p=document.createDocumentFragment(),v=`${i}-${this.config.theme||"default"}`;e.forEach((t,o)=>{const a=`${v}-${t}`;let u=this.tipsCache.get(a);u||(u=this.createTip(t,i,n),this.tipsCache.set(a,u));const{wrapper:g,tip:f}=u;this.updateTipState(g,f,t,s,r,n,c,l);const y=o*(360/e.length)*(Math.PI/180);g.style.left=`${h+Math.sin(y)*m}px`,g.style.bottom=`${d+Math.cos(y)*m}px`,p.appendChild(g)}),u.appendChild(p)}createTip(e,i,s){if(!1===t()){const e={};return{wrapper:e,tip:e}}const r=document.createElement("span"),n=document.createElement("span");n.textContent=e,n.setAttribute("role","option"),n.setAttribute("aria-selected","false"),n.tabIndex=0;const o="24h"===s&&i.includes("24")?"tp-ui-value-tips-24h":"tp-ui-value-tips";return n.classList.add(o),r.classList.add(i),this.config.theme&&(r.classList.add(this.config.theme),n.classList.add(this.config.theme)),r.appendChild(n),{wrapper:r,tip:n}}updateTipState(e,t,i,s,r,n,o,a){e.classList.remove("tp-ui-tips-disabled"),t.classList.remove("tp-ui-tips-disabled"),t.removeAttribute("aria-disabled"),t.tabIndex=0;this.checkIfDisabled(i,s,r,n,o,a)&&(e.classList.add("tp-ui-tips-disabled"),t.classList.add("tp-ui-tips-disabled"),t.setAttribute("aria-disabled","true"),t.tabIndex=-1)}checkIfDisabled(e,t,i,s,r,n){return!!i&&("hours"===t?D.isDisabled(e,r,i):"minutes"===t&&P.isDisabled(e,n,r,i,s))}setCircleSize(e){e?this.config.circle.classList.remove("small-circle"):this.config.circle.classList.add("small-circle")}setCircle24hMode(e){e?(this.config.circle.classList.add("tp-ui-circle-hand-24h"),this.config.clockHand.classList.add("tp-ui-clock-hand-24h")):(this.config.circle.classList.remove("tp-ui-circle-hand-24h"),this.config.clockHand.classList.remove("tp-ui-clock-hand-24h"))}destroy(){this.tipsCache.clear(),this.cachedDimensions.clear(),this.config.tipsWrapper.innerHTML=""}}class O{static processPointerInput(e){const t=q.calculateRawAngle(e.pointerPosition,e.clockCenter);return"hours"===e.mode?this.processHours(t,e):this.processMinutes(t,e)}static processHours(e,t){const i=30*t.incrementHours,s=q.snapToIncrement(e,i),r=q.calculateDistance(t.pointerPosition,t.clockCenter),n="24h"===t.clockType&&q.isInnerCircle(r,t.clockRadius);let o=D.angleToIndex(s,t.clockType,n);const a=D.indexToValue(o,t.clockType,t.amPm),c=D.isDisabled(a,t.amPm,t.disabledTime);c&&(o=D.findNearestValid(o,t.clockType,t.amPm,t.disabledTime,n));const l=D.indexToValue(o,t.clockType,t.amPm);return{angle:D.indexToAngle(o,t.clockType),value:l,index:o,isValid:!c,isInnerCircle:"24h"===t.clockType?n:void 0}}static processMinutes(e,t){const i=6*t.incrementMinutes,s=q.snapToIncrement(e,i);let r=P.angleToIndex(s);const n=P.indexToValue(r),o=t.currentHour||"00",a=P.isDisabled(n,o,t.amPm,t.disabledTime,t.clockType);a&&(r=P.findNearestValid(r,o,t.amPm,t.disabledTime,t.clockType));const c=P.indexToValue(r);return{angle:P.indexToAngle(r),value:c,index:r,isValid:!a}}static valueToAngle(e,t,i){const s=parseInt(e,10);return"hours"===t?D.indexToAngle(s,i):P.indexToAngle(s)}}class V{state;renderer;clockType;disabledTime;incrementHours;incrementMinutes;isDragging=!1;callbacks;constructor(e,t,i,s,r=1,n=1,o={}){this.renderer=e,this.state={...t},this.clockType=i,this.disabledTime=s,this.incrementHours=r,this.incrementMinutes=n,this.callbacks=o}handlePointerMove(e,t,i){this.isDragging=!0;const s={pointerPosition:e,clockCenter:t,clockRadius:i,mode:this.state.mode,clockType:this.clockType,amPm:this.state.amPm,disabledTime:this.disabledTime,incrementHours:this.incrementHours,incrementMinutes:this.incrementMinutes,currentHour:this.state.hour},r=O.processPointerInput(s);r.isValid&&("hours"===this.state.mode?(this.state.hour=r.value,this.state.hourAngle=r.angle,"24h"===this.clockType&&void 0!==r.isInnerCircle&&(this.renderer.setCircleSize(!0),this.renderer.setCircle24hMode(r.isInnerCircle)),this.callbacks.onHourChange&&this.callbacks.onHourChange(r.value)):(this.state.minute=r.value,this.state.minuteAngle=r.angle,this.renderer.setCircleSize(!0),this.renderer.setCircle24hMode(!1),this.callbacks.onMinuteChange&&this.callbacks.onMinuteChange(r.value)),this.renderer.setHandAngle(r.angle),this.renderer.setActiveValue(r.value))}handlePointerUp(){this.isDragging=!1}switchMode(e){this.state.mode,this.state.mode=e;const t="hours"===e?this.state.hourAngle:this.state.minuteAngle,i="hours"===e?this.state.hour:this.state.minute;if("hours"===e&&"24h"===this.clockType){const e=parseInt(i,10),t=0===e||e>=13;this.renderer.setCircleSize(!0),this.renderer.setCircle24hMode(t)}else this.renderer.setCircleSize(!0),this.renderer.setCircle24hMode(!1);this.renderer.setHandAngle(t),this.renderer.setActiveValue(i)}setValue(e,t){const i=O.valueToAngle(t,e,this.clockType);if("hours"===e)if(this.state.hour=t,this.state.hourAngle=i,"24h"===this.clockType){const e=parseInt(t,10),i=0===e||e>=13;this.renderer.setCircleSize(!0),this.renderer.setCircle24hMode(i)}else this.renderer.setCircle24hMode(!1);else this.state.minute=t,this.state.minuteAngle=i,this.renderer.setCircleSize(!0),this.renderer.setCircle24hMode(!1);this.state.mode===e&&(this.renderer.setHandAngle(i),this.renderer.setActiveValue(t))}setAmPm(e){this.state.amPm=e}getState(){return{...this.state}}getHour(){return this.state.hour}getMinute(){return this.state.minute}getAmPm(){return this.state.amPm}updateDisabledTime(e){this.disabledTime=e}destroy(){this.renderer.destroy()}}class N{controller;clockFace;isActive=!1;config;cachedRect=null;cachedCenter=null;cachedRadius=null;constructor(e,t,i={}){this.controller=e,this.clockFace=t,this.config=i}attach(){this.clockFace.addEventListener("mousedown",this.handlePointerDown),this.clockFace.addEventListener("touchstart",this.handlePointerDown,{passive:!1})}detach(){this.clockFace.removeEventListener("mousedown",this.handlePointerDown),this.clockFace.removeEventListener("touchstart",this.handlePointerDown),this.removeGlobalListeners()}handlePointerDown=t=>{if(e())return;const i=t.target;i&&i.classList&&i.classList.contains("tp-ui-tips-disabled")||(t.preventDefault(),this.isActive=!0,this.cachedRect=this.clockFace.getBoundingClientRect(),this.cachedCenter=this.getClockCenter(),this.cachedRadius=this.getClockRadius(),this.processPointerEvent(t),document.addEventListener("mousemove",this.handlePointerMove),document.addEventListener("touchmove",this.handlePointerMove,{passive:!1}),document.addEventListener("mouseup",this.handlePointerUp),document.addEventListener("touchend",this.handlePointerUp))};handlePointerMove=e=>{if(!this.isActive)return;const t=this.getTargetElement(e);t&&t.classList&&t.classList.contains("tp-ui-tips-disabled")||(e.preventDefault(),this.processPointerEvent(e))};handlePointerUp=()=>{if(!this.isActive)return;this.isActive=!1,this.cachedRect=null,this.cachedCenter=null,this.cachedRadius=null,this.controller.handlePointerUp(),this.removeGlobalListeners();const{autoSwitchToMinutes:e,isMobileView:t,hourElement:i,minutesElement:s}=this.config;e&&i?.classList.contains("active")&&!t&&(s?.click(),s?.focus())};processPointerEvent(e){const t=this.getPointerPosition(e),i=this.cachedCenter||this.getClockCenter(),s=this.cachedRadius||this.getClockRadius();this.controller.handlePointerMove(t,i,s)}getPointerPosition(e){const t=this.cachedRect||this.clockFace.getBoundingClientRect();if(e instanceof TouchEvent){const i=e.touches[0]||e.changedTouches[0];return{x:i.clientX-t.left,y:i.clientY-t.top}}return{x:e.clientX-t.left,y:e.clientY-t.top}}getTargetElement(t){if(t instanceof TouchEvent){const i=t.touches[0]||t.changedTouches[0];if(i&&!e())return document.elementFromPoint(i.clientX,i.clientY)}return t.target}getClockCenter(){return{x:this.clockFace.offsetWidth/2,y:this.clockFace.offsetHeight/2}}getClockRadius(){return this.clockFace.offsetWidth/2}removeGlobalListeners(){!1!==t()&&(document.removeEventListener("mousemove",this.handlePointerMove),document.removeEventListener("touchmove",this.handlePointerMove),document.removeEventListener("mouseup",this.handlePointerUp),document.removeEventListener("touchend",this.handlePointerUp))}}class W{renderer;controller;dragHandlers;clockType;disabledTime;tipsWrapper;tipsWrapperFor24h;constructor(e){this.clockType=e.clockType,this.disabledTime=e.disabledTime,this.tipsWrapper=e.tipsWrapper,this.tipsWrapperFor24h=e.tipsWrapperFor24h;const t={clockFace:e.clockFace,tipsWrapper:e.tipsWrapper,tipsWrapperFor24h:e.tipsWrapperFor24h,clockHand:e.clockHand,circle:e.circle,theme:e.theme};this.renderer=new F(t);const i={hour:e.initialHour,minute:e.initialMinute,amPm:e.initialAmPm,hourAngle:this.calculateInitialAngle("hours",e.initialHour),minuteAngle:this.calculateInitialAngle("minutes",e.initialMinute),mode:"hours"},s={onHourChange:e.onHourChange,onMinuteChange:e.onMinuteChange};this.controller=new V(this.renderer,i,e.clockType,e.disabledTime,e.incrementHours||1,e.incrementMinutes||1,s),this.dragHandlers=new N(this.controller,e.clockFace,e.dragConfig||{})}initialize(){this.dragHandlers.attach(),this.switchToHours()}switchToHours(){this.controller.switchMode("hours"),"24h"===this.clockType&&this.tipsWrapperFor24h&&this.tipsWrapperFor24h.classList.remove("none"),this.renderHourTips();const e=this.controller.getState();this.renderer.setActiveValue(e.hour)}switchToMinutes(){this.controller.switchMode("minutes"),this.tipsWrapperFor24h&&this.tipsWrapperFor24h.classList.add("none"),this.renderMinuteTips();const e=this.controller.getState();this.renderer.setActiveValue(e.minute)}setHour(e){this.controller.setValue("hours",e)}setMinute(e){this.controller.setValue("minutes",e)}setAmPm(e){this.controller.setAmPm(e);const t=this.controller.getState();"hours"===t.mode?(this.renderHourTips(),this.renderer.setHandAngle(t.hourAngle),this.renderer.setActiveValue(t.hour)):(this.renderMinuteTips(),this.renderer.setHandAngle(t.minuteAngle),this.renderer.setActiveValue(t.minute))}getHour(){return this.controller.getHour()}getMinute(){return this.controller.getMinute()}getAmPm(){return this.controller.getAmPm()}updateDisabledTime(e){this.controller.updateDisabledTime(e);"hours"===this.controller.getState().mode?this.renderHourTips():this.renderMinuteTips()}renderHourTips(){const e=this.controller.getState().amPm;"24h"===this.clockType?(this.renderer.renderTips(y,"tp-ui-hour-time-12","hours",this.disabledTime,this.clockType,!0,this.tipsWrapper,e),this.tipsWrapperFor24h&&this.renderer.renderTips(f,"tp-ui-hour-time-24","hours",this.disabledTime,this.clockType,!0,this.tipsWrapperFor24h,e)):this.renderer.renderTips(y,"tp-ui-hour-time-12","hours",this.disabledTime,this.clockType,!0,void 0,e)}renderMinuteTips(){const e=this.controller.getState(),t=e.amPm,i=e.hour;this.renderer.renderTips(b,"tp-ui-minutes-time","minutes",this.disabledTime,this.clockType,!0,void 0,t,i)}calculateInitialAngle(e,t){const i=parseInt(t,10);return"hours"===e?i%12*30:6*i}destroy(){this.dragHandlers.detach(),this.controller.destroy()}}class B{core;emitter;clockSystem=null;constructor(e,t){this.core=e,this.emitter=t,this.setupEventListeners()}setupEventListeners(){this.emitter.on("select:hour",({hour:e})=>{this.emitter.emit("animation:clock",{}),this.setHoursToClock(e||null)}),this.emitter.on("select:minute",({minutes:e})=>{this.emitter.emit("animation:clock",{}),this.setMinutesToClock(e||null)}),this.emitter.on("select:am",()=>{this.updateAmPm()}),this.emitter.on("select:pm",()=>{this.updateAmPm()})}initializeClockSystem(){const e=this.core.getClockFace(),t=this.core.getClockHand(),i=this.core.getCircle();if(!e||!t||!i)return;const s="24h"===this.core.options.clock.type,r=this.core.getTipsWrapper();if(!r)return;const n=this.core.getHour(),o=this.core.getMinutes(),a={clockFace:e,tipsWrapper:r,tipsWrapperFor24h:s&&this.core.getTipsWrapperFor24h()||void 0,clockHand:t,circle:i,clockType:this.core.options.clock.type||"12h",disabledTime:this.convertDisabledTime(),initialHour:n?.value||"12",initialMinute:o?.value||"00",initialAmPm:this.getAmPmValue(),theme:this.core.options.ui.theme,incrementHours:this.core.options.clock.incrementHours||1,incrementMinutes:this.core.options.clock.incrementMinutes||1,timepicker:null,dragConfig:{autoSwitchToMinutes:this.core.options.clock.autoSwitchToMinutes,isMobileView:this.core.isMobileView,hourElement:n,minutesElement:o},onHourChange:e=>{const t=this.core.getHour();t&&(t.value=e)},onMinuteChange:e=>{const t=this.core.getMinutes();t&&(t.value=e)}};this.clockSystem=new W(a),this.clockSystem.initialize()}convertDisabledTime(){const e=this.core.disabledTime?.value;if(!e)return null;let t;return e.intervals&&(t=Array.isArray(e.intervals)?e.intervals:[e.intervals]),{hours:e.hours,minutes:e.minutes,isInterval:e.isInterval,intervals:t,clockType:e.clockType}}getAmPmValue(){if("24h"===this.core.options.clock.type)return"";const e=this.core.getActiveTypeMode();if(e){const t=e.textContent?.trim();if("AM"===t||"PM"===t)return t}const t=this.core.getAM();return t?.classList.contains("active")?"AM":"PM"}destroyClockSystem(){this.clockSystem&&(this.clockSystem.destroy(),this.clockSystem=null)}removeCircleClockClasses24h(){const e=this.core.getCircle(),t=this.core.getClockHand();e?.classList.remove("tp-ui-circle-hand-24h"),t?.classList.remove("tp-ui-clock-hand-24h")}setCircleClockClasses24h(){const e=this.core.getCircle(),t=this.core.getClockHand();e&&e.classList.add("tp-ui-circle-hand-24h"),t&&t.classList.add("tp-ui-clock-hand-24h")}setOnStartCSSClassesIfClockType24h(){if("24h"===this.core.options.clock.type){const e=this.core.getInput();if(!e)return;let t;e.value.length>0&&(t=e.value.split(":")[0]),t&&(Number(t)>12||0===Number(t))&&this.setCircleClockClasses24h()}}setBgColorToCircleWithMinutesTips=()=>{const e=this.core.getMinutes(),t=this.core.getCircle();if(e&&t&&e.value&&b.includes(e.value)){const e=getComputedStyle(t).getPropertyValue("--timepicker-primary").trim();e&&(t.style.backgroundColor=e),t.classList.remove("small-circle")}};removeBgColorToCirleWithMinutesTips=()=>{const e=this.core.getMinutes(),t=this.core.getCircle();e&&t&&(e.value&&b.includes(e.value)||(t.style.backgroundColor="",t.classList.add("small-circle")))};setClassActiveToHourOnOpen=()=>{if(this.core.options.ui.mobile||this.core.isMobileView)return;const e=this.core.getHour();e?.classList.add(L)};setMinutesToClock=e=>{this.clockSystem&&(this.removeBgColorToCirleWithMinutesTips(),e&&this.clockSystem.setMinute(e),this.clockSystem.switchToMinutes())};setHoursToClock=e=>{this.clockSystem&&(e&&this.clockSystem.setHour(e),this.clockSystem.switchToHours())};setTransformToCircleWithSwitchesHour=e=>{this.clockSystem&&e&&this.clockSystem.setHour(e)};setTransformToCircleWithSwitchesMinutes=e=>{this.clockSystem&&e&&this.clockSystem.setMinute(e)};updateAmPm=()=>{if(!this.clockSystem||"24h"===this.core.options.clock.type)return;const e=this.getAmPmValue();""!==e&&this.clockSystem.setAmPm(e)};toggleClassActiveToValueTips=e=>{if(this.clockSystem)return;const t=this.core.getAllValueTips();if(!t)return;const i=t.find(t=>Number(t.innerText)===Number(e));t.forEach(e=>{e.classList.remove(L),e.setAttribute("aria-selected","false")}),void 0!==i&&(i.classList.add(L),i.setAttribute("aria-selected","true"))};destroy(){this.destroyClockSystem()}}class R{animation;modal;config;theme;validation;events;clock;constructor(e,t){this.animation=new h(e,t),this.modal=new T(e,t),this.config=new C(e,t),this.theme=new S(e,t),this.validation=new x(e,t),this.events=new $(e,t),this.clock=new B(e,t)}destroy(){this.animation.destroy(),this.modal.destroy(),this.config.destroy(),this.theme.destroy(),this.validation.destroy(),this.events.destroy(),this.clock.destroy()}}const z="is-rippling",U="ripple-hold";let Z=null;function j(e){const t=e.target,i=t.hasAttribute("data-md3-ripple")?t:t.closest("[data-md3-ripple]");if(!i)return;if(0!==e.button&&"mouse"===e.pointerType)return;const s=i.getBoundingClientRect(),r=2*Math.max(s.width,s.height),n=e.clientX-s.left,o=e.clientY-s.top;i.style.setProperty("--ripple-size",`${r}px`),i.style.setProperty("--ripple-x",`${n}px`),i.style.setProperty("--ripple-y",`${o}px`),i.classList.remove(z,U),i.offsetWidth,i.classList.add(z,U),i._rippleHold=!0,Z=i}function K(e){const t=e.target,i=(t.hasAttribute("data-md3-ripple")?t:t.closest("[data-md3-ripple]"))||Z;i&&(i._rippleHold=!1,i.classList.remove(U),setTimeout(()=>{i.classList.remove(z),Z===i&&(Z=null)},1e3))}function Y(e){const t=e.currentTarget;t&&t._rippleHold&&(t._rippleHold=!1,t.classList.remove(U),setTimeout(()=>{t.classList.remove(z),Z===t&&(Z=null)},1e3))}class _{core;managers;emitter;eventsClickMobileHandler=()=>{};mutliEventsMoveHandler=()=>{};constructor(e,t,i){this.core=e,this.managers=t,this.emitter=i}init(){if(!this.core.isDestroyed&&!this.core.isInitialized){try{this.managers.config.updateInputValueWithCurrentTimeOnStart(),this.managers.validation.checkDisabledValuesOnStart()}catch(e){return void this.core.setIsDestroyed(!0)}this.managers.theme.setTimepickerClassToElement(),this.managers.theme.setInputClassToInputElement(),this.managers.theme.setDataOpenToInputIfDoesntExistInWrapper(),this.managers.theme.setClassTopOpenElement(),this.managers.config.getDisableTime(),this.core.options.ui.inline?.enabled||this.managers.events.handleOpenOnClick(),this.managers.events.handleOpenOnEnterFocus(),this.setupCallbackBridge(),this.core.setIsInitialized(!0)}}setupCallbackBridge(){const{callbacks:e}=this.core.options;e.onOpen&&this.emitter.on("open",e.onOpen),e.onCancel&&this.emitter.on("cancel",e.onCancel),e.onConfirm&&this.emitter.on("confirm",e.onConfirm),e.onUpdate&&this.emitter.on("update",e.onUpdate),e.onSelectHour&&this.emitter.on("select:hour",e.onSelectHour),e.onSelectMinute&&this.emitter.on("select:minute",e.onSelectMinute),e.onSelectAM&&this.emitter.on("select:am",e.onSelectAM),e.onSelectPM&&this.emitter.on("select:pm",e.onSelectPM),e.onError&&this.emitter.on("error",e.onError)}mount(){this.core.isDestroyed||(this.core.isInitialized||this.init(),this.eventsBundle())}unmount(e){const t=((e,t)=>{let i;return(...s)=>{clearTimeout(i),i=setTimeout(()=>{e(...s)},t)}})((...e)=>{if(e.length>2||!this.core.getModalElement())return;const[t]=e.filter(e=>"boolean"==typeof e),[i]=e.filter(e=>"function"==typeof e);if(this.core.setIsMobileView(!!this.core.options.ui.mobile),t){const e=this.core.getOkButton();e?.click()}this.core.setIsTouchMouseMove(!1),this.removeEventListeners(),this.managers.animation.removeAnimationToClose();this.core.getOpenElement().forEach(e=>e?.classList.remove("disabled")),setTimeout(()=>{"undefined"!=typeof document&&(document.body.style.overflowY="",document.body.style.paddingRight="")},n),setTimeout(()=>{const e=this.core.getInput();this.core.options.behavior.focusInputAfterClose&&e?.focus();const t=this.core.getModalElement();null!==t&&(t.remove(),this.core.setIsModalRemove(!0))},o),i&&i()},this.core.options.behavior.delayHandler||s);e?t(e):t()}destroy(t){if(this.core.isDestroyed)return;const i="function"==typeof t?{callback:t}:t||{},{keepInputValue:s=!1,callback:r}=i,n=this.core.getInput(),o=s?n?.value:null;this.removeEventListeners();const a=this.core.getModalElement();a?.remove();const c=this.core.getOpenElement();c?.forEach(e=>{e&&(e.classList.remove("disabled","active","tp-ui-open-element"),e.classList.remove("basic","crane-straight","crane","m2","m3-green"))}),n&&(n.classList.remove("tp-ui-invalid-format","invalid-value","error","active","tp-ui-input"),n.removeAttribute("data-open"),n.removeAttribute("data-owner-id"),s&&o&&(n.value=o));const l=this.core.element;l&&(l.classList.remove("basic","crane-straight","crane","m2","m3-green"),l.classList.remove("error","active","disabled"),l.removeAttribute("data-owner-id"),l.removeAttribute("data-open"),this.core.options.ui.cssClass&&l.classList.remove(this.core.options.ui.cssClass));const u=l?.querySelectorAll(".tp-ui-invalid-text");u?.forEach(e=>e.remove()),this.mutliEventsMoveHandler=()=>{},this.eventsClickMobileHandler=()=>{},this.core.reset(),this.managers.destroy(),this.emitter.clear(),e()||(document.body.style.overflowY="",document.body.style.paddingRight=""),r&&r()}eventsBundle(){if(this.core.isDestroyed)return;if(!this.core.isModalRemove)return;if(this.managers.validation.setErrorHandler(),this.managers.validation.removeErrorHandler(),!this.core.options.ui.inline?.enabled){const e=this.core.getOpenElement(),t=this.core.getInput();e.forEach(e=>e?.classList.add("disabled")),t?.blur()}if(this.managers.modal.setScrollbarOrNot(),this.managers.modal.setModalTemplate(),this.managers.modal.setNormalizeClass(),this.managers.modal.removeBackdrop(),this.core.isMobileView)this.managers.config.updateClockFaceAccessibility(!0);else{const e=this.core.getModalElement(),t=e?.querySelector(".tp-ui-mobile-clock-wrapper"),i=e?.querySelector(".tp-ui-wrapper"),s=e?.querySelectorAll("*");t?.classList.add("expanded"),i?.classList.add("expanded"),s?.forEach(e=>{e.classList.contains("tp-ui-select-time")||e.classList.contains("tp-ui-mobile-clock-wrapper")||e.classList.contains("tp-ui-wrapper")||e.classList.add("expanded")})}this.managers.modal.setFlexEndToFooterIfNoKeyboardIcon(),setTimeout(()=>{this.managers.theme.setTheme();const e=this.core.getWrapper();e&&this.core.options.ui.cssClass&&e.classList.add(this.core.options.ui.cssClass)},0),this.managers.animation.setAnimationToOpen(),this.managers.config.getInputValueOnOpenAndSet(),this.managers.clock.initializeClockSystem(),this.managers.clock.setOnStartCSSClassesIfClockType24h(),this.managers.clock.setClassActiveToHourOnOpen(),this.managers.events.handleCancelButton(),this.managers.events.handleOkButton(),this.managers.events.handleHourEvents(),this.managers.events.handleMinutesEvents(),this.managers.events.handleKeyboardInput(),this.core.options.ui.enableSwitchIcon&&this.managers.events.handleSwitchViewButton(),"24h"!==this.core.options.clock.type&&(this.managers.events.handleAmClick(),this.managers.events.handlePmClick()),this.core.options.behavior.focusTrap&&this.managers.events.focusTrapHandler(),this.core.options.ui.inline?.enabled||(this.managers.events.handleEscClick(),this.managers.events.handleBackdropClick());const e=this.core.getModalElement();e&&function(e){if(!1===t())return;const i=e||document;i.addEventListener("pointerdown",j),i.addEventListener("pointerup",K),i.addEventListener("pointercancel",K),i.querySelectorAll("[data-md3-ripple]").forEach(e=>{e.addEventListener("mouseleave",Y)})}(e);const i=this.core.getClockFace();i&&"undefined"!=typeof requestAnimationFrame&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{i?.classList.add("scale-in")})}),this.managers.modal.setShowClassToBackdrop()}removeEventListeners(){if(!1===t())return;E.split(" ").forEach(e=>{document.removeEventListener(e,this.mutliEventsMoveHandler,!1)}),document.removeEventListener("mousedown",this.eventsClickMobileHandler)}}class X{events=new Map;on(e,t){this.events.has(e)||this.events.set(e,new Set),this.events.get(e).add(t)}once(e,t){const i=s=>{t(s),this.off(e,i)};this.on(e,i)}off(e,t){t?this.events.get(e)?.delete(t):this.events.delete(e)}emit(e,t){this.events.get(e)?.forEach(e=>{e(t)})}clear(){this.events.clear()}hasListeners(e){return(this.events.get(e)?.size??0)>0}}const G={type:"12h",incrementHours:1,incrementMinutes:1,autoSwitchToMinutes:!1,disabledTime:void 0,currentTime:void 0},J={theme:"basic",animation:!0,backdrop:!0,mobile:!1,enableSwitchIcon:!1,editable:!1,enableScrollbar:!1,cssClass:void 0,appendModalSelector:"",iconTemplate:"",iconTemplateMobile:"",inline:void 0},Q={am:"AM",pm:"PM",ok:"OK",cancel:"Cancel",time:"Select time",mobileTime:"Enter Time",mobileHour:"Hour",mobileMinute:"Minute"},ee={focusInputAfterClose:!1,focusTrap:!0,delayHandler:300,id:void 0},te={onOpen:void 0,onCancel:void 0,onConfirm:void 0,onUpdate:void 0,onSelectHour:void 0,onSelectMinute:void 0,onSelectAM:void 0,onSelectPM:void 0,onError:void 0};const ie=new Map;return class{core;managers;lifecycle;emitter;constructor(t,s){if(e())throw new Error("TimepickerUI requires browser environment");const r=this.resolveInputElement(t);if(!r)throw new Error("Input element not found");const n=s?.behavior?.id,o=n||`tp-ui-${"undefined"!=typeof window&&window.crypto&&"function"==typeof window.crypto.randomUUID?window.crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}`,a=this.createWrapperElement(r),c=function(e={}){return{clock:{...G,...e.clock||{}},ui:{...J,...e.ui||{}},labels:{...Q,...e.labels||{}},behavior:{...ee,...e.behavior||{}},callbacks:{...te,...e.callbacks||{}}}}(s||{});if(c.ui.inline?.enabled&&void 0===s?.behavior?.focusTrap&&(c.behavior.focusTrap=!1),c.ui.inline?.enabled){if(!c.ui.inline.containerId)throw new Error("inline.containerId is required when inline mode is enabled");if(!e()){if(!document.getElementById(c.ui.inline.containerId))throw new Error(`Container element with id "${c.ui.inline.containerId}" not found`)}}this.emitter=new X,this.core=new i(a,c,o,n);const l=this.core.getInput();if(l){const e=M(l,c.clock.type),t=30*Number(e.hour),i=6*Number(e.minutes);this.core.setDegreesHours(t),this.core.setDegreesMinutes(i)}this.managers=new R(this.core,this.emitter),this.lifecycle=new _(this.core,this.managers,this.emitter),this.managers.config.checkMobileOption(),this.managers.config.preventClockTypeByCurrentTime(),this.setupInternalEventListeners(),ie.set(this.core.instanceId,this)}setupInternalEventListeners(){this.emitter.on("show",()=>{this.core.isDestroyed||this.lifecycle.mount()}),this.emitter.on("cancel",()=>{this.core.isDestroyed||this.lifecycle.unmount()}),this.emitter.on("confirm",e=>{if(!this.core.isDestroyed){const t=this.core.getInput();if(t&&e.hour&&e.minutes){const i=e.type?` ${e.type}`:"";t.value=`${e.hour}:${e.minutes}${i}`}this.lifecycle.unmount()}})}create(){this.lifecycle.init(),this.core.options.ui.inline?.enabled&&this.lifecycle.mount()}open(e){this.lifecycle.mount(),e&&e()}close(e,t){this.lifecycle.unmount(e?t:void 0),!e&&t&&t()}destroy(e){ie.delete(this.core.instanceId),this.lifecycle.destroy(e)}update(e,t){this.core.isDestroyed||(this.core.updateOptions(e.options),this.managers.config.checkMobileOption(),e.create&&this.create(),t&&t())}getValue(){if(this.core.isDestroyed)return{hour:"",minutes:"",type:void 0,time:"",degreesHours:null,degreesMinutes:null};const e=this.core.getHour(),t=this.core.getMinutes(),i=this.core.getActiveTypeMode(),s=e?.value||"12",r=t?.value||"00",n="24h"===this.core.options.clock.type?void 0:i?.textContent||"AM";let o="";return o="24h"===this.core.options.clock.type?`${s.padStart(2,"0")}:${r.padStart(2,"0")}`:`${s}:${r.padStart(2,"0")} ${n}`,{hour:s,minutes:r,type:n,time:o,degreesHours:this.core.degreesHours,degreesMinutes:this.core.degreesMinutes}}setValue(e,t=!0){if(this.core.isDestroyed)return;if(!e||"string"!=typeof e)return;this.core.isInitialized||this.create();const i=e.trim().replace(/[^0-9:APMapm\s]/g,"");let s="12",r="00",n="AM";try{if("24h"===this.core.options.clock.type){const e=i.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=i.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()}const e=this.core.getHour(),o=this.core.getMinutes(),a=this.core.getAM(),c=this.core.getPM();if(e&&(e.value=s,e.setAttribute("aria-valuenow",s),this.core.setDegreesHours(30*Number(s))),o&&(o.value=r,o.setAttribute("aria-valuenow",r),this.core.setDegreesMinutes(6*Number(r))),"24h"!==this.core.options.clock.type&&a&&c&&("AM"===n?(a.classList.add("active"),c.classList.remove("active")):(c.classList.add("active"),a.classList.remove("active"))),t){const e=this.core.getInput();e&&(e.value=i)}const l=this.core.getClockHand();l&&(l.style.transform=`rotateZ(${this.core.degreesHours||0}deg)`)}catch(e){return}}getElement(){return this.core.element}get instanceId(){return this.core.instanceId}get options(){return this.core.options}get isInitialized(){return this.core.isInitialized}get isDestroyed(){return this.core.isDestroyed}get hour(){return this.core.getHour()}get minutes(){return this.core.getMinutes()}get okButton(){return this.core.getOkButton()}get cancelButton(){return this.core.getCancelButton()}get clockHand(){return this.core.getClockHand()}on(e,t){this.core.isDestroyed||this.emitter.on(e,t)}once(e,t){this.core.isDestroyed||this.emitter.once(e,t)}off(e,t){this.core.isDestroyed||this.emitter.off(e,t)}resolveInputElement(e){if(!1===t())return null;let i=null;if("string"==typeof e){if(i=document.querySelector(e),!i)return null}else{if(!(e instanceof HTMLElement))return null;i=e}if("INPUT"===i.tagName)return i;return i.querySelector("input")}createWrapperElement(e){if(!1===t())return e;const i=e.parentElement;if("INPUT"===e.tagName&&!i?.classList.contains("tp-ui")){const t=document.createElement("div");return t.className="tp-ui",e.parentNode?.insertBefore(t,e),t.appendChild(e),t}return i&&!i.classList.contains("tp-ui")&&i.classList.add("tp-ui"),i||e}static getById(e){return ie.get(e)}static getAllInstances(){return Array.from(ie.values())}static isAvailable(t){return!e()&&("string"==typeof t?null!==document.querySelector(t):t instanceof HTMLElement&&document.contains(t))}static destroyAll(){Array.from(ie.values()).forEach(e=>e.destroy()),ie.clear()}}});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "timepicker-ui",
3
- "version": "3.1.3",
3
+ "version": "4.0.0",
4
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
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -24,12 +24,12 @@
24
24
  "./index.css": "./dist/css/index.css",
25
25
  "./theme-crane.css": "./dist/css/themes/theme-crane.css",
26
26
  "./theme-dark.css": "./dist/css/themes/theme-dark.css",
27
- "./theme-m3.css": "./dist/css/themes/theme-m3.css",
27
+ "./theme-m2.css": "./dist/css/themes/theme-m2.css",
28
+ "./theme-m3-green.css": "./dist/css/themes/theme-m3-green.css",
28
29
  "./theme-glassmorphic.css": "./dist/css/themes/theme-glassmorphic.css",
29
30
  "./theme-pastel.css": "./dist/css/themes/theme-pastel.css",
30
31
  "./theme-ai.css": "./dist/css/themes/theme-ai.css",
31
- "./theme-cyberpunk.css": "./dist/css/themes/theme-cyberpunk.css",
32
- "./theme-custom.css": "./dist/css/themes/theme-custom.css"
32
+ "./theme-cyberpunk.css": "./dist/css/themes/theme-cyberpunk.css"
33
33
  },
34
34
  "keywords": [
35
35
  "material-design",
@@ -42,7 +42,7 @@
42
42
  "vanillajs",
43
43
  "typescript"
44
44
  ],
45
- "author": "pglejzer",
45
+ "author": "Piotr Glejzer (@pglejzer)",
46
46
  "license": "MIT",
47
47
  "bugs": {
48
48
  "url": "https://github.com/pglejzer/timepicker-ui/issues"
@@ -1 +0,0 @@
1
- .timepicker-ui-hour.custom,.timepicker-ui-minutes.custom{background-color:var(--timepicker-surface);color:var(--timepicker-text)}.timepicker-ui-hour.custom.active,.timepicker-ui-hour.custom:hover,.timepicker-ui-minutes.custom.active,.timepicker-ui-minutes.custom:hover{background-color:var(--timepicker-surface-hover);color:var(--timepicker-primary)}.timepicker-ui-clock-face.custom{background-color:var(--timepicker-surface)}.timepicker-ui-circle-hand.custom,.timepicker-ui-clock-hand.custom,.timepicker-ui-dot.custom{background-color:var(--timepicker-primary)!important}.timepicker-ui-cancel-btn.custom,.timepicker-ui-ok-btn.custom{color:var(--timepicker-primary)}.timepicker-ui-cancel-btn.custom:hover,.timepicker-ui-ok-btn.custom:hover{background-color:var(--timepicker-border)}.timepicker-ui-wrapper-type-time.custom{color:var(--timepicker-secondary-text)}.timepicker-ui-am.custom,.timepicker-ui-pm.custom{background-color:var(--timepicker-bg);border-color:var(--timepicker-border);color:var(--timepicker-text)}.timepicker-ui-am.custom.active,.timepicker-ui-am.custom:hover,.timepicker-ui-pm.custom.active,.timepicker-ui-pm.custom:hover{background-color:var(--timepicker-surface-hover);color:var(--timepicker-primary)}.timepicker-ui-am.custom.active,.timepicker-ui-pm.custom.active{background-color:var(--timepicker-primary);color:var(--timepicker-on-primary)}.timepicker-ui-keyboard-icon.custom{color:var(--timepicker-text)}.timepicker-ui-keyboard-icon.custom:hover{color:var(--timepicker-primary)}.timepicker-ui-keyboard-icon-wrapper.custom:hover .timepicker-ui-keyboard-icon.custom{background-color:var(--timepicker-border)}.timepicker-ui-tips-disabled.custom{color:var(--timepicker-disabled-text)}.timepicker-ui-value-tips.custom.active{color:var(--timepicker-on-primary)}
@@ -1 +0,0 @@
1
- :root{--timepicker-bg:#fff;--timepicker-surface:#e0e0e0;--timepicker-surface-hover:#ece0fd;--timepicker-input-bg:#e4e4e4;--timepicker-text:#000;--timepicker-secondary-text:#a9a9a9;--timepicker-disabled-text:hsla(0,1%,61%,.6);--timepicker-type-time-text:#787878;--timepicker-icon-text:#4e545a;--timepicker-primary:#6200ee;--timepicker-on-primary:#fff;--timepicker-border:#d6d6d6;--timepicker-hover-bg:#d6d6d6;--timepicker-shadow:0px 3px 5px -1px rgba(0,0,0,.2),0px 5px 8px 0px rgba(0,0,0,.14),0px 1px 14px 0px rgba(0,0,0,.12);--timepicker-font-family:"Roboto",sans-serif;--timepicker-border-radius:4px}.timepicker-ui-wrapper.m3{--timepicker-bg:#e5eadc;--timepicker-surface:#dfe4d6;--timepicker-surface-hover:#dfe4d6;--timepicker-text:#1a1c18;--timepicker-secondary-text:#6b7165;--timepicker-primary:#386a20;--timepicker-on-primary:#042100;--timepicker-border:#74796e;--timepicker-shadow:unset;--timepicker-border-radius:35px}.timepicker-ui-hour-time-12.m3,.timepicker-ui-hour-time-24.m3{color:var(--timepicker-text)}.timepicker-ui-wrapper.m3{background-color:var(--timepicker-bg);border-radius:var(--timepicker-border-radius);box-shadow:var(--timepicker-shadow)}.timepicker-ui-hour.active.m3,.timepicker-ui-minutes.active.m3{background-color:#b8f397;color:var(--timepicker-on-primary)}.timepicker-ui-hour.m3,.timepicker-ui-minutes.m3{background-color:var(--timepicker-surface)}.timepicker-ui-hour:hover.m3,.timepicker-ui-minutes:hover.m3{color:var(--timepicker-primary)}.timepicker-ui-clock-face.m3{background-color:var(--timepicker-surface)}.timepicker-ui-circle-hand.m3,.timepicker-ui-clock-hand.m3,.timepicker-ui-dot.m3{background-color:var(--timepicker-primary)!important}.timepicker-ui-cancel-btn.m3,.timepicker-ui-ok-btn.m3{color:var(--timepicker-primary)}.timepicker-ui-cancel-btn:hover.m3,.timepicker-ui-ok-btn:hover.m3{background-color:var(--timepicker-surface)}.timepicker-ui-wrapper-type-time.m3{color:var(--timepicker-secondary-text)}.timepicker-ui-am.m3,.timepicker-ui-pm.m3{border-color:var(--timepicker-border);border-width:1px}.timepicker-ui-am.m3{border-bottom-width:0}.timepicker-ui-am.active.m3,.timepicker-ui-am:hover.m3,.timepicker-ui-pm.active.m3,.timepicker-ui-pm:hover.m3{background-color:#bbebeb;color:#002021}.timepicker-ui-hour.mobile:hover.m3,.timepicker-ui-minutes.mobile:hover.m3{background-color:var(--timepicker-surface)}