var __extends=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}}(),__assign=this&&this.__assign||Object.assign||function(t){for(var e,n=1,i=arguments.length;n<i;n++){e=arguments[n];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s])}return t};Array.prototype.equals||(Array.prototype.equals=function(t){if(!t||this.length!==t.length)return!1;for(var e=0,n=this.length;e<n;e++)if(this[e]instanceof Array&&t[e]instanceof Array){if(!this[e].equals(t[e]))return!1}else if(this[e]!==t[e])return!1;return!0},Object.defineProperty(Array.prototype,"equals",{enumerable:!1})),$.Event.prototype.stopPropagationAndPreventDefault||($.Event.prototype.stopPropagationAndPreventDefault=function(){this.stopPropagation(),this.preventDefault()}),$.fn.visible||($.fn.visible=function(t){var e=this,n=this.data("visible-interval");return this.is(":visible")?t():(this.one("visible",t),n||(n=setInterval(function(){e.is(":visible")&&(clearInterval(n),e.data("visible-interval",n=null),e.trigger("visible"))},300),this.data("visible-interval",n))),this}),$.fn.input||($.fn.input=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return t.unshift("input"),this.on.apply(this,t)}),String.prototype.startsWith||(String.prototype.startsWith=function(t,e){return this.substr(e||0,t.length)===t}),String.prototype.endsWith||(String.prototype.endsWith=function(t,e){var n=this.toString();("number"!=typeof e||!isFinite(e)||Math.floor(e)!==e||e>n.length)&&(e=n.length),e-=t.length;var i=n.indexOf(t,e);return-1!==i&&i===e}),String.prototype.padStart||(String.prototype.padStart=function(t,e){return t>>=0,e=String(e||" "),this.length>t?String(this):((t-=this.length)>e.length&&(e+=e.repeat(t/e.length)),e.slice(0,t)+String(this))}),String.prototype.padEnd||(String.prototype.padEnd=function(t,e){return t>>=0,e=String(e||" "),this.length>t?String(this):((t-=this.length)>e.length&&(e+=e.repeat(t/e.length)),String(this)+e.slice(0,t))}),String.prototype.repeat||(String.prototype.repeat=function(t){var e=""+this;if((t=+t)<0)throw new RangeError("Repeat count must be non-negative.");if(t===1/0)throw new RangeError("Repeat count must be less than infinity.");if(t=Math.floor(t),0===e.length||0===t)return"";if(e.length*t>=1<<28)throw new RangeError("Repeat count must not overflow maximum string size.");for(var n="";1==(1&t)&&(n+=e),0!==(t>>>=1);)e+=e;return n});var DotVVM;!function(t){!function(t){!function(t){t[t.Red=0]="Red",t[t.Green=1]="Green",t[t.Blue=2]="Blue",t[t.Alpha=3]="Alpha"}(t.RgbaChannel||(t.RgbaChannel={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){"use strict";var e=function(){function t(){}return t.dotvvmBpControl="dotvvm-bp-control",t.dotvvmBpAlert="dotvvm-bp-alert",t.dotvvmBpAutoComplete="dotvvm-bp-auto-complete",t.dotvvmBpButton="dotvvm-bp-button",t.dotvvmBpCarousel="dotvvm-bp-carousel",t.dotvvmBpCheckBox="dotvvm-bp-check-box",t.dotvvmBpCheckBoxList="dotvvm-bp-check-box-list",t.dotvvmBpColorPicker="dotvvm-bp-color-picker",t.dotvvmBpComboBox="dotvvm-bp-combo-box",t.dotvvmBpDataPager="dotvvm-bp-data-pager",t.dotvvmBpDateTimePicker="dotvvm-bp-date-time-picker",t.dotvvmBpDateTimeRangePicker="dotvvm-bp-date-time-range-picker",t.dotvvmBpDialog="dotvvm-bp-dialog",t.dotvvmBpDraggableList="dotvvm-bp-draggable-list",t.dotvvmBpDropDownList="dotvvm-bp-drop-down-list",t.dotvvmBpEditableLiteral="dotvvm-bp-editable-literal",t.dotvvmBpFileUpload="dotvvm-bp-file-upload",t.dotvvmBpFilterBuilder="dotvvm-bp-filter-builder",t.dotvvmBpGridView="dotvvm-bp-grid-view",t.dotvvmBpGridViewUserSettingsEditor="dotvvm-bp-grid-view-user-settings-editor",t.dotvvmBpImageCrop="dotvvm-bp-image-crop",t.dotvvmBpListView="dotvvm-bp-list-view",t.dotvvmBpMaskedTextBox="dotvvm-bp-masked-text-box",t.dotvvmBpModalDialog="dotvvm-bp-modal-dialog",t.dotvvmBpMultiSelect="dotvvm-bp-multi-select",t.dotvvmBpNumericUpDown="dotvvm-bp-numeric-up-down",t.dotvvmBpPanel="dotvvm-bp-panel",t.dotvvmBpRadioButton="dotvvm-bp-radio-button",t.dotvvmBpRadioButtonList="dotvvm-bp-radio-button-list",t.dotvvmBpRangeSlider="dotvvm-bp-range-slider",t.dotvvmBpRating="dotvvm-bp-rating",t.dotvvmBpRichTextBox="dotvvm-bp-rich-text-box",t.dotvvmBpSlider="dotvvm-bp-slider",t.dotvvmBpTabControl="dotvvm-bp-tab-control",t.dotvvmBpTextBox="dotvvm-bp-text-box",t.dotvvmBpTreeView="dotvvm-bp-tree-view",t.dotvvmBpWindow="dotvvm-bp-window",t.dotvvmBpCalendar="dotvvm-bp-calendar",t.dotvvmBpRangeCalendar="dotvvm-bp-range-calendar",t.bpAllowCustom="bp-allow-custom",t.bpAllowUnselect="bp-allow-unselect",t.bpAnimated="bp-animated",t.bpAutoFocus="bp-auto-focus",t.bpDismissible="bp-dismissible",t.bpHasList="bp-has-list",t.bpExpandable="bp-expandable",t.bpRounded="bp-rounded",t.bpStateActive="bp-state-active",t.bpStateBusy="bp-state-busy",t.bpStateChecked="bp-state-checked",t.bpStateDisabled="bp-state-disabled",t.bpStateDragover="bp-state-dragover",t.bpStateEmptyData="bp-state-empty-data",t.bpStateEmptyValue="bp-state-empty-value",t.bpStateError="bp-state-error",t.bpStateExpanded="bp-state-expanded",t.bpStateFocused="bp-state-focused",t.bpStateIndeterminate="bp-state-indeterminate",t.bpStateLoading="bp-state-loading",t.bpStateMoving="bp-state-moving",t.bpStateOpened="bp-state-opened",t.bpStatePartiallyDisabled="bp-state-partially-disabled",t.bpStateResizing="bp-state-resizing",t.bpStateSelected="bp-state-selected",t.bpStateSelectionEnd="bp-state-selection-end",t.bpStateSelectionStart="bp-state-selection-start",t.bpButton="bp-button",t.bpButtonGroup="bp-button-group",t.bpBottom="bp-bottom",t.bpClearFix="bp-clear-fix",t.bpColorPreview="bp-color-preview",t.bpContainer="bp-container",t.bpContents="bp-contents",t.bpCropCanvas="bp-crop-canvas",t.bpDay="bp-day",t.bpDropDown="bp-drop-down",t.bpDropZone="bp-drop-zone",t.bpPlaceholder="bp-placeholder",t.bpErrorMessage="bp-error-message",t.bpFooter="bp-footer",t.bpFixed="bp-fixed",t.bpGrip="bp-grip",t.bpGripE="bp-grip-e",t.bpGripN="bp-grip-n",t.bpGripNE="bp-grip-ne",t.bpGripNW="bp-grip-nw",t.bpGripS="bp-grip-s",t.bpGripSE="bp-grip-se",t.bpGripSW="bp-grip-sw",t.bpGripW="bp-grip-w",t.bpHalf="bp-half",t.bpHeader="bp-header",t.bpCheckBox="bp-check-box",t.bpCheckerboard="bp-checkerboard",t.bpIcon="bp-icon",t.bpImageCanvas="bp-image-canvas",t.bpInput="bp-input",t.bpInputGroup="bp-input-group",t.bpItem="bp-item",t.bpLabel="bp-label",t.bpLeft="bp-left",t.bpList="bp-list",t.bpMax="bp-max",t.bpMiddle="bp-middle",t.bpMin="bp-min",t.bpMonth="bp-month",t.bpNav="bp-nav",t.bpNavItem="bp-nav-item",t.bpOverflowHidden="bp-overflow-hidden",t.bpOverlay="bp-overlay",t.bpPoint="bp-point",t.bpPopup="bp-popup",t.bpProgressBar="bp-progress-bar",t.bpRadioButton="bp-radio-button",t.bpRight="bp-right",t.bpRow="bp-row",t.bpSelectionBox="bp-selection-box",t.bpSeparator="bp-separator",t.bpSwitch="bp-switch",t.bpTable="bp-table",t.bpTextArea="bp-text-area",t.bpTextBox="bp-text-box",t.bpThird="bp-third",t.bpTile="bp-tile",t.bpToolbar="bp-toolbar",t.bpTop="bp-top",t.bpUserControls="bp-user-controls",t.bpValue="bp-value",t.bpWeekend="bp-weekend",t.bpWrapper="bp-wrapper",t.bpYear="bp-year",t.bpAdd="bp-add",t.bpAddCondition="bp-add-condition",t.bpAddGroup="bp-add-group",t.bpClose="bp-close",t.bpCollapse="bp-collapse",t.bpDecrease="bp-decrease",t.bpDelete="bp-delete",t.bpExpand="bp-expand",t.bpIncrease="bp-increase",t.bpMaximize="bp-maximize",t.bpNext="bp-next",t.bpOpen="bp-open",t.bpPrev="bp-prev",t.bpReset="bp-reset",t.bpRotateLeft="bp-rotate-left",t.bpRotateRight="bp-rotate-right",t.bpToggle="bp-toggle",t.bpUnselect="bp-unselect",t.bpZoomIn="bp-zoom-in",t.bpZoomOut="bp-zoom-out",t.bpAlertTypePrefix="bp-alert-",t.bpAlertTypeIcon="bp-alert-type-icon",t.bpButtonTypePrefix="bp-button-",t.bpColorSpectrum="bp-color-spectrum",t.bpHueSlider="bp-hue-slider",t.bpAlphaSlider="bp-alpha-slider",t.bpColorEditor="bp-color-editor",t.bpHexColorEditor="bp-hex-color-editor",t.bpRgbColorEditor="bp-rgb-color-editor",t.bpRgbaColorEditor="bp-rgba-color-editor",t.bpRedChannelEditor="bp-red-channel-editor",t.bpGreenChannelEditor="bp-green-channel-editor",t.bpBlueChannelEditor="bp-blue-channel-editor",t.bpAlphaChannelEditor="bp-alpha-channel-editor",t.bpColorPalette="bp-color-palette",t.bpPredefinedColors="bp-predefined-colors",t.bpCalendar="bp-calendar",t.bpCalendarMain="bp-calendar-main",t.bpCalendarSide="bp-calendar-side",t.bpCalendarSideUpperRow="bp-calendar-side-upper-row",t.bpCalendarSelector="bp-calendar-selector",t.bpCalendarSelectorEnd="bp-calendar-selector-end",t.bpCalendarSelectorStart="bp-calendar-selector-start",t.bpDateSelector="bp-date-selector",t.bpYearSelector="bp-year-selector",t.bpMonthSelector="bp-month-selector",t.bpHourSelector="bp-hour-selector",t.bpMinuteSelector="bp-minute-selector",t.bpOtherMonth="bp-other-month",t.bpSelectFiles="bp-select-files",t.bpUploadedFiles="bp-uploaded-files",t.bpFilterGroup="bp-filter-group",t.bpFilterLogic="bp-filter-logic",t.bpStyleDropDown="bp-style-dropdown",t}();t.BusinessPackCss=e}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){"use strict";var e=function(){function t(){}return t.left=1,t.middle=2,t.right=3,t}();t.MouseButtons=e}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){"use strict";var e=function(){function t(){}return t.isWhiteSpace=function(e){return e===t.spacebar||t.isEnter(e)},t.isUpOrDown=function(e){return e===t.up||e===t.down},t.isLeftOrRight=function(e){return e===t.left||e===t.right},t.isArrow=function(t){return this.isUpOrDown(t)||this.isLeftOrRight(t)},t.isEnter=function(e){return e===t.enter||e===t.numpadEnter},t.isDeleteOrBackspace=function(t){return this.isBackspace(t)||this.isDelete(t)},t.isBackspace=function(e){return e===t.backspace},t.isDelete=function(e){return e===t.delete},t.a=65,t.b=66,t.c=67,t.d=68,t.e=69,t.f=70,t.g=71,t.h=72,t.i=73,t.j=74,t.k=75,t.l=76,t.m=77,t.n=78,t.o=79,t.p=80,t.q=81,t.r=82,t.s=83,t.t=84,t.u=85,t.v=86,t.w=87,t.x=88,t.y=89,t.z=90,t.num0=48,t.num1=49,t.num2=50,t.num3=51,t.num4=52,t.num5=53,t.num6=54,t.num7=55,t.num8=56,t.num9=57,t.numpadZero=96,t.numpadOne=97,t.numpadTwo=98,t.numpadThree=99,t.numpadFour=100,t.numpadFive=101,t.numpadSix=102,t.numpadSeven=103,t.numpadEight=104,t.numpadNine=105,t.numpadMultiply=106,t.numpadAdd=107,t.numpadEnter=108,t.numpadSubtract=109,t.numpadDecimal=110,t.numpadDivide=111,t.f1=112,t.f2=113,t.f3=114,t.f4=115,t.f5=116,t.f6=117,t.f7=118,t.f8=119,t.f9=120,t.f10=121,t.f11=122,t.f12=123,t.f13=124,t.f14=125,t.f15=126,t.colon=186,t.equals=187,t.underscore=189,t.questionMark=191,t.tilde=192,t.openBracket=219,t.backwardSlash=220,t.closeBracket=221,t.quotes=222,t.lessThan=188,t.greaterThan=190,t.backspace=8,t.tab=9,t.clear=12,t.enter=13,t.shift=16,t.control=17,t.alt=18,t.capsLock=20,t.esc=27,t.spacebar=32,t.pageUp=33,t.pageDown=34,t.end=35,t.home=36,t.left=37,t.up=38,t.right=39,t.down=40,t.insert=45,t.delete=46,t.help=47,t.numLock=144,t}();t.KeyboardKeys=e}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){"use strict";var e=function(){function t(){}return Object.defineProperty(t,"isIe",{get:function(){return"Microsoft Internet Explorer"===navigator.appName||!!/\bTrident\b/.test(this.userAgent)},enumerable:!0,configurable:!0}),Object.defineProperty(t,"isEdge",{get:function(){return/webkit\W.*(edge)\W/i.test(this.userAgent)},enumerable:!0,configurable:!0}),Object.defineProperty(t,"isChrome",{get:function(){return/webkit\W.*(chrome|chromium)\W/i.test(this.userAgent)},enumerable:!0,configurable:!0}),Object.defineProperty(t,"isGecko",{get:function(){return/mozilla(?!.*webkit).*\Wgecko\W/i.test(this.userAgent)},enumerable:!0,configurable:!0}),Object.defineProperty(t,"isFirefox",{get:function(){return/mozilla.*\Wfirefox\W/i.test(this.userAgent)},enumerable:!0,configurable:!0}),Object.defineProperty(t,"isSafari",{get:function(){return/webkit\W(?!.*chrome).*safari\W/i.test(this.userAgent)},enumerable:!0,configurable:!0}),t.userAgent=window.navigator&&navigator.userAgent||"",t}();t.Browser=e}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){var e=function(){function t(t){void 0===t&&(t=[]),this.a=t,Object.defineProperty(this,"a",{value:t,writable:!1})}return t.prototype.aggregate=function(t){var e,n;if(0===(e=this.a).length)throw"Aggregate of empty array";n=e[0];for(var i=1,s=e.length;i<s;++i)n=t(n,e[i]);return n},t.prototype.all=function(t){for(var e=this.a,n=0,i=e.length;n<i;++n)if(!t(e[n]))return!1;return!0},t.prototype.any=function(t){var e=this.a;if(!t)return e.length>0;for(var n=0,i=e.length;n<i;++n)if(t(e[n]))return!0;return!1},t.prototype.average=function(t){var e=this.a;t=t||function(t){return t};for(var n=0,i=e.length,s=0;s<i;++s)n+=t(e[s]);return n/i},t.prototype.concat=function(e){return new t(this.a.concat(e))},t.prototype.contains=function(t,e){return e?this.any(function(n){return e.equals(n,t)}):this.any(function(e){return e===t})},t.prototype.count=function(t){return t?this.where(t).count():this.a.length},t.prototype.distinct=function(t){return this.distinctBy(function(t){return t},t)},t.prototype.distinctBy=function(e,n){for(var i,s=this.a,o=[],r=[],a=0,l=s.length;a<l;++a){var u=e(i=s[a]);o.asLinq().contains(u,n)||(o.push(u),r.push(i))}return new t(r)},t.prototype.elementAt=function(t){if(t<0||t>=this.a.length)throw"Index was out of range. Must be non-negative and less than the size of the collection.";return this.a[t]},t.prototype.elementAtOrDefault=function(t,e){return void 0===e&&(e=null),t>=this.a.length||t<0?e:this.a[t]},t.prototype.except=function(e,n){for(var i,s=this.a,o=[],r={},a=n?n.getHashCode:function(t){return Object.getHashCode(t)},l=0,u=e.length;l<u;++l)r[a(e[l])]=1;for(var l=0,u=s.length;l<u;++l)r[a(i=s[l])]||o.push(i);return new t(o)},t.prototype.first=function(t){if(0===this.a.length)throw"Enumeration does not contain elements";if(!t)return this.a[0];var e=this.where(t);if(0===e.count())throw"Enumeration does not contain elements";return e.elementAt(0)},t.prototype.firstOrDefault=function(t,e){return void 0===e&&(e=null),t?this.where(t).elementAtOrDefault(0,e):this.a.length>0?this.a[0]:e},t.prototype.forEach=function(t){for(var e=this.a,n=0,i=e.length;n<i&&!1!==t(e[n],n);++n);},t.prototype.groupBy=function(e,n,i){n=n||function(t){return t},i=i||{equals:function(t,e){return t==e},getHashCode:function(t){return Object.getHashCode(t)}};for(var s,o,r,a=this.a,l={},u=0,c=a.length;u<c;++u)r=void 0,s=e(a[u]),void 0!==l[o=i.getHashCode(s)]&&(r=i.equals(s,l[o].key)?o:o+u),void 0!==r&&r!==o&&(o=r),l[o]=l[o]||{Key:s,Elements:[]},l[o].elements.push(n(a[u]));for(var h=Object.keys(l),p=[],u=0,c=h.length;u<c;++u)p.push(l[h[u]]);return new t(p)},t.prototype.indexOf=function(t,e){var n=this.a;if(e)for(var i=0,s=n.length;i<s;++i){var o=n[i];if(e.equals(o,t))return i}else for(var i=0,s=n.length;i<s;++i)if(n[i]===t)return i;return-1},t.prototype.intersect=function(e,n){for(var i=[],s=0,o=e.length;s<o;++s)this.contains(e[s],n)&&i.push(e[s]);return new t(i)},t.prototype.join=function(e,n,i,s,o){for(var r=[],a=this.select(n),l=e.asLinq().select(i),u=0,c=a.count();u<c;++u){var h=a.elementAt(u),p=-1;if(-1!=(p=l.indexOf(h,o))){var d=l.elementAt(p);r.push(s(h,d))}}return new t(r)},t.prototype.last=function(t){if(0===this.a.length)throw"Enumeration does not contain elements";if(!t)return this.a[this.a.length-1];var e=this.where(t);if(0===e.count())throw"Enumeration does not contain elements";return e.last()},t.prototype.lastOrDefault=function(t,e){if(void 0===e&&(e=null),0===this.a.length)return e;if(!t)return this.a[this.a.length-1];var n=this.where(t);return 0===n.count()?e:n.lastOrDefault(null,e)},t.prototype.max=function(t){var e=this.a;if(0===e.length)throw"Sequence contains no elements.";for(var n=(t=t||function(t){return t})(e[0]),i=0,s=e.length;i<s;++i){var o=t(e[i]);o>n&&(n=o)}return n},t.prototype.min=function(t){var e=this.a;if(0===e.length)throw"Sequence contains no elements.";for(var n=(t=t||function(t){return t})(e[0]),i=0,s=e.length;i<s;++i){var o=t(e[i]);o<n&&(n=o)}return n},t.prototype.orderBy=function(t,e){return e=e||function(t,e){return t>e?1:-1},this.a.sort(function(n,i){return e(t(n),t(i))}),this},t.prototype.orderByDescending=function(t,e){return e=e||function(t,e){return t>e?1:-1},e=function(t){return function(e,n){return-t(e,n)}}(e),this.a.sort(function(n,i){return e(t(n),t(i))}),this},t.prototype.reverse=function(){for(var t=this.a.length-1,e=0;e<t;++e,--t){var n=this.a[e];this.a[e]=this.a[t],this.a[t]=n}return this},t.prototype.select=function(e){for(var n=this.a,i=[],s=0,o=n.length;s<o;++s)i.push(e(n[s],s));return new t(i)},t.prototype.selectMany=function(t,e){for(var n=this.a,i=[],s=0,o=n.length;s<o;++s)i=i.concat(t(n[s]));return e?i.asLinq().select(e):i.asLinq()},t.prototype.sequenceEqual=function(t,e){var n=this.a;if(void 0===n||void 0===t)throw"Do not pass null values to arrays.";if(n===t)return!0;if(n.length!==t.length)return!1;if(e){for(var i=0,s=n.length;i<s;i++)if(!e(n[i],t[i]))return!1}else for(var i=0,s=n.length;i<s;i++)if(n[i]!==t[i])return!1;return!0},t.prototype.single=function(t){var e=this.a;if(!t){if(1!=e.length)throw"Source has none or more than one element";return e[0]}for(var n=null,i=0,s=e.length;i<s;++i)if(t(e[i])){if(null!=n)throw"Source has more than one element";n=e[i]}return n},t.prototype.singleOrDefault=function(t,e){void 0===e&&(e=null);var n=this.a;if(!t)return 1!=n.length?e:n[0];for(var i=null,s=0,o=n.length;s<o;++s)if(t(n[s])){if(null!=i)return e;i=n[s]}return i},t.prototype.skip=function(e){return new t(this.a.slice(e))},t.prototype.skipWhile=function(e){for(var n=this.a,i=0,s=n.length;i<s&&!1!==e(n[i]);++i);return new t(n.slice(i))},t.prototype.sum=function(t){var e=this.a,n=0;if(t)for(var i=0,s=e.length;i<s;++i)n+=t(e[i]);else for(var i=0,s=e.length;i<s;++i)n+=e[i];return n},t.prototype.take=function(e){for(var n=this.a,i=[],s=e>(s=n.length)?s:e,o=0;o<s;++o)i.push(n[o]);return new t(i)},t.prototype.takeWhile=function(e){for(var n,i=this.a,s=[],o=0,r=i.length;o<r&&(n=i[o],e(n));++o)s.push(n);return new t(s)},t.prototype.union=function(e,n){for(var i,s,o=this.a,r=[],a={},l=n?n.getHashCode:function(t){return Object.getHashCode(t)},u=0,c=o.length;u<c;++u)a[s=l(i=o[u])]||(a[s]=i,r.push(i));for(var u=0,c=e.length;u<c;++u)a[s=l(i=e[u])]||(a[s]=i,r.push(i));return new t(r)},t.prototype.where=function(e){for(var n,i=this.a,s=[],o=0,r=i.length;o<r;++o)e(n=i[o])&&s.push(n);return new t(s)},t.prototype.zip=function(e,n){for(var i=this.a,s=[],o=0,r=i.length>e.length?e.length:i.length;o<r;++o)s.push(n(i[o],e[o]));return new t(s)},t.prototype.toArray=function(){return this.a},t}();t.Linq=e}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={})),Array.prototype.asLinq=function(){return new DotVVM.BusinessPack.Linq(this)},Object.getHashCode=function(t){if(t instanceof Number)return Number.getHashCode(t);var e=t instanceof Object?JSON.stringifyNonCircular(t):t.toString(),n=0;if(0===e.length)return n;for(var i=0;i<e.length;++i)n=(n<<5)-n+e.charCodeAt(i);return n},Number.getHashCode=function(t){return t.valueOf()},Object.isPlain=function(t){return!("object"!=typeof t||t.nodeType||t instanceof Window||t.constructor&&!{}.hasOwnProperty.call(t.constructor.prototype,"isPrototypeOf"))},JSON.stringifyNonCircular=function(t){var e=e||"";for(var n in t){var i=t[n];i&&(i instanceof Array||i.IsPlain())?e+=n+":"+JSON.stringify(i):e+=i&&"object"==typeof i?n+":$ref#"+i:n+":"+i}return e};var DotVVM;!function(DotVVM){var BusinessPack;!function(BusinessPack){var Utils=function(){function Utils(){}return Object.defineProperty(Utils,"isDebugModeEnabled",{get:function(){return!!dotvvm.resourceSigns["dotvvm.debug"]},enumerable:!0,configurable:!0}),Utils.warnInDebugMode=function(t){this.isDebugModeEnabled&&console.warn(t+"\nTHIS WARNING IS DISPLAYED ONLY IN DEBUG MODE")},Utils.installBindingHandler=function(t,e){ko.bindingHandlers["dotvvm-businesspack-"+t]={init:function(n,i,s,o,r){var a=$(n),l=Utils.getExtendedBinding(a,i,s),u=new e(a,l,s,r),c={};return c.$bpControl=u,a.data(t,u),u.initialize(),ko.applyBindingsToDescendants(r.extend(c),n),ko.utils.domNodeDisposal.addDisposeCallback(n,function(){return u.dispose()}),{controlsDescendantBindings:!0}},preprocess:function(t){return t.replace(/: *dotvvm\.evaluator\.tryEval\(/g,": DotVVM.BusinessPack.Utils.observableTryEval(")}}},Utils.getExtendedBinding=function(t,e,n){var i=ko.unwrap(e());if(i.visible=n.get("visible"),null==i.tabIndex){var s=Number(t.attr("tabindex"));i.tabIndex=isNaN(s)?null:s}return i},Utils.bindDragEvents=function(t,e,n){var i,s,o=function(){+new Date-+s>100&&(n(),clearInterval(i),i=null)};t.on("dragenter",function(t){e(t),s=new Date,i||(i=setInterval(o,100))}).on("dragover",function(){return s=new Date})},Utils.isObservableArray=function(t){return ko.isComputed(t)?Array.isArray(t.peek()):!!ko.isObservable(t)&&"push"in t},Utils.deepCopy=function(t){var e,n=ko.unwrap(t);if(null===n||void 0===n)return n;if(Array.isArray(n)){e=[];for(var i=0;i<n.length;i++)e[i]=Utils.deepCopy(n[i])}else if("object"==typeof n){e={};for(var s in n)n.hasOwnProperty(s)&&(e[s]=Utils.deepCopy(n[s]))}else e=n;return Utils.isObservableArray(t)?ko.observableArray(e):ko.isObservable(t)?ko.observable(e):e},Utils.deepObservable=function(t){var e=ko.toJS(t);if(null===e||void 0===e)return e;if(Array.isArray(e)){for(var n=0;n<e.length;n++)e[n]=Utils.deepObservable(e[n]);return ko.observableArray(e)}if("object"==typeof e)for(var i in e)e.hasOwnProperty(i)&&(e[i]=Utils.deepObservable(e[i]));return ko.observable(e)},Utils.observableTryEval=function(t){var e,n=this,i=!1,s=!1,o=function(){var e=t();return ko.computed(e)&&"wrappedProperty"in e&&(e=e.wrappedProperty()),e};try{var r=o();i=ko.isWriteableObservable(r),s=this.isObservableArray(r)}catch(t){}if(i){if(e=ko.pureComputed({read:function(){return ko.unwrap(dotvvm.evaluator.tryEval(t))},write:function(e){var n=null,i=null;try{n=o()}catch(e){console.warn("Error '"+e+"' occured while evaluating "+t+"."),i=e}if(!ko.isWriteableObservable(n)){if(i)throw Error("Cannot write a value to ko.computed because the error '"+i+"' occured while evaluating "+t+".");throw Error("Cannot write a value to ko.computed because the expression '"+t+"' does not return an observable.")}n(e)}}),s){var a=function(e,i){var s=null,r=null;try{s=o()}catch(e){console.warn("Error '"+e+"' occured while evaluating "+t+"."),r=e}if(!n.isObservableArray(s)){if(r)throw Error("Cannot push a value to ko.computed because the error '"+r+"' occured while evaluating "+t+".");throw Error("Cannot push a value to ko.computed because the '"+t+"' does not return an observable array.")}s[e].apply(s,i)};e.push=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return a("push",t)},e.remove=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return a("remove",t)},e.pop=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return a("pop",t)},e=e.extend({trackArrayChanges:!0})}}else e=ko.pureComputed({read:function(){return ko.unwrap(dotvvm.evaluator.tryEval(t))}});return e&&(e=e.extend({notify:"always"})),e},Utils.clearObservableArray=function(t){t&&t().length&&t.removeAll()},Utils.ensureObservable=function(t){return ko.isObservable(t)?t:t?ko.observable(t):ko.observable()},Utils.ensureObservableArray=function(t){return ko.isObservable(t)?t:t?ko.observableArray(t):ko.observableArray()},Utils.isDataAccessor=function(t){return"$data"===t},Utils.isPropertyAccessor=function(t){for(var e=0,n=[".","(",")","[","]",";"];e<n.length;e++){var i=n[e];if(t.indexOf(i)>-1)return!1}return!0},Utils.getUnwrappedBindingValue=function(data,bindingExpression){if(null==data)throw Error("The binding value can't be resolved for null or undefined.");return eval("(function ($data) { var $rawData = $data; with(ko.unwrap($rawData)) { return ko.unwrap("+bindingExpression+"); } })")(data)},Utils.getBindingValue=function(data,bindingExpression){if(null==data)throw Error("The binding value can't be resolved for null or undefined.");return eval("(function ($data) { var $rawData = $data; with(ko.unwrap($rawData)) { return ("+bindingExpression+"); } })")(data)},Utils.getDataSourceItems=function(t){if(this.isObservableArray(t))return t;var e=ko.unwrap(t);return e&&e.Items?e.Items:ko.observableArray()},Utils.concatMany=function(t){for(var e=[],n=0,i=t;n<i.length;n++){var s=i[n];e=e.concat(s)}return e},Utils.pushAll=function(t,e){ko.utils.arrayPushAll(t,e)},Utils.htmlEncode=function(t){return $("<div/>").text(t).html()},Utils.normalizeSpaces=function(t){return t?t.replace(new RegExp(this.nonBreakingSpace,"g")," ").replace(new RegExp(Utils.zeroWidthSpace,"g"),""):t},Utils.createGuid=function(t){void 0===t&&(t=!0);for(var e="",n=0;n<32;n++){var i=16*Math.random()|0;!t||8!==n&&12!==n&&16!==n&&20!==n||(e+="-"),e+=(12===n?4:16===n?3&i|8:i).toString(16)}return e},Utils.convertTouchToMouseEvent=function(t){var e=t.type;switch(e){case"touchstart":e="mousedown";break;case"touchmove":e="mousemove";break;case"touchend":e="mouseup";break;case"mousedown":case"mousemove":case"mouseup":return t;default:return this.warnInDebugMode("The '"+e+"' event is not a supported touch event."),null}var n=t.originalEvent;if(n.touches.length>1)return this.warnInDebugMode("Multi touch events are not supported."),null;var i=n.changedTouches[0],s=$.Event(e,{altKey:n.altKey,ctrlKey:n.ctrlKey,metaKey:n.metaKey,shiftKey:n.shiftKey,clientX:i.clientX,clientY:i.clientY,bubbles:t.bubbles,cancelable:t.cancelable,screenX:i.screenX,screenY:i.screenY});return s.originalEvent=t,s},Utils.closeOnOutsideClick=function(t,e){$(document).mouseup(function(n){var i=t;i.is(n.target)||0!==i.has(n.target).length||e(t,n)})},Utils.zeroWidthSpace=String.fromCharCode(65279),Utils.nonBreakingSpace=String.fromCharCode(160),Utils}();BusinessPack.Utils=Utils}(BusinessPack=DotVVM.BusinessPack||(DotVVM.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){"use strict";var e=function(){function t(){}return t.compare=function(t,e){if(0===t.length)return e.length;if(0===e.length)return t.length;t.length>e.length&&(t=(a=[e,t])[0],e=a[1]);for(var n=new Array(t.length+1),i=0;i<=t.length;i++)n[i]=i;for(i=1;i<=e.length;i++){for(var s=i,o=void 0,r=1;r<=t.length;r++)o=e[i-1]===t[r-1]?n[r-1]:Math.min(n[r-1]+1,Math.min(s+1,n[r]+1)),n[r-1]=s,s=o;n[t.length]=s}return n[t.length];var a},t}();t.Levenshtein=e}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){"use strict";var e=function(){function t(){}return t.urlOrEmail=function(t){return new RegExp("(\\b(?:(?:https?://|www\\.)[^/ -\\.]{1}[^\\s\\(\\)\\<\\>]+)\\b(?:[^\\.\\,)]??[/]*))(?=[\\s]*)|(@??\\b[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\b)",t)},t.twoLineBreaks=function(t){return new RegExp("(?:\\r\\n){2}|\\n\\n",t)},t.lineBreak=function(t){return new RegExp("(\\n|\\r\\n)",t)},t.hex8Color=function(t){return new RegExp("^#?([A-Fa-f0-9]{3}|[A-Fa-f0-9]{4}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{8})$",t)},t.hex6Color=function(t){return new RegExp("^#?([A-Fa-f0-9]{3}|[A-Fa-f0-9]{6})$",t)},t.mimeTypeSecondPart=function(t){return new RegExp("/.*$",t)},t.wildcardMimeType=function(t){return new RegExp("/*$",t)},t.getLastMatch=function(t,e,n){for(var i,s=[];i=t.exec(e);)s.push(i);if(s.length){if(n>=0)for(;i=s.pop();)if(i.index<n)return i;return s.pop()}return null},t}();t.RegexUtils=e}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){"use strict";var e=function(){function e(){}return e.createRgbaColor=function(t,e,n,i){return void 0===i&&(i=1),{Red:ko.observable(Math.round(t)),Green:ko.observable(Math.round(e)),Blue:ko.observable(Math.round(n)),Alpha:ko.observable(i)}},e.createHsvaColor=function(t,e,n,i){return void 0===i&&(i=1),{Hue:ko.observable(t),Saturation:ko.observable(e),Value:ko.observable(n),Alpha:ko.observable(i)}},e.areRgbaColorsEqual=function(t,e){return null==t&&null==e||!(!t||!e)&&(t.Red()===e.Red()&&t.Green()===e.Green()&&t.Blue()===e.Blue()&&t.Alpha()===e.Alpha())},e.rgbaToCssColor=function(t){return t?t.Alpha()<1?"rgba("+t.Red()+", "+t.Green()+", "+t.Blue()+", "+t.Alpha()+")":this.rgbaToHexColor(t):"none"},e.updateHueOfRgba=function(t,e){var n=this.rgbaToHsvaColor(t);return n=this.createHsvaColor(e,n.Saturation(),n.Value(),n.Alpha()),this.hsvaToRgbaColor(n)},e.updateChannelOfRgba=function(e,n,i){switch(n){case t.RgbaChannel.Red:return this.createRgbaColor(i,e.Green(),e.Blue(),e.Alpha());case t.RgbaChannel.Green:return this.createRgbaColor(e.Red(),i,e.Blue(),e.Alpha());case t.RgbaChannel.Blue:return this.createRgbaColor(e.Red(),e.Green(),i,e.Alpha());default:return this.createRgbaColor(e.Red(),e.Green(),e.Blue(),i)}},e.rgbaToHsvaColor=function(t){var e,n=t.Red()/255,i=t.Green()/255,s=t.Blue()/255,o=t.Alpha(),r=Math.max(n,i,s),a=Math.min(n,i,s),l=r-a,u=100*(0===r?0:l/r),c=100*r;if(r===a)e=0;else{switch(r){case n:e=(i-s)/l+(i<s?6:0);break;case i:e=(s-n)/l+2;break;default:e=(n-i)/l+4}e=e/6*360}return this.createHsvaColor(e,u,c,o)},e.hueToCssColor=function(t,e){void 0===e&&(e=1);var n=this.hueToRgbaColor(t,e);return this.rgbaToCssColor(n)},e.hueToRgbaColor=function(t,e){void 0===e&&(e=1);var n=this.createHsvaColor(t,100,100,e);return this.hsvaToRgbaColor(n)},e.hsvaToRgbaColor=function(t){var e=t.Hue()/360,n=t.Saturation()/100,i=t.Value()/100,s=t.Alpha(),o=Math.floor(6*e),r=6*e-o,a=i*(1-n),l=i*(1-r*n),u=i*(1-(1-r)*n),c=255,h=255,p=255;switch(o%6){case 0:c*=i,h*=u,p*=a;break;case 1:c*=l,h*=i,p*=a;break;case 2:c*=a,h*=i,p*=u;break;case 3:c*=a,h*=l,p*=i;break;case 4:c*=u,h*=a,p*=i;break;default:c*=i,h*=a,p*=l}return this.createRgbaColor(c,h,p,s)},e.rgbaToHexColor=function(t){var e="#";return e+=t.Red().toString(16).padStart(2,"0"),e+=t.Green().toString(16).padStart(2,"0"),e+=t.Blue().toString(16).padStart(2,"0"),t.Alpha()<1&&(e+=Math.round(255*t.Alpha()).toString(16).padStart(2,"0")),e.toUpperCase()},e.parseHexColor=function(t,e){void 0===e&&(e=!0);var n=this.tryParseHexColor(t,e),i=n[0],s=n[1];if(!i){var o=e?"8-char":"6-char";throw Error("The value '"+(t||"null")+"' must be a valid "+o+" HEX color!")}return s},e.tryParseHexColor=function(e,n){void 0===n&&(n=!0),e=e&&e.trim();var i=n?t.RegexUtils.hex8Color():t.RegexUtils.hex6Color();if(e&&i.test(e)){e.startsWith("#")&&(e=e.substring(1));var s=e.split("");3===s.length?s=[s[0],s[0],s[1],s[1],s[2],s[2]]:4===s.length&&(s=[s[0],s[0],s[1],s[1],s[2],s[2],s[3],s[3]]);var o=this.createRgbaColor(parseInt(s[0]+s[1],16),parseInt(s[2]+s[3],16),parseInt(s[4]+s[5],16));return 8===s.length&&o.Alpha(parseFloat((parseInt(s[6]+s[7],16)/255).toFixed(2))),[!0,o]}return[!1,null]},e}();t.ColorUtils=e}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){"use strict";function e(e){for(var i=$.Deferred(),s=[],o=e.items,a=0;a<o.length;a++){var l=r.getEntry(o[a]);s.push(n(l))}return $.when.apply($,s).done(function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];i.resolve(t.Utils.concatMany(e))}),i.promise()}function n(t){var e=$.Deferred();return t.isFile?s(t).done(function(t){return e.resolve([t])}):t.isDirectory&&i(t).done(e.resolve),e.promise()}function i(e){var i=$.Deferred(),s=[];return e.createReader().readEntries(function(e){for(var o=0;o<e.length;o++)s.push(n(e[o]));$.when.apply($,s).done(function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];i.resolve(t.Utils.concatMany(e))})}),i.promise()}function s(t){var e=$.Deferred();return t.file(e.resolve),e.promise()}var o=["B","KB","MB","GB","TB"],r=function(){function t(){}return t.filesToArray=function(t){for(var e=[],n=0;n<t.length;n++)e.push(t[n]);return e},t.getExtension=function(t){return t.slice(1+(t.lastIndexOf(".")-1>>>0))},t.formatSize=function(t){for(var e=0,n=t;n>=1024&&e<o.length-1;)e++,n=Math.floor(n/1024);return e<=2?dotvvm.globalize.formatString("0.##",n)+" "+o[e]:dotvvm.globalize.formatString("0.#",n)+" "+o[e]},t.isImageFile=function(t){return t&&0===t.type.toUpperCase().indexOf("IMAGE/")},t.getFiles=function(t){return this.hasEntries(t)?e(t):$.Deferred().resolve(this.filesToArray(t.files))},t.hasEntries=function(t){return!(!t.items||!t.items.length)&&null!=this.getEntry(t.items[0])},t.getEntry=function(t){return"getAsEntry"in t?t.getAsEntry():"webkitGetAsEntry"in t?t.webkitGetAsEntry():null},t}();t.FileUtils=r}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){"use strict";function e(t,e,n){e=e||NodeFilter.SHOW_ALL,n=n||function(){return!0};var i=function(t){return n(t)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT};return i.acceptNode=i,document.createTreeWalker(t,e,i,!1)}var n=function(){function n(){}return n.getNode=function(t){return $(t)[0]||null},n.isElement=function(t){return t&&t.nodeType===Node.ELEMENT_NODE},n.isText=function(t){return t&&t.nodeType===Node.TEXT_NODE},n.isWhitespace=function(e){return this.isText(e)&&0===t.Utils.normalizeSpaces(e.nodeValue).trim().length},n.splitText=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var i=[],s=1;s<=e.length;s++){var o=e[s-1];t=t.splitText(o),i.push(t.previousSibling),s===e.length&&i.push(t)}return i},n.isInAnchor=function(t){return $(t).parent().is("a")},n.isLast=function(t){var e=this.getNode(t);return e&&!e.nextSibling},n.isLastOrFalsy=function(t){var e=this.getNode(t);return!e||!e.nextSibling},n.isEmpty=function(e){var n=this.getNode(e);return!$(e).is(this.emptySelector)&&(n.hasChildNodes()?1===n.childNodes.length&&this.isEmpty(n.firstChild):0===t.Utils.normalizeSpaces(n.textContent).length)},n.isInlineContent=function(t){var e=this.getNode(t);return this.isText(e)||$(t).is(this.inlineSelector)},n.getInlineContents=function(t){var e=this;return t.contents().filter(function(t,n){return e.isInlineContent(n)})},n.getWithNextInlineContents=function(t){var e=this.getNextInlineContents(t);return t.add(e)},n.getNextInlineContents=function(t){var e=$([]);if(t.length)for(var n=t[0].nextSibling;this.isInlineContent(n);)e=e.add(n),n=n.nextSibling;return e},n.getNextAllInlineContents=function(t){var e=$([]);if(t.length)for(var n=t[0].nextSibling;n;)this.isInlineContent(n)&&(e=e.add(n)),n=n.nextSibling;return e},n.getWithNextContents=function(t){var e=this.getNextContents(t);return t.add(e)},n.getNextNode=function(t){if(t.hasChildNodes())return t.firstChild;for(;t&&!t.nextSibling;)t=t.parentNode;return t?t.nextSibling:null},n.getNextText=function(t){var e=t.nextSibling;if(e){if(this.isText(e))return e;var n=e.firstChild;if(n&&this.isText(n))return n}return null},n.getNextContents=function(t){var e=$([]);if(t.length)for(var n=t[0].nextSibling;n;)e=e.add(n),n=n.nextSibling;return e},n.removeEmptyText=function(t){if(t.length){for(var n=[],i=e(t[0],NodeFilter.SHOW_TEXT,function(t){return!t.nodeValue.length});i.nextNode();)n.push(i.currentNode);$(n).remove()}},n.hasOnlyOneRow=function(t){return 1===t.find("> thead > tr, > tbody > tr, > tr").length},n.hasOnlyOneColumn=function(t){return 1===t.find("> thead > tr, > tbody > tr, > tr").first().children().length},n.reverse=function(t){for(var e=$([]),n=t.length;n--;)e=e.add(t[n]);return e},n.clone=function(t,e){for(var n=$([]),i=0,s=t.get();i<s.length;i++){var o=s[i];n=n.add($(o.cloneNode(e)))}return n},n.cloneAs=function(t,e,n){for(var i=$([]),s=0,o=t.get();s<o.length;s++){for(var r=o[s].cloneNode(n),a=document.createElement(e),l=0,u=r.attributes.length;l<u;++l){var c=r.attributes.item(l).nodeName,h=r.attributes.item(l).nodeValue;a.setAttribute(c,h)}$(a).append($(r).contents()),i=i.add(a)}return i},n.getPath=function(t,e){return t.is(e)?[]:e.parentsUntil(t).addBack().get().map(this.getOffset)},n.fromPath=function(t,e){for(var n=t[0],i=0,s=e;i<s.length;i++){var o=s[i];n=n.childNodes.length<=o?n.childNodes[n.childNodes.length-1]:n.childNodes[o]}return $(n)},n.closestUntil=function(t,e,n){var i=$(t);return i.is(e)?$([]):i.is(n)?i:i.parentsUntil(e,n).first()},n.canMerge=function(t,e){var n=this.getNode(t),i=this.getNode(e);return!(!this.isElement(n)||!this.isElement(i))&&(n.tagName===i.tagName&&n.className===i.className&&n.attributes.length===i.attributes.length&&function(){for(var t=0;t<n.attributes.length;t++){var e=n.attributes.item(t),s=i.attributes.getNamedItem(e.name);if(!s||e.value!==s.value)return!1}return!0}())},n.getOffset=function(t){for(var e=0;t=t.previousSibling;)e+=1;return e},n.trim=function(t){for(var e=t[0],i=e.childNodes.length-1;i>=0;i--){var s=e.childNodes[i],o=$(s);n.isText(s)?n.isEmpty(s)?o.remove():n.isWhitespace(s)&&t.before(o):(this.trim(o),this.isEmpty(s)&&o.remove())}return t},n.inlineSelector="a,abbr,acronym,b,bdo,big,br,button,caption,cite,code,col,dfn,dir,dt,dd,em,font,hr,i,img,input,kbd,li,label,map,object,q,samp,select,small,span,strikeout,strong,sub,sup,textarea,time,tt,u,var",n.emptySelector="area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed",n.blockSelector=":not("+n.inlineSelector+")",n}();t.DomUtils=n}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){"use strict";var e=function(){function e(){}return e.autoFocus=function(e){void 0===e&&(e=$(document)),e.find(":input:enabled[autofocus],[tabindex]."+t.BusinessPackCss.bpAutoFocus).first().focus().select()},e}();t.FocusManager=e,dotvvm.events.init.subscribe(function(){return e.autoFocus()})}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={})),ko.bindingHandlers["dotvvm-businesspack-FAIcon"]={update:function(t,e){var n=ko.unwrap(e()),i="Empty"!==n?"fa fa"+n.replace(/\.?([A-Z]+)/g,function(t,e){return"-"+e.toLowerCase()}):"";ko.getBindingHandler("css").update(t,function(){return i})}};var DotVVM;!function(t){!function(t){!function(t){"use strict";var e=function(){return function(t){if(this.$element=t,this.$window=$(window),this.$document=$(document),1!==t.length)throw Error("UI primitives can only be initialized using JQuery objects containing exactly one element.")}}();t.PrimitiveBase=e}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(e){function n(t,n){void 0===n&&(n=!1);var i=e.call(this,t)||this;return i.hasExplicitWidth=n,i.$parent=t.parent(),i.scrollHandler=function(t){return i.onScroll(t)},i}return __extends(n,e),Object.defineProperty(n.prototype,"isOpened",{get:function(){return this.$element.hasClass(t.BusinessPackCss.bpStateOpened)},enumerable:!0,configurable:!0}),n.prototype.toggle=function(t){void 0===t&&(t=!this.isOpened),t?this.isOpened?this.update():this.open():this.close()},n.prototype.open=function(e){var n=this;"function"==typeof e?this.$element.on("open",e):this.isOpened||(this.$element.addClass(t.BusinessPackCss.bpStateOpened),this.updateInterval=setInterval(function(){return n.update()},10),window.addEventListener("scroll",this.scrollHandler,!0),this.update(),this.$element.trigger("open"))},n.prototype.close=function(e){"function"==typeof e?this.$element.on("close",e):this.isOpened&&(this.$element.removeClass(t.BusinessPackCss.bpStateOpened),window.removeEventListener("scroll",this.scrollHandler,!0),clearInterval(this.updateInterval),this.$element.trigger("close"))},n.prototype.update=function(){if(this.isOpened){var t=this.$parent.outerWidth(),e=this.$parent.outerHeight(),n=this.$parent.offset(),i=this.$element.outerWidth(),s=this.$element.outerHeight(),o=parseFloat(this.$element.css("margin-top")),r=i-t,a=this.$document.scrollTop(),l=this.$document.scrollLeft(),u=n.top+e-a,c=n.left-l;if(u+s>window.innerHeight){var h=n.top-s-a-2*o;h>=0&&(u=h)}if(c+i>window.innerWidth&&r>0){var p=n.left-r-l;p>=0&&(c=p)}this.$element.css({top:u,left:c}),this.hasExplicitWidth||this.$element.css({minWidth:t})}},n.prototype.onScroll=function(t){var e=$(t.target);this.$parent.is(e)||this.$parent.find(e).length||this.close()},n}(e.PrimitiveBase);e.PopupPanel=n}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(t){"use strict";var e=function(t){function e(e,n){void 0===n&&(n=!1);var i=t.call(this,e)||this;return i.restrictToParent=n,i.hasUpdated=!1,i.$parent=e.parent(),e.mousedown(i.onElementMousedown.bind(i)).css("cursor","move"),i.onDocumentMousemoveHandler=i.onDocumentMousemove.bind(i),i.onDocumentMouseupHandler=i.onDocumentMouseup.bind(i),i}return __extends(e,t),e.prototype.update=function(t){"function"==typeof t?this.$element.on("update",t):this.$element.trigger("update")},e.prototype.change=function(t){"function"==typeof t?this.$element.on("change",t):this.$element.trigger("change")},e.prototype.onElementMousedown=function(t){t.stopPropagationAndPreventDefault(),this.initialX=t.pageX,this.initialY=t.pageY,this.$document.mousemove(this.onDocumentMousemoveHandler),this.$document.mouseup(this.onDocumentMouseupHandler)},e.prototype.onDocumentMousemove=function(t){t.stopPropagationAndPreventDefault();var e=this.calculatePageX(t),n=this.calculatePageY(t),i=this.calculateLeft(e),s=this.calculateTop(n);this.hasUpdated=!0,this.$element.css({left:Math.round(i),top:Math.round(s)}),this.update(),this.initialX=e,this.initialY=n},e.prototype.onDocumentMouseup=function(t){this.$document.off("mousemove",this.onDocumentMousemoveHandler),this.$document.off("mouseup",this.onDocumentMouseupHandler),this.hasUpdated&&(this.change(),this.hasUpdated=!1),this.initialX=null,this.initialY=null},e.prototype.calculatePageX=function(t){var e=t.pageX;if(this.restrictToParent){var n=this.$parent.offset(),i=this.$parent.outerWidth();e<n.left?e=n.left:e>n.left+i&&(e=n.left+i)}return e},e.prototype.calculatePageY=function(t){var e=t.pageY;if(this.restrictToParent){var n=this.$parent.offset(),i=this.$parent.outerHeight();e<n.top?e=n.top:e>n.top+i&&(e=n.top+i)}return e},e.prototype.calculateLeft=function(t){var e=this.$element.position().left+(t-this.initialX);if(this.restrictToParent){var n=this.$element.outerWidth(),i=this.$parent.outerWidth();e<0?e=0:e+n>i&&(e=i-n)}return e},e.prototype.calculateTop=function(t){var e=this.$element.position().top+(t-this.initialY);if(this.restrictToParent){var n=this.$element.outerHeight(),i=this.$parent.outerHeight();e<0?e=0:e+n>i&&(e=i-n)}return e},e}(t.PrimitiveBase);t.Movable=e}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(e){function n(t,n){var i=e.call(this,t)||this;return i.isActive=!1,i.hasUpdated=!1,i.options=__assign({},i.getDefaultOptions(),n),i.$parent=t.parent(),i.$trigger=i.options.$trigger||i.$parent,i.onDocumentMousemoveHandler=i.onDocumentMousemove.bind(i),i.onDocumentMouseupHandler=i.onDocumentMouseup.bind(i),i.$trigger.mousedown(i.onTriggerMousedown.bind(i)),i.update(function(){return i.refreshContents()}),i.reset(),i}return __extends(n,e),n.prototype.update=function(t){"function"==typeof t?this.$element.on("update",t):this.$element.trigger("update")},n.prototype.change=function(t){"function"==typeof t?this.$element.on("change",t):this.$element.trigger("change")},n.prototype.reset=function(){this.$element.css({left:this.initialX,top:this.initialY}).width(0).height(0).hide()},n.prototype.getSelectedItems=function(){var t=this,e=this.options.itemSelector,n=[];return e&&this.$trigger.find(e).each(function(e,i){t.doesItemCollide($(i))&&n.push(i)}),n},n.prototype.getDefaultOptions=function(){return{itemSelector:"."+t.BusinessPackCss.bpItem,restrictToParent:!1,minWidth:0,minHeight:0}},n.prototype.onTriggerMousedown=function(t){if(this.shouldStartSelection(t)){t.stopPropagationAndPreventDefault();var e=this.$parent.offset();this.initialX=t.pageX-e.left,this.initialY=t.pageY-e.top,this.$document.mousemove(this.onDocumentMousemoveHandler),this.$document.mouseup(this.onDocumentMouseupHandler)}},n.prototype.onDocumentMousemove=function(t){t.stopPropagationAndPreventDefault();var e=this.options,n=e.aspectRatio,i=e.tempAspectRatio,s=e.restrictToParent,o=e.minWidth,r=e.minHeight;!n&&i&&t.shiftKey&&(n=i);var a=this.calculatePageX(t),l=this.calculatePageY(t),u=Math.abs(this.initialX-a),c=Math.abs(this.initialY-l);if(n){var h=c*n,p=u/n;this.lockX||h>u?u=h:c=p}else this.lockX?u=this.$element.width():this.lockY&&(c=this.$element.height());var d=this.calculateLeft(a,l,u),f=this.calculateTop(a,l,c);if(n&&s){var g=this.$parent.outerWidth(),m=this.$parent.outerHeight(),b=this.$element.position(),y=d+u-g,v=f+c-m;y>0&&(d-=y),v>0&&(f-=v),d=Math.max(0,d),f=Math.max(0,f),c>m&&(u=(c=m)*n,d=b.left),u>g&&(c=(u=g)/n,f=b.top)}u>=o||c>=r?(this.isActive=!0,this.hasUpdated=!0,this.$element.width(Math.round(u)).height(Math.round(c)).css({top:Math.round(f),left:Math.round(d)}).show(),this.update()):this.refreshContents()},n.prototype.onDocumentMouseup=function(t){this.$document.off("mousemove",this.onDocumentMousemoveHandler),this.$document.off("mouseup",this.onDocumentMouseupHandler),this.hasUpdated&&(this.change(),this.hasUpdated=!1),this.isActive=!1,this.initialX=null,this.initialY=null,this.lockX=!1,this.lockY=!1},n.prototype.shouldStartSelection=function(t){return!t.ctrlKey&&this.$trigger.is(t.target)},n.prototype.calculatePageX=function(t){var e=this.$parent.offset(),n=t.pageX-e.left;if(this.options.restrictToParent){var i=this.$parent.outerWidth();n<0?n=0:n>i&&(n=i)}return n},n.prototype.calculatePageY=function(t){var e=this.$parent.offset(),n=t.pageY-e.top;if(this.options.restrictToParent){var i=this.$parent.outerHeight();n<0?n=0:n>i&&(n=i)}return n},n.prototype.calculateLeft=function(t,e,n){return t<=this.initialX&&e>=this.initialY?this.lockX?this.initialX-n/2:this.initialX-n:t>=this.initialX&&e<=this.initialY?this.lockX?this.initialX-n/2:this.initialX:t<this.initialX&&e<this.initialY?this.lockX?this.initialX-n/2:this.initialX-n:this.lockX?this.initialX-n/2:this.initialX},n.prototype.calculateTop=function(t,e,n){return t<=this.initialX&&e>=this.initialY?this.lockY?this.initialY-n/2:this.initialY:t>=this.initialX&&e<=this.initialY?this.lockY?this.initialY-n/2:this.initialY-n:t<this.initialX&&e<this.initialY?this.lockY?this.initialY-n/2:this.initialY-n:this.lockY?this.initialY-n/2:this.initialY},n.prototype.doesItemCollide=function(t){var e=this.$element.offset().top,n=this.$element.offset().left,i=t.offset().top,s=t.offset().left;return!(e+this.$element.height()<i||e>i+t.height()||n+this.$element.width()<s||n>s+t.width())},n.prototype.refreshContents=function(){},n}(e.PrimitiveBase);e.SelectionBox=n}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(){function e(e,n){this.observable=e,this.callback=n,this.watchers=[],t.Utils.isObservableArray(e)?(this.subscription=e.subscribe(this.onArrayChange,this,"arrayChange"),this.watchArray(e.peek())):(this.subscription=e.subscribe(this.onObjectChange,this),this.watchObject(e.peek()))}return e.watch=function(t,n){return ko.isObservable(t)?new e(t,function(){return n(t.peek())}):null},e.prototype.onArrayChange=function(t){for(var n=0,i=t;n<i.length;n++){var s=i[n],o=s.status,r=s.value;if(ko.isObservable(r))if("added"===o)this.watchers.push(new e(r,this.callback));else if("deleted"===o){var a=this.findWatcher(r);a&&(a.dispose(),this.watchers.splice(this.watchers.indexOf(a),1))}}this.callback()},e.prototype.watchArray=function(t){for(var n=0,i=t;n<i.length;n++){var s=i[n];ko.isObservable(s)&&this.watchers.push(new e(s,this.callback))}},e.prototype.onObjectChange=function(t){for(;this.watchers.length;)this.watchers.pop().dispose();this.watchObject(t),this.callback()},e.prototype.watchObject=function(t){for(var n in t)if(t.hasOwnProperty(n)&&!n.startsWith("$")&&!n.endsWith("$options")){var i=t[n];ko.isObservable(i)&&this.watchers.push(new e(i,this.callback))}},e.prototype.findWatcher=function(t){for(var e=0,n=this.watchers;e<n.length;e++){var i=n[e];if(i.observable===t)return i}return null},e.prototype.dispose=function(){for(this.subscription&&(this.subscription.dispose(),this.subscription=null);this.watchers.length;)this.watchers.pop().dispose()},e}();e.ObservableWatcher=n}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(){function n(){this.$window=$(window),this.$document=$(document),this.eventNs="."+t.Utils.createGuid(!1),this.events={}}return n.prototype.on=function(t,e){return t&&e&&(this.events[t]=this.events[t]||[],this.events[t].push(e)),this},n.prototype.off=function(t,e){if(t){if(this.events.hasOwnProperty(t))if(e)for(var n=this.events[t],i=n.length;i--;)n[i][0]===e&&n.splice(i,1);else delete this.events[t]}else this.events={}},n.prototype.trigger=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var i=0,s=t.split(" ");i<s.length;i++){var o=s[i];if(this.events.hasOwnProperty(o))for(var r=0,a=this.events[o];r<a.length;r++)a[r].apply(null,e)}},n.prototype.disposing=function(t){return this.on("disposing",t)},n.prototype.dispose=function(){this.trigger("disposing"),this.$window.off(this.eventNs),this.$document.off(this.eventNs),this.off()},n.prototype.subscribe=function(t,e){if(void 0!==t){var n=e.bind(this);if(ko.delaySync.run(function(){return n(ko.unwrap(t),!0)}),ko.isObservable(t)){var i=t.subscribe(function(t){return ko.delaySync.run(function(){return n(t,!1)})});this.disposing(function(){return i.dispose()})}}},n.prototype.watch=function(t,n){if(void 0!==t){var i=n.bind(this);if(ko.delaySync.run(function(){return i(ko.unwrap(t),!0)}),ko.isObservable(t)){var s=e.ObservableWatcher.watch(t,function(t){return ko.delaySync.run(function(){return i(t,!1)})});this.disposing(function(){return s.dispose()})}}},n}();e.ReactiveBase=n}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(e){function n(t,n,i,s){var o=e.call(this)||this;return o.$element=t,o.binding=n,o.allBindings=i,o.bindingContext=s,o._templateIds={},o}return __extends(n,e),Object.defineProperty(n.prototype,"isEnabled",{get:function(){var t=ko.unwrap(this.binding.enabled);return void 0===t||t},enumerable:!0,configurable:!0}),n.prototype.initialize=function(){this.subscribe(this.binding.visible,this.onVisibleChange),this.subscribe(this.binding.enabled,this.onEnabledChange)},n.prototype.show=function(t,e){!1!==ko.unwrap(this.binding.visible)&&(t?this.$element.stop(!0).fadeIn(t,e):(this.$element.show(),e&&e()))},n.prototype.hide=function(t,e){t?this.$element.stop(!0).fadeOut(t,e):(this.$element.hide(),e&&e())},n.prototype.toggle=function(t,e,n){t?this.show(e,n):this.hide(e,n)},n.prototype.outside=function(t,e){var n=this,i=function(i){var s=$.Event(t,i);return n.isOutsideOfTree(s.target)?e(s):void 0};this.disposing(function(){return document.removeEventListener(t,i,!0)}),document.addEventListener(t,i,!0)},n.prototype.updateTemplate=function(t,e){var n=this.getTemplateId(t);if(n){var i=this.$element.children("script[id='"+n()+"']"),s=$("<div>").append(i.text());e(s),i.text(s.html()),n.valueHasMutated()}},n.prototype.getTemplateId=function(t){if(this._templateIds.hasOwnProperty(t))return this._templateIds[t];var e=this.$element.children("script[id$='."+t+"'][type='text/html']");return e.length?this._templateIds[t]=ko.observable(e.attr("id")):null},n.prototype.onVisibleChange=function(t){void 0!==t&&this.toggle(!!t)},n.prototype.onEnabledChange=function(){this.$element.toggleClass(t.BusinessPackCss.bpStateDisabled,!this.isEnabled),null!=this.binding.tabIndex&&this.toggleTabIndex()},n.prototype.toggleTabIndex=function(){this.isEnabled?this.$element.attr("tabindex",this.binding.tabIndex):this.$element.removeAttr("tabindex")},n.prototype.isOutsideOfTree=function(t){return!t||!this.$element.is(t)&&0===this.$element.find($(t)).length},n.prototype.postback=function(t){return t?t.call(this.$element[0]):void 0},n.prototype.emptyPostback=function(){dotvvm.postbackScript("null")("root",this.$element[0],[],"",!0,"$root",null,null)},n}(e.ReactiveBase);e.ControlBase=n}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(t){"use strict";var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e}(t.ControlBase);t.EditorBase=e}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return __extends(n,e),Object.defineProperty(n.prototype,"items",{get:function(){return t.Utils.getDataSourceItems(this.binding.dataSource)},enumerable:!0,configurable:!0}),n.prototype.getItemKey=function(e){if(null==(e=ko.unwrap(e)))throw Error("The unique key can't be resolved for null or undefined.");var n=this.getItemKeyBinding();if(n&&!t.Utils.isDataAccessor(n))return t.Utils.getUnwrappedBindingValue(e,n);if("object"==typeof e)throw Error("The unique key can't be resolved. Is KeyBinding property missing?");return e},n.prototype.findItemByKey=function(t){var e=this;return t=ko.unwrap(t),this.findItem(function(n){return e.getItemKey(n)===t})},n.prototype.getItemValueCopy=function(e){return t.Utils.deepCopy(this.getItemValue(e))},n.prototype.getItemValue=function(e){if(null==(e=ko.unwrap(e)))throw Error("The value can't be resolved for null or undefined.");var n=this.getItemValueBinding();return n&&!t.Utils.isDataAccessor(n)?t.Utils.getUnwrappedBindingValue(e,n):e},n.prototype.isValueOfItem=function(t,e){return this.getItemKey(this.findItemByValue(t))===this.getItemKey(e)},n.prototype.findItemByValue=function(e){var n=this;e=ko.unwrap(e);var i=this.getItemValueBinding();if(null!=e&&t.Utils.isDataAccessor(i)){var s=this.getItemKey(e);return this.findItem(function(t){return n.getItemKey(t)===s})}return this.findItem(function(t){return n.getItemValue(t)===e})},n.prototype.getItemText=function(e){if(null==(e=ko.unwrap(e)))throw Error("The text can't be resolved for null or undefined.");var n=this.getItemTextBinding();if(n&&!t.Utils.isDataAccessor(n))return t.Utils.getUnwrappedBindingValue(e,n);if("object"==typeof e)throw Error("The text can't be resolved. Is ItemTextBinding missing?");return e.toString()},n.prototype.createItemFromText=function(e){var n=this.getItemTextBinding();if(t.Utils.isDataAccessor(n))return e;if(!t.Utils.isPropertyAccessor(n))throw Error("The item can't be created. The ItemTextBinding must be a simple property accessor.");return i={},i[n]=e,i;var i},n.prototype.findItemByText=function(t){var e=this;return this.findItem(function(n){return e.getItemText(n)===t})},n.prototype.findItemInDataSourceOrAdd=function(e){var n=this,i=this.items(),s=this.getItemKey(e),o=i.asLinq().singleOrDefault(function(t){return n.getItemKey(t)===s});return o||(o=t.Utils.ensureObservable(e),this.items.push(o)),o},n.prototype.findItem=function(t){return this.getAllItems().asLinq().singleOrDefault(t)},n.prototype.removeAllItemsExcept=function(t){var e=this;this.items.remove(function(n){return t.indexOf(e.getItemKey(n))<0})},n.prototype.warnThatKeyWasNotFound=function(t){console.warn("An item with key equal to '"+t+"' couldn't be found in the DataSource.")},n.prototype.warnThatValueWasNotFound=function(t){console.warn("object"==typeof t?"An item with key equal to '"+this.getItemKey(t)+"' couldn't be found in the DataSource.":"An item with value equal to '"+t+"' couldn't be found in the DataSource.")},n.prototype.getAllItems=function(){return this.items()},n.prototype.getItemKeyBinding=function(){return null},n.prototype.getItemValueBinding=function(){return null},n.prototype.getItemTextBinding=function(){return null},n}(e.ControlBase);e.ItemsControlBase=n}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.allItems=ko.observableArray(),t}return __extends(n,e),n.prototype.initialize=function(){e.prototype.initialize.call(this),this.watch(this.binding.dataSource,this.onDataSourceChange)},n.prototype.isRootItem=function(t){var e=this,n=this.items(),i=this.getItemKey(t);return n.asLinq().any(function(t){return e.getItemKey(t)===i})},n.prototype.shouldLoadChildren=function(t){if(!this.hasChildren(t))return!1;var e=this.getChildren(t);if(!e.length)return!0;for(var n=0,i=e;n<i.length;n++){var s=i[n];if(this.hasChildren(s))return!this.getChildren(s).length}return!1},n.prototype.hasChildren=function(e){var n=this.binding.itemChildrenBinding;if(n){var i=t.Utils.getUnwrappedBindingValue(e,n);return i&&!!i.length}return!1},n.prototype.getChildren=function(e){var n=this.binding.itemChildrenBinding;return n?t.Utils.getUnwrappedBindingValue(e,n)||[]:[]},n.prototype.getParent=function(t){var e=this,n=this.getAllItems(),i=this.getItemKey(t);return n.asLinq().where(function(t){return e.getItemKey(t)===i}).select(function(t){return t.$parent}).singleOrDefault()},n.prototype.getAllItems=function(){return ko.unwrap(this.allItems)},n.prototype.onDataSourceChange=function(){this.allItems(this.getItemsRecursively(null,this.items()))},n.prototype.getItemsRecursively=function(e,n){for(var i=[],s=0,o=n;s<o.length;s++){var r=o[s];r.$parent=e,i.push(r);var a=this.getChildren(r);a.length&&t.Utils.pushAll(i,this.getItemsRecursively(r,a))}return i},n}(e.ItemsControlBase);e.HierarchyItemsControlBase=n}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return __extends(n,e),n.prototype.canBeChecked=function(e){var n=this.binding.itemEnabledBinding;return!!this.isEnabled&&(!n||t.Utils.getUnwrappedBindingValue(e,n))},n.prototype.getItemKeyBinding=function(){return this.binding.itemKeyBinding||this.getItemValueBinding()},n.prototype.getItemValueBinding=function(){return this.binding.itemValueBinding},n.prototype.getItemStyle=function(e){e=ko.unwrap(e);var n={};return n[t.BusinessPackCss.bpStateChecked]=this.isSelected(e),n},n}(e.ItemsControlBase);e.CheckableControlListBase=n}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(t){"use strict";var e=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.searchResults=ko.observableArray(),t}return __extends(n,e),n.prototype.initialize=function(){e.prototype.initialize.call(this),this.searchEngine=this.createSearchEngine(),this.watch(this.binding.dataSource,this.onDataSourceChange)},n.prototype.hasBeenFound=function(t){var e=this;if(null!=(t=ko.unwrap(t))){var n=this.getItemKey(t);return this.searchResults().asLinq().any(function(t){return e.getItemKey(t)===n})}return!1},n.prototype.search=function(t){var e=this;this.searchEngine.search(t).done(function(t){for(var n=0,i=t;n<i.length;n++){var s=i[n];e.findItemInDataSourceOrAdd(s)}e.searchResults(t)})},n.prototype.onDataSourceChange=function(){this.searchEngine.clear(),this.searchEngine.preload(this.items())},n.prototype.createSearchEngine=function(){var e=this,n=this.binding.loadItems;return new t.SearchEngine({getItemKey:this.getItemKey.bind(this),getItemText:this.getItemText.bind(this),loadItems:n?function(){return e.postback(n)}:null})},n.prototype.getItemKeyBinding=function(){return this.binding.itemTextBinding},n.prototype.getItemValueBinding=function(){return this.binding.itemTextBinding},n.prototype.getItemTextBinding=function(){return this.binding.itemTextBinding},n}(t.ItemsControlBase);t.ItemsEditorBase=e}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return __extends(n,e),n.prototype.isItemEnabled=function(e){var n=this.binding.itemEnabledBinding;return!!this.isEnabled&&(!n||t.Utils.getUnwrappedBindingValue(e,n))},n.prototype.search=function(t){null!=t&&t.length?e.prototype.search.call(this,t):(this.searchResults(this.items()),this.searchEngine.cancel())},n.prototype.onDataSourceChange=function(){e.prototype.onDataSourceChange.call(this),this.searchResults(this.items())},n.prototype.getItemKeyBinding=function(){return this.binding.itemKeyBinding||this.getItemValueBinding()},n.prototype.getItemValueBinding=function(){return this.binding.itemValueBinding},n}(e.ItemsEditorBase);e.SelectorBase=n}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(t){"use strict";var e=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.stack=[],e.stackOffset=-1,e}return __extends(e,t),Object.defineProperty(e.prototype,"isEmpty",{get:function(){return!this.stack.length},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"canRedo",{get:function(){return this.stack.length-1>this.stackOffset},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"canUndo",{get:function(){return this.stackOffset>0},enumerable:!0,configurable:!0}),e.prototype.apply=function(t){this.on("apply",t)},e.prototype.record=function(t){this.stackOffset++,this.stack.length>this.stackOffset&&(this.stack=this.stack.slice(0,this.stackOffset)),this.stack.push(t)},e.prototype.rewind=function(){this.stack.length&&this.trigger("apply",this.stack[0])},e.prototype.redo=function(){this.canRedo&&this.trigger("apply",this.stack[++this.stackOffset])},e.prototype.undo=function(){this.canUndo&&this.trigger("apply",this.stack[--this.stackOffset])},e.prototype.reset=function(){this.stack=[],this.stackOffset=-1},e}(t.ReactiveBase);t.UndoManager=e}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(){function e(t){void 0===t&&(t={}),this.options=t,this.items=[],t.getItemKey||(t.getItemKey=function(t){return ko.unwrap(t)}),t.getItemText||(t.getItemText=function(t){return ko.unwrap(t)})}return e.prototype.search=function(t){var e=this;this.cancel(),t=t?t.trim():"";var n=new DotvvmPromise,i=this.options,s=i.getItemText,o=i.loadItems;return this.timeout=setTimeout(function(){e.timeout=null;var i=e.getFromCache(t);if(i)n.resolve(i);else{var r=e.items.filter(function(n){return e.match(s(n),t)});if(o){var a=o(t);a&&(a.done(function(i){n.resolve(e.sort(e.union(r,i),t)),e.preload(i,!1)}),a.fail(function(t){n.reject(t)}))}else n.resolve(e.sort(r,t));n.done(function(n){e.pushToCache(t,n)})}},300),n},e.prototype.preload=function(t,e){void 0===e&&(e=!0),this.items=this.sort(this.union(this.items,t)),e&&(this.cache={})},e.prototype.cancel=function(){this.timeout&&(clearTimeout(this.timeout),this.timeout=null)},e.prototype.clear=function(){this.items.length=0,this.cache={}},e.prototype.getFromCache=function(t){if(t in this.cache){var e=this.cache[t];if(!(Date.now()-e.dateTime>4e3))return e.results;delete this.cache[t]}return null},e.prototype.pushToCache=function(t,e){this.cache[t]={dateTime:Date.now(),results:e}},e.prototype.match=function(t,e){return t=t.toUpperCase(),e=e.toUpperCase(),t.startsWith(e)||t.indexOf(e)>=0},e.prototype.sort=function(e,n){void 0===n&&(n="");var i=this.options.getItemText;return n=n.toUpperCase(),e.sort(function(e,s){var o=i(e).toUpperCase(),r=i(s).toUpperCase();return n?t.Levenshtein.compare(o,n)-t.Levenshtein.compare(r,n):0})},e.prototype.union=function(e,n){for(var i=this.options.getItemKey,s=[],o=[],r=0,a=e.concat(n);r<a.length;r++){var l=a[r],u=i(l);o.indexOf(u)<0&&(s.push(ko.isObservable(l)?l:t.Utils.deepObservable(l)),o.push(u))}return s},e}();e.SearchEngine=n}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return __extends(n,e),Object.defineProperty(n.prototype,"isDisplayed",{get:function(){var t=ko.unwrap(this.binding.isDisplayed);return null==t||t},set:function(t){var e=this.binding.isDisplayed;ko.isWriteableObservable(e)&&e(null!=t?t:null)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"autoHideTimeoutMs",{get:function(){var t=this.binding.autoHideTimeout;return null!=t?1e3*t:null},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"animationDurationMs",{get:function(){var t=this.binding.animationDuration;return null!=t?1e3*t:null},enumerable:!0,configurable:!0}),n.prototype.initialize=function(){var n=this;e.prototype.initialize.call(this),this.$dismissButton=this.$element.children("."+t.BusinessPackCss.bpClose),this.alertTypes=["success","info","warning","danger"],this.$element.mouseenter(function(){return n.stopTimer()}),this.$element.mouseleave(function(){return n.startTimer()}),this.$dismissButton.click(function(t){return n.onDismissButtonClick(t)}),this.subscribe(this.binding.type,this.onTypeChange),this.binding.isDisplayed?this.subscribe(this.binding.isDisplayed,this.onIsDisplayedChange):this.binding.text?this.subscribe(this.binding.text,this.onTextChange):this.onIsDisplayedChange(this.isDisplayed)},n.prototype.show=function(t,n){var i=this;e.prototype.show.call(this,t,function(){i.startTimer(),i.isDisplayed=!0,n&&n()})},n.prototype.hide=function(t,n){var i=this;e.prototype.hide.call(this,t,function(){i.stopTimer(),i.isDisplayed=!1,n&&n()})},n.prototype.startTimer=function(){var t=this,e=this.autoHideTimeoutMs;e&&!this.autoHideTimer&&(this.autoHideTimer=setTimeout(function(){return t.hide(t.animationDurationMs)},e))},n.prototype.stopTimer=function(){this.autoHideTimer&&(clearTimeout(this.autoHideTimer),this.autoHideTimer=null)},n.prototype.onDismissButtonClick=function(t){var e=this;this.hide(this.animationDurationMs,function(){e.postback(e.binding.dismissed)})},n.prototype.onVisibleChange=function(t){void 0!==t&&this.toggle(!1!==this.isDisplayed&&t)},n.prototype.onTypeChange=function(e){e=e.toLowerCase();for(var n=t.BusinessPackCss.bpAlertTypePrefix,i=0,s=this.alertTypes;i<s.length;i++){var o=s[i];o!==e&&this.$element.removeClass(n+o)}this.$element.addClass(n+e)},n.prototype.onIsDisplayedChange=function(t){void 0!==t&&this.toggle(t,this.animationDurationMs)},n.prototype.onTextChange=function(t){this.binding.isDisplayed||this.toggle(!!t,this.animationDurationMs)},n}(e.ControlBase);e.Alert=n,t.Utils.installBindingHandler("Alert",n)}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(n){function i(){var t=null!==n&&n.apply(this,arguments)||this;return t.focusedItemKey=ko.observable(),t.shouldPostbackOnChange=!0,t}return __extends(i,n),Object.defineProperty(i.prototype,"isOpened",{get:function(){return this.popupPanel.isOpened},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"hasValue",{get:function(){var t=this.binding.text();return null!=t&&t.length},enumerable:!0,configurable:!0}),i.prototype.initialize=function(){var i=this;n.prototype.initialize.call(this),this.$textBox=this.$element.children("."+t.BusinessPackCss.bpTextBox),this.$popup=this.$element.children("."+t.BusinessPackCss.bpPopup),this.$results=this.$popup.children("ul"),this.popupPanel=new e.PopupPanel(this.$popup),this.$element.keydown(this.onElementKeydown.bind(this)),this.$textBox.focus(this.onTextBoxFocus.bind(this)),this.$textBox.blur(this.onTextBoxBlur.bind(this)),this.$textBox.keydown(this.onTextBoxKeydown.bind(this)),this.$textBox.input(this.onTextBoxInput.bind(this)),this.$textBox.change(this.onTextBoxChange.bind(this)),this.$popup.mousedown(function(t){return t.preventDefault()}),this.$results.on("click","."+t.BusinessPackCss.bpItem,this.onResultClick.bind(this)),this.outside("click",function(){return i.popupPanel.close()}),this.subscribe(this.searchResults,this.onSearchResultsChange)},i.prototype.togglePopup=function(t){void 0===t&&(t=!this.isOpened);var e=t&&this.isEnabled;this.popupPanel.toggle(e),e||this.unfocusItems()},i.prototype.focusItem=function(t){this.focusedItemKey(this.getItemKey(t))},i.prototype.isFocused=function(t){return this.getItemKey(t)===this.focusedItemKey()},i.prototype.getFocusedItem=function(){return this.findItemByKey(this.focusedItemKey)},i.prototype.unfocusItems=function(){this.focusedItemKey(null)},i.prototype.updatePropertyFromText=function(){this.binding.text(this.$textBox.val())},i.prototype.selectItemText=function(t){this.togglePopup(!1);var e=this.binding.text(),n=t;this.shouldPostbackOnChange=!1,"string"!=typeof n&&(n=this.getItemText(t)),n===e?this.binding.text.notifySubscribers():(this.binding.text(n),this.postback(this.binding.changed))},i.prototype.onElementKeydown=function(e){this.isEnabled&&this.isOpened&&(e.which===t.KeyboardKeys.esc?(e.stopPropagation(),this.togglePopup(!1)):t.KeyboardKeys.isEnter(e.which)?(e.stopPropagationAndPreventDefault(),this.selectFocusedItem()):e.which===t.KeyboardKeys.tab?(e.stopPropagation(),this.selectFocusedItem()):e.which===t.KeyboardKeys.down?(e.stopPropagation(),this.focusNextItem()):e.which===t.KeyboardKeys.up&&(e.stopPropagation(),this.focusPrevItem()))},i.prototype.onTextBoxFocus=function(){this.$element.addClass(t.BusinessPackCss.bpStateFocused)},i.prototype.onTextBoxBlur=function(){this.$element.removeClass(t.BusinessPackCss.bpStateFocused),this.togglePopup(!1)},i.prototype.onTextBoxKeydown=function(e){this.isOpened&&t.KeyboardKeys.isUpOrDown(e.which)&&e.preventDefault()},i.prototype.onTextBoxInput=function(t){var e=this.$textBox.val(),n=this.binding.updateTextOnInput;t.stopPropagation(),this.shouldPostbackOnChange=!0,n&&this.updatePropertyFromText(),this.search(e)},i.prototype.onTextBoxChange=function(t){var e=this.binding,n=e.updateTextOnInput,i=e.changed;n||(t.stopPropagation(),this.updatePropertyFromText()),this.shouldPostbackOnChange&&(t.stopPropagation(),this.postback(i))},i.prototype.onResultClick=function(t){$(t.currentTarget).parent().is(this.$results)&&(t.stopPropagation(),this.selectItemText(ko.dataFor(t.currentTarget)))},i.prototype.onDataSourceChange=function(){n.prototype.onDataSourceChange.call(this),this.searchResults([])},i.prototype.onSearchResultsChange=function(t){var e=this.$textBox.val();this.togglePopup(e&&t.length>0)},i.prototype.focusPrevItem=function(){var e=this.$results.children("."+t.BusinessPackCss.bpItem+"."+t.BusinessPackCss.bpStateFocused).prev();e.length&&(this.scrollToItem(e),this.focusItem(ko.dataFor(e[0])))},i.prototype.focusNextItem=function(){var e=this.$results.children("."+t.BusinessPackCss.bpItem+"."+t.BusinessPackCss.bpStateFocused),n=e.next();n.length||e.length||(n=this.$results.children("."+t.BusinessPackCss.bpItem+":first")),n.length&&(this.scrollToItem(n),this.focusItem(ko.dataFor(n[0])))},i.prototype.scrollToItem=function(t){var e=this.$results.innerHeight(),n=parseInt(this.$results.css("padding-top")),i=parseInt(this.$results.css("padding-bottom")),s=parseInt(t.css("margin-top")),o=parseInt(t.css("margin-bottom")),r=t.is(":first-child")?n:s,a=t.is(":last-child")?i:o,l=t.position().top,u=l+t.outerHeight(!0),c=this.$results.scrollTop();u>e?this.$results.scrollTop(c+(u-e)+a):l<0&&this.$results.scrollTop(c+l-r)},i.prototype.selectFocusedItem=function(){var t=this.getFocusedItem();this.isOpened&&t?this.selectItemText(t):this.togglePopup(!1)},i.prototype.getItemStyle=function(e){e=ko.unwrap(e);var n={};return n[t.BusinessPackCss.bpStateFocused]=this.isFocused(e),n},i}(e.ItemsEditorBase);e.AutoComplete=n,t.Utils.installBindingHandler("AutoComplete",n)}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return __extends(n,e),n.prototype.initialize=function(){var t=this;e.prototype.initialize.call(this),this.buttonTypes=["primary","secondary","success","info","warning","danger"],this.$element.focus(function(){return t.onElementFocus()}),this.$element.blur(function(){return t.onElementBlur()}),this.$element.click(function(e){return t.onElementClick(e)}),this.subscribe(this.binding.type,this.onTypeChange)},n.prototype.onElementFocus=function(){this.$element.addClass(t.BusinessPackCss.bpStateFocused)},n.prototype.onElementBlur=function(){this.$element.removeClass(t.BusinessPackCss.bpStateFocused)},n.prototype.onElementClick=function(t){this.isEnabled&&(t.stopPropagationAndPreventDefault(),this.postback(this.binding.click))},n.prototype.onTypeChange=function(e){e&&(e=e.toLowerCase());for(var n=t.BusinessPackCss.bpButtonTypePrefix,i=0,s=this.buttonTypes;i<s.length;i++){var o=s[i];o!==e&&this.$element.removeClass(n+o)}e&&this.$element.addClass(n+e)},n}(e.ControlBase);e.Button=n,t.Utils.installBindingHandler("Button",n),t.Utils.installBindingHandler("ToolbarButton",n)}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return __extends(n,e),n.prototype.initialize=function(){e.prototype.initialize.call(this),this.activeItemIndex=ko.observable(0),this.subscribe(this.activeItemIndex,this.onActiveItemIndexChange),this.subscribe(this.binding.items,this.onItemsChange),setInterval(this.onTimerTick.bind(this),1e3)},n.prototype.getActiveItem=function(){return this.binding.items().asLinq().firstOrDefault(function(t){return t().IsActive()})},n.prototype.onItemsChange=function(){if(this.binding.items().asLinq().any(function(t){return t().IsActive()})){var t=this.getActiveItem();t&&this.activeItemIndex(this.binding.items().asLinq().indexOf(t))}else this.activeItemIndex(0)},n.prototype.onActiveItemIndexChange=function(e){if(this.binding){var n=this.binding.items();this.activeItem&&this.activeItem().IsActive(!1);var i=n.asLinq().elementAt(e);i().IsActive(!0),this.activeItem=i,t.Utils.warnInDebugMode(e)}},n.prototype.onTimerTick=function(){this.activeItemIndex()==this.binding.items().length-1?this.activeItemIndex(0):this.activeItemIndex(this.activeItemIndex()+1),t.Utils.warnInDebugMode(this.activeItemIndex())},n}(e.ControlBase);e.Carousel=n,t.Utils.installBindingHandler("Carousel",n)}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return __extends(n,e),n.prototype.initialize=function(){e.prototype.initialize.call(this),this.$element.is("input")?this.$input=this.$element:(this.$input=this.$element.children("input"),this.$element.mousedown(this.onElementMousedown.bind(this))),this.$input.focus(this.onInputFocus.bind(this)),this.$input.blur(this.onInputBlur.bind(this)),this.$input.click(this.onInputClick.bind(this)),this.subscribe(this.binding.checked,this.onCheckedChange.bind(this))},n.prototype.onElementMousedown=function(t){this.$input.focus(),t.preventDefault()},n.prototype.onInputFocus=function(){this.$element.addClass(t.BusinessPackCss.bpStateFocused)},n.prototype.onInputBlur=function(){this.$element.removeClass(t.BusinessPackCss.bpStateFocused)},n.prototype.onInputClick=function(e){this.isEnabled&&(this.$element.toggleClass(t.BusinessPackCss.bpStateIndeterminate,this.$input.is(":checkbox")&&this.$input.prop("indeterminate")),this.$element.toggleClass(t.BusinessPackCss.bpStateChecked,this.$input.is(":checked")),this.postback(this.binding.changed))},n.prototype.onCheckedChange=function(e){this.$element.toggleClass(t.BusinessPackCss.bpStateIndeterminate,null==e),this.$element.toggleClass(t.BusinessPackCss.bpStateChecked,null!=e&&e)},n}(e.ControlBase);e.CheckableControl=n,t.Utils.installBindingHandler("CheckBox",n),t.Utils.installBindingHandler("RadioButton",n)}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.selectedItemsKeys=ko.observableArray(),t}return __extends(n,e),n.prototype.initialize=function(){e.prototype.initialize.call(this),this.$element.on("change","[type=checkbox]",this.onInputChange.bind(this)),this.binding.selectedValues&&this.watch(this.binding.selectedValues,this.onSelectedValuesChange)},n.prototype.toggleItem=function(t){this.isSelected(t)?this.unselectItem(t):this.selectItem(t)},n.prototype.selectItem=function(t){if(!this.isSelected(t)){var e=this.getItemValueCopy(t);this.binding.selectedValues.push(ko.observable(e)),this.postback(this.binding.changed)}},n.prototype.unselectItem=function(t){var e=this;this.isSelected(t)&&(this.binding.selectedValues.remove(function(n){return e.isValueOfItem(n,t)}),this.postback(this.binding.changed))},n.prototype.isSelected=function(e){if(!this.binding.selectedValues)return t.Utils.getUnwrappedBindingValue(e,this.binding.itemCheckedBinding);var n=this.getItemKey(e);return this.selectedItemsKeys().asLinq().contains(n)},n.prototype.onInputChange=function(t){t.stopPropagation(),this.binding.selectedValues?this.toggleItem(ko.dataFor(t.target)):this.postback(this.binding.changed)},n.prototype.onSelectedValuesChange=function(e){t.Utils.clearObservableArray(this.selectedItemsKeys);for(var n=0,i=e;n<i.length;n++){var s=i[n],o=this.findItemByValue(s);o?this.selectedItemsKeys.push(this.getItemKey(o)):this.warnThatValueWasNotFound(s)}},n}(e.CheckableControlListBase);e.CheckBoxList=n,t.Utils.installBindingHandler("CheckBoxList",n)}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(n){function i(){var e=null!==n&&n.apply(this,arguments)||this;return e.hue=ko.observable(0),e.alpha=ko.observable(1),e.previewColor=ko.observable(),e.isHexEditorActive=ko.observable(!0),e.nullColor=t.ColorUtils.createRgbaColor(0,0,0),e.isLoadingColor=!1,e.isChangingColor=!1,e}return __extends(i,n),Object.defineProperty(i.prototype,"isOpened",{get:function(){return this.popupPanel.isOpened},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"isPreviewingColor",{get:function(){return this.previewColor()!==this.nullColor},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"hasValue",{get:function(){return null!=this.getSelectedColor()},enumerable:!0,configurable:!0}),i.prototype.initialize=function(){var i=this;n.prototype.initialize.call(this),this.$value=this.$element.children("."+t.BusinessPackCss.bpValue),this.$colorPreview=this.$value.find("."+t.BusinessPackCss.bpColorPreview),this.$unselectButton=this.$element.children("."+t.BusinessPackCss.bpUnselect),this.$toggleButton=this.$element.children("."+t.BusinessPackCss.bpToggle),this.$popup=this.$element.children("."+t.BusinessPackCss.bpPopup),this.$colorSpectrum=this.$popup.children("."+t.BusinessPackCss.bpColorSpectrum),this.$colorGrip=this.$colorSpectrum.children("."+t.BusinessPackCss.bpGrip),this.$alphaSlider=this.$popup.find("."+t.BusinessPackCss.bpAlphaSlider),this.$colorEditorSwitch=this.$popup.find("."+t.BusinessPackCss.bpColorEditor+" > ."+t.BusinessPackCss.bpSwitch),this.$hexColorInput=this.$popup.find("."+t.BusinessPackCss.bpColorEditor+" ."+t.BusinessPackCss.bpHexColorEditor+" > input"),this.$redChannelInput=this.$popup.find("."+t.BusinessPackCss.bpColorEditor+" ."+t.BusinessPackCss.bpRedChannelEditor+" > input"),this.$greenChannelInput=this.$popup.find("."+t.BusinessPackCss.bpColorEditor+" ."+t.BusinessPackCss.bpGreenChannelEditor+" > input"),this.$blueChannelInput=this.$popup.find("."+t.BusinessPackCss.bpColorEditor+" ."+t.BusinessPackCss.bpBlueChannelEditor+" > input"),this.$alphaChannelInput=this.$popup.find("."+t.BusinessPackCss.bpColorEditor+" ."+t.BusinessPackCss.bpAlphaChannelEditor+" > input"),this.$predefinedColors=this.$popup.children("."+t.BusinessPackCss.bpPredefinedColors),this.popupPanel=new e.PopupPanel(this.$popup,!0),this.$element.focusin(this.onElementFocusin.bind(this)),this.$element.focusout(this.onElementFocusout.bind(this)),this.$element.keydown(this.onElementKeydown.bind(this)),this.$value.click(this.onToggleButtonClick.bind(this)),this.$unselectButton.click(this.onUnselectButtonClick.bind(this)),this.$toggleButton.click(this.onToggleButtonClick.bind(this)),this.$popup.mousedown(this.onPopupMousedown.bind(this)),this.$colorSpectrum.mousedown(this.onColorSpectrumMousedown.bind(this)),this.$colorEditorSwitch.click(this.onColorEditorSwitchClick.bind(this)),this.$hexColorInput.keydown(this.onHexColorInputKeydown.bind(this)),this.$hexColorInput.on("input change",this.onHexColorInputChange.bind(this)),this.$redChannelInput.on("input change",function(e){return i.onChannelInputChange(t.RgbaChannel.Red,e)}),this.$greenChannelInput.on("input change",function(e){return i.onChannelInputChange(t.RgbaChannel.Green,e)}),this.$blueChannelInput.on("input change",function(e){return i.onChannelInputChange(t.RgbaChannel.Blue,e)}),this.$alphaChannelInput.on("input change",function(e){return i.onChannelInputChange(t.RgbaChannel.Alpha,e)}),this.$predefinedColors.on("click","."+t.BusinessPackCss.bpItem,this.onPredefinedColorClick.bind(this)),this.outside("click",function(){return i.popupPanel.close()}),this.watch(this.binding.selectedColor,this.onSelectedColorChange),this.watch(this.binding.selectedRgbaColor,this.onSelectedRgbaColorChange),this.subscribe(this.previewColor,this.onPreviewColorChange),this.subscribe(this.hue,this.onHueChange),this.subscribe(this.alpha,this.onAlphaChange)},i.prototype.togglePopup=function(t){void 0===t&&(t=!this.isOpened);var e=t&&this.isEnabled;e&&this.setColorEditorValues(this.previewColor()),this.popupPanel.toggle(e)},i.prototype.selectColor=function(e){if(!this.isSelected(e)){var n=this.binding,i=n.selectedColor,s=n.selectedRgbaColor;i?i(t.ColorUtils.rgbaToHexColor(e)):s(t.Utils.deepCopy(e)),this.postback(this.binding.changed)}},i.prototype.isSelected=function(e){return t.ColorUtils.areRgbaColorsEqual(e,this.getSelectedColor())},i.prototype.getSelectedColor=function(){var e=this.binding,n=e.selectedColor,i=e.selectedRgbaColor,s=e.allowAlphaChannel;return n?t.ColorUtils.tryParseHexColor(n(),s)[1]:i()},i.prototype.unselectColor=function(){if(this.hasValue){var t=this.binding,e=t.selectedColor,n=t.selectedRgbaColor;e?e(null):n(null),this.postback(this.binding.changed)}},i.prototype.onElementFocusin=function(e){this.$element.addClass(t.BusinessPackCss.bpStateFocused)},i.prototype.onElementFocusout=function(e){this.$element.removeClass(t.BusinessPackCss.bpStateFocused),this.isOutsideOfTree(e.relatedTarget)&&this.togglePopup(!1)},i.prototype.onElementKeydown=function(e){this.isEnabled&&(this.isOpened?e.which===t.KeyboardKeys.esc?(e.stopPropagation(),this.togglePopup(!1),this.$element.focus()):t.KeyboardKeys.isEnter(e.which)&&e.preventDefault():e.altKey&&e.which===t.KeyboardKeys.down&&(e.stopPropagation(),this.togglePopup(!0)))},i.prototype.onUnselectButtonClick=function(t){this.isEnabled&&(t.stopPropagation(),this.unselectColor())},i.prototype.onToggleButtonClick=function(t){this.isEnabled&&(t.stopPropagation(),this.togglePopup())},i.prototype.onPopupMousedown=function(e){if(e.stopPropagation(),t.Browser.isGecko){var n=$(e.target),i=!!t.DomUtils.closestUntil(n,this.$popup,":input,[tabindex]").length;!n.is(this.$popup)&&i||(e.preventDefault(),this.$element.focus())}},i.prototype.onColorSpectrumMousedown=function(t){t.stopPropagationAndPreventDefault(),this.isChangingColor=!0,this.$document.on("mousemove"+this.eventNs,this.onColorSpectrumMousemove.bind(this)),this.$document.on("mouseup"+this.eventNs,this.onColorSpectrumMouseup.bind(this)),this.moveColorGripToMousePosition(t.pageX,t.pageY)},i.prototype.onColorSpectrumMousemove=function(t){this.moveColorGripToMousePosition(t.pageX,t.pageY)},i.prototype.onColorSpectrumMouseup=function(t){this.$document.off("mousemove"+this.eventNs+" mouseup"+this.eventNs),this.selectPreviewColor(),this.isChangingColor=!1},i.prototype.onAlphaHueSliderChange=function(){this.selectPreviewColor()},i.prototype.onColorEditorSwitchClick=function(t){t.stopPropagation(),this.isHexEditorActive(!this.isHexEditorActive())},i.prototype.onHexColorInputKeydown=function(e){var n=this.$hexColorInput.val().trim();if((4===n.length||5===n.length)&&t.KeyboardKeys.isEnter(e.which)){var i=this.binding.allowAlphaChannel,s=t.ColorUtils.tryParseHexColor(n,i),o=s[0],r=s[1];o&&(e.stopPropagation(),this.selectColor(r))}},i.prototype.onHexColorInputChange=function(e){var n=this.$hexColorInput.val().trim();if(7===n.length||9===n.length){var i=this.binding.allowAlphaChannel,s=t.ColorUtils.tryParseHexColor(n,i),o=s[0],r=s[1];o&&(e.stopPropagation(),"change"===e.type?this.selectColor(r):this.previewColor(r))}},i.prototype.onChannelInputChange=function(e,n){var i,s=$(n.target),o=parseInt(s.val().trim());e===t.RgbaChannel.Alpha?o>=0&&o<=100&&(i=t.ColorUtils.updateChannelOfRgba(this.previewColor(),e,o/100)):o>=0&&o<=255&&(i=t.ColorUtils.updateChannelOfRgba(this.previewColor(),e,o)),i&&(n.stopPropagation(),"change"===n.type?this.selectColor(i):this.previewColor(i))},i.prototype.onPredefinedColorClick=function(e){var n=this.binding.allowAlphaChannel;e.stopPropagation(),this.selectColor(t.ColorUtils.parseHexColor(ko.dataFor(e.currentTarget),n))},i.prototype.onSelectedColorChange=function(e){var n=this.binding.allowAlphaChannel;this.onSelectedRgbaColorChange(t.ColorUtils.tryParseHexColor(e,n)[1])},i.prototype.onSelectedRgbaColorChange=function(e){if(!this.binding.allowAlphaChannel&&e&&e.Alpha()<1)throw Error("The SelectedRgbaColor.Alpha channel must be equal to 1 when Alpha channel is not allowed. The current value is '"+e.Alpha()+"'.");this.$element.toggleClass(t.BusinessPackCss.bpStateEmptyValue,!e),this.previewColor(e||this.nullColor)},i.prototype.onPreviewColorChange=function(e){if(this.$colorPreview.css("background",t.ColorUtils.rgbaToCssColor(e)),this.$alphaSlider.css("background",this.getAlphaGradient(e)),!this.isChangingColor){var n=t.ColorUtils.rgbaToHsvaColor(e);this.isLoadingColor=!0,this.setColorGripPosition(n),this.alpha(n.Alpha()),this.hue(n.Hue()),this.isLoadingColor=!1}this.setColorEditorValues(e)},i.prototype.onHueChange=function(e,n){var i=t.ColorUtils.hueToCssColor(e);this.$colorSpectrum.css("background",this.getColorSpectrumGradient(i)),this.isLoadingColor||n||(this.isChangingColor=!0,this.previewColor(t.ColorUtils.updateHueOfRgba(this.previewColor(),e)),this.isChangingColor=!1)},i.prototype.onAlphaChange=function(e,n){this.isLoadingColor||n||(this.isChangingColor=!0,this.previewColor(t.ColorUtils.updateChannelOfRgba(this.previewColor(),t.RgbaChannel.Alpha,e)),this.isChangingColor=!1)},i.prototype.moveColorGripToMousePosition=function(t,e){var n=this.$colorSpectrum.offset(),i=this.$colorSpectrum.width(),s=this.$colorSpectrum.height(),o=t-n.left,r=e-n.top;o<0?o=0:o>i&&(o=i),r<0?r=0:r>s&&(r=s),o-=this.$colorGrip.outerWidth()/2,r-=this.$colorGrip.outerHeight()/2,this.$colorGrip.css({left:o,top:r}),this.previewColorFromColorGrip()},i.prototype.getColorSpectrumGradient=function(t){return"linear-gradient(to top, #000, rgba(0, 0, 0, 0)), linear-gradient(to right, #FFF, rgba(255, 255, 255, 0)), linear-gradient("+t+", "+t+")"},i.prototype.getAlphaGradient=function(e){return"linear-gradient(to right, "+("rgba("+(e=t.ColorUtils.updateChannelOfRgba(e,t.RgbaChannel.Alpha,1)).Red()+", "+e.Green()+", "+e.Blue()+", 0)")+", "+t.ColorUtils.rgbaToCssColor(e)+")"},i.prototype.previewColorFromColorGrip=function(){var e=this.$colorGrip.position(),n=this.$colorSpectrum.width(),i=this.$colorSpectrum.height(),s=100*(e.left+this.$colorGrip.outerWidth()/2)/n,o=100*(i-(e.top+this.$colorGrip.outerHeight()/2))/i,r=t.ColorUtils.createHsvaColor(this.hue(),s,o,this.alpha()),a=t.ColorUtils.hsvaToRgbaColor(r);this.previewColor(a)},i.prototype.setColorGripPosition=function(t){var e=this.$colorSpectrum.width(),n=this.$colorSpectrum.height(),i=t.Saturation()*e/100,s=n-t.Value()*n/100;i-=this.$colorGrip.outerWidth()/2,s-=this.$colorGrip.outerHeight()/2,this.$colorGrip.css({left:i,top:s})},i.prototype.setColorEditorValues=function(e){this.$hexColorInput.val(t.ColorUtils.rgbaToHexColor(e)),this.$redChannelInput.val(e.Red()),this.$greenChannelInput.val(e.Green()),this.$blueChannelInput.val(e.Blue()),this.$alphaChannelInput.val((100*e.Alpha()).toFixed(0))},i.prototype.getColorButtonCssClasses=function(e){var n=this.binding.allowAlphaChannel,i=t.ColorUtils.parseHexColor(e,n);return s={},s[t.BusinessPackCss.bpStateSelected]=this.isSelected(i),s;var s},i.prototype.getColorButtonCssStyle=function(e){var n=this.binding.allowAlphaChannel,i=t.ColorUtils.parseHexColor(e,n);return{"background-color":t.ColorUtils.rgbaToCssColor(i)}},i.prototype.selectPreviewColor=function(){this.selectColor(this.previewColor())},i}(e.EditorBase);e.ColorPicker=n,t.Utils.installBindingHandler("ColorPicker",n)}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(n){function i(){var t=null!==n&&n.apply(this,arguments)||this;return t.focusedItemKey=ko.observable(),t.selectedItemKey=ko.observable(),t}return __extends(i,n),Object.defineProperty(i.prototype,"isOpened",{get:function(){return this.popupPanel.isOpened},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"hasValue",{get:function(){var t=this.binding.text();return null!=this.binding.selectedValue()||null!=t&&t.length},enumerable:!0,configurable:!0}),i.prototype.initialize=function(){var i=this;n.prototype.initialize.call(this),this.binding.text=t.Utils.ensureObservable(this.binding.text),this.$textBox=this.$element.children("."+t.BusinessPackCss.bpTextBox),this.$unselectButton=this.$element.children("."+t.BusinessPackCss.bpUnselect),this.$toggleButton=this.$element.children("."+t.BusinessPackCss.bpToggle),this.$popup=this.$element.children("."+t.BusinessPackCss.bpPopup),this.$results=this.$popup.children("ul"),this.popupPanel=new e.PopupPanel(this.$popup),this.$element.keydown(this.onElementKeydown.bind(this)),this.$textBox.focus(this.onTextBoxFocus.bind(this)),this.$textBox.blur(this.onTextBoxBlur.bind(this)),this.$textBox.keydown(this.onTextBoxKeydown.bind(this)),this.$textBox.input(this.onTextBoxInput.bind(this)),this.$popup.mousedown(function(t){return t.preventDefault()}),this.$results.on("click","."+t.BusinessPackCss.bpItem+":not(."+t.BusinessPackCss.bpStateDisabled+")",this.onResultClick.bind(this)),this.$unselectButton.mousedown(function(t){return t.preventDefault()}),this.$unselectButton.click(this.onUnselectButtonClick.bind(this)),this.$toggleButton.mousedown(function(t){return t.preventDefault()}),this.$toggleButton.click(this.onToggleButtonClick.bind(this)),this.outside("click",function(){return i.popupPanel.close()}),this.subscribe(this.binding.text,this.onTextChange),this.watch(this.binding.selectedValue,this.onSelectedValueChange),this.subscribe(this.searchResults,this.onSearchResultsChange)},i.prototype.togglePopup=function(t){void 0===t&&(t=!this.isOpened);var e=t&&this.isEnabled;e&&!this.isOpened&&this.search(null),this.popupPanel.toggle(e)},i.prototype.focusItem=function(t){this.isItemEnabled(t)&&this.focusedItemKey(this.getItemKey(t))},i.prototype.isFocused=function(t){return this.getItemKey(t)===this.focusedItemKey()},i.prototype.getFocusedItem=function(){return this.findItemByKey(this.focusedItemKey)},i.prototype.unfocusAllItems=function(){this.focusedItemKey(null)},i.prototype.selectCurrentText=function(){var e=this.$textBox.val(),n=this.binding.allowUnselect,i=ko.unwrap(this.binding.allowNewItem),s=this.findItemByText(e);if(null==s)if(this.togglePopup(!1),e.trim().length)if(i){var o=this.binding.itemValueBinding;if(!t.Utils.isDataAccessor(o))throw Error("The ItemValueBinding must not be set when AllowNewItem is enabled.");this.selectItem(this.createItemFromText(e))}else this.resetText();else{var r=this.binding.selectedValue();n&&null!==r?(this.binding.selectedValue(null),ko.isWriteableObservable(this.binding.text)&&this.binding.text(""),this.postback(this.binding.changed)):this.resetText()}else this.selectItem(s)},i.prototype.selectItem=function(t){this.togglePopup(!1),this.isItemEnabled(t)&&!this.isSelected(t)?(t=this.findItemInDataSourceOrAdd(t),this.binding.selectedValue(this.getItemValueCopy(t)),this.postback(this.binding.changed)):this.resetText(),this.search(null),this.focusItem(t)},i.prototype.isSelected=function(t){return this.getItemKey(t)===this.selectedItemKey()},i.prototype.getSelectedItem=function(){return this.findItemByKey(this.selectedItemKey)},i.prototype.unselectItem=function(){this.hasValue&&(this.$textBox.val(""),this.selectCurrentText()),this.search(null)},i.prototype.onElementKeydown=function(e){this.isEnabled&&(this.isOpened?e.which===t.KeyboardKeys.esc?(e.stopPropagation(),this.togglePopup(!1)):t.KeyboardKeys.isEnter(e.which)?e.stopPropagationAndPreventDefault():e.which===t.KeyboardKeys.tab?e.stopPropagation():e.which===t.KeyboardKeys.down?(e.stopPropagation(),this.focusNextItem()):e.which===t.KeyboardKeys.up&&(e.stopPropagation(),this.focusPrevItem()):e.which===t.KeyboardKeys.down?(e.stopPropagation(),e.altKey?this.togglePopup(!0):this.selectNextItem()):e.which===t.KeyboardKeys.up&&(e.stopPropagation(),this.selectPrevItem()),(t.KeyboardKeys.isEnter(e.which)||e.which===t.KeyboardKeys.tab)&&this.selectFocusedItemOrCurrentText())},i.prototype.onTextBoxFocus=function(){this.$textBox.select(),this.$element.addClass(t.BusinessPackCss.bpStateFocused)},i.prototype.onTextBoxBlur=function(){this.selectCurrentText(),this.$element.removeClass(t.BusinessPackCss.bpStateFocused),this.togglePopup(!1)},i.prototype.onTextBoxKeydown=function(e){this.isOpened&&t.KeyboardKeys.isUpOrDown(e.which)&&e.preventDefault()},i.prototype.onTextBoxInput=function(e){var n=this.$textBox.val();e.stopPropagation(),!n&&t.KeyboardKeys.isDeleteOrBackspace(e.which)||this.togglePopup(!0),this.search(n)},i.prototype.onResultClick=function(t){$(t.currentTarget).parent().is(this.$results)&&(t.stopPropagation(),this.selectItem(ko.dataFor(t.currentTarget)))},i.prototype.onUnselectButtonClick=function(t){this.isEnabled&&(t.stopPropagation(),this.unselectItem())},i.prototype.onToggleButtonClick=function(t){this.isEnabled&&(t.stopPropagation(),this.$textBox.focus(),this.togglePopup())},i.prototype.onTextChange=function(e){this.$element.toggleClass(t.BusinessPackCss.bpStateEmptyValue,!e)},i.prototype.onSelectedValueChange=function(e){var n=this.findItemByValue(e);this.$element.toggleClass(t.BusinessPackCss.bpStateEmptyValue,null==e),n?(this.selectedItemKey(this.getItemKey(n)),ko.isWriteableObservable(this.binding.text)&&this.binding.text(this.getItemText(n))):(null!=e&&this.warnThatValueWasNotFound(e),this.selectedItemKey(null),ko.isWriteableObservable(this.binding.text)&&this.binding.text(""))},i.prototype.onSearchResultsChange=function(t){var e=this,n=this.getFocusedItem(),i=this.binding.loadItemsMode,s=ko.unwrap(this.binding.allowNewItem);if(this.$textBox.val().length?this.hasBeenFound(n)||(s?this.unfocusAllItems():this.focusFirstSearchResult()):this.unfocusAllItems(),"Replace"===i){var o=t.map(function(t){return e.getItemKey(t)});this.removeAllItemsExcept(o.concat(this.selectedItemKey()))}},i.prototype.focusPrevItem=function(){var e=this.$results.children("."+t.BusinessPackCss.bpItem+"."+t.BusinessPackCss.bpStateFocused).prevAll(":not(."+t.BusinessPackCss.bpStateDisabled+"):first");e.length&&(this.scrollToItem(e),this.focusItem(ko.dataFor(e[0])))},i.prototype.focusNextItem=function(){var e=this.$results.children("."+t.BusinessPackCss.bpItem+"."+t.BusinessPackCss.bpStateFocused),n=e.nextAll(":not(."+t.BusinessPackCss.bpStateDisabled+"):first");n.length||e.length||(n=this.$results.children("."+t.BusinessPackCss.bpItem+":not(."+t.BusinessPackCss.bpStateDisabled+"):first")),n.length&&(this.scrollToItem(n),this.focusItem(ko.dataFor(n[0])))},i.prototype.scrollToItem=function(t){var e=this.$results.innerHeight(),n=parseInt(this.$results.css("padding-top")),i=parseInt(this.$results.css("padding-bottom")),s=parseInt(t.css("margin-top")),o=parseInt(t.css("margin-bottom")),r=t.is(":first-child")?n:s,a=t.is(":last-child")?i:o,l=t.position().top,u=l+t.outerHeight(!0),c=this.$results.scrollTop();u>e?this.$results.scrollTop(c+(u-e)+a):l<0&&this.$results.scrollTop(c+l-r)},i.prototype.focusFirstSearchResult=function(){var t=this.searchResults()[0];t?this.focusItem(t()):this.unfocusAllItems()},i.prototype.selectPrevItem=function(){var e=this.$results.children("."+t.BusinessPackCss.bpItem+"."+t.BusinessPackCss.bpStateSelected).prev(":not(."+t.BusinessPackCss.bpStateDisabled+")");e.length&&this.selectItem(ko.dataFor(e[0]))},i.prototype.selectNextItem=function(){var e=this.$results.children("li."+t.BusinessPackCss.bpStateSelected),n=e.next(":not(."+t.BusinessPackCss.bpStateDisabled+")");n.length||e.length||(n=this.$results.children("."+t.BusinessPackCss.bpItem+":not(."+t.BusinessPackCss.bpStateDisabled+"):first")),n.length&&this.selectItem(ko.dataFor(n[0]))},i.prototype.canSelectFocusedItem=function(){var t=this.getFocusedItem();return this.isOpened&&t&&!this.isSelected(t)},i.prototype.selectFocusedItemOrCurrentText=function(){var t=this.getFocusedItem();this.isOpened&&t?this.selectItem(t):this.selectCurrentText()},i.prototype.getItemStyle=function(e){e=ko.unwrap(e);var n={};return n[t.BusinessPackCss.bpStateDisabled]=!this.isItemEnabled(e),n[t.BusinessPackCss.bpStateFocused]=this.isFocused(e),n[t.BusinessPackCss.bpStateSelected]=this.isSelected(e),n},i.prototype.resetText=function(){var t=this.getSelectedItem(),e=ko.unwrap(this.binding.allowNewItem);ko.isWriteableObservable(this.binding.text)&&(t?this.binding.text(this.getItemText(t)):e||this.binding.text(""))},i}(e.SelectorBase);e.ComboBox=n,t.Utils.installBindingHandler("ComboBox",n)}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=3,i=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.shortcutHits=n,e}return __extends(e,t),e.prototype.initialize=function(){t.prototype.initialize.call(this),this.$document.on("keydown"+this.eventNs,this.onDocumentKeydown.bind(this)),this.$document.on("keyup"+this.eventNs,this.onDocumentKeyup.bind(this))},e.prototype.onDocumentKeydown=function(t){this.isEnabled&&this.wasShortcutPressed(t)&&(t.preventDefault(),this.shortcutHits<n?this.shortcutHits++:(this.postback(this.binding.command),this.shortcutHits=0))},e.prototype.onDocumentKeyup=function(t){this.shortcutHits=n},e.prototype.wasShortcutPressed=function(t){var e=this.binding,n=e.key,i=e.ctrl,s=e.alt,o=e.shift;return t.which===n&&t.altKey===s&&t.ctrlKey===i&&t.shiftKey===o},e}(e.ControlBase);e.CommandShortcut=i,t.Utils.installBindingHandler("CommandShortcut",i)}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){!function(n){function i(){return s().cultures[dotvvm.culture]}function s(){return window.Globalize||window.dotvvm_Globalize}function o(t,e){return(i().calendars.standard.patterns.t.indexOf("tt")>=0?((t+11)%12+1).toString():t.toString())+":"+(e<10?"0"+e.toString():e.toString())}function r(t,e){var n=i();return-1===n.calendars.standard.patterns.t.indexOf("tt")?null:t<12?n.calendars.standard.AM[0]:n.calendars.standard.PM[0]}function a(t,e){var n=new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes()),i=new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes()+1);return t>=n&&t<i}function l(t,e){var n=new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours()),i=new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours()+1);return t>=n&&t<i}function u(t,e){var n=new Date(e.getFullYear(),e.getMonth(),e.getDate()),i=new Date(e.getFullYear(),e.getMonth(),e.getDate()+1);return t>=n&&t<i}function c(t,e){var n=new Date(e.getFullYear(),e.getMonth(),1),i=new Date(e.getFullYear(),e.getMonth()+1,1);return t>=n&&t<i}function h(t,e){var n=new Date(e.getFullYear(),0,1),i=new Date(e.getFullYear()+1,0,1);return t>=n&&t<i}n.getCulture=i,n.getGlobalizeLibrary=s,n.convertStringDayOfWeekToNumber=function(t){switch(t){case"Sunday":return 0;case"Monday":return 1;case"Tuesday":return 2;case"Wednesday":return 3;case"Thursday":return 4;case"Friday":return 5;case"Saturday":return 6;default:return}},n.parseDate=function(t){if(null==t||""===t)return null;var e=dotvvm.globalize.parseDotvvmDate(t);return null==e&&(e=s().parseDate(t,null,i())),null==e&&(e=new Date(t)),e},n.buildFullTimeText=function(t,e){var n=o(t,e),i=r(t);return null==i?n:n+" "+i},n.buildShortTimeText=o,n.buildAmPmString=r,n.getTotalCountOfElapsedMsInDay=function(t){return 36e5*t.getHours()+6e4*t.getMinutes()+1e3*t.getSeconds()+t.getMilliseconds()},n.getStartAndEndOfTheDateInMs=function(t,n){var i,s;switch(n){case e.DateRangeType.Year:i=new Date(t.getFullYear(),0,1,0,0,0).getTime(),s=new Date(t.getFullYear()+1,0,1,0,0,0).getTime()-1;break;case e.DateRangeType.Month:i=new Date(t.getFullYear(),t.getMonth(),1,0,0,0).getTime(),s=new Date(t.getFullYear(),t.getMonth()+1,1,0,0,0).getTime()-1;break;case e.DateRangeType.Date:i=new Date(t.getFullYear(),t.getMonth(),t.getDate(),0,0,0).getTime(),s=new Date(t.getFullYear(),t.getMonth(),t.getDate()+1,0,0,0).getTime()-1;break;case e.DateRangeType.Hour:i=new Date(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),0,0).getTime(),s=new Date(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours()+1,0,0).getTime()-1;break;case e.DateRangeType.Minute:i=new Date(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes()).getTime(),s=new Date(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes()+1).getTime()-1;break;default:i=t.getTime(),s=t.getTime()}return{start:i,end:s}},n.createCopy=function(t){return null==t?null:new Date(t.getTime())},n.areDatesEqual=function(t,e){return t===e||(null==e||null==t?e===t:null!=e&&null!=t&&e.getTime()===t.getTime())},n.isWeekend=function(t){return 0===t.getDay()||6===t.getDay()},n.isDateInGivenMinute=a,n.isDateInDateRangeOfCell=function(t,n,i){switch(i){case e.DateRangeType.Year:return h(t,n);case e.DateRangeType.Month:return c(t,n);case e.DateRangeType.Date:return u(t,n);case e.DateRangeType.Hour:return l(t,n);case e.DateRangeType.Minute:return a(t,n)}},n.isDateInGivenHour=l,n.isDateInGivenDay=u,n.isDateInGivenMonth=c,n.isDateInGivenYear=h,n.getNextOccuranceOfDayOfWeek=function(e,n){(n>6||n<0)&&t.Utils.warnInDebugMode("Given day of week is invalid!");var i=new Date(e.getFullYear(),e.getMonth(),e.getDate());return i.setDate(e.getDate()+(7+n-e.getDay())%7),i}}(e.DateHelper||(e.DateHelper={}))}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(){function n(t,n){this.enabled=!0,this.dateValidator=t,this.observers=new Array,this.calendarType=n,this._currentViewType=n===e.CalendarMode.Time?e.DateRangeType.Hour:e.DateRangeType.Date}return Object.defineProperty(n.prototype,"currentlyDisplayedDate",{get:function(){return this._currentlyDisplayedDate},set:function(t){this._currentlyDisplayedDate=e.DateHelper.createCopy(t)},enumerable:!0,configurable:!0}),n.prototype.getCurrentlyDisplayedDate=function(){return e.DateHelper.createCopy(this.currentlyDisplayedDate)},n.prototype.setCurrentlyDisplayedDate=function(t){this.currentlyDisplayedDate=this.getFirstPossibleDateToShow(t)},Object.defineProperty(n.prototype,"currentlyDisplayedYear",{get:function(){return this.currentlyDisplayedDate.getFullYear()},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"currentlyDisplayedMonth",{get:function(){return this.currentlyDisplayedDate.getMonth()},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"currentlyDisplayedDay",{get:function(){return this.currentlyDisplayedDate.getDate()},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"currentlyDisplayedHour",{get:function(){return this.currentlyDisplayedDate.getHours()},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"currentlyDisplayedMinute",{get:function(){return this.currentlyDisplayedDate.getMinutes()},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"currentViewType",{get:function(){return this._currentViewType},set:function(t){this._currentViewType=t},enumerable:!0,configurable:!0}),n.prototype.getCurrentViewType=function(){return this._currentViewType},n.prototype.setCurrentViewType=function(t){null!=this._currentViewType&&null!=t||(this.calendarType===e.CalendarMode.Time?this.currentViewType=e.DateRangeType.Hour:this.currentViewType=e.DateRangeType.Date),this.calendarType!==e.CalendarMode.Time||t!==e.DateRangeType.Date&&t!==e.DateRangeType.Month&&t!==e.DateRangeType.Year?this.calendarType!==e.CalendarMode.Date||t!==e.DateRangeType.Hour&&t!==e.DateRangeType.Minute?null!=t&&(this._currentViewType=t):this._currentViewType=e.DateRangeType.Date:this._currentViewType=e.DateRangeType.Hour},n.prototype.getCalendarType=function(){return this.calendarType},n.prototype.setCalendarType=function(t){this.calendarType=t,this.setCurrentViewType(this.currentViewType)},n.prototype.subscribe=function(t){this.observers.push(t)},n.prototype.unsubscribe=function(t){var e=this.observers.indexOf(t,0);e>-1&&this.observers.splice(e,1)},n.prototype.notifyObservers=function(t){void 0===t&&(t=e.ChangeType.Complete);for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];this.observers.forEach(function(e){return e.notify.apply(e,[t].concat(n))})},n.prototype.render=function(t,n,i){this.globalizeLibrary=e.DateHelper.getGlobalizeLibrary(),this.culture=e.DateHelper.getCulture(),null!=i&&this.setCurrentViewType(i),null!=n&&this.setCurrentlyDisplayedDate(n),this.$element=$(t),this.createCalendar()},n.prototype.update=function(){null!=this.$element&&this.createCalendar()},n.prototype.getFirstPossibleDateToShow=function(t){if(null!=t&&this.dateValidator.isDateInValidRange(t))return t;if(null!=this.currentlyDisplayedDate&&this.dateValidator.isDateInValidRange(this.currentlyDisplayedDate))return this.currentlyDisplayedDate;var e=new Date;return this.dateValidator.isDateInValidRange(e)||(e=new Date(this.dateValidator.minDate.getTime())),e},n.prototype.createCalendar=function(){switch(null==this.currentlyDisplayedDate&&this.setCurrentlyDisplayedDate(null),this.currentViewType){case e.DateRangeType.Year:this.initYearSelector();break;case e.DateRangeType.Month:this.initMonthSelector();break;case e.DateRangeType.Date:this.initDateSelector();break;case e.DateRangeType.Hour:this.initHourSelector();break;case e.DateRangeType.Minute:this.initMinuteSelector()}},n.prototype.updateCalendarTable=function(e){var n=$(":focus");this.$element.empty(),this.$element.append(e),0==$(":focus").length&&n.parents("."+t.BusinessPackCss.bpCalendar)&&this.$element.focus(),this.calendarRendered()},n.prototype.initMinuteSelector=function(){var n=this;this._currentViewType=e.DateRangeType.Minute;var i=this.createTable().addClass(""+t.BusinessPackCss.bpMinuteSelector),s=this.createTableThead(),o=this.createTableTbody(),r=new Date(this.currentlyDisplayedYear,this.currentlyDisplayedMonth,this.currentlyDisplayedDay,this.currentlyDisplayedHour-1),a=!(this.calendarType===e.CalendarMode.Time&&this.currentlyDisplayedDay!==r.getDate())&&this.dateValidator.isHourInValidRange(r),l=new Date(this.currentlyDisplayedYear,this.currentlyDisplayedMonth,this.currentlyDisplayedDay,this.currentlyDisplayedHour+1),u=!(this.calendarType===e.CalendarMode.Time&&this.currentlyDisplayedDay!==l.getDate())&&this.dateValidator.isHourInValidRange(l),c=this.createRow();a?c.append(this.createPrevLinkCell(function(){return n.changeMinutesPage(-1)})):c.append(c.append(this.createHeaderCell("").addClass(t.BusinessPackCss.bpStateEmptyData))),c.append(this.createLinkCell(e.DateHelper.buildFullTimeText(this.currentlyDisplayedHour,0),function(){return n.initHourSelector()},!1,!u&&!a,!1,!0).attr("colspan",2)),u?c.append(this.createNextLinkCell(function(){return n.changeMinutesPage(1)})):c.append(c.append(this.createHeaderCell("").addClass(t.BusinessPackCss.bpStateEmptyData))),c.addClass(""+t.BusinessPackCss.bpHeader),s.append(c),i.append(s);for(var h=0;h<6;h++){for(var p=this.createRow(),d=0;d<2;d++)!function(t){p.append(n.createMinuteCell(new Date(n.currentlyDisplayedYear,n.currentlyDisplayedMonth,n.currentlyDisplayedDay,n.currentlyDisplayedHour,t,0,0)).attr("colspan",2))}(5*(2*h+d));o.append(p)}i.append(o),this.updateCalendarTable(i)},n.prototype.initHourSelector=function(){var n=this;this._currentViewType=e.DateRangeType.Hour;var i=this.createTable().addClass(""+t.BusinessPackCss.bpHourSelector),s=this.createTableThead(),o=this.createTableTbody();if(this.calendarType!==e.CalendarMode.Time){var r=this.dateValidator.isDayInValidRange(new Date(this.currentlyDisplayedYear,this.currentlyDisplayedMonth,this.currentlyDisplayedDay-1)),a=this.dateValidator.isDayInValidRange(new Date(this.currentlyDisplayedYear,this.currentlyDisplayedMonth,this.currentlyDisplayedDay+1)),l=this.createRow();r?l.append(this.createPrevLinkCell(function(){return n.changeHoursPage(-1)})):l.append(l.append(this.createHeaderCell("").addClass(t.BusinessPackCss.bpStateEmptyData))),l.append(this.createLinkCell(dotvvm.globalize.formatString("d",this.currentlyDisplayedDate),function(){return n.initDateSelector()},!1,!a&&!r,!1,!0).attr("colspan",2)),a?l.append(this.createNextLinkCell(function(){return n.changeHoursPage(1)})):l.append(l.append(this.createHeaderCell("").addClass(t.BusinessPackCss.bpStateEmptyData))),l.addClass(""+t.BusinessPackCss.bpHeader),s.append(l),i.append(s)}for(var u=0;u<6;u++){for(var c=this.createRow(),h=0;h<4;h++)!function(t){c.append(n.createHourCell(new Date(n.currentlyDisplayedYear,n.currentlyDisplayedMonth,n.currentlyDisplayedDay,t,0,0,0)))}(4*u+h);o.append(c)}i.append(o),this.updateCalendarTable(i)},n.prototype.initDateSelector=function(){var n=this;this._currentViewType=e.DateRangeType.Date;var i=this.createTable().addClass(""+t.BusinessPackCss.bpDateSelector),s=this.createTableThead(),o=this.createTableTbody(),r=this.dateValidator.isMonthInValidRange(new Date(this.currentlyDisplayedYear,this.currentlyDisplayedMonth-1,1)),a=this.dateValidator.isMonthInValidRange(new Date(this.currentlyDisplayedYear,this.currentlyDisplayedMonth+1,1)),l=this.createRow();r?l.append(this.createPrevLinkCell(function(){return n.changeDatesPage(-1)})):l.append(l.append(this.createHeaderCell("").addClass(t.BusinessPackCss.bpStateEmptyData))),l.append(this.createLinkCell(dotvvm.globalize.formatString("MMMM yyyy",new Date(this.currentlyDisplayedYear,this.currentlyDisplayedMonth,1)),function(){return n.initMonthSelector()},!1,!a&&!r,!1,!0).attr("colspan",5)),a?l.append(this.createNextLinkCell(function(){return n.changeDatesPage(1)})):l.append(l.append(this.createHeaderCell("").addClass(t.BusinessPackCss.bpStateEmptyData))),l.addClass(""+t.BusinessPackCss.bpHeader),s.append(l);for(var u=this.createRow(),c=0;c<7;c++){var h=this.culture.calendars.standard.days.namesShort[(this.culture.calendars.standard.firstDay+c)%7];u.append(this.createHeaderCell(h))}u.addClass(""+t.BusinessPackCss.bpMonth),s.append(u),i.append(s);for(var p=new Date(this.currentlyDisplayedYear,this.currentlyDisplayedMonth,1);p.getDay()!==this.culture.calendars.standard.firstDay;)p=new Date(p.getFullYear(),p.getMonth(),p.getDate()-1);do{for(var d=this.createRow(),c=0;c<7;c++)!function(t){d.append(n.createDateCell(t))}(p),p=new Date(p.getFullYear(),p.getMonth(),p.getDate()+1);o.append(d)}while(p.getMonth()===this.currentlyDisplayedMonth);i.append(o),this.updateCalendarTable(i)},n.prototype.initMonthSelector=function(){var n=this;this._currentViewType=e.DateRangeType.Month;var i=this.createTable().addClass(""+t.BusinessPackCss.bpMonthSelector),s=this.createTableThead(),o=this.createTableTbody(),r=this.dateValidator.isYearInValidRange(new Date(this.currentlyDisplayedYear-1,0,1)),a=this.dateValidator.isYearInValidRange(new Date(this.currentlyDisplayedYear+1,0,1)),l=this.createRow();r?l.append(this.createPrevLinkCell(function(){return n.changeMonthsPage(-1)})):l.append(l.append(this.createHeaderCell("").addClass(t.BusinessPackCss.bpStateEmptyData))),l.append(this.createLinkCell(this.currentlyDisplayedYear.toString(),function(){return n.initYearSelector()},!1,!a&&!r,!1,!0).attr("colspan",4)),a?l.append(this.createNextLinkCell(function(){return n.changeMonthsPage(1)})):l.append(l.append(this.createHeaderCell("").addClass(t.BusinessPackCss.bpStateEmptyData))),l.addClass(""+t.BusinessPackCss.bpHeader),s.append(l),i.append(s);for(var u=0;u<4;u++){for(var c=this.createRow(),h=0;h<3;h++)!function(t){c.append(n.createMonthCell(new Date(n.currentlyDisplayedYear,t,1,0,0,0,0)).attr("colspan",2))}(3*u+h);o.append(c)}i.append(o),this.updateCalendarTable(i)},n.prototype.initYearSelector=function(){var n=this;this._currentViewType=e.DateRangeType.Year;var i=this.createTable().addClass(""+t.BusinessPackCss.bpYearSelector),s=this.createTableThead(),o=this.createTableTbody(),r=16*Math.floor(this.currentlyDisplayedYear/16),a=this.createRow();this.dateValidator.isYearInValidRange(new Date(r-1,0,1))?a.append(this.createPrevLinkCell(function(){return n.changeYearsPage(-1)})):a.append(a.append(this.createHeaderCell("").addClass(t.BusinessPackCss.bpStateEmptyData))),a.append(this.createHeaderCell("").attr("colspan",2).addClass(t.BusinessPackCss.bpStateEmptyData)),this.dateValidator.isYearInValidRange(new Date(r+16,0,1))?a.append(this.createNextLinkCell(function(){return n.changeYearsPage(1)})):a.append(this.createHeaderCell("").addClass(t.BusinessPackCss.bpStateEmptyData)),a.addClass(""+t.BusinessPackCss.bpHeader),s.append(a),i.append(s);for(var l=0;l<4;l++){for(var u=this.createRow(),c=0;c<4;c++)!function(t){u.append(n.createYearCell(new Date(t,0,1,0,0,0,0)))}(r+4*l+c);o.append(u)}i.append(o),this.updateCalendarTable(i)},n.prototype.calendarRendered=function(){},n.prototype.createYearCell=function(t,n){var i=this;void 0===n&&(n=!1);var s=this.dateValidator.isYearInValidRange(t),o=s&&!this.dateValidator.doesDatePassAllRestrictions(t,e.DateRangeType.Year).doesDatePassRestrictions;return this.createLinkCell(t.getFullYear().toString(),function(){i.currentlyDisplayedDate=t,i.selectYear(t)},n,!s,o)},n.prototype.createMonthCell=function(t,n){var i=this;void 0===n&&(n=!1);var s=this.culture.calendars.standard.months.names[t.getMonth()],o=this.dateValidator.isMonthInValidRange(t),r=o&&!this.dateValidator.doesDatePassAllRestrictions(t,e.DateRangeType.Month).doesDatePassRestrictions;return this.createLinkCell(s,function(){i.currentlyDisplayedDate=t,i.selectMonth(t)},n,!o,r)},n.prototype.createDateCell=function(n,i){var s=this;void 0===i&&(i=!1);var o=this.dateValidator.isDayInValidRange(n),r=o&&!this.dateValidator.doesDatePassAllRestrictions(n,e.DateRangeType.Date).doesDatePassRestrictions,a=this.currentlyDisplayedMonth!==n.getMonth(),l=this.createLinkCell(n.getDate().toString(),function(){a&&s.calendarType===e.CalendarMode.Date||(s.currentlyDisplayedDate=n),s.selectDay(n)},i,!o||r&&this.calendarType===e.CalendarMode.Date,r);return a&&l.addClass(""+t.BusinessPackCss.bpOtherMonth),e.DateHelper.isWeekend(n)&&l.addClass(""+t.BusinessPackCss.bpWeekend),l},n.prototype.changeMinutesPage=function(t){this.currentlyDisplayedDate.setHours(this.currentlyDisplayedHour+t,0,0,0),this.initMinuteSelector()},n.prototype.changeHoursPage=function(t){this.currentlyDisplayedDate.setDate(this.currentlyDisplayedDay+t),this.initHourSelector()},n.prototype.changeDatesPage=function(t){this.currentlyDisplayedDate.setMonth(this.currentlyDisplayedMonth+t,1),this.initDateSelector()},n.prototype.changeMonthsPage=function(t){this.currentlyDisplayedDate.setFullYear(this.currentlyDisplayedYear+t,0,1),this.initMonthSelector()},n.prototype.changeYearsPage=function(t){this.currentlyDisplayedDate.setFullYear(this.currentlyDisplayedYear+16*t,0,1),this.initYearSelector()},n.prototype.createHourCell=function(t,n){var i=this;void 0===n&&(n=!1);var s=e.DateHelper.buildShortTimeText(t.getHours(),t.getMinutes()),o=e.DateHelper.buildAmPmString(t.getHours(),t.getMinutes()),r=this.dateValidator.isHourInValidRange(t),a=r&&!this.dateValidator.doesDatePassAllRestrictions(t,e.DateRangeType.Hour).doesDatePassRestrictions,l=this.createLinkCell("",function(){i.currentlyDisplayedDate=t,i.selectHour(t)},n,!r,a),u=$("<span></span>").text(s),c=l.children("a");if(0==c.length&&(c=l.children("span")),c.append(u),null!=o){var h=$("<span></span>").text(o);c.append(h),l.addClass("double-line")}return l},n.prototype.createMinuteCell=function(t,n){var i=this;void 0===n&&(n=!1);var s=e.DateHelper.buildShortTimeText(t.getHours(),t.getMinutes()),o=e.DateHelper.buildAmPmString(t.getHours(),t.getMinutes()),r=this.dateValidator.isMinuteInValidRange(t),a=r&&!this.dateValidator.doesDatePassAllRestrictions(t,e.DateRangeType.Date).doesDatePassRestrictions,l=this.createLinkCell("",function(){i.currentlyDisplayedDate=t,i.selectMinute(t)},n,!r,a),u=$("<span></span>").text(s),c=l.children("a");if(0==c.length&&(c=l.children("span")),c.append(u),null!=o){var h=$("<span></span>").text(o);c.append(h),l.addClass("double-line")}return l},n.prototype.createCell=function(t){return $("<td></td>").append($("<span></span>").text(t))},n.prototype.createHeaderCell=function(t){return $("<th></th>").append($("<span></span>").text(t))},n.prototype.createLinkCell=function(e,n,i,s,o,r){void 0===i&&(i=!1),void 0===s&&(s=!1),void 0===o&&(o=!1),void 0===r&&(r=!1);var a;a=s||!this.enabled?$("<span></span>").text(e):this.createLink(e,n);var l;return l=r?$("<th></th>"):$("<td></td>"),!s&&this.enabled||l.addClass(t.BusinessPackCss.bpStateDisabled),i&&l.addClass(t.BusinessPackCss.bpStateActive),o&&l.addClass(t.BusinessPackCss.bpStatePartiallyDisabled),l.append(a),l},n.prototype.createPrevLinkCell=function(e){return $("<th></th>").append(this.createEmptyLink(e).append($("<span></span>").addClass("fa fa-arrow-left"))).addClass(""+t.BusinessPackCss.bpPrev)},n.prototype.createNextLinkCell=function(e){return $("<th></th>").append(this.createEmptyLink(e).append($("<span></span>").addClass("fa fa-arrow-right"))).addClass(""+t.BusinessPackCss.bpNext)},n.prototype.createLink=function(t,e){return this.createEmptyLink(e).text(t)},n.prototype.createEmptyLink=function(t){var e=$("<a></a>");return this.enabled&&e.attr({href:"javascript:;",tabindex:-1}).on("click",function(e){t(),e.stopPropagation()}),e},n.prototype.createRow=function(){return $("<tr></tr>")},n.prototype.createTable=function(){return $("<table></table>").addClass(t.BusinessPackCss.bpCalendar)},n.prototype.createTableThead=function(){return $("<thead></thead>")},n.prototype.createTableTbody=function(){return $("<tbody></tbody>")},n}();e.CalendarBase=n}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(n){function i(){return null!==n&&n.apply(this,arguments)||this}return __extends(i,n),Object.defineProperty(i.prototype,"selectedDate",{get:function(){return this._selectedDate},set:function(t){this.setSelectedDate(t),this.notifyObservers(e.ChangeType.Complete,this._selectedDate)},enumerable:!0,configurable:!0}),i.prototype.getSelectedDate=function(){return e.DateHelper.createCopy(this.selectedDate)},i.prototype.setSelectedDate=function(n){if(n=e.DateHelper.createCopy(n),this._selectedDate=this.moveDateToValidRangeIfNessesary(n),null==this._selectedDate&&this.calendarType===e.CalendarMode.Date&&this.currentViewType===e.DateRangeType.Date)return this.dateValidator.findFirstDateThatPassesRestrictions(n,e.DateRangeType.Date).date;e.DateHelper.areDatesEqual(n,this._selectedDate)||(t.Utils.warnInDebugMode("Changed selected date to be valid."),this.notifyObservers(e.ChangeType.Complete,this.selectedDate))},i.prototype.checkSelectedValue=function(){this.setSelectedDate(this.selectedDate)},i.prototype.moveDateToValidRangeIfNessesary=function(t){return null==t?t:this.dateValidator.minDate>t?this.dateValidator.minDate:this.dateValidator.maxDate<t?this.dateValidator.maxDate:this.dateValidator.isThereAnyValidPartInDate(t,null)?t:this.dateValidator.findFirstDateThatPassesRestrictions(t,this.currentViewType).date},i.prototype.getFirstPossibleDateToShow=function(t){if(null!=t&&this.dateValidator.isDateInValidRange(t))return t;if(null!=this.currentlyDisplayedDate&&this.dateValidator.isDateInValidRange(this.currentlyDisplayedDate))return this.currentlyDisplayedDate;if(null!=this.selectedDate&&this.dateValidator.isDateInValidRange(this.selectedDate))return e.DateHelper.createCopy(this.selectedDate);var n=new Date;return this.dateValidator.isDateInValidRange(n)||(n=e.DateHelper.createCopy(this.dateValidator.minDate)),n},i.prototype.createCalendar=function(){n.prototype.createCalendar.call(this)},i.prototype.createYearCell=function(t){return n.prototype.createYearCell.call(this,t,e.DateHelper.isDateInDateRangeOfCell(this.selectedDate,t,e.DateRangeType.Year))},i.prototype.createMonthCell=function(t){return n.prototype.createMonthCell.call(this,t,e.DateHelper.isDateInDateRangeOfCell(this.selectedDate,t,e.DateRangeType.Month))},i.prototype.createDateCell=function(t){return n.prototype.createDateCell.call(this,t,e.DateHelper.isDateInDateRangeOfCell(this.selectedDate,t,e.DateRangeType.Date))},i.prototype.createHourCell=function(t){return n.prototype.createHourCell.call(this,t,e.DateHelper.isDateInDateRangeOfCell(this.selectedDate,t,e.DateRangeType.Hour))},i.prototype.createMinuteCell=function(t){return n.prototype.createMinuteCell.call(this,t,e.DateHelper.isDateInDateRangeOfCell(this.selectedDate,t,e.DateRangeType.Minute)&&null!=this.dateValidator.findFirstDateThatPassesRestrictions(t,e.DateRangeType.Minute))},i.prototype.selectMinute=function(t){this.selectedDate=t,this.update()},i.prototype.selectHour=function(t){for(var e=0,n=0;n<60;)this.dateValidator.isMinuteInValidRange(new Date(this.currentlyDisplayedYear,this.currentlyDisplayedMonth,this.currentlyDisplayedDay,this.currentlyDisplayedHour,n,0))&&e++,n+=5;this.dateValidator.isMinuteInValidRange(new Date(this.currentlyDisplayedYear,this.currentlyDisplayedMonth,this.currentlyDisplayedDay,this.currentlyDisplayedHour,0,0))&&1===e?this.selectMinute(new Date(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),0,0,0)):this.initMinuteSelector()},i.prototype.selectMonth=function(t){this.initDateSelector()},i.prototype.selectYear=function(t){this.initMonthSelector()},i.prototype.selectDay=function(t){this.calendarType===e.CalendarMode.DateTime?this.initHourSelector():(this.selectedDate=t,this.update())},i}(e.CalendarBase);e.Calendar=n}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(){function n(e){this.dateValidator=e,this.observers=new Array,this.$main=$("<div></div>").addClass(t.BusinessPackCss.bpCalendarMain),this.$side=$("<div></div>").addClass(t.BusinessPackCss.bpCalendarSide)}return n.prototype.getCurrentlyDisplayedDate=function(){return e.DateHelper.createCopy(this.currentlyDisplayedDate)},n.prototype.setCurrentlyDisplayedDate=function(t){this.currentlyDisplayedDate=t},Object.defineProperty(n.prototype,"enabled",{get:function(){return this.mainCalendar.enabled},set:function(t){this.mainCalendar.enabled=t,this.sideCalendar.enabled=t},enumerable:!0,configurable:!0}),n.prototype.getCalendarType=function(){return e.CalendarMode.DateTime},n.prototype.subscribe=function(t){this.observers.push(t)},n.prototype.unsubscribe=function(t){var e=this.observers.indexOf(t,0);e>-1&&this.observers.splice(e,1)},n.prototype.notifyObservers=function(t){void 0===t&&(t=e.ChangeType.Complete),this.observers.forEach(function(e){return e.notify(t)})},n.prototype.checkSelectedValue=function(){this.mainCalendar.checkSelectedValue()},n.prototype.update=function(){this.updateSidePanel(),this.mainCalendar.update(),this.sideCalendar.update()},n.prototype.createButton=function(e,n,i,s){void 0===i&&(i=!1),void 0===s&&(s=!1);var o,r=$("<div></div>");return o=s?$("<span></span>").text(e):$("<a>"+e+"</a>").attr({href:"javascript:;"}).on("click",n),r.append(o),i&&r.addClass(""+t.BusinessPackCss.bpStateActive),r},n}();e.CalendarExtendedModeBase=n}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(n){function i(i){var s=n.call(this,i)||this;return s.mainCalendar=new e.Calendar(i,e.CalendarMode.Date),s.mainCalendar.subscribe(s),s.sideCalendar=new e.Calendar(i,e.CalendarMode.Time),s.sideCalendar.subscribe(s),s.setCurrentViewType(e.DateRangeType.Date),s.$sideUpperRow=$("<div></div>").addClass(t.BusinessPackCss.bpCalendarSideUpperRow),s.$side.append(s.$sideUpperRow),s.$sideCalendar=$("<div></div>"),s.$side.append(s.$sideCalendar),s}return __extends(i,n),i.prototype.setSelectedDate=function(t){this.mainCalendar.setSelectedDate(t),this.sideCalendar.setSelectedDate(t),this.mainCalendar.setCurrentlyDisplayedDate(t),this.sideCalendar.setCurrentlyDisplayedDate(t),this.update()},i.prototype.getSelectedDate=function(){return this.mainCalendar.getSelectedDate()},i.prototype.notify=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];this.mainCalendar.setSelectedDate(e[0]),this.sideCalendar.setSelectedDate(e[0]),this.setCurrentViewType(null),this.notifyObservers(t),this.updateSidePanel()},i.prototype.getCurrentViewType=function(){return this.mainCalendar.getCurrentViewType()},i.prototype.setCurrentViewType=function(t){this.mainCalendar.setCurrentViewType(t)},i.prototype.getCalendarType=function(){return this.mainCalendar.getCalendarType()},i.prototype.render=function(t,e,n){this.$element=$(t),this.mainCalendar.render(this.$main[0]),this.sideCalendar.render(this.$sideCalendar[0]),this.mainCalendar.setCurrentlyDisplayedDate(e),this.mainCalendar.setCurrentViewType(n),this.sideCalendar.setCurrentlyDisplayedDate(e),this.sideCalendar.setCurrentViewType(n),this.$element.append(this.$main),this.$element.append(this.$side),this.updateSidePanel()},i.prototype.updateSidePanel=function(){var t=this.mainCalendar.getSelectedDate();null!=t&&this.enabled?(this.$side.show(),this.$sideUpperRow.empty(),this.$sideUpperRow.append($("<span></span>").text(e.DateHelper.buildFullTimeText(t.getHours(),t.getMinutes()))),this.sideCalendar.setSelectedDate(t),this.sideCalendar.setCurrentViewType(null),this.sideCalendar.setCurrentlyDisplayedDate(t),this.sideCalendar.update()):this.$side.hide()},Object.defineProperty(i.prototype,"currentlyDisplayedDate",{get:function(){return this.mainCalendar.getCurrentlyDisplayedDate()},set:function(t){this.mainCalendar.setCurrentlyDisplayedDate(t),this.sideCalendar.setCurrentlyDisplayedDate(t)},enumerable:!0,configurable:!0}),i}(e.CalendarExtendedModeBase);e.CalendarExtended=n}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(n){function i(t){var i=n.call(this,t)||this;return i.isSideCalendarInStartMode=!1,i.isSideCalendarInEndMode=!1,i.mainCalendar=new e.RangeSelection(t,e.CalendarMode.Date),i.mainCalendar.subscribe(i),i.sideCalendar=new e.Calendar(t,e.CalendarMode.Time),i.sideCalendar.subscribe(i),i.buildSideCalendarSelector(),i.$sideCalendar=$("<div></div>"),i.$side.append(i.$sideCalendarSelector),i.$side.append(i.$sideCalendar),i}return __extends(i,n),i.prototype.notify=function(t){for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];var s=t===e.ChangeType.Complete&&void 0!==n[0]&&void 0!==n[1]||t===e.ChangeType.Partial;s&&t===e.ChangeType.Partial?this.putSideCalendarInStartMode():s&&t===e.ChangeType.Complete?this.putSideCalendarInEndMode():!s&&this.isSideCalendarInStartMode?this.setSelectedStartDate(n[0]):!s&&this.putSideCalendarInEndMode&&this.setSelectedEndDate(n[0]),this.update(),this.notifyObservers(t)},i.prototype.updateSidePanel=function(){null!=this.getSelectedStartDate()&&this.enabled?(this.$side.show(),this.isSideCalendarInStartMode&&!this.isSideCalendarInEndMode?this.putSideCalendarInStartMode():!this.isSideCalendarInStartMode&&this.isSideCalendarInEndMode?this.putSideCalendarInEndMode():null!=this.getSelectedStartDate()&&null==this.getSelectedEndDate()?this.putSideCalendarInStartMode():null!=this.getSelectedStartDate()&&null==this.getSelectedEndDate()&&this.putSideCalendarInEndMode(),this.buildSideCalendarSelector()):this.$side.hide()},i.prototype.getCurrentViewType=function(){return this.mainCalendar.getCurrentViewType()},i.prototype.setCurrentViewType=function(t){this.mainCalendar.setCurrentViewType(t)},i.prototype.render=function(t,e,n){this.$element=$(t),this.setCurrentlyDisplayedDate(e),this.setCurrentViewType(n),this.mainCalendar.render(this.$main[0]),this.sideCalendar.render(this.$sideCalendar[0]),this.$element.append(this.$main),this.$element.append(this.$side),this.update()},i.prototype.setSelectedRange=function(t,e){this.mainCalendar.setSelectedRange(t,e)},i.prototype.setSelectedStartDate=function(t){this.mainCalendar.setSelectedStartDate(t)},i.prototype.setSelectedEndDate=function(t){this.mainCalendar.setSelectedEndDate(t)},i.prototype.getSelectedStartDate=function(){return this.mainCalendar.getSelectedStartDate()},i.prototype.getSelectedEndDate=function(){return this.mainCalendar.getSelectedEndDate()},i.prototype.setDisplayedDateToStartDate=function(){this.mainCalendar.setDisplayedDateToStartDate(),this.putSideCalendarInStartMode()},i.prototype.setDisplayedDateToEndDate=function(){this.mainCalendar.setDisplayedDateToEndDate(),this.putSideCalendarInEndMode()},Object.defineProperty(i.prototype,"currentlyDisplayedDate",{get:function(){return this.mainCalendar.getCurrentlyDisplayedDate()},set:function(t){this.mainCalendar.setCurrentlyDisplayedDate(t)},enumerable:!0,configurable:!0}),i.prototype.buildSideCalendarSelector=function(e){var n=this;void 0===e&&(e=!0),void 0==this.$sideCalendarSelector&&(this.$sideCalendarSelector=$("<div></div>").addClass(t.BusinessPackCss.bpCalendarSideUpperRow).addClass(t.BusinessPackCss.bpCalendarSelector)),this.$sideCalendarSelector.empty();var i=this.isSideCalendarInStartMode?function(){}:function(){n.putSideCalendarInStartMode(),n.buildSideCalendarSelector(!0),n.sideCalendar.update()},s=this.isSideCalendarInEndMode?function(){}:function(){n.putSideCalendarInEndMode(),n.buildSideCalendarSelector(!0),n.sideCalendar.update()};if(e)var o=null!=this.getSelectedStartDate()?dotvvm.globalize.formatString("g",this.getSelectedStartDate()):"",r=null!=this.getSelectedEndDate()?dotvvm.globalize.formatString("g",this.getSelectedEndDate()):"";var a=this.createButton(e?""+o:"",i,this.isSideCalendarInStartMode,null==this.getSelectedStartDate()),l=this.createButton(e?""+r:"",s,this.isSideCalendarInEndMode,null==this.getSelectedEndDate());a.addClass(t.BusinessPackCss.bpCalendarSelectorStart),l.addClass(t.BusinessPackCss.bpCalendarSelectorEnd);var u=a.find("a"),c=l.find("a");this.$sideCalendarSelector.append(a),this.$sideCalendarSelector.append(l);var h=0!==u.length&&u[0].scrollWidth>a.innerWidth()||0!==c.length&&l[0].scrollWidth>l.innerWidth();e&&h&&this.buildSideCalendarSelector(!1)},i.prototype.putSideCalendarInStartMode=function(){this.isSideCalendarInStartMode=!0,this.isSideCalendarInEndMode=!1;var t=this.getSelectedStartDate();this.sideCalendar.setCurrentlyDisplayedDate(t),this.sideCalendar.setSelectedDate(t),this.sideCalendar.setCurrentViewType(e.DateRangeType.Hour),this.setCurrentViewType(e.DateRangeType.Hour)},i.prototype.putSideCalendarInEndMode=function(){this.isSideCalendarInStartMode=!1,this.isSideCalendarInEndMode=!0;var t=this.getSelectedEndDate();this.sideCalendar.setCurrentlyDisplayedDate(t),this.sideCalendar.setSelectedDate(t),this.sideCalendar.setCurrentViewType(e.DateRangeType.Hour),this.setCurrentViewType(e.DateRangeType.Hour)},i}(e.CalendarExtendedModeBase);e.RangeCalendarExtended=n}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(n){function i(){return null!==n&&n.apply(this,arguments)||this}return __extends(i,n),Object.defineProperty(i.prototype,"selectedStartDate",{get:function(){return this._selectedStartDate},set:function(t){t=new Date(t.getTime());var n=!e.DateHelper.areDatesEqual(t,this.selectedStartDate);this._selectedStartDate=t,n&&this.notifyObservers(e.ChangeType.Partial,this._selectedStartDate)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"selectedEndDate",{get:function(){return this._selectedEndDate},set:function(t){t=e.DateHelper.createCopy(t);var n=!e.DateHelper.areDatesEqual(t,this.selectedEndDate);(null==t||this.dateValidator.isRangeValid(this.selectedStartDate,t))&&(this._selectedEndDate=t,n&&this.notifyObservers(e.ChangeType.Complete,this._selectedStartDate,this._selectedEndDate))},enumerable:!0,configurable:!0}),i.prototype.setSelectedRange=function(t,n){t=e.DateHelper.createCopy(t),n=e.DateHelper.createCopy(n),this._selectedStartDate=t,this._selectedEndDate=n,this.checkSelectedValue()},i.prototype.setSelectedStartDate=function(t){this.setSelectedRange(t,this._selectedEndDate)},i.prototype.setSelectedEndDate=function(t){this.setSelectedRange(this._selectedStartDate,t)},i.prototype.getSelectedStartDate=function(){return null==this._selectedStartDate?null:e.DateHelper.createCopy(this._selectedStartDate)},i.prototype.getSelectedEndDate=function(){return null==this._selectedEndDate?null:e.DateHelper.createCopy(this._selectedEndDate)},i.prototype.changeRangeToBeValidIfNessesary=function(t,n){return null==t&&null==n?[t,n]:null==t&&null!=n?[null,null]:(this.dateValidator.minDate>t&&(t=e.DateHelper.createCopy(this.dateValidator.minDate)),this.dateValidator.maxDate<n&&(n=e.DateHelper.createCopy(this.dateValidator.maxDate)),this.dateValidator.isRangeValid(t,n)||(n=null),[t,n])},i.prototype.getFirstPossibleDateToShow=function(t){return null==t&&(t=this.selectedStartDate),n.prototype.getFirstPossibleDateToShow.call(this,t)},i.prototype.isAnyItemInCurrentRangeDisabledOrPartiallyDisabled=function(){for(var e=this.$element.find("."+t.BusinessPackCss.bpStateSelected),n=e.length,i=0;i<n;i++){var s=e[i];if($(s).hasClass(t.BusinessPackCss.bpStateDisabled)||$(s).hasClass(t.BusinessPackCss.bpStatePartiallyDisabled))return!0}return!1},i.prototype.createCalendar=function(){n.prototype.createCalendar.call(this)},i.prototype.checkSelectedValue=function(){var n=this.changeRangeToBeValidIfNessesary(this.selectedStartDate,this.selectedEndDate);e.DateHelper.areDatesEqual(this.selectedStartDate,n[0])&&e.DateHelper.areDatesEqual(this.selectedEndDate,n[1])?(this._selectedStartDate=n[0],this._selectedEndDate=n[1]):(t.Utils.warnInDebugMode("Changed selected range to be valid."),this._selectedStartDate=n[0],this._selectedEndDate=n[1],this.notifyObservers(e.ChangeType.Complete,this._selectedStartDate,this._selectedEndDate))},i.prototype.setDisplayedDateToStartDate=function(){var t=this.selectedStartDate;null==t&&(t=this.getFirstPossibleDateToShow(t)),this.setCurrentlyDisplayedDate(t)},i.prototype.setDisplayedDateToEndDate=function(){var t=this.selectedEndDate;null==t&&(t=this.selectedStartDate),null==t&&(t=this.getFirstPossibleDateToShow(t)),this.setCurrentlyDisplayedDate(t)},i.prototype.selectMinute=function(t){this.isAnyItemInCurrentRangeDisabledOrPartiallyDisabled()||this.selectStartOrEndDate(t)},i.prototype.selectHour=function(t){for(var e=0,n=0;n<60;)this.dateValidator.isMinuteInValidRange(new Date(this.currentlyDisplayedYear,this.currentlyDisplayedMonth,this.currentlyDisplayedDay,this.currentlyDisplayedHour,n,0))&&e++,n+=5;this.dateValidator.isMinuteInValidRange(new Date(this.currentlyDisplayedYear,this.currentlyDisplayedMonth,this.currentlyDisplayedDay,this.currentlyDisplayedHour,0,0))&&1===e?this.selectMinute(new Date(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),0,0,0)):this.isAnyItemInCurrentRangeDisabledOrPartiallyDisabled()||this.initMinuteSelector()},i.prototype.selectMonth=function(t){this.isAnyItemInCurrentRangeDisabledOrPartiallyDisabled()||this.initDateSelector()},i.prototype.selectYear=function(t){this.isAnyItemInCurrentRangeDisabledOrPartiallyDisabled()||this.initMonthSelector()},i.prototype.selectDay=function(t){this.calendarType!==e.CalendarMode.DateTime||this.isAnyItemInCurrentRangeDisabledOrPartiallyDisabled()?this.selectStartOrEndDate(t):this.initHourSelector()},i.prototype.selectStartOrEndDate=function(t){void 0==this.selectedStartDate?this.selectedStartDate=t:null==this.selectedEndDate&&this.selectedStartDate>t?this.selectedStartDate=t:null==this.selectedEndDate&&this.selectedStartDate<=t?this.selectedEndDate=t:(this.setSelectedEndDate(null),this.selectedStartDate=t),this.setCurrentViewType(null),this.update()},i.prototype.createYearCell=function(t){var e=n.prototype.createYearCell.call(this,t);return this.addCssClasses(e,t),e},i.prototype.createMonthCell=function(t){var e=n.prototype.createMonthCell.call(this,t);return this.addCssClasses(e,t),e},i.prototype.createDateCell=function(t){var e=n.prototype.createDateCell.call(this,t);return this.addCssClasses(e,t),e},i.prototype.createHourCell=function(t){var e=n.prototype.createHourCell.call(this,t);return this.addCssClasses(e,t),e},i.prototype.createMinuteCell=function(t){var e=n.prototype.createMinuteCell.call(this,t);return this.addCssClasses(e,t),e},i.prototype.addCssClasses=function(n,i){e.DateHelper.isDateInDateRangeOfCell(this.selectedStartDate,i,this.currentViewType)&&n.addClass(""+t.BusinessPackCss.bpStateSelectionStart),e.DateHelper.isDateInDateRangeOfCell(this.selectedEndDate,i,this.currentViewType)?n.addClass(""+t.BusinessPackCss.bpStateSelectionEnd):this.selectedEndDate&&this.selectedStartDate<i&&this.selectedEndDate>i&&n.addClass(""+t.BusinessPackCss.bpStateSelected),this.selectedStartDate&&!this.selectedEndDate&&i>this.selectedStartDate&&n.attr("data-possible-end-date",this.dateValidator.isRangeValid(this.selectedStartDate,i))},i.prototype.calendarRendered=function(){var e=this;n.prototype.calendarRendered.call(this);var i=this.$element.find("td[data-possible-end-date]");i.mouseover(function(t){return e.changeClasesOnHover(t.target)}),i.mouseleave(function(){i.removeClass(""+t.BusinessPackCss.bpStateSelected),i.removeClass(""+t.BusinessPackCss.bpStateSelectionEnd)}),void 0!=this.selectedStartDate&&void 0==this.selectedEndDate&&setTimeout(function(){var t=i.find(":hover");void 0!=t[0]&&e.changeClasesOnHover(t[0])},25)},i.prototype.changeClasesOnHover=function(e){"a"!==e.tagName.toLowerCase()&&"span"!==e.tagName.toLowerCase()||(e=$(e).closest("td")[0]);for(var n=this.$element.find("td[data-possible-end-date]"),i=0;i<n.length&&n[i]!==e;)$(n[i]).addClass(""+t.BusinessPackCss.bpStateSelected),i++;$(e).addClass(""+t.BusinessPackCss.bpStateSelectionEnd)},i}(e.CalendarBase);e.RangeSelection=n}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(t){"use strict";var e=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return __extends(n,e),Object.defineProperty(n.prototype,"displayMode",{get:function(){if(void 0==this.binding.displayMode)return t.DisplayMode.Standard;var e=ko.unwrap(this.binding.displayMode);return t.DisplayMode[e]},enumerable:!0,configurable:!0}),n.prototype.getElement=function(){return this.element[0]},n.prototype.initialize=function(){var t=this;e.prototype.initialize.call(this),this.element=this.$element[0],this.setMinAndMaxDate(),this.subscribe(this.binding.restrictions,function(){t.calendar&&t.calendar.checkSelectedValue()}),this.initializeCalendar(),this.onEnabledChange()},n.prototype.onEnabledChange=function(){e.prototype.onEnabledChange.call(this),void 0!==this.binding.enabled&&this.calendar&&(this.calendar.enabled=ko.unwrap(this.binding.enabled),this.calendar.update())},n.prototype.getViewType=function(){var e=this.$element.attr("data-dotvvm-businesspack-dateTimeControl-viewtype"),n=t.CalendarMode.Date;return"Time"===e?n=t.CalendarMode.Time:"DateTime"===e&&(n=t.CalendarMode.DateTime),n},n.prototype.setMinAndMaxDate=function(){var t=this;this.subscribe(this.binding.minDate,function(){t.calendar&&t.calendar.checkSelectedValue()}),this.subscribe(this.binding.maxDate,function(){t.calendar&&t.calendar.checkSelectedValue()})},n.prototype.fireChangedEvent=function(){this.binding.selectionCompleted&&this.binding.selectionCompleted()},n}(t.ControlBase);t.CalendarControlBase=e}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return __extends(n,t),Object.defineProperty(n.prototype,"selectedDate",{get:function(){return e.DateHelper.parseDate(ko.unwrap(this.binding.selectedDate))},set:function(t){var e=!0;if(null==t||null==this.selectedDate?e=t!=this.selectedDate:null!=t&&null!=this.selectedDate&&(e=t.getTime()!=this.selectedDate.getTime()),e){var n=this.binding.selectedDate;ko.isWriteableObservable(n)&&n(t?dotvvm.serialization.serializeDate(t,!1):null),this.fireChangedEvent()}},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"selectedYear",{get:function(){return this.selectedDate.getFullYear()},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"selectedMonth",{get:function(){return this.selectedDate.getMonth()},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"selectedDay",{get:function(){return this.selectedDate.getDate()},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"selectedHour",{get:function(){return this.selectedDate.getHours()},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"selectedMinute",{get:function(){return this.selectedDate.getMinutes()},enumerable:!0,configurable:!0}),n.prototype.initialize=function(){var e=this;t.prototype.initialize.call(this),this.subscribe(this.binding.selectedDate,function(){return e.updateSelectedDateInCalendar()})},n.prototype.initializeCalendar=function(){var t=new e.DateValidator(this.binding.minDate,this.binding.maxDate,this.binding.restrictions);switch(this.displayMode){case e.DisplayMode.Standard:this.calendar=new e.Calendar(t,this.getViewType());break;case e.DisplayMode.Extended:this.calendar=new e.CalendarExtended(t);break;default:console.error("Unsuported calendar mode!")}this.calendar.subscribe(this),this.calendar.setSelectedDate(this.selectedDate),this.calendar.render(this.$element[0])},n.prototype.notify=function(){this.selectedDate=this.calendar.getSelectedDate(),this.calendar.setCurrentViewType(null)},n.prototype.updateSelectedDateInCalendar=function(){e.DateHelper.areDatesEqual(this.selectedDate,this.calendar.getSelectedDate())||(this.calendar.setSelectedDate(this.selectedDate),this.calendar.setCurrentlyDisplayedDate(this.selectedDate),this.calendar.update())},n}(e.CalendarControlBase);e.CalendarControl=n,t.Utils.installBindingHandler("Calendar",n)}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return __extends(n,t),Object.defineProperty(n.prototype,"selectedStartDate",{get:function(){return e.DateHelper.parseDate(ko.unwrap(this.binding.selectedStartDate))},set:function(t){var e=this.binding.selectedStartDate;ko.isWriteableObservable(e)&&e(t?dotvvm.serialization.serializeDate(t,!1):null)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"selectedEndDate",{get:function(){return e.DateHelper.parseDate(ko.unwrap(this.binding.selectedEndDate))},set:function(t){var e=this.binding.selectedEndDate;ko.isWriteableObservable(e)&&e(t?dotvvm.serialization.serializeDate(t,!1):null)},enumerable:!0,configurable:!0}),n.prototype.notify=function(t){this.selectedStartDate=this.calendar.getSelectedStartDate(),this.selectedEndDate=this.calendar.getSelectedEndDate(),t!==e.ChangeType.Partial&&(null!=this.selectedStartDate&&null==this.selectedEndDate||this.fireChangedEvent(),this.calendar.setCurrentViewType(null))},n.prototype.initializeCalendar=function(){var t=this,n=new e.DateRangeValidator(this.binding.minDate,this.binding.maxDate,this.binding.restrictions);switch(this.displayMode){case e.DisplayMode.Standard:this.calendar=new e.RangeSelection(n,this.getViewType());break;case e.DisplayMode.Extended:this.calendar=new e.RangeCalendarExtended(n);break;default:console.error("Unsuported calendar mode!")}this.calendar.subscribe(this),this.calendar.setSelectedRange(this.selectedStartDate,this.selectedEndDate),dotvvm.events.init.subscribe(function(){t.calendar.render(t.$element[0])})},n.prototype.updateSelectedDatesInCalendar=function(){var t=this,n=function(){return!e.DateHelper.areDatesEqual(t.selectedStartDate,t.calendar.getSelectedStartDate())},i=function(){return!e.DateHelper.areDatesEqual(t.selectedEndDate,t.calendar.getSelectedEndDate())},s=!n()&&!i();this.updateAllreadySchedulled||s||(this.updateAllreadySchedulled=!0,setTimeout(function(){n()&&i()?t.calendar.setSelectedRange(t.selectedStartDate,t.selectedEndDate):n()?t.calendar.setSelectedStartDate(t.selectedStartDate):i()&&t.calendar.setSelectedEndDate(t.selectedEndDate),t.calendar.update(),t.updateAllreadySchedulled=!1},100))},n.prototype.initialize=function(){var e=this;t.prototype.initialize.call(this),this.subscribe(this.binding.selectedStartDate,function(){e.updateSelectedDatesInCalendar()}),this.subscribe(this.binding.selectedEndDate,function(){e.updateSelectedDatesInCalendar()})},n}(e.CalendarControlBase);e.RangeCalendarControl=n,t.Utils.installBindingHandler("RangeCalendar",n)}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(n){function i(){var t=null!==n&&n.apply(this,arguments)||this;return t.doneTypingInterval=2e3,t}return __extends(i,n),i.prototype.destroy=function(){window.removeEventListener("scroll",this.scrollHandler,!0),this.popupElement&&(this.popupElement.remove(),this.popupElement=null,this.calendar.setCurrentViewType(null))},i.destroyActivePopup=function(){i.activePopup&&(i.activePopup.destroy(),i.activePopup=null),i.unregisterGlobalEvent()},i.destroyActivePopupOnEsc=function(t){27===t.keyCode&&(i.destroyActivePopup(),t.stopPropagation())},i.registerGlobalEvent=function(){var t=this;$(document).on("keyup",i.destroyActivePopupOnEsc),this.poopupUpdateHandle=setInterval(function(){return t.updatePopupPosition()},10)},i.unregisterGlobalEvent=function(){$(document).off("keyup",i.destroyActivePopupOnEsc),clearInterval(this.poopupUpdateHandle),this.poopupUpdateHandle=null},i.prototype.hideCalendarOnTab=function(t){9===t.keyCode&&this.destroy()},i.prototype.initialize=function(){var e=this;this.$element.on("keyup",function(){clearTimeout(e.typingTimer),e.typingTimer=setTimeout(function(){return e.updateDateFromTextbox()},e.doneTypingInterval)}),this.$element.on("keydown",function(){clearTimeout(e.typingTimer)}),this.$element.on("keydown",function(t){return e.hideCalendarOnTab(t)}),this.$element.find("a").on("click",function(){return void 0==e.popupElement?e.showPopup():e.destroy()}),this.$element.focusin(function(){return e.$element.addClass(t.BusinessPackCss.bpStateFocused)}),this.$element.focusout(function(){return e.$element.removeClass(t.BusinessPackCss.bpStateFocused)}),this.scrollHandler=function(t){return e.onScroll(t)},n.prototype.initialize.call(this)},i.prototype.updateDateinTextBox=function(t,e,n){void 0===n&&(n=!1);var i=dotvvm.globalize.formatString(this.binding.formatString,e);(dotvvm.globalize.formatString(this.binding.formatString,this.getCurrentDateFromInput(t))!==i||n)&&t.val(i)},i.prototype.getCurrentDateFromInput=function(t){return""===t.val()?null:dotvvm.globalize.parseDate(t.val(),this.binding.formatString)},i.prototype.onScroll=function(t){var e=$(t.target);this.$element.is(e)||this.$element.find(e).length||this.destroy()},i.prototype.showPopup=function(n){var s=this;if(void 0===this.binding.enabled||ko.unwrap(this.binding.enabled)){if(i.activePopup!==this)i.destroyActivePopup(),i.activePopup=this;else{if(void 0!=this.popupElement)return this.calendar.setCurrentlyDisplayedDate(n),this.calendar.setCurrentViewType(e.DateRangeType.Date),void this.calendar.update();this.destroy()}window.addEventListener("scroll",this.scrollHandler,!0),this.popupElement=$("<div></div>").addClass(""+t.BusinessPackCss.dotvvmBpControl).addClass(""+t.BusinessPackCss.bpPopup),this.popupElement.attr("tabindex",-1),this.outside("click",function(t){void 0!=s.popupElement&&i.destroyActivePopup()}),i.registerGlobalEvent(),this.calendar.setCurrentlyDisplayedDate(n),this.calendar.render(this.popupElement[0]),this.$element.append(this.popupElement),this.popupElement.keydown(function(t){return s.hideCalendarOnTab(t)}),i.updatePopupPosition()}},i.updatePopupPosition=function(){if(i.activePopup&&i.activePopup.popupElement){var e=i.activePopup.$element.find("."+t.BusinessPackCss.bpInputGroup),n=i.activePopup.$element.offset();if(n.top+300>$(document).height()&&n.top>300){i.activePopup.popupElement.css({left:n.left,top:null,bottom:$(window).height()-(n.top-$(document).scrollTop())});var s=n.top-$(document).scrollTop();s<0&&$(document).scrollTop($(document).scrollTop()-s)}else i.activePopup.popupElement.css({left:n.left,top:n.top-$(document).scrollTop()+e.outerHeight(),bottom:null})}},i}(e.CalendarControlBase);e.CalendarPopup=n}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(n){function i(){return null!==n&&n.apply(this,arguments)||this}return __extends(i,n),Object.defineProperty(i.prototype,"selectedDate",{get:function(){return e.DateHelper.parseDate(ko.unwrap(this.binding.selectedDate))},set:function(t){var e=!0;if(null==t||null==this.selectedDate?e=t!=this.selectedDate:null!=t&&null!=this.selectedDate&&(e=t.getTime()!=this.selectedDate.getTime()),e){this.updateDateinTextBox(this.input,t);var n=this.binding.selectedDate;ko.isWriteableObservable(n)&&n(t?dotvvm.serialization.serializeDate(t,!1):null),this.fireChangedEvent()}},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"selectedYear",{get:function(){return this.selectedDate.getFullYear()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"selectedMonth",{get:function(){return this.selectedDate.getMonth()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"selectedDay",{get:function(){return this.selectedDate.getDate()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"selectedHour",{get:function(){return this.selectedDate.getHours()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"selectedMinute",{get:function(){return this.selectedDate.getMinutes()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"input",{get:function(){return this.$element.find("input")},enumerable:!0,configurable:!0}),i.prototype.initialize=function(){var e=this;n.prototype.initialize.call(this),this.subscribe(this.binding.selectedDate,function(){e.updateSelectedDateInCalendar(),e.updateDateinTextBox(e.input,e.selectedDate)}),this.input.focus(function(){return e.showPopup()}),this.input.change(function(){e.$element.removeClass(t.BusinessPackCss.bpStateError),e.updateDateFromTextbox(!0),e.updateDateinTextBox(e.input,e.selectedDate,!0)}),this.updateDateinTextBox(this.input,this.selectedDate),this.element.dotvvmDatePickerCalendarPopup=this},i.prototype.initializeCalendar=function(){switch(this.validator=new e.DateValidator(this.binding.minDate,this.binding.maxDate,this.binding.restrictions),this.displayMode){case e.DisplayMode.Standard:this.calendar=new e.Calendar(this.validator,this.getViewType());break;case e.DisplayMode.Extended:this.calendar=new e.CalendarExtended(this.validator);break;default:console.error("Unsuported calendar mode!")}this.calendar.subscribe(this),this.calendar.setSelectedDate(this.selectedDate)},i.prototype.notify=function(){this.selectedDate=this.calendar.getSelectedDate(),!ko.unwrap(this.binding.closePopupOnSelectionComplete)||this.calendar instanceof e.CalendarExtendedModeBase||this.destroy(),this.calendar.setCurrentViewType(null)},i.prototype.updateSelectedDateInCalendar=function(t){void 0===t&&(t=this.selectedDate),e.DateHelper.areDatesEqual(t,this.calendar.getSelectedDate())||(this.calendar.setSelectedDate(t),this.calendar.setCurrentlyDisplayedDate(t),this.calendar.update())},i.prototype.updateDateFromTextbox=function(n,i){void 0===n&&(n=!1),void 0===i&&(i=this.getCurrentDateFromInput(this.input)),this.calendar.getCalendarType()===e.CalendarMode.Time&&(i=new Date(this.selectedYear,this.selectedMonth,this.selectedDay,i.getHours(),i.getMinutes()));var s=!1,o=!1;null==i&&""!==this.input.val()&&(s=!0,t.Utils.warnInDebugMode("Inputed date does not have valid format.")),null==i||this.validator.isDateInValidRange(i)?this.$element.removeClass(t.BusinessPackCss.bpStateError):(this.$element.addClass(t.BusinessPackCss.bpStateError),o=!0,t.Utils.warnInDebugMode("Inputed date cannot be used.")),s||o?n&&(this.calendar.setSelectedDate(i),this.selectedDate=this.calendar.getSelectedDate(),this.$element.removeClass(t.BusinessPackCss.bpStateError)):(this.selectedDate=i,this.updateSelectedDateInCalendar())},i.prototype.showPopup=function(e,i){(void 0==this.binding.enabled||ko.unwrap(this.binding.enabled))&&(null==e&&(e=this.selectedDate),n.prototype.showPopup.call(this,e),this.popupElement.addClass(""+t.BusinessPackCss.dotvvmBpDateTimePicker))},i.prototype.destroy=function(){null==this.selectedDate||this.validator.isDateInValidRange(this.selectedDate)?this.$element.removeClass(t.BusinessPackCss.bpStateError):this.$element.addClass(t.BusinessPackCss.bpStateError),n.prototype.destroy.call(this)},i}(e.CalendarPopup);e.DateTimePickerControl=n,t.Utils.installBindingHandler("DateTimePicker",n)}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(n){function i(){return null!==n&&n.apply(this,arguments)||this}return __extends(i,n),Object.defineProperty(i.prototype,"selectedStartDate",{get:function(){return e.DateHelper.parseDate(ko.unwrap(this.binding.selectedStartDate))},set:function(t){var e=this.binding.selectedStartDate;ko.isWriteableObservable(e)&&(this.updateDateinTextBox(this.inputStart,t),e(t?dotvvm.serialization.serializeDate(t,!1):null))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"selectedEndDate",{get:function(){return e.DateHelper.parseDate(ko.unwrap(this.binding.selectedEndDate))},set:function(t){var e=this.binding.selectedEndDate;ko.isWriteableObservable(e)&&(this.updateDateinTextBox(this.inputEnd,t),e(t?dotvvm.serialization.serializeDate(t,!1):null))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"inputs",{get:function(){return this.$element.find("input")},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"inputStart",{get:function(){return $(this.inputs[0])},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"inputEnd",{get:function(){return $(this.inputs[1])},enumerable:!0,configurable:!0}),i.prototype.notify=function(t){this.selectedStartDate=this.calendar.getSelectedStartDate(),this.selectedEndDate=this.calendar.getSelectedEndDate(),null!=this.selectedStartDate&&null==this.selectedEndDate||t===e.ChangeType.Partial||this.fireChangedEvent(),t!==e.ChangeType.Partial&&(!ko.unwrap(this.binding.closePopupOnSelectionComplete)||this.calendar instanceof e.CalendarExtendedModeBase||(this.destroy(),this.calendar.setCurrentViewType(null)))},i.prototype.initializeCalendar=function(){switch(this.validator=new e.DateRangeValidator(this.binding.minDate,this.binding.maxDate,this.binding.restrictions),this.displayMode){case e.DisplayMode.Standard:this.calendar=new e.RangeSelection(this.validator,this.getViewType());break;case e.DisplayMode.Extended:this.calendar=new e.RangeCalendarExtended(this.validator);break;default:console.error("Unsuported calendar mode!")}this.calendar.subscribe(this),this.calendar.setSelectedRange(this.selectedStartDate,this.selectedEndDate)},i.prototype.updateSelectedDatesInCalendar=function(){var t=this,n=function(){return!e.DateHelper.areDatesEqual(t.selectedStartDate,t.calendar.getSelectedStartDate())},i=function(){return!e.DateHelper.areDatesEqual(t.selectedEndDate,t.calendar.getSelectedEndDate())},s=!n()&&!i();this.updateAllreadySchedulled||s||(this.updateAllreadySchedulled=!0,setTimeout(function(){n()&&i()?t.calendar.setSelectedRange(t.selectedStartDate,t.selectedEndDate):n()?t.calendar.setSelectedStartDate(t.selectedStartDate):i()&&t.calendar.setSelectedEndDate(t.selectedEndDate),t.updateAllreadySchedulled=!1},50))},i.prototype.initialize=function(){var e=this;n.prototype.initialize.call(this),this.subscribe(this.binding.selectedStartDate,function(){e.updateSelectedDatesInCalendar(),e.updateDateinTextBox(e.inputStart,e.selectedStartDate)}),this.subscribe(this.binding.selectedEndDate,function(){e.updateSelectedDatesInCalendar(),e.updateDateinTextBox(e.inputEnd,e.selectedEndDate)}),this.inputStart.focus(function(){e.showPopup(e.selectedStartDate),e.lastActiveInput=0}),this.inputEnd.focus(function(){e.showPopup(e.selectedEndDate),e.lastActiveInput=1}),this.inputStart.change(function(){e.$element.removeClass(t.BusinessPackCss.bpStateError),e.updateDateFromTextbox(!0),e.updateDateinTextBox(e.inputStart,e.selectedStartDate,!0)}),this.inputEnd.change(function(){e.$element.removeClass(t.BusinessPackCss.bpStateError),e.updateDateFromTextbox(!0),e.updateDateinTextBox(e.inputEnd,e.selectedEndDate,!0)}),this.updateDateinTextBox(this.inputStart,this.selectedStartDate),this.updateDateinTextBox(this.inputEnd,this.selectedEndDate),this.element.dotvvmDatePickerCalendarPopup=this},i.prototype.updateDateFromTextbox=function(n){void 0===n&&(n=!1);var i=this.getCurrentDateFromInput(this.inputStart),s=this.getCurrentDateFromInput(this.inputEnd);if(this.calendar.getCalendarType()===e.CalendarMode.Time&&(i=new Date(this.selectedStartDate.getFullYear(),this.selectedStartDate.getMonth(),this.selectedStartDate.getDate(),i.getHours(),i.getMinutes()),s=new Date(this.selectedEndDate.getFullYear(),this.selectedEndDate.getMonth(),this.selectedEndDate.getDate(),s.getHours(),s.getMinutes())),!e.DateHelper.areDatesEqual(i,this.calendar.getSelectedStartDate())||!e.DateHelper.areDatesEqual(s,this.calendar.getSelectedEndDate())){var o=!1,r=!1,a=!1;if(null==i&&""!==this.inputStart.val()&&(o=!0,t.Utils.warnInDebugMode("Invalid start date entered!")),null==s&&""!==this.inputEnd.val()&&(r=!0,t.Utils.warnInDebugMode("Invalid end date entered!")),null==i||null==s||this.validator.isRangeValid(i,s)?this.$element.removeClass(t.BusinessPackCss.bpStateError):(this.$element.addClass(t.BusinessPackCss.bpStateError),a=!0,t.Utils.warnInDebugMode("Invalid range entered!")),o||r||a)n&&(this.calendar.setSelectedRange(i,s),this.selectedStartDate=this.calendar.getSelectedStartDate(),this.selectedEndDate=this.calendar.getSelectedEndDate(),this.$element.removeClass(t.BusinessPackCss.bpStateError));else{this.selectedStartDate=i,this.selectedEndDate=s,this.updateSelectedDatesInCalendar();var l;l=0===this.lastActiveInput?this.selectedStartDate:this.selectedEndDate,this.showPopup(l),this.fireChangedEvent()}}},i.prototype.showPopup=function(e){(void 0==this.binding.enabled||ko.unwrap(this.binding.enabled))&&(n.prototype.showPopup.call(this,e),this.popupElement.addClass(""+t.BusinessPackCss.dotvvmBpDateTimeRangePicker))},i}(e.CalendarPopup);e.DateTimeRangePickerControl=n,t.Utils.installBindingHandler("DateTimeRangePicker",n)}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(t){!function(t){t[t.Date=0]="Date",t[t.DateTime=1]="DateTime",t[t.Time=2]="Time"}(t.CalendarMode||(t.CalendarMode={}))}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(t){!function(t){t[t.Complete=0]="Complete",t[t.Partial=1]="Partial"}(t.ChangeType||(t.ChangeType={}))}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(t){!function(t){t[t.Year=0]="Year",t[t.Month=1]="Month",t[t.Date=2]="Date",t[t.Hour=3]="Hour",t[t.Minute=4]="Minute"}(t.DateRangeType||(t.DateRangeType={}))}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(t){!function(t){t[t.Standard=0]="Standard",t[t.Extended=1]="Extended"}(t.DisplayMode||(t.DisplayMode={}))}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(t){var e=function(){function e(t,e,n){this.minDateObservable=t,this.maxDateObservable=e,this.restrictions=n}return Object.defineProperty(e.prototype,"minDate",{get:function(){return this.minDateObservable&&null!=ko.unwrap(this.minDateObservable)?t.DateHelper.parseDate(ko.unwrap(this.minDateObservable)):new Date(-8e15)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"maxDate",{get:function(){return this.maxDateObservable&&null!=ko.unwrap(this.maxDateObservable)?t.DateHelper.parseDate(ko.unwrap(this.maxDateObservable)):new Date(8e15)},enumerable:!0,configurable:!0}),e.prototype.isDayOfWeekRestriction=function(t){return"DayOfWeekRestriction"===t.Type()},e.prototype.isDateRangeRestriction=function(t){return"DateRangeRestriction"===t.Type()},e}();t.DateValidatorBase=e}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){var n=function(n){function i(){return null!==n&&n.apply(this,arguments)||this}return __extends(i,n),i.prototype.findFirstDateThatPassesRestrictions=function(t,e){if(null==t)return{date:null,dateType:null};var n=this.doesDatePassAllRestrictions(t,e);if(null==n.undecidedRestrictions||0===n.undecidedRestrictions.length)return n.doesDatePassRestrictions?{date:t,dateType:e}:{date:null,dateType:e};for(var i=this.splitDateInParts(t,e),s=new Array,o=0,r=i.Dates;o<r.length;o++){var a=r[o],l=this.doesDatePassAllRestrictions(a,i.dateType);if(l.doesDatePassRestrictions&&(null==l.undecidedRestrictions||0===l.undecidedRestrictions.length))return{date:a,dateType:i.dateType};null!=l.undecidedRestrictions&&0!==l.undecidedRestrictions.length&&s.push(a)}for(var u=0,c=s;u<c.length;u++){var h=c[u],p=this.findFirstDateThatPassesRestrictions(h,i.dateType);if(null!=p)return p}return{date:null,dateType:null}},i.prototype.isThereAnyValidPartInDate=function(t,e){return null!=this.findFirstDateThatPassesRestrictions(t,e).date},i.prototype.doesDatePassAllRestrictions=function(t,n){if(null==ko.unwrap(this.restrictions)||0===this.restrictions().length)return{doesDatePassRestrictions:!0,undecidedRestrictions:null};for(var i=new Array,s=0,o=this.restrictions();s<o.length;s++){var r=o[s],a=this.doesDatePassRestriction(t,r(),n);if(!1===a)return{doesDatePassRestrictions:!1,undecidedRestrictions:null};void 0===a&&i.push(r)}return null!=n&&n!==e.DateRangeType.Minute||0===i.length?0===i.length?{doesDatePassRestrictions:!0,undecidedRestrictions:null}:{doesDatePassRestrictions:!1,undecidedRestrictions:i}:{doesDatePassRestrictions:!1,undecidedRestrictions:null}},i.prototype.doesDatePassRestriction=function(n,i,s){var o,r,a=e.DateHelper.getStartAndEndOfTheDateInMs(n,s);if(this.isDayOfWeekRestriction(i)){if(s===e.DateRangeType.Year||s===e.DateRangeType.Month)return;if(e.DateHelper.convertStringDayOfWeekToNumber(ko.unwrap(i.DayOfWeek))!==n.getDay())return!0;if(null==ko.unwrap(i.StartTime)||null==ko.unwrap(i.EndTime))return!1;o=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime()+ko.unwrap(i.StartTime).TimeMs(),r=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime()+ko.unwrap(i.EndTime).TimeMs()}else{if(!this.isDateRangeRestriction(i))return t.Utils.warnInDebugMode("Unsuported restriction!"),!1;o=e.DateHelper.parseDate(ko.unwrap(i.StartDate)).getTime(),r=e.DateHelper.parseDate(ko.unwrap(i.EndDate)).getTime()}return!this.doesNumericRangesOverloap(o,r,a.start,a.end)||!this.isNumericRange1SubsetOfNumericRange(a.start,a.end,o,r)&&void 0},i.prototype.isNumericRange1SubsetOfNumericRange=function(t,e,n,i){return n<=t&&i>=e},i.prototype.doesNumericRangesOverloap=function(t,e,n,i){return t<=i&&n<=e},i.prototype.splitDateInParts=function(t,n){var i,s=[];switch(n){case e.DateRangeType.Year:i=e.DateRangeType.Month;for(r=0;r<12;r++)s.push(new Date(t.getFullYear(),r++,1));break;case e.DateRangeType.Month:i=e.DateRangeType.Date;for(var o,r=1;;){if((o=new Date(t.getFullYear(),t.getMonth(),r++)).getMonth()!==t.getMonth())break;s.push(o)}break;case e.DateRangeType.Date:i=e.DateRangeType.Hour;for(r=0;r<24;r++)s.push(new Date(t.getFullYear(),t.getMonth(),t.getDate(),r,0,0,0));break;case e.DateRangeType.Hour:i=e.DateRangeType.Minute;for(r=0;r<60;r+=5)s.push(new Date(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),r,0,0))}return{Dates:s,dateType:i}},i.prototype.isYearInValidRange=function(t){var n=new Date(this.minDate.getFullYear(),0,1,0,0,0),i=new Date(this.maxDate.getFullYear()+1,0,1,0,0,0);return!!(t>=n&&t<i)&&this.isThereAnyValidPartInDate(t,e.DateRangeType.Year)},i.prototype.isMonthInValidRange=function(t){var n=new Date(this.minDate.getFullYear(),this.minDate.getMonth(),1,0,0,0),i=new Date(this.maxDate.getFullYear(),this.maxDate.getMonth()+1,1,0,0,0);return!!(t>=n&&t<i)&&this.isThereAnyValidPartInDate(t,e.DateRangeType.Month)},i.prototype.isDayInValidRange=function(t){var n=new Date(this.minDate.getFullYear(),this.minDate.getMonth(),this.minDate.getDate(),0,0,0),i=new Date(this.maxDate.getFullYear(),this.maxDate.getMonth(),this.maxDate.getDate()+1,0,0,0);return!!(t>=n&&t<i)&&this.isThereAnyValidPartInDate(t,e.DateRangeType.Date)},i.prototype.isHourInValidRange=function(t){var n=new Date(this.minDate.getFullYear(),this.minDate.getMonth(),this.minDate.getDate(),this.minDate.getHours(),0,0),i=new Date(this.maxDate.getFullYear(),this.maxDate.getMonth(),this.maxDate.getDate(),this.maxDate.getHours()+1,0,0);return!!(t>=n&&t<i)&&this.isThereAnyValidPartInDate(t,e.DateRangeType.Hour)},i.prototype.isMinuteInValidRange=function(t){var n=new Date(this.minDate.getFullYear(),this.minDate.getMonth(),this.minDate.getDate(),this.minDate.getHours(),this.minDate.getMinutes(),0),i=new Date(this.maxDate.getFullYear(),this.maxDate.getMonth(),this.maxDate.getDate(),this.maxDate.getHours(),this.maxDate.getMinutes()+1,0);return!!(t>=n&&t<i)&&this.isThereAnyValidPartInDate(t,e.DateRangeType.Minute)},i.prototype.isDateInValidRange=function(t){var e=new Date(this.minDate),n=new Date(this.maxDate);return e.setMilliseconds(0),n.setMilliseconds(999),!!(t>=e&&t<n)&&this.isThereAnyValidPartInDate(t,null)},i}(e.DateValidatorBase);e.DateValidator=n}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){var n=function(n){function i(){return null!==n&&n.apply(this,arguments)||this}return __extends(i,n),i.prototype.isRangeValid=function(t,e){if(null==t||null==e)return!1;if(t.getTime()>e.getTime())return!1;if(null!=ko.unwrap(this.restrictions)&&0!==this.restrictions().length)for(var n=0,i=this.restrictions();n<i.length;n++){var s=i[n];if(!this.doesRangePassRestriction(t,e,s()))return!1}return!0},i.prototype.doesRangePassRestriction=function(e,n,i){return this.isDayOfWeekRestriction(i)?this.doesRangePassDayRestriction(e,n,i):this.isDateRangeRestriction(i)?this.doesRangePassRangeRestriction(e,n,i):(t.Utils.warnInDebugMode("Restriction type "+typeof i+" is not supported."),!1)},i.prototype.doesRangePassRangeRestriction=function(t,n,i){return null==ko.unwrap(i.StartDate)||null==ko.unwrap(i.EndDate)||!this.doesNumericRangesOverloap(e.DateHelper.parseDate(ko.unwrap(i.StartDate)).getTime(),e.DateHelper.parseDate(ko.unwrap(i.EndDate)).getTime(),t.getTime(),n.getTime())},i.prototype.doesRangePassDayRestriction=function(t,n,i){if(null!=ko.unwrap(i.DayOfWeek)){var s=e.DateHelper.getNextOccuranceOfDayOfWeek(t,e.DateHelper.convertStringDayOfWeekToNumber(ko.unwrap(i.DayOfWeek))),o=e.DateHelper.getStartAndEndOfTheDateInMs(s,e.DateRangeType.Date);if(null!=ko.unwrap(i.StartTime)&&null!=ko.unwrap(i.EndTime)){var r=ko.unwrap(i.StartTime),a=ko.unwrap(i.EndTime);o.end=o.start+a.TimeMs(),o.start+=r.TimeMs()}return!this.doesNumericRangesOverloap(o.start,o.end,t.getTime(),n.getTime())}return!0},i}(e.DateValidator);e.DateRangeValidator=n}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(DotVVM){var BusinessPack;!function(BusinessPack){var Controls;!function(Controls){"use strict";var DraggableList=function(_super){function DraggableList(){return null!==_super&&_super.apply(this,arguments)||this}return __extends(DraggableList,_super),DraggableList.prototype.initialize=function(){var t=this;_super.prototype.initialize.call(this),this.$element.on("dragover",function(e){return t.onDragOver(e)}),this.$element.on("drop",function(e){return t.onDrop(e)}),document.addEventListener("DOMNodeInserted",function(e){1===e.target.nodeType&&e.target.parentElement===t.$element[0]&&t.initChildEvents(e.target)})},DraggableList.prototype.initChildEvents=function(t){var e=this;$(t).attr("draggable","true").off("drag").on("drag",function(t){return e.onDrag(t)})},DraggableList.prototype.onDragOver=function(t){if(!(ko.unwrap(this.binding.maxItemsCount)>0&&this.$element.children().length>=ko.unwrap(this.binding.maxItemsCount))&&DraggableList.draggedItemGroupName===ko.unwrap(this.binding.groupName)){t.preventDefault(),DraggableList.dragLeaving=!1;var e=this.findChildByY(t.originalEvent.pageY);this.createDragPositionIndicator(e)}},DraggableList.prototype.onDrop=function(e){DraggableList.dragConfirmed=!0,e.preventDefault();var data=this.findChildByY(e.originalEvent.pageY),draggedItem=ko.unwrap(DraggableList.draggedItemSourceCollection)[DraggableList.draggedItemIndex];DraggableList.draggedItemSourceCollection.splice(DraggableList.draggedItemIndex,1),data.index<=DraggableList.draggedItemIndex?this.getDataSource().splice(data.index,0,draggedItem):data.index>DraggableList.draggedItemIndex&&(DraggableList.draggedItemSourceCollection===this.getDataSource()&&data.index--,this.getDataSource().splice(data.index,0,draggedItem)),ko.unwrap(this.binding.itemDragged)&&eval(ko.unwrap(this.binding.itemDragged)),DraggableList.onDragLeave(e)},DraggableList.removeDragPositionIndicator=function(){DraggableList.dragPositionIndicator&&(DraggableList.dragPositionIndicator.remove(),DraggableList.dragPositionIndicator=null)},DraggableList.prototype.createDragPositionIndicator=function(t){var e=this,n=!1;DraggableList.dragPositionIndicator||(DraggableList.dragPositionIndicator=$(""),n=!0),null==t.child?this.$element.append(DraggableList.dragPositionIndicator):t.append?DraggableList.dragPositionIndicator.insertAfter(t.child):DraggableList.dragPositionIndicator.insertBefore(t.child),n&&DraggableList.dragPositionIndicator.on("dragover",function(t){return e.onDragOver(t)})},DraggableList.prototype.getDataSource=function(){return this.allBindings.get("foreach")},DraggableList.prototype.getChildren=function(){return $("")},DraggableList.prototype.findChildByY=function(t){for(var e=this.getChildren(),n={left:0,top:0},i=100,s=0,o=0;o<e.length;o++)if(n=$(e[o]).offset(),i=$(e[o]).outerWidth(),s=$(e[o]).outerHeight(),t<n.top+s/2)return{index:o,child:$(e[o]),append:!1,x:n.left,width:i,y:n.top};return{index:e.length,child:e.length>0?$(e[e.length-1]):null,append:!0,x:n.left,width:i,y:n.top+s}},DraggableList.prototype.onDrag=function(t){DraggableList.draggedItemIndex=ko.contextFor(t.target).$index(),DraggableList.draggedItemSourceCollection=this.getDataSource(),DraggableList.draggedItemGroupName=ko.unwrap(this.binding.groupName),DraggableList.dragConfirmed=!1},DraggableList.getDataSourceFromExpression=function(t){var e=ko.unwrap(t);return void 0===e||null===e?ko.observableArray([]):e.Items||t},DraggableList.onDragLeave=function(t){DraggableList.draggedItemGroupName="",DraggableList.draggedItemIndex=-1,DraggableList.draggedItemSourceCollection=null,DraggableList.dragConfirmed=!1,DraggableList.removeDragPositionIndicator()},DraggableList.onDragLeaveCore=function(t){DraggableList.dragLeaving=!0,window.setTimeout(function(){DraggableList.dragLeaving&&(DraggableList.onDragLeave(t),DraggableList.dragLeaving=!1)},500)},DraggableList}(Controls.ControlBase);Controls.DraggableList=DraggableList;var IndicatorPlacement=function(){return function(){}}();BusinessPack.Utils.installBindingHandler("DraggableList",DraggableList),$(document).on("dragleave",function(t){return DraggableList.onDragLeaveCore(t)})}(Controls=BusinessPack.Controls||(BusinessPack.Controls={}))}(BusinessPack=DotVVM.BusinessPack||(DotVVM.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(n){function i(){var t=null!==n&&n.apply(this,arguments)||this;return t.focusedItemKey=ko.observable(),t.selectedItemKey=ko.observable(),t}return __extends(i,n),Object.defineProperty(i.prototype,"isOpened",{get:function(){return this.popupPanel.isOpened},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"hasValue",{get:function(){return null!=this.binding.selectedValue()},enumerable:!0,configurable:!0}),i.prototype.initialize=function(){var i=this;n.prototype.initialize.call(this),this.$value=this.$element.children("."+t.BusinessPackCss.bpValue),this.$unselectButton=this.$element.children("."+t.BusinessPackCss.bpUnselect),this.$toggleButton=this.$element.children("."+t.BusinessPackCss.bpToggle),this.$popup=this.$element.children("."+t.BusinessPackCss.bpPopup),this.$results=this.$popup.children("ul"),this.popupPanel=new e.PopupPanel(this.$popup),this.$element.focusin(this.onElementFocusin.bind(this)),this.$element.focusout(this.onElementFocusout.bind(this)),this.$element.keydown(this.onElementKeydown.bind(this)),this.$value.click(this.onToggleButtonClick.bind(this)),this.$popup.mousedown(function(t){return t.preventDefault()}),this.$results.on("click","."+t.BusinessPackCss.bpItem+":not(."+t.BusinessPackCss.bpStateDisabled+")",this.onResultClick.bind(this)),this.$unselectButton.click(this.onUnselectButtonClick.bind(this)),this.$toggleButton.click(this.onToggleButtonClick.bind(this)),this.outside("click",function(){return i.popupPanel.close()}),this.watch(this.binding.selectedValue,this.onSelectedValueChange),this.subscribe(this.searchResults,this.onSearchResultsChange)},i.prototype.togglePopup=function(t){void 0===t&&(t=!this.isOpened);var e=t&&this.isEnabled;e&&!this.isOpened&&this.search(null),this.popupPanel.toggle(e)},i.prototype.focusItem=function(t){this.isItemEnabled(t)&&this.focusedItemKey(this.getItemKey(t))},i.prototype.isFocused=function(t){return this.getItemKey(t)===this.focusedItemKey()},i.prototype.getFocusedItem=function(){return this.findItemByKey(this.focusedItemKey)},i.prototype.unfocusItems=function(){this.focusedItemKey(null)},i.prototype.selectItem=function(t){this.togglePopup(!1),this.isItemEnabled(t)&&!this.isSelected(t)&&(this.binding.selectedValue(this.getItemValueCopy(t)),this.postback(this.binding.changed)),this.search(null),this.focusItem(t)},i.prototype.isSelected=function(t){return this.getItemKey(t)===this.selectedItemKey()},i.prototype.getSelectedItem=function(){return this.findItemByKey(this.selectedItemKey)},i.prototype.unselectItem=function(){this.hasValue&&(this.binding.selectedValue(null),this.postback(this.binding.changed)),this.search(null)},i.prototype.onElementFocusin=function(e){this.$element.addClass(t.BusinessPackCss.bpStateFocused)},i.prototype.onElementFocusout=function(e){this.$element.removeClass(t.BusinessPackCss.bpStateFocused),this.isOutsideOfTree(e.relatedTarget)&&this.togglePopup(!1)},i.prototype.onElementKeydown=function(e){this.isEnabled&&(this.isOpened?e.which===t.KeyboardKeys.esc?(e.stopPropagation(),this.togglePopup(!1)):t.KeyboardKeys.isEnter(e.which)?(e.stopPropagationAndPreventDefault(),this.selectFocusedItem()):e.which===t.KeyboardKeys.tab?(e.stopPropagation(),this.selectFocusedItem()):e.which===t.KeyboardKeys.down?(e.stopPropagationAndPreventDefault(),this.focusNextItem()):e.which===t.KeyboardKeys.up&&(e.stopPropagationAndPreventDefault(),this.focusPrevItem()):e.which===t.KeyboardKeys.down?(e.stopPropagationAndPreventDefault(),e.altKey?this.togglePopup(!0):this.selectNextItem()):e.which===t.KeyboardKeys.up&&(e.stopPropagationAndPreventDefault(),this.selectPrevItem()))},i.prototype.onResultClick=function(t){$(t.currentTarget).parent().is(this.$results)&&(t.stopPropagation(),this.selectItem(ko.dataFor(t.currentTarget)))},i.prototype.onUnselectButtonClick=function(t){this.isEnabled&&(t.stopPropagation(),this.unselectItem())},i.prototype.onToggleButtonClick=function(t){this.isEnabled&&(t.stopPropagation(),this.togglePopup())},i.prototype.onSelectedValueChange=function(e){var n=this.findItemByValue(e);this.$element.toggleClass(t.BusinessPackCss.bpStateEmptyValue,!e),n?this.selectedItemKey(this.getItemKey(n)):(null!=e&&this.warnThatValueWasNotFound(e),this.selectedItemKey(null))},i.prototype.onSearchResultsChange=function(t){var e=this.getFocusedItem();this.hasBeenFound(e)||this.focusFirstSearchResult()},i.prototype.focusPrevItem=function(){var e=this.getFocusedElement().prevAll(":not(."+t.BusinessPackCss.bpStateDisabled+"):first");e.length&&(this.scrollToItem(e),this.focusItem(ko.dataFor(e[0])))},i.prototype.focusNextItem=function(){var e=this.getFocusedElement(),n=e.nextAll(":not(."+t.BusinessPackCss.bpStateDisabled+"):first");n.length||e.length||(n=this.$results.children("."+t.BusinessPackCss.bpItem+":not(."+t.BusinessPackCss.bpStateDisabled+"):first")),n.length&&(this.scrollToItem(n),this.focusItem(ko.dataFor(n[0])))},i.prototype.scrollToItem=function(t){var e=this.$results.innerHeight(),n=parseInt(this.$results.css("padding-top")),i=parseInt(this.$results.css("padding-bottom")),s=parseInt(t.css("margin-top")),o=parseInt(t.css("margin-bottom")),r=t.is(":first-child")?n:s,a=t.is(":last-child")?i:o,l=t.position().top,u=l+t.outerHeight(!0),c=this.$results.scrollTop();u>e?this.$results.scrollTop(c+(u-e)+a):l<0&&this.$results.scrollTop(c+l-r)},i.prototype.focusFirstSearchResult=function(){var t=this.searchResults()[0];t?this.focusItem(t()):this.unfocusItems()},i.prototype.selectPrevItem=function(){var e=this.$results.children("."+t.BusinessPackCss.bpItem+"."+t.BusinessPackCss.bpStateSelected).prevAll(":not(."+t.BusinessPackCss.bpStateDisabled+"):first");e.length&&this.selectItem(ko.dataFor(e[0]))},i.prototype.selectNextItem=function(){var e=this.$results.children("li."+t.BusinessPackCss.bpStateSelected),n=e.nextAll(":not(."+t.BusinessPackCss.bpStateDisabled+"):first");n.length||e.length||(n=this.$results.children("."+t.BusinessPackCss.bpItem+":not(."+t.BusinessPackCss.bpStateDisabled+"):first")),n.length&&this.selectItem(ko.dataFor(n[0]))},i.prototype.canSelectFocusedItem=function(){var t=this.getFocusedItem();return this.isOpened&&t&&!this.isSelected(t)},i.prototype.getFocusedElement=function(){return this.$results.children("."+t.BusinessPackCss.bpItem+"."+t.BusinessPackCss.bpStateFocused)},i.prototype.selectFocusedItem=function(){var t=this.getFocusedItem();if(this.isOpened&&t)return this.selectItem(t);this.togglePopup(!1)},i.prototype.getItemStyle=function(e){e=ko.unwrap(e);var n={};return n[t.BusinessPackCss.bpStateDisabled]=!this.isItemEnabled(e),n[t.BusinessPackCss.bpStateFocused]=this.isFocused(e),n[t.BusinessPackCss.bpStateSelected]=this.isSelected(e),n},i}(e.SelectorBase);e.DropDownList=n,t.Utils.installBindingHandler("DropDownList",n)}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";function n(t){$(t).css({height:"auto","overflow-y":"hidden",width:"100%"})}var i=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return __extends(i,e),i.prototype.initialize=function(){e.prototype.initialize.call(this),this.$spanElement=this.$element.children("span"),this.$spanElement.on("click",this.divClicked.bind(this))},i.prototype.keyAction=function(e){if(t.KeyboardKeys.isEnter(e.which)){var n=e.target.value.replace(/\n|\r\n/gi,"");this.binding.text(n),$(e.target).remove(),this.$spanElement.show()}e.which===t.KeyboardKeys.esc&&($(e.target).remove(),this.$spanElement.show())},i.prototype.onKeyDown=function(e){t.KeyboardKeys.isEnter(e.which)&&e.preventDefault()},i.prototype.divClicked=function(){this.$spanElement.hide();var t=$("<textarea />");t.html(this.binding.text()),t.css("font-family",this.$spanElement.css("font-family")),t.css("font-size",this.$spanElement.css("font-size")),t.keydown(this.onKeyDown.bind(this)),t.keyup(this.keyAction.bind(this)),$(this.$element).append(t),t.each(function(){n(this)}).on("input",function(){n(this)}),t.focus()},i}(e.ControlBase);e.EditableLiteral=i,t.Utils.installBindingHandler("EditableLiteral",i)}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(t){"use strict";var e=function(t){function e(e){var n=t.call(this)||this;return n.uploadUrl=e,n}return __extends(e,t),e.prototype.start=function(t){return this.on("start",t)},e.prototype.progress=function(t){return this.on("progress",t)},e.prototype.complete=function(t){return this.on("complete",t)},e.prototype.error=function(t){return this.on("error",t)},e.prototype.processResponse=function(t){try{return JSON.parse(t)}catch(t){return null}},e}(t.ReactiveBase);t.UploaderBase=e}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(t){"use strict";var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.upload=function(t){var e=new FormData;if(t&&t.length){for(var n=0,i=t;n<i.length;n++){var s=i[n];e.append("upload",s)}this.trigger("start",t),this.sendForm(e)}},e.prototype.sendForm=function(t){var e=this,n=dotvvm.getXHR();n.open("POST",this.uploadUrl,!0),n.setRequestHeader("X-DotVVM-AsyncUpload","true"),n.upload.onprogress=function(t){t.lengthComputable&&e.trigger("progress",100*t.loaded/t.total)},n.onload=function(t){var i=e.processResponse(n.responseText);200!==n.status?e.trigger("error","string"==typeof i?i:null):e.trigger("complete",i)},n.send(t)},e}(t.UploaderBase);t.FormDataUploader=e}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(n){function i(){var t=null!==n&&n.apply(this,arguments)||this;return t.previewUrls=[],t}return __extends(i,n),Object.defineProperty(i.prototype,"uploadData",{get:function(){return this.binding.data()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"uploadUrl",{get:function(){return this.binding.uploadUrl},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"areMultipleFilesAllowed",{get:function(){var t=this.binding.allowMultipleFiles;return void 0===t||t},enumerable:!0,configurable:!0}),i.prototype.initialize=function(){var i=this;n.prototype.initialize.call(this),this.$input=this.$element.children("input[type='file']"),this.uploader=new e.FormDataUploader(this.uploadUrl),t.Utils.bindDragEvents(this.$element,function(){return i.onElementDragenter()},function(){return i.onElementDragleave()}),this.$element.on("click","."+t.BusinessPackCss.bpSelectFiles,function(t){return i.onSelectFilesClick(t)}).on("click","."+t.BusinessPackCss.bpDelete,function(t){return i.onDeleteFileClick(t)}).on("dragenter drop",function(t){return t.stopPropagationAndPreventDefault()}).on("dragover",function(t){return t.preventDefault()}).on("drop",function(t){return i.onElementDrop(t)}),this.uploader.start(function(t){return i.onUploadStart(t)}).progress(function(t){return i.onUploadProgress(t)}).complete(function(t){return i.onUploadComplete(t)}).error(function(t){return i.onUploadError(t)}),this.$input.change(function(t){return i.onInputChange(t)}),this.disposing(function(){return i.uploader.dispose()})},i.prototype.onSelectFilesClick=function(t){var e=this.binding.data();this.isEnabled&&!e.IsBusy()&&(t.stopPropagation(),this.$input.click())},i.prototype.onDeleteFileClick=function(t){var e=this.binding.data(),n=ko.dataFor(t.target).FileId;if(this.isEnabled&&n){t.stopPropagation();var i=e.Files().asLinq().single(function(t){return t().FileId()===n()}),s=i().PreviewUrl();s&&this.revokePreviewUrl(s),e.Files.remove(i)}},i.prototype.onInputChange=function(t){var e=this.binding.data(),n=this.$input[0];this.isEnabled&&!e.IsBusy()&&(t.stopPropagation(),this.uploadFiles(n.files))},i.prototype.onElementDragenter=function(){this.isEnabled&&this.$element.addClass(t.BusinessPackCss.bpStateDragover)},i.prototype.onElementDragleave=function(){this.$element.removeClass(t.BusinessPackCss.bpStateDragover)},i.prototype.onElementDrop=function(e){var n=this,i=e.originalEvent.dataTransfer,s=this.binding.data();this.isEnabled&&!s.IsBusy()&&t.FileUtils.getFiles(i).done(function(t){return n.uploadFiles(t)})},i.prototype.onEnabledChange=function(){n.prototype.onEnabledChange.call(this),this.$element.find("."+t.BusinessPackCss.bpSelectFiles).toggleClass(t.BusinessPackCss.bpStateDisabled,!this.isEnabled)},i.prototype.onUploadStart=function(e){for(var n=this.binding.data(),i=0,s=e;i<s.length;i++){var o=s[i],r=this.createUploadFile(o);n.Files.push(ko.observable(r))}this.$element.addClass(t.BusinessPackCss.bpStateBusy),this.$element.removeClass(t.BusinessPackCss.bpStateError),n.Progress(0),n.IsBusy(!0),n.ErrorMessage(null)},i.prototype.onUploadProgress=function(t){this.binding.data().Progress(t)},i.prototype.onUploadComplete=function(e){for(var n=this.binding.data(),i=0,s=e;i<s.length;i++)!function(e){var i=n.Files().asLinq().firstOrDefault(function(t){return t().FileName()===e.FileName});i?(i().FileId(e.FileId),i().FileSize({Bytes:ko.observable(e.FileSize.Bytes),FormattedText:ko.observable(e.FileSize.FormattedText)}),i().IsFileTypeAllowed(e.IsFileTypeAllowed),i().IsMaxSizeExceeded(e.IsMaxSizeExceeded),i().IsAllowed(e.IsAllowed),i().IsUploaded(!0)):t.Utils.warnInDebugMode("Matching file was not found.")}(s[i]);this.isEnabled&&this.postback(this.binding.uploadCompleted),this.$element.removeClass(t.BusinessPackCss.bpStateBusy),this.$element.removeClass(t.BusinessPackCss.bpStateError),n.Progress(0),n.IsBusy(!1),n.ErrorMessage(null),this.$input.val("")},i.prototype.onUploadError=function(e){var n=this.binding.data();this.$element.removeClass(t.BusinessPackCss.bpStateBusy),this.$element.addClass(t.BusinessPackCss.bpStateError),n.Progress(0),n.IsBusy(!1),n.ErrorMessage(e||this.binding.genericErrorText),this.$input.val("")},i.prototype.uploadFiles=function(e){Array.isArray(e)||(e=t.FileUtils.filesToArray(e)),this.areMultipleFilesAllowed||(e=e.slice(0,1));var n=this.binding.data(),i=this.validateFiles(e),s=i[0],o=i[1];!this.areMultipleFilesAllowed&&n.Files().length&&this.clearFiles();for(var r=0,a=o;r<a.length;r++){var l=a[r];n.Files.push(ko.observable(l))}this.uploader.upload(s)},i.prototype.validateFiles=function(t){for(var e=[],n=[],i=0,s=t;i<s.length;i++){var o=s[i],r=this.isFileTypeAllowed(o),a=this.isMaxSizeExceeded(o);a||!r?n.push(this.createUploadFile(o,r,a)):e.push(o)}return[e,n]},i.prototype.isFileTypeAllowed=function(e){var n=this.binding.allowedFileTypes,i=e.type.replace(t.RegexUtils.mimeTypeSecondPart(),""),s=t.FileUtils.getExtension(e.name);if(!n||!e.type)return!0;for(var o=0,r=n.split(",");o<r.length;o++){var a=r[o];if((a=a.trim()).startsWith(".")){if(a.toUpperCase()===s.toUpperCase())return!0}else{if(!e.type)return!0;if(t.RegexUtils.wildcardMimeType().exec(a)&&i===a.replace(t.RegexUtils.mimeTypeSecondPart(),""))return!0;if(e.type===a)return!0}}return!1},i.prototype.isMaxSizeExceeded=function(t){var e=this.binding.maxFileSize;if(e){var n=1024*e*1024;return t.size>n}return!1},i.prototype.createUploadFile=function(e,n,i){void 0===n&&(n=!0),void 0===i&&(i=!1);var s=n&&!i;return{FileId:ko.observable(t.Utils.createGuid(!0)),FileName:ko.observable(e.name),FileSize:ko.observable({Bytes:ko.observable(e.size),FormattedText:ko.observable(t.FileUtils.formatSize(e.size))}),PreviewUrl:ko.observable(this.createPreviewUrl(e)),IsUploaded:ko.observable(!1),IsFileTypeAllowed:ko.observable(n),IsMaxSizeExceeded:ko.observable(i),IsAllowed:ko.observable(s)}},i.prototype.createPreviewUrl=function(e){if(!t.FileUtils.isImageFile(e))return null;var n=URL.createObjectURL(e);return this.previewUrls.push(n),n},i.prototype.revokePreviewUrl=function(t){var e=this.previewUrls.indexOf(t);e>=0&&(this.previewUrls.splice(e,1),URL.revokeObjectURL(t))},i.prototype.clearFiles=function(){for(var t=this.binding.data(),e=0,n=this.previewUrls;e<n.length;e++){var i=n[e];URL.revokeObjectURL(i)}this.previewUrls=[],t.Files([])},i.prototype.getFileStyle=function(e){return n={},n[t.BusinessPackCss.bpStateError]=!e.IsAllowed(),n;var n},i}(e.ControlBase);e.FileUpload=n,t.Utils.installBindingHandler("FileUpload",n)}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return __extends(n,e),n.prototype.initialize=function(){e.prototype.initialize.call(this),this.$element.on("click","."+t.BusinessPackCss.bpFilterLogic,this.onFilterLogicClick.bind(this)),this.$element.on("click","."+t.BusinessPackCss.bpAddGroup,this.onAddGroupClick.bind(this)),this.$element.on("click","."+t.BusinessPackCss.bpAddCondition,this.onAddConditionClick.bind(this)),this.$element.on("click","."+t.BusinessPackCss.bpDelete,this.onDeleteFilterClick.bind(this))},n.prototype.getOperators=function(t){return["Equal","NotEqual","GreaterThan","GreaterThanOrEqual","LessThan","LessThanOrEqual","Null","NotNull","True","False"]},n.prototype.canAddGroup=function(t){var e=this.binding.hierarchyDepth;return 0===e||t+1<e},n.prototype.resetFilter=function(t){t.Value(null)},n.prototype.getDataType=function(t){var e=this.getField(t);return e?e.DataType():null},n.prototype.getField=function(t){for(var e=0,n=this.binding.fields();e<n.length;e++){var i=n[e];if(i().Name()===t)return i()}return null},n.prototype.onFilterLogicClick=function(t){var e=ko.dataFor(t.target).group;switch(e.Logic()){case"And":e.Logic("NotAnd");break;case"NotAnd":e.Logic("Or");break;case"Or":e.Logic("NotOr");break;default:e.Logic("And")}},n.prototype.onAddGroupClick=function(t){var e=ko.dataFor(t.target).group,n={Type:ko.observable("FilterGroup"),Logic:ko.observable(e.Logic()),Filters:ko.observableArray()};e.Filters.push(ko.observable(n))},n.prototype.onAddConditionClick=function(t){var e=this.binding.fields()[0](),n=ko.dataFor(t.target).group,i={Type:ko.observable("FilterCondition"),Field:ko.observable(e.Name()),Operator:ko.observable("Equal"),Value:ko.observable()};n.Filters.push(ko.observable(i))},n.prototype.onDeleteFilterClick=function(t){var e=ko.dataFor(t.target);ko.contextFor(t.target).$parent.group.Filters.remove(function(t){return t()===e})},n}(e.ControlBase);e.FilterBuilder=n,t.Utils.installBindingHandler("FilterBuilder",n)}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(t){"use strict";!function(t){t.selectedRowIndex=ko.observable(),t.clickRow=function(e){var n=ko.unwrap(e);t.selectedRowIndex(n)}}(t.DefaultGridViewRowClickDecorator||(t.DefaultGridViewRowClickDecorator={}))}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return __extends(n,e),n.prototype.initialize=function(){if(e.prototype.initialize.call(this),null!=this.binding.userSettings){if(!ko.isObservable(this.binding.allowReorderColumns)){var t=ko.unwrap(this.binding.allowReorderColumns);t&&(this.binding.allowReorderColumns=ko.observable(t))}this.subscribe(this.binding.allowReorderColumns,this.onAllowReorderColumnsChanged),this.sortColumnsSettings(),this.watch(this.binding.userSettings,this.onUserSettingsChanged)}},n.prototype.getColumnVisible=function(t){return ko.pureComputed(function(){var e=$(t),n=e.closest("table")[0];if(n){var i=n.rows[0].cells[e.index()],s=ko.contextFor(i);if(s)return ko.bindingProvider.instance.getBindingAccessors(i,s).visible()}return!1})},n.prototype.sortColumnsSettings=function(){this.binding.userSettings().ColumnsSettings.sort(function(t,e){return ko.unwrap(t).DisplayOrder()>ko.unwrap(e).DisplayOrder()?1:-1})},n.prototype.getThisElementTHeadRows=function(){return this.getThisElement().find("thead tr")},n.prototype.getThisElement=function(){return this.$element},n.prototype.onUserSettingsChanged=function(){this.onColumnsSettingsChanged()},n.prototype.onColumnsSettingsChanged=function(){this.orderColumns(this.getThisElement(),ko.unwrap(ko.unwrap(this.binding.userSettings).ColumnsSettings))},n.prototype.getDataSourceForEmptyData=function(e){var n=t.Utils.getDataSourceItems(e),i=e().ItemInsertOptions;if(n().length)return e;if(i){var s=i().InsertedItem;if(ko.unwrap(s))return ko.observableArray([s])}return ko.observableArray([])},n.prototype.onAllowReorderColumnsChanged=function(){var t=this.getThisElementTHeadRows();ko.unwrap(this.binding.allowReorderColumns)?(this.onColumnsSettingsChanged(),this.enableDraggable(t)):this.destroyDraggable(t)},n.prototype.getColumnSettingsByColumnName=function(t,e){for(var n=0,i=ko.unwrap(ko.unwrap(e.binding.userSettings).ColumnsSettings);n<i.length;n++){var s=i[n];if(ko.unwrap(ko.unwrap(s).ColumnName)===t)return ko.unwrap(s)}return null},n.prototype.orderColumns=function(t,e){for(var n=this,i=this,s=0,o=e;s<o.length;s++)!function(e){var s,o=ko.unwrap(e);i.getThisElement().find("thead tr th").each(function(){var t=$(this),e=t.attr("data-column");ko.unwrap(o.ColumnName)===e&&(s=t.index())});var r=ko.unwrap(ko.unwrap(o).DisplayOrder);s!==r&&(i.rearrangeColumns(t,s,r),i.updateTemplate("RowTemplate",function(t){return n.rearrangeColumnsIn(t,s,r)}),i.updateTemplate("EditRowTemplate",function(t){return n.rearrangeColumnsIn(t,s,r)}),i.updateTemplate("InsertRowTemplate",function(t){return n.rearrangeColumnsIn(t,s,r)}))}(o[s])},n.prototype.rearrangeColumns=function(t,e,n){var i=this;t.find("tr").each(function(t,s){i.rearrangeColumnsIn($(s),e,n)})},n.prototype.rearrangeColumnsIn=function(t,e,n){var i=t.find("td:eq("+e+")"),s=t.find("td:eq("+n+")");i.detach().insertAfter(s);var o=t.find("th:eq("+e+")"),r=t.find("th:eq("+n+")");o.detach().insertAfter(r)},n.prototype.destroyDraggable=function(t){t.sortable("destroy")},n.prototype.enableDraggable=function(e){var n,i=this;e.sortable({containerSelector:"tr",itemSelector:"th",exclude:".non-dragable",placeholder:'<th class="placeholder"></th>',vertical:!1,onDragStart:function(t,e,i){n=t.index(),t.appendTo(t.parent()),i(t,e)},onDrop:function(e,s,o){var r=e.index();t.Utils.warnInDebugMode("drag on index:"+n+", drop on index:"+r);var a,l=e.closest("table");r>n?(l.find("tbody tr,tfoot tr").each(function(t,e){var i=$(e).children().eq(r);$(e).children().eq(n).insertAfter(i)}),a=i.getThisElement().find("thead tr th").get()):r<n&&(l.find("tbody tr,tfoot tr").each(function(t,e){var i=$(e).children().eq(r);$(e).children().eq(n).insertBefore(i)}),a=i.getThisElement().find("thead tr th").get()),o(e,s);var u=[];a.forEach(function(e){var n=$(e),s=n.attr("data-column"),o=t.Utils.deepCopy(i.getColumnSettingsByColumnName(s,i)),r=n.index();t.Utils.warnInDebugMode("Change columnSetting with columnName: "+o.ColumnName()+", with DisplayOrder:"+o.DisplayOrder()+", to new index :"+n.index()),o.DisplayOrder(r),u.push(ko.observable(o))}),i.updateTemplate("RowTemplate",function(t){return i.rearrangeColumnsIn(t,n,r)}),i.updateTemplate("EditRowTemplate",function(t){return i.rearrangeColumnsIn(t,n,r)}),i.updateTemplate("InsertRowTemplate",function(t){return i.rearrangeColumnsIn(t,n,r)}),i.binding.userSettings().ColumnsSettings(u),i.sortColumnsSettings()}})},n}(e.ControlBase);e.GridView=n,t.Utils.installBindingHandler("GridView",n)}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";function n(t){var e=(t=t||window.event).keyCode||t.which;e!==i.ArrowUp&&e!==i.ArrowDown&&e!==i.Home&&e!==i.End||(s(e),t.preventDefault())}var i;!function(t){t[t.None=0]="None",t[t.ArrowUp=38]="ArrowUp",t[t.ArrowDown=40]="ArrowDown",t[t.Home=36]="Home",t[t.End=35]="End"}(i||(i={}));var s=ko.observable(i.None),o=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.initialize=function(){t.prototype.initialize.call(this),document.onkeydown=n,this.subscribe(s,this.onKeyboardActionChange)},e.prototype.onKeyboardActionChange=function(t){if(ko.unwrap(this.binding.actionEnabled)&&t!==i.None){var e=ko.unwrap(this.binding.rowElementSelector),n=$(e);if(n.length)switch(t){case i.ArrowUp:var o=n.first().prev();o.length&&o.click();break;case i.ArrowDown:var r=n.first().next();r.length&&r.click();break;case i.Home:var a=n.first().prevAll();a.length&&a.last().click();break;case i.End:var l=n.first().nextAll();l.length&&l.last().click()}}s(i.None)},e}(e.ControlBase);e.GridViewKeyboardActionsDecorator=o,t.Utils.installBindingHandler("GridViewKeyboardActionsDecorator",o)}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),Object.defineProperty(e.prototype,"columnsSettings",{get:function(){return this.binding.userSettings().ColumnsSettings},enumerable:!0,configurable:!0}),e}(e.ControlBase);e.GridViewUserSettingsEditor=n,t.Utils.installBindingHandler("GridViewUserSettingsEditor",n)}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e}(e.HierarchyItemsControlBase);e.HierarchyRepeater=n,t.Utils.installBindingHandler("HierarchyRepeater",n)}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(n){function i(i,s){var o=n.call(this,i,s)||this;if(o.$imagePreview=i.find("img"),o.$originalImage=s.$imageCanvas.children("img"),o.$resizeGrips=$('<div class="'+t.BusinessPackCss.bpGrip+" "+t.BusinessPackCss.bpGripN+'" />').add('<div class="'+t.BusinessPackCss.bpGrip+" "+t.BusinessPackCss.bpGripNE+'" />').add('<div class="'+t.BusinessPackCss.bpGrip+" "+t.BusinessPackCss.bpGripE+'" />').add('<div class="'+t.BusinessPackCss.bpGrip+" "+t.BusinessPackCss.bpGripSE+'" />').add('<div class="'+t.BusinessPackCss.bpGrip+" "+t.BusinessPackCss.bpGripS+'" />').add('<div class="'+t.BusinessPackCss.bpGrip+" "+t.BusinessPackCss.bpGripSW+'" />').add('<div class="'+t.BusinessPackCss.bpGrip+" "+t.BusinessPackCss.bpGripW+'" />').add('<div class="'+t.BusinessPackCss.bpGrip+" "+t.BusinessPackCss.bpGripNW+'" />'),o.hasForcedSize)o.$element.mousedown(function(t){return t.stopPropagationAndPreventDefault()});else{var r=o.options.restrictToParent;o.elementMovable=new e.Movable(o.$element,r),o.$parent.css("cursor","crosshair"),o.$resizeGrips.mousedown(o.onResizeGripMousedown.bind(o)),o.$element.append(o.$resizeGrips)}return o}return __extends(i,n),Object.defineProperty(i.prototype,"hasForcedSize",{get:function(){return null!==this.getForcedSize()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"hasForcedRadius",{get:function(){return!!this.options.forcedRadius},enumerable:!0,configurable:!0}),i.prototype.reset=function(){if(this.loadRadius(null),this.hasForcedSize){var t=this.getForcedSize(),e=(this.$parent.width()-t.width)/2,i=(this.$parent.height()-t.height)/2;this.$element.width(t.width).height(t.height).css({left:Math.round(e),top:Math.round(i)}).show()}else n.prototype.reset.call(this)},i.prototype.getCropRectangle=function(){var t=this.$element[0].getBoundingClientRect(),e=this.$originalImage[0].getBoundingClientRect();return this.$element.is(":visible")?{Left:ko.observable(Math.round(t.left-e.left)),Top:ko.observable(Math.round(t.top-e.top)),Width:ko.observable(this.$element.width()),Height:ko.observable(this.$element.height())}:null},i.prototype.loadCropRectangle=function(t){var e=t.Left,n=t.Top,i=t.Width,s=t.Height,o=this.$parent.offset(),r=this.$originalImage[0].getBoundingClientRect();e&&n&&i&&s&&this.$element.width(i()).height(s()).css({left:r.left+e()-o.left,top:r.top+n()-o.top}).show()},i.prototype.loadRadius=function(e){this.hasForcedRadius&&(e=this.options.forcedRadius),e?(this.$element.css("border-radius",e+"%"),this.$element.addClass(t.BusinessPackCss.bpRounded)):(this.$element.css("border-radius",""),this.$element.removeClass(t.BusinessPackCss.bpRounded))},i.prototype.getDefaultOptions=function(){return{tempAspectRatio:1,restrictToParent:!0,$imageCanvas:null,minWidth:5,minHeight:5}},i.prototype.onResizeGripMousedown=function(e){e.stopPropagationAndPreventDefault();var n=$(e.target),i=this.$element.position(),s=this.$element.width(),o=this.$element.height();n.hasClass(t.BusinessPackCss.bpGripN)?(this.initialX=i.left+s/2,this.initialY=i.top+o,this.lockX=!0):n.hasClass(t.BusinessPackCss.bpGripNE)?(this.initialX=i.left,this.initialY=i.top+o):n.hasClass(t.BusinessPackCss.bpGripE)?(this.initialX=i.left,this.initialY=i.top+o/2,this.lockY=!0):n.hasClass(t.BusinessPackCss.bpGripSE)?(this.initialX=i.left,this.initialY=i.top):n.hasClass(t.BusinessPackCss.bpGripS)?(this.initialX=i.left+s/2,this.initialY=i.top,this.lockX=!0):n.hasClass(t.BusinessPackCss.bpGripSW)?(this.initialX=i.left+s,this.initialY=i.top):n.hasClass(t.BusinessPackCss.bpGripW)?(this.initialX=i.left+s,this.initialY=i.top+o/2,this.lockY=!0):n.hasClass(t.BusinessPackCss.bpGripNW)&&(this.initialX=i.left+s,this.initialY=i.top+o),this.$document.mousemove(this.onDocumentMousemoveHandler),this.$document.mouseup(this.onDocumentMouseupHandler)},i.prototype.shouldStartSelection=function(t){return!this.hasForcedSize&&n.prototype.shouldStartSelection.call(this,t)},i.prototype.refreshContents=function(){var t=this.$element.offset(),e=this.options.$imageCanvas.offset();this.$imagePreview.prop("src")!==this.$originalImage.prop("src")&&this.$imagePreview.prop("src",this.$originalImage.prop("src")),this.$imagePreview.width(this.$originalImage.width()),this.$imagePreview.css("transform",this.$originalImage.css("transform")),this.$imagePreview.css({left:-(t.left-e.left),top:-(t.top-e.top)}),n.prototype.refreshContents.call(this)},i.prototype.getForcedSize=function(){var t=this.options,e=t.aspectRatio,n=t.forcedWidth,i=t.forcedHeight;return e=e||1,n?{width:n,height:i||n/e}:i?{width:i*e,height:i}:null},i}(e.SelectionBox);e.CropBox=n}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(n){function i(){return null!==n&&n.apply(this,arguments)||this}return __extends(i,n),i.prototype.initialize=function(){var i=this;n.prototype.initialize.call(this),this.$imageCanvas=this.$element.children("."+t.BusinessPackCss.bpImageCanvas),this.$image=this.$imageCanvas.children("img"),this.$cropCanvas=this.$element.children("."+t.BusinessPackCss.bpCropCanvas),this.$cropOverlay=this.$cropCanvas.children("."+t.BusinessPackCss.bpOverlay),this.$cropBox=this.$cropCanvas.children("."+t.BusinessPackCss.bpSelectionBox),this.$userControls=this.$element.children("."+t.BusinessPackCss.bpUserControls),this.$toggle=this.$userControls.children("."+t.BusinessPackCss.bpToggle),this.$rotateLeft=this.$userControls.children("."+t.BusinessPackCss.bpRotateLeft),this.$rotateRight=this.$userControls.children("."+t.BusinessPackCss.bpRotateRight),this.$zoomIn=this.$userControls.children("."+t.BusinessPackCss.bpZoomIn),this.$zoomOut=this.$userControls.children("."+t.BusinessPackCss.bpZoomOut),this.$reset=this.$userControls.children("."+t.BusinessPackCss.bpReset),this.imageCanvasMovable=new e.Movable(this.$imageCanvas),this.crop=new e.CropBox(this.$cropBox,{$imageCanvas:this.$imageCanvas,forcedWidth:this.binding.forcedCropWidth,forcedHeight:this.binding.forcedCropHeight,forcedRadius:this.binding.forcedCropRadius,aspectRatio:this.getAspectRatio()}),this.$window.on("resize"+this.eventNs,this.onWindowResize.bind(this)),this.$element.on("mousewheel",this.onElementMousewheel.bind(this)),this.imageCanvasMovable.update(function(){return i.crop.update()}),this.imageCanvasMovable.change(function(){return i.postback(i.binding.changed)}),this.$image.on("load",this.onImageLoad.bind(this)),this.$cropOverlay.mousedown(function(t){return t.preventDefault()}),this.$toggle.click(this.onToggleButtonClick.bind(this)),this.$rotateLeft.click(function(t){return i.onRotateButtonClick(-45,t)}),this.$rotateRight.click(function(t){return i.onRotateButtonClick(45,t)}),this.$zoomIn.click(function(t){return i.onZoomButtonClick(1.4,t)}),this.$zoomOut.click(function(t){return i.onZoomButtonClick(-1.4,t)}),this.$reset.click(this.onResetClick.bind(this)),this.crop.update(this.onCropUpdate.bind(this)),this.crop.change(this.onCropChange.bind(this))},i.prototype.rotate=function(t){var e=this.binding.changed,n=ko.unwrap(this.binding.operations),i=(360+(n.Rotate()+t))%360;n.Rotate(i||null),this.postback(e),this.$image.css("transform",i?"rotate("+i+"deg)":"none"),this.crop.update()},i.prototype.zoom=function(t,e){var n=this.binding.operations(),i=n.Resize();this.applyZoom(t,e),i!==n.Resize()&&this.postback(this.binding.changed)},i.prototype.onWindowResize=function(t){this.isSafeToFitAndCenterImage()&&this.fitAndCenterImage(!0)},i.prototype.onElementMousewheel=function(t){var e=this;if(t.ctrlKey){var n=t.originalEvent;t.preventDefault(),clearTimeout(this.zoomTimeoutId),this.applyZoom(n.wheelDelta>0?.7:-.7,{left:t.pageX,top:t.pageY}),this.zoomTimeoutId=setTimeout(function(){e.postback(e.binding.changed),clearTimeout(e.zoomTimeoutId)},200)}},i.prototype.onImageLoad=function(t){var e=this;t.stopPropagation(),this.$image.css({width:"auto"}),this.$image.visible(function(){e.zoomStep=e.$image.width()/100,e.loadOperations()})},i.prototype.onToggleButtonClick=function(t){var e=this.binding,n=e.switchToMovingIconCssClass,i=e.switchToCroppingIconCssClass,s=this.$imageCanvas.css("z-index");t.stopPropagation(),"1000"===s?(this.$imageCanvas.css("z-index","auto"),this.$toggle.children("i").removeClass(i),this.$toggle.children("i").addClass(n),this.$cropOverlay.hide()):(this.$imageCanvas.css("z-index","1000"),this.$toggle.children("i").removeClass(n),this.$toggle.children("i").addClass(i),this.$cropOverlay.show())},i.prototype.onRotateButtonClick=function(t,e){e.stopPropagation(),this.rotate(t)},i.prototype.onZoomButtonClick=function(t,e){e.stopPropagation(),this.zoom(t)},i.prototype.onResetClick=function(t){var e=this.binding.changed,n=ko.unwrap(this.binding.operations),i=this.binding.forcedCropRadius;t.stopPropagation(),n.Resize(null),n.Rotate(null),this.$image.css("transform","none"),this.fitAndCenterImage(!1),n.Crop(null),n.Round(i||null),this.crop.reset(),this.postback(e)},i.prototype.onCropUpdate=function(){var t=ko.unwrap(this.binding.operations),e=this.crop.getCropRectangle();t.Crop(e)},i.prototype.onCropChange=function(){this.postback(this.binding.changed)},i.prototype.loadOperations=function(){var t=!1,e=ko.unwrap(this.binding.operations),n=this.binding.forcedCropRadius,i=ko.unwrap(e.Resize),s=ko.unwrap(e.Rotate),o=ko.unwrap(e.Crop),r=ko.unwrap(e.Round);i&&(this.$image.width(i),this.$imageCanvas.css({left:(this.$element.width()-this.$image.width())/2,top:(this.$element.height()-this.$image.height())/2}),t=!0),s&&(this.$image.css("transform",s>0?"rotate("+s+"deg)":"none"),t=!0),o&&(this.crop.loadCropRectangle(o),t=!0),r?(this.crop.loadRadius(r),e.Round(n||r),t=!0):e.Round(n),t?this.crop.update():this.fitAndCenterImage(!0)},i.prototype.getAspectRatio=function(){var t=this.binding.aspectRatio;if(t){var e=t.split(":");return Number(e[0])/Number(e[1])}return null},i.prototype.fitAndCenterImage=function(t){this.$image.css("width","auto"),this.doesImageFit()||this.fitImage(t),this.$imageCanvas.css({left:(this.$element.width()-this.$image.width())/2,top:(this.$element.height()-this.$image.height())/2}),this.crop.update()},i.prototype.isSafeToFitAndCenterImage=function(){return!this.binding.operations().Crop()},i.prototype.fitImage=function(t){var e,n=this.binding.changed,i=ko.unwrap(this.binding.operations).Resize;if(this.$image.width()>this.$element.width()&&this.$image.width(e=Math.round(this.$element.width())),this.$image.height()>this.$element.height()){var s=this.$element.height()/this.$image.height();this.$image.width(e=Math.round(this.$image.width()*s))}e!==i()&&(i(e),t&&this.postback(n))},i.prototype.doesImageFit=function(){return this.$image.width()<=this.$element.width()&&this.$image.height()<=this.$element.height()},i.prototype.applyZoom=function(t,e){var n=this.$image.width(),i=this.$image.height(),s=this.$imageCanvas.position(),o=this.$imageCanvas.offset(),r=ko.unwrap(this.binding.operations),a=Math.round(n+t*this.zoomStep);if(a>50){r.Resize(a),this.$image.width(a);var l=this.$image.height();e?this.$imageCanvas.css({left:s.left-(a-n)*((e.left-o.left)/n),top:s.top-(l-i)*((e.top-o.top)/i)}):this.$imageCanvas.css({left:s.left-(a-n)/2,top:s.top-(l-i)/2})}this.crop.update()},i}(e.ControlBase);e.ImageCrop=n,t.Utils.installBindingHandler("ImageCrop",n)}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=3,i=function(i){function s(){var t=null!==i&&i.apply(this,arguments)||this;return t.focusedItemsKeys=ko.observableArray(),t.selectedItemsKeys=ko.observableArray(),t.arrowHits=n,t}return __extends(s,i),Object.defineProperty(s.prototype,"hasValue",{get:function(){return!!this.binding.selectedValues().length},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"isTilesView",{get:function(){return"Tiles"===ko.unwrap(this.binding.displayMode)},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"isListView",{get:function(){return"List"===ko.unwrap(this.binding.displayMode)},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"columnLength",{get:function(){var e=this.$list.children("."+t.BusinessPackCss.bpItem+":first-child");return Math.floor(this.$list.innerHeight()/e.outerHeight(!0))},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"rowLength",{get:function(){var e=this.$list.children("."+t.BusinessPackCss.bpItem+":first-child");return Math.floor(this.$list.innerWidth()/e.outerWidth(!0))},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"pageSize",{get:function(){return this.columnLength*this.rowLength},enumerable:!0,configurable:!0}),s.prototype.initialize=function(){i.prototype.initialize.call(this),this.$list=this.$element.children("."+t.BusinessPackCss.bpList),this.$selectionBox=this.$element.children("."+t.BusinessPackCss.bpSelectionBox),this.selection=new e.SelectionBox(this.$selectionBox,{$trigger:this.$list}),this.$element.focusin(this.onElementFocusin.bind(this)),this.$element.focusout(this.onElementFocusout.bind(this)),this.$element.keydown(this.onElementKeydown.bind(this)),this.$element.keyup(this.onElementKeyup.bind(this)),this.$list.on("click","."+t.BusinessPackCss.bpItem,this.onItemClick.bind(this)),this.selection.update(this.onSelectionUpdate.bind(this)),this.selection.change(this.onSelectionChange.bind(this)),this.watch(this.binding.dataSource,this.onDataSourceChange),this.watch(this.binding.selectedValues,this.onSelectedValuesChange)},s.prototype.focusItems=function(t){var e=this;this.focusedItemsKeys(t.map(function(t){return e.getItemKey(t)}))},s.prototype.focusItem=function(t,e){void 0===e&&(e=!0),e?this.focusedItemsKeys([this.getItemKey(t)]):this.focusedItemsKeys.push(this.getItemKey(t))},s.prototype.isFocused=function(t){var e=this.getItemKey(t);return this.focusedItemsKeys().asLinq().contains(e)},s.prototype.getFocusedItems=function(){var t=this;return this.focusedItemsKeys().map(function(e){return t.findItemByKey(e)})},s.prototype.toggleItem=function(t){this.isSelected(t)?this.unselectItem(t):this.selectItem(t)},s.prototype.selectItems=function(t,e){var n=this,i=this.binding.maxSelectedValues;i&&(t=t.slice(0,i)),this.binding.selectedValues(t.map(function(t){return ko.observable(n.getItemValueCopy(t))})),this.postback(this.binding.changed),e?this.focusItem(t.pop()):this.focusItem(t[0])},s.prototype.selectItem=function(t,e){if(void 0===e&&(e=!1),t){var n=ko.observable(this.getItemValueCopy(t));e&&this.areOtherItemsSelected(t)?(this.binding.selectedValues([n]),this.postback(this.binding.changed)):this.canBeSelected(t)&&(this.binding.selectedValues.push(n),this.postback(this.binding.changed)),this.focusItem(t)}},s.prototype.canBeSelected=function(t){var e=this.binding.maxSelectedValues,n=!this.isSelected(t);return n&&e&&(n=this.selectedItemsKeys().length<e),n},s.prototype.isSelected=function(t){var e=this.getItemKey(t);return this.selectedItemsKeys().asLinq().contains(e)},s.prototype.unselectItem=function(t){var e=this;this.isSelected(t)&&(this.binding.selectedValues.remove(function(n){return e.isValueOfItem(n,t)}),this.postback(this.binding.changed),this.focusItem(t))},s.prototype.unselectAllItems=function(){this.hasValue&&(this.binding.selectedValues.removeAll(),this.postback(this.binding.changed))},s.prototype.onElementFocusin=function(e){this.$element.addClass(t.BusinessPackCss.bpStateFocused)},s.prototype.onElementFocusout=function(e){this.$element.removeClass(t.BusinessPackCss.bpStateFocused)},s.prototype.onElementKeydown=function(e){if(!this.selection.isActive){if(t.KeyboardKeys.isArrow(e.which)){if(e.stopPropagationAndPreventDefault(),this.arrowHits<n)return void this.arrowHits++;this.arrowHits=0}e.which===t.KeyboardKeys.right?this.isTilesView&&this.focusOrSelectNextItem(e):e.which===t.KeyboardKeys.down?this.isTilesView?this.focusOrSelectItemBelow(e):this.focusOrSelectNextItem(e):e.which===t.KeyboardKeys.left?this.isTilesView&&this.focusOrSelectPrevItem(e):e.which===t.KeyboardKeys.up?this.isTilesView?this.focusOrSelectItemAbove(e):this.focusOrSelectPrevItem(e):e.which===t.KeyboardKeys.home?this.focusOrSelectFirstItem(e):e.ctrlKey||e.which!==t.KeyboardKeys.pageUp?e.which===t.KeyboardKeys.end?this.focusOrSelectLastItem(e):e.ctrlKey||e.which!==t.KeyboardKeys.pageDown?e.ctrlKey&&e.which===t.KeyboardKeys.spacebar&&(e.stopPropagation(),this.toggleFocusedItem()):this.selectItemOnOrUntilNextPage(e):this.selectItemOnOrUntilPrevPage(e)}},s.prototype.onElementKeyup=function(t){this.arrowHits=n},s.prototype.onItemClick=function(t){var e=$(t.currentTarget);e.parent().is(this.$list)&&(t.stopPropagation(),this.scrollToItem(e),t.ctrlKey?this.toggleItem(ko.dataFor(t.currentTarget)):t.shiftKey?this.selectItemsUntil(t.currentTarget):this.selectItem(ko.dataFor(t.currentTarget),!0))},s.prototype.onSelectionUpdate=function(){var t=this.selection.getSelectedItems();this.focusItems(t.map(ko.dataFor)),this.unselectAllItems()},s.prototype.onSelectionChange=function(){this.selection.getSelectedItems().length?this.selectFocusedItems():(this.ensureFocusedItem(),this.unselectAllItems()),this.selection.reset()},s.prototype.onDataSourceChange=function(){this.focusFirstItem()},s.prototype.onSelectedValuesChange=function(e){t.Utils.clearObservableArray(this.selectedItemsKeys),this.$element.toggleClass(t.BusinessPackCss.bpStateEmptyValue,0===e.length);for(var n=0,i=e;n<i.length;n++){var s=i[n],o=this.findItemByValue(s);o?this.selectedItemsKeys.push(this.getItemKey(o)):this.warnThatValueWasNotFound(s)}},s.prototype.focusOrSelectPrevItem=function(t){t.ctrlKey?this.focusPrevItem():t.shiftKey?this.selectItemsUntilPrev():this.selectPrevItem()},s.prototype.focusPrevItem=function(){var e=this.$list.children("."+t.BusinessPackCss.bpItem+"."+t.BusinessPackCss.bpStateFocused).prev("."+t.BusinessPackCss.bpItem);e.length&&(this.scrollToItem(e),this.focusItem(ko.dataFor(e[0])))},s.prototype.focusOrSelectNextItem=function(t){t.ctrlKey?this.focusNextItem():t.shiftKey?this.selectItemsUntilNext():this.selectNextItem()},s.prototype.focusNextItem=function(){var e=this.$list.children("."+t.BusinessPackCss.bpItem+"."+t.BusinessPackCss.bpStateFocused).next("."+t.BusinessPackCss.bpItem);e.length&&(this.scrollToItem(e),this.focusItem(ko.dataFor(e[0])))},s.prototype.focusOrSelectItemAbove=function(t){t.ctrlKey?this.focusItemAbove():t.shiftKey?this.selectItemsUntilAbove():this.selectItemAbove()},s.prototype.focusItemAbove=function(){var e=this.$list.children("."+t.BusinessPackCss.bpItem+"."+t.BusinessPackCss.bpStateFocused),n=this.findElementAbove(e);n&&(this.scrollToItem($(n)),this.focusItem(ko.dataFor(n)))},s.prototype.focusOrSelectItemBelow=function(t){t.ctrlKey?this.focusItemBelow():t.shiftKey?this.selectItemsUntilBelow():this.selectItemBelow()},s.prototype.focusItemBelow=function(){var e=this.$list.children("."+t.BusinessPackCss.bpItem+"."+t.BusinessPackCss.bpStateFocused),n=this.findElementBelow(e);n&&(this.scrollToItem($(n)),this.focusItem(ko.dataFor(n)))},s.prototype.focusOrSelectFirstItem=function(t){t.preventDefault(),t.ctrlKey?this.focusFirstItem():t.shiftKey?this.selectItemsUntilFirst():this.selectFirstItem()},s.prototype.focusFirstItem=function(){var e=this.items(),n=this.$list.children("."+t.BusinessPackCss.bpItem+":first-child");e.length&&(this.scrollToItem(n),this.focusItem(e[0]))},s.prototype.selectItemOnOrUntilPrevPage=function(t){t.preventDefault(),t.shiftKey||this.selectItemOnPrevPage()},s.prototype.focusOrSelectLastItem=function(t){t.preventDefault(),t.ctrlKey?this.focusLastItem():t.shiftKey?this.selectItemsUntilLast():this.selectLastItem()},s.prototype.focusLastItem=function(){var e=this.items(),n=this.$list.children("."+t.BusinessPackCss.bpItem+":last-child");e.length&&(this.scrollToItem(n),this.focusItem(e[e.length-1]))},s.prototype.selectItemOnOrUntilNextPage=function(t){t.preventDefault(),t.shiftKey||this.selectItemOnNextPage()},s.prototype.ensureFocusedItem=function(){this.focusedItemsKeys().length||this.focusFirstItem()},s.prototype.selectItemsUntilPrev=function(){var e=this.$list.children("."+t.BusinessPackCss.bpItem+"."+t.BusinessPackCss.bpStateFocused).prev("."+t.BusinessPackCss.bpItem);e.length&&this.selectItemsUntil(e[0])},s.prototype.selectPrevItem=function(){var e=this.$list.children("."+t.BusinessPackCss.bpItem+"."+t.BusinessPackCss.bpStateFocused).prev("."+t.BusinessPackCss.bpItem);e.length&&(this.scrollToItem(e),this.selectItem(ko.dataFor(e[0]),!0))},s.prototype.selectItemsUntilNext=function(){var e=this.$list.children("."+t.BusinessPackCss.bpItem+"."+t.BusinessPackCss.bpStateFocused).next("."+t.BusinessPackCss.bpItem);e.length&&this.selectItemsUntil(e[0])},s.prototype.selectNextItem=function(){var e=this.$list.children("."+t.BusinessPackCss.bpItem+"."+t.BusinessPackCss.bpStateFocused).next("."+t.BusinessPackCss.bpItem);e.length&&(this.scrollToItem(e),this.selectItem(ko.dataFor(e[0]),!0))},s.prototype.selectItemsUntilAbove=function(){var e=this.$list.children("."+t.BusinessPackCss.bpItem+"."+t.BusinessPackCss.bpStateFocused),n=this.findElementAbove(e);n&&this.selectItemsUntil(n)},s.prototype.selectItemAbove=function(){var e=this.$list.children("."+t.BusinessPackCss.bpItem+"."+t.BusinessPackCss.bpStateFocused),n=this.findElementAbove(e);n&&(this.scrollToItem($(n)),this.selectItem(ko.dataFor(n),!0))},s.prototype.selectItemOnPrevPage=function(){var e=this.$list.children("."+t.BusinessPackCss.bpItem+"."+t.BusinessPackCss.bpStateFocused),n=this.findElementOnPrevPage(e);n&&(this.scrollToItem($(n)),this.selectItem(ko.dataFor(n),!0))},s.prototype.selectItemsUntilBelow=function(){var e=this.$list.children("."+t.BusinessPackCss.bpItem+"."+t.BusinessPackCss.bpStateFocused),n=this.findElementBelow(e);n&&this.selectItemsUntil(n)},s.prototype.selectItemBelow=function(){var e=this.$list.children("."+t.BusinessPackCss.bpItem+"."+t.BusinessPackCss.bpStateFocused),n=this.findElementBelow(e);n&&(this.scrollToItem($(n)),this.selectItem(ko.dataFor(n),!0))},s.prototype.selectItemOnNextPage=function(){var e=this.$list.children("."+t.BusinessPackCss.bpItem+"."+t.BusinessPackCss.bpStateFocused),n=this.findElementOnNextPage(e);n&&(this.scrollToItem($(n)),this.selectItem(ko.dataFor(n),!0))},s.prototype.selectItemsUntilFirst=function(){var e=this.$list.children("."+t.BusinessPackCss.bpItem+":first-child")[0];e&&this.selectItemsUntil(e)},s.prototype.selectFirstItem=function(){var e=this.$list.children("."+t.BusinessPackCss.bpItem+":first-child")[0];e&&(this.scrollToItem($(e)),this.selectItem(ko.dataFor(e),!0))},s.prototype.selectItemsUntilLast=function(){var e=this.$list.children("."+t.BusinessPackCss.bpItem+":last-child")[0];e&&this.selectItemsUntil(e)},s.prototype.selectLastItem=function(){var e=this.$list.children("."+t.BusinessPackCss.bpItem+":last-child")[0];e&&(this.scrollToItem($(e)),this.selectItem(ko.dataFor(e),!0))},s.prototype.toggleFocusedItem=function(){this.toggleItem(this.getFocusedItems()[0])},s.prototype.selectItemsUntil=function(e){var n,i=$(e).closest("."+t.BusinessPackCss.bpItem),s=this.$list.children("."+t.BusinessPackCss.bpItem+"."+t.BusinessPackCss.bpStateSelected),o=this.$list.children("."+t.BusinessPackCss.bpItem+"."+t.BusinessPackCss.bpStateFocused).first(),r=!0;this.scrollToItem($(e)),n=0===s.not(o).length?o:o.index()<s.last().index()?s.last():s.first(),i.index()<n.index()&&(n=(l=[i,n])[0],i=l[1],r=!1);var a=n.toArray();n.is(i)||(a=n.nextUntil(i).add(n).add(i).toArray()),this.selectItems(a.map(ko.dataFor),r);var l},s.prototype.selectFocusedItems=function(){this.selectItems(this.getFocusedItems(),!0)},s.prototype.areOtherItemsSelected=function(t){var e=this.getItemKey(t);return this.selectedItemsKeys().asLinq().any(function(t){return t!==e})},s.prototype.findElementAbove=function(e){var n=e.index()-this.rowLength,i=this.$list.children("."+t.BusinessPackCss.bpItem);return n<0?null:i[n]},s.prototype.findElementOnPrevPage=function(e){var n=e.index(),i=this.$list.children("."+t.BusinessPackCss.bpItem),s=(n+this.pageSize)%this.pageSize;if(s<this.rowLength)return(o=n-this.rowLength*this.columnLength)<0?i[0]:i[o];var o=n-Math.floor(s/this.rowLength)*this.rowLength;return i[o]},s.prototype.findElementBelow=function(e){var n=e.index()+this.rowLength,i=this.$list.children("."+t.BusinessPackCss.bpItem),s=i.length-1;return n>s?this.isOnLastLine(e)?null:i[s]:i[n]},s.prototype.findElementOnNextPage=function(e){var n=e.index(),i=this.$list.children("."+t.BusinessPackCss.bpItem),s=(n+this.pageSize)%this.pageSize,o=this.rowLength*(this.columnLength-1),r=i.length-1;if(s>=o)return(a=n+this.rowLength*this.columnLength)>r?i[r]:i[a];var a=n+Math.floor((this.pageSize-1-s)/this.rowLength)*this.rowLength;return i[a]},s.prototype.scrollToItem=function(t){var e=this.$list.innerHeight(),n=parseInt(this.$list.css("padding-top")),i=parseInt(this.$list.css("padding-bottom")),s=parseInt(t.css("margin-top")),o=parseInt(t.css("margin-bottom")),r=this.isOnFirstLine(t)?n:s,a=this.isOnLastLine(t)?i:o,l=t.position().top,u=l+t.outerHeight(!0),c=this.$list.scrollTop();u>e?this.$list.scrollTop(c+(u-e)+a):l<0&&this.$list.scrollTop(c+l-r)},s.prototype.isOnFirstLine=function(t){return t.index()<this.rowLength},s.prototype.isOnLastLine=function(e){var n=this.$list.children("."+t.BusinessPackCss.bpItem),i=n.length%this.rowLength,s=n.length-(i||this.rowLength);return e.index()>=s},s.prototype.getItemKeyBinding=function(){return this.binding.itemKeyBinding||this.getItemValueBinding()},s.prototype.getItemValueBinding=function(){return this.binding.itemValueBinding},s.prototype.getItemStyle=function(e){e=ko.unwrap(e);var n={};return n[t.BusinessPackCss.bpStateSelected]=this.isSelected(e),n[t.BusinessPackCss.bpStateFocused]=this.isFocused(e),n[t.BusinessPackCss.bpTile]=this.isTilesView,n[t.BusinessPackCss.bpRow]=this.isListView,n},s}(e.ItemsControlBase);e.ListView=i,t.Utils.installBindingHandler("ListView",i)}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(){function n(t,e){var n=this;this.textMask=t,this.bufferOfInsertedChars=e,this.insertFunctionality=function(t,e){var i=t,s=n.getIndexOfFirstInsertableCharAfter(t);if(n.checkRegexWithValueOnIndex(s,e)){var o=n.bufferOfInsertedChars.slice();o.splice(s,0,e),o.pop(),n.writeValuesToBufferWithCheck(o,0,n.maxBufferIndex),i=n.getIndexOfFirstInsertableCharAfter(n.getNextIndex(s))}var r=n.getIndexOfLastFilledBufferItem();return i>r&&(i=n.getNextIndex(r)),i},this.overtypeFunctionality=function(t,e){var i=n.getIndexOfFirstInsertableCharAfter(t),s=i;return n.checkRegexWithValueOnIndex(i,e)&&(n.writeValueToBufferByIndex(i,e),s=n.getIndexOfFirstInsertableCharAfter(n.getNextIndex(i))),s},this.addCharToBufferByIndex=function(t,e){for(;n.isHardCodedCharOnIndex(t);)t=n.getNextIndex(t);return n.checkRegexWithValueOnIndex(t,e)&&(n.writeValueToBufferByIndex(t,e),t=n.getNextIndex(t)),t},this.getIndexOfFirstInsertableCharBefore=function(t){for(;n.isHardCodedCharOnIndex(t);)t=n.getPreviousIndex(t);return t},this.getIndexOfFirstInsertableCharAfter=function(t){for(;n.isHardCodedCharOnIndex(t);)t=n.getNextIndex(t);return t},this.maxBufferIndex=e.length-1}return n.prototype.writeValuesToBufferWithCheck=function(t,n,i){void 0===i&&(i=this.maxBufferIndex),this.clearBufferOnIndexes(new e.CaretIndexPosition(n,i));for(var s=n,o=0,r=t;o<r.length;o++){var a=r[o];if(this.isBufferFull())break;null==a||"_"===a||this.isHardCodedCharOnIndex(s)&&this.getHardCodedCharOnIndex(s)===a?s++:s=this.addCharToBufferByIndex(s,a)}return s},n.prototype.getFirstHardcodedString=function(){if(0!==this.getIndexOfFirstInsertableChar()){for(var t=0,e="";this.textMask.getHardCodedCharOnIndex(t);)e+=this.textMask.getHardCodedCharOnIndex(t),t++;return e}return""},n.prototype.isMaxBufferIndex=function(t){return t>=this.maxBufferIndex},n.prototype.shiftDelete=function(t){var e=this.getIndexOfFirstInsertableCharAfter(t);return this.writeValueToBufferByIndex(e,null),this.rearrangeBufferOfInsertedChars(),e},n.prototype.shiftBackspace=function(t){var e=this.getIndexOfFirstInsertableCharBefore(this.getPreviousIndex(t));return this.writeValueToBufferByIndex(e,null),this.rearrangeBufferOfInsertedChars(),e},n.prototype.writeCharToBuffer=function(t,e){if("_"===e)return t;var n=t,i=this.getIndexOfFirstInsertableChar();return t=i>=t?i:t,n=this.isBufferFull()?this.overtypeFunctionality(t,e):this.insertFunctionality(t,e),this.rearrangeBufferOfInsertedChars(),n},n.prototype.clearBufferOnIndexes=function(t){for(var e=t.startIndex();e<=t.endIndex()&&e<=this.maxBufferIndex;e++)this.isHardCodedCharOnIndex(e)||this.writeValueToBufferByIndex(e,null);return this.rearrangeBufferOfInsertedChars(),t.startIndex()},n.prototype.rearrangeBufferOfInsertedChars=function(){var t=this.bufferOfInsertedChars.join("").split("");t.reverse();for(var e=new Array,n=0;n<=this.maxBufferIndex;n++)if(this.isHardCodedCharOnIndex(n))e.push(null);else{var i=t.pop();this.checkRegexWithValueOnIndex(n,i)?e.push(i):(t.push(i),e.push(null))}this.bufferOfInsertedChars=e},n.prototype.createStringFromAllBuffers=function(){for(var t=new Array,e=0;e<=this.maxBufferIndex;e++){var n=this.bufferOfInsertedChars[e];n&&0!==n.length?t.push(n):this.isHardCodedCharOnIndex(e)?t.push(this.getHardCodedCharOnIndex(e)):t.push("_")}return t.join("")},n.prototype.writeValueToBufferByIndex=function(e,n){t.Utils.warnInDebugMode("write '"+n+"', on index:"+e),this.bufferOfInsertedChars[e]=n},n.prototype.clearBuffer=function(){this.clearBufferOnIndexes(new e.CaretIndexPosition(0,this.maxBufferIndex))},n.prototype.clearBufferFromIndex=function(t){this.clearBufferOnIndexes(new e.CaretIndexPosition(t,this.maxBufferIndex))},n.prototype.getIndexOfFirstInsertableChar=function(){return this.textMask.getIndexOfFirstInsertableChar()},n.prototype.isBufferFull=function(){for(var t=0,e=0,n=this.bufferOfInsertedChars;e<n.length;e++){var i=n[e];if(!(i&&0!==i.length||this.isHardCodedCharOnIndex(t)))return!1;t++}return!0},n.prototype.isBufferOfInsertedCharsEmpty=function(){return this.bufferOfInsertedChars.asLinq().all(function(t){return null==t})},n.prototype.checkRegexWithValueOnIndex=function(t,e){return this.textMask.checkRegexWithValueOnIndex(t,e)},n.prototype.isHardCodedCharOnIndex=function(t){return this.textMask.isHardCodedCharOnIndex(t)},n.prototype.getHardCodedCharOnIndex=function(t){return this.textMask.getHardCodedCharOnIndex(t)},n.prototype.getRegexOnIndex=function(t){return this.textMask.getRegexOnIndex(t)},n.prototype.getNextIndex=function(t){return++t},n.prototype.getPreviousIndex=function(t){return--t},n.prototype.getIndexOfLastFilledBufferItem=function(){for(var t=new Array(this.maxBufferIndex+1),e=0;e<=this.maxBufferIndex;e++)t[e]=this.bufferOfInsertedChars[e],this.isHardCodedCharOnIndex(e)&&(t[e]=this.getHardCodedCharOnIndex(e));var n=t.indexOf(null);return-1===n?this.maxBufferIndex+1:n},n}();e.BufferResolver=n}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(t){"use strict";var e=function(){return function(t,e){var n=this;this.isSelection=function(){return n._startIndex!==n._endIndex},this.startIndex=function(){return n._startIndex},this.endIndex=function(){return n._endIndex},this._startIndex=t,this._endIndex=e}}();t.CaretIndexPosition=e}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(n){function i(){var i=null!==n&&n.apply(this,arguments)||this;return i.lastCaretPosition=0,i.initPatterns=function(){var t=ko.isObservable(i.binding.patterns)?i.binding.patterns():i.createDefaultPatterns();return i.binding.additionalPatterns&&(t=__assign({},t,i.binding.additionalPatterns())),t},i.createBufferResolver=function(t){for(var n=new e.TextMask,s=new Array,o=0,r=t;o<r.length;o++){var a=r[o];s.push(null),a in i.patterns?n.pushRegex(i.getRegexByKey(a)):n.pushHardCodedChar(a)}return new e.BufferResolver(n,s)},i.listen=function(){i.$element.blur(i.blurEvent),i.$element.mouseup(i.onFocusEvent),i.$element.change(function(t){return i.onElementChange(t)}),i.$element.focus(i.onFocusEvent),i.$element.keydown(i.keydownEvent),i.$element.keypress(i.keypressEvent),i.$element.on("paste",i.pasteEvent),i.$element.on("input",i.pasteEvent),i.$element.on("drop",i.dropEvent)},i.dropEvent=function(t){var e=t.originalEvent.dataTransfer.getData("text/plain").split("");i.writeValuesWithCheck(i.$element,e),t.stopPropagationAndPreventDefault()},i.pasteEvent=function(t){var e=t.originalEvent.clipboardData.getData("Text").split("");i.writeValuesWithCheck(i.$element,e),t.stopPropagationAndPreventDefault()},i.writeValuesWithCheck=function(t,e){var n=i.bufferResolver.getFirstHardcodedString(),s=n.length;e.asLinq().take(s).toArray().join("")===n&&(e=e.asLinq().skip(s).toArray());var o=i.getActualCaretPosition();if(o.isSelection()){r=i.bufferResolver.writeValuesToBufferWithCheck(e,o.startIndex(),o.endIndex());i.writeBufferToElement(i.bufferResolver,r)}else{var r=i.bufferResolver.writeValuesToBufferWithCheck(e,o.startIndex());i.writeBufferToElement(i.bufferResolver,r)}},i.onFocusEvent=function(t){i.bufferResolver.isBufferOfInsertedCharsEmpty()&&i.writeBufferToElement(i.bufferResolver,i.getIndexOfLastFilledBufferItem()),i.getActualCaretPosition().startIndex()>i.getIndexOfLastFilledBufferItem()&&i.setCaretPosition(i.getIndexOfLastFilledBufferItem())},i.blurEvent=function(t){i.bufferResolver.isBufferOfInsertedCharsEmpty()?i.cleanUpElement():i.writeBufferToElement(i.bufferResolver,null)},i.getIndexOfLastFilledBufferItem=function(){return i.bufferResolver.getIndexOfLastFilledBufferItem()},i.clearSelection=function(t){var e=i.bufferResolver.clearBufferOnIndexes(t);i.writeBufferToElement(i.bufferResolver,e)},i.checkIfInvaliOperation=function(e,n){var s=t.KeyboardKeys.isDelete(n)&&i.bufferResolver.isMaxBufferIndex(e.startIndex())&&i.bufferResolver.isBufferFull(),o=t.KeyboardKeys.isBackspace(n)&&e.startIndex()===i.bufferResolver.getIndexOfFirstInsertableChar()&&!e.isSelection();return s||o},i.removeChar=function(e,n){if(t.KeyboardKeys.isDelete(n)){s=i.bufferResolver.shiftDelete(e.startIndex());i.writeBufferToElement(i.bufferResolver,s)}else if(t.KeyboardKeys.isBackspace(n)){var s=i.bufferResolver.shiftBackspace(e.startIndex());i.writeBufferToElement(i.bufferResolver,s)}},i.keydownEvent=function(e){var n=e.which||e.keyCode,s=i.getActualCaretPosition();if(n===t.KeyboardKeys.esc)return i.cleanUpBufferAndElement(i.bufferResolver),void e.stopPropagationAndPreventDefault();i.checkIfInvaliOperation(s,n)?e.stopPropagationAndPreventDefault():t.KeyboardKeys.isDeleteOrBackspace(n)&&(s.isSelection()?i.clearSelection(s):i.removeChar(s,n),e.stopPropagationAndPreventDefault())},i.keypressEvent=function(e){var n=e.which||e.keyCode,s=i.getActualCaretPosition();if(i.bufferResolver.isMaxBufferIndex(s.startIndex()-1))e.stopPropagationAndPreventDefault();else if(!(e.ctrlKey||e.altKey||e.metaKey||n<t.KeyboardKeys.spacebar)&&n>0){var o=e.key;if(s.isSelection()){var r=i.bufferResolver.clearBufferOnIndexes(s);i.writeBufferToElement(i.bufferResolver,r)}var a=i.bufferResolver.writeCharToBuffer(s.startIndex(),o);i.writeBufferToElement(i.bufferResolver,a),e.stopPropagationAndPreventDefault()}},i.getActualCaretPosition=function(){var n=i.getElementToMaskAsHtmlInput();return null==n.setSelectionRange&&t.Utils.warnInDebugMode("element.setSelectionRange is null!"),n.selectionStart===n.selectionEnd?new e.CaretIndexPosition(n.selectionStart,n.selectionEnd):new e.CaretIndexPosition(n.selectionStart,n.selectionEnd-1)},i.setCaretPosition=function(t){var e=i.getElementToMaskAsHtmlInput();if(null!=e.setSelectionRange)e.setSelectionRange(t,t);else if(null!=e.createTextRange){var n=e.createTextRange();n.collapse(!0),n.moveEnd("character",t),n.moveStart("character",t),n.select()}},i.writeBufferToElement=function(t,e){var n=t.createStringFromAllBuffers();i.$element.val(n),i.binding.text(n),null!=e&&i.setCaretPosition(e)},i.cleanUpElement=function(){i.$element.val(null),i.binding.text(null)},i.cleanUpBufferAndElement=function(t){t.clearBuffer(),i.$element.val(null)},i.getRegexByKey=function(t){var e=(0,i.patterns[t])().ClientRegex;return new RegExp(e())},i.getElementToMaskAsHtmlInput=function(){return i.$element.get(0)},i.createDefaultPatterns=function(){return{0:ko.observable({ClientRegex:ko.observable("\\d")}),9:ko.observable({ClientRegex:ko.observable("\\d|\\s")}),"#":ko.observable({ClientRegex:ko.observable("\\d|\\+|-|\\s")}),L:ko.observable({ClientRegex:ko.observable("[a-zA-Z]")}),"?":ko.observable({ClientRegex:ko.observable("[a-zA-Z]|\\s")}),"&":ko.observable({ClientRegex:ko.observable("\\S")}),C:ko.observable({ClientRegex:ko.observable(".")}),A:ko.observable({ClientRegex:ko.observable("[a-zA-Z]|\\d")}),a:ko.observable({ClientRegex:ko.observable("[a-zA-Z]|\\d|\\s")})}},i}return __extends(i,n),i.prototype.initialize=function(){var t=this;n.prototype.initialize.call(this);var e=ko.unwrap(this.binding.mask);this.patterns=this.initPatterns(),this.bufferResolver=this.createBufferResolver(e.split("")),this.lastCaretPosition=this.bufferResolver.getIndexOfFirstInsertableChar(),this.listen(),this.subscribe(this.binding.text,function(e){if(null!=e){t.bufferResolver.clearBuffer();var n=t.bufferResolver.writeValuesToBufferWithCheck(e.split(""),0);t.writeBufferToElement(t.bufferResolver,n)}else t.cleanUpBufferAndElement(t.bufferResolver)})},i.prototype.onElementChange=function(t){t.stopPropagation(),this.postback(this.binding.changed)},i}(e.ControlBase);e.MaskedTextBox=n,t.Utils.installBindingHandler("MaskedTextBox",n)}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(t){"use strict";var e=function(){function t(){this.hardCodedCharsMask=new Array,this.regexsMask=new Array}return t.prototype.isRegexOnIndex=function(t){return null==this.hardCodedCharsMask[t]&&null!=this.regexsMask[t]},t.prototype.checkRegexWithValueOnIndex=function(t,e){return null!==e&&void 0!==e&&(this.isRegexOnIndex(t)&&this.regexsMask[t].test(e))},t.prototype.getRegexOnIndex=function(t){return this.regexsMask[t]},t.prototype.isHardCodedCharOnIndex=function(t){return null!=this.hardCodedCharsMask[t]&&null==this.regexsMask[t]},t.prototype.getHardCodedCharOnIndex=function(t){return this.hardCodedCharsMask[t]},t.prototype.pushRegex=function(t){this.hardCodedCharsMask.push(null),this.regexsMask.push(t)},t.prototype.pushHardCodedChar=function(t){this.regexsMask.push(null),this.hardCodedCharsMask.push(t)},t.prototype.getIndexOfFirstInsertableChar=function(){var t=this.regexsMask.asLinq().firstOrDefault(function(t){return null!=t});return null!=t?this.regexsMask.indexOf(t):0},t}();t.TextMask=e}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.focusInside=!1,t}return __extends(n,e),Object.defineProperty(n.prototype,"isDisplayed",{get:function(){return void 0!=this.binding.isDisplayed&&ko.unwrap(this.binding.isDisplayed)},set:function(t){var e=this.binding.isDisplayed;t?this.open():this.close(),ko.isWriteableObservable(e)&&e(t?t:null)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"closeOnOutsideClick",{get:function(){return void 0==this.binding.closeOnOutsideClick||ko.unwrap(this.binding.closeOnOutsideClick)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"closeOnEscape",{get:function(){return void 0==this.binding.closeOnEscape||ko.unwrap(this.binding.closeOnEscape)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"animationDuration",{get:function(){return void 0==this.binding.animationDuration?0:1e3*ko.unwrap(this.binding.animationDuration)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"width",{get:function(){return void 0==this.binding.width?"420px":ko.unwrap(this.binding.width)},set:function(t){var e=this.binding.width;ko.isWriteableObservable(e)&&e(t?t:null)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"height",{get:function(){if(void 0!=this.binding.height)return ko.unwrap(this.binding.height)},set:function(t){var e=this.binding.height;ko.isWriteableObservable(e)&&e(t?t:null)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"allowResize",{get:function(){return void 0!=this.binding.allowResize&&ko.unwrap(this.binding.allowResize)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"deathZoneSize",{get:function(){return void 0==this.binding.deathZoneSize?0:ko.unwrap(this.binding.deathZoneSize)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"initialPositionX",{get:function(){if(void 0!=this.binding.initialPositionLeft){var t=ko.unwrap(this.binding.initialPositionLeft);return isNaN(Number(t))||(t+="px"),t}},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"initialPositionY",{get:function(){if(void 0!=this.binding.initialPositionTop){var t=ko.unwrap(this.binding.initialPositionTop);return isNaN(Number(t))||(t+="px"),t}},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"$overlay",{get:function(){if(null!=this._overlay)return this._overlay;var e=$("<div></div>").addClass(t.BusinessPackCss.bpOverlay);return e.insertBefore(this.$element),this._overlay=e,e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"showOverlay",{get:function(){return ko.unwrap(this.binding.showOverlay)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"isTopMostOpenedDialog",{get:function(){return n.topMostOppenedDialog===this},enumerable:!0,configurable:!0}),Object.defineProperty(n,"topMostOppenedDialog",{get:function(){return n.openedDialogs[n.openedDialogs.length-1]},enumerable:!0,configurable:!0}),n.prototype.initialize=function(){var i=this;e.prototype.initialize.call(this),this.subscribe(this.binding.width,function(t){return i.applyDialogTransformations(void 0,void 0,t,void 0)}),this.subscribe(this.binding.height,function(t){return i.applyDialogTransformations(void 0,void 0,void 0,t)}),this.$element.focusin(function(){return i.focusInside=!0}),this.$element.focusout(function(){return i.focusInside=!1}),this.$element.mousedown(function(e){$(e.target).closest("."+t.BusinessPackCss.dotvvmBpDialog)[0]===i.$element[0]&&i.bringToFront()}),this.closeOnOutsideClick&&this.outside("click",function(t){i.isTopMostOpenedDialog&&(i.isDisplayed=!1)}),n.escapeEventRegistered||(n.escapeEventRegistered=!0,$(document).on("keyup",function(t){27===t.keyCode&&(n.escapePressDetected(),t.stopPropagation())})),this.allowResize&&this.initResizing(),$(window).on("orientationchange",function(){i.$element.is(":hidden")||i.checkIfDialogIsNotOutsideOfViewport()&&i.moveToInitialPosition(!0)}),this.applyDialogTransformations(void 0,void 0,this.width,this.height),$(window).resize(function(){return i.initSizeLimits()}),this.initSizeLimits(),this.subscribe(this.binding.isDisplayed,function(t){void 0!=t&&(i.isDisplayed=t)})},n.escapePressDetected=function(){if(0!==this.openedDialogs.length){var t=this.openedDialogs[this.openedDialogs.length-1];t.closeOnEscape&&(t.isDisplayed=!1)}},n.prototype.close=function(){this.changeVisibility(!1);var t=n.openedDialogs.indexOf(this);-1!==t&&n.openedDialogs.splice(t,1),this.showOverlay&&(this.hideOverlay(),this.showOverlayOfTopMostOppenedDialog())},n.prototype.showOverlayOfTopMostOppenedDialog=function(){for(var t=n.openedDialogs.length-1;t>=0;){if(n.openedDialogs[t].showOverlay)return void n.openedDialogs[t].showShowOverlay();t--}},n.prototype.open=function(){this.changeVisibility(!0),-1===n.openedDialogs.indexOf(this)&&n.openedDialogs.push(this),this.bringToFront(),t.FocusManager.autoFocus(this.$element),this.showOverlay&&(n.hideAllOverlays(),this.showShowOverlay())},n.hideAllOverlays=function(){for(var t=0,e=n.openedDialogs;t<e.length;t++)e[t].hideOverlay()},n.prototype.hideOverlay=function(){if(this.showOverlay&&!this.$overlay.is(":hidden")){var t=this.animationDuration;t>0?this.$overlay.fadeOut(t):this.$overlay.hide(),$("body").css("overflow","")}},n.prototype.showShowOverlay=function(){var e=this.animationDuration;e>0?(this.$overlay.css("z-index",parseInt(this.$element.css("z-index"))-1),this.$overlay.fadeIn(e)):(this.$overlay.css("z-index",parseInt(this.$element.css("z-index"))-1),this.$overlay.show(),this.$element.addClass(t.BusinessPackCss.bpStateOpened)),$("body").css("overflow","hidden")},n.prototype.bringToFront=function(){var e=n.openedDialogs.indexOf(this);if(e!==n.openedDialogs.length-1){-1!==e&&n.openedDialogs.splice(e,1),n.openedDialogs.push(this),$($.map(n.openedDialogs,function(t){return t.$element})).removeClass(t.BusinessPackCss.bpStateActive);for(var i=1e3,s=0,o=n.openedDialogs;s<o.length;s++)(l=o[s]).$element.css("z-index",i+1),l.$overlay.css("z-index",i),i+=10;i*=n.openedDialogs.length,this.$element.css("z-index",i+1),this.$overlay.css("z-index",i);for(var r=0,a=n.openedDialogs;r<a.length;r++){var l=a[r],u=Number(l.$element.css("z-index"));l.$element.parents("."+t.BusinessPackCss.dotvvmBpDialog).each(function(t,e){return u+=Number($(e).css("z-index"))}),l.$element.css("z-index",u+1),l.$overlay.css("z-index",u)}n.openedDialogs.sort(function(t,e){return+(Number(t.$element.css("z-index"))>Number(e.$element.css("z-index")))||+(Number(t.$element.css("z-index"))===Number(e.$element.css("z-index"))-1)});var c=n.openedDialogs[n.openedDialogs.length-1];c.$element.addClass(t.BusinessPackCss.bpStateActive),c.focusInside||c.$element.focus()}else this.focusInside||this.$element.focus()},n.prototype.changeVisibility=function(e){var n=this;if(void 0!=e){var i=this.animationDuration;e?(this.bringToFront(),i>0?this.$element.fadeIn(i,function(){return n.$element.addClass(t.BusinessPackCss.bpStateOpened)}):(this.$element.show(),this.$element.addClass(t.BusinessPackCss.bpStateOpened)),this.fixHeightAndWidthToMatchLimits(),this.wasEverDisplayed||this.moveToInitialPosition(),this.wasEverDisplayed=!0):i>0?this.$element.fadeOut(i,function(){return n.$element.removeClass(t.BusinessPackCss.bpStateOpened)}):(this.$element.hide(),this.$element.removeClass(t.BusinessPackCss.bpStateOpened))}},n.prototype.initSizeLimits=function(){var t=ko.unwrap(this.binding.minWidth),e=ko.unwrap(this.binding.minHeight);this.sizeLimits={minWidth:t,maxWidth:$(window).width()-this.deathZoneSize,minHeight:e,maxHeight:$(window).height()-this.deathZoneSize},this.sizeLimits.maxHeight<this.$element.height()&&(this.sizeLimits.maxHeight=this.$element.height()),this.sizeLimits.maxWidth<this.$element.width()&&(this.sizeLimits.maxWidth=this.$element.width())},n.prototype.initResizing=function(){var e=this;$(document).on("keyup keydown",function(t){e.shiftKeyPressed=t.shiftKey});var n=this.$element.children("."+t.BusinessPackCss.bpContainer);n.children("."+t.BusinessPackCss.bpGripN).on("touchstart mousedown",function(n){return e.startResizeDragDrag(t.Utils.convertTouchToMouseEvent(n),"n")}),n.children("."+t.BusinessPackCss.bpGripNE).on("touchstart mousedown",function(n){return e.startResizeDragDrag(t.Utils.convertTouchToMouseEvent(n),"ne")}),n.children("."+t.BusinessPackCss.bpGripE).on("touchstart mousedown",function(n){return e.startResizeDragDrag(t.Utils.convertTouchToMouseEvent(n),"e")}),n.children("."+t.BusinessPackCss.bpGripSE).on("touchstart mousedown",function(n){return e.startResizeDragDrag(t.Utils.convertTouchToMouseEvent(n),"se")}),n.children("."+t.BusinessPackCss.bpGripS).on("touchstart mousedown",function(n){return e.startResizeDragDrag(t.Utils.convertTouchToMouseEvent(n),"s")}),n.children("."+t.BusinessPackCss.bpGripSW).on("touchstart mousedown",function(n){return e.startResizeDragDrag(t.Utils.convertTouchToMouseEvent(n),"sw")}),n.children("."+t.BusinessPackCss.bpGripW).on("touchstart mousedown",function(n){return e.startResizeDragDrag(t.Utils.convertTouchToMouseEvent(n),"w")}),n.children("."+t.BusinessPackCss.bpGripNW).on("touchstart mousedown",function(n){return e.startResizeDragDrag(t.Utils.convertTouchToMouseEvent(n),"nw")})},n.prototype.startResizeDragDrag=function(e,n){var i=this;this.wasResized=!0,this.bringToFront(),this.mousePositionOnLastDragUpdate={x:e.clientX,y:e.clientY},this.aspectRatio=this.$element.height()/this.$element.width();var s=function(e){return i.resizeDrag(t.Utils.convertTouchToMouseEvent(e),n)};this.$element.addClass(t.BusinessPackCss.bpStateResizing),this.pauseEvent(e),$(document).on("mouseup touchend",function(e){$(document).off("mousemove touchmove",s),setTimeout(function(){return i.$element.removeClass(t.BusinessPackCss.bpStateResizing)},1)}),$(document).on("mousemove touchmove",s)},n.prototype.constrain=function(t,e,n){return t>n?n:t<e?e:t},n.prototype.resizeDrag=function(e,n,i){if(void 0===i&&(i=!1),this.pauseEvent(e),this.allowResize){var s=this.mousePositionOnLastDragUpdate.y-e.clientY,o=e.clientY-this.mousePositionOnLastDragUpdate.y,r=e.clientX-this.mousePositionOnLastDragUpdate.x,a=this.mousePositionOnLastDragUpdate.x-e.clientX;i&&(r*=2,a*=2);var l,u,c,h;n.indexOf("e")>=0?l=this.$element.width()+r:n.indexOf("w")>=0&&(c=this.$element.position().left-a,l=this.$element.width()+a),this.shiftKeyPressed&&n.length>=2?u=l*this.aspectRatio|0:n.indexOf("s")>=0?u=this.$element.height()+o:n.indexOf("n")>=0&&(h=this.$element.position().top-s,u=this.$element.height()+s);var p=e.clientX<this.deathZoneSize||e.clientX>$(window).width()-this.deathZoneSize,d=e.clientY<this.deathZoneSize||e.clientY>$(window).height()-this.deathZoneSize,f=this.constrain(u,this.sizeLimits.minHeight,this.sizeLimits.maxHeight),g=this.constrain(l,this.sizeLimits.minWidth,this.sizeLimits.maxWidth),m=f===u&&!d,b=g===l&&!p;void 0!=u&&m?this.mousePositionOnLastDragUpdate.y=e.clientY:void 0!=u&&(u=void 0,h=void 0,t.Utils.warnInDebugMode("MAX / MIN height exceeded")),void 0!=l&&b?this.mousePositionOnLastDragUpdate.x=e.clientX:void 0!=l&&(l=void 0,c=void 0,t.Utils.warnInDebugMode("MAX / MIN width exceeded")),this.applyDialogTransformations(c,h,l,u)}},n.prototype.applyDialogTransformations=function(t,e,n,i){if(void 0!=t){var s=void 0;switch(typeof t){case"number":s=t+"px";break;case"string":s=t}this.$element.css("left",s)}if(void 0!=e){var o=void 0;switch(typeof e){case"number":o=e+"px";break;case"string":o=e}this.$element.css("top",o)}if(void 0!=n){var r=void 0;switch(typeof n){case"number":r=n+"px";break;case"string":r=n}this.$element.css("width",r),this.width=r}if(void 0!=i){var a=void 0;switch(typeof i){case"number":a=i+"px";break;case"string":a=i}this.$element.css("height",a),this.height=a}},n.prototype.calculateInitialPossition=function(){return{x:$(window).width()/2-this.$element.width()/2,y:$(window).height()/20}},n.prototype.moveToInitialPosition=function(t){void 0===t&&(t=!1);var e=this.initialPositionX,n=this.initialPositionY,i=this.calculateInitialPossition();void 0!=e?this.$element.css("left",e):this.$element.css("left",i.x),void 0!=n?this.$element.css("top",n):this.$element.css("top",i.y)},n.prototype.checkIfDialogIsNotOutsideOfViewport=function(){var t=this.getOnScreenPossition(this.$element);return t.left>this.$window.innerWidth()||t.top>this.$window.innerHeight()},n.prototype.getOnScreenPossition=function(t){var e=t.offset();return{top:e.top-$(window).scrollTop(),left:e.left-$(window).scrollLeft()}},n.prototype.pauseEvent=function(t){return t.stopPropagation&&t.stopPropagation(),t.preventDefault&&t.preventDefault(),t.cancelBubble=!0,t.returnValue=!1,!1},n.prototype.fixHeightAndWidthToMatchLimits=function(){if(this.$element.is(":hidden"))t.Utils.warnInDebugMode("Tried to get dialog size when it's hidden.");else{var e=this.$element.height(),n=this.$element.width(),i=this.constrain(e,this.sizeLimits.minHeight,this.sizeLimits.maxHeight),s=this.constrain(n,this.sizeLimits.minWidth,this.sizeLimits.maxWidth);this.applyDialogTransformations(void 0,void 0,s,i)}},n.openedDialogs=new Array,n.escapeEventRegistered=!1,n}(e.ControlBase);e.DialogBase=n}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(t){"use strict";var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),Object.defineProperty(e.prototype,"dialog",{get:function(){if(ko.contextFor(this.$element[0].parentNode).$bpControl)return ko.contextFor(this.$element[0].parentNode).$bpControl},enumerable:!0,configurable:!0}),e.prototype.initialize=function(){var e=this;t.prototype.initialize.call(this),this.$element.on("click",function(t){e.isEnabled&&(e.action(),t.stopPropagation())})},e}(t.ControlBase);t.DialogButtonBase=e}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.action=function(){ko.contextFor(this.$element[0].parentNode).$bpControl.close&&(ko.contextFor(this.$element[0].parentNode).$bpControl.isDisplayed=!1)},e}(e.DialogButtonBase);e.DialogCloseButton=n,t.Utils.installBindingHandler("DialogCloseButton",n)}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.iconMaximize="dotvvm-bp-control bp-icon fa fa-window-maximize",e.iconRestore="dotvvm-bp-control bp-icon fa fa-window-restore",e}return __extends(n,t),n.prototype.initialize=function(){var e=this;t.prototype.initialize.call(this),this.$element.click(function(){return e.changeIcon()}),this.subscribe(this.dialog.binding.windowState,function(){return e.changeIcon()}),this.changeIcon()},n.prototype.action=function(){this.dialog.windowState=this.dialog.windowState===e.WindowState.Maximized?e.WindowState.Normal:e.WindowState.Maximized},n.prototype.changeIcon=function(){var t=this.$element.find("i");0!==t.length&&(t.removeClass(),this.dialog.windowState===e.WindowState.Maximized?t.addClass(this.iconRestore):t.addClass(this.iconMaximize))},n}(e.DialogButtonBase);e.DialogMaximizeButton=n,t.Utils.installBindingHandler("DialogMaximizeButton",n)}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.initialize=function(){var e=this;t.prototype.initialize.call(this),$(window).resize(function(){e.moveToInitialPosition()}),$(window).scroll(function(){e.moveToInitialPosition()})},e.prototype.resizeDrag=function(e,n){t.prototype.resizeDrag.call(this,e,n,void 0==this.initialPositionX),this.wasResized=!0,this.moveToInitialPosition()},e.prototype.moveToInitialPosition=function(e){void 0===e&&(e=!1),!e&&this.wasResized&&void 0!=this.initialPositionX||t.prototype.moveToInitialPosition.call(this,e)},e}(e.DialogBase);e.ModalDialog=n,t.Utils.installBindingHandler("ModalDialog",n)}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(e){!function(n){"use strict";var i=function(n){function i(){var t=null!==n&&n.apply(this,arguments)||this;return t.wasEverDisplayed=!1,t}return __extends(i,n),Object.defineProperty(i.prototype,"allowMove",{get:function(){return void 0==this.binding.allowMove||ko.unwrap(this.binding.allowMove)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"windowState",{get:function(){if(void 0!=this._windowState)return this._windowState;var t=ko.unwrap(this.binding.windowState);return s[t]},set:function(t){var e=t!==this.windowState;switch(t){case s.Maximized:(e||null==this.sizeBeforeMaximize||null==this.possitionBeforeMaximize)&&(this.sizeBeforeMaximize={height:this.$element.height(),width:this.$element.width()},this.possitionBeforeMaximize={x:this.$element.css("left"),y:this.$element.css("top")}),this.applyDialogTransformations(this.deathZoneSize,this.deathZoneSize,$(window).width()-2*this.deathZoneSize,$(window).height()-2*this.deathZoneSize);break;case s.Normal:e&&(this.applyDialogTransformations(this.possitionBeforeMaximize.x,this.possitionBeforeMaximize.y,this.sizeBeforeMaximize.width,this.sizeBeforeMaximize.height),this.possitionBeforeMaximize=null,this.sizeBeforeMaximize=null)}if(this.toogleResizeHandles(t!==s.Maximized),e){var n=this.binding.windowState;ko.isWriteableObservable(n)?n(t?s[t]:null):this._windowState=t}},enumerable:!0,configurable:!0}),i.prototype.initialize=function(){var i=this;n.prototype.initialize.call(this),this.allowMove&&this.$element.children("."+e.BusinessPackCss.bpContainer).children("."+e.BusinessPackCss.bpHeader).on("touchstart mousedown",function(e){return i.startMoveDrag(t.BusinessPack.Utils.convertTouchToMouseEvent(e))}),this.subscribe(this.binding.windowState,function(){return i.windowState=i.windowState});var o=function(){i.isDisplayed&&i.windowState===s.Maximized&&(i.windowState=s.Maximized)};$(document).on("scroll",o),$(window).on("resize",o)},i.prototype.changeVisibility=function(t){n.prototype.changeVisibility.call(this,t),t&&(this.windowState=this.windowState)},i.prototype.calculateInitialPossition=function(){for(var t=this,i=n.prototype.calculateInitialPossition.call(this),s=$("."+e.BusinessPackCss.dotvvmBpWindow+":visible");s.is(function(e,n){var s=t.getOnScreenPossition($(n));return i.x===s.left&&i.y===s.top});)i.x+=20,i.y+=20;return i},i.prototype.moveToInitialPosition=function(t){void 0===t&&(t=!1),!t&&this.wasMoved||n.prototype.moveToInitialPosition.call(this,t)},i.prototype.startMoveDrag=function(t){var n=this;this.bringToFront(),this.mousePositionOnLastDragUpdate={x:t.clientX,y:t.clientY};var i=function(t){return n.moveDrag(e.Utils.convertTouchToMouseEvent(t))};this.$element.addClass(e.BusinessPackCss.bpStateMoving),this.pauseEvent(t),$(document).on("mouseup touchend",function(t){$(document).off("mousemove touchmove",i),setTimeout(function(){return n.$element.removeClass(e.BusinessPackCss.bpStateMoving)},1)}),$(document).on("mousemove touchmove",i)},i.prototype.moveDrag=function(t){if(this.windowState!==s.Maximized){this.wasMoved=!0;var e=this.getOnScreenPossition(this.$element),n=t.clientX-this.mousePositionOnLastDragUpdate.x,i=t.clientY-this.mousePositionOnLastDragUpdate.y,o=e.left+n,r=e.top+i,a=$(window).width()-this.$element.width()-this.deathZoneSize,l=$(window).height()-this.$element.height()-this.deathZoneSize,u=this.constrain(o,this.deathZoneSize,a),c=this.constrain(r,this.deathZoneSize,l);o!==u?o=u:this.mousePositionOnLastDragUpdate.x=this.mousePositionOnLastDragUpdate.x+n,r!==c?r=c:this.mousePositionOnLastDragUpdate.y=this.mousePositionOnLastDragUpdate.y+i,this.applyDialogTransformations(o,r,void 0,void 0)}},i.prototype.resizeDrag=function(t,e){this.windowState!==s.Maximized&&n.prototype.resizeDrag.call(this,t,e,!1)},i.prototype.toogleResizeHandles=function(t){var n=this.$element.find("."+e.BusinessPackCss.bpGrip);void 0==t&&(t=n.is(":visible")),t?n.show():n.hide()},i}(n.DialogBase);n.Window=i;var s;!function(t){t[t.Normal=0]="Normal",t[t.Maximized=1]="Maximized"}(s=n.WindowState||(n.WindowState={})),e.Utils.installBindingHandler("Window",i)}(e.Controls||(e.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(n){function i(){var t=null!==n&&n.apply(this,arguments)||this;return t.focusedItemKey=ko.observable(),t.selectedItemsKeys=ko.observableArray(),t}return __extends(i,n),Object.defineProperty(i.prototype,"isOpened",{get:function(){return this.popupPanel.isOpened},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"hasValue",{get:function(){return!!this.binding.selectedValues().length},enumerable:!0,configurable:!0}),i.prototype.initialize=function(){var i=this;n.prototype.initialize.call(this),this.binding.text=t.Utils.ensureObservable(this.binding.text),this.$textBox=this.$element.children("."+t.BusinessPackCss.bpTextBox),this.$popup=this.$element.children("."+t.BusinessPackCss.bpPopup),this.$results=this.$popup.children("ul"),this.popupPanel=new e.PopupPanel(this.$popup),this.$element.mousedown(this.onElementMousedown.bind(this)),this.$element.keydown(this.onElementKeydown.bind(this)),this.$element.on("mousedown","."+t.BusinessPackCss.bpValue,function(t){return t.preventDefault()}),this.$element.on("click","."+t.BusinessPackCss.bpValue+" ."+t.BusinessPackCss.bpUnselect,this.onUnselectButtonClick.bind(this)),this.$textBox.focus(this.onTextBoxFocus.bind(this)),this.$textBox.blur(this.onTextBoxBlur.bind(this)),this.$textBox.mousedown(function(t){return t.stopPropagation()}),this.$textBox.keydown(this.onTextBoxKeydown.bind(this)),this.$textBox.input(this.onTextBoxInput.bind(this)),this.$popup.mousedown(function(t){return t.preventDefault()}),this.$results.on("click","."+t.BusinessPackCss.bpItem+":not(."+t.BusinessPackCss.bpStateDisabled+")",this.onResultClick.bind(this)),this.outside("click",function(){return i.popupPanel.close()}),this.watch(this.binding.selectedValues,this.onSelectedValuesChange),this.subscribe(this.searchResults,this.onSearchResultsChange)},i.prototype.togglePopup=function(t){void 0===t&&(t=!this.isOpened);var e=t&&this.isEnabled;e&&!this.isOpened&&this.search(null),this.popupPanel.toggle(e),e||this.resetText()},i.prototype.focusItem=function(t){this.isItemEnabled(t)&&this.focusedItemKey(this.getItemKey(t))},i.prototype.isFocused=function(t){return this.getItemKey(t)===this.focusedItemKey()},i.prototype.getFocusedItem=function(){return this.findItemByKey(this.focusedItemKey)},i.prototype.unfocusAllItems=function(){this.focusedItemKey(null)},i.prototype.selectCurrentText=function(){var e=this.$textBox.val(),n=ko.unwrap(this.binding.allowNewItems),i=this.findItemByText(e);if(null==i)if(e.trim().length&&n){var s=this.binding.itemValueBinding;if(!t.Utils.isDataAccessor(s))throw Error("The ItemValueBinding must not be set when AllowNewItems is enabled.");this.selectItem(this.createItemFromText(e))}else this.resetText();else this.selectItem(i)},i.prototype.toggleItem=function(t){this.isSelected(t)?this.unselectItem(t):this.selectItem(t)},i.prototype.selectItem=function(t){if(this.isItemEnabled(t)&&!this.isSelected(t)){t=this.findItemInDataSourceOrAdd(t);var e=this.getItemValueCopy(t);this.resetText(),this.binding.selectedValues.push(ko.observable(e)),this.postback(this.binding.changed)}this.search(null),this.focusItem(t)},i.prototype.isSelected=function(t){var e=this.getItemKey(t);return this.selectedItemsKeys().asLinq().contains(e)},i.prototype.getSelectedItems=function(){var t=this;return this.selectedItemsKeys().map(function(e){return t.findItemByKey(e)})},i.prototype.unselectItem=function(t){var e=this;this.isItemEnabled(t)&&this.isSelected(t)&&(this.binding.selectedValues.remove(function(n){return e.isValueOfItem(n,t)}),this.postback(this.binding.changed)),this.search(null),this.focusItem(t)},i.prototype.unselectAllItems=function(){this.hasValue&&(this.binding.selectedValues.removeAll(),this.postback(this.binding.changed)),this.search(null)},i.prototype.onElementMousedown=function(t){this.$textBox.focus(),t.preventDefault()},i.prototype.onElementKeydown=function(e){this.isEnabled&&(this.isOpened?e.which===t.KeyboardKeys.esc?(e.stopPropagation(),this.togglePopup(!1)):t.KeyboardKeys.isEnter(e.which)?e.stopPropagationAndPreventDefault():e.which===t.KeyboardKeys.tab?e.stopPropagation():e.which===t.KeyboardKeys.down?(e.stopPropagation(),this.focusNextItem()):e.which===t.KeyboardKeys.up&&(e.stopPropagation(),this.focusPrevItem()):e.altKey&&e.which===t.KeyboardKeys.down&&(e.stopPropagation(),this.togglePopup(!0)),e.which!==t.KeyboardKeys.backspace||this.$textBox.val()||(e.stopPropagationAndPreventDefault(),this.unselecteLastItem()),t.KeyboardKeys.isEnter(e.which)?this.toggleFocusedItemOrCurrentText():e.which===t.KeyboardKeys.tab&&this.selectFocusedItemOrCurrentText())},i.prototype.onUnselectButtonClick=function(t){this.isEnabled&&(t.stopPropagation(),this.unselectItem(ko.dataFor(t.target)))},i.prototype.onTextBoxFocus=function(){this.$element.addClass(t.BusinessPackCss.bpStateFocused),this.togglePopup(!0)},i.prototype.onTextBoxBlur=function(){this.$element.removeClass(t.BusinessPackCss.bpStateFocused),this.togglePopup(!1)},i.prototype.onTextBoxKeydown=function(e){this.isOpened&&t.KeyboardKeys.isUpOrDown(e.which)&&e.preventDefault()},i.prototype.onTextBoxInput=function(t){var e=this.$textBox.val();t.stopPropagation(),this.togglePopup(!0),this.$textBox.attr("size",e.length||2),this.search(e)},i.prototype.onResultClick=function(t){$(t.currentTarget).parent().is(this.$results)&&(t.stopPropagation(),this.toggleItem(ko.dataFor(t.currentTarget)))},i.prototype.onSelectedValuesChange=function(e){t.Utils.clearObservableArray(this.selectedItemsKeys),e.length?(this.$textBox.removeAttr("placeholder"),this.$element.removeClass(t.BusinessPackCss.bpStateEmptyValue)):(this.$textBox.attr("placeholder",this.binding.placeholder),this.$element.addClass(t.BusinessPackCss.bpStateEmptyValue));for(var n=0,i=e;n<i.length;n++){var s=i[n],o=this.findItemByValue(s);o?this.selectedItemsKeys.push(this.getItemKey(o)):this.warnThatValueWasNotFound(s)}this.popupPanel.update()},i.prototype.onSearchResultsChange=function(t){var e=this,n=this.getFocusedItem(),i=this.binding.loadItemsMode,s=ko.unwrap(this.binding.allowNewItems);if(this.$textBox.val().length?this.hasBeenFound(n)||(s?this.unfocusAllItems():this.focusFirstSearchResult()):this.unfocusAllItems(),"Replace"===i){var o=t.map(function(t){return e.getItemKey(t)});this.removeAllItemsExcept(o.concat(this.selectedItemsKeys()))}},i.prototype.focusPrevItem=function(){var e=this.$results.children("."+t.BusinessPackCss.bpItem+"."+t.BusinessPackCss.bpStateFocused).prevAll(":not(."+t.BusinessPackCss.bpStateDisabled+"):first");e.length&&(this.scrollToItem(e),this.focusItem(ko.dataFor(e[0])))},i.prototype.focusNextItem=function(){var e=this.$results.children("."+t.BusinessPackCss.bpItem+"."+t.BusinessPackCss.bpStateFocused),n=e.nextAll(":not(."+t.BusinessPackCss.bpStateDisabled+"):first");n.length||e.length||(n=this.$results.children("."+t.BusinessPackCss.bpItem+":not(."+t.BusinessPackCss.bpStateDisabled+"):first")),n.length&&(this.scrollToItem(n),this.focusItem(ko.dataFor(n[0])))},i.prototype.scrollToItem=function(t){var e=this.$results.innerHeight(),n=parseInt(this.$results.css("padding-top")),i=parseInt(this.$results.css("padding-bottom")),s=parseInt(t.css("margin-top")),o=parseInt(t.css("margin-bottom")),r=t.is(":first-child")?n:s,a=t.is(":last-child")?i:o,l=t.position().top,u=l+t.outerHeight(!0),c=this.$results.scrollTop();u>e?this.$results.scrollTop(c+(u-e)+a):l<0&&this.$results.scrollTop(c+l-r)},i.prototype.focusFirstSearchResult=function(){var t=this.searchResults()[0];t?this.focusItem(t()):this.unfocusAllItems()},i.prototype.canSelectFocusedItem=function(){var t=this.getFocusedItem();return this.isOpened&&t&&!this.isSelected(t)},i.prototype.selectFocusedItemOrCurrentText=function(){var t=this.getFocusedItem();return this.isOpened&&t?this.selectItem(t):this.selectCurrentText()},i.prototype.toggleFocusedItemOrCurrentText=function(){var t=this.getFocusedItem();return this.isOpened&&t?this.toggleItem(t):this.selectCurrentText()},i.prototype.unselecteLastItem=function(){this.isEnabled&&(this.binding.selectedValues.pop(),this.postback(this.binding.changed))},i.prototype.getSelectedItemStyle=function(e){e=ko.unwrap(e);var n={};return n[t.BusinessPackCss.bpStateDisabled]=!this.isItemEnabled(e),n},i.prototype.getItemStyle=function(e){e=ko.unwrap(e);var n={};return n[t.BusinessPackCss.bpStateDisabled]=!this.isItemEnabled(e),n[t.BusinessPackCss.bpStateFocused]=this.isFocused(e),n[t.BusinessPackCss.bpStateSelected]=this.isSelected(e),n},i.prototype.resetText=function(){this.binding.text(""),this.$textBox.attr("size",2)},i}(e.SelectorBase);e.MultiSelect=n,t.Utils.installBindingHandler("MultiSelect",n)}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.textBoxValue=ko.observable(),t.holdTimeoutId=null,t.changeIntervalId=null,t.hasPendingChanges=!1,t}return __extends(n,e),Object.defineProperty(n.prototype,"value",{get:function(){return this.binding.value()},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"hasValue",{get:function(){return null!=this.value},enumerable:!0,configurable:!0}),n.prototype.initialize=function(){var n=this;e.prototype.initialize.call(this),this.$textBox=this.$element.children("."+t.BusinessPackCss.bpTextBox),this.$increaseButton=this.$element.find("."+t.BusinessPackCss.bpIncrease),this.$decreaseButton=this.$element.find("."+t.BusinessPackCss.bpDecrease),this.$element.mousedown(this.onElementMousedown.bind(this)),this.$element.keydown(this.onElementKeydown.bind(this)),this.$textBox.focus(this.onTextBoxFocus.bind(this)),this.$textBox.blur(this.onTextBoxBlur.bind(this)),this.$textBox.keydown(this.onTextBoxKeydown.bind(this)),this.$textBox.change(this.onTextBoxChange.bind(this)),this.$increaseButton.mousedown(this.onIncreaseButtonMousedown.bind(this)),this.$decreaseButton.mousedown(this.onDecreaseButtonMousedown.bind(this)),this.subscribe(this.binding.value,this.onValueChange.bind(this)),this.subscribe(this.binding.maxValue,function(){return n.validateControl()}),this.subscribe(this.binding.minValue,function(){return n.validateControl()})},n.prototype.increase=function(){this.applyIncrease(1),this.postbackChangesIfPending()},n.prototype.decrease=function(){this.applyDecrease(1),this.postbackChangesIfPending()},n.prototype.onElementMousedown=function(){this.$textBox.focus()},n.prototype.onElementKeydown=function(e){this.isEnabled&&t.KeyboardKeys.isUpOrDown(e.which)&&(e.stopPropagation(),this.setKeydownTimeout(e.which===t.KeyboardKeys.up,e.ctrlKey))},n.prototype.onTextBoxFocus=function(){this.$element.addClass(t.BusinessPackCss.bpStateFocused)},n.prototype.onTextBoxBlur=function(){this.$element.removeClass(t.BusinessPackCss.bpStateFocused)},n.prototype.onTextBoxKeydown=function(e){t.KeyboardKeys.isUpOrDown(e.which)&&e.preventDefault()},n.prototype.onTextBoxChange=function(t){t.stopPropagation(),this.updateValueFromTextBox(),this.postbackChangesIfPending()},n.prototype.onIncreaseButtonMousedown=function(t){this.isEnabled&&(t.stopPropagationAndPreventDefault(),this.setMousedownTimeout(this.applyIncrease.bind(this)))},n.prototype.onDecreaseButtonMousedown=function(t){this.isEnabled&&(t.stopPropagationAndPreventDefault(),this.setMousedownTimeout(this.applyDecrease.bind(this)))},n.prototype.onValueChange=function(e){this.validateControl(),this.$element.toggleClass(t.BusinessPackCss.bpStateEmptyValue,null==e),this.textBoxValue(e)},n.prototype.setKeydownTimeout=function(t,e){var n=this,i=e?10:1,s=null==this.holdTimeoutId?600:200;clearTimeout(this.holdTimeoutId),t?this.applyIncrease(i):this.applyDecrease(i),this.holdTimeoutId=setTimeout(function(){n.clearTimeoutsAndIntervals(),n.postbackChangesIfPending()},s)},n.prototype.setMousedownTimeout=function(t){var e=this;clearTimeout(this.holdTimeoutId),t(1),this.holdTimeoutId=setTimeout(function(){e.changeIntervalId=setInterval(t,50,1)},600),this.$document.one("mouseup",function(){e.clearTimeoutsAndIntervals(),e.postbackChangesIfPending()})},n.prototype.applyIncrease=function(t){this.updateValueFromTextBox();var e=this.computeValue(t);this.changeValue(e)},n.prototype.applyDecrease=function(t){this.updateValueFromTextBox();var e=this.computeValue(-t);this.changeValue(e)},n.prototype.updateValueFromTextBox=function(){var t=this.$textBox.val().trim(),e=dotvvm.globalize.parseNumber(t);this.textBoxValue.valueHasMutated(),this.changeValue(isNaN(e)?null:e)},n.prototype.computeValue=function(t){var e=this.binding.value(),n=ko.unwrap(this.binding.step)*t,i=this.getNumberOfDecimals(),s=e+n;return Number(s.toFixed(i))},n.prototype.changeValue=function(t){var e=this.binding.value(),n=ko.unwrap(this.binding.maxValue),i=ko.unwrap(this.binding.minValue);null!=i&&t<i&&(t=i),null!=n&&t>n&&(t=n),t!==e&&(this.binding.value(t),this.hasPendingChanges=!0)},n.prototype.clearTimeoutsAndIntervals=function(){clearTimeout(this.holdTimeoutId),this.holdTimeoutId=null,clearInterval(this.changeIntervalId),this.changeIntervalId=null},n.prototype.getNumberOfDecimals=function(){var t=this.binding.value(),e=ko.unwrap(this.binding.step),n=Math.floor(e)!==e?e.toString().split(".")[1].length||0:0;if(null!=t){var i=Math.floor(t)!==t?t.toString().split(".")[1].length||0:0;return Math.max(n,i)}return n},n.prototype.postbackChangesIfPending=function(){this.hasPendingChanges&&(this.postback(this.binding.changed),this.hasPendingChanges=!1)},n.prototype.validateControl=function(){var t=this.binding.value(),e=ko.unwrap(this.binding.maxValue),n=ko.unwrap(this.binding.minValue);if(null!=e&&null!=n&&n>=e)throw new Error("The MinValue must be less than MaxValue.");if(null!=t){if(null!=e&&t>e)throw new Error("The Value must be less than or equal to MaxValue.");if(null!=n&&t<n)throw new Error("The Value must be greater than or equal to MinValue.")}},n}(e.ControlBase);e.NumericUpDown=n,t.Utils.installBindingHandler("NumericUpDown",n)}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.selectedItemKey=ko.observable(null),e}return __extends(e,t),e.prototype.initialize=function(){t.prototype.initialize.call(this),this.$element.on("change","[type=radio]",this.onInputChange.bind(this)),this.watch(this.binding.selectedValue,this.onSelectedValueChange)},e.prototype.selectItem=function(t){this.isSelected(t)||(this.binding.selectedValue(this.getItemValueCopy(t)),this.postback(this.binding.changed))},e.prototype.isSelected=function(t){return this.getItemKey(t)===this.selectedItemKey()},e.prototype.onInputChange=function(t){t.stopPropagation(),this.selectItem(ko.dataFor(t.target))},e.prototype.onSelectedValueChange=function(t){var e=this.findItemByValue(t);e?this.selectedItemKey(this.getItemKey(e)):(null!=t&&this.warnThatValueWasNotFound(t),this.selectedItemKey(null))},e}(e.CheckableControlListBase);e.RadioButtonList=n,t.Utils.installBindingHandler("RadioButtonList",n)}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(n){function i(){return null!==n&&n.apply(this,arguments)||this}return __extends(i,n),i.prototype.initialize=function(){var i=this;n.prototype.initialize.call(this),this.container=this.$element.find("> ."+t.BusinessPackCss.bpContainer).get(0),this.pointFactory=new e.RatingPointFactory(this.container,this.onPointValueChanged.bind(this)),this.subscribe(this.binding.fullPointIconCssClass,function(t){i.updatePointClasses(t,ko.unwrap(i.binding.halfPointIconCssClass),ko.unwrap(i.binding.emptyPointIconCssClass))}),this.subscribe(this.binding.halfPointIconCssClass,function(t){i.updatePointClasses(ko.unwrap(i.binding.fullPointIconCssClass),t,ko.unwrap(i.binding.emptyPointIconCssClass))}),this.subscribe(this.binding.emptyPointIconCssClass,function(t){i.updatePointClasses(ko.unwrap(i.binding.fullPointIconCssClass),ko.unwrap(i.binding.halfPointIconCssClass),t)}),this.subscribe(this.binding.maxValue,function(t){i.render(ko.unwrap(i.binding.value),t)}),this.subscribe(this.binding.value,function(t){i.updateDisplayedValue(t)}),this.binding.allowPreviewOnHover&&this.enablePreview(),this.subscribe(this.binding.enabled,function(t){t?i.enable():i.disable()})},i.prototype.render=function(t,e){this.container.innerHTML="",this.binding.allowHalfPoints?this.firstPoint=this.pointFactory.getHalfPointLinkedList(t,e):this.firstPoint=this.pointFactory.getFullPointLinkedList(t,e),ko.unwrap(this.binding.enabled)&&this.enable(),this.displayedValue=t},i.prototype.updateDisplayedValue=function(t){for(var n=t,i=this.firstPoint;n>1;)n-=1,i=i.next;i.setState(e.RatingPointStateConverter.valueToState(n),!0,!0),this.displayedValue=t},i.prototype.updatePointClasses=function(t,e,n){this.pointFactory&&(this.pointFactory.fullPointIconCssClass=t,this.pointFactory.halfPointIconCssClass=e,this.pointFactory.emptyPointIconCssClass=n),this.firstPoint&&this.foreachPoint(function(i){i.fullPointIconCssClass=t,i.halfPointIconCssClass=e,i.emptyPointIconCssClass=n,i.render()})},i.prototype.enable=function(){this.foreachPoint(function(t){t.enable()}),this.binding.allowPreviewOnHover&&this.enablePreview()},i.prototype.disable=function(){this.foreachPoint(function(t){t.disable()}),this.binding.allowPreviewOnHover&&this.disablePreview()},i.prototype.enablePreview=function(){var t=this;this.$element.get(0).onmouseleave=function(){return t.updateDisplayedValue(t.displayedValue)},this.foreachPoint(function(t){return t.enablePreview()})},i.prototype.disablePreview=function(){this.$element.get(0).onmouseleave=null,this.foreachPoint(function(t){return t.disablePreview()})},i.prototype.onPointValueChanged=function(t){this.displayedValue=t,this.displayedValue!==ko.unwrap(this.binding.value)&&(this.binding.value(this.displayedValue),this.postback(this.binding.changed))},i.prototype.foreachPoint=function(t){for(var e=this.firstPoint;e;)t(e),e=e.next},i}(e.ControlBase);e.Rating=n,t.Utils.installBindingHandler("Rating",n)}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(){function n(t,e,n,i){this.container=t,this.fullPointIconCssClass=e,this.halfPointIconCssClass=n,this.emptyPointIconCssClass=i}return n.prototype.setState=function(t,n,i){void 0===n&&(n=!1),void 0===i&&(i=!1),t!==this.state&&(this.state=t,this.render()),this.next&&n&&this.next.setState(e.RatingPointState.Empty,!0,!1),this.previous&&i&&this.previous.setState(e.RatingPointState.Full,!1,!0)},n.prototype.render=function(){this.point||(this.point=document.createElement("div"),this.point.className=t.BusinessPackCss.bpPoint,this.icon=document.createElement("i"),this.point.appendChild(this.icon),this.appendAdditionalElements(this.point),this.container.appendChild(this.point),this.enabled&&this.setClickHandlers(),this.previewEnabled&&this.setPreviewHandlers()),this.icon.className=t.BusinessPackCss.bpIcon+" "+this.getClassName(this.state)},n.prototype.enable=function(){this.enabled=!0,this.setClickHandlers()},n.prototype.disable=function(){this.enabled=!1,this.removeClickHandlers()},n.prototype.enablePreview=function(){this.previewEnabled=!0,this.setPreviewHandlers()},n.prototype.disablePreview=function(){this.previewEnabled=!1,this.removePreviewHandlers()},n.prototype.appendAdditionalElements=function(t){},n.prototype.notifyRatingValueChanged=function(){for(var t=0,n=this.previous;n;)++t,n=n.previous;this.valueChanged(t+e.RatingPointStateConverter.stateToValue(this.state))},n.prototype.getClassName=function(t){switch(t){case e.RatingPointState.Full:return this.fullPointIconCssClass;case e.RatingPointState.Half:return this.halfPointIconCssClass;case e.RatingPointState.Empty:return this.emptyPointIconCssClass;default:throw new Error("Passed argument must not be '"+String(t)+"'.")}},n}();e.RatingPoint=n}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(e){function n(t,n,i,s,o,r){var a=e.call(this,t,n,i,s)||this;return a.leftState=o,a.rightState=r,a}return __extends(n,e),n.prototype.appendAdditionalElements=function(e){this.left=this.getHalf(t.BusinessPackCss.bpLeft),this.right=this.getHalf(t.BusinessPackCss.bpRight),e.appendChild(this.left),e.appendChild(this.right)},n.prototype.setClickHandlers=function(){var t=this;this.left.onclick=function(){t.setState(t.leftState,!0,!0),t.notifyRatingValueChanged()},this.right.onclick=function(){t.setState(t.rightState,!0,!0),t.notifyRatingValueChanged()}},n.prototype.removeClickHandlers=function(){this.left.onclick=null,this.right.onclick=null},n.prototype.setPreviewHandlers=function(){var t=this;this.left.onmouseenter=function(){t.setState(t.leftState,!0,!0)},this.right.onmouseenter=function(){t.setState(t.rightState,!0,!0)}},n.prototype.removePreviewHandlers=function(){this.left.onmouseenter=null,this.right.onmouseenter=null},n.prototype.getHalf=function(e){var n=document.createElement("div");return n.classList.add(t.BusinessPackCss.bpHalf,e),n},n}(e.RatingPoint);e.RatingDiPoint=n}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(t){"use strict";var e=function(t){function e(e,n,i,s,o){var r=t.call(this,e,n,i,s)||this;return r.clickState=o,r}return __extends(e,t),e.prototype.setClickHandlers=function(){var t=this;this.point.onclick=function(){t.setState(t.clickState,!0,!0),t.notifyRatingValueChanged()}},e.prototype.removeClickHandlers=function(){this.point.onclick=null},e.prototype.setPreviewHandlers=function(){var t=this;this.point.onmouseenter=function(){t.setState(t.clickState,!0,!0)}},e.prototype.removePreviewHandlers=function(){this.point.onmouseenter=null},e}(t.RatingPoint);t.RatingMonoPoint=e}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(t){"use strict";var e=function(){function e(t,e){this.container=t,this.onValueChanged=e}return e.prototype.getFullPointLinkedList=function(e,n){var i=this;return this.getPointLinkedList(function(){return new t.RatingDiPoint(i.container,i.fullPointIconCssClass,i.halfPointIconCssClass,i.emptyPointIconCssClass,t.RatingPointState.Empty,t.RatingPointState.Full)},function(){return new t.RatingMonoPoint(i.container,i.fullPointIconCssClass,i.halfPointIconCssClass,i.emptyPointIconCssClass,t.RatingPointState.Full)},e,n)},e.prototype.getHalfPointLinkedList=function(e,n){var i=this;return this.getPointLinkedList(function(){return new t.RatingTriPoint(i.container,i.fullPointIconCssClass,i.halfPointIconCssClass,i.emptyPointIconCssClass,t.RatingPointState.Empty,t.RatingPointState.Half,t.RatingPointState.Full)},function(){return new t.RatingDiPoint(i.container,i.fullPointIconCssClass,i.halfPointIconCssClass,i.emptyPointIconCssClass,t.RatingPointState.Half,t.RatingPointState.Full)},e,n)},e.prototype.getPointLinkedList=function(t,e,n,i){for(var s=this.initializePoint(t(),n),o=s,r=1;r<i;r++){var a=this.initializePoint(e(),n-r);o.next=a,a.previous=o,o=a}return s},e.prototype.initializePoint=function(e,n){return e.setState(t.RatingPointStateConverter.valueToState(n)),e.valueChanged=this.onValueChanged,e},e}();t.RatingPointFactory=e}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(t){"use strict";!function(t){t[t.Empty=0]="Empty",t[t.Half=1]="Half",t[t.Full=2]="Full"}(t.RatingPointState||(t.RatingPointState={}))}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(t){"use strict";var e=function(){function e(){}return e.valueToState=function(e){return e>=1?t.RatingPointState.Full:e>0?t.RatingPointState.Half:t.RatingPointState.Empty},e.stateToValue=function(e){switch(e){case t.RatingPointState.Full:return 1;case t.RatingPointState.Half:return.5;case t.RatingPointState.Empty:return 0}},e}();t.RatingPointStateConverter=e}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(e){function n(t,n,i,s,o,r,a){var l=e.call(this,t,n,i,s)||this;return l.leftState=o,l.middleState=r,l.rightState=a,l}return __extends(n,e),n.prototype.appendAdditionalElements=function(e){this.left=this.getThird(t.BusinessPackCss.bpLeft),this.middle=this.getThird(t.BusinessPackCss.bpMiddle),this.right=this.getThird(t.BusinessPackCss.bpRight),e.appendChild(this.left),e.appendChild(this.middle),e.appendChild(this.right)},n.prototype.setClickHandlers=function(){var t=this;this.left.onclick=function(){t.setState(t.leftState,!0,!0),t.notifyRatingValueChanged()},this.middle.onclick=function(){t.setState(t.middleState,!0,!0),t.notifyRatingValueChanged()},this.right.onclick=function(){t.setState(t.rightState,!0,!0),t.notifyRatingValueChanged()}},n.prototype.removeClickHandlers=function(){this.left.onclick=null,this.middle.onclick=null,this.right.onclick=null},n.prototype.setPreviewHandlers=function(){var t=this;this.left.onmouseenter=function(){t.setState(t.leftState,!0,!0)},this.middle.onmouseenter=function(){t.setState(t.middleState,!0,!0)},this.right.onmouseenter=function(){t.setState(t.rightState,!0,!0)}},n.prototype.removePreviewHandlers=function(){this.left.onmouseenter=null,this.middle.onmouseenter=null,this.right.onmouseenter=null},n.prototype.getThird=function(e){var n=document.createElement("div");return n.classList.add(t.BusinessPackCss.bpThird,e),n},n}(e.RatingPoint);e.RatingTriPoint=n}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";function n(t){t.isCollapsed||(i(t),s(t))}function i(e){var n=e.getTexts();if(n.length){var i=e.startOffset,s=e.startContainer[0];if(t.DomUtils.isText(s)&&i===s.nodeValue.length){var o=n.indexOf(s);if(o>=0){var r=n[o+1];r&&e.startOn(r,0)}}}}function s(e){var n=e.getTexts();if(n.length){var i=e.endOffset,s=e.endContainer[0];if(t.DomUtils.isText(s)&&0===i){var o=n.indexOf(s);if(o>=0){var r=n[o-1];r&&e.endOn(r,r.nodeValue.length)}}}}function o(e){var n=e.startOffset,i=e.startContainer[0],s=e.endOffset,o=e.endContainer[0];if(t.DomUtils.isText(i)&&n>0){var r=i.splitText(n);e.startOn(r,0),o===i&&e.endOn(r,s-n)}}function r(e){var n=e.endOffset,i=e.endNode[0];if(t.DomUtils.isText(i)&&n<i.nodeValue.length){var s=i.splitText(n).previousSibling;e.endOn(s,s.nodeValue.length)}}var a=function(){function e(t){this.range=t.cloneRange(),n(this)}return Object.defineProperty(e.prototype,"isCollapsed",{get:function(){return this.range.collapsed},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"startOffset",{get:function(){return this.range.startOffset},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"startContainer",{get:function(){return $(this.range.startContainer)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"startNode",{get:function(){var e=this.range.startContainer;return t.DomUtils.isText(e)?$(e):$(e.childNodes[this.startOffset])},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"startChar",{get:function(){var e=this.startContainer[0],n=this.startNode[0];return t.DomUtils.isText(e)?e.nodeValue[this.startOffset]||null:t.DomUtils.isText(n)?n.nodeValue[0]||null:null},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"endOffset",{get:function(){return this.range.endOffset},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"endContainer",{get:function(){return $(this.range.endContainer)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"endNode",{get:function(){var e=this.range.endContainer;return t.DomUtils.isText(e)?$(e):$(e.childNodes[this.endOffset])},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"endChar",{get:function(){var e=this.endContainer[0],n=this.endNode[0];return t.DomUtils.isText(e)?e.nodeValue[this.endOffset]||null:t.DomUtils.isText(n)?n.nodeValue[0]||null:null},enumerable:!0,configurable:!0}),e.get=function(){var t=document.getSelection();return t.rangeCount>0?new e(t.getRangeAt(0)):null},e.create=function(){return new e(document.createRange())},e.restore=function(t){return!(!$.contains(document.documentElement,t.startContainer[0])||!$.contains(document.documentElement,t.endContainer[0]))&&(this.create().startOn(t.startContainer,t.startOffset).endOn(t.endContainer,t.endOffset).apply(),!0)},e.getLength=function(){var t=this.get();return t?t.getLength():0},e.deleteContents=function(){var t=this.get();t&&t.deleteContents()},e.isInList=function(){var t=this.get();return!!t&&t.isInList()},e.isInTableCell=function(){var t=this.get();return!!t&&t.isInTableCell()},e.isInAnchor=function(){var t=this.get();return!!t&&t.isInAnchor()},e.prototype.save=function(){return{startContainer:this.startContainer,startOffset:this.startOffset,endContainer:this.endContainer,endOffset:this.endOffset}},e.prototype.commonAncestor=function(t){var e=$(this.range.commonAncestorContainer);return t&&!e.is(t)?e.parentsUntil("[contenteditable=true]",t).first():e.not("[contenteditable=true]")},e.prototype.startAncestor=function(t){var e=$(this.range.startContainer);return t&&!e.is(t)?e.parentsUntil("[contenteditable=true]",t).first():e.not("[contenteditable=true]")},e.prototype.endAncestor=function(t){var e=$(this.range.endContainer);return t&&!e.is(t)?e.parentsUntil("[contenteditable=true]",t).first():e.not("[contenteditable=true]")},e.prototype.singleAncestor=function(t){var e=this.startAncestor(t),n=this.endAncestor(t);return e.is(n)?e:$([])},e.prototype.deleteContents=function(){return this.range.deleteContents(),this},e.prototype.extractContents=function(){return $(this.range.extractContents())},e.prototype.splitOnEdges=function(){return this.isCollapsed||(o(this),r(this)),this},e.prototype.insert=function(e){return this.range.insertNode(t.DomUtils.getNode(e)),$(e)},e.prototype.wrapContents=function(e){return this.range.surroundContents(t.DomUtils.getNode(e)),$(e)},e.prototype.select=function(e){return this.range.selectNode(t.DomUtils.getNode(e)),this},e.prototype.selectContents=function(e){return this.range.selectNodeContents(t.DomUtils.getNode(e)),this},e.prototype.selectWord=function(t){return this.selectContents(t.container)},e.prototype.startOn=function(e,n){return this.range.setStart(t.DomUtils.getNode(e),n),this},e.prototype.startBefore=function(e){return this.range.setStartBefore(t.DomUtils.getNode(e)),this},e.prototype.startAfter=function(e){return this.range.setStartAfter(t.DomUtils.getNode(e)),this},e.prototype.startOnWord=function(t){return this.startOn(t.container,t.offset)},e.prototype.endOn=function(e,n){return this.range.setEnd(t.DomUtils.getNode(e),n),this},e.prototype.endBefore=function(e){return this.range.setEndBefore(t.DomUtils.getNode(e)),this},e.prototype.endAfter=function(e){return this.range.setEndAfter(t.DomUtils.getNode(e)),this},e.prototype.endOnWord=function(t){return this.endOn(t.container,t.offset)},e.prototype.collapseToStart=function(){return this.range.collapse(!0),this},e.prototype.collapseToEnd=function(){return this.range.collapse(!1),this},e.prototype.apply=function(){var t=document.getSelection();t.removeAllRanges(),t.addRange(this.range)},e.prototype.isInList=function(){return!!this.singleAncestor("ul,ol").length},e.prototype.isInTableCell=function(){return!!this.singleAncestor("td,th").length},e.prototype.isInAnchor=function(){return!!this.singleAncestor("a").length},e.prototype.isOnText=function(){return t.DomUtils.isText(this.range.startContainer)&&t.DomUtils.isText(this.range.endContainer)},e.prototype.getWordRange=function(){var e=this.endNode[0];if(!this.isCollapsed||!e)return null;var n=t.Utils.normalizeSpaces(e.nodeValue),i=t.Utils.normalizeSpaces(this.endChar);if(!i)return this.getNextWordRange();if(t.DomUtils.isText(e)&&" "!==i){var s=$(e.previousSibling).is("br"),o=n.lastIndexOf(" ",this.endOffset-1),r=$(e.nextSibling).is("br"),a=n.indexOf(" ",this.endOffset);if(!(s||o>=0||r||a>=0))return{container:this.endContainer,offset:this.endOffset};var l=o>=0?o+1:0,u=(a>=0?a:n.length)-l,c=this.endOffset-l;if(u>0){var h=t.DomUtils.splitText(e,l,u);return{container:$(h[1]),offset:c}}}return null},e.prototype.getNextWordRange=function(){var e=this.endNode[0];if(!this.isCollapsed||!e)return null;var n=t.DomUtils.getNextText(e);return n?(this.startOn(n,0).collapseToStart(),this.getWordRange()):null},e.prototype.getNextContents=function(){var e=this.endOffset,n=this.range.endContainer,i=this.endNode;if(t.DomUtils.isText(n)){if(0===e)return t.DomUtils.getWithNextContents($(n));if(e<n.nodeValue.length){var s=n.splitText(e);return t.DomUtils.getWithNextContents($(s))}return t.DomUtils.getNextContents($(n))}return t.DomUtils.getWithNextContents(i)},e.prototype.getNodes=function(){var e=this.startContainer[0],n=this.endContainer[0],i=this.commonAncestor()[0],s=e;if(s===n)return $(s).is("[contenteditable=true]")?[]:[s];for(var o=[];s&&s!==n;)s=t.DomUtils.getNextNode(s),o.push(s);for(s=e;s&&s!==i&&!$(s).is("[contenteditable=true]");)o.unshift(s),s=s.parentNode;return o},e.prototype.getTexts=function(){for(var e=[],n=0,i=this.getNodes();n<i.length;n++){var s=i[n];t.DomUtils.isText(s)&&e.push(s)}return e},e.prototype.getLength=function(){return this.toString().length},e.prototype.toString=function(){return this.range.toString()},e.prototype.clone=function(){return new e(this.range.cloneRange())},e}();e.TextRange=a}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(){function n(){}return n.save=function(i){var s={path:[],offset:0},o={path:[],offset:0};if(n.isInEditor(i)){var r=e.TextRange.get();s.path=t.DomUtils.getPath(i,r.startContainer),s.offset=r.startOffset,o.path=t.DomUtils.getPath(i,r.endContainer),o.offset=r.endOffset}return{start:s,end:o}},n.restore=function(n,i){var s=i.start,o=i.end;e.TextRange.create().startOn(t.DomUtils.fromPath(n,s.path),s.offset).endOn(t.DomUtils.fromPath(n,o.path),o.offset).apply()},n.isInEditor=function(t){var n=e.TextRange.get();return!!n&&((t.is(n.startContainer)||t.find(n.startContainer).length)&&(t.is(n.endContainer)||t.find(n.endContainer).length))},n}();e.TextSelection=n}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";function n(t){if(t.length){var n=e.TextRange.get();i(n,t),s(n,t)}}function i(e,n){var i=e.clone().collapseToStart().startBefore(n).extractContents();i=t.DomUtils.trim(i),$(n).before(i)}function s(e,n){var i=e.clone().collapseToEnd().endAfter(n).extractContents();i=t.DomUtils.trim(i),$(n).after(i)}var o=function(){function i(t){void 0===t&&(t=[]),this.alternatives=t}return i.prototype.getState=function(t){for(var e=!1,n=!0,i=0,s=t;i<s.length;i++){var o=s[i];if(!this.shouldSkip(o)){var r=this.getNodeState(o);if(!r)return!1;if(n)e=r,n=!1;else if(r!==e)return!1}}return e},i.prototype.getNodeState=function(t){return this.isSuitableWrapper(t)||this.isFormatted(t)},i.prototype.toggle=function(t,e){this.areFormatted(t,e)?this.remove(t,e):this.apply(t,e)},i.prototype.toggleAfter=function(t,e){return this.isFormatted(t,e)?this.removeAfter(t,e):this.applyAfter(t,e)},i.prototype.apply=function(t,e){for(var n=0,i=t;n<i.length;n++){var s=i[n];if(!this.shouldSkip(s)&&!this.isFormatted(s,e)){var o=$(s),r=$(s.previousSibling),a=$(s.nextSibling);this.isSuitableWrapper(r,e)?(r.append(o),this.isSuitableWrapper(a,e)&&(r.append(a.contents()),a.remove())):this.isSuitableWrapper(a,e)?a.prepend(o):this.wrap(s,e)}}},i.prototype.applyAfter=function(n,i){var s=this.createWrapper(i),o=document.createTextNode(t.Utils.zeroWidthSpace),r=e.TextRange.get();if(n){var a=$(n),l=!n.previousSibling&&!n.nextSibling,u=t.Utils.normalizeSpaces(n.nodeValue);l&&a.is("br")||0===u.length?a.replaceWith(s.append(o)):a.after(s.append(o))}else r.insert(s).append(o);return o},i.prototype.remove=function(t,e){this.splitWrappers(t,e);for(var n=0,i=t;n<i.length;n++){var s=i[n];if(!this.shouldSkip(s)&&this.isFormatted(s,e)){var o=this.findWrapper(s,e);this.unwrap(o)}}},i.prototype.removeAfter=function(e,n){var i=this.findWrapper(e,n),s=null;return i.length&&(t.DomUtils.isEmpty(i)?i.remove():(s=document.createTextNode(t.Utils.zeroWidthSpace),i.after(s))),s},i.prototype.shouldSkip=function(e){return!t.DomUtils.isInlineContent(e)},i.prototype.areFormatted=function(t,e){for(var n=0,i=t;n<i.length;n++){var s=i[n];if(!this.shouldSkip(s)&&!this.isFormatted(s,e))return!1}return!0},i.prototype.isFormatted=function(t,e){return!!t&&!!this.findWrapper(t,e).length},i.prototype.isSuitableWrapper=function(e,n){var i=this.createWrapper(n);return t.DomUtils.canMerge(i,e)},i.prototype.findWrapper=function(e,n){return t.DomUtils.closestUntil(e,"[contenteditable=true]",this.mergeWrapperSelectors(n))},i.prototype.splitWrappers=function(t,e){for(var i=0,s=t;i<s.length;i++){var o=s[i];this.isFormatted(o,e)&&n(this.findWrapper(o,e))}},i.prototype.mergeWrapperSelectors=function(t){for(var e=this.getWrapperSelector(t),n=0,i=this.alternatives;n<i.length;n++)e+=","+i[n].getWrapperSelector(t);return e},i.prototype.wrap=function(t,e){$(t).wrap(this.createWrapper(e))},i.prototype.unwrap=function(t){for(var e=t[0];e.firstChild;)t.before($(e.firstChild));t.remove()},i}();e.InlineFormatBase=o;var r=function(t){function e(e,n){void 0===n&&(n=[]);var i=t.call(this,n)||this;return i.tagName=e,i}return __extends(e,t),e.prototype.getWrapperSelector=function(){return this.tagName},e.prototype.createWrapper=function(){return $("<"+this.tagName+">")},e}(o);e.TagInlineFormat=r;var a=function(t){function e(e,n,i){void 0===i&&(i=[]);var s=t.call(this,i)||this;return s.tagName=e,s.className=n,s}return __extends(e,t),e.prototype.getWrapperSelector=function(){return this.tagName+"."+this.className},e.prototype.createWrapper=function(){return $("<"+this.tagName+">").addClass(this.className)},e}(o);e.ClassInlineFormat=a;var l=function(e){function n(t,n,i){void 0===i&&(i=[]);var s=e.call(this,i)||this;return s.tagName=t,s.styleName=n,s}return __extends(n,e),n.prototype.getNodeState=function(e){var n=this.tagName+"[style*='"+this.styleName+":']",i=t.DomUtils.closestUntil(e,"[contenteditable=true]",n);return!!i.length&&i.css(this.styleName)},n.prototype.getWrapperSelector=function(t){return this.tagName+"[style*='"+this.styleName+":"+t+";'],"+this.tagName+"[style$='"+this.styleName+":"+t+"'],"+this.tagName+"[style*='"+this.styleName+": "+t+";'],"+this.tagName+"[style$='"+this.styleName+": "+t+"']"},n.prototype.createWrapper=function(t){return $("<"+this.tagName+">").css(this.styleName,t)},n}(o);e.StyleInlineFormat=l;var u=function(t){function e(e,n,i,s){void 0===s&&(s=[]);var o=t.call(this,e,n,s)||this;return o.styleValue=i,o}return __extends(e,t),e.prototype.getNodeState=function(t){return this.isFormatted(t)},e.prototype.getWrapperSelector=function(){return t.prototype.getWrapperSelector.call(this,this.styleValue)},e.prototype.createWrapper=function(){return t.prototype.createWrapper.call(this,this.styleValue)},e}(l);e.StyleValueInlineFormat=u}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";function n(t,e){try{document.execCommand(o(t),!1,e)}catch(t){}}function i(t){try{return document.queryCommandState(o(t))}catch(t){return!1}}function s(t){try{return document.queryCommandValue(o(t))}catch(t){return null}}function o(t){return t.startsWith("align")?t.replace("Justify","Full").replace("align","justify"):t.startsWith("toggle")?t.replace("toggle","insert"):t}function r(n){var i=e.TextRange.get().singleAncestor(t.DomUtils.blockSelector);i.length?(t.DomUtils.removeEmptyText(i),g(i)):(t.DomUtils.removeEmptyText(n.$input),g(n.$input))}function a(n,i){void 0===i&&(i=!1);var s,o=e.TextRange.get(),r=o.save();(s=o.isInTableCell()?t.DomUtils.getInlineContents(o.singleAncestor("td,th")).filter(function(e,n){return!t.DomUtils.isWhitespace(n)}).first():t.DomUtils.getInlineContents(n.$input).filter(function(e,n){return!t.DomUtils.isWhitespace(n)}).first()).length?(l(s),e.TextRange.restore(r)):i&&n.$input.is(":empty")&&n.insertParagraph()}function l(e){if(e.length){var n=t.DomUtils.getWithNextInlineContents(e).wrapAll("<p/>").parent();l(t.DomUtils.getNextAllInlineContents(n).filter(function(e,n){return!t.DomUtils.isWhitespace(n)}).first())}}function u(e){var n=e.children(t.DomUtils.blockSelector).first();n.length&&(l(t.DomUtils.getNextAllInlineContents(n).filter(function(e,n){return!t.DomUtils.isWhitespace(n)}).first()),e.after(n.nextAll().addBack()))}function c(e){var n=e.prev(t.DomUtils.blockSelector);t.DomUtils.removeEmptyText(n),n.is(":empty")&&n.html("<br>")}function h(e){var n=e.$input.clone();return t.DomUtils.removeEmptyText(n),p(n,"big","code","em","small","span","strikeout","strong","sub","sup","u"),d(n),g(n),t.Utils.normalizeSpaces(n.html())}function p(e){for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];for(var s=0,o=n;s<o.length;s++)for(var r=o[s],a=0,l=e.find(r).get();a<l.length;a++){for(var u=l[a],c=void 0,h=u.tagName;(c=u.nextSibling)&&t.DomUtils.canMerge(u,c);)$(u).append($(c).contents()),$(c).remove();for(var p=0,d=$(u).find(h).get();p<d.length;p++){var f=d[p];t.DomUtils.canMerge(u,f)&&$(f).replaceWith($(f).contents())}}}function d(t){for(var e=0,n=t.find("p:empty").get();e<n.length;e++){var i=n[e];$(i).remove()}}function f(){var n=e.TextRange.get();if(n&&n.isCollapsed){var i=n.endContainer[0],s=n.save();t.DomUtils.isText(i)&&i.nodeValue.length>1&&i.nodeValue.startsWith(t.Utils.zeroWidthSpace)&&(i.nodeValue=i.nodeValue.substr(1),s.startOffset=s.endOffset-=1,e.TextRange.restore(s))}}function g(t){for(var e=0,n=t.find("br:last-child").get();e<n.length;e++){var i=n[e];!i.nextSibling&&i.parentNode.childNodes.length>1&&$(i).remove()}}var m=function(o){function l(t){var n=o.call(this)||this;return n.$input=t,n.inlineFormats={},n.history=new e.UndoManager,n.registerInlineFormats(),n.history.apply(n.onHistoryApply.bind(n)),n.$document.on("selectionchange"+n.eventNs,n.onDocumentSelectionChange.bind(n)),t.focus(n.onInputFocus.bind(n)),t.blur(n.onInputBlur.bind(n)),t.keydown(n.onInputKeydown.bind(n)),t.keyup(n.onInputKeyup.bind(n)),t.on("keyup input",function(){return n.update()}),n.enable(),n}return __extends(l,o),Object.defineProperty(l.prototype,"html",{get:function(){return h(this)},set:function(t){t!==this.html?(this.$input.html(t),this.oldSelection=null,this.recordUndo()):this.history.isEmpty&&this.recordUndo()},enumerable:!0,configurable:!0}),l.prototype.enable=function(){this.$input.prop("contenteditable",!0)},l.prototype.disable=function(){this.$input.prop("contenteditable",!1)},l.prototype.change=function(t){this.on("change",t)},l.prototype.update=function(t){t?this.on("update",t):(this.trigger("update"),this.oldHtml!==this.html&&(this.recordUndo(),this.oldHtml=this.html,this.trigger("change")))},l.prototype.undo=function(){this.history.undo()},l.prototype.recordUndo=function(){this.history.record({contents:this.$input.contents().clone(),selection:e.TextSelection.save(this.$input)})},l.prototype.redo=function(){this.history.redo()},l.prototype.cut=function(){this.$input.focus(),n("cut")},l.prototype.copy=function(){this.$input.focus(),n("copy")},l.prototype.paste=function(){this.$input.focus(),n("paste")},l.prototype.formatInline=function(t,n){if(t in this.inlineFormats){this.$input.focus(),r(this);var i=e.TextRange.get(),s=this.inlineFormats[t],o=i.getWordRange();if(o&&i.selectWord(o).apply(),i.splitOnEdges(),i.isCollapsed){var a=i.endNode[0],l=s.toggleAfter(a,n);l&&i.startOn(l,1).collapseToEnd().apply()}else{var u=i.save();s.toggle(i.getNodes(),n),o?i.startOnWord(o).collapseToStart().apply():e.TextRange.restore(u)}this.update()}},l.prototype.bold=function(){this.formatInline("bold")},l.prototype.italic=function(){this.formatInline("italic")},l.prototype.underline=function(){this.formatInline("underline")},l.prototype.strikeThrough=function(){this.formatInline("strikeThrough")},l.prototype.subscript=function(){this.formatInline("subscript")},l.prototype.superscript=function(){this.formatInline("superscript")},l.prototype.backColor=function(t){this.formatInline("backColor",t)},l.prototype.foreColor=function(t){this.formatInline("foreColor",t)},l.prototype.fontName=function(t){this.formatInline("fontName",t)},l.prototype.fontSize=function(t){this.formatInline("fontSize",t+"pt")},l.prototype.formatBlock=function(n){if(n){this.$input.focus(),a(this,!0),r(this);var i=e.TextRange.get(),s=i.save(),o=i.startAncestor(t.DomUtils.blockSelector),l=i.endAncestor(t.DomUtils.blockSelector),u=$([]);u=u.add(o),o.is(l)||(u=u.add(o.nextUntil(l,t.DomUtils.blockSelector)).add(l));for(var c=0,h=u.get();c<h.length;c++){var p=h[c],d=$(p),f=t.DomUtils.cloneAs(d,n);if(d.is("ol,ul"))for(var g=!0,m=0,b=d.children("li").get();m<b.length;m++){var y=b[m],v=$(y);g||f.append("<br>"),f.append(v.text()),g=!1}else f.append(d.contents());d.replaceWith(f)}e.TextRange.restore(s),this.update()}},l.prototype.align=function(t){t&&(this.$input.focus(),a(this,!0),r(this),n("justify"+t),this.update())},l.prototype.alignLeft=function(){this.align("Left")},l.prototype.alignCenter=function(){this.align("Center")},l.prototype.alignRight=function(){this.align("Right")},l.prototype.alignJustify=function(){this.align("Full")},l.prototype.indent=function(){if(this.$input.focus(),e.TextRange.isInList()){var n=(l=e.TextRange.get()).save(),i=l.singleAncestor("li"),s=i.parent(),o=i.prev();if(o.length){var r=o.children("ol,ul").last();r.length||(r=t.DomUtils.clone(s).appendTo(o)),r.append(i),e.TextRange.restore(n),this.update()}}else{a(this,!0);var l=e.TextRange.get(),u=l.singleAncestor(t.DomUtils.blockSelector);if(u.length){var c=parseInt(u.css("margin-left"))+25;u.css("margin-left",c+"px"),this.update()}}},l.prototype.outdent=function(){if(this.$input.focus(),e.TextRange.isInList()){var n=(l=e.TextRange.get()).save(),i=l.singleAncestor("li"),s=i.parent(),o=i.parents("li").first(),r=i.nextAll();o.length&&(r.length&&t.DomUtils.clone(s).append(r).appendTo(i),o.after(i),s.children().length||s.remove(),e.TextRange.restore(n),this.update())}else{a(this,!0);var l=e.TextRange.get(),u=l.singleAncestor(t.DomUtils.blockSelector);if(u.length){var c=parseInt(u.css("margin-left"))-25;u.css("margin-left",c>0?c+"px":""),this.update()}}},l.prototype.nextTableCell=function(){this.$input.focus();var t=e.TextRange.get(),n=t.endAncestor("td,th").next();n.length||(n=t.endAncestor("tr").next().children().first()),n.length||(n=t.endAncestor("thead").next().children("tr").first().children().first()),n.length?t.startOn(n,0).collapseToStart().apply():(this.insertTableRow(),this.nextTableCell())},l.prototype.prevTableCell=function(){this.$input.focus();var t=e.TextRange.get(),n=t.startAncestor("td,th").prev();n.length||(n=t.startAncestor("tr").prev().children().last()),n.length||(n=t.endAncestor("tbody").prev().children("tr").last().children().last()),n.length&&t.startOn(n,0).collapseToStart().apply()},l.prototype.insertLine=function(){this.$input.focus(),e.TextRange.get().deleteContents(),r(this);var n=e.TextRange.get(),i=n.getNextContents(),s=$("<br>");i.length?i.detach():t.DomUtils.isLastOrFalsy(n.endNode)&&(i=$("<br>")),n.insert(s).after(i),n.startAfter(s).collapseToStart().apply(),this.update()},l.prototype.insertBlock=function(){e.TextRange.isInList()?this.insertListItem():this.insertParagraph()},l.prototype.toggleList=function(n){if(n){this.$input.focus(),a(this,!0),r(this);var i=e.TextRange.get(),s=i.save();if(e.TextRange.isInList()){var o=i.singleAncestor("li"),l=o.parent();if(!o.length)return;if(l.is(n)){var c=o.children("ol,ul").last(),h=t.DomUtils.reverse(o.prevAll().detach()),p=o.nextAll().detach(),d=$("<p><br></p>"),f=$([]);if(o.is(":empty")||d.empty().append(o.contents()),t.DomUtils.isLast(c)&&(p=c.children().add(p),c.remove()),h.length){b=t.DomUtils.clone(l).append(h);f=f.add(b)}if(f=f.add(d),p.length){y=t.DomUtils.clone(l).append(p);f=f.add(y)}l.replaceWith(f),u(d),e.TextRange.restore(s)||i.startOn(d,0).collapseToStart().apply()}else{var g=l.children();l.replaceWith($("<"+n+">").append(g)),e.TextRange.restore(s)}}else{var m=i.singleAncestor(t.DomUtils.blockSelector),b=m.prev("ol,ul"),y=m.next("ol,ul"),v=$("<li>");b.length||m.before(b=$("<"+n+">")),v.append(m.contents()).appendTo(b),m.remove(),y.length&&(b.append(y.children()),y.remove()),e.TextRange.restore(s)||i.startOn(v,0).collapseToStart().apply()}this.update()}},l.prototype.toggleOrderedList=function(){this.toggleList("ol")},l.prototype.toggleUnorderedList=function(){this.toggleList("ul")},l.prototype.autoInsertList=function(){if(this.$input.focus(),e.TextRange.isInList())return!1;r(this);var n=e.TextRange.get(),i=n.singleAncestor(t.DomUtils.blockSelector),s=this.$input[0].childNodes;if(i.length&&(s=i[0].childNodes),1===s.length){var o=s[0],a=o.nodeValue;if(t.DomUtils.isText(o)){var l=void 0;if(a.match(/^\s*-$/g)?l=$("<ul>"):a.match(/^\s*1[\.\)]$/g)?l=$("<ol>").css("list-style-type","decimal"):a.match(/^\s*a[\.\)]$/g)&&(l=$("<ol>").css("list-style-type","lower-alpha")),l){var u=$("<li>").appendTo(l);return i.not("td,th").length?i.replaceWith(l):$(o).replaceWith(l),n.startOn(u,0).apply(),this.update(),!0}}}return!1},l.prototype.insertListItem=function(){if(this.$input.focus(),e.TextRange.isInList()){e.TextRange.deleteContents(),r(this);var n=e.TextRange.get(),i=n.singleAncestor("li");if(i.is(":empty")){var s=i.parent(),o=t.DomUtils.reverse(i.prevAll().detach()),a=i.nextAll().detach(),l=$("<p><br></p>"),u=$([]);if(o.length){var c=t.DomUtils.clone(s).append(o);u=u.add(c)}if(u=u.add(l),a.length){var h=t.DomUtils.clone(s).append(a);u=u.add(h)}s.replaceWith(u),n.startOn(l,0).collapseToStart().apply()}else{var p=$("<li>").append(n.getNextContents()).insertAfter(i);n.startOn(p,0).collapseToStart().apply()}this.update()}},l.prototype.insertParagraph=function(){if(this.$input.focus(),!e.TextRange.isInList()){e.TextRange.deleteContents(),a(this),r(this);var n=e.TextRange.get(),i=n.startAncestor(t.DomUtils.blockSelector),s=n.getNextContents(),o=$("<p><br></p>");s.length&&o.empty().append(s),i.length?i.after(o):n.insert(o),c(o),n.startOn(o,0).collapseToStart().apply(),this.update()}},l.prototype.insertTable=function(t,n){if(t&&n&&(this.$input.focus(),!e.TextRange.isInTableCell())){e.TextRange.deleteContents(),r(this);for(var i=e.TextRange.get(),s=i.endAncestor("p"),o=$("<thead><tr></tr></thead>"),a=$("<tbody>"),l=$([]),u=0;u<n;u++)l=$("<th>"),o.children("tr").prepend(l);for(var c=0;c<t-1;c++){for(var h=$("<tr>"),u=0;u<n;u++)h.append("<td>");a.append(h)}var p=$("<table>").append(o).append(a);s.length?s.after(p):i.insert(p),i.startOn(l,0).collapseToStart().apply(),this.update()}},l.prototype.deleteTable=function(){this.$input.focus();var t=e.TextRange.get(),n=t.singleAncestor("table");n.length&&(n.next().length?t.startAfter(n).collapseToStart().apply():t.startBefore(n).collapseToStart().apply(),n.remove(),this.update())},l.prototype.insertTableRow=function(n){this.$input.focus();var i=e.TextRange.get(),s=i.singleAncestor("table"),o=i.singleAncestor("tr");if(o.length){for(var r=o.parent("thead"),a=o.children().length,l=t.DomUtils.clone(o);a--;)l.prepend("<td>");n?r.length||o.before(l):r.length?s.children("tbody").prepend(l):o.after(l),this.update()}},l.prototype.deleteTableRow=function(){this.$input.focus();var n=e.TextRange.get(),i=n.singleAncestor("table"),s=n.singleAncestor("tr");if(t.DomUtils.hasOnlyOneRow(i))this.deleteTable();else if(s.length){var o=$([]),r=s.prev(),a=s.next(),l=n.endAncestor("td,th").index()+1;a.length?o=a.children(":nth-child("+l+")"):r.length&&(o=r.children(":nth-child("+l+")")),s.siblings().length?s.remove():s.parent().remove(),o.length&&n.startOn(o,0).collapseToStart().apply(),this.update()}},l.prototype.insertTableColumn=function(n){this.$input.focus();var i=e.TextRange.get(),s=i.singleAncestor("table"),o=i.singleAncestor("td,th"),r=o.index()+1;if(o.length){for(var a=0,l=s.find("> thead > tr, > tbody > tr, > tr").get();a<l.length;a++){var u=l[a],c=$(u).children(":nth-child("+r+")");n?c.before(t.DomUtils.clone(c)):c.after(t.DomUtils.clone(c))}this.update()}},l.prototype.deleteTableColumn=function(){this.$input.focus();var n=e.TextRange.get(),i=n.singleAncestor("table"),s=n.singleAncestor("td,th"),o=s.index()+1;if(t.DomUtils.hasOnlyOneColumn(i))this.deleteTable();else if(s.length){var r=s.next(),a=i.find("> thead > tr, > tbody > tr, > tr");r.length||(r=s.prev());for(var l=0,u=a.get();l<u.length;l++){var c=u[l];$(c).children(":nth-child("+o+")").remove()}r.length&&n.startOn(r,0).collapseToStart().apply(),this.update()}},l.prototype.insertImage=function(t,n,i,s){if(void 0===n&&(n=null),void 0===i&&(i=null),void 0===s&&(s=null),t){this.$input.focus(),e.TextRange.deleteContents();var o=e.TextRange.get(),r=$("<img>").attr("src",t);n&&r.attr("title",n).attr("alt",n),i&&r.attr("width",i),s&&r.attr("height",s),o.insert(r),o.startAfter(r).collapseToStart().apply(),this.update()}},l.prototype.insertLink=function(n,i){if(void 0===i&&(i=null),n){this.$input.focus(),e.TextRange.deleteContents();var s=e.TextRange.get(),o=t.RegexUtils.urlOrEmail("i").exec(n),r=$("<a>").text(i||n);if(o){var a=o[1],l=o[2];a?r.attr("href",a.startsWith("www")?"http://"+a:a).attr("rel","nofollow"):r.attr("href","mailto:"+l)}else r.attr("href",n);s.insert(r),s.startAfter(r).collapseToStart().apply(),this.update()}},l.prototype.removeLink=function(){this.$input.focus();var t=e.TextRange.get(),n=t.singleAncestor("a");if(n.length){var i=t.save(),s=n.contents();n.replaceWith(s),e.TextRange.restore(i)||t.startAfter(s.last()).collapseToStart().apply()}},l.prototype.autoInsertLink=function(){this.$input.focus();var n=e.TextRange.get(),i=t.RegexUtils.urlOrEmail("gi"),s=n.endNode[0];if(t.DomUtils.isText(s)&&!t.DomUtils.isInAnchor(s)){var o=s.nodeValue,r=t.RegexUtils.getLastMatch(i,o,n.endOffset);if(r){var a=r[0],l=r[1],u=r[2],c=t.DomUtils.splitText(s,r.index,a.length)[1],h=$("<a>");return l?h.attr("href",l.startsWith("www")?"http://"+l:l).attr("rel","nofollow"):h.attr("href","mailto:"+u),h=$(c).wrap(h).parent(),n.isOnText()||n.startAfter(h).collapseToStart().apply(),this.update(),!0}}return!1},l.prototype.insertText=function(t){t&&(this.$input.focus(),n("insertText",t),this.update())},l.prototype.clearFormat=function(){this.$input.focus(),n("removeFormat"),this.update()},l.prototype.selectAll=function(){this.$input.focus(),n("selectAll")},l.prototype.delete=function(){this.$input.focus(),n("delete"),this.update()},l.prototype.isCommandEnabled=function(t){return"undo"===t?this.history.canUndo:"redo"===t?this.history.canRedo:"clearFormat"===t?e.TextRange.getLength()>0:"insertTable"===t?!e.TextRange.isInTableCell():t.indexOf("Table")>0?e.TextRange.isInTableCell():"insertLink"===t?!e.TextRange.isInAnchor():"removeLink"!==t||e.TextRange.isInAnchor()},l.prototype.isCommandVisible=function(t){return"insertTable"===t?!e.TextRange.isInTableCell():t.indexOf("Table")>0?e.TextRange.isInTableCell():"insertLink"===t?!e.TextRange.isInAnchor():"removeLink"!==t||e.TextRange.isInAnchor()},l.prototype.getCommandState=function(t){var n=e.TextRange.get();if(!n)return null;if(t in this.inlineFormats)return this.inlineFormats[t].getState(n.getNodes());if(t.startsWith("align"))return i(t);if("toggleOrderedList"===t)return n.singleAncestor("ol,ul").is("ol");if("toggleUnorderedList"===t)return n.singleAncestor("ol,ul").is("ul");var o=s(t);return o?"formatBlock"===t?"Normal"!==o?o:null:o:null},l.prototype.registerInlineFormats=function(){this.inlineFormats.bold=new e.TagInlineFormat("strong",[new e.TagInlineFormat("b"),new e.StyleValueInlineFormat("span","font-weight","bold")]),this.inlineFormats.italic=new e.TagInlineFormat("em",[new e.TagInlineFormat("i"),new e.StyleValueInlineFormat("span","font-style","italic")]),this.inlineFormats.underline=new e.TagInlineFormat("u",[new e.StyleValueInlineFormat("span","text-decoration","underline")]),this.inlineFormats.strikeThrough=new e.TagInlineFormat("strike",[new e.StyleValueInlineFormat("span","text-decoration","line-through")]),this.inlineFormats.subscript=new e.TagInlineFormat("sub"),this.inlineFormats.superscript=new e.TagInlineFormat("sup"),this.inlineFormats.backColor=new e.StyleInlineFormat("span","background-color"),this.inlineFormats.foreColor=new e.StyleInlineFormat("span","color"),this.inlineFormats.fontName=new e.StyleInlineFormat("span","font-family"),this.inlineFormats.fontSize=new e.StyleInlineFormat("span","font-size"),this.inlineFormats.code=new e.TagInlineFormat("code"),this.inlineFormats.big=new e.TagInlineFormat("big"),this.inlineFormats.small=new e.TagInlineFormat("small"),this.inlineFormats.marker=new e.ClassInlineFormat("span","marker")},l.prototype.onDocumentSelectionChange=function(){e.TextSelection.isInEditor(this.$input)&&this.update()},l.prototype.onInputFocus=function(){this.oldHtml=this.html,null!=this.oldSelection&&(e.TextSelection.restore(this.$input,this.oldSelection),this.oldSelection=null),n("styleWithCSS",!1),n("enableInlineTableEditing",!1),n("enableObjectResizing",!1),n("respectVisibilityInDesign",!0),n("autoUrlDetect",!1),n("defaultParagraphSeparator","p"),n("insertBrOnReturn",!1)},l.prototype.onInputBlur=function(){this.oldSelection=e.TextSelection.save(this.$input),this.update()},l.prototype.onInputKeydown=function(n){var i=!0;t.KeyboardKeys.isWhiteSpace(n.which)&&this.autoInsertLink(),t.KeyboardKeys.isEnter(n.which)?n.shiftKey?this.insertLine():this.insertBlock():n.which===t.KeyboardKeys.spacebar?i=this.autoInsertList():n.which===t.KeyboardKeys.tab?n.shiftKey?e.TextRange.isInTableCell()?this.prevTableCell():this.outdent():e.TextRange.isInTableCell()?this.nextTableCell():this.indent():n.ctrlKey&&n.which===t.KeyboardKeys.z?this.undo():n.ctrlKey&&n.which===t.KeyboardKeys.y?this.redo():n.ctrlKey&&n.which===t.KeyboardKeys.b?this.bold():n.ctrlKey&&n.which===t.KeyboardKeys.i?this.italic():n.ctrlKey&&n.which===t.KeyboardKeys.u?this.underline():i=!1,i&&n.stopPropagationAndPreventDefault()},l.prototype.onInputKeyup=function(){f()},l.prototype.onHistoryApply=function(t){this.$input.empty().append(t.contents.clone()),this.oldHtml=this.html,e.TextSelection.restore(this.$input,t.selection),this.trigger("change")},l}(e.ReactiveBase);e.ContentEditable=m}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(n){function i(){return null!==n&&n.apply(this,arguments)||this}return __extends(i,n),i.prototype.initialize=function(){var i=this;this.$toolbar=this.$element.find("."+t.BusinessPackCss.bpToolbar),this.$textArea=this.$element.find("."+t.BusinessPackCss.bpTextArea),this.content=new e.ContentEditable(this.$textArea),n.prototype.initialize.call(this),this.$document.on("click"+this.eventNs,this.onDocumentClick.bind(this)),this.$element.click(this.onElementClick.bind(this)),this.$toolbar.on("mousedown",this.onToolbarMousedown.bind(this)),this.$toolbar.on("click","."+t.BusinessPackCss.bpDropDown,this.onToolbarDropDownClick.bind(this)),this.$toolbar.on("click","[data-trigger]",this.onToolbarTriggerClick.bind(this)),this.$textArea.focus(this.onTextAreaFocus.bind(this)),this.$textArea.blur(this.onTextAreaBlur.bind(this)),this.content.change(this.onContentChange.bind(this)),this.content.update(function(){return i.updateToolbar()}),this.subscribe(this.binding.html,this.onHtmlChange),this.disposing(function(){return i.content.dispose()}),this.updateToolbar()},i.prototype.updateToolbar=function(){for(var e=this.$toolbar.find("[data-trigger]"),n=this.$toolbar.find("."+t.BusinessPackCss.bpDropDown),i=0,s=e.get();i<s.length;i++){var o=s[i],r=$(o),a=r.closest("."+t.BusinessPackCss.bpItem),l=r.data("trigger");if(l)if(a.toggleClass(t.BusinessPackCss.bpStateDisabled,!this.content.isCommandEnabled(l)),a.toggle(this.content.isCommandVisible(l)),"formatBlock"===l){var u=r.data("format"),c=this.content.getCommandState("formatBlock");r.toggleClass(t.BusinessPackCss.bpStateSelected,u===c)}else if("formatInline"===l){u=r.data("format");r.toggleClass(t.BusinessPackCss.bpStateSelected,this.content.getCommandState(u))}else{var h=this.content.getCommandState(l);"boolean"==typeof h&&a.toggleClass(t.BusinessPackCss.bpStateChecked,h)}}for(var p=0,d=n.get();p<d.length;p++){var f=d[p],g=$(f),m=g.find("li."+t.BusinessPackCss.bpStateSelected),b=g.data("default-text");1===m.length&&(b=m.children("span").text()),b&&g.children("span").text(b)}},i.prototype.onDocumentClick=function(e){for(var n=0,i=this.$toolbar.find("."+t.BusinessPackCss.bpDropDown).get();n<i.length;n++){var s=i[n],o=$(s);o.is(e.target)||o.find(e.target).length||o.removeClass(t.BusinessPackCss.bpStateOpened)}},i.prototype.onElementClick=function(t){this.isPopup(t.target)||this.$textArea.focus()},i.prototype.onToolbarMousedown=function(t){this.isPopup(t.target)||t.preventDefault()},i.prototype.onToolbarDropDownClick=function(e){var n=$(e.currentTarget),i=n.data("command");this.isEnabled&&!this.isPopup(e.target)&&(n.hasClass(t.BusinessPackCss.bpStateOpened)||("insertLink"===i?this.initializeInsertLinkPopup(n):"insertImage"===i&&this.initializeInsertImagePopup(n)),n.toggleClass(t.BusinessPackCss.bpStateOpened))},i.prototype.initializeInsertLinkPopup=function(n){var i=e.TextRange.get(),s=n.find("."+t.BusinessPackCss.bpPopup),o=t.RegexUtils.urlOrEmail("i"),r=i?i.toString():"";o.test(r)?s.find("input[name=url]").val(r):s.find("input[name=url]").val(""),s.find("input[name=text]").val(r)},i.prototype.initializeInsertImagePopup=function(e){var n=e.find("."+t.BusinessPackCss.bpPopup);n.find("input[name=url]").val(""),n.find("input[name=description]").val(""),n.find("input[name=width]").val(""),n.find("input[name=height]").val("")},i.prototype.onToolbarTriggerClick=function(t){var e=$(t.currentTarget),n=e.data("trigger");this.isEnabled&&n&&this.content.isCommandEnabled(n)&&("formatBlock"===n?this.onFormatBlockCommandClick(e):"formatInline"===n?this.onFormatInlineCommandClick(e):"insertLink"===n?this.onInsertLinkCommandClick(e):"insertImage"===n?this.onInsertImageCommandClick(e):"insertTable"===n?this.onInsertTableCommandClick(e):this.content[n](),this.updateToolbar())},i.prototype.onFormatBlockCommandClick=function(e){var n=e.data("format"),i=this.content.getCommandState("formatBlock"),s=e.closest("."+t.BusinessPackCss.bpDropDown);n&&(this.content.formatBlock(n!==i?n:"p"),s.removeClass(t.BusinessPackCss.bpStateOpened))},i.prototype.onFormatInlineCommandClick=function(e){var n=e.data("format"),i=e.closest("."+t.BusinessPackCss.bpDropDown);n&&(this.content.formatInline(n),i.removeClass(t.BusinessPackCss.bpStateOpened))},i.prototype.onInsertLinkCommandClick=function(e){var n=e.closest("."+t.BusinessPackCss.bpPopup),i=(n.closest("."+t.BusinessPackCss.bpDropDown),n.find("input[name=text]").val()),s=n.find("input[name=url]").val();this.content.insertLink(s,i)},i.prototype.onInsertImageCommandClick=function(e){var n=e.closest("."+t.BusinessPackCss.bpPopup),i=n.closest("."+t.BusinessPackCss.bpDropDown),s=n.find("input[name=description]").val(),o=n.find("input[name=url]").val(),r=n.find("input[name=width]").val(),a=n.find("input[name=height]").val();this.content.insertImage(o,s,r,a),i.removeClass(t.BusinessPackCss.bpStateOpened)},i.prototype.onInsertTableCommandClick=function(e){var n=e.closest("."+t.BusinessPackCss.bpPopup),i=n.closest("."+t.BusinessPackCss.bpDropDown),s=n.find("input[name=rows]").val(),o=n.find("input[name=columns]").val();this.content.insertTable(s,o),i.removeClass(t.BusinessPackCss.bpStateOpened)},i.prototype.onTextAreaFocus=function(){this.$element.addClass(t.BusinessPackCss.bpStateFocused)},i.prototype.onTextAreaBlur=function(){this.$element.removeClass(t.BusinessPackCss.bpStateFocused)},i.prototype.onContentChange=function(){this.binding.html(this.content.html),this.binding.onChanged&&this.binding.onChanged()},i.prototype.onEnabledChange=function(){n.prototype.onEnabledChange.call(this),this.isEnabled?this.content.enable():this.content.disable()},i.prototype.toggleTabIndex=function(){this.isEnabled?this.$textArea.attr("tabindex",this.binding.tabIndex):this.$textArea.removeAttr("tabindex")},i.prototype.onHtmlChange=function(t){this.content.html=t},i.prototype.isPopup=function(e){var n=$(e).closest("."+t.BusinessPackCss.bpItem).find("."+t.BusinessPackCss.bpPopup);return n.is(e)||!!n.find(e).length},i}(e.ControlBase);e.RichTextBox=n,t.Utils.installBindingHandler("RichTextBox",n)}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.holdTimeoutId=null,t}return __extends(n,e),Object.defineProperty(n.prototype,"maxValue",{get:function(){return ko.unwrap(this.binding.maxValue)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"minValue",{get:function(){return ko.unwrap(this.binding.minValue)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"enabled",{get:function(){return void 0==this.binding.enabled||ko.unwrap(this.binding.enabled)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"step",{get:function(){return ko.unwrap(this.binding.step)},enumerable:!0,configurable:!0}),n.prototype.initialize=function(){var n=this;e.prototype.initialize.call(this),this.$selection=this.$element.find("."+t.BusinessPackCss.bpValue),this.subscribe(this.binding.minValue,function(){return n.update(!0)}),this.subscribe(this.binding.maxValue,function(){return n.update(!0)})},n.prototype.startDrag=function(e,n){var i=this;if(this.enabled){n.focus();var s=$(window),o=function(e){return i.handleDraged(t.Utils.convertTouchToMouseEvent(e),n)};s.on("mousemove touchmove",o);var r=function(){s.off("mousemove touchmove",o),i.fireChangedEvent(),s.off("mouseup touchend",r)};s.on("mouseup touchend",r),e.preventDefault()}},n.prototype.handleDraged=function(t,e){var n=(parseInt(this.$element.css("padding-left"))+parseInt(this.$element.css("padding-right")))/2,i=t.clientX-this.$element.offset().left-n;i<0&&(i=0),i>this.$element.innerWidth()&&(i=this.$element.innerWidth());var s=this.calculateCurrentValueFromPossition(i);return this.constrain(s,this.minValue,this.maxValue)},n.prototype.constrain=function(t,e,n){return t>n?n:t<e?e:t},n.prototype.getPercentageRepresentationOfValue=function(t){return 100*(t-this.minValue)/(this.maxValue-this.minValue)},n.prototype.getPercentageRepresentationOfWidth=function(t){return 100*t/this.$element.width()},n.prototype.setWidthOfSelection=function(t){var e=this.getPercentageRepresentationOfValue(t);this.$selection.width(e+"%")},n.prototype.getWidthInPixelsFromValue=function(t){return this.$element.width()/(this.maxValue-this.minValue)*t},n.prototype.moveHandler=function(t,e){e.css("left",this.getPercentageRepresentationOfValue(t)+"%")},n.prototype.calculateCurrentValueFromPossition=function(t){var e=this.getStepWidth();t=Math.round(t/e)*e;var n=this.minValue+this.getPercentageRepresentationOfWidth(t)/100*(this.maxValue-this.minValue);return Number(n.toFixed(5))},n.prototype.getStepWidth=function(){return this.getWidthInPixelsFromValue(this.step)},n.prototype.fireChangedEvent=function(){this.binding.changed&&this.binding.changed()},n}(e.ControlBase);e.SliderBase=n}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return __extends(n,e),Object.defineProperty(n.prototype,"selectedStartValue",{get:function(){return ko.unwrap(this.binding.selectedStartValue)},set:function(t){var e=this.binding.selectedStartValue;ko.isWriteableObservable(e)&&e(void 0!=t?t:null),this.updateHandlesAndSelectedValue(this.selectedStartValue,this.selectedEndValue)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"selectedEndValue",{get:function(){return ko.unwrap(this.binding.selectedEndValue)},set:function(t){var e=this.binding.selectedEndValue;ko.isWriteableObservable(e)&&e(void 0!=t?t:null),this.updateHandlesAndSelectedValue(this.selectedStartValue,this.selectedEndValue)},enumerable:!0,configurable:!0}),n.prototype.update=function(t){var e=this;void 0===t&&(t=!1);var n=!(e.startValueAtLastPostBack===e.selectedStartValue||e.endValueAtLastPostBack===e.selectedEndValue);(t||!this.updateAllReaduScheduled&&!n)&&(this.updateAllReaduScheduled=!0,setTimeout(function(){e.checkRangeAndRepairItIfNessesary(),e.updateHandlesAndSelectedValue(e.selectedStartValue,e.selectedEndValue),e.updateAllReaduScheduled=!1},100))},n.prototype.checkRangeAndRepairItIfNessesary=function(){var e=!1,n=!1;this.selectedStartValue>this.selectedEndValue&&(t.Utils.warnInDebugMode("Start of the range cannot be after its end."),this.selectedStartValue=this.minValue,e=!0),this.selectedEndValue<this.selectedStartValue&&(t.Utils.warnInDebugMode("End of the range cannot be before its start."),this.selectedEndValue=this.maxValue,n=!0),this.selectedStartValue<this.minValue&&(t.Utils.warnInDebugMode("Start of the range is lower than MIN value. "),this.selectedStartValue=this.minValue,e=!0),this.selectedEndValue>this.maxValue&&(t.Utils.warnInDebugMode("End of the range is higher than MAX value. "),this.selectedEndValue=this.maxValue,n=!0),(e||n)&&this.fireChangedEvent()},n.prototype.initialize=function(){var n=this;this.$handleStart=this.$element.find("."+t.BusinessPackCss.bpMin),this.$handleEnd=this.$element.find("."+t.BusinessPackCss.bpMax),e.prototype.initialize.call(this),this.subscribe(this.binding.selectedStartValue,function(){n.update(!0)}),this.subscribe(this.binding.selectedEndValue,function(){n.update(!0)}),this.checkRangeAndRepairItIfNessesary(),this.updateHandlesAndSelectedValue(this.selectedStartValue,this.selectedEndValue),this.$handleStart.focus(function(t){return n.onHandleFocus(t)}),this.$handleStart.blur(function(t){return n.onHandleBlur(t)}),this.$handleStart.keydown(function(t){return n.onHandleKeydown(t)}),this.$handleEnd.focus(function(t){return n.onHandleFocus(t)}),this.$handleEnd.blur(function(t){return n.onHandleBlur(t)}),this.$handleEnd.keydown(function(t){return n.onHandleKeydown(t)}),this.$handleStart.on("touchstart mousedown",function(t){return n.startDrag(t,n.$handleStart)}),this.$handleEnd.on("touchstart mousedown",function(t){return n.startDrag(t,n.$handleEnd)})},n.prototype.onHandleFocus=function(e){this.$element.addClass(t.BusinessPackCss.bpStateFocused),$(e.target).addClass(t.BusinessPackCss.bpStateFocused)},n.prototype.onHandleBlur=function(e){this.$element.removeClass(t.BusinessPackCss.bpStateFocused),$(e.target).removeClass(t.BusinessPackCss.bpStateFocused)},n.prototype.onHandleKeydown=function(e){var n=this;this.isEnabled&&t.KeyboardKeys.isLeftOrRight(e.which)&&(e.stopPropagation(),this.$handleStart.is(e.target)?this.setKeydownTimeout(e.which===t.KeyboardKeys.right,this.selectedStartValue,function(t){return t>n.selectedEndValue&&(t=n.selectedEndValue),n.selectedStartValue=t}):this.setKeydownTimeout(e.which===t.KeyboardKeys.right,this.selectedEndValue,function(t){return t<n.selectedStartValue&&(t=n.selectedStartValue),n.selectedEndValue=t}))},n.prototype.setKeydownTimeout=function(t,e,n){var i=this,s=null==this.holdTimeoutId?600:200,o=e+(t?this.step:-this.step);clearTimeout(this.holdTimeoutId),n(o=this.constrain(o,this.minValue,this.maxValue)),this.holdTimeoutId=setTimeout(function(){clearTimeout(i.holdTimeoutId),i.holdTimeoutId=null,i.fireChangedEvent()},s)},n.prototype.handleDraged=function(t,n){if(!this.enabled)return null;var i,s=n==this.$handleStart,o=n==this.$handleEnd;if(s){t.clientX+=n.width()/2,i=e.prototype.handleDraged.call(this,t,n);var r=this.selectedEndValue;i>r&&(i=r),this.selectedStartValue=i}if(o){t.clientX-=n.width()/2,i=e.prototype.handleDraged.call(this,t,n);var a=this.selectedStartValue;i<a&&(i=a),this.selectedEndValue=i}return i},n.prototype.updateHandles=function(){this.moveHandler(this.selectedStartValue,this.$handleStart),this.moveHandler(this.selectedEndValue,this.$handleEnd)},n.prototype.updateHandlesAndSelectedValue=function(t,e){var n=e-t;this.setWidthOfSelection(this.minValue+n),this.shiftSelection(t),this.moveHandler(t,this.$handleStart),this.moveHandler(e,this.$handleEnd)},n.prototype.shiftSelection=function(t){var e=this.getPercentageRepresentationOfValue(t);this.$selection.css("left",e+"%")},n.prototype.fireChangedEvent=function(){var t=!1;this.selectedStartValue!==this.startValueAtLastPostBack&&(this.startValueAtLastPostBack=this.selectedStartValue,t=!0),this.selectedEndValue!==this.endValueAtLastPostBack&&(this.endValueAtLastPostBack=this.selectedEndValue,t=!0),t&&e.prototype.fireChangedEvent.call(this)},n.prototype.toggleTabIndex=function(){this.isEnabled?(this.$handleStart.attr("tabindex",this.binding.tabIndex),this.$handleEnd.attr("tabindex",this.binding.tabIndex)):(this.$handleStart.removeAttr("tabindex"),this.$handleEnd.removeAttr("tabindex"))},n}(e.SliderBase);e.RangeSlider=n,t.Utils.installBindingHandler("RangeSlider",n)}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return __extends(n,e),Object.defineProperty(n.prototype,"selectedValue",{get:function(){return ko.unwrap(this.binding.selectedValue)},set:function(t){var e=this.binding.selectedValue;this.updateHandleAndValue(t),ko.isWriteableObservable(e)&&e(void 0!=t?t:null)},enumerable:!0,configurable:!0}),n.prototype.initialize=function(){var n=this;this.$handle=this.$element.find("."+t.BusinessPackCss.bpGrip),e.prototype.initialize.call(this),this.subscribe(this.binding.selectedValue,function(t){return n.updateHandleAndValue(t)}),this.updateHandleAndValue(this.selectedValue),this.$handle.on("touchstart mousedown",function(t){return n.startDrag(t,n.$handle)}),this.$handle.focus(function(t){return n.onHandleFocus(t)}),this.$handle.blur(function(t){return n.onHandleBlur(t)}),this.$handle.keydown(function(t){return n.onHandleKeydown(t)}),this.$element.click(function(t){return n.moveHandleOnClick(t)}),this.valueAtLastPostback=this.selectedValue},n.prototype.onHandleFocus=function(e){this.$element.addClass(t.BusinessPackCss.bpStateFocused),this.$handle.addClass(t.BusinessPackCss.bpStateFocused)},n.prototype.onHandleBlur=function(e){this.$element.removeClass(t.BusinessPackCss.bpStateFocused),this.$handle.removeClass(t.BusinessPackCss.bpStateFocused)},n.prototype.onHandleKeydown=function(e){this.isEnabled&&t.KeyboardKeys.isLeftOrRight(e.which)&&(e.stopPropagation(),this.setKeydownTimeout(e.which===t.KeyboardKeys.right))},n.prototype.setKeydownTimeout=function(t){var e=this,n=null==this.holdTimeoutId?600:200,i=t?this.step:-this.step,s=this.selectedValue+i;clearTimeout(this.holdTimeoutId),s=this.constrain(s,this.minValue,this.maxValue),this.selectedValue=s,this.holdTimeoutId=setTimeout(function(){clearTimeout(e.holdTimeoutId),e.holdTimeoutId=null,e.fireChangedEvent()},n)},n.prototype.moveHandleOnClick=function(t){if(this.enabled){var e=t.clientX-this.$element.offset().left;this.selectedValue=this.calculateCurrentValueFromPossition(e),this.fireChangedEvent()}},n.prototype.update=function(t){var e=this;(t||!this.updateAllReaduScheduled&&e.valueAtLastPostback===e.selectedValue)&&(this.updateAllReaduScheduled=!0,setTimeout(function(){e.checkValueAndRepairItIfNessesary(),e.updateHandleAndValue(e.selectedValue),e.updateAllReaduScheduled=!1},100))},n.prototype.updateHandleAndValue=function(t){this.setWidthOfSelection(t),this.moveHandler(this.selectedValue,this.$handle)},n.prototype.handleDraged=function(t,n){var i=e.prototype.handleDraged.call(this,t,n);return this.selectedValue=i,i},n.prototype.fireChangedEvent=function(){this.selectedValue!==this.valueAtLastPostback&&(this.valueAtLastPostback=this.selectedValue,e.prototype.fireChangedEvent.call(this))},n.prototype.checkValueAndRepairItIfNessesary=function(){var e=!1;this.selectedValue>this.maxValue&&(this.selectedValue=this.maxValue,t.Utils.warnInDebugMode("Selected value fixed to match max value."),e=!0),this.selectedValue<this.minValue&&(this.selectedValue=this.maxValue,t.Utils.warnInDebugMode("Selected value fixed to match min value."),e=!0),e&&this.fireChangedEvent()},n.prototype.toggleTabIndex=function(){this.isEnabled?this.$handle.attr("tabindex",this.binding.tabIndex):this.$handle.removeAttr("tabindex")},n}(e.SliderBase);e.Slider=n,t.Utils.installBindingHandler("Slider",n)}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.activeTabIndex=0,t}return __extends(n,e),Object.defineProperty(n.prototype,"activeTabKey",{get:function(){return ko.unwrap(this.binding.activeTabKey)||null},set:function(t){var e=this.binding.activeTabKey;ko.isWriteableObservable(e)&&e(null!=t?t:null)},enumerable:!0,configurable:!0}),n.prototype.initialize=function(){var n=this;e.prototype.initialize.call(this),this.$headers=this.$element.children("."+t.BusinessPackCss.bpNav),this.$container=this.$element.children("."+t.BusinessPackCss.bpContainer),this.$headers.on("click","li",function(t){return n.onHeaderClick(t)}),this.binding.activeTabKey||(this.binding.activeTabKey=ko.observable(null),this.binding.tabIsActiveBinding&&this.watch(this.binding.dataSource,this.onDataSourceChange)),this.subscribe(this.binding.activeTabKey,this.onActiveTabKeyChange),setTimeout(function(){n.updateActiveCssClass()},0)},n.prototype.onHeaderClick=function(e){var n=$(e.currentTarget),i=n.index();n.hasClass(t.BusinessPackCss.bpStateDisabled)||this.activeTabIndex!==i&&(this.binding.dataSource?this.activeTabKey=this.getItemKey(ko.dataFor(e.currentTarget)):this.activeTabKey=this.getTabKeyByIndex(i),this.postback(this.binding.activeTabChanged))},n.prototype.onActiveTabKeyChange=function(t){if(this.activeTabIndex=0,this.binding.dataSource){var e=this.findItemByKey(t);e&&(this.activeTabIndex=this.items().indexOf(e),this.updateTabIsActiveBinding())}else for(var n=this.binding.tabs,i=0;i<n.length;i++)if(this.getTabKeyByIndex(i)===t){this.activeTabIndex=i;break}this.updateActiveCssClass()},n.prototype.onDataSourceChange=function(){for(var e=this.binding.tabIsActiveBinding,n=0,i=this.items();n<i.length;n++){var s=i[n];if(t.Utils.getUnwrappedBindingValue(s,e)){this.activeTabKey=this.getItemKey(s),this.activeTabIndex=this.items().indexOf(s);break}}},n.prototype.updateTabIsActiveBinding=function(){for(var e=this.binding.tabIsActiveBinding,n=this.binding.activeTabKey(),i=0,s=this.getAllItems();i<s.length;i++){var o=s[i],r=t.Utils.getBindingValue(o,e);ko.isWriteableObservable(r)&&r(this.getItemKey(o)===n)}},n.prototype.updateActiveCssClass=function(){var e=$(this.$headers.children()[this.activeTabIndex]),n=$(this.$container.children()[this.activeTabIndex]);this.$headers.children().removeClass(t.BusinessPackCss.bpStateActive),this.$container.children().removeClass(t.BusinessPackCss.bpStateActive),e.addClass(t.BusinessPackCss.bpStateActive),n.addClass(t.BusinessPackCss.bpStateActive)},n.prototype.getTabKeyByIndex=function(t){return this.binding.tabs[t].Key||this.generateTabKey(t)},n.prototype.generateTabKey=function(t){return"Tab"+t},n.prototype.getItemKeyBinding=function(){return this.binding.tabKeyBinding},n}(e.ItemsControlBase);e.TabControl=n,t.Utils.installBindingHandler("TabControl",n)}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return __extends(n,e),n.prototype.initialize=function(){e.prototype.initialize.call(this),this.$element.focus(this.onElementFocus.bind(this)),this.$element.blur(this.onElementBlur.bind(this)),this.$element.change(this.onElementChange.bind(this))},n.prototype.onElementFocus=function(){this.$element.addClass(t.BusinessPackCss.bpStateFocused)},n.prototype.onElementBlur=function(){this.$element.removeClass(t.BusinessPackCss.bpStateFocused)},n.prototype.onElementChange=function(t){this.isEnabled&&this.postback(this.binding.changed)},n}(e.ControlBase);e.TextBox=n,t.Utils.installBindingHandler("TextBox",n)}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return __extends(n,e),n.prototype.initialize=function(){e.prototype.initialize.call(this),this.subscribe(this.binding.text,this.onTextChanged)},n.prototype.onTextChanged=function(t){var e=this.generateHtml(t);this.$element.html(e)},n.prototype.generateHtml=function(t){if(!t)return"";var e=t.trim();return e=this.generateHtmlLinks(e),e=this.generateHtmlParagraphs(e),e=this.generateHtmlLineBreaks(e)},n.prototype.generateHtmlLinks=function(e){for(var n="",i=t.RegexUtils.urlOrEmail("i"),s=ko.unwrap(this.binding.hyperlinkTarget),o=s||0!==s.length,r=0,a=e.split(i);r<a.length;r++){var l=a[r];null!=i.exec(l)?l.startsWith("http")?n+=o?'<a rel="nofollow" href="'+l+'" target="'+s+'">'+l+"</a>":'<a rel="nofollow" href="'+l+'">'+l+"</a>":l.startsWith("www")?n+=o?'<a rel="nofollow" href="http://'+l+'" target="'+s+'">'+l+"</a>":'<a rel="nofollow" href="http://'+l+'">'+l+"</a>":l.startsWith("@")?n+=t.Utils.htmlEncode(l):n+='<a href="mailto:'+l+'">'+l+"</a>":n+=t.Utils.htmlEncode(l)}return n},n.prototype.generateHtmlParagraphs=function(e){var n=t.RegexUtils.twoLineBreaks("gi"),i=e.split(n);if(i.length>1){for(var s="",o=0,r=i;o<r.length;o++)s+="<p>"+r[o]+"</p>";return s}return e},n.prototype.generateHtmlLineBreaks=function(e){return e.replace(t.RegexUtils.lineBreak("gi"),"<br>")},n}(e.ControlBase);e.TextView=n,t.Utils.installBindingHandler("TextView",n)}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));var DotVVM;!function(t){!function(t){!function(e){"use strict";var n=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.focusedItemKey=ko.observable(),t.expandedItemsKeys=ko.observableArray(),t.selectedItemsKeys=ko.observableArray(),t.loadingItemsKeys=ko.observableArray(),t}return __extends(n,e),Object.defineProperty(n.prototype,"hasValue",{get:function(){return!!this.binding.selectedValues&&!!this.binding.selectedValues().length},enumerable:!0,configurable:!0}),n.prototype.initialize=function(){e.prototype.initialize.call(this),this.$element.focusin(this.onElementFocusin.bind(this)),this.$element.focusout(this.onElementFocusout.bind(this)),this.$element.keydown(this.onElementKeydown.bind(this)),this.$element.on("click","."+t.BusinessPackCss.bpExpand,this.onExpandClick.bind(this)),this.$element.on("click","."+t.BusinessPackCss.bpCollapse,this.onCollapseClick.bind(this)),this.$element.on("mousedown","."+t.BusinessPackCss.bpToggle,function(t){return t.preventDefault()}),this.$element.on("change","."+t.BusinessPackCss.bpToggle,this.onCheckBoxChange.bind(this)),this.$element.on("mousedown","."+t.BusinessPackCss.bpItem+" > label",this.onLabelMousedown.bind(this)),this.$element.on("click","."+t.BusinessPackCss.bpItem+" > label",this.onLabelClick.bind(this)),this.$element.on("dblclick","."+t.BusinessPackCss.bpItem+" > label",this.onLabelDblClick.bind(this)),this.binding.selectedValues?this.watch(this.binding.selectedValues,this.onSelectedValuesChange):this.$element.addClass(t.BusinessPackCss.bpStateEmptyValue)},n.prototype.expandPathToItem=function(t){ko.isObservable(t)||(t=this.findItemByKey(this.getItemKey(t)));for(var e=t.$parent;e;)this.expandItem(e),e=e.$parent},n.prototype.expandItem=function(t){var e=this;if(!this.isExpanded(t)&&!this.isParentLoading(t)){var n=this.getItemKey(t);this.focusItem(t),this.expandedItemsKeys.push(n),this.canLoadChildren(t)&&(this.loadingItemsKeys.push(n),this.binding.loadChildren(t).done(function(i){e.populateItem(t,i),e.loadingItemsKeys.remove(n)}))}},n.prototype.collapseItem=function(t){this.isExpanded(t)&&(this.expandedItemsKeys.remove(this.getItemKey(t)),this.focusItem(t))},n.prototype.isExpanded=function(t){var e=this.getItemKey(t);return this.expandedItemsKeys().asLinq().contains(e)},n.prototype.isLoading=function(t){var e=this.getItemKey(t);return!!this.loadingItemsKeys().asLinq().contains(e)||!!this.isParentLoading(t)&&this.hasChildren(t)},n.prototype.isParentLoading=function(t){var e=this.getParent(t);if(e){var n=this.getItemKey(e);if(this.loadingItemsKeys().asLinq().contains(n))return!0}return!1},n.prototype.focusItem=function(t){this.focusedItemKey(this.getItemKey(t))},n.prototype.isFocused=function(t){return this.getItemKey(t)===this.focusedItemKey()},n.prototype.getFocusedItem=function(){return this.findItemByKey(this.focusedItemKey)},n.prototype.toggleItem=function(t){var e=this.binding.checkBoxMode;this.isSelected(t)&&this.canBeChecked(t)?this.unselectItem(t):this.selectItem(t,"Hidden"===e)},n.prototype.selectItems=function(e,n){var i=this;if(this.binding.selectedValues){if(n){s=e.map(function(t){return ko.observable(i.getItemValueCopy(t))});this.binding.selectedValues(s)}else{for(var s=[],o=0,r=e;o<r.length;o++){var a=r[o];this.canBeSelected(a)&&s.push(ko.observable(this.getItemValueCopy(a)))}t.Utils.pushAll(this.binding.selectedValues,s)}this.postback(this.binding.changed)}},n.prototype.selectItem=function(t,e){if(this.binding.selectedValues&&t){var n=ko.observable(this.getItemValueCopy(t));e&&this.areOtherItemsSelected([t])?(this.binding.selectedValues([n]),this.postback(this.binding.changed)):this.canBeSelected(t)&&(this.binding.selectedValues.push(n),this.postback(this.binding.changed))}},n.prototype.unselectItems=function(t){var e=this;this.binding.selectedValues&&(this.binding.selectedValues.remove(function(n){return t.asLinq().any(function(t){return e.isValueOfItem(n,t)})}),this.postback(this.binding.changed))},n.prototype.unselectItem=function(t){var e=this;this.binding.selectedValues&&t&&this.isSelected(t)&&(this.binding.selectedValues.remove(function(n){return e.isValueOfItem(n,t)}),this.postback(this.binding.changed))},n.prototype.canBeSelected=function(t){var e=this.binding.checkBoxMode,n=!this.isSelected(t);return n&&"Hidden"===e&&(n=0===this.selectedItemsKeys().length),n&&"VisibleOnLeafs"===e&&(n=!this.hasChildren(t)),n},n.prototype.isSelected=function(t){var e=this.getItemKey(t);return this.selectedItemsKeys().asLinq().contains(e)},n.prototype.hasChildren=function(n){var i=this.binding.itemHasChildrenBinding;return i?t.Utils.getUnwrappedBindingValue(n,i):e.prototype.hasChildren.call(this,n)},n.prototype.onElementFocusin=function(e){this.$element.addClass(t.BusinessPackCss.bpStateFocused)},n.prototype.onElementFocusout=function(e){this.$element.removeClass(t.BusinessPackCss.bpStateFocused)},n.prototype.onElementKeydown=function(e){e.which===t.KeyboardKeys.left?(e.stopPropagationAndPreventDefault(),this.collapseFocusedItemOrFocusOnParentItem()):e.which===t.KeyboardKeys.right?(e.stopPropagationAndPreventDefault(),this.expandFocusedItemOrFocusOnChildItem()):e.which===t.KeyboardKeys.down?(e.stopPropagationAndPreventDefault(),this.focusNextItem()):e.which===t.KeyboardKeys.up?(e.stopPropagationAndPreventDefault(),this.focusPrevItem()):e.which===t.KeyboardKeys.spacebar&&(e.stopPropagation(),this.toggleFocusedItem())},n.prototype.onExpandClick=function(e){e.stopPropagation(),this.scrollToItem($(e.target).closest("."+t.BusinessPackCss.bpItem)),this.expandItem(ko.dataFor(e.target))},n.prototype.onCollapseClick=function(e){e.stopPropagation(),this.scrollToItem($(e.target).closest("."+t.BusinessPackCss.bpItem)),this.collapseItem(ko.dataFor(e.target))},n.prototype.onCheckBoxChange=function(t){var e=$(t.target),n=ko.dataFor(t.target);if(t.stopPropagation(),this.focusItem(n),e.prop("checked"))if(this.binding.autoCheckChildren){i=this.getRelatedItemsToCheck(n);this.selectItems(i)}else this.selectItem(n);else if(this.binding.autoCheckChildren){var i=this.getRelatedItemsToCheck(n);this.unselectItems(i)}else this.unselectItem(n)},n.prototype.getRelatedItemsToCheck=function(e){var n=[e];return t.Utils.pushAll(n,this.getParentsToCheck(e)),t.Utils.pushAll(n,this.getDescendantsToCheck(e)),n},n.prototype.getParentsToCheck=function(e){var n=[],i=this.getParent(e);return i&&this.areAllOtherChildrenSelected(i,e)&&(n.push(i()),t.Utils.pushAll(n,this.getParentsToCheck(i))),n},n.prototype.getDescendantsToCheck=function(e){for(var n=[],i=0,s=this.getChildren(e);i<s.length;i++){var o=s[i];n.push(o()),t.Utils.pushAll(n,this.getDescendantsToCheck(o))}return n},n.prototype.onLabelMousedown=function(e){this.scrollToItem($(e.target).closest("."+t.BusinessPackCss.bpItem)),this.focusItem(ko.dataFor(e.currentTarget))},n.prototype.onLabelClick=function(t){var e=ko.dataFor(t.currentTarget),n=this.binding,i=n.selectedValues,s=n.checkBoxMode;i?"Hidden"===s&&(this.selectItem(e,!0),this.focusItem(e)):this.isExpanded(e)?this.collapseItem(e):this.expandItem(e)},n.prototype.onLabelDblClick=function(t){var e=this.binding,n=e.selectedValues,i=e.checkBoxMode;if(n&&"Hidden"===i){var s=ko.dataFor(t.currentTarget);this.isExpanded(s)?this.collapseItem(s):this.expandItem(s)}},n.prototype.onDataSourceChange=function(){e.prototype.onDataSourceChange.call(this),this.findItemByKey(this.focusedItemKey)||this.focusOnFirstItem()},n.prototype.onSelectedValuesChange=function(e){t.Utils.clearObservableArray(this.selectedItemsKeys),this.$element.toggleClass(t.BusinessPackCss.bpStateEmptyValue,0===e.length);for(var n=0,i=e;n<i.length;n++){var s=i[n],o=this.findItemByValue(s);o?(this.selectedItemsKeys.push(this.getItemKey(o)),this.expandPathToItem(o)):this.warnThatValueWasNotFound(s)}},n.prototype.expandFocusedItemOrFocusOnChildItem=function(){this.$element.children("."+t.BusinessPackCss.bpList).find("."+t.BusinessPackCss.bpItem+"."+t.BusinessPackCss.bpStateFocused).hasClass(t.BusinessPackCss.bpStateExpanded)?this.focusOnChildItem():this.expandFocusedItem()},n.prototype.expandFocusedItem=function(){this.expandItem(this.getFocusedItem())},n.prototype.collapseFocusedItemOrFocusOnParentItem=function(){this.$element.children("."+t.BusinessPackCss.bpList).find("."+t.BusinessPackCss.bpItem+"."+t.BusinessPackCss.bpStateFocused).hasClass(t.BusinessPackCss.bpStateExpanded)?this.collapseFocusedItem():this.focusOnParentItem()},n.prototype.collapseFocusedItem=function(){this.collapseItem(this.getFocusedItem())},n.prototype.focusOnParentItem=function(){var e=this.$element.children("."+t.BusinessPackCss.bpList).find("."+t.BusinessPackCss.bpItem+"."+t.BusinessPackCss.bpStateFocused).parents("."+t.BusinessPackCss.bpItem);e.length&&(this.scrollToItem($(e[0])),this.focusItem(ko.dataFor(e[0])))},n.prototype.focusPrevItem=function(){var e=this.$element.children("."+t.BusinessPackCss.bpList).find("."+t.BusinessPackCss.bpItem+"."+t.BusinessPackCss.bpStateFocused),n=this.findPrevVisibleItem(e);n&&(this.scrollToItem($(n)),this.focusItem(ko.dataFor(n)))},n.prototype.focusNextItem=function(){var e=this.$element.children("."+t.BusinessPackCss.bpList).find("."+t.BusinessPackCss.bpItem+"."+t.BusinessPackCss.bpStateFocused),n=this.findNextVisibleItem(e);n&&(this.scrollToItem($(n)),this.focusItem(ko.dataFor(n)))},n.prototype.focusOnChildItem=function(){var e=this.$element.children("."+t.BusinessPackCss.bpList).find("."+t.BusinessPackCss.bpItem+"."+t.BusinessPackCss.bpStateFocused).children("."+t.BusinessPackCss.bpList).children("."+t.BusinessPackCss.bpItem);e.length&&(this.scrollToItem($(e[0])),this.focusItem(ko.dataFor(e[0])))},n.prototype.focusOnFirstItem=function(){var t=this.items();t.length&&this.focusItem(t[0])},n.prototype.toggleFocusedItem=function(){this.toggleItem(this.getFocusedItem())},n.prototype.canBeChecked=function(t){var e=this.binding.checkBoxMode;return"Visible"===e||"VisibleOnLeafs"===e&&!this.hasChildren(t)},n.prototype.areOtherItemsSelected=function(t){var e=this,n=t.map(function(t){return e.getItemKey(t)});return this.selectedItemsKeys().asLinq().except(n).any()},n.prototype.findPrevVisibleItem=function(e){var n=e.prev("."+t.BusinessPackCss.bpItem).find("."+t.BusinessPackCss.bpItem+":visible:last");return n.length||(n=e.prev("."+t.BusinessPackCss.bpItem)),n.length||(n=e.parents("."+t.BusinessPackCss.bpItem)),n.length?n[0]:null},n.prototype.findNextVisibleItem=function(e){if(e.hasClass(t.BusinessPackCss.bpStateExpanded))return e.children("."+t.BusinessPackCss.bpList).children("."+t.BusinessPackCss.bpItem)[0];var n=e.next("."+t.BusinessPackCss.bpItem);return n.length||(n=e.parents("."+t.BusinessPackCss.bpItem).next()),n.length?n[0]:null},n.prototype.areAllOtherChildrenSelected=function(t,e){for(var n=0,i=this.getChildren(t);n<i.length;n++){var s=i[n];if(this.getItemKey(s)!==this.getItemKey(e)&&!this.isSelected(s))return!1}return!0},n.prototype.isAnyDescendantSelected=function(t){for(var e=0,n=this.getChildren(t);e<n.length;e++){var i=n[e];if(this.isSelected(i)||this.isAnyDescendantSelected(i))return!0}return!1},n.prototype.canLoadChildren=function(t){return!!this.binding.loadChildren&&this.shouldLoadChildren(t)},n.prototype.populateItem=function(e,n){var i=this.binding.itemChildrenBinding;if(i){var s=t.Utils.getBindingValue(e,i);if(ko.isWriteableObservable(s)&&(s(t.Utils.deepObservable(n)()),this.isSelected(e)&&this.binding.autoCheckChildren)){var o=this.getDescendantsToCheck(e);this.selectItems(o)}}},n.prototype.scrollToItem=function(e){var n=this.$element.children("."+t.BusinessPackCss.bpList),i=(this.getParentTop(n,e),n.innerHeight()),s=parseInt(n.css("padding-top")),o=parseInt(n.css("padding-bottom")),r=parseInt(e.css("margin-top")),a=parseInt(e.css("margin-bottom")),l=e.parent().is(n)&&e.is(":first-child")?s:r,u=e.parent().is(n)&&e.is(":last-child")?o:a,c=e.position().top,h=c+e.outerHeight(!0),p=n.scrollTop();h>i?n.scrollTop(p+(h-i)+u):c<0&&n.scrollTop(p+c-l)},n.prototype.getParentTop=function(t,e){for(var n=e.parent(),i=0;!n.is(t);)i+=n.position().top,n=n.parent();return i},n.prototype.getItemKeyBinding=function(){return this.binding.itemKeyBinding||this.getItemValueBinding()},n.prototype.getItemValueBinding=function(){return this.binding.itemValueBinding},n.prototype.getCheckState=function(t){return!!this.isSelected(t)||!(!this.binding.autoCheckChildren||!this.isAnyDescendantSelected(t))&&null},n.prototype.getItemStyle=function(e){return n={},n[t.BusinessPackCss.bpExpandable]=this.hasChildren(e),n[t.BusinessPackCss.bpStateExpanded]=this.isExpanded(e),n[t.BusinessPackCss.bpStateLoading]=this.isLoading(e),n[t.BusinessPackCss.bpStateFocused]=this.isFocused(e),n[t.BusinessPackCss.bpStateSelected]=this.isSelected(e),n;var n},n.prototype.getLabelStyle=function(e){var n=this.getCheckState(e);return i={},i[t.BusinessPackCss.bpStateChecked]=n,i[t.BusinessPackCss.bpStateIndeterminate]=null===n,i;var i},n}(e.HierarchyItemsControlBase);e.TreeView=n,t.Utils.installBindingHandler("TreeView",n)}(t.Controls||(t.Controls={}))}(t.BusinessPack||(t.BusinessPack={}))}(DotVVM||(DotVVM={}));