!function(){function e(e){return function(e){if(Array.isArray(e))return n(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||t(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e,a){return function(e){if(Array.isArray(e))return e}(e)||function(e,a){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==t)return;var n,r,o=[],l=!0,i=!1;try{for(t=t.call(e);!(l=(n=t.next()).done)&&(o.push(n.value),!a||o.length!==a);l=!0);}catch(u){i=!0,r=u}finally{try{l||null==t.return||t.return()}finally{if(i)throw r}}return o}(e,a)||t(e,a)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function t(e,a){if(e){if("string"==typeof e)return n(e,a);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?n(e,a):void 0}}function n(e,a){(null==a||a>e.length)&&(a=e.length);for(var t=0,n=new Array(a);to?1:-1}return t>n?1:-1}function W(e,a){var t=P(e,a);if(0===t){var n=e.getDate(),r=a.getDate();return n===r?0:n>r?1:-1}return t}var F=function(e){return new Date(e)},Y=function(e){return Array.isArray(e)?e.map(F):F(e)};function E(e,a){var t=F(e);return t.setDate(t.getDate()+a),t}var N=function(e){return E(e,-1)},V=function(e){return E(e,1)},L=function(){var e=new Date;return e.setHours(0,0,0,0),e};var U=a(n("calendar-day"),1)[0],$=r({name:U,props:{item:o(Object),color:String,index:Number,offset:l(0),rowHeight:String},emits:["click"],setup:function(e,a){var t=a.emit,n=a.slots,r=i((function(){var a=e.item,t=e.index,n=e.color,r=e.offset,o={height:e.rowHeight};if("placeholder"===a.type)return o.width="100%",o;if(0===t&&(o.marginLeft="".concat(100*r/7,"%")),n)switch(a.type){case"end":case"start":case"start-end":case"multiple-middle":case"multiple-selected":o.background=n;break;case"middle":o.color=n}return o})),o=function(){"disabled"!==e.item.type&&t("click",e.item)},l=function(){var a=e.item.topInfo;if(a||n["top-info"])return u("div",{class:R("top-info")},[n["top-info"]?n["top-info"](e.item):a])},c=function(){var a=e.item.bottomInfo;if(a||n["bottom-info"])return u("div",{class:R("bottom-info")},[n["bottom-info"]?n["bottom-info"](e.item):a])},d=function(){var a=e.item,t=e.color,n=e.rowHeight,r=a.type,o=a.text,i=[l(),o,c()];return"selected"===r?u("div",{class:R("selected-day"),style:{width:n,height:n,background:t}},[i]):i};return function(){var a=e.item,t=a.type,n=a.className;return"placeholder"===t?u("div",{class:R("day"),style:r.value},null):u("div",{role:"gridcell",style:r.value,class:[R("day",t),n],tabindex:"disabled"===t?void 0:-1,onClick:o},[d()])}}}),G=a(n("calendar-month"),1)[0],X={date:o(Date),type:String,color:String,minDate:o(Date),maxDate:o(Date),showMark:Boolean,rowHeight:f,formatter:Function,lazyRender:Boolean,currentDate:[Date,Array],allowSameDay:Boolean,showSubtitle:Boolean,showMonthTitle:Boolean,firstDayOfWeek:Number},Z=r({name:G,props:X,emits:["click","update-height"],setup:function(e,t){var n=t.emit,r=t.slots,o=a(c(),2),l=o[0],f=o[1],g=d(),y=d(),b=B(y),w=i((function(){return a=e.date,H("monthTitle",a.getFullYear(),a.getMonth()+1);var a})),_=i((function(){return s(e.rowHeight)})),k=i((function(){var a=e.date.getDay();return e.firstDayOfWeek?(a+7-e.firstDayOfWeek)%7:a})),D=i((function(){return C(e.date.getFullYear(),e.date.getMonth()+1)})),x=i((function(){return l.value||!e.lazyRender})),z=function(t){var n=e.type,r=e.minDate,o=e.maxDate,l=e.currentDate;if(W(t,r)<0||W(t,o)>0)return"disabled";if(null===l)return"";if(Array.isArray(l)){if("multiple"===n)return function(a){var t=function(a){return e.currentDate.some((function(e){return 0===W(e,a)}))};if(t(a)){var n=N(a),r=V(a),o=t(n),l=t(r);return o&&l?"multiple-middle":o?"end":l?"start":"multiple-selected"}return""}(t);if("range"===n)return function(t){var n=a(e.currentDate,2),r=n[0],o=n[1];if(!r)return"";var l=W(t,r);if(!o)return 0===l?"start":"";var i=W(t,o);return e.allowSameDay&&0===l&&0===i?"start-end":0===l?"start":0===i?"end":l>0&&i<0?"middle":""}(t)}else if("single"===n)return 0===W(t,l)?"selected":"";return""},S=function(a){if("range"===e.type){if("start"===a||"end"===a)return H(a);if("start-end"===a)return"".concat(H("start"),"/").concat(H("end"))}},T=function(){if(e.showMonthTitle)return u("div",{class:R("month-title")},[w.value])},A=function(){if(e.showMark&&x.value)return u("div",{class:R("month-mark")},[e.date.getMonth()+1])},O=i((function(){var e=Math.ceil((D.value+k.value)/7);return Array(e).fill({type:"placeholder"})})),M=i((function(){for(var a=[],t=e.date.getFullYear(),n=e.date.getMonth(),r=1;r<=D.value;r++){var o=new Date(t,n,r),l=z(o),i={date:o,type:l,text:r,bottomInfo:S(l)};e.formatter&&(i=e.formatter(i)),a.push(i)}return a})),I=i((function(){return M.value.filter((function(e){return"disabled"===e.type}))})),j=function(a,t){return u($,{item:a,index:t,color:e.color,offset:k.value,rowHeight:_.value,onClick:function(e){return n("click",e)}},p(r,["top-info","bottom-info"]))};return v({getTitle:function(){return w.value},getHeight:function(){return b.value},setVisible:f,scrollToDate:function(e,a){if(g.value){var t=m(g.value),n=O.value.length,r=(Math.ceil((a.getDate()+k.value)/7)-1)*t.height/n;h(e,t.top+r+e.scrollTop-m(e).top)}},disabledDays:I}),function(){return u("div",{class:R("month"),ref:y},[T(),u("div",{ref:g,role:"grid",class:R("days")},[A(),(x.value?M:O).value.map(j)])])}}}),q=a(n("calendar-header"),1)[0],J=r({name:q,props:{title:String,subtitle:String,showTitle:Boolean,showSubtitle:Boolean,firstDayOfWeek:Number},emits:["click-subtitle"],setup:function(a,t){var n=t.slots,r=t.emit,o=function(){if(a.showTitle){var e=a.title||H("title"),t=n.title?n.title():e;return u("div",{class:R("header-title")},[t])}},l=function(e){return r("click-subtitle",e)},i=function(){if(a.showSubtitle){var e=n.subtitle?n.subtitle():a.subtitle;return u("div",{class:R("header-subtitle"),onClick:l},[e])}};return function(){return u("div",{class:R("header")},[o(),i(),(t=a.firstDayOfWeek,n=H("weekdays"),r=[].concat(e(n.slice(t,7)),e(n.slice(0,t))),u("div",{class:R("weekdays")},[r.map((function(e){return u("span",{class:R("weekday")},[e])}))]))]);var t,n,r}}}),K={show:Boolean,type:g("single"),title:String,color:String,round:y,readonly:Boolean,poppable:y,maxRange:b(null),position:g("bottom"),teleport:[String,Object],showMark:y,showTitle:y,formatter:Function,rowHeight:f,confirmText:String,rangePrompt:String,lazyRender:y,showConfirm:y,defaultDate:[Date,Array],allowSameDay:Boolean,showSubtitle:y,closeOnPopstate:y,showRangePrompt:y,confirmDisabledText:String,closeOnClickOverlay:y,safeAreaInsetTop:Boolean,safeAreaInsetBottom:y,minDate:{type:Date,validator:w,default:L},maxDate:{type:Date,validator:w,default:function(){var e=L();return new Date(e.getFullYear(),e.getMonth()+6,e.getDate())}},firstDayOfWeek:{type:f,default:0,validator:function(e){return e>=0&&e<=6}}},Q=r({name:j,props:K,emits:["select","confirm","unselect","month-show","over-range","update:show","click-subtitle"],setup:function(t,n){var r,o=n.emit,l=n.slots,c=function(e){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t.minDate,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.maxDate;return-1===W(e,a)?a:1===W(e,n)?n:e},s=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:t.defaultDate,a=t.type,n=t.minDate,r=t.maxDate;if(null===e)return e;var o=L();if("range"===a){Array.isArray(e)||(e=[]);var l=c(e[0]||o,n,N(r)),i=c(e[1]||o,V(n));return[l,i]}return"multiple"===a?Array.isArray(e)?e.map((function(e){return c(e)})):[c(o)]:(e&&!Array.isArray(e)||(e=o),c(e))},f=d(),h=d(""),g=d(s()),y=a(M(),2),b=y[0],w=y[1],O=i((function(){return t.firstDayOfWeek?+t.firstDayOfWeek%7:0})),C=i((function(){var e=[],a=new Date(t.minDate);a.setDate(1);do{e.push(new Date(a)),a.setMonth(a.getMonth()+1)}while(1!==P(a,t.maxDate));return e})),B=i((function(){if(g.value){if("range"===t.type)return!g.value[0]||!g.value[1];if("multiple"===t.type)return!g.value.length}return!g.value})),I=function(){var e=z(f.value),a=e+r,t=C.value.map((function(e,a){return b.value[a].getHeight()}));if(!(a>t.reduce((function(e,a){return e+a}),0)&&e>0)){for(var n,l=0,i=[-1,-1],u=0;u=e&&(i[1]=u,n||(n=c,i[0]=u),b.value[u].showed||(b.value[u].showed=!0,o("month-show",{date:c.date,title:c.getTitle()}))),l+=t[u]}C.value.forEach((function(e,a){var t=a>=i[0]-1&&a<=i[1]+1;b.value[a].setVisible(t)})),n&&(h.value=n.getTitle())}},j=function(e){x((function(){C.value.some((function(a,t){return 0===P(a,e)&&(f.value&&b.value[t].scrollToDate(f.value,e),!0)})),I()}))},U=function(){if(!t.poppable||t.show)if(g.value){var e="single"===t.type?g.value:g.value[0];j(e)}else x(I)},$=function(){t.poppable&&!t.show||x((function(){r=Math.floor(m(f).height),U()}))},G=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:s();g.value=e,U()},X=function(){var e;return o("confirm",null!=(e=g.value)?e:Y(g.value))},q=function(e,a){var n=function(e){g.value=e,o("select",Y(e))};if(a&&"range"===t.type){var r=function(e){var a=t.maxRange,n=t.rangePrompt,r=t.showRangePrompt;return!(a&&function(e){var a=e[0].getTime();return(e[1].getTime()-a)/864e5+1}(e)>a&&(r&&T(n||H("rangePrompt",a)),o("over-range"),1))}(e);if(!r)return void n([e[0],E(e[0],+t.maxRange-1)])}n(e),a&&!t.showConfirm&&X()},K=i((function(){return b.value.reduce((function(a,t){var n,r;return a.push.apply(a,e(null!=(r=null==(n=t.disabledDays)?void 0:n.value)?r:[])),a}),[])})),Q=function(n){if(!t.readonly&&n.date){var r=n.date,l=t.type;if("range"===l){if(!g.value)return void q([r]);var i=a(g.value,2),u=i[0],c=i[1];if(u&&!c){var d=W(r,u);if(1===d){var s=function(e,a,t){var n;return null==(n=e.find((function(e){return-1===W(a,e.date)&&-1===W(e.date,t)})))?void 0:n.date}(K.value,u,r);if(s){var v=N(s);-1===W(u,v)?q([u,v]):q([r])}else q([u,r],!0)}else-1===d?q([r]):t.allowSameDay&&q([r,r],!0)}else q([r])}else if("multiple"===l){if(!g.value)return void q([r]);var f=g.value,m=f.findIndex((function(e){return 0===W(e,r)}));if(-1!==m){var h=a(f.splice(m,1),1)[0];o("unselect",F(h))}else t.maxRange&&f.length>=t.maxRange?T(t.rangePrompt||H("rangePrompt",t.maxRange)):q([].concat(e(f),[r]))}else q(r,!0)}},ee=function(e){return o("update:show",e)},ae=function(e,a){var n=0!==a||!t.showSubtitle;return u(Z,S({ref:w(a),date:e,currentDate:g.value,showMonthTitle:n,firstDayOfWeek:O.value},p(t,["type","color","minDate","maxDate","showMark","formatter","rowHeight","lazyRender","showSubtitle","allowSameDay"]),{onClick:Q}),p(l,["top-info","bottom-info"]))},te=function(){if(l.footer)return l.footer();if(t.showConfirm){var e=l["confirm-text"],a=B.value,n=a?t.confirmDisabledText:t.confirmText;return u(A,{round:!0,block:!0,type:"danger",color:t.color,class:R("confirm"),disabled:a,nativeType:"button",onClick:X},{default:function(){return[e?e({disabled:a}):n||H("confirm")]}})}},ne=function(){return u("div",{class:R()},[u(J,{title:t.title,subtitle:h.value,showTitle:t.showTitle,showSubtitle:t.showSubtitle,firstDayOfWeek:O.value,"onClick-subtitle":function(e){return o("click-subtitle",e)}},p(l,["title","subtitle"])),u("div",{ref:f,class:R("body"),onScroll:I},[C.value.map(ae)]),u("div",{class:[R("footer"),{"van-safe-area-bottom":t.safeAreaInsetBottom}]},[te()])])};return _((function(){return t.show}),$),_((function(){return[t.type,t.minDate,t.maxDate]}),(function(){return G(s(g.value))})),_((function(){return t.defaultDate}),(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;g.value=e,U()})),v({reset:G,scrollToDate:j}),k($),function(){return t.poppable?u(D,{show:t.show,class:R("popup"),round:t.round,position:t.position,closeable:t.showTitle||t.showSubtitle,teleport:t.teleport,closeOnPopstate:t.closeOnPopstate,safeAreaInsetTop:t.safeAreaInsetTop,closeOnClickOverlay:t.closeOnClickOverlay,"onUpdate:show":ee},{default:ne}):ne()}}});t("C",O(Q))}}}))}();