jb-date-input
Version:
jalali date input web component
2 lines • 43.4 kB
JavaScript
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.getPrototypeOf,r=Object.prototype.hasOwnProperty,s=(s,l,o)=>(o=null!=s?e(a(s)):{},((e,a,s,l)=>{if(a&&"object"==typeof a||"function"==typeof a)for(var o,u=i(a),h=0,c=u.length;h<c;h++)o=u[h],r.call(e,o)||o===s||t(e,o,{get:(e=>a[e]).bind(null,o),enumerable:!(l=n(a,o))||l.enumerable});return e})(!l&&s&&s.__esModule?o:t(o,"default",{value:s,enumerable:!0}),s));require("jb-calendar");const l=s(require("jb-input"));require("jb-popover");const o=s(require("jb-validation")),u=s(require("jb-core")),h=s(require("date-fns")),c=s(require("date-fns-jalali"));function d(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function m(e,t,n,i,a){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!a)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?a.call(e,n):a?a.value=n:t.set(e,n),n}var p=class{lightness;chroma;hue;variableName;get value(){return`oklch(${this.lightness} ${this.chroma} ${this.hue})`}constructor(e,t){this.variableName=t,this.lightness=e.lightness,this.chroma=e.chroma,this.hue=e.hue}};function g(e){return new p({lightness:6*(3+1.3*e)*.01,chroma:.001*(14+.09*e),hue:258.36},`--jb-neutral-${e}`)}function y(e){return new p({lightness:e.lightness-.1,chroma:e.chroma-.05,hue:e.hue},`${e.variableName}-pressed`)}function f(e){const t=Math.min(e.lightness+.12*(1-e.lightness),.985),n=e.chroma*(1-.15*(t-e.lightness));return new p({lightness:t,chroma:Number(n.toFixed(3)),hue:e.hue},`${e.variableName}-l`)}function b(e){const t=Math.max(e.lightness-.12*e.lightness,.02),n=e.chroma*(1-.15*(t-e.lightness));return new p({lightness:t,chroma:n,hue:e.hue},`${e.variableName}-d`)}function v(e){const t=Math.min(e.lightness+.65*(1-e.lightness),.93),n=.55*e.chroma*(1-.08*(t-e.lightness)),i=e.hue>=70&&e.hue<=162?5:-3,a=e.hue+i;return new p({lightness:t,chroma:Number(n.toFixed(3)),hue:a},`${e.variableName}-subtle`)}function V(e){const t=Math.max(e.lightness-.35,.22),n=Math.min(1.6*e.chroma,.28);return new p({lightness:Number(t.toFixed(3)),chroma:Number(n.toFixed(3)),hue:e.hue},`${e.variableName}-contrast`)}function D(e){return{main:e,hover:(t=e,new p({lightness:t.lightness+.07,chroma:t.chroma+.07,hue:t.hue},`${t.variableName}-hover`)),pressed:y(e),light:f(e),dark:b(e),subtle:v(e),contrast:V(e)};var t}const I=new p({lightness:.6,chroma:.26,hue:256},"--jb-primary"),N=new p({lightness:.6,chroma:.26,hue:286},"--jb-secondary"),A=new p({lightness:.75,chroma:.18,hue:70},"--jb-yellow"),w=new p({lightness:.68,chroma:.1484,hue:162.1},"--jb-green"),E=new p({lightness:.6,chroma:.22,hue:23.21},"--jb-red"),M={single:{black:new p({lightness:.14,chroma:0,hue:0},"--jb-black"),white:new p({lightness:1,chroma:0,hue:0},"--jb-white"),highlight:new p({lightness:.93,chroma:.2302,hue:125.18},"--jb-highlight")},neutral:[g(0),g(1),g(2),g(3),g(4),g(5),g(6),g(7),g(8),g(9),g(10)],primary:D(I),secondary:D(N),yellow:D(A),green:D(w),red:D(E)};function T(e){try{const{value:t,...n}=e;window.CSS.registerProperty({...n}),function(e,t){try{t&&(document.documentElement.style.getPropertyValue(e)||document.documentElement.style.setProperty(e,t))}catch(e){}}(e.name,t)}catch(e){}}function j(e,t){T({name:t??e.variableName,syntax:"<color>",inherits:!0,initialValue:e.value})}function O(){var e;T({name:"--jb-radius",inherits:!0,value:"1rem",initialValue:"16px",syntax:"<length-percentage>"}),T({name:"--jb-radius-xs",inherits:!0,value:"0.5rem",initialValue:"8px",syntax:"<length-percentage>"}),T({name:"--jb-radius-sm",inherits:!0,value:"0.75rem",initialValue:"12px",syntax:"<length-percentage>"}),T({name:"--jb-radius-lg",inherits:!0,value:"1.25rem",initialValue:"20px",syntax:"<length-percentage>"}),T({name:"--jb-radius-xl",inherits:!0,value:"1.5rem",initialValue:"24px",syntax:"<length-percentage>"}),function(e){j(e.neutral[0],"--jb-neutral"),j(e.primary.main),j(e.secondary.main),j(e.single.black),j(e.single.white),j(e.single.highlight),j(e.yellow.main),j(e.green.main),j(e.red.main),j(e.red.main);for(let t=1;t<=10;t++)j(e.neutral[t])}(M),j((e=M).single.black,"--jb-text-primary"),j(e.neutral[7],"--jb-text-secondary"),j(e.single.white,"--jb-text-contrast")}var _,S;(S=_||(_={})).jalali="JALALI",S.gregorian="GREGORIAN",S.timeStamp="TIME_STAMP";const L=" / / ",R="YYYY/MM/DD",Y=/^(?<year>[\u06F0-\u06F90-9,\s]{4})\/(?<month>[\u06F0-\u06F90-9,\s]{2})\/(?<day>[\u06F0-\u06F90-9,\s]{2})$/g,F={minRangeViolation:"تاریخ انتخابی کمتر از بازه مجاز است",maxRangeViolation:"تاریخ انتخابی بیشتر از بازه مجاز است",required:"لطفا مقدار تاریخ را کامل وارد کنید"};var B,k,C,P,x,G,H,U,J,W,q;function $(e){return[1,5,9,13,17,22,26,30].includes(e%33)}function Z(e){return e.substring(5,7)}function X(e){return e.substring(0,4)}function K(e){return e.substring(8,10)}function z(e){const{showPersianNumber:t,dateInputType:n,selection:i,event:{data:a,inputType:r}}=e,s=i.start;let l=s,o=e.value;return a&&function(e){return(0,u.faToEnDigits)(e).replace(/[^\u06F0-\u06F90-9/]/g,"")}(e.event.data||"").split("").forEach(((e,t)=>{let i=s+t;if(!function(e){return/[\u06F0-\u06F90-9/]/g.test(e)}(e))return;4!=i&&7!=i||("/"==e&&c(i+1),i++);let a=!1;if("/"==e)return;const r=Number(e);5==i&&r>1&&(h("0",i),i++);const l=function(e,t,n){let i=!1;return 5==n&&1==t&&e[6]>"2"&&(i=!0),6==n&&t>2&&"1"==e[5]&&(i=!0),6==n&&0==t&&"0"==e[5]&&(i=!0),5==n&&0==t&&"0"==e[4]&&(i=!0),{isIgnoreChar:i,caretPos:n}}(o,r,i);i=l.caretPos;const u=function(e,t,n,i,a){let r=!1;if(8==n&&t>3&&(a("0",n),n++),9==n&&t>1&&"3"==i[8]&&(r=!0),9==n&&0==t&&"0"==i[8]&&(r=!0),8==n&&0==t&&"0"==i[9]&&(r=!0),"JALALI"==e&&!r){const e=Z(i),s=Number(e);if(9==n&&"3"==i[8]&&t>0&&s>6&&(r=!0),8==n&&3==t){if(12==s){const e=Number(X(i));!Number.isNaN(e)&&$(e)||(r=!0)}i[9]>"0"&&(2==e.length&&parseInt(i)>6&&a("0",9),2==e.length&&s<7&&i[9]>"1"&&a("1",9))}}return{isIgnoreChar:r,caretPos:n}}(n,r,i,o,h);i=u.caretPos,a=a||u.isIgnoreChar||l.isIgnoreChar,a||(h(e,i),c(i+1))})),"deleteContentBackward"!=r&&"deleteContentForward"!=r&&"delete"!=r&&"deleteByCut"!=r&&"deleteByDrag"!=r||function(e,t,n,i,a){let r=0;"deleteContentBackward"==e&&(r=t!==n?0:-1);for(let e=t;e<=n;e++)i(" ",e+r);a(t+r)}(r,i.start,i.end,h,c),{value:o,selectionStart:l,selectionEnd:l};function h(e,n){o=function(e,t,n,i){if(4!=t&&7!=t||(e="/"),t>9||t<0)return n;const a=n.split("");return i&&(e=(0,u.enToFaDigits)(e)),a[t]=e,a.join("")}(e,n,o,t)}function c(e){l=e}}function Q(e){const t=e.selectionStart;if(t){const n=X(e.inputValue).trim().length;if(n<t&&t<=4)return n;const i=Z(e.inputValue).trim().length;if(i+5<t&&t>4&&t<=7)return i+5;const a=K(e.inputValue).trim().length;if(a+8<t&&t>7&&t<=10)return a+8}return null}(k=B||(B={})).jalali="JALALI",k.gregorian="GREGORIAN";var ee=class{get valueFormat(){return d(this,U,"f")}set valueFormat(e){m(this,U,e,"f")}get nicheNumbers(){return d(this,H,"f")}get yearOnEmptyBaseOnInputType(){return"JALALI"==d(this,G,"f")?d(this,H,"f").calendarYearOnEmpty.jalali:d(this,H,"f").calendarYearOnEmpty.gregorian}get monthOnEmptyBaseOnValueType(){return"JALALI"==this.valueType?d(this,H,"f").calendarMonthOnEmpty.jalali:d(this,H,"f").calendarMonthOnEmpty.gregorian}get inputType(){return d(this,G,"f")}get valueType(){return d(this,x,"f")}constructor(e){C.add(this),x.set(this,"GREGORIAN"),G.set(this,B.jalali),H.set(this,{calendarYearOnEmpty:{jalali:P.todayJalaliYear,gregorian:P.todayGregorianYear},calendarMonthOnEmpty:{jalali:P.todayJalaliMonth,gregorian:P.todayGregorianMonth}}),U.set(this,"YYYY-MM-DDTHH:mm:ss.SSS[Z]"),e.inputType&&m(this,G,e.inputType,"f"),e.valueType&&m(this,x,e.valueType,"f")}setInputType(e){m(this,G,e,"f")}setValueType(e){m(this,x,e,"f")}getYearValueBaseOnInputType(e){return d(this,G,"f")==B.jalali?e.jalali.year:e.gregorian.year}getMonthValueBaseOnInputType(e){return d(this,G,"f")==B.jalali?e.jalali.month:e.gregorian.month}getDayValueBaseOnInputType(e){return d(this,G,"f")==B.jalali?e.jalali.day:e.gregorian.day}getDateFromValueDateString(e){let t=null;if("TIME_STAMP"==this.valueType)t=P.getDateFromTimestamp(parseInt(e));else{const n=this.getDateObjectValueBaseOnFormat(e),i=parseInt(n.year),a=parseInt(n.month),r=parseInt(n.day);null!=n&&null!==i&&null!==a&&null!==r&&("GREGORIAN"==this.valueType&&(t=P.getDateFromGregorian(i,a,r)),"JALALI"==this.valueType&&(t=P.getDateFromJalali(i,a,r)))}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 n="0000",i=e.time.hour?.toString().padStart(2,"0")??"00",a=e.time.minute?.toString().padStart(2,"0")??"00",r=e.time.second?.toString().padStart(2,"0")??"00",s=e.time.millisecond?.toString().padStart(3,"0")??"000",l=()=>{const{year:t,month:l,day:o}=e.gregorian,u=null==t?n:t<1e3?t<100?t<10?"000"+t:"00"+t:"0"+t:t.toString(),h=null==l?"00":l<10?"0"+l:l.toString(),c=null==o?"00":o<10?"0"+o:o.toString();return d(this,U,"f").replace("YYYY",u).replace("MM",h).replace("DD",c).replace("HH",i).replace("mm",a).replace("ss",r).replace("SSS",s).replace("[Z]","Ž").replace("Z","+00:00").replace("Ž","Z")},o=()=>{const{year:t,month:l,day:o}=e.jalali,u=null==t?n:t<1e3?t<100?t<10?"000"+t:"00"+t:"0"+t:t.toString(),h=null==l?"00":l<10?"0"+l:l.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",i).replace("mm",a).replace("ss",r).replace("SSS",s).replace("[Z]","Ž").replace("Z","+00:00").replace("Ž","Z")};if("object"==typeof e)switch(t){case"GREGORIAN":return l();case"JALALI":return o();case"TIME_STAMP":if(e.timeStamp)return e.timeStamp.toString()}return""}getCalendarYear(e){const t=this.inputType==B.gregorian?d(this,H,"f").calendarYearOnEmpty.gregorian:d(this,H,"f").calendarYearOnEmpty.jalali;return this.getYearValueBaseOnInputType(e)||t}getCalendarMonth(e){const t=this.inputType==B.gregorian?d(this,H,"f").calendarMonthOnEmpty.gregorian:d(this,H,"f").calendarMonthOnEmpty.jalali;return this.getMonthValueBaseOnInputType(e)||t}getCalendarDay(e){return this.getDayValueBaseOnInputType(e)}setCalendarDefaultDateView(e,t,n=d(this,G,"f")){n==B.gregorian?(d(this,H,"f").calendarYearOnEmpty.gregorian=e,d(this,H,"f").calendarMonthOnEmpty.gregorian=t):n==B.jalali&&(d(this,H,"f").calendarYearOnEmpty.jalali=e,d(this,H,"f").calendarMonthOnEmpty.jalali=t)}getDateValueObjectBaseOnInputType(e,t,n,i,a,r,s,l,o){return d(this,G,"f")==B.gregorian?d(this,C,"m",J).call(this,e,t,n,i,a,r,s,l,o):d(this,G,"f")==B.jalali?d(this,C,"m",W).call(this,e,t,n,i,a,r,s,l,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,n,i,a,r,s,l,o){return"GREGORIAN"==d(this,x,"f")||"TIME_STAMP"==d(this,x,"f")?d(this,C,"m",J).call(this,e,t,n,i,a,r,s,l,o):"JALALI"==d(this,x,"f")?d(this,C,"m",W).call(this,e,t,n,i,a,r,s,l,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:(0,h.getYear)(e),month:(0,h.getMonth)(e)+1,day:(0,h.getDate)(e)},jalali:{year:(0,c.getYear)(e),month:(0,c.getMonth)(e)+1,day:(0,c.getDate)(e)},timeStamp:(0,h.getTime)(e),time:{hour:(0,c.getHours)(e),minute:(0,c.getMinutes)(e),second:(0,c.getSeconds)(e),millisecond:(0,c.getMilliseconds)(e)}}}static checkJalaliDateValidation(e,t,n){const i={isValid:!0,error:null};return isNaN(e)&&(i.isValid=!1,i.error="INVALID_YEAR"),isNaN(t)&&(i.isValid=!1,i.error="INVALID_MONTH"),isNaN(n)&&(i.isValid=!1,i.error="INVALID_DAY"),t<1&&(i.isValid=!1,i.error="INVALID_MIN_MONTH_NUMBER"),n<1&&(i.isValid=!1,i.error="INVALID_MIN_DAY_NUMBER"),t>12&&(i.isValid=!1,i.error="INVALID_MAX_MONTH_NUMBER"),n>31&&(i.isValid=!1,i.error="INVALID_MAX_DAY_NUMBER"),e<1e3&&(i.isValid=!1,i.error="INVALID_MIN_YEAR_NUMBER"),e>9999&&(i.isValid=!1,i.error="INVALID_MAX_YEAR_NUMBER"),t>6&&t<12&&n>30&&(i.isValid=!1,i.error="INVALID_DAY_IN_MONTH"),12==t&&n>30&&(i.isValid=!1,i.error="INVALID_DAY_IN_MONTH"),i.isValid&&12==t&&12==t&&30==n&&($(e)||(i.isValid=!1,i.error="INVALID_DAY_FOR_LEAP")),i}static checkGregorianDateValidation(e,t,n){const i={isValid:!0,error:null};if(isNaN(e)&&(i.isValid=!1,i.error="INVALID_YEAR"),isNaN(t)&&(i.isValid=!1,i.error="INVALID_MONTH"),isNaN(n)&&(i.isValid=!1,i.error="INVALID_DAY"),t<1&&(i.isValid=!1,i.error="INVALID_MIN_MONTH_NUMBER"),n<1&&(i.isValid=!1,i.error="INVALID_MIN_DAY_NUMBER"),t>12&&(i.isValid=!1,i.error="INVALID_MAX_MONTH_NUMBER"),n>31&&(i.isValid=!1,i.error="INVALID_MAX_DAY_NUMBER"),e<1e3&&(i.isValid=!1,i.error="INVALID_MIN_YEAR_NUMBER"),e>9999&&(i.isValid=!1,i.error="INVALID_MAX_YEAR_NUMBER"),[2,4,6,9,11].includes(n)&&n>30&&(i.isValid=!1,i.error="INVALID_DAY_IN_MONTH"),2==t&&n>28)if(29==n){const a=P.getDateFromGregorian(e,t,n);(0,h.isLeapYear)(a)||(i.isValid=!1,i.error="INVALID_DAY_FOR_LEAP")}else i.isValid=!1,i.error="INVALID_DAY_IN_MONTH";return i}getDateObjectValueBaseOnFormat(e,t=d(this,U,"f")){const n=d(P,P,"m",q).call(P,e,t),i={year:null,month:null,day:null,hour:null,millisecond:null,minute:null,second:null};return n&&n.groups&&(i.year=n.groups.year,i.month=n.groups.month,i.day=n.groups.day,i.hour=n.groups.hour,i.minute=n.groups.minute,i.second=n.groups.second,i.millisecond=n.groups.millisecond),i}static getDate(e,t,n,i,a,r,s,l){return i==B.jalali?P.getDateFromJalali(e,t,n):P.getDateFromGregorian(e,t,n)}static getDateFromGregorian(e,t,n,i,a,r,s){return new Date(e,t-1,n,i,a,r,s)}static getDateFromJalali(e,t,n,i,a,r,s){return(0,c.newDate)(e,t-1,n,i,a,r,s)}static getDateFromTimestamp(e){return new Date(e)}static get todayGregorianYear(){return(0,h.getYear)(new Date)}static get todayJalaliYear(){return(0,c.getYear)(new Date)}static get todayGregorianMonth(){return(0,h.getMonth)(new Date)+1}static get todayJalaliMonth(){return(0,c.getMonth)(new Date)+1}};P=ee,x=new WeakMap,G=new WeakMap,H=new WeakMap,U=new WeakMap,C=new WeakSet,J=function e(t,n,i,a,r,s,l,o,u){const m={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}},p=P.checkGregorianDateValidation(t,n,i);if(!p.isValid)return"INVALID_MIN_DAY_NUMBER"==p.error?d(this,C,"m",e).call(this,t,n,1,a,r,s,l,o,u):"INVALID_MIN_MONTH_NUMBER"==p.error?d(this,C,"m",e).call(this,t,1,i,a,r,s,l,o,u):"INVALID_MIN_YEAR_NUMBER"==p.error?d(this,C,"m",e).call(this,1900,n,i,a,r,s,l,o,u):"INVALID_MAX_DAY_NUMBER"==p.error?d(this,C,"m",e).call(this,t,n,31,a,r,s,l,o,u):"INVALID_MAX_MONTH_NUMBER"==p.error?d(this,C,"m",e).call(this,t,12,i,a,r,s,l,o,u):"INVALID_MAX_YEAR_NUMBER"==p.error?d(this,C,"m",e).call(this,9e3,n,i,a,r,s,l,o,u):"INVALID_DAY_IN_MONTH"==p.error&&r!=n&&i>29||"INVALID_DAY_FOR_LEAP"==p.error&&a!=t&&29==i?d(this,C,"m",e).call(this,t,n,i-1,a,r,s,l,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 g=P.getDateFromGregorian(t,n,i,s,l,o,u);return m.gregorian={year:(0,h.getYear)(g),month:(0,h.getMonth)(g)+1,day:(0,h.getDate)(g)},m.jalali={year:(0,c.getYear)(g),month:(0,c.getMonth)(g)+1,day:(0,c.getDate)(g)},m.timeStamp=(0,h.getTime)(g),m.time={hour:s,minute:l,second:o,millisecond:u},m},W=function e(t,n,i,a,r,s,l,o,u){const m={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}},p=P.checkJalaliDateValidation(t,n,i);if(!p.isValid){if("INVALID_MIN_DAY_NUMBER"==p.error)return d(this,C,"m",e).call(this,t,n,1,a,r,s,l,o,u);if("INVALID_MIN_MONTH_NUMBER"==p.error)return d(this,C,"m",e).call(this,t,1,i,a,r,s,l,o,u);if("INVALID_MIN_YEAR_NUMBER"==p.error)return d(this,C,"m",e).call(this,1300,n,i,a,r,s,l,o,u);if("INVALID_MAX_DAY_NUMBER"==p.error)return d(this,C,"m",e).call(this,t,n,31,a,r,s,l,o,u);if("INVALID_MAX_MONTH_NUMBER"==p.error)return d(this,C,"m",e).call(this,t,12,i,a,r,s,l,o,u);if("INVALID_MAX_YEAR_NUMBER"==p.error)return d(this,C,"m",e).call(this,9999,n,i,a,r,s,l,o,u);if("INVALID_DAY_IN_MONTH"==p.error&&r!=n&&31==i)return d(this,C,"m",e).call(this,t,n,i-1,a,r,s,l,o,u);if("INVALID_DAY_FOR_LEAP"==p.error){const i=$(t)?30:29;return d(this,C,"m",e).call(this,t,n,i,a,r,s,l,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 g=P.getDateFromJalali(t,n,i,s,l,o,u);return m.gregorian={year:(0,h.getYear)(g),month:(0,h.getMonth)(g)+1,day:(0,h.getDate)(g)},m.jalali={year:(0,c.getYear)(g),month:(0,c.getMonth)(g)+1,day:(0,c.getDate)(g)},m.timeStamp=(0,h.getTime)(g),m.time={hour:s,minute:l,second:o,millisecond:u},m},q=function(e,t){const n=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(n,"g").exec(e)};const te={validator:e=>null!=e.inputObject.year&&null!=e.inputObject.month&&null!=e.inputObject.day,message:F.required,stateType:"valueMissing"};var ne,ie,ae,re,se,le,oe,ue,he,ce,de,me,pe,ge,ye,fe,be,ve,Ve,De,Ie,Ne,Ae,we,Ee,Me,Te,je,Oe,_e,Se,Le,Re,Ye,Fe,Be,ke,Ce,Pe,xe,Ge,He,Ue,Je,We,qe,$e,Ze,Xe,Ke,ze,Qe,et,tt,nt,it,at,rt,st,lt,ot,ut,ht,ct,dt,mt,pt,gt,yt,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 bt=class e extends HTMLElement{get isAutoValidationDisabled(){return d(this,re,"f")}set isAutoValidationDisabled(e){m(this,re,e,"f")}get validation(){return d(this,ae,"f")}get disabled(){return d(this,oe,"f")}set disabled(e){m(this,oe,e,"f"),this.elements.input.disabled=e,e?d(this,ie,"f").states?.add("disabled"):d(this,ie,"f").states?.delete("disabled")}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,n){this.elements.input.setSelectionRange(e,t,n)}set required(e){m(this,ue,e,"f"),d(this,ne,"m",gt).call(this,!1)}get required(){return d(this,ue,"f")}get name(){return this.getAttribute("name")||""}get form(){return d(this,ie,"f").form}get value(){return this.getDateValue()}set value(e){d(this,ne,"m",xe).call(this,e),d(this,ne,"m",Ze).call(this)}get isDirty(){return this.value!==(this.initialValue??d(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 d(this,se,"f").getDateValueFromValueObject(d(this,he,"f"))}get inputValue(){return d(this,ne,"a",ge)}get placeholder(){return d(this,me,"f")}set placeholder(e){m(this,me,e,"f"),this.elements.input.elements.input.placeholder=null!==e?e:"",d(this,ne,"m",Ze).call(this)}get showCalendar(){return d(this,le,"f")}set showCalendar(e){m(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"))}get inputType(){return d(this,se,"f").inputType}set inputType(e){Object.values(B).includes(e)?(d(this,se,"f").setInputType(e),this.onInputTypeChange()):console.error(`${e} is not a valid input type`)}get valueType(){return d(this,se,"f").valueType}set valueType(e){Object.values(_).includes(e)?d(this,se,"f").setValueType(e):console.error(`${e} is not a valid value type`)}get yearValue(){switch(this.valueType){case"JALALI":return d(this,he,"f").jalali.year;case"GREGORIAN":case"TIME_STAMP":return d(this,he,"f").gregorian.year;default:return null}}get yearDisplayValue(){switch(this.inputType){case"JALALI":return d(this,he,"f").jalali.year;case"GREGORIAN":return d(this,he,"f").gregorian.year;default:return null}}get monthValue(){switch(this.valueType){case"JALALI":return d(this,he,"f").jalali.month;case"GREGORIAN":case"TIME_STAMP":return d(this,he,"f").gregorian.month;default:return null}}get monthDisplayValue(){switch(this.inputType){case"JALALI":return d(this,he,"f").jalali.month;case"GREGORIAN":return d(this,he,"f").gregorian.month;default:return null}}get dayValue(){switch(this.valueType){case"JALALI":return d(this,he,"f").jalali.day;case"GREGORIAN":case"TIME_STAMP":return d(this,he,"f").gregorian.day;default:return null}}get dayDisplayValue(){switch(this.inputType){case"JALALI":return d(this,he,"f").jalali.day;case"GREGORIAN":return d(this,he,"f").gregorian.day;default:return null}}get yearBaseOnInputType(){switch(this.inputType){case B.jalali:return d(this,he,"f").jalali.year;case B.gregorian:return d(this,he,"f").gregorian.year;default:return null}}get monthBaseOnInputType(){switch(this.inputType){case B.jalali:return d(this,he,"f").jalali.month;case B.gregorian:return d(this,he,"f").gregorian.month;default:return null}}get dayBaseOnInputType(){switch(this.inputType){case B.jalali:return d(this,he,"f").jalali.day;case B.gregorian:return d(this,he,"f").gregorian.day;default:return null}}get typedYear(){return X(this.inputValue)}get typedMonth(){return Z(this.inputValue)}get typedDay(){return K(this.inputValue)}get sTypedYear(){return X(d(this,ne,"a",pe))}get sTypedMonth(){return Z(d(this,ne,"a",pe))}get sTypedDay(){return K(d(this,ne,"a",pe))}get valueFormat(){return d(this,se,"f").valueFormat}get showPersianNumber(){return d(this,fe,"f")}set showPersianNumber(e){m(this,fe,e,"f"),d(this,ne,"m",Ze).call(this)}constructor(){super(),ne.add(this),ie.set(this,void 0),ae.set(this,new o.ValidationHelper({clearValidationError:this.clearValidationError.bind(this),getValue:()=>d(this,ne,"a",ce),getValidations:d(this,ne,"m",lt).bind(this),getValueString:e=>e.text,setValidationResult:d(this,ne,"m",ft).bind(this),showValidationError:this.showValidationError.bind(this)})),re.set(this,!1),se.set(this,new ee({inputType:this.getAttribute("input-type"),valueType:this.getAttribute("value-type")})),le.set(this,!1),this.dateRestrictions={min:null,max:null},oe.set(this,!1),ue.set(this,!1),he.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,me.set(this,null),fe.set(this,!1),Ne.set(this,!1),ze.set(this," / / "),ut.set(this,!1),"function"==typeof this.attachInternals&&m(this,ie,this.attachInternals(),"f"),d(this,ne,"m",Ve).call(this)}connectedCallback(){d(this,ne,"m",be).call(this),d(this,ne,"m",we).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[...l.JBInputWebComponent.observedAttributes,...e.dateInputObservedAttributes]}attributeChangedCallback(t,n,i){e.dateInputObservedAttributes.includes(t)?d(this,ne,"m",Ee).call(this,t,i):l.JBInputWebComponent.observedAttributes.includes(t)&&this.elements.input.setAttribute(t,i)}setFormat(e){d(this,se,"f").valueFormat=e;const t=this.getAttribute("min");t&&d(this,ne,"m",Me).call(this,t);const n=this.getAttribute("max");n&&d(this,ne,"m",Te).call(this,n)}setMinDate(e){d(this,ne,"m",Me).call(this,e)}setMaxDate(e){d(this,ne,"m",Te).call(this,e)}getDateValue(e=this.valueType){return d(this,se,"f").getDateValueStringFromValueObject(d(this,he,"f"),e)}focus(){this.elements.input.focus(),this.showCalendar=!0}triggerInputValidation(e=!0){return d(this,ne,"m",gt).call(this,e)}showValidationError(e){this.elements.input.showValidationError(e),d(this,ie,"f").states?.add("invalid")}clearValidationError(){this.elements.input.clearValidationError(),d(this,ie,"f").states?.delete("invalid")}async onInputTypeChange(){d(this,Ne,"f")||await d(this,ne,"m",Ae).call(this),this.elements.calendar.inputType=this.inputType,d(this,ne,"m",Ze).call(this)}setCalendarDefaultDateView(e,t,n){e&&t&&(d(this,se,"f").setCalendarDefaultDateView(e,t,n),d(this,ne,"m",He).call(this))}checkValidity(){const e=d(this,ae,"f").checkValiditySync({showError:!1});return e.isAllValid||d(this,ne,"m",yt).call(this),e.isAllValid}reportValidity(){const e=d(this,ae,"f").checkValiditySync({showError:!0});return e.isAllValid||d(this,ne,"m",yt).call(this),e.isAllValid}get validationMessage(){return d(this,ie,"f").validationMessage}};ie=new WeakMap,ae=new WeakMap,re=new WeakMap,se=new WeakMap,le=new WeakMap,oe=new WeakMap,ue=new WeakMap,he=new WeakMap,me=new WeakMap,fe=new WeakMap,Ne=new WeakMap,ze=new WeakMap,ut=new WeakMap,ne=new WeakSet,ce=function(){return{inputObject:d(this,se,"f").getDateObjectValueBaseOnFormat(d(this,ne,"a",pe),R),text:d(this,ne,"a",pe),valueText:this.value,valueObject:d(this,he,"f")}},de=function(){d(this,ie,"f")&&"function"==typeof d(this,ie,"f").setFormValue&&d(this,ie,"f").setFormValue(this.value)},pe=function(){let e=d(this,ne,"a",ge);return d(this,fe,"f")&&(e=(0,u.faToEnDigits)(e)),e},ge=function(){return this.elements.input.value},ye=function(e){this.elements.input.value=e},be=function(){const e=new CustomEvent("load",{bubbles:!0,composed:!0});this.dispatchEvent(e)},ve=function(){const e=new CustomEvent("init",{bubbles:!0,composed:!0});this.dispatchEvent(e)},Ve=function(){const e=this.attachShadow({mode:"open",delegatesFocus:!0});O();const t=document.createElement("template");t.innerHTML='<style>: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))}: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)}</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")},d(this,ne,"m",Ie).call(this),d(this,ne,"m",De).call(this)},De=function(){(0,u.isMobile)()?this.elements.input.setAttribute("readonly","true"):this.elements.input.removeAttribute("readonly")},Ie=function(){this.elements.input.addEventListener("beforeinput",d(this,ne,"m",Se).bind(this)),(0,u.listenAndSilentEvent)(this.elements.input,"focus",d(this,ne,"m",et).bind(this),{passive:!0}),(0,u.listenAndSilentEvent)(this.elements.input,"blur",d(this,ne,"m",nt).bind(this),{passive:!0}),(0,u.listenAndSilentEvent)(this.elements.input,"keypress",d(this,ne,"m",Le).bind(this)),(0,u.listenAndSilentEvent)(this.elements.input,"keyup",d(this,ne,"m",Re).bind(this)),(0,u.listenAndSilentEvent)(this.elements.input,"keydown",d(this,ne,"m",Fe).bind(this)),this.elements.calendarTriggerButton.addEventListener("focus",d(this,ne,"m",ht).bind(this)),this.elements.calendarTriggerButton.addEventListener("blur",d(this,ne,"m",ct).bind(this)),this.elements.calendarTriggerButton.addEventListener("click",d(this,ne,"m",dt).bind(this)),this.elements.calendar.addEventListener("select",(e=>d(this,ne,"m",mt).call(this,e))),this.elements.calendar.addEventListener("init",d(this,ne,"m",ot).bind(this)),this.elements.calendar.addEventListener("blur",d(this,ne,"m",at).bind(this),{passive:!0}),this.elements.popover.addEventListener("close",d(this,ne,"m",rt).bind(this),{passive:!0})},Ae=async function(){return d(this,Ne,"f")||(await customElements.whenDefined("jb-input"),await customElements.whenDefined("jb-calendar"),await customElements.whenDefined("jb-popover"),m(this,Ne,!0,"f")),Promise.resolve()},we=function(){d(this,ne,"m",Ae).call(this).then((()=>{d(this,ne,"m",Ge).call(this),this.value=this.getAttribute("value")||"",d(this,ne,"m",ve).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":d(this,ne,"m",Me).call(this,t);break;case"max":d(this,ne,"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,this.elements.calendar.showPersianNumber=!0),"false"!=t&&null!=t||(this.showPersianNumber=!1,this.elements.calendar.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?d(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 : "+d(this,se,"f").valueFormat)},Te=function(e){let t=null;t="string"==typeof e?d(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 : "+d(this,se,"f").valueFormat)},je=function(e){d(this,ne,"m",Oe).call(this,e)},Oe=function(e){const t=(0,u.createInputEvent)("input",e,{cancelable:!1});this.dispatchEvent(t)},_e=function(e){e.stopPropagation();const t=(0,u.createInputEvent)("beforeinput",e,{cancelable:!0});return this.dispatchEvent(t),t.defaultPrevented&&e.preventDefault(),t.defaultPrevented},Se=function(e){if(d(this,ne,"m",_e).call(this,e))return;const t=e.target;e.data&&this.placeholder&&""===t.value&&(m(this,ne,L,"a",ye),t.setSelectionRange(0,0));const n=z({dateInputType:d(this,se,"f").inputType,showPersianNumber:this.showPersianNumber,value:d(this,ne,"a",ge),selection:{start:t.selectionStart,end:t.selectionEnd},event:{data:e.data,inputType:e.inputType}});e.preventDefault(),m(this,ne,n.value,"a",ye),t.setSelectionRange(n.selectionStart,n.selectionEnd),this.placeholder&&t.value==L&&m(this,ne,"","a",ye),d(this,ne,"m",je).call(this,e)},Le=function(e){e.stopPropagation();const t=(0,u.createKeyboardEvent)("keypress",e,{cancelable:!1});this.dispatchEvent(t)},Re=function(e){d(this,ne,"m",Xe).call(this,d(this,ne,"a",pe)),d(this,ne,"m",Ye).call(this,e)},Ye=function(e){e.stopPropagation();const t=(0,u.createKeyboardEvent)("keyup",e,{cancelable:!1});this.dispatchEvent(t)},Fe=function(e){if(!d(this,ne,"m",Be).call(this,e))return void e.preventDefault();const t=e.target;if(38==e.keyCode||40==e.keyCode){const n=t.selectionStart;n<5&&(38==e.keyCode?d(this,ne,"m",ke).call(this,1):d(this,ne,"m",ke).call(this,-1),t.setSelectionRange(0,4)),n>4&&n<8&&(38==e.keyCode?d(this,ne,"m",Ce).call(this,1):d(this,ne,"m",Ce).call(this,-1),t.setSelectionRange(5,7)),n>7&&(38==e.keyCode?d(this,ne,"m",Pe).call(this,1):d(this,ne,"m",Pe).call(this,-1),t.setSelectionRange(8,10)),e.preventDefault()}},Be=function(e){e.stopPropagation();const t=(0,u.createKeyboardEvent)("keydown",e,{cancelable:!1});return this.dispatchEvent(t)},ke=function(e){const t=this.yearDisplayValue?this.yearDisplayValue:d(this,se,"f").yearOnEmptyBaseOnInputType,n=this.monthDisplayValue||1,i=this.dayDisplayValue||1,{hour:a,minute:r,millisecond:s,second:l}=d(this,he,"f").time;d(this,ne,"m",$e).call(this,t+e,n,i,a,r,l,s),d(this,ne,"m",Ze).call(this)},Ce=function(e){const t=this.yearDisplayValue?this.yearDisplayValue:d(this,se,"f").yearOnEmptyBaseOnInputType,n=this.monthDisplayValue||1;let i=this.dayDisplayValue||1;const{hour:a,minute:r,millisecond:s,second:l}=d(this,he,"f").time;d(this,ne,"m",$e).call(this,t,n+e,i,a,r,l,s),d(this,ne,"m",Ze).call(this)},Pe=function(e){const t=this.yearDisplayValue?this.yearDisplayValue:d(this,se,"f").yearOnEmptyBaseOnInputType,n=this.monthDisplayValue||1,i=this.dayDisplayValue||1,{hour:a,minute:r,millisecond:s,second:l}=d(this,he,"f").time;d(this,ne,"m",$e).call(this,t,n,i+e,a,r,l,s),d(this,ne,"m",Ze).call(this)},xe=function(e){if("string"==typeof e)switch(d(this,se,"f").valueType){case"GREGORIAN":case"JALALI":d(this,ne,"m",We).call(this,e);break;case"TIME_STAMP":d(this,ne,"m",Je).call(this,e)}else e instanceof Date&&d(this,ne,"m",Ue).call(this,e);d(this,ne,"m",de).call(this)},Ge=function(){m(this,he,{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")},He=function(){const e={year:d(this,se,"f").getCalendarYear(d(this,he,"f")),month:d(this,se,"f").getCalendarMonth(d(this,he,"f")),day:d(this,se,"f").getCalendarDay(d(this,he,"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)},Ue=function(e){const t=d(this,se,"f").getDateObjectValueFromDateValue(e);m(this,he,t,"f"),d(this,ne,"m",He).call(this)},Je=function(e){const t=Number(e);m(this,he,d(this,se,"f").getDateValueObjectFromTimeStamp(t),"f"),d(this,ne,"m",He).call(this)},We=function(e){const t=d(this,se,"f").getDateObjectValueBaseOnFormat(e);t.year&&t.month&&t.day?d(this,ne,"m",qe).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"):d(this,ne,"m",Ge).call(this)},qe=function(e,t,n,i,a,r,s){const l=this.yearValue,o=this.monthValue,u=d(this,se,"f").getDateValueObjectBaseOnValueType(e,t,n,l,o,i,a,r,s);m(this,he,u,"f"),d(this,ne,"m",He).call(this)},$e=function(e,t,n,i,a,r,s){const l=this.yearBaseOnInputType,o=this.monthBaseOnInputType,u=d(this,se,"f").getDateValueObjectBaseOnInputType(e,t,n,l,o,i,a,r,s);m(this,he,u,"f"),d(this,ne,"m",He).call(this),d(this,ne,"m",de).call(this)},Ze=function(){const{year:e,month:t,day:n}=this.inputType==B.jalali?d(this,he,"f").jalali:d(this,he,"f").gregorian;if(this.placeholder&&!(e&&t&&n))return void m(this,ne,"","a",ye);let i=R,a=" ",r=" ",s=" ";null==e||Number.isNaN(e)||(a=e<10?"000"+e:e<100?"00"+e:e<1e3?"0"+e:e.toString()),null==t||Number.isNaN(t)||(r=t<10?"0"+t:t.toString()),null==n||Number.isNaN(n)||(s=n<10?"0"+n:n.toString()),d(this,fe,"f")&&(a=(0,u.enToFaDigits)(a),r=(0,u.enToFaDigits)(r),s=(0,u.enToFaDigits)(s)),i=i.replace("YYYY",a).replace("MM",r).replace("DD",s),m(this,ne,i,"a",ye)},Xe=function(e){Y.lastIndex=0;const t=Y.exec(e);if(t&&t.groups){const{hour:e,minute:n,millisecond:i,second:a}=d(this,he,"f").time,r=Number(t.groups.year),s=Number(t.groups.month),l=Number(t.groups.day);r&&s&&l&&d(this,ne,"m",$e).call(this,r,s,l,e,n,a,i)}},Ke=function(){const e=Q({inputValue:this.inputValue,selectionStart:this.elements.input.selectionStart});null!==e&&this.elements.input.setSelectionRange(e,e)},Qe=function(e){const t=()=>{m(this,ze,e,"f")};return d(this,ze,"f")!=e?(m(this,ze,e,"f"),{isUpdated:!0,updatePrevValue:t}):{isUpdated:!1,updatePrevValue:t}},et=function(e){m(this,ze,d(this,ne,"a",pe),"f"),this.focus(),document.addEventListener("selectionchange",d(this,ne,"m",Ke).bind(this)),d(this,ne,"m",tt).call(this,e)},tt=function(e){e.stopPropagation();const t=(0,u.createFocusEvent)("focus",e,{cancelable:!1});this.dispatchEvent(t)},nt=function(e){document.removeEventListener("selectionchange",d(this,ne,"m",Ke).bind(this));const t=e.relatedTarget;t!==this.elements.calendar&&t!==this.elements.calendarTriggerButton&&(this.showCalendar=!1);const n=d(this,ne,"a",pe),i=d(this,ne,"m",Qe).call(this,n);if(i.isUpdated){d(this,ne,"m",Xe).call(this,n);const t=d(this,ne,"m",st).call(this);d(this,ne,"m",gt).call(this,!0),t.defaultPrevented?(e.preventDefault(),d(this,ne,"m",Xe).call(this,d(this,ze,"f"))):i.updatePrevValue()}d(this,ne,"m",it).call(this,e)},it=function(e){e.stopPropagation();const t=(0,u.createFocusEvent)("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)},rt=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(te),this.dateRestrictions.min&&e.push({validator:e=>{return t=new Date(e.valueObject.timeStamp),n=this.dateRestrictions.min,(0,h.isAfter)(t,n)||(0,h.isEqual)(t,n);var t,n},message:F.minRangeViolation,stateType:"rangeUnderflow"}),this.dateRestrictions.max&&e.push({validator:e=>{return t=new Date(e.valueObject.timeStamp),n=this.dateRestrictions.max,(0,h.isBefore)(t,n)||(0,h.isEqual)(t,n);var t,n},message:F.maxRangeViolation,stateType:"rangeOverflow"}),e},ot=function(){this.elements.calendar.dateRestrictions.min=this.dateRestrictions.min,this.elements.calendar.dateRestrictions.max=this.dateRestrictions.max,this.elements.calendar.defaultCalendarData={gregorian:{year:d(this,se,"f").nicheNumbers.calendarYearOnEmpty.gregorian,month:d(this,se,"f").nicheNumbers.calendarMonthOnEmpty.gregorian},jalali:{year:d(this,se,"f").nicheNumbers.calendarYearOnEmpty.jalali,month:d(this,se,"f").nicheNumbers.calendarMonthOnEmpty.jalali}},d(this,ne,"m",He).call(this)},ht=function(e){const t=e.relatedTarget;this.showCalendar&&t&&[this.elements.calendar,this.elements.input].includes(t)?(t.focus(),this.showCalendar=!1):(m(this,ut,!0,"f"),this.showCalendar=!0)},ct=function(e){[this.elements.calendar,this.elements.input].includes(e.relatedTarget)||(this.showCalendar=!1)},dt=function(){const e=this.shadowRoot?.activeElement;e&&!d(this,ut,"f")&&e==this.elements.calendarTriggerButton&&(this.showCalendar=!this.showCalendar),m(this,ut,!1,"f")},mt=function(e){const t=e.target,{year:n,month:i,day:a}=t.value;if(n&&i&&a){const t=structuredClone(this.valueInDate),{hour:r,minute:s,millisecond:l,second:o}=d(this,he,"f").time;d(this,ne,"m",$e).call(this,n,i,a,r,s,o,l),d(this,ne,"m",Ze).call(this),this.showCalendar=!1,d(this,ne,"m",pt).call(this),d(this,ne,"m",gt).call(this,!0);d(this,ne,"m",st).call(this).defaultPrevented&&(e.preventDefault(),d(this,ne,"m",Ue).call(this,t),d(this,ne,"m",Ze).call(this))}},pt=function(){const e=new CustomEvent("select");this.dispatchEvent(e)},gt=function(e){if(!this.isAutoValidationDisabled)return d(this,ae,"f").checkValidity({showError:e})},yt=function(){const e=new CustomEvent("invalid");this.dispatchEvent(e)},ft=function(e){if(e.isAllValid)d(this,ie,"f").setValidity({},"");else{const t={};let n="";e.validationList.forEach((e=>{e.isValid||(e.validation.stateType?t[e.validation.stateType]=!0:t.customError=!0,""==n&&(n=e.message))})),d(this,ie,"f").setValidity(t,n)}},bt.formAssociated=!0;!customElements.get("jb-date-input")&&window.customElements.define("jb-date-input",bt),Object.defineProperty(exports,"InputTypes",{enumerable:!0,get:function(){return B}}),exports.JBDateInputWebComponent=bt,Object.defineProperty(exports,"ValueTypes",{enumerable:!0,get:function(){return _}}),exports.emptyInputValueString=L,exports.getFixedCaretPos=Q,exports.handleBeforeInput=z;
//# sourceMappingURL=jb-date-input.cjs.js.map