pacem 0.53.0-stevin → 0.53.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/css/pacem-dark-content.min.css +1 -1
- package/dist/css/pacem-dark-shell.min.css +1 -1
- package/dist/css/pacem-dark.min.css +1 -1
- package/dist/css/pacem-light-content.min.css +1 -1
- package/dist/css/pacem-light-shell.min.css +1 -1
- package/dist/css/pacem-light.min.css +1 -1
- package/dist/css/pacem-phousys-content.min.css +1 -1
- package/dist/css/pacem-phousys-shell.min.css +1 -1
- package/dist/css/pacem-phousys.min.css +1 -1
- package/dist/js/azure-maps.d.ts +1 -1
- package/dist/js/pacem-2d.d.ts +1 -1
- package/dist/js/pacem-2d.js +2 -1
- package/dist/js/pacem-2d.min.js +2 -2
- package/dist/js/pacem-3d.d.ts +29 -1
- package/dist/js/pacem-3d.js +58 -24
- package/dist/js/pacem-3d.min.js +2 -2
- package/dist/js/pacem-charts.d.ts +1 -1
- package/dist/js/pacem-charts.js +2 -1
- package/dist/js/pacem-charts.min.js +2 -2
- package/dist/js/pacem-cms.d.ts +1 -1
- package/dist/js/pacem-cms.js +2 -1
- package/dist/js/pacem-cms.min.js +2 -2
- package/dist/js/pacem-core.d.ts +1 -1
- package/dist/js/pacem-core.js +2 -1
- package/dist/js/pacem-core.min.js +2 -2
- package/dist/js/pacem-foundation.d.ts +1 -1
- package/dist/js/pacem-foundation.js +2 -1
- package/dist/js/pacem-foundation.min.js +2 -2
- package/dist/js/pacem-fx.d.ts +1 -1
- package/dist/js/pacem-fx.js +2 -1
- package/dist/js/pacem-fx.min.js +2 -2
- package/dist/js/pacem-logging.d.ts +1 -1
- package/dist/js/pacem-logging.js +2 -1
- package/dist/js/pacem-logging.min.js +2 -2
- package/dist/js/pacem-maps.d.ts +1 -1
- package/dist/js/pacem-maps.js +2 -1
- package/dist/js/pacem-maps.min.js +2 -2
- package/dist/js/pacem-media.d.ts +1 -1
- package/dist/js/pacem-media.js +2 -1
- package/dist/js/pacem-media.min.js +2 -2
- package/dist/js/pacem-networking.d.ts +1 -1
- package/dist/js/pacem-networking.js +2 -1
- package/dist/js/pacem-networking.min.js +2 -2
- package/dist/js/pacem-numerical.d.ts +1 -1
- package/dist/js/pacem-numerical.js +2 -1
- package/dist/js/pacem-numerical.min.js +2 -2
- package/dist/js/pacem-plus.d.ts +1 -1
- package/dist/js/pacem-plus.js +2 -1
- package/dist/js/pacem-plus.min.js +2 -2
- package/dist/js/pacem-scaffolding.d.ts +1 -1
- package/dist/js/pacem-scaffolding.js +11 -1
- package/dist/js/pacem-scaffolding.min.js +2 -2
- package/dist/js/pacem-ui.d.ts +1 -1
- package/dist/js/pacem-ui.js +2 -1
- package/dist/js/pacem-ui.min.js +2 -2
- package/dist/js/swagger-types.d.ts +1 -1
- package/package.json +8 -9
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* pacem v0.53.0
|
|
2
|
+
* pacem v0.53.0 (https://js.pacem.it)
|
|
3
3
|
* Copyright 2026 Pacem (https://pacem.it)
|
|
4
4
|
* Licensed under Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
var Pacem,__decorate=this&&this.__decorate||function(e,t,a,i){var n,s=arguments.length,r=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,a):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,a,i);else for(var o=e.length-1;o>=0;o--)(n=e[o])&&(r=(s<3?n(r):s>3?n(t,a,r):n(t,a))||r);return s>3&&r&&Object.defineProperty(t,a,r),r};!function(e){!function(t){t.FieldChangeEventName="change";class FieldChangeEvent extends e.CustomTypedEvent{constructor(e){super(t.FieldChangeEventName,e,{bubbles:!0,cancelable:!1})}}t.FieldChangeEvent=FieldChangeEvent}(e.Scaffolding||(e.Scaffolding={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(a){const i="pacem:model:original-value";class PacemFormRelevantElement extends t.PacemElement{viewActivatedCallback(){super.viewActivatedCallback(),this.form=e.CustomElementUtils.findAncestorOfType(this,a.PacemFormElement)}}__decorate([e.Watch({converter:e.PropertyConverters.Element})],PacemFormRelevantElement.prototype,"form",void 0),a.PacemFormRelevantElement=PacemFormRelevantElement;class PacemModelElement extends PacemFormRelevantElement{viewActivatedCallback(){super.viewActivatedCallback(),this._registerFieldConditionally(),this._setAsOriginalValue(this.value)}_registerFieldConditionally(){const t=this.name,a=this.form;if(!(e.Utils.isNullOrEmpty(t)||e.Utils.isNull(a)||this.hasAttribute("autobind")&&("off"===this.getAttribute("autobind")||"false"===this.getAttribute("autobind"))||(a.registerField(t,this),this.hasAttribute("value")))){const i=a.id=a.id||"frm_"+e.Utils.uniqueCode();this.setAttribute("value",`{{ #${i}.entity.${t}, twoway }}`)}}propertyChangedCallback(t,a,i,n){switch(super.propertyChangedCallback(t,a,i,n),t){case"value":this.viewValue=this.getViewValue(i);break;case"valid":i?e.Utils.removeClass(this,e.PCSS+"-invalid"):e.Utils.addClass(this,e.PCSS+"-invalid");break;case"dirty":i?e.Utils.addClass(this,e.PCSS+"-dirty"):e.Utils.removeClass(this,e.PCSS+"-dirty");break;case"name":let t=this.form;null!=t&&a&&t.unregisterField(a),this._registerFieldConditionally();break;case"form":let n=this.name;e.Utils.isNullOrEmpty(n)||null!=a&&a.unregisterField(n),this._registerFieldConditionally()}}disconnectedCallback(){let t=this.name,a=this.form;e.Utils.isNullOrEmpty(t)||e.Utils.isNull(a)||a.unregisterField(t),super.disconnectedCallback()}get originalValue(){return e.CustomElementUtils.getAttachedPropertyValue(this,i)}_setAsOriginalValue(t){e.CustomElementUtils.setAttachedPropertyValue(this,i,t)}reset(){this.value=this.originalValue,this.dirty=!1}setPristine(){this._setAsOriginalValue(this.value),this.dirty=!1}setDirty(){this.dirty=!0}}__decorate([e.Watch({converter:e.PropertyConverters.String})],PacemModelElement.prototype,"viewValue",void 0),__decorate([e.Watch({converter:{convert:(e,t)=>t instanceof PacemModelElement?t.convertValueAttributeToProperty(e):e,convertBack:e=>e.toString()}})],PacemModelElement.prototype,"value",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Boolean})],PacemModelElement.prototype,"dirty",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Boolean})],PacemModelElement.prototype,"valid",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],PacemModelElement.prototype,"name",void 0),a.PacemModelElement=PacemModelElement;class PacemBaseElement extends PacemModelElement{constructor(){super(...arguments),this.focusHandler=t=>{const a=(t=!0)=>{e.Utils.hasClass(this.parentElement,"."+e.PCSS+"-fieldgroup")&&(t?e.Utils.addClass:e.Utils.removeClass).apply(this,[this.parentElement,e.PCSS+"-focus"])};switch(t.type){case"focus":e.Utils.addClass(this,e.PCSS+"-focus"),a(),this._preFocusValue=this.value;break;case"blur":e.Utils.removeClass(this,e.PCSS+"-focus"),a(!1)}t.bubbles?this.emit(t):this.dispatchEvent(new FocusEvent(t.type))},this.changeHandler=t=>{const a=this.value;this.onChange(t).then(t=>{this.compareValuePropertyValues(a,t)||(this.dispatchEvent(new e.Scaffolding.FieldChangeEvent({fieldName:this.name,oldValue:a,currentValue:t,firstChange:!this.dirty})),this.dirty=!0)},e=>{})},this.keydownHandler=t=>{e.stopPropagationHandler(t)},this.keyupHandler=t=>{switch(t.keyCode){case 27:e.stopPropagationHandler(t),this.compareValuePropertyValues(this.originalValue,this._preFocusValue)?this.reset():this.value=this._preFocusValue,this.blur();break;case 13:this.preventKeyboardSubmit&&e.stopPropagationHandler(t)}}}compareValuePropertyValues(t,a){return e.DefaultComparer(t,a)}get preventKeyboardSubmit(){return!1}propertyChangedCallback(t,a,i,n){switch(super.propertyChangedCallback(t,a,i,n),t){case"required":case"disabled":case"autofocus":case"placeholder":case"readonly":for(let e of this.inputFields)i?e.setAttribute(t,i):e.removeAttribute(t);break;case"tabOrder":for(let e of this.inputFields)e.setAttribute("tabindex",i);break;case"value":this.acceptValue(i)}if("required"===t||"disabled"===t||"readonly"===t){let a=`${e.PCSS}-${t}`;i?e.Utils.addClass(this,a):e.Utils.removeClass(this,a)}"readonly"===t?this.toggleReadonlyView(i):"required"===t?this.aria.attributes.set("required",!!i+""):"valid"===t&&this.aria.attributes.set("invalid",(!i&&!!this.dirty)+"")}registerInputFields(t=this.inputFields){e.Utils.isNull(t)||e.Utils.isArray(t)||(t=[t]);for(let a of t)a.addEventListener("focus",this.focusHandler,!1),a.addEventListener("blur",this.focusHandler,!1),a.addEventListener("change",this.changeHandler,!1),a.addEventListener("keydown",this.keydownHandler,!1),a.addEventListener("keyup",this.keyupHandler,!1),a.addEventListener("mousedown",e.stopPropagationHandler,!1),a.addEventListener("touchstart",e.stopPropagationHandler,{passive:!1,capture:!1})}unregisterInputFields(t=this.inputFields){e.Utils.isNull(t)||e.Utils.isArray(t)||(t=[t]);for(let a of t)e.Utils.isNull(a)||(a.removeEventListener("touchstart",e.stopPropagationHandler,{capture:!1}),a.removeEventListener("keydown",this.keydownHandler,!1),a.removeEventListener("keyup",this.keyupHandler,!1),a.removeEventListener("mousedown",e.stopPropagationHandler,!1),a.removeEventListener("change",this.changeHandler,!1),a.removeEventListener("focus",this.focusHandler,!1),a.removeEventListener("blur",this.focusHandler,!1))}viewActivatedCallback(){if(super.viewActivatedCallback(),this.toggleReadonlyView(this.readonly||!1),!e.Utils.isNullOrEmpty(this.id)){const e=document.querySelector(`label[for=${this.id}]`);e?e.id?this.aria.attributes.set("labelledby",e.id):this.aria.attributes.set("label",e.textContent):(this.aria.attributes.remove("labelledby"),this.aria.attributes.remove("label"))}this.registerInputFields()}disconnectedCallback(){this.unregisterInputFields(),super.disconnectedCallback()}focus(){const e=this.inputFields;e&&e.length&&e[0].focus()}blur(){const t=this.inputFields;if(!e.Utils.isNullOrEmpty(t))for(let e of t)e.blur()}}__decorate([e.Watch({converter:e.PropertyConverters.Boolean})],PacemBaseElement.prototype,"required",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Boolean})],PacemBaseElement.prototype,"autofocus",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Boolean})],PacemBaseElement.prototype,"readonly",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],PacemBaseElement.prototype,"name",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],PacemBaseElement.prototype,"placeholder",void 0),a.PacemBaseElement=PacemBaseElement;class PacemItemElement extends t.PacemElement{#e;findContainer(){return e.CustomElementUtils.findAncestor(this,e=>e instanceof PacemItemsContainerBaseElement)}get container(){return this.#e}viewActivatedCallback(){super.viewActivatedCallback();const t=this.#e=this.findContainer();e.Utils.isNull(t)||t.register(this)}disconnectedCallback(){e.Utils.isNull(this.#e)||this.#e.unregister(this),super.disconnectedCallback()}}a.PacemItemElement=PacemItemElement;class PacemItemsContainerBaseElement extends PacemBaseElement{register(t){let a=!0;return e.Utils.isNull(this.items)?this.items=[t]:-1===this.items.indexOf(t)?this.items.push(t):a=!1,a}unregister(t){const a=!e.Utils.isNull(this.items)&&this.items.indexOf(t);return a>=0&&(this.items.splice(a,1)[0],!0)}}__decorate([e.Watch()],PacemItemsContainerBaseElement.prototype,"items",void 0),a.PacemItemsContainerBaseElement=PacemItemsContainerBaseElement;let n=class PacemDataItemElement extends PacemItemElement{};__decorate([e.Watch({converter:{convert:(t,a)=>{if("true"===t)return!0;if("false"===t)return!1;let i=parseFloat(t);if(!isNaN(i))return i;let n=e.Utils.Dates.parse(t);return e.Utils.Dates.isDate(n)?n:t},convertBack:e=>e.toString()}})],n.prototype,"value",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],n.prototype,"label",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Boolean})],n.prototype,"disabled",void 0),n=__decorate([e.CustomElement({tagName:e.P+"-data-item"})],n),a.PacemDataItemElement=n;class PacemDataSourceElement extends PacemItemsContainerBaseElement{constructor(e=!1){super(),this.multipleChoice=e,this._itemPropertyChangedHandler=e=>{this.databind()}}register(t){const a=super.register(t);return a&&t.addEventListener(e.PropertyChangeEventName,this._itemPropertyChangedHandler,!1),a}unregister(t){const a=super.register(t);return a&&t.removeEventListener(e.PropertyChangeEventName,this._itemPropertyChangedHandler,!1),a}buildAdaptedDatasource(e=this.datasource){return e&&e.map(e=>this.mapEntityToItem(e))}databind(t=this.buildAdaptedDatasource(this.datasource)){if(e.Utils.isNull(t)&&e.Utils.isNull(this.adaptedDatasource))return;const a=this.adaptedDatasource=t||[];e.Utils.isNullOrEmpty(a.filter(e=>this.isDataSourceItemSelected(e)))&&this.handleDatasourceMismatch(a)}handleDatasourceMismatch(e){this.value=void 0}isItemSelected(t,a=this.value){if(e.Utils.isNullOrEmpty(a))return!1;const i=this.mapEntityToValue(t),n=this.compareBy;return this.multipleChoice&&e.Utils.isArray(a)?!e.Utils.isNull(a.find(t=>t==i||"object"==typeof t&&!e.Utils.isNullOrEmpty(n)&&n in i&&n in t&&i[n]==t[n])):!this.multipleChoice&&(a==i||"object"==typeof a&&!e.Utils.isNullOrEmpty(n)&&n in i&&n in a&&i[n]==a[n])}isDataSourceItemSelected(t,a=this.value){if(e.Utils.isNullOrEmpty(a))return!1;if(t.disabled)return!1;const i=this.compareBy;if(this.multipleChoice&&e.Utils.isArray(a)){let n=a.find(a=>a==t.value||"object"==typeof a&&!e.Utils.isNullOrEmpty(i)&&i in a&&!e.Utils.isNullOrEmpty(t.value)&&i in t.value&&a[i]==t.value[i]);return!e.Utils.isNull(n)}return!this.multipleChoice&&!e.Utils.isNullOrEmpty(t.value)&&(a==t.value||"object"==typeof a&&!e.Utils.isNullOrEmpty(i)&&i in a&&!e.Utils.isNullOrEmpty(t.value)&&i in t.value&&a[i]==t.value[i])}mapEntityToValue(e){if(null==e)throw"entity cannot be null";if(e instanceof n)return e.value;let t,a=e;return(t=this.valueProperty)&&(a=e[t]),a}mapEntityToViewValue(e){if(null==e)throw"entity cannot be null";if(e instanceof n)return e.label||e.value;let t,a=e.toString();return(t=this.textProperty)&&(a=e[t]),a}mapEntityToItem(t){if(null==t)throw"entity cannot be null";if(t instanceof n)return{value:t.value,viewValue:t.label||t.value,disabled:t.disabled,data:t};let a=!1;const i=this.disabledProperty;return e.Utils.isNullOrEmpty(i)||(a=t[i]||!1),{value:this.mapEntityToValue(t),viewValue:this.mapEntityToViewValue(t),disabled:a,data:t}}propertyChangedCallback(e,t,a,i){switch(super.propertyChangedCallback(e,t,a,i),e){case"datasource":case"textProperty":case"disabledProperty":case"valueProperty":cancelAnimationFrame(this._handle),this._handle=requestAnimationFrame(()=>{this.databind(),this.viewValue=this.getViewValue(this.value)});break;case"items":cancelAnimationFrame(this._handleItems),this._handleItems=requestAnimationFrame(()=>{this.datasource=this.items})}}getViewValue(t){if(!e.Utils.isNullOrEmpty(this.datasource))return this.datasource.filter(e=>this.isItemSelected(e)).map(e=>this.mapEntityToViewValue(e)).join(", ")}convertValueAttributeToProperty(e){return this.multipleChoice?e.split(",").map(e=>e.trim()):e}compareValuePropertyValues(t,a){return e.DefaultComparer(t,a)}}__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Json})],PacemDataSourceElement.prototype,"datasource",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String})],PacemDataSourceElement.prototype,"valueProperty",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String})],PacemDataSourceElement.prototype,"textProperty",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String})],PacemDataSourceElement.prototype,"disabledProperty",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String})],PacemDataSourceElement.prototype,"compareBy",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Json})],PacemDataSourceElement.prototype,"adaptedDatasource",void 0),__decorate([e.Debounce(!0)],PacemDataSourceElement.prototype,"databind",null),a.PacemDataSourceElement=PacemDataSourceElement}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(a){const i={convert:(t,a)=>/\{.+\}/.test(t)?e.PropertyConverters.Json.convert(t):e.PropertyConverters.String.convert(t),convertBack:(t,a)=>"string"==typeof t?t:e.PropertyConverters.Json.convertBack(t,a)};let n=class PacemCalendarMonthPickerElement extends t.PacemElement{propertyChangedCallback(t,a,i,n){if(super.propertyChangedCallback(t,a,i,n),"viewYear"===t)this.dispatchEvent(new CustomEvent("viewyearchange",{detail:new Date(i,0,1),bubbles:!1,cancelable:!1})),e.Utils.removeClass(this,"viewyear-next viewyear-previous"),requestAnimationFrame(()=>{e.Utils.addClass(this,a>i?"viewyear-previous":"viewyear-next")})}_getMonthLabel(t){const a=(new Date).getFullYear();return new Date(a,t,1).toLocaleString(e.Utils.lang(this),{month:"short"})}_isThisMonth(e,t=this.viewYear){return this._isSelectedMonth(e,new Date,t)}_isSelectedMonth(t,a=this.month,i=this.viewYear){const n=e.Utils.parseDate(a);if(!e.Utils.Dates.isDate(n))return!1;const s=i??(new Date).getFullYear();return n.getMonth()===t&&n.getFullYear()===s}_setMonth(e){const t=this.viewYear,a=new Date(t,e,1);this.month=a,this.dispatchEvent(new CustomEvent("monthselect",{detail:a,bubbles:!1,cancelable:!1}))}};__decorate([e.Watch({converter:e.PropertyConverters.Date})],n.prototype,"month",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Date})],n.prototype,"viewYear",void 0),n=__decorate([e.CustomElement({tagName:e.P+"-calendar-month-picker",shadow:e.Defaults.USE_SHADOW_ROOT,template:`<div class="${e.PCSS}-month-picker">${function(){let t="";for(let a=0;a<12;a++)t+=`<div class="calendar-month month-${a+1}"><${e.P}-span class="month-button text-ellipsed" on-click=":host._setMonth(${a})" css-class="{{ { 'selected-month': :host._isSelectedMonth(${a}, :host.month, :host.viewYear), 'this-month': :host._isThisMonth(${a}, :host.viewYear) } }}" text="{{ :host._getMonthLabel(${a}) }}"></${e.P}-span></div>`;return t}()}</div>`})],n),a.PacemCalendarMonthPickerElement=n;class CalendarDateUnselectEvent extends e.Components.UI.DateSelectEvent{constructor(){super(void 0)}}a.CalendarDateUnselectEvent=CalendarDateUnselectEvent;function s(e){return e-e%10}let r=class PacemCalendarYearPickerElement extends t.PacemElement{propertyChangedCallback(t,a,i,n){if(super.propertyChangedCallback(t,a,i,n),"viewYear"===t)this.dispatchEvent(new CustomEvent("viewyearchange",{detail:new Date(i,0,1),bubbles:!1,cancelable:!1})),e.Utils.removeClass(this,"viewyear-next viewyear-previous"),requestAnimationFrame(()=>{e.Utils.addClass(this,a>i?"viewyear-previous":"viewyear-next")})}_getYearLabel(e,t=this.viewYear){return""+(s(t)+e)}_isThisYear(e,t=this.viewYear){return this._isSelectedYear(e,new Date,t)}_isSelectedYear(t,a=this.year,i=this.viewYear){const n=e.Utils.parseDate(a);if(!e.Utils.Dates.isDate(n))return!1;const r=s(i)+t;return n.getFullYear()===r}_setYear(e){const t=s(this.viewYear),a=new Date(t+e,0,1);this.year=a,this.dispatchEvent(new CustomEvent("yearselect",{detail:a,bubbles:!1,cancelable:!1}))}};__decorate([e.Watch({converter:e.PropertyConverters.Date})],r.prototype,"year",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Date})],r.prototype,"viewYear",void 0),r=__decorate([e.CustomElement({tagName:e.P+"-calendar-year-picker",shadow:e.Defaults.USE_SHADOW_ROOT,template:`<div class="${e.PCSS}-year-picker">${function(){let t="";for(let a=0;a<12;a++)t+=`<div class="calendar-year year-${a+1}"><${e.P}-span class="year-button text-ellipsed" on-click=":host._setYear(${a})" css-class="{{ { 'selected-year': :host._isSelectedYear(${a}, :host.year, :host.viewYear), 'this-year': :host._isThisYear(${a}, :host.viewYear) } }}" text="{{ :host._getYearLabel(${a}, :host.viewYear) }}"></${e.P}-span></div>`;return t}()}</div>`})],r),a.PacemCalendarYearPickerElement=r;let o=class PacemCalendarPickerElement extends a.PacemBaseElement{constructor(){super(...arguments),this.viewmode="calendar",this.#t=!1,this._swipeHandler=e=>{switch(e.detail.direction){case"left":this._next(e);break;case"right":this._prev(e)}},this._clearBtnHandler=t=>{t.preventDefault(),this._viewDate=new Date,this.changeHandler(new e.Components.Scaffolding.CalendarDateUnselectEvent)},this._viewDateChangeHandler=e=>{this._onViewDateChange(e)},this._popCalendarHandler=t=>{if(this.#t)return;this.viewmode="calendar";const a=e.Utils.parseDate(this.value);this._calendar.viewDate=this._monthPicker.month=this._yearPicker.year=e.Utils.Dates.isDate(a)?a:this._calendar.viewDate;const i=e.Utils.offset(this._input),n=this._dropdown;n.style.top=i.top+i.height+"px",n.style.left=i.left+"px",n.hidden=!1,requestAnimationFrame(()=>{e.Utils.addClass(n,"dropdown-in")})},this._hideCalendarHandler=e=>{const t=e.composedPath()||[];t.indexOf(this._input)>=0||t.indexOf(this._dropdown)>=0||this._hideCalendar()}}#t;propertyChangedCallback(e,t,a,i){switch(super.propertyChangedCallback(e,t,a,i),e){case"viewmode":case"_viewDate":this._onViewDateChange(this._viewDate)}}viewActivatedCallback(){super.viewActivatedCallback();const t=this._dropdown=this._proxy.dom[0],a=this._calendar=t.querySelector(e.P+"-calendar"),i=this._monthPicker=t.querySelector(e.P+"-calendar-month-picker"),n=this._yearPicker=t.querySelector(e.P+"-calendar-year-picker");this._monthLabel=t.querySelector(".calendar-month"),this._yearLabel=t.querySelector(".calendar-year"),this._rangeLabel=t.querySelector(".calendar-year-range");const s=this._calendar.now=new Date,r=e.Utils.Dates.parse(this.value),o=e.Utils.Dates.isDate(r)?r:s;a.dayLabelFormatter=t=>e.Utils.parseDate(t).toLocaleString(e.Utils.lang(this),{day:"numeric"}),i.addEventListener("viewyearchange",this._viewDateChangeHandler,!1),n.addEventListener("viewyearchange",this._viewDateChangeHandler,!1),a.addEventListener("viewdatechange",this._viewDateChangeHandler,!1),a.viewDate=o,a.date=r;const l=this._input;l.addEventListener("focus",this._popCalendarHandler,!1),l.addEventListener("mousedown",this._popCalendarHandler,!1),t.addEventListener("mousedown",e.stopPropagationHandler,!1),window.document.body.addEventListener("mousedown",this._hideCalendarHandler,!0),this._clearButton.addEventListener("mousedown",this._clearBtnHandler,!1);const c=new e.Components.PacemSwipeElement;a.behaviors.push(c),i.behaviors.push(c),n.behaviors.push(c),c.addEventListener("swipe",this._swipeHandler,!1);const d=e.CustomElementUtils.findAncestorShell(this);this._swiper=d.appendChild(c)}disconnectedCallback(){const t=this._input;e.Utils.isNull(t)||(this._clearButton.removeEventListener("mousedown",this._clearBtnHandler,!1),t.removeEventListener("focus",this._popCalendarHandler,!1),t.removeEventListener("mousedown",this._popCalendarHandler,!1),this._dropdown.removeEventListener("mousedown",e.stopPropagationHandler,!1),window.document.body.removeEventListener("mousedown",this._hideCalendarHandler,!0),this._calendar.removeEventListener("viewdatechange",this._viewDateChangeHandler,!1),this._monthPicker.removeEventListener("viewyearchange",this._viewDateChangeHandler,!1),this._yearPicker.removeEventListener("viewyearchange",this._viewDateChangeHandler,!1));const a=this._swiper;if(!e.Utils.isNull(a)){const e=this._calendar,t=this._monthPicker,i=this._yearPicker;for(let n of[e,t,i]){const e=n.behaviors.indexOf(a);e>=0&&n.behaviors.splice(e,1)}a.removeEventListener("swipe",this._swipeHandler,!1),a.remove(),this._swiper=null}super.disconnectedCallback()}_getHeaderLabel(t,a=this.viewmode){const i=e.Utils.parseDate(t);return e.Utils.Dates.isDate(i)?i.toLocaleString(e.Utils.lang(this),{weekday:"narrow"}):"..."}_prev(e){let t=-1;switch(this.viewmode){case"month":t=-12;break;case"year":t=-120}this._jumpMonths(t)}_next(e){let t=1;switch(this.viewmode){case"month":t=12;break;case"year":t=120}this._jumpMonths(t)}_jumpMonths(t){const a=e.Utils.parseDate(this._viewDate);this._viewDate=e.Utils.Dates.addMonths(a,t)}_setMonth(e){this._viewDate=e.detail,this.viewmode="calendar"}_setYear(e){this._viewDate=e.detail,this.viewmode="month"}_onViewDateChange(t){if(e.Utils.isNullOrEmpty(t))return;const a=e.Utils.parseDate(this._viewDate);if(e.Utils.Dates.isDate(a)&&!e.Utils.isNull(this._monthLabel))switch(this.viewmode){case"month":this._yearLabel.text=a.toLocaleString(e.Utils.lang(this),{year:"numeric"});break;case"year":const t=s(a.getFullYear());this._rangeLabel.text=`${t} - ${t+12-1}`;break;default:this._monthLabel.text=a.toLocaleString(e.Utils.lang(this),{month:"long",year:"numeric"})}}_hideCalendar(){e.Utils.removeClass(this._dropdown,"dropdown-in"),e.Utils.addAnimationEndCallback(this._dropdown,t=>{this._dropdown.hidden=!0,e.Utils.removeClass(this._dropdown,"dropdown-select")},250)}get inputFields(){return[this._input]}toggleReadonlyView(e){this.isReady&&(this._input.readOnly=!0,this._input.hidden=e,this._span.hide=!e)}onChange(t){return new Promise((a,i)=>{if(e.CustomEventUtils.isInstanceOf(t,e.Components.UI.DateSelectEvent)){e.Utils.addClass(this._dropdown,"dropdown-select");e.CustomEventUtils.isInstanceOf(t,e.Components.Scaffolding.CalendarDateUnselectEvent)&&(this.#t=!0),this.focus(),this.#t=!1,this._hideCalendar(),a(this.value=t.detail)}else a(this.value)})}acceptValue(t){this._input.value=this.viewValue;const a=this._calendar;if(!e.Utils.isNull(a)){const i=e.Utils.parseDate(t);e.Utils.Dates.isDate(i)?a.viewDate=a.date=i:a.date=void 0}}getViewValue(t){const a=e.Utils.Dates.parse(t);return e.Utils.Dates.isDate(a)?e.Utils.core.date(a,this.format||"short",e.Utils.lang(this)):""}compareValuePropertyValues(t,a){const i=e.Utils.parseDate(t),n=e.Utils.parseDate(a);return!(!e.Utils.isNullOrEmpty(i)||!e.Utils.isNullOrEmpty(n))||!e.Utils.isNullOrEmpty(i)&&!e.Utils.isNullOrEmpty(n)&&i.valueOf()==n.valueOf()}convertValueAttributeToProperty(t){return e.PropertyConverters.Datetime.convert(t)}};__decorate([e.ViewChild("input[type=text]")],o.prototype,"_input",void 0),__decorate([e.ViewChild(`.${e.PCSS}-readonly`)],o.prototype,"_span",void 0),__decorate([e.ViewChild(`${e.P}-button[clear]`)],o.prototype,"_clearButton",void 0),__decorate([e.ViewChild(e.P+"-shell-proxy")],o.prototype,"_proxy",void 0),__decorate([e.Watch({emit:!1,converter:i})],o.prototype,"format",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Eval})],o.prototype,"disabledRanges",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],o.prototype,"weekStart",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],o.prototype,"viewmode",void 0),__decorate([e.Watch()],o.prototype,"_week",void 0),__decorate([e.Watch()],o.prototype,"_viewDate",void 0),o=__decorate([e.CustomElement({tagName:e.P+"-calendar-picker",shadow:e.Defaults.USE_SHADOW_ROOT,template:`<div class="${e.PCSS}-calendar-picker">\n <input type="text" class="${e.PCSS}-input" /><${e.P}-span text="{{ :host.viewValue }}" class="${e.PCSS}-readonly"></${e.P}-span>\n <${e.P}-button class="button-flat ${e.PCSS}-anim anim-pop anim-sudden anim-quick pos-absolute absolute-right absolute-top display-block ${e.PCSS}-margin margin-0"\n tab-order="-1"\n hide="{{ :host.readonly || :host.required || !Pacem.Utils.Dates.isDate(Pacem.Utils.Dates.parse(:host.value)) }}"\n icon-glyph="close"\n clear></${e.P}-button>\n</div>\n<${e.P}-shell-proxy>\n <div class="${e.PCSS}-calendar-picker-dropdown" pacem hidden>\n <${e.P}-collapse collapse="false">\n <div class="dropdown-grid">\n <div class="calendar-title">\n <${e.P}-span class="calendar-month calendar-zoom" on-click=":host.viewmode = 'month'" hide="{{ :host.viewmode !== 'calendar' }}"></${e.P}-span>\n <${e.P}-span class="calendar-year calendar-zoom" on-click=":host.viewmode = 'year'" hide="{{ :host.viewmode !== 'month' }}"></${e.P}-span>\n <${e.P}-span class="calendar-year-range" hide="{{ :host.viewmode !== 'year' }}"></${e.P}-span>\n </div>\n <div class="calendar-month-nav ${e.PCSS}-buttonset buttons">\n <div class="buttonset-left">\n <${e.P}-button class="button button-size size-auto" on-click=":host._prev($event)" icon-glyph="chevron_left"></${e.P}-button>\n <${e.P}-button class="button button-size size-auto" on-click=":host._next($event)" icon-glyph="chevron_right"></${e.P}-button>\n </div>\n </div>\n ${function(){let t="";for(let a=0;a<7;a++)t+=`<${e.P}-span class="calendar-heading day-${a+1} text-ellipsed" text="{{ :host._getHeaderLabel(:host._week[${a}]) }}"></${e.P}-span>`;return`<${e.P}-panel hide="{{ :host.viewmode !== 'calendar' }}" class="calendar-header">${t}</${e.P}-panel>`}()}\n <${e.P}-calendar hide="{{ :host.viewmode !== 'calendar' }}" week="{{ :host._week, twoway }}" view-date="{{ :host._viewDate, twoway }}" week-start="{{ :host.weekStart }}" disabled-ranges="{{ :host.disabledRanges }}" on-dateselect="{{ :host.changeHandler($event) }}"></${e.P}-calendar>\n <${e.P}-calendar-month-picker hide="{{ :host.viewmode !== 'month' }}" on-monthselect=":host._setMonth($event)" month="{{ :host.value || Date.now() }}" view-year="{{ :host._viewDate && :host._viewDate.getFullYear() }}"></${e.P}-calendar-month-picker>\n <${e.P}-calendar-year-picker hide="{{ :host.viewmode !== 'year' }}" on-yearselect=":host._setYear($event)" year="{{ :host.value || Date.now() }}" view-year="{{ :host._viewDate && :host._viewDate.getFullYear() }}"></${e.P}-calendar-year-picker>\n </div>\n <${e.P}-collapse>\n </div>\n</${e.P}-shell-proxy>`})],o),a.PacemCalendarPickerElement=o}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(a){a.CHAR_COUNTER_CHILD=`<${e.P}-char-count hide="{{ :host.readonly || !(:host.minlength > 0 || :host.maxlength > 0) }}" minlength="{{ :host.minlength }}" maxlength="{{ :host.maxlength }}" string="{{ :host.value }}"></${e.P}-char-count>`;let i=class PacemCharCountElement extends t.PacemElement{_isValid(e){const t=this._length(e);return!(this.minlength>0&&t<this.minlength)&&!(this.maxlength>0&&t>this.maxlength)}_length(e){return e&&e.length||0}};__decorate([e.Watch({converter:e.PropertyConverters.Number})],i.prototype,"minlength",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Number})],i.prototype,"maxlength",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],i.prototype,"string",void 0),i=__decorate([e.CustomElement({tagName:e.P+"-char-count",shadow:e.Defaults.USE_SHADOW_ROOT,template:`<${e.P}-panel class="${e.PCSS}-char-count" css-class="{{ {'valid': :host._isValid(:host.string), 'invalid': !:host._isValid(:host.string) } }}">\n <${e.P}-span hide="{{ !(:host.minlength > 0) }}" class="${e.PCSS}-char-min" content="{{ :host.minlength }}"></${e.P}-span>\n <${e.P}-span class="${e.PCSS}-char-curr" content="{{ :host._length(:host.string) || '0' }}"></${e.P}-span>\n <${e.P}-span hide="{{ !(:host.maxlength > 0) }}" class="${e.PCSS}-char-max" content="{{ :host.maxlength }}"></${e.P}-span>\n</${e.P}-panel>`})],i),a.PacemCharCountElement=i}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){let a=class PacemCheckboxListElement extends t.PacemDataSourceElement{acceptValue(e){}constructor(){super(!0),this._selectedUiItems=[],this.key="_"+e.Utils.uniqueCode()}get inputFields(){return[]}propertyChangedCallback(e,t,a,i){super.propertyChangedCallback(e,t,a,i),"disabled"===e&&(this._disable.model=a)}viewActivatedCallback(){super.viewActivatedCallback(),this._disable.model=this.disabled}toggleReadonlyView(e){this._span.hidden=!e,this._repeater.hidden=e}_selectionChanged(e,t,a){if("selected"===e.detail.propertyName){let a,i=this._selectedUiItems;!0===e.detail.currentValue?i.push(this.datasource[t]):-1!==(a=i.indexOf(this.datasource[t]))&&i.splice(a,1)}}onChange(t){const a=this.value=this._selectedUiItems.map(e=>this.mapEntityToValue(e));return e.Utils.fromResult(a)}};__decorate([e.ViewChild(`span.${e.PCSS}-readonly`)],a.prototype,"_span",void 0),__decorate([e.ViewChild(e.P+"-repeater")],a.prototype,"_repeater",void 0),__decorate([e.ViewChild(e.P+"-data")],a.prototype,"_disable",void 0),a=__decorate([e.CustomElement({tagName:e.P+"-checkbox-list",template:`<${e.P}-repeater datasource="{{ :host.adaptedDatasource }}">\n <ol class="${e.PCSS}-checkbox-list ${e.PCSS}-viewfinder" pacem>\n <template>\n <li><${e.P}-checkbox disabled="{{ ::_disable.model || ^item.disabled }}" name="{{ :host.key, once }}" autobind="off" caption="{{ ^item.viewValue }}" true-value="{{ ^item.value }}" selected="{{ :host.isDataSourceItemSelected(^item, :host.value) }}"\non-focus=":host.focusHandler($event)" on-blur=":host.focusHandler($event)"\non-${e.PropertyChangeEventName}=":host._selectionChanged($event, ^index, ^item)" on-change=":host.changeHandler($event)"></${e.P}-checkbox></li>\n </template>\n </ol>\n</${e.P}-repeater><span class="${e.PCSS}-readonly"><${e.P}-text text="{{ :host.viewValue }}"></${e.P}-text></span><${e.P}-data></${e.P}-data><${e.P}-content></${e.P}-content>`,shadow:e.Defaults.USE_SHADOW_ROOT})],a),t.PacemCheckboxListElement=a}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){const a={convert:e=>"true"===e||"false"!==e&&e,convertBack:e=>e.toString()};let i=class PacemCheckboxElement extends t.PacemBaseElement{constructor(){super("checkbox"),this.caption="",this._key="_"+e.Utils.uniqueCode()}convertValueAttributeToProperty(e){a.convert(e)===this.trueValue?this.trueValue:this.falseValue}toggleReadonlyView(e){this.span.hidden=!e,this._checkbox.hidden=this._label.hidden=e}get inputFields(){return[this._checkbox]}onChange(t){this.selected=this._checkbox.checked;const a=this.value=this.selected?this.trueValue:this.falseValue;return e.Utils.fromResult(a)}viewActivatedCallback(){super.viewActivatedCallback(),this._checkbox.id=this._label.htmlFor=this._key,this._synchronizeUi(),this.value==this.trueValue?this.selected=!0:this.value==this.falseValue&&(this.selected=!1)}propertyChangedCallback(t,a,i,n){if(super.propertyChangedCallback(t,a,i,n),this.isReady)switch(t){case"caption":this._label.hidden=e.Utils.isNullOrEmpty(i);break;case"name":this._checkbox.name=i;break;case"selected":this._synchronizeUi()}}_synchronizeUi(t=this.selected){(this._checkbox.checked=t)?(this.value=this.trueValue,e.Utils.addClass(this,e.PCSS+"-selected"),this.aria.attributes.set("checked","true")):(this.value=this.falseValue,e.Utils.removeClass(this,e.PCSS+"-selected"),this.aria.attributes.set("checked","false"))}acceptValue(e){this.selected=e==this.trueValue}getViewValue(t){return e.Utils.isNull(t)?"":this.caption}};__decorate([e.ViewChild("input[type=checkbox]")],i.prototype,"_checkbox",void 0),__decorate([e.ViewChild("label")],i.prototype,"_label",void 0),__decorate([e.ViewChild(`.${e.PCSS}-readonly`)],i.prototype,"span",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],i.prototype,"caption",void 0),__decorate([e.Watch({emit:!1,converter:a})],i.prototype,"trueValue",void 0),__decorate([e.Watch({emit:!1,converter:a})],i.prototype,"falseValue",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Boolean})],i.prototype,"selected",void 0),i=__decorate([e.CustomElement({tagName:e.P+"-checkbox",template:`<${e.P}-span class="${e.PCSS}-readonly ${e.PCSS}-checkbox" text="{{ :host.caption }}"></${e.P}-span>\n<input type="checkbox" class="${e.PCSS}-input" /><label class="${e.PCSS}-label ${e.PCSS}-checkbox ${e.PCSS}-viewfinder" pacem><${e.P}-span content="{{ :host.caption }}"></${e.P}-span></label>`,shadow:e.Defaults.USE_SHADOW_ROOT})],i),t.PacemCheckboxElement=i}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(a){a.FormSubmitEventName="submit",a.FormResetEventName="reset";class FormSubmitEvent extends e.CustomTypedEvent{constructor(e){super(a.FormSubmitEventName,e,{bubbles:!0,cancelable:!0})}}a.FormSubmitEvent=FormSubmitEvent;class FormResetEvent extends Event{constructor(){super(a.FormResetEventName,{bubbles:!0,cancelable:!0})}}a.FormResetEvent=FormResetEvent;const i=["download",e.Scaffolding.FieldChangeEventName,e.CommandEventName],n=!1;class FormEventEmitter{constructor(t){this._element=t,this._itemEmitHandler=t=>{if(this._element.handle(t),t.type===e.CommandEventName){const e=t;this._element.handle(new CustomEvent("item"+e.detail.commandName.toLowerCase(),{detail:e.detail.commandArgument}))}}}start(){i.forEach(e=>this._element.addEventListener(e,this._itemEmitHandler,!1))}stop(){i.forEach(e=>this._element.removeEventListener(e,this._itemEmitHandler,!1))}}a.FormEventEmitter=FormEventEmitter;let s=class PacemFormElement extends a.PacemFormRelevantElement{constructor(){super("form"),this.method=e.Net.HttpMethod.Post,this._emitter=null,this._buttons={submit:void 0,reset:void 0},this.#a=!1,this._keyupHandler=t=>{if(!(13!==t.keyCode||t.shiftKey||t.ctrlKey||t.altKey||t.metaKey)){let a=t.currentTarget.querySelector(e.P+"-button[type=submit]");e.Utils.isNull(a)||!e.Utils.isVisible(a)||a.disabled||a.click()}},this._submit=(t,a)=>{e.Utils.isNull(a)||e.avoidHandler(a),Promise.all(this._validateAllFields()).then(e=>{-1===e.findIndex(e=>!1===e)&&this.submit(t).then(e=>{this.setPristine()},e=>{})})},this._reset=t=>{e.Utils.isNull(t)||e.avoidHandler(t);var i=new FormResetEvent;if(this.dispatchEvent(i),!i.defaultPrevented){for(var n in this._fields){var s=this._fields[n];s instanceof a.PacemModelElement&&s.reset()}for(var r of this._subForms)r._reset()}},this._fields={},this._validators={},this._subForms=[],this._fieldPropertyChanged=e=>{switch(e.detail.propertyName){case"value":let t=e.target;this._checkFieldValidity(t.name);break;case"dirty":this._checkDirtyness();break;case"valid":this._checkValidity()}},this._validatorPropertyChanged=e=>{const t=e.target,a=t.watch;if("invalid"===e.detail.propertyName){let e=this._fields[t.watch];t.invalid?e.valid=!1:this._checkFieldValidity(a)}else this._checkFieldValidity(a)},this.suddenValidation=!0,this.resettable=!0,this._emitter=new FormEventEmitter(this)}propertyChangedCallback(t,a,i,n){super.propertyChangedCallback(t,a,i,n),("method"===t&&!0===this.autogenerate&&!e.Utils.isNullOrEmpty(this.metadata)||"metadata"===t&&!0===this.autogenerate||"autogenerate"===t&&!0===i&&this.metadata&&(this.metadata.props||this.metadata).length>0)&&this._buildUpForm()}viewActivatedCallback(){super.viewActivatedCallback(),this.form&&this.form.registerSubForm(this),this._checkValidity(),this.addEventListener("keyup",this._keyupHandler,!1),this._emitter.start()}disconnectedCallback(){this._emitter.stop(),this.removeEventListener("keyup",this._keyupHandler,!1),this.form&&this.form.unregisterSubForm(this),super.disconnectedCallback()}_buildUpForm(){const t="_"+e.Utils.uniqueCode(),a=this.id=this.id||t,i="fetch"+t,n=document.createElement("form");n.id="form"+t,n.className=e.PCSS+"-form",n.setAttribute("pacem",""),n.setAttribute("novalidate","");const s=`<${e.P}-repeater datasource="{{ #${a}.metadata && (#${a}.metadata.props || #${a}.metadata) }}">\n <${e.P}-panel css="{{ #${a}.metadata.display && #${a}.metadata.display.css }}" css-class="{{ (#${a}.metadata.display && #${a}.metadata.display.cssClass || []).concat(#${a}.suddenValidation ? [] : ['lazy-validation']) }}" class="${e.PCSS}-animatable-list ${e.PCSS}-list-appear">\n <template>\n <${e.P}-form-field fetch-credentials="{{ #${a}.fetchCredentials }}" fetch-headers="{{ #${a}.fetchHeaders }}"\n logger="{{ #${a}.logger }}" entity="{{ #${a}.entity, twoway }}" \n metadata="{{ ^item }}" readonly="{{ #${a}.readonly || ^item.isReadOnly }}"></${e.P}-form-field>\n </template>\n </${e.P}-panel>\n</${e.P}-repeater>\n<${e.P}-fetch logger="{{ #${a}.logger }}" id="${i}" method="${this.method}" credentials="{{ #${a}.fetchCredentials }}" headers="{{ #${a}.fetchHeaders }}"></${e.P}-fetch> \n<div class="${e.PCSS}-buttonset buttons">\n <div class="buttonset-left">\n <${e.P}-button logger="{{ #${a}.logger }}" on-click="#${a}._submit(#${a}.fetcher || #${i}, $event)" type="submit" hide="{{ #${a}.readonly || $pacem.isNullOrEmpty(#${a}.action) || !$pacem.isNull(#${a}.form) }}"\nclass="button primary button-size size-small"\ncss-class="{{ {'buttonset-last': !#${a}.resettable || !#${a}.dirty || !$pacem.isNull(#${a}.form) } }}" \ndisabled="{{ (#${a}.suddenValidation && (!(#${a}.valid && #${a}.dirty))) || #${a}.fetching }}">\n <${e.P}-panel class="submit-spinner ${e.PCSS}-anim anim-pop" hide="{{ !#${a}.fetching }}"><i class="${e.PCSS}-icon ${e.PCSS}-anim anim-rotate rotate-uniform display-block">refresh</i></${e.P}-panel>\n <${e.P}-text text="{{ #${a}.submitCaption || 'OK' }}"></${e.P}-text>\n </${e.P}-button>\n <${e.P}-button logger="{{ #${a}.logger }}" on-click="#${a}._reset($event)" type="reset" class="button button-size size-small" css-class="{{ {'buttonset-first': #${a}.readonly || $pacem.isNullOrEmpty(#${a}.action) || !$pacem.isNull(#${a}.form)} }}" hide="{{ !#${a}.resettable || #${a}.readonly || !#${a}.dirty || !Pacem.Utils.isNull(#${a}.form) }}" disabled="{{ #${a}.fetching }}">\n <${e.P}-text text="{{ #${a}.resetCaption || 'Reset' }}"></${e.P}-text>\n </${e.P}-button>\n</div></div>`;n.innerHTML=s,this.innerHTML="",this.appendChild(n),n.addEventListener("submit",e.avoidHandler,!1);const r=this._buttons,o=this._buttons={submit:n.lastElementChild.firstElementChild.firstElementChild,reset:n.lastElementChild.firstElementChild.lastElementChild};this.dispatchEvent(new e.PropertyChangeEvent({propertyName:"formButtons",currentValue:o,oldValue:r}))}get formButtons(){return this._buttons}#a;get fetching(){return this.#a}submit(t){return new Promise((a,i)=>{e.Utils.isNull(t)&&i("Fetcher cannot be null while submitting a form."),this._submitInternally(t).then(e=>{this.dispatchEvent(new CustomEvent("success",{detail:e})),a(e)},e=>{e!==n&&this.dispatchEvent(new CustomEvent("fail",{detail:e})),i(e)})})}reset(){this._reset()}_submitInternally(a,i){if(e.Utils.isNull(a))throw"Fetcher cannot be null while submitting a form.";var s=e.DeferPromise.defer();const r=this.entity,o=this.entityName;var l={};e.Utils.isNullOrEmpty(o)?l=r:l[o]=r;i={parameters:l,fields:this._getAllFields()};var c=new FormSubmitEvent(i);if(this.dispatchEvent(c),c.defaultPrevented)s.reject(n);else{a.parameters=e.Utils.extend({},c.detail.parameters);const i=t=>{a.removeEventListener(e.Net.FetchSuccessEventName,i,!1),a.removeEventListener(e.Net.FetchErrorEventName,r,!1);const o=t.detail;if(e.Net.Fetcher.isEmpty(o)&&(a.removeEventListener(e.Net.FetchResultEventName,n,!1),this.success=!0,s.resolve({})),205===o.status)this._reset()},n=t=>{a.removeEventListener(e.Net.FetchResultEventName,n,!1);var i=t.detail;"object"==typeof i&&i.hasOwnProperty("success")?!0===i.success?(this.success=!0,s.resolve(i.result||{})):(this.fail=!0,s.reject(i.error)):(this.success=!0,s.resolve(i))},r=t=>{a.removeEventListener(e.Net.FetchSuccessEventName,i,!1),a.removeEventListener(e.Net.FetchResultEventName,n,!1),a.removeEventListener(e.Net.FetchErrorEventName,r,!1),this.fail=!0;const o=t.detail;s.reject(o)},o=t=>{if("fetching"===t.detail.propertyName)!0===t.detail.currentValue?(e.Utils.addClass(this,e.PCSS+"-fetching"),this.#a=!0,this.dispatchEvent(new e.PropertyChangeEvent({currentValue:!0,oldValue:!1,propertyName:"fetching"}))):(this.#a=!1,this.dispatchEvent(new e.PropertyChangeEvent({currentValue:!1,oldValue:!0,propertyName:"fetching"})),e.Utils.removeClass(this,e.PCSS+"-fetching"),a.removeEventListener(e.PropertyChangeEventName,o,!1))};a.addEventListener(e.PropertyChangeEventName,o,!1),a.addEventListener(e.Net.FetchSuccessEventName,i,!1),a.addEventListener(e.Net.FetchResultEventName,n,!1),a.addEventListener(e.Net.FetchErrorEventName,r,!1),e.Utils.isNullOrEmpty(this.action)||(a.url=this.action),a instanceof t.PacemFetchElement&&!a.autofetch&&a.fetch(),this.success=this.fail=!1}return s.promise}_getAllFields(t={}){for(var a of(e.Utils.extend(t,this._fields),this._subForms))a._getAllFields(t);return t}apply(t){if(!e.Utils.isNullOrEmpty(t)){this.entity=e.Utils.extend({},this.entity,t);for(let e in t)this.setDirty(e)}}setPristine(...e){this._setAs(!1,...e)}setDirty(...e){this._setAs(!0,...e)}_setAs(t,...i){const n=!e.Utils.isEmpty(i);for(let e in this._fields)if(!n||i.indexOf(e)>=0){const i=this._fields[e];i instanceof a.PacemModelElement&&(t?i.setDirty():i.setPristine())}for(let e of this._subForms)t?e.setDirty(...i):e.setPristine(...i)}_checkFieldValidity(e){return this.suddenValidation?e in this._fields?this._validateField(e,!1):Promise.resolve(!1):Promise.resolve(null)}validate(t){return e.Utils.isNullOrEmpty(t)?Promise.all(this._validateAllFields()).then(e=>!e.some(e=>!1===e)):this._validateField(t,!1)}_validateAllFields(e=!0){const t=[];for(let a in this._fields)t.push(this._validateField(a,e));for(let a of this._subForms)Array.prototype.push.apply(t,a._validateAllFields(e));return t}_validateField(t,a){return new Promise((i,n)=>{var s=this._fields[t];if(s){var r=this._validators[s.name];r&&r.length>0?(this.log(e.Logging.LogLevel.Log,`Computing "${s.name}" validity.`),Promise.all(r.map(e=>e.validate(s.value).then(t=>!(e.invalid=!t)))).then(t=>{let n=!0;for(var r of t)if(!1===r){n=!1,a&&s.setDirty();break}this.log(e.Logging.LogLevel.Log,`Property "${s.name}" turns out to be ${n?"":"not "}valid.`),i(s.valid=n)})):(this.log(e.Logging.LogLevel.Log,`Property "${s.name}" has no validators.`),i(s.valid=!0))}else this.log(e.Logging.LogLevel.Log,`Property "${t}" has no fields in this form.`),i(!0)})}_checkDirtyness(){let e=!1;for(var t in this._fields)if(!0===this._fields[t].dirty){e=!0;break}if(!1===e)for(var a of this._subForms)if(a.dirty){e=!0;break}this.dirty=e}_checkValidity(){let t=!0;for(var a in this._fields)if(this.log(e.Logging.LogLevel.Log,`Checking "${a}" validity.`),!1===this._fields[a].valid){this.log(e.Logging.LogLevel.Log,`"${a}" is not valid.`),t=!1;break}if(!0===t)for(var i of this._subForms)if(!i.valid){t=!1;break}this.valid=t}registerSubForm(t){let a=this._subForms;-1==a.indexOf(t)&&(t.addEventListener(e.PropertyChangeEventName,this._fieldPropertyChanged,!1),a.push(t),this._checkValidity(),this._checkDirtyness())}unregisterSubForm(t){let a=this._subForms,i=a.indexOf(t);i>=0&&(t.removeEventListener(e.PropertyChangeEventName,this._fieldPropertyChanged,!1),a.splice(i,1),this._checkValidity(),this._checkDirtyness())}registerField(t,a){var i=this._fields;i[t]!=a&&(this.unregisterField(t,!1),i[t]=a,this.log(e.Logging.LogLevel.Log,`Registering "${t}" field.`),a instanceof HTMLElement&&a.addEventListener(e.PropertyChangeEventName,this._fieldPropertyChanged,!1),this._checkFieldValidity(t),this._checkDirtyness())}unregisterField(t,a=!0){var i=this._fields,n=i[t];n instanceof HTMLElement&&n.removeEventListener(e.PropertyChangeEventName,this._fieldPropertyChanged,!1),delete i[t],n&&!0===a&&(this._checkValidity(),this._checkDirtyness())}registerValidator(t,a){var i=this._validators[t]=this._validators[t]||[];-1==i.indexOf(a)&&(i.push(a),a instanceof HTMLElement&&a.addEventListener(e.PropertyChangeEventName,this._validatorPropertyChanged,!1),this.log(e.Logging.LogLevel.Log,`Calling "${t}" validity check after validator registration.`),this._checkFieldValidity(t))}unregisterValidator(e,t){this._unregisterValidator(e,t,!0)}_unregisterValidator(t,a,i){var n=this._validators[t]=this._validators[t]||[],s=n.indexOf(a);s>=0&&(a instanceof HTMLElement&&a.removeEventListener(e.PropertyChangeEventName,this._validatorPropertyChanged,!1),n.splice(s,1),i&&this._checkFieldValidity(t))}};__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Element})],s.prototype,"fetcher",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String})],s.prototype,"fetchCredentials",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Json})],s.prototype,"fetchHeaders",void 0),__decorate([e.Watch({reflectBack:!0,converter:e.PropertyConverters.String})],s.prototype,"method",void 0),__decorate([e.Watch({reflectBack:!0,converter:e.PropertyConverters.String})],s.prototype,"submitCaption",void 0),__decorate([e.Watch({reflectBack:!0,converter:e.PropertyConverters.String})],s.prototype,"resetCaption",void 0),__decorate([e.Debounce(100)],s.prototype,"_buildUpForm",null),__decorate([e.Watch({reflectBack:!0,converter:e.PropertyConverters.Boolean})],s.prototype,"valid",void 0),__decorate([e.Watch({reflectBack:!0,converter:e.PropertyConverters.Boolean})],s.prototype,"dirty",void 0),__decorate([e.Watch({reflectBack:!0,converter:e.PropertyConverters.Boolean})],s.prototype,"readonly",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Boolean})],s.prototype,"success",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Boolean})],s.prototype,"fail",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Json})],s.prototype,"entity",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String})],s.prototype,"entityName",void 0),__decorate([e.Watch()],s.prototype,"metadata",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Boolean})],s.prototype,"autogenerate",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Boolean})],s.prototype,"suddenValidation",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Boolean})],s.prototype,"resettable",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],s.prototype,"action",void 0),s=__decorate([e.CustomElement({tagName:e.P+"-form"})],s),a.PacemFormElement=s}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(a){let i=class PacemChildFormPropagatorElement extends t.PacemEventTarget{propertyChangedCallback(t,a,i,n){if(super.propertyChangedCallback(t,a,i,n),!n){const a=this.property,n=this.watch,s=!e.Utils.isNullOrEmpty(a),r=!e.Utils.isNull(this.model);("watch"===t||"property"===t||"model"===t&&s&&r&&e.Utils.isArray(i)&&i.some(e=>!(a in e)||e[a]!==n)||"model"===t&&s&&r&&!e.Utils.isArray(i)&&(!(a in i)||i[a]!==n))&&this._synchronize()}}viewActivatedCallback(){super.viewActivatedCallback(),this._synchronize()}_synchronize(){const t=this.model,a=this.property,i=this.watch;if(!e.Utils.isNullOrEmpty(t)&&!e.Utils.isNullOrEmpty(a))if(e.Utils.isArray(t)){for(let e of t)e[a]=i;this.model=t.slice(0)}else t[a]=i,this.model=e.Utils.extend({},t)}};__decorate([e.Watch({emit:!0})],i.prototype,"model",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String,reflectBack:!0})],i.prototype,"property",void 0),__decorate([e.Watch({emit:!1})],i.prototype,"watch",void 0),i=__decorate([e.CustomElement({tagName:e.P+"-childform-propagator"})],i),a.PacemChildFormPropagatorElement=i;let n=class PacemChildFormElement extends a.PacemBaseElement{constructor(){super(...arguments),this._model=[],this._subForms=[]}get inputFields(){return[]}toggleReadonlyView(e){}onChange(e){return new Promise((e,t)=>{var a=this._modelToEntity();e(this.value=a)})}acceptValue(e){this._entityToModel(e)}getViewValue(e){return""}convertValueAttributeToProperty(t){return e.PropertyConverters.Json.convert(t,this)}propertyChangedCallback(e,t,a,i){if(super.propertyChangedCallback(e,t,a,i),"mode"===e)this._entityToModel()}_dragStart(t){var a=t.detail;const i=e.Utils.offset(a.element),n=a.floater;n.style.width=i.width+"px",n.style.height=i.height+"px"}_dragEnd(e){"array"===this.mode&&this._triggerChange()}reset(){super.reset(),this._subForms.forEach(e=>{e.setPristine()})}_itemCreate(t){const a=t.detail.index,i=this._subForms;t.detail.dom[0].childNodes.forEach(t=>{t instanceof Element&&t.localName===e.P+"-form"&&i.splice(a,i.length-a,t)})}_itemChange(t,a){"entity"===a.detail.propertyName&&e.Utils.Json.stringify(this._model[t])!==e.Utils.Json.stringify(a.detail.currentValue)&&(this._model.splice(t,1,a.detail.currentValue),this._triggerChange())}_deleteAt(t){e.avoidHandler(t.srcEvent);const a=this._model;"array"===this.mode?a.splice(t.detail,1):a.splice(0,a.length),this._triggerChange()}_addItem(e){const t=this.mode,a=this._model;"array"===t?a.push({}):a.splice(0,a.length,{}),this._triggerChange()}_triggerChange(){this.changeHandler(new Event("change"))}_entityToModel(t=this.value){if("array"===this.mode){let a=t||[];e.Utils.isArray(a)&&this._model.cloneFrom(a)}else{const a=this._model,i=a.length;1===i&&a[0]===t||(e.Utils.isNull(t)?a.splice(0,i):a.splice(0,i,t))}}_modelToEntity(t=this._model){return"array"===this.mode?e.Utils.clone(t):t&&t.length&&t[0]||null}};__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String})],n.prototype,"fetchCredentials",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Json})],n.prototype,"fetchHeaders",void 0),__decorate([e.ViewChild("."+e.PCSS+"-childform")],n.prototype,"_container",void 0),__decorate([e.ViewChild(e.P+"-drag-drop")],n.prototype,"_dragger",void 0),__decorate([e.ViewChild("."+e.PCSS+"-childform-item-floater")],n.prototype,"_floater",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],n.prototype,"mode",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Boolean})],n.prototype,"lockItems",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Json})],n.prototype,"metadata",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Json})],n.prototype,"_model",void 0),n=__decorate([e.CustomElement({tagName:e.P+"-childform",shadow:e.Defaults.USE_SHADOW_ROOT,template:`<${e.P}-repeater datasource="{{ :host._model }}" on-itemdelete=":host._deleteAt($event)" on-${t.RepeaterItemCreateEventName}=":host._itemCreate($event)">\n <div class="${e.PCSS}-childform">\n <template>\n <${e.P}-panel class="${e.PCSS}-childform-item" behaviors="{{ [::_dragger] }}">\n <${e.P}-panel class="childform-item-handle ${e.PCSS}-margin margin-right-1" hide="{{ :host.lockItems || :host.readonly || :host.mode !== 'array' || !(:host._model && :host._model.length > 1) }}"><i class="${e.PCSS}-icon drag-handle">drag_handle</i></${e.P}-panel>\n <${e.P}-panel class="childform-item-index text-small"><${e.P}-span hide="{{ !:host.readonly || :host.mode !== 'array' }}" class="${e.PCSS}-margin margin-right-1" text="{{ ^index+1 }}"></${e.P}-span></${e.P}-panel>\n <${e.P}-form entity="{{ ^item }}" fetch-headers="{{ :host.fetchHeaders }}" fetch-credentials="{{ :host.fetchCredentials }}" on-${e.PropertyChangeEventName}=":host._itemChange(^index, $event)" readonly="{{ :host.readonly }}" metadata="{{ :host.metadata }}" autogenerate="true" logger="{{ :host.logger }}"></${e.P}-form>\n <${e.P}-button tab-order="-1" class="flat circular circle-small clear ${e.PCSS}-margin margin-left-1" hide="{{ :host.lockItems || :host.readonly }}" command-name="delete" command-argument="{{ ^index }}"></${e.P}-button>\n </${e.P}-panel>\n </template>\n </div>\n <${e.P}-button tab-order="-1" class="flat circular circle-small add" hide="{{ :host.lockItems || :host.readonly || !(:host.mode === 'array' || $pacem.isNullOrEmpty(:host._model)) }}" on-click=":host._addItem($event)"></${e.P}-button>\n</${e.P}-repeater>\n<div class="${e.PCSS}-childform-item-floater ${e.PCSS}-panel panel-border">\n <div class="corner top-left"></div><div class="corner top-right"></div><div class="corner bottom-left"></div><div class="corner bottom-right"></div>\n</div>\n<${e.P}-drag-drop floater="{{ ::_floater }}" disabled="{{ :host.lockItems }}"\n on-${e.UI.DragDropEventType.Start}=":host._dragStart($event)"\n on-${e.UI.DragDropEventType.End}=":host._dragEnd($event)" \n drop-behavior="${e.UI.DropBehavior.InsertChild}" mode="${e.UI.DragDataMode.Alias}" handle-selector=".drag-handle" drop-targets="{{ [::_container] }}"></${e.P}-drag-drop>`})],n),a.PacemChildFormElement=n}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){function a(e){return e instanceof HTMLDivElement&&"true"===e.contentEditable&&e.hasAttribute("pacem")&&e.hasAttribute("role")&&"presenter"===e.attributes.role.value}t.ContenteditableDOMObserver=class ContenteditableDOMObserver{constructor(e,t,a="*[contenteditable=false]"){this.#i=t,this.#n=a,this.#s=new MutationObserver(e=>{const a=(e,i)=>{e.childNodes.forEach(e=>a(e,i)),t(e,i)};for(let t of e){const e=t.addedNodes,i=t.removedNodes;for(let t=0;t<e.length;t++){const i=e.item(t);a(i,!1)}for(let e=0;e<i.length;e++){const t=i.item(e);a(t,!0)}}}),this._initContainer(e)}_initContainer(e){e.querySelectorAll(this.#n).forEach(e=>this.#i(e)),this.#s.observe(e,{subtree:!0,childList:!0}),this.#r=e}_disposeContainer(t){const a=this.#s;e.Utils.isNull(a)||a.disconnect(),t.querySelectorAll(this.#n).forEach(e=>this.#i(e,!0))}dispose(){this._disposeContainer(this.#r)}#n;#i;#r;#s};class ContenteditableUtils{static getDefaultDashboard(){const a=new DocumentFragment,i=document.createElement("div");e.Utils.addClass(i,e.PCSS+"-contenteditable-toolbar");const n=new t.PacemContenteditableHistoryCommandElement;n.command="undo",n.keyboardShortcut="Ctrl+Z";const s=new t.PacemContenteditableHistoryCommandElement;s.command="redo",s.keyboardShortcut="Ctrl+Y",i.append(n,s);const r=document.createElement("div");e.Utils.addClass(r,e.PCSS+"-contenteditable-separator");const o=document.createElement("div");e.Utils.addClass(o,e.PCSS+"-contenteditable-toolbar");const l=new t.PacemContenteditableExecCommandElement;l.command=t.KnownExecCommand.Bold,l.keyboardShortcut="Ctrl+B";const c=new t.PacemContenteditableExecCommandElement;c.command=t.KnownExecCommand.Italic,c.keyboardShortcut="Ctrl+I";const d=new t.PacemContenteditableExecCommandElement;d.command=t.KnownExecCommand.Underline,d.keyboardShortcut="Ctrl+U";const h=new t.PacemContenteditableExecCommandElement;h.command=t.KnownExecCommand.StrikeThrough,d.keyboardShortcut="Ctrl+K";const p=new t.PacemContenteditableExecCommandElement;p.command=t.KnownExecCommand.UnorderedList;const u=new t.PacemContenteditableExecCommandElement;u.command=t.KnownExecCommand.OrderedList;const m=new t.PacemContenteditableAlignCommandElement;m.align="left";const v=new t.PacemContenteditableAlignCommandElement;v.align="center";const _=new t.PacemContenteditableAlignCommandElement;_.align="right";const g=new t.PacemContenteditableAlignCommandElement;g.align="justify",o.append(l,c,d,h,p,u,m,v,_,g);const y=document.createElement("div");e.Utils.addClass(y,e.PCSS+"-contenteditable-separator");const f=document.createElement("div");e.Utils.addClass(f,e.PCSS+"-contenteditable-toolbar");const C=new t.PacemContenteditableLinkCommandElement,P=new t.PacemContenteditableImageCommandElement;return f.append(C,P),a.append(i,r,o,y,f),a}static findSurroundingNode(t,i){for(var n=t instanceof Node?t:t.commonAncestorContainer;n&&!("string"==typeof i&&n instanceof Element&&n.tagName===i.toUpperCase()||"function"==typeof i&&e.Utils.isNull(i.prototype)&&i(n)||"function"==typeof i&&!e.Utils.isNull(i.prototype)&&n instanceof i);){const e=n.parentNode;if(a(e)){n=null;break}n=e}return n}static findSurroundingBlockElement(e){return this.findSurroundingNode(e,ContenteditableUtils.isBlockElement)}static findSurroundingSiblingBlockElements(e){let t=[];if(a(e.startContainer)){if(!e.collapsed){const a=e.startContainer;for(let i=e.startOffset;i<=e.endOffset;i++){const e=a.children.item(i);this.isBlockElement(e)&&t.push(a.children.item(i))}}return t}if(e.startContainer===e.endContainer){let t=e.startContainer;for(;!ContenteditableUtils.isBlockElement(t)&&"true"!=t.parentElement.contentEditable;)t=t.parentElement;return t instanceof Element?[t]:"true"===t.parentElement.contentEditable?[]:[t.parentElement]}let i=e.commonAncestorContainer,n=!1;for(let a=0;a<i.childNodes.length;a++){const s=i.childNodes.item(a);if((!n&&s.contains(e.startContainer)||n)&&ContenteditableUtils.isBlockElement(s)&&(t.push(s),n=!0,s.contains(e.endContainer)))break}return n?t:i instanceof Element&&!a(i)?[i]:[]}static findContainingRootElements(e){const t=e.cloneRange(),a=e.cloneRange();t.collapse(!0),a.collapse();let i=this.findSurroundingNode(t,e=>"true"===e.parentElement.contentEditable);const n=[i];for(;!i.contains(a.startContainer);)n.push(i=i.nextElementSibling);return n}static isBlockElement(e){return e instanceof Element&&!getComputedStyle(e).display.startsWith("inline")}static select(e,t=!1){const a=document.createRange();t?(a.setStart(e,0),a.setEnd(e,e.childNodes.length)):(a.setStartBefore(e),a.setEndAfter(e));const i=document.getSelection();return i.removeAllRanges(),i.addRange(a),a}static copyAttributes(e,t){const a=t.attributes;for(let t=0;t<a.length;t++){const i=a.item(t);e.setAttribute(i.name,i.value)}}static testInertElementWrapping(t){if(!e.Utils.isNull(t)){const e=t.startContainer,i=t.startOffset;var a;if(e===t.endContainer&&i==t.endOffset-1&&(a=e.childNodes.item(i))instanceof HTMLElement&&"false"===a.contentEditable)return{result:!0,element:a}}return{result:!1}}}t.ContenteditableUtils=ContenteditableUtils}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){const a="execute",i="<p><br></p>";class ContenteditableChangeEvent extends e.CustomTypedEvent{constructor(e){super("contenteditablechange",{html:e})}}class PacemContenteditableCommandElement extends t.PacemItemElement{constructor(){super(...arguments),this._containerPropChangeHandler=e=>{const t=e.detail;this.containerPropertyChangedCallback(t.propertyName,t.oldValue,t.currentValue,t.firstChange)}}execCommand(...e){const t=this;t.disabled||t.exec.apply(t,e).then(e=>{t.dispatchEvent(new Event(a))},e=>{console.error(e)})}connectedCallback(){super.connectedCallback(),e.Utils.addClass(this,e.PCSS+"-contenteditable-command")}viewActivatedCallback(){super.viewActivatedCallback();const t=this.container;e.Utils.isNull(t)||(this.contentElement=t.contentElement,t.addEventListener(e.PropertyChangeEventName,this._containerPropChangeHandler,!1))}disconnectedCallback(){const t=this.container;e.Utils.isNull(t)||t.removeEventListener(e.PropertyChangeEventName,this._containerPropChangeHandler,!1),super.disconnectedCallback()}containerPropertyChangedCallback(e,t,a,i){"range"===e&&(this.range=a)}}function n(e){return e instanceof PacemContenteditableCommandElement&&"pasteCallback"in e&&"function"==typeof e.pasteCallback}function s(e){return e?.nodeType==Node.ELEMENT_NODE}__decorate([e.Watch()],PacemContenteditableCommandElement.prototype,"range",void 0),__decorate([e.Watch()],PacemContenteditableCommandElement.prototype,"contentElement",void 0),t.PacemContenteditableCommandElement=PacemContenteditableCommandElement;let r=class PacemContenteditableElement extends t.PacemItemsContainerBaseElement{constructor(){super("rich text editor"),this._focusHandler=e=>{this._ensureInteractiveMarkup()},this._blurHandler=e=>{const t=this._container;for(let e of this.items)e.cleanUp(t);this._checkChangedHandler(e)},this._pasteHandler=t=>{t.preventDefault();const a=this.range,i=t.clipboardData.files;if(e.Utils.isNull(a)||0!==i.length)for(let e=0;e<i.length;e++){const a=i.item(e);for(let e of this.items)n(e)&&e.pasteCallback(a).then(e=>this._checkChangedHandler(t),e=>{})}else{const e=t.clipboardData.getData("text/plain").replace(/</gi,"<").replace(/\n/gi,"<br />"),i=a.createContextualFragment(e);a.deleteContents(),a.insertNode(i),this._checkChangedHandler(t)}},this._shortcutHandler=e=>{e.ctrlKey&&-1===["C","V","X"].indexOf(e.key?.toUpperCase())&&e.preventDefault()},this._inputHandler=e=>{this._fixRangeMarkup(),this._checkChangedHandler(e)},this._checkChangedHandler=t=>{const a=this._container,n=a.innerHTML;var s=n;(e.Utils.isNullOrEmpty(n)||"<br>"===n||n===i)&&(a.innerHTML=i,s=""),s!=this.value&&(this.changeHandler(new ContenteditableChangeEvent(s)),this.value!=this.#o.current&&this._updateHistory()),this._fireHistoryChange()},this._selectionChangeHandler=e=>{const t=document.getSelection();if(t&&t.anchorNode&&this._container.contains(t.anchorNode)){const e=t.getRangeAt(0);this.range=e.cloneRange()}else this.range=null}}#o;get history(){return this.#o}reset(){super.reset(),this.#o.reset(),this._fireHistoryChange()}_fireHistoryChange(){const t=this.#o;this.dispatchEvent(new e.PropertyChangeEvent({propertyName:"history",oldValue:t,currentValue:t}))}convertValueAttributeToProperty(e){return e}toggleReadonlyView(e){this._dashboard.hidden=e,e?this._container.removeAttribute("contenteditable"):(this._container.setAttribute("contenteditable","true"),document.execCommand("defaultParagraphSeparator",!1,"p"))}register(e){return!!super.register(e)&&(e.addEventListener(a,this._checkChangedHandler,!1),!0)}unregister(e){return!!super.unregister(e)&&(e.removeEventListener(a,this._checkChangedHandler,!1),!0)}get preventKeyboardSubmit(){return!0}get inputFields(){return[this._container]}get contentElement(){return this._container}onChange(t){return new Promise((a,i)=>{if(e.CustomEventUtils.isInstanceOf(t,ContenteditableChangeEvent)){a(this.value=t.detail.html),this._selectionChangeHandler(t)}else a(this.value)})}_fixRangeMarkup(){const t=this.range,a=e=>{e.childNodes.forEach(e=>a(e)),s(e)&&"SPAN"===e.tagName?Element.prototype.replaceWith.apply(e,Array.from(e.childNodes)):e instanceof HTMLElement&&e.removeAttribute("style")};e.Utils.isNull(t)||(e=>{let t=e;s(t)||(t=e.parentElement),a(t)})(t.commonAncestorContainer)}_ensureInteractiveMarkup(){const t=this._container,a=t.childNodes,n=a.length;if(0==n||t.innerHTML===i)t.innerHTML=i;else{let t,i;const s=e=>{i.setEndAfter(e);const t=document.createElement("p");i.surroundContents(t)};for(let r=0;r<n;r++)t=a.item(r),t instanceof Element?i&&(s(t.previousSibling),i=null):e.Utils.isNull(i)&&(i=document.createRange(),i.setStartBefore(t));e.Utils.isNull(i)||s(t)}}_updateHistory(){this.#o.push(this.value),this._fireHistoryChange()}acceptValue(t){e.Utils.isNull(this._container)||t==this._container.innerHTML||(this._container.innerHTML=t)}viewActivatedCallback(){super.viewActivatedCallback();const t=this._container;this.#o=new e.HistoryService(this.value),t.addEventListener("blur",this._blurHandler,!1),t.addEventListener("keydown",this._shortcutHandler,!1),t.addEventListener("focus",this._focusHandler,!1),t.addEventListener("input",this._inputHandler,!1),t.addEventListener("paste",this._pasteHandler,!1),document.addEventListener("selectionchange",this._selectionChangeHandler,!1)}disconnectedCallback(){document.removeEventListener("selectionchange",this._selectionChangeHandler,!1);const t=this._container;e.Utils.isNull(t)||(t.removeEventListener("keydown",this._shortcutHandler,!1),t.removeEventListener("blur",this._blurHandler,!1),t.removeEventListener("focus",this._focusHandler,!1),t.removeEventListener("input",this._inputHandler,!1),t.removeEventListener("paste",this._pasteHandler,!1)),super.disconnectedCallback()}getViewValue(e){return e}};__decorate([e.ViewChild("div[pacem]")],r.prototype,"_container",void 0),__decorate([e.ViewChild("div[dashboard]")],r.prototype,"_dashboard",void 0),__decorate([e.Watch()],r.prototype,"range",void 0),__decorate([e.Debounce(500)],r.prototype,"_updateHistory",null),r=__decorate([e.CustomElement({tagName:e.P+"-contenteditable",shadow:e.Defaults.USE_SHADOW_ROOT,template:`<div class="${e.PCSS}-contenteditable ${e.PCSS}-viewfinder">\n <div contenteditable="true" role="presenter" pacem></div>\n</div>${t.CHAR_COUNTER_CHILD}\n<div dashboard>\n <${e.P}-content></${e.P}-content>\n</div>`})],r),t.PacemContenteditableElement=r}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){const a={convert:(t,a)=>/\{.+\}/.test(t)?e.PropertyConverters.Json.convert(t):e.PropertyConverters.String.convert(t),convertBack:(t,a)=>"string"==typeof t?t:e.PropertyConverters.Json.convertBack(t,a)};let i=class PacemDatetimePickerElement extends t.PacemBaseElement{constructor(){super(),this.precision="day",this._months=[],this._dates=[],this._a24=[],this._a60=[],this._years=[],this.hours="00",this.minutes="00",this.seconds="00"}get inputFields(){return[this._yearel,this._monthel,this._dateel,this._hourel,this._minel,this._secel]}toggleReadonlyView(e){this._allFields.hidden=e}convertValueAttributeToProperty(t){return e.PropertyConverters.Datetime.convert(t)}connectedCallback(){super.connectedCallback();const t=new Date;let a=this.year=t.getFullYear();this.min=new Date(a-100,0,1),this.max=new Date(a+10,11,31),this.month=t.getMonth();let i=[],n=[],s=[],r=e.Utils.leftPad;for(let t=0;t<12;t++){let n=new Date(a,t,1),s=n.toLocaleString(e.Utils.lang(this),{month:"short"});i.push({value:t,date:n,label:s})}this._months=i;for(let e=0;e<24;e++)n.push(r(e,2,"0"));this._a24=n;for(let e=0;e<60;e++)s.push(r(e,2,"0"));this._a60=s}propertyChangedCallback(t,a,i,n){switch(super.propertyChangedCallback(t,a,i,n),t){case"dateValue":this.log(e.Logging.LogLevel.Log,`dateValue changed from ${a} to ${i}`),this._disassembleDate(i);break;case"min":case"max":e.Utils.isNullOrEmpty(this.min)||e.Utils.isNullOrEmpty(this.max)||this._setupYears();break;case"year":case"month":this._buildupDates();break;case"date":case"hours":case"minutes":case"seconds":this._buildup()}}acceptValue(t){this.dateValue=e.Utils.parseDate(t)}_disassembleDate(t){if(!t)return void(this.date=void 0);"string"==typeof t&&(t=e.Utils.parseDate(t));const a=t=>e.Utils.leftPad(t,2,"0");this.year=t.getFullYear(),this.month=t.getMonth(),this.date=t.getDate(),this.hours=a(t.getHours()),this.minutes=a(t.getMinutes()),this.seconds=a(t.getSeconds())}_setupYears(){let t=[];const a=e.Utils.parseDate(this.min),i=e.Utils.parseDate(this.max);for(let e=a.getFullYear();e<=i.getFullYear();e++)t.push(e);this._years=t}onChange(e){return new Promise((e,t)=>{e(this.value=this._computeValue())})}_buildupDates(t){t&&t.stopPropagation();const a=this,i={weekday:"short",day:"numeric"},n=e=>{try{let t=+a.month;return new Date(+a.year,+a.month,e).getMonth()==t}catch(e){return!1}};var s=[];if(!e.Utils.isNullOrEmpty(a.year)&&!e.Utils.isNullOrEmpty(a.month)){let t=1;do{let n=new Date(+a.year,+a.month,t),r=n.toLocaleString(e.Utils.lang(this),i);s.push({value:t,date:n,label:r,disabled:n<this.min||n>this.max})}while(n(++t))}this._dates=s,n(+this.date)?this._buildup():this.date=""}_computeValue(){const t=this;if(e.Utils.isNullOrEmpty(t.year)||e.Utils.isNullOrEmpty(t.month)||e.Utils.isNullOrEmpty(t.date))return null;try{let e=new Date(+t.year,+t.month,+t.date);return e.setHours(+t.hours),e.setMinutes(+t.minutes),e.setSeconds(+t.seconds),e.setMilliseconds(0),Number.isNaN(e.valueOf())?null:e}catch(e){return null}}_buildup(e){e&&e.stopPropagation(),this.dateValue=this._computeValue()}getViewValue(t){const a=t;return a?e.Utils.core.date(a,this.format||("day"!=this.precision?"full":"short"),e.Utils.lang(this)):""}};__decorate([e.ViewChild("."+e.PCSS+"-datetime-picker-year > "+e.P+"-select")],i.prototype,"_yearel",void 0),__decorate([e.ViewChild("."+e.PCSS+"-datetime-picker-month > "+e.P+"-select")],i.prototype,"_monthel",void 0),__decorate([e.ViewChild("."+e.PCSS+"-datetime-picker-date > "+e.P+"-select")],i.prototype,"_dateel",void 0),__decorate([e.ViewChild("."+e.PCSS+"-datetime-picker-hours > "+e.P+"-select")],i.prototype,"_hourel",void 0),__decorate([e.ViewChild("."+e.PCSS+"-datetime-picker-minutes > "+e.P+"-select")],i.prototype,"_minel",void 0),__decorate([e.ViewChild("."+e.PCSS+"-datetime-picker-seconds > "+e.P+"-select")],i.prototype,"_secel",void 0),__decorate([e.ViewChild(`div.${e.PCSS}-datetime-picker-fields`)],i.prototype,"_allFields",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Datetime})],i.prototype,"dateValue",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Datetime})],i.prototype,"min",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Datetime})],i.prototype,"max",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],i.prototype,"precision",void 0),__decorate([e.Watch({emit:!1,converter:a})],i.prototype,"format",void 0),__decorate([e.Watch()],i.prototype,"_dates",void 0),__decorate([e.Watch()],i.prototype,"_years",void 0),__decorate([e.Watch()],i.prototype,"year",void 0),__decorate([e.Watch()],i.prototype,"month",void 0),__decorate([e.Watch()],i.prototype,"date",void 0),__decorate([e.Watch()],i.prototype,"hours",void 0),__decorate([e.Watch()],i.prototype,"minutes",void 0),__decorate([e.Watch()],i.prototype,"seconds",void 0),__decorate([e.Debounce(10)],i.prototype,"_buildup",null),i=__decorate([e.CustomElement({tagName:e.P+"-datetime-picker",shadow:e.Defaults.USE_SHADOW_ROOT,template:`<div class="${e.PCSS}-datetime-picker">\n <div class="${e.PCSS}-datetime-picker-fields ${e.PCSS}-viewfinder">\n\n <div class="${e.PCSS}-datetime-picker-year">\n <${e.P}-select value="{{ :host.year, twoway }}" placeholder="..." datasource="{{ :host._years }}">\n </${e.P}-select></div>\n\n <div class="${e.PCSS}-datetime-picker-month">\n <${e.P}-select value="{{ :host.month, twoway }}" placeholder="..." value-property="value" text-property="label" datasource="{{ :host._months }}">\n </${e.P}-select></div>\n\n <div class="${e.PCSS}-datetime-picker-date">\n <${e.P}-select value="{{ :host.date, twoway }}" placeholder="..." value-property="value" text-property="label" datasource="{{ :host._dates }}">\n </${e.P}-select></div>\n\n <${e.P}-panel class="${e.PCSS}-datetime-picker-hours" hide="{{ :host.precision === 'day' }}">\n <${e.P}-select value="{{ :host.hours, twoway }}" datasource="{{ :host._a24 }}">\n </${e.P}-select></${e.P}-panel>\n\n <${e.P}-panel class="${e.PCSS}-datetime-picker-minutes" hide="{{ :host.precision === 'day' }}">\n <${e.P}-select value="{{ :host.minutes, twoway }}" datasource="{{ :host._a60 }}">\n </${e.P}-select></${e.P}-panel>\n\n <${e.P}-panel class="${e.PCSS}-datetime-picker-seconds" hide="{{ :host.precision !== 'second' }}">\n <${e.P}-select value="{{ :host.seconds, twoway }}" datasource="{{ :host._a60 }}">\n </${e.P}-select></${e.P}-panel>\n\n </div>\n <${e.P}-panel class="${e.PCSS}-datetime-picker-preview" hide="{{ Pacem.Utils.isNullOrEmpty(:host.dateValue) || :host.precision === 'day' || :host.readonly }}">\n <dl>\n <dt>local:</dt><dd><${e.P}-text text="{{ :host.viewValue }}"></${e.P}-text></dd>\n <dt>iso:</dt><dd><${e.P}-text text="{{ (:host.dateValue && :host.dateValue.toISOString()) || '' }}"></${e.P}-text></dd>\n </dl>\n </${e.P}-panel>\n <${e.P}-span class="${e.PCSS}-readonly" css-class="{{ { 'date': :host.precision === 'day', 'datetime': :host.precision !== 'day' } }}" content="{{ :host.viewValue }}" hide="{{ !:host.readonly }}"></${e.P}-span>\n</div>`})],i),t.PacemDatetimePickerElement=i}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(a){function i(e){return new RegExp(e).source}let n=class PacemFormFieldElement extends a.PacemFormRelevantElement{constructor(t=new e.MarkdownService){super(),this._md=t,this._entityPropertyChangeHandler=t=>{this.dispatchEvent(new e.PropertyChangeEvent({propertyName:"entity",currentValue:this.entity}))},this._labelClickHandler=e=>{document.getElementById(this._label.htmlFor).focus()},this._key="_"+e.Utils.uniqueCode()}get key(){return this._key}get fetcher(){return this._fetcher}get field(){return this._field}viewActivatedCallback(){super.viewActivatedCallback(),this._buildUpForm(),this._buildUpFetcher()}propertyChangedCallback(t,a,i,n){switch(super.propertyChangedCallback(t,a,i,n),t){case"readonly":this._ensureBalloon();break;case"metadata":this._ensureBalloon(),this._buildUpCss(),this._buildUpLabel(),this._buildUpField();break;case"entity":a instanceof HTMLElement&&a.removeEventListener(e.PropertyChangeEventName,this._entityPropertyChangeHandler,!1),i instanceof HTMLElement&&i.addEventListener(e.PropertyChangeEventName,this._entityPropertyChangeHandler,!1)}}disconnectedCallback(){this.entity instanceof HTMLElement&&this.entity.removeEventListener(e.PropertyChangeEventName,this._entityPropertyChangeHandler,!1),e.Utils.isNull(this._label)||this._label.removeEventListener("click",this._labelClickHandler,!1),e.Utils.isNull(this._balloon)||this._balloon.remove(),super.disconnectedCallback()}_normalizeTooltip(){const e=this.metadata&&this.metadata.extra&&this.metadata.extra.tooltip||!1;return"object"==typeof e?e:{type:e}}_ensureBalloon(){var a,i;const n=this.readonly||!1===(i=this._normalizeTooltip()).type||e.Utils.isNullOrEmpty(a=this.metadata&&this.metadata.display&&this.metadata.display.description);if(e.Utils.isNull(this._balloon)&&!n){let a=document.createElement(e.P+"-balloon");a.options={behavior:t.UI.BalloonBehavior.Tooltip,trigger:i.trigger||t.UI.BalloonTrigger.Hover,position:i.position||t.UI.BalloonPosition.Top,hoverDelay:200,hoverTimeout:50,align:i.align||t.UI.BalloonAlignment.Auto},e.Utils.addClass(a,e.PCSS+"-field-tooltip"),e.CustomElementUtils.findAncestorShell(this).appendChild(this._balloon=a)}const s=this._balloon;if(!(e.Utils.isNull(s)||(s.target=this._label,s.disabled=n))){const e=a||"";switch(i.type){case"md":case"markdown":s.innerHTML=this._md.toHtml(e);break;case"html":s.innerHTML=e;break;default:s.innerText=e}}}_buildUpCss(){const t=this.metadata?.display;if(!e.Utils.isNull(t)){if("function"==typeof t.cssClass){const{cssClassAttr:e}=t.cssClass(this,"$this","$this.entity");this.setAttribute("css-class",e)}else this.cssClass=t.cssClass;if("function"==typeof t.css){const{cssAttr:e}=t.css(this,"$this","$this.entity");this.setAttribute("css",e)}else this.css=t.css}}_buildUpLabel(){const t=this._label,a=t.firstElementChild,i=this.metadata;t.htmlFor=this._key,e.Utils.addClass(t,e.PCSS+"-label");const n=this.metadata.validators;if(n&&n.find(e=>"required"===e.type)?e.Utils.addClass(t,e.PCSS+"-required"):e.Utils.removeClass(t,e.PCSS+"-required"),e.Utils.isNull(this._balloon)||this._balloon.disabled?e.Utils.removeClass(t,e.PCSS+"-tooltip"):e.Utils.addClass(t,e.PCSS+"-tooltip"),"function"==typeof i.display?.name){const{contentAttr:e}=i.display.name(this,":host",":host.entity","::_form");a.setAttribute("content",e)}else a.removeAttribute("content"),a.content=i.display&&i.display.name||i.prop;t.setAttribute("id","label"+this._key),t.addEventListener("click",this._labelClickHandler,!1)}_isValueNullOrEmpty(t=this.entity,a=this.metadata){if(e.Utils.isNull(a))return!0;const i=a.prop.split(".");let n=t;for(let t=0;t<i.length;t++){const a=i[t];if(e.Utils.isNullOrEmpty(n&&n[a]))return!0;n=n[a]}return!1}_handleValueChange(t){if("value"===t.detail.propertyName){const a=t.detail.currentValue,i=this.metadata.prop;if(this.entity instanceof HTMLElement){let t=e.CustomElementUtils.camelToKebab(i);e.Utils.isNullOrEmpty(a)?this.entity.removeAttribute(t):this.entity.setAttribute(t,a.toString())}else this.entity[i]=a}}_adjustDependencyValue(t){return e.Utils.Dates.isDate(t)?e.Utils.Dates.parse(t).toISOString():t}_broadcastFetchResult(e){this.dispatchEvent(new CustomEvent("fetch",{detail:e,bubbles:!0,cancelable:!1}))}_buildUpFetcher(){var e=this._fetcher;e.setAttribute("id","fetch"+this._key),e.setAttribute("on-fetchresult",":host._broadcastFetchResult($event.detail)")}_buildUpForm(){var e=this._form;e.setAttribute("id","form"+this._key),e.setAttribute("sudden-validation","{{ ::form.suddenValidation }}")}_buildUpField(){this._field&&this._field.remove(),this._fetcher.removeAttribute("parameters"),this._fetcher.result=this._fetcher.url=null;for(var t=this._validators.children.length-1;t>=0;t--)this._validators.children[t].remove();var n=this.metadata;let s=e.P+"-input-text",r=e.P+(n.display&&"slider"===n.display.ui?"-slider":"-input-number"),o={id:this._key,name:n.prop,readonly:"{{ :host.readonly || :host.metadata.isReadOnly || ::_form.readonly }}",value:`{{ :host.entity.${n.prop}, twoway }}`,placeholder:`${n.display&&n.display.watermark||""}`};1==n.extra?.autofocus&&(o["on-load"]="requestAnimationFrame(() => $this.focus())");let l=n.extra||{},c={},d="false",h="",p="",u="",m=[];if(!e.Utils.isNullOrEmpty(l.dependsOn))if("function"==typeof l.dependsOn){const S=l.dependsOn(this,":host",":host.entity","$this.entity"),k=S.hideAttr;if(e.Utils.isNullOrEmpty(k)||this.setAttribute("hide",k),e.Utils.isNullOrEmpty(S.disabledAttr)||(d=S.disabledAttr,e.CustomElementUtils.isBindingAttribute(d)&&(p=e.CustomElementUtils.extractBindingAttributeExpression(d))),!e.Utils.isNullOrEmpty(S.parameterAttrs)){const $=S.parameterAttrs,U=[];for(let N in $){const x=$[N];U.push(`${N}: ${x}`),m.push({prop:x})}u=U.join(", ")}}else{m=l.dependsOn;let V={empty:[],notEqual:{}},O={empty:[],notEqual:{}},A=[],D=[];for(var v of m){let H=":host.entity."+v.prop,L="$this.entity."+v.prop;if(e.Utils.isNullOrEmpty(v.value)){if(!v.optional){let I=e=>"$pacem.isNullOrEmpty("+e+")";V.empty.push(I(H)),v.hide&&O.empty.push(I(L))}}else{let F=e=>e+" !== "+JSON.stringify(v.value);(V.notEqual[H]=V.notEqual[H]||[]).push(F(H)),v.hide&&(O.notEqual[L]=O.notEqual[L]||[]).push(F(L))}D.push(H),A.push(`${v.alias||v.prop}: :host._adjustDependencyValue(${H})`),v.optional||(h+=`!$pacem.isNullOrEmpty(${H}) && `)}u=A.join(", ");let T=t=>{let a="false",i="false";if(!e.Utils.isNullOrEmpty(t.notEqual)){const e=[];for(let a in t.notEqual)e.push("("+t.notEqual[a].join(" && ")+")");a="("+e.join(" || ")+")"}return e.Utils.isNullOrEmpty(t.empty)||(i="("+t.empty.join(" || ")+")"),a+" || "+i};p=T(V),d=`{{ ${p} }}`,this.setAttribute("hide",`{{ ${T(O)} }}`)}const _="fn",g=this[_]=this[_]||{},y=(t=[])=>{let a=(m||[]).map(e=>":host.entity."+e.prop).join(", ");const i="fn"+e.Utils.uniqueCode();if("function"==typeof t)g[i]=t;else{if(!e.Utils.isArray(t))throw"Unsupported source format.";g[i]=()=>t}return`{{ :host.${_}.${i}(${a}) }}`},f=new DocumentFragment;let C;if("function"==typeof n.type){var P=n.type(this,":host",":host.entity");if(-1===P.tagName.indexOf("-"))this.log(e.Logging.LogLevel.Error,`${s} is not an allowed form-field`);else{function W(t,a){if(!e.Utils.isNullOrEmpty(a))for(let i of a){if(-1===i.tagName.indexOf("-")){this.log(e.Logging.LogLevel.Error,`${i.tagName} is not an allowed child element for form-field ${s}`);continue}const a=document.createElement(i.tagName);if(!e.Utils.isNullOrEmpty(i.attrs))for(let e in i.attrs){const t=i.attrs[e];a.setAttribute(e,t)}e.Utils.isNullOrEmpty(i.children)||W(a,i.children),t.appendChild(a)}}s=P.tagName,e.Utils.extend(o,P.attrs||{}),W(f,P.children)}}else switch(C=n.display&&n.display.ui){case"contentEditable":console.warn("`contentEditable` ui hint is deprecated. Lean on `dataType` equal to 'HTML' instead."),s=e.P+"-contenteditable",f.append(a.ContenteditableUtils.getDefaultDashboard());break;case"snapshot":s=e.P+"-snapshot",l.width>0&&(o.width=""+l.width),l.height>0&&(o.height=""+l.height),l.quality>=0&&(o.quality=""+l.quality);break;case"chars":case"digits":case"otp":s=e.P+"-input-chars",l.charCount>0&&(o.charCount=""+l.charCount),e.Utils.isNullOrEmpty(l.inputTransform)||(o["input-transform"]=l.inputTransform);break;case"oneToMany":case"dropdown":case"radioList":case"checkboxList":case"manyToMany":"oneToMany"===C||"dropdown"===C?(s=e.P+"-select",!1!==l.preventWheel&&(o["on-wheel"]="$event.preventDefault()")):(delete o.placeholder,s=e.P+("radioList"===C?"-radio-list":"-checkbox-list")),e.Utils.isNullOrEmpty(l.textProperty)||(o["text-property"]=l.textProperty),e.Utils.isNullOrEmpty(l.disabledProperty)||(o["disabled-property"]=l.disabledProperty),e.Utils.isNullOrEmpty(l.valueProperty)||(n.isComplexType?o["compare-by"]=l.valueProperty:o["value-property"]=l.valueProperty),e.Utils.isNullOrEmpty(l.source)?(this._fetcher.id=`fetch${this._key}`,this._fetcher.url=l.sourceUrl,this._fetcher.method=l.verb,c.parameters=`{{ { ${u} } }}`,c.disabled=d,o.datasource=`{{ ${h}Pacem.Utils.getApiResult(#fetch${this._key}.result) || null }}`):o.datasource=y(l.source);break;case"suggest":case"tags":case"autocomplete":const B="tags"===n.display.ui;s=e.P+(B?"-tags":"-suggest"),this._fetcher.id=`fetch${this._key}`,e.Utils.isNullOrEmpty(l.textProperty)||(o["text-property"]=l.textProperty);let R=`#${this._key}.value`;if(e.Utils.isNullOrEmpty(l.valueProperty)||(o["compare-by"]=l.valueProperty,B?R=`(${R} && ${R}.${l.valueProperty}) || ''`:n.isComplexType?R+=` && ${R}.${l.valueProperty}`:o["value-property"]=l.valueProperty),e.Utils.isNullOrEmpty(l.sourceUrl)?o.datasource=y(l.source):(c.url=`${l.sourceUrl}`,this._fetcher.method=l.verb,e.Utils.isNullOrEmpty(l.dependsOn)?c.parameters=`{{ {q: #${this._key}.hint || '', ${l.valueProperty||"value"}: ${R} || '' } }}`:(c.parameters=`{{ { ${u}, q: #${this._key}.hint || '', ${l.valueProperty||"value"}: ${R} || '' } }}`,c.disabled=d),o.datasource=`{{ ${h}Pacem.Utils.getApiResult(#fetch${this._key}.result) || null }}`),B)o["allow-new"]=(!0===n.extra.allowNew).toString(),o["allow-duplicates"]=(!0===n.extra.allowDuplicates).toString();else{if(e.Utils.isNullOrEmpty(l.disabledProperty)||(o["disabled-property"]=l.disabledProperty),!e.Utils.isNullOrEmpty(l.itemtemplate)){const z=l.itemtemplate;z instanceof HTMLElement?(o.itemtemplate="{{ #"+(z.id=z.id||this._key+"_itemtmpl")+" }}",z.isConnected||this.append(z)):o.itemtemplate=z}if(!e.Utils.isNullOrEmpty(l.filterFields)){const j=l.filterFields;o["filter-fields"]=e.Utils.isArray(j)?j.join(" "):j}e.Utils.isNullOrEmpty(l.maxSuggestions)||(o["max-suggestions"]=l.maxSuggestions.toString())}break;case"calendar":s=e.P+"-calendar-picker";const M=n.display?.format??n.extra?.format;e.Utils.isNullOrEmpty(M)||(o.format="{{ "+JSON.stringify(M)+" }}"),e.Utils.isNullOrEmpty(l.disabledRanges)||(o["disabled-ranges"]="{{ "+JSON.stringify(l.disabledRanges)+" }}");break;case"dictionary":s=e.P+"-namevalue-list",o.dictionary="true";break;case"switcher":if("boolean"!==(n.type||"").toLowerCase())break;o.class="checkbox-switch";default:let q=(n.dataType||n.type||"").toLowerCase();switch(q){case"upload":s=e.P+"-upload";let J=n.extra||{};o.url=J.uploadUrl,o.parallelism=""+J.parallelism,o["chunk-size"]=""+J.chunkSize,o["max-image-width"]=""+J.maxImageWidth,o["max-image-height"]=""+J.maxImageHeight,o["select-mode"]=J.mode??"file";break;case"html":s=e.P+"-contenteditable",f.append(a.ContenteditableUtils.getDefaultDashboard());break;case"enumeration":s=e.P+"-radio-list",o.class=e.PCSS+"-radio-list",o["value-property"]="value",o["text-property"]="caption",o.datasource="{{ "+JSON.stringify(n.extra.enum)+" }}",delete o.placeholder;break;case"password":s=e.P+"-input-password";break;case"emailaddress":s=e.P+"-input-email";break;case"color":s=e.P+"-input-color";break;case"time":case"date":case"datetime":s=e.P+"-datetime-picker",delete o.placeholder,"datetime"===q&&(o.precision="minute");const Y=n.display?.format??n.extra?.format;e.Utils.isNullOrEmpty(Y)||(o.format="{{ "+JSON.stringify(Y)+" }}"),e.Utils.isNullOrEmpty(l.disabledRanges)||(o["disabled-ranges"]="{{ "+JSON.stringify(l.disabledRanges)+" }}");break;case"url":s=e.P+"-input-url";break;case"phonenumber":s=e.P+"-input-tel";break;case"multilinetext":s=e.P+"-textarea";break;case"markdown":s=e.P+"-textarea-markdown";break;case"latlng":s=e.P+"-latlng",e.Utils.isNullOrEmpty(n.extra)||"object"!=typeof n.extra||e.Utils.isArray(n.extra)||(o.options=JSON.stringify(n.extra));break;case"percent":case"percentage":case"currency":let K="currency"===q?{style:"currency",currency:"EUR"}:{style:"percent",maximumFractionDigits:2},G=n.display?.format??K;o.format=JSON.stringify(G);default:switch((n.type||"").toLowerCase()){case"boolean":s=e.P+"-checkbox",o["true-value"]="{{ true }}",o["false-value"]="{{ false }}",o.caption=o.placeholder,delete o.placeholder;break;case"byte":o.min="0",o.max="255";case"int16":case"int32":case"int64":case"short":case"integer":case"int":case"long":o.step=""+(n.extra?.step??"1"),s=r;const X=n.display?.format;e.Utils.isNullOrEmpty(X)||(o.format=JSON.stringify(X)),!1!==l.preventWheel&&s===e.P+"-input-number"&&(o["on-wheel"]="$event.preventDefault()");break;case"double":case"decimal":case"float":case"single":case"number":s=r,o.step=""+(n.extra?.step??"any");const Z=n.display?.format;e.Utils.isNullOrEmpty(Z)||(o.format=JSON.stringify(Z)),!1!==l.preventWheel&&s===e.P+"-input-number"&&(o["on-wheel"]="$event.preventDefault()");break;default:if(("array"===n.type||"object"===n.type)&&!e.Utils.isNullOrEmpty(n.props)){if(s=e.P+"-childform",delete o.placeholder,o.metadata=e.Utils.Json.stringify(n.props,{functions:e.JsonFunctionConversion.Reference}),o.mode=n.type,o["lock-items"]=""+(n.extra&&n.extra.lockItems||!1),o.logger="{{ :host.logger }}",!e.Utils.isNullOrEmpty(m)){var b="";for(let Q of m)b+=`<${e.P}-childform-propagator model="${o.value}" watch="{{ :host.entity.${Q.prop} }}" property="${Q.alias||Q.prop}"></${e.P}-childform-propagator>\n`;this._container.innerHTML=b}o["fetch-credentials"]="{{ :host.fetchCredentials }}",o["fetch-headers"]="{{ :host.fetchHeaders }}"}}}}if(!e.Utils.isNullOrEmpty(n.commands)){e.Utils.addClass(this._container,e.PCSS+"-fieldgroup");const ee=this._container.appendChild(document.createElement("div")),te=this._container.appendChild(document.createElement("div"));e.Utils.addClass(ee,`fieldgroup-prepend ${e.PCSS}-buttonset buttons`),e.Utils.addClass(te,`fieldgroup-append ${e.PCSS}-buttonset buttons`);const ae=p||"false";n.commands.forEach(t=>{const a=document.createElement(e.P+"-button");a.setAttribute("icon-glyph",t.icon),a.setAttribute("command-name",t.name),t.dependsOnValue?(a.setAttribute("disabled",`{{ (${ae}) || !::_form.valid || $pacem.isNullOrEmpty(:host.entity.${n.prop}) }}`),a.setAttribute("command-argument",`{{ :host.entity.${n.prop} }}`)):a.setAttribute("disabled",d),a.setAttribute("tooltip",t.tooltip),e.Utils.isNullOrEmpty(t.cssClass)||e.Utils.addClass(a,t.cssClass.join(" ")),(t.prepend?ee:te).appendChild(a)})}e.Utils.isNullOrEmpty(n.validators)||n.validators.forEach(t=>{var r,l={},c={};switch(function(e){return"errorMessage"in e}(t)&&(l=t.params||{},c["error-message"]=t.errorMessage),function(e){return"attributes"in e&&"function"==typeof e.attributes}(t)&&e.Utils.extend(c,t.attributes(this,":host",":host.entity")),t.type){case"required":o.required="true",r=new a.PacemRequiredValidatorElement;break;case"length":let d=new a.PacemLengthValidatorElement;r=d;let h=l&&l.max,p=l&&l.min;null!=h?(o.maxlength=""+(d.max=h),s===e.P+"-input-chars"&&(o.count??=""+h)):"max"in c&&(o.max=c.max),null!=p?o.minlength=""+(d.min=p):"min"in c&&(o.minlength=c.min);break;case"range":let u=new a.PacemRangeValidatorElement;r=u;let v=l&&l.max,_=l&&l.min,g=s===e.P+"-datetime-picker";null!=v?(u.max=v,o.max="{{ "+(g?"'"+v+"'":v)+" }}"):"max"in c&&(o.max=c.max),null!=_?(u.min=_,o.min="{{ "+(g?"'"+_+"'":_)+" }}"):"min"in c&&(o.min=c.min);break;case"email":let y=new a.PacemRegexValidatorElement;r=y,o.pattern=i(y.pattern=/^[\w\-\.]+@[\w\-\.]+\.[a-zA-Z0-9]{2,6}$/);break;case"regex":let f=new a.PacemRegexValidatorElement;r=f;let C=l.pattern;C||=c.pattern,o.pattern=i(C),f.pattern=C;break;case"binary":let P=new a.PacemBinaryValidatorElement;r=P;let b=l.pattern;null!=b?(o.pattern=i(b),P.pattern=b):"pattern"in c&&(o.pattern=c.pattern);let E=l&&l.maxSize;null!=E?(P.maxSize=E,o["max-size"]=""+E):"max-size"in c&&(o["max-size"]=c["max-size"]);break;case"compare":let w=new a.PacemCompareValidatorElement;r=w;let S="";if("value"in l)S=JSON.stringify(l.value);else{S=`:host.entity.${"to"in l?l.to:l.toProperty}`}const k=`{{ ${S} }}`;w.setAttribute("to",k);let $=w.operator=l.operator||c.operator||"equal";if(s===e.P+"-datetime-picker")switch($){case"lessOrEqual":case"less":o.max=k;break;case"greaterOrEqual":case"greater":o.min=k}break;case"async":let U=new a.PacemAsyncValidatorElement;r=U,U.url=l.url;let N=[],x=l.dependsOn||m;N.push(`${n.prop}: :host._adjustDependencyValue(:host.entity.${n.prop})`);for(let e of x||[])N.push(`${e.alias||e.prop}: :host._adjustDependencyValue(:host.entity.${e.prop})`);U.setAttribute("parameters",`{{ { ${N.join(", ")} } }}`),U.method=l.verb||e.Net.HttpMethod.Get,U.setAttribute("fetch-credentials","{{ :host.fetchCredentials }}"),U.setAttribute("fetch-headers","{{ :host.fetchHeaders }}");break;case"custom":r=new a.PacemCustomValidatorElement;break;default:if(!e.Utils.isNullOrEmpty(t.type)&&t.type.indexOf("-")>0){const e=t.type,i=document.createElement(e);i instanceof a.PacemBaseValidatorElement&&(r=i)}}if(e.Utils.isNull(r))throw`Cannot generate a formfield validator based on type: ${t.type}.`;r.watch=n.prop,r.setAttribute("hide","{{ !this.invalid }}"),r.setAttribute("disabled",d);for(let e in c)r.setAttribute(e,c[e]);this._validators.appendChild(r)});let E=document.createElement(s);for(var w in o){let ie;e.Utils.isNullOrEmpty(ie=o[w])||E.setAttribute(w,ie)}for(var w in E.append(f),this._field=E,this._container.insertBefore(E,this._container.firstElementChild),c){let ne;e.Utils.isNullOrEmpty(ne=c[w])||this._fetcher.setAttribute(w,ne)}this.dispatchEvent(new e.PropertyChangeEvent({propertyName:"field",currentValue:E}))}};__decorate([e.ViewChild("label")],n.prototype,"_label",void 0),__decorate([e.ViewChild(`div.${e.PCSS}-input-container`)],n.prototype,"_container",void 0),__decorate([e.ViewChild(e.P+"-fetch")],n.prototype,"_fetcher",void 0),__decorate([e.ViewChild(e.P+"-form")],n.prototype,"_form",void 0),__decorate([e.ViewChild(e.P+"-panel."+e.PCSS+"-validators")],n.prototype,"_validators",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Json})],n.prototype,"metadata",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Json})],n.prototype,"fetchHeaders",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],n.prototype,"fetchCredentials",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Boolean})],n.prototype,"readonly",void 0),__decorate([e.Watch()],n.prototype,"entity",void 0),n=__decorate([e.CustomElement({tagName:e.P+"-form-field",template:`<${e.P}-form class="${e.PCSS}-field" logger="{{ :host.logger }}" \ncss-class="{{ {'${e.PCSS}-fetching': ::_fetcher.fetching, '${e.PCSS}-dirty': this.dirty, '${e.PCSS}-invalid': !this.valid, '${e.PCSS}-editable': !:host.readonly, '${e.PCSS}-readonly': :host.readonly, '${e.PCSS}-pristine': !this.dirty, '${e.PCSS}-valid': this.valid, '${e.PCSS}-has-value': !:host._isValueNullOrEmpty(:host.entity, :host.metadata) } }}">\n <label class="${e.PCSS}-label"><${e.P}-span></${e.P}-span></label>\n <div class="${e.PCSS}-input-container"></div>\n <${e.P}-fetch debounce="300" logger="{{ :host.logger }}" credentials="{{ :host.fetchCredentials }}" headers="{{ :host.fetchHeaders }}" diff-by-values="true"\n on-fetchresult=":host._broadcastFetchResult($event.detail)"></${e.P}-fetch>\n <${e.P}-panel class="${e.PCSS}-validators" hide="{{ ::_form.valid || !::_form.dirty || :host.readonly }}"></${e.P}-panel>\n</${e.P}-form>`})],n),a.PacemFormFieldElement=n}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){let a=class PacemGeolocateElement extends t.PacemBaseElement{constructor(){super(...arguments),this._dragendHandler=e=>{this._reverseGeocoder.position=e.detail.position}}get inputFields(){return[]}toggleReadonlyView(e){this._setupSuggest(),this._setupMapMarker()}onChange(t){return new Promise((a,i)=>{if("success"===t.type&&t.target===this._reverseGeocoder){const i=this.#l.position,n=t.detail.sort((t,a)=>e.Maps.MapProjection.distanceBetween(t.position,i)<e.Maps.MapProjection.distanceBetween(a.position,i)?0:-1),s=n[0].position.altitude,r=e.Utils.extend({},n[0],{position:e.Utils.extend({altitude:s},i)});a(this.value=r)}else t.type===e.Scaffolding.FieldChangeEventName&&t.target===this._suggest?a(this.value=this._suggest.value):a(this.value)})}fetch(t){e.Maps.LatLng.isLatLng(t)&&(this.#l.position=this._reverseGeocoder.position=t)}compareValuePropertyValues(t,a){const i=t?.position??e.Maps.LatLng.Empty,n=a?.position??e.Maps.LatLng.Empty;return e.Maps.LatLng.equals(i,n)}acceptValue(t){e.Utils.isNull(t)?this._datasource.model=[]:(this._datasource.model=[t],this._setupMapMarker()),this._setupSuggest()}getViewValue(e){return e?.fullAddress||""}convertValueAttributeToProperty(t){return e.PropertyConverters.Json.convert(t,this)}#l;viewActivatedCallback(){super.viewActivatedCallback(),this._setup()}propertyChangedCallback(e,t,a,i){if(super.propertyChangedCallback(e,t,a,i),!i)switch(e){case"adapter":this._setupAdapters(a);break;case"map":t&&this._detachMarker(t),a&&this._setupMapMarker(a);break;case"icon":this._setupMapMarker();break;case"plaeholder":this._setupSuggest();break;case"disabled":this._setupMapMarker(),this._setupSuggest()}}disconnectedCallback(){this._disposeMarker(),super.disconnectedCallback()}_setupAdapters(t=this.adapter){const a=this._geocoder,i=this._reverseGeocoder;e.Utils.isNull(a)||(a.adapter=t),e.Utils.isNull(i)||(i.adapter=t)}_setupSuggest(){const t=this._suggest;e.Utils.isNull(t)||(t.placeholder=this.placeholder??"search...",t.readonly=this.readonly,t.disabled=this.disabled,t.value=this.value)}_detachMarker(t=this.map){const a=this.#l;e.Utils.isNull(a)||a.map!==t||a.remove()}_createMarker(){const t=new e.Components.Maps.PacemMapMarkerElement;return t.addEventListener("dragend",this._dragendHandler,!1),t}_disposeMarker(){const t=this.#l;e.Utils.isNull(t)||t.removeEventListener("dragend",this._dragendHandler,!1)}_setupMapMarker(t=this.map){const a=this.#l||(this.#l=this._createMarker());a.icon=this.icon,a.draggable=!this.readonly&&!this.disabled,a.hide=this.disabled;const i=this.value;i&&i.position&&(a.position=i.position),a.map===t||e.Utils.isNull(t)||t.appendChild(a)}_setup(){this._setupAdapters(),this._setupSuggest(),this._setupMapMarker()}};__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Element})],a.prototype,"adapter",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Element})],a.prototype,"map",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Json})],a.prototype,"icon",void 0),__decorate([e.ViewChild(e.P+"-data[ds]")],a.prototype,"_datasource",void 0),__decorate([e.ViewChild(e.P+"-suggest")],a.prototype,"_suggest",void 0),__decorate([e.ViewChild(e.P+"-map-geocode")],a.prototype,"_geocoder",void 0),__decorate([e.ViewChild(e.P+"-map-geocode[reverse]")],a.prototype,"_reverseGeocoder",void 0),a=__decorate([e.CustomElement({tagName:e.P+"-geolocate",shadow:!1,template:`<${e.P}-map-geocode search="{{ ::_suggest.hint }}"\n disabled="{{ (::_suggest.hint || '').length < 3 }}" on-success="::_datasource.model = $event.detail"></${e.P}-map-geocode>\n<${e.P}-map-geocode reverse on-success=":host.changeHandler($event)"></${e.P}-map-geocode>\n\n<${e.P}-data ds></${e.P}-data>\n\n<${e.P}-suggest on-change=":host.changeHandler($event)" datasource="{{ ::_datasource.model || [] }}"\n compare-by="fullAddress" text-property="fullAddress"></${e.P}-suggest>`})],a),t.PacemGeolocateElement=a}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(a){class HierarchyChangeEvent extends CustomEvent{constructor(e){super("hierarchychange",{detail:e,bubbles:!1,cancelable:!1})}}const i="hierarchy-item",n=i+" "+e.PCSS+"-anim anim-fade-in anim-sudden",s="{{ { 'item-disabled' : ^item.disabled } }}",r="pacemHierarchy",o="item-content",l="item-link",c=l+" icon-rotate rotate-135",d="link",h="item-move",p="drag_indicator",u="parents";let m=class PacemHierarchyElement extends a.PacemBaseElement{getViewValue(e){return""}convertValueAttributeToProperty(t){return e.Utils.Json.parse(t)}constructor(){super(),this.#c=new Map,this.#d=new Map,this.unlinkCaption="Delete",this._binderClickHandler=t=>{const a=t.originalEvent.type;if("mousedown"===a&&1===t.originalEvent.button){e.avoidHandler(t.originalEvent);const a=t.srcElement;this._unlink(a)}else if("click"===a||"contextmenu"===a){e.avoidHandler(t.originalEvent),this.#h=t.srcElement;const a=this._balloon;a.target={x:t.pageX,y:t.pageY},a.popup()}},this._dragInitHandler=t=>{let a=t.detail;const i=this._dragger;i.floater=document.createElement("span"),i.dropTargets=Array.from(this.#d.keys()).filter(e=>e!==a.element),e.Utils.isNull(this.#p)||this.#p.remove();const n=this.#p=new e.Components.UI.PacemBinderElement;n.from=a.element,this.#u.appendChild(n)},this._dragStartHandler=t=>{e.Utils.addClass(t.detail.element,"item-drag")},this._dragHandler=e=>{this.#p.to=e.detail.currentPosition},this._dragEndHandler=t=>{e.Utils.removeClass(t.detail.element,"item-drag"),this.#p.remove(),this.#p=null},this._dropHandler=e=>{const t=e.detail.data,a=this.#d.get(e.detail.target);this._isInAncestors(t,a)||this._isInDescendants(t,a)||this._compileHierarchy({source:t,target:a})},this._dragOverHandler=e=>{const t=e.detail.data,a=this.#d.get(e.detail.target);(a.disabled||this._isInAncestors(t,a)||this._isInDescendants(t,a))&&e.preventDefault()},this._dragOutHandler=e=>{},this._popoutHandler=e=>{this._balloon.popout()},this.#m=e.Utils.uniqueCode()}#m;#c;#p;#h;#d;#u;get inputFields(){return[]}toggleReadonlyView(t){this._dragger.disabled=t,e.Utils.isNull(this._adaptedDatasource)||this._databind()}onChange(t){return new Promise((a,i)=>{e.CustomEventUtils.isInstanceOf(t,HierarchyChangeEvent)&&a(this.value=t.detail),a(this.value)})}acceptValue(e){}viewActivatedCallback(){super.viewActivatedCallback(),this.#u=e.CustomElementUtils.findAncestorShell(this),this._setupItemTemplate(),this._setupDragger(),this._setupBalloon()}propertyChangedCallback(e,t,a,i){switch(super.propertyChangedCallback(e,t,a,i),e){case"datasource":case"textProperty":case"disabledProperty":case"valueProperty":cancelAnimationFrame(this._handle),this._handle=requestAnimationFrame(()=>{this._buildAdaptedDatasource()});break;case"itemtemplate":i||this._setupItemTemplate();break;case"_adaptedDatasource":case"value":cancelAnimationFrame(this._handle2),this._handle2=requestAnimationFrame(()=>{this._databind()})}}disconnectedCallback(){this._disposeDragger(),this._disposeBalloon(),super.disconnectedCallback()}_buildAdaptedDatasource(e=this.datasource){this._adaptedDatasource=e&&e.map(e=>this._mapEntityToItem(e))}_mapEntityToValue(e){let t,a=e;return(t=this.valueProperty)&&(a=e[t]),a}_mapEntityToViewValue(e){let t,a=e.toString();return(t=this.textProperty)&&(a=e[t]),a}_mapEntityToItem(t){if(null==t)throw new Error("Entity cannot be null");let a=!1;const i=this.disabledProperty;return e.Utils.isNullOrEmpty(i)||(a=t[i]||!1),{value:this._mapEntityToValue(t),viewValue:this._mapEntityToViewValue(t),disabled:a,data:t}}_unlink(e){var a;e instanceof t.UI.PacemBinderElement?a=e:(e.preventDefault(),e.stopPropagation(),a=this.#h);const{parent:i,child:n}=JSON.parse(a.dataset[r]),s=this._adaptedDatasource,o=s.find(e=>e.value===i),l=s.find(e=>e.value===n);o.disabled||l.disabled||this._compileHierarchy({source:o,target:l},!0)}_buildHierarchyItemDomId(e){return`hierarchyitem_${this.#m}_${e}`}_itemCreate(a){const n=a.detail.dom.find(e=>e instanceof HTMLElement&&e.classList.contains(i)),s=(a.detail.index,a.detail.item);n.id=this._buildHierarchyItemDomId(s.value),s.disabled?n.setAttribute("behaviors","{{ [#"+this._dragger2.id+"] }}"):n.setAttribute("behaviors","{{ [#"+this._dragger.id+", #"+this._dragger2.id+"] }}");for(let a of s.parents||[]){const i=new e.Components.UI.PacemBinderElement;i.to=n,i.toAnchor=t.UI.BinderAnchor.Top,i.toEnd=t.UI.BinderEnd.Arrow,i.setAttribute("from","{{ #"+this._buildHierarchyItemDomId(a.value)+" }}"),i.fromAnchor=t.UI.BinderAnchor.Bottom,i.cssClass=["hierarchy-binder"],i.interactive=!this.readonly&&!s.disabled&&!a.disabled,i.addEventListener(t.UI.BinderInteractionEventName,this._binderClickHandler,!1),i.dataset[r]=JSON.stringify({parent:a.value,child:s.value}),this.#c.set(s.value,i),this.#u.appendChild(i)}this.#d.has(n)||this.#d.set(n,s)}_itemRemove(e){const a=e.detail.dom.find(e=>e instanceof HTMLElement&&e.classList.contains(i)),n=e.detail.item,s=this.#c;if(s.has(n.value)){const e=s.get(n.value);e.removeEventListener(t.UI.BinderInteractionEventName,this._binderClickHandler,!1),e.remove(),s.delete(n.value)}this.#d.has(a)&&this.#d.delete(a)}_setupItemTemplate(){if(this.itemtemplate instanceof HTMLTemplateElement){const a=this.itemtemplate.cloneNode(!0).content,i=document.createElement("template"),r=document.createElement(e.P+"-panel");r.className=n,r.setAttribute("css-class",s);const l=new t.UI.PacemIconElement;l.setAttribute("icon",p),l.className=h,r.appendChild(l);const u=document.createElement("div");u.className=o,u.append(a),r.appendChild(u);const m=new t.UI.PacemIconElement;m.setAttribute("icon",d),m.className=c,r.appendChild(m),i.content.appendChild(r),this._template=i}else this._template=this._defaultTemplate}_compileHierarchy(t,a=!1){const i=e.Utils.clone(this.value||[]),n=t.source.value,s=t.target.value,r=this.parentsProperty||u;var o=i.find(e=>e[this.valueProperty]===s);if(a){if(!e.Utils.isNull(o)){const e=o[r]||[],t=e.indexOf(n);t>=0&&e.splice(t,1)}}else e.Utils.isNull(o)&&((o={})[this.valueProperty]=s,o[r]=[],i.push(o)),o[r].push(n);this._cleanupHierarchy(i),this.changeHandler(new HierarchyChangeEvent(i))}_cleanupHierarchy(t=[]){const a=this.valueProperty,i=this.parentsProperty||u,n=(s,r)=>{const o=t.find(e=>e[a]==r);if(e.Utils.isNull(o)||e.Utils.isNullOrEmpty(o[i]))return!1;const l=o[i];return l.indexOf(s)>=0||l.some(e=>n(s,e))};for(let e of t){const t=e[i]||[];for(let e=t.length-1;e>=0;e--){const a=t[e],i=t.filter(e=>e!==a);for(let s of i)if(n(a,s)){t.splice(e,1);break}}}}_setupDragger(){const t=this._dragger;t.id="hierarchy_link_"+this.#m,t.handleSelector="."+l,t.dropBehavior=e.UI.DropBehavior.None,t.spillBehavior=e.UI.DropTargetMissedBehavior.None,t.mode=e.UI.DragDataMode.Copy,t.addEventListener(e.UI.DragDropEventType.Drop,this._dropHandler,!1),t.addEventListener(e.UI.DragDropEventType.Drag,this._dragHandler,!1),t.addEventListener(e.UI.DragDropEventType.Init,this._dragInitHandler,!1),t.addEventListener(e.UI.DragDropEventType.Start,this._dragStartHandler,!1),t.addEventListener(e.UI.DragDropEventType.End,this._dragEndHandler,!1),t.addEventListener(e.UI.DragDropEventType.Over,this._dragOverHandler,!1),t.addEventListener(e.UI.DragDropEventType.Out,this._dragOutHandler,!1);const a=this._dragger2;a.id="hierarchy_move_"+this.#m,a.mode=e.UI.DragDataMode.Self,a.dropBehavior=e.UI.DropBehavior.None,a.spillBehavior=e.UI.DropTargetMissedBehavior.None,a.handleSelector="."+h}_disposeDragger(){const t=this._dragger;e.Utils.isNull(t)||(t.removeEventListener(e.UI.DragDropEventType.Drop,this._dropHandler,!1),t.removeEventListener(e.UI.DragDropEventType.Drag,this._dragHandler,!1),t.removeEventListener(e.UI.DragDropEventType.Init,this._dragInitHandler,!1),t.removeEventListener(e.UI.DragDropEventType.Start,this._dragStartHandler,!1),t.removeEventListener(e.UI.DragDropEventType.End,this._dragEndHandler,!1),t.removeEventListener(e.UI.DragDropEventType.Over,this._dragOverHandler,!1),t.removeEventListener(e.UI.DragDropEventType.Out,this._dragOutHandler,!1))}_setupBalloon(){this._balloon=this._shellProxy.dom.find(e=>e instanceof t.UI.PacemBalloonElement),window.addEventListener("mousedown",this._popoutHandler,!1)}_disposeBalloon(){window.removeEventListener("mousedown",this._popoutHandler,!1)}_isInAncestors(t,a){return!e.Utils.isNull(a)&&!e.Utils.isNullOrEmpty(a.parents)&&(a.parents.indexOf(t)>=0||a.parents.some(e=>this._isInAncestors(t,e)))}_isInDescendants(e,t){return this._isInAncestors(t,e)}_databind(){this._repeater.datasource=[];const t=this.valueProperty;if(e.Utils.isNullOrEmpty(t))throw new Error("Missing valueProperty.");const a=e.Utils.clone(this._adaptedDatasource||[]),i=this.value||[],n=this.parentsProperty||u;for(let s of a){const r=i.find(e=>e[t]===s.value);e.Utils.isNull(r)||(s.parents=(r[n]||[]).map(e=>a.find(t=>t.value===e)).filter(t=>!e.Utils.isNull(t)))}this._databindByParents(a)}_databindByParents(t){const a=[];function i(){return a.reduce((e,t)=>e+t.length,0)}do{if(e.Utils.isNullOrEmpty(a)){const i=t.filter(t=>e.Utils.isNullOrEmpty(t.parents));a.push(i)}else{const i=Array.prototype.concat.apply([],a),n=a[a.length-1],s=t.filter(t=>!e.Utils.isNullOrEmpty(t.parents)&&(t.parents.every(e=>i.indexOf(e)>=0)&&t.parents.some(e=>n.indexOf(e)>=0)));a.push(s)}}while(i()<t.length);this._repeater.datasource=a}};__decorate([e.ViewChild("template[default]")],m.prototype,"_defaultTemplate",void 0),__decorate([e.ViewChild(e.P+"-repeater")],m.prototype,"_repeater",void 0),__decorate([e.ViewChild(e.P+"-drag-drop")],m.prototype,"_dragger",void 0),__decorate([e.ViewChild(e.P+"-drag-drop[move]")],m.prototype,"_dragger2",void 0),__decorate([e.ViewChild(e.P+"-shell-proxy")],m.prototype,"_shellProxy",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Json})],m.prototype,"datasource",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String})],m.prototype,"valueProperty",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String})],m.prototype,"textProperty",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String})],m.prototype,"disabledProperty",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],m.prototype,"unlinkCaption",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Json})],m.prototype,"_adaptedDatasource",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Element})],m.prototype,"itemtemplate",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Element})],m.prototype,"_template",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String})],m.prototype,"parentsProperty",void 0),m=__decorate([e.CustomElement({tagName:e.P+"-hierarchy",shadow:e.Defaults.USE_SHADOW_ROOT,template:`<${e.P}-repeater>\n <template>\n <${e.P}-repeater on-${t.RepeaterItemCreateEventName}=":host._itemCreate($event)" on-${t.RepeaterItemRemoveEventName}=":host._itemRemove($event)" datasource="{{ ^item }}">\n <div class="hierarchy-level">\n <${e.P}-template-proxy target="{{ :host._template }}"></${e.P}-template-proxy>\n </div>\n </${e.P}-repeater>\n </template>\n </div>\n</${e.P}-repeater><${e.P}-content></${e.P}-content>\n<${e.P}-drag-drop></${e.P}-drag-drop>\n<${e.P}-drag-drop move></${e.P}-drag-drop>\n<template default>\n <${e.P}-panel class="${n} item-default" css-class="${s}">\n <${e.P}-icon class="${h}" icon="${p}"></${e.P}-icon>\n <pacem-span class="${o}" content="{{ ^item.viewValue }}"></${e.P}-span>\n <${e.P}-icon class="${c}" icon="${d}"></${e.P}-icon>\n </${e.P}-panel>\n</template>\n<${e.P}-shell-proxy>\n <${e.P}-balloon options="{{ { behavior: Pacem.Components.UI.BalloonBehavior.Inert } }}">\n <${e.P}-button icon-glyph="link_off" class="${e.PCSS}-margin margin-0 button-flat display-flex flex-middle icon-rotate rotate-135"\n on-click=":host._unlink($event)"\n on-mousedown="$event.stopPropagation()"\n on-mouseup="::_balloon.popout()"><${e.P}-text class="${e.PCSS}-margin margin-left-1" text="{{ :host.unlinkCaption }}"></${e.P}-text></${e.P}-button>\n </${e.P}-balloon>\n</${e.P}-shell-proxy>`})],m),a.PacemHierarchyElement=m}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){let a;!function(e){e.Input="input",e.Blur="blur"}(a=t.ChangePolicy||(t.ChangePolicy={}));const i="pacem:scaffolding:input_field";class PacemBaseInputElement extends t.PacemBaseElement{constructor(){super(...arguments),this.debounce=!1,this.changePolicy=a.Input,this._focusHandler=e=>{if(!this.autoselect)return;let t=this.inputField;for(let e of this.inputFields??[])if(e===document.activeElement){t=e;break}t?.select()}}propertyChangedCallback(e,t,a,i){if(super.propertyChangedCallback(e,t,a,i),"placeholder"===e)for(let t of this.inputFields??[])t.setAttribute(e,a)}acceptValue(t){this.inputField&&t!==this.inputField.value&&(this.inputField.value=e.Utils.isNullOrEmpty(t)?"":t)}get inputField(){return this.inputFields[0]}onChange(e){return new Promise(t=>{if(this.readonly)t(this.value);else if("input"===e.type&&this.changePolicy===a.Blur)t(this.value);else{const e=()=>{const e=this.getValue(this.inputField.value);e!==this.value&&(this.value=e),t(e)},a=this.debounce;"number"==typeof a&&a>0?(clearTimeout(this._handle),this._handle=setTimeout(e,a)):!0===a?(cancelAnimationFrame(this._handle),this._handle=requestAnimationFrame(e)):requestAnimationFrame(e)}})}registerInputFields(t=this.inputFields){super.registerInputFields(t),e.Utils.isNull(t)||e.Utils.isArray(t)||(t=[t]);for(let a of t??[])a instanceof HTMLInputElement&&"on"!==e.CustomElementUtils.getAttachedPropertyValue(a,i,"off")&&(e.CustomElementUtils.setAttachedPropertyValue(a,i,"on"),a.size=1,a.autocomplete="off",a.addEventListener("input",this.changeHandler,!1),a.addEventListener("focus",this._focusHandler,!1))}unregisterInputFields(t=this.inputFields){super.unregisterInputFields(t),e.Utils.isNull(t)||e.Utils.isArray(t)||(t=[t]);for(let a of t??[])"on"===e.CustomElementUtils.getAttachedPropertyValue(a,i)&&(e.CustomElementUtils.deleteAttachedPropertyValue(a,i),a.removeEventListener("input",this.changeHandler,!1),a.removeEventListener("focus",this._focusHandler,!1))}viewActivatedCallback(){super.viewActivatedCallback(),this.registerInputFields()}disconnectedCallback(){this.unregisterInputFields(),super.disconnectedCallback()}}__decorate([e.Watch({emit:!1,converter:{convert:e=>{switch(e){case"true":return!0;case"false":return!1;default:return parseFloat(e)}},convertBack:e=>e.toString()}})],PacemBaseInputElement.prototype,"debounce",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String})],PacemBaseInputElement.prototype,"changePolicy",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Boolean})],PacemBaseInputElement.prototype,"autoselect",void 0),t.PacemBaseInputElement=PacemBaseInputElement;class PacemOrdinalInputElement extends PacemBaseInputElement{convertValueAttributeToProperty(e){return parseFloat(e)}propertyChangedCallback(e,t,a,i){switch(super.propertyChangedCallback(e,t,a,i),e){case"min":case"max":case"step":null!=a?this.inputField.setAttribute(e,a):this.inputField.removeAttribute(e)}}}__decorate([e.Watch({converter:e.PropertyConverters.Number})],PacemOrdinalInputElement.prototype,"min",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Number})],PacemOrdinalInputElement.prototype,"max",void 0),__decorate([e.Watch({converter:{convert:e=>{const t=parseFloat(e);return isNaN(t)?"any":t},convertBack:e=>e.toString()}})],PacemOrdinalInputElement.prototype,"step",void 0),t.PacemOrdinalInputElement=PacemOrdinalInputElement;class PacemTextualInputElement extends PacemBaseInputElement{convertValueAttributeToProperty(e){return e}propertyChangedCallback(e,t,a,i){switch(super.propertyChangedCallback(e,t,a,i),e){case"pattern":case"maxlength":case"minlength":null!=a?this.inputField.setAttribute(e,a):this.inputField.removeAttribute(e)}}getValue(t){return e.Utils.isNullOrEmpty(t)?null:t}getViewValue(e){return e}}__decorate([e.Watch({converter:e.PropertyConverters.String})],PacemTextualInputElement.prototype,"pattern",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Number})],PacemTextualInputElement.prototype,"minlength",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Number})],PacemTextualInputElement.prototype,"maxlength",void 0),t.PacemTextualInputElement=PacemTextualInputElement}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(a){let i=class PacemCharsInputElement extends a.PacemBaseInputElement{constructor(){super(),this.charCount=6,this.inputTransform="none",this._itemCreateHandler=e=>{const{dom:t,index:a}=e.detail,i=t.find(e=>e instanceof HTMLInputElement);this.#v[a]=i,this.registerInputFields(i)},this.#v=[]}redactViewValue(e=this.value){this.viewValue=this.getViewValue(e)}getValue(t){const a=this.#v.reduce((t,a)=>t+(e.Utils.isNullOrEmpty(a.value)?" ":a.value),"");switch(this.inputTransform){case"lowercase":return a.toLowerCase();case"uppercase":return a.toUpperCase();default:return a}}getViewValue(t){const a=this.charCount;return"password"==this.inputTransform?e.Arrays.range(a).map(e=>"*").join(""):t}convertValueAttributeToProperty(e){return e}toggleReadonlyView(e=this.readonly){this._span.hidden=!e,this._chars.hidden=e}focus(){for(let e of this.inputFields??[])if(e===document.activeElement)return void(this.autofocus&&e.select());super.focus()}propertyChangedCallback(e,t,a,i){if(super.propertyChangedCallback(e,t,a,i),!i)switch(e){case"charCount":this._databind(),this.redactViewValue();break;case"inputTransform":this.registerInputFields(),this.value=this.getValue(this.value)}}registerInputFields(t=this.inputFields){super.registerInputFields(t),e.Utils.isNull(t)||e.Utils.isArray(t)||(t=[t]);const a=this.#v;for(let i of t??[]){const t=a.indexOf(i);e.Utils.toggleClass(i,"last-char",t===this.charCount-1),e.Utils.toggleClass(i,"first-char",0===t),e.Utils.isNullOrEmpty(i.id)&&i.setAttribute("id","code_"+t+"_"+e.Utils.uniqueCode()),i.value=this.value?.charAt(t)||"","password"===this.inputTransform?i.setAttribute("type","password"):i.setAttribute("type","text")}}acceptValue(e){const t=this.#v;if("string"==typeof e){let a=0;const i=Math.min(e.length,t.length);for(let n=0;n<i;n++)t[n].value=e.charAt(n),a++;for(let e=a;e<t.length;e++)t[e].value=""}}onChange(t){return super.onChange(t).then(a=>{const i=this.#v,n=i.indexOf(t.target);if(n>=0&&n<i.length-1){const t=i[n];if(e.Utils.isNullOrEmpty(t.value?.trim()))t.value="";else{i[n+1].focus()}}return a})}viewActivatedCallback(){super.viewActivatedCallback(),e.Utils.isNull(this.autoselect)&&(this.autoselect=!0),this._chars.addEventListener(t.RepeaterItemCreateEventName,this._itemCreateHandler,!1),this._databind()}disconnectedCallback(){const a=this._chars;e.Utils.isNull(a)||a.removeEventListener(t.RepeaterItemCreateEventName,this._itemCreateHandler),super.disconnectedCallback()}_databind(){const t=this.charCount,a=this.#v;a.length>t&&super.unregisterInputFields(a.splice(t)),this._chars.datasource=e.Arrays.range(t)}#v;get inputFields(){return this.#v}};__decorate([e.Watch({emit:!1,reflectBack:!0,converter:e.PropertyConverters.Number})],i.prototype,"charCount",void 0),__decorate([e.Watch({emit:!1,reflectBack:!0,converter:e.PropertyConverters.String})],i.prototype,"inputTransform",void 0),__decorate([e.ViewChild(e.P+"-repeater")],i.prototype,"_chars",void 0),__decorate([e.ViewChild("span."+e.PCSS+"-readonly")],i.prototype,"_span",void 0),i=__decorate([e.CustomElement({tagName:e.P+"-input-chars",template:`<${e.P}-repeater class="display-flex flex-nowrap">\n <template><input type="text" class="${e.PCSS}-input flex-auto" maxlength="1" /></template>\n </${e.P}-repeater><span class="${e.PCSS}-readonly"><${e.P}-text text="{{ :host.viewValue }}"></${e.P}-text></span>`,shadow:e.Defaults.USE_SHADOW_ROOT})],i),a.PacemCharsInputElement=i}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){let a=class PacemColorInputElement extends t.PacemBaseElement{acceptValue(e){const t=this._parseValue(e);null!=t&&(this._tint.value=t.tint,this._alpha.value=t.alpha.toString())}convertValueAttributeToProperty(e){return e}onChange(t){const a=this._alpha.valueAsNumber||parseInt(this._alpha.value),i=this._tint.value,n=this.value=this._getValue(i,a);return e.Utils.fromResult(n)}constructor(){super()}toggleReadonlyView(e){this._wrapper.hidden=e,this._span.hidden=!e}_getValue(t,a){if(isNaN(a)||100===a)return t;const i=e.Colors.parse(t);return i.a=.01*a,e.Colors.stringify(i)}_parseValue(t){const a=e.Colors.parse(t);return e.Utils.isNullOrEmpty(a)?null:{tint:e.Colors.stringify({r:a.r,g:a.g,b:a.b}),alpha:100*a.a}}getViewValue(e){return e}get inputFields(){return[this._tint,this._alpha]}};__decorate([e.ViewChild("input[type=color]")],a.prototype,"_tint",void 0),__decorate([e.ViewChild("input[type=number]")],a.prototype,"_alpha",void 0),__decorate([e.ViewChild(`.${e.PCSS}-viewfinder`)],a.prototype,"_wrapper",void 0),__decorate([e.ViewChild(`.${e.PCSS}-readonly`)],a.prototype,"_span",void 0),a=__decorate([e.CustomElement({tagName:e.P+"-input-color",template:`<div class="${e.PCSS}-viewfinder">\n<${e.P}-panel class="${e.PCSS}-input-color" css="{{ { 'background-color': :host.viewValue } }}"><input type="color" class="${e.PCSS}-input" /></${e.P}-panel>\n<input class="${e.PCSS}-input" type="number" min="0" max="100" step="1" value="100" />\n</div>\n<${e.P}-span class="${e.PCSS}-readonly" css="{{ { 'background-color': :host.viewValue } }}"></${e.P}-span>`,shadow:e.Defaults.USE_SHADOW_ROOT})],a),t.PacemColorInputElement=a}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){let a=class PacemEmailInputElement extends t.PacemTextualInputElement{toggleReadonlyView(e){this.input.hidden=e,this.anchor.hidden=!e}get inputFields(){return[this.input]}};__decorate([e.ViewChild("input[type=email]")],a.prototype,"input",void 0),__decorate([e.ViewChild(e.P+"-a")],a.prototype,"anchor",void 0),a=__decorate([e.CustomElement({tagName:e.P+"-input-email",template:`<input type="email" class="${e.PCSS}-input ${e.PCSS}-viewfinder" />${t.CHAR_COUNTER_CHILD}<${e.P}-a class="${e.PCSS}-readonly" disabled="{{ $pacem.isNullOrEmpty(:host.value) }}" href="{{ 'mailto:'+ :host.value }}"><${e.P}-text text="{{ :host.viewValue }}"></${e.P}-text></${e.P}-a>`,shadow:e.Defaults.USE_SHADOW_ROOT})],a),t.PacemEmailInputElement=a}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){t.FileUploadEventName="fileupload",t.FileChangeEventName="filechange";class StoragePickEvent extends e.CustomTypedEvent{constructor(e){super("pick",e)}}class FileUploadEvent extends e.CustomTypedEvent{constructor(e){super(t.FileUploadEventName,e)}}t.FileUploadEvent=FileUploadEvent;class FileChangeEvent extends e.CustomTypedEvent{constructor(e){super(t.FileChangeEventName,e)}}t.FileChangeEvent=FileChangeEvent;async function a(e,t={files:0,directories:0,size:0}){for await(let[i,n]of e.entries())if("file"===n.kind){t.files++;const e=await n.getFile();t.size+=e.size}else t.directories++,await a(n,t);return t}let i=class PacemUploadElement extends t.PacemBaseElement{constructor(t=new e.Animations.TweenService){super(),this._tweener=t,this.undoCaption="undo",this.retryCaption="retry",this.clearCaption="clear",this.uploading=!1,this.size=0,this.percentage=0,this.complete=!1,this.failed=!1,this.invalidFile=!1,this._fields={parallelism:3,uid:"",ongoing:0,enqueuer:null,blob:null,retryFrom:0,chunkSize:131072,undone:!1}}convertValueAttributeToProperty(e){return e}acceptValue(e){this.percentage=0,this.uploading=!1,this._fileupload.value=""}_getMimeIcon(t=this.value,a=this.uploading,i=this.selectMode??"file"){if(a)return"sync";const n=!e.Utils.isNullOrEmpty(t);switch(i){case"directory":case"directory-picker":return n?"folder":"drive_folder_upload";case"multiple":case"multiple-picker":return n?"files":"upload_file"}if(e.Utils.isNullOrEmpty(t))return"upload_file";var s=t;"object"==typeof t&&(s=t.name);const r=/\.([\w]+)(\s|$)/.exec(s);if(r&&r.length)switch(r[1].toLowerCase()){case"pdf":return"picture_as_pdf";case"jpg":case"jpeg":case"gif":case"png":return"filter"}return"filter_none"}get blob(){return this._fields.blob}get inputFields(){return[this._fileupload]}getViewValue(t){const a=this._localValue||t;if(e.Utils.isNullOrEmpty(a))return"";if("string"==typeof a)return a;let i="name"in a?a.name:"";e.Utils.isArray(a)&&(i=a.map(e=>e.name).join(", "));const{size:n,files:s}=this._stats;return`${i}\n(${s} file${1===s?"":"s"}, ${e.Utils.core.size(n)})`}toggleReadonlyView(e){this._setupInputElement(e)}viewActivatedCallback(){super.viewActivatedCallback(),this._setupInputElement(),this._fileupload.addEventListener("click",e.stopPropagationHandler,!1)}propertyChangedCallback(e,t,a,i){if(super.propertyChangedCallback(e,t,a,i),!i&&"selectMode"===e)this._setupInputElement()}disconnectedCallback(){this._fileupload&&this._fileupload.removeEventListener("click",e.stopPropagationHandler,!1),super.disconnectedCallback()}_setupInputElement(e=this.readonly,t=this.selectMode??"file"){const a=this._fileupload;switch(a.removeAttribute("webkitdirectory"),a.removeAttribute("multiple"),a.hidden=e,t){case"directory":a.setAttribute("webkitdirectory","true");break;case"multiple":a.setAttribute("multiple","true");break;case"directory-picker":case"file-picker":case"multiple-picker":a.hidden=!0}}_dispatchDownload(t){e.avoidHandler(t);const a=this._localValue||this.value,i=e=>{this.dispatchEvent(new CustomEvent("download",{detail:e,bubbles:!0,cancelable:!1}))};e.Utils.isNullOrEmpty(a)||("string"==typeof a?i(a):"content"in a&&!e.Utils.isNullOrEmpty(a.content)?e.Utils.download(e.Utils.dataURLToBlob("data:application/download;base64,"+a.content),a.name,a.type):"name"in a&&("kind"in a&&"file"===a.kind?a.getFile().then(t=>{e.Utils.download(t,t.name,t.type)}):i(a.name)))}reset(){super.reset(),this._localValue=null,this.invalidFile=!1}_validateAll(){const e=this._stats,t=this.maxSize;return t>0&&t<e.size?(this.invalidFile=!0,!1):(this.invalidFile=!1,!0)}_validateSingleFile(e=this._fileupload.files[0],t){e instanceof File&&(t=e.name),t=t.substring(t.lastIndexOf("\\")+1);const a=this.maxSize;if(a>0&&a<e.size)return this.invalidFile=!0,!1;const i=this.pattern;return i&&!new RegExp(i,"i").test(t)?(this.invalidFile=!0,!1):(this.invalidFile=!1,!0)}upload(e,t,a){if(this._validateSingleFile(e,t))return this._upload(e,t,a)}async _upload(e,t,a){var i=this,n=i._fields;if(!e)return;!t&&e instanceof File&&(t=e.name),i.failed=!1,n.undone=!1,n.ongoing=0;const s=e,r=i.size=s.size;t=t.substring(t.lastIndexOf("\\")+1),i.percentage=0,i.complete=!1;var o={filename:t,length:r,action:"start",state:a,type:e.type};i.uploading=!0;try{var l=await i._fetch(o);if(l.ok){var c=await l.json();n.retryFrom=0,n.blob=s,n.uid=c.uid,i._manage()}else i.uploading=!1;return l}catch(e){i.uploading=!1}}async _blobToBase64(t){const a=await e.Utils.blobToDataURL(t);return a.substring(a.indexOf("base64,")+7)}async _doUpload(e,t){var a=this,i=a._fields;i.ongoing++;var n={chunk:await this._blobToBase64(e),uid:i.uid,position:t,action:"do"};try{const e=await a._fetch(n);if(e.ok){if(i.ongoing--,i.undone)return;const t=await e.json();t.percentage>this.percentage&&await a._tweenPercentage(Math.round(Math.max(1,t.percentage)),200),a.complete!=t.complete&&(a.complete=t.complete,!0===a.complete&&(a.uploading=!1,a.changeHandler(new FileUploadEvent(t))))}else i.retryFrom=t,a.failed=!0,a.uploading=!1}catch(e){i.retryFrom=t,a.failed=!0,a.uploading=!1}}_manage(){const e=this._fields,t=this.size,a=e.blob,i=this.chunkSize||e.chunkSize;var n=e.retryFrom,s=n+i;e.enqueuer=setInterval(()=>{if(n<t&&!this.failed){const t=this.parallelism||e.parallelism;if(e.ongoing>=t)return;this._doUpload(a.slice(n,s),n),s=(n=s)+i}else{this._fileupload.value="",window.clearInterval(e.enqueuer)}},100)}async _buildLocalValue(t,a=t.name,i=t){return this._localValue={name:a,size:i.size,type:t.type,lastModified:e.Utils.parseDate(t.lastModified).toISOString(),content:await this._blobToBase64(i)}}_canPick(){return"showDirectoryPicker"in window&&(()=>{try{return window.self===window.top}catch{return!1}})()}_tryPickDirectory(){this._canPick()&&window.showDirectoryPicker({mode:"read"}).then(e=>{this.changeHandler(new StoragePickEvent(e))})}_tryPickFiles(e="multiple-picker"===this.selectMode,t=this.pattern){this._canPick()&&window.showOpenFilePicker({multiple:e}).then(e=>{this.changeHandler(new StoragePickEvent(e))})}_clickHandler(t){if(e.avoidHandler(t),!this.readonly)switch(this.selectMode){case"directory-picker":this._tryPickDirectory();break;case"file-picker":case"multiple-picker":this._tryPickFiles()}}async _mimicCompute(){this.uploading=!0,e.Utils.isNullOrEmpty(this.value)?await e.Utils.idle(250):(this.percentage=0,await e.Utils.waitForAnimationEnd(this._tuner)),await this._tweener.run(0,100,500,0,e.Animations.Easings.sineInOut,(e,t)=>{this.percentage=t}),this.percentage=0,this.uploading=!1}onChange(t){return new Promise(async(i,n)=>{if(e.CustomEventUtils.isInstanceOf(t,FileUploadEvent)){const e=this.value=t.detail.filename;this.dispatchEvent(t),i(e)}else if(e.CustomEventUtils.isInstanceOf(t,StoragePickEvent)){let e,n,s,r=t.detail;switch(this.selectMode){case"directory-picker":e=r,this._stats=await a(e);break;case"multiple-picker":case"file-picker":s=r,1===s.length&&(r=s[0]),this._stats=await async function(e){const t={files:0,directories:0,size:0};for(let a of e){const e=await a.getFile();t.files++,t.size+=e.size}return t}(s);break;default:this._stats={directories:0,files:0,size:0}}i(this.value=this._localValue=r);const o=this._validateAll();this.dispatchEvent(new FileChangeEvent({directory:e,file:n,files:s,valid:o}))}else{let t=this._fileupload;if(0===t.files.length)this._stats={directories:0,files:0,size:0},i(this.value=null);else{const a=t.files.length;if(this._stats={directories:0,files:a,size:Array.from(t.files).reduce((e,t,a)=>e+t.size,0)},a>1){const e=Array.from(t.files);i(this.value=this._localValue=e);const a=this._validateAll();this.dispatchEvent(new FileChangeEvent({files:e,valid:a}))}else{const a=t.files[0],n=a.name;let s=a;this._validateSingleFile(a)||e.Utils.isNullOrEmpty(this.url)?(/\.(jpe?g|png)$/i.test(n)&&this.maxImageWidth>0&&this.maxImageHeight>0&&(s=await e.Utils.Images.resize(s,this.maxImageWidth,this.maxImageHeight,{quality:.8})),await this._buildLocalValue(a,n,s),e.Utils.isNullOrEmpty(this.url)?(await this._mimicCompute(),i(this.value=this._localValue)):(this._upload(s,t.value),i(this.value))):i(this.value=await this._buildLocalValue(a)),this.dispatchEvent(new FileChangeEvent({valid:!this.invalidFile,file:a}))}}}})}_fetch(t){return fetch(this.url,{method:"POST",credentials:this.fetchCredentials,headers:e.Utils.extend({Accept:"application/json","Content-Type":"application/json"},this.fetchHeaders||{}),body:JSON.stringify(t)})}async _undo(e){e.preventDefault(),e.stopPropagation();var t=this,a=t._fields,i=t._fileupload;clearInterval(a.enqueuer);var n={action:"undo",uid:a.uid};try{var s=await t._fetch(n);return s.ok&&(a.undone=!0,t.size=0,t._tweenPercentage(0,300)),s}catch(e){}finally{return i.value="",t.uploading=!1,s}}_tweenPercentage(t,a=500){const i=this.percentage;return this._tweener.run(i,t,a,0,e.Animations.Easings.sineInOut,(e,t)=>{this.percentage=t})}_retry(e){e.preventDefault(),e.stopPropagation(),this.failed=!1,this._manage()}_clear(e){e.preventDefault(),e.stopPropagation(),this.invalidFile=!1;const t=this.inputFields[0];t.value="",/safari/i.test(navigator.userAgent)||(t.type="",t.type="file"),this.changeHandler(null)}};__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Json})],i.prototype,"fetchCredentials",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String})],i.prototype,"fetchHeaders",void 0),__decorate([e.ViewChild("input[type=file]")],i.prototype,"_fileupload",void 0),__decorate([e.ViewChild(`${e.P}-tuner`)],i.prototype,"_tuner",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],i.prototype,"undoCaption",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],i.prototype,"retryCaption",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],i.prototype,"clearCaption",void 0),__decorate([e.Watch({emit:!1,reflectBack:!0,converter:e.PropertyConverters.String})],i.prototype,"pattern",void 0),__decorate([e.Watch({emit:!1,reflectBack:!0,converter:e.PropertyConverters.String})],i.prototype,"url",void 0),__decorate([e.Watch({emit:!1,reflectBack:!0,converter:e.PropertyConverters.Number})],i.prototype,"maxImageWidth",void 0),__decorate([e.Watch({emit:!1,reflectBack:!0,converter:e.PropertyConverters.Number})],i.prototype,"parallelism",void 0),__decorate([e.Watch({emit:!1,reflectBack:!0,converter:e.PropertyConverters.Number})],i.prototype,"chunkSize",void 0),__decorate([e.Watch({emit:!1,reflectBack:!0,converter:e.PropertyConverters.Number})],i.prototype,"maxImageHeight",void 0),__decorate([e.Watch({emit:!1,reflectBack:!0,converter:e.PropertyConverters.Number})],i.prototype,"maxSize",void 0),__decorate([e.Watch({reflectBack:!0,converter:e.PropertyConverters.String})],i.prototype,"selectMode",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Boolean})],i.prototype,"uploading",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Number})],i.prototype,"size",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Number})],i.prototype,"percentage",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Boolean})],i.prototype,"complete",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Boolean})],i.prototype,"failed",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Boolean})],i.prototype,"invalidFile",void 0),i=__decorate([e.CustomElement({tagName:e.P+"-upload",shadow:e.Defaults.USE_SHADOW_ROOT,template:`<${e.P}-button on-click=":host._dispatchDownload($event)" class="${e.PCSS}-upload ${e.PCSS}-viewfinder flat" css-class="{{ {'upload-chosen': !$pacem.isNullOrEmpty(:host.value) && !:host.uploading, 'upload-error': !$pacem.isNullOrEmpty(:host.value) && :host.invalidFile && $pacem.isNullOrEmpty(:host.url), 'upload-readonly': :host.readonly } }}">\n\n <${e.P}-panel class="upload-button" hide="{{ (:host.uploading || :host.failed) && !$pacem.isNullOrEmpty(:host.url) }}">\n <${e.P}-button tooltip="{{ :host.readonly ? :host.viewValue : 'upload' }}" class="button-circle pos-relative overflow-hidden"\n icon-glyph="{{ :host._getMimeIcon(:host.value, :host.uploading, :host.selectMode) }}"\n on-click=":host._clickHandler($event)"\n on-mouseover="$this.iconGlyph = :host._getMimeIcon(:host.readonly ? :host.value : '', :host.uploading, :host.selectMode)"\n on-mouseout="$this.iconGlyph = :host._getMimeIcon(:host.value, :host.uploading, :host.selectMode)"\n css-class="{{ {'${e.PCSS}-anim anim-rotate': :host.uploading, 'button-error': :host.invalidFile, 'button-primary': $pacem.isNullOrEmpty(:host.value) && !:host.invalidFile, 'button-success': !Pacem.Utils.isNullOrEmpty(:host.value) && !:host.invalidFile } }}">\n <input type="file" class="${e.PCSS}-transparent ${e.PCSS}-clickable pos-absolute absolute-left absolute-right absolute-top absolute-bottom" />\n </${e.P}-button>\n </${e.P}-panel>\n <${e.P}-panel class="upload-button" hide="{{ !:host.failed }}">\n <${e.P}-button class="button-circle button-flat" icon-glyph="refresh"\n tooltip="{{ :host.retryCaption }}" on-click=":host._retry($event)"><${e.P}-text text="{{ :host.retryCaption }}"></${e.P}-text></${e.P}-button>\n </${e.P}-panel>\n <${e.P}-panel class="upload-button" hide="{{ !:host.uploading || $pacem.isNullOrEmpty(:host.url) }}">\n <${e.P}-button class="button-circle button-flat" icon-glyph="clear" tooltip="{{ :host.undoCaption }}" \n on-click=":host._undo($event)"><${e.P}-text text="{{ :host.undoCaption }}"></${e.P}-text></${e.P}-button>\n </${e.P}-panel>\n\n <${e.P}-span tooltip="{{ :host.viewValue }}"\n hide="{{ $pacem.isNullOrEmpty(:host.value) || :host.uploading }}" class="upload-data readonly text-reset display-block ${e.PCSS}-anim text-truncate text-left ${e.PCSS}-pad pad-right-3" text="{{ :host.viewValue }}"></${e.P}-span>\n\n <${e.P}-panel class="upload-progress hit-none" hide="{{ :host.readonly || (!$pacem.isNullOrEmpty(:host.value) && !:host.uploading) }}">\n <${e.P}-tuner value="{{ :host.percentage }}" css-class="{{ {'tuner-success': !:host.invalidFile, 'tuner-error': :host.invalidFile} }}" interactive="false"></${e.P}-tuner>\n </${e.P}-panel>\n\n <${e.P}-button class="button-circle button-flat clear-button" icon-glyph="clear" hide="{{ $pacem.isNullOrEmpty(:host.value) || :host.uploading }}" tooltip="{{ :host.clearCaption }}" on-click=":host._clear($event)"></${e.P}-button>\n \n</${e.P}-button>`})],i),t.PacemUploadElement=i}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){let a=class PacemHiddenInputElement extends t.PacemTextualInputElement{constructor(){super()}toggleReadonlyView(e){}get inputFields(){return[this.input]}};__decorate([e.ViewChild("input[type=hidden]")],a.prototype,"input",void 0),a=__decorate([e.CustomElement({tagName:e.P+"-input-hidden",template:'<input type="hidden" />',shadow:e.Defaults.USE_SHADOW_ROOT})],a),t.PacemHiddenInputElement=a}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){const a=e.Utils.getUserMediaFunctions();let i;!function(e){e.Start="start",e.Taking="taking",e.Confirm="confirm"}(i=t.SnapshotStep||(t.SnapshotStep={}));class ConfirmSnapshotEvent extends e.CustomUIEvent{constructor(e){super("confirmsnapshot",{buffer:e})}}let n=class PacemSnapshotElement extends t.PacemBaseElement{constructor(){super(...arguments),this.step=i.Start,this._canUseWebcam=a.length>0,this._countdown=0,this._webcamInitialized=!1,this._grabberChangeHandler=t=>{const a=this._grabber;a.files.length>0&&e.Utils.blobToDataURL(a.files[0]).then(t=>{e.Utils.loadImage(t).then(e=>{this._shutter(e)})})},this._snapshooterClickHandler=t=>{e.avoidHandler(t),this.step=i.Taking},this._pickerClickHandler=t=>{e.avoidHandler(t),this._grabber.click()},this._takerClickHandler=t=>{e.avoidHandler(t),this._countdown=0,this._shutter()},this._timerClickHandler=t=>{e.avoidHandler(t),this._countdown=3,this._shutter()},this._confirmerClickHandler=t=>{e.avoidHandler(t),this.changeHandler(new ConfirmSnapshotEvent(this._buffer))}}get inputFields(){return[]}toggleReadonlyView(e){}onChange(t){return new Promise((a,n)=>{e.CustomEventUtils.isInstanceOf(t,ConfirmSnapshotEvent)?(a(this.value=t.detail.buffer),this.step=i.Start):a(this.value)})}acceptValue(e){this._renderValue(e)}getViewValue(e){return e}convertValueAttributeToProperty(t){return e.PropertyConverters.String.convert(t,this)}get _getUserMedia(){return this._canUseWebcam&&a[0]}propertyChangedCallback(e,t,a,n){switch(super.propertyChangedCallback(e,t,a,n),e){case"step":switch(a){case i.Start:this._buffer=null;const e=this._grabber;e.value="",/safari/i.test(navigator.userAgent)||(e.type="",e.type="file");break;case i.Taking:this._ensureWebcamRunning()}break;case"_buffer":this._renderValue(a||this.value);break;case"width":case"height":this._syncSize()}}viewActivatedCallback(){super.viewActivatedCallback(),this._syncSize(),this._picker.addEventListener("click",this._pickerClickHandler,!1),this._snapshooter.addEventListener("click",this._snapshooterClickHandler,!1),this._taker.addEventListener("click",this._takerClickHandler,!1),this._timer.addEventListener("click",this._timerClickHandler,!1),this._confirmer.addEventListener("click",this._confirmerClickHandler,!1),this._grabber.addEventListener("change",this._grabberChangeHandler,!1)}disconnectedCallback(){this.isReady&&(this._picker.removeEventListener("click",this._pickerClickHandler,!1),this._snapshooter.removeEventListener("click",this._snapshooterClickHandler,!1),this._taker.removeEventListener("click",this._takerClickHandler,!1),this._timer.removeEventListener("click",this._timerClickHandler,!1),this._confirmer.removeEventListener("click",this._confirmerClickHandler,!1),this._grabber.removeEventListener("change",this._grabberChangeHandler,!1)),super.disconnectedCallback()}_syncSize(){const t=this._stage,a=this._player;e.Utils.isNull(t)||e.Utils.isNull(a)||(t.style.width=a.style.width=this.width&&this.width+"px"||"",t.style.height=a.style.height=this.height&&this.height+"px"||"",this._renderValue(this._buffer||this.value))}_shutter(t){const a=this,i=this._player,n=this._stage;var s,r;if(a._confirmer.disabled=!0,e.Utils.isNull(t)&&(t=a._player),t instanceof HTMLVideoElement?(s=t.videoWidth,r=t.videoHeight):(s=t.naturalWidth,r=t.naturalHeight),a._countdown<=0){var o=document.createElement("canvas");o.width=this.width||n.clientWidth,o.height=this.height||n.clientHeight;var l=o.getContext("2d");e.Utils.cropImageOntoCanvas(t,l,s,r);let c=a._root;c.insertBefore(o,i),o.className="snapshot-brightout",setTimeout(function(){c.removeChild(o)},1e3),a._refreshBuffer(o.toDataURL()).then(e=>{a._setToBeConfirmed(e),a._confirmer.disabled=!1})}else setTimeout(()=>{a._countdown--,this._shutter()},1e3)}_renderValue(t=this.value){let a=this._stage;if(!e.Utils.isNull(a)){a.width=a.clientWidth,a.height=a.clientHeight;let i=a.getContext("2d");e.Utils.isNullOrEmpty(t)?i.clearRect(0,0,a.width,a.height):e.Utils.loadImage(t).then(t=>{e.Utils.cropImageOntoCanvas(t,i,t.width,t.height)})}}_setToBeConfirmed(e){this.step=i.Confirm,this._buffer=e}_refreshBuffer(t){var a=this._stage;let i;return a.width=a.clientWidth,a.height=a.clientHeight,this.quality>0&&(i=Math.min(1,Math.max(0,this.quality))),e.Utils.cropImage(t,a.width,a.height,i)}_ensureWebcamRunning(){if(this._canUseWebcam&&!this._webcamInitialized){var t=this;t._webcamInitialized=!0,t._getUserMedia.apply(navigator,[{video:!0},function(e){t._player.srcObject=e},function(a){t.log(e.Logging.LogLevel.Error,(a||a.message).toString())}])}}};__decorate([e.ViewChild("."+e.PCSS+"-snapshot")],n.prototype,"_root",void 0),__decorate([e.ViewChild("canvas")],n.prototype,"_stage",void 0),__decorate([e.ViewChild("input[type=file]")],n.prototype,"_grabber",void 0),__decorate([e.ViewChild("video")],n.prototype,"_player",void 0),__decorate([e.ViewChild(e.P+"-button.button.snapshot-upload")],n.prototype,"_picker",void 0),__decorate([e.ViewChild(e.P+"-button.button.snapshot-camera")],n.prototype,"_snapshooter",void 0),__decorate([e.ViewChild(e.P+"-button.button.snapshot-take")],n.prototype,"_taker",void 0),__decorate([e.ViewChild(e.P+"-button.button.snapshot-timer3s")],n.prototype,"_timer",void 0),__decorate([e.ViewChild(e.P+"-button.button.snapshot-confirm")],n.prototype,"_confirmer",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],n.prototype,"step",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Number})],n.prototype,"width",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Number})],n.prototype,"height",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Number})],n.prototype,"quality",void 0),__decorate([e.Watch()],n.prototype,"_countdown",void 0),__decorate([e.Watch({emit:!1})],n.prototype,"_buffer",void 0),n=__decorate([e.CustomElement({tagName:e.P+"-snapshot",shadow:e.Defaults.USE_SHADOW_ROOT,template:`<${e.P}-panel class="${e.PCSS}-snapshot" \ncss-class="{{ { \n'snapshot-start': :host.step === '${i.Start}',\n'snapshot-taking': :host.step === '${i.Taking}', \n'snapshot-confirm': :host.step === '${i.Confirm}' } }}">\n \n <canvas class="${e.PCSS}-viewfinder"></canvas>\n\n <video autoplay="autoplay"></video>\n\n <input type="file" accept="image/*" />\n\n <div class="${e.PCSS}-buttonset snapshot-step step-start">\n <div class="buttonset-center">\n <${e.P}-button class="button snapshot-upload" icon-glyph="upload"></${e.P}-button>\n <${e.P}-button class="button snapshot-camera" icon-glyph="photo_camera"></${e.P}-button> \n </div>\n </div>\n\n <div class="${e.PCSS}-buttonset snapshot-step step-taking">\n <div class="buttonset-center">\n <${e.P}-button class="button snapshot-undo" icon-glyph="undo" on-click=":host.step = '${i.Start}'"></${e.P}-button>\n <${e.P}-button class="button snapshot-take" icon-glyph="camera"></${e.P}-button>\n <${e.P}-button class="button snapshot-timer3s" icon-glyph="timer_3"></${e.P}-button>\n </div>\n </div>\n\n <div class="${e.PCSS}-buttonset snapshot-step step-confirm">\n <div class="buttonset-center">\n <${e.P}-button class="button snapshot-undo" icon-glyph="undo" on-click=":host.step = '${i.Start}'"></${e.P}-button>\n <${e.P}-button class="button snapshot-confirm" icon-glyph="done"></${e.P}-button>\n </div>\n </div>\n\n <${e.P}-span class="snapshot-countdown" text="{{ :host._countdown }}" hide="{{ :host.step !== '${i.Taking}' || !(:host._countdown > 0) }}"></${e.P}-span>\n <${e.P}-span hide="{{ :host._canUseWebcam }}"><${e.P}-content></${e.P}-content></${e.P}-span>\n\n</${e.P}-panel>`})],n),t.PacemSnapshotElement=n}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){let a=class PacemUrlInputElement extends t.PacemTextualInputElement{constructor(){super()}toggleReadonlyView(e){this.input.hidden=e,this.anchor.hidden=!e}get inputFields(){return[this.input]}};__decorate([e.ViewChild("input[type=url]")],a.prototype,"input",void 0),__decorate([e.ViewChild(e.P+"-a")],a.prototype,"anchor",void 0),a=__decorate([e.CustomElement({tagName:e.P+"-input-url",template:`<input type="url" class="${e.PCSS}-input" />${t.CHAR_COUNTER_CHILD}<${e.P}-a class="${e.PCSS}-readonly" disabled="{{ $pacem.isNullOrEmpty(:host.value) }}" href="{{ :host.value }}" target="_blank"><${e.P}-text text="{{ :host.viewValue }}"></${e.P}-text></${e.P}-a>`,shadow:e.Defaults.USE_SHADOW_ROOT})],a),t.PacemUrlInputElement=a}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(a){a.Picture=class Picture{},a.ImageFetchRequestEventName="imagefetchrequest";class ImageFetchRequestEvent extends e.CustomTypedEvent{constructor(e){super(a.ImageFetchRequestEventName,e,{bubbles:!0})}}a.ImageFetchRequestEvent=ImageFetchRequestEvent;let i=class PacemEditImageElement extends t.PacemElement{constructor(){super(...arguments),this._index=0,this.hint=""}_uploaderPropertyChangedCallback(e){const t=e.detail.currentValue;switch(e.detail.propertyName){case"percentage":this._progressbar.percentage=100*t;break;case"uploading":t&&this._done(!0)}}_thumbnailUploaderPropertyChangedCallback(e){const t=e.detail.currentValue;switch(e.detail.propertyName){case"percentage":this._progressbar.percentage=100*t;break;case"uploading":this._done(t)}}_uploaderFileUploadCallback(t){const a=this._uploader,i=this._thumbUploader,n=i.maxImageWidth,s=i.maxImageHeight;if(n>0&&s>0){var r=a.blob;const o=t.detail.uid;e.Utils.resizeImage(r,n,s).then(e=>{e==r?this._done(!1):i.upload(e,"thumbnail.jpg",o)})}else this._done(!1)}_done(e){e||this._imagefetch(0),this._repeater.hidden=e,this._progressbar.hidden=!e}_snapshotPropertyChangedCallback(t){if("value"===t.detail.propertyName){const a=e.Utils.dataURLToBlob(t.detail.currentValue);this._uploader.upload(a,"snapshot.jpg")}}reset(){this._snapshot.step=a.SnapshotStep.Start}propertyChangedCallback(t,a,i,n){switch(super.propertyChangedCallback(t,a,i,n),t){case"imageSet":let t=i||{skip:0,set:[]};e.Utils.isNullOrEmpty(this._images)||0===t.skip?this._images=t.set:e.Utils.isNull(this._images)||Array.prototype.splice.apply(this._images,[t.skip,this._images.length-t.skip].concat(t.set)),this._fetching=!1;break;case"hint":n||this._imagefetch(0)}}_imagefetchSuddenly(e){this._fetching=!0,this._imagefetch(e)}_imagefetch(e){e>=0||(e=this._images&&this._images.length||0),this.dispatchEvent(new ImageFetchRequestEvent({hint:this.hint,skip:e,take:18}))}};__decorate([e.Watch({converter:e.PropertyConverters.String})],i.prototype,"uploadUrl",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],i.prototype,"hint",void 0),__decorate([e.Watch()],i.prototype,"imageSet",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],i.prototype,"value",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Number})],i.prototype,"maxWidth",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Number})],i.prototype,"maxHeight",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Number})],i.prototype,"maxThumbnailWidth",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Number})],i.prototype,"maxThumbnailHeight",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Boolean})],i.prototype,"allowSnapshot",void 0),__decorate([e.Watch()],i.prototype,"_fetching",void 0),__decorate([e.Watch()],i.prototype,"_images",void 0),__decorate([e.ViewChild(e.P+"-repeater")],i.prototype,"_repeater",void 0),__decorate([e.ViewChild(e.P+"-upload[main]")],i.prototype,"_uploader",void 0),__decorate([e.ViewChild(e.P+"-upload[thumb]")],i.prototype,"_thumbUploader",void 0),__decorate([e.ViewChild(e.P+"-snapshot")],i.prototype,"_snapshot",void 0),__decorate([e.ViewChild(e.P+"-progressbar")],i.prototype,"_progressbar",void 0),__decorate([e.Debounce(500)],i.prototype,"_imagefetch",null),i=__decorate([e.CustomElement({tagName:e.P+"-edit-image",shadow:e.Defaults.USE_SHADOW_ROOT,template:`<${e.P}-panel class="${e.PCSS}-edit-image"\n css-class="{{ {'${e.PCSS}-snapshot': ::_snapshot.step != '${a.SnapshotStep.Start}', '${e.PCSS}-uploading': ::_uploader.uploading, '${e.PCSS}-upload-enabled': !Pacem.Utils.isNullOrEmpty(:host.uploadUrl), '${e.PCSS}-snapshot-enabled': !Pacem.Utils.isNullOrEmpty(:host.uploadUrl) && :host.allowSnapshot} }}">\n <div>\n <${e.P}-input-search value="{{ :host.hint, twoway }}"></${e.P}-input-search>\n <${e.P}-upload main pattern=".+.(jpe?g|png|svg|ico)$" url="{{ :host.uploadUrl }}"\n max-image-width="{{ :host.maxWidth }}" max-image-height="{{ :host.maxHeight }}"\n on-${a.FileUploadEventName}=":host._uploaderFileUploadCallback($event)"\n on-${e.PropertyChangeEventName}=":host._uploaderPropertyChangedCallback($event)" hide="{{ Pacem.Utils.isNullOrEmpty(:host.uploadUrl) || ::_thumbUploader.uploading }}"></${e.P}-upload>\n <${e.P}-upload thumb pattern=".+.(jpe?g|png|svg|ico)$" url="{{ :host.uploadUrl }}" hide="{{ !::_thumbUploader.uploading }}"\n max-image-width="{{ :host.maxThumbnailWidth }}" max-image-height="{{ :host.maxThumbnailHeight }}"\n on-${e.PropertyChangeEventName}=":host._thumbnailUploaderPropertyChangedCallback($event)"></${e.P}-upload>\n <${e.P}-button class="${e.PCSS}-snapshot" on-click="Pacem.avoidHandler($event); ::_snapshot.step = '${a.SnapshotStep.Taking}'" hide="{{ Pacem.Utils.isNullOrEmpty(:host.uploadUrl) || !:host.allowSnapshot }}"></${e.P}-button>\n <${e.P}-infinite-scroller container="{{ ::_repeater }}" on-fetchmore=":host._imagefetchSuddenly()" disabled="{{ :host._fetching || :host.disabled || :host._images.length >= :host.imageSet.total }}"></${e.P}-infinite-scroller>\n <${e.P}-repeater datasource="{{ :host._images }}">\n <template>\n <${e.P}-img css-class="{{ {'${e.PCSS}-selected': ^item.src === :host.value } }}" on-click=":host.value = ^item.src" src="{{ ^item.thumb }}" adapt="contain"></${e.P}-img>\n </template>\n </${e.P}-repeater>\n <${e.P}-progressbar class="progressbar-smaller progressbar-accent" caption="{{ ::_thumbUploader.uploading ? 'thumbnail...' : 'uploading...' }}"></${e.P}-progressbar>\n </div>\n <div>\n <${e.P}-snapshot hide="{{ !:host.allowSnapshot }}" on-${e.PropertyChangeEventName}=":host._snapshotPropertyChangedCallback($event)"></${e.P}-snapshot>\n </div>\n </${e.P}-panel>`})],i),a.PacemEditImageElement=i;let n=class PacemImageInputElement extends a.PacemBaseElement{constructor(){super(...arguments),this._broadcastFetchRequestEventName=e=>{this.dispatchEvent(new ImageFetchRequestEvent(e.detail))},this._innerValueChangedHandler=t=>{"value"!==t.detail.propertyName||e.Utils.isNull(this._dialog)||(this._dialog.state=t.detail.currentValue)}}convertValueAttributeToProperty(e){return e}getViewValue(e){return e}get inputFields(){return[]}_clear(e){this.changeHandler(e)}onChange(a){let i=this.value;return e.CustomEventUtils.isInstanceOf(a,t.UI.DialogResultEvent)&&a.detail.button===t.UI.DialogButton.Ok?i=this.value=a.detail.state:a.target===this._input?i=this.value=this._input.value:a.target===this._clearBtn&&(i=this.value=void 0),e.Utils.fromResult(i)}toggleReadonlyView(e){this._input.hidden=this._editBtn.hide=this._clearBtn.hide=e}_addDialog(){var a=document.createElement(e.P+"-dialog");return a.buttons=t.UI.DialogButtons.OkCancel,a.addEventListener(t.UI.DialogResultEventName,this.changeHandler,!1),a.appendChild(this._addEditImage()),document.body.appendChild(a),this._dialog=a}_removeDialog(){this._removeEditImage(),e.Utils.isNull(this._dialog)||(this._dialog.removeEventListener(t.UI.DialogResultEventName,this.changeHandler,!1),this._dialog.remove())}_addEditImage(){var t=document.createElement(e.P+"-edit-image");return t.disabled=!0,t.addEventListener(e.PropertyChangeEventName,this._innerValueChangedHandler,!1),t.addEventListener(a.ImageFetchRequestEventName,this._broadcastFetchRequestEventName,!1),t.uploadUrl=this.uploadUrl,t.allowSnapshot=this.allowSnapshot,t.maxWidth=this.maxWidth,t.maxHeight=this.maxHeight,t.maxThumbnailHeight=this.maxThumbnailHeight,t.maxThumbnailWidth=this.maxThumbnailWidth,this._editImage=t}_removeEditImage(){e.Utils.isNull(this._editImage)||(this._editImage.removeEventListener(e.PropertyChangeEventName,this._innerValueChangedHandler,!1),this._editImage.removeEventListener(a.ImageFetchRequestEventName,this._broadcastFetchRequestEventName,!1))}connectedCallback(){super.connectedCallback(),this._addDialog()}disconnectedCallback(){this._removeDialog(),super.disconnectedCallback()}propertyChangedCallback(t,a,i,n){switch(super.propertyChangedCallback(t,a,i,n),t){case"uploadUrl":e.Utils.isNull(this._editImage)||(this._editImage.uploadUrl=i);break;case"allowSnapshot":e.Utils.isNull(this._editImage)||(this._editImage.allowSnapshot=i);break;case"imageSet":e.Utils.isNull(this._editImage)||(this._editImage.imageSet=i);break;case"maxThumbnailHeight":e.Utils.isNull(this._editImage)||(this._editImage.maxThumbnailHeight=i);break;case"maxThumbnailWidth":e.Utils.isNull(this._editImage)||(this._editImage.maxThumbnailWidth=i);break;case"maxHeight":e.Utils.isNull(this._editImage)||(this._editImage.maxHeight=i);break;case"maxWidth":e.Utils.isNull(this._editImage)||(this._editImage.maxWidth=i)}}acceptValue(t){e.Utils.isNull(this._editImage)||(this._editImage.value=t)}_update(e){this._image.src=e}_retrieve(){return this.value}_edit(a){e.avoidHandler(a);var i=this._editImage,n=this.value;i.disabled=!1,i.reset(),i.value=n,this._dialog.open(n).then(e=>{switch(e.button){case t.UI.DialogButton.Cancel:this._update(this.value);break;case t.UI.DialogButton.Ok:this._update(e.state)}this._editImage.disabled=!0})}};__decorate([e.ViewChild(e.P+"-img")],n.prototype,"_image",void 0),__decorate([e.ViewChild(e.P+"-button."+e.PCSS+"-edit")],n.prototype,"_editBtn",void 0),__decorate([e.ViewChild(e.P+"-button."+e.PCSS+"-clear")],n.prototype,"_clearBtn",void 0),__decorate([e.ViewChild(e.P+"-input-url")],n.prototype,"_input",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String})],n.prototype,"uploadUrl",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Json})],n.prototype,"imageSet",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Number})],n.prototype,"maxWidth",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Number})],n.prototype,"maxHeight",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Number})],n.prototype,"maxThumbnailWidth",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Number})],n.prototype,"maxThumbnailHeight",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Boolean})],n.prototype,"allowSnapshot",void 0),n=__decorate([e.CustomElement({tagName:e.P+"-input-image",shadow:e.Defaults.USE_SHADOW_ROOT,template:`<div class="${e.PCSS}-input-image"><${e.P}-img src="{{ :host.value }}" adapt="contain"></${e.P}-img><div class="${e.PCSS}-input-image-dashboard">\n <${e.P}-button on-click=":host._edit($event)" hide="{{ :host.disabled }}" class="${e.PCSS}-edit">Edit</${e.P}-button>\n <${e.P}-button on-click=":host._clear($event)" hide="{{ :host.disabled }}" class="${e.PCSS}-clear">Clear</${e.P}-button>\n</div><${e.P}-input-url placeholder="{{ :host.placeholder }}" on-change=":host.changeHandler($event)" value="{{ :host.value }}"></${e.P}-input-url>\n\n <${e.P}-panel hide="{{ Pacem.Utils.isNullOrEmpty(:host.value) }}">\n <dl class="${e.PCSS}-input-image-preview">\n <dt>dimensions:</dt><dd><${e.P}-text text="{{ ::_image.size.width +'x'+ ::_image.size.height }}"></${e.P}-text></dd>\n <dt>size:</dt><dd><${e.P}-text text="{{ $pacem.size(::_image.size.weight) }}"></${e.P}-text></dd>\n </dl></${e.P}-panel>\n\n</div>`})],n),a.PacemImageInputElement=n}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){let a=class PacemNumberInputElement extends t.PacemOrdinalInputElement{toggleReadonlyView(e){this._span.hidden=!e,this._input.hidden=e}get inputFields(){return[this._input]}getViewValue(e){return null!=this.value?this._format(this.value):void 0}_format(t=this.value){const a=this.format;return e.Utils.isNullOrEmpty(a)?t.toString():new Intl.NumberFormat(e.Utils.lang(this),a).format(t)}getValue(e){const t=this.inputField.valueAsNumber||parseFloat(this.inputField.value);return isNaN(t)?void 0:t}viewActivatedCallback(){super.viewActivatedCallback();this._input.addEventListener("wheel",this.emitHandler,{capture:!1,passive:!1})}disconnectedCallback(){if(!e.Utils.isNull(this._input)){this._input.removeEventListener("wheel",this.emitHandler,{capture:!1,passive:!1})}super.disconnectedCallback()}};__decorate([e.ViewChild("input[type=number]")],a.prototype,"_input",void 0),__decorate([e.ViewChild(`span.${e.PCSS}-readonly`)],a.prototype,"_span",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Json})],a.prototype,"format",void 0),a=__decorate([e.CustomElement({tagName:e.P+"-input-number",template:`<input type="number" class="${e.PCSS}-input ${e.PCSS}-viewfinder" /><span class="${e.PCSS}-readonly"><${e.P}-text text="{{ :host.viewValue }}"></${e.P}-text></span>`,shadow:e.Defaults.USE_SHADOW_ROOT})],a),t.PacemNumberInputElement=a}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){let a=class PacemPasswordInputElement extends t.PacemTextualInputElement{constructor(){super(),this._togglerMousedownHandler=t=>{0==t.button&&(e.avoidHandler(t),this.toggleVisibility())}}get inputFields(){return[this._input]}viewActivatedCallback(){super.viewActivatedCallback();const t=this.id??"_"+e.Utils.uniqueCode(),a=this._input.id=t+"_ctrl";this._toggler.setAttribute("aria-controls",a),this._toggler.setAttribute("role","button"),this._syncToggler(),this._toggler.addEventListener("mousedown",this._togglerMousedownHandler,!1)}disconnectedCallback(){e.Utils.isNull(this._toggler)||this._toggler.removeEventListener("mousedown",this._togglerMousedownHandler,!1)}toggleVisibility(){const e=this._input.type;this._input.type="password"===e?"text":"password",this._syncToggler()}_syncToggler(){const e="password"===this._input.type;this._toggler.innerText=e?"visibility_off":"visibility",this._toggler.setAttribute("aria-expanded",(!e).toString())}toggleReadonlyView(e){this._input.hidden=this._toggler.hidden=e,this._span.hidden=!e}getViewValue(t){return e.Utils.leftPad("",Math.floor(8+3*Math.random()),"•")}};__decorate([e.ViewChild("input[type=password]")],a.prototype,"_input",void 0),__decorate([e.ViewChild(`span.${e.PCSS}-readonly`)],a.prototype,"_span",void 0),__decorate([e.ViewChild(`i.${e.PCSS}-icon.${e.PCSS}-clickable`)],a.prototype,"_toggler",void 0),a=__decorate([e.CustomElement({tagName:e.P+"-input-password",template:`<input type="password" class="${e.PCSS}-input ${e.PCSS}-viewfinder" /><i class="${e.PCSS}-icon ${e.PCSS}-clickable"></i>\n${t.CHAR_COUNTER_CHILD}<span class="${e.PCSS}-readonly"><${e.P}-text text="{{ :host.viewValue }}"></${e.P}-text></span>`,shadow:e.Defaults.USE_SHADOW_ROOT})],a),t.PacemPasswordInputElement=a}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){let a=class PacemSearchInputElement extends t.PacemTextualInputElement{constructor(){super()}get inputFields(){return[this.input]}toggleReadonlyView(e){}};__decorate([e.ViewChild("input[type=search]")],a.prototype,"input",void 0),a=__decorate([e.CustomElement({tagName:e.P+"-input-search",template:'<input type="search" class="'+e.PCSS+'-input" />',shadow:e.Defaults.USE_SHADOW_ROOT})],a),t.PacemSearchInputElement=a}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){let a=class PacemTelInputElement extends t.PacemTextualInputElement{constructor(){super()}toggleReadonlyView(e){this.input.hidden=e,this.anchor.hidden=!e}get inputFields(){return[this.input]}};__decorate([e.ViewChild("input[type=tel]")],a.prototype,"input",void 0),__decorate([e.ViewChild(e.P+"-a")],a.prototype,"anchor",void 0),a=__decorate([e.CustomElement({tagName:e.P+"-input-tel",template:`<input type="tel" class="${e.PCSS}-input" /><${e.P}-a class="${e.PCSS}-readonly" disabled="{{ $pacem.isNullOrEmpty(:host.value) }}" href="{{ 'tel:'+ :host.value }}"><${e.P}-text text="{{ :host.viewValue }}"></${e.P}-text></${e.P}-a>`,shadow:e.Defaults.USE_SHADOW_ROOT})],a),t.PacemTelInputElement=a}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){let a=class PacemTextInputElement extends t.PacemTextualInputElement{constructor(){super()}toggleReadonlyView(e){this._span.hidden=!e,this._input.hidden=e}get inputFields(){return[this._input]}};__decorate([e.ViewChild("input[type=text]")],a.prototype,"_input",void 0),__decorate([e.ViewChild("span."+e.PCSS+"-readonly")],a.prototype,"_span",void 0),a=__decorate([e.CustomElement({tagName:e.P+"-input-text",template:`<input type="text" class="${e.PCSS}-input" />${t.CHAR_COUNTER_CHILD}<span class="${e.PCSS}-readonly"><${e.P}-text text="{{ :host.viewValue }}"></${e.P}-text></span>`,shadow:e.Defaults.USE_SHADOW_ROOT})],a),t.PacemTextInputElement=a}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){t.DEFAULT_TILES="",t.DEFAULT_ATTRIBUTION="";let a=class PacemLatLngElement extends t.PacemBaseElement{convertValueAttributeToProperty(e){const t=/^\s*([+-]?\d+\.?\d+)[,\s]\s*([+-]?\d+\.?\d+)\s*$/.exec(e);if(t&&3===t.length)return{lat:parseFloat(t[1]),lng:parseFloat(t[2])};throw`Invalid coordinates format for "${e}"`}compareValuePropertyValues(e,t){return!(!e||"number"!=typeof e.lat||"number"!=typeof e.lng||!t||"number"!=typeof t.lat||"number"!=typeof t.lng)&&(e.lat===t.lat&&e.lng===t.lng)}getViewValue(e){return this._getViewValue(e)}_getViewValue(e,t=8){return e&&"number"==typeof e.lat&&"number"==typeof e.lng&&e.lat.toFixed(t)+","+e.lng.toFixed(t)||""}get inputFields(){return[this._latInput,this._lngInput]}toggleReadonlyView(e){this._inputContainer.hidden=e}acceptValue(e){let t=this._ensureValue(e);this._lat=t.lat,this._lng=t.lng}_ensureValue(t){return t&&"number"==typeof t.lat&&"number"==typeof t.lng?t:e.Components.Maps.MapConsts.DEFAULT_COORDS}onChange(t){if(t&&"dragend"===t.type){var a=t;this._lat=a.detail.position.lat,this._lng=a.detail.position.lng}const i=this._lat,n=this._lng;return e.Utils.isNull(i)||e.Utils.isNull(n)?e.Utils.fromResult(this.value):e.Utils.fromResult(this.value={lat:i,lng:n})}propertyChangedCallback(t,a,i,n){if(super.propertyChangedCallback(t,a,i,n),"options"===t&&!n){const t=e.Utils.clone(i||{provider:"osm"});this._synchronizeOptions(t)}}viewActivatedCallback(){super.viewActivatedCallback(),this._synchronizeOptions()}_synchronizeOptions(t=this.options||{provider:"osm"}){const a=this._marker,i=this._map;switch(a.icon=t.icon,t&&t.provider){case"azure":this._azureAdapter.subscriptionKey=t.apiKey,i.adapter=this._azureAdapter;break;case"google":case"gmaps":this._googleAdapter.apiKey=t.apiKey,i.adapter=this._googleAdapter;break;default:e.Utils.isNullOrEmpty(t.attribution)||(this._leafletAdapter.attribution=t.attribution),e.Utils.isNullOrEmpty(t.tiles)||(this._leafletAdapter.tiles=t.tiles),i.adapter=this._leafletAdapter}delete t.provider,delete t.icon,delete t.apiKey,delete t.attribution,delete t.tiles;for(let e in t)e in i&&(i[e]=t[e])}};__decorate([e.ViewChild(e.P+"-map-adapter-leaflet")],a.prototype,"_leafletAdapter",void 0),__decorate([e.ViewChild(e.P+"-map-adapter-azure")],a.prototype,"_azureAdapter",void 0),__decorate([e.ViewChild(e.P+"-map-adapter-google")],a.prototype,"_googleAdapter",void 0),__decorate([e.ViewChild(e.P+"-map")],a.prototype,"_map",void 0),__decorate([e.ViewChild(e.P+"-map-marker")],a.prototype,"_marker",void 0),__decorate([e.ViewChild(e.P+"-input-number:nth-child(1)")],a.prototype,"_latInput",void 0),__decorate([e.ViewChild(e.P+"-input-number:nth-child(2)")],a.prototype,"_lngInput",void 0),__decorate([e.ViewChild(`.${e.PCSS}-latlng-fields`)],a.prototype,"_inputContainer",void 0),__decorate([e.ViewChild(e.P+"-fetch")],a.prototype,"_fetcher",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Json,emit:!1})],a.prototype,"options",void 0),__decorate([e.Watch()],a.prototype,"_lat",void 0),__decorate([e.Watch()],a.prototype,"_lng",void 0),a=__decorate([e.CustomElement({tagName:e.P+"-latlng",shadow:e.Defaults.USE_SHADOW_ROOT,template:`<div class="${e.PCSS}-latlng">\n <div class="${e.PCSS}-latlng-fields ${e.PCSS}-viewfinder">\n <${e.P}-input-number class="${e.PCSS}-lat" value="{{ :host._lat, twoway }}" min="-90" max="90" step="{{ 'any' }}"></${e.P}-input-number>\n <${e.P}-input-number class="${e.PCSS}-lng" value="{{ :host._lng, twoway }}" min="-180" max="180" step="{{ 'any' }}"></${e.P}-input-number>\n </div>\n <${e.P}-panel hide="{{ Pacem.Utils.isNull(:host.value) || :host.readonly }}">\n <dl class="${e.PCSS}-latlng-preview">\n <dt>decimals:</dt><dd><${e.P}-text text="{{ :host._getViewValue(:host.value, 12) }}"></${e.P}-text></dd>\n <dt>address:</dt><dd><${e.P}-text text="{{ ::_fetcher.result.display_name || '?' }}"></${e.P}-text></dd>\n <dt>degrees:</dt><dd><${e.P}-span css-class="{{ {'${e.PCSS}-lat-north': :host._lat > 0, '${e.PCSS}-lat-south': :host._lat < 0} }}" content="{{ $pacem.decToDeg(Math.abs(:host._lat)) }}"></${e.P}-span>,\n <${e.P}-span css-class="{{ {'${e.PCSS}-lng-east': :host._lng > 0, '${e.PCSS}-lng-west': :host._lng < 0} }}" content="{{ $pacem.decToDeg(Math.abs(:host._lng)) }}"></${e.P}-span></dd>\n </dl>\n </${e.P}-panel>\n <${e.P}-span class="${e.PCSS}-readonly" hide="{{ !:host.readonly }}" content="{{ :host.viewValue + ($pacem.isNullOrEmpty(::_fetcher.result.display_name) ? '' : (' <small>'+ ::_fetcher.result.display_name +'</small>')) }}"></${e.P}-span>\n\n <${e.P}-map-adapter-leaflet></${e.P}-map-adapter-leaflet>\n <${e.P}-map-adapter-azure></${e.P}-map-adapter-azure>\n <${e.P}-map-adapter-google></${e.P}-map-adapter-google>\n\n <${e.P}-map adapter="{{ ::_adapter }}">\n <${e.P}-map-marker position="{{ :host._ensureValue(:host.value) }}" on-dragend=":host.changeHandler($event)" draggable="{{ !:host.readonly }}"></${e.P}-map-marker>\n </${e.P}-map>\n <${e.P}-fetch disabled="{{ $pacem.isNull(:host.value) }}" parameters="{{ { format: 'json', lat: :host._lat, lon: :host._lng } }}" url="https://nominatim.openstreetmap.org/reverse"></${e.P}-fetch>\n</div>`})],a),t.PacemLatLngElement=a}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){const a=`change-policy="${t.ChangePolicy.Blur}" readonly="{{ :host.readonly }}"`;function i(t){return e.Utils.isNullOrEmpty(t&&t.name)}let n=class PacemNameValueListElement extends t.PacemBaseElement{constructor(){super(...arguments),this.inputFields=[],this._bag=[]}toggleReadonlyView(e){}onChange(e){return new Promise((e,t)=>{let a=this._bagToValue(this._bag);this.compareValuePropertyValues(a,this.value)?t():e(this.value=a)})}acceptValue(e){this._bag=this._valueToBag(e)}getViewValue(e){return""}compareValuePropertyValues(t,a){return e.Utils.Json.stringify(t)===e.Utils.Json.stringify(a)}convertValueAttributeToProperty(t){return e.PropertyConverters.Json.convert(t)}propertyChangedCallback(e,t,a,i){super.propertyChangedCallback(e,t,a,i),"dictionary"!==e||i||(this.value=this._bagToValue())}_bagToValue(e=this._bag){if(!this.dictionary){let t=[];for(let a of e||[])i(a)||t.find(e=>e.name===a.name&&e.value===a.value)||t.push(a);return t}let t={};for(let a of e||[])a.name in t||(t[a.name]=a.value);return t}_valueToBag(t=this.value){const a=[];if(!e.Utils.isNullOrEmpty(t)&&"object"==typeof t)if(this.dictionary&&!e.Utils.isArray(t))for(let e in t)a.push({name:e,value:t[e]});else!this.dictionary&&e.Utils.isArray(t)&&Array.prototype.splice.apply(a,[0,0].concat(t.map(t=>e.Utils.clone(t))));return e.Utils.isNullOrEmpty(a)?[{name:"",value:""}]:a}_deleteAt(e){this._bag.splice(e.detail,1),this.changeHandler(e)}_addItem(t){const a=this._bag,n=this._bag[this._bag.length-1];!e.Utils.isEmpty(a)&&i(n)||a.push({name:"",value:""})}};__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Boolean})],n.prototype,"dictionary",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Json})],n.prototype,"_bag",void 0),n=__decorate([e.CustomElement({tagName:e.P+"-namevalue-list",shadow:e.Defaults.USE_SHADOW_ROOT,template:`<${e.P}-repeater datasource="{{ :host._bag }}" on-itemdelete=":host._deleteAt($event)">\n <template>\n <div class="${e.PCSS}-fieldset ${e.PCSS}-margin margin-bottom-1">\n <div class="fieldset-auto">\n <div class="${e.PCSS}-fieldgroup">\n <${e.P}-input-text ${a} value="{{ ^item.name, twoway }}" on-change=":host.changeHandler($event)"></${e.P}-input-text>\n <div class="fieldgroup-prepend"></div>\n </div>\n <div class="${e.PCSS}-fieldgroup">\n <${e.P}-input-text ${a} value="{{ ^item.value, twoway }}" on-change=":host.changeHandler($event)"></${e.P}-input-text>\n <div class="fieldgroup-append">\n <${e.P}-button class="${e.PCSS}-cell cols-2 flat delete" hide="{{ :host.readonly }}" command-name="delete" command-argument="{{ ^index }}"></${e.P}-button>\n </div>\n </div>\n </div>\n </div>\n </template>\n <${e.P}-button class="flat add" hide="{{ :host.readonly }}" on-click=":host._addItem($event)"></${e.P}-button>\n</${e.P}-repeater>`})],n),t.PacemNameValueListElement=n}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){let a=class PacemPropertyPickerElement extends t.PacemBaseElement{get inputFields(){return[this._select]}toggleReadonlyView(e){this._select.readonly=e}onChange(t){return e.Utils.fromResult(this.value=this._select.value)}acceptValue(e){this._select.value=e}getViewValue(e){return this._select.viewValue}convertValueAttributeToProperty(t){return e.PropertyConverters.Element.convert(t)}viewActivatedCallback(){super.viewActivatedCallback(),this._databind()}propertyChangedCallback(e,t,a,i){if(super.propertyChangedCallback(e,t,a,i),!i&&"target"===e)this._databind()}_databind(){const t=[],a=(i,n,s)=>{const r=i[n];if("object"==typeof r&&null!=r&&!e.Utils.isArray(r))for(let e of Object.keys(r)){const i=s+"."+e;t.push(i),a(r,e,i)}};let i=this.target;if(!e.Utils.isNull(i)){let n=e.CustomElementUtils.getWatchedProperties(i);for(let e of n){let n=e.name;t.push(n),a(i,n,n)}}this._select.datasource=t.sort()}};__decorate([e.ViewChild(e.P+"-select")],a.prototype,"_select",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Element})],a.prototype,"target",void 0),a=__decorate([e.CustomElement({tagName:e.P+"-property-picker",shadow:e.Defaults.USE_SHADOW_ROOT,template:`<${e.P}-select></${e.P}-select>`})],a),t.PacemPropertyPickerElement=a}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){let a=class PacemRadioListElement extends t.PacemDataSourceElement{acceptValue(e){}constructor(){super(),this.key="_"+e.Utils.uniqueCode()}get inputFields(){return[]}propertyChangedCallback(e,t,a,i){super.propertyChangedCallback(e,t,a,i),"disabled"===e&&(this._disable.model=a)}viewActivatedCallback(){super.viewActivatedCallback(),this._disable.model=this.disabled}toggleReadonlyView(e){this._repeater.hidden=e,this._span.hidden=!e}_selectionChanged(e,t,a){"selected"===e.detail.propertyName&&!0===e.detail.currentValue&&(this._selectedValue=this.mapEntityToValue(this.datasource[t]),this.changeHandler(e))}onChange(t){return this.value=this._selectedValue,this.databind(),e.Utils.fromResult(this._selectedValue)}};__decorate([e.ViewChild(e.P+"-repeater")],a.prototype,"_repeater",void 0),__decorate([e.ViewChild(e.P+"-data")],a.prototype,"_disable",void 0),__decorate([e.ViewChild(`span.${e.PCSS}-readonly`)],a.prototype,"_span",void 0),a=__decorate([e.CustomElement({tagName:e.P+"-radio-list",template:`<${e.P}-repeater datasource="{{ :host.adaptedDatasource }}">\n <ol class="${e.PCSS}-radio-list ${e.PCSS}-viewfinder" pacem>\n <template>\n <li><${e.P}-radio disabled="{{ ::_disable.model || ^item.disabled }}" name="{{ :host.key, once }}" autobind="off" caption="{{ ^item.viewValue }}" value="{{ ^item.value }}" selected="{{ :host.isDataSourceItemSelected(^item, :host.value) }}"\non-focus=":host.focusHandler($event)" on-blur=":host.focusHandler($event)"\non-${e.PropertyChangeEventName}=":host._selectionChanged($event, ^index, ^item)"></${e.P}-radio></li>\n </template>\n </ol>\n</${e.P}-repeater><span class="${e.PCSS}-readonly ${e.PCSS}-radio"><${e.P}-text text="{{ :host.viewValue }}"></${e.P}-text></span><${e.P}-data></${e.P}-data><${e.P}-content></${e.P}-content>`,shadow:e.Defaults.USE_SHADOW_ROOT})],a),t.PacemRadioListElement=a}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){let a=class PacemRadioElement extends t.PacemBaseElement{convertValueAttributeToProperty(e){return e}constructor(){super(),this._key="_"+e.Utils.uniqueCode()}toggleReadonlyView(e){this.span.hidden=!e,this._radio.hidden=e}get inputFields(){return[this._radio]}onChange(t){this.selected=this._radio.checked;const a=this.selected?this._radio.value:void 0;return e.Utils.fromResult(a)}viewActivatedCallback(){super.viewActivatedCallback(),this._radio.id=this._label.htmlFor=this._key}propertyChangedCallback(t,a,i,n){switch(super.propertyChangedCallback(t,a,i,n),t){case"name":this._radio.name=i;break;case"selected":(this._radio.checked=i)?e.Utils.addClass(this,e.PCSS+"-selected"):e.Utils.removeClass(this,e.PCSS+"-selected")}}acceptValue(t){this._radio.value=e.Utils.isNullOrEmpty(t)?"":t}getViewValue(t){return e.Utils.isNull(t)?"":this.caption}};__decorate([e.ViewChild("input[type=radio]")],a.prototype,"_radio",void 0),__decorate([e.ViewChild("label")],a.prototype,"_label",void 0),__decorate([e.ViewChild(`.${e.PCSS}-readonly`)],a.prototype,"span",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],a.prototype,"caption",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Boolean})],a.prototype,"selected",void 0),a=__decorate([e.CustomElement({tagName:e.P+"-radio",template:`<${e.P}-span class="${e.PCSS}-readonly ${e.PCSS}-radio" text="{{ :host.caption }}"></${e.P}-span><input type="radio" class="${e.PCSS}-input" /><label class="${e.PCSS}-label ${e.PCSS}-radio ${e.PCSS}-viewfinder"><${e.P}-text text="{{ :host.caption }}"></${e.P}-text></label>`,shadow:e.Defaults.USE_SHADOW_ROOT})],a),t.PacemRadioElement=a}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(a){let i=class PacemSelectElement extends a.PacemDataSourceElement{constructor(){super(...arguments),this.emptyOption=!0}toggleReadonlyView(e){this._repeater.hidden=e,this._span.hidden=!e}get inputFields(){return[this._select]}_manageDom(t){const a=t.detail,i=a.item;let n=a.dom.find(e=>e instanceof HTMLOptionElement);n.value=i.value,n.textContent=i.viewValue,n.disabled=i.disabled,n.selected=this.isDataSourceItemSelected(i),(e.Utils.isNullOrEmpty(n.value)?e.Utils.addClass:e.Utils.removeClass).apply(this,[n,e.PCSS+"-watermark"])}onChange(t){let a,i=this._select.selectedIndex,n=this.adaptedDatasource,s=i>=0&&n[i];return a=null!=s?s.value:void 0,e.Utils.fromResult(this.value=a)}propertyChangedCallback(e,t,a,i){switch(super.propertyChangedCallback(e,t,a,i),e){case"placeholder":case"emptyOption":this.databind()}}buildAdaptedDatasource(e=this.datasource){let t=super.buildAdaptedDatasource(e);return t&&this.emptyOption&&t.splice(0,0,{viewValue:this.placeholder||"",value:void 0,data:void 0}),t}handleDatasourceMismatch(t){this.emptyOption?super.handleDatasourceMismatch(t):e.Utils.isNullOrEmpty(t)?this.value=void 0:this.value=t[0].value}acceptValue(t){const a=this.adaptedDatasource,i=a&&a.filter(e=>this.isDataSourceItemSelected(e,t));if(i&&1==i.length)this._select.selectedIndex=a.indexOf(i[0]);else{this._select.value=void 0;let t=this._select.options;t.length>0&&e.Utils.isNullOrEmpty(t[0].value)&&(this._select.selectedIndex=0)}}viewActivatedCallback(){super.viewActivatedCallback();this._select.addEventListener("wheel",this.emitHandler,{capture:!1,passive:!1})}disconnectedCallback(){if(!e.Utils.isNull(this._select)){this._select.removeEventListener("wheel",this.emitHandler,{capture:!1,passive:!1})}super.disconnectedCallback()}};__decorate([e.ViewChild("select")],i.prototype,"_select",void 0),__decorate([e.ViewChild(e.P+"-repeater")],i.prototype,"_repeater",void 0),__decorate([e.ViewChild(`span.${e.PCSS}-readonly`)],i.prototype,"_span",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Boolean})],i.prototype,"emptyOption",void 0),i=__decorate([e.CustomElement({tagName:e.P+"-select",template:`<${e.P}-repeater datasource="{{ :host.adaptedDatasource }}" on-${t.RepeaterItemCreateEventName}=":host._manageDom($event)">\n <select class="${e.PCSS}-select ${e.PCSS}-viewfinder">\n <template>\n <option></option>\n </template>\n </select>\n</${e.P}-repeater><span class="${e.PCSS}-readonly"><${e.P}-text text="{{ :host.viewValue }}"></${e.P}-text></span><${e.P}-content></${e.P}-content>`,shadow:e.Defaults.USE_SHADOW_ROOT})],i),a.PacemSelectElement=i}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(a){let i=class PacemSliderElement extends a.PacemBaseElement{constructor(){super(...arguments),this.inputFields=[],this._dragHandler=e=>{e.preventDefault(),this._computeAndAssignValue(e.detail.currentPosition.x,"end"!==this.changePolicy)},this._endHandler=e=>{e.preventDefault(),this._computeAndAssignValue(e.detail.currentPosition.x,"end"===this.changePolicy)},this._startHandler=e=>{this._thumb.focus()},this._downHandler=t=>{const a=t instanceof MouseEvent?t.clientX:t.touches&&t.touches.length&&t.touches[0].clientX,i=this._trackSize;e.Utils.isNullOrEmpty(i)||this._computeAndAssignValue(a,!0)},this._keydownHandler=t=>{switch(t.keyCode){case 39:case 37:e.avoidHandler(t);let a=39===t.keyCode,i=("number"!=typeof this.step?1:this.step)*(a?1:-1),n=!1,s=t=>{n=!0,window.removeEventListener("keyup",s,!1),e.Utils.removeClass(this,"slider-keydown")};window.addEventListener("keyup",s,!1),e.Utils.addClass(this,"slider-keydown"),e.Utils.accelerateCallback(e=>{(e.cancel=n)||this._setValue(this.value+i)})}}}onChange(e){return new Promise((t,a)=>{"slide"===e.type&&t(this.value=e.detail),t(this.value)})}_draw(t=this.value){const a=this._trackSize;if(e.Utils.isNull(a))return;const i=e.Utils.isNullOrEmpty(t)?this.min:parseFloat(t),n=Math.min(1,Math.max(0,(i-this.min)/(this.max-this.min)));this._progress.style.transform=`scale(${n}, 1)`,this._thumb.style.transform=`translateX(${Math.round(n*a.width)}px)`}_format(t){const a=this.format;if(!e.Utils.isNullOrEmpty(a))return new Intl.NumberFormat(e.Utils.lang(this),a).format(t);let i="-";e.Utils.isNull(t)||(i=t.toLocaleString());let n=new CustomEvent("formatvalue",{detail:{value:t}});return this.dispatchEvent(n),e.Utils.isNull(n.detail.output)?i:n.detail.output}acceptValue(e){this._draw(e)}getViewValue(e){return this._format(e)}convertValueAttributeToProperty(e){return parseFloat(e)}toggleReadonlyView(e){this._thumb.hidden=e}_setTrackSize(e){const t=e.detail;this._trackSize={x:t.left,y:t.top,width:t.width,height:t.height},this._draw(this.value)}_computeAndAssignValue(e,t){if(this.readonly||this.disabled)return;const a=this._trackSize,i=this.step;let n=(e-a.x)/a.width,s=(this.max-this.min)*n+this.min;"number"==typeof i&&(s=Math.round(s/i)*i),t?this._setValue(s):this._draw(s)}_setValue(t){isNaN(t)||e.Utils.isNull(t)?t=void 0:(!isNaN(this.min)&&t<this.min&&(t=this.min),!isNaN(this.max)&&t>this.max&&(t=this.max)),this.changeHandler(new CustomEvent("slide",{detail:t}))}connectedCallback(){super.connectedCallback(),this.addEventListener("mousedown",this._downHandler,!1),this.addEventListener("touchstart",this._downHandler,{passive:!1,capture:!1})}viewActivatedCallback(){super.viewActivatedCallback(),this._dragger.addEventListener(e.UI.DragDropEventType.Init,this._startHandler,!1),this._dragger.addEventListener(e.UI.DragDropEventType.Drag,this._dragHandler,!1),this._dragger.addEventListener(e.UI.DragDropEventType.End,this._endHandler,!1),this._thumb.addEventListener("keydown",this._keydownHandler,!1),this._min.text=this._format(this.min),this._max.text=this._format(this.max);const a=this._shellProxy.dom[0];e.Utils.isNull(a)||(a.target=this._thumb,a.options={trigger:t.UI.BalloonTrigger.Focus,trackPosition:!0,position:t.UI.BalloonPosition.Top,align:t.UI.BalloonAlignment.Center,behavior:t.UI.BalloonBehavior.Tooltip,hoverDelay:0,hoverTimeout:0},this._syncThumbLabel()),this._thumb.tabIndex=0}_syncThumbLabel(t=this.thumbLabel){const a=this._shellProxy.dom[0];(t?e.Utils.addClass:e.Utils.removeClass).apply(this,[this,"slider-thumblabel"]),a.disabled=!t}disconnectedCallback(){this.removeEventListener("mousedown",this._downHandler,!1),this.removeEventListener("touchstart",this._downHandler,{capture:!1}),e.Utils.isNull(this._dragger)||(this._dragger.removeEventListener(e.UI.DragDropEventType.End,this._endHandler,!1),this._dragger.removeEventListener(e.UI.DragDropEventType.Drag,this._dragHandler,!1),this._dragger.removeEventListener(e.UI.DragDropEventType.Init,this._startHandler,!1)),e.Utils.isNull(this._thumb)||this._thumb.removeEventListener("keydown",this._keydownHandler,!1),super.disconnectedCallback()}propertyChangedCallback(t,a,i,n){if(super.propertyChangedCallback(t,a,i,n),!n)switch(t){case"thumbLabel":this._syncThumbLabel(i);break;case"min":case"max":e.Utils.isNull(this._max)||e.Utils.isNull(this._min)||(this._min.text=this._format(this.min),this._max.text=this._format(this.max)),this._setValue(this.value),this._draw()}}};__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Number})],i.prototype,"min",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Number})],i.prototype,"max",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Boolean})],i.prototype,"thumbLabel",void 0),__decorate([e.Watch({emit:!1,converter:{convert:e=>{let t=parseFloat(e);return isNaN(t)?"any":t},convertBack:e=>(e||"").toString()}})],i.prototype,"step",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String})],i.prototype,"changePolicy",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Json})],i.prototype,"format",void 0),__decorate([e.ViewChild(".slider-track")],i.prototype,"_track",void 0),__decorate([e.ViewChild(".slider-progress")],i.prototype,"_progress",void 0),__decorate([e.ViewChild(".slider-thumb")],i.prototype,"_thumb",void 0),__decorate([e.ViewChild(`${e.P}-text[min]`)],i.prototype,"_min",void 0),__decorate([e.ViewChild(`${e.P}-text[max]`)],i.prototype,"_max",void 0),__decorate([e.ViewChild(`${e.P}-drag-drop`)],i.prototype,"_dragger",void 0),__decorate([e.ViewChild(`${e.P}-shell-proxy`)],i.prototype,"_shellProxy",void 0),i=__decorate([e.CustomElement({tagName:e.P+"-slider",template:`<div class="${e.PCSS}-viewfinder ${e.PCSS}-slider"><${e.P}-text text="{{ :host._format(:host.min) }}" min></${e.P}-text>\n <div class="slider-track"><div class="slider-progress"></div></div>\n <${e.P}-panel class="${e.PCSS}-clickable slider-thumb" behaviors="{{ [::_dragger] }}">\n <div class="thumb-label"></div>\n </${e.P}-panel>\n <${e.P}-text text="{{ :host._format(:host.max) }}" max></${e.P}-text>\n <div class="slider-footer"><${e.P}-text text="{{ :host.viewValue }}"></${e.P}-text></div>\n </div>\n<${e.P}-drag-drop lock-timeout="0"></${e.P}-drag-drop><${e.P}-resize watch-position="true" on-${t.ResizeEventName}=":host._setTrackSize($event)" target="{{ ::_track }}"></${e.P}-resize>\n<${e.P}-shell-proxy><${e.P}-balloon class="text-center"><${e.P}-text text="{{ :host.viewValue }}"></${e.P}-text></${e.P}-balloon></${e.P}-shell-proxy>\n`,shadow:e.Defaults.USE_SHADOW_ROOT})],i),a.PacemSliderElement=i}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(a){class SuggestionSelectEvent extends e.CustomTypedEvent{constructor(e){super("suggestionselect",{selectedValue:e})}}let i=class PacemSuggestElement extends a.PacemDataSourceElement{constructor(){super(...arguments),this._toggleBtnHandler=e=>{e.preventDefault(),this.disabled||this._balloon.toggle()},this._clearBtnHandler=e=>{e.preventDefault(),this.hint=this._input.value="",this.value=void 0,this._focus(null),this.changeHandler(new SuggestionSelectEvent(null))},this._balloonPopupHandler=t=>{e.Utils.addClass(this._btnArrow,"rotate-180")},this._balloonPopoutHandler=t=>{e.Utils.removeClass(this._btnArrow,"rotate-180")},this._inputHandler=e=>{switch(e.keyCode){case 9:case 13:break;default:this._focus(null),this.hint=this._input.value,this.changeHandler(new SuggestionSelectEvent(null))}},this._keyupHandler=t=>{this.#_&&(e.avoidHandler(t),this.#_=!1)},this._focusHandler=e=>{if(this.preventFocus){e.preventDefault();this._balloon.visible?this.popout():this.popup()}const t=this._input.value;this.viewValue!=t&&this._databind()},this._blurHandler=e=>{this._undo()},this.#_=!1,this._keydownHandler=t=>{var a=!1;if(e.Utils.isNull(this.#g)){const i=this._findFirstAvailableListItem();if(!e.Utils.isNull(i))switch(t.keyCode){case 40:e.avoidHandler(t),this._focus(i);break;case 13:e.avoidHandler(t),a=!0,1===this.#y.length?this._select(i):this._focus(i)}}else{var i,n=this.#g,s=n;const r=t=>!e.Utils.isNull(t)&&"li"===t.localName&&"true"===t.dataset.pacemDisabled,o=t=>!e.Utils.isNull(t)&&"li"===t.localName&&"true"!==t.dataset.pacemDisabled;switch(t.keyCode){case 38:e.avoidHandler(t);do{if(o(s=s.previousElementSibling)){i=s;break}}while(r(s));i??=n;break;case 40:e.avoidHandler(t);do{if(o(s=s.nextElementSibling)){i=s;break}}while(r(s));i??=n;break;case 27:e.avoidHandler(t),this._undo(),this.popout();break;case 9:case 13:e.avoidHandler(t),a=!0,this._select()}this._focus(i),this.#_=a}},this._selectHandler=t=>{e.avoidHandler(t),this._select(t.currentTarget)}}get inputFields(){return[this._input]}acceptValue(t){/*!this._isTyping && */!this.allowNew&&e.Utils.isNullOrEmpty(this.datasource)||(this._input.value=this.getViewValue(t)||(this._isTyping?this._input.value:""))}getViewValue(t){var a=super.getViewValue(t);return e.Utils.isNullOrEmpty(a)&&this.allowNew&&!e.Utils.isNullOrEmpty(t)&&(a=this.mapEntityToViewValue(t)),a}onChange(e){return new Promise((t,a)=>{if("suggestionselect"===e.type){const a=e.detail.selectedValue;this.value=a,a&&this.popout(),t(a)}else t(this.value)})}viewActivatedCallback(){super.viewActivatedCallback(),this._setDropdownMode(),this._setupItemTemplate();var t=this._createBalloon();t.appendChild(this._repeater),this._checkBalloon(t);e.CustomElementUtils.findAncestorShell(this).appendChild(t),this._balloon=t,this._input.addEventListener("mousedown",this._focusHandler,!1),this._input.addEventListener("keydown",this._keydownHandler,!1),this._input.addEventListener("keyup",this._keyupHandler,!1),this._input.addEventListener("focus",this._focusHandler,!1),this._input.addEventListener("blur",this._blurHandler,!1),this._input.addEventListener("input",this._inputHandler,!1),this._btnClear.addEventListener("mousedown",this._clearBtnHandler,!1),this._btnArrow.addEventListener("mousedown",this._toggleBtnHandler,!1),this._databind(),this._syncButtons()}propertyChangedCallback(t,a,i,n){if(super.propertyChangedCallback(t,a,i,n),e.Utils.isNull(this._balloon))return;const s=this._isTyping;switch(t){case"adaptedDatasource":e.Utils.isNullOrEmpty(i)?this.popout():s?this.popup():this._input.value=this.getViewValue(this.value);break;case"hint":s||i===this._input.value||(this._input.value=i,this.#g=null);break;case"readonly":this._setDropdownMode();case"disabled":case"value":this._checkBalloon();break;case"itemtemplate":n||this._setupItemTemplate();break;case"allowTyping":n||this._setDropdownMode()}["adaptedDatasource","hint","value"].indexOf(t)>=0&&this._databind(),["allowTyping","value","hint"].indexOf(t)>=0&&this._syncButtons()}disconnectedCallback(){e.Utils.isNull(this._balloon)||(this._balloon.removeEventListener("popup",this._balloonPopupHandler,!1),this._balloon.removeEventListener("popout",this._balloonPopoutHandler,!1),this._balloon.remove()),e.Utils.isNull(this._input)||(this._input.removeEventListener("mousedown",this._focusHandler,!1),this._input.removeEventListener("focus",this._focusHandler,!1),this._input.removeEventListener("blur",this._blurHandler,!1),this._input.removeEventListener("keydown",this._keydownHandler,!1),this._input.removeEventListener("keyup",this._keyupHandler,!1),this._input.removeEventListener("input",this._inputHandler,!1)),e.Utils.isNull(this._btnClear)||this._btnClear.removeEventListener("mousedown",this._clearBtnHandler,!1),e.Utils.isNull(this._btnArrow)||this._btnArrow.addEventListener("mousedown",this._toggleBtnHandler,!1),super.disconnectedCallback()}#y;_databind(){if(!e.Utils.isNull(this._repeater)){const e=this.#y=this._filter(this.adaptedDatasource,this._input.value);this._repeater.datasource=e}}_syncButtons(){e.Utils.isNull(this._btnArrow)||(this._btnArrow.hide=!1!==this.allowTyping||!e.Utils.isNullOrEmpty(this._input.value||this.value)),e.Utils.isNull(this._btnClear)||(this._btnClear.hide=this.readonly||e.Utils.isNullOrEmpty(this._input.value||this.value))}get _isTyping(){return e.Utils.is(this._input,":focus")}_undo(){this._focus(null),this.hint=this._input.value=this.getViewValue(this.value)||""}_findFirstAvailableListItem(){var t;if(!0===this._balloon.visible&&!e.Utils.isNull(t=this._repeater.querySelector("ol > li")))for(;!e.Utils.isNull(t)&&"true"===t.dataset.pacemDisabled&&"li"===t.localName;)t=t.nextElementSibling;return t}#_;_setDropdownMode(e=this.allowTyping){this._input.readOnly=!(e??1)}_setupItemTemplate(){if(this.itemtemplate instanceof HTMLTemplateElement){const e=this.itemtemplate.cloneNode(!0).content,t=document.createElement("template"),a=document.createElement("li");a.append(e),t.content.appendChild(a),this._tmplProxy.target=t}else this._tmplProxy.target=this._defaultTemplate}#g;_focus(t){if(this.preventFocus)return;if(e.Utils.isNull(t))return void(this.#g=null);const a=t.parentElement.children;for(let e=0;e<a.length;e++){const i=a.item(e);if(i===t){i.dataset.pacemFocused="true",this.#g=i;const e=this._input,t=e.value=JSON.parse(i.dataset.pacemViewValue);e.setSelectionRange(t.length,t.length)}else delete i.dataset.pacemFocused}}_select(e=this.#g){const t=JSON.parse(e.dataset.pacemValue);"true"===e.dataset.pacemDisabled||this.changeHandler(new SuggestionSelectEvent(t))}_filter(t,a,i=this.value){let n=t||[];if(!e.Utils.isNullOrEmpty(a&&a.trim())){const t=a.toLowerCase().split(" ");let i=n.filter(a=>{for(let i of t){if(a.viewValue?.toLowerCase().indexOf(i)>=0)return!0;const t=this.filterFields;if(!e.Utils.isNullOrEmpty(t)){const n=a.data;if("object"==typeof n&&!e.Utils.isNullOrEmpty(n))for(let a of t){const t=a.split(".");let s=0,r=n;for(;!e.Utils.isNull(r)&&s<t.length;)r=r[t[s]],s++;if(!e.Utils.isNullOrEmpty(r)&&r.toString().toLowerCase().indexOf(i)>=0)return!0}}}return!1});n=this.allowNew&&e.Utils.isNullOrEmpty(this.valueProperty)&&e.Utils.isNullOrEmpty(this.textProperty)&&(e.Utils.isNullOrEmpty(i)||e.Utils.isNull(i.find(e=>e.viewValue===a)))?[{value:a,viewValue:a,data:a}].concat(i):i}let s=n;return!1!==this.allowTyping&&(s=n.slice(0,this.maxSuggestions||10)),this._isTyping&&this.popup(),this._balloon.style.opacity=e.Utils.isNullOrEmpty(s)?"0":"",this.log(e.Logging.LogLevel.Log,`${s.length} dropdown suggestion(s), given hint '${a}' and ${(t||[]).length} datasource items`),s}_itemCreate(e){const t=e.detail.dom.find(e=>e instanceof HTMLLIElement),a=e.detail.item,i=(e.detail.index,!0===a.disabled);t.tabIndex=i?-1:0,t.dataset.pacemValue=JSON.stringify(a.value),t.dataset.pacemViewValue=JSON.stringify(a.viewValue),t.dataset.pacemDisabled=i.toString(),t.addEventListener("mousedown",this._selectHandler,!1)}_itemRemove(e){e.detail.dom.find(e=>e instanceof HTMLLIElement).removeEventListener("mousedown",this._selectHandler,!1)}toggleReadonlyView(e){this.span.hidden=!e,this._input.hidden=e,e?this._btnClear.hide=this._btnArrow.hide=!0:this._syncButtons()}popup(t=100){!e.Utils.isNullOrEmpty(this.adaptedDatasource)&&e.Utils.isVisible(this)&&(console.log("Popping up from here..."),this._balloon?.popup(t))}popout(e=0){this.#g=null,this._balloon?.popout(e)}_checkBalloon(t=this._balloon){if(!e.Utils.isNull(t)){const a=!e.Utils.isNullOrEmpty(this.value)&&!e.Utils.isNullOrEmpty(this._input.value);t.disabled=a||this.readonly||this.disabled||!1}}_createBalloon(){const a=document.createElement(e.P+"-balloon");return e.Utils.addClass(a,"suggest dropdown"),a.options={trackPosition:!0,trigger:t.UI.BalloonTrigger.Focus,position:t.UI.BalloonPosition.VerticalAuto,size:t.UI.BalloonSizing.Match,align:t.UI.BalloonAlignment.Start,behavior:t.UI.BalloonBehavior.Menu,hoverDelay:100,hoverTimeout:0},a.addEventListener("popup",this._balloonPopupHandler,!1),a.addEventListener("popout",this._balloonPopoutHandler,!1),a.target=this._input,a}};__decorate([e.ViewChild("input[type=text]")],i.prototype,"_input",void 0),__decorate([e.ViewChild(e.P+"-repeater")],i.prototype,"_repeater",void 0),__decorate([e.ViewChild(`span.${e.PCSS}-readonly`)],i.prototype,"span",void 0),__decorate([e.ViewChild("template")],i.prototype,"_defaultTemplate",void 0),__decorate([e.ViewChild(e.P+"-template-proxy")],i.prototype,"_tmplProxy",void 0),__decorate([e.ViewChild(`${e.P}-button[toggle]`)],i.prototype,"_btnArrow",void 0),__decorate([e.ViewChild(`${e.P}-button[clear]`)],i.prototype,"_btnClear",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],i.prototype,"hint",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Number})],i.prototype,"maxSuggestions",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Boolean})],i.prototype,"allowTyping",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Boolean})],i.prototype,"preventFocus",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Element})],i.prototype,"itemtemplate",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.StringArray})],i.prototype,"filterFields",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Boolean})],i.prototype,"allowNew",void 0),i=__decorate([e.CustomElement({tagName:e.P+"-suggest",shadow:e.Defaults.USE_SHADOW_ROOT,template:`<div class="${e.PCSS}-relative"><input type="text" class="${e.PCSS}-input" />\n<${e.P}-button clear tab-order="-1"\nclass="button-flat ${e.PCSS}-anim anim-pop anim-sudden anim-quick pos-absolute absolute-right absolute-top display-block ${e.PCSS}-margin margin-0" \n icon-glyph="highlight_off"></${e.P}-button>\n<${e.P}-button \nclass="button-flat icon-rotate ${e.PCSS}-anim anim-pop anim-sudden anim-quick pos-absolute absolute-right absolute-top display-block ${e.PCSS}-margin margin-0" \n icon-glyph="arrow_drop_down" tab-order="-1" toggle></${e.P}-button>\n</div>\n<span class="${e.PCSS}-readonly"><${e.P}-text text="{{ :host.viewValue }}"></${e.P}-text></span>\n<${e.P}-repeater on-${t.RepeaterItemCreateEventName}=":host._itemCreate($event)" on-${t.RepeaterItemRemoveEventName}=":host._itemRemove($event)">\n <ol>\n <${e.P}-template-proxy></${e.P}-template-proxy>\n </ol>\n</${e.P}-repeater><${e.P}-content></${e.P}-content>\n<template>\n <li><${e.P}-span content="{{ $pacem.highlight(^item.viewValue, :host.hint) }}"></${e.P}-span></li>\n</template>`})],i),a.PacemSuggestElement=i}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(a){class TagRemoveEvent extends e.CustomTypedEvent{constructor(e){super("tagremove",{index:e})}}class TagAddEvent extends e.CustomTypedEvent{constructor(e){super("tagadd",{value:e})}}let i=class PacemTagElement extends t.PacemElement{propertyChangedCallback(t,a,i,n){switch(super.propertyChangedCallback(t,a,i,n),t){case"readonly":let t=!!i;(t?e.Utils.addClass:e.Utils.removeClass)(this,"tag-readonly"),this._btn.disabled=this._btn.hide=t;break;case"tag":e.Utils.removeClass(this,"tag-out")}}_remove(){e.Utils.addClass(this,"tag-out"),e.Utils.addAnimationEndCallback(this,()=>{this.dispatchEvent(new Event("remove"))})}};__decorate([e.Watch({converter:e.PropertyConverters.String})],i.prototype,"tag",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Boolean})],i.prototype,"readonly",void 0),__decorate([e.ViewChild(e.P+"-button")],i.prototype,"_btn",void 0),i=__decorate([e.CustomElement({tagName:e.P+"-tag",shadow:e.Defaults.USE_SHADOW_ROOT,template:`<${e.P}-text text="{{ :host.tag }}"></${e.P}-text>\n <${e.P}-button on-click=":host._remove()"></${e.P}-button>`})],i),a.PacemTagElement=i;let n=class PacemTagsElement extends a.PacemDataSourceElement{constructor(){super(!0),this.inputFields=[]}toggleReadonlyView(e){this._suggest.readonly=e,this.querySelector(".tag-new").hidden=e}_tagRemove(e){this.changeHandler(new TagRemoveEvent(e))}_tagAdd(e){this.changeHandler(new TagAddEvent(e))}handleDatasourceMismatch(){}propertyChangedCallback(t,a,i,n){switch(super.propertyChangedCallback(t,a,i,n),t){case"datasource":case"textProperty":this._suggest[t]=i;break;case"valueProperty":if(!e.Utils.isNullOrEmpty(i))throw`Cannot set 'valueProperty' on ${this.constructor.name}s.`;break;case"value":this._tags.datasource=i}}onChange(t){return new Promise((a,i)=>{switch(t.type){case"tagremove":this._justAddedIndex=-1;const i=t.detail.index,n=e.Utils.clone(this.value),s=n.splice(i+1),r=n.splice(0,i);a(this.value=r.concat(s));break;case"tagadd":const o=t.detail.value,l=e.Utils.clone(this.value);if(!e.Utils.isNullOrEmpty(o)&&(this.allowDuplicates||e.Utils.isNullOrEmpty(l&&l.find(e=>this.mapEntityToViewValue(e)==this.mapEntityToViewValue(o))))){let e=(l||[]).concat([o]);a(this.value=e),this._justAddedIndex=this.value.length-1,setTimeout(()=>{this._suggest.focus()},250),this._suggest.blur(),this._suggest.hint="",this._suggest.reset()}break;default:a(this.value)}})}acceptValue(e){}};__decorate([e.Watch({converter:e.PropertyConverters.String})],n.prototype,"hint",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Boolean})],n.prototype,"allowDuplicates",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Boolean})],n.prototype,"allowNew",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Number})],n.prototype,"_justAddedIndex",void 0),__decorate([e.ViewChild(e.P+"-suggest")],n.prototype,"_suggest",void 0),__decorate([e.ViewChild(e.P+"-repeater."+e.PCSS+"-tags")],n.prototype,"_tags",void 0),n=__decorate([e.CustomElement({tagName:e.P+"-tags",shadow:e.Defaults.USE_SHADOW_ROOT,template:`<${e.P}-repeater class="${e.PCSS}-tags">\n <ul class="${e.PCSS}-tags ${e.PCSS}-viewfinder ${e.PCSS}-list list-unstyled list-inline">\n <template>\n <li class="${e.PCSS}-tag">\n <${e.P}-tag on-remove=":host._tagRemove(^index)" css-class="{{ { 'tag-in': :host._justAddedIndex === ^index } }}" tag="{{ :host.mapEntityToViewValue(^item) }}" readonly="{{ :host.readonly }}"></${e.P}-tag>\n </li>\n </template>\n <li class="tag-new">\n <${e.P}-suggest logger="{{ :host.logger }}" placeholder="{{ :host.placeholder }}" allow-new="{{ :host.allowNew }}" class="${e.PCSS}-tags" on-change=":host._tagAdd($this.value)" hint="{{ :host.hint, twoway }}">\n <${e.P}-content></${e.P}-content>\n </${e.P}-suggest>\n </li>\n </ul>\n</${e.P}-repeater>`})],n),a.PacemTagsElement=n}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){let a=class PacemMarkdownTextAreaElement extends t.PacemTextualInputElement{constructor(t=new e.MarkdownService){super(),this._md=t,this.rows=5,this.cols=50,this._keydownHandler=t=>{if(9===t.keyCode){const i=this.input,n=i.value;var a=i.selectionStart;i.value=n.substr(0,a)+" "+n.substr(a),e.preventDefaultHandler(t)}}}toggleReadonlyView(e){this.input.hidden=e}get preventKeyboardSubmit(){return!0}get inputFields(){return[this.input]}getViewValue(e){return this._md.toHtml(e)}propertyChangedCallback(e,t,a,i){super.propertyChangedCallback(e,t,a,i),"rows"===e||"cols"===e?this.inputField.setAttribute(e,a):"viewValue"==e&&(this._markdown.innerHTML=a)}viewActivatedCallback(){super.viewActivatedCallback(),this.input.addEventListener("keydown",this._keydownHandler,!1)}disconnectedCallback(){this.input&&this.input.removeEventListener("keydown",this._keydownHandler,!1),super.disconnectedCallback()}};__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Number})],a.prototype,"rows",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Number})],a.prototype,"cols",void 0),__decorate([e.ViewChild("textarea")],a.prototype,"input",void 0),__decorate([e.ViewChild(`div.${e.PCSS}-readonly`)],a.prototype,"_markdown",void 0),a=__decorate([e.CustomElement({tagName:e.P+"-textarea-markdown",template:`<textarea class="${e.PCSS}-input" pacem></textarea>${t.CHAR_COUNTER_CHILD}<div class="${e.PCSS}-readonly ${e.PCSS}-markdown"></div>`,shadow:e.Defaults.USE_SHADOW_ROOT})],a),t.PacemMarkdownTextAreaElement=a}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){let a=class PacemTextAreaElement extends t.PacemTextualInputElement{constructor(){super(...arguments),this.rows=5,this.cols=50}get preventKeyboardSubmit(){return!0}toggleReadonlyView(e){this._span.hidden=!e,this._input.hidden=e}get inputFields(){return[this._input]}propertyChangedCallback(e,t,a,i){super.propertyChangedCallback(e,t,a,i),"rows"!==e&&"cols"!==e||this.inputField.setAttribute(e,a)}};__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Number})],a.prototype,"rows",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Number})],a.prototype,"cols",void 0),__decorate([e.ViewChild("textarea")],a.prototype,"_input",void 0),__decorate([e.ViewChild(`span.${e.PCSS}-readonly`)],a.prototype,"_span",void 0),a=__decorate([e.CustomElement({tagName:e.P+"-textarea",template:`<textarea class="${e.PCSS}-input" pacem></textarea>${t.CHAR_COUNTER_CHILD}<span class="${e.PCSS}-readonly"><${e.P}-text text="{{ :host.viewValue }}"></${e.P}-text></span>`,shadow:e.Defaults.USE_SHADOW_ROOT})],a),t.PacemTextAreaElement=a}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){class PacemBaseValidatorElement extends t.PacemFormRelevantElement{constructor(){super()}viewActivatedCallback(){super.viewActivatedCallback(),e.Utils.addClass(this,e.PCSS+"-validator")}propertyChangedCallback(t,a,i,n){super.propertyChangedCallback(t,a,i,n);let s=this.form;switch(t){case"watch":a&&s&&s.unregisterValidator(i,this),s&&s.registerValidator(i,this);break;case"invalid":break;case"form":let t=this.watch;e.Utils.isNullOrEmpty(t)||(null!=a&&a.unregisterValidator(t,this),null!=i&&i.registerValidator(t,this));break;case"disabled":this.triggerFormFieldValidation()}}#f;triggerFormFieldValidation(){const t=this.form,a=this.watch;e.Utils.isNull(t)||e.Utils.isNullOrEmpty(a)||(cancelAnimationFrame(this.#f),this.#f=requestAnimationFrame(()=>{t.validate(a)}))}validate(t){return this.disabled?e.Utils.fromResult(!0):this.evaluate(t)}}function a(t){return e.Utils.isNullOrEmpty(t)}__decorate([e.Watch({converter:e.PropertyConverters.Boolean})],PacemBaseValidatorElement.prototype,"invalid",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],PacemBaseValidatorElement.prototype,"errorMessage",void 0),__decorate([e.Watch({emit:!1,reflectBack:!0,converter:e.PropertyConverters.String})],PacemBaseValidatorElement.prototype,"watch",void 0),t.PacemBaseValidatorElement=PacemBaseValidatorElement,t.BASIC_VALIDATOR_TEMPLATE=`<${e.P}-span part="error-message" hide="{{ !:host.invalid }}" text="{{ :host.errorMessage }}"></${e.P}-span>`;let i=class PacemRequiredValidatorElement extends PacemBaseValidatorElement{evaluate(t){let i=!a(t);return e.Utils.fromResult(i)}};i=__decorate([e.CustomElement({tagName:e.P+"-required-validator",template:t.BASIC_VALIDATOR_TEMPLATE,shadow:e.Defaults.USE_SHADOW_ROOT})],i),t.PacemRequiredValidatorElement=i;let n=class PacemRegexValidatorElement extends PacemBaseValidatorElement{propertyChangedCallback(e,t,a,i){super.propertyChangedCallback(e,t,a,i),i||"pattern"!==e||this.triggerFormFieldValidation()}evaluate(t){let i=!0,n=this.pattern;return a(t)||(i=new RegExp(n).test(t)),e.Utils.fromResult(i)}};__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String})],n.prototype,"pattern",void 0),n=__decorate([e.CustomElement({tagName:e.P+"-regex-validator",template:t.BASIC_VALIDATOR_TEMPLATE,shadow:e.Defaults.USE_SHADOW_ROOT})],n),t.PacemRegexValidatorElement=n;let s=class PacemLengthValidatorElement extends PacemBaseValidatorElement{propertyChangedCallback(e,t,a,i){super.propertyChangedCallback(e,t,a,i),i||"min"!==e&&"max"!==e||this.triggerFormFieldValidation()}evaluate(t){let i=!0;return a(t)||(this.min>=0&&(i=i&&(t||"").toString().length>=this.min),this.max>=0&&(i=i&&(t||"").toString().length<=this.max)),e.Utils.fromResult(i)}};__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Number})],s.prototype,"min",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Number})],s.prototype,"max",void 0),s=__decorate([e.CustomElement({tagName:e.P+"-length-validator",template:t.BASIC_VALIDATOR_TEMPLATE,shadow:e.Defaults.USE_SHADOW_ROOT})],s),t.PacemLengthValidatorElement=s;let r=class PacemRangeValidatorElement extends PacemBaseValidatorElement{propertyChangedCallback(e,t,a,i){super.propertyChangedCallback(e,t,a,i),i||"min"!==e&&"max"!==e||this.triggerFormFieldValidation()}evaluate(t){let i=!0;if(!a(t)){let a=t;t instanceof Date||"number"!=typeof t&&(a=e.Utils.parseDate(t))instanceof Date&&isFinite(a.valueOf())?(null!=this.min&&(i=i&&a.valueOf()>=e.Utils.parseDate(this.min).valueOf()),null!=this.max&&(i=i&&a.valueOf()<=e.Utils.parseDate(this.max).valueOf())):(null!=this.min&&(i=i&&t>=this.min),null!=this.max&&(i=i&&t<=this.max))}return e.Utils.fromResult(i)}};__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Number})],r.prototype,"min",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Number})],r.prototype,"max",void 0),r=__decorate([e.CustomElement({tagName:e.P+"-range-validator",template:t.BASIC_VALIDATOR_TEMPLATE,shadow:e.Defaults.USE_SHADOW_ROOT})],r),t.PacemRangeValidatorElement=r;let o=class PacemCompareValidatorElement extends PacemBaseValidatorElement{propertyChangedCallback(e,t,a,i){super.propertyChangedCallback(e,t,a,i),i||"operator"!==e&&"to"!==e||this.triggerFormFieldValidation()}_prepareValuesForComparison(t,a){return e.Utils.Dates.isDate(t)||e.Utils.Dates.isDate(a)?[e.Utils.parseDate(t),e.Utils.parseDate(a)]:[t,a]}evaluate(t){let i=!0,n=this.to;if(!a(t)&&!a(n)){const e=this._prepareValuesForComparison(t,n);switch(t=e[0],n=e[1],this.operator){case"lessOrEqual":i=t<=n;break;case"less":i=t<n;break;case"greaterOrEqual":i=t>=n;break;case"greater":i=t>n;break;case"notEqual":i=t!==n;break;default:i=t===n}}return e.Utils.fromResult(i)}};__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String})],o.prototype,"operator",void 0),__decorate([e.Watch({emit:!1,reflectBack:!0})],o.prototype,"to",void 0),o=__decorate([e.CustomElement({tagName:e.P+"-compare-validator",template:t.BASIC_VALIDATOR_TEMPLATE,shadow:e.Defaults.USE_SHADOW_ROOT})],o),t.PacemCompareValidatorElement=o;let l=class PacemBinaryValidatorElement extends PacemBaseValidatorElement{propertyChangedCallback(e,t,a,i){super.propertyChangedCallback(e,t,a,i),i||"pattern"!==e&&"maxSize"!==e||this.triggerFormFieldValidation()}evaluate(t){let i=!0,n=this.pattern,s=this.maxSize;if(!a(t)){if(!e.Utils.isNullOrEmpty(n)){let e="string"==typeof t?t:t.name;i=new RegExp(n,"i").test(e)}!e.Utils.isNull(s)&&"object"==typeof t&&t.size>0&&(i=i&&t.size<=s)}return e.Utils.fromResult(i)}};__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String})],l.prototype,"pattern",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String})],l.prototype,"maxSize",void 0),l=__decorate([e.CustomElement({tagName:e.P+"-binary-validator",template:t.BASIC_VALIDATOR_TEMPLATE,shadow:e.Defaults.USE_SHADOW_ROOT})],l),t.PacemBinaryValidatorElement=l;let c=class PacemAsyncValidatorElement extends PacemBaseValidatorElement{constructor(){super(...arguments),this._deferredToken=null}_evaluateResult(){const t=this._fetcher.result;switch(t){case"true":return!0;case"false":return!1;default:try{let a=JSON.parse(t);return e.Utils.getApiResult(a)||!1}catch(e){return!1}}}_fetch(t){const a=this._deferredToken,i=this._fetcher;var n=this.parameters||{};n[this.watch]=t;const s={parameters:n,url:this.url,as:"text",method:this.method},r=e.Utils.jsonSortStringify(s),o=this.#C;let l=!1;if(e.Utils.isNullOrEmpty(o)||(l=r===o),l){const e=this._evaluateResult();a.resolve(e)}else e.Utils.extend(i,s),clearTimeout(this._debouncer),this._debouncer=setTimeout(()=>{i.fetch().then(e=>{const t=this._evaluateResult();a.resolve(t),this.#C=r},e=>{a.resolve(!1)})},1e3);return a.promise}#C;evaluate(t){return e.Utils.isNullOrEmpty(t)?e.Utils.fromResult(!0):(this._deferredToken=this._deferredToken=e.DeferPromise.defer(),this._fetch(t).then(e=>(this._deferredToken=null,e),e=>(this._deferredToken=null,!1)))}propertyChangedCallback(e,t,a,i){if(super.propertyChangedCallback(e,t,a,i),!i)switch(e){case"parameters":case"url":case"method":case"fetchCredentials":case"fetchHeaders":this.triggerFormFieldValidation()}}};__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Json})],c.prototype,"parameters",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Json})],c.prototype,"fetchCredentials",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Json})],c.prototype,"fetchHeaders",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String})],c.prototype,"url",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String})],c.prototype,"method",void 0),__decorate([e.ViewChild(e.P+"-fetch")],c.prototype,"_fetcher",void 0),c=__decorate([e.CustomElement({tagName:e.P+"-async-validator",template:t.BASIC_VALIDATOR_TEMPLATE+`<${e.P}-fetch autofetch="false" throttle="true" credentials="{{ :host.fetchCredentials }}" headers="{{ :host.fetchHeaders }}"></${e.P}-fetch>`,shadow:e.Defaults.USE_SHADOW_ROOT})],c),t.PacemAsyncValidatorElement=c;let d=class PacemCustomValidatorElement extends PacemBaseValidatorElement{propertyChangedCallback(e,t,a,i){super.propertyChangedCallback(e,t,a,i),i||"isValid"!==e||this.triggerFormFieldValidation()}evaluate(t){let i=!0;return a(t)||(i=!!this.isValid),e.Utils.fromResult(i)}};__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Boolean})],d.prototype,"isValid",void 0),d=__decorate([e.CustomElement({tagName:e.P+"-custom-validator",template:t.BASIC_VALIDATOR_TEMPLATE,shadow:e.Defaults.USE_SHADOW_ROOT})],d),t.PacemCustomValidatorElement=d}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){class PacemContenteditableButtonCommandElement extends t.PacemContenteditableCommandElement{cleanUp(e){}propertyChangedCallback(t,a,i,n){super.propertyChangedCallback(t,a,i,n),"range"===t&&(this.active=!e.Utils.isNull(i))}getTooltip(t=this.altText,a=this.keyboardShortcut){const i=t;return e.Utils.isNullOrEmpty(a)?i:`${i} (${a})`}}__decorate([e.Watch({converter:e.PropertyConverters.String})],PacemContenteditableButtonCommandElement.prototype,"icon",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],PacemContenteditableButtonCommandElement.prototype,"keyboardShortcut",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],PacemContenteditableButtonCommandElement.prototype,"altText",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Boolean})],PacemContenteditableButtonCommandElement.prototype,"active",void 0),t.PacemContenteditableButtonCommandElement=PacemContenteditableButtonCommandElement,t.CONTENTELEMENT_BUTTONCOMMAND_TEMPLATE=`<${e.P}-button disabled="{{ !:host.active }}" css-class="{{ {'text-primary': :host.isRelevant(:host.range)} }}" tooltip="{{ :host.getTooltip(:host.altText, :host.keyboardShortcut) }}" class="button" on-click=":host.execCommand()"><${e.P}-icon class="text-rootsize" icon="{{ :host.icon }}"></${e.P}-icon></${e.P}-button>\n <${e.P}-shortcut disabled="{{ !:host.active }}" target="{{ :host.contentElement }}" combination="{{ :host.keyboardShortcut }}" on-execute=":host.execCommand()"></${e.P}-shortcut>`}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){function a(e){return"format_align_"+e}let i=class PacemContenteditableAlignCommandElement extends t.PacemContenteditableButtonCommandElement{isRelevant(a){const i=t.ContenteditableUtils.findSurroundingSiblingBlockElements(a);if(e.Utils.isNullOrEmpty(i))return!1;const n=i[0];return getComputedStyle(n).textAlign==this.align}propertyChangedCallback(t,i,n,s){super.propertyChangedCallback(t,i,n,s),"align"===t&&((e.Utils.isNullOrEmpty(this.icon)||this.icon===a(i))&&(this.icon=a(n)),(e.Utils.isNullOrEmpty(this.altText)||this.altText===i)&&(this.altText=n))}exec(){const a=t.ContenteditableUtils.findSurroundingSiblingBlockElements(this.range);let i;for(let n of a)t.ContenteditableUtils.isBlockElement(n)&&n instanceof HTMLElement&&(e.Utils.isNull(i)&&(i=e.Utils.hasClass(n,"text-"+this.align)?"":this.align),n.style.textAlign="",e.Utils.removeClass(n,"text-left text-right text-center text-justify"),e.Utils.isEmpty(i)||e.Utils.addClass(n,"text-"+i));return Promise.resolve()}};__decorate([e.Watch({converter:e.PropertyConverters.String})],i.prototype,"align",void 0),i=__decorate([e.CustomElement({tagName:e.P+"-contenteditable-aligncommand",shadow:e.Defaults.USE_SHADOW_ROOT,template:t.CONTENTELEMENT_BUTTONCOMMAND_TEMPLATE})],i),t.PacemContenteditableAlignCommandElement=i}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){let a;function i(e){const t=e?.toLowerCase();switch(t){case"bold":case"italic":return"format_"+t;case"underline":return"format_underlined";case"strikethrough":return"strikethrough_s";case"insertorderedlist":return"format_list_numbered";case"insertunorderedlist":return"format_list_bulleted";case"justifyleft":case"justifyright":case"justifycenter":return"format_align_"+t.substr(7);case"justifyfull":return"format_align_justify";default:return"help_outline"}}function n(e,t){const a=e?.toLowerCase();switch(a){case"bold":return["b","strong"];case"italic":return["i","em"];case"underline":return["u"];case"strikethrough":return["strike","s","del"];case"insertorderedlist":return["ol"];case"insertunorderedlist":return["ul"];case"justifyleft":return[{style:{name:"text-align",value:"left"}}];case"justifyright":return[{style:{name:"text-align",value:"right"}}];case"justifycenter":return[{style:{name:"text-align",value:"center"}}];case"justifyfull":return[{style:{name:"text-align",value:"justify"}}];case"formatblock":return[t];default:return["none"]}}!function(e){e.Bold="bold",e.Italic="italic",e.Underline="underline",e.StrikeThrough="strikeThrough",e.OrderedList="insertOrderedList",e.UnorderedList="insertUnorderedList",e.JustifyLeft="justifyLeft",e.JustifyCenter="justifyCenter",e.JustifyRight="justifyRight",e.JustifyFull="justifyFull"}(a=t.KnownExecCommand||(t.KnownExecCommand={}));let s=class PacemContenteditableExecCommandElement extends t.PacemContenteditableButtonCommandElement{_matchRelevance(a,i){const n="object"==typeof i?t.ContenteditableUtils.findSurroundingNode(a,t=>t instanceof HTMLElement&&(e.Utils.isNullOrEmpty(i.tagName)||t.tagName===i.tagName.toUpperCase())&&t.style[i.style.name]===i.style.value):t.ContenteditableUtils.findSurroundingNode(a,i);return!e.Utils.isNull(n)}isRelevant(e){const t=n(this.command,this.argument);for(let a of t)if(this._matchRelevance(e,a))return!0;return!1}propertyChangedCallback(t,a,n,s){super.propertyChangedCallback(t,a,n,s),"command"===t&&((e.Utils.isNullOrEmpty(this.icon)||this.icon===i(a))&&(this.icon=i(n)),(e.Utils.isNullOrEmpty(this.altText)||this.altText===a)&&(this.altText=n))}exec(){return new Promise((a,i)=>{const s=this.range,r=n(this.command,this.argument)[0];if(!e.Utils.isNull(s)){const a=t.ContenteditableUtils.testInertElementWrapping(s);if(a.result&&"string"==typeof r&&["b","i","strike","u"].indexOf(r)>=0){const i=t.ContenteditableUtils.findSurroundingNode(s,r);if(e.Utils.isNull(i)||1!==i.childNodes.length){const e=document.createElement(r),i=a.element,n=s.extractContents();s.insertNode(e),e.append(n),t.ContenteditableUtils.select(i)}else{const e=i.childNodes.item(0),n=a.element;i.parentElement.replaceChild(e,i),t.ContenteditableUtils.select(n)}}else document.execCommand(this.command,!1,this.argument)}a()})}};__decorate([e.Watch({converter:e.PropertyConverters.String})],s.prototype,"command",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String})],s.prototype,"argument",void 0),s=__decorate([e.CustomElement({tagName:e.P+"-contenteditable-execcommand",shadow:e.Defaults.USE_SHADOW_ROOT,template:t.CONTENTELEMENT_BUTTONCOMMAND_TEMPLATE})],s),t.PacemContenteditableExecCommandElement=s}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){let a=class PacemContenteditableHistoryCommandElement extends t.PacemContenteditableButtonCommandElement{exec(){return new Promise((t,a)=>{const i=this.container?.history;if(!e.Utils.isNull(i)){if("redo"===this.command)i.canRedo&&(i.redo(),t());else i.canUndo&&(i.undo(),t());this.contentElement.innerHTML=i.current}})}isRelevant(e){return!1}propertyChangedCallback(e,t,a,i){if(super.propertyChangedCallback(e,t,a,i),"command"===e)this.icon=this.icon||a,this.altText=a,this.keyboardShortcut=this.keyboardShortcut||"Ctrl+"+("redo"===a?"Y":"Z")}containerPropertyChangedCallback(t,a,i,n){super.containerPropertyChangedCallback(t,a,i,n);const s=this.container,r=s.history;"range"!==t&&"history"!==t||(this.active=!e.Utils.isNull(s.range)&&("redo"===this.command&&r?.canRedo||"redo"!==this.command&&r?.canUndo))}};__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String,reflectBack:!0})],a.prototype,"command",void 0),a=__decorate([e.CustomElement({tagName:e.P+"-contenteditable-historycommand",shadow:e.Defaults.USE_SHADOW_ROOT,template:t.CONTENTELEMENT_BUTTONCOMMAND_TEMPLATE})],a),t.PacemContenteditableHistoryCommandElement=a}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){function a(t,a){return new Promise((i,n)=>{e.Utils.blobToDataURL(a).then(e.Utils.loadImage).then(e=>{const a=document.createElement("picture");a.setAttribute("contenteditable","false"),e.tabIndex=0,a.appendChild(e),t.deleteContents(),t.insertNode(a),i(a)})})}let i=class PacemContenteditableImageCommandElement extends t.PacemContenteditableButtonCommandElement{constructor(){super(...arguments),this._setBehaviorHandler=e=>{const a=e.target.parentElement;this.range=t.ContenteditableUtils.select(a)},this._disposeBehaviorHandler=e=>{}}pasteCallback(e){return e.type.startsWith("image")?a(this.range,e):Promise.reject()}cleanUp(t){t.querySelectorAll("picture[contenteditable=false]").forEach(e=>{for(let t=e.childNodes.length-1;t>0;t--)e.childNodes.item(t).remove()}),t.querySelectorAll("div."+e.PCSS+"-rescale").forEach(e=>e.remove())}isRelevant(e){return!1}viewActivatedCallback(){super.viewActivatedCallback(),e.Utils.isNullOrEmpty(this.altText)&&(this.altText="insert image"),e.Utils.isNullOrEmpty(this.icon)&&(this.icon="insert_photo"),e.Utils.isNullOrEmpty(this.keyboardShortcut)&&(this.keyboardShortcut="Ctrl+Shift+I"),this._rescale.addEventListener("rescale",this._rescaleImg,!1)}disconnectedCallback(){e.Utils.isNull(this._rescale)||(this._rescale.removeEventListener("rescale",this._rescaleImg,!1),this._disposeContainer()),super.disconnectedCallback()}propertyChangedCallback(t,a,i,n){switch(super.propertyChangedCallback(t,a,i,n),t){case"disabled":e.Utils.isNull(this._rescale)||(this._rescale.disabled=i);break;case"contentElement":a&&this._disposeContainer(a),i&&this._initContainer(i);break;case"range":this._rangeChangeCallback(a,i)}}exec(){return new Promise((t,i)=>{const n=this._file,s=this.range;n.onchange=i=>{const r=n.files[0];e.Utils.isNull(r)?t():a(s,r).then(e=>{n.value="",t()})},n.click()})}_rescaleImg(e){e.preventDefault();const t=e.detail.element,a=e.detail.targetRect,i=t.firstElementChild;i.style.width=a.width+"px",i.style.height=a.height+"px"}#P;_rangeChangeCallback(t,a){if(!e.Utils.isNull(t)&&!t.collapsed&&t.commonAncestorContainer instanceof Element&&t.commonAncestorContainer===t.startContainer&&t.commonAncestorContainer===t.endContainer&&t.startOffset===t.endOffset-1){const e=t.commonAncestorContainer.childNodes.item(t.startOffset);e instanceof HTMLPictureElement&&this._rescale.unregister(e)}if(!e.Utils.isNull(a)&&!a.collapsed&&a.commonAncestorContainer instanceof Element&&a.commonAncestorContainer===a.startContainer&&a.commonAncestorContainer===a.endContainer&&a.startOffset===a.endOffset-1){const e=a.commonAncestorContainer.childNodes.item(a.startOffset);e instanceof HTMLPictureElement&&this._rescale.register(e)}}_enhancePictureElement(e){e.firstElementChild&&(e.firstElementChild.addEventListener("focus",this._setBehaviorHandler,!1),e.firstElementChild.addEventListener("blur",this._disposeBehaviorHandler,!1))}_downgradePictureElement(e){e.firstElementChild&&(e.firstElementChild.removeEventListener("focus",this._setBehaviorHandler,!1),e.firstElementChild.removeEventListener("blur",this._disposeBehaviorHandler,!1))}_initContainer(e=this.contentElement){this.#P=new t.ContenteditableDOMObserver(e,(e,t)=>{e instanceof HTMLPictureElement&&(t?this._downgradePictureElement(e):this._enhancePictureElement(e))},"picture")}_disposeContainer(t=this.contentElement){const a=this.#P;e.Utils.isNull(a)||a.dispose()}};__decorate([e.ViewChild("input[type=file]")],i.prototype,"_file",void 0),__decorate([e.ViewChild(e.P+"-rescale")],i.prototype,"_rescale",void 0),i=__decorate([e.CustomElement({tagName:e.P+"-contenteditable-imagecommand",shadow:e.Defaults.USE_SHADOW_ROOT,template:`<input type="file" accept="image/png, image/gif, image/jpeg, image/bmp, image/x-icon" class="${e.PCSS}-trasparent ${e.PCSS}-inert" pacem hidden>`+t.CONTENTELEMENT_BUTTONCOMMAND_TEMPLATE+`<${e.P}-rescale keep-proportions="true"></${e.P}-rescale>`})],i),t.PacemContenteditableImageCommandElement=i}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){let a=class PacemContenteditableLinkCommandElement extends t.PacemContenteditableButtonCommandElement{isRelevant(a){return!e.Utils.isNull(t.ContenteditableUtils.findSurroundingNode(a,HTMLAnchorElement))}viewActivatedCallback(){super.viewActivatedCallback(),e.Utils.isNullOrEmpty(this.altText)&&(this.altText="insert link"),e.Utils.isNullOrEmpty(this.icon)&&(this.icon="insert_link"),e.Utils.isNullOrEmpty(this.keyboardShortcut)&&(this.keyboardShortcut="Ctrl+H")}exec(e,a=this.target){return new Promise((i,n)=>{var s=this.range,r=t.ContenteditableUtils.findSurroundingNode(s,HTMLAnchorElement),o="http://",l=/<a.*href=\"([^\"]*)/;if(r&&l.test(r.outerHTML)&&(o=l.exec(r.outerHTML)[1]),"current"===e)return"http://"==o?"":o;var c=e||void 0===e&&window.prompt("link (empty to unlink):",o);c?(document.execCommand("createLink",!1,c),(r=t.ContenteditableUtils.findSurroundingNode(s,HTMLAnchorElement))&&r.setAttribute("target",a||"_blank")):document.execCommand("unlink"),i()})}};__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String})],a.prototype,"target",void 0),a=__decorate([e.CustomElement({tagName:e.P+"-contenteditable-linkcommand",shadow:e.Defaults.USE_SHADOW_ROOT,template:t.CONTENTELEMENT_BUTTONCOMMAND_TEMPLATE})],a),t.PacemContenteditableLinkCommandElement=a}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){function a(e){return e instanceof HTMLModElement&&"INS"===e.tagName}let i=class PacemContenteditablePlaceholderElement extends t.PacemContenteditableCommandElement{constructor(){super(...arguments),this._focusHandler=e=>{const a=e.target;this.range=t.ContenteditableUtils.select(a)}}#b;#E;cleanUp(t){t.querySelectorAll("ins[contenteditable=false]").forEach(t=>{e.Utils.removeClass(t,"placeholder-selected")})}exec(e){const a=function(e,t){const a=document.createElement("ins");return a.textContent=t,a.setAttribute("contenteditable","false"),a.tabIndex=0,e.deleteContents(),e.insertNode(a),a}(this.range,e);return t.ContenteditableUtils.select(a).collapse(!1),Promise.resolve(a)}isRelevant(e){return this.#b?.result??!1}viewActivatedCallback(){super.viewActivatedCallback(),this._fillDropdown(),this._initContainer()}propertyChangedCallback(e,t,a,i){if(super.propertyChangedCallback(e,t,a,i),!i)switch(e){case"datasource":this._fillDropdown();break;case"contentElement":t&&this._disposeContainer(t),a&&this._initContainer(a);break;case"range":this._changeRelevancy()}}disconnectedCallback(){this._disposeContainer(),super.disconnectedCallback()}_changeRelevancy(i=this.range){const n=this.#b;e.Utils.isNull(n?.element)||e.Utils.removeClass(n.element,"placeholder-selected");const s=this.#b=function(e){const i=t.ContenteditableUtils.testInertElementWrapping(e);if(i.result&&a(i.element)){const e=i.element;return{result:!0,element:e,placeholder:e.textContent}}return{result:!1}}(i);e.Utils.isNull(s?.element)||e.Utils.addClass(s.element,"placeholder-selected"),s.result?this._dropdown.value=s.placeholder:(this._dropdown.popout(),this._dropdown.value=void 0)}_fillDropdown(e=this.datasource||[]){const t=this.#E=e.map(e=>"string"==typeof e?{placeholder:e,definition:e}:e),a=this._dropdown;a.textProperty=a.valueProperty="placeholder",a.datasource=t}#P;_initContainer(e=this.contentElement){this.#P=new t.ContenteditableDOMObserver(e,(e,t)=>{a(e)&&(t?this._downgradePlaceholderElement(e):this._enhancePlaceholderElement(e))},"ins[contenteditable=false]")}_disposeContainer(t=this.contentElement){const a=this.#P;e.Utils.isNull(a)||a.dispose()}_enhancePlaceholderElement(e){e.addEventListener("focus",this._focusHandler,!1)}_downgradePlaceholderElement(e){e.removeEventListener("focus",this._focusHandler,!1)}};__decorate([e.ViewChild("template")],i.prototype,"_itemtemplate",void 0),__decorate([e.ViewChild(e.P+"-suggest")],i.prototype,"_dropdown",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Json})],i.prototype,"datasource",void 0),i=__decorate([e.CustomElement({tagName:e.P+"-contenteditable-placeholder",shadow:e.Defaults.USE_SHADOW_ROOT,template:`<template>\n<${e.P}-span text="{{ ^item.viewValue }}" class="text-tech"></${e.P}-span>\n<${e.P}-markdown hide="{{ $pacem.isNullOrEmpty(^item.data.definition) || ^item.viewValue === ^item.data.definition }}" class="${e.PCSS}-margin margin-0 text-small" value="{{ ^item.data.definition }}"></${e.P}-markdown>\n</template>\n<${e.P}-suggest placeholder="Placeholder" class="pacem-button button" disabled="{{ $pacem.isNull(:host.range) }}"\n on-change=":host.execCommand($this.value)"\n css-class="{{ {'text-primary': :host.isRelevant(:host.range)} }}" \n compare-by="placeholder" text-property="placeholder" itemtemplate="{{ ::_itemtemplate }}" prevent-focus="true" allow-typing="false"></${e.P}-suggest>`})],i),t.PacemContenteditablePlaceholderElement=i}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){let a=class PacemContenteditableWrapCommandElement extends t.PacemContenteditableButtonCommandElement{isRelevant(a){return!e.Utils.isNull(t.ContenteditableUtils.findSurroundingNode(a,this.tagname))}exec(){return new Promise((a,i)=>{const n=this.tagname;if(!e.Utils.isNullOrEmpty(n)){const a=this.range,i=t.ContenteditableUtils.findSurroundingNode(a,n)||t.ContenteditableUtils.findSurroundingNode(a.startContainer,n)||t.ContenteditableUtils.findSurroundingNode(a.endContainer,n);if(e.Utils.isNull(i)){const i=t.ContenteditableUtils.findSurroundingSiblingBlockElements(a);if(!e.Utils.isNullOrEmpty(i)){const e=document.createElement(n);if(1===i.length){const n=i[0];a.setStart(n,0),a.setEnd(n,n.childNodes.length);const s=a.extractContents();e.append(s),t.ContenteditableUtils.copyAttributes(e,n),n.parentElement.insertBefore(e,n),n.remove()}else{a.setStartBefore(i[0]),a.setEndAfter(i[i.length-1]);const t=a.extractContents();e.append(t),a.insertNode(e)}t.ContenteditableUtils.select(e,!0).collapse()}}else{a.setStart(i,0),a.setEnd(i,i.childNodes.length);let e=!1;const n=i.childNodes;for(let a=0;a<n.length;a++){const i=n.item(a);if(!t.ContenteditableUtils.isBlockElement(i)){e=!0;break}}if(e){const e=document.createElement("p");t.ContenteditableUtils.copyAttributes(e,i),e.append(a.extractContents()),i.parentNode.replaceChild(e,i);t.ContenteditableUtils.select(e,!0).collapse()}else{i.parentNode.replaceChild(a.extractContents(),i);t.ContenteditableUtils.select(a.endContainer,!0).collapse()}}}a()})}};__decorate([e.Watch({converter:e.PropertyConverters.String})],a.prototype,"tagname",void 0),a=__decorate([e.CustomElement({tagName:e.P+"-contenteditable-wrapcommand",shadow:e.Defaults.USE_SHADOW_ROOT,template:t.CONTENTELEMENT_BUTTONCOMMAND_TEMPLATE})],a),t.PacemContenteditableWrapCommandElement=a}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(e){!function(e){let t;!function(e){e.String="string",e.Number="number",e.Datetime="datetime",e.Boolean="boolean",e.Binary="binary",e.Object="object"}(t=e.ApiParameterType||(e.ApiParameterType={}));e.ApiParserBase=class ApiParserBase{async load(e,t){let a=await fetch(e,{mode:"cors",credentials:"omit",headers:t});try{let t=await a.json();return this.parse(t,e)}catch(e){return null}}};const a=/^#\/(definitions|components\/schemas)\/(.+)$/;e.getOpenApiDefinition=function(e,t){var i=a.exec(t);return i&&i.length>2?{name:i[2],schema:e.definitions[i[2]]}:null}}(e.OpenApi||(e.OpenApi={}))}(e.Scaffolding||(e.Scaffolding={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){class OpenApi3Parser extends t.ApiParserBase{parse(e,t){let a=e;"string"==typeof a&&(a=JSON.parse(a));const i=a,n=[],s=this._gatherDefinitions(new Map,i.components.schemas);for(let e in i.paths)for(let t in i.paths[e]){const a=i.paths[e][t];n.push({path:e,method:t.toUpperCase(),parameters:this._convertToApiParameters(a.parameters),response:this._tryGetResponse(s,a.responses)})}return{endpoints:n,definitions:s,baseUrl:t}}_convertToApiParameters(e=[]){const t=[];for(let a of e){const e=a.schema;"type"in e&&t.push({name:a.name,required:a.required,type:this._translateType(e.type,e.format)})}return t}_translateType(e,a){switch(e){case"number":case"integer":return t.ApiParameterType.Number;case"boolean":return t.ApiParameterType.Boolean;case"string":switch(a){case"date":case"date-time":return t.ApiParameterType.Datetime;case"byte":return t.ApiParameterType.Binary;case"binary":throw"Binary octets not supported."}return t.ApiParameterType.String}return t.ApiParameterType.String}_gatherDefinitions(e,t){const a={};for(let i in t)a[i]=this._findDefinition(e,t,i);return a}_findDefinition(e,t,a){if(e.has(a))return e.get(a);if(a in t){const i=t[a];return e.set(a,i),i}return null}_findDefinitionName(e){var t=/#\/components\/schemas\/(.+)/.exec(e);return null==t||t.length<2?e:t[1]}_tryGetResponse(t,a){let i,n={responses:a}.responses[200];if(e.Utils.isNullOrEmpty(n&&n.content))return null;for(let e in n.content){i=n.content[e].schema;break}let s,r,o="object";return"$ref"in i?(r=this._findDefinitionName(i.$ref),s=t[r]):(o=i.type,s=i,"array"===i.type&&("$ref"in i.items?(r=this._findDefinitionName(i.items.$ref),s=t[r]):s=i.items)),{type:o,fullType:r,meta:s}}}t.OpenApi3Parser=OpenApi3Parser}(t.OpenApi||(t.OpenApi={}))}(e.Scaffolding||(e.Scaffolding={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){const a=e.Net.HttpMethod;class SwaggerParser extends t.ApiParserBase{_findDefinitionName(e){var t=/#\/definitions\/(.+)/.exec(e);return null==t||t.length<2?e:t[1]}parse(e,t){let i=e;"string"==typeof i&&(i=JSON.parse(i));const n=i;let s={};for(let e in n.definitions){s[this._findDefinitionName(e)]=n.definitions[e]}let r="";if(n.host&&n.schemes.length>0)r=n.schemes[0]+"://"+n.host+n.basePath;else if(t){let e=/^(https?):\/\/([^\/]+)/.exec(t);e&&e.length&&(!n.schemes&&e.length>1&&(n.schemes=[e[1]]),!n.host&&e.length>2&&(n.host=e[2],n.basePath=""),r=e[0])}else console.warn("Not able to find a base url from the OpenApi specs.");let o={endpoints:[],definitions:s,baseUrl:r};for(let e in n.paths){let t=n.paths[e];for(let i of[a.Get,a.Delete,a.Post,a.Put]){let a=t[i.toLowerCase()];if(a){let t=this._tryGetEndpoint(n,a,e,i);o.endpoints.push(t)}}}return o}_tryGetEndpoint(e,t,a,i){return{response:this._tryGetResponse(e,t),path:a,method:i,parameters:this._tryGetParameters(e,t)}}_translateType(e,a){switch(e){case"number":case"integer":return t.ApiParameterType.Number;case"boolean":return t.ApiParameterType.Boolean;case"string":switch(a){case"date":case"date-time":return t.ApiParameterType.Datetime;case"byte":return t.ApiParameterType.Binary;case"binary":throw"Binary octets not supported."}return t.ApiParameterType.String}return t.ApiParameterType.String}_tryGetParameters(e,a){return(a.parameters||[]).map(a=>{const i=a;let n={name:i.name,required:i.required||!1},s=a.type;if(a.schema){let i=a;n.type=t.ApiParameterType.Object;let s=n.fullType=this._findDefinitionName(i.schema.$ref);n.meta=e.definitions[s]}else s&&(n.type=this._translateType(s,a.format));return n})}_tryGetResponse(e,t){let a=t.responses[200];if(!a||!a.schema)return null;let i,n,s=a.schema.type||"object";return a.schema.$ref?(n=this._findDefinitionName(a.schema.$ref),i=e.definitions[n]):(i=a.schema,a.schema.items&&(a.schema.items.hasOwnProperty("$ref")?(n=this._findDefinitionName(a.schema.items.$ref),i=e.definitions[n]):i=a.schema.items)),{type:s,fullType:n,meta:i}}}t.SwaggerParser=SwaggerParser}(t.OpenApi||(t.OpenApi={}))}(e.Scaffolding||(e.Scaffolding={}))}(Pacem||(Pacem={})),function(e){!function(e){!function(e){class OpenApiParser extends e.ApiParserBase{constructor(t=new e.OpenApi3Parser,a=new e.SwaggerParser){super(),this._openApi3=t,this._swagger=a}parse(e,t){let a=e;"string"==typeof a&&(a=JSON.parse(a));const i=a;return"openapi"in i?this._openApi3.parse(i,t):this._swagger.parse(i,t)}}e.OpenApiParser=OpenApiParser}(e.OpenApi||(e.OpenApi={}))}(e.Scaffolding||(e.Scaffolding={}))}(Pacem||(Pacem={}));
|
|
6
|
+
"use strict";var Pacem,__decorate=this&&this.__decorate||function(e,t,a,i){var n,s=arguments.length,r=s<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,a):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,a,i);else for(var o=e.length-1;o>=0;o--)(n=e[o])&&(r=(s<3?n(r):s>3?n(t,a,r):n(t,a))||r);return s>3&&r&&Object.defineProperty(t,a,r),r};!function(e){!function(t){t.FieldChangeEventName="change";class FieldChangeEvent extends e.CustomTypedEvent{constructor(e){super(t.FieldChangeEventName,e,{bubbles:!0,cancelable:!1})}}t.FieldChangeEvent=FieldChangeEvent}(e.Scaffolding||(e.Scaffolding={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(a){const i="pacem:model:original-value";class PacemFormRelevantElement extends t.PacemElement{viewActivatedCallback(){super.viewActivatedCallback(),this.form=e.CustomElementUtils.findAncestorOfType(this,a.PacemFormElement)}}__decorate([e.Watch({converter:e.PropertyConverters.Element})],PacemFormRelevantElement.prototype,"form",void 0),a.PacemFormRelevantElement=PacemFormRelevantElement;class PacemModelElement extends PacemFormRelevantElement{viewActivatedCallback(){super.viewActivatedCallback(),this._registerFieldConditionally(),this._setAsOriginalValue(this.value)}_registerFieldConditionally(){const t=this.name,a=this.form;if(!(e.Utils.isNullOrEmpty(t)||e.Utils.isNull(a)||this.hasAttribute("autobind")&&("off"===this.getAttribute("autobind")||"false"===this.getAttribute("autobind"))||(a.registerField(t,this),this.hasAttribute("value")))){const i=a.id=a.id||"frm_"+e.Utils.uniqueCode();this.setAttribute("value",`{{ #${i}.entity.${t}, twoway }}`)}}propertyChangedCallback(t,a,i,n){switch(super.propertyChangedCallback(t,a,i,n),t){case"value":this.viewValue=this.getViewValue(i);break;case"valid":i?e.Utils.removeClass(this,e.PCSS+"-invalid"):e.Utils.addClass(this,e.PCSS+"-invalid");break;case"dirty":i?e.Utils.addClass(this,e.PCSS+"-dirty"):e.Utils.removeClass(this,e.PCSS+"-dirty");break;case"name":let t=this.form;null!=t&&a&&t.unregisterField(a),this._registerFieldConditionally();break;case"form":let n=this.name;e.Utils.isNullOrEmpty(n)||null!=a&&a.unregisterField(n),this._registerFieldConditionally()}}disconnectedCallback(){let t=this.name,a=this.form;e.Utils.isNullOrEmpty(t)||e.Utils.isNull(a)||a.unregisterField(t),super.disconnectedCallback()}get originalValue(){return e.CustomElementUtils.getAttachedPropertyValue(this,i)}_setAsOriginalValue(t){e.CustomElementUtils.setAttachedPropertyValue(this,i,t)}reset(){this.value=this.originalValue,this.dirty=!1}setPristine(){this._setAsOriginalValue(this.value),this.dirty=!1}setDirty(){this.dirty=!0}}__decorate([e.Watch({converter:e.PropertyConverters.String})],PacemModelElement.prototype,"viewValue",void 0),__decorate([e.Watch({converter:{convert:(e,t)=>t instanceof PacemModelElement?t.convertValueAttributeToProperty(e):e,convertBack:e=>e.toString()}})],PacemModelElement.prototype,"value",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Boolean})],PacemModelElement.prototype,"dirty",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Boolean})],PacemModelElement.prototype,"valid",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],PacemModelElement.prototype,"name",void 0),a.PacemModelElement=PacemModelElement;class PacemBaseElement extends PacemModelElement{constructor(){super(...arguments),this.focusHandler=t=>{const a=(t=!0)=>{e.Utils.hasClass(this.parentElement,"."+e.PCSS+"-fieldgroup")&&(t?e.Utils.addClass:e.Utils.removeClass).apply(this,[this.parentElement,e.PCSS+"-focus"])};switch(t.type){case"focus":e.Utils.addClass(this,e.PCSS+"-focus"),a(),this._preFocusValue=this.value;break;case"blur":e.Utils.removeClass(this,e.PCSS+"-focus"),a(!1)}t.bubbles?this.emit(t):this.dispatchEvent(new FocusEvent(t.type))},this.changeHandler=t=>{const a=this.value;this.onChange(t).then(t=>{this.compareValuePropertyValues(a,t)||(this.dispatchEvent(new e.Scaffolding.FieldChangeEvent({fieldName:this.name,oldValue:a,currentValue:t,firstChange:!this.dirty})),this.dirty=!0)},e=>{})},this.keydownHandler=t=>{e.stopPropagationHandler(t)},this.keyupHandler=t=>{switch(t.keyCode){case 27:e.stopPropagationHandler(t),this.compareValuePropertyValues(this.originalValue,this._preFocusValue)?this.reset():this.value=this._preFocusValue,this.blur();break;case 13:this.preventKeyboardSubmit&&e.stopPropagationHandler(t)}}}compareValuePropertyValues(t,a){return e.DefaultComparer(t,a)}get preventKeyboardSubmit(){return!1}propertyChangedCallback(t,a,i,n){switch(super.propertyChangedCallback(t,a,i,n),t){case"required":case"disabled":case"autofocus":case"placeholder":case"readonly":for(let e of this.inputFields)i?e.setAttribute(t,i):e.removeAttribute(t);break;case"tabOrder":for(let e of this.inputFields)e.setAttribute("tabindex",i);break;case"value":this.acceptValue(i)}if("required"===t||"disabled"===t||"readonly"===t){let a=`${e.PCSS}-${t}`;i?e.Utils.addClass(this,a):e.Utils.removeClass(this,a)}"readonly"===t?this.toggleReadonlyView(i):"required"===t?this.aria.attributes.set("required",!!i+""):"valid"===t&&this.aria.attributes.set("invalid",(!i&&!!this.dirty)+"")}registerInputFields(t=this.inputFields){e.Utils.isNull(t)||e.Utils.isArray(t)||(t=[t]);for(let a of t)a.addEventListener("focus",this.focusHandler,!1),a.addEventListener("blur",this.focusHandler,!1),a.addEventListener("change",this.changeHandler,!1),a.addEventListener("keydown",this.keydownHandler,!1),a.addEventListener("keyup",this.keyupHandler,!1),a.addEventListener("mousedown",e.stopPropagationHandler,!1),a.addEventListener("touchstart",e.stopPropagationHandler,{passive:!1,capture:!1})}unregisterInputFields(t=this.inputFields){e.Utils.isNull(t)||e.Utils.isArray(t)||(t=[t]);for(let a of t)e.Utils.isNull(a)||(a.removeEventListener("touchstart",e.stopPropagationHandler,{capture:!1}),a.removeEventListener("keydown",this.keydownHandler,!1),a.removeEventListener("keyup",this.keyupHandler,!1),a.removeEventListener("mousedown",e.stopPropagationHandler,!1),a.removeEventListener("change",this.changeHandler,!1),a.removeEventListener("focus",this.focusHandler,!1),a.removeEventListener("blur",this.focusHandler,!1))}viewActivatedCallback(){if(super.viewActivatedCallback(),this.toggleReadonlyView(this.readonly||!1),!e.Utils.isNullOrEmpty(this.id)){const e=document.querySelector(`label[for=${this.id}]`);e?e.id?this.aria.attributes.set("labelledby",e.id):this.aria.attributes.set("label",e.textContent):(this.aria.attributes.remove("labelledby"),this.aria.attributes.remove("label"))}this.registerInputFields()}disconnectedCallback(){this.unregisterInputFields(),super.disconnectedCallback()}focus(){const e=this.inputFields;e&&e.length&&e[0].focus()}blur(){const t=this.inputFields;if(!e.Utils.isNullOrEmpty(t))for(let e of t)e.blur()}}__decorate([e.Watch({converter:e.PropertyConverters.Boolean})],PacemBaseElement.prototype,"required",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Boolean})],PacemBaseElement.prototype,"autofocus",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Boolean})],PacemBaseElement.prototype,"readonly",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],PacemBaseElement.prototype,"name",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],PacemBaseElement.prototype,"placeholder",void 0),a.PacemBaseElement=PacemBaseElement;class PacemItemElement extends t.PacemElement{#e;findContainer(){return e.CustomElementUtils.findAncestor(this,e=>e instanceof PacemItemsContainerBaseElement)}get container(){return this.#e}viewActivatedCallback(){super.viewActivatedCallback();const t=this.#e=this.findContainer();e.Utils.isNull(t)||t.register(this)}disconnectedCallback(){e.Utils.isNull(this.#e)||this.#e.unregister(this),super.disconnectedCallback()}}a.PacemItemElement=PacemItemElement;class PacemItemsContainerBaseElement extends PacemBaseElement{register(t){let a=!0;return e.Utils.isNull(this.items)?this.items=[t]:-1===this.items.indexOf(t)?this.items.push(t):a=!1,a}unregister(t){const a=!e.Utils.isNull(this.items)&&this.items.indexOf(t);return a>=0&&(this.items.splice(a,1)[0],!0)}}__decorate([e.Watch()],PacemItemsContainerBaseElement.prototype,"items",void 0),a.PacemItemsContainerBaseElement=PacemItemsContainerBaseElement;let n=class PacemDataItemElement extends PacemItemElement{};__decorate([e.Watch({converter:{convert:(t,a)=>{if("true"===t)return!0;if("false"===t)return!1;let i=parseFloat(t);if(!isNaN(i))return i;let n=e.Utils.Dates.parse(t);return e.Utils.Dates.isDate(n)?n:t},convertBack:e=>e.toString()}})],n.prototype,"value",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],n.prototype,"label",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Boolean})],n.prototype,"disabled",void 0),n=__decorate([e.CustomElement({tagName:e.P+"-data-item"})],n),a.PacemDataItemElement=n;class PacemDataSourceElement extends PacemItemsContainerBaseElement{constructor(e=!1){super(),this.multipleChoice=e,this._itemPropertyChangedHandler=e=>{this.databind()}}register(t){const a=super.register(t);return a&&t.addEventListener(e.PropertyChangeEventName,this._itemPropertyChangedHandler,!1),a}unregister(t){const a=super.register(t);return a&&t.removeEventListener(e.PropertyChangeEventName,this._itemPropertyChangedHandler,!1),a}buildAdaptedDatasource(e=this.datasource){return e&&e.map(e=>this.mapEntityToItem(e))}databind(t=this.buildAdaptedDatasource(this.datasource)){if(e.Utils.isNull(t)&&e.Utils.isNull(this.adaptedDatasource))return;const a=this.adaptedDatasource=t||[];e.Utils.isNullOrEmpty(a.filter(e=>this.isDataSourceItemSelected(e)))&&this.handleDatasourceMismatch(a)}handleDatasourceMismatch(e){this.value=void 0}isItemSelected(t,a=this.value){if(e.Utils.isNullOrEmpty(a))return!1;const i=this.mapEntityToValue(t),n=this.compareBy;return this.multipleChoice&&e.Utils.isArray(a)?!e.Utils.isNull(a.find(t=>t==i||"object"==typeof t&&!e.Utils.isNullOrEmpty(n)&&n in i&&n in t&&i[n]==t[n])):!this.multipleChoice&&(a==i||"object"==typeof a&&!e.Utils.isNullOrEmpty(n)&&n in i&&n in a&&i[n]==a[n])}isDataSourceItemSelected(t,a=this.value){if(e.Utils.isNullOrEmpty(a))return!1;if(t.disabled)return!1;const i=this.compareBy;if(this.multipleChoice&&e.Utils.isArray(a)){let n=a.find(a=>a==t.value||"object"==typeof a&&!e.Utils.isNullOrEmpty(i)&&i in a&&!e.Utils.isNullOrEmpty(t.value)&&i in t.value&&a[i]==t.value[i]);return!e.Utils.isNull(n)}return!this.multipleChoice&&!e.Utils.isNullOrEmpty(t.value)&&(a==t.value||"object"==typeof a&&!e.Utils.isNullOrEmpty(i)&&i in a&&!e.Utils.isNullOrEmpty(t.value)&&i in t.value&&a[i]==t.value[i])}mapEntityToValue(e){if(null==e)throw"entity cannot be null";if(e instanceof n)return e.value;let t,a=e;return(t=this.valueProperty)&&(a=e[t]),a}mapEntityToViewValue(e){if(null==e)throw"entity cannot be null";if(e instanceof n)return e.label||e.value;let t,a=e.toString();return(t=this.textProperty)&&(a=e[t]),a}mapEntityToItem(t){if(null==t)throw"entity cannot be null";if(t instanceof n)return{value:t.value,viewValue:t.label||t.value,disabled:t.disabled,data:t};let a=!1;const i=this.disabledProperty;return e.Utils.isNullOrEmpty(i)||(a=t[i]||!1),{value:this.mapEntityToValue(t),viewValue:this.mapEntityToViewValue(t),disabled:a,data:t}}propertyChangedCallback(e,t,a,i){switch(super.propertyChangedCallback(e,t,a,i),e){case"datasource":case"textProperty":case"disabledProperty":case"valueProperty":cancelAnimationFrame(this._handle),this._handle=requestAnimationFrame(()=>{this.databind(),this.viewValue=this.getViewValue(this.value)});break;case"items":cancelAnimationFrame(this._handleItems),this._handleItems=requestAnimationFrame(()=>{this.datasource=this.items})}}getViewValue(t){if(!e.Utils.isNullOrEmpty(this.datasource))return this.datasource.filter(e=>this.isItemSelected(e)).map(e=>this.mapEntityToViewValue(e)).join(", ")}convertValueAttributeToProperty(e){return this.multipleChoice?e.split(",").map(e=>e.trim()):e}compareValuePropertyValues(t,a){return e.DefaultComparer(t,a)}}__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Json})],PacemDataSourceElement.prototype,"datasource",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String})],PacemDataSourceElement.prototype,"valueProperty",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String})],PacemDataSourceElement.prototype,"textProperty",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String})],PacemDataSourceElement.prototype,"disabledProperty",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String})],PacemDataSourceElement.prototype,"compareBy",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Json})],PacemDataSourceElement.prototype,"adaptedDatasource",void 0),__decorate([e.Debounce(!0)],PacemDataSourceElement.prototype,"databind",null),a.PacemDataSourceElement=PacemDataSourceElement}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(a){const i={convert:(t,a)=>/\{.+\}/.test(t)?e.PropertyConverters.Json.convert(t):e.PropertyConverters.String.convert(t),convertBack:(t,a)=>"string"==typeof t?t:e.PropertyConverters.Json.convertBack(t,a)};let n=class PacemCalendarMonthPickerElement extends t.PacemElement{propertyChangedCallback(t,a,i,n){if(super.propertyChangedCallback(t,a,i,n),"viewYear"===t)this.dispatchEvent(new CustomEvent("viewyearchange",{detail:new Date(i,0,1),bubbles:!1,cancelable:!1})),e.Utils.removeClass(this,"viewyear-next viewyear-previous"),requestAnimationFrame(()=>{e.Utils.addClass(this,a>i?"viewyear-previous":"viewyear-next")})}_getMonthLabel(t){const a=(new Date).getFullYear();return new Date(a,t,1).toLocaleString(e.Utils.lang(this),{month:"short"})}_isThisMonth(e,t=this.viewYear){return this._isSelectedMonth(e,new Date,t)}_isSelectedMonth(t,a=this.month,i=this.viewYear){const n=e.Utils.parseDate(a);if(!e.Utils.Dates.isDate(n))return!1;const s=i??(new Date).getFullYear();return n.getMonth()===t&&n.getFullYear()===s}_setMonth(e){const t=this.viewYear,a=new Date(t,e,1);this.month=a,this.dispatchEvent(new CustomEvent("monthselect",{detail:a,bubbles:!1,cancelable:!1}))}};__decorate([e.Watch({converter:e.PropertyConverters.Date})],n.prototype,"month",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Date})],n.prototype,"viewYear",void 0),n=__decorate([e.CustomElement({tagName:e.P+"-calendar-month-picker",shadow:e.Defaults.USE_SHADOW_ROOT,template:`<div class="${e.PCSS}-month-picker">${function(){let t="";for(let a=0;a<12;a++)t+=`<div class="calendar-month month-${a+1}"><${e.P}-span class="month-button text-ellipsed" on-click=":host._setMonth(${a})" css-class="{{ { 'selected-month': :host._isSelectedMonth(${a}, :host.month, :host.viewYear), 'this-month': :host._isThisMonth(${a}, :host.viewYear) } }}" text="{{ :host._getMonthLabel(${a}) }}"></${e.P}-span></div>`;return t}()}</div>`})],n),a.PacemCalendarMonthPickerElement=n;class CalendarDateUnselectEvent extends e.Components.UI.DateSelectEvent{constructor(){super(void 0)}}a.CalendarDateUnselectEvent=CalendarDateUnselectEvent;function s(e){return e-e%10}let r=class PacemCalendarYearPickerElement extends t.PacemElement{propertyChangedCallback(t,a,i,n){if(super.propertyChangedCallback(t,a,i,n),"viewYear"===t)this.dispatchEvent(new CustomEvent("viewyearchange",{detail:new Date(i,0,1),bubbles:!1,cancelable:!1})),e.Utils.removeClass(this,"viewyear-next viewyear-previous"),requestAnimationFrame(()=>{e.Utils.addClass(this,a>i?"viewyear-previous":"viewyear-next")})}_getYearLabel(e,t=this.viewYear){return""+(s(t)+e)}_isThisYear(e,t=this.viewYear){return this._isSelectedYear(e,new Date,t)}_isSelectedYear(t,a=this.year,i=this.viewYear){const n=e.Utils.parseDate(a);if(!e.Utils.Dates.isDate(n))return!1;const r=s(i)+t;return n.getFullYear()===r}_setYear(e){const t=s(this.viewYear),a=new Date(t+e,0,1);this.year=a,this.dispatchEvent(new CustomEvent("yearselect",{detail:a,bubbles:!1,cancelable:!1}))}};__decorate([e.Watch({converter:e.PropertyConverters.Date})],r.prototype,"year",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Date})],r.prototype,"viewYear",void 0),r=__decorate([e.CustomElement({tagName:e.P+"-calendar-year-picker",shadow:e.Defaults.USE_SHADOW_ROOT,template:`<div class="${e.PCSS}-year-picker">${function(){let t="";for(let a=0;a<12;a++)t+=`<div class="calendar-year year-${a+1}"><${e.P}-span class="year-button text-ellipsed" on-click=":host._setYear(${a})" css-class="{{ { 'selected-year': :host._isSelectedYear(${a}, :host.year, :host.viewYear), 'this-year': :host._isThisYear(${a}, :host.viewYear) } }}" text="{{ :host._getYearLabel(${a}, :host.viewYear) }}"></${e.P}-span></div>`;return t}()}</div>`})],r),a.PacemCalendarYearPickerElement=r;let o=class PacemCalendarPickerElement extends a.PacemBaseElement{constructor(){super(...arguments),this.viewmode="calendar",this.#t=!1,this._swipeHandler=e=>{switch(e.detail.direction){case"left":this._next(e);break;case"right":this._prev(e)}},this._clearBtnHandler=t=>{t.preventDefault(),this._viewDate=new Date,this.changeHandler(new e.Components.Scaffolding.CalendarDateUnselectEvent)},this._viewDateChangeHandler=e=>{this._onViewDateChange(e)},this._popCalendarHandler=t=>{if(this.#t)return;this.viewmode="calendar";const a=e.Utils.parseDate(this.value);this._calendar.viewDate=this._monthPicker.month=this._yearPicker.year=e.Utils.Dates.isDate(a)?a:this._calendar.viewDate;const i=e.Utils.offset(this._input),n=this._dropdown;n.style.top=i.top+i.height+"px",n.style.left=i.left+"px",n.hidden=!1,requestAnimationFrame(()=>{e.Utils.addClass(n,"dropdown-in")})},this._hideCalendarHandler=e=>{const t=e.composedPath()||[];t.indexOf(this._input)>=0||t.indexOf(this._dropdown)>=0||this._hideCalendar()}}#t;propertyChangedCallback(e,t,a,i){switch(super.propertyChangedCallback(e,t,a,i),e){case"viewmode":case"_viewDate":this._onViewDateChange(this._viewDate)}}viewActivatedCallback(){super.viewActivatedCallback();const t=this._dropdown=this._proxy.dom[0],a=this._calendar=t.querySelector(e.P+"-calendar"),i=this._monthPicker=t.querySelector(e.P+"-calendar-month-picker"),n=this._yearPicker=t.querySelector(e.P+"-calendar-year-picker");this._monthLabel=t.querySelector(".calendar-month"),this._yearLabel=t.querySelector(".calendar-year"),this._rangeLabel=t.querySelector(".calendar-year-range");const s=this._calendar.now=new Date,r=e.Utils.Dates.parse(this.value),o=e.Utils.Dates.isDate(r)?r:s;a.dayLabelFormatter=t=>e.Utils.parseDate(t).toLocaleString(e.Utils.lang(this),{day:"numeric"}),i.addEventListener("viewyearchange",this._viewDateChangeHandler,!1),n.addEventListener("viewyearchange",this._viewDateChangeHandler,!1),a.addEventListener("viewdatechange",this._viewDateChangeHandler,!1),a.viewDate=o,a.date=r;const l=this._input;l.addEventListener("focus",this._popCalendarHandler,!1),l.addEventListener("mousedown",this._popCalendarHandler,!1),t.addEventListener("mousedown",e.stopPropagationHandler,!1),window.document.body.addEventListener("mousedown",this._hideCalendarHandler,!0),this._clearButton.addEventListener("mousedown",this._clearBtnHandler,!1);const c=new e.Components.PacemSwipeElement;a.behaviors.push(c),i.behaviors.push(c),n.behaviors.push(c),c.addEventListener("swipe",this._swipeHandler,!1);const d=e.CustomElementUtils.findAncestorShell(this);this._swiper=d.appendChild(c)}disconnectedCallback(){const t=this._input;e.Utils.isNull(t)||(this._clearButton.removeEventListener("mousedown",this._clearBtnHandler,!1),t.removeEventListener("focus",this._popCalendarHandler,!1),t.removeEventListener("mousedown",this._popCalendarHandler,!1),this._dropdown.removeEventListener("mousedown",e.stopPropagationHandler,!1),window.document.body.removeEventListener("mousedown",this._hideCalendarHandler,!0),this._calendar.removeEventListener("viewdatechange",this._viewDateChangeHandler,!1),this._monthPicker.removeEventListener("viewyearchange",this._viewDateChangeHandler,!1),this._yearPicker.removeEventListener("viewyearchange",this._viewDateChangeHandler,!1));const a=this._swiper;if(!e.Utils.isNull(a)){const e=this._calendar,t=this._monthPicker,i=this._yearPicker;for(let n of[e,t,i]){const e=n.behaviors.indexOf(a);e>=0&&n.behaviors.splice(e,1)}a.removeEventListener("swipe",this._swipeHandler,!1),a.remove(),this._swiper=null}super.disconnectedCallback()}_getHeaderLabel(t,a=this.viewmode){const i=e.Utils.parseDate(t);return e.Utils.Dates.isDate(i)?i.toLocaleString(e.Utils.lang(this),{weekday:"narrow"}):"..."}_prev(e){let t=-1;switch(this.viewmode){case"month":t=-12;break;case"year":t=-120}this._jumpMonths(t)}_next(e){let t=1;switch(this.viewmode){case"month":t=12;break;case"year":t=120}this._jumpMonths(t)}_jumpMonths(t){const a=e.Utils.parseDate(this._viewDate);this._viewDate=e.Utils.Dates.addMonths(a,t)}_setMonth(e){this._viewDate=e.detail,this.viewmode="calendar"}_setYear(e){this._viewDate=e.detail,this.viewmode="month"}_onViewDateChange(t){if(e.Utils.isNullOrEmpty(t))return;const a=e.Utils.parseDate(this._viewDate);if(e.Utils.Dates.isDate(a)&&!e.Utils.isNull(this._monthLabel))switch(this.viewmode){case"month":this._yearLabel.text=a.toLocaleString(e.Utils.lang(this),{year:"numeric"});break;case"year":const t=s(a.getFullYear());this._rangeLabel.text=`${t} - ${t+12-1}`;break;default:this._monthLabel.text=a.toLocaleString(e.Utils.lang(this),{month:"long",year:"numeric"})}}_hideCalendar(){e.Utils.removeClass(this._dropdown,"dropdown-in"),e.Utils.addAnimationEndCallback(this._dropdown,t=>{this._dropdown.hidden=!0,e.Utils.removeClass(this._dropdown,"dropdown-select")},250)}get inputFields(){return[this._input]}toggleReadonlyView(e){this.isReady&&(this._input.readOnly=!0,this._input.hidden=e,this._span.hide=!e)}onChange(t){return new Promise((a,i)=>{if(e.CustomEventUtils.isInstanceOf(t,e.Components.UI.DateSelectEvent)){e.Utils.addClass(this._dropdown,"dropdown-select");e.CustomEventUtils.isInstanceOf(t,e.Components.Scaffolding.CalendarDateUnselectEvent)&&(this.#t=!0),this.focus(),this.#t=!1,this._hideCalendar(),a(this.value=t.detail)}else a(this.value)})}acceptValue(t){this._input.value=this.viewValue;const a=this._calendar;if(!e.Utils.isNull(a)){const i=e.Utils.parseDate(t);e.Utils.Dates.isDate(i)?a.viewDate=a.date=i:a.date=void 0}}getViewValue(t){const a=e.Utils.Dates.parse(t);return e.Utils.Dates.isDate(a)?e.Utils.core.date(a,this.format||"short",e.Utils.lang(this)):""}compareValuePropertyValues(t,a){const i=e.Utils.parseDate(t),n=e.Utils.parseDate(a);return!(!e.Utils.isNullOrEmpty(i)||!e.Utils.isNullOrEmpty(n))||!e.Utils.isNullOrEmpty(i)&&!e.Utils.isNullOrEmpty(n)&&i.valueOf()==n.valueOf()}convertValueAttributeToProperty(t){return e.PropertyConverters.Datetime.convert(t)}};__decorate([e.ViewChild("input[type=text]")],o.prototype,"_input",void 0),__decorate([e.ViewChild(`.${e.PCSS}-readonly`)],o.prototype,"_span",void 0),__decorate([e.ViewChild(`${e.P}-button[clear]`)],o.prototype,"_clearButton",void 0),__decorate([e.ViewChild(e.P+"-shell-proxy")],o.prototype,"_proxy",void 0),__decorate([e.Watch({emit:!1,converter:i})],o.prototype,"format",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Eval})],o.prototype,"disabledRanges",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],o.prototype,"weekStart",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],o.prototype,"viewmode",void 0),__decorate([e.Watch()],o.prototype,"_week",void 0),__decorate([e.Watch()],o.prototype,"_viewDate",void 0),o=__decorate([e.CustomElement({tagName:e.P+"-calendar-picker",shadow:e.Defaults.USE_SHADOW_ROOT,template:`<div class="${e.PCSS}-calendar-picker">\n <input type="text" class="${e.PCSS}-input" /><${e.P}-span text="{{ :host.viewValue }}" class="${e.PCSS}-readonly"></${e.P}-span>\n <${e.P}-button class="button-flat ${e.PCSS}-anim anim-pop anim-sudden anim-quick pos-absolute absolute-right absolute-top display-block ${e.PCSS}-margin margin-0"\n tab-order="-1"\n hide="{{ :host.readonly || :host.required || !Pacem.Utils.Dates.isDate(Pacem.Utils.Dates.parse(:host.value)) }}"\n icon-glyph="close"\n clear></${e.P}-button>\n</div>\n<${e.P}-shell-proxy>\n <div class="${e.PCSS}-calendar-picker-dropdown" pacem hidden>\n <${e.P}-collapse collapse="false">\n <div class="dropdown-grid">\n <div class="calendar-title">\n <${e.P}-span class="calendar-month calendar-zoom" on-click=":host.viewmode = 'month'" hide="{{ :host.viewmode !== 'calendar' }}"></${e.P}-span>\n <${e.P}-span class="calendar-year calendar-zoom" on-click=":host.viewmode = 'year'" hide="{{ :host.viewmode !== 'month' }}"></${e.P}-span>\n <${e.P}-span class="calendar-year-range" hide="{{ :host.viewmode !== 'year' }}"></${e.P}-span>\n </div>\n <div class="calendar-month-nav ${e.PCSS}-buttonset buttons">\n <div class="buttonset-left">\n <${e.P}-button class="button button-size size-auto" on-click=":host._prev($event)" icon-glyph="chevron_left"></${e.P}-button>\n <${e.P}-button class="button button-size size-auto" on-click=":host._next($event)" icon-glyph="chevron_right"></${e.P}-button>\n </div>\n </div>\n ${function(){let t="";for(let a=0;a<7;a++)t+=`<${e.P}-span class="calendar-heading day-${a+1} text-ellipsed" text="{{ :host._getHeaderLabel(:host._week[${a}]) }}"></${e.P}-span>`;return`<${e.P}-panel hide="{{ :host.viewmode !== 'calendar' }}" class="calendar-header">${t}</${e.P}-panel>`}()}\n <${e.P}-calendar hide="{{ :host.viewmode !== 'calendar' }}" week="{{ :host._week, twoway }}" view-date="{{ :host._viewDate, twoway }}" week-start="{{ :host.weekStart }}" disabled-ranges="{{ :host.disabledRanges }}" on-dateselect="{{ :host.changeHandler($event) }}"></${e.P}-calendar>\n <${e.P}-calendar-month-picker hide="{{ :host.viewmode !== 'month' }}" on-monthselect=":host._setMonth($event)" month="{{ :host.value || Date.now() }}" view-year="{{ :host._viewDate && :host._viewDate.getFullYear() }}"></${e.P}-calendar-month-picker>\n <${e.P}-calendar-year-picker hide="{{ :host.viewmode !== 'year' }}" on-yearselect=":host._setYear($event)" year="{{ :host.value || Date.now() }}" view-year="{{ :host._viewDate && :host._viewDate.getFullYear() }}"></${e.P}-calendar-year-picker>\n </div>\n <${e.P}-collapse>\n </div>\n</${e.P}-shell-proxy>`})],o),a.PacemCalendarPickerElement=o}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(a){a.CHAR_COUNTER_CHILD=`<${e.P}-char-count hide="{{ :host.readonly || !(:host.minlength > 0 || :host.maxlength > 0) }}" minlength="{{ :host.minlength }}" maxlength="{{ :host.maxlength }}" string="{{ :host.value }}"></${e.P}-char-count>`;let i=class PacemCharCountElement extends t.PacemElement{_isValid(e){const t=this._length(e);return!(this.minlength>0&&t<this.minlength)&&!(this.maxlength>0&&t>this.maxlength)}_length(e){return e&&e.length||0}};__decorate([e.Watch({converter:e.PropertyConverters.Number})],i.prototype,"minlength",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Number})],i.prototype,"maxlength",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],i.prototype,"string",void 0),i=__decorate([e.CustomElement({tagName:e.P+"-char-count",shadow:e.Defaults.USE_SHADOW_ROOT,template:`<${e.P}-panel class="${e.PCSS}-char-count" css-class="{{ {'valid': :host._isValid(:host.string), 'invalid': !:host._isValid(:host.string) } }}">\n <${e.P}-span hide="{{ !(:host.minlength > 0) }}" class="${e.PCSS}-char-min" content="{{ :host.minlength }}"></${e.P}-span>\n <${e.P}-span class="${e.PCSS}-char-curr" content="{{ :host._length(:host.string) || '0' }}"></${e.P}-span>\n <${e.P}-span hide="{{ !(:host.maxlength > 0) }}" class="${e.PCSS}-char-max" content="{{ :host.maxlength }}"></${e.P}-span>\n</${e.P}-panel>`})],i),a.PacemCharCountElement=i}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){let a=class PacemCheckboxListElement extends t.PacemDataSourceElement{acceptValue(e){}constructor(){super(!0),this._selectedUiItems=[],this.key="_"+e.Utils.uniqueCode()}get inputFields(){return[]}propertyChangedCallback(e,t,a,i){super.propertyChangedCallback(e,t,a,i),"disabled"===e&&(this._disable.model=a)}viewActivatedCallback(){super.viewActivatedCallback(),this._disable.model=this.disabled}toggleReadonlyView(e){this._span.hidden=!e,this._repeater.hidden=e}_selectionChanged(e,t,a){if("selected"===e.detail.propertyName){let a,i=this._selectedUiItems;!0===e.detail.currentValue?i.push(this.datasource[t]):-1!==(a=i.indexOf(this.datasource[t]))&&i.splice(a,1)}}onChange(t){const a=this.value=this._selectedUiItems.map(e=>this.mapEntityToValue(e));return e.Utils.fromResult(a)}};__decorate([e.ViewChild(`span.${e.PCSS}-readonly`)],a.prototype,"_span",void 0),__decorate([e.ViewChild(e.P+"-repeater")],a.prototype,"_repeater",void 0),__decorate([e.ViewChild(e.P+"-data")],a.prototype,"_disable",void 0),a=__decorate([e.CustomElement({tagName:e.P+"-checkbox-list",template:`<${e.P}-repeater datasource="{{ :host.adaptedDatasource }}">\n <ol class="${e.PCSS}-checkbox-list ${e.PCSS}-viewfinder" pacem>\n <template>\n <li><${e.P}-checkbox disabled="{{ ::_disable.model || ^item.disabled }}" name="{{ :host.key, once }}" autobind="off" caption="{{ ^item.viewValue }}" true-value="{{ ^item.value }}" selected="{{ :host.isDataSourceItemSelected(^item, :host.value) }}"\non-focus=":host.focusHandler($event)" on-blur=":host.focusHandler($event)"\non-${e.PropertyChangeEventName}=":host._selectionChanged($event, ^index, ^item)" on-change=":host.changeHandler($event)"></${e.P}-checkbox></li>\n </template>\n </ol>\n</${e.P}-repeater><span class="${e.PCSS}-readonly"><${e.P}-text text="{{ :host.viewValue }}"></${e.P}-text></span><${e.P}-data></${e.P}-data><${e.P}-content></${e.P}-content>`,shadow:e.Defaults.USE_SHADOW_ROOT})],a),t.PacemCheckboxListElement=a}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){const a={convert:e=>"true"===e||"false"!==e&&e,convertBack:e=>e.toString()};let i=class PacemCheckboxElement extends t.PacemBaseElement{constructor(){super("checkbox"),this.caption="",this._key="_"+e.Utils.uniqueCode()}convertValueAttributeToProperty(e){a.convert(e)===this.trueValue?this.trueValue:this.falseValue}toggleReadonlyView(e){this.span.hidden=!e,this._checkbox.hidden=this._label.hidden=e}get inputFields(){return[this._checkbox]}onChange(t){this.selected=this._checkbox.checked;const a=this.value=this.selected?this.trueValue:this.falseValue;return e.Utils.fromResult(a)}viewActivatedCallback(){super.viewActivatedCallback(),this._checkbox.id=this._label.htmlFor=this._key,this._synchronizeUi(),this.value==this.trueValue?this.selected=!0:this.value==this.falseValue&&(this.selected=!1)}propertyChangedCallback(t,a,i,n){if(super.propertyChangedCallback(t,a,i,n),this.isReady)switch(t){case"caption":this._label.hidden=e.Utils.isNullOrEmpty(i);break;case"name":this._checkbox.name=i;break;case"selected":this._synchronizeUi()}}_synchronizeUi(t=this.selected){(this._checkbox.checked=t)?(this.value=this.trueValue,e.Utils.addClass(this,e.PCSS+"-selected"),this.aria.attributes.set("checked","true")):(this.value=this.falseValue,e.Utils.removeClass(this,e.PCSS+"-selected"),this.aria.attributes.set("checked","false"))}acceptValue(e){this.selected=e==this.trueValue}getViewValue(t){return e.Utils.isNull(t)?"":this.caption}};__decorate([e.ViewChild("input[type=checkbox]")],i.prototype,"_checkbox",void 0),__decorate([e.ViewChild("label")],i.prototype,"_label",void 0),__decorate([e.ViewChild(`.${e.PCSS}-readonly`)],i.prototype,"span",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],i.prototype,"caption",void 0),__decorate([e.Watch({emit:!1,converter:a})],i.prototype,"trueValue",void 0),__decorate([e.Watch({emit:!1,converter:a})],i.prototype,"falseValue",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Boolean})],i.prototype,"selected",void 0),i=__decorate([e.CustomElement({tagName:e.P+"-checkbox",template:`<${e.P}-span class="${e.PCSS}-readonly ${e.PCSS}-checkbox" text="{{ :host.caption }}"></${e.P}-span>\n<input type="checkbox" class="${e.PCSS}-input" /><label class="${e.PCSS}-label ${e.PCSS}-checkbox ${e.PCSS}-viewfinder" pacem><${e.P}-span content="{{ :host.caption }}"></${e.P}-span></label>`,shadow:e.Defaults.USE_SHADOW_ROOT})],i),t.PacemCheckboxElement=i}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(a){a.FormSubmitEventName="submit",a.FormResetEventName="reset";class FormSubmitEvent extends e.CustomTypedEvent{constructor(e){super(a.FormSubmitEventName,e,{bubbles:!0,cancelable:!0})}}a.FormSubmitEvent=FormSubmitEvent;class FormResetEvent extends Event{constructor(){super(a.FormResetEventName,{bubbles:!0,cancelable:!0})}}a.FormResetEvent=FormResetEvent;const i=["download",e.Scaffolding.FieldChangeEventName,e.CommandEventName],n=!1;class FormEventEmitter{constructor(t){this._element=t,this._itemEmitHandler=t=>{if(this._element.handle(t),t.type===e.CommandEventName){const e=t;this._element.handle(new CustomEvent("item"+e.detail.commandName.toLowerCase(),{detail:e.detail.commandArgument}))}}}start(){i.forEach(e=>this._element.addEventListener(e,this._itemEmitHandler,!1))}stop(){i.forEach(e=>this._element.removeEventListener(e,this._itemEmitHandler,!1))}}a.FormEventEmitter=FormEventEmitter;let s=class PacemFormElement extends a.PacemFormRelevantElement{constructor(){super("form"),this.method=e.Net.HttpMethod.Post,this._emitter=null,this._buttons={submit:void 0,reset:void 0},this.#a=!1,this._keyupHandler=t=>{if(!(13!==t.keyCode||t.shiftKey||t.ctrlKey||t.altKey||t.metaKey)){let a=t.currentTarget.querySelector(e.P+"-button[type=submit]");e.Utils.isNull(a)||!e.Utils.isVisible(a)||a.disabled||a.click()}},this._submit=(t,a)=>{e.Utils.isNull(a)||e.avoidHandler(a),Promise.all(this._validateAllFields()).then(e=>{-1===e.findIndex(e=>!1===e)&&this.submit(t).then(e=>{this.setPristine()},e=>{})})},this._reset=t=>{e.Utils.isNull(t)||e.avoidHandler(t);var i=new FormResetEvent;if(this.dispatchEvent(i),!i.defaultPrevented){for(var n in this._fields){var s=this._fields[n];s instanceof a.PacemModelElement&&s.reset()}for(var r of this._subForms)r._reset()}},this._fields={},this._validators={},this._subForms=[],this._fieldPropertyChanged=e=>{switch(e.detail.propertyName){case"value":let t=e.target;this._checkFieldValidity(t.name);break;case"dirty":this._checkDirtyness();break;case"valid":this._checkValidity()}},this._validatorPropertyChanged=e=>{const t=e.target,a=t.watch;if("invalid"===e.detail.propertyName){let e=this._fields[t.watch];t.invalid?e.valid=!1:this._checkFieldValidity(a)}else this._checkFieldValidity(a)},this.suddenValidation=!0,this.resettable=!0,this._emitter=new FormEventEmitter(this)}propertyChangedCallback(t,a,i,n){super.propertyChangedCallback(t,a,i,n),("method"===t&&!0===this.autogenerate&&!e.Utils.isNullOrEmpty(this.metadata)||"metadata"===t&&!0===this.autogenerate||"autogenerate"===t&&!0===i&&this.metadata&&(this.metadata.props||this.metadata).length>0)&&this._buildUpForm()}viewActivatedCallback(){super.viewActivatedCallback(),this.form&&this.form.registerSubForm(this),this._checkValidity(),this.addEventListener("keyup",this._keyupHandler,!1),this._emitter.start()}disconnectedCallback(){this._emitter.stop(),this.removeEventListener("keyup",this._keyupHandler,!1),this.form&&this.form.unregisterSubForm(this),super.disconnectedCallback()}_buildUpForm(){const t="_"+e.Utils.uniqueCode(),a=this.id=this.id||t,i="fetch"+t,n=document.createElement("form");n.id="form"+t,n.className=e.PCSS+"-form",n.setAttribute("pacem",""),n.setAttribute("novalidate","");const s=`<${e.P}-repeater datasource="{{ #${a}.metadata && (#${a}.metadata.props || #${a}.metadata) }}">\n <${e.P}-panel css="{{ #${a}.metadata.display && #${a}.metadata.display.css }}" css-class="{{ (#${a}.metadata.display && #${a}.metadata.display.cssClass || []).concat(#${a}.suddenValidation ? [] : ['lazy-validation']) }}" class="${e.PCSS}-animatable-list ${e.PCSS}-list-appear">\n <template>\n <${e.P}-form-field fetch-credentials="{{ #${a}.fetchCredentials }}" fetch-headers="{{ #${a}.fetchHeaders }}"\n logger="{{ #${a}.logger }}" entity="{{ #${a}.entity, twoway }}" \n metadata="{{ ^item }}" readonly="{{ #${a}.readonly || ^item.isReadOnly }}"></${e.P}-form-field>\n </template>\n </${e.P}-panel>\n</${e.P}-repeater>\n<${e.P}-fetch logger="{{ #${a}.logger }}" id="${i}" method="${this.method}" credentials="{{ #${a}.fetchCredentials }}" headers="{{ #${a}.fetchHeaders }}"></${e.P}-fetch> \n<div class="${e.PCSS}-buttonset buttons">\n <div class="buttonset-left">\n <${e.P}-button logger="{{ #${a}.logger }}" on-click="#${a}._submit(#${a}.fetcher || #${i}, $event)" type="submit" hide="{{ #${a}.readonly || $pacem.isNullOrEmpty(#${a}.action) || !$pacem.isNull(#${a}.form) }}"\nclass="button primary button-size size-small"\ncss-class="{{ {'buttonset-last': !#${a}.resettable || !#${a}.dirty || !$pacem.isNull(#${a}.form) } }}" \ndisabled="{{ (#${a}.suddenValidation && (!(#${a}.valid && #${a}.dirty))) || #${a}.fetching }}">\n <${e.P}-panel class="submit-spinner ${e.PCSS}-anim anim-pop" hide="{{ !#${a}.fetching }}"><i class="${e.PCSS}-icon ${e.PCSS}-anim anim-rotate rotate-uniform display-block">refresh</i></${e.P}-panel>\n <${e.P}-text text="{{ #${a}.submitCaption || 'OK' }}"></${e.P}-text>\n </${e.P}-button>\n <${e.P}-button logger="{{ #${a}.logger }}" on-click="#${a}._reset($event)" type="reset" class="button button-size size-small" css-class="{{ {'buttonset-first': #${a}.readonly || $pacem.isNullOrEmpty(#${a}.action) || !$pacem.isNull(#${a}.form)} }}" hide="{{ !#${a}.resettable || #${a}.readonly || !#${a}.dirty || !Pacem.Utils.isNull(#${a}.form) }}" disabled="{{ #${a}.fetching }}">\n <${e.P}-text text="{{ #${a}.resetCaption || 'Reset' }}"></${e.P}-text>\n </${e.P}-button>\n</div></div>`;n.innerHTML=s,this.innerHTML="",this.appendChild(n),n.addEventListener("submit",e.avoidHandler,!1);const r=this._buttons,o=this._buttons={submit:n.lastElementChild.firstElementChild.firstElementChild,reset:n.lastElementChild.firstElementChild.lastElementChild};this.dispatchEvent(new e.PropertyChangeEvent({propertyName:"formButtons",currentValue:o,oldValue:r}))}get formButtons(){return this._buttons}#a;get fetching(){return this.#a}submit(t){return new Promise((a,i)=>{e.Utils.isNull(t)&&i("Fetcher cannot be null while submitting a form."),this._submitInternally(t).then(e=>{this.dispatchEvent(new CustomEvent("success",{detail:e})),a(e)},e=>{e!==n&&this.dispatchEvent(new CustomEvent("fail",{detail:e})),i(e)})})}reset(){this._reset()}_submitInternally(a,i){if(e.Utils.isNull(a))throw"Fetcher cannot be null while submitting a form.";var s=e.DeferPromise.defer();const r=this.entity,o=this.entityName;var l={};e.Utils.isNullOrEmpty(o)?l=r:l[o]=r;i={parameters:l,fields:this._getAllFields()};var c=new FormSubmitEvent(i);if(this.dispatchEvent(c),c.defaultPrevented)s.reject(n);else{a.parameters=e.Utils.extend({},c.detail.parameters);const i=t=>{a.removeEventListener(e.Net.FetchSuccessEventName,i,!1),a.removeEventListener(e.Net.FetchErrorEventName,r,!1);const o=t.detail;if(e.Net.Fetcher.isEmpty(o)&&(a.removeEventListener(e.Net.FetchResultEventName,n,!1),this.success=!0,s.resolve({})),205===o.status)this._reset()},n=t=>{a.removeEventListener(e.Net.FetchResultEventName,n,!1);var i=t.detail;"object"==typeof i&&i.hasOwnProperty("success")?!0===i.success?(this.success=!0,s.resolve(i.result||{})):(this.fail=!0,s.reject(i.error)):(this.success=!0,s.resolve(i))},r=t=>{a.removeEventListener(e.Net.FetchSuccessEventName,i,!1),a.removeEventListener(e.Net.FetchResultEventName,n,!1),a.removeEventListener(e.Net.FetchErrorEventName,r,!1),this.fail=!0;const o=t.detail;s.reject(o)},o=t=>{if("fetching"===t.detail.propertyName)!0===t.detail.currentValue?(e.Utils.addClass(this,e.PCSS+"-fetching"),this.#a=!0,this.dispatchEvent(new e.PropertyChangeEvent({currentValue:!0,oldValue:!1,propertyName:"fetching"}))):(this.#a=!1,this.dispatchEvent(new e.PropertyChangeEvent({currentValue:!1,oldValue:!0,propertyName:"fetching"})),e.Utils.removeClass(this,e.PCSS+"-fetching"),a.removeEventListener(e.PropertyChangeEventName,o,!1))};a.addEventListener(e.PropertyChangeEventName,o,!1),a.addEventListener(e.Net.FetchSuccessEventName,i,!1),a.addEventListener(e.Net.FetchResultEventName,n,!1),a.addEventListener(e.Net.FetchErrorEventName,r,!1),e.Utils.isNullOrEmpty(this.action)||(a.url=this.action),a instanceof t.PacemFetchElement&&!a.autofetch&&a.fetch(),this.success=this.fail=!1}return s.promise}_getAllFields(t={}){for(var a of(e.Utils.extend(t,this._fields),this._subForms))a._getAllFields(t);return t}apply(t){if(!e.Utils.isNullOrEmpty(t)){this.entity=e.Utils.extend({},this.entity,t);for(let e in t)this.setDirty(e)}}setPristine(...e){this._setAs(!1,...e)}setDirty(...e){this._setAs(!0,...e)}_setAs(t,...i){const n=!e.Utils.isEmpty(i);for(let e in this._fields)if(!n||i.indexOf(e)>=0){const i=this._fields[e];i instanceof a.PacemModelElement&&(t?i.setDirty():i.setPristine())}for(let e of this._subForms)t?e.setDirty(...i):e.setPristine(...i)}_checkFieldValidity(e){return this.suddenValidation?e in this._fields?this._validateField(e,!1):Promise.resolve(!1):Promise.resolve(null)}validate(t){return e.Utils.isNullOrEmpty(t)?Promise.all(this._validateAllFields()).then(e=>!e.some(e=>!1===e)):this._validateField(t,!1)}_validateAllFields(e=!0){const t=[];for(let a in this._fields)t.push(this._validateField(a,e));for(let a of this._subForms)Array.prototype.push.apply(t,a._validateAllFields(e));return t}_validateField(t,a){return new Promise((i,n)=>{var s=this._fields[t];if(s){var r=this._validators[s.name];r&&r.length>0?(this.log(e.Logging.LogLevel.Log,`Computing "${s.name}" validity.`),Promise.all(r.map(e=>e.validate(s.value).then(t=>!(e.invalid=!t)))).then(t=>{let n=!0;for(var r of t)if(!1===r){n=!1,a&&s.setDirty();break}this.log(e.Logging.LogLevel.Log,`Property "${s.name}" turns out to be ${n?"":"not "}valid.`),i(s.valid=n)})):(this.log(e.Logging.LogLevel.Log,`Property "${s.name}" has no validators.`),i(s.valid=!0))}else this.log(e.Logging.LogLevel.Log,`Property "${t}" has no fields in this form.`),i(!0)})}_checkDirtyness(){let e=!1;for(var t in this._fields)if(!0===this._fields[t].dirty){e=!0;break}if(!1===e)for(var a of this._subForms)if(a.dirty){e=!0;break}this.dirty=e}_checkValidity(){let t=!0;for(var a in this._fields)if(this.log(e.Logging.LogLevel.Log,`Checking "${a}" validity.`),!1===this._fields[a].valid){this.log(e.Logging.LogLevel.Log,`"${a}" is not valid.`),t=!1;break}if(!0===t)for(var i of this._subForms)if(!i.valid){t=!1;break}this.valid=t}registerSubForm(t){let a=this._subForms;-1==a.indexOf(t)&&(t.addEventListener(e.PropertyChangeEventName,this._fieldPropertyChanged,!1),a.push(t),this._checkValidity(),this._checkDirtyness())}unregisterSubForm(t){let a=this._subForms,i=a.indexOf(t);i>=0&&(t.removeEventListener(e.PropertyChangeEventName,this._fieldPropertyChanged,!1),a.splice(i,1),this._checkValidity(),this._checkDirtyness())}registerField(t,a){var i=this._fields;i[t]!=a&&(this.unregisterField(t,!1),i[t]=a,this.log(e.Logging.LogLevel.Log,`Registering "${t}" field.`),a instanceof HTMLElement&&a.addEventListener(e.PropertyChangeEventName,this._fieldPropertyChanged,!1),this._checkFieldValidity(t),this._checkDirtyness())}unregisterField(t,a=!0){var i=this._fields,n=i[t];n instanceof HTMLElement&&n.removeEventListener(e.PropertyChangeEventName,this._fieldPropertyChanged,!1),delete i[t],n&&!0===a&&(this._checkValidity(),this._checkDirtyness())}registerValidator(t,a){var i=this._validators[t]=this._validators[t]||[];-1==i.indexOf(a)&&(i.push(a),a instanceof HTMLElement&&a.addEventListener(e.PropertyChangeEventName,this._validatorPropertyChanged,!1),this.log(e.Logging.LogLevel.Log,`Calling "${t}" validity check after validator registration.`),this._checkFieldValidity(t))}unregisterValidator(e,t){this._unregisterValidator(e,t,!0)}_unregisterValidator(t,a,i){var n=this._validators[t]=this._validators[t]||[],s=n.indexOf(a);s>=0&&(a instanceof HTMLElement&&a.removeEventListener(e.PropertyChangeEventName,this._validatorPropertyChanged,!1),n.splice(s,1),i&&this._checkFieldValidity(t))}};__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Element})],s.prototype,"fetcher",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String})],s.prototype,"fetchCredentials",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Json})],s.prototype,"fetchHeaders",void 0),__decorate([e.Watch({reflectBack:!0,converter:e.PropertyConverters.String})],s.prototype,"method",void 0),__decorate([e.Watch({reflectBack:!0,converter:e.PropertyConverters.String})],s.prototype,"submitCaption",void 0),__decorate([e.Watch({reflectBack:!0,converter:e.PropertyConverters.String})],s.prototype,"resetCaption",void 0),__decorate([e.Debounce(100)],s.prototype,"_buildUpForm",null),__decorate([e.Watch({reflectBack:!0,converter:e.PropertyConverters.Boolean})],s.prototype,"valid",void 0),__decorate([e.Watch({reflectBack:!0,converter:e.PropertyConverters.Boolean})],s.prototype,"dirty",void 0),__decorate([e.Watch({reflectBack:!0,converter:e.PropertyConverters.Boolean})],s.prototype,"readonly",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Boolean})],s.prototype,"success",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Boolean})],s.prototype,"fail",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Json})],s.prototype,"entity",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String})],s.prototype,"entityName",void 0),__decorate([e.Watch()],s.prototype,"metadata",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Boolean})],s.prototype,"autogenerate",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Boolean})],s.prototype,"suddenValidation",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Boolean})],s.prototype,"resettable",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],s.prototype,"action",void 0),s=__decorate([e.CustomElement({tagName:e.P+"-form"})],s),a.PacemFormElement=s}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(a){let i=class PacemChildFormPropagatorElement extends t.PacemEventTarget{propertyChangedCallback(t,a,i,n){if(super.propertyChangedCallback(t,a,i,n),!n){const a=this.property,n=this.watch,s=!e.Utils.isNullOrEmpty(a),r=!e.Utils.isNull(this.model);("watch"===t||"property"===t||"model"===t&&s&&r&&e.Utils.isArray(i)&&i.some(e=>!(a in e)||e[a]!==n)||"model"===t&&s&&r&&!e.Utils.isArray(i)&&(!(a in i)||i[a]!==n))&&this._synchronize()}}viewActivatedCallback(){super.viewActivatedCallback(),this._synchronize()}_synchronize(){const t=this.model,a=this.property,i=this.watch;if(!e.Utils.isNullOrEmpty(t)&&!e.Utils.isNullOrEmpty(a))if(e.Utils.isArray(t)){for(let e of t)e[a]=i;this.model=t.slice(0)}else t[a]=i,this.model=e.Utils.extend({},t)}};__decorate([e.Watch({emit:!0})],i.prototype,"model",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String,reflectBack:!0})],i.prototype,"property",void 0),__decorate([e.Watch({emit:!1})],i.prototype,"watch",void 0),i=__decorate([e.CustomElement({tagName:e.P+"-childform-propagator"})],i),a.PacemChildFormPropagatorElement=i;let n=class PacemChildFormElement extends a.PacemBaseElement{constructor(){super(...arguments),this._model=[],this._subForms=[]}get inputFields(){return[]}toggleReadonlyView(e){}onChange(e){return new Promise((e,t)=>{var a=this._modelToEntity();e(this.value=a)})}acceptValue(e){this._entityToModel(e)}getViewValue(e){return""}convertValueAttributeToProperty(t){return e.PropertyConverters.Json.convert(t,this)}propertyChangedCallback(e,t,a,i){if(super.propertyChangedCallback(e,t,a,i),"mode"===e)this._entityToModel()}_dragStart(t){var a=t.detail;const i=e.Utils.offset(a.element),n=a.floater;n.style.width=i.width+"px",n.style.height=i.height+"px"}_dragEnd(e){"array"===this.mode&&this._triggerChange()}reset(){super.reset(),this._subForms.forEach(e=>{e.setPristine()})}_itemCreate(t){const a=t.detail.index,i=this._subForms;t.detail.dom[0].childNodes.forEach(t=>{t instanceof Element&&t.localName===e.P+"-form"&&i.splice(a,i.length-a,t)})}_itemChange(t,a){"entity"===a.detail.propertyName&&e.Utils.Json.stringify(this._model[t])!==e.Utils.Json.stringify(a.detail.currentValue)&&(this._model.splice(t,1,a.detail.currentValue),this._triggerChange())}_deleteAt(t){e.avoidHandler(t.srcEvent);const a=this._model;"array"===this.mode?a.splice(t.detail,1):a.splice(0,a.length),this._triggerChange()}_addItem(e){const t=this.mode,a=this._model;"array"===t?a.push({}):a.splice(0,a.length,{}),this._triggerChange()}_triggerChange(){this.changeHandler(new Event("change"))}_entityToModel(t=this.value){if("array"===this.mode){let a=t||[];e.Utils.isArray(a)&&this._model.cloneFrom(a)}else{const a=this._model,i=a.length;1===i&&a[0]===t||(e.Utils.isNull(t)?a.splice(0,i):a.splice(0,i,t))}}_modelToEntity(t=this._model){return"array"===this.mode?e.Utils.clone(t):t&&t.length&&t[0]||null}};__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String})],n.prototype,"fetchCredentials",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Json})],n.prototype,"fetchHeaders",void 0),__decorate([e.ViewChild("."+e.PCSS+"-childform")],n.prototype,"_container",void 0),__decorate([e.ViewChild(e.P+"-drag-drop")],n.prototype,"_dragger",void 0),__decorate([e.ViewChild("."+e.PCSS+"-childform-item-floater")],n.prototype,"_floater",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],n.prototype,"mode",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Boolean})],n.prototype,"lockItems",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Json})],n.prototype,"metadata",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Json})],n.prototype,"_model",void 0),n=__decorate([e.CustomElement({tagName:e.P+"-childform",shadow:e.Defaults.USE_SHADOW_ROOT,template:`<${e.P}-repeater datasource="{{ :host._model }}" on-itemdelete=":host._deleteAt($event)" on-${t.RepeaterItemCreateEventName}=":host._itemCreate($event)">\n <div class="${e.PCSS}-childform">\n <template>\n <${e.P}-panel class="${e.PCSS}-childform-item" behaviors="{{ [::_dragger] }}">\n <${e.P}-panel class="childform-item-handle ${e.PCSS}-margin margin-right-1" hide="{{ :host.lockItems || :host.readonly || :host.mode !== 'array' || !(:host._model && :host._model.length > 1) }}"><i class="${e.PCSS}-icon drag-handle">drag_handle</i></${e.P}-panel>\n <${e.P}-panel class="childform-item-index text-small"><${e.P}-span hide="{{ !:host.readonly || :host.mode !== 'array' }}" class="${e.PCSS}-margin margin-right-1" text="{{ ^index+1 }}"></${e.P}-span></${e.P}-panel>\n <${e.P}-form entity="{{ ^item }}" fetch-headers="{{ :host.fetchHeaders }}" fetch-credentials="{{ :host.fetchCredentials }}" on-${e.PropertyChangeEventName}=":host._itemChange(^index, $event)" readonly="{{ :host.readonly }}" metadata="{{ :host.metadata }}" autogenerate="true" logger="{{ :host.logger }}"></${e.P}-form>\n <${e.P}-button tab-order="-1" class="flat circular circle-small clear ${e.PCSS}-margin margin-left-1" hide="{{ :host.lockItems || :host.readonly }}" command-name="delete" command-argument="{{ ^index }}"></${e.P}-button>\n </${e.P}-panel>\n </template>\n </div>\n <${e.P}-button tab-order="-1" class="flat circular circle-small add" hide="{{ :host.lockItems || :host.readonly || !(:host.mode === 'array' || $pacem.isNullOrEmpty(:host._model)) }}" on-click=":host._addItem($event)"></${e.P}-button>\n</${e.P}-repeater>\n<div class="${e.PCSS}-childform-item-floater ${e.PCSS}-panel panel-border">\n <div class="corner top-left"></div><div class="corner top-right"></div><div class="corner bottom-left"></div><div class="corner bottom-right"></div>\n</div>\n<${e.P}-drag-drop floater="{{ ::_floater }}" disabled="{{ :host.lockItems }}"\n on-${e.UI.DragDropEventType.Start}=":host._dragStart($event)"\n on-${e.UI.DragDropEventType.End}=":host._dragEnd($event)" \n drop-behavior="${e.UI.DropBehavior.InsertChild}" mode="${e.UI.DragDataMode.Alias}" handle-selector=".drag-handle" drop-targets="{{ [::_container] }}"></${e.P}-drag-drop>`})],n),a.PacemChildFormElement=n}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){function a(e){return e instanceof HTMLDivElement&&"true"===e.contentEditable&&e.hasAttribute("pacem")&&e.hasAttribute("role")&&"presenter"===e.attributes.role.value}t.ContenteditableDOMObserver=class ContenteditableDOMObserver{constructor(e,t,a="*[contenteditable=false]"){this.#i=t,this.#n=a,this.#s=new MutationObserver(e=>{const a=(e,i)=>{e.childNodes.forEach(e=>a(e,i)),t(e,i)};for(let t of e){const e=t.addedNodes,i=t.removedNodes;for(let t=0;t<e.length;t++){const i=e.item(t);a(i,!1)}for(let e=0;e<i.length;e++){const t=i.item(e);a(t,!0)}}}),this._initContainer(e)}_initContainer(e){e.querySelectorAll(this.#n).forEach(e=>this.#i(e)),this.#s.observe(e,{subtree:!0,childList:!0}),this.#r=e}_disposeContainer(t){const a=this.#s;e.Utils.isNull(a)||a.disconnect(),t.querySelectorAll(this.#n).forEach(e=>this.#i(e,!0))}dispose(){this._disposeContainer(this.#r)}#n;#i;#r;#s};class ContenteditableUtils{static getDefaultDashboard(){const a=new DocumentFragment,i=document.createElement("div");e.Utils.addClass(i,e.PCSS+"-contenteditable-toolbar");const n=new t.PacemContenteditableHistoryCommandElement;n.command="undo",n.keyboardShortcut="Ctrl+Z";const s=new t.PacemContenteditableHistoryCommandElement;s.command="redo",s.keyboardShortcut="Ctrl+Y",i.append(n,s);const r=document.createElement("div");e.Utils.addClass(r,e.PCSS+"-contenteditable-separator");const o=document.createElement("div");e.Utils.addClass(o,e.PCSS+"-contenteditable-toolbar");const l=new t.PacemContenteditableExecCommandElement;l.command=t.KnownExecCommand.Bold,l.keyboardShortcut="Ctrl+B";const c=new t.PacemContenteditableExecCommandElement;c.command=t.KnownExecCommand.Italic,c.keyboardShortcut="Ctrl+I";const d=new t.PacemContenteditableExecCommandElement;d.command=t.KnownExecCommand.Underline,d.keyboardShortcut="Ctrl+U";const h=new t.PacemContenteditableExecCommandElement;h.command=t.KnownExecCommand.StrikeThrough,d.keyboardShortcut="Ctrl+K";const p=new t.PacemContenteditableExecCommandElement;p.command=t.KnownExecCommand.UnorderedList;const u=new t.PacemContenteditableExecCommandElement;u.command=t.KnownExecCommand.OrderedList;const m=new t.PacemContenteditableAlignCommandElement;m.align="left";const v=new t.PacemContenteditableAlignCommandElement;v.align="center";const _=new t.PacemContenteditableAlignCommandElement;_.align="right";const g=new t.PacemContenteditableAlignCommandElement;g.align="justify",o.append(l,c,d,h,p,u,m,v,_,g);const y=document.createElement("div");e.Utils.addClass(y,e.PCSS+"-contenteditable-separator");const f=document.createElement("div");e.Utils.addClass(f,e.PCSS+"-contenteditable-toolbar");const C=new t.PacemContenteditableLinkCommandElement,P=new t.PacemContenteditableImageCommandElement;return f.append(C,P),a.append(i,r,o,y,f),a}static findSurroundingNode(t,i){for(var n=t instanceof Node?t:t.commonAncestorContainer;n&&!("string"==typeof i&&n instanceof Element&&n.tagName===i.toUpperCase()||"function"==typeof i&&e.Utils.isNull(i.prototype)&&i(n)||"function"==typeof i&&!e.Utils.isNull(i.prototype)&&n instanceof i);){const e=n.parentNode;if(a(e)){n=null;break}n=e}return n}static findSurroundingBlockElement(e){return this.findSurroundingNode(e,ContenteditableUtils.isBlockElement)}static findSurroundingSiblingBlockElements(e){let t=[];if(a(e.startContainer)){if(!e.collapsed){const a=e.startContainer;for(let i=e.startOffset;i<=e.endOffset;i++){const e=a.children.item(i);this.isBlockElement(e)&&t.push(a.children.item(i))}}return t}if(e.startContainer===e.endContainer){let t=e.startContainer;for(;!ContenteditableUtils.isBlockElement(t)&&"true"!=t.parentElement.contentEditable;)t=t.parentElement;return t instanceof Element?[t]:"true"===t.parentElement.contentEditable?[]:[t.parentElement]}let i=e.commonAncestorContainer,n=!1;for(let a=0;a<i.childNodes.length;a++){const s=i.childNodes.item(a);if((!n&&s.contains(e.startContainer)||n)&&ContenteditableUtils.isBlockElement(s)&&(t.push(s),n=!0,s.contains(e.endContainer)))break}return n?t:i instanceof Element&&!a(i)?[i]:[]}static findContainingRootElements(e){const t=e.cloneRange(),a=e.cloneRange();t.collapse(!0),a.collapse();let i=this.findSurroundingNode(t,e=>"true"===e.parentElement.contentEditable);const n=[i];for(;!i.contains(a.startContainer);)n.push(i=i.nextElementSibling);return n}static isBlockElement(e){return e instanceof Element&&!getComputedStyle(e).display.startsWith("inline")}static select(e,t=!1){const a=document.createRange();t?(a.setStart(e,0),a.setEnd(e,e.childNodes.length)):(a.setStartBefore(e),a.setEndAfter(e));const i=document.getSelection();return i.removeAllRanges(),i.addRange(a),a}static copyAttributes(e,t){const a=t.attributes;for(let t=0;t<a.length;t++){const i=a.item(t);e.setAttribute(i.name,i.value)}}static testInertElementWrapping(t){if(!e.Utils.isNull(t)){const e=t.startContainer,i=t.startOffset;var a;if(e===t.endContainer&&i==t.endOffset-1&&(a=e.childNodes.item(i))instanceof HTMLElement&&"false"===a.contentEditable)return{result:!0,element:a}}return{result:!1}}}t.ContenteditableUtils=ContenteditableUtils}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){const a="execute",i="<p><br></p>";class ContenteditableChangeEvent extends e.CustomTypedEvent{constructor(e){super("contenteditablechange",{html:e})}}class PacemContenteditableCommandElement extends t.PacemItemElement{constructor(){super(...arguments),this._containerPropChangeHandler=e=>{const t=e.detail;this.containerPropertyChangedCallback(t.propertyName,t.oldValue,t.currentValue,t.firstChange)}}execCommand(...e){const t=this;t.disabled||t.exec.apply(t,e).then(e=>{t.dispatchEvent(new Event(a))},e=>{console.error(e)})}connectedCallback(){super.connectedCallback(),e.Utils.addClass(this,e.PCSS+"-contenteditable-command")}viewActivatedCallback(){super.viewActivatedCallback();const t=this.container;e.Utils.isNull(t)||(this.contentElement=t.contentElement,t.addEventListener(e.PropertyChangeEventName,this._containerPropChangeHandler,!1))}disconnectedCallback(){const t=this.container;e.Utils.isNull(t)||t.removeEventListener(e.PropertyChangeEventName,this._containerPropChangeHandler,!1),super.disconnectedCallback()}containerPropertyChangedCallback(e,t,a,i){"range"===e&&(this.range=a)}}function n(e){return e instanceof PacemContenteditableCommandElement&&"pasteCallback"in e&&"function"==typeof e.pasteCallback}function s(e){return e?.nodeType==Node.ELEMENT_NODE}__decorate([e.Watch()],PacemContenteditableCommandElement.prototype,"range",void 0),__decorate([e.Watch()],PacemContenteditableCommandElement.prototype,"contentElement",void 0),t.PacemContenteditableCommandElement=PacemContenteditableCommandElement;let r=class PacemContenteditableElement extends t.PacemItemsContainerBaseElement{constructor(){super("rich text editor"),this._focusHandler=e=>{this._ensureInteractiveMarkup()},this._blurHandler=e=>{const t=this._container;for(let e of this.items)e.cleanUp(t);this._checkChangedHandler(e)},this._pasteHandler=t=>{t.preventDefault();const a=this.range,i=t.clipboardData.files;if(e.Utils.isNull(a)||0!==i.length)for(let e=0;e<i.length;e++){const a=i.item(e);for(let e of this.items)n(e)&&e.pasteCallback(a).then(e=>this._checkChangedHandler(t),e=>{})}else{const e=t.clipboardData.getData("text/plain").replace(/</gi,"<").replace(/\n/gi,"<br />"),i=a.createContextualFragment(e);a.deleteContents(),a.insertNode(i),this._checkChangedHandler(t)}},this._shortcutHandler=e=>{e.ctrlKey&&-1===["C","V","X"].indexOf(e.key?.toUpperCase())&&e.preventDefault()},this._inputHandler=e=>{this._fixRangeMarkup(),this._checkChangedHandler(e)},this._checkChangedHandler=t=>{const a=this._container,n=a.innerHTML;var s=n;(e.Utils.isNullOrEmpty(n)||"<br>"===n||n===i)&&(a.innerHTML=i,s=""),s!=this.value&&(this.changeHandler(new ContenteditableChangeEvent(s)),this.value!=this.#o.current&&this._updateHistory()),this._fireHistoryChange()},this._selectionChangeHandler=e=>{const t=document.getSelection();if(t&&t.anchorNode&&this._container.contains(t.anchorNode)){const e=t.getRangeAt(0);this.range=e.cloneRange()}else this.range=null}}#o;get history(){return this.#o}reset(){super.reset(),this.#o.reset(),this._fireHistoryChange()}_fireHistoryChange(){const t=this.#o;this.dispatchEvent(new e.PropertyChangeEvent({propertyName:"history",oldValue:t,currentValue:t}))}convertValueAttributeToProperty(e){return e}toggleReadonlyView(e){this._dashboard.hidden=e,e?this._container.removeAttribute("contenteditable"):(this._container.setAttribute("contenteditable","true"),document.execCommand("defaultParagraphSeparator",!1,"p"))}register(e){return!!super.register(e)&&(e.addEventListener(a,this._checkChangedHandler,!1),!0)}unregister(e){return!!super.unregister(e)&&(e.removeEventListener(a,this._checkChangedHandler,!1),!0)}get preventKeyboardSubmit(){return!0}get inputFields(){return[this._container]}get contentElement(){return this._container}onChange(t){return new Promise((a,i)=>{if(e.CustomEventUtils.isInstanceOf(t,ContenteditableChangeEvent)){a(this.value=t.detail.html),this._selectionChangeHandler(t)}else a(this.value)})}_fixRangeMarkup(){const t=this.range,a=e=>{e.childNodes.forEach(e=>a(e)),s(e)&&"SPAN"===e.tagName?Element.prototype.replaceWith.apply(e,Array.from(e.childNodes)):e instanceof HTMLElement&&e.removeAttribute("style")};e.Utils.isNull(t)||(e=>{let t=e;s(t)||(t=e.parentElement),a(t)})(t.commonAncestorContainer)}_ensureInteractiveMarkup(){const t=this._container,a=t.childNodes,n=a.length;if(0==n||t.innerHTML===i)t.innerHTML=i;else{let t,i;const s=e=>{i.setEndAfter(e);const t=document.createElement("p");i.surroundContents(t)};for(let r=0;r<n;r++)t=a.item(r),t instanceof Element?i&&(s(t.previousSibling),i=null):e.Utils.isNull(i)&&(i=document.createRange(),i.setStartBefore(t));e.Utils.isNull(i)||s(t)}}_updateHistory(){this.#o.push(this.value),this._fireHistoryChange()}acceptValue(t){e.Utils.isNull(this._container)||t==this._container.innerHTML||(this._container.innerHTML=t)}viewActivatedCallback(){super.viewActivatedCallback();const t=this._container;this.#o=new e.HistoryService(this.value),t.addEventListener("blur",this._blurHandler,!1),t.addEventListener("keydown",this._shortcutHandler,!1),t.addEventListener("focus",this._focusHandler,!1),t.addEventListener("input",this._inputHandler,!1),t.addEventListener("paste",this._pasteHandler,!1),document.addEventListener("selectionchange",this._selectionChangeHandler,!1)}disconnectedCallback(){document.removeEventListener("selectionchange",this._selectionChangeHandler,!1);const t=this._container;e.Utils.isNull(t)||(t.removeEventListener("keydown",this._shortcutHandler,!1),t.removeEventListener("blur",this._blurHandler,!1),t.removeEventListener("focus",this._focusHandler,!1),t.removeEventListener("input",this._inputHandler,!1),t.removeEventListener("paste",this._pasteHandler,!1)),super.disconnectedCallback()}getViewValue(e){return e}};__decorate([e.ViewChild("div[pacem]")],r.prototype,"_container",void 0),__decorate([e.ViewChild("div[dashboard]")],r.prototype,"_dashboard",void 0),__decorate([e.Watch()],r.prototype,"range",void 0),__decorate([e.Debounce(500)],r.prototype,"_updateHistory",null),r=__decorate([e.CustomElement({tagName:e.P+"-contenteditable",shadow:e.Defaults.USE_SHADOW_ROOT,template:`<div class="${e.PCSS}-contenteditable ${e.PCSS}-viewfinder">\n <div contenteditable="true" role="presenter" pacem></div>\n</div>${t.CHAR_COUNTER_CHILD}\n<div dashboard>\n <${e.P}-content></${e.P}-content>\n</div>`})],r),t.PacemContenteditableElement=r}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){const a={convert:(t,a)=>/\{.+\}/.test(t)?e.PropertyConverters.Json.convert(t):e.PropertyConverters.String.convert(t),convertBack:(t,a)=>"string"==typeof t?t:e.PropertyConverters.Json.convertBack(t,a)};let i=class PacemDatetimePickerElement extends t.PacemBaseElement{constructor(){super(),this.precision="day",this._months=[],this._dates=[],this._a24=[],this._a60=[],this._years=[],this.hours="00",this.minutes="00",this.seconds="00"}get inputFields(){return[this._yearel,this._monthel,this._dateel,this._hourel,this._minel,this._secel]}toggleReadonlyView(e){this._allFields.hidden=e}convertValueAttributeToProperty(t){return e.PropertyConverters.Datetime.convert(t)}connectedCallback(){super.connectedCallback();const t=new Date;let a=this.year=t.getFullYear();this.min=new Date(a-100,0,1),this.max=new Date(a+10,11,31),this.month=t.getMonth();let i=[],n=[],s=[],r=e.Utils.leftPad;for(let t=0;t<12;t++){let n=new Date(a,t,1),s=n.toLocaleString(e.Utils.lang(this),{month:"short"});i.push({value:t,date:n,label:s})}this._months=i;for(let e=0;e<24;e++)n.push(r(e,2,"0"));this._a24=n;for(let e=0;e<60;e++)s.push(r(e,2,"0"));this._a60=s}propertyChangedCallback(t,a,i,n){switch(super.propertyChangedCallback(t,a,i,n),t){case"dateValue":this.log(e.Logging.LogLevel.Log,`dateValue changed from ${a} to ${i}`),this._disassembleDate(i);break;case"min":case"max":e.Utils.isNullOrEmpty(this.min)||e.Utils.isNullOrEmpty(this.max)||this._setupYears();break;case"year":case"month":this._buildupDates();break;case"date":case"hours":case"minutes":case"seconds":this._buildup()}}acceptValue(t){this.dateValue=e.Utils.parseDate(t)}_disassembleDate(t){if(!t)return void(this.date=void 0);"string"==typeof t&&(t=e.Utils.parseDate(t));const a=t=>e.Utils.leftPad(t,2,"0");this.year=t.getFullYear(),this.month=t.getMonth(),this.date=t.getDate(),this.hours=a(t.getHours()),this.minutes=a(t.getMinutes()),this.seconds=a(t.getSeconds())}_setupYears(){let t=[];const a=e.Utils.parseDate(this.min),i=e.Utils.parseDate(this.max);for(let e=a.getFullYear();e<=i.getFullYear();e++)t.push(e);this._years=t}onChange(e){return new Promise((e,t)=>{e(this.value=this._computeValue())})}_buildupDates(t){t&&t.stopPropagation();const a=this,i={weekday:"short",day:"numeric"},n=e=>{try{let t=+a.month;return new Date(+a.year,+a.month,e).getMonth()==t}catch(e){return!1}};var s=[];if(!e.Utils.isNullOrEmpty(a.year)&&!e.Utils.isNullOrEmpty(a.month)){let t=1;do{let n=new Date(+a.year,+a.month,t),r=n.toLocaleString(e.Utils.lang(this),i);s.push({value:t,date:n,label:r,disabled:n<this.min||n>this.max})}while(n(++t))}this._dates=s,n(+this.date)?this._buildup():this.date=""}_computeValue(){const t=this;if(e.Utils.isNullOrEmpty(t.year)||e.Utils.isNullOrEmpty(t.month)||e.Utils.isNullOrEmpty(t.date))return null;try{let e=new Date(+t.year,+t.month,+t.date);return e.setHours(+t.hours),e.setMinutes(+t.minutes),e.setSeconds(+t.seconds),e.setMilliseconds(0),Number.isNaN(e.valueOf())?null:e}catch(e){return null}}_buildup(e){e&&e.stopPropagation(),this.dateValue=this._computeValue()}getViewValue(t){const a=t;return a?e.Utils.core.date(a,this.format||("day"!=this.precision?"full":"short"),e.Utils.lang(this)):""}};__decorate([e.ViewChild("."+e.PCSS+"-datetime-picker-year > "+e.P+"-select")],i.prototype,"_yearel",void 0),__decorate([e.ViewChild("."+e.PCSS+"-datetime-picker-month > "+e.P+"-select")],i.prototype,"_monthel",void 0),__decorate([e.ViewChild("."+e.PCSS+"-datetime-picker-date > "+e.P+"-select")],i.prototype,"_dateel",void 0),__decorate([e.ViewChild("."+e.PCSS+"-datetime-picker-hours > "+e.P+"-select")],i.prototype,"_hourel",void 0),__decorate([e.ViewChild("."+e.PCSS+"-datetime-picker-minutes > "+e.P+"-select")],i.prototype,"_minel",void 0),__decorate([e.ViewChild("."+e.PCSS+"-datetime-picker-seconds > "+e.P+"-select")],i.prototype,"_secel",void 0),__decorate([e.ViewChild(`div.${e.PCSS}-datetime-picker-fields`)],i.prototype,"_allFields",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Datetime})],i.prototype,"dateValue",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Datetime})],i.prototype,"min",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Datetime})],i.prototype,"max",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],i.prototype,"precision",void 0),__decorate([e.Watch({emit:!1,converter:a})],i.prototype,"format",void 0),__decorate([e.Watch()],i.prototype,"_dates",void 0),__decorate([e.Watch()],i.prototype,"_years",void 0),__decorate([e.Watch()],i.prototype,"year",void 0),__decorate([e.Watch()],i.prototype,"month",void 0),__decorate([e.Watch()],i.prototype,"date",void 0),__decorate([e.Watch()],i.prototype,"hours",void 0),__decorate([e.Watch()],i.prototype,"minutes",void 0),__decorate([e.Watch()],i.prototype,"seconds",void 0),__decorate([e.Debounce(10)],i.prototype,"_buildup",null),i=__decorate([e.CustomElement({tagName:e.P+"-datetime-picker",shadow:e.Defaults.USE_SHADOW_ROOT,template:`<div class="${e.PCSS}-datetime-picker">\n <div class="${e.PCSS}-datetime-picker-fields ${e.PCSS}-viewfinder">\n\n <div class="${e.PCSS}-datetime-picker-year">\n <${e.P}-select value="{{ :host.year, twoway }}" placeholder="..." datasource="{{ :host._years }}">\n </${e.P}-select></div>\n\n <div class="${e.PCSS}-datetime-picker-month">\n <${e.P}-select value="{{ :host.month, twoway }}" placeholder="..." value-property="value" text-property="label" datasource="{{ :host._months }}">\n </${e.P}-select></div>\n\n <div class="${e.PCSS}-datetime-picker-date">\n <${e.P}-select value="{{ :host.date, twoway }}" placeholder="..." value-property="value" text-property="label" datasource="{{ :host._dates }}">\n </${e.P}-select></div>\n\n <${e.P}-panel class="${e.PCSS}-datetime-picker-hours" hide="{{ :host.precision === 'day' }}">\n <${e.P}-select value="{{ :host.hours, twoway }}" datasource="{{ :host._a24 }}">\n </${e.P}-select></${e.P}-panel>\n\n <${e.P}-panel class="${e.PCSS}-datetime-picker-minutes" hide="{{ :host.precision === 'day' }}">\n <${e.P}-select value="{{ :host.minutes, twoway }}" datasource="{{ :host._a60 }}">\n </${e.P}-select></${e.P}-panel>\n\n <${e.P}-panel class="${e.PCSS}-datetime-picker-seconds" hide="{{ :host.precision !== 'second' }}">\n <${e.P}-select value="{{ :host.seconds, twoway }}" datasource="{{ :host._a60 }}">\n </${e.P}-select></${e.P}-panel>\n\n </div>\n <${e.P}-panel class="${e.PCSS}-datetime-picker-preview" hide="{{ Pacem.Utils.isNullOrEmpty(:host.dateValue) || :host.precision === 'day' || :host.readonly }}">\n <dl>\n <dt>local:</dt><dd><${e.P}-text text="{{ :host.viewValue }}"></${e.P}-text></dd>\n <dt>iso:</dt><dd><${e.P}-text text="{{ (:host.dateValue && :host.dateValue.toISOString()) || '' }}"></${e.P}-text></dd>\n </dl>\n </${e.P}-panel>\n <${e.P}-span class="${e.PCSS}-readonly" css-class="{{ { 'date': :host.precision === 'day', 'datetime': :host.precision !== 'day' } }}" content="{{ :host.viewValue }}" hide="{{ !:host.readonly }}"></${e.P}-span>\n</div>`})],i),t.PacemDatetimePickerElement=i}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(a){function i(e){return new RegExp(e).source}let n=class PacemFormFieldElement extends a.PacemFormRelevantElement{constructor(t=new e.MarkdownService){super(),this._md=t,this._entityPropertyChangeHandler=t=>{this.dispatchEvent(new e.PropertyChangeEvent({propertyName:"entity",currentValue:this.entity}))},this._labelClickHandler=e=>{document.getElementById(this._label.htmlFor).focus()},this._key="_"+e.Utils.uniqueCode()}get key(){return this._key}get fetcher(){return this._fetcher}get field(){return this._field}viewActivatedCallback(){super.viewActivatedCallback(),this._buildUpForm(),this._buildUpFetcher()}propertyChangedCallback(t,a,i,n){switch(super.propertyChangedCallback(t,a,i,n),t){case"readonly":this._ensureBalloon();break;case"metadata":this._ensureBalloon(),this._buildUpCss(),this._buildUpLabel(),this._buildUpField();break;case"entity":a instanceof HTMLElement&&a.removeEventListener(e.PropertyChangeEventName,this._entityPropertyChangeHandler,!1),i instanceof HTMLElement&&i.addEventListener(e.PropertyChangeEventName,this._entityPropertyChangeHandler,!1)}}disconnectedCallback(){this.entity instanceof HTMLElement&&this.entity.removeEventListener(e.PropertyChangeEventName,this._entityPropertyChangeHandler,!1),e.Utils.isNull(this._label)||this._label.removeEventListener("click",this._labelClickHandler,!1),e.Utils.isNull(this._balloon)||this._balloon.remove(),super.disconnectedCallback()}_normalizeTooltip(){const e=this.metadata&&this.metadata.extra&&this.metadata.extra.tooltip||!1;return"object"==typeof e?e:{type:e}}_ensureBalloon(){var a,i;const n=this.readonly||!1===(i=this._normalizeTooltip()).type||e.Utils.isNullOrEmpty(a=this.metadata&&this.metadata.display&&this.metadata.display.description);if(e.Utils.isNull(this._balloon)&&!n){let a=document.createElement(e.P+"-balloon");a.options={behavior:t.UI.BalloonBehavior.Tooltip,trigger:i.trigger||t.UI.BalloonTrigger.Hover,position:i.position||t.UI.BalloonPosition.Top,hoverDelay:200,hoverTimeout:50,align:i.align||t.UI.BalloonAlignment.Auto},e.Utils.addClass(a,e.PCSS+"-field-tooltip"),e.CustomElementUtils.findAncestorShell(this).appendChild(this._balloon=a)}const s=this._balloon;if(!(e.Utils.isNull(s)||(s.target=this._label,s.disabled=n))){const e=a||"";switch(i.type){case"md":case"markdown":s.innerHTML=this._md.toHtml(e);break;case"html":s.innerHTML=e;break;default:s.innerText=e}}}_buildUpCss(){const t=this.metadata?.display;if(!e.Utils.isNull(t)){if("function"==typeof t.cssClass){const{cssClassAttr:e}=t.cssClass(this,"$this","$this.entity");this.setAttribute("css-class",e)}else this.cssClass=t.cssClass;if("function"==typeof t.css){const{cssAttr:e}=t.css(this,"$this","$this.entity");this.setAttribute("css",e)}else this.css=t.css}}_buildUpLabel(){const t=this._label,a=t.firstElementChild,i=this.metadata;t.htmlFor=this._key,e.Utils.addClass(t,e.PCSS+"-label");const n=this.metadata.validators;if(n&&n.find(e=>"required"===e.type)?e.Utils.addClass(t,e.PCSS+"-required"):e.Utils.removeClass(t,e.PCSS+"-required"),e.Utils.isNull(this._balloon)||this._balloon.disabled?e.Utils.removeClass(t,e.PCSS+"-tooltip"):e.Utils.addClass(t,e.PCSS+"-tooltip"),"function"==typeof i.display?.name){const{contentAttr:e}=i.display.name(this,":host",":host.entity","::_form");a.setAttribute("content",e)}else a.removeAttribute("content"),a.content=i.display&&i.display.name||i.prop;t.setAttribute("id","label"+this._key),t.addEventListener("click",this._labelClickHandler,!1)}_isValueNullOrEmpty(t=this.entity,a=this.metadata){if(e.Utils.isNull(a))return!0;const i=a.prop.split(".");let n=t;for(let t=0;t<i.length;t++){const a=i[t];if(e.Utils.isNullOrEmpty(n&&n[a]))return!0;n=n[a]}return!1}_handleValueChange(t){if("value"===t.detail.propertyName){const a=t.detail.currentValue,i=this.metadata.prop;if(this.entity instanceof HTMLElement){let t=e.CustomElementUtils.camelToKebab(i);e.Utils.isNullOrEmpty(a)?this.entity.removeAttribute(t):this.entity.setAttribute(t,a.toString())}else this.entity[i]=a}}_adjustDependencyValue(t){return e.Utils.Dates.isDate(t)?e.Utils.Dates.parse(t).toISOString():t}_broadcastFetchResult(e){this.dispatchEvent(new CustomEvent("fetch",{detail:e,bubbles:!0,cancelable:!1}))}_buildUpFetcher(){var e=this._fetcher;e.setAttribute("id","fetch"+this._key),e.setAttribute("on-fetchresult",":host._broadcastFetchResult($event.detail)")}_buildUpForm(){var e=this._form;e.setAttribute("id","form"+this._key),e.setAttribute("sudden-validation","{{ ::form.suddenValidation }}")}_buildUpField(){this._field&&this._field.remove(),this._fetcher.removeAttribute("parameters"),this._fetcher.result=this._fetcher.url=null;for(var t=this._validators.children.length-1;t>=0;t--)this._validators.children[t].remove();var n=this.metadata;let s=e.P+"-input-text",r=e.P+(n.display&&"slider"===n.display.ui?"-slider":"-input-number"),o={id:this._key,name:n.prop,readonly:"{{ :host.readonly || :host.metadata.isReadOnly || ::_form.readonly }}",value:`{{ :host.entity.${n.prop}, twoway }}`,placeholder:`${n.display&&n.display.watermark||""}`};1==n.extra?.autofocus&&(o["on-load"]="requestAnimationFrame(() => $this.focus())");let l=n.extra||{},c={},d="false",h="",p="",u="",m=[];if(!e.Utils.isNullOrEmpty(l.dependsOn))if("function"==typeof l.dependsOn){const S=l.dependsOn(this,":host",":host.entity","$this.entity"),k=S.hideAttr;if(e.Utils.isNullOrEmpty(k)||this.setAttribute("hide",k),e.Utils.isNullOrEmpty(S.disabledAttr)||(d=S.disabledAttr,e.CustomElementUtils.isBindingAttribute(d)&&(p=e.CustomElementUtils.extractBindingAttributeExpression(d))),!e.Utils.isNullOrEmpty(S.parameterAttrs)){const $=S.parameterAttrs,U=[];for(let N in $){const x=$[N];U.push(`${N}: ${x}`),m.push({prop:x})}u=U.join(", ")}}else{m=l.dependsOn;let V={empty:[],notEqual:{}},O={empty:[],notEqual:{}},A=[],D=[];for(var v of m){let H=":host.entity."+v.prop,L="$this.entity."+v.prop;if(e.Utils.isNullOrEmpty(v.value)){if(!v.optional){let I=e=>"$pacem.isNullOrEmpty("+e+")";V.empty.push(I(H)),v.hide&&O.empty.push(I(L))}}else{let F=e=>e+" !== "+JSON.stringify(v.value);(V.notEqual[H]=V.notEqual[H]||[]).push(F(H)),v.hide&&(O.notEqual[L]=O.notEqual[L]||[]).push(F(L))}D.push(H),A.push(`${v.alias||v.prop}: :host._adjustDependencyValue(${H})`),v.optional||(h+=`!$pacem.isNullOrEmpty(${H}) && `)}u=A.join(", ");let T=t=>{let a="false",i="false";if(!e.Utils.isNullOrEmpty(t.notEqual)){const e=[];for(let a in t.notEqual)e.push("("+t.notEqual[a].join(" && ")+")");a="("+e.join(" || ")+")"}return e.Utils.isNullOrEmpty(t.empty)||(i="("+t.empty.join(" || ")+")"),a+" || "+i};p=T(V),d=`{{ ${p} }}`,this.setAttribute("hide",`{{ ${T(O)} }}`)}const _="fn",g=this[_]=this[_]||{},y=(t=[])=>{let a=(m||[]).map(e=>":host.entity."+e.prop).join(", ");const i="fn"+e.Utils.uniqueCode();if("function"==typeof t)g[i]=t;else{if(!e.Utils.isArray(t))throw"Unsupported source format.";g[i]=()=>t}return`{{ :host.${_}.${i}(${a}) }}`},f=new DocumentFragment;let C;if("function"==typeof n.type){var P=n.type(this,":host",":host.entity");if(-1===P.tagName.indexOf("-"))this.log(e.Logging.LogLevel.Error,`${s} is not an allowed form-field`);else{function W(t,a){if(!e.Utils.isNullOrEmpty(a))for(let i of a){if(-1===i.tagName.indexOf("-")){this.log(e.Logging.LogLevel.Error,`${i.tagName} is not an allowed child element for form-field ${s}`);continue}const a=document.createElement(i.tagName);if(!e.Utils.isNullOrEmpty(i.attrs))for(let e in i.attrs){const t=i.attrs[e];a.setAttribute(e,t)}e.Utils.isNullOrEmpty(i.children)||W(a,i.children),t.appendChild(a)}}s=P.tagName,e.Utils.extend(o,P.attrs||{}),W(f,P.children)}}else switch(C=n.display&&n.display.ui){case"contentEditable":console.warn("`contentEditable` ui hint is deprecated. Lean on `dataType` equal to 'HTML' instead."),s=e.P+"-contenteditable",f.append(a.ContenteditableUtils.getDefaultDashboard());break;case"snapshot":s=e.P+"-snapshot",l.width>0&&(o.width=""+l.width),l.height>0&&(o.height=""+l.height),l.quality>=0&&(o.quality=""+l.quality);break;case"chars":case"digits":case"otp":s=e.P+"-input-chars",l.charCount>0&&(o.charCount=""+l.charCount),e.Utils.isNullOrEmpty(l.inputTransform)||(o["input-transform"]=l.inputTransform);break;case"oneToMany":case"dropdown":case"radioList":case"checkboxList":case"manyToMany":"oneToMany"===C||"dropdown"===C?(s=e.P+"-select",!1!==l.preventWheel&&(o["on-wheel"]="$event.preventDefault()")):(delete o.placeholder,s=e.P+("radioList"===C?"-radio-list":"-checkbox-list")),e.Utils.isNullOrEmpty(l.textProperty)||(o["text-property"]=l.textProperty),e.Utils.isNullOrEmpty(l.disabledProperty)||(o["disabled-property"]=l.disabledProperty),e.Utils.isNullOrEmpty(l.valueProperty)||(n.isComplexType?o["compare-by"]=l.valueProperty:o["value-property"]=l.valueProperty),e.Utils.isNullOrEmpty(l.source)?(this._fetcher.id=`fetch${this._key}`,this._fetcher.url=l.sourceUrl,this._fetcher.method=l.verb,c.parameters=`{{ { ${u} } }}`,c.disabled=d,o.datasource=`{{ ${h}Pacem.Utils.getApiResult(#fetch${this._key}.result) || null }}`):o.datasource=y(l.source);break;case"suggest":case"tags":case"autocomplete":const B="tags"===n.display.ui;s=e.P+(B?"-tags":"-suggest"),this._fetcher.id=`fetch${this._key}`,e.Utils.isNullOrEmpty(l.textProperty)||(o["text-property"]=l.textProperty);let R=`#${this._key}.value`;if(e.Utils.isNullOrEmpty(l.valueProperty)||(o["compare-by"]=l.valueProperty,B?R=`(${R} && ${R}.${l.valueProperty}) || ''`:n.isComplexType?R+=` && ${R}.${l.valueProperty}`:o["value-property"]=l.valueProperty),e.Utils.isNullOrEmpty(l.sourceUrl)?o.datasource=y(l.source):(c.url=`${l.sourceUrl}`,this._fetcher.method=l.verb,e.Utils.isNullOrEmpty(l.dependsOn)?c.parameters=`{{ {q: #${this._key}.hint || '', ${l.valueProperty||"value"}: ${R} || '' } }}`:(c.parameters=`{{ { ${u}, q: #${this._key}.hint || '', ${l.valueProperty||"value"}: ${R} || '' } }}`,c.disabled=d),o.datasource=`{{ ${h}Pacem.Utils.getApiResult(#fetch${this._key}.result) || null }}`),B)o["allow-new"]=(!0===n.extra.allowNew).toString(),o["allow-duplicates"]=(!0===n.extra.allowDuplicates).toString();else{if(e.Utils.isNullOrEmpty(l.disabledProperty)||(o["disabled-property"]=l.disabledProperty),!e.Utils.isNullOrEmpty(l.itemtemplate)){const z=l.itemtemplate;z instanceof HTMLElement?(o.itemtemplate="{{ #"+(z.id=z.id||this._key+"_itemtmpl")+" }}",z.isConnected||this.append(z)):o.itemtemplate=z}if(!e.Utils.isNullOrEmpty(l.filterFields)){const j=l.filterFields;o["filter-fields"]=e.Utils.isArray(j)?j.join(" "):j}e.Utils.isNullOrEmpty(l.maxSuggestions)||(o["max-suggestions"]=l.maxSuggestions.toString())}break;case"calendar":s=e.P+"-calendar-picker";const M=n.display?.format??n.extra?.format;e.Utils.isNullOrEmpty(M)||(o.format="{{ "+JSON.stringify(M)+" }}"),e.Utils.isNullOrEmpty(l.disabledRanges)||(o["disabled-ranges"]="{{ "+JSON.stringify(l.disabledRanges)+" }}");break;case"dictionary":s=e.P+"-namevalue-list",o.dictionary="true";break;case"switcher":if("boolean"!==(n.type||"").toLowerCase())break;o.class="checkbox-switch";default:let q=(n.dataType||n.type||"").toLowerCase();switch(q){case"upload":s=e.P+"-upload";let J=n.extra||{};o.url=J.uploadUrl,o.parallelism=""+J.parallelism,o["chunk-size"]=""+J.chunkSize,o["max-image-width"]=""+J.maxImageWidth,o["max-image-height"]=""+J.maxImageHeight,o["select-mode"]=J.mode??"file";break;case"html":s=e.P+"-contenteditable",f.append(a.ContenteditableUtils.getDefaultDashboard());break;case"enumeration":s=e.P+"-radio-list",o.class=e.PCSS+"-radio-list",o["value-property"]="value",o["text-property"]="caption",o.datasource="{{ "+JSON.stringify(n.extra.enum)+" }}",delete o.placeholder;break;case"password":s=e.P+"-input-password";break;case"emailaddress":s=e.P+"-input-email";break;case"color":s=e.P+"-input-color";break;case"time":case"date":case"datetime":s=e.P+"-datetime-picker",delete o.placeholder,"datetime"===q&&(o.precision="minute");const Y=n.display?.format??n.extra?.format;e.Utils.isNullOrEmpty(Y)||(o.format="{{ "+JSON.stringify(Y)+" }}"),e.Utils.isNullOrEmpty(l.disabledRanges)||(o["disabled-ranges"]="{{ "+JSON.stringify(l.disabledRanges)+" }}");break;case"url":s=e.P+"-input-url";break;case"phonenumber":s=e.P+"-input-tel";break;case"multilinetext":s=e.P+"-textarea";break;case"markdown":s=e.P+"-textarea-markdown";break;case"latlng":s=e.P+"-latlng",e.Utils.isNullOrEmpty(n.extra)||"object"!=typeof n.extra||e.Utils.isArray(n.extra)||(o.options=JSON.stringify(n.extra));break;case"percent":case"percentage":case"currency":let K="currency"===q?{style:"currency",currency:"EUR"}:{style:"percent",maximumFractionDigits:2},G=n.display?.format??K;o.format=JSON.stringify(G);default:switch((n.type||"").toLowerCase()){case"boolean":s=e.P+"-checkbox",o["true-value"]="{{ true }}",o["false-value"]="{{ false }}",o.caption=o.placeholder,delete o.placeholder;break;case"byte":o.min="0",o.max="255";case"int16":case"int32":case"int64":case"short":case"integer":case"int":case"long":o.step=""+(n.extra?.step??"1"),s=r;const X=n.display?.format;e.Utils.isNullOrEmpty(X)||(o.format=JSON.stringify(X)),!1!==l.preventWheel&&s===e.P+"-input-number"&&(o["on-wheel"]="$event.preventDefault()");break;case"double":case"decimal":case"float":case"single":case"number":s=r,o.step=""+(n.extra?.step??"any");const Z=n.display?.format;e.Utils.isNullOrEmpty(Z)||(o.format=JSON.stringify(Z)),!1!==l.preventWheel&&s===e.P+"-input-number"&&(o["on-wheel"]="$event.preventDefault()");break;default:if(("array"===n.type||"object"===n.type)&&!e.Utils.isNullOrEmpty(n.props)){if(s=e.P+"-childform",delete o.placeholder,o.metadata=e.Utils.Json.stringify(n.props,{functions:e.JsonFunctionConversion.Reference}),o.mode=n.type,o["lock-items"]=""+(n.extra&&n.extra.lockItems||!1),o.logger="{{ :host.logger }}",!e.Utils.isNullOrEmpty(m)){var b="";for(let Q of m)b+=`<${e.P}-childform-propagator model="${o.value}" watch="{{ :host.entity.${Q.prop} }}" property="${Q.alias||Q.prop}"></${e.P}-childform-propagator>\n`;this._container.innerHTML=b}o["fetch-credentials"]="{{ :host.fetchCredentials }}",o["fetch-headers"]="{{ :host.fetchHeaders }}"}}}}if(!e.Utils.isNullOrEmpty(n.commands)){e.Utils.addClass(this._container,e.PCSS+"-fieldgroup");const ee=this._container.appendChild(document.createElement("div")),te=this._container.appendChild(document.createElement("div"));e.Utils.addClass(ee,`fieldgroup-prepend ${e.PCSS}-buttonset buttons`),e.Utils.addClass(te,`fieldgroup-append ${e.PCSS}-buttonset buttons`);const ae=p||"false";n.commands.forEach(t=>{const a=document.createElement(e.P+"-button");a.setAttribute("icon-glyph",t.icon),a.setAttribute("command-name",t.name),t.dependsOnValue?(a.setAttribute("disabled",`{{ (${ae}) || !::_form.valid || $pacem.isNullOrEmpty(:host.entity.${n.prop}) }}`),a.setAttribute("command-argument",`{{ :host.entity.${n.prop} }}`)):a.setAttribute("disabled",d),a.setAttribute("tooltip",t.tooltip),e.Utils.isNullOrEmpty(t.cssClass)||e.Utils.addClass(a,t.cssClass.join(" ")),(t.prepend?ee:te).appendChild(a)})}e.Utils.isNullOrEmpty(n.validators)||n.validators.forEach(t=>{var r,l={},c={};switch(function(e){return"errorMessage"in e}(t)&&(l=t.params||{},c["error-message"]=t.errorMessage),function(e){return"attributes"in e&&"function"==typeof e.attributes}(t)&&e.Utils.extend(c,t.attributes(this,":host",":host.entity")),t.type){case"required":o.required="true",r=new a.PacemRequiredValidatorElement;break;case"length":let d=new a.PacemLengthValidatorElement;r=d;let h=l&&l.max,p=l&&l.min;null!=h?(o.maxlength=""+(d.max=h),s===e.P+"-input-chars"&&(o.count??=""+h)):"max"in c&&(o.max=c.max),null!=p?o.minlength=""+(d.min=p):"min"in c&&(o.minlength=c.min);break;case"range":let u=new a.PacemRangeValidatorElement;r=u;let v=l&&l.max,_=l&&l.min,g=s===e.P+"-datetime-picker";null!=v?(u.max=v,o.max="{{ "+(g?"'"+v+"'":v)+" }}"):"max"in c&&(o.max=c.max),null!=_?(u.min=_,o.min="{{ "+(g?"'"+_+"'":_)+" }}"):"min"in c&&(o.min=c.min);break;case"email":let y=new a.PacemRegexValidatorElement;r=y,o.pattern=i(y.pattern=/^[\w\-\.]+@[\w\-\.]+\.[a-zA-Z0-9]{2,6}$/);break;case"regex":let f=new a.PacemRegexValidatorElement;r=f;let C=l.pattern;C||=c.pattern,o.pattern=i(C),f.pattern=C;break;case"binary":let P=new a.PacemBinaryValidatorElement;r=P;let b=l.pattern;null!=b?(o.pattern=i(b),P.pattern=b):"pattern"in c&&(o.pattern=c.pattern);let E=l&&l.maxSize;null!=E?(P.maxSize=E,o["max-size"]=""+E):"max-size"in c&&(o["max-size"]=c["max-size"]);break;case"compare":let w=new a.PacemCompareValidatorElement;r=w;let S="";if("value"in l)S=JSON.stringify(l.value);else{S=`:host.entity.${"to"in l?l.to:l.toProperty}`}const k=`{{ ${S} }}`;w.setAttribute("to",k);let $=w.operator=l.operator||c.operator||"equal";if(s===e.P+"-datetime-picker")switch($){case"lessOrEqual":case"less":o.max=k;break;case"greaterOrEqual":case"greater":o.min=k}break;case"async":let U=new a.PacemAsyncValidatorElement;r=U,U.url=l.url;let N=[],x=l.dependsOn||m;N.push(`${n.prop}: :host._adjustDependencyValue(:host.entity.${n.prop})`);for(let e of x||[])N.push(`${e.alias||e.prop}: :host._adjustDependencyValue(:host.entity.${e.prop})`);U.setAttribute("parameters",`{{ { ${N.join(", ")} } }}`),U.method=l.verb||e.Net.HttpMethod.Get,U.setAttribute("fetch-credentials","{{ :host.fetchCredentials }}"),U.setAttribute("fetch-headers","{{ :host.fetchHeaders }}");break;case"custom":r=new a.PacemCustomValidatorElement;break;default:if(!e.Utils.isNullOrEmpty(t.type)&&t.type.indexOf("-")>0){const e=t.type,i=document.createElement(e);i instanceof a.PacemBaseValidatorElement&&(r=i)}}if(e.Utils.isNull(r))throw`Cannot generate a formfield validator based on type: ${t.type}.`;r.watch=n.prop,r.setAttribute("hide","{{ !this.invalid }}"),r.setAttribute("disabled",d);for(let e in c)r.setAttribute(e,c[e]);this._validators.appendChild(r)});let E=document.createElement(s);for(var w in o){let ie;e.Utils.isNullOrEmpty(ie=o[w])||E.setAttribute(w,ie)}for(var w in E.append(f),this._field=E,this._container.insertBefore(E,this._container.firstElementChild),c){let ne;e.Utils.isNullOrEmpty(ne=c[w])||this._fetcher.setAttribute(w,ne)}this.dispatchEvent(new e.PropertyChangeEvent({propertyName:"field",currentValue:E}))}};__decorate([e.ViewChild("label")],n.prototype,"_label",void 0),__decorate([e.ViewChild(`div.${e.PCSS}-input-container`)],n.prototype,"_container",void 0),__decorate([e.ViewChild(e.P+"-fetch")],n.prototype,"_fetcher",void 0),__decorate([e.ViewChild(e.P+"-form")],n.prototype,"_form",void 0),__decorate([e.ViewChild(e.P+"-panel."+e.PCSS+"-validators")],n.prototype,"_validators",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Json})],n.prototype,"metadata",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Json})],n.prototype,"fetchHeaders",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],n.prototype,"fetchCredentials",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Boolean})],n.prototype,"readonly",void 0),__decorate([e.Watch()],n.prototype,"entity",void 0),n=__decorate([e.CustomElement({tagName:e.P+"-form-field",template:`<${e.P}-form class="${e.PCSS}-field" logger="{{ :host.logger }}" \ncss-class="{{ {'${e.PCSS}-fetching': ::_fetcher.fetching, '${e.PCSS}-dirty': this.dirty, '${e.PCSS}-invalid': !this.valid, '${e.PCSS}-editable': !:host.readonly, '${e.PCSS}-readonly': :host.readonly, '${e.PCSS}-pristine': !this.dirty, '${e.PCSS}-valid': this.valid, '${e.PCSS}-has-value': !:host._isValueNullOrEmpty(:host.entity, :host.metadata) } }}">\n <label class="${e.PCSS}-label"><${e.P}-span></${e.P}-span></label>\n <div class="${e.PCSS}-input-container"></div>\n <${e.P}-fetch debounce="300" logger="{{ :host.logger }}" credentials="{{ :host.fetchCredentials }}" headers="{{ :host.fetchHeaders }}" diff-by-values="true"\n on-fetchresult=":host._broadcastFetchResult($event.detail)"></${e.P}-fetch>\n <${e.P}-panel class="${e.PCSS}-validators" hide="{{ ::_form.valid || !::_form.dirty || :host.readonly }}"></${e.P}-panel>\n</${e.P}-form>`})],n),a.PacemFormFieldElement=n}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){let a=class PacemGeolocateElement extends t.PacemBaseElement{constructor(){super(...arguments),this._dragendHandler=e=>{this._reverseGeocoder.position=e.detail.position}}get inputFields(){return[]}toggleReadonlyView(e){this._setupSuggest(),this._setupMapMarker()}onChange(t){return new Promise((a,i)=>{if("success"===t.type&&t.target===this._reverseGeocoder){const i=this.#l.position,n=t.detail.sort((t,a)=>e.Maps.MapProjection.distanceBetween(t.position,i)<e.Maps.MapProjection.distanceBetween(a.position,i)?0:-1),s=n[0].position.altitude,r=e.Utils.extend({},n[0],{position:e.Utils.extend({altitude:s},i)});a(this.value=r)}else t.type===e.Scaffolding.FieldChangeEventName&&t.target===this._suggest?a(this.value=this._suggest.value):a(this.value)})}fetch(t){e.Maps.LatLng.isLatLng(t)&&(this.#l.position=this._reverseGeocoder.position=t)}compareValuePropertyValues(t,a){const i=t?.position??e.Maps.LatLng.Empty,n=a?.position??e.Maps.LatLng.Empty;return e.Maps.LatLng.equals(i,n)}acceptValue(t){e.Utils.isNull(t)?this._datasource.model=[]:(this._datasource.model=[t],this._setupMapMarker()),this._setupSuggest()}getViewValue(e){return e?.fullAddress||""}convertValueAttributeToProperty(t){return e.PropertyConverters.Json.convert(t,this)}#l;viewActivatedCallback(){super.viewActivatedCallback(),this._setup()}propertyChangedCallback(e,t,a,i){if(super.propertyChangedCallback(e,t,a,i),!i)switch(e){case"adapter":this._setupAdapters(a);break;case"map":t&&this._detachMarker(t),a&&this._setupMapMarker(a);break;case"icon":this._setupMapMarker();break;case"plaeholder":this._setupSuggest();break;case"disabled":this._setupMapMarker(),this._setupSuggest()}}disconnectedCallback(){this._disposeMarker(),super.disconnectedCallback()}_setupAdapters(t=this.adapter){const a=this._geocoder,i=this._reverseGeocoder;e.Utils.isNull(a)||(a.adapter=t),e.Utils.isNull(i)||(i.adapter=t)}_setupSuggest(){const t=this._suggest;e.Utils.isNull(t)||(t.placeholder=this.placeholder??"search...",t.readonly=this.readonly,t.disabled=this.disabled,t.value=this.value)}_detachMarker(t=this.map){const a=this.#l;e.Utils.isNull(a)||a.map!==t||a.remove()}_createMarker(){const t=new e.Components.Maps.PacemMapMarkerElement;return t.addEventListener("dragend",this._dragendHandler,!1),t}_disposeMarker(){const t=this.#l;e.Utils.isNull(t)||t.removeEventListener("dragend",this._dragendHandler,!1)}_setupMapMarker(t=this.map){const a=this.#l||(this.#l=this._createMarker());a.icon=this.icon,a.draggable=!this.readonly&&!this.disabled,a.hide=this.disabled;const i=this.value;i&&i.position&&(a.position=i.position),a.map===t||e.Utils.isNull(t)||t.appendChild(a)}_setup(){this._setupAdapters(),this._setupSuggest(),this._setupMapMarker()}};__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Element})],a.prototype,"adapter",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Element})],a.prototype,"map",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Json})],a.prototype,"icon",void 0),__decorate([e.ViewChild(e.P+"-data[ds]")],a.prototype,"_datasource",void 0),__decorate([e.ViewChild(e.P+"-suggest")],a.prototype,"_suggest",void 0),__decorate([e.ViewChild(e.P+"-map-geocode")],a.prototype,"_geocoder",void 0),__decorate([e.ViewChild(e.P+"-map-geocode[reverse]")],a.prototype,"_reverseGeocoder",void 0),a=__decorate([e.CustomElement({tagName:e.P+"-geolocate",shadow:!1,template:`<${e.P}-map-geocode search="{{ ::_suggest.hint }}"\n disabled="{{ (::_suggest.hint || '').length < 3 }}" on-success="::_datasource.model = $event.detail"></${e.P}-map-geocode>\n<${e.P}-map-geocode reverse on-success=":host.changeHandler($event)"></${e.P}-map-geocode>\n\n<${e.P}-data ds></${e.P}-data>\n\n<${e.P}-suggest on-change=":host.changeHandler($event)" datasource="{{ ::_datasource.model || [] }}"\n compare-by="fullAddress" text-property="fullAddress"></${e.P}-suggest>`})],a),t.PacemGeolocateElement=a}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(a){class HierarchyChangeEvent extends CustomEvent{constructor(e){super("hierarchychange",{detail:e,bubbles:!1,cancelable:!1})}}const i="hierarchy-item",n=i+" "+e.PCSS+"-anim anim-fade-in anim-sudden",s="{{ { 'item-disabled' : ^item.disabled } }}",r="pacemHierarchy",o="item-content",l="item-link",c=l+" icon-rotate rotate-135",d="link",h="item-move",p="drag_indicator",u="parents";let m=class PacemHierarchyElement extends a.PacemBaseElement{getViewValue(e){return""}convertValueAttributeToProperty(t){return e.Utils.Json.parse(t)}constructor(){super(),this.#c=new Map,this.#d=new Map,this.unlinkCaption="Delete",this._binderClickHandler=t=>{const a=t.originalEvent.type;if("mousedown"===a&&1===t.originalEvent.button){e.avoidHandler(t.originalEvent);const a=t.srcElement;this._unlink(a)}else if("click"===a||"contextmenu"===a){e.avoidHandler(t.originalEvent),this.#h=t.srcElement;const a=this._balloon;a.target={x:t.pageX,y:t.pageY},a.popup()}},this._dragInitHandler=t=>{let a=t.detail;const i=this._dragger;i.floater=document.createElement("span"),i.dropTargets=Array.from(this.#d.keys()).filter(e=>e!==a.element),e.Utils.isNull(this.#p)||this.#p.remove();const n=this.#p=new e.Components.UI.PacemBinderElement;n.from=a.element,this.#u.appendChild(n)},this._dragStartHandler=t=>{e.Utils.addClass(t.detail.element,"item-drag")},this._dragHandler=e=>{this.#p.to=e.detail.currentPosition},this._dragEndHandler=t=>{e.Utils.removeClass(t.detail.element,"item-drag"),this.#p.remove(),this.#p=null},this._dropHandler=e=>{const t=e.detail.data,a=this.#d.get(e.detail.target);this._isInAncestors(t,a)||this._isInDescendants(t,a)||this._compileHierarchy({source:t,target:a})},this._dragOverHandler=e=>{const t=e.detail.data,a=this.#d.get(e.detail.target);(a.disabled||this._isInAncestors(t,a)||this._isInDescendants(t,a))&&e.preventDefault()},this._dragOutHandler=e=>{},this._popoutHandler=e=>{this._balloon.popout()},this.#m=e.Utils.uniqueCode()}#m;#c;#p;#h;#d;#u;get inputFields(){return[]}toggleReadonlyView(t){this._dragger.disabled=t,e.Utils.isNull(this._adaptedDatasource)||this._databind()}onChange(t){return new Promise((a,i)=>{e.CustomEventUtils.isInstanceOf(t,HierarchyChangeEvent)&&a(this.value=t.detail),a(this.value)})}acceptValue(e){}viewActivatedCallback(){super.viewActivatedCallback(),this.#u=e.CustomElementUtils.findAncestorShell(this),this._setupItemTemplate(),this._setupDragger(),this._setupBalloon()}propertyChangedCallback(e,t,a,i){switch(super.propertyChangedCallback(e,t,a,i),e){case"datasource":case"textProperty":case"disabledProperty":case"valueProperty":cancelAnimationFrame(this._handle),this._handle=requestAnimationFrame(()=>{this._buildAdaptedDatasource()});break;case"itemtemplate":i||this._setupItemTemplate();break;case"_adaptedDatasource":case"value":cancelAnimationFrame(this._handle2),this._handle2=requestAnimationFrame(()=>{this._databind()})}}disconnectedCallback(){this._disposeDragger(),this._disposeBalloon(),super.disconnectedCallback()}_buildAdaptedDatasource(e=this.datasource){this._adaptedDatasource=e&&e.map(e=>this._mapEntityToItem(e))}_mapEntityToValue(e){let t,a=e;return(t=this.valueProperty)&&(a=e[t]),a}_mapEntityToViewValue(e){let t,a=e.toString();return(t=this.textProperty)&&(a=e[t]),a}_mapEntityToItem(t){if(null==t)throw new Error("Entity cannot be null");let a=!1;const i=this.disabledProperty;return e.Utils.isNullOrEmpty(i)||(a=t[i]||!1),{value:this._mapEntityToValue(t),viewValue:this._mapEntityToViewValue(t),disabled:a,data:t}}_unlink(e){var a;e instanceof t.UI.PacemBinderElement?a=e:(e.preventDefault(),e.stopPropagation(),a=this.#h);const{parent:i,child:n}=JSON.parse(a.dataset[r]),s=this._adaptedDatasource,o=s.find(e=>e.value===i),l=s.find(e=>e.value===n);o.disabled||l.disabled||this._compileHierarchy({source:o,target:l},!0)}_buildHierarchyItemDomId(e){return`hierarchyitem_${this.#m}_${e}`}_itemCreate(a){const n=a.detail.dom.find(e=>e instanceof HTMLElement&&e.classList.contains(i)),s=(a.detail.index,a.detail.item);n.id=this._buildHierarchyItemDomId(s.value),s.disabled?n.setAttribute("behaviors","{{ [#"+this._dragger2.id+"] }}"):n.setAttribute("behaviors","{{ [#"+this._dragger.id+", #"+this._dragger2.id+"] }}");for(let a of s.parents||[]){const i=new e.Components.UI.PacemBinderElement;i.to=n,i.toAnchor=t.UI.BinderAnchor.Top,i.toEnd=t.UI.BinderEnd.Arrow,i.setAttribute("from","{{ #"+this._buildHierarchyItemDomId(a.value)+" }}"),i.fromAnchor=t.UI.BinderAnchor.Bottom,i.cssClass=["hierarchy-binder"],i.interactive=!this.readonly&&!s.disabled&&!a.disabled,i.addEventListener(t.UI.BinderInteractionEventName,this._binderClickHandler,!1),i.dataset[r]=JSON.stringify({parent:a.value,child:s.value}),this.#c.set(s.value,i),this.#u.appendChild(i)}this.#d.has(n)||this.#d.set(n,s)}_itemRemove(e){const a=e.detail.dom.find(e=>e instanceof HTMLElement&&e.classList.contains(i)),n=e.detail.item,s=this.#c;if(s.has(n.value)){const e=s.get(n.value);e.removeEventListener(t.UI.BinderInteractionEventName,this._binderClickHandler,!1),e.remove(),s.delete(n.value)}this.#d.has(a)&&this.#d.delete(a)}_setupItemTemplate(){if(this.itemtemplate instanceof HTMLTemplateElement){const a=this.itemtemplate.cloneNode(!0).content,i=document.createElement("template"),r=document.createElement(e.P+"-panel");r.className=n,r.setAttribute("css-class",s);const l=new t.UI.PacemIconElement;l.setAttribute("icon",p),l.className=h,r.appendChild(l);const u=document.createElement("div");u.className=o,u.append(a),r.appendChild(u);const m=new t.UI.PacemIconElement;m.setAttribute("icon",d),m.className=c,r.appendChild(m),i.content.appendChild(r),this._template=i}else this._template=this._defaultTemplate}_compileHierarchy(t,a=!1){const i=e.Utils.clone(this.value||[]),n=t.source.value,s=t.target.value,r=this.parentsProperty||u;var o=i.find(e=>e[this.valueProperty]===s);if(a){if(!e.Utils.isNull(o)){const e=o[r]||[],t=e.indexOf(n);t>=0&&e.splice(t,1)}}else e.Utils.isNull(o)&&((o={})[this.valueProperty]=s,o[r]=[],i.push(o)),o[r].push(n);this._cleanupHierarchy(i),this.changeHandler(new HierarchyChangeEvent(i))}_cleanupHierarchy(t=[]){const a=this.valueProperty,i=this.parentsProperty||u,n=(s,r)=>{const o=t.find(e=>e[a]==r);if(e.Utils.isNull(o)||e.Utils.isNullOrEmpty(o[i]))return!1;const l=o[i];return l.indexOf(s)>=0||l.some(e=>n(s,e))};for(let e of t){const t=e[i]||[];for(let e=t.length-1;e>=0;e--){const a=t[e],i=t.filter(e=>e!==a);for(let s of i)if(n(a,s)){t.splice(e,1);break}}}}_setupDragger(){const t=this._dragger;t.id="hierarchy_link_"+this.#m,t.handleSelector="."+l,t.dropBehavior=e.UI.DropBehavior.None,t.spillBehavior=e.UI.DropTargetMissedBehavior.None,t.mode=e.UI.DragDataMode.Copy,t.addEventListener(e.UI.DragDropEventType.Drop,this._dropHandler,!1),t.addEventListener(e.UI.DragDropEventType.Drag,this._dragHandler,!1),t.addEventListener(e.UI.DragDropEventType.Init,this._dragInitHandler,!1),t.addEventListener(e.UI.DragDropEventType.Start,this._dragStartHandler,!1),t.addEventListener(e.UI.DragDropEventType.End,this._dragEndHandler,!1),t.addEventListener(e.UI.DragDropEventType.Over,this._dragOverHandler,!1),t.addEventListener(e.UI.DragDropEventType.Out,this._dragOutHandler,!1);const a=this._dragger2;a.id="hierarchy_move_"+this.#m,a.mode=e.UI.DragDataMode.Self,a.dropBehavior=e.UI.DropBehavior.None,a.spillBehavior=e.UI.DropTargetMissedBehavior.None,a.handleSelector="."+h}_disposeDragger(){const t=this._dragger;e.Utils.isNull(t)||(t.removeEventListener(e.UI.DragDropEventType.Drop,this._dropHandler,!1),t.removeEventListener(e.UI.DragDropEventType.Drag,this._dragHandler,!1),t.removeEventListener(e.UI.DragDropEventType.Init,this._dragInitHandler,!1),t.removeEventListener(e.UI.DragDropEventType.Start,this._dragStartHandler,!1),t.removeEventListener(e.UI.DragDropEventType.End,this._dragEndHandler,!1),t.removeEventListener(e.UI.DragDropEventType.Over,this._dragOverHandler,!1),t.removeEventListener(e.UI.DragDropEventType.Out,this._dragOutHandler,!1))}_setupBalloon(){this._balloon=this._shellProxy.dom.find(e=>e instanceof t.UI.PacemBalloonElement),window.addEventListener("mousedown",this._popoutHandler,!1)}_disposeBalloon(){window.removeEventListener("mousedown",this._popoutHandler,!1)}_isInAncestors(t,a){return!e.Utils.isNull(a)&&!e.Utils.isNullOrEmpty(a.parents)&&(a.parents.indexOf(t)>=0||a.parents.some(e=>this._isInAncestors(t,e)))}_isInDescendants(e,t){return this._isInAncestors(t,e)}_databind(){this._repeater.datasource=[];const t=this.valueProperty;if(e.Utils.isNullOrEmpty(t))throw new Error("Missing valueProperty.");const a=e.Utils.clone(this._adaptedDatasource||[]),i=this.value||[],n=this.parentsProperty||u;for(let s of a){const r=i.find(e=>e[t]===s.value);e.Utils.isNull(r)||(s.parents=(r[n]||[]).map(e=>a.find(t=>t.value===e)).filter(t=>!e.Utils.isNull(t)))}this._databindByParents(a)}_databindByParents(t){const a=[];function i(){return a.reduce((e,t)=>e+t.length,0)}do{if(e.Utils.isNullOrEmpty(a)){const i=t.filter(t=>e.Utils.isNullOrEmpty(t.parents));a.push(i)}else{const i=Array.prototype.concat.apply([],a),n=a[a.length-1],s=t.filter(t=>!e.Utils.isNullOrEmpty(t.parents)&&(t.parents.every(e=>i.indexOf(e)>=0)&&t.parents.some(e=>n.indexOf(e)>=0)));a.push(s)}}while(i()<t.length);this._repeater.datasource=a}};__decorate([e.ViewChild("template[default]")],m.prototype,"_defaultTemplate",void 0),__decorate([e.ViewChild(e.P+"-repeater")],m.prototype,"_repeater",void 0),__decorate([e.ViewChild(e.P+"-drag-drop")],m.prototype,"_dragger",void 0),__decorate([e.ViewChild(e.P+"-drag-drop[move]")],m.prototype,"_dragger2",void 0),__decorate([e.ViewChild(e.P+"-shell-proxy")],m.prototype,"_shellProxy",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Json})],m.prototype,"datasource",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String})],m.prototype,"valueProperty",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String})],m.prototype,"textProperty",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String})],m.prototype,"disabledProperty",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],m.prototype,"unlinkCaption",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Json})],m.prototype,"_adaptedDatasource",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Element})],m.prototype,"itemtemplate",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Element})],m.prototype,"_template",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String})],m.prototype,"parentsProperty",void 0),m=__decorate([e.CustomElement({tagName:e.P+"-hierarchy",shadow:e.Defaults.USE_SHADOW_ROOT,template:`<${e.P}-repeater>\n <template>\n <${e.P}-repeater on-${t.RepeaterItemCreateEventName}=":host._itemCreate($event)" on-${t.RepeaterItemRemoveEventName}=":host._itemRemove($event)" datasource="{{ ^item }}">\n <div class="hierarchy-level">\n <${e.P}-template-proxy target="{{ :host._template }}"></${e.P}-template-proxy>\n </div>\n </${e.P}-repeater>\n </template>\n </div>\n</${e.P}-repeater><${e.P}-content></${e.P}-content>\n<${e.P}-drag-drop></${e.P}-drag-drop>\n<${e.P}-drag-drop move></${e.P}-drag-drop>\n<template default>\n <${e.P}-panel class="${n} item-default" css-class="${s}">\n <${e.P}-icon class="${h}" icon="${p}"></${e.P}-icon>\n <pacem-span class="${o}" content="{{ ^item.viewValue }}"></${e.P}-span>\n <${e.P}-icon class="${c}" icon="${d}"></${e.P}-icon>\n </${e.P}-panel>\n</template>\n<${e.P}-shell-proxy>\n <${e.P}-balloon options="{{ { behavior: Pacem.Components.UI.BalloonBehavior.Inert } }}">\n <${e.P}-button icon-glyph="link_off" class="${e.PCSS}-margin margin-0 button-flat display-flex flex-middle icon-rotate rotate-135"\n on-click=":host._unlink($event)"\n on-mousedown="$event.stopPropagation()"\n on-mouseup="::_balloon.popout()"><${e.P}-text class="${e.PCSS}-margin margin-left-1" text="{{ :host.unlinkCaption }}"></${e.P}-text></${e.P}-button>\n </${e.P}-balloon>\n</${e.P}-shell-proxy>`})],m),a.PacemHierarchyElement=m}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){let a;!function(e){e.Input="input",e.Blur="blur"}(a=t.ChangePolicy||(t.ChangePolicy={}));const i="pacem:scaffolding:input_field";class PacemBaseInputElement extends t.PacemBaseElement{constructor(){super(...arguments),this.debounce=!1,this.changePolicy=a.Input,this._focusHandler=e=>{if(!this.autoselect)return;let t=this.inputField;for(let e of this.inputFields??[])if(e===document.activeElement){t=e;break}t?.select()}}propertyChangedCallback(e,t,a,i){if(super.propertyChangedCallback(e,t,a,i),"placeholder"===e)for(let t of this.inputFields??[])t.setAttribute(e,a)}acceptValue(t){this.inputField&&t!==this.inputField.value&&(this.inputField.value=e.Utils.isNullOrEmpty(t)?"":t)}get inputField(){return this.inputFields[0]}onChange(e){return new Promise(t=>{if(this.readonly)t(this.value);else if("input"===e.type&&this.changePolicy===a.Blur)t(this.value);else{const e=()=>{const e=this.getValue(this.inputField.value);e!==this.value&&(this.value=e),t(e)},a=this.debounce;"number"==typeof a&&a>0?(clearTimeout(this._handle),this._handle=setTimeout(e,a)):!0===a?(cancelAnimationFrame(this._handle),this._handle=requestAnimationFrame(e)):requestAnimationFrame(e)}})}registerInputFields(t=this.inputFields){super.registerInputFields(t),e.Utils.isNull(t)||e.Utils.isArray(t)||(t=[t]);for(let a of t??[])a instanceof HTMLInputElement&&"on"!==e.CustomElementUtils.getAttachedPropertyValue(a,i,"off")&&(e.CustomElementUtils.setAttachedPropertyValue(a,i,"on"),a.size=1,a.autocomplete="off",a.addEventListener("input",this.changeHandler,!1),a.addEventListener("focus",this._focusHandler,!1))}unregisterInputFields(t=this.inputFields){super.unregisterInputFields(t),e.Utils.isNull(t)||e.Utils.isArray(t)||(t=[t]);for(let a of t??[])"on"===e.CustomElementUtils.getAttachedPropertyValue(a,i)&&(e.CustomElementUtils.deleteAttachedPropertyValue(a,i),a.removeEventListener("input",this.changeHandler,!1),a.removeEventListener("focus",this._focusHandler,!1))}viewActivatedCallback(){super.viewActivatedCallback(),this.registerInputFields()}disconnectedCallback(){this.unregisterInputFields(),super.disconnectedCallback()}}__decorate([e.Watch({emit:!1,converter:{convert:e=>{switch(e){case"true":return!0;case"false":return!1;default:return parseFloat(e)}},convertBack:e=>e.toString()}})],PacemBaseInputElement.prototype,"debounce",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String})],PacemBaseInputElement.prototype,"changePolicy",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Boolean})],PacemBaseInputElement.prototype,"autoselect",void 0),t.PacemBaseInputElement=PacemBaseInputElement;class PacemOrdinalInputElement extends PacemBaseInputElement{convertValueAttributeToProperty(e){return parseFloat(e)}propertyChangedCallback(e,t,a,i){switch(super.propertyChangedCallback(e,t,a,i),e){case"min":case"max":case"step":null!=a?this.inputField.setAttribute(e,a):this.inputField.removeAttribute(e)}}}__decorate([e.Watch({converter:e.PropertyConverters.Number})],PacemOrdinalInputElement.prototype,"min",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Number})],PacemOrdinalInputElement.prototype,"max",void 0),__decorate([e.Watch({converter:{convert:e=>{const t=parseFloat(e);return isNaN(t)?"any":t},convertBack:e=>e.toString()}})],PacemOrdinalInputElement.prototype,"step",void 0),t.PacemOrdinalInputElement=PacemOrdinalInputElement;class PacemTextualInputElement extends PacemBaseInputElement{convertValueAttributeToProperty(e){return e}propertyChangedCallback(e,t,a,i){switch(super.propertyChangedCallback(e,t,a,i),e){case"pattern":case"maxlength":case"minlength":null!=a?this.inputField.setAttribute(e,a):this.inputField.removeAttribute(e)}}getValue(t){return e.Utils.isNullOrEmpty(t)?null:t}getViewValue(e){return e}}__decorate([e.Watch({converter:e.PropertyConverters.String})],PacemTextualInputElement.prototype,"pattern",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Number})],PacemTextualInputElement.prototype,"minlength",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Number})],PacemTextualInputElement.prototype,"maxlength",void 0),t.PacemTextualInputElement=PacemTextualInputElement}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(a){let i=class PacemCharsInputElement extends a.PacemBaseInputElement{constructor(){super(),this.charCount=6,this.inputTransform="none",this._itemCreateHandler=e=>{const{dom:t,index:a}=e.detail,i=t.find(e=>e instanceof HTMLInputElement);this.#v[a]=i,this.registerInputFields(i)},this.#v=[]}redactViewValue(e=this.value){this.viewValue=this.getViewValue(e)}getValue(t){const a=this.#v.reduce((t,a)=>t+(e.Utils.isNullOrEmpty(a.value)?" ":a.value),"");switch(this.inputTransform){case"lowercase":return a.toLowerCase();case"uppercase":return a.toUpperCase();default:return a}}getViewValue(t){const a=this.charCount;return"password"==this.inputTransform?e.Arrays.range(a).map(e=>"*").join(""):t}convertValueAttributeToProperty(e){return e}toggleReadonlyView(e=this.readonly){this._span.hidden=!e,this._chars.hidden=e}focus(){for(let e of this.inputFields??[])if(e===document.activeElement)return void(this.autofocus&&e.select());super.focus()}propertyChangedCallback(e,t,a,i){if(super.propertyChangedCallback(e,t,a,i),!i)switch(e){case"charCount":this._databind(),this.redactViewValue();break;case"inputTransform":this.registerInputFields(),this.value=this.getValue(this.value)}}registerInputFields(t=this.inputFields){super.registerInputFields(t),e.Utils.isNull(t)||e.Utils.isArray(t)||(t=[t]);const a=this.#v;for(let i of t??[]){const t=a.indexOf(i);e.Utils.toggleClass(i,"last-char",t===this.charCount-1),e.Utils.toggleClass(i,"first-char",0===t),e.Utils.isNullOrEmpty(i.id)&&i.setAttribute("id","code_"+t+"_"+e.Utils.uniqueCode()),i.value=this.value?.charAt(t)||"","password"===this.inputTransform?i.setAttribute("type","password"):i.setAttribute("type","text")}}acceptValue(e){const t=this.#v;if("string"==typeof e){let a=0;const i=Math.min(e.length,t.length);for(let n=0;n<i;n++)t[n].value=e.charAt(n),a++;for(let e=a;e<t.length;e++)t[e].value=""}}onChange(t){return super.onChange(t).then(a=>{const i=this.#v,n=i.indexOf(t.target);if(n>=0&&n<i.length-1){const t=i[n];if(e.Utils.isNullOrEmpty(t.value?.trim()))t.value="";else{i[n+1].focus()}}return a})}viewActivatedCallback(){super.viewActivatedCallback(),e.Utils.isNull(this.autoselect)&&(this.autoselect=!0),this._chars.addEventListener(t.RepeaterItemCreateEventName,this._itemCreateHandler,!1),this._databind()}disconnectedCallback(){const a=this._chars;e.Utils.isNull(a)||a.removeEventListener(t.RepeaterItemCreateEventName,this._itemCreateHandler),super.disconnectedCallback()}_databind(){const t=this.charCount,a=this.#v;a.length>t&&super.unregisterInputFields(a.splice(t)),this._chars.datasource=e.Arrays.range(t)}#v;get inputFields(){return this.#v}};__decorate([e.Watch({emit:!1,reflectBack:!0,converter:e.PropertyConverters.Number})],i.prototype,"charCount",void 0),__decorate([e.Watch({emit:!1,reflectBack:!0,converter:e.PropertyConverters.String})],i.prototype,"inputTransform",void 0),__decorate([e.ViewChild(e.P+"-repeater")],i.prototype,"_chars",void 0),__decorate([e.ViewChild("span."+e.PCSS+"-readonly")],i.prototype,"_span",void 0),i=__decorate([e.CustomElement({tagName:e.P+"-input-chars",template:`<${e.P}-repeater class="display-flex flex-nowrap">\n <template><input type="text" class="${e.PCSS}-input flex-auto" maxlength="1" /></template>\n </${e.P}-repeater><span class="${e.PCSS}-readonly"><${e.P}-text text="{{ :host.viewValue }}"></${e.P}-text></span>`,shadow:e.Defaults.USE_SHADOW_ROOT})],i),a.PacemCharsInputElement=i}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){let a=class PacemColorInputElement extends t.PacemBaseElement{acceptValue(e){const t=this._parseValue(e);null!=t&&(this._tint.value=t.tint,this._alpha.value=t.alpha.toString())}convertValueAttributeToProperty(e){return e}onChange(t){const a=this._alpha.valueAsNumber||parseInt(this._alpha.value),i=this._tint.value,n=this.value=this._getValue(i,a);return e.Utils.fromResult(n)}constructor(){super()}toggleReadonlyView(e){this._wrapper.hidden=e,this._span.hidden=!e}_getValue(t,a){if(isNaN(a)||100===a)return t;const i=e.Colors.parse(t);return i.a=.01*a,e.Colors.stringify(i)}_parseValue(t){const a=e.Colors.parse(t);return e.Utils.isNullOrEmpty(a)?null:{tint:e.Colors.stringify({r:a.r,g:a.g,b:a.b}),alpha:100*a.a}}getViewValue(e){return e}get inputFields(){return[this._tint,this._alpha]}};__decorate([e.ViewChild("input[type=color]")],a.prototype,"_tint",void 0),__decorate([e.ViewChild("input[type=number]")],a.prototype,"_alpha",void 0),__decorate([e.ViewChild(`.${e.PCSS}-viewfinder`)],a.prototype,"_wrapper",void 0),__decorate([e.ViewChild(`.${e.PCSS}-readonly`)],a.prototype,"_span",void 0),a=__decorate([e.CustomElement({tagName:e.P+"-input-color",template:`<div class="${e.PCSS}-viewfinder">\n<${e.P}-panel class="${e.PCSS}-input-color" css="{{ { 'background-color': :host.viewValue } }}"><input type="color" class="${e.PCSS}-input" /></${e.P}-panel>\n<input class="${e.PCSS}-input" type="number" min="0" max="100" step="1" value="100" />\n</div>\n<${e.P}-span class="${e.PCSS}-readonly" css="{{ { 'background-color': :host.viewValue } }}"></${e.P}-span>`,shadow:e.Defaults.USE_SHADOW_ROOT})],a),t.PacemColorInputElement=a}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){let a=class PacemEmailInputElement extends t.PacemTextualInputElement{toggleReadonlyView(e){this.input.hidden=e,this.anchor.hidden=!e}get inputFields(){return[this.input]}};__decorate([e.ViewChild("input[type=email]")],a.prototype,"input",void 0),__decorate([e.ViewChild(e.P+"-a")],a.prototype,"anchor",void 0),a=__decorate([e.CustomElement({tagName:e.P+"-input-email",template:`<input type="email" class="${e.PCSS}-input ${e.PCSS}-viewfinder" />${t.CHAR_COUNTER_CHILD}<${e.P}-a class="${e.PCSS}-readonly" disabled="{{ $pacem.isNullOrEmpty(:host.value) }}" href="{{ 'mailto:'+ :host.value }}"><${e.P}-text text="{{ :host.viewValue }}"></${e.P}-text></${e.P}-a>`,shadow:e.Defaults.USE_SHADOW_ROOT})],a),t.PacemEmailInputElement=a}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){t.FileUploadEventName="fileupload",t.FileChangeEventName="filechange";class StoragePickEvent extends e.CustomTypedEvent{constructor(e){super("pick",e)}}class FileUploadEvent extends e.CustomTypedEvent{constructor(e){super(t.FileUploadEventName,e)}}t.FileUploadEvent=FileUploadEvent;class FileChangeEvent extends e.CustomTypedEvent{constructor(e){super(t.FileChangeEventName,e)}}t.FileChangeEvent=FileChangeEvent;async function a(e,t={files:0,directories:0,size:0}){for await(let[i,n]of e.entries())if("file"===n.kind){t.files++;const e=await n.getFile();t.size+=e.size}else t.directories++,await a(n,t);return t}let i=class PacemUploadElement extends t.PacemBaseElement{constructor(t=new e.Animations.TweenService){super(),this._tweener=t,this.undoCaption="undo",this.retryCaption="retry",this.clearCaption="clear",this.uploading=!1,this.size=0,this.percentage=0,this.complete=!1,this.failed=!1,this.invalidFile=!1,this._fields={parallelism:3,uid:"",ongoing:0,enqueuer:null,blob:null,retryFrom:0,chunkSize:131072,undone:!1}}convertValueAttributeToProperty(e){return e}acceptValue(e){this.percentage=0,this.uploading=!1,this._fileupload.value=""}_getMimeIcon(t=this.value,a=this.uploading,i=this.selectMode??"file"){if(a)return"sync";const n=!e.Utils.isNullOrEmpty(t);switch(i){case"directory":case"directory-picker":return n?"folder":"drive_folder_upload";case"multiple":case"multiple-picker":return n?"files":"upload_file"}if(e.Utils.isNullOrEmpty(t))return"upload_file";var s=t;"object"==typeof t&&(s=t.name);const r=/\.([\w]+)(\s|$)/.exec(s);if(r&&r.length)switch(r[1].toLowerCase()){case"pdf":return"picture_as_pdf";case"jpg":case"jpeg":case"gif":case"png":return"filter"}return"filter_none"}get blob(){return this._fields.blob}get inputFields(){return[this._fileupload]}getViewValue(t){const a=this._localValue||t;if(e.Utils.isNullOrEmpty(a))return"";if("string"==typeof a)return a;let i="name"in a?a.name:"";e.Utils.isArray(a)&&(i=a.map(e=>e.name).join(", "));const{size:n,files:s}=this._stats;return`${i}\n(${s} file${1===s?"":"s"}, ${e.Utils.core.size(n)})`}toggleReadonlyView(e){this._setupInputElement(e)}viewActivatedCallback(){super.viewActivatedCallback(),this._setupInputElement(),this._fileupload.addEventListener("click",e.stopPropagationHandler,!1)}propertyChangedCallback(e,t,a,i){if(super.propertyChangedCallback(e,t,a,i),!i&&"selectMode"===e)this._setupInputElement()}disconnectedCallback(){this._fileupload&&this._fileupload.removeEventListener("click",e.stopPropagationHandler,!1),super.disconnectedCallback()}_setupInputElement(e=this.readonly,t=this.selectMode??"file"){const a=this._fileupload;switch(a.removeAttribute("webkitdirectory"),a.removeAttribute("multiple"),a.hidden=e,t){case"directory":a.setAttribute("webkitdirectory","true");break;case"multiple":a.setAttribute("multiple","true");break;case"directory-picker":case"file-picker":case"multiple-picker":a.hidden=!0}}_dispatchDownload(t){e.avoidHandler(t);const a=this._localValue||this.value,i=e=>{this.dispatchEvent(new CustomEvent("download",{detail:e,bubbles:!0,cancelable:!1}))};e.Utils.isNullOrEmpty(a)||("string"==typeof a?i(a):"content"in a&&!e.Utils.isNullOrEmpty(a.content)?e.Utils.download(e.Utils.dataURLToBlob("data:application/download;base64,"+a.content),a.name,a.type):"name"in a&&("kind"in a&&"file"===a.kind?a.getFile().then(t=>{e.Utils.download(t,t.name,t.type)}):i(a.name)))}reset(){super.reset(),this._localValue=null,this.invalidFile=!1}_validateAll(){const e=this._stats,t=this.maxSize;return t>0&&t<e.size?(this.invalidFile=!0,!1):(this.invalidFile=!1,!0)}_validateSingleFile(e=this._fileupload.files[0],t){e instanceof File&&(t=e.name),t=t.substring(t.lastIndexOf("\\")+1);const a=this.maxSize;if(a>0&&a<e.size)return this.invalidFile=!0,!1;const i=this.pattern;return i&&!new RegExp(i,"i").test(t)?(this.invalidFile=!0,!1):(this.invalidFile=!1,!0)}upload(e,t,a){if(this._validateSingleFile(e,t))return this._upload(e,t,a)}async _upload(e,t,a){var i=this,n=i._fields;if(!e)return;!t&&e instanceof File&&(t=e.name),i.failed=!1,n.undone=!1,n.ongoing=0;const s=e,r=i.size=s.size;t=t.substring(t.lastIndexOf("\\")+1),i.percentage=0,i.complete=!1;var o={filename:t,length:r,action:"start",state:a,type:e.type};i.uploading=!0;try{var l=await i._fetch(o);if(l.ok){var c=await l.json();n.retryFrom=0,n.blob=s,n.uid=c.uid,i._manage()}else i.uploading=!1;return l}catch(e){i.uploading=!1}}async _blobToBase64(t){const a=await e.Utils.blobToDataURL(t);return a.substring(a.indexOf("base64,")+7)}async _doUpload(e,t){var a=this,i=a._fields;i.ongoing++;var n={chunk:await this._blobToBase64(e),uid:i.uid,position:t,action:"do"};try{const e=await a._fetch(n);if(e.ok){if(i.ongoing--,i.undone)return;const t=await e.json();t.percentage>this.percentage&&await a._tweenPercentage(Math.round(Math.max(1,t.percentage)),200),a.complete!=t.complete&&(a.complete=t.complete,!0===a.complete&&(a.uploading=!1,a.changeHandler(new FileUploadEvent(t))))}else i.retryFrom=t,a.failed=!0,a.uploading=!1}catch(e){i.retryFrom=t,a.failed=!0,a.uploading=!1}}_manage(){const e=this._fields,t=this.size,a=e.blob,i=this.chunkSize||e.chunkSize;var n=e.retryFrom,s=n+i;e.enqueuer=setInterval(()=>{if(n<t&&!this.failed){const t=this.parallelism||e.parallelism;if(e.ongoing>=t)return;this._doUpload(a.slice(n,s),n),s=(n=s)+i}else{this._fileupload.value="",window.clearInterval(e.enqueuer)}},100)}async _buildLocalValue(t,a=t.name,i=t){return this._localValue={name:a,size:i.size,type:t.type,lastModified:e.Utils.parseDate(t.lastModified).toISOString(),content:await this._blobToBase64(i)}}_canPick(){return"showDirectoryPicker"in window&&(()=>{try{return window.self===window.top}catch{return!1}})()}_tryPickDirectory(){this._canPick()&&window.showDirectoryPicker({mode:"read"}).then(e=>{this.changeHandler(new StoragePickEvent(e))})}_tryPickFiles(e="multiple-picker"===this.selectMode,t=this.pattern){this._canPick()&&window.showOpenFilePicker({multiple:e}).then(e=>{this.changeHandler(new StoragePickEvent(e))})}_clickHandler(t){if(e.avoidHandler(t),!this.readonly)switch(this.selectMode){case"directory-picker":this._tryPickDirectory();break;case"file-picker":case"multiple-picker":this._tryPickFiles()}}async _mimicCompute(){this.uploading=!0,e.Utils.isNullOrEmpty(this.value)?await e.Utils.idle(250):(this.percentage=0,await e.Utils.waitForAnimationEnd(this._tuner)),await this._tweener.run(0,100,500,0,e.Animations.Easings.sineInOut,(e,t)=>{this.percentage=t}),this.percentage=0,this.uploading=!1}onChange(t){return new Promise(async(i,n)=>{if(e.CustomEventUtils.isInstanceOf(t,FileUploadEvent)){const e=this.value=t.detail.filename;this.dispatchEvent(t),i(e)}else if(e.CustomEventUtils.isInstanceOf(t,StoragePickEvent)){let e,n,s,r=t.detail;switch(this.selectMode){case"directory-picker":e=r,this._stats=await a(e);break;case"multiple-picker":case"file-picker":s=r,1===s.length&&(r=s[0]),this._stats=await async function(e){const t={files:0,directories:0,size:0};for(let a of e){const e=await a.getFile();t.files++,t.size+=e.size}return t}(s);break;default:this._stats={directories:0,files:0,size:0}}i(this.value=this._localValue=r);const o=this._validateAll();this.dispatchEvent(new FileChangeEvent({directory:e,file:n,files:s,valid:o}))}else{let t=this._fileupload;if(0===t.files.length)this._stats={directories:0,files:0,size:0},i(this.value=null);else{const a=t.files.length;if(this._stats={directories:0,files:a,size:Array.from(t.files).reduce((e,t,a)=>e+t.size,0)},a>1){const e=Array.from(t.files);i(this.value=this._localValue=e);const a=this._validateAll();this.dispatchEvent(new FileChangeEvent({files:e,valid:a}))}else{const a=t.files[0],n=a.name;let s=a;this._validateSingleFile(a)||e.Utils.isNullOrEmpty(this.url)?(/\.(jpe?g|png)$/i.test(n)&&this.maxImageWidth>0&&this.maxImageHeight>0&&(s=await e.Utils.Images.resize(s,this.maxImageWidth,this.maxImageHeight,{quality:.8})),await this._buildLocalValue(a,n,s),e.Utils.isNullOrEmpty(this.url)?(await this._mimicCompute(),i(this.value=this._localValue)):(this._upload(s,t.value),i(this.value))):i(this.value=await this._buildLocalValue(a)),this.dispatchEvent(new FileChangeEvent({valid:!this.invalidFile,file:a}))}}}})}_fetch(t){return fetch(this.url,{method:"POST",credentials:this.fetchCredentials,headers:e.Utils.extend({Accept:"application/json","Content-Type":"application/json"},this.fetchHeaders||{}),body:JSON.stringify(t)})}async _undo(e){e.preventDefault(),e.stopPropagation();var t=this,a=t._fields,i=t._fileupload;clearInterval(a.enqueuer);var n={action:"undo",uid:a.uid};try{var s=await t._fetch(n);return s.ok&&(a.undone=!0,t.size=0,t._tweenPercentage(0,300)),s}catch(e){}finally{return i.value="",t.uploading=!1,s}}_tweenPercentage(t,a=500){const i=this.percentage;return this._tweener.run(i,t,a,0,e.Animations.Easings.sineInOut,(e,t)=>{this.percentage=t})}_retry(e){e.preventDefault(),e.stopPropagation(),this.failed=!1,this._manage()}_clear(e){e.preventDefault(),e.stopPropagation(),this.invalidFile=!1;const t=this.inputFields[0];t.value="",/safari/i.test(navigator.userAgent)||(t.type="",t.type="file"),this.changeHandler(null)}};__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Json})],i.prototype,"fetchCredentials",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String})],i.prototype,"fetchHeaders",void 0),__decorate([e.ViewChild("input[type=file]")],i.prototype,"_fileupload",void 0),__decorate([e.ViewChild(`${e.P}-tuner`)],i.prototype,"_tuner",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],i.prototype,"undoCaption",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],i.prototype,"retryCaption",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],i.prototype,"clearCaption",void 0),__decorate([e.Watch({emit:!1,reflectBack:!0,converter:e.PropertyConverters.String})],i.prototype,"pattern",void 0),__decorate([e.Watch({emit:!1,reflectBack:!0,converter:e.PropertyConverters.String})],i.prototype,"url",void 0),__decorate([e.Watch({emit:!1,reflectBack:!0,converter:e.PropertyConverters.Number})],i.prototype,"maxImageWidth",void 0),__decorate([e.Watch({emit:!1,reflectBack:!0,converter:e.PropertyConverters.Number})],i.prototype,"parallelism",void 0),__decorate([e.Watch({emit:!1,reflectBack:!0,converter:e.PropertyConverters.Number})],i.prototype,"chunkSize",void 0),__decorate([e.Watch({emit:!1,reflectBack:!0,converter:e.PropertyConverters.Number})],i.prototype,"maxImageHeight",void 0),__decorate([e.Watch({emit:!1,reflectBack:!0,converter:e.PropertyConverters.Number})],i.prototype,"maxSize",void 0),__decorate([e.Watch({reflectBack:!0,converter:e.PropertyConverters.String})],i.prototype,"selectMode",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Boolean})],i.prototype,"uploading",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Number})],i.prototype,"size",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Number})],i.prototype,"percentage",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Boolean})],i.prototype,"complete",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Boolean})],i.prototype,"failed",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Boolean})],i.prototype,"invalidFile",void 0),i=__decorate([e.CustomElement({tagName:e.P+"-upload",shadow:e.Defaults.USE_SHADOW_ROOT,template:`<${e.P}-button on-click=":host._dispatchDownload($event)" class="${e.PCSS}-upload ${e.PCSS}-viewfinder flat" css-class="{{ {'upload-chosen': !$pacem.isNullOrEmpty(:host.value) && !:host.uploading, 'upload-error': !$pacem.isNullOrEmpty(:host.value) && :host.invalidFile && $pacem.isNullOrEmpty(:host.url), 'upload-readonly': :host.readonly } }}">\n\n <${e.P}-panel class="upload-button" hide="{{ (:host.uploading || :host.failed) && !$pacem.isNullOrEmpty(:host.url) }}">\n <${e.P}-button tooltip="{{ :host.readonly ? :host.viewValue : 'upload' }}" class="button-circle pos-relative overflow-hidden"\n icon-glyph="{{ :host._getMimeIcon(:host.value, :host.uploading, :host.selectMode) }}"\n on-click=":host._clickHandler($event)"\n on-mouseover="$this.iconGlyph = :host._getMimeIcon(:host.readonly ? :host.value : '', :host.uploading, :host.selectMode)"\n on-mouseout="$this.iconGlyph = :host._getMimeIcon(:host.value, :host.uploading, :host.selectMode)"\n css-class="{{ {'${e.PCSS}-anim anim-rotate': :host.uploading, 'button-error': :host.invalidFile, 'button-primary': $pacem.isNullOrEmpty(:host.value) && !:host.invalidFile, 'button-success': !Pacem.Utils.isNullOrEmpty(:host.value) && !:host.invalidFile } }}">\n <input type="file" class="${e.PCSS}-transparent ${e.PCSS}-clickable pos-absolute absolute-left absolute-right absolute-top absolute-bottom" />\n </${e.P}-button>\n </${e.P}-panel>\n <${e.P}-panel class="upload-button" hide="{{ !:host.failed }}">\n <${e.P}-button class="button-circle button-flat" icon-glyph="refresh"\n tooltip="{{ :host.retryCaption }}" on-click=":host._retry($event)"><${e.P}-text text="{{ :host.retryCaption }}"></${e.P}-text></${e.P}-button>\n </${e.P}-panel>\n <${e.P}-panel class="upload-button" hide="{{ !:host.uploading || $pacem.isNullOrEmpty(:host.url) }}">\n <${e.P}-button class="button-circle button-flat" icon-glyph="clear" tooltip="{{ :host.undoCaption }}" \n on-click=":host._undo($event)"><${e.P}-text text="{{ :host.undoCaption }}"></${e.P}-text></${e.P}-button>\n </${e.P}-panel>\n\n <${e.P}-span tooltip="{{ :host.viewValue }}"\n hide="{{ $pacem.isNullOrEmpty(:host.value) || :host.uploading }}" class="upload-data readonly text-reset display-block ${e.PCSS}-anim text-truncate text-left ${e.PCSS}-pad pad-right-3" text="{{ :host.viewValue }}"></${e.P}-span>\n\n <${e.P}-panel class="upload-progress hit-none" hide="{{ :host.readonly || (!$pacem.isNullOrEmpty(:host.value) && !:host.uploading) }}">\n <${e.P}-tuner value="{{ :host.percentage }}" css-class="{{ {'tuner-success': !:host.invalidFile, 'tuner-error': :host.invalidFile} }}" interactive="false"></${e.P}-tuner>\n </${e.P}-panel>\n\n <${e.P}-button class="button-circle button-flat clear-button" icon-glyph="clear" hide="{{ $pacem.isNullOrEmpty(:host.value) || :host.uploading }}" tooltip="{{ :host.clearCaption }}" on-click=":host._clear($event)"></${e.P}-button>\n \n</${e.P}-button>`})],i),t.PacemUploadElement=i}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){let a=class PacemHiddenInputElement extends t.PacemTextualInputElement{constructor(){super()}toggleReadonlyView(e){}get inputFields(){return[this.input]}};__decorate([e.ViewChild("input[type=hidden]")],a.prototype,"input",void 0),a=__decorate([e.CustomElement({tagName:e.P+"-input-hidden",template:'<input type="hidden" />',shadow:e.Defaults.USE_SHADOW_ROOT})],a),t.PacemHiddenInputElement=a}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){const a=e.Utils.getUserMediaFunctions();let i;!function(e){e.Start="start",e.Taking="taking",e.Confirm="confirm"}(i=t.SnapshotStep||(t.SnapshotStep={}));class ConfirmSnapshotEvent extends e.CustomUIEvent{constructor(e){super("confirmsnapshot",{buffer:e})}}let n=class PacemSnapshotElement extends t.PacemBaseElement{constructor(){super(...arguments),this.step=i.Start,this._canUseWebcam=a.length>0,this._countdown=0,this._webcamInitialized=!1,this._grabberChangeHandler=t=>{const a=this._grabber;a.files.length>0&&e.Utils.blobToDataURL(a.files[0]).then(t=>{e.Utils.loadImage(t).then(e=>{this._shutter(e)})})},this._snapshooterClickHandler=t=>{e.avoidHandler(t),this.step=i.Taking},this._pickerClickHandler=t=>{e.avoidHandler(t),this._grabber.click()},this._takerClickHandler=t=>{e.avoidHandler(t),this._countdown=0,this._shutter()},this._timerClickHandler=t=>{e.avoidHandler(t),this._countdown=3,this._shutter()},this._confirmerClickHandler=t=>{e.avoidHandler(t),this.changeHandler(new ConfirmSnapshotEvent(this._buffer))}}get inputFields(){return[]}toggleReadonlyView(e){}onChange(t){return new Promise((a,n)=>{e.CustomEventUtils.isInstanceOf(t,ConfirmSnapshotEvent)?(a(this.value=t.detail.buffer),this.step=i.Start):a(this.value)})}acceptValue(e){this._renderValue(e)}getViewValue(e){return e}convertValueAttributeToProperty(t){return e.PropertyConverters.String.convert(t,this)}get _getUserMedia(){return this._canUseWebcam&&a[0]}propertyChangedCallback(e,t,a,n){switch(super.propertyChangedCallback(e,t,a,n),e){case"step":switch(a){case i.Start:this._buffer=null;const e=this._grabber;e.value="",/safari/i.test(navigator.userAgent)||(e.type="",e.type="file");break;case i.Taking:this._ensureWebcamRunning()}break;case"_buffer":this._renderValue(a||this.value);break;case"width":case"height":this._syncSize()}}viewActivatedCallback(){super.viewActivatedCallback(),this._syncSize(),this._picker.addEventListener("click",this._pickerClickHandler,!1),this._snapshooter.addEventListener("click",this._snapshooterClickHandler,!1),this._taker.addEventListener("click",this._takerClickHandler,!1),this._timer.addEventListener("click",this._timerClickHandler,!1),this._confirmer.addEventListener("click",this._confirmerClickHandler,!1),this._grabber.addEventListener("change",this._grabberChangeHandler,!1)}disconnectedCallback(){this.isReady&&(this._picker.removeEventListener("click",this._pickerClickHandler,!1),this._snapshooter.removeEventListener("click",this._snapshooterClickHandler,!1),this._taker.removeEventListener("click",this._takerClickHandler,!1),this._timer.removeEventListener("click",this._timerClickHandler,!1),this._confirmer.removeEventListener("click",this._confirmerClickHandler,!1),this._grabber.removeEventListener("change",this._grabberChangeHandler,!1)),super.disconnectedCallback()}_syncSize(){const t=this._stage,a=this._player;e.Utils.isNull(t)||e.Utils.isNull(a)||(t.style.width=a.style.width=this.width&&this.width+"px"||"",t.style.height=a.style.height=this.height&&this.height+"px"||"",this._renderValue(this._buffer||this.value))}_shutter(t){const a=this,i=this._player,n=this._stage;var s,r;if(a._confirmer.disabled=!0,e.Utils.isNull(t)&&(t=a._player),t instanceof HTMLVideoElement?(s=t.videoWidth,r=t.videoHeight):(s=t.naturalWidth,r=t.naturalHeight),a._countdown<=0){var o=document.createElement("canvas");o.width=this.width||n.clientWidth,o.height=this.height||n.clientHeight;var l=o.getContext("2d");e.Utils.cropImageOntoCanvas(t,l,s,r);let c=a._root;c.insertBefore(o,i),o.className="snapshot-brightout",setTimeout(function(){c.removeChild(o)},1e3),a._refreshBuffer(o.toDataURL()).then(e=>{a._setToBeConfirmed(e),a._confirmer.disabled=!1})}else setTimeout(()=>{a._countdown--,this._shutter()},1e3)}_renderValue(t=this.value){let a=this._stage;if(!e.Utils.isNull(a)){a.width=a.clientWidth,a.height=a.clientHeight;let i=a.getContext("2d");e.Utils.isNullOrEmpty(t)?i.clearRect(0,0,a.width,a.height):e.Utils.loadImage(t).then(t=>{e.Utils.cropImageOntoCanvas(t,i,t.width,t.height)})}}_setToBeConfirmed(e){this.step=i.Confirm,this._buffer=e}_refreshBuffer(t){var a=this._stage;let i;return a.width=a.clientWidth,a.height=a.clientHeight,this.quality>0&&(i=Math.min(1,Math.max(0,this.quality))),e.Utils.cropImage(t,a.width,a.height,i)}_ensureWebcamRunning(){if(this._canUseWebcam&&!this._webcamInitialized){var t=this;t._webcamInitialized=!0,t._getUserMedia.apply(navigator,[{video:!0},function(e){t._player.srcObject=e},function(a){t.log(e.Logging.LogLevel.Error,(a||a.message).toString())}])}}};__decorate([e.ViewChild("."+e.PCSS+"-snapshot")],n.prototype,"_root",void 0),__decorate([e.ViewChild("canvas")],n.prototype,"_stage",void 0),__decorate([e.ViewChild("input[type=file]")],n.prototype,"_grabber",void 0),__decorate([e.ViewChild("video")],n.prototype,"_player",void 0),__decorate([e.ViewChild(e.P+"-button.button.snapshot-upload")],n.prototype,"_picker",void 0),__decorate([e.ViewChild(e.P+"-button.button.snapshot-camera")],n.prototype,"_snapshooter",void 0),__decorate([e.ViewChild(e.P+"-button.button.snapshot-take")],n.prototype,"_taker",void 0),__decorate([e.ViewChild(e.P+"-button.button.snapshot-timer3s")],n.prototype,"_timer",void 0),__decorate([e.ViewChild(e.P+"-button.button.snapshot-confirm")],n.prototype,"_confirmer",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],n.prototype,"step",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Number})],n.prototype,"width",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Number})],n.prototype,"height",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Number})],n.prototype,"quality",void 0),__decorate([e.Watch()],n.prototype,"_countdown",void 0),__decorate([e.Watch({emit:!1})],n.prototype,"_buffer",void 0),n=__decorate([e.CustomElement({tagName:e.P+"-snapshot",shadow:e.Defaults.USE_SHADOW_ROOT,template:`<${e.P}-panel class="${e.PCSS}-snapshot" \ncss-class="{{ { \n'snapshot-start': :host.step === '${i.Start}',\n'snapshot-taking': :host.step === '${i.Taking}', \n'snapshot-confirm': :host.step === '${i.Confirm}' } }}">\n \n <canvas class="${e.PCSS}-viewfinder"></canvas>\n\n <video autoplay="autoplay"></video>\n\n <input type="file" accept="image/*" />\n\n <div class="${e.PCSS}-buttonset snapshot-step step-start">\n <div class="buttonset-center">\n <${e.P}-button class="button snapshot-upload" icon-glyph="upload"></${e.P}-button>\n <${e.P}-button class="button snapshot-camera" icon-glyph="photo_camera"></${e.P}-button> \n </div>\n </div>\n\n <div class="${e.PCSS}-buttonset snapshot-step step-taking">\n <div class="buttonset-center">\n <${e.P}-button class="button snapshot-undo" icon-glyph="undo" on-click=":host.step = '${i.Start}'"></${e.P}-button>\n <${e.P}-button class="button snapshot-take" icon-glyph="camera"></${e.P}-button>\n <${e.P}-button class="button snapshot-timer3s" icon-glyph="timer_3"></${e.P}-button>\n </div>\n </div>\n\n <div class="${e.PCSS}-buttonset snapshot-step step-confirm">\n <div class="buttonset-center">\n <${e.P}-button class="button snapshot-undo" icon-glyph="undo" on-click=":host.step = '${i.Start}'"></${e.P}-button>\n <${e.P}-button class="button snapshot-confirm" icon-glyph="done"></${e.P}-button>\n </div>\n </div>\n\n <${e.P}-span class="snapshot-countdown" text="{{ :host._countdown }}" hide="{{ :host.step !== '${i.Taking}' || !(:host._countdown > 0) }}"></${e.P}-span>\n <${e.P}-span hide="{{ :host._canUseWebcam }}"><${e.P}-content></${e.P}-content></${e.P}-span>\n\n</${e.P}-panel>`})],n),t.PacemSnapshotElement=n}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){let a=class PacemUrlInputElement extends t.PacemTextualInputElement{constructor(){super()}toggleReadonlyView(e){this.input.hidden=e,this.anchor.hidden=!e}get inputFields(){return[this.input]}};__decorate([e.ViewChild("input[type=url]")],a.prototype,"input",void 0),__decorate([e.ViewChild(e.P+"-a")],a.prototype,"anchor",void 0),a=__decorate([e.CustomElement({tagName:e.P+"-input-url",template:`<input type="url" class="${e.PCSS}-input" />${t.CHAR_COUNTER_CHILD}<${e.P}-a class="${e.PCSS}-readonly" disabled="{{ $pacem.isNullOrEmpty(:host.value) }}" href="{{ :host.value }}" target="_blank"><${e.P}-text text="{{ :host.viewValue }}"></${e.P}-text></${e.P}-a>`,shadow:e.Defaults.USE_SHADOW_ROOT})],a),t.PacemUrlInputElement=a}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(a){a.Picture=class Picture{},a.ImageFetchRequestEventName="imagefetchrequest";class ImageFetchRequestEvent extends e.CustomTypedEvent{constructor(e){super(a.ImageFetchRequestEventName,e,{bubbles:!0})}}a.ImageFetchRequestEvent=ImageFetchRequestEvent;let i=class PacemEditImageElement extends t.PacemElement{constructor(){super(...arguments),this._index=0,this.hint=""}_uploaderPropertyChangedCallback(e){const t=e.detail.currentValue;switch(e.detail.propertyName){case"percentage":this._progressbar.percentage=100*t;break;case"uploading":t&&this._done(!0)}}_thumbnailUploaderPropertyChangedCallback(e){const t=e.detail.currentValue;switch(e.detail.propertyName){case"percentage":this._progressbar.percentage=100*t;break;case"uploading":this._done(t)}}_uploaderFileUploadCallback(t){const a=this._uploader,i=this._thumbUploader,n=i.maxImageWidth,s=i.maxImageHeight;if(n>0&&s>0){var r=a.blob;const o=t.detail.uid;e.Utils.resizeImage(r,n,s).then(e=>{e==r?this._done(!1):i.upload(e,"thumbnail.jpg",o)})}else this._done(!1)}_done(e){e||this._imagefetch(0),this._repeater.hidden=e,this._progressbar.hidden=!e}_snapshotPropertyChangedCallback(t){if("value"===t.detail.propertyName){const a=e.Utils.dataURLToBlob(t.detail.currentValue);this._uploader.upload(a,"snapshot.jpg")}}reset(){this._snapshot.step=a.SnapshotStep.Start}propertyChangedCallback(t,a,i,n){switch(super.propertyChangedCallback(t,a,i,n),t){case"imageSet":let t=i||{skip:0,set:[]};e.Utils.isNullOrEmpty(this._images)||0===t.skip?this._images=t.set:e.Utils.isNull(this._images)||Array.prototype.splice.apply(this._images,[t.skip,this._images.length-t.skip].concat(t.set)),this._fetching=!1;break;case"hint":n||this._imagefetch(0)}}_imagefetchSuddenly(e){this._fetching=!0,this._imagefetch(e)}_imagefetch(e){e>=0||(e=this._images&&this._images.length||0),this.dispatchEvent(new ImageFetchRequestEvent({hint:this.hint,skip:e,take:18}))}};__decorate([e.Watch({converter:e.PropertyConverters.String})],i.prototype,"uploadUrl",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],i.prototype,"hint",void 0),__decorate([e.Watch()],i.prototype,"imageSet",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],i.prototype,"value",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Number})],i.prototype,"maxWidth",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Number})],i.prototype,"maxHeight",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Number})],i.prototype,"maxThumbnailWidth",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Number})],i.prototype,"maxThumbnailHeight",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Boolean})],i.prototype,"allowSnapshot",void 0),__decorate([e.Watch()],i.prototype,"_fetching",void 0),__decorate([e.Watch()],i.prototype,"_images",void 0),__decorate([e.ViewChild(e.P+"-repeater")],i.prototype,"_repeater",void 0),__decorate([e.ViewChild(e.P+"-upload[main]")],i.prototype,"_uploader",void 0),__decorate([e.ViewChild(e.P+"-upload[thumb]")],i.prototype,"_thumbUploader",void 0),__decorate([e.ViewChild(e.P+"-snapshot")],i.prototype,"_snapshot",void 0),__decorate([e.ViewChild(e.P+"-progressbar")],i.prototype,"_progressbar",void 0),__decorate([e.Debounce(500)],i.prototype,"_imagefetch",null),i=__decorate([e.CustomElement({tagName:e.P+"-edit-image",shadow:e.Defaults.USE_SHADOW_ROOT,template:`<${e.P}-panel class="${e.PCSS}-edit-image"\n css-class="{{ {'${e.PCSS}-snapshot': ::_snapshot.step != '${a.SnapshotStep.Start}', '${e.PCSS}-uploading': ::_uploader.uploading, '${e.PCSS}-upload-enabled': !Pacem.Utils.isNullOrEmpty(:host.uploadUrl), '${e.PCSS}-snapshot-enabled': !Pacem.Utils.isNullOrEmpty(:host.uploadUrl) && :host.allowSnapshot} }}">\n <div>\n <${e.P}-input-search value="{{ :host.hint, twoway }}"></${e.P}-input-search>\n <${e.P}-upload main pattern=".+.(jpe?g|png|svg|ico)$" url="{{ :host.uploadUrl }}"\n max-image-width="{{ :host.maxWidth }}" max-image-height="{{ :host.maxHeight }}"\n on-${a.FileUploadEventName}=":host._uploaderFileUploadCallback($event)"\n on-${e.PropertyChangeEventName}=":host._uploaderPropertyChangedCallback($event)" hide="{{ Pacem.Utils.isNullOrEmpty(:host.uploadUrl) || ::_thumbUploader.uploading }}"></${e.P}-upload>\n <${e.P}-upload thumb pattern=".+.(jpe?g|png|svg|ico)$" url="{{ :host.uploadUrl }}" hide="{{ !::_thumbUploader.uploading }}"\n max-image-width="{{ :host.maxThumbnailWidth }}" max-image-height="{{ :host.maxThumbnailHeight }}"\n on-${e.PropertyChangeEventName}=":host._thumbnailUploaderPropertyChangedCallback($event)"></${e.P}-upload>\n <${e.P}-button class="${e.PCSS}-snapshot" on-click="Pacem.avoidHandler($event); ::_snapshot.step = '${a.SnapshotStep.Taking}'" hide="{{ Pacem.Utils.isNullOrEmpty(:host.uploadUrl) || !:host.allowSnapshot }}"></${e.P}-button>\n <${e.P}-infinite-scroller container="{{ ::_repeater }}" on-fetchmore=":host._imagefetchSuddenly()" disabled="{{ :host._fetching || :host.disabled || :host._images.length >= :host.imageSet.total }}"></${e.P}-infinite-scroller>\n <${e.P}-repeater datasource="{{ :host._images }}">\n <template>\n <${e.P}-img css-class="{{ {'${e.PCSS}-selected': ^item.src === :host.value } }}" on-click=":host.value = ^item.src" src="{{ ^item.thumb }}" adapt="contain"></${e.P}-img>\n </template>\n </${e.P}-repeater>\n <${e.P}-progressbar class="progressbar-smaller progressbar-accent" caption="{{ ::_thumbUploader.uploading ? 'thumbnail...' : 'uploading...' }}"></${e.P}-progressbar>\n </div>\n <div>\n <${e.P}-snapshot hide="{{ !:host.allowSnapshot }}" on-${e.PropertyChangeEventName}=":host._snapshotPropertyChangedCallback($event)"></${e.P}-snapshot>\n </div>\n </${e.P}-panel>`})],i),a.PacemEditImageElement=i;let n=class PacemImageInputElement extends a.PacemBaseElement{constructor(){super(...arguments),this._broadcastFetchRequestEventName=e=>{this.dispatchEvent(new ImageFetchRequestEvent(e.detail))},this._innerValueChangedHandler=t=>{"value"!==t.detail.propertyName||e.Utils.isNull(this._dialog)||(this._dialog.state=t.detail.currentValue)}}convertValueAttributeToProperty(e){return e}getViewValue(e){return e}get inputFields(){return[]}_clear(e){this.changeHandler(e)}onChange(a){let i=this.value;return e.CustomEventUtils.isInstanceOf(a,t.UI.DialogResultEvent)&&a.detail.button===t.UI.DialogButton.Ok?i=this.value=a.detail.state:a.target===this._input?i=this.value=this._input.value:a.target===this._clearBtn&&(i=this.value=void 0),e.Utils.fromResult(i)}toggleReadonlyView(e){this._input.hidden=this._editBtn.hide=this._clearBtn.hide=e}_addDialog(){var a=document.createElement(e.P+"-dialog");return a.buttons=t.UI.DialogButtons.OkCancel,a.addEventListener(t.UI.DialogResultEventName,this.changeHandler,!1),a.appendChild(this._addEditImage()),document.body.appendChild(a),this._dialog=a}_removeDialog(){this._removeEditImage(),e.Utils.isNull(this._dialog)||(this._dialog.removeEventListener(t.UI.DialogResultEventName,this.changeHandler,!1),this._dialog.remove())}_addEditImage(){var t=document.createElement(e.P+"-edit-image");return t.disabled=!0,t.addEventListener(e.PropertyChangeEventName,this._innerValueChangedHandler,!1),t.addEventListener(a.ImageFetchRequestEventName,this._broadcastFetchRequestEventName,!1),t.uploadUrl=this.uploadUrl,t.allowSnapshot=this.allowSnapshot,t.maxWidth=this.maxWidth,t.maxHeight=this.maxHeight,t.maxThumbnailHeight=this.maxThumbnailHeight,t.maxThumbnailWidth=this.maxThumbnailWidth,this._editImage=t}_removeEditImage(){e.Utils.isNull(this._editImage)||(this._editImage.removeEventListener(e.PropertyChangeEventName,this._innerValueChangedHandler,!1),this._editImage.removeEventListener(a.ImageFetchRequestEventName,this._broadcastFetchRequestEventName,!1))}connectedCallback(){super.connectedCallback(),this._addDialog()}disconnectedCallback(){this._removeDialog(),super.disconnectedCallback()}propertyChangedCallback(t,a,i,n){switch(super.propertyChangedCallback(t,a,i,n),t){case"uploadUrl":e.Utils.isNull(this._editImage)||(this._editImage.uploadUrl=i);break;case"allowSnapshot":e.Utils.isNull(this._editImage)||(this._editImage.allowSnapshot=i);break;case"imageSet":e.Utils.isNull(this._editImage)||(this._editImage.imageSet=i);break;case"maxThumbnailHeight":e.Utils.isNull(this._editImage)||(this._editImage.maxThumbnailHeight=i);break;case"maxThumbnailWidth":e.Utils.isNull(this._editImage)||(this._editImage.maxThumbnailWidth=i);break;case"maxHeight":e.Utils.isNull(this._editImage)||(this._editImage.maxHeight=i);break;case"maxWidth":e.Utils.isNull(this._editImage)||(this._editImage.maxWidth=i)}}acceptValue(t){e.Utils.isNull(this._editImage)||(this._editImage.value=t)}_update(e){this._image.src=e}_retrieve(){return this.value}_edit(a){e.avoidHandler(a);var i=this._editImage,n=this.value;i.disabled=!1,i.reset(),i.value=n,this._dialog.open(n).then(e=>{switch(e.button){case t.UI.DialogButton.Cancel:this._update(this.value);break;case t.UI.DialogButton.Ok:this._update(e.state)}this._editImage.disabled=!0})}};__decorate([e.ViewChild(e.P+"-img")],n.prototype,"_image",void 0),__decorate([e.ViewChild(e.P+"-button."+e.PCSS+"-edit")],n.prototype,"_editBtn",void 0),__decorate([e.ViewChild(e.P+"-button."+e.PCSS+"-clear")],n.prototype,"_clearBtn",void 0),__decorate([e.ViewChild(e.P+"-input-url")],n.prototype,"_input",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String})],n.prototype,"uploadUrl",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Json})],n.prototype,"imageSet",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Number})],n.prototype,"maxWidth",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Number})],n.prototype,"maxHeight",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Number})],n.prototype,"maxThumbnailWidth",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Number})],n.prototype,"maxThumbnailHeight",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Boolean})],n.prototype,"allowSnapshot",void 0),n=__decorate([e.CustomElement({tagName:e.P+"-input-image",shadow:e.Defaults.USE_SHADOW_ROOT,template:`<div class="${e.PCSS}-input-image"><${e.P}-img src="{{ :host.value }}" adapt="contain"></${e.P}-img><div class="${e.PCSS}-input-image-dashboard">\n <${e.P}-button on-click=":host._edit($event)" hide="{{ :host.disabled }}" class="${e.PCSS}-edit">Edit</${e.P}-button>\n <${e.P}-button on-click=":host._clear($event)" hide="{{ :host.disabled }}" class="${e.PCSS}-clear">Clear</${e.P}-button>\n</div><${e.P}-input-url placeholder="{{ :host.placeholder }}" on-change=":host.changeHandler($event)" value="{{ :host.value }}"></${e.P}-input-url>\n\n <${e.P}-panel hide="{{ Pacem.Utils.isNullOrEmpty(:host.value) }}">\n <dl class="${e.PCSS}-input-image-preview">\n <dt>dimensions:</dt><dd><${e.P}-text text="{{ ::_image.size.width +'x'+ ::_image.size.height }}"></${e.P}-text></dd>\n <dt>size:</dt><dd><${e.P}-text text="{{ $pacem.size(::_image.size.weight) }}"></${e.P}-text></dd>\n </dl></${e.P}-panel>\n\n</div>`})],n),a.PacemImageInputElement=n}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){let a=class PacemNumberInputElement extends t.PacemOrdinalInputElement{toggleReadonlyView(e){this._span.hidden=!e,this._input.hidden=e}get inputFields(){return[this._input]}getViewValue(e){return null!=this.value?this._format(this.value):void 0}_format(t=this.value){const a=this.format;return e.Utils.isNullOrEmpty(a)?t.toString():new Intl.NumberFormat(e.Utils.lang(this),a).format(t)}getValue(e){const t=this.inputField.valueAsNumber||parseFloat(this.inputField.value);return isNaN(t)?void 0:t}viewActivatedCallback(){super.viewActivatedCallback();this._input.addEventListener("wheel",this.emitHandler,{capture:!1,passive:!1})}disconnectedCallback(){if(!e.Utils.isNull(this._input)){this._input.removeEventListener("wheel",this.emitHandler,{capture:!1,passive:!1})}super.disconnectedCallback()}};__decorate([e.ViewChild("input[type=number]")],a.prototype,"_input",void 0),__decorate([e.ViewChild(`span.${e.PCSS}-readonly`)],a.prototype,"_span",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Json})],a.prototype,"format",void 0),a=__decorate([e.CustomElement({tagName:e.P+"-input-number",template:`<input type="number" class="${e.PCSS}-input ${e.PCSS}-viewfinder" /><span class="${e.PCSS}-readonly"><${e.P}-text text="{{ :host.viewValue }}"></${e.P}-text></span>`,shadow:e.Defaults.USE_SHADOW_ROOT})],a),t.PacemNumberInputElement=a}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){let a=class PacemPasswordInputElement extends t.PacemTextualInputElement{constructor(){super(),this._togglerMousedownHandler=t=>{0==t.button&&(e.avoidHandler(t),this.toggleVisibility())}}get inputFields(){return[this._input]}viewActivatedCallback(){super.viewActivatedCallback();const t=this.id??"_"+e.Utils.uniqueCode(),a=this._input.id=t+"_ctrl";this._toggler.setAttribute("aria-controls",a),this._toggler.setAttribute("role","button"),this._syncToggler(),this._toggler.addEventListener("mousedown",this._togglerMousedownHandler,!1)}disconnectedCallback(){e.Utils.isNull(this._toggler)||this._toggler.removeEventListener("mousedown",this._togglerMousedownHandler,!1)}toggleVisibility(){const e=this._input.type;this._input.type="password"===e?"text":"password",this._syncToggler()}_syncToggler(){const e="password"===this._input.type;this._toggler.innerText=e?"visibility_off":"visibility",this._toggler.setAttribute("aria-expanded",(!e).toString())}toggleReadonlyView(e){this._input.hidden=this._toggler.hidden=e,this._span.hidden=!e}getViewValue(t){return e.Utils.leftPad("",Math.floor(8+3*Math.random()),"•")}};__decorate([e.ViewChild("input[type=password]")],a.prototype,"_input",void 0),__decorate([e.ViewChild(`span.${e.PCSS}-readonly`)],a.prototype,"_span",void 0),__decorate([e.ViewChild(`i.${e.PCSS}-icon.${e.PCSS}-clickable`)],a.prototype,"_toggler",void 0),a=__decorate([e.CustomElement({tagName:e.P+"-input-password",template:`<input type="password" class="${e.PCSS}-input ${e.PCSS}-viewfinder" /><i class="${e.PCSS}-icon ${e.PCSS}-clickable"></i>\n${t.CHAR_COUNTER_CHILD}<span class="${e.PCSS}-readonly"><${e.P}-text text="{{ :host.viewValue }}"></${e.P}-text></span>`,shadow:e.Defaults.USE_SHADOW_ROOT})],a),t.PacemPasswordInputElement=a}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){let a=class PacemSearchInputElement extends t.PacemTextualInputElement{constructor(){super()}get inputFields(){return[this.input]}toggleReadonlyView(e){}};__decorate([e.ViewChild("input[type=search]")],a.prototype,"input",void 0),a=__decorate([e.CustomElement({tagName:e.P+"-input-search",template:'<input type="search" class="'+e.PCSS+'-input" />',shadow:e.Defaults.USE_SHADOW_ROOT})],a),t.PacemSearchInputElement=a}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){let a=class PacemTelInputElement extends t.PacemTextualInputElement{constructor(){super()}toggleReadonlyView(e){this.input.hidden=e,this.anchor.hidden=!e}get inputFields(){return[this.input]}};__decorate([e.ViewChild("input[type=tel]")],a.prototype,"input",void 0),__decorate([e.ViewChild(e.P+"-a")],a.prototype,"anchor",void 0),a=__decorate([e.CustomElement({tagName:e.P+"-input-tel",template:`<input type="tel" class="${e.PCSS}-input" /><${e.P}-a class="${e.PCSS}-readonly" disabled="{{ $pacem.isNullOrEmpty(:host.value) }}" href="{{ 'tel:'+ :host.value }}"><${e.P}-text text="{{ :host.viewValue }}"></${e.P}-text></${e.P}-a>`,shadow:e.Defaults.USE_SHADOW_ROOT})],a),t.PacemTelInputElement=a}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){let a=class PacemTextInputElement extends t.PacemTextualInputElement{constructor(){super()}toggleReadonlyView(e){this._span.hidden=!e,this._input.hidden=e}get inputFields(){return[this._input]}};__decorate([e.ViewChild("input[type=text]")],a.prototype,"_input",void 0),__decorate([e.ViewChild("span."+e.PCSS+"-readonly")],a.prototype,"_span",void 0),a=__decorate([e.CustomElement({tagName:e.P+"-input-text",template:`<input type="text" class="${e.PCSS}-input" />${t.CHAR_COUNTER_CHILD}<span class="${e.PCSS}-readonly"><${e.P}-text text="{{ :host.viewValue }}"></${e.P}-text></span>`,shadow:e.Defaults.USE_SHADOW_ROOT})],a),t.PacemTextInputElement=a}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){t.DEFAULT_TILES="",t.DEFAULT_ATTRIBUTION="";let a=class PacemLatLngElement extends t.PacemBaseElement{convertValueAttributeToProperty(e){const t=/^\s*([+-]?\d+\.?\d+)[,\s]\s*([+-]?\d+\.?\d+)\s*$/.exec(e);if(t&&3===t.length)return{lat:parseFloat(t[1]),lng:parseFloat(t[2])};throw`Invalid coordinates format for "${e}"`}compareValuePropertyValues(e,t){return!(!e||"number"!=typeof e.lat||"number"!=typeof e.lng||!t||"number"!=typeof t.lat||"number"!=typeof t.lng)&&(e.lat===t.lat&&e.lng===t.lng)}getViewValue(e){return this._getViewValue(e)}_getViewValue(e,t=8){return e&&"number"==typeof e.lat&&"number"==typeof e.lng&&e.lat.toFixed(t)+","+e.lng.toFixed(t)||""}get inputFields(){return[this._latInput,this._lngInput]}toggleReadonlyView(e){this._inputContainer.hidden=e}acceptValue(e){let t=this._ensureValue(e);this._lat=t.lat,this._lng=t.lng}_ensureValue(t){return t&&"number"==typeof t.lat&&"number"==typeof t.lng?t:e.Components.Maps.MapConsts.DEFAULT_COORDS}onChange(t){if(t&&"dragend"===t.type){var a=t;this._lat=a.detail.position.lat,this._lng=a.detail.position.lng}const i=this._lat,n=this._lng;return e.Utils.isNull(i)||e.Utils.isNull(n)?e.Utils.fromResult(this.value):e.Utils.fromResult(this.value={lat:i,lng:n})}propertyChangedCallback(t,a,i,n){if(super.propertyChangedCallback(t,a,i,n),"options"===t&&!n){const t=e.Utils.clone(i||{provider:"osm"});this._synchronizeOptions(t)}}viewActivatedCallback(){super.viewActivatedCallback(),this._synchronizeOptions()}_synchronizeOptions(t=this.options||{provider:"osm"}){const a=this._marker,i=this._map;switch(a.icon=t.icon,t&&t.provider){case"azure":this._azureAdapter.subscriptionKey=t.apiKey,i.adapter=this._azureAdapter;break;case"google":case"gmaps":this._googleAdapter.apiKey=t.apiKey,i.adapter=this._googleAdapter;break;default:e.Utils.isNullOrEmpty(t.attribution)||(this._leafletAdapter.attribution=t.attribution),e.Utils.isNullOrEmpty(t.tiles)||(this._leafletAdapter.tiles=t.tiles),i.adapter=this._leafletAdapter}delete t.provider,delete t.icon,delete t.apiKey,delete t.attribution,delete t.tiles;for(let e in t)e in i&&(i[e]=t[e])}};__decorate([e.ViewChild(e.P+"-map-adapter-leaflet")],a.prototype,"_leafletAdapter",void 0),__decorate([e.ViewChild(e.P+"-map-adapter-azure")],a.prototype,"_azureAdapter",void 0),__decorate([e.ViewChild(e.P+"-map-adapter-google")],a.prototype,"_googleAdapter",void 0),__decorate([e.ViewChild(e.P+"-map")],a.prototype,"_map",void 0),__decorate([e.ViewChild(e.P+"-map-marker")],a.prototype,"_marker",void 0),__decorate([e.ViewChild(e.P+"-input-number:nth-child(1)")],a.prototype,"_latInput",void 0),__decorate([e.ViewChild(e.P+"-input-number:nth-child(2)")],a.prototype,"_lngInput",void 0),__decorate([e.ViewChild(`.${e.PCSS}-latlng-fields`)],a.prototype,"_inputContainer",void 0),__decorate([e.ViewChild(e.P+"-fetch")],a.prototype,"_fetcher",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Json,emit:!1})],a.prototype,"options",void 0),__decorate([e.Watch()],a.prototype,"_lat",void 0),__decorate([e.Watch()],a.prototype,"_lng",void 0),a=__decorate([e.CustomElement({tagName:e.P+"-latlng",shadow:e.Defaults.USE_SHADOW_ROOT,template:`<div class="${e.PCSS}-latlng">\n <div class="${e.PCSS}-latlng-fields ${e.PCSS}-viewfinder">\n <${e.P}-input-number class="${e.PCSS}-lat" value="{{ :host._lat, twoway }}" min="-90" max="90" step="{{ 'any' }}"></${e.P}-input-number>\n <${e.P}-input-number class="${e.PCSS}-lng" value="{{ :host._lng, twoway }}" min="-180" max="180" step="{{ 'any' }}"></${e.P}-input-number>\n </div>\n <${e.P}-panel hide="{{ Pacem.Utils.isNull(:host.value) || :host.readonly }}">\n <dl class="${e.PCSS}-latlng-preview">\n <dt>decimals:</dt><dd><${e.P}-text text="{{ :host._getViewValue(:host.value, 12) }}"></${e.P}-text></dd>\n <dt>address:</dt><dd><${e.P}-text text="{{ ::_fetcher.result.display_name || '?' }}"></${e.P}-text></dd>\n <dt>degrees:</dt><dd><${e.P}-span css-class="{{ {'${e.PCSS}-lat-north': :host._lat > 0, '${e.PCSS}-lat-south': :host._lat < 0} }}" content="{{ $pacem.decToDeg(Math.abs(:host._lat)) }}"></${e.P}-span>,\n <${e.P}-span css-class="{{ {'${e.PCSS}-lng-east': :host._lng > 0, '${e.PCSS}-lng-west': :host._lng < 0} }}" content="{{ $pacem.decToDeg(Math.abs(:host._lng)) }}"></${e.P}-span></dd>\n </dl>\n </${e.P}-panel>\n <${e.P}-span class="${e.PCSS}-readonly" hide="{{ !:host.readonly }}" content="{{ :host.viewValue + ($pacem.isNullOrEmpty(::_fetcher.result.display_name) ? '' : (' <small>'+ ::_fetcher.result.display_name +'</small>')) }}"></${e.P}-span>\n\n <${e.P}-map-adapter-leaflet></${e.P}-map-adapter-leaflet>\n <${e.P}-map-adapter-azure></${e.P}-map-adapter-azure>\n <${e.P}-map-adapter-google></${e.P}-map-adapter-google>\n\n <${e.P}-map adapter="{{ ::_adapter }}">\n <${e.P}-map-marker position="{{ :host._ensureValue(:host.value) }}" on-dragend=":host.changeHandler($event)" draggable="{{ !:host.readonly }}"></${e.P}-map-marker>\n </${e.P}-map>\n <${e.P}-fetch disabled="{{ $pacem.isNull(:host.value) }}" parameters="{{ { format: 'json', lat: :host._lat, lon: :host._lng } }}" url="https://nominatim.openstreetmap.org/reverse"></${e.P}-fetch>\n</div>`})],a),t.PacemLatLngElement=a}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){const a=`change-policy="${t.ChangePolicy.Blur}" readonly="{{ :host.readonly }}"`;function i(t){return e.Utils.isNullOrEmpty(t&&t.name)}let n=class PacemNameValueListElement extends t.PacemBaseElement{constructor(){super(...arguments),this.inputFields=[],this._bag=[]}toggleReadonlyView(e){}onChange(e){return new Promise((e,t)=>{let a=this._bagToValue(this._bag);this.compareValuePropertyValues(a,this.value)?t():e(this.value=a)})}acceptValue(e){this._bag=this._valueToBag(e)}getViewValue(e){return""}compareValuePropertyValues(t,a){return e.Utils.Json.stringify(t)===e.Utils.Json.stringify(a)}convertValueAttributeToProperty(t){return e.PropertyConverters.Json.convert(t)}propertyChangedCallback(e,t,a,i){super.propertyChangedCallback(e,t,a,i),"dictionary"!==e||i||(this.value=this._bagToValue())}_bagToValue(e=this._bag){if(!this.dictionary){let t=[];for(let a of e||[])i(a)||t.find(e=>e.name===a.name&&e.value===a.value)||t.push(a);return t}let t={};for(let a of e||[])a.name in t||(t[a.name]=a.value);return t}_valueToBag(t=this.value){const a=[];if(!e.Utils.isNullOrEmpty(t)&&"object"==typeof t)if(this.dictionary&&!e.Utils.isArray(t))for(let e in t)a.push({name:e,value:t[e]});else!this.dictionary&&e.Utils.isArray(t)&&Array.prototype.splice.apply(a,[0,0].concat(t.map(t=>e.Utils.clone(t))));return e.Utils.isNullOrEmpty(a)?[{name:"",value:""}]:a}_deleteAt(e){this._bag.splice(e.detail,1),this.changeHandler(e)}_addItem(t){const a=this._bag,n=this._bag[this._bag.length-1];!e.Utils.isEmpty(a)&&i(n)||a.push({name:"",value:""})}};__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Boolean})],n.prototype,"dictionary",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Json})],n.prototype,"_bag",void 0),n=__decorate([e.CustomElement({tagName:e.P+"-namevalue-list",shadow:e.Defaults.USE_SHADOW_ROOT,template:`<${e.P}-repeater datasource="{{ :host._bag }}" on-itemdelete=":host._deleteAt($event)">\n <template>\n <div class="${e.PCSS}-fieldset ${e.PCSS}-margin margin-bottom-1">\n <div class="fieldset-auto">\n <div class="${e.PCSS}-fieldgroup">\n <${e.P}-input-text ${a} value="{{ ^item.name, twoway }}" on-change=":host.changeHandler($event)"></${e.P}-input-text>\n <div class="fieldgroup-prepend"></div>\n </div>\n <div class="${e.PCSS}-fieldgroup">\n <${e.P}-input-text ${a} value="{{ ^item.value, twoway }}" on-change=":host.changeHandler($event)"></${e.P}-input-text>\n <div class="fieldgroup-append">\n <${e.P}-button class="${e.PCSS}-cell cols-2 flat delete" hide="{{ :host.readonly }}" command-name="delete" command-argument="{{ ^index }}"></${e.P}-button>\n </div>\n </div>\n </div>\n </div>\n </template>\n <${e.P}-button class="flat add" hide="{{ :host.readonly }}" on-click=":host._addItem($event)"></${e.P}-button>\n</${e.P}-repeater>`})],n),t.PacemNameValueListElement=n}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){let a=class PacemPropertyPickerElement extends t.PacemBaseElement{get inputFields(){return[this._select]}toggleReadonlyView(e){this._select.readonly=e}onChange(t){return e.Utils.fromResult(this.value=this._select.value)}acceptValue(e){this._select.value=e}getViewValue(e){return this._select.viewValue}convertValueAttributeToProperty(t){return e.PropertyConverters.Element.convert(t)}viewActivatedCallback(){super.viewActivatedCallback(),this._databind()}propertyChangedCallback(e,t,a,i){if(super.propertyChangedCallback(e,t,a,i),!i&&"target"===e)this._databind()}_databind(){const t=[],a=(i,n,s)=>{const r=i[n];if("object"==typeof r&&null!=r&&!e.Utils.isArray(r))for(let e of Object.keys(r)){const i=s+"."+e;t.push(i),a(r,e,i)}};let i=this.target;if(!e.Utils.isNull(i)){let n=e.CustomElementUtils.getWatchedProperties(i);for(let e of n){let n=e.name;t.push(n),a(i,n,n)}}this._select.datasource=t.sort()}};__decorate([e.ViewChild(e.P+"-select")],a.prototype,"_select",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Element})],a.prototype,"target",void 0),a=__decorate([e.CustomElement({tagName:e.P+"-property-picker",shadow:e.Defaults.USE_SHADOW_ROOT,template:`<${e.P}-select></${e.P}-select>`})],a),t.PacemPropertyPickerElement=a}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){let a=class PacemRadioListElement extends t.PacemDataSourceElement{acceptValue(e){}constructor(){super(),this.key="_"+e.Utils.uniqueCode()}get inputFields(){return[]}propertyChangedCallback(e,t,a,i){super.propertyChangedCallback(e,t,a,i),"disabled"===e&&(this._disable.model=a)}viewActivatedCallback(){super.viewActivatedCallback(),this._disable.model=this.disabled}toggleReadonlyView(e){this._repeater.hidden=e,this._span.hidden=!e}_selectionChanged(e,t,a){"selected"===e.detail.propertyName&&!0===e.detail.currentValue&&(this._selectedValue=this.mapEntityToValue(this.datasource[t]),this.changeHandler(e))}onChange(t){return this.value=this._selectedValue,this.databind(),e.Utils.fromResult(this._selectedValue)}};__decorate([e.ViewChild(e.P+"-repeater")],a.prototype,"_repeater",void 0),__decorate([e.ViewChild(e.P+"-data")],a.prototype,"_disable",void 0),__decorate([e.ViewChild(`span.${e.PCSS}-readonly`)],a.prototype,"_span",void 0),a=__decorate([e.CustomElement({tagName:e.P+"-radio-list",template:`<${e.P}-repeater datasource="{{ :host.adaptedDatasource }}">\n <ol class="${e.PCSS}-radio-list ${e.PCSS}-viewfinder" pacem>\n <template>\n <li><${e.P}-radio disabled="{{ ::_disable.model || ^item.disabled }}" name="{{ :host.key, once }}" autobind="off" caption="{{ ^item.viewValue }}" value="{{ ^item.value }}" selected="{{ :host.isDataSourceItemSelected(^item, :host.value) }}"\non-focus=":host.focusHandler($event)" on-blur=":host.focusHandler($event)"\non-${e.PropertyChangeEventName}=":host._selectionChanged($event, ^index, ^item)"></${e.P}-radio></li>\n </template>\n </ol>\n</${e.P}-repeater><span class="${e.PCSS}-readonly ${e.PCSS}-radio"><${e.P}-text text="{{ :host.viewValue }}"></${e.P}-text></span><${e.P}-data></${e.P}-data><${e.P}-content></${e.P}-content>`,shadow:e.Defaults.USE_SHADOW_ROOT})],a),t.PacemRadioListElement=a}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){let a=class PacemRadioElement extends t.PacemBaseElement{convertValueAttributeToProperty(e){return e}constructor(){super(),this._key="_"+e.Utils.uniqueCode()}toggleReadonlyView(e){this.span.hidden=!e,this._radio.hidden=e}get inputFields(){return[this._radio]}onChange(t){this.selected=this._radio.checked;const a=this.selected?this._radio.value:void 0;return e.Utils.fromResult(a)}viewActivatedCallback(){super.viewActivatedCallback(),this._radio.id=this._label.htmlFor=this._key}propertyChangedCallback(t,a,i,n){switch(super.propertyChangedCallback(t,a,i,n),t){case"name":this._radio.name=i;break;case"selected":(this._radio.checked=i)?e.Utils.addClass(this,e.PCSS+"-selected"):e.Utils.removeClass(this,e.PCSS+"-selected")}}acceptValue(t){this._radio.value=e.Utils.isNullOrEmpty(t)?"":t}getViewValue(t){return e.Utils.isNull(t)?"":this.caption}};__decorate([e.ViewChild("input[type=radio]")],a.prototype,"_radio",void 0),__decorate([e.ViewChild("label")],a.prototype,"_label",void 0),__decorate([e.ViewChild(`.${e.PCSS}-readonly`)],a.prototype,"span",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],a.prototype,"caption",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Boolean})],a.prototype,"selected",void 0),a=__decorate([e.CustomElement({tagName:e.P+"-radio",template:`<${e.P}-span class="${e.PCSS}-readonly ${e.PCSS}-radio" text="{{ :host.caption }}"></${e.P}-span><input type="radio" class="${e.PCSS}-input" /><label class="${e.PCSS}-label ${e.PCSS}-radio ${e.PCSS}-viewfinder"><${e.P}-text text="{{ :host.caption }}"></${e.P}-text></label>`,shadow:e.Defaults.USE_SHADOW_ROOT})],a),t.PacemRadioElement=a}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(a){let i=class PacemSelectElement extends a.PacemDataSourceElement{constructor(){super(...arguments),this.emptyOption=!0}toggleReadonlyView(e){this._repeater.hidden=e,this._span.hidden=!e}get inputFields(){return[this._select]}_manageDom(t){const a=t.detail,i=a.item;let n=a.dom.find(e=>e instanceof HTMLOptionElement);n.value=i.value,n.textContent=i.viewValue,n.disabled=i.disabled,n.selected=this.isDataSourceItemSelected(i),(e.Utils.isNullOrEmpty(n.value)?e.Utils.addClass:e.Utils.removeClass).apply(this,[n,e.PCSS+"-watermark"])}onChange(t){let a,i=this._select.selectedIndex,n=this.adaptedDatasource,s=i>=0&&n[i];return a=null!=s?s.value:void 0,e.Utils.fromResult(this.value=a)}propertyChangedCallback(e,t,a,i){switch(super.propertyChangedCallback(e,t,a,i),e){case"placeholder":case"emptyOption":this.databind()}}buildAdaptedDatasource(e=this.datasource){let t=super.buildAdaptedDatasource(e);return t&&this.emptyOption&&t.splice(0,0,{viewValue:this.placeholder||"",value:void 0,data:void 0}),t}handleDatasourceMismatch(t){this.emptyOption?super.handleDatasourceMismatch(t):e.Utils.isNullOrEmpty(t)?this.value=void 0:this.value=t[0].value}acceptValue(t){const a=this.adaptedDatasource,i=a&&a.filter(e=>this.isDataSourceItemSelected(e,t));if(i&&1==i.length)this._select.selectedIndex=a.indexOf(i[0]);else{this._select.value=void 0;let t=this._select.options;t.length>0&&e.Utils.isNullOrEmpty(t[0].value)&&(this._select.selectedIndex=0)}}viewActivatedCallback(){super.viewActivatedCallback();this._select.addEventListener("wheel",this.emitHandler,{capture:!1,passive:!1})}disconnectedCallback(){if(!e.Utils.isNull(this._select)){this._select.removeEventListener("wheel",this.emitHandler,{capture:!1,passive:!1})}super.disconnectedCallback()}};__decorate([e.ViewChild("select")],i.prototype,"_select",void 0),__decorate([e.ViewChild(e.P+"-repeater")],i.prototype,"_repeater",void 0),__decorate([e.ViewChild(`span.${e.PCSS}-readonly`)],i.prototype,"_span",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Boolean})],i.prototype,"emptyOption",void 0),i=__decorate([e.CustomElement({tagName:e.P+"-select",template:`<${e.P}-repeater datasource="{{ :host.adaptedDatasource }}" on-${t.RepeaterItemCreateEventName}=":host._manageDom($event)">\n <select class="${e.PCSS}-select ${e.PCSS}-viewfinder">\n <template>\n <option></option>\n </template>\n </select>\n</${e.P}-repeater><span class="${e.PCSS}-readonly"><${e.P}-text text="{{ :host.viewValue }}"></${e.P}-text></span><${e.P}-content></${e.P}-content>`,shadow:e.Defaults.USE_SHADOW_ROOT})],i),a.PacemSelectElement=i}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(a){let i=class PacemSliderElement extends a.PacemBaseElement{constructor(){super(...arguments),this.inputFields=[],this._dragHandler=e=>{e.preventDefault(),this._computeAndAssignValue(e.detail.currentPosition.x,"end"!==this.changePolicy)},this._endHandler=e=>{e.preventDefault(),this._computeAndAssignValue(e.detail.currentPosition.x,"end"===this.changePolicy)},this._startHandler=e=>{this._thumb.focus()},this._downHandler=t=>{const a=t instanceof MouseEvent?t.clientX:t.touches&&t.touches.length&&t.touches[0].clientX,i=this._trackSize;e.Utils.isNullOrEmpty(i)||this._computeAndAssignValue(a,!0)},this._keydownHandler=t=>{switch(t.keyCode){case 39:case 37:e.avoidHandler(t);let a=39===t.keyCode,i=("number"!=typeof this.step?1:this.step)*(a?1:-1),n=!1,s=t=>{n=!0,window.removeEventListener("keyup",s,!1),e.Utils.removeClass(this,"slider-keydown")};window.addEventListener("keyup",s,!1),e.Utils.addClass(this,"slider-keydown"),e.Utils.accelerateCallback(e=>{(e.cancel=n)||this._setValue(this.value+i)})}}}onChange(e){return new Promise((t,a)=>{"slide"===e.type&&t(this.value=e.detail),t(this.value)})}_draw(t=this.value){const a=this._trackSize;if(e.Utils.isNull(a))return;const i=e.Utils.isNullOrEmpty(t)?this.min:parseFloat(t),n=Math.min(1,Math.max(0,(i-this.min)/(this.max-this.min)));this._progress.style.transform=`scale(${n}, 1)`,this._thumb.style.transform=`translateX(${Math.round(n*a.width)}px)`}_format(t){const a=this.format;if(!e.Utils.isNullOrEmpty(a))return new Intl.NumberFormat(e.Utils.lang(this),a).format(t);let i="-";e.Utils.isNull(t)||(i=t.toLocaleString());let n=new CustomEvent("formatvalue",{detail:{value:t}});return this.dispatchEvent(n),e.Utils.isNull(n.detail.output)?i:n.detail.output}acceptValue(e){this._draw(e)}getViewValue(e){return this._format(e)}convertValueAttributeToProperty(e){return parseFloat(e)}toggleReadonlyView(t){this._thumb.hidden=t;const a="cursor-pointer";t?(e.Utils.removeClass(this._max,a),e.Utils.removeClass(this._min,a)):(e.Utils.addClass(this._max,a),e.Utils.addClass(this._min,a))}_setTrackSize(e){const t=e.detail;this._trackSize={x:t.left,y:t.top,width:t.width,height:t.height},this._draw(this.value)}_computeAndAssignValue(e,t){if(this.readonly||this.disabled)return;const a=this._trackSize,i=this.step;let n=(e-a.x)/a.width,s=(this.max-this.min)*n+this.min;"number"==typeof i&&(s=Math.round(s/i)*i),t?this._setValue(s):this._draw(s)}_setValue(t){isNaN(t)||e.Utils.isNull(t)?t=void 0:(!isNaN(this.min)&&t<this.min&&(t=this.min),!isNaN(this.max)&&t>this.max&&(t=this.max)),this.changeHandler(new CustomEvent("slide",{detail:t}))}connectedCallback(){super.connectedCallback(),this.addEventListener("mousedown",this._downHandler,!1),this.addEventListener("touchstart",this._downHandler,{passive:!1,capture:!1})}viewActivatedCallback(){super.viewActivatedCallback(),this._dragger.addEventListener(e.UI.DragDropEventType.Init,this._startHandler,!1),this._dragger.addEventListener(e.UI.DragDropEventType.Drag,this._dragHandler,!1),this._dragger.addEventListener(e.UI.DragDropEventType.End,this._endHandler,!1),this._thumb.addEventListener("keydown",this._keydownHandler,!1),this._min.text=this._format(this.min),this._max.text=this._format(this.max);const a=this._shellProxy.dom[0];e.Utils.isNull(a)||(a.target=this._thumb,a.options={trigger:t.UI.BalloonTrigger.Focus,trackPosition:!0,position:t.UI.BalloonPosition.Top,align:t.UI.BalloonAlignment.Center,behavior:t.UI.BalloonBehavior.Tooltip,hoverDelay:0,hoverTimeout:0},this._syncThumbLabel()),this._thumb.tabIndex=0}_syncThumbLabel(t=this.thumbLabel){const a=this._shellProxy.dom[0];(t?e.Utils.addClass:e.Utils.removeClass).apply(this,[this,"slider-thumblabel"]),a.disabled=!t}disconnectedCallback(){this.removeEventListener("mousedown",this._downHandler,!1),this.removeEventListener("touchstart",this._downHandler,{capture:!1}),e.Utils.isNull(this._dragger)||(this._dragger.removeEventListener(e.UI.DragDropEventType.End,this._endHandler,!1),this._dragger.removeEventListener(e.UI.DragDropEventType.Drag,this._dragHandler,!1),this._dragger.removeEventListener(e.UI.DragDropEventType.Init,this._startHandler,!1)),e.Utils.isNull(this._thumb)||this._thumb.removeEventListener("keydown",this._keydownHandler,!1),super.disconnectedCallback()}propertyChangedCallback(t,a,i,n){if(super.propertyChangedCallback(t,a,i,n),!n)switch(t){case"thumbLabel":this._syncThumbLabel(i);break;case"min":case"max":e.Utils.isNull(this._max)||e.Utils.isNull(this._min)||(this._min.text=this._format(this.min),this._max.text=this._format(this.max)),this._setValue(this.value),this._draw()}}};__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Number})],i.prototype,"min",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Number})],i.prototype,"max",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Boolean})],i.prototype,"thumbLabel",void 0),__decorate([e.Watch({emit:!1,converter:{convert:e=>{let t=parseFloat(e);return isNaN(t)?"any":t},convertBack:e=>(e||"").toString()}})],i.prototype,"step",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String})],i.prototype,"changePolicy",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Json})],i.prototype,"format",void 0),__decorate([e.ViewChild(".slider-track")],i.prototype,"_track",void 0),__decorate([e.ViewChild(".slider-progress")],i.prototype,"_progress",void 0),__decorate([e.ViewChild(".slider-thumb")],i.prototype,"_thumb",void 0),__decorate([e.ViewChild(`${e.P}-text[min]`)],i.prototype,"_min",void 0),__decorate([e.ViewChild(`${e.P}-text[max]`)],i.prototype,"_max",void 0),__decorate([e.ViewChild(`${e.P}-drag-drop`)],i.prototype,"_dragger",void 0),__decorate([e.ViewChild(`${e.P}-shell-proxy`)],i.prototype,"_shellProxy",void 0),i=__decorate([e.CustomElement({tagName:e.P+"-slider",template:`<div class="${e.PCSS}-viewfinder ${e.PCSS}-slider"><${e.P}-text text="{{ :host._format(:host.min) }}" min></${e.P}-text>\n <div class="slider-track"><div class="slider-progress"></div></div>\n <${e.P}-panel class="${e.PCSS}-clickable slider-thumb" behaviors="{{ [::_dragger] }}">\n <div class="thumb-label"></div>\n </${e.P}-panel>\n <${e.P}-text text="{{ :host._format(:host.max) }}" max></${e.P}-text>\n <div class="slider-footer"><${e.P}-text text="{{ :host.viewValue }}"></${e.P}-text></div>\n </div>\n<${e.P}-drag-drop lock-timeout="0"></${e.P}-drag-drop><${e.P}-resize watch-position="true" on-${t.ResizeEventName}=":host._setTrackSize($event)" target="{{ ::_track }}"></${e.P}-resize>\n<${e.P}-shell-proxy><${e.P}-balloon class="text-center"><${e.P}-text text="{{ :host.viewValue }}"></${e.P}-text></${e.P}-balloon></${e.P}-shell-proxy>\n`,shadow:e.Defaults.USE_SHADOW_ROOT})],i),a.PacemSliderElement=i}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(a){class SuggestionSelectEvent extends e.CustomTypedEvent{constructor(e){super("suggestionselect",{selectedValue:e})}}let i=class PacemSuggestElement extends a.PacemDataSourceElement{constructor(){super(...arguments),this._toggleBtnHandler=e=>{e.preventDefault(),this.disabled||this._balloon.toggle()},this._clearBtnHandler=e=>{e.preventDefault(),this.hint=this._input.value="",this.value=void 0,this._focus(null),this.changeHandler(new SuggestionSelectEvent(null))},this._balloonPopupHandler=t=>{e.Utils.addClass(this._btnArrow,"rotate-180")},this._balloonPopoutHandler=t=>{e.Utils.removeClass(this._btnArrow,"rotate-180")},this._inputHandler=e=>{switch(e.keyCode){case 9:case 13:break;default:this._focus(null),this.hint=this._input.value,this.changeHandler(new SuggestionSelectEvent(null))}},this._keyupHandler=t=>{this.#_&&(e.avoidHandler(t),this.#_=!1)},this._focusHandler=e=>{if(this.preventFocus){e.preventDefault();this._balloon.visible?this.popout():this.popup()}const t=this._input.value;this.viewValue!=t&&this._databind()},this._blurHandler=e=>{this._undo()},this.#_=!1,this._keydownHandler=t=>{var a=!1;if(e.Utils.isNull(this.#g)){const i=this._findFirstAvailableListItem();if(!e.Utils.isNull(i))switch(t.keyCode){case 40:e.avoidHandler(t),this._focus(i);break;case 13:e.avoidHandler(t),a=!0,1===this.#y.length?this._select(i):this._focus(i)}}else{var i,n=this.#g,s=n;const r=t=>!e.Utils.isNull(t)&&"li"===t.localName&&"true"===t.dataset.pacemDisabled,o=t=>!e.Utils.isNull(t)&&"li"===t.localName&&"true"!==t.dataset.pacemDisabled;switch(t.keyCode){case 38:e.avoidHandler(t);do{if(o(s=s.previousElementSibling)){i=s;break}}while(r(s));i??=n;break;case 40:e.avoidHandler(t);do{if(o(s=s.nextElementSibling)){i=s;break}}while(r(s));i??=n;break;case 27:e.avoidHandler(t),this._undo(),this.popout();break;case 9:case 13:e.avoidHandler(t),a=!0,this._select()}this._focus(i),this.#_=a}},this._selectHandler=t=>{e.avoidHandler(t),this._select(t.currentTarget)}}get inputFields(){return[this._input]}acceptValue(t){/*!this._isTyping && */!this.allowNew&&e.Utils.isNullOrEmpty(this.datasource)||(this._input.value=this.getViewValue(t)||(this._isTyping?this._input.value:""))}getViewValue(t){var a=super.getViewValue(t);return e.Utils.isNullOrEmpty(a)&&this.allowNew&&!e.Utils.isNullOrEmpty(t)&&(a=this.mapEntityToViewValue(t)),a}onChange(e){return new Promise((t,a)=>{if("suggestionselect"===e.type){const a=e.detail.selectedValue;this.value=a,a&&this.popout(),t(a)}else t(this.value)})}viewActivatedCallback(){super.viewActivatedCallback(),this._setDropdownMode(),this._setupItemTemplate();var t=this._createBalloon();t.appendChild(this._repeater),this._checkBalloon(t);e.CustomElementUtils.findAncestorShell(this).appendChild(t),this._balloon=t,this._input.addEventListener("mousedown",this._focusHandler,!1),this._input.addEventListener("keydown",this._keydownHandler,!1),this._input.addEventListener("keyup",this._keyupHandler,!1),this._input.addEventListener("focus",this._focusHandler,!1),this._input.addEventListener("blur",this._blurHandler,!1),this._input.addEventListener("input",this._inputHandler,!1),this._btnClear.addEventListener("mousedown",this._clearBtnHandler,!1),this._btnArrow.addEventListener("mousedown",this._toggleBtnHandler,!1),this._databind(),this._syncButtons()}propertyChangedCallback(t,a,i,n){if(super.propertyChangedCallback(t,a,i,n),e.Utils.isNull(this._balloon))return;const s=this._isTyping;switch(t){case"adaptedDatasource":e.Utils.isNullOrEmpty(i)?this.popout():s?this.popup():this._input.value=this.getViewValue(this.value);break;case"hint":s||i===this._input.value||(this._input.value=i,this.#g=null);break;case"readonly":this._setDropdownMode();case"disabled":case"value":this._checkBalloon();break;case"itemtemplate":n||this._setupItemTemplate();break;case"allowTyping":n||this._setDropdownMode()}["adaptedDatasource","hint","value"].indexOf(t)>=0&&this._databind(),["allowTyping","value","hint"].indexOf(t)>=0&&this._syncButtons()}disconnectedCallback(){e.Utils.isNull(this._balloon)||(this._balloon.removeEventListener("popup",this._balloonPopupHandler,!1),this._balloon.removeEventListener("popout",this._balloonPopoutHandler,!1),this._balloon.remove()),e.Utils.isNull(this._input)||(this._input.removeEventListener("mousedown",this._focusHandler,!1),this._input.removeEventListener("focus",this._focusHandler,!1),this._input.removeEventListener("blur",this._blurHandler,!1),this._input.removeEventListener("keydown",this._keydownHandler,!1),this._input.removeEventListener("keyup",this._keyupHandler,!1),this._input.removeEventListener("input",this._inputHandler,!1)),e.Utils.isNull(this._btnClear)||this._btnClear.removeEventListener("mousedown",this._clearBtnHandler,!1),e.Utils.isNull(this._btnArrow)||this._btnArrow.addEventListener("mousedown",this._toggleBtnHandler,!1),super.disconnectedCallback()}#y;_databind(){if(!e.Utils.isNull(this._repeater)){const e=this.#y=this._filter(this.adaptedDatasource,this._input.value);this._repeater.datasource=e}}_syncButtons(){e.Utils.isNull(this._btnArrow)||(this._btnArrow.hide=!1!==this.allowTyping||!e.Utils.isNullOrEmpty(this._input.value||this.value)),e.Utils.isNull(this._btnClear)||(this._btnClear.hide=this.readonly||e.Utils.isNullOrEmpty(this._input.value||this.value))}get _isTyping(){return e.Utils.is(this._input,":focus")}_undo(){this._focus(null),this.hint=this._input.value=this.getViewValue(this.value)||""}_findFirstAvailableListItem(){var t;if(!0===this._balloon.visible&&!e.Utils.isNull(t=this._repeater.querySelector("ol > li")))for(;!e.Utils.isNull(t)&&"true"===t.dataset.pacemDisabled&&"li"===t.localName;)t=t.nextElementSibling;return t}#_;_setDropdownMode(e=this.allowTyping){this._input.readOnly=!(e??1)}_setupItemTemplate(){if(this.itemtemplate instanceof HTMLTemplateElement){const e=this.itemtemplate.cloneNode(!0).content,t=document.createElement("template"),a=document.createElement("li");a.append(e),t.content.appendChild(a),this._tmplProxy.target=t}else this._tmplProxy.target=this._defaultTemplate}#g;_focus(t){if(this.preventFocus)return;if(e.Utils.isNull(t))return void(this.#g=null);const a=t.parentElement.children;for(let e=0;e<a.length;e++){const i=a.item(e);if(i===t){i.dataset.pacemFocused="true",this.#g=i;const e=this._input,t=e.value=JSON.parse(i.dataset.pacemViewValue);e.setSelectionRange(t.length,t.length)}else delete i.dataset.pacemFocused}}_select(e=this.#g){const t=JSON.parse(e.dataset.pacemValue);"true"===e.dataset.pacemDisabled||this.changeHandler(new SuggestionSelectEvent(t))}_filter(t,a,i=this.value){let n=t||[];if(!e.Utils.isNullOrEmpty(a&&a.trim())){const t=a.toLowerCase().split(" ");let i=n.filter(a=>{for(let i of t){if(a.viewValue?.toLowerCase().indexOf(i)>=0)return!0;const t=this.filterFields;if(!e.Utils.isNullOrEmpty(t)){const n=a.data;if("object"==typeof n&&!e.Utils.isNullOrEmpty(n))for(let a of t){const t=a.split(".");let s=0,r=n;for(;!e.Utils.isNull(r)&&s<t.length;)r=r[t[s]],s++;if(!e.Utils.isNullOrEmpty(r)&&r.toString().toLowerCase().indexOf(i)>=0)return!0}}}return!1});n=this.allowNew&&e.Utils.isNullOrEmpty(this.valueProperty)&&e.Utils.isNullOrEmpty(this.textProperty)&&(e.Utils.isNullOrEmpty(i)||e.Utils.isNull(i.find(e=>e.viewValue===a)))?[{value:a,viewValue:a,data:a}].concat(i):i}let s=n;return!1!==this.allowTyping&&(s=n.slice(0,this.maxSuggestions||10)),this._isTyping&&this.popup(),this._balloon.style.opacity=e.Utils.isNullOrEmpty(s)?"0":"",this.log(e.Logging.LogLevel.Log,`${s.length} dropdown suggestion(s), given hint '${a}' and ${(t||[]).length} datasource items`),s}_itemCreate(e){const t=e.detail.dom.find(e=>e instanceof HTMLLIElement),a=e.detail.item,i=(e.detail.index,!0===a.disabled);t.tabIndex=i?-1:0,t.dataset.pacemValue=JSON.stringify(a.value),t.dataset.pacemViewValue=JSON.stringify(a.viewValue),t.dataset.pacemDisabled=i.toString(),t.addEventListener("mousedown",this._selectHandler,!1)}_itemRemove(e){e.detail.dom.find(e=>e instanceof HTMLLIElement).removeEventListener("mousedown",this._selectHandler,!1)}toggleReadonlyView(e){this.span.hidden=!e,this._input.hidden=e,e?this._btnClear.hide=this._btnArrow.hide=!0:this._syncButtons()}popup(t=100){!e.Utils.isNullOrEmpty(this.adaptedDatasource)&&e.Utils.isVisible(this)&&(console.log("Popping up from here..."),this._balloon?.popup(t))}popout(e=0){this.#g=null,this._balloon?.popout(e)}_checkBalloon(t=this._balloon){if(!e.Utils.isNull(t)){const a=!e.Utils.isNullOrEmpty(this.value)&&!e.Utils.isNullOrEmpty(this._input.value);t.disabled=a||this.readonly||this.disabled||!1}}_createBalloon(){const a=document.createElement(e.P+"-balloon");return e.Utils.addClass(a,"suggest dropdown"),a.options={trackPosition:!0,trigger:t.UI.BalloonTrigger.Focus,position:t.UI.BalloonPosition.VerticalAuto,size:t.UI.BalloonSizing.Match,align:t.UI.BalloonAlignment.Start,behavior:t.UI.BalloonBehavior.Menu,hoverDelay:100,hoverTimeout:0},a.addEventListener("popup",this._balloonPopupHandler,!1),a.addEventListener("popout",this._balloonPopoutHandler,!1),a.target=this._input,a}};__decorate([e.ViewChild("input[type=text]")],i.prototype,"_input",void 0),__decorate([e.ViewChild(e.P+"-repeater")],i.prototype,"_repeater",void 0),__decorate([e.ViewChild(`span.${e.PCSS}-readonly`)],i.prototype,"span",void 0),__decorate([e.ViewChild("template")],i.prototype,"_defaultTemplate",void 0),__decorate([e.ViewChild(e.P+"-template-proxy")],i.prototype,"_tmplProxy",void 0),__decorate([e.ViewChild(`${e.P}-button[toggle]`)],i.prototype,"_btnArrow",void 0),__decorate([e.ViewChild(`${e.P}-button[clear]`)],i.prototype,"_btnClear",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],i.prototype,"hint",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Number})],i.prototype,"maxSuggestions",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Boolean})],i.prototype,"allowTyping",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Boolean})],i.prototype,"preventFocus",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Element})],i.prototype,"itemtemplate",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.StringArray})],i.prototype,"filterFields",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Boolean})],i.prototype,"allowNew",void 0),i=__decorate([e.CustomElement({tagName:e.P+"-suggest",shadow:e.Defaults.USE_SHADOW_ROOT,template:`<div class="${e.PCSS}-relative"><input type="text" class="${e.PCSS}-input" />\n<${e.P}-button clear tab-order="-1"\nclass="button-flat ${e.PCSS}-anim anim-pop anim-sudden anim-quick pos-absolute absolute-right absolute-top display-block ${e.PCSS}-margin margin-0" \n icon-glyph="highlight_off"></${e.P}-button>\n<${e.P}-button \nclass="button-flat icon-rotate ${e.PCSS}-anim anim-pop anim-sudden anim-quick pos-absolute absolute-right absolute-top display-block ${e.PCSS}-margin margin-0" \n icon-glyph="arrow_drop_down" tab-order="-1" toggle></${e.P}-button>\n</div>\n<span class="${e.PCSS}-readonly"><${e.P}-text text="{{ :host.viewValue }}"></${e.P}-text></span>\n<${e.P}-repeater on-${t.RepeaterItemCreateEventName}=":host._itemCreate($event)" on-${t.RepeaterItemRemoveEventName}=":host._itemRemove($event)">\n <ol>\n <${e.P}-template-proxy></${e.P}-template-proxy>\n </ol>\n</${e.P}-repeater><${e.P}-content></${e.P}-content>\n<template>\n <li><${e.P}-span content="{{ $pacem.highlight(^item.viewValue, :host.hint) }}"></${e.P}-span></li>\n</template>`})],i),a.PacemSuggestElement=i}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(a){class TagRemoveEvent extends e.CustomTypedEvent{constructor(e){super("tagremove",{index:e})}}class TagAddEvent extends e.CustomTypedEvent{constructor(e){super("tagadd",{value:e})}}let i=class PacemTagElement extends t.PacemElement{propertyChangedCallback(t,a,i,n){switch(super.propertyChangedCallback(t,a,i,n),t){case"readonly":let t=!!i;(t?e.Utils.addClass:e.Utils.removeClass)(this,"tag-readonly"),this._btn.disabled=this._btn.hide=t;break;case"tag":e.Utils.removeClass(this,"tag-out")}}_remove(){e.Utils.addClass(this,"tag-out"),e.Utils.addAnimationEndCallback(this,()=>{this.dispatchEvent(new Event("remove"))})}};__decorate([e.Watch({converter:e.PropertyConverters.String})],i.prototype,"tag",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Boolean})],i.prototype,"readonly",void 0),__decorate([e.ViewChild(e.P+"-button")],i.prototype,"_btn",void 0),i=__decorate([e.CustomElement({tagName:e.P+"-tag",shadow:e.Defaults.USE_SHADOW_ROOT,template:`<${e.P}-text text="{{ :host.tag }}"></${e.P}-text>\n <${e.P}-button on-click=":host._remove()"></${e.P}-button>`})],i),a.PacemTagElement=i;let n=class PacemTagsElement extends a.PacemDataSourceElement{constructor(){super(!0),this.inputFields=[]}toggleReadonlyView(e){this._suggest.readonly=e,this.querySelector(".tag-new").hidden=e}_tagRemove(e){this.changeHandler(new TagRemoveEvent(e))}_tagAdd(e){this.changeHandler(new TagAddEvent(e))}handleDatasourceMismatch(){}propertyChangedCallback(t,a,i,n){switch(super.propertyChangedCallback(t,a,i,n),t){case"datasource":case"textProperty":this._suggest[t]=i;break;case"valueProperty":if(!e.Utils.isNullOrEmpty(i))throw`Cannot set 'valueProperty' on ${this.constructor.name}s.`;break;case"value":this._tags.datasource=i}}onChange(t){return new Promise((a,i)=>{switch(t.type){case"tagremove":this._justAddedIndex=-1;const i=t.detail.index,n=e.Utils.clone(this.value),s=n.splice(i+1),r=n.splice(0,i);a(this.value=r.concat(s));break;case"tagadd":const o=t.detail.value,l=e.Utils.clone(this.value);if(!e.Utils.isNullOrEmpty(o)&&(this.allowDuplicates||e.Utils.isNullOrEmpty(l&&l.find(e=>this.mapEntityToViewValue(e)==this.mapEntityToViewValue(o))))){let e=(l||[]).concat([o]);a(this.value=e),this._justAddedIndex=this.value.length-1,setTimeout(()=>{this._suggest.focus()},250),this._suggest.blur(),this._suggest.hint="",this._suggest.reset()}break;default:a(this.value)}})}acceptValue(e){}};__decorate([e.Watch({converter:e.PropertyConverters.String})],n.prototype,"hint",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Boolean})],n.prototype,"allowDuplicates",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Boolean})],n.prototype,"allowNew",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Number})],n.prototype,"_justAddedIndex",void 0),__decorate([e.ViewChild(e.P+"-suggest")],n.prototype,"_suggest",void 0),__decorate([e.ViewChild(e.P+"-repeater."+e.PCSS+"-tags")],n.prototype,"_tags",void 0),n=__decorate([e.CustomElement({tagName:e.P+"-tags",shadow:e.Defaults.USE_SHADOW_ROOT,template:`<${e.P}-repeater class="${e.PCSS}-tags">\n <ul class="${e.PCSS}-tags ${e.PCSS}-viewfinder ${e.PCSS}-list list-unstyled list-inline">\n <template>\n <li class="${e.PCSS}-tag">\n <${e.P}-tag on-remove=":host._tagRemove(^index)" css-class="{{ { 'tag-in': :host._justAddedIndex === ^index } }}" tag="{{ :host.mapEntityToViewValue(^item) }}" readonly="{{ :host.readonly }}"></${e.P}-tag>\n </li>\n </template>\n <li class="tag-new">\n <${e.P}-suggest logger="{{ :host.logger }}" placeholder="{{ :host.placeholder }}" allow-new="{{ :host.allowNew }}" class="${e.PCSS}-tags" on-change=":host._tagAdd($this.value)" hint="{{ :host.hint, twoway }}">\n <${e.P}-content></${e.P}-content>\n </${e.P}-suggest>\n </li>\n </ul>\n</${e.P}-repeater>`})],n),a.PacemTagsElement=n}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){let a=class PacemMarkdownTextAreaElement extends t.PacemTextualInputElement{constructor(t=new e.MarkdownService){super(),this._md=t,this.rows=5,this.cols=50,this._keydownHandler=t=>{if(9===t.keyCode){const i=this.input,n=i.value;var a=i.selectionStart;i.value=n.substr(0,a)+" "+n.substr(a),e.preventDefaultHandler(t)}}}toggleReadonlyView(e){this.input.hidden=e}get preventKeyboardSubmit(){return!0}get inputFields(){return[this.input]}getViewValue(e){return this._md.toHtml(e)}propertyChangedCallback(e,t,a,i){super.propertyChangedCallback(e,t,a,i),"rows"===e||"cols"===e?this.inputField.setAttribute(e,a):"viewValue"==e&&(this._markdown.innerHTML=a)}viewActivatedCallback(){super.viewActivatedCallback(),this.input.addEventListener("keydown",this._keydownHandler,!1)}disconnectedCallback(){this.input&&this.input.removeEventListener("keydown",this._keydownHandler,!1),super.disconnectedCallback()}};__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Number})],a.prototype,"rows",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Number})],a.prototype,"cols",void 0),__decorate([e.ViewChild("textarea")],a.prototype,"input",void 0),__decorate([e.ViewChild(`div.${e.PCSS}-readonly`)],a.prototype,"_markdown",void 0),a=__decorate([e.CustomElement({tagName:e.P+"-textarea-markdown",template:`<textarea class="${e.PCSS}-input" pacem></textarea>${t.CHAR_COUNTER_CHILD}<div class="${e.PCSS}-readonly ${e.PCSS}-markdown"></div>`,shadow:e.Defaults.USE_SHADOW_ROOT})],a),t.PacemMarkdownTextAreaElement=a}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){let a=class PacemTextAreaElement extends t.PacemTextualInputElement{constructor(){super(...arguments),this.rows=5,this.cols=50}get preventKeyboardSubmit(){return!0}toggleReadonlyView(e){this._span.hidden=!e,this._input.hidden=e}get inputFields(){return[this._input]}propertyChangedCallback(e,t,a,i){super.propertyChangedCallback(e,t,a,i),"rows"!==e&&"cols"!==e||this.inputField.setAttribute(e,a)}};__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Number})],a.prototype,"rows",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Number})],a.prototype,"cols",void 0),__decorate([e.ViewChild("textarea")],a.prototype,"_input",void 0),__decorate([e.ViewChild(`span.${e.PCSS}-readonly`)],a.prototype,"_span",void 0),a=__decorate([e.CustomElement({tagName:e.P+"-textarea",template:`<textarea class="${e.PCSS}-input" pacem></textarea>${t.CHAR_COUNTER_CHILD}<span class="${e.PCSS}-readonly"><${e.P}-text text="{{ :host.viewValue }}"></${e.P}-text></span>`,shadow:e.Defaults.USE_SHADOW_ROOT})],a),t.PacemTextAreaElement=a}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){class PacemBaseValidatorElement extends t.PacemFormRelevantElement{constructor(){super()}viewActivatedCallback(){super.viewActivatedCallback(),e.Utils.addClass(this,e.PCSS+"-validator")}propertyChangedCallback(t,a,i,n){super.propertyChangedCallback(t,a,i,n);let s=this.form;switch(t){case"watch":a&&s&&s.unregisterValidator(i,this),s&&s.registerValidator(i,this);break;case"invalid":break;case"form":let t=this.watch;e.Utils.isNullOrEmpty(t)||(null!=a&&a.unregisterValidator(t,this),null!=i&&i.registerValidator(t,this));break;case"disabled":this.triggerFormFieldValidation()}}#f;triggerFormFieldValidation(){const t=this.form,a=this.watch;e.Utils.isNull(t)||e.Utils.isNullOrEmpty(a)||(cancelAnimationFrame(this.#f),this.#f=requestAnimationFrame(()=>{t.validate(a)}))}validate(t){return this.disabled?e.Utils.fromResult(!0):this.evaluate(t)}}function a(t){return e.Utils.isNullOrEmpty(t)}__decorate([e.Watch({converter:e.PropertyConverters.Boolean})],PacemBaseValidatorElement.prototype,"invalid",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],PacemBaseValidatorElement.prototype,"errorMessage",void 0),__decorate([e.Watch({emit:!1,reflectBack:!0,converter:e.PropertyConverters.String})],PacemBaseValidatorElement.prototype,"watch",void 0),t.PacemBaseValidatorElement=PacemBaseValidatorElement,t.BASIC_VALIDATOR_TEMPLATE=`<${e.P}-span part="error-message" hide="{{ !:host.invalid }}" text="{{ :host.errorMessage }}"></${e.P}-span>`;let i=class PacemRequiredValidatorElement extends PacemBaseValidatorElement{evaluate(t){let i=!a(t);return e.Utils.fromResult(i)}};i=__decorate([e.CustomElement({tagName:e.P+"-required-validator",template:t.BASIC_VALIDATOR_TEMPLATE,shadow:e.Defaults.USE_SHADOW_ROOT})],i),t.PacemRequiredValidatorElement=i;let n=class PacemRegexValidatorElement extends PacemBaseValidatorElement{propertyChangedCallback(e,t,a,i){super.propertyChangedCallback(e,t,a,i),i||"pattern"!==e||this.triggerFormFieldValidation()}evaluate(t){let i=!0,n=this.pattern;return a(t)||(i=new RegExp(n).test(t)),e.Utils.fromResult(i)}};__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String})],n.prototype,"pattern",void 0),n=__decorate([e.CustomElement({tagName:e.P+"-regex-validator",template:t.BASIC_VALIDATOR_TEMPLATE,shadow:e.Defaults.USE_SHADOW_ROOT})],n),t.PacemRegexValidatorElement=n;let s=class PacemLengthValidatorElement extends PacemBaseValidatorElement{propertyChangedCallback(e,t,a,i){super.propertyChangedCallback(e,t,a,i),i||"min"!==e&&"max"!==e||this.triggerFormFieldValidation()}evaluate(t){let i=!0;return a(t)||(this.min>=0&&(i=i&&(t||"").toString().length>=this.min),this.max>=0&&(i=i&&(t||"").toString().length<=this.max)),e.Utils.fromResult(i)}};__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Number})],s.prototype,"min",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Number})],s.prototype,"max",void 0),s=__decorate([e.CustomElement({tagName:e.P+"-length-validator",template:t.BASIC_VALIDATOR_TEMPLATE,shadow:e.Defaults.USE_SHADOW_ROOT})],s),t.PacemLengthValidatorElement=s;let r=class PacemRangeValidatorElement extends PacemBaseValidatorElement{propertyChangedCallback(e,t,a,i){super.propertyChangedCallback(e,t,a,i),i||"min"!==e&&"max"!==e||this.triggerFormFieldValidation()}evaluate(t){let i=!0;if(!a(t)){let a=t;t instanceof Date||"number"!=typeof t&&(a=e.Utils.parseDate(t))instanceof Date&&isFinite(a.valueOf())?(null!=this.min&&(i=i&&a.valueOf()>=e.Utils.parseDate(this.min).valueOf()),null!=this.max&&(i=i&&a.valueOf()<=e.Utils.parseDate(this.max).valueOf())):(null!=this.min&&(i=i&&t>=this.min),null!=this.max&&(i=i&&t<=this.max))}return e.Utils.fromResult(i)}};__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Number})],r.prototype,"min",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Number})],r.prototype,"max",void 0),r=__decorate([e.CustomElement({tagName:e.P+"-range-validator",template:t.BASIC_VALIDATOR_TEMPLATE,shadow:e.Defaults.USE_SHADOW_ROOT})],r),t.PacemRangeValidatorElement=r;let o=class PacemCompareValidatorElement extends PacemBaseValidatorElement{propertyChangedCallback(e,t,a,i){super.propertyChangedCallback(e,t,a,i),i||"operator"!==e&&"to"!==e||this.triggerFormFieldValidation()}_prepareValuesForComparison(t,a){return e.Utils.Dates.isDate(t)||e.Utils.Dates.isDate(a)?[e.Utils.parseDate(t),e.Utils.parseDate(a)]:[t,a]}evaluate(t){let i=!0,n=this.to;if(!a(t)&&!a(n)){const e=this._prepareValuesForComparison(t,n);switch(t=e[0],n=e[1],this.operator){case"lessOrEqual":i=t<=n;break;case"less":i=t<n;break;case"greaterOrEqual":i=t>=n;break;case"greater":i=t>n;break;case"notEqual":i=t!==n;break;default:i=t===n}}return e.Utils.fromResult(i)}};__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String})],o.prototype,"operator",void 0),__decorate([e.Watch({emit:!1,reflectBack:!0})],o.prototype,"to",void 0),o=__decorate([e.CustomElement({tagName:e.P+"-compare-validator",template:t.BASIC_VALIDATOR_TEMPLATE,shadow:e.Defaults.USE_SHADOW_ROOT})],o),t.PacemCompareValidatorElement=o;let l=class PacemBinaryValidatorElement extends PacemBaseValidatorElement{propertyChangedCallback(e,t,a,i){super.propertyChangedCallback(e,t,a,i),i||"pattern"!==e&&"maxSize"!==e||this.triggerFormFieldValidation()}evaluate(t){let i=!0,n=this.pattern,s=this.maxSize;if(!a(t)){if(!e.Utils.isNullOrEmpty(n)){let e="string"==typeof t?t:t.name;i=new RegExp(n,"i").test(e)}!e.Utils.isNull(s)&&"object"==typeof t&&t.size>0&&(i=i&&t.size<=s)}return e.Utils.fromResult(i)}};__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String})],l.prototype,"pattern",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String})],l.prototype,"maxSize",void 0),l=__decorate([e.CustomElement({tagName:e.P+"-binary-validator",template:t.BASIC_VALIDATOR_TEMPLATE,shadow:e.Defaults.USE_SHADOW_ROOT})],l),t.PacemBinaryValidatorElement=l;let c=class PacemAsyncValidatorElement extends PacemBaseValidatorElement{constructor(){super(...arguments),this._deferredToken=null}_evaluateResult(){const t=this._fetcher.result;switch(t){case"true":return!0;case"false":return!1;default:try{let a=JSON.parse(t);return e.Utils.getApiResult(a)||!1}catch(e){return!1}}}_fetch(t){const a=this._deferredToken,i=this._fetcher;var n=this.parameters||{};n[this.watch]=t;const s={parameters:n,url:this.url,as:"text",method:this.method},r=e.Utils.jsonSortStringify(s),o=this.#C;let l=!1;if(e.Utils.isNullOrEmpty(o)||(l=r===o),l){const e=this._evaluateResult();a.resolve(e)}else e.Utils.extend(i,s),clearTimeout(this._debouncer),this._debouncer=setTimeout(()=>{i.fetch().then(e=>{const t=this._evaluateResult();a.resolve(t),this.#C=r},e=>{a.resolve(!1)})},1e3);return a.promise}#C;evaluate(t){return e.Utils.isNullOrEmpty(t)?e.Utils.fromResult(!0):(this._deferredToken=this._deferredToken=e.DeferPromise.defer(),this._fetch(t).then(e=>(this._deferredToken=null,e),e=>(this._deferredToken=null,!1)))}propertyChangedCallback(e,t,a,i){if(super.propertyChangedCallback(e,t,a,i),!i)switch(e){case"parameters":case"url":case"method":case"fetchCredentials":case"fetchHeaders":this.triggerFormFieldValidation()}}};__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Json})],c.prototype,"parameters",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Json})],c.prototype,"fetchCredentials",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Json})],c.prototype,"fetchHeaders",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String})],c.prototype,"url",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String})],c.prototype,"method",void 0),__decorate([e.ViewChild(e.P+"-fetch")],c.prototype,"_fetcher",void 0),c=__decorate([e.CustomElement({tagName:e.P+"-async-validator",template:t.BASIC_VALIDATOR_TEMPLATE+`<${e.P}-fetch autofetch="false" throttle="true" credentials="{{ :host.fetchCredentials }}" headers="{{ :host.fetchHeaders }}"></${e.P}-fetch>`,shadow:e.Defaults.USE_SHADOW_ROOT})],c),t.PacemAsyncValidatorElement=c;let d=class PacemCustomValidatorElement extends PacemBaseValidatorElement{propertyChangedCallback(e,t,a,i){super.propertyChangedCallback(e,t,a,i),i||"isValid"!==e||this.triggerFormFieldValidation()}evaluate(t){let i=!0;return a(t)||(i=!!this.isValid),e.Utils.fromResult(i)}};__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Boolean})],d.prototype,"isValid",void 0),d=__decorate([e.CustomElement({tagName:e.P+"-custom-validator",template:t.BASIC_VALIDATOR_TEMPLATE,shadow:e.Defaults.USE_SHADOW_ROOT})],d),t.PacemCustomValidatorElement=d}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){class PacemContenteditableButtonCommandElement extends t.PacemContenteditableCommandElement{cleanUp(e){}propertyChangedCallback(t,a,i,n){super.propertyChangedCallback(t,a,i,n),"range"===t&&(this.active=!e.Utils.isNull(i))}getTooltip(t=this.altText,a=this.keyboardShortcut){const i=t;return e.Utils.isNullOrEmpty(a)?i:`${i} (${a})`}}__decorate([e.Watch({converter:e.PropertyConverters.String})],PacemContenteditableButtonCommandElement.prototype,"icon",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],PacemContenteditableButtonCommandElement.prototype,"keyboardShortcut",void 0),__decorate([e.Watch({converter:e.PropertyConverters.String})],PacemContenteditableButtonCommandElement.prototype,"altText",void 0),__decorate([e.Watch({converter:e.PropertyConverters.Boolean})],PacemContenteditableButtonCommandElement.prototype,"active",void 0),t.PacemContenteditableButtonCommandElement=PacemContenteditableButtonCommandElement,t.CONTENTELEMENT_BUTTONCOMMAND_TEMPLATE=`<${e.P}-button disabled="{{ !:host.active }}" css-class="{{ {'text-primary': :host.isRelevant(:host.range)} }}" tooltip="{{ :host.getTooltip(:host.altText, :host.keyboardShortcut) }}" class="button" on-click=":host.execCommand()"><${e.P}-icon class="text-rootsize" icon="{{ :host.icon }}"></${e.P}-icon></${e.P}-button>\n <${e.P}-shortcut disabled="{{ !:host.active }}" target="{{ :host.contentElement }}" combination="{{ :host.keyboardShortcut }}" on-execute=":host.execCommand()"></${e.P}-shortcut>`}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){function a(e){return"format_align_"+e}let i=class PacemContenteditableAlignCommandElement extends t.PacemContenteditableButtonCommandElement{isRelevant(a){const i=t.ContenteditableUtils.findSurroundingSiblingBlockElements(a);if(e.Utils.isNullOrEmpty(i))return!1;const n=i[0];return getComputedStyle(n).textAlign==this.align}propertyChangedCallback(t,i,n,s){super.propertyChangedCallback(t,i,n,s),"align"===t&&((e.Utils.isNullOrEmpty(this.icon)||this.icon===a(i))&&(this.icon=a(n)),(e.Utils.isNullOrEmpty(this.altText)||this.altText===i)&&(this.altText=n))}exec(){const a=t.ContenteditableUtils.findSurroundingSiblingBlockElements(this.range);let i;for(let n of a)t.ContenteditableUtils.isBlockElement(n)&&n instanceof HTMLElement&&(e.Utils.isNull(i)&&(i=e.Utils.hasClass(n,"text-"+this.align)?"":this.align),n.style.textAlign="",e.Utils.removeClass(n,"text-left text-right text-center text-justify"),e.Utils.isEmpty(i)||e.Utils.addClass(n,"text-"+i));return Promise.resolve()}};__decorate([e.Watch({converter:e.PropertyConverters.String})],i.prototype,"align",void 0),i=__decorate([e.CustomElement({tagName:e.P+"-contenteditable-aligncommand",shadow:e.Defaults.USE_SHADOW_ROOT,template:t.CONTENTELEMENT_BUTTONCOMMAND_TEMPLATE})],i),t.PacemContenteditableAlignCommandElement=i}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){let a;function i(e){const t=e?.toLowerCase();switch(t){case"bold":case"italic":return"format_"+t;case"underline":return"format_underlined";case"strikethrough":return"strikethrough_s";case"insertorderedlist":return"format_list_numbered";case"insertunorderedlist":return"format_list_bulleted";case"justifyleft":case"justifyright":case"justifycenter":return"format_align_"+t.substr(7);case"justifyfull":return"format_align_justify";default:return"help_outline"}}function n(e,t){const a=e?.toLowerCase();switch(a){case"bold":return["b","strong"];case"italic":return["i","em"];case"underline":return["u"];case"strikethrough":return["strike","s","del"];case"insertorderedlist":return["ol"];case"insertunorderedlist":return["ul"];case"justifyleft":return[{style:{name:"text-align",value:"left"}}];case"justifyright":return[{style:{name:"text-align",value:"right"}}];case"justifycenter":return[{style:{name:"text-align",value:"center"}}];case"justifyfull":return[{style:{name:"text-align",value:"justify"}}];case"formatblock":return[t];default:return["none"]}}!function(e){e.Bold="bold",e.Italic="italic",e.Underline="underline",e.StrikeThrough="strikeThrough",e.OrderedList="insertOrderedList",e.UnorderedList="insertUnorderedList",e.JustifyLeft="justifyLeft",e.JustifyCenter="justifyCenter",e.JustifyRight="justifyRight",e.JustifyFull="justifyFull"}(a=t.KnownExecCommand||(t.KnownExecCommand={}));let s=class PacemContenteditableExecCommandElement extends t.PacemContenteditableButtonCommandElement{_matchRelevance(a,i){const n="object"==typeof i?t.ContenteditableUtils.findSurroundingNode(a,t=>t instanceof HTMLElement&&(e.Utils.isNullOrEmpty(i.tagName)||t.tagName===i.tagName.toUpperCase())&&t.style[i.style.name]===i.style.value):t.ContenteditableUtils.findSurroundingNode(a,i);return!e.Utils.isNull(n)}isRelevant(e){const t=n(this.command,this.argument);for(let a of t)if(this._matchRelevance(e,a))return!0;return!1}propertyChangedCallback(t,a,n,s){super.propertyChangedCallback(t,a,n,s),"command"===t&&((e.Utils.isNullOrEmpty(this.icon)||this.icon===i(a))&&(this.icon=i(n)),(e.Utils.isNullOrEmpty(this.altText)||this.altText===a)&&(this.altText=n))}exec(){return new Promise((a,i)=>{const s=this.range,r=n(this.command,this.argument)[0];if(!e.Utils.isNull(s)){const a=t.ContenteditableUtils.testInertElementWrapping(s);if(a.result&&"string"==typeof r&&["b","i","strike","u"].indexOf(r)>=0){const i=t.ContenteditableUtils.findSurroundingNode(s,r);if(e.Utils.isNull(i)||1!==i.childNodes.length){const e=document.createElement(r),i=a.element,n=s.extractContents();s.insertNode(e),e.append(n),t.ContenteditableUtils.select(i)}else{const e=i.childNodes.item(0),n=a.element;i.parentElement.replaceChild(e,i),t.ContenteditableUtils.select(n)}}else document.execCommand(this.command,!1,this.argument)}a()})}};__decorate([e.Watch({converter:e.PropertyConverters.String})],s.prototype,"command",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String})],s.prototype,"argument",void 0),s=__decorate([e.CustomElement({tagName:e.P+"-contenteditable-execcommand",shadow:e.Defaults.USE_SHADOW_ROOT,template:t.CONTENTELEMENT_BUTTONCOMMAND_TEMPLATE})],s),t.PacemContenteditableExecCommandElement=s}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){let a=class PacemContenteditableHistoryCommandElement extends t.PacemContenteditableButtonCommandElement{exec(){return new Promise((t,a)=>{const i=this.container?.history;if(!e.Utils.isNull(i)){if("redo"===this.command)i.canRedo&&(i.redo(),t());else i.canUndo&&(i.undo(),t());this.contentElement.innerHTML=i.current}})}isRelevant(e){return!1}propertyChangedCallback(e,t,a,i){if(super.propertyChangedCallback(e,t,a,i),"command"===e)this.icon=this.icon||a,this.altText=a,this.keyboardShortcut=this.keyboardShortcut||"Ctrl+"+("redo"===a?"Y":"Z")}containerPropertyChangedCallback(t,a,i,n){super.containerPropertyChangedCallback(t,a,i,n);const s=this.container,r=s.history;"range"!==t&&"history"!==t||(this.active=!e.Utils.isNull(s.range)&&("redo"===this.command&&r?.canRedo||"redo"!==this.command&&r?.canUndo))}};__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String,reflectBack:!0})],a.prototype,"command",void 0),a=__decorate([e.CustomElement({tagName:e.P+"-contenteditable-historycommand",shadow:e.Defaults.USE_SHADOW_ROOT,template:t.CONTENTELEMENT_BUTTONCOMMAND_TEMPLATE})],a),t.PacemContenteditableHistoryCommandElement=a}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){function a(t,a){return new Promise((i,n)=>{e.Utils.blobToDataURL(a).then(e.Utils.loadImage).then(e=>{const a=document.createElement("picture");a.setAttribute("contenteditable","false"),e.tabIndex=0,a.appendChild(e),t.deleteContents(),t.insertNode(a),i(a)})})}let i=class PacemContenteditableImageCommandElement extends t.PacemContenteditableButtonCommandElement{constructor(){super(...arguments),this._setBehaviorHandler=e=>{const a=e.target.parentElement;this.range=t.ContenteditableUtils.select(a)},this._disposeBehaviorHandler=e=>{}}pasteCallback(e){return e.type.startsWith("image")?a(this.range,e):Promise.reject()}cleanUp(t){t.querySelectorAll("picture[contenteditable=false]").forEach(e=>{for(let t=e.childNodes.length-1;t>0;t--)e.childNodes.item(t).remove()}),t.querySelectorAll("div."+e.PCSS+"-rescale").forEach(e=>e.remove())}isRelevant(e){return!1}viewActivatedCallback(){super.viewActivatedCallback(),e.Utils.isNullOrEmpty(this.altText)&&(this.altText="insert image"),e.Utils.isNullOrEmpty(this.icon)&&(this.icon="insert_photo"),e.Utils.isNullOrEmpty(this.keyboardShortcut)&&(this.keyboardShortcut="Ctrl+Shift+I"),this._rescale.addEventListener("rescale",this._rescaleImg,!1)}disconnectedCallback(){e.Utils.isNull(this._rescale)||(this._rescale.removeEventListener("rescale",this._rescaleImg,!1),this._disposeContainer()),super.disconnectedCallback()}propertyChangedCallback(t,a,i,n){switch(super.propertyChangedCallback(t,a,i,n),t){case"disabled":e.Utils.isNull(this._rescale)||(this._rescale.disabled=i);break;case"contentElement":a&&this._disposeContainer(a),i&&this._initContainer(i);break;case"range":this._rangeChangeCallback(a,i)}}exec(){return new Promise((t,i)=>{const n=this._file,s=this.range;n.onchange=i=>{const r=n.files[0];e.Utils.isNull(r)?t():a(s,r).then(e=>{n.value="",t()})},n.click()})}_rescaleImg(e){e.preventDefault();const t=e.detail.element,a=e.detail.targetRect,i=t.firstElementChild;i.style.width=a.width+"px",i.style.height=a.height+"px"}#P;_rangeChangeCallback(t,a){if(!e.Utils.isNull(t)&&!t.collapsed&&t.commonAncestorContainer instanceof Element&&t.commonAncestorContainer===t.startContainer&&t.commonAncestorContainer===t.endContainer&&t.startOffset===t.endOffset-1){const e=t.commonAncestorContainer.childNodes.item(t.startOffset);e instanceof HTMLPictureElement&&this._rescale.unregister(e)}if(!e.Utils.isNull(a)&&!a.collapsed&&a.commonAncestorContainer instanceof Element&&a.commonAncestorContainer===a.startContainer&&a.commonAncestorContainer===a.endContainer&&a.startOffset===a.endOffset-1){const e=a.commonAncestorContainer.childNodes.item(a.startOffset);e instanceof HTMLPictureElement&&this._rescale.register(e)}}_enhancePictureElement(e){e.firstElementChild&&(e.firstElementChild.addEventListener("focus",this._setBehaviorHandler,!1),e.firstElementChild.addEventListener("blur",this._disposeBehaviorHandler,!1))}_downgradePictureElement(e){e.firstElementChild&&(e.firstElementChild.removeEventListener("focus",this._setBehaviorHandler,!1),e.firstElementChild.removeEventListener("blur",this._disposeBehaviorHandler,!1))}_initContainer(e=this.contentElement){this.#P=new t.ContenteditableDOMObserver(e,(e,t)=>{e instanceof HTMLPictureElement&&(t?this._downgradePictureElement(e):this._enhancePictureElement(e))},"picture")}_disposeContainer(t=this.contentElement){const a=this.#P;e.Utils.isNull(a)||a.dispose()}};__decorate([e.ViewChild("input[type=file]")],i.prototype,"_file",void 0),__decorate([e.ViewChild(e.P+"-rescale")],i.prototype,"_rescale",void 0),i=__decorate([e.CustomElement({tagName:e.P+"-contenteditable-imagecommand",shadow:e.Defaults.USE_SHADOW_ROOT,template:`<input type="file" accept="image/png, image/gif, image/jpeg, image/bmp, image/x-icon" class="${e.PCSS}-trasparent ${e.PCSS}-inert" pacem hidden>`+t.CONTENTELEMENT_BUTTONCOMMAND_TEMPLATE+`<${e.P}-rescale keep-proportions="true"></${e.P}-rescale>`})],i),t.PacemContenteditableImageCommandElement=i}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){let a=class PacemContenteditableLinkCommandElement extends t.PacemContenteditableButtonCommandElement{isRelevant(a){return!e.Utils.isNull(t.ContenteditableUtils.findSurroundingNode(a,HTMLAnchorElement))}viewActivatedCallback(){super.viewActivatedCallback(),e.Utils.isNullOrEmpty(this.altText)&&(this.altText="insert link"),e.Utils.isNullOrEmpty(this.icon)&&(this.icon="insert_link"),e.Utils.isNullOrEmpty(this.keyboardShortcut)&&(this.keyboardShortcut="Ctrl+H")}exec(e,a=this.target){return new Promise((i,n)=>{var s=this.range,r=t.ContenteditableUtils.findSurroundingNode(s,HTMLAnchorElement),o="http://",l=/<a.*href=\"([^\"]*)/;if(r&&l.test(r.outerHTML)&&(o=l.exec(r.outerHTML)[1]),"current"===e)return"http://"==o?"":o;var c=e||void 0===e&&window.prompt("link (empty to unlink):",o);c?(document.execCommand("createLink",!1,c),(r=t.ContenteditableUtils.findSurroundingNode(s,HTMLAnchorElement))&&r.setAttribute("target",a||"_blank")):document.execCommand("unlink"),i()})}};__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.String})],a.prototype,"target",void 0),a=__decorate([e.CustomElement({tagName:e.P+"-contenteditable-linkcommand",shadow:e.Defaults.USE_SHADOW_ROOT,template:t.CONTENTELEMENT_BUTTONCOMMAND_TEMPLATE})],a),t.PacemContenteditableLinkCommandElement=a}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){function a(e){return e instanceof HTMLModElement&&"INS"===e.tagName}let i=class PacemContenteditablePlaceholderElement extends t.PacemContenteditableCommandElement{constructor(){super(...arguments),this._focusHandler=e=>{const a=e.target;this.range=t.ContenteditableUtils.select(a)}}#b;#E;cleanUp(t){t.querySelectorAll("ins[contenteditable=false]").forEach(t=>{e.Utils.removeClass(t,"placeholder-selected")})}exec(e){const a=function(e,t){const a=document.createElement("ins");return a.textContent=t,a.setAttribute("contenteditable","false"),a.tabIndex=0,e.deleteContents(),e.insertNode(a),a}(this.range,e);return t.ContenteditableUtils.select(a).collapse(!1),Promise.resolve(a)}isRelevant(e){return this.#b?.result??!1}viewActivatedCallback(){super.viewActivatedCallback(),this._fillDropdown(),this._initContainer()}propertyChangedCallback(e,t,a,i){if(super.propertyChangedCallback(e,t,a,i),!i)switch(e){case"datasource":this._fillDropdown();break;case"contentElement":t&&this._disposeContainer(t),a&&this._initContainer(a);break;case"range":this._changeRelevancy()}}disconnectedCallback(){this._disposeContainer(),super.disconnectedCallback()}_changeRelevancy(i=this.range){const n=this.#b;e.Utils.isNull(n?.element)||e.Utils.removeClass(n.element,"placeholder-selected");const s=this.#b=function(e){const i=t.ContenteditableUtils.testInertElementWrapping(e);if(i.result&&a(i.element)){const e=i.element;return{result:!0,element:e,placeholder:e.textContent}}return{result:!1}}(i);e.Utils.isNull(s?.element)||e.Utils.addClass(s.element,"placeholder-selected"),s.result?this._dropdown.value=s.placeholder:(this._dropdown.popout(),this._dropdown.value=void 0)}_fillDropdown(e=this.datasource||[]){const t=this.#E=e.map(e=>"string"==typeof e?{placeholder:e,definition:e}:e),a=this._dropdown;a.textProperty=a.valueProperty="placeholder",a.datasource=t}#P;_initContainer(e=this.contentElement){this.#P=new t.ContenteditableDOMObserver(e,(e,t)=>{a(e)&&(t?this._downgradePlaceholderElement(e):this._enhancePlaceholderElement(e))},"ins[contenteditable=false]")}_disposeContainer(t=this.contentElement){const a=this.#P;e.Utils.isNull(a)||a.dispose()}_enhancePlaceholderElement(e){e.addEventListener("focus",this._focusHandler,!1)}_downgradePlaceholderElement(e){e.removeEventListener("focus",this._focusHandler,!1)}};__decorate([e.ViewChild("template")],i.prototype,"_itemtemplate",void 0),__decorate([e.ViewChild(e.P+"-suggest")],i.prototype,"_dropdown",void 0),__decorate([e.Watch({emit:!1,converter:e.PropertyConverters.Json})],i.prototype,"datasource",void 0),i=__decorate([e.CustomElement({tagName:e.P+"-contenteditable-placeholder",shadow:e.Defaults.USE_SHADOW_ROOT,template:`<template>\n<${e.P}-span text="{{ ^item.viewValue }}" class="text-tech"></${e.P}-span>\n<${e.P}-markdown hide="{{ $pacem.isNullOrEmpty(^item.data.definition) || ^item.viewValue === ^item.data.definition }}" class="${e.PCSS}-margin margin-0 text-small" value="{{ ^item.data.definition }}"></${e.P}-markdown>\n</template>\n<${e.P}-suggest placeholder="Placeholder" class="pacem-button button" disabled="{{ $pacem.isNull(:host.range) }}"\n on-change=":host.execCommand($this.value)"\n css-class="{{ {'text-primary': :host.isRelevant(:host.range)} }}" \n compare-by="placeholder" text-property="placeholder" itemtemplate="{{ ::_itemtemplate }}" prevent-focus="true" allow-typing="false"></${e.P}-suggest>`})],i),t.PacemContenteditablePlaceholderElement=i}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){let a=class PacemContenteditableWrapCommandElement extends t.PacemContenteditableButtonCommandElement{isRelevant(a){return!e.Utils.isNull(t.ContenteditableUtils.findSurroundingNode(a,this.tagname))}exec(){return new Promise((a,i)=>{const n=this.tagname;if(!e.Utils.isNullOrEmpty(n)){const a=this.range,i=t.ContenteditableUtils.findSurroundingNode(a,n)||t.ContenteditableUtils.findSurroundingNode(a.startContainer,n)||t.ContenteditableUtils.findSurroundingNode(a.endContainer,n);if(e.Utils.isNull(i)){const i=t.ContenteditableUtils.findSurroundingSiblingBlockElements(a);if(!e.Utils.isNullOrEmpty(i)){const e=document.createElement(n);if(1===i.length){const n=i[0];a.setStart(n,0),a.setEnd(n,n.childNodes.length);const s=a.extractContents();e.append(s),t.ContenteditableUtils.copyAttributes(e,n),n.parentElement.insertBefore(e,n),n.remove()}else{a.setStartBefore(i[0]),a.setEndAfter(i[i.length-1]);const t=a.extractContents();e.append(t),a.insertNode(e)}t.ContenteditableUtils.select(e,!0).collapse()}}else{a.setStart(i,0),a.setEnd(i,i.childNodes.length);let e=!1;const n=i.childNodes;for(let a=0;a<n.length;a++){const i=n.item(a);if(!t.ContenteditableUtils.isBlockElement(i)){e=!0;break}}if(e){const e=document.createElement("p");t.ContenteditableUtils.copyAttributes(e,i),e.append(a.extractContents()),i.parentNode.replaceChild(e,i);t.ContenteditableUtils.select(e,!0).collapse()}else{i.parentNode.replaceChild(a.extractContents(),i);t.ContenteditableUtils.select(a.endContainer,!0).collapse()}}}a()})}};__decorate([e.Watch({converter:e.PropertyConverters.String})],a.prototype,"tagname",void 0),a=__decorate([e.CustomElement({tagName:e.P+"-contenteditable-wrapcommand",shadow:e.Defaults.USE_SHADOW_ROOT,template:t.CONTENTELEMENT_BUTTONCOMMAND_TEMPLATE})],a),t.PacemContenteditableWrapCommandElement=a}(t.Scaffolding||(t.Scaffolding={}))}(e.Components||(e.Components={}))}(Pacem||(Pacem={})),function(e){!function(e){!function(e){let t;!function(e){e.String="string",e.Number="number",e.Datetime="datetime",e.Boolean="boolean",e.Binary="binary",e.Object="object"}(t=e.ApiParameterType||(e.ApiParameterType={}));e.ApiParserBase=class ApiParserBase{async load(e,t){let a=await fetch(e,{mode:"cors",credentials:"omit",headers:t});try{let t=await a.json();return this.parse(t,e)}catch(e){return null}}};const a=/^#\/(definitions|components\/schemas)\/(.+)$/;e.getOpenApiDefinition=function(e,t){var i=a.exec(t);return i&&i.length>2?{name:i[2],schema:e.definitions[i[2]]}:null}}(e.OpenApi||(e.OpenApi={}))}(e.Scaffolding||(e.Scaffolding={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){class OpenApi3Parser extends t.ApiParserBase{parse(e,t){let a=e;"string"==typeof a&&(a=JSON.parse(a));const i=a,n=[],s=this._gatherDefinitions(new Map,i.components.schemas);for(let e in i.paths)for(let t in i.paths[e]){const a=i.paths[e][t];n.push({path:e,method:t.toUpperCase(),parameters:this._convertToApiParameters(a.parameters),response:this._tryGetResponse(s,a.responses)})}return{endpoints:n,definitions:s,baseUrl:t}}_convertToApiParameters(e=[]){const t=[];for(let a of e){const e=a.schema;"type"in e&&t.push({name:a.name,required:a.required,type:this._translateType(e.type,e.format)})}return t}_translateType(e,a){switch(e){case"number":case"integer":return t.ApiParameterType.Number;case"boolean":return t.ApiParameterType.Boolean;case"string":switch(a){case"date":case"date-time":return t.ApiParameterType.Datetime;case"byte":return t.ApiParameterType.Binary;case"binary":throw"Binary octets not supported."}return t.ApiParameterType.String}return t.ApiParameterType.String}_gatherDefinitions(e,t){const a={};for(let i in t)a[i]=this._findDefinition(e,t,i);return a}_findDefinition(e,t,a){if(e.has(a))return e.get(a);if(a in t){const i=t[a];return e.set(a,i),i}return null}_findDefinitionName(e){var t=/#\/components\/schemas\/(.+)/.exec(e);return null==t||t.length<2?e:t[1]}_tryGetResponse(t,a){let i,n={responses:a}.responses[200];if(e.Utils.isNullOrEmpty(n&&n.content))return null;for(let e in n.content){i=n.content[e].schema;break}let s,r,o="object";return"$ref"in i?(r=this._findDefinitionName(i.$ref),s=t[r]):(o=i.type,s=i,"array"===i.type&&("$ref"in i.items?(r=this._findDefinitionName(i.items.$ref),s=t[r]):s=i.items)),{type:o,fullType:r,meta:s}}}t.OpenApi3Parser=OpenApi3Parser}(t.OpenApi||(t.OpenApi={}))}(e.Scaffolding||(e.Scaffolding={}))}(Pacem||(Pacem={})),function(e){!function(t){!function(t){const a=e.Net.HttpMethod;class SwaggerParser extends t.ApiParserBase{_findDefinitionName(e){var t=/#\/definitions\/(.+)/.exec(e);return null==t||t.length<2?e:t[1]}parse(e,t){let i=e;"string"==typeof i&&(i=JSON.parse(i));const n=i;let s={};for(let e in n.definitions){s[this._findDefinitionName(e)]=n.definitions[e]}let r="";if(n.host&&n.schemes.length>0)r=n.schemes[0]+"://"+n.host+n.basePath;else if(t){let e=/^(https?):\/\/([^\/]+)/.exec(t);e&&e.length&&(!n.schemes&&e.length>1&&(n.schemes=[e[1]]),!n.host&&e.length>2&&(n.host=e[2],n.basePath=""),r=e[0])}else console.warn("Not able to find a base url from the OpenApi specs.");let o={endpoints:[],definitions:s,baseUrl:r};for(let e in n.paths){let t=n.paths[e];for(let i of[a.Get,a.Delete,a.Post,a.Put]){let a=t[i.toLowerCase()];if(a){let t=this._tryGetEndpoint(n,a,e,i);o.endpoints.push(t)}}}return o}_tryGetEndpoint(e,t,a,i){return{response:this._tryGetResponse(e,t),path:a,method:i,parameters:this._tryGetParameters(e,t)}}_translateType(e,a){switch(e){case"number":case"integer":return t.ApiParameterType.Number;case"boolean":return t.ApiParameterType.Boolean;case"string":switch(a){case"date":case"date-time":return t.ApiParameterType.Datetime;case"byte":return t.ApiParameterType.Binary;case"binary":throw"Binary octets not supported."}return t.ApiParameterType.String}return t.ApiParameterType.String}_tryGetParameters(e,a){return(a.parameters||[]).map(a=>{const i=a;let n={name:i.name,required:i.required||!1},s=a.type;if(a.schema){let i=a;n.type=t.ApiParameterType.Object;let s=n.fullType=this._findDefinitionName(i.schema.$ref);n.meta=e.definitions[s]}else s&&(n.type=this._translateType(s,a.format));return n})}_tryGetResponse(e,t){let a=t.responses[200];if(!a||!a.schema)return null;let i,n,s=a.schema.type||"object";return a.schema.$ref?(n=this._findDefinitionName(a.schema.$ref),i=e.definitions[n]):(i=a.schema,a.schema.items&&(a.schema.items.hasOwnProperty("$ref")?(n=this._findDefinitionName(a.schema.items.$ref),i=e.definitions[n]):i=a.schema.items)),{type:s,fullType:n,meta:i}}}t.SwaggerParser=SwaggerParser}(t.OpenApi||(t.OpenApi={}))}(e.Scaffolding||(e.Scaffolding={}))}(Pacem||(Pacem={})),function(e){!function(e){!function(e){class OpenApiParser extends e.ApiParserBase{constructor(t=new e.OpenApi3Parser,a=new e.SwaggerParser){super(),this._openApi3=t,this._swagger=a}parse(e,t){let a=e;"string"==typeof a&&(a=JSON.parse(a));const i=a;return"openapi"in i?this._openApi3.parse(i,t):this._swagger.parse(i,t)}}e.OpenApiParser=OpenApiParser}(e.OpenApi||(e.OpenApi={}))}(e.Scaffolding||(e.Scaffolding={}))}(Pacem||(Pacem={}));
|