UNPKG

jb-date-input

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