import*as t from"@momentum-ui/icons/data/momentumUiIconsNames.json";import*as e from"@momentum-ui/utils/lib/getColorValue";import*as i from"lit";import*as s from"lit/decorators.js";import*as o from"lit/directives/class-map.js";import*as a from"lit/directives/if-defined.js";import*as r from"lit/directives/repeat.js";import*as m from"lit/directives/style-map.js";import*as n from"luxon";import*as l from"mobx";var h,u,p={2218(t,e,i){i.d(e,{AG:()=>R,F7:()=>f,K_:()=>v}),i(2273),i(9189);var s=i(2900),o=i(9609),a=i(878),r=i(3331),m=i(4084),n=i(2927),l=i(8899),h=i(4955),u=i(3517),p=i(9642),c=i(7911),d=function(t,e,i,s){var o,a=arguments.length,r=a<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,s);else for(var m=t.length-1;m>=0;m--)(o=t[m])&&(r=(a<3?o(r):a>3?o(e,i,r):o(e,i))||r);return a>3&&r&&Object.defineProperty(e,i,r),r};const f=[s.R5.HOUR,s.R5.MINUTE,s.R5.SECOND,s.R5.AM_PM],v=[s.R5.HOUR,s.R5.MINUTE,s.R5.SECOND],y={[s.R5.HOUR]:"HH",[s.R5.MINUTE]:"MM",[s.R5.SECOND]:"SS",[s.R5.AM_PM]:"AM"};var R;!function(t){let e=class extends n.LitElement{constructor(){super(...arguments),this.twoDigitAutoTab=!1,this.twentyFourHourFormat=!1,this.timeSpecificity=s.R5.SECOND,this.locale="en-US",this.value=null,this.showDefaultNowTime=!0,this.finalTwentyFourFormat=!1,this.timeObject=(0,a.tB)(),this.tabNext=!1,this.timeValue={[s.R5.HOUR]:"12",[s.R5.MINUTE]:"00",[s.R5.SECOND]:"00",[s.R5.AM_PM]:"AM"},this.timeValidity={[s.R5.HOUR]:!0,[s.R5.MINUTE]:!0,[s.R5.SECOND]:!0,[s.R5.AM_PM]:!0},this.addLeadingZeros=t=>{if(t){if(0===t.length)return"00";if(1===t.length)return`0${t}`}return t},this.formatAndValidate=(t,e)=>{if(t&&(this.updateValidity(t,e),this.timeValidity[e]))return this.addLeadingZeros(t)},this.getLocaleTimeFormat=t=>{const e=t.toFormat("tt"),[,i]=e.split(" ");return!i},this.updateTimeValues=()=>{let t;t=this.finalTwentyFourFormat?this.timeObject.toFormat("HH:mm:ss"):this.timeObject.toFormat("hh:mm:ss a");const[e,i]=t.split(" "),o=e.split(":");v.forEach(t=>{const e=this.formatAndValidate(o.shift(),t);e&&(t===s.R5.HOUR&&i&&(this.timeValue[s.R5.AM_PM]=i),this.timeValue[t]=e)})},this.updateValidity=(t,e)=>{let i=!0;if(!this.showDefaultNowTime&&!this.value&&!t)return void(this.timeValidity[e]=!0);const o=e=>{null===t.match(e)&&(i=!1)};switch(e){case s.R5.HOUR:this.finalTwentyFourFormat?o(new RegExp(r.b.twentyFourHourString)):o(new RegExp(r.b.hourString));break;case s.R5.MINUTE:case s.R5.SECOND:o(new RegExp(r.b.minuteSecondString));break;case s.R5.AM_PM:o(new RegExp(r.b.amPmString))}this.timeValidity[e]=i},this.to12HourFormat=(t,e)=>{if(!this.finalTwentyFourFormat&&this.timeValidity[s.R5.HOUR]&&this.timeValidity[s.R5.AM_PM]){let i=Number(e);return"PM"===t?i=12+i%12:i%=12,i}},this.isEntireTimeValid=()=>{const t=[s.R5.HOUR];this.timeSpecificity!==s.R5.MINUTE&&this.timeSpecificity!==s.R5.SECOND||t.push(s.R5.MINUTE),this.timeSpecificity===s.R5.SECOND&&t.push(s.R5.SECOND),this.finalTwentyFourFormat||t.push(s.R5.AM_PM);const e=t.every(t=>this.timeValidity[t]);return(this.showDefaultNowTime||this.value||t.every(t=>!!this.timeValue[t]))&&e},this.updateTimeUnit=t=>{var e,i;if(this.updateValidity(this.timeValue[t],t),this.showDefaultNowTime||this.value){if(this.timeObject&&this.timeValidity[t]){if(t!==s.R5.AM_PM)this.timeObject=null===(e=this.timeObject)||void 0===e?void 0:e.set({[t]:Number(this.timeValue[t])});else{const t=this.to12HourFormat(this.timeValue[s.R5.AM_PM],this.timeValue[s.R5.HOUR]);void 0!==t&&(this.timeObject=null===(i=this.timeObject)||void 0===i?void 0:i.set({hour:t}))}this.isEntireTimeValid()&&(this.value=this.timeObject.toISOTime({suppressMilliseconds:!0})||this.value,this.dispatchTimeChangeEvent())}}else{const t=this.timeValue[s.R5.HOUR]||"00",e=this.timeValue[s.R5.MINUTE]||"00",i=this.timeValue[s.R5.SECOND]||"00";try{let o=`${t}:${e}:${i}`;!this.finalTwentyFourFormat&&this.timeValue[s.R5.AM_PM]&&(o+=` ${this.timeValue[s.R5.AM_PM]}`),this.timeObject=p.DateTime.fromFormat(o,this.finalTwentyFourFormat?"HH:mm:ss":"hh:mm:ss a"),this.timeObject.isValid&&this.isEntireTimeValid()&&(this.value=this.timeObject.toISOTime({suppressMilliseconds:!0}),this.dispatchTimeChangeEvent())}catch(t){console.warn("Failed to construct time object:")}}},this.formatTimeUnit=t=>{if(1===this.timeValue[t].length)"0"!==this.timeValue[t]&&(this.timeValue[t]="0"+this.timeValue[t]);else if(this.timeValue[t].length>2&&"0"===this.timeValue[t][0]){const e=this.timeValue[t].substring(1);RegExp(r.b.noPrecedingZerosString).test(e)&&(this.timeValue[t]=e)}this.requestUpdate()},this.messageType=t=>t?"":"error",this.generateTimeBox=t=>{const e=(i=this.finalTwentyFourFormat,{[s.R5.HOUR]:{type:"number",min:i?0:1,max:i?23:12},[s.R5.MINUTE]:{type:"number",min:0,max:59},[s.R5.SECOND]:{type:"number",min:0,max:59},[s.R5.AM_PM]:{type:"text",min:void 0,max:void 0}})[t];var i;return n.html`
        ${t===s.R5.MINUTE||t===s.R5.SECOND?n.html` <span class="colon-separator">:</span> `:n.nothing}
        <md-input
          newMomentum
          select-when-in-focus
          exportparts="input:timepicker-part-input"
          class="${`time-input-box ${t}`}"
          id="time-${f.findIndex(e=>e===t)+1}"
          value="${this.timeValue[t]}"
          type="${e.type}"
          min=${(0,u.ifDefined)(e.min)}
          max=${(0,u.ifDefined)(e.max)}
          maxLength=${2}
          placeholder="${y[t]}"
          @input-change=${e=>this.handleTimeChange(e,t)}
          @input-keydown=${e=>this.handleTimeKeyDown(e,t)}
          @input-blur=${e=>this.handleTimeBlur(e,t)}
          .messageArr=${[{message:"",type:this.messageType(this.timeValidity[t])}]}
          .ariaLabel="${t}-input"
          ariaInvalid="${!this.timeValidity[t]}"
        ></md-input>
      `},this.generateAmPmComboBox=()=>n.html`
        <md-combobox
          newMomentum
          select-when-in-focus
          class="amPm-combo-box"
          .options=${["AM","PM"]}
          .value=${[this.timeValue[s.R5.AM_PM]]}
          .preventFilter=${!0}
          is-dropdown-arrow
          no-clear-icon
          .inputValue=${this.timeValue[s.R5.AM_PM]}
          .ariaLabel=${this.timeValue[s.R5.AM_PM]}
          @change-selected=${t=>this.handleTimeChange(t,s.R5.AM_PM)}
        >
        </md-combobox>
      `}get timePickerClassMap(){return{"twenty-four-hour-format":this.finalTwentyFourFormat}}connectedCallback(){super.connectedCallback(),this.initializeTimeValues()}updated(t){super.updated(t),["value","locale","twentyFourHourFormat","showDefaultNowTime","timeSpecificity"].some(e=>t.has(e))&&this.initializeTimeValues()}initializeTimeValues(){if(this.showDefaultNowTime||this.value){const t=this.value||(0,a.tB)().toISOTime({suppressMilliseconds:!0});t&&this.updateValue(t)}else{const t=p.DateTime.now().setLocale(this.locale),e=this.getLocaleTimeFormat(t);this.finalTwentyFourFormat=this.twentyFourHourFormat||e;const i=this.timeSpecificity===s.R5.MINUTE||this.timeSpecificity===s.R5.SECOND,o=this.timeSpecificity===s.R5.SECOND;this.timeValue={[s.R5.HOUR]:"",[s.R5.MINUTE]:i?"":"00",[s.R5.SECOND]:o?"":"00",[s.R5.AM_PM]:"AM"}}}updateValue(t){const e=t||this.value;if(!e)return;this.timeObject=p.DateTime.fromISO(e,{locale:this.locale});const i=this.getLocaleTimeFormat(this.timeObject);this.finalTwentyFourFormat=this.twentyFourHourFormat||i,this.value=this.timeObject.toISOTime({suppressMilliseconds:!0}),this.updateTimeValues()}dispatchTimeChangeEvent(){this.dispatchEvent(new CustomEvent("time-selection-change",{bubbles:!0,composed:!0,detail:{time:this.value,data:this.timeObject,isValid:this.isEntireTimeValid()}}))}handleTimeChange(t,e){var i,o,a;this.timeValue[e]=null===(i=null==t?void 0:t.detail)||void 0===i?void 0:i.value,this.requestUpdate(),this.formatTimeUnit(e);const r=this.timeValue[e];if(this.twoDigitAutoTab&&this.tabNext&&(e!==s.R5.AM_PM&&2===r.length&&"0"!==r[0]||"00"===r)){t.preventDefault();const e=null==t?void 0:t.target,i=null===(o=this.shadowRoot)||void 0===o?void 0:o.querySelectorAll("md-input, md-combobox");if(i){const t=Array.prototype.findIndex.call(i,t=>null==e?void 0:e.isEqualNode(t)),s=(t+1)%i.length;if(t<i.length-1){const t=null===(a=i[s].shadowRoot)||void 0===a?void 0:a.querySelector("input");null==t||t.focus()}}}else e===s.R5.AM_PM&&this.updateTimeUnit(e);t.stopPropagation(),this.dispatchEvent(new CustomEvent(`${e}-change`,{bubbles:!0,composed:!0,detail:{srcEvent:t,value:`${this.timeValue[e]}`,isValid:this.timeValidity[e]}}))}handleTimeKeyDown(t,e){var i;const o=null===(i=null==t?void 0:t.detail)||void 0===i?void 0:i.srcEvent;if(!o)return void console.warn("srcEvent is undefined");const{key:a}=o;a===s.Uz.ArrowDown||a===s.Uz.ArrowUp?this.tabNext=!1:this.tabNext=!0,this.timeValidity[e]=!0,this.requestUpdate(),t.stopPropagation(),this.dispatchEvent(new CustomEvent(`${e}-keydown`,{bubbles:!0,composed:!0,detail:{srcEvent:t,value:`${this.timeValue[e]}`}}))}handleTimeBlur(t,e){"0"===this.timeValue[e]&&(this.timeValue[e]="00"),this.updateTimeUnit(e),this.requestUpdate(),t.stopPropagation(),this.dispatchEvent(new CustomEvent(`${e}-blur`,{bubbles:!0,composed:!0,detail:{srcEvent:t,time:this.value,isValid:this.timeValidity[e]}}))}static get styles(){return[m.A,c.A]}render(){return n.html`
        <div class="md-timepicker ${(0,h.classMap)(this.timePickerClassMap)}">
          <div class="time-inputs-wrapper">
            ${this.generateTimeBox(s.R5.HOUR)}
            ${this.timeSpecificity===s.R5.HOUR?n.nothing:this.generateTimeBox(s.R5.MINUTE)}
            ${this.timeSpecificity===s.R5.MINUTE||this.timeSpecificity===s.R5.HOUR?n.nothing:this.generateTimeBox(s.R5.SECOND)}
            ${this.finalTwentyFourFormat?n.nothing:this.generateAmPmComboBox()}
          </div>
        </div>
      `}};d([(0,l.property)({type:Boolean,attribute:"two-digit-auto-tab"})],e.prototype,"twoDigitAutoTab",void 0),d([(0,l.property)({type:Boolean,attribute:"twenty-four-hour-format",reflect:!0})],e.prototype,"twentyFourHourFormat",void 0),d([(0,l.property)({type:String})],e.prototype,"timeSpecificity",void 0),d([(0,l.property)({type:String})],e.prototype,"locale",void 0),d([(0,l.property)({type:String,reflect:!0})],e.prototype,"value",void 0),d([(0,l.property)({type:Boolean,attribute:"show-default-now-time"})],e.prototype,"showDefaultNowTime",void 0),d([(0,l.state)()],e.prototype,"finalTwentyFourFormat",void 0),d([(0,l.state)()],e.prototype,"timeObject",void 0),d([(0,l.state)()],e.prototype,"tabNext",void 0),d([(0,l.state)()],e.prototype,"timeValue",void 0),d([(0,l.state)()],e.prototype,"timeValidity",void 0),e=d([(0,o.w)("md-timepicker")],e),t.ELEMENT=e}(R||(R={}))},2900(t,e,i){var s,o,a,r;i.d(e,{R5:()=>o,Uz:()=>s,iw:()=>r}),function(t){t.ArrowDown="ArrowDown",t.ArrowLeft="ArrowLeft",t.ArrowRight="ArrowRight",t.ArrowUp="ArrowUp",t.Backspace="Backspace",t.Delete="Delete",t.End="End",t.Enter="Enter",t.Escape="Escape",t.Home="Home",t.Space="Space",t.Tab="Tab",t.Digit1="Digit1",t.Digit2="Digit2",t.Digit3="Digit3",t.Digit4="Digit4",t.Digit5="Digit5",t.Digit6="Digit6",t.Digit7="Digit7",t.Digit8="Digit8",t.Digit9="Digit9",t.NumpadEnter="NumpadEnter"}(s||(s={})),function(t){t.HOUR="hour",t.MINUTE="minute",t.SECOND="second",t.AM_PM="am_pm"}(o||(o={})),function(t){t.GRAMMAR="grammar",t.FALSE="false",t.SPELLING="spelling",t.TRUE="true"}(a||(a={})),function(t){t.AriaActivedescendant="aria-activedescendant"}(r||(r={}))},9500(e,i,s){var o,a;e.exports=(o={default:()=>t.default},a={},s.d(a,o),a)},3496(t,i,s){var o,a;t.exports=(o={default:()=>e.default},a={},s.d(a,o),a)},2927(t,e,s){var o,a;t.exports=(o={LitElement:()=>i.LitElement,css:()=>i.css,html:()=>i.html,nothing:()=>i.nothing},a={},s.d(a,o),a)},8899(t,e,i){var o,a;t.exports=(o={property:()=>s.property,query:()=>s.query,queryAll:()=>s.queryAll,state:()=>s.state},a={},i.d(a,o),a)},4955(t,e,i){var s,a;t.exports=(s={classMap:()=>o.classMap},a={},i.d(a,s),a)},3517(t,e,i){var s,o;t.exports=(s={ifDefined:()=>a.ifDefined},o={},i.d(o,s),o)},2577(t,e,i){var s,o;t.exports=(s={repeat:()=>r.repeat},o={},i.d(o,s),o)},1156(t,e,i){var s,o;t.exports=(s={styleMap:()=>m.styleMap},o={},i.d(o,s),o)},9642(t,e,i){var s,o;t.exports=(s={DateTime:()=>n.DateTime},o={},i.d(o,s),o)},4980(t,e,i){var s,o;t.exports=(s={action:()=>l.action,observable:()=>l.observable},o={},i.d(o,s),o)}},c={};function d(t){var e=c[t];if(void 0!==e)return e.exports;var i=c[t]={exports:{}};return p[t].call(i.exports,i,i.exports,d),i.exports}d.m=p,h=[],d.O=(t,e,i,s)=>{if(!e){var o=1/0;for(n=0;n<h.length;n++){for(var[e,i,s]=h[n],a=!0,r=0;r<e.length;r++)(!1&s||o>=s)&&Object.keys(d.O).every(t=>d.O[t](e[r]))?e.splice(r--,1):(a=!1,s<o&&(o=s));if(a){h.splice(n--,1);var m=i();void 0!==m&&(t=m)}}return t}s=s||0;for(var n=h.length;n>0&&h[n-1][2]>s;n--)h[n]=h[n-1];h[n]=[e,i,s]},d.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return d.d(e,{a:e}),e},d.d=(t,e)=>{for(var i in e)d.o(e,i)&&!d.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},d.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),d.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);export{d as __webpack_require__};u={502:0,519:0,1745:0,2169:0,2900:0,4545:0,4928:0,5369:0,5757:0,6060:0,6920:0,7145:0,8111:0,8138:0,8442:0},d.C=t=>{var e,i,{__webpack_esm_ids__:s,__webpack_esm_modules__:o,__webpack_esm_runtime__:a}=t,r=0;for(e in o)d.o(o,e)&&(d.m[e]=o[e]);for(a&&a(d);r<s.length;r++)i=s[r],d.o(u,i)&&u[i]&&u[i][0](),u[s[r]]=0;d.O()},d.O.j=t=>0===u[t];import*as f from"../7103.js";d.C(f);import*as v from"../9609.js";d.C(v);import*as y from"../4084.js";d.C(y);import*as R from"../3305.js";d.C(R);import*as g from"../4739.js";d.C(g);import*as b from"../7154.js";d.C(b);import*as w from"../9773.js";d.C(w);import*as T from"../5983.js";d.C(T);import*as M from"../9488.js";d.C(M);import*as E from"../1821.js";d.C(E);import*as O from"../2364.js";d.C(O);import*as V from"../9938.js";d.C(V);import*as C from"../4781.js";d.C(C);import*as D from"../5201.js";d.C(D);import*as j from"../5584.js";d.C(j);import*as A from"../8227.js";d.C(A);import*as N from"../7704.js";d.C(N);import*as S from"../2797.js";d.C(S);import*as x from"../3970.js";d.C(x);import*as F from"../7906.js";d.C(F);import*as U from"../9336.js";d.C(U);import*as _ from"../2369.js";d.C(_);import*as P from"../9189.js";d.C(P);import*as $ from"../4047.js";d.C($);import*as H from"../3331.js";d.C(H);import*as I from"../4431.js";d.C(I);import*as k from"../4654.js";d.C(k);import*as L from"../8497.js";d.C(L);import*as B from"../7911.js";d.C(B);var q=d.O(void 0,[7103,9609,4084,3305,4739,7154,9773,5983,9488,1821,2364,9938,4781,5201,5584,8227,7704,2797,3970,7906,9336,2369,9189,4047,3331,4431,4654,8497,7911],()=>d(2218));const z=(q=d.O(q)).AG,G=q.K_,K=q.F7;export{z as TimePicker,G as timeSpecificity,K as timeUnits};