jb-date-input
Version:
jalali date input web component
2 lines • 39.7 kB
JavaScript
import"jb-calendar";import{JBInputWebComponent as e}from"jb-input";import"jb-popover";import{ValidationHelper as t}from"jb-validation";import{createFocusEvent as i,createInputEvent as a,createKeyboardEvent as n,enToFaDigits as s,faToEnDigits as l,isMobile as r,listenAndSilentEvent as o}from"jb-core";import{registerDefaultVariables as u}from"jb-core/theme";import{getDate as h,getMonth as c,getTime as d,getYear as m,isAfter as p,isBefore as g,isEqual as f,isLeapYear as y}from"date-fns";import{getDate as b,getHours as v,getMilliseconds as V,getMinutes as D,getMonth as I,getSeconds as A,getYear as N,newDate as E}from"date-fns-jalali";import{JBDictionary as M,i18n as T}from"jb-core/i18n";function w(e,t,i,a){if("a"===i&&!a)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?a:"a"===i?a.call(e):a?a.value:t.get(e)}function _(e,t,i,a,n){if("m"===a)throw new TypeError("Private method is not writable");if("a"===a&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===a?n.call(e,i):n?n.value=i:t.set(e,i),i}var j,O;(O=j||(j={})).jalali="JALALI",O.gregorian="GREGORIAN",O.timeStamp="TIME_STAMP";const S=" / / ",R="YYYY/MM/DD",L=/^(?<year>[\u06F0-\u06F90-9,\s]{4})\/(?<month>[\u06F0-\u06F90-9,\s]{2})\/(?<day>[\u06F0-\u06F90-9,\s]{2})$/g;var Y,B,k,C,F,P,G,x,H,U,J;function W(e){return[1,5,9,13,17,22,26,30].includes(e%33)}function q(e){return e.substring(5,7)}function Z(e){return e.substring(0,4)}function X(e){return e.substring(8,10)}function $(e){const{showPersianNumber:t,dateInputType:i,selection:a,event:{data:n,inputType:r}}=e,o=a.start;let u=o,h=e.value;var c;return n&&(c=e.event.data||"",l(c).replace(/[^\u06F0-\u06F90-9/]/g,"")).split("").forEach(((e,t)=>{let a=o+t;if(!/[\u06F0-\u06F90-9/]/g.test(e))return;4!=a&&7!=a||("/"==e&&m(a+1),a++);let n=!1;if("/"==e)return;const s=Number(e);5==a&&s>1&&(d("0",a),a++);const l=function(e,t,i){let a=!1;return 5==i&&1==t&&e[6]>"2"&&(a=!0),6==i&&t>2&&"1"==e[5]&&(a=!0),6==i&&0==t&&"0"==e[5]&&(a=!0),5==i&&0==t&&"0"==e[4]&&(a=!0),{isIgnoreChar:a,caretPos:i}}(h,s,a);a=l.caretPos;const r=function(e,t,i,a,n){let s=!1;if(8==i&&t>3&&(n("0",i),i++),9==i&&t>1&&"3"==a[8]&&(s=!0),9==i&&0==t&&"0"==a[8]&&(s=!0),8==i&&0==t&&"0"==a[9]&&(s=!0),"JALALI"==e&&!s){const e=q(a),l=Number(e);if(9==i&&"3"==a[8]&&t>0&&l>6&&(s=!0),8==i&&3==t){if(12==l){const e=Number(Z(a));!Number.isNaN(e)&&W(e)||(s=!0)}a[9]>"0"&&(2==e.length&&parseInt(a)>6&&n("0",9),2==e.length&&l<7&&a[9]>"1"&&n("1",9))}}return{isIgnoreChar:s,caretPos:i}}(i,s,a,h,d);a=r.caretPos,n=n||r.isIgnoreChar||l.isIgnoreChar,n||(d(e,a),m(a+1))})),"deleteContentBackward"!=r&&"deleteContentForward"!=r&&"delete"!=r&&"deleteByCut"!=r&&"deleteByDrag"!=r||function(e,t,i,a,n){let s=0;"deleteContentBackward"==e&&(s=t!==i?0:-1);for(let e=t;e<=i;e++)a(" ",e+s);n(t+s)}(r,a.start,a.end,d,m),{value:h,selectionStart:u,selectionEnd:u};function d(e,i){h=function(e,t,i,a){if(4!=t&&7!=t||(e="/"),t>9||t<0)return i;const n=i.split("");return a&&(e=s(e)),n[t]=e,n.join("")}(e,i,h,t)}function m(e){u=e}}function z(e){const t=e.selectionStart;if(t){const i=Z(e.inputValue).trim().length,a=q(e.inputValue).trim().length,n=X(e.inputValue).trim().length;if(i<t&&(t<=4||0==a&&0==n))return i;if(t>4&&(t<=7&&a+5<t||0==n&&a<2))return a+5;if(n+8<t&&t>7&&t<=10)return n+8}return null}(B=Y||(Y={})).jalali="JALALI",B.gregorian="GREGORIAN";var K=class{get valueFormat(){return w(this,x,"f")}set valueFormat(e){_(this,x,e,"f")}get nicheNumbers(){return w(this,G,"f")}get yearOnEmptyBaseOnInputType(){return"JALALI"==w(this,P,"f")?w(this,G,"f").calendarYearOnEmpty.jalali:w(this,G,"f").calendarYearOnEmpty.gregorian}get monthOnEmptyBaseOnValueType(){return"JALALI"==this.valueType?w(this,G,"f").calendarMonthOnEmpty.jalali:w(this,G,"f").calendarMonthOnEmpty.gregorian}get inputType(){return w(this,P,"f")}get valueType(){return w(this,F,"f")}constructor(e){k.add(this),F.set(this,"GREGORIAN"),P.set(this,"persian"==T.locale.calendar?Y.jalali:Y.gregorian),G.set(this,{calendarYearOnEmpty:{jalali:C.todayJalaliYear,gregorian:C.todayGregorianYear},calendarMonthOnEmpty:{jalali:C.todayJalaliMonth,gregorian:C.todayGregorianMonth}}),x.set(this,"YYYY-MM-DDTHH:mm:ss.SSS[Z]"),e.inputType&&_(this,P,e.inputType,"f"),e.valueType&&_(this,F,e.valueType,"f")}setInputType(e){_(this,P,e,"f")}setValueType(e){_(this,F,e,"f")}getYearValueBaseOnInputType(e){return w(this,P,"f")==Y.jalali?e.jalali.year:e.gregorian.year}getMonthValueBaseOnInputType(e){return w(this,P,"f")==Y.jalali?e.jalali.month:e.gregorian.month}getDayValueBaseOnInputType(e){return w(this,P,"f")==Y.jalali?e.jalali.day:e.gregorian.day}getDateFromValueDateString(e){let t=null;if("TIME_STAMP"==this.valueType)t=C.getDateFromTimestamp(parseInt(e));else{const i=this.getDateObjectValueBaseOnFormat(e),a=parseInt(i.year),n=parseInt(i.month),s=parseInt(i.day);null!=i&&null!==a&&null!==n&&null!==s&&("GREGORIAN"==this.valueType&&(t=C.getDateFromGregorian(a,n,s)),"JALALI"==this.valueType&&(t=C.getDateFromJalali(a,n,s)))}return t}getDateValueFromValueObject(e){if(e.gregorian.year&&e.gregorian.month&&e.gregorian.day){return new Date(e.gregorian.year,e.gregorian.month-1,e.gregorian.day)}return null}getDateValueStringFromValueObject(e,t=this.valueType){const i="0000",a=e.time.hour?.toString().padStart(2,"0")??"00",n=e.time.minute?.toString().padStart(2,"0")??"00",s=e.time.second?.toString().padStart(2,"0")??"00",l=e.time.millisecond?.toString().padStart(3,"0")??"000",r=()=>{const{year:t,month:r,day:o}=e.gregorian,u=null==t?i:t<1e3?t<100?t<10?"000"+t:"00"+t:"0"+t:t.toString(),h=null==r?"00":r<10?"0"+r:r.toString(),c=null==o?"00":o<10?"0"+o:o.toString();return w(this,x,"f").replace("YYYY",u).replace("MM",h).replace("DD",c).replace("HH",a).replace("mm",n).replace("ss",s).replace("SSS",l).replace("[Z]","Ž").replace("Z","+00:00").replace("Ž","Z")},o=()=>{const{year:t,month:r,day:o}=e.jalali,u=null==t?i:t<1e3?t<100?t<10?"000"+t:"00"+t:"0"+t:t.toString(),h=null==r?"00":r<10?"0"+r:r.toString(),c=null==o?"00":o<10?"0"+o:o.toString();return this.valueFormat.replace("YYYY",u).replace("MM",h).replace("DD",c).replace("HH",a).replace("mm",n).replace("ss",s).replace("SSS",l).replace("[Z]","Ž").replace("Z","+00:00").replace("Ž","Z")};if("object"==typeof e)switch(t){case"GREGORIAN":return r();case"JALALI":return o();case"TIME_STAMP":if(e.timeStamp)return e.timeStamp.toString()}return""}getCalendarYear(e){const t=this.inputType==Y.gregorian?w(this,G,"f").calendarYearOnEmpty.gregorian:w(this,G,"f").calendarYearOnEmpty.jalali;return this.getYearValueBaseOnInputType(e)||t}getCalendarMonth(e){const t=this.inputType==Y.gregorian?w(this,G,"f").calendarMonthOnEmpty.gregorian:w(this,G,"f").calendarMonthOnEmpty.jalali;return this.getMonthValueBaseOnInputType(e)||t}getCalendarDay(e){return this.getDayValueBaseOnInputType(e)}setCalendarDefaultDateView(e,t,i=w(this,P,"f")){i==Y.gregorian?(w(this,G,"f").calendarYearOnEmpty.gregorian=e,w(this,G,"f").calendarMonthOnEmpty.gregorian=t):i==Y.jalali&&(w(this,G,"f").calendarYearOnEmpty.jalali=e,w(this,G,"f").calendarMonthOnEmpty.jalali=t)}getDateValueObjectBaseOnInputType(e,t,i,a,n,s,l,r,o){return w(this,P,"f")==Y.gregorian?w(this,k,"m",H).call(this,e,t,i,a,n,s,l,r,o):w(this,P,"f")==Y.jalali?w(this,k,"m",U).call(this,e,t,i,a,n,s,l,r,o):(console.error("INVALID_INPUT_TYPE"),{gregorian:{year:null,month:null,day:null},jalali:{year:null,month:null,day:null},timeStamp:null,time:{hour:null,minute:null,second:null,millisecond:null}})}getDateValueObjectBaseOnValueType(e,t,i,a,n,s,l,r,o){return"GREGORIAN"==w(this,F,"f")||"TIME_STAMP"==w(this,F,"f")?w(this,k,"m",H).call(this,e,t,i,a,n,s,l,r,o):"JALALI"==w(this,F,"f")?w(this,k,"m",U).call(this,e,t,i,a,n,s,l,r,o):(console.error("INVALID_INPUT_TYPE"),{gregorian:{year:null,month:null,day:null},jalali:{year:null,month:null,day:null},timeStamp:null,time:{hour:null,minute:null,second:null,millisecond:null}})}getDateValueObjectFromTimeStamp(e){const t=new Date(e);return isFinite(+t)?this.getDateObjectValueFromDateValue(t):{gregorian:{year:null,month:null,day:null},jalali:{year:null,month:null,day:null},timeStamp:null,time:{hour:null,minute:null,second:null,millisecond:null}}}getDateObjectValueFromDateValue(e){return{gregorian:{year:m(e),month:c(e)+1,day:h(e)},jalali:{year:N(e),month:I(e)+1,day:b(e)},timeStamp:d(e),time:{hour:v(e),minute:D(e),second:A(e),millisecond:V(e)}}}static checkJalaliDateValidation(e,t,i){const a={isValid:!0,error:null};return isNaN(e)&&(a.isValid=!1,a.error="INVALID_YEAR"),isNaN(t)&&(a.isValid=!1,a.error="INVALID_MONTH"),isNaN(i)&&(a.isValid=!1,a.error="INVALID_DAY"),t<1&&(a.isValid=!1,a.error="INVALID_MIN_MONTH_NUMBER"),i<1&&(a.isValid=!1,a.error="INVALID_MIN_DAY_NUMBER"),t>12&&(a.isValid=!1,a.error="INVALID_MAX_MONTH_NUMBER"),i>31&&(a.isValid=!1,a.error="INVALID_MAX_DAY_NUMBER"),e<1e3&&(a.isValid=!1,a.error="INVALID_MIN_YEAR_NUMBER"),e>9999&&(a.isValid=!1,a.error="INVALID_MAX_YEAR_NUMBER"),t>6&&t<12&&i>30&&(a.isValid=!1,a.error="INVALID_DAY_IN_MONTH"),12==t&&i>30&&(a.isValid=!1,a.error="INVALID_DAY_IN_MONTH"),a.isValid&&12==t&&12==t&&30==i&&(W(e)||(a.isValid=!1,a.error="INVALID_DAY_FOR_LEAP")),a}static checkGregorianDateValidation(e,t,i){const a={isValid:!0,error:null};if(isNaN(e)&&(a.isValid=!1,a.error="INVALID_YEAR"),isNaN(t)&&(a.isValid=!1,a.error="INVALID_MONTH"),isNaN(i)&&(a.isValid=!1,a.error="INVALID_DAY"),t<1&&(a.isValid=!1,a.error="INVALID_MIN_MONTH_NUMBER"),i<1&&(a.isValid=!1,a.error="INVALID_MIN_DAY_NUMBER"),t>12&&(a.isValid=!1,a.error="INVALID_MAX_MONTH_NUMBER"),i>31&&(a.isValid=!1,a.error="INVALID_MAX_DAY_NUMBER"),e<1e3&&(a.isValid=!1,a.error="INVALID_MIN_YEAR_NUMBER"),e>9999&&(a.isValid=!1,a.error="INVALID_MAX_YEAR_NUMBER"),[2,4,6,9,11].includes(i)&&i>30&&(a.isValid=!1,a.error="INVALID_DAY_IN_MONTH"),2==t&&i>28)if(29==i){const n=C.getDateFromGregorian(e,t,i);y(n)||(a.isValid=!1,a.error="INVALID_DAY_FOR_LEAP")}else a.isValid=!1,a.error="INVALID_DAY_IN_MONTH";return a}getDateObjectValueBaseOnFormat(e,t=w(this,x,"f")){const i=w(C,C,"m",J).call(C,e,t),a={year:null,month:null,day:null,hour:null,millisecond:null,minute:null,second:null};return i&&i.groups&&(a.year=i.groups.year,a.month=i.groups.month,a.day=i.groups.day,a.hour=i.groups.hour,a.minute=i.groups.minute,a.second=i.groups.second,a.millisecond=i.groups.millisecond),a}static getDate(e,t,i,a,n,s,l,r){return a==Y.jalali?C.getDateFromJalali(e,t,i):C.getDateFromGregorian(e,t,i)}static getDateFromGregorian(e,t,i,a,n,s,l){return new Date(e,t-1,i,a,n,s,l)}static getDateFromJalali(e,t,i,a,n,s,l){return E(e,t-1,i,a,n,s,l)}static getDateFromTimestamp(e){return new Date(e)}static get todayGregorianYear(){return m(new Date)}static get todayJalaliYear(){return N(new Date)}static get todayGregorianMonth(){return c(new Date)+1}static get todayJalaliMonth(){return I(new Date)+1}};C=K,F=new WeakMap,P=new WeakMap,G=new WeakMap,x=new WeakMap,k=new WeakSet,H=function e(t,i,a,n,s,l,r,o,u){const p={gregorian:{year:null,month:null,day:null},jalali:{year:null,month:null,day:null},timeStamp:null,time:{hour:null,minute:null,second:null,millisecond:null}},g=C.checkGregorianDateValidation(t,i,a);if(!g.isValid)return"INVALID_MIN_DAY_NUMBER"==g.error?w(this,k,"m",e).call(this,t,i,1,n,s,l,r,o,u):"INVALID_MIN_MONTH_NUMBER"==g.error?w(this,k,"m",e).call(this,t,1,a,n,s,l,r,o,u):"INVALID_MIN_YEAR_NUMBER"==g.error?w(this,k,"m",e).call(this,1900,i,a,n,s,l,r,o,u):"INVALID_MAX_DAY_NUMBER"==g.error?w(this,k,"m",e).call(this,t,i,31,n,s,l,r,o,u):"INVALID_MAX_MONTH_NUMBER"==g.error?w(this,k,"m",e).call(this,t,12,a,n,s,l,r,o,u):"INVALID_MAX_YEAR_NUMBER"==g.error?w(this,k,"m",e).call(this,9e3,i,a,n,s,l,r,o,u):"INVALID_DAY_IN_MONTH"==g.error&&s!=i&&a>29||"INVALID_DAY_FOR_LEAP"==g.error&&n!=t&&29==a?w(this,k,"m",e).call(this,t,i,a-1,n,s,l,r,o,u):{gregorian:{year:null,month:null,day:null},jalali:{year:null,month:null,day:null},timeStamp:null,time:{hour:null,minute:null,second:null,millisecond:null}};const f=C.getDateFromGregorian(t,i,a,l,r,o,u);return p.gregorian={year:m(f),month:c(f)+1,day:h(f)},p.jalali={year:N(f),month:I(f)+1,day:b(f)},p.timeStamp=d(f),p.time={hour:l,minute:r,second:o,millisecond:u},p},U=function e(t,i,a,n,s,l,r,o,u){const p={gregorian:{year:null,month:null,day:null},jalali:{year:null,month:null,day:null},timeStamp:null,time:{hour:null,minute:null,second:null,millisecond:null}},g=C.checkJalaliDateValidation(t,i,a);if(!g.isValid){if("INVALID_MIN_DAY_NUMBER"==g.error)return w(this,k,"m",e).call(this,t,i,1,n,s,l,r,o,u);if("INVALID_MIN_MONTH_NUMBER"==g.error)return w(this,k,"m",e).call(this,t,1,a,n,s,l,r,o,u);if("INVALID_MIN_YEAR_NUMBER"==g.error)return w(this,k,"m",e).call(this,1300,i,a,n,s,l,r,o,u);if("INVALID_MAX_DAY_NUMBER"==g.error)return w(this,k,"m",e).call(this,t,i,31,n,s,l,r,o,u);if("INVALID_MAX_MONTH_NUMBER"==g.error)return w(this,k,"m",e).call(this,t,12,a,n,s,l,r,o,u);if("INVALID_MAX_YEAR_NUMBER"==g.error)return w(this,k,"m",e).call(this,9999,i,a,n,s,l,r,o,u);if("INVALID_DAY_IN_MONTH"==g.error&&s!=i&&31==a)return w(this,k,"m",e).call(this,t,i,a-1,n,s,l,r,o,u);if("INVALID_DAY_FOR_LEAP"==g.error){const a=W(t)?30:29;return w(this,k,"m",e).call(this,t,i,a,n,s,l,r,o,u)}return{gregorian:{year:null,month:null,day:null},jalali:{year:null,month:null,day:null},timeStamp:null,time:{hour:null,minute:null,second:null,millisecond:null}}}const f=C.getDateFromJalali(t,i,a,l,r,o,u);return p.gregorian={year:m(f),month:c(f)+1,day:h(f)},p.jalali={year:N(f),month:I(f)+1,day:b(f)},p.timeStamp=d(f),p.time={hour:l,minute:r,second:o,millisecond:u},p},J=function(e,t){const i=t.replace("YYYY","(?<year>[\\d]{4})").replace("MM","(?<month>[\\d]{2})").replace("DD","(?<day>[\\d]{2})").replace("HH","(?<hour>[\\d]{2})").replace("mm","(?<minute>[\\d]{2})").replace("ss","(?<second>[\\d]{2})").replace("SSS","(?<millisecond>[\\d]{3})").replace("[Z]","Ž").replace("Z","(?<zone>([\\+,-]\\d{2}:\\d{2}))").replace("Ž","Z");return new RegExp(i,"g").exec(e)};const Q=new M({fa:{minRangeViolation:"تاریخ انتخابی کمتر از بازه مجاز است",maxRangeViolation:"تاریخ انتخابی بیشتر از بازه مجاز است",required:"لطفا مقدار تاریخ را کامل وارد کنید"},en:{minRangeViolation:"Your selected date is before valid date range",maxRangeViolation:"Your selected date is after valid date range",required:"Please fill date completely"}}),ee={validator:e=>null!=e.inputObject.year&&null!=e.inputObject.month&&null!=e.inputObject.day,message:Q.get(T,"required"),stateType:"valueMissing"};var te,ie,ae,ne,se,le,re,oe,ue,he,ce,de,me,pe,ge,fe,ye,be,ve,Ve,De,Ie,Ae,Ne,Ee,Me,Te,we,_e,je,Oe,Se,Re,Le,Ye,Be,ke,Ce,Fe,Pe,Ge,xe,He,Ue,Je,We,qe,Ze,Xe,$e,ze,Ke,Qe,et,tt,it,at,nt,st,lt,rt,ot,ut,ht,ct,dt,mt,pt,gt,ft;null==HTMLElement&&console.error("you cant render web component on a server side. try to load this component as a client side component");var yt=class i extends HTMLElement{get isAutoValidationDisabled(){return w(this,ne,"f")}set isAutoValidationDisabled(e){_(this,ne,e,"f")}get validation(){return w(this,ae,"f")}get disabled(){return w(this,re,"f")}set disabled(e){_(this,re,e,"f"),this.elements.input.disabled=e,e?(w(this,ie,"f").states?.add("disabled"),w(this,ie,"f").ariaDisabled="true"):(w(this,ie,"f").states?.delete("disabled"),w(this,ie,"f").ariaDisabled="false")}get selectionStart(){return this.elements.input.selectionStart}set selectionStart(e){this.elements.input.selectionStart=e}get selectionEnd(){return this.elements.input.selectionEnd}set selectionEnd(e){this.elements.input.selectionEnd=e}get selectionDirection(){return this.elements.input.selectionDirection}set selectionDirection(e){this.elements.input.selectionDirection=e}setSelectionRange(e,t,i){this.elements.input.setSelectionRange(e,t,i)}set required(e){_(this,oe,e,"f"),w(this,ie,"f").ariaRequired=e?"true":"false",w(this,te,"m",pt).call(this,!1)}get required(){return w(this,oe,"f")}get name(){return this.getAttribute("name")||""}get form(){return w(this,ie,"f").form}get value(){return this.getDateValue()}set value(e){w(this,te,"m",Pe).call(this,e),w(this,te,"m",Ze).call(this)}get isDirty(){return this.value!==(this.initialValue??w(this,se,"f").getDateValueStringFromValueObject({gregorian:{year:null,month:null,day:null},jalali:{year:null,month:null,day:null},timeStamp:null,time:{hour:null,minute:null,second:null,millisecond:null}},this.valueType))}setMonthList(e,t){this.elements.calendar.setMonthList(e,t)}get valueInDate(){return w(this,se,"f").getDateValueFromValueObject(w(this,ue,"f"))}get inputValue(){return w(this,te,"a",pe)}get placeholder(){return w(this,de,"f")}set placeholder(e){_(this,de,e,"f"),w(this,ie,"f").ariaPlaceholder=e,this.elements.input.elements.input.placeholder=null!==e?e:"",w(this,te,"m",Ze).call(this)}get showCalendar(){return w(this,le,"f")}set showCalendar(e){_(this,le,e,"f"),1==e?(this.elements.calendar.setupStyleBaseOnCssDirection(),this.elements.popover.open(),this.elements.calendarTriggerButton.classList.add("--active")):(this.elements.popover.close(),this.elements.calendarTriggerButton.classList.remove("--active"),w(this,te,"m",xe).call(this))}get inputType(){return w(this,se,"f").inputType}set inputType(e){Object.values(Y).includes(e)?(w(this,se,"f").setInputType(e),this.onInputTypeChange()):console.error(`${e} is not a valid input type`)}get valueType(){return w(this,se,"f").valueType}set valueType(e){Object.values(j).includes(e)?w(this,se,"f").setValueType(e):console.error(`${e} is not a valid value type`)}get yearValue(){switch(this.valueType){case"JALALI":return w(this,ue,"f").jalali.year;case"GREGORIAN":case"TIME_STAMP":return w(this,ue,"f").gregorian.year;default:return null}}get yearDisplayValue(){switch(this.inputType){case"JALALI":return w(this,ue,"f").jalali.year;case"GREGORIAN":return w(this,ue,"f").gregorian.year;default:return null}}get monthValue(){switch(this.valueType){case"JALALI":return w(this,ue,"f").jalali.month;case"GREGORIAN":case"TIME_STAMP":return w(this,ue,"f").gregorian.month;default:return null}}get monthDisplayValue(){switch(this.inputType){case"JALALI":return w(this,ue,"f").jalali.month;case"GREGORIAN":return w(this,ue,"f").gregorian.month;default:return null}}get dayValue(){switch(this.valueType){case"JALALI":return w(this,ue,"f").jalali.day;case"GREGORIAN":case"TIME_STAMP":return w(this,ue,"f").gregorian.day;default:return null}}get dayDisplayValue(){switch(this.inputType){case"JALALI":return w(this,ue,"f").jalali.day;case"GREGORIAN":return w(this,ue,"f").gregorian.day;default:return null}}get yearBaseOnInputType(){switch(this.inputType){case Y.jalali:return w(this,ue,"f").jalali.year;case Y.gregorian:return w(this,ue,"f").gregorian.year;default:return null}}get monthBaseOnInputType(){switch(this.inputType){case Y.jalali:return w(this,ue,"f").jalali.month;case Y.gregorian:return w(this,ue,"f").gregorian.month;default:return null}}get dayBaseOnInputType(){switch(this.inputType){case Y.jalali:return w(this,ue,"f").jalali.day;case Y.gregorian:return w(this,ue,"f").gregorian.day;default:return null}}get typedYear(){return Z(this.inputValue)}get typedMonth(){return q(this.inputValue)}get typedDay(){return X(this.inputValue)}get sTypedYear(){return Z(w(this,te,"a",me))}get sTypedMonth(){return q(w(this,te,"a",me))}get sTypedDay(){return X(w(this,te,"a",me))}get valueFormat(){return w(this,se,"f").valueFormat}get showPersianNumber(){return w(this,fe,"f")}set showPersianNumber(e){_(this,fe,e,"f"),this.elements.calendar.showPersianNumber=e,w(this,te,"m",Ze).call(this)}constructor(){super(),te.add(this),ie.set(this,void 0),ae.set(this,new t({clearValidationError:this.clearValidationError.bind(this),getValue:()=>w(this,te,"a",he),getValidations:w(this,te,"m",lt).bind(this),getValueString:e=>e.text,setValidationResult:w(this,te,"m",ft).bind(this),showValidationError:this.showValidationError.bind(this)})),ne.set(this,!1),se.set(this,new K({inputType:this.getAttribute("input-type"),valueType:this.getAttribute("value-type")})),le.set(this,!1),this.dateRestrictions={min:null,max:null},re.set(this,!1),oe.set(this,!1),ue.set(this,{gregorian:{year:null,month:null,day:null},jalali:{year:null,month:null,day:null},timeStamp:null,time:{hour:null,minute:null,second:null,millisecond:null}}),this.initialValue=null,de.set(this,null),fe.set(this,"arabext"==T.locale.numberingSystem),Ie.set(this,!1),ze.set(this,S),ot.set(this,!1),"function"==typeof this.attachInternals&&_(this,ie,this.attachInternals(),"f"),w(this,te,"m",ve).call(this)}connectedCallback(){w(this,te,"m",ye).call(this),w(this,te,"m",Ne).call(this)}static get dateInputObservedAttributes(){return["value-type","value","name","format","min","max","required","input-type","direction","show-persian-number","placeholder","disabled","error"]}static get observedAttributes(){return[...e.observedAttributes,...i.dateInputObservedAttributes]}attributeChangedCallback(t,a,n){i.dateInputObservedAttributes.includes(t)?w(this,te,"m",Ee).call(this,t,n):e.observedAttributes.includes(t)&&this.elements.input.setAttribute(t,n)}setFormat(e){w(this,se,"f").valueFormat=e;const t=this.getAttribute("min");t&&w(this,te,"m",Me).call(this,t);const i=this.getAttribute("max");i&&w(this,te,"m",Te).call(this,i)}setMinDate(e){w(this,te,"m",Me).call(this,e)}setMaxDate(e){w(this,te,"m",Te).call(this,e)}getDateValue(e=this.valueType){return w(this,se,"f").getDateValueStringFromValueObject(w(this,ue,"f"),e)}focus(){this.elements.input.focus(),this.showCalendar=!0}triggerInputValidation(e=!0){return w(this,te,"m",pt).call(this,e)}showValidationError(e){this.elements.input.showValidationError(e),w(this,ie,"f").states?.add("invalid")}clearValidationError(){this.elements.input.clearValidationError(),w(this,ie,"f").states?.delete("invalid")}async onInputTypeChange(){w(this,Ie,"f")||await w(this,te,"m",Ae).call(this),this.elements.calendar.inputType=this.inputType,w(this,te,"m",Ze).call(this)}setCalendarDefaultDateView(e,t,i){e&&t&&(w(this,se,"f").setCalendarDefaultDateView(e,t,i),w(this,te,"m",xe).call(this))}checkValidity(){const e=w(this,ae,"f").checkValiditySync({showError:!1});return e.isAllValid||w(this,te,"m",gt).call(this),e.isAllValid}reportValidity(){const e=w(this,ae,"f").checkValiditySync({showError:!0});return e.isAllValid||w(this,te,"m",gt).call(this),e.isAllValid}get validationMessage(){return w(this,ie,"f").validationMessage}};ie=new WeakMap,ae=new WeakMap,ne=new WeakMap,se=new WeakMap,le=new WeakMap,re=new WeakMap,oe=new WeakMap,ue=new WeakMap,de=new WeakMap,fe=new WeakMap,Ie=new WeakMap,ze=new WeakMap,ot=new WeakMap,te=new WeakSet,he=function(){return{inputObject:w(this,se,"f").getDateObjectValueBaseOnFormat(w(this,te,"a",me),R),text:w(this,te,"a",me),valueText:this.value,valueObject:w(this,ue,"f")}},ce=function(){w(this,ie,"f")&&"function"==typeof w(this,ie,"f").setFormValue&&w(this,ie,"f").setFormValue(this.value)},me=function(){let e=w(this,te,"a",pe);return w(this,fe,"f")&&(e=l(e)),e},pe=function(){return this.elements.input.value},ge=function(e){this.elements.input.value=e},ye=function(){const e=new CustomEvent("load",{bubbles:!0,composed:!0});this.dispatchEvent(e)},be=function(){const e=new CustomEvent("init",{bubbles:!0,composed:!0});this.dispatchEvent(e)},ve=function(){const e=this.attachShadow({mode:"open",delegatesFocus:!0});u();const t=document.createElement("template");t.innerHTML='<style>:host{display:block}:host(:focus),:host(:focus-visible){outline:none}.jb-date-input-web-component{width:100%;margin:var(--margin);position:relative}.jb-date-input-web-component:focus-visible{outline:none}.jb-date-input-web-component .calendar-trigger{display:var(--calendar-trigger-display,block);width:var(--calendar-trigger-width,1.5rem);height:var(--calendar-trigger-height,1.5rem);cursor:pointer;object-fit:contain}.jb-date-input-web-component .calendar-trigger.--active svg .cls-1{fill:var(--calendar-icon-color-active)}.jb-date-input-web-component .calendar-trigger svg{width:100%;height:100%}.jb-date-input-web-component .calendar-trigger svg .cls-1{fill:var(--calendar-icon-color)} :host{--margin:var(--jb-date-input-margin,0 0);--calendar-trigger-display:var(--jb-date-input-calendar-trigger-display,block);--calendar-trigger-width:var(--jb-date-input-calendar-trigger-width,1.5rem);--calendar-trigger-height:var(--jb-date-input-calendar-trigger-height,1.5rem);--calendar-icon-color:var(--jb-date-input-calendar-icon-color,var(--jb-neutral-6));--calendar-icon-color-active:var(--jb-date-input-calendar-icon-color-active,var(--jb-neutral))}</style>\n\n <div class="jb-date-input-web-component">\n <jb-input disable-auto-validation part="input">\n <div class="date-input-end-section" slot="end-section">\n <div class="calendar-trigger" tabindex="0" >\n <slot name="calendar-trigger-icon">\n <svg xmlns="http://www.w3.org/2000/svg" id="CalendarIcon" viewBox="0 0 44.97 44.46">\n <defs>\n <style></style>\n </defs>\n <g>\n <path id="Path_11948" data-name="Path 11948" class="cls-1" d="M41.91,12H3.67C2,12,.61,12.59.61,13.37S2,14.78,3.67,14.78H41.91c1.69,0,3.06-.63,3.06-1.41S43.6,12,41.91,12Z" transform="translate(0 0)"/>\n <path id="Path_11946" data-name="Path 11946" class="cls-1" d="M33.73,2.22H33V1.36A1.58,1.58,0,0,0,31.33,0a1.61,1.61,0,0,0-1.69,1.36v.86l-5.88,0V1.48A1.46,1.46,0,0,0,22.31,0h-.12a1.59,1.59,0,0,0-1.7,1.48v.74l-6.07,0V1.36A1.6,1.6,0,0,0,12.76,0C11.93,0,11,.61,11,1.36v.89C4.87,2.58,0,7.18,0,12.79v21.1c0,5.83,5.24,10.57,11.68,10.57h21.6C39.73,44.46,45,39.72,45,33.89V12.79C45,7,40.17,2.22,33.73,2.22ZM42,33.89c0,4.33-3.89,7.85-8.68,7.85H11.69C6.9,41.74,3,38.22,3,33.89V12.79C3,8.67,6.53,5.29,11,5v.68C11,6.4,12,7,12.76,7a1.63,1.63,0,0,0,1.67-1.36V4.93h6.06v.85c0,.75,1,1.23,1.71,1.23s1.56-.48,1.56-1.23V4.93h5.88v.72A1.62,1.62,0,0,0,31.33,7,1.59,1.59,0,0,0,33,5.65V4.93h.3c4.79,0,8.68,3.53,8.68,7.86Z"/>\n </g>\n </svg>\n </slot>\n </div>\n </div>\n \x3c!-- <slot name="end-section"></slot> --\x3e\n </jb-input>\n <jb-popover part="popover">\n <jb-calendar tabindex="0" part="calendar"></jb-calendar>\n </jb-popover>\n </div>\n ',e.appendChild(t.content.cloneNode(!0)),this.elements={input:e.querySelector("jb-input"),calendarTriggerButton:e.querySelector(".calendar-trigger"),calendar:e.querySelector("jb-calendar"),popover:e.querySelector("jb-popover")},w(this,te,"m",De).call(this),w(this,te,"m",Ve).call(this)},Ve=function(){r()?this.elements.input.setAttribute("readonly","true"):this.elements.input.removeAttribute("readonly")},De=function(){this.elements.input.addEventListener("beforeinput",w(this,te,"m",Oe).bind(this)),o(this.elements.input,"focus",w(this,te,"m",Qe).bind(this),{passive:!0}),o(this.elements.input,"blur",w(this,te,"m",tt).bind(this),{passive:!0}),o(this.elements.input,"keypress",w(this,te,"m",Se).bind(this)),o(this.elements.input,"keyup",w(this,te,"m",Re).bind(this)),o(this.elements.input,"keydown",w(this,te,"m",Ye).bind(this)),this.elements.calendarTriggerButton.addEventListener("focus",w(this,te,"m",ut).bind(this)),this.elements.calendarTriggerButton.addEventListener("blur",w(this,te,"m",ht).bind(this)),this.elements.calendarTriggerButton.addEventListener("click",w(this,te,"m",ct).bind(this)),this.elements.calendar.addEventListener("select",(e=>w(this,te,"m",dt).call(this,e))),this.elements.calendar.addEventListener("init",w(this,te,"m",rt).bind(this)),this.elements.calendar.addEventListener("blur",w(this,te,"m",at).bind(this),{passive:!0}),this.elements.popover.addEventListener("close",w(this,te,"m",nt).bind(this),{passive:!0})},Ae=async function(){return w(this,Ie,"f")||(await customElements.whenDefined("jb-input"),await customElements.whenDefined("jb-calendar"),await customElements.whenDefined("jb-popover"),_(this,Ie,!0,"f")),Promise.resolve()},Ne=function(){w(this,te,"m",Ae).call(this).then((()=>{w(this,te,"m",Ge).call(this),this.value=this.getAttribute("value")||"",w(this,te,"m",be).call(this)}))},Ee=function(e,t){switch(e){case"value":this.value=t;break;case"name":this.elements.input.setAttribute("name",t);break;case"value-type":this.valueType=t;break;case"format":this.setFormat(t);break;case"min":w(this,te,"m",Me).call(this,t);break;case"max":w(this,te,"m",Te).call(this,t);break;case"required":this.required=""===t||"true"==t;break;case"input-type":this.inputType=t;break;case"direction":this.elements.calendar.setAttribute("direction",t);break;case"show-persian-number":"true"==t||""===t?this.showPersianNumber=!0:"false"!=t&&null!=t||(this.showPersianNumber=!1);break;case"placeholder":this.placeholder=t;break;case"disabled":this.disabled=""===t||"true"==t;break;case"error":this.reportValidity()}},Me=function(e){let t=null;t="string"==typeof e?w(this,se,"f").getDateFromValueDateString(e):e,t?(this.dateRestrictions.min=t,this.elements.calendar.dateRestrictions&&(this.elements.calendar.dateRestrictions.min=t)):console.error(`min date ${e} is not valid and it will be ignored`,"\n","please provide min date in format : "+w(this,se,"f").valueFormat)},Te=function(e){let t=null;t="string"==typeof e?w(this,se,"f").getDateFromValueDateString(e):e,t?(this.dateRestrictions.max=t,this.elements.calendar.dateRestrictions&&(this.elements.calendar.dateRestrictions.max=t)):console.error(`max date ${e} is not valid and it will be ignored`,"\n","please provide max date in format : "+w(this,se,"f").valueFormat)},we=function(e){w(this,te,"m",_e).call(this,e)},_e=function(e){const t=a("input",e,{cancelable:!1});this.dispatchEvent(t)},je=function(e){e.stopPropagation();const t=a("beforeinput",e,{cancelable:!0});return this.dispatchEvent(t),t.defaultPrevented&&e.preventDefault(),t.defaultPrevented},Oe=function(e){if(w(this,te,"m",je).call(this,e))return;const t=e.target;e.data&&this.placeholder&&""===t.value&&(_(this,te,S,"a",ge),t.setSelectionRange(0,0));const i=$({dateInputType:w(this,se,"f").inputType,showPersianNumber:this.showPersianNumber,value:w(this,te,"a",pe),selection:{start:t.selectionStart,end:t.selectionEnd},event:{data:e.data,inputType:e.inputType}});e.preventDefault(),_(this,te,i.value,"a",ge),t.setSelectionRange(i.selectionStart,i.selectionEnd),this.placeholder&&t.value==S&&_(this,te,"","a",ge),w(this,te,"m",we).call(this,e)},Se=function(e){e.stopPropagation();const t=n("keypress",e,{cancelable:!1});this.dispatchEvent(t)},Re=function(e){w(this,te,"m",Xe).call(this,w(this,te,"a",me)),w(this,te,"m",Le).call(this,e)},Le=function(e){e.stopPropagation();const t=n("keyup",e,{cancelable:!1});this.dispatchEvent(t)},Ye=function(e){if(!w(this,te,"m",Be).call(this,e))return void e.preventDefault();const t=e.target;if(38==e.keyCode||40==e.keyCode){const i=t.selectionStart;i<5&&(38==e.keyCode?w(this,te,"m",ke).call(this,1):w(this,te,"m",ke).call(this,-1),t.setSelectionRange(0,4)),i>4&&i<8&&(38==e.keyCode?w(this,te,"m",Ce).call(this,1):w(this,te,"m",Ce).call(this,-1),t.setSelectionRange(5,7)),i>7&&(38==e.keyCode?w(this,te,"m",Fe).call(this,1):w(this,te,"m",Fe).call(this,-1),t.setSelectionRange(8,10)),e.preventDefault()}},Be=function(e){e.stopPropagation();const t=n("keydown",e,{cancelable:!1});return this.dispatchEvent(t)},ke=function(e){const t=this.yearDisplayValue?this.yearDisplayValue:w(this,se,"f").yearOnEmptyBaseOnInputType,i=this.monthDisplayValue||1,a=this.dayDisplayValue||1,{hour:n,minute:s,millisecond:l,second:r}=w(this,ue,"f").time;w(this,te,"m",qe).call(this,t+e,i,a,n,s,r,l),w(this,te,"m",Ze).call(this)},Ce=function(e){const t=this.yearDisplayValue?this.yearDisplayValue:w(this,se,"f").yearOnEmptyBaseOnInputType,i=this.monthDisplayValue||1;let a=this.dayDisplayValue||1;const{hour:n,minute:s,millisecond:l,second:r}=w(this,ue,"f").time;w(this,te,"m",qe).call(this,t,i+e,a,n,s,r,l),w(this,te,"m",Ze).call(this)},Fe=function(e){const t=this.yearDisplayValue?this.yearDisplayValue:w(this,se,"f").yearOnEmptyBaseOnInputType,i=this.monthDisplayValue||1,a=this.dayDisplayValue||1,{hour:n,minute:s,millisecond:l,second:r}=w(this,ue,"f").time;w(this,te,"m",qe).call(this,t,i,a+e,n,s,r,l),w(this,te,"m",Ze).call(this)},Pe=function(e){if("string"==typeof e)switch(w(this,se,"f").valueType){case"GREGORIAN":case"JALALI":w(this,te,"m",Je).call(this,e);break;case"TIME_STAMP":w(this,te,"m",Ue).call(this,e)}else e instanceof Date&&w(this,te,"m",He).call(this,e);w(this,te,"m",ce).call(this)},Ge=function(){_(this,ue,{gregorian:{year:null,month:null,day:null},jalali:{year:null,month:null,day:null},timeStamp:null,time:{hour:null,minute:null,second:null,millisecond:null}},"f")},xe=function(){const e={year:w(this,se,"f").getCalendarYear(w(this,ue,"f")),month:w(this,se,"f").getCalendarMonth(w(this,ue,"f")),day:w(this,se,"f").getCalendarDay(w(this,ue,"f"))};e.year&&e.month&&e.day?this.elements.calendar.value=e:e.year&&e.month&&(this.elements.calendar.data.selectedYear=e.year,this.elements.calendar.data.selectedMonth=e.month)},He=function(e){const t=w(this,se,"f").getDateObjectValueFromDateValue(e);_(this,ue,t,"f"),w(this,te,"m",xe).call(this)},Ue=function(e){const t=Number(e);_(this,ue,w(this,se,"f").getDateValueObjectFromTimeStamp(t),"f"),w(this,te,"m",xe).call(this)},Je=function(e){const t=w(this,se,"f").getDateObjectValueBaseOnFormat(e);t.year&&t.month&&t.day?w(this,te,"m",We).call(this,Number(t.year),Number(t.month),Number(t.day),Number(t.hour??"00"),Number(t.minute??"00"),Number(t.second??"00"),Number(t.millisecond??"000")):null!=e&&""!==e?console.error("your inputted Date doest match default or your specified Format"):w(this,te,"m",Ge).call(this)},We=function(e,t,i,a,n,s,l){const r=this.yearValue,o=this.monthValue,u=w(this,se,"f").getDateValueObjectBaseOnValueType(e,t,i,r,o,a,n,s,l);_(this,ue,u,"f"),w(this,te,"m",xe).call(this)},qe=function(e,t,i,a,n,s,l){const r=this.yearBaseOnInputType,o=this.monthBaseOnInputType,u=w(this,se,"f").getDateValueObjectBaseOnInputType(e,t,i,r,o,a,n,s,l);_(this,ue,u,"f"),w(this,te,"m",xe).call(this),w(this,te,"m",ce).call(this)},Ze=function(){const{year:e,month:t,day:i}=this.inputType==Y.jalali?w(this,ue,"f").jalali:w(this,ue,"f").gregorian;if(this.placeholder&&!(e&&t&&i))return void _(this,te,"","a",ge);let a=R,n=" ",l=" ",r=" ";null==e||Number.isNaN(e)||(n=e<10?"000"+e:e<100?"00"+e:e<1e3?"0"+e:e.toString()),null==t||Number.isNaN(t)||(l=t<10?"0"+t:t.toString()),null==i||Number.isNaN(i)||(r=i<10?"0"+i:i.toString()),w(this,fe,"f")&&(n=s(n),l=s(l),r=s(r)),a=a.replace("YYYY",n).replace("MM",l).replace("DD",r),_(this,te,a,"a",ge)},Xe=function(e){L.lastIndex=0;const t=L.exec(e);if(t&&t.groups){const{hour:e,minute:i,millisecond:a,second:n}=w(this,ue,"f").time,s=Number(t.groups.year),l=Number(t.groups.month),r=Number(t.groups.day);s&&l&&r&&w(this,te,"m",qe).call(this,s,l,r,e,i,n,a)}},$e=function(){const e=z({inputValue:this.inputValue,selectionStart:this.elements.input.selectionStart});null!==e&&e!==this.elements.input.selectionStart&&this.elements.input.setSelectionRange(e,e);const t=function(e){return e<5?"YEAR":e<8?"MONTH":e<11?"DAY":null}(e??this.elements.input.selectionStart);t&&(this.elements.calendar.activeSection=t)},Ke=function(e){const t=()=>{_(this,ze,e,"f")};return w(this,ze,"f")!=e?(_(this,ze,e,"f"),{isUpdated:!0,updatePrevValue:t}):{isUpdated:!1,updatePrevValue:t}},Qe=function(e){_(this,ze,w(this,te,"a",me),"f"),this.focus(),document.addEventListener("selectionchange",w(this,te,"m",$e).bind(this)),w(this,te,"m",et).call(this,e)},et=function(e){e.stopPropagation();const t=i("focus",e,{cancelable:!1});this.dispatchEvent(t)},tt=function(e){document.removeEventListener("selectionchange",w(this,te,"m",$e).bind(this));const t=e.relatedTarget;t!==this.elements.calendar&&t!==this.elements.calendarTriggerButton&&(this.showCalendar=!1);const i=w(this,te,"a",me),a=w(this,te,"m",Ke).call(this,i);if(a.isUpdated){w(this,te,"m",Xe).call(this,i);const t=w(this,te,"m",st).call(this);w(this,te,"m",pt).call(this,!0),t.defaultPrevented?(e.preventDefault(),w(this,te,"m",Xe).call(this,w(this,ze,"f"))):a.updatePrevValue()}w(this,te,"m",it).call(this,e)},it=function(e){e.stopPropagation();const t=i("blur",e,{cancelable:!1});this.dispatchEvent(t)},at=function(e){const t=e.relatedTarget;t!==this.elements.input&&t!==this.elements.calendarTriggerButton&&(this.showCalendar=!1)},nt=function(){this.showCalendar=!1,this.elements.input.blur()},st=function(){const e=new Event("change",{composed:!0,bubbles:!0,cancelable:!0});return this.dispatchEvent(e),e},lt=function(){const e=[];return null!==this.getAttribute("error")&&this.getAttribute("error").trim().length>0&&e.push({validator:void 0,message:this.getAttribute("error"),stateType:"customError"}),this.required&&e.push(ee),this.dateRestrictions.min&&e.push({validator:e=>{return t=new Date(e.valueObject.timeStamp),i=this.dateRestrictions.min,p(t,i)||f(t,i);var t,i},message:Q.get(T,"minRangeViolation"),stateType:"rangeUnderflow"}),this.dateRestrictions.max&&e.push({validator:e=>{return t=new Date(e.valueObject.timeStamp),i=this.dateRestrictions.max,g(t,i)||f(t,i);var t,i},message:Q.get(T,"maxRangeViolation"),stateType:"rangeOverflow"}),e},rt=function(){this.elements.calendar.dateRestrictions.min=this.dateRestrictions.min,this.elements.calendar.dateRestrictions.max=this.dateRestrictions.max,this.elements.calendar.defaultCalendarData={gregorian:{year:w(this,se,"f").nicheNumbers.calendarYearOnEmpty.gregorian,month:w(this,se,"f").nicheNumbers.calendarMonthOnEmpty.gregorian},jalali:{year:w(this,se,"f").nicheNumbers.calendarYearOnEmpty.jalali,month:w(this,se,"f").nicheNumbers.calendarMonthOnEmpty.jalali}},w(this,te,"m",xe).call(this)},ut=function(e){const t=e.relatedTarget;this.showCalendar&&t&&[this.elements.calendar,this.elements.input].includes(t)?(t.focus(),this.showCalendar=!1):(_(this,ot,!0,"f"),this.showCalendar=!0)},ht=function(e){[this.elements.calendar,this.elements.input].includes(e.relatedTarget)||(this.showCalendar=!1)},ct=function(){const e=this.shadowRoot?.activeElement;e&&!w(this,ot,"f")&&e==this.elements.calendarTriggerButton&&(this.showCalendar=!this.showCalendar),_(this,ot,!1,"f")},dt=function(e){const t=e.target,{year:i,month:a,day:n}=t.value;if(i&&a&&n){const t=structuredClone(this.valueInDate),{hour:s,minute:l,millisecond:r,second:o}=w(this,ue,"f").time;w(this,te,"m",qe).call(this,i,a,n,s,l,o,r),w(this,te,"m",Ze).call(this),this.showCalendar=!1,w(this,te,"m",mt).call(this),w(this,te,"m",pt).call(this,!0);w(this,te,"m",st).call(this).defaultPrevented&&(e.preventDefault(),w(this,te,"m",He).call(this,t),w(this,te,"m",Ze).call(this))}},mt=function(){const e=new CustomEvent("select");this.dispatchEvent(e)},pt=function(e){if(!this.isAutoValidationDisabled)return w(this,ae,"f").checkValidity({showError:e})},gt=function(){const e=new CustomEvent("invalid");this.dispatchEvent(e)},ft=function(e){if(e.isAllValid)w(this,ie,"f").setValidity({},"");else{const t={};let i="";e.validationList.forEach((e=>{e.isValid||(e.validation.stateType?t[e.validation.stateType]=!0:t.customError=!0,""==i&&(i=e.message))})),w(this,ie,"f").setValidity(t,i)}},yt.formAssociated=!0;!customElements.get("jb-date-input")&&window.customElements.define("jb-date-input",yt);export{Y as InputTypes,yt as JBDateInputWebComponent,j as ValueTypes,Q as dictionary,S as emptyInputValueString,z as getFixedCaretPos,$ as handleBeforeInput};
//# sourceMappingURL=jb-date-input.js.map