﻿var _dateChooser,keyCode={TAB:9,ESC:27,PAGEUP:33,PAGEDOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40},landscapeCutoffHeight=460;function callback(e,t,a){document.forms[0].year.value=e,document.forms[0].month.value=getMonthName(t+1),document.forms[0].day.value=a}function createClickFunction(e){return function f(t){for(var a,n=WP.Events.getThis(t);"TD"!==n.nodeName.toUpperCase();)n=n.parentNode;if("calnext"===(a=n.id||n.getAttribute("name")))return _dateChooser.drawNextMonth(),WP.Events.cancelEvent(t),WP.Events.preventDefault(t),!1;if("calprev"===a)return _dateChooser.drawPreviousMonth(),WP.Events.cancelEvent(t),WP.Events.preventDefault(t),!1;if("calcancel"!==a){var o=a.replace("cal",""),r=makeDate(_dateChooser.year,_dateChooser.month+1,o);return r.getMonth()!=_dateChooser.month?(_dateChooser.year=r.getFullYear(),_dateChooser.month=r.getMonth(),_dateChooser.date=r.getDate()):_dateChooser.date=o,$afe.select(".currentselected").removeClass("currentselected"),$afe.jq(n).addClass("currentselected"),e.call(_dateChooser,_dateChooser.year,_dateChooser.month,_dateChooser.date,_dateChooser.input),_dateChooser.clearCalendar(),WP.Events.cancelEvent(t),WP.Events.preventDefault(t),!1}_dateChooser.clearCalendar()}}function DateChooser(e,t,a,n,o){this.trigger=e,this.callback=t,this.input=o,this.filter=a||function(){return!0},n&&"function"==typeof n.getYear?this.today=n:"string"==typeof n?(this.today=new Date(n),isNaN(this.today)&&(this.today=new Date)):this.today=new Date,this.month=this.today.getMonth(),this.year=this.today.getFullYear(),this.date=this.today.getDate(),this.calendar=null,this.clickFunction=createClickFunction(t)}function isInCalendar(e){var t,a;for(a=e,t=0;a&&t<8;a=a.parentNode,t++)if(a&&a.id&&"calendar"===a.id.toLowerCase())return!0;return!1}function lo(e){for(var t=WP.Events.getThis(e);"TD"!==t.nodeName.toUpperCase();)t=t.parentNode;$afe.jq(t).removeClass("hi")}function hi(e,t){return function(a){var n=WP.Events.getThis(a);if(t)for(;"DIV"!==n.nodeName.toUpperCase();)n=n.parentNode;else for(;"TD"!==n.nodeName.toUpperCase();)n=n.parentNode;$afe.jq(n).addClass("hi"),$afe.jq(n).hasClass("ctrl")&&!e||!_dateChooser.focusOn||_dateChooser.focusOn===n.id||(document.getElementById(_dateChooser.focusOn)&&lo({target:document.getElementById(_dateChooser.focusOn),srcElement:document.getElementById(_dateChooser.focusOn)}),_dateChooser.focusOn=n.id)}}function ctrlMouseDown(e){_dateChooser.mouseDown=!0}function ctrlFocus(e){_dateChooser.mouseDown?(_dateChooser.redrawn&&(_dateChooser.mouseDown=!1,_dateChooser.redrawn=!1),hi()(e)):(_dateChooser.redrawn=!1,hi(!0)(e))}function restoreHi(e){var t,a,n=WP.Events.getThis(e);n&&"calendar"!==n.className&&!isInCalendar(n)&&(a=$afe.select(".currentselected"),_dateChooser.focusOn&&(a.length>0?document.getElementById(a[0].id).firstChild.focus():((t=document.getElementById(_dateChooser.focusOn)).firstChild&&t.firstChild.blur(),lo({target:t,srcElement:t}))))}function _removeCalendar(e){var t=$afe.select("#calendar"),a=$afe.select(".calendarshield");t.length>0&&(WP.Events.removeListener(document.body,"click",removeCalendar),WP.Events.removeListener(document.body,"mouseover",restoreHi),$afe.jq(window).off("orientationchange resize",handleOrientationChange),checkIfMobile()&&$$WP.Utilities.UI.ToggleBodyScrolling(!1),accessibilityRestorePage(),t.remove(),a.remove(),_dateChooser=null)}function removeCalendar(e){var t=WP.Events.getThis(e);t&&"calendar"!==t.className&&!isInCalendar(t)&&_removeCalendar()}function removeCalendarExternal(){_removeCalendar()}function keyOnPrevMonth(e){var t;if(9===e.keyCode)return e.shiftKey?((t=document.getElementById("calcancel").firstChild)&&"BUTTON"===t.nodeName.toUpperCase()?t.focus():document.getElementById("cal"+_dateChooser.lastDate).firstChild.focus(),WP.Events.preventDefault(e)):void 0;13===e.keyCode&&(_dateChooser.wasEnter=!0)}function keyOnNextMonth(e){var t;if(9===e.keyCode)return!e.shiftKey||(t=document.getElementById("calprev").firstChild)&&"BUTTON"===t.nodeName.toUpperCase()?void 0:((t=document.getElementById("calcancel").firstChild)&&"BUTTON"===t.nodeName.toUpperCase()?t.focus():document.getElementById("cal"+_dateChooser.lastDate).firstChild.focus(),WP.Events.preventDefault(e));13===e.keyCode&&(_dateChooser.wasEnter=!0)}function tabOnCancel(e){var t;if(9===e.keyCode){if(e.shiftKey)return;return(t=document.getElementById("calprev").firstChild)&&"BUTTON"===t.nodeName.toUpperCase()||(t=document.getElementById("calnext").firstChild)&&"BUTTON"===t.nodeName.toUpperCase()?t.focus():document.getElementById("cal"+_dateChooser.firstDate).firstChild.focus(),WP.Events.preventDefault(e)}}function checkIfMobile(){return document.documentElement.className.indexOf("mobile")>=0||document.documentElement.className.indexOf("respquestionnaire")>=0}function checkIfPopup(){var e=document.getElementById("appPopupRoot"),t=!1;null!=e&&(t=1==e.getElementsByClassName("_PopupContainer").length);return t||1==document.getElementsByClassName("Popup").length}function handleOrientationChange(){var e=document.getElementById("calendar");this.positionCalendar(this._dateChooser.trigger,e);var t=checkIfMobile();"orientationchange"!==window.event.type||t||scrollCalendarIntoView()}function scrollCalendarIntoView(){var e=document.getElementById("calendar");setTimeout((function(){e.scrollIntoView({behavior:"smooth",block:"start"})}),600)}function positionCalendar(e,t){var a=checkIfPopup(),n=checkIfMobile();if(e.offsetParent||(e=document.getElementById(e.id)),e.offsetParent){if(t.style.position="absolute",pos=getElementPosition(e),topElement=pos.topElement,topElement.appendChild(t),$$WPContain.Popup.__zIndex+=3,t.style.zIndex=3e3+$$WPContain.Popup.__zIndex,t.style.left=pos.x,t.style.top=pos.y,datatileContainer=$afe.select("html.datatile")[0],popupContainer=$afe.jq(e).parents(".Popup")[0],defaultContainer=document.getElementById("main"),container=popupContainer||datatileContainer||defaultContainer,containerOffsetWidth=container.offsetWidth,containerOffsetHeight=container.offsetHeight,pos=getElementPosition(e,container),t.offsetWidth){var o=parseInt(t.style.left,10);overflow=parseInt(pos.x,10)+t.offsetWidth-containerOffsetWidth,overflow>0&&(overflow<o?t.style.left=o-overflow+"px":t.style.left="0px")}if(t.offsetHeight){var r=parseInt(t.style.top,10);overflow=parseInt(pos.y,10)+t.offsetHeight-containerOffsetHeight,overflow>0&&(overflow<r?t.style.top=r-overflow+"px":t.style.top="0px");var s=document.body.clientHeight;s<landscapeCutoffHeight&&(t.style.top=s/3+"px")}if(a&&!n){t.style.position="fixed";var d=e.getBoundingClientRect(),l=d.top,i=d.left,c=window.innerHeight-l-t.offsetHeight,h=window.innerWidth-i-t.offsetWidth;t.style.top=c<0?l+c+"px":l+"px",t.style.left=h<0?i+h+"px":i+"px"}n&&(t.style.left="50%",t.style.position="fixed",t.style.top="50%")}else $afe.jq(e.parentNode).safeInsertBefore(t,this.trigger),$afe.jq(e).addClass("hidden")}function HandleKeyUp(e){e.keyCode==keyCode.ESC&&(e.stopPropagation(),e.preventDefault(),_dateChooser.clearCalendar())}function HandleKeyDown(e){for(var t=!1,a=document.activeElement;"TD"!==a.nodeName.toUpperCase();)a=a.parentNode;var n=a.id||a.getAttribute("name");if(a.className.indexOf("ctrl")<0){var o=n.replace("cal","");switch(e.keyCode){case keyCode.RIGHT:moveFocusByDay(o,1),t=!0;break;case keyCode.LEFT:moveFocusByDay(o,-1),t=!0;break;case keyCode.DOWN:moveFocusByDay(o,7),t=!0;break;case keyCode.UP:moveFocusByDay(o,-7),t=!0;break;case keyCode.PAGEDOWN:moveFocusByMonth(o,1),t=!0;break;case keyCode.PAGEUP:moveFocusByMonth(o,-1),t=!0;break;case keyCode.HOME:moveFocusToFirstDayOfWeek(o),t=!0;break;case keyCode.END:moveFocusToLastDayOfWeek(o),t=!0;break;case keyCode.ESC:t=!0}a=document.activeElement,null!==_dateChooser&&"0"==a.tabIndex&&(_dateChooser.focusOn=a.parentElement.id),t&&(e.stopPropagation(),e.preventDefault())}}function moveFocusToFirstDayOfWeek(e){var t=_dateChooser.year,a=_dateChooser.month,n=new Date(t,a,e).getDay()-getFirstDayOfWeek(),o=e-(n=n<0?n+7:n);document.getElementById("cal"+o).firstChild.focus()}function moveFocusToLastDayOfWeek(e){var t=_dateChooser.year,a=_dateChooser.month,n=new Date(t,a,e).getDay()-getFirstDayOfWeek();n=n<0?-1-n:6-n;var o=parseInt(e)+n;document.getElementById("cal"+o).firstChild.focus()}function moveFocusByDay(e,t){var a=_dateChooser.year,n=_dateChooser.month,o=parseInt(e)+t,r=new Date(a,n,o),s=r.getMonth(),d=r.getFullYear();t>0&&(s>n||d>a)?hasSelectableDay(s,d)?_dateChooser.drawNextMonth(r.getDate()):_dateChooser.isDateDisplayed(o)&&document.getElementById("cal"+o).firstChild.focus():t<0&&(s<n||d<a)?hasSelectableDay(s,d)?_dateChooser.drawPreviousMonth(r.getDate()):_dateChooser.isDateDisplayed(o)&&document.getElementById("cal"+o).firstChild.focus():document.getElementById("cal"+o).firstChild.focus()}function moveFocusByMonth(e,t){e=parseInt(e);var a=_dateChooser.year,n=_dateChooser.month,o=new Date(a,n,e).getDate();1==t&&e<=0||-1==t&&e>_dateChooser.lastDateOfMonth?(o=o>_dateChooser.lastDateOfMonth?_dateChooser.lastDateOfMonth:o,document.getElementById("cal"+o).firstChild.focus()):hasSelectableDay(n+t,a)?1==t?_dateChooser.drawNextMonth(o):-1==t&&_dateChooser.drawPreviousMonth(o):1==Math.abs(t)&&(o=1===t?o+new Date(a,n+1,0).getDate():o-new Date(a,n,0).getDate(),_dateChooser.isDateDisplayed(o)&&document.getElementById("cal"+o).firstChild.focus())}function buildNavHeaderObject(e,t){var a=WP.DOM.Create.tag,n=$$WP.Strings.get("PrevButtonTooltip","UI.Calendar"),o=$$WP.Strings.get("NextButtonTooltip","UI.Calendar"),r=$$WP.Strings.get("PrevButtonOverride","UI.Calendar"),s=$$WP.Strings.get("NextButtonOverride","UI.Calendar");""===r&&(r="&laquo;"),""===s&&(s="&raquo");var d,l,i=!hasSelectableDay(e,t),c=document.createElement("nav"),h=a("table","calendarheader",""),u=document.createElement("thead"),m=document.createElement("tr");return h.setAttribute("role","presentation"),hasSelectableDay(e-1,t)||i?(d=a("td","ctrl"+(hasSelectableDay(e-1,t)||i?"":"n"),"calprev",n),l=a("button","","","",r),d.appendChild(l),l.setAttribute("aria-label",n)):(d=a("td","ctrl"+(hasSelectableDay(e-1,t)||i?"":"n"),"calprev",$$WP.I18N.monthTitleFormat(makeDate(t,e)),""),(l=a("button","","","",r)).setAttribute("aria-disabled","true"),l.setAttribute("aria-label",n),l.style.cursor="default",d.appendChild(l)),m.appendChild(d),m.appendChild(a("th","hdr calmonth","monthlabel","",$$WP.I18N.monthTitleFormat(makeDate(t,e+1)))),m.lastChild.colSpan=5,hasSelectableDay(e+1,t)||i?(d=a("td","ctrl"+(hasSelectableDay(e+1,t)||i?"":"n"),"calnext",o),l=a("button","","","",s),d.appendChild(l),l.setAttribute("aria-label",o)):(d=a("td","ctrl"+(hasSelectableDay(e+1,t)||i?"":"n"),"calnext",$$WP.I18N.monthTitleFormat(makeDate(t,e+2)),""),(l=a("button","","","",s)).setAttribute("aria-label",o),l.setAttribute("aria-disabled","true"),l.style.cursor="default",d.appendChild(l)),c.appendChild(h),h.appendChild(u),u.appendChild(m),m.appendChild(d),c}function dfltClndrCallbackFactory(e){return function(t,a,n){var o=document.getElementById(e);o&&(o.holdErrors=!1,o.openingCalendar=!1,t&&!isNaN(a)&&a>-1&&a<12&&n&&(o.value=formatDate(new Date(t,a,n)),_dateChooser.today=parseDate(o.value,!0),WP.Events.fireEvent(o,"change"),o.focus()))}}function textBoxDataChooser(e,t,a,n){var o,r,s,d;r=document.getElementById(t),"string"==typeof n&&n.length>0?o=window[n](t):"function"==typeof n&&(o=n),"function"!=typeof o&&(o=dfltClndrCallbackFactory(t)),d=$afe.jq(r).safeAttr("data-focus-dte"),""!==r.value?s=parseDate(r.value,!0):void 0!==d&&(s=WP.Utils.dte2date(d)),new DateChooser(e,o,WP.Validators.Calendar[a],s,r).drawCalendar()}function writeCalendar(e,t,a,n,o,r,s,d){var l,i;"string"==typeof e&&(e=$afe.select("#"+e)),l=$afe.jq(createElement("button","calendar datechooserAnchor")),$$WPUtil.IsNullOrEmpty(d)||l.safeAttr("id",d),l.safeAttr("type","button"),i=$afe.select('label[for="'+e.attr("id")+'"]').text(),$$WPUtil.IsNullOrEmpty(i)&&(i=$$WP.Strings.get("DefaultFieldDescription","UI.Calendar")),$$WP.Strings.addMnemonic("@MYCHART@AssociatedLabelText@",i,!1,"UI.Calendar",$$WP.Strings.EncodingTypes.HTML),l.safeAttr("aria-label",HTMLUnencode($$WP.Strings.get("DatePickerDescription","UI.Calendar"))),l.safeAppend($$WP.SimpleTemplates.Img({src:a,"aria-hidden":"true",focusable:"false",alt:HTMLUnencode($$WP.Strings.get("DatePickerDescription","UI.Calendar"))})),$$WP.Strings.removeMnemonic("@MYCHART@AssociatedLabelText@","UI.Calendar"),"range"===t&&($$WPUtil.IsNullOrEmpty(n)||(window.cachedStartDate=WP.Utils.dte2date(n)),$$WPUtil.IsNullOrEmpty(o)||(window.cachedEndDate=WP.Utils.dte2date(o))),l.click((function(){return e.prop("openingCalendar",!0),e.prop("holdErrors",!1),textBoxDataChooser(l[0],e.prop("id"),t,r),!1})).on("mousedown",(function(){e.prop("holdErrors",!0)})).on("mouseout",(function(){e.prop("holdErrors",!1),e.prop("openingCalendar",!1)})),l.safeInsertAfter(e)}function clearCalendarDateRange(){window.cachedStartDate=null,window.cachedEndDate=null}function hasSelectableDay(e,t){var a=1,n=makeDate(t,e+1,a);for(e=n.getMonth();n.getMonth()===e;){if(_dateChooser.filter(n.getFullYear(),n.getMonth(),a))return!0;n.setDate(++a)}return!1}function pageLo(e){for(var t=WP.Events.getThis(e);"DIV"!==t.nodeName.toUpperCase();)t=t.parentNode;$afe.jq(t).removeClass("hover")}function pageHi(){return function(e){for(var t=WP.Events.getThis(e);"DIV"!==t.nodeName.toUpperCase();)t=t.parentNode;$afe.jq(t).addClass("hover"),_dateChooser.focusOn&&_dateChooser.focusOn!==t.id&&pageLo({target:document.getElementById(_dateChooser.focusOn),srcElement:document.getElementById(_dateChooser.focusOn)}),_dateChooser.focusOn=t.id}}function pageCalendarEffects(){var e,t,a,n;if(null!==(e=document.getElementById("pagecalendar"))&&(_dateChooser=function(){},null!==(t=e.getElementsByTagName("div"))))for(a=0;a<t.length;a++)n=t[a],($afe.jq(n).hasClass("NoData")||$afe.jq(n).hasClass("EditData")||$afe.jq(n).hasClass("ctrl"))&&(WP.Events.addListener(n,"mouseover",(function(){this.firstChild.focus()})),WP.Events.addListener(n,"mouseout",(function(){this.firstChild.blur()})),WP.Events.addListener(n.firstChild,"focus",pageHi()),WP.Events.addListener(n.firstChild,"blur",pageLo))}function accessibilityHidePage(){var e=accessibilityGetElements();for(i=0;i<e.length;i++)e[i]&&e[i].setAttribute("aria-hidden","true")}function accessibilityRestorePage(){var e=accessibilityGetElements();for(i=0;i<e.length;i++)e[i]&&e[i].removeAttribute("aria-hidden")}function accessibilityGetElements(){var e=[document.getElementById("header"),document.getElementById("footer"),document.getElementById("content")];if(WP.DOM.Browser.isSafari||WP.DOM.Browser.isIPhone||WP.DOM.Browser.isIPad||WP.DOM.Browser.isIPod){var t=$afe.jq(_dateChooser.trigger).parents(".Popup, ._Popup");t.length>0&&e.push(t[0])}return e}DateChooser.prototype.drawCalendar=function(e){e=void 0===e?null:e,_removeCalendar(!0),_dateChooser=this;var t,a,n,o=document.createElement("div");n=new Date,o.id="calendar",o.className="calendar",o.setAttribute("role","dialog"),o.setAttribute("aria-modal","true"),o.setAttribute("aria-labelledby","monthlabel"),this.lastDayOfMonth=new Date(this.year,this.month+1,0),this.lastDateOfMonth=this.lastDayOfMonth.getDate();var r=getFirstDayOfWeek(),s=this.lastDayOfMonth.getDay()-r;if(this.lastDisplayedDateId=s>=0?this.lastDateOfMonth-s+6:this.lastDateOfMonth-s+7,s=new Date(this.year,this.month,1).getDay()-r,this.firstDisplayedDateId=s>=0?1-s:-s-6,o.appendChild(this.getCalendarObject()),this.setClickFunction(o),positionCalendar(this.trigger,o),t=checkIfMobile(),a=checkIfPopup(),t){var d=document.createElement("div");d.className="calendarshield",d.setAttribute("tabindex","-1");var l=$afe.select("._PopupContainer");a&&l.length>0?document.getElementsByClassName("_PopupContainer")[0].appendChild(d):document.body.appendChild(d),$afe.select(".calendarshield").css({"z-index":o.style.zIndex-1})}var i=$afe.select(".currentselected");i.removeClass("currentselect"),this.calendar=o,WP.Events.addListener(document.body,"click",removeCalendar),WP.Events.addListener(document.body,"mouseover",restoreHi),$afe.jq(window).on("orientationchange resize",handleOrientationChange),null!=e?(e=e>this.lastDateOfMonth?this.lastDateOfMonth:e,document.getElementById("cal"+e).firstChild.focus()):0!==i.length?(document.getElementById(i[0].id).firstChild.focus(),this.focusOn=i[0].id):this.month===this.today.getMonth()&&this.year===this.today.getFullYear()&&document.getElementById("cal"+n.getDate())?(document.getElementById("cal"+this.date).firstChild.focus(),this.focusOn="cal"+this.date):document.getElementById("cal"+this.firstDate)&&(document.getElementById("cal"+this.firstDate).firstChild.focus(),this.focusOn="cal"+this.firstDate),WP.Events.addListener(document.getElementById("calprev"),"keydown",keyOnPrevMonth),WP.Events.addListener(document.getElementById("calnext"),"keydown",keyOnNextMonth),WP.Events.addListener(document.getElementById("calcancel"),"keydown",tabOnCancel),accessibilityHidePage(),this.firstDate="",this.lastDate="",t&&$$WP.Utilities.UI.ToggleBodyScrolling(!0),$afe.jq(window).on("orientationchange resize",handleOrientationChange)},DateChooser.prototype.clearCalendar=function(){_removeCalendar(),this.callback(),this.trigger.className=this.trigger.className.replace(" hidden",""),this.trigger.focus()},DateChooser.prototype.setClickFunction=function(e){var t,a,n,o=this.clickFunction,r=e.getElementsByTagName("td"),s=(new Date,document.all?"hand":"pointer"),enable=function(e){WP.Events.addListener(e,"click",o),"ctrl"===e.className?(WP.Events.addListener(e,"mouseover",hi()),WP.Events.addListener(e,"mouseout",lo),WP.Events.addListener(e,"mousedown",ctrlMouseDown),WP.Events.addListener(e.firstChild,"focus",ctrlFocus),WP.Events.addListener(e.firstChild,"blur",lo)):(WP.Events.addListener(e,"mouseover",(function(){e.firstChild.focus()})),WP.Events.addListener(e.firstChild,"focus",hi())),e.style.cursor=s},disable=function(e){e.style.cursor="default"};for(a=0;a<r.length;++a)"null"!==(n=(t=r[a]).className)&&"hdr"!==n&&t.firstChild&&("ctrl"===n?enable(t):n.indexOf("wkndn")>=0||0===n.indexOf("n")||n.indexOf("ctrln")>=0?disable(t):enable(t));WP.Events.addListener(e,"keydown",HandleKeyDown),WP.Events.addListener(e,"keyup",HandleKeyUp)},DateChooser.prototype.isDateDisplayed=function(e){return e>=this.firstDisplayedDateId&&e<=this.lastDisplayedDateId},DateChooser.prototype.drawNextMonth=function(e){if(e=void 0===e?null:e,this.clearCalendar(),this.month=(this.month+1)%12,0===this.month&&this.year++,this.drawCalendar(e),e){0!==(t=$afe.select(".currentselected")).length&&t[0].id!==_dateChooser.focusOn&&lo({target:document.getElementById(t[0].id),srcElement:document.getElementById(t[0].id)})}else{var t,a=document.getElementById("calnext");if(null!==a)if((a=a.firstChild)&&"BUTTON"===a.nodeName.toUpperCase())a.focus(),0!==(t=$afe.select(".currentselected")).length&&t[0].id===_dateChooser.focusOn||lo({target:document.getElementById(_dateChooser.focusOn),srcElement:document.getElementById(_dateChooser.focusOn)});document.getElementsByClassName("calendarwrapper")[0].scroll({top:0,left:0})}},DateChooser.prototype.drawPreviousMonth=function(e){if(e=void 0===e?null:e,this.clearCalendar(),this.month=this.month-1,this.month<0&&(this.month+=12),11===this.month&&this.year--,this.drawCalendar(e),e){0!==(t=$afe.select(".currentselected")).length&&t[0].id!==_dateChooser.focusOn&&lo({target:document.getElementById(t[0].id),srcElement:document.getElementById(t[0].id)})}else{var t,a=document.getElementById("calprev").firstChild;if(a&&"BUTTON"===a.nodeName.toUpperCase())a.focus(),0!==(t=$afe.select(".currentselected")).length&&t[0].id===_dateChooser.focusOn||lo({target:document.getElementById(_dateChooser.focusOn),srcElement:document.getElementById(_dateChooser.focusOn)});document.getElementsByClassName("calendarwrapper")[0].scroll({top:0,left:0})}},DateChooser.prototype.getCalendarObject=function(){var e,t,a,n,o,r=document.createElement("div"),s=document.createElement("tbody"),d=this.month,l=this.year,i=this.filter,c=new Date,h=c.getDate(),u=c.getMonth(),m=c.getFullYear(),p=WP.DOM.Create.tag,C=$$WP.Strings.get("CancelButton","UI.Calendar");r.className="calendarflexbox";var g=document.createElement("div");g.className="calendarwrapper";var y,v=buildNavHeaderObject(d,l);for(r.appendChild(v),e=document.createElement("table"),thead=document.createElement("thead"),t=document.createElement("tr"),o=0;o<7;o++)a=p("th","hdr","","",getDayLetter((o+getFirstDayOfWeek())%7)),$afe.jq(a).safeAttr("aria-hidden","true"),t.appendChild(a);thead.appendChild(t),e.appendChild(thead);for(var D,getClassName=function(e,t){var a,n,o=e.getMonth(),r=e.getDate(),s=e.getFullYear(),d=e.getDay();return a=0===d||6===d,n=o===u&&r===h&&s===m,(i(s,o,r)?a?"wknd":"d":a?"wkndn":"n")+(n?" today":"")+(t?" othermonth":"")},E=this.firstDisplayedDateId,P=new Date(l,d,E);P.getMonth()!==d+1&&P.getFullYear()<=l;){for(t=document.createElement("tr"),D=0;D<7;D++)y=P.getMonth()!==d,a=p("td",getClassName(P,y),"cal"+E),(n=p("button","","","",P.getDate())).setAttribute("aria-label",$$WP.I18N.getCalendarDateAriaString(P)),this.filter(P.getFullYear(),P.getMonth(),P.getDate())?(n.setAttribute("tabindex","0"),y||(this.firstDate&&""!==this.firstDate||(this.firstDate=P.getDate()),(!this.lastDate||this.lastDate<P.getDate())&&(this.lastDate=P.getDate()))):(n.setAttribute("tabindex","-1"),n.setAttribute("aria-disabled","true"),n.style.cursor="default"),a.appendChild(n),P.getTime()===_dateChooser.today.getTime()&&(applyClass(a,"currentselected"),applyClass(a,"hi")),t.appendChild(a),P.setDate(P.getDate()+1),E++;s.appendChild(t)}e.appendChild(s),g.appendChild(e),r.appendChild(g);var I=p("div");return e=p("table","calendarfooter",""),s=p("tbody"),t=document.createElement("tr"),a=p("td","ctrl","calcancel"),n=p("button","","","",C),a.appendChild(n),t.appendChild(a),s.appendChild(t),e.appendChild(s),I.appendChild(e),r.appendChild(I),e.setAttribute("role","presentation"),t.firstChild.colSpan=7,r},$$WP.Utilities.UI.Calendars=function $$WP$Utilities$UI$Calendars(e){"load"===e.type&&$afe.select("input.date.withCalendar").each((function(){var e=$afe.jq(this);e.next().is("button.datechooserAnchor")||writeCalendar(e,e.safeAttr("data-filter"),makeStaticLink("images/calendar.svg"),e.safeAttr("data-filter-from"),e.safeAttr("data-filter-to"),e.safeAttr("data-callback"),void 0,void 0,"Pears")}))},$$WP.Utilities.UI.Map.Support.calendars=$$WP.Utilities.UI.Calendars;