@pacem/pacem 1.0.0-babbage → 1.0.0-bernoulli
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/browser/pacem-2d.js +1 -1
- package/dist/browser/pacem-2d.min.js +2 -2
- package/dist/browser/pacem-2d.min.js.map +1 -1
- package/dist/browser/pacem-3d.js +1 -1
- package/dist/browser/pacem-3d.min.js +2 -2
- package/dist/browser/pacem-3d.min.js.map +1 -1
- package/dist/browser/pacem-charts.js +1 -1
- package/dist/browser/pacem-charts.min.js +2 -2
- package/dist/browser/pacem-charts.min.js.map +1 -1
- package/dist/browser/pacem-cms.js +1 -1
- package/dist/browser/pacem-cms.min.js +2 -2
- package/dist/browser/pacem-cms.min.js.map +1 -1
- package/dist/browser/pacem-core.js +1 -1
- package/dist/browser/pacem-core.min.js +2 -2
- package/dist/browser/pacem-core.min.js.map +1 -1
- package/dist/browser/pacem-foundation.js +1 -1
- package/dist/browser/pacem-foundation.min.js +2 -2
- package/dist/browser/pacem-foundation.min.js.map +1 -1
- package/dist/browser/pacem-fx.js +1 -1
- package/dist/browser/pacem-fx.min.js +2 -2
- package/dist/browser/pacem-fx.min.js.map +1 -1
- package/dist/browser/pacem-logging.js +1 -1
- package/dist/browser/pacem-logging.min.js +2 -2
- package/dist/browser/pacem-logging.min.js.map +1 -1
- package/dist/browser/pacem-maps.js +1 -1
- package/dist/browser/pacem-maps.min.js +2 -2
- package/dist/browser/pacem-maps.min.js.map +1 -1
- package/dist/browser/pacem-media.js +1 -1
- package/dist/browser/pacem-media.min.js +2 -2
- package/dist/browser/pacem-media.min.js.map +1 -1
- package/dist/browser/pacem-networking.js +1 -1
- package/dist/browser/pacem-networking.min.js +2 -2
- package/dist/browser/pacem-networking.min.js.map +1 -1
- package/dist/browser/pacem-numerical.js +1 -1
- package/dist/browser/pacem-numerical.min.js +2 -2
- package/dist/browser/pacem-numerical.min.js.map +1 -1
- package/dist/browser/pacem-plus.js +1 -1
- package/dist/browser/pacem-plus.min.js +2 -2
- package/dist/browser/pacem-plus.min.js.map +1 -1
- package/dist/browser/pacem-scaffolding.js +1 -1
- package/dist/browser/pacem-scaffolding.min.js +2 -2
- package/dist/browser/pacem-scaffolding.min.js.map +1 -1
- package/dist/browser/pacem-ui.js +1 -1
- package/dist/browser/pacem-ui.min.js +2 -2
- package/dist/browser/pacem-ui.min.js.map +1 -1
- package/dist/bundle/pacem.min.mjs +1 -1
- package/dist/bundle/pacem.mjs +1 -1
- package/dist/typings/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @pacem/pacem v1.0.0-
|
|
2
|
+
* @pacem/pacem v1.0.0-bernoulli (https://js.pacem.it)
|
|
3
3
|
* Pacem (https://pacem.it)
|
|
4
4
|
* Licensed under Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
!function(e,t,i,r){"use strict";const s="change";class a extends t.CustomTypedEvent{constructor(e){super(s,e,{bubbles:!0,cancelable:!1})}}var n;!function(e){e.String="string",e.Number="number",e.Datetime="datetime",e.Boolean="boolean",e.Binary="binary",e.Object="object"}(n||(n={}));class o{async load(e,t){let i=await fetch(e,{mode:"cors",credentials:"omit",headers:t});try{let t=await i.json();return this.parse(t,e)}catch(e){return null}}}const l=/^#\/(definitions|components\/schemas)\/(.+)$/;const c=t.Net.HttpMethod;class d extends o{_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 r=i;let s={};for(let e in r.definitions){s[this._findDefinitionName(e)]=r.definitions[e]}let a="";if(r.host&&r.schemes.length>0)a=r.schemes[0]+"://"+r.host+r.basePath;else if(t){let e=/^(https?):\/\/([^\/]+)/.exec(t);e&&e.length&&(!r.schemes&&e.length>1&&(r.schemes=[e[1]]),!r.host&&e.length>2&&(r.host=e[2],r.basePath=""),a=e[0])}else console.warn("Not able to find a base url from the OpenApi specs.");let n={endpoints:[],definitions:s,baseUrl:a};for(let e in r.paths){let t=r.paths[e];for(let i of[c.Get,c.Delete,c.Post,c.Put]){let s=t[i.toLowerCase()];if(s){let t=this._tryGetEndpoint(r,s,e,i);n.endpoints.push(t)}}}return n}_tryGetEndpoint(e,t,i,r){return{response:this._tryGetResponse(e,t),path:i,method:r,parameters:this._tryGetParameters(e,t)}}_translateType(e,t){switch(e){case"number":case"integer":return n.Number;case"boolean":return n.Boolean;case"string":switch(t){case"date":case"date-time":return n.Datetime;case"byte":return n.Binary;case"binary":throw"Binary octets not supported."}return n.String}return n.String}_tryGetParameters(e,t){return(t.parameters||[]).map(t=>{const i=t;let r={name:i.name,required:i.required||!1},s=t.type;if(t.schema){let i=t;r.type=n.Object;let s=r.fullType=this._findDefinitionName(i.schema.$ref);r.meta=e.definitions[s]}else s&&(r.type=this._translateType(s,t.format));return r})}_tryGetResponse(e,t){let i=t.responses[200];if(!i||!i.schema)return null;let r,s,a=i.schema.type||"object";return i.schema.$ref?(s=this._findDefinitionName(i.schema.$ref),r=e.definitions[s]):(r=i.schema,i.schema.items&&(i.schema.items.hasOwnProperty("$ref")?(s=this._findDefinitionName(i.schema.items.$ref),r=e.definitions[s]):r=i.schema.items)),{type:a,fullType:s,meta:r}}}class h extends o{parse(e,t){let i=e;"string"==typeof i&&(i=JSON.parse(i));const r=i,s=[],a=this._gatherDefinitions(new Map,r.components.schemas);for(let e in r.paths)for(let t in r.paths[e]){const i=r.paths[e][t];s.push({path:e,method:t.toUpperCase(),parameters:this._convertToApiParameters(i.parameters),response:this._tryGetResponse(a,i.responses)})}return{endpoints:s,definitions:a,baseUrl:t}}_convertToApiParameters(e=[]){const t=[];for(let i of e){const e=i.schema;"type"in e&&t.push({name:i.name,required:i.required,type:this._translateType(e.type,e.format)})}return t}_translateType(e,t){switch(e){case"number":case"integer":return n.Number;case"boolean":return n.Boolean;case"string":switch(t){case"date":case"date-time":return n.Datetime;case"byte":return n.Binary;case"binary":throw"Binary octets not supported."}return n.String}return n.String}_gatherDefinitions(e,t){const i={};for(let r in t)i[r]=this._findDefinition(e,t,r);return i}_findDefinition(e,t,i){if(e.has(i))return e.get(i);if(i in t){const r=t[i];return e.set(i,r),r}return null}_findDefinitionName(e){var t=/#\/components\/schemas\/(.+)/.exec(e);return null==t||t.length<2?e:t[1]}_tryGetResponse(e,i){let r,s={responses:i}.responses[200];if(t.Utils.isNullOrEmpty(s&&s.content))return null;for(let e in s.content){r=s.content[e].schema;break}let a,n,o="object";return"$ref"in r?(n=this._findDefinitionName(r.$ref),a=e[n]):(o=r.type,a=r,"array"===r.type&&("$ref"in r.items?(n=this._findDefinitionName(r.items.$ref),a=e[n]):a=r.items)),{type:o,fullType:n,meta:a}}}var p=Object.freeze({__proto__:null,get ApiParameterType(){return n},ApiParserBase:o,OpenApi3Parser:h,OpenApiParser:class extends o{constructor(e=new h,t=new d){super(),this._openApi3=e,this._swagger=t}parse(e,t){let i=e;"string"==typeof i&&(i=JSON.parse(i));const r=i;return"openapi"in r?this._openApi3.parse(r,t):this._swagger.parse(r,t)}},SwaggerParser:d,getOpenApiDefinition:function(e,t){var i=l.exec(t);return i&&i.length>2?{name:i[2],schema:e.definitions[i[2]]}:null}}),u=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};const m={display:(e,t,i)=>i[`${e}_${t}`],validator:(e,t,i,r)=>r["validator_"+e+"_"+i]??r["validator_"+e+t+"_"+i],commandTooltip:(e,t)=>t["command_tooltip_"+e]};class v{static localizeMetadata(e,t,i){return v._localizeMetadata(e,t,i)}static _localizeMetadata(e,i,r,s=""){r=t.Utils.extend({},m,r);for(let a of e.props){if("props"in a&&"object"==typeof a.props&&!t.Utils.isArray(a.props)){const e=s+a.prop+".";a.props=v._localizeMetadata(a.props,i,r,e)}const e=a.display=a.display??{},n=s+a.prop;if(e.name=r.display("name",n,i)??e.name,e.watermark=r.display("watermark",n,i)??e.watermark,e.description=r.display("description",n,i)??e.description,!t.Utils.isNullOrEmpty(a.commands))for(let e of a.commands){const s=r.commandTooltip(e.name,i);t.Utils.isNullOrEmpty(s)||(e.tooltip=s)}if(!t.Utils.isNullOrEmpty(a.validators)){const e={};for(let s of a.validators){const a=s.type;if("string"==typeof a){const o=e[a]=(e[a]??-1)+1,l=r.validator(a,o,n,i);t.Utils.isNullOrEmpty(l)||(s.errorMessage=l)}}}}return e}}u([t.Transformer("forms.localizeMetadata")],v,"localizeMetadata",null);var g=Object.freeze({__proto__:null,Forms:v}),y=Object.freeze({__proto__:null,FieldChangeEvent:a,FieldChangeEventName:s,L10n:g,OpenApi:p}),f=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};const _="submit",b="reset";class C extends t.CustomTypedEvent{constructor(e){super(_,e,{bubbles:!0,cancelable:!0})}}class P extends Event{constructor(){super(b,{bubbles:!0,cancelable:!0})}}const w=["download",s,t.CommandEventName],E=!1;class S{constructor(e){this._element=e,this._itemEmitHandler=e=>{if(this._element.handle(e),e.type===t.CommandEventName){const t=e;this._element.handle(new CustomEvent("item"+t.detail.commandName.toLowerCase(),{detail:t.detail.commandArgument}))}}}start(){w.forEach(e=>this._element.addEventListener(e,this._itemEmitHandler,!1))}stop(){w.forEach(e=>this._element.removeEventListener(e,this._itemEmitHandler,!1))}}class $ extends t.Components.PacemElement{viewActivatedCallback(){super.viewActivatedCallback(),this.form=t.CustomElementUtils.findAncestorOfType(this,k)}}f([t.Watch({converter:t.PropertyConverters.Element})],$.prototype,"form",void 0);let k=class extends ${constructor(){super("form"),this.method=t.Net.HttpMethod.Post,this._emitter=null,this._buttons={submit:void 0,reset:void 0},this.#e=!1,this._keyupHandler=e=>{if(!(13!==e.keyCode||e.shiftKey||e.ctrlKey||e.altKey||e.metaKey)){let i=e.currentTarget.querySelector(t.P+"-button[type=submit]");t.Utils.isNull(i)||!t.Utils.isVisible(i)||i.disabled||i.click()}},this._submit=(e,i)=>{t.Utils.isNull(i)||t.avoidHandler(i),Promise.all(this._validateAllFields()).then(t=>{-1===t.findIndex(e=>!1===e)&&this.submit(e).then(e=>{this.setPristine()},e=>{})})},this._reset=e=>{t.Utils.isNull(e)||t.avoidHandler(e);var i=new P;if(this.dispatchEvent(i),!i.defaultPrevented){for(var r in this._fields){var s=this._fields[r];s instanceof O&&s.reset()}for(var a of this._subForms)a._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,i=t.watch;if("invalid"===e.detail.propertyName){let e=this._fields[t.watch];t.invalid?e.valid=!1:this._checkFieldValidity(i)}else this._checkFieldValidity(i)},this.suddenValidation=!0,this.resettable=!0,this._emitter=new S(this)}propertyChangedCallback(e,i,r,s){super.propertyChangedCallback(e,i,r,s),("method"===e&&!0===this.autogenerate&&!t.Utils.isNullOrEmpty(this.metadata)||"metadata"===e&&!0===this.autogenerate||"autogenerate"===e&&!0===r&&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 e="_"+t.Utils.uniqueCode(),i=this.id=this.id||e,r="fetch"+e,s=document.createElement("form");s.id="form"+e,s.className=t.PCSS+"-form",s.setAttribute("pacem",""),s.setAttribute("novalidate","");const a=`<${t.P}-repeater datasource="{{ #${i}.metadata && (#${i}.metadata.props || #${i}.metadata) }}">\n <${t.P}-panel css="{{ #${i}.metadata.display && #${i}.metadata.display.css }}" css-class="{{ (#${i}.metadata.display && #${i}.metadata.display.cssClass || []).concat(#${i}.suddenValidation ? [] : ['lazy-validation']) }}" class="${t.PCSS}-animatable-list ${t.PCSS}-list-appear">\n <template>\n <${t.P}-form-field fetch-credentials="{{ #${i}.fetchCredentials }}" fetch-headers="{{ #${i}.fetchHeaders }}"\n logger="{{ #${i}.logger }}" entity="{{ #${i}.entity, twoway }}" \n metadata="{{ ^item }}" readonly="{{ #${i}.readonly || ^item.isReadOnly }}"></${t.P}-form-field>\n </template>\n </${t.P}-panel>\n</${t.P}-repeater>\n<${t.P}-fetch logger="{{ #${i}.logger }}" id="${r}" method="${this.method}" credentials="{{ #${i}.fetchCredentials }}" headers="{{ #${i}.fetchHeaders }}"></${t.P}-fetch> \n<div class="${t.PCSS}-buttonset buttons">\n <div class="buttonset-left">\n <${t.P}-button logger="{{ #${i}.logger }}" on-click="#${i}._submit(#${i}.fetcher || #${r}, $event)" type="submit" hide="{{ #${i}.readonly || $pacem.isNullOrEmpty(#${i}.action) || !$pacem.isNull(#${i}.form) }}"\nclass="button primary button-size size-small"\ncss-class="{{ {'buttonset-last': !#${i}.resettable || !#${i}.dirty || !$pacem.isNull(#${i}.form) } }}" \ndisabled="{{ (#${i}.suddenValidation && (!(#${i}.valid && #${i}.dirty))) || #${i}.fetching }}">\n <${t.P}-panel class="submit-spinner ${t.PCSS}-anim anim-pop" hide="{{ !#${i}.fetching }}"><i class="${t.PCSS}-icon ${t.PCSS}-anim anim-rotate rotate-uniform display-block">refresh</i></${t.P}-panel>\n <${t.P}-text text="{{ #${i}.submitCaption || 'OK' }}"></${t.P}-text>\n </${t.P}-button>\n <${t.P}-button logger="{{ #${i}.logger }}" on-click="#${i}._reset($event)" type="reset" class="button button-size size-small" css-class="{{ {'buttonset-first': #${i}.readonly || $pacem.isNullOrEmpty(#${i}.action) || !$pacem.isNull(#${i}.form)} }}" hide="{{ !#${i}.resettable || #${i}.readonly || !#${i}.dirty || !$pacem.isNull(#${i}.form) }}" disabled="{{ #${i}.fetching }}">\n <${t.P}-text text="{{ #${i}.resetCaption || 'Reset' }}"></${t.P}-text>\n </${t.P}-button>\n</div></div>`;s.innerHTML=a,this.innerHTML="",this.appendChild(s),s.addEventListener("submit",t.avoidHandler,!1);const n=this._buttons,o=this._buttons={submit:s.lastElementChild.firstElementChild.firstElementChild,reset:s.lastElementChild.firstElementChild.lastElementChild};this.dispatchEvent(new t.PropertyChangeEvent({propertyName:"formButtons",currentValue:o,oldValue:n}))}get formButtons(){return this._buttons}#e;get fetching(){return this.#e}submit(e){return new Promise((i,r)=>{t.Utils.isNull(e)&&r("Fetcher cannot be null while submitting a form."),this._submitInternally(e).then(e=>{this.dispatchEvent(new CustomEvent("success",{detail:e})),i(e)},e=>{e!==E&&this.dispatchEvent(new CustomEvent("fail",{detail:e})),r(e)})})}reset(){this._reset()}_submitInternally(e,i){if(t.Utils.isNull(e))throw"Fetcher cannot be null while submitting a form.";var r=t.DeferPromise.defer();const s=this.entity,a=this.entityName;var n={};t.Utils.isNullOrEmpty(a)?n=s:n[a]=s;i={parameters:n,fields:this._getAllFields()};var o=new C(i);if(this.dispatchEvent(o),o.defaultPrevented)r.reject(E);else{e.parameters=t.Utils.extend({},o.detail.parameters);const i=n=>{e.removeEventListener(t.Net.FetchSuccessEventName,i,!1),e.removeEventListener(t.Net.FetchErrorEventName,a,!1);const o=n.detail;if(t.Net.Fetcher.isEmpty(o)&&(e.removeEventListener(t.Net.FetchResultEventName,s,!1),this.success=!0,r.resolve({})),205===o.status)this._reset()},s=i=>{e.removeEventListener(t.Net.FetchResultEventName,s,!1);var a=i.detail;"object"==typeof a&&a.hasOwnProperty("success")?!0===a.success?(this.success=!0,r.resolve(a.result||{})):(this.fail=!0,r.reject(a.error)):(this.success=!0,r.resolve(a))},a=n=>{e.removeEventListener(t.Net.FetchSuccessEventName,i,!1),e.removeEventListener(t.Net.FetchResultEventName,s,!1),e.removeEventListener(t.Net.FetchErrorEventName,a,!1),this.fail=!0;const o=n.detail;r.reject(o)},n=i=>{if("fetching"===i.detail.propertyName)!0===i.detail.currentValue?(t.Utils.addClass(this,t.PCSS+"-fetching"),this.#e=!0,this.dispatchEvent(new t.PropertyChangeEvent({currentValue:!0,oldValue:!1,propertyName:"fetching"}))):(this.#e=!1,this.dispatchEvent(new t.PropertyChangeEvent({currentValue:!1,oldValue:!0,propertyName:"fetching"})),t.Utils.removeClass(this,t.PCSS+"-fetching"),e.removeEventListener(t.PropertyChangeEventName,n,!1))};e.addEventListener(t.PropertyChangeEventName,n,!1),e.addEventListener(t.Net.FetchSuccessEventName,i,!1),e.addEventListener(t.Net.FetchResultEventName,s,!1),e.addEventListener(t.Net.FetchErrorEventName,a,!1),t.Utils.isNullOrEmpty(this.action)||(e.url=this.action),e instanceof t.Components.PacemFetchElement&&!e.autofetch&&e.fetch(),this.success=this.fail=!1}return r.promise}_getAllFields(e={}){for(var i of(t.Utils.extend(e,this._fields),this._subForms))i._getAllFields(e);return e}apply(e){if(!t.Utils.isNullOrEmpty(e)){this.entity=t.Utils.extend({},this.entity,e);for(let t in e)this.setDirty(t)}}setPristine(...e){this._setAs(!1,...e)}setDirty(...e){this._setAs(!0,...e)}_setAs(e,...i){const r=!t.Utils.isEmpty(i);for(let t in this._fields)if(!r||i.indexOf(t)>=0){const i=this._fields[t];i instanceof O&&(e?i.setDirty():i.setPristine())}for(let t of this._subForms)e?t.setDirty(...i):t.setPristine(...i)}_checkFieldValidity(e){return this.suddenValidation?e in this._fields?this._validateField(e,!1):Promise.resolve(!1):Promise.resolve(null)}validate(e){return t.Utils.isNullOrEmpty(e)?Promise.all(this._validateAllFields()).then(e=>!e.some(e=>!1===e)):this._validateField(e,!1)}_validateAllFields(e=!0){const t=[];for(let i in this._fields)t.push(this._validateField(i,e));for(let i of this._subForms)Array.prototype.push.apply(t,i._validateAllFields(e));return t}_validateField(e,i){return new Promise((r,s)=>{var a=this._fields[e];if(a){var n=this._validators[a.name];n&&n.length>0?(this.log(t.Logging.LogLevel.Log,`Computing "${a.name}" validity.`),Promise.all(n.map(e=>e.validate(a.value).then(t=>!(e.invalid=!t)))).then(e=>{let s=!0;for(var n of e)if(!1===n){s=!1,i&&a.setDirty();break}this.log(t.Logging.LogLevel.Log,`Property "${a.name}" turns out to be ${s?"":"not "}valid.`),r(a.valid=s)})):(this.log(t.Logging.LogLevel.Log,`Property "${a.name}" has no validators.`),r(a.valid=!0))}else this.log(t.Logging.LogLevel.Log,`Property "${e}" has no fields in this form.`),r(!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 i of this._subForms)if(i.dirty){e=!0;break}this.dirty=e}_checkValidity(){let e=!0;for(var i in this._fields)if(this.log(t.Logging.LogLevel.Log,`Checking "${i}" validity.`),!1===this._fields[i].valid){this.log(t.Logging.LogLevel.Log,`"${i}" is not valid.`),e=!1;break}if(!0===e)for(var r of this._subForms)if(!r.valid){e=!1;break}this.valid=e}registerSubForm(e){let i=this._subForms;-1==i.indexOf(e)&&(e.addEventListener(t.PropertyChangeEventName,this._fieldPropertyChanged,!1),i.push(e),this._checkValidity(),this._checkDirtyness())}unregisterSubForm(e){let i=this._subForms,r=i.indexOf(e);r>=0&&(e.removeEventListener(t.PropertyChangeEventName,this._fieldPropertyChanged,!1),i.splice(r,1),this._checkValidity(),this._checkDirtyness())}registerField(e,i){var r=this._fields;r[e]!=i&&(this.unregisterField(e,!1),r[e]=i,this.log(t.Logging.LogLevel.Log,`Registering "${e}" field.`),i instanceof HTMLElement&&i.addEventListener(t.PropertyChangeEventName,this._fieldPropertyChanged,!1),this._checkFieldValidity(e),this._checkDirtyness())}unregisterField(e,i=!0){var r=this._fields,s=r[e];s instanceof HTMLElement&&s.removeEventListener(t.PropertyChangeEventName,this._fieldPropertyChanged,!1),delete r[e],s&&!0===i&&(this._checkValidity(),this._checkDirtyness())}registerValidator(e,i){var r=this._validators[e]=this._validators[e]||[];-1==r.indexOf(i)&&(r.push(i),i instanceof HTMLElement&&i.addEventListener(t.PropertyChangeEventName,this._validatorPropertyChanged,!1),this.log(t.Logging.LogLevel.Log,`Calling "${e}" validity check after validator registration.`),this._checkFieldValidity(e))}unregisterValidator(e,t){this._unregisterValidator(e,t,!0)}_unregisterValidator(e,i,r){var s=this._validators[e]=this._validators[e]||[],a=s.indexOf(i);a>=0&&(i instanceof HTMLElement&&i.removeEventListener(t.PropertyChangeEventName,this._validatorPropertyChanged,!1),s.splice(a,1),r&&this._checkFieldValidity(e))}};f([t.Watch({emit:!1,converter:t.PropertyConverters.Element})],k.prototype,"fetcher",void 0),f([t.Watch({emit:!1,converter:t.PropertyConverters.String})],k.prototype,"fetchCredentials",void 0),f([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],k.prototype,"fetchHeaders",void 0),f([t.Watch({reflectBack:!0,converter:t.PropertyConverters.String})],k.prototype,"method",void 0),f([t.Watch({reflectBack:!0,converter:t.PropertyConverters.String})],k.prototype,"submitCaption",void 0),f([t.Watch({reflectBack:!0,converter:t.PropertyConverters.String})],k.prototype,"resetCaption",void 0),f([t.Debounce(100)],k.prototype,"_buildUpForm",null),f([t.Watch({reflectBack:!0,converter:t.PropertyConverters.Boolean})],k.prototype,"valid",void 0),f([t.Watch({reflectBack:!0,converter:t.PropertyConverters.Boolean})],k.prototype,"dirty",void 0),f([t.Watch({reflectBack:!0,converter:t.PropertyConverters.Boolean})],k.prototype,"readonly",void 0),f([t.Watch({converter:t.PropertyConverters.Boolean})],k.prototype,"success",void 0),f([t.Watch({converter:t.PropertyConverters.Boolean})],k.prototype,"fail",void 0),f([t.Watch({converter:t.PropertyConverters.Json})],k.prototype,"entity",void 0),f([t.Watch({emit:!1,converter:t.PropertyConverters.String})],k.prototype,"entityName",void 0),f([t.Watch()],k.prototype,"metadata",void 0),f([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],k.prototype,"autogenerate",void 0),f([t.Watch({converter:t.PropertyConverters.Boolean})],k.prototype,"suddenValidation",void 0),f([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],k.prototype,"resettable",void 0),f([t.Watch({converter:t.PropertyConverters.String})],k.prototype,"action",void 0),k=f([t.CustomElement({tagName:t.P+"-form"})],k);var U=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};const N="pacem:model:original-value";class O extends ${viewActivatedCallback(){super.viewActivatedCallback(),this._registerFieldConditionally(),this._setAsOriginalValue(this.value)}_registerFieldConditionally(){const e=this.name,i=this.form;if(!(t.Utils.isNullOrEmpty(e)||t.Utils.isNull(i)||this.hasAttribute("autobind")&&("off"===this.getAttribute("autobind")||"false"===this.getAttribute("autobind"))||(i.registerField(e,this),this.hasAttribute("value")))){const r=i.id=i.id||"frm_"+t.Utils.uniqueCode();this.setAttribute("value",`{{ #${r}.entity.${e}, twoway }}`)}}propertyChangedCallback(e,i,r,s){switch(super.propertyChangedCallback(e,i,r,s),e){case"value":this.viewValue=this.getViewValue(r);break;case"valid":r?t.Utils.removeClass(this,t.PCSS+"-invalid"):t.Utils.addClass(this,t.PCSS+"-invalid");break;case"dirty":r?t.Utils.addClass(this,t.PCSS+"-dirty"):t.Utils.removeClass(this,t.PCSS+"-dirty");break;case"name":let e=this.form;null!=e&&i&&e.unregisterField(i),this._registerFieldConditionally();break;case"form":let s=this.name;t.Utils.isNullOrEmpty(s)||null!=i&&i.unregisterField(s),this._registerFieldConditionally()}}disconnectedCallback(){let e=this.name,i=this.form;t.Utils.isNullOrEmpty(e)||t.Utils.isNull(i)||i.unregisterField(e),super.disconnectedCallback()}get originalValue(){return t.CustomElementUtils.getAttachedPropertyValue(this,N)}_setAsOriginalValue(e){t.CustomElementUtils.setAttachedPropertyValue(this,N,e)}reset(){this.value=this.originalValue,this.dirty=!1}setPristine(){this._setAsOriginalValue(this.value),this.dirty=!1}setDirty(){this.dirty=!0}}U([t.Watch({converter:t.PropertyConverters.String})],O.prototype,"viewValue",void 0),U([t.Watch({converter:{convert:(e,t)=>t instanceof O?t.convertValueAttributeToProperty(e):e,convertBack:e=>e.toString()}})],O.prototype,"value",void 0),U([t.Watch({converter:t.PropertyConverters.Boolean})],O.prototype,"dirty",void 0),U([t.Watch({converter:t.PropertyConverters.Boolean})],O.prototype,"valid",void 0),U([t.Watch({converter:t.PropertyConverters.String})],O.prototype,"name",void 0);class x extends O{constructor(){super(...arguments),this.focusHandler=e=>{const i=(e=!0)=>{t.Utils.hasClass(this.parentElement,"."+t.PCSS+"-fieldgroup")&&(e?t.Utils.addClass:t.Utils.removeClass).apply(this,[this.parentElement,t.PCSS+"-focus"])};switch(e.type){case"focus":t.Utils.addClass(this,t.PCSS+"-focus"),i(),this._preFocusValue=this.value;break;case"blur":t.Utils.removeClass(this,t.PCSS+"-focus"),i(!1)}e.bubbles?this.emit(e):this.dispatchEvent(new FocusEvent(e.type))},this.changeHandler=e=>{const t=this.value;this.onChange(e).then(e=>{this.compareValuePropertyValues(t,e)||(this.dispatchEvent(new a({fieldName:this.name,oldValue:t,currentValue:e,firstChange:!this.dirty})),this.dirty=!0)},e=>{})},this.keydownHandler=e=>{t.stopPropagationHandler(e)},this.keyupHandler=e=>{switch(e.keyCode){case 27:t.stopPropagationHandler(e),this.compareValuePropertyValues(this.originalValue,this._preFocusValue)?this.reset():this.value=this._preFocusValue,this.blur();break;case 13:this.preventKeyboardSubmit&&t.stopPropagationHandler(e)}}}compareValuePropertyValues(e,i){return t.DefaultComparer(e,i)}get preventKeyboardSubmit(){return!1}propertyChangedCallback(e,i,r,s){switch(super.propertyChangedCallback(e,i,r,s),e){case"required":case"disabled":case"autofocus":case"placeholder":case"readonly":for(let t of this.inputFields)r?t.setAttribute(e,r):t.removeAttribute(e);break;case"tabOrder":for(let e of this.inputFields)e.setAttribute("tabindex",r);break;case"value":this.acceptValue(r)}if("required"===e||"disabled"===e||"readonly"===e){let i=`${t.PCSS}-${e}`;r?t.Utils.addClass(this,i):t.Utils.removeClass(this,i)}"readonly"===e?this.toggleReadonlyView(r):"required"===e?this.aria.attributes.set("required",!!r+""):"valid"===e&&this.aria.attributes.set("invalid",(!r&&!!this.dirty)+"")}registerInputFields(e=this.inputFields){t.Utils.isNull(e)||t.Utils.isArray(e)||(e=[e]);for(let i of e)i.addEventListener("focus",this.focusHandler,!1),i.addEventListener("blur",this.focusHandler,!1),i.addEventListener("change",this.changeHandler,!1),i.addEventListener("keydown",this.keydownHandler,!1),i.addEventListener("keyup",this.keyupHandler,!1),i.addEventListener("mousedown",t.stopPropagationHandler,!1),i.addEventListener("touchstart",t.stopPropagationHandler,{passive:!1,capture:!1})}unregisterInputFields(e=this.inputFields){t.Utils.isNull(e)||t.Utils.isArray(e)||(e=[e]);for(let i of e)t.Utils.isNull(i)||(i.removeEventListener("touchstart",t.stopPropagationHandler,{capture:!1}),i.removeEventListener("keydown",this.keydownHandler,!1),i.removeEventListener("keyup",this.keyupHandler,!1),i.removeEventListener("mousedown",t.stopPropagationHandler,!1),i.removeEventListener("change",this.changeHandler,!1),i.removeEventListener("focus",this.focusHandler,!1),i.removeEventListener("blur",this.focusHandler,!1))}viewActivatedCallback(){if(super.viewActivatedCallback(),this.toggleReadonlyView(this.readonly||!1),!t.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 e=this.inputFields;if(!t.Utils.isNullOrEmpty(e))for(let t of e)t.blur()}}U([t.Watch({converter:t.PropertyConverters.Boolean})],x.prototype,"required",void 0),U([t.Watch({converter:t.PropertyConverters.Boolean})],x.prototype,"autofocus",void 0),U([t.Watch({converter:t.PropertyConverters.Boolean})],x.prototype,"readonly",void 0),U([t.Watch({converter:t.PropertyConverters.String})],x.prototype,"name",void 0),U([t.Watch({converter:t.PropertyConverters.String})],x.prototype,"placeholder",void 0);class V extends t.Components.PacemElement{#t;findContainer(){return t.CustomElementUtils.findAncestor(this,e=>e instanceof D)}get container(){return this.#t}viewActivatedCallback(){super.viewActivatedCallback();const e=this.#t=this.findContainer();t.Utils.isNull(e)||e.register(this)}disconnectedCallback(){t.Utils.isNull(this.#t)||this.#t.unregister(this),super.disconnectedCallback()}}class D extends x{register(e){let i=!0;return t.Utils.isNull(this.items)?this.items=[e]:-1===this.items.indexOf(e)?this.items.push(e):i=!1,i}unregister(e){const i=!t.Utils.isNull(this.items)&&this.items.indexOf(e);return i>=0&&(this.items.splice(i,1)[0],!0)}}U([t.Watch()],D.prototype,"items",void 0);let H=class extends V{};U([t.Watch({converter:{convert:(e,i)=>{if("true"===e)return!0;if("false"===e)return!1;let r=parseFloat(e);if(!isNaN(r))return r;let s=t.Utils.Dates.parse(e);return t.Utils.Dates.isDate(s)?s:e},convertBack:e=>e.toString()}})],H.prototype,"value",void 0),U([t.Watch({converter:t.PropertyConverters.String})],H.prototype,"label",void 0),U([t.Watch({converter:t.PropertyConverters.Boolean})],H.prototype,"disabled",void 0),H=U([t.CustomElement({tagName:t.P+"-data-item"})],H);class A extends D{constructor(e=!1){super(),this.multipleChoice=e,this._itemPropertyChangedHandler=e=>{this.databind()}}register(e){const i=super.register(e);return i&&e.addEventListener(t.PropertyChangeEventName,this._itemPropertyChangedHandler,!1),i}unregister(e){const i=super.register(e);return i&&e.removeEventListener(t.PropertyChangeEventName,this._itemPropertyChangedHandler,!1),i}buildAdaptedDatasource(e=this.datasource){return e&&e.map(e=>this.mapEntityToItem(e))}databind(e=this.buildAdaptedDatasource(this.datasource)){if(t.Utils.isNull(e)&&t.Utils.isNull(this.adaptedDatasource))return;const i=this.adaptedDatasource=e||[];t.Utils.isNullOrEmpty(i.filter(e=>this.isDataSourceItemSelected(e)))&&this.handleDatasourceMismatch(i)}handleDatasourceMismatch(e){this.value=void 0}isItemSelected(e,i=this.value){if(t.Utils.isNullOrEmpty(i))return!1;const r=this.mapEntityToValue(e),s=this.compareBy;return this.multipleChoice&&t.Utils.isArray(i)?!t.Utils.isNull(i.find(e=>e==r||"object"==typeof e&&!t.Utils.isNullOrEmpty(s)&&s in r&&s in e&&r[s]==e[s])):!this.multipleChoice&&(i==r||"object"==typeof i&&!t.Utils.isNullOrEmpty(s)&&s in r&&s in i&&r[s]==i[s])}isDataSourceItemSelected(e,i=this.value){if(t.Utils.isNullOrEmpty(i))return!1;if(e.disabled)return!1;const r=this.compareBy;if(this.multipleChoice&&t.Utils.isArray(i)){let s=i.find(i=>i==e.value||"object"==typeof i&&!t.Utils.isNullOrEmpty(r)&&r in i&&!t.Utils.isNullOrEmpty(e.value)&&r in e.value&&i[r]==e.value[r]);return!t.Utils.isNull(s)}return!this.multipleChoice&&!t.Utils.isNullOrEmpty(e.value)&&(i==e.value||"object"==typeof i&&!t.Utils.isNullOrEmpty(r)&&r in i&&!t.Utils.isNullOrEmpty(e.value)&&r in e.value&&i[r]==e.value[r])}mapEntityToValue(e){if(null==e)throw"entity cannot be null";if(e instanceof H)return e.value;let t,i=e;return(t=this.valueProperty)&&(i=e[t]),i}mapEntityToViewValue(e){if(null==e)throw"entity cannot be null";if(e instanceof H)return e.label||e.value;let t,i=e.toString();return(t=this.textProperty)&&(i=e[t]),i}mapEntityToItem(e){if(null==e)throw"entity cannot be null";if(e instanceof H)return{value:e.value,viewValue:e.label||e.value,disabled:e.disabled,data:e};let i=!1;const r=this.disabledProperty;return t.Utils.isNullOrEmpty(r)||(i=e[r]||!1),{value:this.mapEntityToValue(e),viewValue:this.mapEntityToViewValue(e),disabled:i,data:e}}propertyChangedCallback(e,t,i,r){switch(super.propertyChangedCallback(e,t,i,r),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(e){if(!t.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(e,i){return t.DefaultComparer(e,i)}}U([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],A.prototype,"datasource",void 0),U([t.Watch({emit:!1,converter:t.PropertyConverters.String})],A.prototype,"valueProperty",void 0),U([t.Watch({emit:!1,converter:t.PropertyConverters.String})],A.prototype,"textProperty",void 0),U([t.Watch({emit:!1,converter:t.PropertyConverters.String})],A.prototype,"disabledProperty",void 0),U([t.Watch({emit:!1,converter:t.PropertyConverters.String})],A.prototype,"compareBy",void 0),U([t.Watch({converter:t.PropertyConverters.Json})],A.prototype,"adaptedDatasource",void 0),U([t.Debounce(!0)],A.prototype,"databind",null);var L=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};const T=`<${t.P}-char-count hide="{{ :host.readonly || !(:host.minlength > 0 || :host.maxlength > 0) }}" minlength="{{ :host.minlength }}" maxlength="{{ :host.maxlength }}" string="{{ :host.value }}"></${t.P}-char-count>`;let R=class extends t.Components.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}};L([t.Watch({converter:t.PropertyConverters.Number})],R.prototype,"minlength",void 0),L([t.Watch({converter:t.PropertyConverters.Number})],R.prototype,"maxlength",void 0),L([t.Watch({converter:t.PropertyConverters.String})],R.prototype,"string",void 0),R=L([t.CustomElement({tagName:t.P+"-char-count",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<${t.P}-panel class="${t.PCSS}-char-count" css-class="{{ {'valid': :host._isValid(:host.string), 'invalid': !:host._isValid(:host.string) } }}">\n <${t.P}-span hide="{{ !(:host.minlength > 0) }}" class="${t.PCSS}-char-min" content="{{ :host.minlength }}"></${t.P}-span>\n <${t.P}-span class="${t.PCSS}-char-curr" content="{{ :host._length(:host.string) || '0' }}"></${t.P}-span>\n <${t.P}-span hide="{{ !(:host.maxlength > 0) }}" class="${t.PCSS}-char-max" content="{{ :host.maxlength }}"></${t.P}-span>\n</${t.P}-panel>`})],R);var W=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};const I="execute",F="<p><br></p>";class j extends t.CustomTypedEvent{constructor(e){super("contenteditablechange",{html:e})}}class B extends V{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(I))},e=>{console.error(e)})}connectedCallback(){super.connectedCallback(),t.Utils.addClass(this,t.PCSS+"-contenteditable-command")}viewActivatedCallback(){super.viewActivatedCallback();const e=this.container;t.Utils.isNull(e)||(this.contentElement=e.contentElement,e.addEventListener(t.PropertyChangeEventName,this._containerPropChangeHandler,!1))}disconnectedCallback(){const e=this.container;t.Utils.isNull(e)||e.removeEventListener(t.PropertyChangeEventName,this._containerPropChangeHandler,!1),super.disconnectedCallback()}containerPropertyChangedCallback(e,t,i,r){"range"===e&&(this.range=i)}}function M(e){return e instanceof B&&"pasteCallback"in e&&"function"==typeof e.pasteCallback}function z(e){return e?.nodeType==Node.ELEMENT_NODE}W([t.Watch()],B.prototype,"range",void 0),W([t.Watch()],B.prototype,"contentElement",void 0);let q=class extends D{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=e=>{e.preventDefault();const i=this.range,r=e.clipboardData.files;if(t.Utils.isNull(i)||0!==r.length)for(let t=0;t<r.length;t++){const i=r.item(t);for(let t of this.items)M(t)&&t.pasteCallback(i).then(t=>this._checkChangedHandler(e),e=>{})}else{const t=e.clipboardData.getData("text/plain").replace(/</gi,"<").replace(/\n/gi,"<br />"),r=i.createContextualFragment(t);i.deleteContents(),i.insertNode(r),this._checkChangedHandler(e)}},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=e=>{const i=this._container,r=i.innerHTML;var s=r;(t.Utils.isNullOrEmpty(r)||"<br>"===r||r===F)&&(i.innerHTML=F,s=""),s!=this.value&&(this.changeHandler(new j(s)),this.value!=this.#i.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}}#i;get history(){return this.#i}reset(){super.reset(),this.#i.reset(),this._fireHistoryChange()}_fireHistoryChange(){const e=this.#i;this.dispatchEvent(new t.PropertyChangeEvent({propertyName:"history",oldValue:e,currentValue:e}))}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(I,this._checkChangedHandler,!1),!0)}unregister(e){return!!super.unregister(e)&&(e.removeEventListener(I,this._checkChangedHandler,!1),!0)}get preventKeyboardSubmit(){return!0}get inputFields(){return[this._container]}get contentElement(){return this._container}onChange(e){return new Promise((i,r)=>{if(t.CustomEventUtils.isInstanceOf(e,j)){i(this.value=e.detail.html),this._selectionChangeHandler(e)}else i(this.value)})}_fixRangeMarkup(){const e=this.range,i=e=>{e.childNodes.forEach(e=>i(e)),z(e)&&"SPAN"===e.tagName?Element.prototype.replaceWith.apply(e,Array.from(e.childNodes)):e instanceof HTMLElement&&e.removeAttribute("style")};t.Utils.isNull(e)||(e=>{let t=e;z(t)||(t=e.parentElement),i(t)})(e.commonAncestorContainer)}_ensureInteractiveMarkup(){const e=this._container,i=e.childNodes,r=i.length;if(0==r||e.innerHTML===F)e.innerHTML=F;else{let e,s;const a=e=>{s.setEndAfter(e);const t=document.createElement("p");s.surroundContents(t)};for(let n=0;n<r;n++)e=i.item(n),e instanceof Element?s&&(a(e.previousSibling),s=null):t.Utils.isNull(s)&&(s=document.createRange(),s.setStartBefore(e));t.Utils.isNull(s)||a(e)}}_updateHistory(){this.#i.push(this.value),this._fireHistoryChange()}acceptValue(e){t.Utils.isNull(this._container)||e==this._container.innerHTML||(this._container.innerHTML=e)}viewActivatedCallback(){super.viewActivatedCallback();const t=this._container;this.#i=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 e=this._container;t.Utils.isNull(e)||(e.removeEventListener("keydown",this._shortcutHandler,!1),e.removeEventListener("blur",this._blurHandler,!1),e.removeEventListener("focus",this._focusHandler,!1),e.removeEventListener("input",this._inputHandler,!1),e.removeEventListener("paste",this._pasteHandler,!1)),super.disconnectedCallback()}getViewValue(e){return e}};W([t.ViewChild("div[pacem]")],q.prototype,"_container",void 0),W([t.ViewChild("div[dashboard]")],q.prototype,"_dashboard",void 0),W([t.Watch()],q.prototype,"range",void 0),W([t.Debounce(500)],q.prototype,"_updateHistory",null),q=W([t.CustomElement({tagName:t.P+"-contenteditable",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<div class="${t.PCSS}-contenteditable ${t.PCSS}-viewfinder">\n <div contenteditable="true" role="presenter" pacem></div>\n</div>${T}\n<div dashboard>\n <${t.P}-content></${t.P}-content>\n</div>`})],q);var J=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};class Y extends B{cleanUp(e){}propertyChangedCallback(e,i,r,s){super.propertyChangedCallback(e,i,r,s),"range"===e&&(this.active=!t.Utils.isNull(r))}getTooltip(e=this.altText,i=this.keyboardShortcut){const r=e;return t.Utils.isNullOrEmpty(i)?r:`${r} (${i})`}}J([t.Watch({converter:t.PropertyConverters.String})],Y.prototype,"icon",void 0),J([t.Watch({converter:t.PropertyConverters.String})],Y.prototype,"keyboardShortcut",void 0),J([t.Watch({converter:t.PropertyConverters.String})],Y.prototype,"altText",void 0),J([t.Watch({converter:t.PropertyConverters.Boolean})],Y.prototype,"active",void 0);const K=`<${t.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()"><${t.P}-icon class="text-rootsize" icon="{{ :host.icon }}"></${t.P}-icon></${t.P}-button>\n <${t.P}-shortcut disabled="{{ !:host.active }}" target="{{ :host.contentElement }}" combination="{{ :host.keyboardShortcut }}" on-execute=":host.execCommand()"></${t.P}-shortcut>`;var G=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};let X=class extends Y{exec(){return new Promise((e,i)=>{const r=this.container?.history;if(!t.Utils.isNull(r)){if("redo"===this.command)r.canRedo&&(r.redo(),e());else r.canUndo&&(r.undo(),e());this.contentElement.innerHTML=r.current}})}isRelevant(e){return!1}propertyChangedCallback(e,t,i,r){if(super.propertyChangedCallback(e,t,i,r),"command"===e)this.icon=this.icon||i,this.altText=i,this.keyboardShortcut=this.keyboardShortcut||"Ctrl+"+("redo"===i?"Y":"Z")}containerPropertyChangedCallback(e,i,r,s){super.containerPropertyChangedCallback(e,i,r,s);const a=this.container,n=a.history;"range"!==e&&"history"!==e||(this.active=!t.Utils.isNull(a.range)&&("redo"===this.command&&n?.canRedo||"redo"!==this.command&&n?.canUndo))}};G([t.Watch({emit:!1,converter:t.PropertyConverters.String,reflectBack:!0})],X.prototype,"command",void 0),X=G([t.CustomElement({tagName:t.P+"-contenteditable-historycommand",shadow:t.Defaults.USE_SHADOW_ROOT,template:K})],X);var Z=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};let Q=class extends Y{isRelevant(e){return!t.Utils.isNull(de.findSurroundingNode(e,HTMLAnchorElement))}viewActivatedCallback(){super.viewActivatedCallback(),t.Utils.isNullOrEmpty(this.altText)&&(this.altText="insert link"),t.Utils.isNullOrEmpty(this.icon)&&(this.icon="insert_link"),t.Utils.isNullOrEmpty(this.keyboardShortcut)&&(this.keyboardShortcut="Ctrl+H")}exec(e,t=this.target){return new Promise((i,r)=>{var s=this.range,a=de.findSurroundingNode(s,HTMLAnchorElement),n="http://",o=/<a.*href=\"([^\"]*)/;if(a&&o.test(a.outerHTML)&&(n=o.exec(a.outerHTML)[1]),"current"===e)return"http://"==n?"":n;var l=e||void 0===e&&window.prompt("link (empty to unlink):",n);l?(document.execCommand("createLink",!1,l),(a=de.findSurroundingNode(s,HTMLAnchorElement))&&a.setAttribute("target",t||"_blank")):document.execCommand("unlink"),i()})}};Z([t.Watch({emit:!1,converter:t.PropertyConverters.String})],Q.prototype,"target",void 0),Q=Z([t.CustomElement({tagName:t.P+"-contenteditable-linkcommand",shadow:t.Defaults.USE_SHADOW_ROOT,template:K})],Q);var ee=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};function te(e,i){return new Promise((r,s)=>{t.Utils.blobToDataURL(i).then(t.Utils.loadImage).then(t=>{const i=document.createElement("picture");i.setAttribute("contenteditable","false"),t.tabIndex=0,i.appendChild(t),e.deleteContents(),e.insertNode(i),r(i)})})}let ie=class extends Y{constructor(){super(...arguments),this._setBehaviorHandler=e=>{const t=e.target.parentElement;this.range=de.select(t)},this._disposeBehaviorHandler=e=>{}}pasteCallback(e){return e.type.startsWith("image")?te(this.range,e):Promise.reject()}cleanUp(e){e.querySelectorAll("picture[contenteditable=false]").forEach(e=>{for(let t=e.childNodes.length-1;t>0;t--)e.childNodes.item(t).remove()}),e.querySelectorAll("div."+t.PCSS+"-rescale").forEach(e=>e.remove())}isRelevant(e){return!1}viewActivatedCallback(){super.viewActivatedCallback(),t.Utils.isNullOrEmpty(this.altText)&&(this.altText="insert image"),t.Utils.isNullOrEmpty(this.icon)&&(this.icon="insert_photo"),t.Utils.isNullOrEmpty(this.keyboardShortcut)&&(this.keyboardShortcut="Ctrl+Shift+I"),this._rescale.addEventListener("rescale",this._rescaleImg,!1)}disconnectedCallback(){t.Utils.isNull(this._rescale)||(this._rescale.removeEventListener("rescale",this._rescaleImg,!1),this._disposeContainer()),super.disconnectedCallback()}propertyChangedCallback(e,i,r,s){switch(super.propertyChangedCallback(e,i,r,s),e){case"disabled":t.Utils.isNull(this._rescale)||(this._rescale.disabled=r);break;case"contentElement":i&&this._disposeContainer(i),r&&this._initContainer(r);break;case"range":this._rangeChangeCallback(i,r)}}exec(){return new Promise((e,i)=>{const r=this._file,s=this.range;r.onchange=i=>{const a=r.files[0];t.Utils.isNull(a)?e():te(s,a).then(t=>{r.value="",e()})},r.click()})}_rescaleImg(e){e.preventDefault();const t=e.detail.element,i=e.detail.targetRect,r=t.firstElementChild;r.style.width=i.width+"px",r.style.height=i.height+"px"}#r;_rangeChangeCallback(e,i){if(!t.Utils.isNull(e)&&!e.collapsed&&e.commonAncestorContainer instanceof Element&&e.commonAncestorContainer===e.startContainer&&e.commonAncestorContainer===e.endContainer&&e.startOffset===e.endOffset-1){const t=e.commonAncestorContainer.childNodes.item(e.startOffset);t instanceof HTMLPictureElement&&this._rescale.unregister(t)}if(!t.Utils.isNull(i)&&!i.collapsed&&i.commonAncestorContainer instanceof Element&&i.commonAncestorContainer===i.startContainer&&i.commonAncestorContainer===i.endContainer&&i.startOffset===i.endOffset-1){const e=i.commonAncestorContainer.childNodes.item(i.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.#r=new ce(e,(e,t)=>{e instanceof HTMLPictureElement&&(t?this._downgradePictureElement(e):this._enhancePictureElement(e))},"picture")}_disposeContainer(e=this.contentElement){const i=this.#r;t.Utils.isNull(i)||i.dispose()}};ee([t.ViewChild("input[type=file]")],ie.prototype,"_file",void 0),ee([t.ViewChild(t.P+"-rescale")],ie.prototype,"_rescale",void 0),ie=ee([t.CustomElement({tagName:t.P+"-contenteditable-imagecommand",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<input type="file" accept="image/png, image/gif, image/jpeg, image/bmp, image/x-icon" class="${t.PCSS}-trasparent ${t.PCSS}-inert" pacem hidden>`+K+`<${t.P}-rescale keep-proportions="true"></${t.P}-rescale>`})],ie);var re,se=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};function ae(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 ne(e,t){const i=e?.toLowerCase();switch(i){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"}(re||(re={}));let oe=class extends Y{_matchRelevance(e,i){const r="object"==typeof i?de.findSurroundingNode(e,e=>e instanceof HTMLElement&&(t.Utils.isNullOrEmpty(i.tagName)||e.tagName===i.tagName.toUpperCase())&&e.style[i.style.name]===i.style.value):de.findSurroundingNode(e,i);return!t.Utils.isNull(r)}isRelevant(e){const t=ne(this.command,this.argument);for(let i of t)if(this._matchRelevance(e,i))return!0;return!1}propertyChangedCallback(e,i,r,s){super.propertyChangedCallback(e,i,r,s),"command"===e&&((t.Utils.isNullOrEmpty(this.icon)||this.icon===ae(i))&&(this.icon=ae(r)),(t.Utils.isNullOrEmpty(this.altText)||this.altText===i)&&(this.altText=r))}exec(){return new Promise((e,i)=>{const r=this.range,s=ne(this.command,this.argument)[0];if(!t.Utils.isNull(r)){const e=de.testInertElementWrapping(r);if(e.result&&"string"==typeof s&&["b","i","strike","u"].indexOf(s)>=0){const i=de.findSurroundingNode(r,s);if(t.Utils.isNull(i)||1!==i.childNodes.length){const t=document.createElement(s),i=e.element,a=r.extractContents();r.insertNode(t),t.append(a),de.select(i)}else{const t=i.childNodes.item(0),r=e.element;i.parentElement.replaceChild(t,i),de.select(r)}}else document.execCommand(this.command,!1,this.argument)}e()})}};function le(e){return e instanceof HTMLDivElement&&"true"===e.contentEditable&&e.hasAttribute("pacem")&&e.hasAttribute("role")&&"presenter"===e.attributes.role.value}se([t.Watch({converter:t.PropertyConverters.String})],oe.prototype,"command",void 0),se([t.Watch({emit:!1,converter:t.PropertyConverters.String})],oe.prototype,"argument",void 0),oe=se([t.CustomElement({tagName:t.P+"-contenteditable-execcommand",shadow:t.Defaults.USE_SHADOW_ROOT,template:K})],oe);class ce{constructor(e,t,i="*[contenteditable=false]"){this.#s=t,this.#a=i,this.#n=new MutationObserver(e=>{const i=(e,r)=>{e.childNodes.forEach(e=>i(e,r)),t(e,r)};for(let t of e){const e=t.addedNodes,r=t.removedNodes;for(let t=0;t<e.length;t++){const r=e.item(t);i(r,!1)}for(let e=0;e<r.length;e++){const t=r.item(e);i(t,!0)}}}),this._initContainer(e)}_initContainer(e){e.querySelectorAll(this.#a).forEach(e=>this.#s(e)),this.#n.observe(e,{subtree:!0,childList:!0}),this.#o=e}_disposeContainer(e){const i=this.#n;t.Utils.isNull(i)||i.disconnect(),e.querySelectorAll(this.#a).forEach(e=>this.#s(e,!0))}dispose(){this._disposeContainer(this.#o)}#a;#s;#o;#n}class de{static getDefaultDashboard(){const e=new DocumentFragment,i=document.createElement("div");t.Utils.addClass(i,t.PCSS+"-contenteditable-toolbar");const r=new X;r.command="undo",r.keyboardShortcut="Ctrl+Z";const s=new X;s.command="redo",s.keyboardShortcut="Ctrl+Y",i.append(r,s);const a=document.createElement("div");t.Utils.addClass(a,t.PCSS+"-contenteditable-separator");const n=document.createElement("div");t.Utils.addClass(n,t.PCSS+"-contenteditable-toolbar");const o=new oe;o.command=re.Bold,o.keyboardShortcut="Ctrl+B";const l=new oe;l.command=re.Italic,l.keyboardShortcut="Ctrl+I";const c=new oe;c.command=re.Underline,c.keyboardShortcut="Ctrl+U";const d=new oe;d.command=re.StrikeThrough,c.keyboardShortcut="Ctrl+K";const h=new oe;h.command=re.UnorderedList;const p=new oe;p.command=re.OrderedList;const u=new ue;u.align="left";const m=new ue;m.align="center";const v=new ue;v.align="right";const g=new ue;g.align="justify",n.append(o,l,c,d,h,p,u,m,v,g);const y=document.createElement("div");t.Utils.addClass(y,t.PCSS+"-contenteditable-separator");const f=document.createElement("div");t.Utils.addClass(f,t.PCSS+"-contenteditable-toolbar");const _=new Q,b=new ie;return f.append(_,b),e.append(i,a,n,y,f),e}static findSurroundingNode(e,i){for(var r=e instanceof Node?e:e.commonAncestorContainer;r&&!("string"==typeof i&&r instanceof Element&&r.tagName===i.toUpperCase()||"function"==typeof i&&t.Utils.isNull(i.prototype)&&i(r)||"function"==typeof i&&!t.Utils.isNull(i.prototype)&&r instanceof i);){const e=r.parentNode;if(le(e)){r=null;break}r=e}return r}static findSurroundingBlockElement(e){return this.findSurroundingNode(e,de.isBlockElement)}static findSurroundingSiblingBlockElements(e){let t=[];if(le(e.startContainer)){if(!e.collapsed){const i=e.startContainer;for(let r=e.startOffset;r<=e.endOffset;r++){const e=i.children.item(r);this.isBlockElement(e)&&t.push(i.children.item(r))}}return t}if(e.startContainer===e.endContainer){let t=e.startContainer;for(;!de.isBlockElement(t)&&"true"!=t.parentElement.contentEditable;)t=t.parentElement;return t instanceof Element?[t]:"true"===t.parentElement.contentEditable?[]:[t.parentElement]}let i=e.commonAncestorContainer,r=!1;for(let s=0;s<i.childNodes.length;s++){const a=i.childNodes.item(s);if((!r&&a.contains(e.startContainer)||r)&&de.isBlockElement(a)&&(t.push(a),r=!0,a.contains(e.endContainer)))break}return r?t:i instanceof Element&&!le(i)?[i]:[]}static findContainingRootElements(e){const t=e.cloneRange(),i=e.cloneRange();t.collapse(!0),i.collapse();let r=this.findSurroundingNode(t,e=>"true"===e.parentElement.contentEditable);const s=[r];for(;!r.contains(i.startContainer);)s.push(r=r.nextElementSibling);return s}static isBlockElement(e){return e instanceof Element&&!getComputedStyle(e).display.startsWith("inline")}static select(e,t=!1){const i=document.createRange();t?(i.setStart(e,0),i.setEnd(e,e.childNodes.length)):(i.setStartBefore(e),i.setEndAfter(e));const r=document.getSelection();return r.removeAllRanges(),r.addRange(i),i}static copyAttributes(e,t){const i=t.attributes;for(let t=0;t<i.length;t++){const r=i.item(t);e.setAttribute(r.name,r.value)}}static testInertElementWrapping(e){if(!t.Utils.isNull(e)){const t=e.startContainer,r=e.startOffset;var i;if(t===e.endContainer&&r==e.endOffset-1&&(i=t.childNodes.item(r))instanceof HTMLElement&&"false"===i.contentEditable)return{result:!0,element:i}}return{result:!1}}}var he=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};function pe(e){return"format_align_"+e}let ue=class extends Y{isRelevant(e){const i=de.findSurroundingSiblingBlockElements(e);if(t.Utils.isNullOrEmpty(i))return!1;const r=i[0];return getComputedStyle(r).textAlign==this.align}propertyChangedCallback(e,i,r,s){super.propertyChangedCallback(e,i,r,s),"align"===e&&((t.Utils.isNullOrEmpty(this.icon)||this.icon===pe(i))&&(this.icon=pe(r)),(t.Utils.isNullOrEmpty(this.altText)||this.altText===i)&&(this.altText=r))}exec(){const e=de.findSurroundingSiblingBlockElements(this.range);let i;for(let r of e)de.isBlockElement(r)&&r instanceof HTMLElement&&(t.Utils.isNull(i)&&(i=t.Utils.hasClass(r,"text-"+this.align)?"":this.align),r.style.textAlign="",t.Utils.removeClass(r,"text-left text-right text-center text-justify"),t.Utils.isEmpty(i)||t.Utils.addClass(r,"text-"+i));return Promise.resolve()}};he([t.Watch({converter:t.PropertyConverters.String})],ue.prototype,"align",void 0),ue=he([t.CustomElement({tagName:t.P+"-contenteditable-aligncommand",shadow:t.Defaults.USE_SHADOW_ROOT,template:K})],ue);var me=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};function ve(e){return e instanceof HTMLModElement&&"INS"===e.tagName}let ge=class extends B{constructor(){super(...arguments),this._focusHandler=e=>{const t=e.target;this.range=de.select(t)}}#l;#c;cleanUp(e){e.querySelectorAll("ins[contenteditable=false]").forEach(e=>{t.Utils.removeClass(e,"placeholder-selected")})}exec(e){const t=function(e,t){const i=document.createElement("ins");return i.textContent=t,i.setAttribute("contenteditable","false"),i.tabIndex=0,e.deleteContents(),e.insertNode(i),i}(this.range,e);return de.select(t).collapse(!1),Promise.resolve(t)}isRelevant(e){return this.#l?.result??!1}viewActivatedCallback(){super.viewActivatedCallback(),this._fillDropdown(),this._initContainer()}propertyChangedCallback(e,t,i,r){if(super.propertyChangedCallback(e,t,i,r),!r)switch(e){case"datasource":this._fillDropdown();break;case"contentElement":t&&this._disposeContainer(t),i&&this._initContainer(i);break;case"range":this._changeRelevancy()}}disconnectedCallback(){this._disposeContainer(),super.disconnectedCallback()}_changeRelevancy(e=this.range){const i=this.#l;t.Utils.isNull(i?.element)||t.Utils.removeClass(i.element,"placeholder-selected");const r=this.#l=function(e){const t=de.testInertElementWrapping(e);if(t.result&&ve(t.element)){const e=t.element;return{result:!0,element:e,placeholder:e.textContent}}return{result:!1}}(e);t.Utils.isNull(r?.element)||t.Utils.addClass(r.element,"placeholder-selected"),r.result?this._dropdown.value=r.placeholder:(this._dropdown.popout(),this._dropdown.value=void 0)}_fillDropdown(e=this.datasource||[]){const t=this.#c=e.map(e=>"string"==typeof e?{placeholder:e,definition:e}:e),i=this._dropdown;i.textProperty=i.valueProperty="placeholder",i.datasource=t}#r;_initContainer(e=this.contentElement){this.#r=new ce(e,(e,t)=>{ve(e)&&(t?this._downgradePlaceholderElement(e):this._enhancePlaceholderElement(e))},"ins[contenteditable=false]")}_disposeContainer(e=this.contentElement){const i=this.#r;t.Utils.isNull(i)||i.dispose()}_enhancePlaceholderElement(e){e.addEventListener("focus",this._focusHandler,!1)}_downgradePlaceholderElement(e){e.removeEventListener("focus",this._focusHandler,!1)}};me([t.ViewChild("template")],ge.prototype,"_itemtemplate",void 0),me([t.ViewChild(t.P+"-suggest")],ge.prototype,"_dropdown",void 0),me([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],ge.prototype,"datasource",void 0),ge=me([t.CustomElement({tagName:t.P+"-contenteditable-placeholder",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<template>\n<${t.P}-span text="{{ ^item.viewValue }}" class="text-tech"></${t.P}-span>\n<${t.P}-markdown hide="{{ $pacem.isNullOrEmpty(^item.data.definition) || ^item.viewValue === ^item.data.definition }}" class="${t.PCSS}-margin margin-0 text-small" value="{{ ^item.data.definition }}"></${t.P}-markdown>\n</template>\n<${t.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"></${t.P}-suggest>`})],ge);var ye=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};let fe=class extends Y{isRelevant(e){return!t.Utils.isNull(de.findSurroundingNode(e,this.tagname))}exec(){return new Promise((e,i)=>{const r=this.tagname;if(!t.Utils.isNullOrEmpty(r)){const e=this.range,i=de.findSurroundingNode(e,r)||de.findSurroundingNode(e.startContainer,r)||de.findSurroundingNode(e.endContainer,r);if(t.Utils.isNull(i)){const i=de.findSurroundingSiblingBlockElements(e);if(!t.Utils.isNullOrEmpty(i)){const t=document.createElement(r);if(1===i.length){const r=i[0];e.setStart(r,0),e.setEnd(r,r.childNodes.length);const s=e.extractContents();t.append(s),de.copyAttributes(t,r),r.parentElement.insertBefore(t,r),r.remove()}else{e.setStartBefore(i[0]),e.setEndAfter(i[i.length-1]);const r=e.extractContents();t.append(r),e.insertNode(t)}de.select(t,!0).collapse()}}else{e.setStart(i,0),e.setEnd(i,i.childNodes.length);let t=!1;const r=i.childNodes;for(let e=0;e<r.length;e++){const i=r.item(e);if(!de.isBlockElement(i)){t=!0;break}}if(t){const t=document.createElement("p");de.copyAttributes(t,i),t.append(e.extractContents()),i.parentNode.replaceChild(t,i);de.select(t,!0).collapse()}else{i.parentNode.replaceChild(e.extractContents(),i);de.select(e.endContainer,!0).collapse()}}}e()})}};ye([t.Watch({converter:t.PropertyConverters.String})],fe.prototype,"tagname",void 0),fe=ye([t.CustomElement({tagName:t.P+"-contenteditable-wrapcommand",shadow:t.Defaults.USE_SHADOW_ROOT,template:K})],fe);var _e=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};const be={convert:(e,i)=>/\{.+\}/.test(e)?t.PropertyConverters.Json.convert(e):t.PropertyConverters.String.convert(e),convertBack:(e,i)=>"string"==typeof e?e:t.PropertyConverters.Json.convertBack(e,i)};let Ce=class extends t.Components.PacemElement{propertyChangedCallback(e,i,r,s){if(super.propertyChangedCallback(e,i,r,s),"viewYear"===e)this.dispatchEvent(new CustomEvent("viewyearchange",{detail:new Date(r,0,1),bubbles:!1,cancelable:!1})),t.Utils.removeClass(this,"viewyear-next viewyear-previous"),requestAnimationFrame(()=>{t.Utils.addClass(this,i>r?"viewyear-previous":"viewyear-next")})}_getMonthLabel(e){const i=(new Date).getFullYear();return new Date(i,e,1).toLocaleString(t.Utils.lang(this),{month:"short"})}_isThisMonth(e,t=this.viewYear){return this._isSelectedMonth(e,new Date,t)}_isSelectedMonth(e,i=this.month,r=this.viewYear){const s=t.Utils.parseDate(i);if(!t.Utils.Dates.isDate(s))return!1;const a=r??(new Date).getFullYear();return s.getMonth()===e&&s.getFullYear()===a}_setMonth(e){const t=this.viewYear,i=new Date(t,e,1);this.month=i,this.dispatchEvent(new CustomEvent("monthselect",{detail:i,bubbles:!1,cancelable:!1}))}};_e([t.Watch({converter:t.PropertyConverters.Date})],Ce.prototype,"month",void 0),_e([t.Watch({converter:t.PropertyConverters.Date})],Ce.prototype,"viewYear",void 0),Ce=_e([t.CustomElement({tagName:t.P+"-calendar-month-picker",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<div class="${t.PCSS}-month-picker">${function(){let e="";for(let i=0;i<12;i++)e+=`<div class="calendar-month month-${i+1}"><${t.P}-span class="month-button text-ellipsed" on-click=":host._setMonth(${i})" css-class="{{ { 'selected-month': :host._isSelectedMonth(${i}, :host.month, :host.viewYear), 'this-month': :host._isThisMonth(${i}, :host.viewYear) } }}" text="{{ :host._getMonthLabel(${i}) }}"></${t.P}-span></div>`;return e}()}</div>`})],Ce);class Pe extends i.Components.UI.DateSelectEvent{constructor(){super(void 0)}}function we(e){return e-e%10}let Ee=class extends t.Components.PacemElement{propertyChangedCallback(e,i,r,s){if(super.propertyChangedCallback(e,i,r,s),"viewYear"===e)this.dispatchEvent(new CustomEvent("viewyearchange",{detail:new Date(r,0,1),bubbles:!1,cancelable:!1})),t.Utils.removeClass(this,"viewyear-next viewyear-previous"),requestAnimationFrame(()=>{t.Utils.addClass(this,i>r?"viewyear-previous":"viewyear-next")})}_getYearLabel(e,t=this.viewYear){return""+(we(t)+e)}_isThisYear(e,t=this.viewYear){return this._isSelectedYear(e,new Date,t)}_isSelectedYear(e,i=this.year,r=this.viewYear){const s=t.Utils.parseDate(i);if(!t.Utils.Dates.isDate(s))return!1;const a=we(r)+e;return s.getFullYear()===a}_setYear(e){const t=we(this.viewYear),i=new Date(t+e,0,1);this.year=i,this.dispatchEvent(new CustomEvent("yearselect",{detail:i,bubbles:!1,cancelable:!1}))}};_e([t.Watch({converter:t.PropertyConverters.Date})],Ee.prototype,"year",void 0),_e([t.Watch({converter:t.PropertyConverters.Date})],Ee.prototype,"viewYear",void 0),Ee=_e([t.CustomElement({tagName:t.P+"-calendar-year-picker",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<div class="${t.PCSS}-year-picker">${function(){let e="";for(let i=0;i<12;i++)e+=`<div class="calendar-year year-${i+1}"><${t.P}-span class="year-button text-ellipsed" on-click=":host._setYear(${i})" css-class="{{ { 'selected-year': :host._isSelectedYear(${i}, :host.year, :host.viewYear), 'this-year': :host._isThisYear(${i}, :host.viewYear) } }}" text="{{ :host._getYearLabel(${i}, :host.viewYear) }}"></${t.P}-span></div>`;return e}()}</div>`})],Ee);let Se=class extends x{constructor(){super(...arguments),this.viewmode="calendar",this.#d=!1,this._swipeHandler=e=>{switch(e.detail.direction){case"left":this._next(e);break;case"right":this._prev(e)}},this._clearBtnHandler=e=>{e.preventDefault(),this._viewDate=new Date,this.changeHandler(new Pe)},this._viewDateChangeHandler=e=>{this._onViewDateChange(e)},this._popCalendarHandler=e=>{if(this.#d)return;this.viewmode="calendar";const i=t.Utils.parseDate(this.value);this._calendar.viewDate=this._monthPicker.month=this._yearPicker.year=t.Utils.Dates.isDate(i)?i:this._calendar.viewDate;const r=t.Utils.offset(this._input),s=this._dropdown;s.style.top=r.top+r.height+"px",s.style.left=r.left+"px",s.hidden=!1,requestAnimationFrame(()=>{t.Utils.addClass(s,"dropdown-in")})},this._hideCalendarHandler=e=>{const t=e.composedPath()||[];t.indexOf(this._input)>=0||t.indexOf(this._dropdown)>=0||this._hideCalendar()}}#d;propertyChangedCallback(e,t,i,r){switch(super.propertyChangedCallback(e,t,i,r),e){case"viewmode":case"_viewDate":this._onViewDateChange(this._viewDate)}}viewActivatedCallback(){super.viewActivatedCallback();const e=this._dropdown=this._proxy.dom[0],i=this._calendar=e.querySelector(t.P+"-calendar"),r=this._monthPicker=e.querySelector(t.P+"-calendar-month-picker"),s=this._yearPicker=e.querySelector(t.P+"-calendar-year-picker");this._monthLabel=e.querySelector(".calendar-month"),this._yearLabel=e.querySelector(".calendar-year"),this._rangeLabel=e.querySelector(".calendar-year-range");const a=this._calendar.now=new Date,n=t.Utils.Dates.parse(this.value),o=t.Utils.Dates.isDate(n)?n:a;i.dayLabelFormatter=e=>t.Utils.parseDate(e).toLocaleString(t.Utils.lang(this),{day:"numeric"}),r.addEventListener("viewyearchange",this._viewDateChangeHandler,!1),s.addEventListener("viewyearchange",this._viewDateChangeHandler,!1),i.addEventListener("viewdatechange",this._viewDateChangeHandler,!1),i.viewDate=o,i.date=n;const l=this._input;l.addEventListener("focus",this._popCalendarHandler,!1),l.addEventListener("mousedown",this._popCalendarHandler,!1),e.addEventListener("mousedown",t.stopPropagationHandler,!1),window.document.body.addEventListener("mousedown",this._hideCalendarHandler,!0),this._clearButton.addEventListener("mousedown",this._clearBtnHandler,!1);const c=new t.Components.PacemSwipeElement;i.behaviors.push(c),r.behaviors.push(c),s.behaviors.push(c),c.addEventListener("swipe",this._swipeHandler,!1);const d=t.CustomElementUtils.findAncestorShell(this);this._swiper=d.appendChild(c)}disconnectedCallback(){const e=this._input;t.Utils.isNull(e)||(this._clearButton.removeEventListener("mousedown",this._clearBtnHandler,!1),e.removeEventListener("focus",this._popCalendarHandler,!1),e.removeEventListener("mousedown",this._popCalendarHandler,!1),this._dropdown.removeEventListener("mousedown",t.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 i=this._swiper;if(!t.Utils.isNull(i)){const e=this._calendar,t=this._monthPicker,r=this._yearPicker;for(let s of[e,t,r]){const e=s.behaviors.indexOf(i);e>=0&&s.behaviors.splice(e,1)}i.removeEventListener("swipe",this._swipeHandler,!1),i.remove(),this._swiper=null}super.disconnectedCallback()}_getHeaderLabel(e,i=this.viewmode){const r=t.Utils.parseDate(e);return t.Utils.Dates.isDate(r)?r.toLocaleString(t.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(e){const i=t.Utils.parseDate(this._viewDate);this._viewDate=t.Utils.Dates.addMonths(i,e)}_setMonth(e){this._viewDate=e.detail,this.viewmode="calendar"}_setYear(e){this._viewDate=e.detail,this.viewmode="month"}_onViewDateChange(e){if(t.Utils.isNullOrEmpty(e))return;const i=t.Utils.parseDate(this._viewDate);if(t.Utils.Dates.isDate(i)&&!t.Utils.isNull(this._monthLabel))switch(this.viewmode){case"month":this._yearLabel.text=i.toLocaleString(t.Utils.lang(this),{year:"numeric"});break;case"year":const e=we(i.getFullYear());this._rangeLabel.text=`${e} - ${e+12-1}`;break;default:this._monthLabel.text=i.toLocaleString(t.Utils.lang(this),{month:"long",year:"numeric"})}}_hideCalendar(){t.Utils.removeClass(this._dropdown,"dropdown-in"),t.Utils.addAnimationEndCallback(this._dropdown,e=>{this._dropdown.hidden=!0,t.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(e){return new Promise((r,s)=>{if(t.CustomEventUtils.isInstanceOf(e,i.Components.UI.DateSelectEvent)){t.Utils.addClass(this._dropdown,"dropdown-select");t.CustomEventUtils.isInstanceOf(e,Pe)&&(this.#d=!0),this.focus(),this.#d=!1,this._hideCalendar(),r(this.value=e.detail)}else r(this.value)})}acceptValue(e){this._input.value=this.viewValue;const i=this._calendar;if(!t.Utils.isNull(i)){const r=t.Utils.parseDate(e);t.Utils.Dates.isDate(r)?i.viewDate=i.date=r:i.date=void 0}}getViewValue(e){const i=t.Utils.Dates.parse(e);return t.Utils.Dates.isDate(i)?t.Utils.core.date(i,this.format||"short",t.Utils.lang(this)):""}compareValuePropertyValues(e,i){const r=t.Utils.parseDate(e),s=t.Utils.parseDate(i);return!(!t.Utils.isNullOrEmpty(r)||!t.Utils.isNullOrEmpty(s))||!t.Utils.isNullOrEmpty(r)&&!t.Utils.isNullOrEmpty(s)&&r.valueOf()==s.valueOf()}convertValueAttributeToProperty(e){return t.PropertyConverters.Datetime.convert(e)}};_e([t.ViewChild("input[type=text]")],Se.prototype,"_input",void 0),_e([t.ViewChild(`.${t.PCSS}-readonly`)],Se.prototype,"_span",void 0),_e([t.ViewChild(`${t.P}-button[clear]`)],Se.prototype,"_clearButton",void 0),_e([t.ViewChild(t.P+"-shell-proxy")],Se.prototype,"_proxy",void 0),_e([t.Watch({emit:!1,converter:be})],Se.prototype,"format",void 0),_e([t.Watch({converter:t.PropertyConverters.Eval})],Se.prototype,"disabledRanges",void 0),_e([t.Watch({converter:t.PropertyConverters.String})],Se.prototype,"weekStart",void 0),_e([t.Watch({converter:t.PropertyConverters.String})],Se.prototype,"viewmode",void 0),_e([t.Watch()],Se.prototype,"_week",void 0),_e([t.Watch()],Se.prototype,"_viewDate",void 0),Se=_e([t.CustomElement({tagName:t.P+"-calendar-picker",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<div class="${t.PCSS}-calendar-picker">\n <input type="text" class="${t.PCSS}-input" /><${t.P}-span text="{{ :host.viewValue }}" class="${t.PCSS}-readonly"></${t.P}-span>\n <${t.P}-button class="button-flat ${t.PCSS}-anim anim-pop anim-sudden anim-quick pos-absolute absolute-right absolute-top display-block ${t.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></${t.P}-button>\n</div>\n<${t.P}-shell-proxy>\n <div class="${t.PCSS}-calendar-picker-dropdown" pacem hidden>\n <${t.P}-collapse collapse="false">\n <div class="dropdown-grid">\n <div class="calendar-title">\n <${t.P}-span class="calendar-month calendar-zoom" on-click=":host.viewmode = 'month'" hide="{{ :host.viewmode !== 'calendar' }}"></${t.P}-span>\n <${t.P}-span class="calendar-year calendar-zoom" on-click=":host.viewmode = 'year'" hide="{{ :host.viewmode !== 'month' }}"></${t.P}-span>\n <${t.P}-span class="calendar-year-range" hide="{{ :host.viewmode !== 'year' }}"></${t.P}-span>\n </div>\n <div class="calendar-month-nav ${t.PCSS}-buttonset buttons">\n <div class="buttonset-left">\n <${t.P}-button class="button button-size size-auto" on-click=":host._prev($event)" icon-glyph="chevron_left"></${t.P}-button>\n <${t.P}-button class="button button-size size-auto" on-click=":host._next($event)" icon-glyph="chevron_right"></${t.P}-button>\n </div>\n </div>\n ${function(){let e="";for(let i=0;i<7;i++)e+=`<${t.P}-span class="calendar-heading day-${i+1} text-ellipsed" text="{{ :host._getHeaderLabel(:host._week[${i}]) }}"></${t.P}-span>`;return`<${t.P}-panel hide="{{ :host.viewmode !== 'calendar' }}" class="calendar-header">${e}</${t.P}-panel>`}()}\n <${t.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) }}"></${t.P}-calendar>\n <${t.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() }}"></${t.P}-calendar-month-picker>\n <${t.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() }}"></${t.P}-calendar-year-picker>\n </div>\n <${t.P}-collapse>\n </div>\n</${t.P}-shell-proxy>`})],Se);var $e=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};const ke={convert:e=>"true"===e||"false"!==e&&e,convertBack:e=>e.toString()};let Ue=class extends x{constructor(){super("checkbox"),this.caption="",this._key="_"+t.Utils.uniqueCode()}convertValueAttributeToProperty(e){ke.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(e){this.selected=this._checkbox.checked;const i=this.value=this.selected?this.trueValue:this.falseValue;return t.Utils.fromResult(i)}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(e,i,r,s){if(super.propertyChangedCallback(e,i,r,s),this.isReady)switch(e){case"caption":this._label.hidden=t.Utils.isNullOrEmpty(r);break;case"name":this._checkbox.name=r;break;case"selected":this._synchronizeUi()}}_synchronizeUi(e=this.selected){(this._checkbox.checked=e)?(this.value=this.trueValue,t.Utils.addClass(this,t.PCSS+"-selected"),this.aria.attributes.set("checked","true")):(this.value=this.falseValue,t.Utils.removeClass(this,t.PCSS+"-selected"),this.aria.attributes.set("checked","false"))}acceptValue(e){this.selected=e==this.trueValue}getViewValue(e){return t.Utils.isNull(e)?"":this.caption}};$e([t.ViewChild("input[type=checkbox]")],Ue.prototype,"_checkbox",void 0),$e([t.ViewChild("label")],Ue.prototype,"_label",void 0),$e([t.ViewChild(`.${t.PCSS}-readonly`)],Ue.prototype,"span",void 0),$e([t.Watch({converter:t.PropertyConverters.String})],Ue.prototype,"caption",void 0),$e([t.Watch({emit:!1,converter:ke})],Ue.prototype,"trueValue",void 0),$e([t.Watch({emit:!1,converter:ke})],Ue.prototype,"falseValue",void 0),$e([t.Watch({converter:t.PropertyConverters.Boolean})],Ue.prototype,"selected",void 0),Ue=$e([t.CustomElement({tagName:t.P+"-checkbox",template:`<${t.P}-span class="${t.PCSS}-readonly ${t.PCSS}-checkbox" text="{{ :host.caption }}"></${t.P}-span>\n<input type="checkbox" class="${t.PCSS}-input" /><label class="${t.PCSS}-label ${t.PCSS}-checkbox ${t.PCSS}-viewfinder" pacem><${t.P}-span content="{{ :host.caption }}"></${t.P}-span></label>`,shadow:t.Defaults.USE_SHADOW_ROOT})],Ue);var Ne=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};let Oe=class extends A{acceptValue(e){}constructor(){super(!0),this._selectedUiItems=[],this.key="_"+t.Utils.uniqueCode()}get inputFields(){return[]}propertyChangedCallback(e,t,i,r){super.propertyChangedCallback(e,t,i,r),"disabled"===e&&(this._disable.model=i)}viewActivatedCallback(){super.viewActivatedCallback(),this._disable.model=this.disabled}toggleReadonlyView(e){this._span.hidden=!e,this._repeater.hidden=e}_selectionChanged(e,t,i){if("selected"===e.detail.propertyName){let i,r=this._selectedUiItems;!0===e.detail.currentValue?r.push(this.datasource[t]):-1!==(i=r.indexOf(this.datasource[t]))&&r.splice(i,1)}}onChange(e){const i=this.value=this._selectedUiItems.map(e=>this.mapEntityToValue(e));return t.Utils.fromResult(i)}};Ne([t.ViewChild(`span.${t.PCSS}-readonly`)],Oe.prototype,"_span",void 0),Ne([t.ViewChild(t.P+"-repeater")],Oe.prototype,"_repeater",void 0),Ne([t.ViewChild(t.P+"-data")],Oe.prototype,"_disable",void 0),Oe=Ne([t.CustomElement({tagName:t.P+"-checkbox-list",template:`<${t.P}-repeater datasource="{{ :host.adaptedDatasource }}">\n <ol class="${t.PCSS}-checkbox-list ${t.PCSS}-viewfinder" pacem>\n <template>\n <li><${t.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-${t.PropertyChangeEventName}=":host._selectionChanged($event, ^index, ^item)" on-change=":host.changeHandler($event)"></${t.P}-checkbox></li>\n </template>\n </ol>\n</${t.P}-repeater><span class="${t.PCSS}-readonly"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></span><${t.P}-data></${t.P}-data><${t.P}-content></${t.P}-content>`,shadow:t.Defaults.USE_SHADOW_ROOT})],Oe);var xe=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};let Ve=class extends t.PacemEventTarget{propertyChangedCallback(e,i,r,s){if(super.propertyChangedCallback(e,i,r,s),!s){const i=this.property,s=this.watch,a=!t.Utils.isNullOrEmpty(i),n=!t.Utils.isNull(this.model);("watch"===e||"property"===e||"model"===e&&a&&n&&t.Utils.isArray(r)&&r.some(e=>!(i in e)||e[i]!==s)||"model"===e&&a&&n&&!t.Utils.isArray(r)&&(!(i in r)||r[i]!==s))&&this._synchronize()}}viewActivatedCallback(){super.viewActivatedCallback(),this._synchronize()}_synchronize(){const e=this.model,i=this.property,r=this.watch;if(!t.Utils.isNullOrEmpty(e)&&!t.Utils.isNullOrEmpty(i))if(t.Utils.isArray(e)){for(let t of e)t[i]=r;this.model=e.slice(0)}else e[i]=r,this.model=t.Utils.extend({},e)}};xe([t.Watch({emit:!0})],Ve.prototype,"model",void 0),xe([t.Watch({emit:!1,converter:t.PropertyConverters.String,reflectBack:!0})],Ve.prototype,"property",void 0),xe([t.Watch({emit:!1})],Ve.prototype,"watch",void 0),Ve=xe([t.CustomElement({tagName:t.P+"-childform-propagator"})],Ve);let De=class extends x{constructor(){super(...arguments),this._model=[],this._subForms=[]}get inputFields(){return[]}toggleReadonlyView(e){}onChange(e){return new Promise((e,t)=>{var i=this._modelToEntity();e(this.value=i)})}acceptValue(e){this._entityToModel(e)}getViewValue(e){return""}convertValueAttributeToProperty(e){return t.PropertyConverters.Json.convert(e,this)}propertyChangedCallback(e,t,i,r){if(super.propertyChangedCallback(e,t,i,r),"mode"===e)this._entityToModel()}_dragStart(e){var i=e.detail;const r=t.Utils.offset(i.element),s=i.floater;s.style.width=r.width+"px",s.style.height=r.height+"px"}_dragEnd(e){"array"===this.mode&&this._triggerChange()}reset(){super.reset(),this._subForms.forEach(e=>{e.setPristine()})}_itemCreate(e){const i=e.detail.index,r=this._subForms;e.detail.dom[0].childNodes.forEach(e=>{e instanceof Element&&e.localName===t.P+"-form"&&r.splice(i,r.length-i,e)})}_itemChange(e,i){"entity"===i.detail.propertyName&&t.Utils.Json.stringify(this._model[e])!==t.Utils.Json.stringify(i.detail.currentValue)&&(this._model.splice(e,1,i.detail.currentValue),this._triggerChange())}_deleteAt(e){t.avoidHandler(e.srcEvent);const i=this._model;"array"===this.mode?i.splice(e.detail,1):i.splice(0,i.length),this._triggerChange()}_addItem(e){const t=this.mode,i=this._model;"array"===t?i.push({}):i.splice(0,i.length,{}),this._triggerChange()}_triggerChange(){this.changeHandler(new Event("change"))}_entityToModel(e=this.value){if("array"===this.mode){let i=e||[];t.Utils.isArray(i)&&this._model.cloneFrom(i)}else{const i=this._model,r=i.length;1===r&&i[0]===e||(t.Utils.isNull(e)?i.splice(0,r):i.splice(0,r,e))}}_modelToEntity(e=this._model){return"array"===this.mode?t.Utils.clone(e):e&&e.length&&e[0]||null}};xe([t.Watch({emit:!1,converter:t.PropertyConverters.String})],De.prototype,"fetchCredentials",void 0),xe([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],De.prototype,"fetchHeaders",void 0),xe([t.ViewChild("."+t.PCSS+"-childform")],De.prototype,"_container",void 0),xe([t.ViewChild(t.P+"-drag-drop")],De.prototype,"_dragger",void 0),xe([t.ViewChild("."+t.PCSS+"-childform-item-floater")],De.prototype,"_floater",void 0),xe([t.Watch({converter:t.PropertyConverters.String})],De.prototype,"mode",void 0),xe([t.Watch({converter:t.PropertyConverters.Boolean})],De.prototype,"lockItems",void 0),xe([t.Watch({converter:t.PropertyConverters.Json})],De.prototype,"metadata",void 0),xe([t.Watch({converter:t.PropertyConverters.Json})],De.prototype,"_model",void 0),De=xe([t.CustomElement({tagName:t.P+"-childform",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<${t.P}-repeater datasource="{{ :host._model }}" on-itemdelete=":host._deleteAt($event)" on-${t.Components.RepeaterItemCreateEventName}=":host._itemCreate($event)">\n <div class="${t.PCSS}-childform">\n <template>\n <${t.P}-panel class="${t.PCSS}-childform-item" behaviors="{{ [::_dragger] }}">\n <${t.P}-panel class="childform-item-handle ${t.PCSS}-margin margin-right-1" hide="{{ :host.lockItems || :host.readonly || :host.mode !== 'array' || !(:host._model && :host._model.length > 1) }}"><i class="${t.PCSS}-icon drag-handle">drag_handle</i></${t.P}-panel>\n <${t.P}-panel class="childform-item-index text-small"><${t.P}-span hide="{{ !:host.readonly || :host.mode !== 'array' }}" class="${t.PCSS}-margin margin-right-1" text="{{ ^index+1 }}"></${t.P}-span></${t.P}-panel>\n <${t.P}-form entity="{{ ^item }}" fetch-headers="{{ :host.fetchHeaders }}" fetch-credentials="{{ :host.fetchCredentials }}" on-${t.PropertyChangeEventName}=":host._itemChange(^index, $event)" readonly="{{ :host.readonly }}" metadata="{{ :host.metadata }}" autogenerate="true" logger="{{ :host.logger }}"></${t.P}-form>\n <${t.P}-button tab-order="-1" class="flat circular circle-small clear ${t.PCSS}-margin margin-left-1" hide="{{ :host.lockItems || :host.readonly }}" command-name="delete" command-argument="{{ ^index }}"></${t.P}-button>\n </${t.P}-panel>\n </template>\n </div>\n <${t.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)"></${t.P}-button>\n</${t.P}-repeater>\n<div class="${t.PCSS}-childform-item-floater ${t.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<${t.P}-drag-drop floater="{{ ::_floater }}" disabled="{{ :host.lockItems }}"\n on-${t.UI.DragDropEventType.Start}=":host._dragStart($event)"\n on-${t.UI.DragDropEventType.End}=":host._dragEnd($event)" \n drop-behavior="${t.UI.DropBehavior.InsertChild}" mode="${t.UI.DragDataMode.Alias}" handle-selector=".drag-handle" drop-targets="{{ [::_container] }}"></${t.P}-drag-drop>`})],De);var He=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};const Ae={convert:(e,i)=>/\{.+\}/.test(e)?t.PropertyConverters.Json.convert(e):t.PropertyConverters.String.convert(e),convertBack:(e,i)=>"string"==typeof e?e:t.PropertyConverters.Json.convertBack(e,i)};let Le=class extends x{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(e){return t.PropertyConverters.Datetime.convert(e)}connectedCallback(){super.connectedCallback();const e=new Date;let i=this.year=e.getFullYear();this.min=new Date(i-100,0,1),this.max=new Date(i+10,11,31),this.month=e.getMonth();let r=[],s=[],a=[],n=t.Utils.leftPad;for(let e=0;e<12;e++){let s=new Date(i,e,1),a=s.toLocaleString(t.Utils.lang(this),{month:"short"});r.push({value:e,date:s,label:a})}this._months=r;for(let e=0;e<24;e++)s.push(n(e,2,"0"));this._a24=s;for(let e=0;e<60;e++)a.push(n(e,2,"0"));this._a60=a}propertyChangedCallback(e,i,r,s){switch(super.propertyChangedCallback(e,i,r,s),e){case"dateValue":this.log(t.Logging.LogLevel.Log,`dateValue changed from ${i} to ${r}`),this._disassembleDate(r);break;case"min":case"max":t.Utils.isNullOrEmpty(this.min)||t.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(e){this.dateValue=t.Utils.parseDate(e)}_disassembleDate(e){if(!e)return void(this.date=void 0);"string"==typeof e&&(e=t.Utils.parseDate(e));const i=e=>t.Utils.leftPad(e,2,"0");this.year=e.getFullYear(),this.month=e.getMonth(),this.date=e.getDate(),this.hours=i(e.getHours()),this.minutes=i(e.getMinutes()),this.seconds=i(e.getSeconds())}_setupYears(){let e=[];const i=t.Utils.parseDate(this.min),r=t.Utils.parseDate(this.max);for(let t=i.getFullYear();t<=r.getFullYear();t++)e.push(t);this._years=e}onChange(e){return new Promise((e,t)=>{e(this.value=this._computeValue())})}_buildupDates(e){e&&e.stopPropagation();const i=this,r={weekday:"short",day:"numeric"},s=e=>{try{let t=+i.month;return new Date(+i.year,+i.month,e).getMonth()==t}catch(e){return!1}};var a=[];if(!t.Utils.isNullOrEmpty(i.year)&&!t.Utils.isNullOrEmpty(i.month)){let e=1;do{let s=new Date(+i.year,+i.month,e),n=s.toLocaleString(t.Utils.lang(this),r);a.push({value:e,date:s,label:n,disabled:s<this.min||s>this.max})}while(s(++e))}this._dates=a,s(+this.date)?this._buildup():this.date=""}_computeValue(){const e=this;if(t.Utils.isNullOrEmpty(e.year)||t.Utils.isNullOrEmpty(e.month)||t.Utils.isNullOrEmpty(e.date))return null;try{let t=new Date(+e.year,+e.month,+e.date);return t.setHours(+e.hours),t.setMinutes(+e.minutes),t.setSeconds(+e.seconds),t.setMilliseconds(0),Number.isNaN(t.valueOf())?null:t}catch(e){return null}}_buildup(e){e&&e.stopPropagation(),this.dateValue=this._computeValue()}getViewValue(e){const i=e;return i?t.Utils.core.date(i,this.format||("day"!=this.precision?"full":"short"),t.Utils.lang(this)):""}};He([t.ViewChild("."+t.PCSS+"-datetime-picker-year > "+t.P+"-select")],Le.prototype,"_yearel",void 0),He([t.ViewChild("."+t.PCSS+"-datetime-picker-month > "+t.P+"-select")],Le.prototype,"_monthel",void 0),He([t.ViewChild("."+t.PCSS+"-datetime-picker-date > "+t.P+"-select")],Le.prototype,"_dateel",void 0),He([t.ViewChild("."+t.PCSS+"-datetime-picker-hours > "+t.P+"-select")],Le.prototype,"_hourel",void 0),He([t.ViewChild("."+t.PCSS+"-datetime-picker-minutes > "+t.P+"-select")],Le.prototype,"_minel",void 0),He([t.ViewChild("."+t.PCSS+"-datetime-picker-seconds > "+t.P+"-select")],Le.prototype,"_secel",void 0),He([t.ViewChild(`div.${t.PCSS}-datetime-picker-fields`)],Le.prototype,"_allFields",void 0),He([t.Watch({converter:t.PropertyConverters.Datetime})],Le.prototype,"dateValue",void 0),He([t.Watch({converter:t.PropertyConverters.Datetime})],Le.prototype,"min",void 0),He([t.Watch({converter:t.PropertyConverters.Datetime})],Le.prototype,"max",void 0),He([t.Watch({converter:t.PropertyConverters.String})],Le.prototype,"precision",void 0),He([t.Watch({emit:!1,converter:Ae})],Le.prototype,"format",void 0),He([t.Watch()],Le.prototype,"_dates",void 0),He([t.Watch()],Le.prototype,"_years",void 0),He([t.Watch()],Le.prototype,"year",void 0),He([t.Watch()],Le.prototype,"month",void 0),He([t.Watch()],Le.prototype,"date",void 0),He([t.Watch()],Le.prototype,"hours",void 0),He([t.Watch()],Le.prototype,"minutes",void 0),He([t.Watch()],Le.prototype,"seconds",void 0),He([t.Debounce(10)],Le.prototype,"_buildup",null),Le=He([t.CustomElement({tagName:t.P+"-datetime-picker",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<div class="${t.PCSS}-datetime-picker">\n <div class="${t.PCSS}-datetime-picker-fields ${t.PCSS}-viewfinder">\n\n <div class="${t.PCSS}-datetime-picker-year">\n <${t.P}-select value="{{ :host.year, twoway }}" placeholder="..." datasource="{{ :host._years }}">\n </${t.P}-select></div>\n\n <div class="${t.PCSS}-datetime-picker-month">\n <${t.P}-select value="{{ :host.month, twoway }}" placeholder="..." value-property="value" text-property="label" datasource="{{ :host._months }}">\n </${t.P}-select></div>\n\n <div class="${t.PCSS}-datetime-picker-date">\n <${t.P}-select value="{{ :host.date, twoway }}" placeholder="..." value-property="value" text-property="label" datasource="{{ :host._dates }}">\n </${t.P}-select></div>\n\n <${t.P}-panel class="${t.PCSS}-datetime-picker-hours" hide="{{ :host.precision === 'day' }}">\n <${t.P}-select value="{{ :host.hours, twoway }}" datasource="{{ :host._a24 }}">\n </${t.P}-select></${t.P}-panel>\n\n <${t.P}-panel class="${t.PCSS}-datetime-picker-minutes" hide="{{ :host.precision === 'day' }}">\n <${t.P}-select value="{{ :host.minutes, twoway }}" datasource="{{ :host._a60 }}">\n </${t.P}-select></${t.P}-panel>\n\n <${t.P}-panel class="${t.PCSS}-datetime-picker-seconds" hide="{{ :host.precision !== 'second' }}">\n <${t.P}-select value="{{ :host.seconds, twoway }}" datasource="{{ :host._a60 }}">\n </${t.P}-select></${t.P}-panel>\n\n </div>\n <${t.P}-panel class="${t.PCSS}-datetime-picker-preview" hide="{{ Pacem.Utils.isNullOrEmpty(:host.dateValue) || :host.precision === 'day' || :host.readonly }}">\n <dl>\n <dt>local:</dt><dd><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></dd>\n <dt>iso:</dt><dd><${t.P}-text text="{{ (:host.dateValue && :host.dateValue.toISOString()) || '' }}"></${t.P}-text></dd>\n </dl>\n </${t.P}-panel>\n <${t.P}-span class="${t.PCSS}-readonly" css-class="{{ { 'date': :host.precision === 'day', 'datetime': :host.precision !== 'day' } }}" content="{{ :host.viewValue }}" hide="{{ !:host.readonly }}"></${t.P}-span>\n</div>`})],Le);var Te=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};class Re extends ${constructor(){super()}viewActivatedCallback(){super.viewActivatedCallback(),t.Utils.addClass(this,t.PCSS+"-validator")}propertyChangedCallback(e,i,r,s){super.propertyChangedCallback(e,i,r,s);let a=this.form;switch(e){case"watch":i&&a&&a.unregisterValidator(r,this),a&&a.registerValidator(r,this);break;case"invalid":break;case"form":let e=this.watch;t.Utils.isNullOrEmpty(e)||(null!=i&&i.unregisterValidator(e,this),null!=r&&r.registerValidator(e,this));break;case"disabled":this.triggerFormFieldValidation()}}#h;triggerFormFieldValidation(){const e=this.form,i=this.watch;t.Utils.isNull(e)||t.Utils.isNullOrEmpty(i)||(cancelAnimationFrame(this.#h),this.#h=requestAnimationFrame(()=>{e.validate(i)}))}validate(e){return this.disabled?t.Utils.fromResult(!0):this.evaluate(e)}}Te([t.Watch({converter:t.PropertyConverters.Boolean})],Re.prototype,"invalid",void 0),Te([t.Watch({converter:t.PropertyConverters.String})],Re.prototype,"errorMessage",void 0),Te([t.Watch({emit:!1,reflectBack:!0,converter:t.PropertyConverters.String})],Re.prototype,"watch",void 0);const We=`<${t.P}-span part="error-message" hide="{{ !:host.invalid }}" text="{{ :host.errorMessage }}"></${t.P}-span>`;function Ie(e){return t.Utils.isNullOrEmpty(e)}let Fe=class extends Re{evaluate(e){let i=!Ie(e);return t.Utils.fromResult(i)}};Fe=Te([t.CustomElement({tagName:t.P+"-required-validator",template:We,shadow:t.Defaults.USE_SHADOW_ROOT})],Fe);let je=class extends Re{propertyChangedCallback(e,t,i,r){super.propertyChangedCallback(e,t,i,r),r||"pattern"!==e||this.triggerFormFieldValidation()}evaluate(e){let i=!0,r=this.pattern;return Ie(e)||(i=new RegExp(r).test(e)),t.Utils.fromResult(i)}};Te([t.Watch({emit:!1,converter:t.PropertyConverters.String})],je.prototype,"pattern",void 0),je=Te([t.CustomElement({tagName:t.P+"-regex-validator",template:We,shadow:t.Defaults.USE_SHADOW_ROOT})],je);let Be=class extends Re{propertyChangedCallback(e,t,i,r){super.propertyChangedCallback(e,t,i,r),r||"min"!==e&&"max"!==e||this.triggerFormFieldValidation()}evaluate(e){let i=!0;return Ie(e)||(this.min>=0&&(i=i&&(e||"").toString().length>=this.min),this.max>=0&&(i=i&&(e||"").toString().length<=this.max)),t.Utils.fromResult(i)}};Te([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],Be.prototype,"min",void 0),Te([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],Be.prototype,"max",void 0),Be=Te([t.CustomElement({tagName:t.P+"-length-validator",template:We,shadow:t.Defaults.USE_SHADOW_ROOT})],Be);let Me=class extends Re{propertyChangedCallback(e,t,i,r){super.propertyChangedCallback(e,t,i,r),r||"min"!==e&&"max"!==e||this.triggerFormFieldValidation()}evaluate(e){let i=!0;if(!Ie(e)){let r=e;e instanceof Date||"number"!=typeof e&&(r=t.Utils.parseDate(e))instanceof Date&&isFinite(r.valueOf())?(null!=this.min&&(i=i&&r.valueOf()>=t.Utils.parseDate(this.min).valueOf()),null!=this.max&&(i=i&&r.valueOf()<=t.Utils.parseDate(this.max).valueOf())):(null!=this.min&&(i=i&&e>=this.min),null!=this.max&&(i=i&&e<=this.max))}return t.Utils.fromResult(i)}};Te([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],Me.prototype,"min",void 0),Te([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],Me.prototype,"max",void 0),Me=Te([t.CustomElement({tagName:t.P+"-range-validator",template:We,shadow:t.Defaults.USE_SHADOW_ROOT})],Me);let ze=class extends Re{propertyChangedCallback(e,t,i,r){super.propertyChangedCallback(e,t,i,r),r||"operator"!==e&&"to"!==e||this.triggerFormFieldValidation()}_prepareValuesForComparison(e,i){return t.Utils.Dates.isDate(e)||t.Utils.Dates.isDate(i)?[t.Utils.parseDate(e),t.Utils.parseDate(i)]:[e,i]}evaluate(e){let i=!0,r=this.to;if(!Ie(e)&&!Ie(r)){const t=this._prepareValuesForComparison(e,r);switch(e=t[0],r=t[1],this.operator){case"lessOrEqual":i=e<=r;break;case"less":i=e<r;break;case"greaterOrEqual":i=e>=r;break;case"greater":i=e>r;break;case"notEqual":i=e!==r;break;default:i=e===r}}return t.Utils.fromResult(i)}};Te([t.Watch({emit:!1,converter:t.PropertyConverters.String})],ze.prototype,"operator",void 0),Te([t.Watch({emit:!1,reflectBack:!0})],ze.prototype,"to",void 0),ze=Te([t.CustomElement({tagName:t.P+"-compare-validator",template:We,shadow:t.Defaults.USE_SHADOW_ROOT})],ze);let qe=class extends Re{propertyChangedCallback(e,t,i,r){super.propertyChangedCallback(e,t,i,r),r||"pattern"!==e&&"maxSize"!==e||this.triggerFormFieldValidation()}evaluate(e){let i=!0,r=this.pattern,s=this.maxSize;if(!Ie(e)){if(!t.Utils.isNullOrEmpty(r)){let t="string"==typeof e?e:e.name;i=new RegExp(r,"i").test(t)}!t.Utils.isNull(s)&&"object"==typeof e&&e.size>0&&(i=i&&e.size<=s)}return t.Utils.fromResult(i)}};Te([t.Watch({emit:!1,converter:t.PropertyConverters.String})],qe.prototype,"pattern",void 0),Te([t.Watch({emit:!1,converter:t.PropertyConverters.String})],qe.prototype,"maxSize",void 0),qe=Te([t.CustomElement({tagName:t.P+"-binary-validator",template:We,shadow:t.Defaults.USE_SHADOW_ROOT})],qe);let Je=class extends Re{constructor(){super(...arguments),this._deferredToken=null}_evaluateResult(){const e=this._fetcher.result;switch(e){case"true":return!0;case"false":return!1;default:try{let i=JSON.parse(e);return t.Utils.getApiResult(i)||!1}catch(e){return!1}}}_fetch(e){const i=this._deferredToken,r=this._fetcher;var s=this.parameters||{};s[this.watch]=e;const a={parameters:s,url:this.url,as:"text",method:this.method},n=t.Utils.jsonSortStringify(a),o=this.#p;let l=!1;if(t.Utils.isNullOrEmpty(o)||(l=n===o),l){const e=this._evaluateResult();i.resolve(e)}else t.Utils.extend(r,a),clearTimeout(this._debouncer),this._debouncer=setTimeout(()=>{r.fetch().then(e=>{const t=this._evaluateResult();i.resolve(t),this.#p=n},e=>{i.resolve(!1)})},1e3);return i.promise}#p;evaluate(e){return t.Utils.isNullOrEmpty(e)?t.Utils.fromResult(!0):(this._deferredToken=this._deferredToken=t.DeferPromise.defer(),this._fetch(e).then(e=>(this._deferredToken=null,e),e=>(this._deferredToken=null,!1)))}propertyChangedCallback(e,t,i,r){if(super.propertyChangedCallback(e,t,i,r),!r)switch(e){case"parameters":case"url":case"method":case"fetchCredentials":case"fetchHeaders":this.triggerFormFieldValidation()}}};Te([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],Je.prototype,"parameters",void 0),Te([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],Je.prototype,"fetchCredentials",void 0),Te([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],Je.prototype,"fetchHeaders",void 0),Te([t.Watch({emit:!1,converter:t.PropertyConverters.String})],Je.prototype,"url",void 0),Te([t.Watch({emit:!1,converter:t.PropertyConverters.String})],Je.prototype,"method",void 0),Te([t.ViewChild(t.P+"-fetch")],Je.prototype,"_fetcher",void 0),Je=Te([t.CustomElement({tagName:t.P+"-async-validator",template:We+`<${t.P}-fetch autofetch="false" throttle="true" credentials="{{ :host.fetchCredentials }}" headers="{{ :host.fetchHeaders }}"></${t.P}-fetch>`,shadow:t.Defaults.USE_SHADOW_ROOT})],Je);let Ye=class extends Re{propertyChangedCallback(e,t,i,r){super.propertyChangedCallback(e,t,i,r),r||"isValid"!==e||this.triggerFormFieldValidation()}evaluate(e){let i=!0;return Ie(e)||(i=!!this.isValid),t.Utils.fromResult(i)}};Te([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],Ye.prototype,"isValid",void 0),Ye=Te([t.CustomElement({tagName:t.P+"-custom-validator",template:We,shadow:t.Defaults.USE_SHADOW_ROOT})],Ye);var Ke=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};function Ge(e){return new RegExp(e).source}let Xe=class extends ${constructor(e=new i.Components.UI.MarkdownService){super(),this._md=e,this._entityPropertyChangeHandler=e=>{this.dispatchEvent(new t.PropertyChangeEvent({propertyName:"entity",currentValue:this.entity}))},this._labelClickHandler=e=>{document.getElementById(this._label.htmlFor).focus()},this._key="_"+t.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(e,i,r,s){switch(super.propertyChangedCallback(e,i,r,s),e){case"readonly":this._ensureBalloon();break;case"metadata":this._ensureBalloon(),this._buildUpCss(),this._buildUpLabel(),this._buildUpField();break;case"entity":i instanceof HTMLElement&&i.removeEventListener(t.PropertyChangeEventName,this._entityPropertyChangeHandler,!1),r instanceof HTMLElement&&r.addEventListener(t.PropertyChangeEventName,this._entityPropertyChangeHandler,!1)}}disconnectedCallback(){this.entity instanceof HTMLElement&&this.entity.removeEventListener(t.PropertyChangeEventName,this._entityPropertyChangeHandler,!1),t.Utils.isNull(this._label)||this._label.removeEventListener("click",this._labelClickHandler,!1),t.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 e,r;const s=this.readonly||!1===(r=this._normalizeTooltip()).type||t.Utils.isNullOrEmpty(e=this.metadata&&this.metadata.display&&this.metadata.display.description);if(t.Utils.isNull(this._balloon)&&!s){let e=document.createElement(t.P+"-balloon");e.options={behavior:i.Components.UI.BalloonBehavior.Tooltip,trigger:r.trigger||i.Components.UI.BalloonTrigger.Hover,position:r.position||i.Components.UI.BalloonPosition.Top,hoverDelay:200,hoverTimeout:50,align:r.align||i.Components.UI.BalloonAlignment.Auto},t.Utils.addClass(e,t.PCSS+"-field-tooltip"),t.CustomElementUtils.findAncestorShell(this).appendChild(this._balloon=e)}const a=this._balloon;if(!(t.Utils.isNull(a)||(a.target=this._label,a.disabled=s))){const t=e||"";switch(r.type){case"md":case"markdown":a.innerHTML=this._md.toHtml(t);break;case"html":a.innerHTML=t;break;default:a.innerText=t}}}_buildUpCss(){const e=this.metadata?.display;if(!t.Utils.isNull(e)){if("function"==typeof e.cssClass){const{cssClassAttr:t}=e.cssClass(this,"$this","$this.entity");this.setAttribute("css-class",t)}else this.cssClass=e.cssClass;if("function"==typeof e.css){const{cssAttr:t}=e.css(this,"$this","$this.entity");this.setAttribute("css",t)}else this.css=e.css}}_buildUpLabel(){const e=this._label,i=e.firstElementChild,r=this.metadata;e.htmlFor=this._key,t.Utils.addClass(e,t.PCSS+"-label");const s=this.metadata.validators;if(s&&s.find(e=>"required"===e.type)?t.Utils.addClass(e,t.PCSS+"-required"):t.Utils.removeClass(e,t.PCSS+"-required"),t.Utils.isNull(this._balloon)||this._balloon.disabled?t.Utils.removeClass(e,t.PCSS+"-tooltip"):t.Utils.addClass(e,t.PCSS+"-tooltip"),"function"==typeof r.display?.name){const{contentAttr:e}=r.display.name(this,":host",":host.entity","::_form");i.setAttribute("content",e)}else i.removeAttribute("content"),i.content=r.display&&r.display.name||r.prop;e.setAttribute("id","label"+this._key),e.addEventListener("click",this._labelClickHandler,!1)}_isValueNullOrEmpty(e=this.entity,i=this.metadata){if(t.Utils.isNull(i))return!0;const r=i.prop.split(".");let s=e;for(let e=0;e<r.length;e++){const i=r[e];if(t.Utils.isNullOrEmpty(s&&s[i]))return!0;s=s[i]}return!1}_handleValueChange(e){if("value"===e.detail.propertyName){const i=e.detail.currentValue,r=this.metadata.prop;if(this.entity instanceof HTMLElement){let e=t.CustomElementUtils.camelToKebab(r);t.Utils.isNullOrEmpty(i)?this.entity.removeAttribute(e):this.entity.setAttribute(e,i.toString())}else this.entity[r]=i}}_adjustDependencyValue(e){return t.Utils.Dates.isDate(e)?t.Utils.Dates.parse(e).toISOString():e}_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 }}")}_apiResult(e){return t.Utils.getApiResult(e)}_buildUpField(){this._field&&this._field.remove(),this._fetcher.removeAttribute("parameters"),this._fetcher.result=this._fetcher.url=null;for(var e=this._validators.children.length-1;e>=0;e--)this._validators.children[e].remove();var i=this.metadata;let r=t.P+"-input-text",s=t.P+(i.display&&"slider"===i.display.ui?"-slider":"-input-number"),a={id:this._key,name:i.prop,readonly:"{{ :host.readonly || :host.metadata.isReadOnly || ::_form.readonly }}",value:`{{ :host.entity.${i.prop}, twoway }}`,placeholder:`${i.display&&i.display.watermark||""}`};1==i.extra?.autofocus&&(a["on-load"]="requestAnimationFrame(() => $this.focus())");let n=i.extra||{},o={},l="false",c="",d="",h="",p=[];if(!t.Utils.isNullOrEmpty(n.dependsOn))if("function"==typeof n.dependsOn){const w=n.dependsOn(this,":host",":host.entity","$this.entity"),E=w.hideAttr;if(t.Utils.isNullOrEmpty(E)||this.setAttribute("hide",E),t.Utils.isNullOrEmpty(w.disabledAttr)||(l=w.disabledAttr,t.CustomElementUtils.isBindingAttribute(l)&&(d=t.CustomElementUtils.extractBindingAttributeExpression(l))),!t.Utils.isNullOrEmpty(w.parameterAttrs)){const S=w.parameterAttrs,$=[];for(let k in S){const U=S[k];$.push(`${k}: ${U}`),p.push({prop:U})}h=$.join(", ")}}else{p=n.dependsOn;let N={empty:[],notEqual:{}},O={empty:[],notEqual:{}},x=[];for(var u of p){let D=":host.entity."+u.prop,H="$this.entity."+u.prop;if(t.Utils.isNullOrEmpty(u.value)){if(!u.optional){let A=e=>"$pacem.isNullOrEmpty("+e+")";N.empty.push(A(D)),u.hide&&O.empty.push(A(H))}}else{let L=e=>e+" !== "+JSON.stringify(u.value);(N.notEqual[D]=N.notEqual[D]||[]).push(L(D)),u.hide&&(O.notEqual[H]=O.notEqual[H]||[]).push(L(H))}x.push(`${u.alias||u.prop}: :host._adjustDependencyValue(${D})`),u.optional||(c+=`!$pacem.isNullOrEmpty(${D}) && `)}h=x.join(", ");let V=e=>{let i="false",r="false";if(!t.Utils.isNullOrEmpty(e.notEqual)){const t=[];for(let i in e.notEqual)t.push("("+e.notEqual[i].join(" && ")+")");i="("+t.join(" || ")+")"}return t.Utils.isNullOrEmpty(e.empty)||(r="("+e.empty.join(" || ")+")"),i+" || "+r};d=V(N),l=`{{ ${d} }}`,this.setAttribute("hide",`{{ ${V(O)} }}`)}const m="fn",v=this[m]=this[m]||{},g=(e=[])=>{let i=(p||[]).map(e=>":host.entity."+e.prop).join(", ");const r="fn"+t.Utils.uniqueCode();if("function"==typeof e)v[r]=e;else{if(!t.Utils.isArray(e))throw"Unsupported source format.";v[r]=()=>e}return`{{ :host.${m}.${r}(${i}) }}`},y=new DocumentFragment;let f;if("function"==typeof i.type){var _=i.type(this,":host",":host.entity");if(-1===_.tagName.indexOf("-"))this.log(t.Logging.LogLevel.Error,`${r} is not an allowed form-field`);else{function T(e,i){if(!t.Utils.isNullOrEmpty(i))for(let s of i){if(-1===s.tagName.indexOf("-")){this.log(t.Logging.LogLevel.Error,`${s.tagName} is not an allowed child element for form-field ${r}`);continue}const i=document.createElement(s.tagName);if(!t.Utils.isNullOrEmpty(s.attrs))for(let e in s.attrs){const t=s.attrs[e];i.setAttribute(e,t)}t.Utils.isNullOrEmpty(s.children)||T(i,s.children),e.appendChild(i)}}r=_.tagName,t.Utils.extend(a,_.attrs||{}),T(y,_.children)}}else switch(f=i.display&&i.display.ui){case"contentEditable":console.warn("`contentEditable` ui hint is deprecated. Lean on `dataType` equal to 'HTML' instead."),r=t.P+"-contenteditable",y.append(de.getDefaultDashboard());break;case"snapshot":r=t.P+"-snapshot",n.width>0&&(a.width=""+n.width),n.height>0&&(a.height=""+n.height),n.quality>=0&&(a.quality=""+n.quality);break;case"chars":case"digits":case"otp":r=t.P+"-input-chars",n.charCount>0&&(a.charCount=""+n.charCount),t.Utils.isNullOrEmpty(n.inputTransform)||(a["input-transform"]=n.inputTransform);break;case"oneToMany":case"dropdown":case"radioList":case"checkboxList":case"manyToMany":"oneToMany"===f||"dropdown"===f?(r=t.P+"-select",!1!==n.preventWheel&&(a["on-wheel"]="$event.preventDefault()")):(delete a.placeholder,r=t.P+("radioList"===f?"-radio-list":"-checkbox-list")),t.Utils.isNullOrEmpty(n.textProperty)||(a["text-property"]=n.textProperty),t.Utils.isNullOrEmpty(n.disabledProperty)||(a["disabled-property"]=n.disabledProperty),t.Utils.isNullOrEmpty(n.valueProperty)||(i.isComplexType?a["compare-by"]=n.valueProperty:a["value-property"]=n.valueProperty),t.Utils.isNullOrEmpty(n.source)?(this._fetcher.id=`fetch${this._key}`,this._fetcher.url=n.sourceUrl,this._fetcher.method=n.verb,o.parameters=`{{ { ${h} } }}`,o.disabled=l,a.datasource=`{{ ${c}:host._apiResult(#fetch${this._key}.result) || null }}`):a.datasource=g(n.source);break;case"suggest":case"tags":case"autocomplete":const R="tags"===i.display.ui;r=t.P+(R?"-tags":"-suggest"),this._fetcher.id=`fetch${this._key}`,t.Utils.isNullOrEmpty(n.textProperty)||(a["text-property"]=n.textProperty);let W=`#${this._key}.value`;if(t.Utils.isNullOrEmpty(n.valueProperty)||(a["compare-by"]=n.valueProperty,R?W=`(${W} && ${W}.${n.valueProperty}) || ''`:i.isComplexType?W+=` && ${W}.${n.valueProperty}`:a["value-property"]=n.valueProperty),t.Utils.isNullOrEmpty(n.sourceUrl)?a.datasource=g(n.source):(o.url=`${n.sourceUrl}`,this._fetcher.method=n.verb,t.Utils.isNullOrEmpty(n.dependsOn)?o.parameters=`{{ {q: #${this._key}.hint || '', ${n.valueProperty||"value"}: ${W} || '' } }}`:(o.parameters=`{{ { ${h}, q: #${this._key}.hint || '', ${n.valueProperty||"value"}: ${W} || '' } }}`,o.disabled=l),a.datasource=`{{ ${c}:host._apiResult(#fetch${this._key}.result) || null }}`),R)a["allow-new"]=(!0===i.extra.allowNew).toString(),a["allow-duplicates"]=(!0===i.extra.allowDuplicates).toString();else{if(t.Utils.isNullOrEmpty(n.disabledProperty)||(a["disabled-property"]=n.disabledProperty),!t.Utils.isNullOrEmpty(n.itemtemplate)){const j=n.itemtemplate;j instanceof HTMLElement?(a.itemtemplate="{{ #"+(j.id=j.id||this._key+"_itemtmpl")+" }}",j.isConnected||this.append(j)):a.itemtemplate=j}if(!t.Utils.isNullOrEmpty(n.filterFields)){const B=n.filterFields;a["filter-fields"]=t.Utils.isArray(B)?B.join(" "):B}t.Utils.isNullOrEmpty(n.maxSuggestions)||(a["max-suggestions"]=n.maxSuggestions.toString())}break;case"calendar":r=t.P+"-calendar-picker";const I=i.display?.format??i.extra?.format;t.Utils.isNullOrEmpty(I)||(a.format="{{ "+JSON.stringify(I)+" }}"),t.Utils.isNullOrEmpty(n.disabledRanges)||(a["disabled-ranges"]="{{ "+JSON.stringify(n.disabledRanges)+" }}");break;case"dictionary":r=t.P+"-namevalue-list",a.dictionary="true";break;case"switcher":if("boolean"!==(i.type||"").toLowerCase())break;a.class="checkbox-switch";default:let F=(i.dataType||i.type||"").toLowerCase();switch(F){case"upload":r=t.P+"-upload";let M=i.extra||{};a.url=M.uploadUrl,a.parallelism=""+M.parallelism,a["chunk-size"]=""+M.chunkSize,a["max-image-width"]=""+M.maxImageWidth,a["max-image-height"]=""+M.maxImageHeight,a["select-mode"]=M.mode??"file";break;case"html":r=t.P+"-contenteditable",y.append(de.getDefaultDashboard());break;case"enumeration":r=t.P+"-radio-list",a.class=t.PCSS+"-radio-list",a["value-property"]="value",a["text-property"]="caption",a.datasource="{{ "+JSON.stringify(i.extra.enum)+" }}",delete a.placeholder;break;case"password":r=t.P+"-input-password";break;case"emailaddress":r=t.P+"-input-email";break;case"color":r=t.P+"-input-color";break;case"time":case"date":case"datetime":r=t.P+"-datetime-picker",delete a.placeholder,"datetime"===F&&(a.precision="minute");const z=i.display?.format??i.extra?.format;t.Utils.isNullOrEmpty(z)||(a.format="{{ "+JSON.stringify(z)+" }}"),t.Utils.isNullOrEmpty(n.disabledRanges)||(a["disabled-ranges"]="{{ "+JSON.stringify(n.disabledRanges)+" }}");break;case"url":r=t.P+"-input-url";break;case"phonenumber":r=t.P+"-input-tel";break;case"multilinetext":r=t.P+"-textarea";break;case"markdown":r=t.P+"-textarea-markdown";break;case"latlng":r=t.P+"-latlng",t.Utils.isNullOrEmpty(i.extra)||"object"!=typeof i.extra||t.Utils.isArray(i.extra)||(a.options=JSON.stringify(i.extra));break;case"percent":case"percentage":case"currency":let q="currency"===F?{style:"currency",currency:"EUR"}:{style:"percent",maximumFractionDigits:2},J=i.display?.format??q;a.format=JSON.stringify(J);default:switch((i.type||"").toLowerCase()){case"boolean":r=t.P+"-checkbox",a["true-value"]="{{ true }}",a["false-value"]="{{ false }}",a.caption=a.placeholder,delete a.placeholder;break;case"byte":a.min="0",a.max="255";case"int16":case"int32":case"int64":case"short":case"integer":case"int":case"long":a.step=""+(i.extra?.step??"1"),r=s;const Y=i.display?.format;t.Utils.isNullOrEmpty(Y)||(a.format=JSON.stringify(Y)),!1!==n.preventWheel&&r===t.P+"-input-number"&&(a["on-wheel"]="$event.preventDefault()");break;case"double":case"decimal":case"float":case"single":case"number":r=s,a.step=""+(i.extra?.step??"any");const K=i.display?.format;t.Utils.isNullOrEmpty(K)||(a.format=JSON.stringify(K)),!1!==n.preventWheel&&r===t.P+"-input-number"&&(a["on-wheel"]="$event.preventDefault()");break;default:if(("array"===i.type||"object"===i.type)&&!t.Utils.isNullOrEmpty(i.props)){if(r=t.P+"-childform",delete a.placeholder,a.metadata=t.Utils.Json.stringify(i.props,{functions:t.JsonFunctionConversion.Reference}),a.mode=i.type,a["lock-items"]=""+(i.extra&&i.extra.lockItems||!1),a.logger="{{ :host.logger }}",!t.Utils.isNullOrEmpty(p)){var b="";for(let G of p)b+=`<${t.P}-childform-propagator model="${a.value}" watch="{{ :host.entity.${G.prop} }}" property="${G.alias||G.prop}"></${t.P}-childform-propagator>\n`;this._container.innerHTML=b}a["fetch-credentials"]="{{ :host.fetchCredentials }}",a["fetch-headers"]="{{ :host.fetchHeaders }}"}}}}if(!t.Utils.isNullOrEmpty(i.commands)){t.Utils.addClass(this._container,t.PCSS+"-fieldgroup");const X=this._container.appendChild(document.createElement("div")),Z=this._container.appendChild(document.createElement("div"));t.Utils.addClass(X,`fieldgroup-prepend ${t.PCSS}-buttonset buttons`),t.Utils.addClass(Z,`fieldgroup-append ${t.PCSS}-buttonset buttons`);const Q=d||"false";i.commands.forEach(e=>{const r=document.createElement(t.P+"-button");r.setAttribute("icon-glyph",e.icon),r.setAttribute("command-name",e.name),e.dependsOnValue?(r.setAttribute("disabled",`{{ (${Q}) || !::_form.valid || $pacem.isNullOrEmpty(:host.entity.${i.prop}) }}`),r.setAttribute("command-argument",`{{ :host.entity.${i.prop} }}`)):r.setAttribute("disabled",l),r.setAttribute("tooltip",e.tooltip),t.Utils.isNullOrEmpty(e.cssClass)||t.Utils.addClass(r,e.cssClass.join(" ")),(e.prepend?X:Z).appendChild(r)})}t.Utils.isNullOrEmpty(i.validators)||i.validators.forEach(e=>{var s,n={},o={};switch(function(e){return"errorMessage"in e}(e)&&(n=e.params||{},o["error-message"]=e.errorMessage),function(e){return"attributes"in e&&"function"==typeof e.attributes}(e)&&t.Utils.extend(o,e.attributes(this,":host",":host.entity")),e.type){case"required":a.required="true",s=new Fe;break;case"length":let l=new Be;s=l;let c=n&&n.max,d=n&&n.min;null!=c?(a.maxlength=""+(l.max=c),r===t.P+"-input-chars"&&(a.count??=""+c)):"max"in o&&(a.max=o.max),null!=d?a.minlength=""+(l.min=d):"min"in o&&(a.minlength=o.min);break;case"range":let h=new Me;s=h;let u=n&&n.max,m=n&&n.min,v=r===t.P+"-datetime-picker";null!=u?(h.max=u,a.max="{{ "+(v?"'"+u+"'":u)+" }}"):"max"in o&&(a.max=o.max),null!=m?(h.min=m,a.min="{{ "+(v?"'"+m+"'":m)+" }}"):"min"in o&&(a.min=o.min);break;case"email":let g=new je;s=g,a.pattern=Ge(g.pattern=/^[\w\-\.]+@[\w\-\.]+\.[a-zA-Z0-9]{2,6}$/);break;case"regex":let y=new je;s=y;let f=n.pattern;f||=o.pattern,a.pattern=Ge(f),y.pattern=f;break;case"binary":let _=new qe;s=_;let b=n.pattern;null!=b?(a.pattern=Ge(b),_.pattern=b):"pattern"in o&&(a.pattern=o.pattern);let C=n&&n.maxSize;null!=C?(_.maxSize=C,a["max-size"]=""+C):"max-size"in o&&(a["max-size"]=o["max-size"]);break;case"compare":let P=new ze;s=P;let w="";if("value"in n)w=JSON.stringify(n.value);else{w=`:host.entity.${"to"in n?n.to:n.toProperty}`}const E=`{{ ${w} }}`;P.setAttribute("to",E);let S=P.operator=n.operator||o.operator||"equal";if(r===t.P+"-datetime-picker")switch(S){case"lessOrEqual":case"less":a.max=E;break;case"greaterOrEqual":case"greater":a.min=E}break;case"async":let $=new Je;s=$,$.url=n.url;let k=[],U=n.dependsOn||p;k.push(`${i.prop}: :host._adjustDependencyValue(:host.entity.${i.prop})`);for(let e of U||[])k.push(`${e.alias||e.prop}: :host._adjustDependencyValue(:host.entity.${e.prop})`);$.setAttribute("parameters",`{{ { ${k.join(", ")} } }}`),$.method=n.verb||t.Net.HttpMethod.Get,$.setAttribute("fetch-credentials","{{ :host.fetchCredentials }}"),$.setAttribute("fetch-headers","{{ :host.fetchHeaders }}");break;case"custom":s=new Ye;break;default:if(!t.Utils.isNullOrEmpty(e.type)&&e.type.indexOf("-")>0){const t=e.type,i=document.createElement(t);i instanceof Re&&(s=i)}}if(t.Utils.isNull(s))throw`Cannot generate a formfield validator based on type: ${e.type}.`;s.watch=i.prop,s.setAttribute("hide","{{ !this.invalid }}"),s.setAttribute("disabled",l);for(let e in o)s.setAttribute(e,o[e]);this._validators.appendChild(s)});let C=document.createElement(r);for(var P in a){let ee;t.Utils.isNullOrEmpty(ee=a[P])||C.setAttribute(P,ee)}for(var P in C.append(y),this._field=C,this._container.insertBefore(C,this._container.firstElementChild),o){let te;t.Utils.isNullOrEmpty(te=o[P])||this._fetcher.setAttribute(P,te)}this.dispatchEvent(new t.PropertyChangeEvent({propertyName:"field",currentValue:C}))}};Ke([t.ViewChild("label")],Xe.prototype,"_label",void 0),Ke([t.ViewChild(`div.${t.PCSS}-input-container`)],Xe.prototype,"_container",void 0),Ke([t.ViewChild(t.P+"-fetch")],Xe.prototype,"_fetcher",void 0),Ke([t.ViewChild(t.P+"-form")],Xe.prototype,"_form",void 0),Ke([t.ViewChild(t.P+"-panel."+t.PCSS+"-validators")],Xe.prototype,"_validators",void 0),Ke([t.Watch({converter:t.PropertyConverters.Json})],Xe.prototype,"metadata",void 0),Ke([t.Watch({converter:t.PropertyConverters.Json})],Xe.prototype,"fetchHeaders",void 0),Ke([t.Watch({converter:t.PropertyConverters.String})],Xe.prototype,"fetchCredentials",void 0),Ke([t.Watch({converter:t.PropertyConverters.Boolean})],Xe.prototype,"readonly",void 0),Ke([t.Watch()],Xe.prototype,"entity",void 0),Xe=Ke([t.CustomElement({tagName:t.P+"-form-field",template:`<${t.P}-form class="${t.PCSS}-field" logger="{{ :host.logger }}" \ncss-class="{{ {'${t.PCSS}-fetching': ::_fetcher.fetching, '${t.PCSS}-dirty': this.dirty, '${t.PCSS}-invalid': !this.valid, '${t.PCSS}-editable': !:host.readonly, '${t.PCSS}-readonly': :host.readonly, '${t.PCSS}-pristine': !this.dirty, '${t.PCSS}-valid': this.valid, '${t.PCSS}-has-value': !:host._isValueNullOrEmpty(:host.entity, :host.metadata) } }}">\n <label class="${t.PCSS}-label"><${t.P}-span></${t.P}-span></label>\n <div class="${t.PCSS}-input-container"></div>\n <${t.P}-fetch debounce="300" logger="{{ :host.logger }}" credentials="{{ :host.fetchCredentials }}" headers="{{ :host.fetchHeaders }}" diff-by-values="true"\n on-fetchresult=":host._broadcastFetchResult($event.detail)"></${t.P}-fetch>\n <${t.P}-panel class="${t.PCSS}-validators" hide="{{ ::_form.valid || !::_form.dirty || :host.readonly }}"></${t.P}-panel>\n</${t.P}-form>`})],Xe);var Ze=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};let Qe=class extends x{constructor(){super(...arguments),this._dragendHandler=e=>{this._reverseGeocoder.position=e.detail.position}}get inputFields(){return[]}toggleReadonlyView(e){this._setupSuggest(),this._setupMapMarker()}onChange(e){return new Promise((i,a)=>{if("success"===e.type&&e.target===this._reverseGeocoder){const s=this.#u.position,a=e.detail.sort((e,t)=>r.Maps.MapProjection.distanceBetween(e.position,s)<r.Maps.MapProjection.distanceBetween(t.position,s)?0:-1),n=a[0].position.altitude,o=t.Utils.extend({},a[0],{position:t.Utils.extend({altitude:n},s)});i(this.value=o)}else e.type===s&&e.target===this._suggest?i(this.value=this._suggest.value):i(this.value)})}fetch(e){r.Maps.LatLng.isLatLng(e)&&(this.#u.position=this._reverseGeocoder.position=e)}compareValuePropertyValues(e,t){const i=e?.position??r.Maps.LatLng.Empty,s=t?.position??r.Maps.LatLng.Empty;return r.Maps.LatLng.equals(i,s)}acceptValue(e){t.Utils.isNull(e)?this._datasource.model=[]:(this._datasource.model=[e],this._setupMapMarker()),this._setupSuggest()}getViewValue(e){return e?.fullAddress||""}convertValueAttributeToProperty(e){return t.PropertyConverters.Json.convert(e,this)}#u;viewActivatedCallback(){super.viewActivatedCallback(),this._setup()}propertyChangedCallback(e,t,i,r){if(super.propertyChangedCallback(e,t,i,r),!r)switch(e){case"adapter":this._setupAdapters(i);break;case"map":t&&this._detachMarker(t),i&&this._setupMapMarker(i);break;case"icon":this._setupMapMarker();break;case"plaeholder":this._setupSuggest();break;case"disabled":this._setupMapMarker(),this._setupSuggest()}}disconnectedCallback(){this._disposeMarker(),super.disconnectedCallback()}_setupAdapters(e=this.adapter){const i=this._geocoder,r=this._reverseGeocoder;t.Utils.isNull(i)||(i.adapter=e),t.Utils.isNull(r)||(r.adapter=e)}_setupSuggest(){const e=this._suggest;t.Utils.isNull(e)||(e.placeholder=this.placeholder??"search...",e.readonly=this.readonly,e.disabled=this.disabled,e.value=this.value)}_detachMarker(e=this.map){const i=this.#u;t.Utils.isNull(i)||i.map!==e||i.remove()}_createMarker(){const e=new r.Components.Maps.PacemMapMarkerElement;return e.addEventListener("dragend",this._dragendHandler,!1),e}_disposeMarker(){const e=this.#u;t.Utils.isNull(e)||e.removeEventListener("dragend",this._dragendHandler,!1)}_setupMapMarker(e=this.map){const i=this.#u||(this.#u=this._createMarker());i.icon=this.icon,i.draggable=!this.readonly&&!this.disabled,i.hide=this.disabled;const r=this.value;r&&r.position&&(i.position=r.position),i.map===e||t.Utils.isNull(e)||e.appendChild(i)}_setup(){this._setupAdapters(),this._setupSuggest(),this._setupMapMarker()}};Ze([t.Watch({emit:!1,converter:t.PropertyConverters.Element})],Qe.prototype,"adapter",void 0),Ze([t.Watch({emit:!1,converter:t.PropertyConverters.Element})],Qe.prototype,"map",void 0),Ze([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],Qe.prototype,"icon",void 0),Ze([t.ViewChild(t.P+"-data[ds]")],Qe.prototype,"_datasource",void 0),Ze([t.ViewChild(t.P+"-suggest")],Qe.prototype,"_suggest",void 0),Ze([t.ViewChild(t.P+"-map-geocode")],Qe.prototype,"_geocoder",void 0),Ze([t.ViewChild(t.P+"-map-geocode[reverse]")],Qe.prototype,"_reverseGeocoder",void 0),Qe=Ze([t.CustomElement({tagName:t.P+"-geolocate",shadow:!1,template:`<${t.P}-map-geocode search="{{ ::_suggest.hint }}"\n disabled="{{ (::_suggest.hint || '').length < 3 }}" on-success="::_datasource.model = $event.detail"></${t.P}-map-geocode>\n<${t.P}-map-geocode reverse on-success=":host.changeHandler($event)"></${t.P}-map-geocode>\n\n<${t.P}-data ds></${t.P}-data>\n\n<${t.P}-suggest on-change=":host.changeHandler($event)" datasource="{{ ::_datasource.model || [] }}"\n compare-by="fullAddress" text-property="fullAddress"></${t.P}-suggest>`})],Qe);var et=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};class tt extends CustomEvent{constructor(e){super("hierarchychange",{detail:e,bubbles:!1,cancelable:!1})}}const it="hierarchy-item",rt=it+" "+t.PCSS+"-anim anim-fade-in anim-sudden",st="{{ { 'item-disabled' : ^item.disabled } }}",at="pacemHierarchy",nt="item-content",ot="item-link",lt=ot+" icon-rotate rotate-135",ct="link",dt="item-move",ht="drag_indicator",pt="parents";let ut=class extends x{getViewValue(e){return""}convertValueAttributeToProperty(e){return t.Utils.Json.parse(e)}constructor(){super(),this.#m=new Map,this.#v=new Map,this.unlinkCaption="Delete",this._binderClickHandler=e=>{const i=e.originalEvent.type;if("mousedown"===i&&1===e.originalEvent.button){t.avoidHandler(e.originalEvent);const i=e.srcElement;this._unlink(i)}else if("click"===i||"contextmenu"===i){t.avoidHandler(e.originalEvent),this.#g=e.srcElement;const i=this._balloon;i.target={x:e.pageX,y:e.pageY},i.popup()}},this._dragInitHandler=e=>{let r=e.detail;const s=this._dragger;s.floater=document.createElement("span"),s.dropTargets=Array.from(this.#v.keys()).filter(e=>e!==r.element),t.Utils.isNull(this.#y)||this.#y.remove();const a=this.#y=new i.Components.UI.PacemBinderElement;a.from=r.element,this.#f.appendChild(a)},this._dragStartHandler=e=>{t.Utils.addClass(e.detail.element,"item-drag")},this._dragHandler=e=>{this.#y.to=e.detail.currentPosition},this._dragEndHandler=e=>{t.Utils.removeClass(e.detail.element,"item-drag"),this.#y.remove(),this.#y=null},this._dropHandler=e=>{const t=e.detail.data,i=this.#v.get(e.detail.target);this._isInAncestors(t,i)||this._isInDescendants(t,i)||this._compileHierarchy({source:t,target:i})},this._dragOverHandler=e=>{const t=e.detail.data,i=this.#v.get(e.detail.target);(i.disabled||this._isInAncestors(t,i)||this._isInDescendants(t,i))&&e.preventDefault()},this._dragOutHandler=e=>{},this._popoutHandler=e=>{this._balloon.popout()},this.#_=t.Utils.uniqueCode()}#_;#m;#y;#g;#v;#f;get inputFields(){return[]}toggleReadonlyView(e){this._dragger.disabled=e,t.Utils.isNull(this._adaptedDatasource)||this._databind()}onChange(e){return new Promise((i,r)=>{t.CustomEventUtils.isInstanceOf(e,tt)&&i(this.value=e.detail),i(this.value)})}acceptValue(e){}viewActivatedCallback(){super.viewActivatedCallback(),this.#f=t.CustomElementUtils.findAncestorShell(this),this._setupItemTemplate(),this._setupDragger(),this._setupBalloon()}propertyChangedCallback(e,t,i,r){switch(super.propertyChangedCallback(e,t,i,r),e){case"datasource":case"textProperty":case"disabledProperty":case"valueProperty":cancelAnimationFrame(this._handle),this._handle=requestAnimationFrame(()=>{this._buildAdaptedDatasource()});break;case"itemtemplate":r||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,i=e;return(t=this.valueProperty)&&(i=e[t]),i}_mapEntityToViewValue(e){let t,i=e.toString();return(t=this.textProperty)&&(i=e[t]),i}_mapEntityToItem(e){if(null==e)throw new Error("Entity cannot be null");let i=!1;const r=this.disabledProperty;return t.Utils.isNullOrEmpty(r)||(i=e[r]||!1),{value:this._mapEntityToValue(e),viewValue:this._mapEntityToViewValue(e),disabled:i,data:e}}_unlink(e){var t;e instanceof i.Components.UI.PacemBinderElement?t=e:(e.preventDefault(),e.stopPropagation(),t=this.#g);const{parent:r,child:s}=JSON.parse(t.dataset[at]),a=this._adaptedDatasource,n=a.find(e=>e.value===r),o=a.find(e=>e.value===s);n.disabled||o.disabled||this._compileHierarchy({source:n,target:o},!0)}_buildHierarchyItemDomId(e){return`hierarchyitem_${this.#_}_${e}`}_itemCreate(e){const t=e.detail.dom.find(e=>e instanceof HTMLElement&&e.classList.contains(it));e.detail.index;const r=e.detail.item;t.id=this._buildHierarchyItemDomId(r.value),r.disabled?t.setAttribute("behaviors","{{ [#"+this._dragger2.id+"] }}"):t.setAttribute("behaviors","{{ [#"+this._dragger.id+", #"+this._dragger2.id+"] }}");for(let e of r.parents||[]){const s=new i.Components.UI.PacemBinderElement;s.to=t,s.toAnchor=i.Components.UI.BinderAnchor.Top,s.toEnd=i.Components.UI.BinderEnd.Arrow,s.setAttribute("from","{{ #"+this._buildHierarchyItemDomId(e.value)+" }}"),s.fromAnchor=i.Components.UI.BinderAnchor.Bottom,s.cssClass=["hierarchy-binder"],s.interactive=!this.readonly&&!r.disabled&&!e.disabled,s.addEventListener(i.Components.UI.BinderInteractionEventName,this._binderClickHandler,!1),s.dataset[at]=JSON.stringify({parent:e.value,child:r.value}),this.#m.set(r.value,s),this.#f.appendChild(s)}this.#v.has(t)||this.#v.set(t,r)}_itemRemove(e){const t=e.detail.dom.find(e=>e instanceof HTMLElement&&e.classList.contains(it)),r=e.detail.item,s=this.#m;if(s.has(r.value)){const e=s.get(r.value);e.removeEventListener(i.Components.UI.BinderInteractionEventName,this._binderClickHandler,!1),e.remove(),s.delete(r.value)}this.#v.has(t)&&this.#v.delete(t)}_setupItemTemplate(){if(this.itemtemplate instanceof HTMLTemplateElement){const e=this.itemtemplate.cloneNode(!0).content,r=document.createElement("template"),s=document.createElement(t.P+"-panel");s.className=rt,s.setAttribute("css-class",st);const a=new i.Components.UI.PacemIconElement;a.setAttribute("icon",ht),a.className=dt,s.appendChild(a);const n=document.createElement("div");n.className=nt,n.append(e),s.appendChild(n);const o=new i.Components.UI.PacemIconElement;o.setAttribute("icon",ct),o.className=lt,s.appendChild(o),r.content.appendChild(s),this._template=r}else this._template=this._defaultTemplate}_compileHierarchy(e,i=!1){const r=t.Utils.clone(this.value||[]),s=e.source.value,a=e.target.value,n=this.parentsProperty||pt;var o=r.find(e=>e[this.valueProperty]===a);if(i){if(!t.Utils.isNull(o)){const e=o[n]||[],t=e.indexOf(s);t>=0&&e.splice(t,1)}}else t.Utils.isNull(o)&&((o={})[this.valueProperty]=a,o[n]=[],r.push(o)),o[n].push(s);this._cleanupHierarchy(r),this.changeHandler(new tt(r))}_cleanupHierarchy(e=[]){const i=this.valueProperty,r=this.parentsProperty||pt,s=(a,n)=>{const o=e.find(e=>e[i]==n);if(t.Utils.isNull(o)||t.Utils.isNullOrEmpty(o[r]))return!1;const l=o[r];return l.indexOf(a)>=0||l.some(e=>s(a,e))};for(let t of e){const e=t[r]||[];for(let t=e.length-1;t>=0;t--){const i=e[t],r=e.filter(e=>e!==i);for(let a of r)if(s(i,a)){e.splice(t,1);break}}}}_setupDragger(){const e=this._dragger;e.id="hierarchy_link_"+this.#_,e.handleSelector="."+ot,e.dropBehavior=t.UI.DropBehavior.None,e.spillBehavior=t.UI.DropTargetMissedBehavior.None,e.mode=t.UI.DragDataMode.Copy,e.addEventListener(t.UI.DragDropEventType.Drop,this._dropHandler,!1),e.addEventListener(t.UI.DragDropEventType.Drag,this._dragHandler,!1),e.addEventListener(t.UI.DragDropEventType.Init,this._dragInitHandler,!1),e.addEventListener(t.UI.DragDropEventType.Start,this._dragStartHandler,!1),e.addEventListener(t.UI.DragDropEventType.End,this._dragEndHandler,!1),e.addEventListener(t.UI.DragDropEventType.Over,this._dragOverHandler,!1),e.addEventListener(t.UI.DragDropEventType.Out,this._dragOutHandler,!1);const i=this._dragger2;i.id="hierarchy_move_"+this.#_,i.mode=t.UI.DragDataMode.Self,i.dropBehavior=t.UI.DropBehavior.None,i.spillBehavior=t.UI.DropTargetMissedBehavior.None,i.handleSelector="."+dt}_disposeDragger(){const e=this._dragger;t.Utils.isNull(e)||(e.removeEventListener(t.UI.DragDropEventType.Drop,this._dropHandler,!1),e.removeEventListener(t.UI.DragDropEventType.Drag,this._dragHandler,!1),e.removeEventListener(t.UI.DragDropEventType.Init,this._dragInitHandler,!1),e.removeEventListener(t.UI.DragDropEventType.Start,this._dragStartHandler,!1),e.removeEventListener(t.UI.DragDropEventType.End,this._dragEndHandler,!1),e.removeEventListener(t.UI.DragDropEventType.Over,this._dragOverHandler,!1),e.removeEventListener(t.UI.DragDropEventType.Out,this._dragOutHandler,!1))}_setupBalloon(){this._balloon=this._shellProxy.dom.find(e=>e instanceof i.Components.UI.PacemBalloonElement),window.addEventListener("mousedown",this._popoutHandler,!1)}_disposeBalloon(){window.removeEventListener("mousedown",this._popoutHandler,!1)}_isInAncestors(e,i){return!t.Utils.isNull(i)&&!t.Utils.isNullOrEmpty(i.parents)&&(i.parents.indexOf(e)>=0||i.parents.some(t=>this._isInAncestors(e,t)))}_isInDescendants(e,t){return this._isInAncestors(t,e)}_databind(){this._repeater.datasource=[];const e=this.valueProperty;if(t.Utils.isNullOrEmpty(e))throw new Error("Missing valueProperty.");const i=t.Utils.clone(this._adaptedDatasource||[]),r=this.value||[],s=this.parentsProperty||pt;for(let a of i){const n=r.find(t=>t[e]===a.value);t.Utils.isNull(n)||(a.parents=(n[s]||[]).map(e=>i.find(t=>t.value===e)).filter(e=>!t.Utils.isNull(e)))}this._databindByParents(i)}_databindByParents(e){const i=[];function r(){return i.reduce((e,t)=>e+t.length,0)}do{if(t.Utils.isNullOrEmpty(i)){const r=e.filter(e=>t.Utils.isNullOrEmpty(e.parents));i.push(r)}else{const r=Array.prototype.concat.apply([],i),s=i[i.length-1],a=e.filter(e=>!t.Utils.isNullOrEmpty(e.parents)&&(e.parents.every(e=>r.indexOf(e)>=0)&&e.parents.some(e=>s.indexOf(e)>=0)));i.push(a)}}while(r()<e.length);this._repeater.datasource=i}};et([t.ViewChild("template[default]")],ut.prototype,"_defaultTemplate",void 0),et([t.ViewChild(t.P+"-repeater")],ut.prototype,"_repeater",void 0),et([t.ViewChild(t.P+"-drag-drop")],ut.prototype,"_dragger",void 0),et([t.ViewChild(t.P+"-drag-drop[move]")],ut.prototype,"_dragger2",void 0),et([t.ViewChild(t.P+"-shell-proxy")],ut.prototype,"_shellProxy",void 0),et([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],ut.prototype,"datasource",void 0),et([t.Watch({emit:!1,converter:t.PropertyConverters.String})],ut.prototype,"valueProperty",void 0),et([t.Watch({emit:!1,converter:t.PropertyConverters.String})],ut.prototype,"textProperty",void 0),et([t.Watch({emit:!1,converter:t.PropertyConverters.String})],ut.prototype,"disabledProperty",void 0),et([t.Watch({converter:t.PropertyConverters.String})],ut.prototype,"unlinkCaption",void 0),et([t.Watch({converter:t.PropertyConverters.Json})],ut.prototype,"_adaptedDatasource",void 0),et([t.Watch({emit:!1,converter:t.PropertyConverters.Element})],ut.prototype,"itemtemplate",void 0),et([t.Watch({converter:t.PropertyConverters.Element})],ut.prototype,"_template",void 0),et([t.Watch({emit:!1,converter:t.PropertyConverters.String})],ut.prototype,"parentsProperty",void 0),ut=et([t.CustomElement({tagName:t.P+"-hierarchy",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<${t.P}-repeater>\n <template>\n <${t.P}-repeater on-${t.Components.RepeaterItemCreateEventName}=":host._itemCreate($event)" on-${t.Components.RepeaterItemRemoveEventName}=":host._itemRemove($event)" datasource="{{ ^item }}">\n <div class="hierarchy-level">\n <${t.P}-template-proxy target="{{ :host._template }}"></${t.P}-template-proxy>\n </div>\n </${t.P}-repeater>\n </template>\n </div>\n</${t.P}-repeater><${t.P}-content></${t.P}-content>\n<${t.P}-drag-drop></${t.P}-drag-drop>\n<${t.P}-drag-drop move></${t.P}-drag-drop>\n<template default>\n <${t.P}-panel class="${rt} item-default" css-class="${st}">\n <${t.P}-icon class="${dt}" icon="${ht}"></${t.P}-icon>\n <pacem-span class="${nt}" content="{{ ^item.viewValue }}"></${t.P}-span>\n <${t.P}-icon class="${lt}" icon="${ct}"></${t.P}-icon>\n </${t.P}-panel>\n</template>\n<${t.P}-shell-proxy>\n <${t.P}-balloon options="{{ { behavior: ComponentsUI.UI.BalloonBehavior.Inert } }}">\n <${t.P}-button icon-glyph="link_off" class="${t.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()"><${t.P}-text class="${t.PCSS}-margin margin-left-1" text="{{ :host.unlinkCaption }}"></${t.P}-text></${t.P}-button>\n </${t.P}-balloon>\n</${t.P}-shell-proxy>`})],ut);var mt,vt=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};!function(e){e.Input="input",e.Blur="blur"}(mt||(mt={}));const gt="pacem:scaffolding:input_field";class yt extends x{constructor(){super(...arguments),this.debounce=!1,this.changePolicy=mt.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,i,r){if(super.propertyChangedCallback(e,t,i,r),"placeholder"===e)for(let t of this.inputFields??[])t.setAttribute(e,i)}acceptValue(e){this.inputField&&e!==this.inputField.value&&(this.inputField.value=t.Utils.isNullOrEmpty(e)?"":e)}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===mt.Blur)t(this.value);else{const e=()=>{const e=this.getValue(this.inputField.value);e!==this.value&&(this.value=e),t(e)},i=this.debounce;"number"==typeof i&&i>0?(clearTimeout(this._handle),this._handle=setTimeout(e,i)):!0===i?(cancelAnimationFrame(this._handle),this._handle=requestAnimationFrame(e)):requestAnimationFrame(e)}})}registerInputFields(e=this.inputFields){super.registerInputFields(e),t.Utils.isNull(e)||t.Utils.isArray(e)||(e=[e]);for(let i of e??[])(i instanceof HTMLInputElement||i instanceof HTMLTextAreaElement)&&"on"!==t.CustomElementUtils.getAttachedPropertyValue(i,gt,"off")&&(t.CustomElementUtils.setAttachedPropertyValue(i,gt,"on"),"size"in i&&(i.size=1),i.autocomplete="off",i.addEventListener("input",this.changeHandler,!1),i.addEventListener("focus",this._focusHandler,!1))}unregisterInputFields(e=this.inputFields){super.unregisterInputFields(e),t.Utils.isNull(e)||t.Utils.isArray(e)||(e=[e]);for(let i of e??[])"on"===t.CustomElementUtils.getAttachedPropertyValue(i,gt)&&(t.CustomElementUtils.deleteAttachedPropertyValue(i,gt),i.removeEventListener("input",this.changeHandler,!1),i.removeEventListener("focus",this._focusHandler,!1))}viewActivatedCallback(){super.viewActivatedCallback(),this.registerInputFields()}disconnectedCallback(){this.unregisterInputFields(),super.disconnectedCallback()}}vt([t.Watch({emit:!1,converter:{convert:e=>{switch(e){case"true":return!0;case"false":return!1;default:return parseFloat(e)}},convertBack:e=>e.toString()}})],yt.prototype,"debounce",void 0),vt([t.Watch({emit:!1,converter:t.PropertyConverters.String})],yt.prototype,"changePolicy",void 0),vt([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],yt.prototype,"autoselect",void 0);class ft extends yt{convertValueAttributeToProperty(e){return parseFloat(e)}propertyChangedCallback(e,t,i,r){switch(super.propertyChangedCallback(e,t,i,r),e){case"min":case"max":case"step":null!=i?this.inputField.setAttribute(e,i):this.inputField.removeAttribute(e)}}}vt([t.Watch({converter:t.PropertyConverters.Number})],ft.prototype,"min",void 0),vt([t.Watch({converter:t.PropertyConverters.Number})],ft.prototype,"max",void 0),vt([t.Watch({converter:{convert:e=>{const t=parseFloat(e);return isNaN(t)?"any":t},convertBack:e=>e.toString()}})],ft.prototype,"step",void 0);class _t extends yt{convertValueAttributeToProperty(e){return e}propertyChangedCallback(e,t,i,r){switch(super.propertyChangedCallback(e,t,i,r),e){case"pattern":case"maxlength":case"minlength":null!=i?this.inputField.setAttribute(e,i):this.inputField.removeAttribute(e)}}getValue(e){return t.Utils.isNullOrEmpty(e)?null:e}getViewValue(e){return e}}vt([t.Watch({converter:t.PropertyConverters.String})],_t.prototype,"pattern",void 0),vt([t.Watch({converter:t.PropertyConverters.Number})],_t.prototype,"minlength",void 0),vt([t.Watch({converter:t.PropertyConverters.Number})],_t.prototype,"maxlength",void 0);var bt=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};let Ct=class extends yt{constructor(){super(),this.charCount=6,this.inputTransform="none",this._itemCreateHandler=e=>{const{dom:t,index:i}=e.detail,r=t.find(e=>e instanceof HTMLInputElement);this.#b[i]=r,this.registerInputFields(r)},this.#b=[]}redactViewValue(e=this.value){this.viewValue=this.getViewValue(e)}getValue(e){const i=this.#b.reduce((e,i)=>e+(t.Utils.isNullOrEmpty(i.value)?" ":i.value),"");switch(this.inputTransform){case"lowercase":return i.toLowerCase();case"uppercase":return i.toUpperCase();default:return i}}getViewValue(t){const i=this.charCount;return"password"==this.inputTransform?e.Arrays.range(i).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,i,r){if(super.propertyChangedCallback(e,t,i,r),!r)switch(e){case"charCount":this._databind(),this.redactViewValue();break;case"inputTransform":this.registerInputFields(),this.value=this.getValue(this.value)}}registerInputFields(e=this.inputFields){super.registerInputFields(e),t.Utils.isNull(e)||t.Utils.isArray(e)||(e=[e]);const i=this.#b;for(let r of e??[]){const e=i.indexOf(r);t.Utils.toggleClass(r,"last-char",e===this.charCount-1),t.Utils.toggleClass(r,"first-char",0===e),t.Utils.isNullOrEmpty(r.id)&&r.setAttribute("id","code_"+e+"_"+t.Utils.uniqueCode()),r.value=this.value?.charAt(e)||"","password"===this.inputTransform?r.setAttribute("type","password"):r.setAttribute("type","text")}}acceptValue(e){const t=this.#b;if("string"==typeof e){let i=0;const r=Math.min(e.length,t.length);for(let s=0;s<r;s++)t[s].value=e.charAt(s),i++;for(let e=i;e<t.length;e++)t[e].value=""}}onChange(e){return super.onChange(e).then(i=>{const r=this.#b,s=r.indexOf(e.target);if(s>=0&&s<r.length-1){const e=r[s];if(t.Utils.isNullOrEmpty(e.value?.trim()))e.value="";else{r[s+1].focus()}}return i})}viewActivatedCallback(){super.viewActivatedCallback(),t.Utils.isNull(this.autoselect)&&(this.autoselect=!0),this._chars.addEventListener(t.Components.RepeaterItemCreateEventName,this._itemCreateHandler,!1),this._databind()}disconnectedCallback(){const e=this._chars;t.Utils.isNull(e)||e.removeEventListener(t.Components.RepeaterItemCreateEventName,this._itemCreateHandler),super.disconnectedCallback()}_databind(){const t=this.charCount,i=this.#b;i.length>t&&super.unregisterInputFields(i.splice(t)),this._chars.datasource=e.Arrays.range(t)}#b;get inputFields(){return this.#b}};bt([t.Watch({emit:!1,reflectBack:!0,converter:t.PropertyConverters.Number})],Ct.prototype,"charCount",void 0),bt([t.Watch({emit:!1,reflectBack:!0,converter:t.PropertyConverters.String})],Ct.prototype,"inputTransform",void 0),bt([t.ViewChild(t.P+"-repeater")],Ct.prototype,"_chars",void 0),bt([t.ViewChild("span."+t.PCSS+"-readonly")],Ct.prototype,"_span",void 0),Ct=bt([t.CustomElement({tagName:t.P+"-input-chars",template:`<${t.P}-repeater class="display-flex flex-nowrap">\n <template><input type="text" class="${t.PCSS}-input flex-auto" maxlength="1" /></template>\n </${t.P}-repeater><span class="${t.PCSS}-readonly"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></span>`,shadow:t.Defaults.USE_SHADOW_ROOT})],Ct);var Pt=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};let wt=class extends x{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(e){const i=this._alpha.valueAsNumber||parseInt(this._alpha.value),r=this._tint.value,s=this.value=this._getValue(r,i);return t.Utils.fromResult(s)}constructor(){super()}toggleReadonlyView(e){this._wrapper.hidden=e,this._span.hidden=!e}_getValue(t,i){if(isNaN(i)||100===i)return t;const r=e.Colors.parse(t);return r.a=.01*i,e.Colors.stringify(r)}_parseValue(i){const r=e.Colors.parse(i);return t.Utils.isNullOrEmpty(r)?null:{tint:e.Colors.stringify({r:r.r,g:r.g,b:r.b}),alpha:100*r.a}}getViewValue(e){return e}get inputFields(){return[this._tint,this._alpha]}};Pt([t.ViewChild("input[type=color]")],wt.prototype,"_tint",void 0),Pt([t.ViewChild("input[type=number]")],wt.prototype,"_alpha",void 0),Pt([t.ViewChild(`.${t.PCSS}-viewfinder`)],wt.prototype,"_wrapper",void 0),Pt([t.ViewChild(`.${t.PCSS}-readonly`)],wt.prototype,"_span",void 0),wt=Pt([t.CustomElement({tagName:t.P+"-input-color",template:`<div class="${t.PCSS}-viewfinder">\n<${t.P}-panel class="${t.PCSS}-input-color" css="{{ { 'background-color': :host.viewValue } }}"><input type="color" class="${t.PCSS}-input" /></${t.P}-panel>\n<input class="${t.PCSS}-input" type="number" min="0" max="100" step="1" value="100" />\n</div>\n<${t.P}-span class="${t.PCSS}-readonly" css="{{ { 'background-color': :host.viewValue } }}"></${t.P}-span>`,shadow:t.Defaults.USE_SHADOW_ROOT})],wt);var Et=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};let St=class extends _t{toggleReadonlyView(e){this.input.hidden=e,this.anchor.hidden=!e}get inputFields(){return[this.input]}};Et([t.ViewChild("input[type=email]")],St.prototype,"input",void 0),Et([t.ViewChild(t.P+"-a")],St.prototype,"anchor",void 0),St=Et([t.CustomElement({tagName:t.P+"-input-email",template:`<input type="email" class="${t.PCSS}-input ${t.PCSS}-viewfinder" />${T}<${t.P}-a class="${t.PCSS}-readonly" disabled="{{ $pacem.isNullOrEmpty(:host.value) }}" href="{{ 'mailto:'+ :host.value }}"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></${t.P}-a>`,shadow:t.Defaults.USE_SHADOW_ROOT})],St);var $t=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};const kt="fileupload",Ut="filechange";class Nt extends t.CustomTypedEvent{constructor(e){super("pick",e)}}class Ot extends t.CustomTypedEvent{constructor(e){super(kt,e)}}class xt extends t.CustomTypedEvent{constructor(e){super(Ut,e)}}async function Vt(e,t={files:0,directories:0,size:0}){for await(let[i,r]of e.entries())if("file"===r.kind){t.files++;const e=await r.getFile();t.size+=e.size}else t.directories++,await Vt(r,t);return t}let Dt=class extends x{constructor(e=new t.Animations.TweenService){super(),this._tweener=e,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(e=this.value,i=this.uploading,r=this.selectMode??"file"){if(i)return"sync";const s=!t.Utils.isNullOrEmpty(e);switch(r){case"directory":case"directory-picker":return s?"folder":"drive_folder_upload";case"multiple":case"multiple-picker":return s?"files":"upload_file"}if(t.Utils.isNullOrEmpty(e))return"upload_file";var a=e;"object"==typeof e&&(a=e.name);const n=/\.([\w]+)(\s|$)/.exec(a);if(n&&n.length)switch(n[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(e){const i=this._localValue||e;if(t.Utils.isNullOrEmpty(i))return"";if("string"==typeof i)return i;let r="name"in i?i.name:"";t.Utils.isArray(i)&&(r=i.map(e=>e.name).join(", "));const s=this._stats;if(t.Utils.isNullOrEmpty(s))return r;const{size:a,files:n}=s;return`${r}\n(${n} file${1===n?"":"s"}, ${t.Utils.core.size(a)})`}toggleReadonlyView(e){this._setupInputElement(e)}viewActivatedCallback(){super.viewActivatedCallback(),this._setupInputElement(),this._fileupload.addEventListener("click",t.stopPropagationHandler,!1)}propertyChangedCallback(e,t,i,r){if(super.propertyChangedCallback(e,t,i,r),!r&&"selectMode"===e)this._setupInputElement()}disconnectedCallback(){this._fileupload&&this._fileupload.removeEventListener("click",t.stopPropagationHandler,!1),super.disconnectedCallback()}_setupInputElement(e=this.readonly,t=this.selectMode??"file"){const i=this._fileupload;switch(i.removeAttribute("webkitdirectory"),i.removeAttribute("multiple"),i.hidden=e,t){case"directory":i.setAttribute("webkitdirectory","true");break;case"multiple":i.setAttribute("multiple","true");break;case"directory-picker":case"file-picker":case"multiple-picker":i.hidden=!0}}_dispatchDownload(e){t.avoidHandler(e);const i=this._localValue||this.value,r=e=>{this.dispatchEvent(new CustomEvent("download",{detail:e,bubbles:!0,cancelable:!1}))};t.Utils.isNullOrEmpty(i)||("string"==typeof i?r(i):"content"in i&&!t.Utils.isNullOrEmpty(i.content)?t.Utils.download(t.Utils.dataURLToBlob("data:application/download;base64,"+i.content),i.name,i.type):"name"in i&&("kind"in i&&"file"===i.kind?i.getFile().then(e=>{t.Utils.download(e,e.name,e.type)}):r(i.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 i=this.maxSize;if(i>0&&i<e.size)return this.invalidFile=!0,!1;const r=this.pattern;return r&&!new RegExp(r,"i").test(t)?(this.invalidFile=!0,!1):(this.invalidFile=!1,!0)}upload(e,t,i){if(this._validateSingleFile(e,t))return this._upload(e,t,i)}async _upload(e,t,i){var r=this,s=r._fields;if(!e)return;!t&&e instanceof File&&(t=e.name),r.failed=!1,s.undone=!1,s.ongoing=0;const a=e,n=r.size=a.size;t=t.substring(t.lastIndexOf("\\")+1),r.percentage=0,r.complete=!1;var o={filename:t,length:n,action:"start",state:i,type:e.type};r.uploading=!0;try{var l=await r._fetch(o);if(l.ok){var c=await l.json();s.retryFrom=0,s.blob=a,s.uid=c.uid,r._manage()}else r.uploading=!1;return l}catch(e){r.uploading=!1}}async _blobToBase64(e){const i=await t.Utils.blobToDataURL(e);return i.substring(i.indexOf("base64,")+7)}async _doUpload(e,t){var i=this,r=i._fields;r.ongoing++;var s={chunk:await this._blobToBase64(e),uid:r.uid,position:t,action:"do"};try{const e=await i._fetch(s);if(e.ok){if(r.ongoing--,r.undone)return;const t=await e.json();t.percentage>this.percentage&&await i._tweenPercentage(Math.round(Math.max(1,t.percentage)),200),i.complete!=t.complete&&(i.complete=t.complete,!0===i.complete&&(i.uploading=!1,i.changeHandler(new Ot(t))))}else r.retryFrom=t,i.failed=!0,i.uploading=!1}catch(e){r.retryFrom=t,i.failed=!0,i.uploading=!1}}_manage(){const e=this._fields,t=this.size,i=e.blob,r=this.chunkSize||e.chunkSize;var s=e.retryFrom,a=s+r;e.enqueuer=setInterval(()=>{if(s<t&&!this.failed){const t=this.parallelism||e.parallelism;if(e.ongoing>=t)return;this._doUpload(i.slice(s,a),s),a=(s=a)+r}else{this._fileupload.value="",window.clearInterval(e.enqueuer)}},100)}async _buildLocalValue(e,i=e.name,r=e){return this._localValue={name:i,size:r.size,type:e.type,lastModified:t.Utils.parseDate(e.lastModified).toISOString(),content:await this._blobToBase64(r)}}_canPick(e){return"showDirectoryPicker"in e&&(()=>{try{return e.self===e.top}catch{return!1}})()}_tryPickDirectory(){this._canPick(window)&&window.showDirectoryPicker({mode:"read"}).then(e=>{this.changeHandler(new Nt(e))})}_tryPickFiles(e="multiple-picker"===this.selectMode,t=this.pattern){this._canPick(window)&&window.showOpenFilePicker({multiple:e}).then(e=>{this.changeHandler(new Nt(e))})}_clickHandler(e){if(t.avoidHandler(e),!this.readonly)switch(this.selectMode){case"directory-picker":this._tryPickDirectory();break;case"file-picker":case"multiple-picker":this._tryPickFiles()}}async _mimicCompute(){this.uploading=!0,t.Utils.isNullOrEmpty(this.value)?await t.Utils.idle(250):(this.percentage=0,await t.Utils.waitForAnimationEnd(this._tuner)),await this._tweener.run(0,100,500,0,t.Animations.Easings.sineInOut,(e,t)=>{this.percentage=t}),this.percentage=0,this.uploading=!1}onChange(e){return new Promise(async(i,r)=>{if(t.CustomEventUtils.isInstanceOf(e,Ot)){const t=this.value=e.detail.filename;this.dispatchEvent(e),i(t)}else if(t.CustomEventUtils.isInstanceOf(e,Nt)){let t,r,s,a=e.detail;switch(this.selectMode){case"directory-picker":t=a,this._stats=await Vt(t);break;case"multiple-picker":case"file-picker":s=a,1===s.length&&(a=s[0]),this._stats=await async function(e){const t={files:0,directories:0,size:0};for(let i of e){const e=await i.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=a);const n=this._validateAll();this.dispatchEvent(new xt({directory:t,file:r,files:s,valid:n}))}else{let e=this._fileupload;if(0===e.files.length)this._stats={directories:0,files:0,size:0},i(this.value=null);else{const r=e.files.length;if(this._stats={directories:0,files:r,size:Array.from(e.files).reduce((e,t,i)=>e+t.size,0)},r>1){const t=Array.from(e.files);i(this.value=this._localValue=t);const r=this._validateAll();this.dispatchEvent(new xt({files:t,valid:r}))}else{const r=e.files[0],s=r.name;let a=r;this._validateSingleFile(r)||t.Utils.isNullOrEmpty(this.url)?(/\.(jpe?g|png)$/i.test(s)&&this.maxImageWidth>0&&this.maxImageHeight>0&&(a=await t.Utils.Images.resize(a,this.maxImageWidth,this.maxImageHeight,{quality:.8})),await this._buildLocalValue(r,s,a),t.Utils.isNullOrEmpty(this.url)?(await this._mimicCompute(),i(this.value=this._localValue)):(this._upload(a,e.value),i(this.value))):i(this.value=await this._buildLocalValue(r)),this.dispatchEvent(new xt({valid:!this.invalidFile,file:r}))}}}})}_fetch(e){return fetch(this.url,{method:"POST",credentials:this.fetchCredentials,headers:t.Utils.extend({Accept:"application/json","Content-Type":"application/json"},this.fetchHeaders||{}),body:JSON.stringify(e)})}async _undo(e){e.preventDefault(),e.stopPropagation();var t=this,i=t._fields,r=t._fileupload;clearInterval(i.enqueuer);var s={action:"undo",uid:i.uid};try{var a=await t._fetch(s);return a.ok&&(i.undone=!0,t.size=0,t._tweenPercentage(0,300)),a}catch(e){}finally{return r.value="",t.uploading=!1,a}}_tweenPercentage(e,i=500){const r=this.percentage;return this._tweener.run(r,e,i,0,t.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)}};$t([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],Dt.prototype,"fetchCredentials",void 0),$t([t.Watch({emit:!1,converter:t.PropertyConverters.String})],Dt.prototype,"fetchHeaders",void 0),$t([t.ViewChild("input[type=file]")],Dt.prototype,"_fileupload",void 0),$t([t.ViewChild(`${t.P}-tuner`)],Dt.prototype,"_tuner",void 0),$t([t.Watch({converter:t.PropertyConverters.String})],Dt.prototype,"undoCaption",void 0),$t([t.Watch({converter:t.PropertyConverters.String})],Dt.prototype,"retryCaption",void 0),$t([t.Watch({converter:t.PropertyConverters.String})],Dt.prototype,"clearCaption",void 0),$t([t.Watch({emit:!1,reflectBack:!0,converter:t.PropertyConverters.String})],Dt.prototype,"pattern",void 0),$t([t.Watch({emit:!1,reflectBack:!0,converter:t.PropertyConverters.String})],Dt.prototype,"url",void 0),$t([t.Watch({emit:!1,reflectBack:!0,converter:t.PropertyConverters.Number})],Dt.prototype,"maxImageWidth",void 0),$t([t.Watch({emit:!1,reflectBack:!0,converter:t.PropertyConverters.Number})],Dt.prototype,"parallelism",void 0),$t([t.Watch({emit:!1,reflectBack:!0,converter:t.PropertyConverters.Number})],Dt.prototype,"chunkSize",void 0),$t([t.Watch({emit:!1,reflectBack:!0,converter:t.PropertyConverters.Number})],Dt.prototype,"maxImageHeight",void 0),$t([t.Watch({emit:!1,reflectBack:!0,converter:t.PropertyConverters.Number})],Dt.prototype,"maxSize",void 0),$t([t.Watch({reflectBack:!0,converter:t.PropertyConverters.String})],Dt.prototype,"selectMode",void 0),$t([t.Watch({converter:t.PropertyConverters.Boolean})],Dt.prototype,"uploading",void 0),$t([t.Watch({converter:t.PropertyConverters.Number})],Dt.prototype,"size",void 0),$t([t.Watch({converter:t.PropertyConverters.Number})],Dt.prototype,"percentage",void 0),$t([t.Watch({converter:t.PropertyConverters.Boolean})],Dt.prototype,"complete",void 0),$t([t.Watch({converter:t.PropertyConverters.Boolean})],Dt.prototype,"failed",void 0),$t([t.Watch({converter:t.PropertyConverters.Boolean})],Dt.prototype,"invalidFile",void 0),Dt=$t([t.CustomElement({tagName:t.P+"-upload",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<${t.P}-button on-click=":host._dispatchDownload($event)" class="${t.PCSS}-upload ${t.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 <${t.P}-panel class="upload-button" hide="{{ (:host.uploading || :host.failed) && !$pacem.isNullOrEmpty(:host.url) }}">\n <${t.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="{{ {'${t.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="${t.PCSS}-transparent ${t.PCSS}-clickable pos-absolute absolute-left absolute-right absolute-top absolute-bottom" />\n </${t.P}-button>\n </${t.P}-panel>\n <${t.P}-panel class="upload-button" hide="{{ !:host.failed }}">\n <${t.P}-button class="button-circle button-flat" icon-glyph="refresh"\n tooltip="{{ :host.retryCaption }}" on-click=":host._retry($event)"><${t.P}-text text="{{ :host.retryCaption }}"></${t.P}-text></${t.P}-button>\n </${t.P}-panel>\n <${t.P}-panel class="upload-button" hide="{{ !:host.uploading || $pacem.isNullOrEmpty(:host.url) }}">\n <${t.P}-button class="button-circle button-flat" icon-glyph="clear" tooltip="{{ :host.undoCaption }}" \n on-click=":host._undo($event)"><${t.P}-text text="{{ :host.undoCaption }}"></${t.P}-text></${t.P}-button>\n </${t.P}-panel>\n\n <${t.P}-span tooltip="{{ :host.viewValue }}"\n hide="{{ $pacem.isNullOrEmpty(:host.value) || :host.uploading }}" class="upload-data readonly text-reset display-block ${t.PCSS}-anim text-truncate text-left ${t.PCSS}-pad pad-right-3" text="{{ :host.viewValue }}"></${t.P}-span>\n\n <${t.P}-panel class="upload-progress hit-none" hide="{{ :host.readonly || (!$pacem.isNullOrEmpty(:host.value) && !:host.uploading) }}">\n <${t.P}-tuner value="{{ :host.percentage }}" css-class="{{ {'tuner-success': !:host.invalidFile, 'tuner-error': :host.invalidFile} }}" interactive="false"></${t.P}-tuner>\n </${t.P}-panel>\n\n <${t.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)"></${t.P}-button>\n \n</${t.P}-button>`})],Dt);var Ht=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};let At=class extends _t{constructor(){super()}toggleReadonlyView(e){}get inputFields(){return[this.input]}};Ht([t.ViewChild("input[type=hidden]")],At.prototype,"input",void 0),At=Ht([t.CustomElement({tagName:t.P+"-input-hidden",template:'<input type="hidden" />',shadow:t.Defaults.USE_SHADOW_ROOT})],At);var Lt=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};const Tt=t.Utils.getUserMediaFunctions();var Rt;!function(e){e.Start="start",e.Taking="taking",e.Confirm="confirm"}(Rt||(Rt={}));class Wt extends t.CustomUIEvent{constructor(e){super("confirmsnapshot",{buffer:e})}}let It=class extends x{constructor(){super(...arguments),this._resizeHandler=e=>{this._renderValue()},this.step=Rt.Start,this._canUseWebcam=Tt.length>0,this._countdown=0,this._webcamInitialized=!1,this._grabberChangeHandler=e=>{const i=this._grabber;i.files.length>0&&t.Utils.blobToDataURL(i.files[0]).then(e=>{t.Utils.loadImage(e).then(e=>{this._shutter(e)})})},this._snapshooterClickHandler=e=>{t.avoidHandler(e),this.step=Rt.Taking},this._pickerClickHandler=e=>{t.avoidHandler(e),this._grabber.click()},this._takerClickHandler=e=>{t.avoidHandler(e),this._countdown=0,this._shutter()},this._timerClickHandler=e=>{t.avoidHandler(e),this._countdown=3,this._shutter()},this._confirmerClickHandler=e=>{t.avoidHandler(e),this.changeHandler(new Wt(this._buffer))}}get inputFields(){return[]}toggleReadonlyView(e){}onChange(e){return new Promise((i,r)=>{t.CustomEventUtils.isInstanceOf(e,Wt)?(i(this.value=e.detail.buffer),this.step=Rt.Start):i(this.value)})}acceptValue(e){this._renderValue(e)}getViewValue(e){return e}convertValueAttributeToProperty(e){return t.PropertyConverters.String.convert(e,this)}get _getUserMedia(){return this._canUseWebcam&&Tt[0]}propertyChangedCallback(e,t,i,r){switch(super.propertyChangedCallback(e,t,i,r),e){case"step":switch(i){case Rt.Start:this._buffer=null;const e=this._grabber;e.value="",/safari/i.test(navigator.userAgent)||(e.type="",e.type="file");break;case Rt.Taking:this._ensureWebcamRunning()}break;case"_buffer":this._renderValue(i||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 e=this._stage,i=this._player;t.Utils.isNull(e)||t.Utils.isNull(i)||(e.style.width=i.style.width=this.width&&this.width+"px"||"",e.style.height=i.style.height=this.height&&this.height+"px"||"",this._renderValue(this._buffer||this.value))}_shutter(e){const i=this,r=this._player,s=this._stage;var a,n;if(i._confirmer.disabled=!0,t.Utils.isNull(e)&&(e=i._player),e instanceof HTMLVideoElement?(a=e.videoWidth,n=e.videoHeight):(a=e.naturalWidth,n=e.naturalHeight),i._countdown<=0){var o=document.createElement("canvas");o.width=this.width||s.clientWidth,o.height=this.height||s.clientHeight;var l=o.getContext("2d");t.Utils.cropImageOntoCanvas(e,l,a,n);let c=i._root;c.insertBefore(o,r),o.className="snapshot-brightout",setTimeout(function(){c.removeChild(o)},1e3),i._refreshBuffer(o.toDataURL()).then(e=>{i._setToBeConfirmed(e),i._confirmer.disabled=!1})}else setTimeout(()=>{i._countdown--,this._shutter()},1e3)}_renderValue(e=this.value){let i=this._stage;if(!t.Utils.isNull(i)){i.width=i.clientWidth,i.height=i.clientHeight;let r=i.getContext("2d");t.Utils.isNullOrEmpty(e)?r.clearRect(0,0,i.width,i.height):t.Utils.loadImage(e).then(e=>{t.Utils.cropImageOntoCanvas(e,r,e.width,e.height)})}}_setToBeConfirmed(e){this.step=Rt.Confirm,this._buffer=e}_refreshBuffer(e){var i=this._stage;let r;return i.width=i.clientWidth,i.height=i.clientHeight,this.quality>0&&(r=Math.min(1,Math.max(0,this.quality))),t.Utils.cropImage(e,i.width,i.height,r)}_ensureWebcamRunning(){if(this._canUseWebcam&&!this._webcamInitialized){var e=this;e._webcamInitialized=!0,e._getUserMedia.apply(navigator,[{video:!0},function(t){e._player.srcObject=t},function(i){e.log(t.Logging.LogLevel.Error,(i||i.message).toString())}])}}};Lt([t.ViewChild("."+t.PCSS+"-snapshot")],It.prototype,"_root",void 0),Lt([t.ViewChild("canvas")],It.prototype,"_stage",void 0),Lt([t.ViewChild("input[type=file]")],It.prototype,"_grabber",void 0),Lt([t.ViewChild("video")],It.prototype,"_player",void 0),Lt([t.ViewChild(t.P+"-button.button.snapshot-upload")],It.prototype,"_picker",void 0),Lt([t.ViewChild(t.P+"-button.button.snapshot-camera")],It.prototype,"_snapshooter",void 0),Lt([t.ViewChild(t.P+"-button.button.snapshot-take")],It.prototype,"_taker",void 0),Lt([t.ViewChild(t.P+"-button.button.snapshot-timer3s")],It.prototype,"_timer",void 0),Lt([t.ViewChild(t.P+"-button.button.snapshot-confirm")],It.prototype,"_confirmer",void 0),Lt([t.Watch({converter:t.PropertyConverters.String})],It.prototype,"step",void 0),Lt([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],It.prototype,"width",void 0),Lt([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],It.prototype,"height",void 0),Lt([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],It.prototype,"quality",void 0),Lt([t.Watch()],It.prototype,"_countdown",void 0),Lt([t.Watch({emit:!1})],It.prototype,"_buffer",void 0),It=Lt([t.CustomElement({tagName:t.P+"-snapshot",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<${t.P}-panel class="${t.PCSS}-snapshot" \ncss-class="{{ { \n'snapshot-start': :host.step === '${Rt.Start}',\n'snapshot-taking': :host.step === '${Rt.Taking}', \n'snapshot-confirm': :host.step === '${Rt.Confirm}' } }}">\n\n <${t.P}-resize target="{{ ::_stage }}" on-resize=":host._resizeHandler($event)"></${t.P}-resize>\n\n <canvas class="${t.PCSS}-viewfinder"></canvas>\n\n <video autoplay="autoplay"></video>\n\n <input type="file" accept="image/*" />\n\n <div class="${t.PCSS}-buttonset snapshot-step step-start">\n <div class="buttonset-center">\n <${t.P}-button class="button snapshot-upload" icon-glyph="upload"></${t.P}-button>\n <${t.P}-button class="button snapshot-camera" icon-glyph="photo_camera"></${t.P}-button> \n </div>\n </div>\n\n <div class="${t.PCSS}-buttonset snapshot-step step-taking">\n <div class="buttonset-center">\n <${t.P}-button class="button snapshot-undo" icon-glyph="undo" on-click=":host.step = '${Rt.Start}'"></${t.P}-button>\n <${t.P}-button class="button snapshot-take" icon-glyph="camera"></${t.P}-button>\n <${t.P}-button class="button snapshot-timer3s" icon-glyph="timer_3"></${t.P}-button>\n </div>\n </div>\n\n <div class="${t.PCSS}-buttonset snapshot-step step-confirm">\n <div class="buttonset-center">\n <${t.P}-button class="button snapshot-undo" icon-glyph="undo" on-click=":host.step = '${Rt.Start}'"></${t.P}-button>\n <${t.P}-button class="button snapshot-confirm" icon-glyph="done"></${t.P}-button>\n </div>\n </div>\n\n <${t.P}-span class="snapshot-countdown" text="{{ :host._countdown }}" hide="{{ :host.step !== '${Rt.Taking}' || !(:host._countdown > 0) }}"></${t.P}-span>\n <${t.P}-span hide="{{ :host._canUseWebcam }}"><${t.P}-content></${t.P}-content></${t.P}-span>\n\n</${t.P}-panel>`})],It);var Ft=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};const jt="imagefetchrequest";class Bt extends t.CustomTypedEvent{constructor(e){super(jt,e,{bubbles:!0})}}let Mt=class extends t.Components.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(e){const i=this._uploader,r=this._thumbUploader,s=r.maxImageWidth,a=r.maxImageHeight;if(s>0&&a>0){var n=i.blob;const o=e.detail.uid;t.Utils.resizeImage(n,s,a).then(e=>{e==n?this._done(!1):r.upload(e,"thumbnail.jpg",o)})}else this._done(!1)}_done(e){e||this._imagefetch(0),this._repeater.hidden=e,this._progressbar.hidden=!e}_snapshotPropertyChangedCallback(e){if("value"===e.detail.propertyName){const i=t.Utils.dataURLToBlob(e.detail.currentValue);this._uploader.upload(i,"snapshot.jpg")}}reset(){this._snapshot.step=Rt.Start}propertyChangedCallback(e,i,r,s){switch(super.propertyChangedCallback(e,i,r,s),e){case"imageSet":let e=r||{skip:0,set:[]};t.Utils.isNullOrEmpty(this._images)||0===e.skip?this._images=e.set:t.Utils.isNull(this._images)||Array.prototype.splice.apply(this._images,[e.skip,this._images.length-e.skip].concat(e.set)),this._fetching=!1;break;case"hint":s||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 Bt({hint:this.hint,skip:e,take:18}))}};Ft([t.Watch({converter:t.PropertyConverters.String})],Mt.prototype,"uploadUrl",void 0),Ft([t.Watch({converter:t.PropertyConverters.String})],Mt.prototype,"hint",void 0),Ft([t.Watch()],Mt.prototype,"imageSet",void 0),Ft([t.Watch({converter:t.PropertyConverters.String})],Mt.prototype,"value",void 0),Ft([t.Watch({converter:t.PropertyConverters.Number})],Mt.prototype,"maxWidth",void 0),Ft([t.Watch({converter:t.PropertyConverters.Number})],Mt.prototype,"maxHeight",void 0),Ft([t.Watch({converter:t.PropertyConverters.Number})],Mt.prototype,"maxThumbnailWidth",void 0),Ft([t.Watch({converter:t.PropertyConverters.Number})],Mt.prototype,"maxThumbnailHeight",void 0),Ft([t.Watch({converter:t.PropertyConverters.Boolean})],Mt.prototype,"allowSnapshot",void 0),Ft([t.Watch()],Mt.prototype,"_fetching",void 0),Ft([t.Watch()],Mt.prototype,"_images",void 0),Ft([t.ViewChild(t.P+"-repeater")],Mt.prototype,"_repeater",void 0),Ft([t.ViewChild(t.P+"-upload[main]")],Mt.prototype,"_uploader",void 0),Ft([t.ViewChild(t.P+"-upload[thumb]")],Mt.prototype,"_thumbUploader",void 0),Ft([t.ViewChild(t.P+"-snapshot")],Mt.prototype,"_snapshot",void 0),Ft([t.ViewChild(t.P+"-progressbar")],Mt.prototype,"_progressbar",void 0),Ft([t.Debounce(500)],Mt.prototype,"_imagefetch",null),Mt=Ft([t.CustomElement({tagName:t.P+"-edit-image",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<${t.P}-panel class="${t.PCSS}-edit-image"\n css-class="{{ {'${t.PCSS}-snapshot': ::_snapshot.step != '${Rt.Start}', '${t.PCSS}-uploading': ::_uploader.uploading, '${t.PCSS}-upload-enabled': !Pacem.Utils.isNullOrEmpty(:host.uploadUrl), '${t.PCSS}-snapshot-enabled': !Pacem.Utils.isNullOrEmpty(:host.uploadUrl) && :host.allowSnapshot} }}">\n <div>\n <${t.P}-input-search value="{{ :host.hint, twoway }}"></${t.P}-input-search>\n <${t.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-${kt}=":host._uploaderFileUploadCallback($event)"\n on-${t.PropertyChangeEventName}=":host._uploaderPropertyChangedCallback($event)" hide="{{ Pacem.Utils.isNullOrEmpty(:host.uploadUrl) || ::_thumbUploader.uploading }}"></${t.P}-upload>\n <${t.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-${t.PropertyChangeEventName}=":host._thumbnailUploaderPropertyChangedCallback($event)"></${t.P}-upload>\n <${t.P}-button class="${t.PCSS}-snapshot" on-click="Pacem.avoidHandler($event); ::_snapshot.step = '${Rt.Taking}'" hide="{{ Pacem.Utils.isNullOrEmpty(:host.uploadUrl) || !:host.allowSnapshot }}"></${t.P}-button>\n <${t.P}-infinite-scroller container="{{ ::_repeater }}" on-fetchmore=":host._imagefetchSuddenly()" disabled="{{ :host._fetching || :host.disabled || :host._images.length >= :host.imageSet.total }}"></${t.P}-infinite-scroller>\n <${t.P}-repeater datasource="{{ :host._images }}">\n <template>\n <${t.P}-img css-class="{{ {'${t.PCSS}-selected': ^item.src === :host.value } }}" on-click=":host.value = ^item.src" src="{{ ^item.thumb }}" adapt="contain"></${t.P}-img>\n </template>\n </${t.P}-repeater>\n <${t.P}-progressbar class="progressbar-smaller progressbar-accent" caption="{{ ::_thumbUploader.uploading ? 'thumbnail...' : 'uploading...' }}"></${t.P}-progressbar>\n </div>\n <div>\n <${t.P}-snapshot hide="{{ !:host.allowSnapshot }}" on-${t.PropertyChangeEventName}=":host._snapshotPropertyChangedCallback($event)"></${t.P}-snapshot>\n </div>\n </${t.P}-panel>`})],Mt);let zt=class extends x{constructor(){super(...arguments),this._broadcastFetchRequestEventName=e=>{this.dispatchEvent(new Bt(e.detail))},this._innerValueChangedHandler=e=>{"value"!==e.detail.propertyName||t.Utils.isNull(this._dialog)||(this._dialog.state=e.detail.currentValue)}}convertValueAttributeToProperty(e){return e}getViewValue(e){return e}get inputFields(){return[]}_clear(e){this.changeHandler(e)}onChange(e){let r=this.value;return t.CustomEventUtils.isInstanceOf(e,i.Components.UI.DialogResultEvent)&&e.detail.button===i.Components.UI.DialogButton.Ok?r=this.value=e.detail.state:e.target===this._input?r=this.value=this._input.value:e.target===this._clearBtn&&(r=this.value=void 0),t.Utils.fromResult(r)}toggleReadonlyView(e){this._input.hidden=this._editBtn.hide=this._clearBtn.hide=e}_addDialog(){var e=document.createElement(t.P+"-dialog");return e.buttons=i.Components.UI.DialogButtons.OkCancel,e.addEventListener(i.Components.UI.DialogResultEventName,this.changeHandler,!1),e.appendChild(this._addEditImage()),document.body.appendChild(e),this._dialog=e}_removeDialog(){this._removeEditImage(),t.Utils.isNull(this._dialog)||(this._dialog.removeEventListener(i.Components.UI.DialogResultEventName,this.changeHandler,!1),this._dialog.remove())}_addEditImage(){var e=document.createElement(t.P+"-edit-image");return e.disabled=!0,e.addEventListener(t.PropertyChangeEventName,this._innerValueChangedHandler,!1),e.addEventListener(jt,this._broadcastFetchRequestEventName,!1),e.uploadUrl=this.uploadUrl,e.allowSnapshot=this.allowSnapshot,e.maxWidth=this.maxWidth,e.maxHeight=this.maxHeight,e.maxThumbnailHeight=this.maxThumbnailHeight,e.maxThumbnailWidth=this.maxThumbnailWidth,this._editImage=e}_removeEditImage(){t.Utils.isNull(this._editImage)||(this._editImage.removeEventListener(t.PropertyChangeEventName,this._innerValueChangedHandler,!1),this._editImage.removeEventListener(jt,this._broadcastFetchRequestEventName,!1))}connectedCallback(){super.connectedCallback(),this._addDialog()}disconnectedCallback(){this._removeDialog(),super.disconnectedCallback()}propertyChangedCallback(e,i,r,s){switch(super.propertyChangedCallback(e,i,r,s),e){case"uploadUrl":t.Utils.isNull(this._editImage)||(this._editImage.uploadUrl=r);break;case"allowSnapshot":t.Utils.isNull(this._editImage)||(this._editImage.allowSnapshot=r);break;case"imageSet":t.Utils.isNull(this._editImage)||(this._editImage.imageSet=r);break;case"maxThumbnailHeight":t.Utils.isNull(this._editImage)||(this._editImage.maxThumbnailHeight=r);break;case"maxThumbnailWidth":t.Utils.isNull(this._editImage)||(this._editImage.maxThumbnailWidth=r);break;case"maxHeight":t.Utils.isNull(this._editImage)||(this._editImage.maxHeight=r);break;case"maxWidth":t.Utils.isNull(this._editImage)||(this._editImage.maxWidth=r)}}acceptValue(e){t.Utils.isNull(this._editImage)||(this._editImage.value=e)}_update(e){this._image.src=e}_retrieve(){return this.value}_edit(e){t.avoidHandler(e);var r=this._editImage,s=this.value;r.disabled=!1,r.reset(),r.value=s,this._dialog.open(s).then(e=>{switch(e.button){case i.Components.UI.DialogButton.Cancel:this._update(this.value);break;case i.Components.UI.DialogButton.Ok:this._update(e.state)}this._editImage.disabled=!0})}};Ft([t.ViewChild(t.P+"-img")],zt.prototype,"_image",void 0),Ft([t.ViewChild(t.P+"-button."+t.PCSS+"-edit")],zt.prototype,"_editBtn",void 0),Ft([t.ViewChild(t.P+"-button."+t.PCSS+"-clear")],zt.prototype,"_clearBtn",void 0),Ft([t.ViewChild(t.P+"-input-url")],zt.prototype,"_input",void 0),Ft([t.Watch({emit:!1,converter:t.PropertyConverters.String})],zt.prototype,"uploadUrl",void 0),Ft([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],zt.prototype,"imageSet",void 0),Ft([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],zt.prototype,"maxWidth",void 0),Ft([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],zt.prototype,"maxHeight",void 0),Ft([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],zt.prototype,"maxThumbnailWidth",void 0),Ft([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],zt.prototype,"maxThumbnailHeight",void 0),Ft([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],zt.prototype,"allowSnapshot",void 0),zt=Ft([t.CustomElement({tagName:t.P+"-input-image",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<div class="${t.PCSS}-input-image"><${t.P}-img src="{{ :host.value }}" adapt="contain"></${t.P}-img><div class="${t.PCSS}-input-image-dashboard">\n <${t.P}-button on-click=":host._edit($event)" hide="{{ :host.disabled }}" class="${t.PCSS}-edit">Edit</${t.P}-button>\n <${t.P}-button on-click=":host._clear($event)" hide="{{ :host.disabled }}" class="${t.PCSS}-clear">Clear</${t.P}-button>\n</div><${t.P}-input-url placeholder="{{ :host.placeholder }}" on-change=":host.changeHandler($event)" value="{{ :host.value }}"></${t.P}-input-url>\n\n <${t.P}-panel hide="{{ Pacem.Utils.isNullOrEmpty(:host.value) }}">\n <dl class="${t.PCSS}-input-image-preview">\n <dt>dimensions:</dt><dd><${t.P}-text text="{{ ::_image.size.width +'x'+ ::_image.size.height }}"></${t.P}-text></dd>\n <dt>size:</dt><dd><${t.P}-text text="{{ $pacem.size(::_image.size.weight) }}"></${t.P}-text></dd>\n </dl></${t.P}-panel>\n\n</div>`})],zt);var qt=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};let Jt=class extends ft{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(e=this.value){const i=this.format;return t.Utils.isNullOrEmpty(i)?e.toString():new Intl.NumberFormat(t.Utils.lang(this),i).format(e)}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(!t.Utils.isNull(this._input)){this._input.removeEventListener("wheel",this.emitHandler,{capture:!1,passive:!1})}super.disconnectedCallback()}};qt([t.ViewChild("input[type=number]")],Jt.prototype,"_input",void 0),qt([t.ViewChild(`span.${t.PCSS}-readonly`)],Jt.prototype,"_span",void 0),qt([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],Jt.prototype,"format",void 0),Jt=qt([t.CustomElement({tagName:t.P+"-input-number",template:`<input type="number" class="${t.PCSS}-input ${t.PCSS}-viewfinder" /><span class="${t.PCSS}-readonly"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></span>`,shadow:t.Defaults.USE_SHADOW_ROOT})],Jt);var Yt=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};let Kt=class extends _t{constructor(){super(),this._togglerMousedownHandler=e=>{0==e.button&&(t.avoidHandler(e),this.toggleVisibility())}}get inputFields(){return[this._input]}viewActivatedCallback(){super.viewActivatedCallback();const e=this.id??"_"+t.Utils.uniqueCode(),i=this._input.id=e+"_ctrl";this._toggler.setAttribute("aria-controls",i),this._toggler.setAttribute("role","button"),this._syncToggler(),this._toggler.addEventListener("mousedown",this._togglerMousedownHandler,!1)}disconnectedCallback(){t.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(e){return t.Utils.leftPad("",Math.floor(8+3*Math.random()),"•")}};Yt([t.ViewChild("input[type=password]")],Kt.prototype,"_input",void 0),Yt([t.ViewChild(`span.${t.PCSS}-readonly`)],Kt.prototype,"_span",void 0),Yt([t.ViewChild(`i.${t.PCSS}-icon.${t.PCSS}-clickable`)],Kt.prototype,"_toggler",void 0),Kt=Yt([t.CustomElement({tagName:t.P+"-input-password",template:`<input type="password" class="${t.PCSS}-input ${t.PCSS}-viewfinder" /><i class="${t.PCSS}-icon ${t.PCSS}-clickable"></i>\n${T}<span class="${t.PCSS}-readonly"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></span>`,shadow:t.Defaults.USE_SHADOW_ROOT})],Kt);var Gt=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};let Xt=class extends _t{constructor(){super()}get inputFields(){return[this.input]}toggleReadonlyView(e){}};Gt([t.ViewChild("input[type=search]")],Xt.prototype,"input",void 0),Xt=Gt([t.CustomElement({tagName:t.P+"-input-search",template:'<input type="search" class="'+t.PCSS+'-input" />',shadow:t.Defaults.USE_SHADOW_ROOT})],Xt);var Zt=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};let Qt=class extends _t{constructor(){super()}toggleReadonlyView(e){this.input.hidden=e,this.anchor.hidden=!e}get inputFields(){return[this.input]}};Zt([t.ViewChild("input[type=tel]")],Qt.prototype,"input",void 0),Zt([t.ViewChild(t.P+"-a")],Qt.prototype,"anchor",void 0),Qt=Zt([t.CustomElement({tagName:t.P+"-input-tel",template:`<input type="tel" class="${t.PCSS}-input" /><${t.P}-a class="${t.PCSS}-readonly" disabled="{{ $pacem.isNullOrEmpty(:host.value) }}" href="{{ 'tel:'+ :host.value }}"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></${t.P}-a>`,shadow:t.Defaults.USE_SHADOW_ROOT})],Qt);var ei=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};let ti=class extends _t{constructor(){super()}toggleReadonlyView(e){this._span.hidden=!e,this._input.hidden=e}get inputFields(){return[this._input]}};ei([t.ViewChild("input[type=text]")],ti.prototype,"_input",void 0),ei([t.ViewChild("span."+t.PCSS+"-readonly")],ti.prototype,"_span",void 0),ti=ei([t.CustomElement({tagName:t.P+"-input-text",template:`<input type="text" class="${t.PCSS}-input" />${T}<span class="${t.PCSS}-readonly"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></span>`,shadow:t.Defaults.USE_SHADOW_ROOT})],ti);var ii=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};let ri=class extends _t{constructor(){super()}toggleReadonlyView(e){this.input.hidden=e,this.anchor.hidden=!e}get inputFields(){return[this.input]}};ii([t.ViewChild("input[type=url]")],ri.prototype,"input",void 0),ii([t.ViewChild(t.P+"-a")],ri.prototype,"anchor",void 0),ri=ii([t.CustomElement({tagName:t.P+"-input-url",template:`<input type="url" class="${t.PCSS}-input" />${T}<${t.P}-a class="${t.PCSS}-readonly" disabled="{{ $pacem.isNullOrEmpty(:host.value) }}" href="{{ :host.value }}" target="_blank"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></${t.P}-a>`,shadow:t.Defaults.USE_SHADOW_ROOT})],ri);var si=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};let ai=class extends x{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(e){return e&&"number"==typeof e.lat&&"number"==typeof e.lng?e:r.Components.Maps.MapConsts.DEFAULT_COORDS}onChange(e){if(e&&"dragend"===e.type){var i=e;this._lat=i.detail.position.lat,this._lng=i.detail.position.lng}const r=this._lat,s=this._lng;return t.Utils.isNull(r)||t.Utils.isNull(s)?t.Utils.fromResult(this.value):t.Utils.fromResult(this.value={lat:r,lng:s})}propertyChangedCallback(e,i,r,s){if(super.propertyChangedCallback(e,i,r,s),"options"===e&&!s){const e=t.Utils.clone(r||{provider:"osm"});this._synchronizeOptions(e)}}viewActivatedCallback(){super.viewActivatedCallback(),this._synchronizeOptions()}_synchronizeOptions(e=this.options||{provider:"osm"}){const i=this._marker,r=this._map;switch(i.icon=e.icon,e&&e.provider){case"azure":this._azureAdapter.subscriptionKey=e.apiKey,r.adapter=this._azureAdapter;break;case"google":case"gmaps":this._googleAdapter.apiKey=e.apiKey,r.adapter=this._googleAdapter;break;default:t.Utils.isNullOrEmpty(e.attribution)||(this._leafletAdapter.attribution=e.attribution),t.Utils.isNullOrEmpty(e.tiles)||(this._leafletAdapter.tiles=e.tiles),r.adapter=this._leafletAdapter}delete e.provider,delete e.icon,delete e.apiKey,delete e.attribution,delete e.tiles;for(let t in e)t in r&&(r[t]=e[t])}};si([t.ViewChild(t.P+"-map-adapter-leaflet")],ai.prototype,"_leafletAdapter",void 0),si([t.ViewChild(t.P+"-map-adapter-azure")],ai.prototype,"_azureAdapter",void 0),si([t.ViewChild(t.P+"-map-adapter-google")],ai.prototype,"_googleAdapter",void 0),si([t.ViewChild(t.P+"-map")],ai.prototype,"_map",void 0),si([t.ViewChild(t.P+"-map-marker")],ai.prototype,"_marker",void 0),si([t.ViewChild(t.P+"-input-number:nth-child(1)")],ai.prototype,"_latInput",void 0),si([t.ViewChild(t.P+"-input-number:nth-child(2)")],ai.prototype,"_lngInput",void 0),si([t.ViewChild(`.${t.PCSS}-latlng-fields`)],ai.prototype,"_inputContainer",void 0),si([t.ViewChild(t.P+"-fetch")],ai.prototype,"_fetcher",void 0),si([t.Watch({converter:t.PropertyConverters.Json,emit:!1})],ai.prototype,"options",void 0),si([t.Watch()],ai.prototype,"_lat",void 0),si([t.Watch()],ai.prototype,"_lng",void 0),ai=si([t.CustomElement({tagName:t.P+"-latlng",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<div class="${t.PCSS}-latlng">\n <div class="${t.PCSS}-latlng-fields ${t.PCSS}-viewfinder">\n <${t.P}-input-number class="${t.PCSS}-lat" value="{{ :host._lat, twoway }}" min="-90" max="90" step="{{ 'any' }}"></${t.P}-input-number>\n <${t.P}-input-number class="${t.PCSS}-lng" value="{{ :host._lng, twoway }}" min="-180" max="180" step="{{ 'any' }}"></${t.P}-input-number>\n </div>\n <${t.P}-panel hide="{{ Pacem.Utils.isNull(:host.value) || :host.readonly }}">\n <dl class="${t.PCSS}-latlng-preview">\n <dt>decimals:</dt><dd><${t.P}-text text="{{ :host._getViewValue(:host.value, 12) }}"></${t.P}-text></dd>\n <dt>address:</dt><dd><${t.P}-text text="{{ ::_fetcher.result.display_name || '?' }}"></${t.P}-text></dd>\n <dt>degrees:</dt><dd><${t.P}-span css-class="{{ {'${t.PCSS}-lat-north': :host._lat > 0, '${t.PCSS}-lat-south': :host._lat < 0} }}" content="{{ $pacem.decToDeg(Math.abs(:host._lat)) }}"></${t.P}-span>,\n <${t.P}-span css-class="{{ {'${t.PCSS}-lng-east': :host._lng > 0, '${t.PCSS}-lng-west': :host._lng < 0} }}" content="{{ $pacem.decToDeg(Math.abs(:host._lng)) }}"></${t.P}-span></dd>\n </dl>\n </${t.P}-panel>\n <${t.P}-span class="${t.PCSS}-readonly" hide="{{ !:host.readonly }}" content="{{ :host.viewValue + ($pacem.isNullOrEmpty(::_fetcher.result.display_name) ? '' : (' <small>'+ ::_fetcher.result.display_name +'</small>')) }}"></${t.P}-span>\n\n <${t.P}-map-adapter-leaflet></${t.P}-map-adapter-leaflet>\n <${t.P}-map-adapter-azure></${t.P}-map-adapter-azure>\n <${t.P}-map-adapter-google></${t.P}-map-adapter-google>\n\n <${t.P}-map adapter="{{ ::_adapter }}">\n <${t.P}-map-marker position="{{ :host._ensureValue(:host.value) }}" on-dragend=":host.changeHandler($event)" draggable="{{ !:host.readonly }}"></${t.P}-map-marker>\n </${t.P}-map>\n <${t.P}-fetch disabled="{{ $pacem.isNull(:host.value) }}" parameters="{{ { format: 'json', lat: :host._lat, lon: :host._lng } }}" url="https://nominatim.openstreetmap.org/reverse"></${t.P}-fetch>\n</div>`})],ai);var ni=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};const oi=`change-policy="${mt.Blur}" readonly="{{ :host.readonly }}"`;function li(e){return t.Utils.isNullOrEmpty(e&&e.name)}let ci=class extends x{constructor(){super(...arguments),this.inputFields=[],this._bag=[]}toggleReadonlyView(e){}onChange(e){return new Promise((e,t)=>{let i=this._bagToValue(this._bag);this.compareValuePropertyValues(i,this.value)?t():e(this.value=i)})}acceptValue(e){this._bag=this._valueToBag(e)}getViewValue(e){return""}compareValuePropertyValues(e,i){return t.Utils.Json.stringify(e)===t.Utils.Json.stringify(i)}convertValueAttributeToProperty(e){return t.PropertyConverters.Json.convert(e)}propertyChangedCallback(e,t,i,r){super.propertyChangedCallback(e,t,i,r),"dictionary"!==e||r||(this.value=this._bagToValue())}_bagToValue(e=this._bag){if(!this.dictionary){let t=[];for(let i of e||[])li(i)||t.find(e=>e.name===i.name&&e.value===i.value)||t.push(i);return t}let t={};for(let i of e||[])i.name in t||(t[i.name]=i.value);return t}_valueToBag(e=this.value){const i=[];if(!t.Utils.isNullOrEmpty(e)&&"object"==typeof e)if(this.dictionary&&!t.Utils.isArray(e))for(let t in e)i.push({name:t,value:e[t]});else!this.dictionary&&t.Utils.isArray(e)&&Array.prototype.splice.apply(i,[0,0].concat(e.map(e=>t.Utils.clone(e))));return t.Utils.isNullOrEmpty(i)?[{name:"",value:""}]:i}_deleteAt(e){this._bag.splice(e.detail,1),this.changeHandler(e)}_addItem(e){const i=this._bag,r=this._bag[this._bag.length-1];!t.Utils.isEmpty(i)&&li(r)||i.push({name:"",value:""})}};ni([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],ci.prototype,"dictionary",void 0),ni([t.Watch({converter:t.PropertyConverters.Json})],ci.prototype,"_bag",void 0),ci=ni([t.CustomElement({tagName:t.P+"-namevalue-list",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<${t.P}-repeater datasource="{{ :host._bag }}" on-itemdelete=":host._deleteAt($event)">\n <template>\n <div class="${t.PCSS}-fieldset ${t.PCSS}-margin margin-bottom-1">\n <div class="fieldset-auto">\n <div class="${t.PCSS}-fieldgroup">\n <${t.P}-input-text ${oi} value="{{ ^item.name, twoway }}" on-change=":host.changeHandler($event)"></${t.P}-input-text>\n <div class="fieldgroup-prepend"></div>\n </div>\n <div class="${t.PCSS}-fieldgroup">\n <${t.P}-input-text ${oi} value="{{ ^item.value, twoway }}" on-change=":host.changeHandler($event)"></${t.P}-input-text>\n <div class="fieldgroup-append">\n <${t.P}-button class="${t.PCSS}-cell cols-2 flat delete" hide="{{ :host.readonly }}" command-name="delete" command-argument="{{ ^index }}"></${t.P}-button>\n </div>\n </div>\n </div>\n </div>\n </template>\n <${t.P}-button class="flat add" hide="{{ :host.readonly }}" on-click=":host._addItem($event)"></${t.P}-button>\n</${t.P}-repeater>`})],ci);var di=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};let hi=class extends x{get inputFields(){return[this._select]}toggleReadonlyView(e){this._select.readonly=e}onChange(e){return t.Utils.fromResult(this.value=this._select.value)}acceptValue(e){this._select.value=e}getViewValue(e){return this._select.viewValue}convertValueAttributeToProperty(e){return t.PropertyConverters.Element.convert(e)}viewActivatedCallback(){super.viewActivatedCallback(),this._databind()}propertyChangedCallback(e,t,i,r){if(super.propertyChangedCallback(e,t,i,r),!r&&"target"===e)this._databind()}_databind(){const e=[],i=(r,s,a)=>{const n=r[s];if("object"==typeof n&&null!=n&&!t.Utils.isArray(n))for(let t of Object.keys(n)){const r=a+"."+t;e.push(r),i(n,t,r)}};let r=this.target;if(!t.Utils.isNull(r)){let s=t.CustomElementUtils.getWatchedProperties(r);for(let t of s){let s=t.name;e.push(s),i(r,s,s)}}this._select.datasource=e.sort()}};di([t.ViewChild(t.P+"-select")],hi.prototype,"_select",void 0),di([t.Watch({converter:t.PropertyConverters.Element})],hi.prototype,"target",void 0),hi=di([t.CustomElement({tagName:t.P+"-property-picker",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<${t.P}-select></${t.P}-select>`})],hi);var pi=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};let ui=class extends x{convertValueAttributeToProperty(e){return e}constructor(){super(),this._key="_"+t.Utils.uniqueCode()}toggleReadonlyView(e){this.span.hidden=!e,this._radio.hidden=e}get inputFields(){return[this._radio]}onChange(e){this.selected=this._radio.checked;const i=this.selected?this._radio.value:void 0;return t.Utils.fromResult(i)}viewActivatedCallback(){super.viewActivatedCallback(),this._radio.id=this._label.htmlFor=this._key}propertyChangedCallback(e,i,r,s){switch(super.propertyChangedCallback(e,i,r,s),e){case"name":this._radio.name=r;break;case"selected":(this._radio.checked=r)?t.Utils.addClass(this,t.PCSS+"-selected"):t.Utils.removeClass(this,t.PCSS+"-selected")}}acceptValue(e){this._radio.value=t.Utils.isNullOrEmpty(e)?"":e}getViewValue(e){return t.Utils.isNull(e)?"":this.caption}};pi([t.ViewChild("input[type=radio]")],ui.prototype,"_radio",void 0),pi([t.ViewChild("label")],ui.prototype,"_label",void 0),pi([t.ViewChild(`.${t.PCSS}-readonly`)],ui.prototype,"span",void 0),pi([t.Watch({converter:t.PropertyConverters.String})],ui.prototype,"caption",void 0),pi([t.Watch({converter:t.PropertyConverters.Boolean})],ui.prototype,"selected",void 0),ui=pi([t.CustomElement({tagName:t.P+"-radio",template:`<${t.P}-span class="${t.PCSS}-readonly ${t.PCSS}-radio" text="{{ :host.caption }}"></${t.P}-span><input type="radio" class="${t.PCSS}-input" /><label class="${t.PCSS}-label ${t.PCSS}-radio ${t.PCSS}-viewfinder"><${t.P}-text text="{{ :host.caption }}"></${t.P}-text></label>`,shadow:t.Defaults.USE_SHADOW_ROOT})],ui);var mi=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};let vi=class extends A{acceptValue(e){}constructor(){super(),this.key="_"+t.Utils.uniqueCode()}get inputFields(){return[]}propertyChangedCallback(e,t,i,r){super.propertyChangedCallback(e,t,i,r),"disabled"===e&&(this._disable.model=i)}viewActivatedCallback(){super.viewActivatedCallback(),this._disable.model=this.disabled}toggleReadonlyView(e){this._repeater.hidden=e,this._span.hidden=!e}_selectionChanged(e,t,i){"selected"===e.detail.propertyName&&!0===e.detail.currentValue&&(this._selectedValue=this.mapEntityToValue(this.datasource[t]),this.changeHandler(e))}onChange(e){return this.value=this._selectedValue,this.databind(),t.Utils.fromResult(this._selectedValue)}};mi([t.ViewChild(t.P+"-repeater")],vi.prototype,"_repeater",void 0),mi([t.ViewChild(t.P+"-data")],vi.prototype,"_disable",void 0),mi([t.ViewChild(`span.${t.PCSS}-readonly`)],vi.prototype,"_span",void 0),vi=mi([t.CustomElement({tagName:t.P+"-radio-list",template:`<${t.P}-repeater datasource="{{ :host.adaptedDatasource }}">\n <ol class="${t.PCSS}-radio-list ${t.PCSS}-viewfinder" pacem>\n <template>\n <li><${t.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-${t.PropertyChangeEventName}=":host._selectionChanged($event, ^index, ^item)"></${t.P}-radio></li>\n </template>\n </ol>\n</${t.P}-repeater><span class="${t.PCSS}-readonly ${t.PCSS}-radio"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></span><${t.P}-data></${t.P}-data><${t.P}-content></${t.P}-content>`,shadow:t.Defaults.USE_SHADOW_ROOT})],vi);var gi=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};let yi=class extends A{constructor(){super(...arguments),this.emptyOption=!0}toggleReadonlyView(e){this._repeater.hidden=e,this._span.hidden=!e}get inputFields(){return[this._select]}_manageDom(e){const i=e.detail,r=i.item;let s=i.dom.find(e=>e instanceof HTMLOptionElement);s.value=r.value,s.textContent=r.viewValue,s.disabled=r.disabled,s.selected=this.isDataSourceItemSelected(r),(t.Utils.isNullOrEmpty(s.value)?t.Utils.addClass:t.Utils.removeClass).apply(this,[s,t.PCSS+"-watermark"])}onChange(e){let i,r=this._select.selectedIndex,s=this.adaptedDatasource,a=r>=0&&s[r];return i=null!=a?a.value:void 0,t.Utils.fromResult(this.value=i)}propertyChangedCallback(e,t,i,r){switch(super.propertyChangedCallback(e,t,i,r),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(e){this.emptyOption?super.handleDatasourceMismatch(e):t.Utils.isNullOrEmpty(e)?this.value=void 0:this.value=e[0].value}acceptValue(e){const i=this.adaptedDatasource,r=i&&i.filter(t=>this.isDataSourceItemSelected(t,e));if(r&&1==r.length)this._select.selectedIndex=i.indexOf(r[0]);else{this._select.value=void 0;let e=this._select.options;e.length>0&&t.Utils.isNullOrEmpty(e[0].value)&&(this._select.selectedIndex=0)}}viewActivatedCallback(){super.viewActivatedCallback();this._select.addEventListener("wheel",this.emitHandler,{capture:!1,passive:!1})}disconnectedCallback(){if(!t.Utils.isNull(this._select)){this._select.removeEventListener("wheel",this.emitHandler,{capture:!1,passive:!1})}super.disconnectedCallback()}};gi([t.ViewChild("select")],yi.prototype,"_select",void 0),gi([t.ViewChild(t.P+"-repeater")],yi.prototype,"_repeater",void 0),gi([t.ViewChild(`span.${t.PCSS}-readonly`)],yi.prototype,"_span",void 0),gi([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],yi.prototype,"emptyOption",void 0),yi=gi([t.CustomElement({tagName:t.P+"-select",template:`<${t.P}-repeater datasource="{{ :host.adaptedDatasource }}" on-${t.Components.RepeaterItemCreateEventName}=":host._manageDom($event)">\n <select class="${t.PCSS}-select ${t.PCSS}-viewfinder">\n <template>\n <option></option>\n </template>\n </select>\n</${t.P}-repeater><span class="${t.PCSS}-readonly"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></span><${t.P}-content></${t.P}-content>`,shadow:t.Defaults.USE_SHADOW_ROOT})],yi);var fi=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};let _i=class extends x{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=e=>{const i=e instanceof MouseEvent?e.clientX:e.touches&&e.touches.length&&e.touches[0].clientX,r=this._trackSize;t.Utils.isNullOrEmpty(r)||this._computeAndAssignValue(i,!0)},this._keydownHandler=e=>{switch(e.keyCode){case 39:case 37:t.avoidHandler(e);let i=39===e.keyCode,r=("number"!=typeof this.step?1:this.step)*(i?1:-1),s=!1,a=e=>{s=!0,window.removeEventListener("keyup",a,!1),t.Utils.removeClass(this,"slider-keydown")};window.addEventListener("keyup",a,!1),t.Utils.addClass(this,"slider-keydown"),t.Utils.accelerateCallback(e=>{(e.cancel=s)||this._setValue(this.value+r)})}}}onChange(e){return new Promise((t,i)=>{"slide"===e.type&&t(this.value=e.detail),t(this.value)})}_draw(e=this.value){const i=this._trackSize;if(t.Utils.isNull(i))return;const r=t.Utils.isNullOrEmpty(e)?this.min:parseFloat(e),s=Math.min(1,Math.max(0,(r-this.min)/(this.max-this.min)));this._progress.style.transform=`scale(${s}, 1)`,this._thumb.style.transform=`translateX(${Math.round(s*i.width)}px)`}_format(e){const i=this.format;if(!t.Utils.isNullOrEmpty(i))return new Intl.NumberFormat(t.Utils.lang(this),i).format(e);let r="-";t.Utils.isNull(e)||(r=e.toLocaleString());let s=new CustomEvent("formatvalue",{detail:{value:e}});return this.dispatchEvent(s),t.Utils.isNull(s.detail.output)?r:s.detail.output}acceptValue(e){this._draw(e)}getViewValue(e){return this._format(e)}convertValueAttributeToProperty(e){return parseFloat(e)}toggleReadonlyView(e){this._thumb.hidden=e;const i="cursor-pointer";e?(t.Utils.removeClass(this._max,i),t.Utils.removeClass(this._min,i)):(t.Utils.addClass(this._max,i),t.Utils.addClass(this._min,i))}_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 i=this._trackSize,r=this.step;let s=(e-i.x)/i.width,a=(this.max-this.min)*s+this.min;"number"==typeof r&&(a=Math.round(a/r)*r),t?this._setValue(a):this._draw(a)}_setValue(e){isNaN(e)||t.Utils.isNull(e)?e=void 0:(!isNaN(this.min)&&e<this.min&&(e=this.min),!isNaN(this.max)&&e>this.max&&(e=this.max)),this.changeHandler(new CustomEvent("slide",{detail:e}))}connectedCallback(){super.connectedCallback(),this.addEventListener("mousedown",this._downHandler,!1),this.addEventListener("touchstart",this._downHandler,{passive:!1,capture:!1})}viewActivatedCallback(){super.viewActivatedCallback(),this._dragger.addEventListener(t.UI.DragDropEventType.Init,this._startHandler,!1),this._dragger.addEventListener(t.UI.DragDropEventType.Drag,this._dragHandler,!1),this._dragger.addEventListener(t.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 e=this._shellProxy.dom[0];t.Utils.isNull(e)||(e.target=this._thumb,e.options={trigger:i.Components.UI.BalloonTrigger.Focus,trackPosition:!0,position:i.Components.UI.BalloonPosition.Top,align:i.Components.UI.BalloonAlignment.Center,behavior:i.Components.UI.BalloonBehavior.Tooltip,hoverDelay:0,hoverTimeout:0},this._syncThumbLabel()),this._thumb.tabIndex=0}_syncThumbLabel(e=this.thumbLabel){const i=this._shellProxy.dom[0];(e?t.Utils.addClass:t.Utils.removeClass).apply(this,[this,"slider-thumblabel"]),i.disabled=!e}disconnectedCallback(){this.removeEventListener("mousedown",this._downHandler,!1),this.removeEventListener("touchstart",this._downHandler,{capture:!1}),t.Utils.isNull(this._dragger)||(this._dragger.removeEventListener(t.UI.DragDropEventType.End,this._endHandler,!1),this._dragger.removeEventListener(t.UI.DragDropEventType.Drag,this._dragHandler,!1),this._dragger.removeEventListener(t.UI.DragDropEventType.Init,this._startHandler,!1)),t.Utils.isNull(this._thumb)||this._thumb.removeEventListener("keydown",this._keydownHandler,!1),super.disconnectedCallback()}propertyChangedCallback(e,i,r,s){if(super.propertyChangedCallback(e,i,r,s),!s)switch(e){case"thumbLabel":this._syncThumbLabel(r);break;case"min":case"max":t.Utils.isNull(this._max)||t.Utils.isNull(this._min)||(this._min.text=this._format(this.min),this._max.text=this._format(this.max)),this._setValue(this.value),this._draw()}}};fi([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],_i.prototype,"min",void 0),fi([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],_i.prototype,"max",void 0),fi([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],_i.prototype,"thumbLabel",void 0),fi([t.Watch({emit:!1,converter:{convert:e=>{let t=parseFloat(e);return isNaN(t)?"any":t},convertBack:e=>(e||"").toString()}})],_i.prototype,"step",void 0),fi([t.Watch({emit:!1,converter:t.PropertyConverters.String})],_i.prototype,"changePolicy",void 0),fi([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],_i.prototype,"format",void 0),fi([t.ViewChild(".slider-track")],_i.prototype,"_track",void 0),fi([t.ViewChild(".slider-progress")],_i.prototype,"_progress",void 0),fi([t.ViewChild(".slider-thumb")],_i.prototype,"_thumb",void 0),fi([t.ViewChild(`${t.P}-text[min]`)],_i.prototype,"_min",void 0),fi([t.ViewChild(`${t.P}-text[max]`)],_i.prototype,"_max",void 0),fi([t.ViewChild(`${t.P}-drag-drop`)],_i.prototype,"_dragger",void 0),fi([t.ViewChild(`${t.P}-shell-proxy`)],_i.prototype,"_shellProxy",void 0),_i=fi([t.CustomElement({tagName:t.P+"-slider",template:`<div class="${t.PCSS}-viewfinder ${t.PCSS}-slider"><${t.P}-text text="{{ :host._format(:host.min) }}" min></${t.P}-text>\n <div class="slider-track"><div class="slider-progress"></div></div>\n <${t.P}-panel class="${t.PCSS}-clickable slider-thumb" behaviors="{{ [::_dragger] }}">\n <div class="thumb-label"></div>\n </${t.P}-panel>\n <${t.P}-text text="{{ :host._format(:host.max) }}" max></${t.P}-text>\n <div class="slider-footer"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></div>\n </div>\n<${t.P}-drag-drop lock-timeout="0"></${t.P}-drag-drop><${t.P}-resize watch-position="true" on-${t.Components.ResizeEventName}=":host._setTrackSize($event)" target="{{ ::_track }}"></${t.P}-resize>\n<${t.P}-shell-proxy><${t.P}-balloon class="text-center"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></${t.P}-balloon></${t.P}-shell-proxy>\n`,shadow:t.Defaults.USE_SHADOW_ROOT})],_i);var bi=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};class Ci extends t.CustomTypedEvent{constructor(e){super("suggestionselect",{selectedValue:e})}}let Pi=class extends A{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 Ci(null))},this._balloonPopupHandler=e=>{t.Utils.addClass(this._btnArrow,"rotate-180")},this._balloonPopoutHandler=e=>{t.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 Ci(null))}},this._keyupHandler=e=>{this.#C&&(t.avoidHandler(e),this.#C=!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.#C=!1,this._keydownHandler=e=>{var i=!1;if(t.Utils.isNull(this.#P)){const r=this._findFirstAvailableListItem();if(!t.Utils.isNull(r))switch(e.keyCode){case 40:t.avoidHandler(e),this._focus(r);break;case 13:t.avoidHandler(e),i=!0,1===this.#w.length?this._select(r):this._focus(r)}}else{var r,s=this.#P,a=s;const n=e=>!t.Utils.isNull(e)&&"li"===e.localName&&"true"===e.dataset.pacemDisabled,o=e=>!t.Utils.isNull(e)&&"li"===e.localName&&"true"!==e.dataset.pacemDisabled;switch(e.keyCode){case 38:t.avoidHandler(e);do{if(o(a=a.previousElementSibling)){r=a;break}}while(n(a));r??=s;break;case 40:t.avoidHandler(e);do{if(o(a=a.nextElementSibling)){r=a;break}}while(n(a));r??=s;break;case 27:t.avoidHandler(e),this._undo(),this.popout();break;case 9:case 13:t.avoidHandler(e),i=!0,this._select()}this._focus(r),this.#C=i}},this._selectHandler=e=>{t.avoidHandler(e),this._select(e.currentTarget)}}get inputFields(){return[this._input]}acceptValue(e){/*!this._isTyping && */!this.allowNew&&t.Utils.isNullOrEmpty(this.datasource)||(this._input.value=this.getViewValue(e)||(this._isTyping?this._input.value:""))}getViewValue(e){var i=super.getViewValue(e);return t.Utils.isNullOrEmpty(i)&&this.allowNew&&!t.Utils.isNullOrEmpty(e)&&(i=this.mapEntityToViewValue(e)),i}onChange(e){return new Promise((t,i)=>{if("suggestionselect"===e.type){const i=e.detail.selectedValue;this.value=i,i&&this.popout(),t(i)}else t(this.value)})}viewActivatedCallback(){super.viewActivatedCallback(),this._setDropdownMode(),this._setupItemTemplate();var e=this._createBalloon();e.appendChild(this._repeater),this._checkBalloon(e);t.CustomElementUtils.findAncestorShell(this).appendChild(e),this._balloon=e,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(e,i,r,s){if(super.propertyChangedCallback(e,i,r,s),t.Utils.isNull(this._balloon))return;const a=this._isTyping;switch(e){case"adaptedDatasource":t.Utils.isNullOrEmpty(r)?this.popout():a?this.popup():this._input.value=this.getViewValue(this.value);break;case"hint":a||r===this._input.value||(this._input.value=r,this.#P=null);break;case"readonly":this._setDropdownMode();case"disabled":case"value":this._checkBalloon();break;case"itemtemplate":s||this._setupItemTemplate();break;case"allowTyping":s||this._setDropdownMode()}["adaptedDatasource","hint","value"].indexOf(e)>=0&&this._databind(),["allowTyping","value","hint"].indexOf(e)>=0&&this._syncButtons()}disconnectedCallback(){t.Utils.isNull(this._balloon)||(this._balloon.removeEventListener("popup",this._balloonPopupHandler,!1),this._balloon.removeEventListener("popout",this._balloonPopoutHandler,!1),this._balloon.remove()),t.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)),t.Utils.isNull(this._btnClear)||this._btnClear.removeEventListener("mousedown",this._clearBtnHandler,!1),t.Utils.isNull(this._btnArrow)||this._btnArrow.addEventListener("mousedown",this._toggleBtnHandler,!1),super.disconnectedCallback()}#w;_databind(){if(!t.Utils.isNull(this._repeater)){const e=this.#w=this._filter(this.adaptedDatasource,this._input.value);this._repeater.datasource=e}}_syncButtons(){t.Utils.isNull(this._btnArrow)||(this._btnArrow.hide=!1!==this.allowTyping||!t.Utils.isNullOrEmpty(this._input.value||this.value)),t.Utils.isNull(this._btnClear)||(this._btnClear.hide=this.readonly||t.Utils.isNullOrEmpty(this._input.value||this.value))}get _isTyping(){return t.Utils.is(this._input,":focus")}_undo(){this._focus(null),this.hint=this._input.value=this.getViewValue(this.value)||""}_findFirstAvailableListItem(){var e;if(!0===this._balloon.visible&&!t.Utils.isNull(e=this._repeater.querySelector("ol > li")))for(;!t.Utils.isNull(e)&&"true"===e.dataset.pacemDisabled&&"li"===e.localName;)e=e.nextElementSibling;return e}#C;_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"),i=document.createElement("li");i.append(e),t.content.appendChild(i),this._tmplProxy.target=t}else this._tmplProxy.target=this._defaultTemplate}#P;_focus(e){if(this.preventFocus)return;if(t.Utils.isNull(e))return void(this.#P=null);const i=e.parentElement.children;for(let t=0;t<i.length;t++){const r=i.item(t);if(r===e){r.dataset.pacemFocused="true",this.#P=r;const e=this._input,t=e.value=JSON.parse(r.dataset.pacemViewValue);e.setSelectionRange(t.length,t.length)}else delete r.dataset.pacemFocused}}_select(e=this.#P){const t=JSON.parse(e.dataset.pacemValue);"true"===e.dataset.pacemDisabled||this.changeHandler(new Ci(t))}_filter(e,i,r=this.value){let s=e||[];if(!t.Utils.isNullOrEmpty(i&&i.trim())){const e=i.toLowerCase().split(" ");let r=s.filter(i=>{for(let r of e){if(i.viewValue?.toLowerCase().indexOf(r)>=0)return!0;const e=this.filterFields;if(!t.Utils.isNullOrEmpty(e)){const s=i.data;if("object"==typeof s&&!t.Utils.isNullOrEmpty(s))for(let i of e){const e=i.split(".");let a=0,n=s;for(;!t.Utils.isNull(n)&&a<e.length;)n=n[e[a]],a++;if(!t.Utils.isNullOrEmpty(n)&&n.toString().toLowerCase().indexOf(r)>=0)return!0}}}return!1});s=this.allowNew&&t.Utils.isNullOrEmpty(this.valueProperty)&&t.Utils.isNullOrEmpty(this.textProperty)&&(t.Utils.isNullOrEmpty(r)||t.Utils.isNull(r.find(e=>e.viewValue===i)))?[{value:i,viewValue:i,data:i}].concat(r):r}let a=s;return!1!==this.allowTyping&&(a=s.slice(0,this.maxSuggestions||10)),this._isTyping&&this.popup(),this._balloon.style.opacity=t.Utils.isNullOrEmpty(a)?"0":"",this.log(t.Logging.LogLevel.Log,`${a.length} dropdown suggestion(s), given hint '${i}' and ${(e||[]).length} datasource items`),a}_itemCreate(e){const t=e.detail.dom.find(e=>e instanceof HTMLLIElement),i=e.detail.item;e.detail.index;const r=!0===i.disabled;t.tabIndex=r?-1:0,t.dataset.pacemValue=JSON.stringify(i.value),t.dataset.pacemViewValue=JSON.stringify(i.viewValue),t.dataset.pacemDisabled=r.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(e=100){!t.Utils.isNullOrEmpty(this.adaptedDatasource)&&t.Utils.isVisible(this)&&this._balloon?.popup(e)}popout(e=0){this.#P=null,this._balloon?.popout(e)}_checkBalloon(e=this._balloon){if(!t.Utils.isNull(e)){const i=!t.Utils.isNullOrEmpty(this.value)&&!t.Utils.isNullOrEmpty(this._input.value);e.disabled=i||this.readonly||this.disabled||!1}}_createBalloon(){const e=document.createElement(t.P+"-balloon");return t.Utils.addClass(e,"suggest dropdown"),e.options={trackPosition:!0,trigger:i.Components.UI.BalloonTrigger.Focus,position:i.Components.UI.BalloonPosition.VerticalAuto,size:i.Components.UI.BalloonSizing.Match,align:i.Components.UI.BalloonAlignment.Start,behavior:i.Components.UI.BalloonBehavior.Menu,hoverDelay:100,hoverTimeout:0},e.addEventListener("popup",this._balloonPopupHandler,!1),e.addEventListener("popout",this._balloonPopoutHandler,!1),e.target=this._input,e}};bi([t.ViewChild("input[type=text]")],Pi.prototype,"_input",void 0),bi([t.ViewChild(t.P+"-repeater")],Pi.prototype,"_repeater",void 0),bi([t.ViewChild(`span.${t.PCSS}-readonly`)],Pi.prototype,"span",void 0),bi([t.ViewChild("template")],Pi.prototype,"_defaultTemplate",void 0),bi([t.ViewChild(t.P+"-template-proxy")],Pi.prototype,"_tmplProxy",void 0),bi([t.ViewChild(`${t.P}-button[toggle]`)],Pi.prototype,"_btnArrow",void 0),bi([t.ViewChild(`${t.P}-button[clear]`)],Pi.prototype,"_btnClear",void 0),bi([t.Watch({converter:t.PropertyConverters.String})],Pi.prototype,"hint",void 0),bi([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],Pi.prototype,"maxSuggestions",void 0),bi([t.Watch({converter:t.PropertyConverters.Boolean})],Pi.prototype,"allowTyping",void 0),bi([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],Pi.prototype,"preventFocus",void 0),bi([t.Watch({emit:!1,converter:t.PropertyConverters.Element})],Pi.prototype,"itemtemplate",void 0),bi([t.Watch({emit:!1,converter:t.PropertyConverters.StringArray})],Pi.prototype,"filterFields",void 0),bi([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],Pi.prototype,"allowNew",void 0),Pi=bi([t.CustomElement({tagName:t.P+"-suggest",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<div class="${t.PCSS}-relative"><input type="text" class="${t.PCSS}-input" />\n<${t.P}-button clear tab-order="-1"\nclass="button-flat ${t.PCSS}-anim anim-pop anim-sudden anim-quick pos-absolute absolute-right absolute-top display-block ${t.PCSS}-margin margin-0" \n icon-glyph="highlight_off"></${t.P}-button>\n<${t.P}-button \nclass="button-flat icon-rotate ${t.PCSS}-anim anim-pop anim-sudden anim-quick pos-absolute absolute-right absolute-top display-block ${t.PCSS}-margin margin-0" \n icon-glyph="arrow_drop_down" tab-order="-1" toggle></${t.P}-button>\n</div>\n<span class="${t.PCSS}-readonly"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></span>\n<${t.P}-repeater on-${t.Components.RepeaterItemCreateEventName}=":host._itemCreate($event)" on-${t.Components.RepeaterItemRemoveEventName}=":host._itemRemove($event)">\n <ol>\n <${t.P}-template-proxy></${t.P}-template-proxy>\n </ol>\n</${t.P}-repeater><${t.P}-content></${t.P}-content>\n<template>\n <li><${t.P}-span content="{{ $pacem.highlight(^item.viewValue, :host.hint) }}"></${t.P}-span></li>\n</template>`})],Pi);var wi=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};class Ei extends t.CustomTypedEvent{constructor(e){super("tagremove",{index:e})}}class Si extends t.CustomTypedEvent{constructor(e){super("tagadd",{value:e})}}let $i=class extends t.Components.PacemElement{propertyChangedCallback(e,i,r,s){switch(super.propertyChangedCallback(e,i,r,s),e){case"readonly":let e=!!r;(e?t.Utils.addClass:t.Utils.removeClass)(this,"tag-readonly"),this._btn.disabled=this._btn.hide=e;break;case"tag":t.Utils.removeClass(this,"tag-out")}}_remove(){t.Utils.addClass(this,"tag-out"),t.Utils.addAnimationEndCallback(this,()=>{this.dispatchEvent(new Event("remove"))})}};wi([t.Watch({converter:t.PropertyConverters.String})],$i.prototype,"tag",void 0),wi([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],$i.prototype,"readonly",void 0),wi([t.ViewChild(t.P+"-button")],$i.prototype,"_btn",void 0),$i=wi([t.CustomElement({tagName:t.P+"-tag",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<${t.P}-text text="{{ :host.tag }}"></${t.P}-text>\n <${t.P}-button on-click=":host._remove()"></${t.P}-button>`})],$i);let ki=class extends A{constructor(){super(!0),this.inputFields=[]}toggleReadonlyView(e){this._suggest.readonly=e,this.querySelector(".tag-new").hidden=e}_tagRemove(e){this.changeHandler(new Ei(e))}_tagAdd(e){this.changeHandler(new Si(e))}handleDatasourceMismatch(){}propertyChangedCallback(e,i,r,s){switch(super.propertyChangedCallback(e,i,r,s),e){case"datasource":case"textProperty":this._suggest[e]=r;break;case"valueProperty":if(!t.Utils.isNullOrEmpty(r))throw`Cannot set 'valueProperty' on ${this.constructor.name}s.`;break;case"value":this._tags.datasource=r}}onChange(e){return new Promise((i,r)=>{switch(e.type){case"tagremove":this._justAddedIndex=-1;const r=e.detail.index,s=t.Utils.clone(this.value),a=s.splice(r+1),n=s.splice(0,r);i(this.value=n.concat(a));break;case"tagadd":const o=e.detail.value,l=t.Utils.clone(this.value);if(!t.Utils.isNullOrEmpty(o)&&(this.allowDuplicates||t.Utils.isNullOrEmpty(l&&l.find(e=>this.mapEntityToViewValue(e)==this.mapEntityToViewValue(o))))){let e=(l||[]).concat([o]);i(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:i(this.value)}})}acceptValue(e){}};wi([t.Watch({converter:t.PropertyConverters.String})],ki.prototype,"hint",void 0),wi([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],ki.prototype,"allowDuplicates",void 0),wi([t.Watch({converter:t.PropertyConverters.Boolean})],ki.prototype,"allowNew",void 0),wi([t.Watch({converter:t.PropertyConverters.Number})],ki.prototype,"_justAddedIndex",void 0),wi([t.ViewChild(t.P+"-suggest")],ki.prototype,"_suggest",void 0),wi([t.ViewChild(t.P+"-repeater."+t.PCSS+"-tags")],ki.prototype,"_tags",void 0),ki=wi([t.CustomElement({tagName:t.P+"-tags",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<${t.P}-repeater class="${t.PCSS}-tags">\n <ul class="${t.PCSS}-tags ${t.PCSS}-viewfinder ${t.PCSS}-list list-unstyled list-inline">\n <template>\n <li class="${t.PCSS}-tag">\n <${t.P}-tag on-remove=":host._tagRemove(^index)" css-class="{{ { 'tag-in': :host._justAddedIndex === ^index } }}" tag="{{ :host.mapEntityToViewValue(^item) }}" readonly="{{ :host.readonly }}"></${t.P}-tag>\n </li>\n </template>\n <li class="tag-new">\n <${t.P}-suggest logger="{{ :host.logger }}" placeholder="{{ :host.placeholder }}" allow-new="{{ :host.allowNew }}" class="${t.PCSS}-tags" on-change=":host._tagAdd($this.value)" hint="{{ :host.hint, twoway }}">\n <${t.P}-content></${t.P}-content>\n </${t.P}-suggest>\n </li>\n </ul>\n</${t.P}-repeater>`})],ki);var Ui=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};let Ni=class extends _t{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,i,r){super.propertyChangedCallback(e,t,i,r),"rows"!==e&&"cols"!==e||this.inputField.setAttribute(e,i)}};Ui([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],Ni.prototype,"rows",void 0),Ui([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],Ni.prototype,"cols",void 0),Ui([t.ViewChild("textarea")],Ni.prototype,"_input",void 0),Ui([t.ViewChild(`span.${t.PCSS}-readonly`)],Ni.prototype,"_span",void 0),Ni=Ui([t.CustomElement({tagName:t.P+"-textarea",template:`<textarea class="${t.PCSS}-input" pacem></textarea>${T}<span class="${t.PCSS}-readonly"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></span>`,shadow:t.Defaults.USE_SHADOW_ROOT})],Ni);var Oi=function(e,t,i,r){var s,a=arguments.length,n=a<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,r);else for(var o=e.length-1;o>=0;o--)(s=e[o])&&(n=(a<3?s(n):a>3?s(t,i,n):s(t,i))||n);return a>3&&n&&Object.defineProperty(t,i,n),n};let xi=class extends _t{constructor(e=new i.Components.UI.MarkdownService){super(),this._md=e,this.rows=5,this.cols=50,this._keydownHandler=e=>{if(9===e.keyCode){const r=this.input,s=r.value;var i=r.selectionStart;r.value=s.substr(0,i)+" "+s.substr(i),t.preventDefaultHandler(e)}}}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,i,r){super.propertyChangedCallback(e,t,i,r),"rows"===e||"cols"===e?this.inputField.setAttribute(e,i):"viewValue"==e&&(this._markdown.innerHTML=i)}viewActivatedCallback(){super.viewActivatedCallback(),this.input.addEventListener("keydown",this._keydownHandler,!1)}disconnectedCallback(){this.input&&this.input.removeEventListener("keydown",this._keydownHandler,!1),super.disconnectedCallback()}};Oi([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],xi.prototype,"rows",void 0),Oi([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],xi.prototype,"cols",void 0),Oi([t.ViewChild("textarea")],xi.prototype,"input",void 0),Oi([t.ViewChild(`div.${t.PCSS}-readonly`)],xi.prototype,"_markdown",void 0),xi=Oi([t.CustomElement({tagName:t.P+"-textarea-markdown",template:`<textarea class="${t.PCSS}-input" pacem></textarea>${T}<div class="${t.PCSS}-readonly ${t.PCSS}-markdown"></div>`,shadow:t.Defaults.USE_SHADOW_ROOT})],xi);var Vi=Object.freeze({__proto__:null,BASIC_VALIDATOR_TEMPLATE:We,CHAR_COUNTER_CHILD:T,CONTENTELEMENT_BUTTONCOMMAND_TEMPLATE:K,CalendarDateUnselectEvent:Pe,get ChangePolicy(){return mt},ContenteditableDOMObserver:ce,ContenteditableUtils:de,DEFAULT_ATTRIBUTION:"",DEFAULT_TILES:"",FileChangeEvent:xt,FileChangeEventName:Ut,FileUploadEvent:Ot,FileUploadEventName:kt,FormEventEmitter:S,FormResetEvent:P,FormResetEventName:b,FormSubmitEvent:C,FormSubmitEventName:_,ImageFetchRequestEvent:Bt,ImageFetchRequestEventName:jt,get KnownExecCommand(){return re},get PacemAsyncValidatorElement(){return Je},PacemBaseElement:x,PacemBaseInputElement:yt,PacemBaseValidatorElement:Re,get PacemBinaryValidatorElement(){return qe},get PacemCalendarMonthPickerElement(){return Ce},get PacemCalendarPickerElement(){return Se},get PacemCalendarYearPickerElement(){return Ee},get PacemCharCountElement(){return R},get PacemCharsInputElement(){return Ct},get PacemCheckboxElement(){return Ue},get PacemCheckboxListElement(){return Oe},get PacemChildFormElement(){return De},get PacemChildFormPropagatorElement(){return Ve},get PacemColorInputElement(){return wt},get PacemCompareValidatorElement(){return ze},get PacemContenteditableAlignCommandElement(){return ue},PacemContenteditableButtonCommandElement:Y,PacemContenteditableCommandElement:B,get PacemContenteditableElement(){return q},get PacemContenteditableExecCommandElement(){return oe},get PacemContenteditableHistoryCommandElement(){return X},get PacemContenteditableImageCommandElement(){return ie},get PacemContenteditableLinkCommandElement(){return Q},get PacemContenteditablePlaceholderElement(){return ge},get PacemContenteditableWrapCommandElement(){return fe},get PacemCustomValidatorElement(){return Ye},get PacemDataItemElement(){return H},PacemDataSourceElement:A,get PacemDatetimePickerElement(){return Le},get PacemEditImageElement(){return Mt},get PacemEmailInputElement(){return St},get PacemFormElement(){return k},get PacemFormFieldElement(){return Xe},PacemFormRelevantElement:$,get PacemGeolocateElement(){return Qe},get PacemHiddenInputElement(){return At},get PacemHierarchyElement(){return ut},get PacemImageInputElement(){return zt},PacemItemElement:V,PacemItemsContainerBaseElement:D,get PacemLatLngElement(){return ai},get PacemLengthValidatorElement(){return Be},get PacemMarkdownTextAreaElement(){return xi},PacemModelElement:O,get PacemNameValueListElement(){return ci},get PacemNumberInputElement(){return Jt},PacemOrdinalInputElement:ft,get PacemPasswordInputElement(){return Kt},get PacemPropertyPickerElement(){return hi},get PacemRadioElement(){return ui},get PacemRadioListElement(){return vi},get PacemRangeValidatorElement(){return Me},get PacemRegexValidatorElement(){return je},get PacemRequiredValidatorElement(){return Fe},get PacemSearchInputElement(){return Xt},get PacemSelectElement(){return yi},get PacemSliderElement(){return _i},get PacemSnapshotElement(){return It},get PacemSuggestElement(){return Pi},get PacemTagElement(){return $i},get PacemTagsElement(){return ki},get PacemTelInputElement(){return Qt},get PacemTextAreaElement(){return Ni},get PacemTextInputElement(){return ti},PacemTextualInputElement:_t,get PacemUploadElement(){return Dt},get PacemUrlInputElement(){return ri},Picture:class{},get SnapshotStep(){return Rt}}),Di=Object.freeze({__proto__:null,Scaffolding:Vi}),Hi=Object.freeze({__proto__:null,Components:Di,Scaffolding:y});e.DeepMerger.merge(Hi)}(Pacem,Pacem,Pacem,Pacem);
|
|
6
|
+
!function(e,t,i,a){"use strict";const r="change";class FieldChangeEvent extends t.CustomTypedEvent{constructor(e){super(r,e,{bubbles:!0,cancelable:!1})}}var s;!function(e){e.String="string",e.Number="number",e.Datetime="datetime",e.Boolean="boolean",e.Binary="binary",e.Object="object"}(s||(s={}));class ApiParserBase{async load(e,t){let i=await fetch(e,{mode:"cors",credentials:"omit",headers:t});try{let t=await i.json();return this.parse(t,e)}catch(e){return null}}}const n=/^#\/(definitions|components\/schemas)\/(.+)$/;const o=t.Net.HttpMethod;class SwaggerParser extends 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 a=i;let r={};for(let e in a.definitions){r[this._findDefinitionName(e)]=a.definitions[e]}let s="";if(a.host&&a.schemes.length>0)s=a.schemes[0]+"://"+a.host+a.basePath;else if(t){let e=/^(https?):\/\/([^\/]+)/.exec(t);e&&e.length&&(!a.schemes&&e.length>1&&(a.schemes=[e[1]]),!a.host&&e.length>2&&(a.host=e[2],a.basePath=""),s=e[0])}else console.warn("Not able to find a base url from the OpenApi specs.");let n={endpoints:[],definitions:r,baseUrl:s};for(let e in a.paths){let t=a.paths[e];for(let i of[o.Get,o.Delete,o.Post,o.Put]){let r=t[i.toLowerCase()];if(r){let t=this._tryGetEndpoint(a,r,e,i);n.endpoints.push(t)}}}return n}_tryGetEndpoint(e,t,i,a){return{response:this._tryGetResponse(e,t),path:i,method:a,parameters:this._tryGetParameters(e,t)}}_translateType(e,t){switch(e){case"number":case"integer":return s.Number;case"boolean":return s.Boolean;case"string":switch(t){case"date":case"date-time":return s.Datetime;case"byte":return s.Binary;case"binary":throw"Binary octets not supported."}return s.String}return s.String}_tryGetParameters(e,t){return(t.parameters||[]).map(t=>{const i=t;let a={name:i.name,required:i.required||!1},r=t.type;if(t.schema){let i=t;a.type=s.Object;let r=a.fullType=this._findDefinitionName(i.schema.$ref);a.meta=e.definitions[r]}else r&&(a.type=this._translateType(r,t.format));return a})}_tryGetResponse(e,t){let i=t.responses[200];if(!i||!i.schema)return null;let a,r,s=i.schema.type||"object";return i.schema.$ref?(r=this._findDefinitionName(i.schema.$ref),a=e.definitions[r]):(a=i.schema,i.schema.items&&(i.schema.items.hasOwnProperty("$ref")?(r=this._findDefinitionName(i.schema.items.$ref),a=e.definitions[r]):a=i.schema.items)),{type:s,fullType:r,meta:a}}}class OpenApi3Parser extends ApiParserBase{parse(e,t){let i=e;"string"==typeof i&&(i=JSON.parse(i));const a=i,r=[],s=this._gatherDefinitions(new Map,a.components.schemas);for(let e in a.paths)for(let t in a.paths[e]){const i=a.paths[e][t];r.push({path:e,method:t.toUpperCase(),parameters:this._convertToApiParameters(i.parameters),response:this._tryGetResponse(s,i.responses)})}return{endpoints:r,definitions:s,baseUrl:t}}_convertToApiParameters(e=[]){const t=[];for(let i of e){const e=i.schema;"type"in e&&t.push({name:i.name,required:i.required,type:this._translateType(e.type,e.format)})}return t}_translateType(e,t){switch(e){case"number":case"integer":return s.Number;case"boolean":return s.Boolean;case"string":switch(t){case"date":case"date-time":return s.Datetime;case"byte":return s.Binary;case"binary":throw"Binary octets not supported."}return s.String}return s.String}_gatherDefinitions(e,t){const i={};for(let a in t)i[a]=this._findDefinition(e,t,a);return i}_findDefinition(e,t,i){if(e.has(i))return e.get(i);if(i in t){const a=t[i];return e.set(i,a),a}return null}_findDefinitionName(e){var t=/#\/components\/schemas\/(.+)/.exec(e);return null==t||t.length<2?e:t[1]}_tryGetResponse(e,i){let a,r={responses:i}.responses[200];if(t.Utils.isNullOrEmpty(r&&r.content))return null;for(let e in r.content){a=r.content[e].schema;break}let s,n,o="object";return"$ref"in a?(n=this._findDefinitionName(a.$ref),s=e[n]):(o=a.type,s=a,"array"===a.type&&("$ref"in a.items?(n=this._findDefinitionName(a.items.$ref),s=e[n]):s=a.items)),{type:o,fullType:n,meta:s}}}var l=Object.freeze({__proto__:null,get ApiParameterType(){return s},ApiParserBase:ApiParserBase,OpenApi3Parser:OpenApi3Parser,OpenApiParser:class OpenApiParser extends ApiParserBase{constructor(e=new OpenApi3Parser,t=new SwaggerParser){super(),this._openApi3=e,this._swagger=t}parse(e,t){let i=e;"string"==typeof i&&(i=JSON.parse(i));const a=i;return"openapi"in a?this._openApi3.parse(a,t):this._swagger.parse(a,t)}},SwaggerParser:SwaggerParser,getOpenApiDefinition:function(e,t){var i=n.exec(t);return i&&i.length>2?{name:i[2],schema:e.definitions[i[2]]}:null}}),c=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};const d={display:(e,t,i)=>i[`${e}_${t}`],validator:(e,t,i,a)=>a["validator_"+e+"_"+i]??a["validator_"+e+t+"_"+i],commandTooltip:(e,t)=>t["command_tooltip_"+e]};class Forms{static localizeMetadata(e,t,i){return Forms._localizeMetadata(e,t,i)}static _localizeMetadata(e,i,a,r=""){a=t.Utils.extend({},d,a);for(let s of e.props){if("props"in s&&"object"==typeof s.props&&!t.Utils.isArray(s.props)){const e=r+s.prop+".";s.props=Forms._localizeMetadata(s.props,i,a,e)}const e=s.display=s.display??{},n=r+s.prop;if(e.name=a.display("name",n,i)??e.name,e.watermark=a.display("watermark",n,i)??e.watermark,e.description=a.display("description",n,i)??e.description,!t.Utils.isNullOrEmpty(s.commands))for(let e of s.commands){const r=a.commandTooltip(e.name,i);t.Utils.isNullOrEmpty(r)||(e.tooltip=r)}if(!t.Utils.isNullOrEmpty(s.validators)){const e={};for(let r of s.validators){const s=r.type;if("string"==typeof s){const o=e[s]=(e[s]??-1)+1,l=a.validator(s,o,n,i);t.Utils.isNullOrEmpty(l)||(r.errorMessage=l)}}}}return e}}c([t.Transformer("forms.localizeMetadata")],Forms,"localizeMetadata",null);var h=Object.freeze({__proto__:null,Forms:Forms}),p=Object.freeze({__proto__:null,FieldChangeEvent:FieldChangeEvent,FieldChangeEventName:r,L10n:h,OpenApi:l}),u=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};const m="submit",v="reset";class FormSubmitEvent extends t.CustomTypedEvent{constructor(e){super(m,e,{bubbles:!0,cancelable:!0})}}class FormResetEvent extends Event{constructor(){super(v,{bubbles:!0,cancelable:!0})}}const g=["download",r,t.CommandEventName],y=!1;class FormEventEmitter{constructor(e){this._element=e,this._itemEmitHandler=e=>{if(this._element.handle(e),e.type===t.CommandEventName){const t=e;this._element.handle(new CustomEvent("item"+t.detail.commandName.toLowerCase(),{detail:t.detail.commandArgument}))}}}start(){g.forEach(e=>this._element.addEventListener(e,this._itemEmitHandler,!1))}stop(){g.forEach(e=>this._element.removeEventListener(e,this._itemEmitHandler,!1))}}class PacemFormRelevantElement extends t.Components.PacemElement{viewActivatedCallback(){super.viewActivatedCallback(),this.form=t.CustomElementUtils.findAncestorOfType(this,f)}}u([t.Watch({converter:t.PropertyConverters.Element})],PacemFormRelevantElement.prototype,"form",void 0);let f=class PacemFormElement extends PacemFormRelevantElement{constructor(){super("form"),this.method=t.Net.HttpMethod.Post,this._emitter=null,this._buttons={submit:void 0,reset:void 0},this.#e=!1,this._keyupHandler=e=>{if(!(13!==e.keyCode||e.shiftKey||e.ctrlKey||e.altKey||e.metaKey)){let i=e.currentTarget.querySelector(t.P+"-button[type=submit]");t.Utils.isNull(i)||!t.Utils.isVisible(i)||i.disabled||i.click()}},this._submit=(e,i)=>{t.Utils.isNull(i)||t.avoidHandler(i),Promise.all(this._validateAllFields()).then(t=>{-1===t.findIndex(e=>!1===e)&&this.submit(e).then(e=>{this.setPristine()},e=>{})})},this._reset=e=>{t.Utils.isNull(e)||t.avoidHandler(e);var i=new FormResetEvent;if(this.dispatchEvent(i),!i.defaultPrevented){for(var a in this._fields){var r=this._fields[a];r instanceof PacemModelElement&&r.reset()}for(var s of this._subForms)s._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,i=t.watch;if("invalid"===e.detail.propertyName){let e=this._fields[t.watch];t.invalid?e.valid=!1:this._checkFieldValidity(i)}else this._checkFieldValidity(i)},this.suddenValidation=!0,this.resettable=!0,this._emitter=new FormEventEmitter(this)}propertyChangedCallback(e,i,a,r){super.propertyChangedCallback(e,i,a,r),("method"===e&&!0===this.autogenerate&&!t.Utils.isNullOrEmpty(this.metadata)||"metadata"===e&&!0===this.autogenerate||"autogenerate"===e&&!0===a&&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 e="_"+t.Utils.uniqueCode(),i=this.id=this.id||e,a="fetch"+e,r=document.createElement("form");r.id="form"+e,r.className=t.PCSS+"-form",r.setAttribute("pacem",""),r.setAttribute("novalidate","");const s=`<${t.P}-repeater datasource="{{ #${i}.metadata && (#${i}.metadata.props || #${i}.metadata) }}">\n <${t.P}-panel css="{{ #${i}.metadata.display && #${i}.metadata.display.css }}" css-class="{{ (#${i}.metadata.display && #${i}.metadata.display.cssClass || []).concat(#${i}.suddenValidation ? [] : ['lazy-validation']) }}" class="${t.PCSS}-animatable-list ${t.PCSS}-list-appear">\n <template>\n <${t.P}-form-field fetch-credentials="{{ #${i}.fetchCredentials }}" fetch-headers="{{ #${i}.fetchHeaders }}"\n logger="{{ #${i}.logger }}" entity="{{ #${i}.entity, twoway }}" \n metadata="{{ ^item }}" readonly="{{ #${i}.readonly || ^item.isReadOnly }}"></${t.P}-form-field>\n </template>\n </${t.P}-panel>\n</${t.P}-repeater>\n<${t.P}-fetch logger="{{ #${i}.logger }}" id="${a}" method="${this.method}" credentials="{{ #${i}.fetchCredentials }}" headers="{{ #${i}.fetchHeaders }}"></${t.P}-fetch> \n<div class="${t.PCSS}-buttonset buttons">\n <div class="buttonset-left">\n <${t.P}-button logger="{{ #${i}.logger }}" on-click="#${i}._submit(#${i}.fetcher || #${a}, $event)" type="submit" hide="{{ #${i}.readonly || $pacem.isNullOrEmpty(#${i}.action) || !$pacem.isNull(#${i}.form) }}"\nclass="button primary button-size size-small"\ncss-class="{{ {'buttonset-last': !#${i}.resettable || !#${i}.dirty || !$pacem.isNull(#${i}.form) } }}" \ndisabled="{{ (#${i}.suddenValidation && (!(#${i}.valid && #${i}.dirty))) || #${i}.fetching }}">\n <${t.P}-panel class="submit-spinner ${t.PCSS}-anim anim-pop" hide="{{ !#${i}.fetching }}"><i class="${t.PCSS}-icon ${t.PCSS}-anim anim-rotate rotate-uniform display-block">refresh</i></${t.P}-panel>\n <${t.P}-text text="{{ #${i}.submitCaption || 'OK' }}"></${t.P}-text>\n </${t.P}-button>\n <${t.P}-button logger="{{ #${i}.logger }}" on-click="#${i}._reset($event)" type="reset" class="button button-size size-small" css-class="{{ {'buttonset-first': #${i}.readonly || $pacem.isNullOrEmpty(#${i}.action) || !$pacem.isNull(#${i}.form)} }}" hide="{{ !#${i}.resettable || #${i}.readonly || !#${i}.dirty || !$pacem.isNull(#${i}.form) }}" disabled="{{ #${i}.fetching }}">\n <${t.P}-text text="{{ #${i}.resetCaption || 'Reset' }}"></${t.P}-text>\n </${t.P}-button>\n</div></div>`;r.innerHTML=s,this.innerHTML="",this.appendChild(r),r.addEventListener("submit",t.avoidHandler,!1);const n=this._buttons,o=this._buttons={submit:r.lastElementChild.firstElementChild.firstElementChild,reset:r.lastElementChild.firstElementChild.lastElementChild};this.dispatchEvent(new t.PropertyChangeEvent({propertyName:"formButtons",currentValue:o,oldValue:n}))}get formButtons(){return this._buttons}#e;get fetching(){return this.#e}submit(e){return new Promise((i,a)=>{t.Utils.isNull(e)&&a("Fetcher cannot be null while submitting a form."),this._submitInternally(e).then(e=>{this.dispatchEvent(new CustomEvent("success",{detail:e})),i(e)},e=>{e!==y&&this.dispatchEvent(new CustomEvent("fail",{detail:e})),a(e)})})}reset(){this._reset()}_submitInternally(e,i){if(t.Utils.isNull(e))throw"Fetcher cannot be null while submitting a form.";var a=t.DeferPromise.defer();const r=this.entity,s=this.entityName;var n={};t.Utils.isNullOrEmpty(s)?n=r:n[s]=r;i={parameters:n,fields:this._getAllFields()};var o=new FormSubmitEvent(i);if(this.dispatchEvent(o),o.defaultPrevented)a.reject(y);else{e.parameters=t.Utils.extend({},o.detail.parameters);const i=n=>{e.removeEventListener(t.Net.FetchSuccessEventName,i,!1),e.removeEventListener(t.Net.FetchErrorEventName,s,!1);const o=n.detail;if(t.Net.Fetcher.isEmpty(o)&&(e.removeEventListener(t.Net.FetchResultEventName,r,!1),this.success=!0,a.resolve({})),205===o.status)this._reset()},r=i=>{e.removeEventListener(t.Net.FetchResultEventName,r,!1);var s=i.detail;"object"==typeof s&&s.hasOwnProperty("success")?!0===s.success?(this.success=!0,a.resolve(s.result||{})):(this.fail=!0,a.reject(s.error)):(this.success=!0,a.resolve(s))},s=n=>{e.removeEventListener(t.Net.FetchSuccessEventName,i,!1),e.removeEventListener(t.Net.FetchResultEventName,r,!1),e.removeEventListener(t.Net.FetchErrorEventName,s,!1),this.fail=!0;const o=n.detail;a.reject(o)},n=i=>{if("fetching"===i.detail.propertyName)!0===i.detail.currentValue?(t.Utils.addClass(this,t.PCSS+"-fetching"),this.#e=!0,this.dispatchEvent(new t.PropertyChangeEvent({currentValue:!0,oldValue:!1,propertyName:"fetching"}))):(this.#e=!1,this.dispatchEvent(new t.PropertyChangeEvent({currentValue:!1,oldValue:!0,propertyName:"fetching"})),t.Utils.removeClass(this,t.PCSS+"-fetching"),e.removeEventListener(t.PropertyChangeEventName,n,!1))};e.addEventListener(t.PropertyChangeEventName,n,!1),e.addEventListener(t.Net.FetchSuccessEventName,i,!1),e.addEventListener(t.Net.FetchResultEventName,r,!1),e.addEventListener(t.Net.FetchErrorEventName,s,!1),t.Utils.isNullOrEmpty(this.action)||(e.url=this.action),e instanceof t.Components.PacemFetchElement&&!e.autofetch&&e.fetch(),this.success=this.fail=!1}return a.promise}_getAllFields(e={}){for(var i of(t.Utils.extend(e,this._fields),this._subForms))i._getAllFields(e);return e}apply(e){if(!t.Utils.isNullOrEmpty(e)){this.entity=t.Utils.extend({},this.entity,e);for(let t in e)this.setDirty(t)}}setPristine(...e){this._setAs(!1,...e)}setDirty(...e){this._setAs(!0,...e)}_setAs(e,...i){const a=!t.Utils.isEmpty(i);for(let t in this._fields)if(!a||i.indexOf(t)>=0){const i=this._fields[t];i instanceof PacemModelElement&&(e?i.setDirty():i.setPristine())}for(let t of this._subForms)e?t.setDirty(...i):t.setPristine(...i)}_checkFieldValidity(e){return this.suddenValidation?e in this._fields?this._validateField(e,!1):Promise.resolve(!1):Promise.resolve(null)}validate(e){return t.Utils.isNullOrEmpty(e)?Promise.all(this._validateAllFields()).then(e=>!e.some(e=>!1===e)):this._validateField(e,!1)}_validateAllFields(e=!0){const t=[];for(let i in this._fields)t.push(this._validateField(i,e));for(let i of this._subForms)Array.prototype.push.apply(t,i._validateAllFields(e));return t}_validateField(e,i){return new Promise((a,r)=>{var s=this._fields[e];if(s){var n=this._validators[s.name];n&&n.length>0?(this.log(t.Logging.LogLevel.Log,`Computing "${s.name}" validity.`),Promise.all(n.map(e=>e.validate(s.value).then(t=>!(e.invalid=!t)))).then(e=>{let r=!0;for(var n of e)if(!1===n){r=!1,i&&s.setDirty();break}this.log(t.Logging.LogLevel.Log,`Property "${s.name}" turns out to be ${r?"":"not "}valid.`),a(s.valid=r)})):(this.log(t.Logging.LogLevel.Log,`Property "${s.name}" has no validators.`),a(s.valid=!0))}else this.log(t.Logging.LogLevel.Log,`Property "${e}" has no fields in this form.`),a(!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 i of this._subForms)if(i.dirty){e=!0;break}this.dirty=e}_checkValidity(){let e=!0;for(var i in this._fields)if(this.log(t.Logging.LogLevel.Log,`Checking "${i}" validity.`),!1===this._fields[i].valid){this.log(t.Logging.LogLevel.Log,`"${i}" is not valid.`),e=!1;break}if(!0===e)for(var a of this._subForms)if(!a.valid){e=!1;break}this.valid=e}registerSubForm(e){let i=this._subForms;-1==i.indexOf(e)&&(e.addEventListener(t.PropertyChangeEventName,this._fieldPropertyChanged,!1),i.push(e),this._checkValidity(),this._checkDirtyness())}unregisterSubForm(e){let i=this._subForms,a=i.indexOf(e);a>=0&&(e.removeEventListener(t.PropertyChangeEventName,this._fieldPropertyChanged,!1),i.splice(a,1),this._checkValidity(),this._checkDirtyness())}registerField(e,i){var a=this._fields;a[e]!=i&&(this.unregisterField(e,!1),a[e]=i,this.log(t.Logging.LogLevel.Log,`Registering "${e}" field.`),i instanceof HTMLElement&&i.addEventListener(t.PropertyChangeEventName,this._fieldPropertyChanged,!1),this._checkFieldValidity(e),this._checkDirtyness())}unregisterField(e,i=!0){var a=this._fields,r=a[e];r instanceof HTMLElement&&r.removeEventListener(t.PropertyChangeEventName,this._fieldPropertyChanged,!1),delete a[e],r&&!0===i&&(this._checkValidity(),this._checkDirtyness())}registerValidator(e,i){var a=this._validators[e]=this._validators[e]||[];-1==a.indexOf(i)&&(a.push(i),i instanceof HTMLElement&&i.addEventListener(t.PropertyChangeEventName,this._validatorPropertyChanged,!1),this.log(t.Logging.LogLevel.Log,`Calling "${e}" validity check after validator registration.`),this._checkFieldValidity(e))}unregisterValidator(e,t){this._unregisterValidator(e,t,!0)}_unregisterValidator(e,i,a){var r=this._validators[e]=this._validators[e]||[],s=r.indexOf(i);s>=0&&(i instanceof HTMLElement&&i.removeEventListener(t.PropertyChangeEventName,this._validatorPropertyChanged,!1),r.splice(s,1),a&&this._checkFieldValidity(e))}};u([t.Watch({emit:!1,converter:t.PropertyConverters.Element})],f.prototype,"fetcher",void 0),u([t.Watch({emit:!1,converter:t.PropertyConverters.String})],f.prototype,"fetchCredentials",void 0),u([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],f.prototype,"fetchHeaders",void 0),u([t.Watch({reflectBack:!0,converter:t.PropertyConverters.String})],f.prototype,"method",void 0),u([t.Watch({reflectBack:!0,converter:t.PropertyConverters.String})],f.prototype,"submitCaption",void 0),u([t.Watch({reflectBack:!0,converter:t.PropertyConverters.String})],f.prototype,"resetCaption",void 0),u([t.Debounce(100)],f.prototype,"_buildUpForm",null),u([t.Watch({reflectBack:!0,converter:t.PropertyConverters.Boolean})],f.prototype,"valid",void 0),u([t.Watch({reflectBack:!0,converter:t.PropertyConverters.Boolean})],f.prototype,"dirty",void 0),u([t.Watch({reflectBack:!0,converter:t.PropertyConverters.Boolean})],f.prototype,"readonly",void 0),u([t.Watch({converter:t.PropertyConverters.Boolean})],f.prototype,"success",void 0),u([t.Watch({converter:t.PropertyConverters.Boolean})],f.prototype,"fail",void 0),u([t.Watch({converter:t.PropertyConverters.Json})],f.prototype,"entity",void 0),u([t.Watch({emit:!1,converter:t.PropertyConverters.String})],f.prototype,"entityName",void 0),u([t.Watch()],f.prototype,"metadata",void 0),u([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],f.prototype,"autogenerate",void 0),u([t.Watch({converter:t.PropertyConverters.Boolean})],f.prototype,"suddenValidation",void 0),u([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],f.prototype,"resettable",void 0),u([t.Watch({converter:t.PropertyConverters.String})],f.prototype,"action",void 0),f=u([t.CustomElement({tagName:t.P+"-form"})],f);var _=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};const b="pacem:model:original-value";class PacemModelElement extends PacemFormRelevantElement{viewActivatedCallback(){super.viewActivatedCallback(),this._registerFieldConditionally(),this._setAsOriginalValue(this.value)}_registerFieldConditionally(){const e=this.name,i=this.form;if(!(t.Utils.isNullOrEmpty(e)||t.Utils.isNull(i)||this.hasAttribute("autobind")&&("off"===this.getAttribute("autobind")||"false"===this.getAttribute("autobind"))||(i.registerField(e,this),this.hasAttribute("value")))){const a=i.id=i.id||"frm_"+t.Utils.uniqueCode();this.setAttribute("value",`{{ #${a}.entity.${e}, twoway }}`)}}propertyChangedCallback(e,i,a,r){switch(super.propertyChangedCallback(e,i,a,r),e){case"value":this.viewValue=this.getViewValue(a);break;case"valid":a?t.Utils.removeClass(this,t.PCSS+"-invalid"):t.Utils.addClass(this,t.PCSS+"-invalid");break;case"dirty":a?t.Utils.addClass(this,t.PCSS+"-dirty"):t.Utils.removeClass(this,t.PCSS+"-dirty");break;case"name":let e=this.form;null!=e&&i&&e.unregisterField(i),this._registerFieldConditionally();break;case"form":let r=this.name;t.Utils.isNullOrEmpty(r)||null!=i&&i.unregisterField(r),this._registerFieldConditionally()}}disconnectedCallback(){let e=this.name,i=this.form;t.Utils.isNullOrEmpty(e)||t.Utils.isNull(i)||i.unregisterField(e),super.disconnectedCallback()}get originalValue(){return t.CustomElementUtils.getAttachedPropertyValue(this,b)}_setAsOriginalValue(e){t.CustomElementUtils.setAttachedPropertyValue(this,b,e)}reset(){this.value=this.originalValue,this.dirty=!1}setPristine(){this._setAsOriginalValue(this.value),this.dirty=!1}setDirty(){this.dirty=!0}}_([t.Watch({converter:t.PropertyConverters.String})],PacemModelElement.prototype,"viewValue",void 0),_([t.Watch({converter:{convert:(e,t)=>t instanceof PacemModelElement?t.convertValueAttributeToProperty(e):e,convertBack:e=>e.toString()}})],PacemModelElement.prototype,"value",void 0),_([t.Watch({converter:t.PropertyConverters.Boolean})],PacemModelElement.prototype,"dirty",void 0),_([t.Watch({converter:t.PropertyConverters.Boolean})],PacemModelElement.prototype,"valid",void 0),_([t.Watch({converter:t.PropertyConverters.String})],PacemModelElement.prototype,"name",void 0);class PacemBaseElement extends PacemModelElement{constructor(){super(...arguments),this.focusHandler=e=>{const i=(e=!0)=>{t.Utils.hasClass(this.parentElement,"."+t.PCSS+"-fieldgroup")&&(e?t.Utils.addClass:t.Utils.removeClass).apply(this,[this.parentElement,t.PCSS+"-focus"])};switch(e.type){case"focus":t.Utils.addClass(this,t.PCSS+"-focus"),i(),this._preFocusValue=this.value;break;case"blur":t.Utils.removeClass(this,t.PCSS+"-focus"),i(!1)}e.bubbles?this.emit(e):this.dispatchEvent(new FocusEvent(e.type))},this.changeHandler=e=>{const t=this.value;this.onChange(e).then(e=>{this.compareValuePropertyValues(t,e)||(this.dispatchEvent(new FieldChangeEvent({fieldName:this.name,oldValue:t,currentValue:e,firstChange:!this.dirty})),this.dirty=!0)},e=>{})},this.keydownHandler=e=>{t.stopPropagationHandler(e)},this.keyupHandler=e=>{switch(e.keyCode){case 27:t.stopPropagationHandler(e),this.compareValuePropertyValues(this.originalValue,this._preFocusValue)?this.reset():this.value=this._preFocusValue,this.blur();break;case 13:this.preventKeyboardSubmit&&t.stopPropagationHandler(e)}}}compareValuePropertyValues(e,i){return t.DefaultComparer(e,i)}get preventKeyboardSubmit(){return!1}propertyChangedCallback(e,i,a,r){switch(super.propertyChangedCallback(e,i,a,r),e){case"required":case"disabled":case"autofocus":case"placeholder":case"readonly":for(let t of this.inputFields)a?t.setAttribute(e,a):t.removeAttribute(e);break;case"tabOrder":for(let e of this.inputFields)e.setAttribute("tabindex",a);break;case"value":this.acceptValue(a)}if("required"===e||"disabled"===e||"readonly"===e){let i=`${t.PCSS}-${e}`;a?t.Utils.addClass(this,i):t.Utils.removeClass(this,i)}"readonly"===e?this.toggleReadonlyView(a):"required"===e?this.aria.attributes.set("required",!!a+""):"valid"===e&&this.aria.attributes.set("invalid",(!a&&!!this.dirty)+"")}registerInputFields(e=this.inputFields){t.Utils.isNull(e)||t.Utils.isArray(e)||(e=[e]);for(let i of e)i.addEventListener("focus",this.focusHandler,!1),i.addEventListener("blur",this.focusHandler,!1),i.addEventListener("change",this.changeHandler,!1),i.addEventListener("keydown",this.keydownHandler,!1),i.addEventListener("keyup",this.keyupHandler,!1),i.addEventListener("mousedown",t.stopPropagationHandler,!1),i.addEventListener("touchstart",t.stopPropagationHandler,{passive:!1,capture:!1})}unregisterInputFields(e=this.inputFields){t.Utils.isNull(e)||t.Utils.isArray(e)||(e=[e]);for(let i of e)t.Utils.isNull(i)||(i.removeEventListener("touchstart",t.stopPropagationHandler,{capture:!1}),i.removeEventListener("keydown",this.keydownHandler,!1),i.removeEventListener("keyup",this.keyupHandler,!1),i.removeEventListener("mousedown",t.stopPropagationHandler,!1),i.removeEventListener("change",this.changeHandler,!1),i.removeEventListener("focus",this.focusHandler,!1),i.removeEventListener("blur",this.focusHandler,!1))}viewActivatedCallback(){if(super.viewActivatedCallback(),this.toggleReadonlyView(this.readonly||!1),!t.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 e=this.inputFields;if(!t.Utils.isNullOrEmpty(e))for(let t of e)t.blur()}}_([t.Watch({converter:t.PropertyConverters.Boolean})],PacemBaseElement.prototype,"required",void 0),_([t.Watch({converter:t.PropertyConverters.Boolean})],PacemBaseElement.prototype,"autofocus",void 0),_([t.Watch({converter:t.PropertyConverters.Boolean})],PacemBaseElement.prototype,"readonly",void 0),_([t.Watch({converter:t.PropertyConverters.String})],PacemBaseElement.prototype,"name",void 0),_([t.Watch({converter:t.PropertyConverters.String})],PacemBaseElement.prototype,"placeholder",void 0);class PacemItemElement extends t.Components.PacemElement{#t;findContainer(){return t.CustomElementUtils.findAncestor(this,e=>e instanceof PacemItemsContainerBaseElement)}get container(){return this.#t}viewActivatedCallback(){super.viewActivatedCallback();const e=this.#t=this.findContainer();t.Utils.isNull(e)||e.register(this)}disconnectedCallback(){t.Utils.isNull(this.#t)||this.#t.unregister(this),super.disconnectedCallback()}}class PacemItemsContainerBaseElement extends PacemBaseElement{register(e){let i=!0;return t.Utils.isNull(this.items)?this.items=[e]:-1===this.items.indexOf(e)?this.items.push(e):i=!1,i}unregister(e){const i=!t.Utils.isNull(this.items)&&this.items.indexOf(e);return i>=0&&(this.items.splice(i,1)[0],!0)}}_([t.Watch()],PacemItemsContainerBaseElement.prototype,"items",void 0);let C=class PacemDataItemElement extends PacemItemElement{};_([t.Watch({converter:{convert:(e,i)=>{if("true"===e)return!0;if("false"===e)return!1;let a=parseFloat(e);if(!isNaN(a))return a;let r=t.Utils.Dates.parse(e);return t.Utils.Dates.isDate(r)?r:e},convertBack:e=>e.toString()}})],C.prototype,"value",void 0),_([t.Watch({converter:t.PropertyConverters.String})],C.prototype,"label",void 0),_([t.Watch({converter:t.PropertyConverters.Boolean})],C.prototype,"disabled",void 0),C=_([t.CustomElement({tagName:t.P+"-data-item"})],C);class PacemDataSourceElement extends PacemItemsContainerBaseElement{constructor(e=!1){super(),this.multipleChoice=e,this._itemPropertyChangedHandler=e=>{this.databind()}}register(e){const i=super.register(e);return i&&e.addEventListener(t.PropertyChangeEventName,this._itemPropertyChangedHandler,!1),i}unregister(e){const i=super.register(e);return i&&e.removeEventListener(t.PropertyChangeEventName,this._itemPropertyChangedHandler,!1),i}buildAdaptedDatasource(e=this.datasource){return e&&e.map(e=>this.mapEntityToItem(e))}databind(e=this.buildAdaptedDatasource(this.datasource)){if(t.Utils.isNull(e)&&t.Utils.isNull(this.adaptedDatasource))return;const i=this.adaptedDatasource=e||[];t.Utils.isNullOrEmpty(i.filter(e=>this.isDataSourceItemSelected(e)))&&this.handleDatasourceMismatch(i)}handleDatasourceMismatch(e){this.value=void 0}isItemSelected(e,i=this.value){if(t.Utils.isNullOrEmpty(i))return!1;const a=this.mapEntityToValue(e),r=this.compareBy;return this.multipleChoice&&t.Utils.isArray(i)?!t.Utils.isNull(i.find(e=>e==a||"object"==typeof e&&!t.Utils.isNullOrEmpty(r)&&r in a&&r in e&&a[r]==e[r])):!this.multipleChoice&&(i==a||"object"==typeof i&&!t.Utils.isNullOrEmpty(r)&&r in a&&r in i&&a[r]==i[r])}isDataSourceItemSelected(e,i=this.value){if(t.Utils.isNullOrEmpty(i))return!1;if(e.disabled)return!1;const a=this.compareBy;if(this.multipleChoice&&t.Utils.isArray(i)){let r=i.find(i=>i==e.value||"object"==typeof i&&!t.Utils.isNullOrEmpty(a)&&a in i&&!t.Utils.isNullOrEmpty(e.value)&&a in e.value&&i[a]==e.value[a]);return!t.Utils.isNull(r)}return!this.multipleChoice&&!t.Utils.isNullOrEmpty(e.value)&&(i==e.value||"object"==typeof i&&!t.Utils.isNullOrEmpty(a)&&a in i&&!t.Utils.isNullOrEmpty(e.value)&&a in e.value&&i[a]==e.value[a])}mapEntityToValue(e){if(null==e)throw"entity cannot be null";if(e instanceof C)return e.value;let t,i=e;return(t=this.valueProperty)&&(i=e[t]),i}mapEntityToViewValue(e){if(null==e)throw"entity cannot be null";if(e instanceof C)return e.label||e.value;let t,i=e.toString();return(t=this.textProperty)&&(i=e[t]),i}mapEntityToItem(e){if(null==e)throw"entity cannot be null";if(e instanceof C)return{value:e.value,viewValue:e.label||e.value,disabled:e.disabled,data:e};let i=!1;const a=this.disabledProperty;return t.Utils.isNullOrEmpty(a)||(i=e[a]||!1),{value:this.mapEntityToValue(e),viewValue:this.mapEntityToViewValue(e),disabled:i,data:e}}propertyChangedCallback(e,t,i,a){switch(super.propertyChangedCallback(e,t,i,a),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(e){if(!t.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(e,i){return t.DefaultComparer(e,i)}}_([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],PacemDataSourceElement.prototype,"datasource",void 0),_([t.Watch({emit:!1,converter:t.PropertyConverters.String})],PacemDataSourceElement.prototype,"valueProperty",void 0),_([t.Watch({emit:!1,converter:t.PropertyConverters.String})],PacemDataSourceElement.prototype,"textProperty",void 0),_([t.Watch({emit:!1,converter:t.PropertyConverters.String})],PacemDataSourceElement.prototype,"disabledProperty",void 0),_([t.Watch({emit:!1,converter:t.PropertyConverters.String})],PacemDataSourceElement.prototype,"compareBy",void 0),_([t.Watch({converter:t.PropertyConverters.Json})],PacemDataSourceElement.prototype,"adaptedDatasource",void 0),_([t.Debounce(!0)],PacemDataSourceElement.prototype,"databind",null);var P=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};const E=`<${t.P}-char-count hide="{{ :host.readonly || !(:host.minlength > 0 || :host.maxlength > 0) }}" minlength="{{ :host.minlength }}" maxlength="{{ :host.maxlength }}" string="{{ :host.value }}"></${t.P}-char-count>`;let w=class PacemCharCountElement extends t.Components.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}};P([t.Watch({converter:t.PropertyConverters.Number})],w.prototype,"minlength",void 0),P([t.Watch({converter:t.PropertyConverters.Number})],w.prototype,"maxlength",void 0),P([t.Watch({converter:t.PropertyConverters.String})],w.prototype,"string",void 0),w=P([t.CustomElement({tagName:t.P+"-char-count",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<${t.P}-panel class="${t.PCSS}-char-count" css-class="{{ {'valid': :host._isValid(:host.string), 'invalid': !:host._isValid(:host.string) } }}">\n <${t.P}-span hide="{{ !(:host.minlength > 0) }}" class="${t.PCSS}-char-min" content="{{ :host.minlength }}"></${t.P}-span>\n <${t.P}-span class="${t.PCSS}-char-curr" content="{{ :host._length(:host.string) || '0' }}"></${t.P}-span>\n <${t.P}-span hide="{{ !(:host.maxlength > 0) }}" class="${t.PCSS}-char-max" content="{{ :host.maxlength }}"></${t.P}-span>\n</${t.P}-panel>`})],w);var S=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};const k="execute",$="<p><br></p>";class ContenteditableChangeEvent extends t.CustomTypedEvent{constructor(e){super("contenteditablechange",{html:e})}}class PacemContenteditableCommandElement extends 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(k))},e=>{console.error(e)})}connectedCallback(){super.connectedCallback(),t.Utils.addClass(this,t.PCSS+"-contenteditable-command")}viewActivatedCallback(){super.viewActivatedCallback();const e=this.container;t.Utils.isNull(e)||(this.contentElement=e.contentElement,e.addEventListener(t.PropertyChangeEventName,this._containerPropChangeHandler,!1))}disconnectedCallback(){const e=this.container;t.Utils.isNull(e)||e.removeEventListener(t.PropertyChangeEventName,this._containerPropChangeHandler,!1),super.disconnectedCallback()}containerPropertyChangedCallback(e,t,i,a){"range"===e&&(this.range=i)}}function U(e){return e instanceof PacemContenteditableCommandElement&&"pasteCallback"in e&&"function"==typeof e.pasteCallback}function N(e){return e?.nodeType==Node.ELEMENT_NODE}S([t.Watch()],PacemContenteditableCommandElement.prototype,"range",void 0),S([t.Watch()],PacemContenteditableCommandElement.prototype,"contentElement",void 0);let O=class PacemContenteditableElement extends 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=e=>{e.preventDefault();const i=this.range,a=e.clipboardData.files;if(t.Utils.isNull(i)||0!==a.length)for(let t=0;t<a.length;t++){const i=a.item(t);for(let t of this.items)U(t)&&t.pasteCallback(i).then(t=>this._checkChangedHandler(e),e=>{})}else{const t=e.clipboardData.getData("text/plain").replace(/</gi,"<").replace(/\n/gi,"<br />"),a=i.createContextualFragment(t);i.deleteContents(),i.insertNode(a),this._checkChangedHandler(e)}},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=e=>{const i=this._container,a=i.innerHTML;var r=a;(t.Utils.isNullOrEmpty(a)||"<br>"===a||a===$)&&(i.innerHTML=$,r=""),r!=this.value&&(this.changeHandler(new ContenteditableChangeEvent(r)),this.value!=this.#i.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}}#i;get history(){return this.#i}reset(){super.reset(),this.#i.reset(),this._fireHistoryChange()}_fireHistoryChange(){const e=this.#i;this.dispatchEvent(new t.PropertyChangeEvent({propertyName:"history",oldValue:e,currentValue:e}))}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(k,this._checkChangedHandler,!1),!0)}unregister(e){return!!super.unregister(e)&&(e.removeEventListener(k,this._checkChangedHandler,!1),!0)}get preventKeyboardSubmit(){return!0}get inputFields(){return[this._container]}get contentElement(){return this._container}onChange(e){return new Promise((i,a)=>{if(t.CustomEventUtils.isInstanceOf(e,ContenteditableChangeEvent)){i(this.value=e.detail.html),this._selectionChangeHandler(e)}else i(this.value)})}_fixRangeMarkup(){const e=this.range,i=e=>{e.childNodes.forEach(e=>i(e)),N(e)&&"SPAN"===e.tagName?Element.prototype.replaceWith.apply(e,Array.from(e.childNodes)):e instanceof HTMLElement&&e.removeAttribute("style")};t.Utils.isNull(e)||(e=>{let t=e;N(t)||(t=e.parentElement),i(t)})(e.commonAncestorContainer)}_ensureInteractiveMarkup(){const e=this._container,i=e.childNodes,a=i.length;if(0==a||e.innerHTML===$)e.innerHTML=$;else{let e,r;const s=e=>{r.setEndAfter(e);const t=document.createElement("p");r.surroundContents(t)};for(let n=0;n<a;n++)e=i.item(n),e instanceof Element?r&&(s(e.previousSibling),r=null):t.Utils.isNull(r)&&(r=document.createRange(),r.setStartBefore(e));t.Utils.isNull(r)||s(e)}}_updateHistory(){this.#i.push(this.value),this._fireHistoryChange()}acceptValue(e){t.Utils.isNull(this._container)||e==this._container.innerHTML||(this._container.innerHTML=e)}viewActivatedCallback(){super.viewActivatedCallback();const t=this._container;this.#i=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 e=this._container;t.Utils.isNull(e)||(e.removeEventListener("keydown",this._shortcutHandler,!1),e.removeEventListener("blur",this._blurHandler,!1),e.removeEventListener("focus",this._focusHandler,!1),e.removeEventListener("input",this._inputHandler,!1),e.removeEventListener("paste",this._pasteHandler,!1)),super.disconnectedCallback()}getViewValue(e){return e}};S([t.ViewChild("div[pacem]")],O.prototype,"_container",void 0),S([t.ViewChild("div[dashboard]")],O.prototype,"_dashboard",void 0),S([t.Watch()],O.prototype,"range",void 0),S([t.Debounce(500)],O.prototype,"_updateHistory",null),O=S([t.CustomElement({tagName:t.P+"-contenteditable",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<div class="${t.PCSS}-contenteditable ${t.PCSS}-viewfinder">\n <div contenteditable="true" role="presenter" pacem></div>\n</div>${E}\n<div dashboard>\n <${t.P}-content></${t.P}-content>\n</div>`})],O);var x=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};class PacemContenteditableButtonCommandElement extends PacemContenteditableCommandElement{cleanUp(e){}propertyChangedCallback(e,i,a,r){super.propertyChangedCallback(e,i,a,r),"range"===e&&(this.active=!t.Utils.isNull(a))}getTooltip(e=this.altText,i=this.keyboardShortcut){const a=e;return t.Utils.isNullOrEmpty(i)?a:`${a} (${i})`}}x([t.Watch({converter:t.PropertyConverters.String})],PacemContenteditableButtonCommandElement.prototype,"icon",void 0),x([t.Watch({converter:t.PropertyConverters.String})],PacemContenteditableButtonCommandElement.prototype,"keyboardShortcut",void 0),x([t.Watch({converter:t.PropertyConverters.String})],PacemContenteditableButtonCommandElement.prototype,"altText",void 0),x([t.Watch({converter:t.PropertyConverters.Boolean})],PacemContenteditableButtonCommandElement.prototype,"active",void 0);const V=`<${t.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()"><${t.P}-icon class="text-rootsize" icon="{{ :host.icon }}"></${t.P}-icon></${t.P}-button>\n <${t.P}-shortcut disabled="{{ !:host.active }}" target="{{ :host.contentElement }}" combination="{{ :host.keyboardShortcut }}" on-execute=":host.execCommand()"></${t.P}-shortcut>`;var D=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};let H=class PacemContenteditableHistoryCommandElement extends PacemContenteditableButtonCommandElement{exec(){return new Promise((e,i)=>{const a=this.container?.history;if(!t.Utils.isNull(a)){if("redo"===this.command)a.canRedo&&(a.redo(),e());else a.canUndo&&(a.undo(),e());this.contentElement.innerHTML=a.current}})}isRelevant(e){return!1}propertyChangedCallback(e,t,i,a){if(super.propertyChangedCallback(e,t,i,a),"command"===e)this.icon=this.icon||i,this.altText=i,this.keyboardShortcut=this.keyboardShortcut||"Ctrl+"+("redo"===i?"Y":"Z")}containerPropertyChangedCallback(e,i,a,r){super.containerPropertyChangedCallback(e,i,a,r);const s=this.container,n=s.history;"range"!==e&&"history"!==e||(this.active=!t.Utils.isNull(s.range)&&("redo"===this.command&&n?.canRedo||"redo"!==this.command&&n?.canUndo))}};D([t.Watch({emit:!1,converter:t.PropertyConverters.String,reflectBack:!0})],H.prototype,"command",void 0),H=D([t.CustomElement({tagName:t.P+"-contenteditable-historycommand",shadow:t.Defaults.USE_SHADOW_ROOT,template:V})],H);var A=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};let T=class PacemContenteditableLinkCommandElement extends PacemContenteditableButtonCommandElement{isRelevant(e){return!t.Utils.isNull(ContenteditableUtils.findSurroundingNode(e,HTMLAnchorElement))}viewActivatedCallback(){super.viewActivatedCallback(),t.Utils.isNullOrEmpty(this.altText)&&(this.altText="insert link"),t.Utils.isNullOrEmpty(this.icon)&&(this.icon="insert_link"),t.Utils.isNullOrEmpty(this.keyboardShortcut)&&(this.keyboardShortcut="Ctrl+H")}exec(e,t=this.target){return new Promise((i,a)=>{var r=this.range,s=ContenteditableUtils.findSurroundingNode(r,HTMLAnchorElement),n="http://",o=/<a.*href=\"([^\"]*)/;if(s&&o.test(s.outerHTML)&&(n=o.exec(s.outerHTML)[1]),"current"===e)return"http://"==n?"":n;var l=e||void 0===e&&window.prompt("link (empty to unlink):",n);l?(document.execCommand("createLink",!1,l),(s=ContenteditableUtils.findSurroundingNode(r,HTMLAnchorElement))&&s.setAttribute("target",t||"_blank")):document.execCommand("unlink"),i()})}};A([t.Watch({emit:!1,converter:t.PropertyConverters.String})],T.prototype,"target",void 0),T=A([t.CustomElement({tagName:t.P+"-contenteditable-linkcommand",shadow:t.Defaults.USE_SHADOW_ROOT,template:V})],T);var R=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};function L(e,i){return new Promise((a,r)=>{t.Utils.blobToDataURL(i).then(t.Utils.loadImage).then(t=>{const i=document.createElement("picture");i.setAttribute("contenteditable","false"),t.tabIndex=0,i.appendChild(t),e.deleteContents(),e.insertNode(i),a(i)})})}let I=class PacemContenteditableImageCommandElement extends PacemContenteditableButtonCommandElement{constructor(){super(...arguments),this._setBehaviorHandler=e=>{const t=e.target.parentElement;this.range=ContenteditableUtils.select(t)},this._disposeBehaviorHandler=e=>{}}pasteCallback(e){return e.type.startsWith("image")?L(this.range,e):Promise.reject()}cleanUp(e){e.querySelectorAll("picture[contenteditable=false]").forEach(e=>{for(let t=e.childNodes.length-1;t>0;t--)e.childNodes.item(t).remove()}),e.querySelectorAll("div."+t.PCSS+"-rescale").forEach(e=>e.remove())}isRelevant(e){return!1}viewActivatedCallback(){super.viewActivatedCallback(),t.Utils.isNullOrEmpty(this.altText)&&(this.altText="insert image"),t.Utils.isNullOrEmpty(this.icon)&&(this.icon="insert_photo"),t.Utils.isNullOrEmpty(this.keyboardShortcut)&&(this.keyboardShortcut="Ctrl+Shift+I"),this._rescale.addEventListener("rescale",this._rescaleImg,!1)}disconnectedCallback(){t.Utils.isNull(this._rescale)||(this._rescale.removeEventListener("rescale",this._rescaleImg,!1),this._disposeContainer()),super.disconnectedCallback()}propertyChangedCallback(e,i,a,r){switch(super.propertyChangedCallback(e,i,a,r),e){case"disabled":t.Utils.isNull(this._rescale)||(this._rescale.disabled=a);break;case"contentElement":i&&this._disposeContainer(i),a&&this._initContainer(a);break;case"range":this._rangeChangeCallback(i,a)}}exec(){return new Promise((e,i)=>{const a=this._file,r=this.range;a.onchange=i=>{const s=a.files[0];t.Utils.isNull(s)?e():L(r,s).then(t=>{a.value="",e()})},a.click()})}_rescaleImg(e){e.preventDefault();const t=e.detail.element,i=e.detail.targetRect,a=t.firstElementChild;a.style.width=i.width+"px",a.style.height=i.height+"px"}#a;_rangeChangeCallback(e,i){if(!t.Utils.isNull(e)&&!e.collapsed&&e.commonAncestorContainer instanceof Element&&e.commonAncestorContainer===e.startContainer&&e.commonAncestorContainer===e.endContainer&&e.startOffset===e.endOffset-1){const t=e.commonAncestorContainer.childNodes.item(e.startOffset);t instanceof HTMLPictureElement&&this._rescale.unregister(t)}if(!t.Utils.isNull(i)&&!i.collapsed&&i.commonAncestorContainer instanceof Element&&i.commonAncestorContainer===i.startContainer&&i.commonAncestorContainer===i.endContainer&&i.startOffset===i.endOffset-1){const e=i.commonAncestorContainer.childNodes.item(i.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.#a=new ContenteditableDOMObserver(e,(e,t)=>{e instanceof HTMLPictureElement&&(t?this._downgradePictureElement(e):this._enhancePictureElement(e))},"picture")}_disposeContainer(e=this.contentElement){const i=this.#a;t.Utils.isNull(i)||i.dispose()}};R([t.ViewChild("input[type=file]")],I.prototype,"_file",void 0),R([t.ViewChild(t.P+"-rescale")],I.prototype,"_rescale",void 0),I=R([t.CustomElement({tagName:t.P+"-contenteditable-imagecommand",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<input type="file" accept="image/png, image/gif, image/jpeg, image/bmp, image/x-icon" class="${t.PCSS}-trasparent ${t.PCSS}-inert" pacem hidden>`+V+`<${t.P}-rescale keep-proportions="true"></${t.P}-rescale>`})],I);var F,W=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};function B(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 j(e,t){const i=e?.toLowerCase();switch(i){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"}(F||(F={}));let M=class PacemContenteditableExecCommandElement extends PacemContenteditableButtonCommandElement{_matchRelevance(e,i){const a="object"==typeof i?ContenteditableUtils.findSurroundingNode(e,e=>e instanceof HTMLElement&&(t.Utils.isNullOrEmpty(i.tagName)||e.tagName===i.tagName.toUpperCase())&&e.style[i.style.name]===i.style.value):ContenteditableUtils.findSurroundingNode(e,i);return!t.Utils.isNull(a)}isRelevant(e){const t=j(this.command,this.argument);for(let i of t)if(this._matchRelevance(e,i))return!0;return!1}propertyChangedCallback(e,i,a,r){super.propertyChangedCallback(e,i,a,r),"command"===e&&((t.Utils.isNullOrEmpty(this.icon)||this.icon===B(i))&&(this.icon=B(a)),(t.Utils.isNullOrEmpty(this.altText)||this.altText===i)&&(this.altText=a))}exec(){return new Promise((e,i)=>{const a=this.range,r=j(this.command,this.argument)[0];if(!t.Utils.isNull(a)){const e=ContenteditableUtils.testInertElementWrapping(a);if(e.result&&"string"==typeof r&&["b","i","strike","u"].indexOf(r)>=0){const i=ContenteditableUtils.findSurroundingNode(a,r);if(t.Utils.isNull(i)||1!==i.childNodes.length){const t=document.createElement(r),i=e.element,s=a.extractContents();a.insertNode(t),t.append(s),ContenteditableUtils.select(i)}else{const t=i.childNodes.item(0),a=e.element;i.parentElement.replaceChild(t,i),ContenteditableUtils.select(a)}}else document.execCommand(this.command,!1,this.argument)}e()})}};function z(e){return e instanceof HTMLDivElement&&"true"===e.contentEditable&&e.hasAttribute("pacem")&&e.hasAttribute("role")&&"presenter"===e.attributes.role.value}W([t.Watch({converter:t.PropertyConverters.String})],M.prototype,"command",void 0),W([t.Watch({emit:!1,converter:t.PropertyConverters.String})],M.prototype,"argument",void 0),M=W([t.CustomElement({tagName:t.P+"-contenteditable-execcommand",shadow:t.Defaults.USE_SHADOW_ROOT,template:V})],M);class ContenteditableDOMObserver{constructor(e,t,i="*[contenteditable=false]"){this.#r=t,this.#s=i,this.#n=new MutationObserver(e=>{const i=(e,a)=>{e.childNodes.forEach(e=>i(e,a)),t(e,a)};for(let t of e){const e=t.addedNodes,a=t.removedNodes;for(let t=0;t<e.length;t++){const a=e.item(t);i(a,!1)}for(let e=0;e<a.length;e++){const t=a.item(e);i(t,!0)}}}),this._initContainer(e)}_initContainer(e){e.querySelectorAll(this.#s).forEach(e=>this.#r(e)),this.#n.observe(e,{subtree:!0,childList:!0}),this.#o=e}_disposeContainer(e){const i=this.#n;t.Utils.isNull(i)||i.disconnect(),e.querySelectorAll(this.#s).forEach(e=>this.#r(e,!0))}dispose(){this._disposeContainer(this.#o)}#s;#r;#o;#n}class ContenteditableUtils{static getDefaultDashboard(){const e=new DocumentFragment,i=document.createElement("div");t.Utils.addClass(i,t.PCSS+"-contenteditable-toolbar");const a=new H;a.command="undo",a.keyboardShortcut="Ctrl+Z";const r=new H;r.command="redo",r.keyboardShortcut="Ctrl+Y",i.append(a,r);const s=document.createElement("div");t.Utils.addClass(s,t.PCSS+"-contenteditable-separator");const n=document.createElement("div");t.Utils.addClass(n,t.PCSS+"-contenteditable-toolbar");const o=new M;o.command=F.Bold,o.keyboardShortcut="Ctrl+B";const l=new M;l.command=F.Italic,l.keyboardShortcut="Ctrl+I";const c=new M;c.command=F.Underline,c.keyboardShortcut="Ctrl+U";const d=new M;d.command=F.StrikeThrough,c.keyboardShortcut="Ctrl+K";const h=new M;h.command=F.UnorderedList;const p=new M;p.command=F.OrderedList;const u=new Y;u.align="left";const m=new Y;m.align="center";const v=new Y;v.align="right";const g=new Y;g.align="justify",n.append(o,l,c,d,h,p,u,m,v,g);const y=document.createElement("div");t.Utils.addClass(y,t.PCSS+"-contenteditable-separator");const f=document.createElement("div");t.Utils.addClass(f,t.PCSS+"-contenteditable-toolbar");const _=new T,b=new I;return f.append(_,b),e.append(i,s,n,y,f),e}static findSurroundingNode(e,i){for(var a=e instanceof Node?e:e.commonAncestorContainer;a&&!("string"==typeof i&&a instanceof Element&&a.tagName===i.toUpperCase()||"function"==typeof i&&t.Utils.isNull(i.prototype)&&i(a)||"function"==typeof i&&!t.Utils.isNull(i.prototype)&&a instanceof i);){const e=a.parentNode;if(z(e)){a=null;break}a=e}return a}static findSurroundingBlockElement(e){return this.findSurroundingNode(e,ContenteditableUtils.isBlockElement)}static findSurroundingSiblingBlockElements(e){let t=[];if(z(e.startContainer)){if(!e.collapsed){const i=e.startContainer;for(let a=e.startOffset;a<=e.endOffset;a++){const e=i.children.item(a);this.isBlockElement(e)&&t.push(i.children.item(a))}}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,a=!1;for(let r=0;r<i.childNodes.length;r++){const s=i.childNodes.item(r);if((!a&&s.contains(e.startContainer)||a)&&ContenteditableUtils.isBlockElement(s)&&(t.push(s),a=!0,s.contains(e.endContainer)))break}return a?t:i instanceof Element&&!z(i)?[i]:[]}static findContainingRootElements(e){const t=e.cloneRange(),i=e.cloneRange();t.collapse(!0),i.collapse();let a=this.findSurroundingNode(t,e=>"true"===e.parentElement.contentEditable);const r=[a];for(;!a.contains(i.startContainer);)r.push(a=a.nextElementSibling);return r}static isBlockElement(e){return e instanceof Element&&!getComputedStyle(e).display.startsWith("inline")}static select(e,t=!1){const i=document.createRange();t?(i.setStart(e,0),i.setEnd(e,e.childNodes.length)):(i.setStartBefore(e),i.setEndAfter(e));const a=document.getSelection();return a.removeAllRanges(),a.addRange(i),i}static copyAttributes(e,t){const i=t.attributes;for(let t=0;t<i.length;t++){const a=i.item(t);e.setAttribute(a.name,a.value)}}static testInertElementWrapping(e){if(!t.Utils.isNull(e)){const t=e.startContainer,a=e.startOffset;var i;if(t===e.endContainer&&a==e.endOffset-1&&(i=t.childNodes.item(a))instanceof HTMLElement&&"false"===i.contentEditable)return{result:!0,element:i}}return{result:!1}}}var q=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};function J(e){return"format_align_"+e}let Y=class PacemContenteditableAlignCommandElement extends PacemContenteditableButtonCommandElement{isRelevant(e){const i=ContenteditableUtils.findSurroundingSiblingBlockElements(e);if(t.Utils.isNullOrEmpty(i))return!1;const a=i[0];return getComputedStyle(a).textAlign==this.align}propertyChangedCallback(e,i,a,r){super.propertyChangedCallback(e,i,a,r),"align"===e&&((t.Utils.isNullOrEmpty(this.icon)||this.icon===J(i))&&(this.icon=J(a)),(t.Utils.isNullOrEmpty(this.altText)||this.altText===i)&&(this.altText=a))}exec(){const e=ContenteditableUtils.findSurroundingSiblingBlockElements(this.range);let i;for(let a of e)ContenteditableUtils.isBlockElement(a)&&a instanceof HTMLElement&&(t.Utils.isNull(i)&&(i=t.Utils.hasClass(a,"text-"+this.align)?"":this.align),a.style.textAlign="",t.Utils.removeClass(a,"text-left text-right text-center text-justify"),t.Utils.isEmpty(i)||t.Utils.addClass(a,"text-"+i));return Promise.resolve()}};q([t.Watch({converter:t.PropertyConverters.String})],Y.prototype,"align",void 0),Y=q([t.CustomElement({tagName:t.P+"-contenteditable-aligncommand",shadow:t.Defaults.USE_SHADOW_ROOT,template:V})],Y);var G=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};function K(e){return e instanceof HTMLModElement&&"INS"===e.tagName}let X=class PacemContenteditablePlaceholderElement extends PacemContenteditableCommandElement{constructor(){super(...arguments),this._focusHandler=e=>{const t=e.target;this.range=ContenteditableUtils.select(t)}}#l;#c;cleanUp(e){e.querySelectorAll("ins[contenteditable=false]").forEach(e=>{t.Utils.removeClass(e,"placeholder-selected")})}exec(e){const t=function(e,t){const i=document.createElement("ins");return i.textContent=t,i.setAttribute("contenteditable","false"),i.tabIndex=0,e.deleteContents(),e.insertNode(i),i}(this.range,e);return ContenteditableUtils.select(t).collapse(!1),Promise.resolve(t)}isRelevant(e){return this.#l?.result??!1}viewActivatedCallback(){super.viewActivatedCallback(),this._fillDropdown(),this._initContainer()}propertyChangedCallback(e,t,i,a){if(super.propertyChangedCallback(e,t,i,a),!a)switch(e){case"datasource":this._fillDropdown();break;case"contentElement":t&&this._disposeContainer(t),i&&this._initContainer(i);break;case"range":this._changeRelevancy()}}disconnectedCallback(){this._disposeContainer(),super.disconnectedCallback()}_changeRelevancy(e=this.range){const i=this.#l;t.Utils.isNull(i?.element)||t.Utils.removeClass(i.element,"placeholder-selected");const a=this.#l=function(e){const t=ContenteditableUtils.testInertElementWrapping(e);if(t.result&&K(t.element)){const e=t.element;return{result:!0,element:e,placeholder:e.textContent}}return{result:!1}}(e);t.Utils.isNull(a?.element)||t.Utils.addClass(a.element,"placeholder-selected"),a.result?this._dropdown.value=a.placeholder:(this._dropdown.popout(),this._dropdown.value=void 0)}_fillDropdown(e=this.datasource||[]){const t=this.#c=e.map(e=>"string"==typeof e?{placeholder:e,definition:e}:e),i=this._dropdown;i.textProperty=i.valueProperty="placeholder",i.datasource=t}#a;_initContainer(e=this.contentElement){this.#a=new ContenteditableDOMObserver(e,(e,t)=>{K(e)&&(t?this._downgradePlaceholderElement(e):this._enhancePlaceholderElement(e))},"ins[contenteditable=false]")}_disposeContainer(e=this.contentElement){const i=this.#a;t.Utils.isNull(i)||i.dispose()}_enhancePlaceholderElement(e){e.addEventListener("focus",this._focusHandler,!1)}_downgradePlaceholderElement(e){e.removeEventListener("focus",this._focusHandler,!1)}};G([t.ViewChild("template")],X.prototype,"_itemtemplate",void 0),G([t.ViewChild(t.P+"-suggest")],X.prototype,"_dropdown",void 0),G([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],X.prototype,"datasource",void 0),X=G([t.CustomElement({tagName:t.P+"-contenteditable-placeholder",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<template>\n<${t.P}-span text="{{ ^item.viewValue }}" class="text-tech"></${t.P}-span>\n<${t.P}-markdown hide="{{ $pacem.isNullOrEmpty(^item.data.definition) || ^item.viewValue === ^item.data.definition }}" class="${t.PCSS}-margin margin-0 text-small" value="{{ ^item.data.definition }}"></${t.P}-markdown>\n</template>\n<${t.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"></${t.P}-suggest>`})],X);var Z=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};let Q=class PacemContenteditableWrapCommandElement extends PacemContenteditableButtonCommandElement{isRelevant(e){return!t.Utils.isNull(ContenteditableUtils.findSurroundingNode(e,this.tagname))}exec(){return new Promise((e,i)=>{const a=this.tagname;if(!t.Utils.isNullOrEmpty(a)){const e=this.range,i=ContenteditableUtils.findSurroundingNode(e,a)||ContenteditableUtils.findSurroundingNode(e.startContainer,a)||ContenteditableUtils.findSurroundingNode(e.endContainer,a);if(t.Utils.isNull(i)){const i=ContenteditableUtils.findSurroundingSiblingBlockElements(e);if(!t.Utils.isNullOrEmpty(i)){const t=document.createElement(a);if(1===i.length){const a=i[0];e.setStart(a,0),e.setEnd(a,a.childNodes.length);const r=e.extractContents();t.append(r),ContenteditableUtils.copyAttributes(t,a),a.parentElement.insertBefore(t,a),a.remove()}else{e.setStartBefore(i[0]),e.setEndAfter(i[i.length-1]);const a=e.extractContents();t.append(a),e.insertNode(t)}ContenteditableUtils.select(t,!0).collapse()}}else{e.setStart(i,0),e.setEnd(i,i.childNodes.length);let t=!1;const a=i.childNodes;for(let e=0;e<a.length;e++){const i=a.item(e);if(!ContenteditableUtils.isBlockElement(i)){t=!0;break}}if(t){const t=document.createElement("p");ContenteditableUtils.copyAttributes(t,i),t.append(e.extractContents()),i.parentNode.replaceChild(t,i);ContenteditableUtils.select(t,!0).collapse()}else{i.parentNode.replaceChild(e.extractContents(),i);ContenteditableUtils.select(e.endContainer,!0).collapse()}}}e()})}};Z([t.Watch({converter:t.PropertyConverters.String})],Q.prototype,"tagname",void 0),Q=Z([t.CustomElement({tagName:t.P+"-contenteditable-wrapcommand",shadow:t.Defaults.USE_SHADOW_ROOT,template:V})],Q);var ee=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};const te={convert:(e,i)=>/\{.+\}/.test(e)?t.PropertyConverters.Json.convert(e):t.PropertyConverters.String.convert(e),convertBack:(e,i)=>"string"==typeof e?e:t.PropertyConverters.Json.convertBack(e,i)};let ie=class PacemCalendarMonthPickerElement extends t.Components.PacemElement{propertyChangedCallback(e,i,a,r){if(super.propertyChangedCallback(e,i,a,r),"viewYear"===e)this.dispatchEvent(new CustomEvent("viewyearchange",{detail:new Date(a,0,1),bubbles:!1,cancelable:!1})),t.Utils.removeClass(this,"viewyear-next viewyear-previous"),requestAnimationFrame(()=>{t.Utils.addClass(this,i>a?"viewyear-previous":"viewyear-next")})}_getMonthLabel(e){const i=(new Date).getFullYear();return new Date(i,e,1).toLocaleString(t.Utils.lang(this),{month:"short"})}_isThisMonth(e,t=this.viewYear){return this._isSelectedMonth(e,new Date,t)}_isSelectedMonth(e,i=this.month,a=this.viewYear){const r=t.Utils.parseDate(i);if(!t.Utils.Dates.isDate(r))return!1;const s=a??(new Date).getFullYear();return r.getMonth()===e&&r.getFullYear()===s}_setMonth(e){const t=this.viewYear,i=new Date(t,e,1);this.month=i,this.dispatchEvent(new CustomEvent("monthselect",{detail:i,bubbles:!1,cancelable:!1}))}};ee([t.Watch({converter:t.PropertyConverters.Date})],ie.prototype,"month",void 0),ee([t.Watch({converter:t.PropertyConverters.Date})],ie.prototype,"viewYear",void 0),ie=ee([t.CustomElement({tagName:t.P+"-calendar-month-picker",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<div class="${t.PCSS}-month-picker">${function(){let e="";for(let i=0;i<12;i++)e+=`<div class="calendar-month month-${i+1}"><${t.P}-span class="month-button text-ellipsed" on-click=":host._setMonth(${i})" css-class="{{ { 'selected-month': :host._isSelectedMonth(${i}, :host.month, :host.viewYear), 'this-month': :host._isThisMonth(${i}, :host.viewYear) } }}" text="{{ :host._getMonthLabel(${i}) }}"></${t.P}-span></div>`;return e}()}</div>`})],ie);class CalendarDateUnselectEvent extends i.Components.UI.DateSelectEvent{constructor(){super(void 0)}}function ae(e){return e-e%10}let re=class PacemCalendarYearPickerElement extends t.Components.PacemElement{propertyChangedCallback(e,i,a,r){if(super.propertyChangedCallback(e,i,a,r),"viewYear"===e)this.dispatchEvent(new CustomEvent("viewyearchange",{detail:new Date(a,0,1),bubbles:!1,cancelable:!1})),t.Utils.removeClass(this,"viewyear-next viewyear-previous"),requestAnimationFrame(()=>{t.Utils.addClass(this,i>a?"viewyear-previous":"viewyear-next")})}_getYearLabel(e,t=this.viewYear){return""+(ae(t)+e)}_isThisYear(e,t=this.viewYear){return this._isSelectedYear(e,new Date,t)}_isSelectedYear(e,i=this.year,a=this.viewYear){const r=t.Utils.parseDate(i);if(!t.Utils.Dates.isDate(r))return!1;const s=ae(a)+e;return r.getFullYear()===s}_setYear(e){const t=ae(this.viewYear),i=new Date(t+e,0,1);this.year=i,this.dispatchEvent(new CustomEvent("yearselect",{detail:i,bubbles:!1,cancelable:!1}))}};ee([t.Watch({converter:t.PropertyConverters.Date})],re.prototype,"year",void 0),ee([t.Watch({converter:t.PropertyConverters.Date})],re.prototype,"viewYear",void 0),re=ee([t.CustomElement({tagName:t.P+"-calendar-year-picker",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<div class="${t.PCSS}-year-picker">${function(){let e="";for(let i=0;i<12;i++)e+=`<div class="calendar-year year-${i+1}"><${t.P}-span class="year-button text-ellipsed" on-click=":host._setYear(${i})" css-class="{{ { 'selected-year': :host._isSelectedYear(${i}, :host.year, :host.viewYear), 'this-year': :host._isThisYear(${i}, :host.viewYear) } }}" text="{{ :host._getYearLabel(${i}, :host.viewYear) }}"></${t.P}-span></div>`;return e}()}</div>`})],re);let se=class PacemCalendarPickerElement extends PacemBaseElement{constructor(){super(...arguments),this.viewmode="calendar",this.#d=!1,this._swipeHandler=e=>{switch(e.detail.direction){case"left":this._next(e);break;case"right":this._prev(e)}},this._clearBtnHandler=e=>{e.preventDefault(),this._viewDate=new Date,this.changeHandler(new CalendarDateUnselectEvent)},this._viewDateChangeHandler=e=>{this._onViewDateChange(e)},this._popCalendarHandler=e=>{if(this.#d)return;this.viewmode="calendar";const i=t.Utils.parseDate(this.value);this._calendar.viewDate=this._monthPicker.month=this._yearPicker.year=t.Utils.Dates.isDate(i)?i:this._calendar.viewDate;const a=t.Utils.offset(this._input),r=this._dropdown;r.style.top=a.top+a.height+"px",r.style.left=a.left+"px",r.hidden=!1,requestAnimationFrame(()=>{t.Utils.addClass(r,"dropdown-in")})},this._hideCalendarHandler=e=>{const t=e.composedPath()||[];t.indexOf(this._input)>=0||t.indexOf(this._dropdown)>=0||this._hideCalendar()}}#d;propertyChangedCallback(e,t,i,a){switch(super.propertyChangedCallback(e,t,i,a),e){case"viewmode":case"_viewDate":this._onViewDateChange(this._viewDate)}}viewActivatedCallback(){super.viewActivatedCallback();const e=this._dropdown=this._proxy.dom[0],i=this._calendar=e.querySelector(t.P+"-calendar"),a=this._monthPicker=e.querySelector(t.P+"-calendar-month-picker"),r=this._yearPicker=e.querySelector(t.P+"-calendar-year-picker");this._monthLabel=e.querySelector(".calendar-month"),this._yearLabel=e.querySelector(".calendar-year"),this._rangeLabel=e.querySelector(".calendar-year-range");const s=this._calendar.now=new Date,n=t.Utils.Dates.parse(this.value),o=t.Utils.Dates.isDate(n)?n:s;i.dayLabelFormatter=e=>t.Utils.parseDate(e).toLocaleString(t.Utils.lang(this),{day:"numeric"}),a.addEventListener("viewyearchange",this._viewDateChangeHandler,!1),r.addEventListener("viewyearchange",this._viewDateChangeHandler,!1),i.addEventListener("viewdatechange",this._viewDateChangeHandler,!1),i.viewDate=o,i.date=n;const l=this._input;l.addEventListener("focus",this._popCalendarHandler,!1),l.addEventListener("mousedown",this._popCalendarHandler,!1),e.addEventListener("mousedown",t.stopPropagationHandler,!1),window.document.body.addEventListener("mousedown",this._hideCalendarHandler,!0),this._clearButton.addEventListener("mousedown",this._clearBtnHandler,!1);const c=new t.Components.PacemSwipeElement;i.behaviors.push(c),a.behaviors.push(c),r.behaviors.push(c),c.addEventListener("swipe",this._swipeHandler,!1);const d=t.CustomElementUtils.findAncestorShell(this);this._swiper=d.appendChild(c)}disconnectedCallback(){const e=this._input;t.Utils.isNull(e)||(this._clearButton.removeEventListener("mousedown",this._clearBtnHandler,!1),e.removeEventListener("focus",this._popCalendarHandler,!1),e.removeEventListener("mousedown",this._popCalendarHandler,!1),this._dropdown.removeEventListener("mousedown",t.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 i=this._swiper;if(!t.Utils.isNull(i)){const e=this._calendar,t=this._monthPicker,a=this._yearPicker;for(let r of[e,t,a]){const e=r.behaviors.indexOf(i);e>=0&&r.behaviors.splice(e,1)}i.removeEventListener("swipe",this._swipeHandler,!1),i.remove(),this._swiper=null}super.disconnectedCallback()}_getHeaderLabel(e,i=this.viewmode){const a=t.Utils.parseDate(e);return t.Utils.Dates.isDate(a)?a.toLocaleString(t.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(e){const i=t.Utils.parseDate(this._viewDate);this._viewDate=t.Utils.Dates.addMonths(i,e)}_setMonth(e){this._viewDate=e.detail,this.viewmode="calendar"}_setYear(e){this._viewDate=e.detail,this.viewmode="month"}_onViewDateChange(e){if(t.Utils.isNullOrEmpty(e))return;const i=t.Utils.parseDate(this._viewDate);if(t.Utils.Dates.isDate(i)&&!t.Utils.isNull(this._monthLabel))switch(this.viewmode){case"month":this._yearLabel.text=i.toLocaleString(t.Utils.lang(this),{year:"numeric"});break;case"year":const e=ae(i.getFullYear());this._rangeLabel.text=`${e} - ${e+12-1}`;break;default:this._monthLabel.text=i.toLocaleString(t.Utils.lang(this),{month:"long",year:"numeric"})}}_hideCalendar(){t.Utils.removeClass(this._dropdown,"dropdown-in"),t.Utils.addAnimationEndCallback(this._dropdown,e=>{this._dropdown.hidden=!0,t.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(e){return new Promise((a,r)=>{if(t.CustomEventUtils.isInstanceOf(e,i.Components.UI.DateSelectEvent)){t.Utils.addClass(this._dropdown,"dropdown-select");t.CustomEventUtils.isInstanceOf(e,CalendarDateUnselectEvent)&&(this.#d=!0),this.focus(),this.#d=!1,this._hideCalendar(),a(this.value=e.detail)}else a(this.value)})}acceptValue(e){this._input.value=this.viewValue;const i=this._calendar;if(!t.Utils.isNull(i)){const a=t.Utils.parseDate(e);t.Utils.Dates.isDate(a)?i.viewDate=i.date=a:i.date=void 0}}getViewValue(e){const i=t.Utils.Dates.parse(e);return t.Utils.Dates.isDate(i)?t.Utils.core.date(i,this.format||"short",t.Utils.lang(this)):""}compareValuePropertyValues(e,i){const a=t.Utils.parseDate(e),r=t.Utils.parseDate(i);return!(!t.Utils.isNullOrEmpty(a)||!t.Utils.isNullOrEmpty(r))||!t.Utils.isNullOrEmpty(a)&&!t.Utils.isNullOrEmpty(r)&&a.valueOf()==r.valueOf()}convertValueAttributeToProperty(e){return t.PropertyConverters.Datetime.convert(e)}};ee([t.ViewChild("input[type=text]")],se.prototype,"_input",void 0),ee([t.ViewChild(`.${t.PCSS}-readonly`)],se.prototype,"_span",void 0),ee([t.ViewChild(`${t.P}-button[clear]`)],se.prototype,"_clearButton",void 0),ee([t.ViewChild(t.P+"-shell-proxy")],se.prototype,"_proxy",void 0),ee([t.Watch({emit:!1,converter:te})],se.prototype,"format",void 0),ee([t.Watch({converter:t.PropertyConverters.Eval})],se.prototype,"disabledRanges",void 0),ee([t.Watch({converter:t.PropertyConverters.String})],se.prototype,"weekStart",void 0),ee([t.Watch({converter:t.PropertyConverters.String})],se.prototype,"viewmode",void 0),ee([t.Watch()],se.prototype,"_week",void 0),ee([t.Watch()],se.prototype,"_viewDate",void 0),se=ee([t.CustomElement({tagName:t.P+"-calendar-picker",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<div class="${t.PCSS}-calendar-picker">\n <input type="text" class="${t.PCSS}-input" /><${t.P}-span text="{{ :host.viewValue }}" class="${t.PCSS}-readonly"></${t.P}-span>\n <${t.P}-button class="button-flat ${t.PCSS}-anim anim-pop anim-sudden anim-quick pos-absolute absolute-right absolute-top display-block ${t.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></${t.P}-button>\n</div>\n<${t.P}-shell-proxy>\n <div class="${t.PCSS}-calendar-picker-dropdown" pacem hidden>\n <${t.P}-collapse collapse="false">\n <div class="dropdown-grid">\n <div class="calendar-title">\n <${t.P}-span class="calendar-month calendar-zoom" on-click=":host.viewmode = 'month'" hide="{{ :host.viewmode !== 'calendar' }}"></${t.P}-span>\n <${t.P}-span class="calendar-year calendar-zoom" on-click=":host.viewmode = 'year'" hide="{{ :host.viewmode !== 'month' }}"></${t.P}-span>\n <${t.P}-span class="calendar-year-range" hide="{{ :host.viewmode !== 'year' }}"></${t.P}-span>\n </div>\n <div class="calendar-month-nav ${t.PCSS}-buttonset buttons">\n <div class="buttonset-left">\n <${t.P}-button class="button button-size size-auto" on-click=":host._prev($event)" icon-glyph="chevron_left"></${t.P}-button>\n <${t.P}-button class="button button-size size-auto" on-click=":host._next($event)" icon-glyph="chevron_right"></${t.P}-button>\n </div>\n </div>\n ${function(){let e="";for(let i=0;i<7;i++)e+=`<${t.P}-span class="calendar-heading day-${i+1} text-ellipsed" text="{{ :host._getHeaderLabel(:host._week[${i}]) }}"></${t.P}-span>`;return`<${t.P}-panel hide="{{ :host.viewmode !== 'calendar' }}" class="calendar-header">${e}</${t.P}-panel>`}()}\n <${t.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) }}"></${t.P}-calendar>\n <${t.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() }}"></${t.P}-calendar-month-picker>\n <${t.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() }}"></${t.P}-calendar-year-picker>\n </div>\n <${t.P}-collapse>\n </div>\n</${t.P}-shell-proxy>`})],se);var ne=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};const oe={convert:e=>"true"===e||"false"!==e&&e,convertBack:e=>e.toString()};let le=class PacemCheckboxElement extends PacemBaseElement{constructor(){super("checkbox"),this.caption="",this._key="_"+t.Utils.uniqueCode()}convertValueAttributeToProperty(e){oe.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(e){this.selected=this._checkbox.checked;const i=this.value=this.selected?this.trueValue:this.falseValue;return t.Utils.fromResult(i)}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(e,i,a,r){if(super.propertyChangedCallback(e,i,a,r),this.isReady)switch(e){case"caption":this._label.hidden=t.Utils.isNullOrEmpty(a);break;case"name":this._checkbox.name=a;break;case"selected":this._synchronizeUi()}}_synchronizeUi(e=this.selected){(this._checkbox.checked=e)?(this.value=this.trueValue,t.Utils.addClass(this,t.PCSS+"-selected"),this.aria.attributes.set("checked","true")):(this.value=this.falseValue,t.Utils.removeClass(this,t.PCSS+"-selected"),this.aria.attributes.set("checked","false"))}acceptValue(e){this.selected=e==this.trueValue}getViewValue(e){return t.Utils.isNull(e)?"":this.caption}};ne([t.ViewChild("input[type=checkbox]")],le.prototype,"_checkbox",void 0),ne([t.ViewChild("label")],le.prototype,"_label",void 0),ne([t.ViewChild(`.${t.PCSS}-readonly`)],le.prototype,"span",void 0),ne([t.Watch({converter:t.PropertyConverters.String})],le.prototype,"caption",void 0),ne([t.Watch({emit:!1,converter:oe})],le.prototype,"trueValue",void 0),ne([t.Watch({emit:!1,converter:oe})],le.prototype,"falseValue",void 0),ne([t.Watch({converter:t.PropertyConverters.Boolean})],le.prototype,"selected",void 0),le=ne([t.CustomElement({tagName:t.P+"-checkbox",template:`<${t.P}-span class="${t.PCSS}-readonly ${t.PCSS}-checkbox" text="{{ :host.caption }}"></${t.P}-span>\n<input type="checkbox" class="${t.PCSS}-input" /><label class="${t.PCSS}-label ${t.PCSS}-checkbox ${t.PCSS}-viewfinder" pacem><${t.P}-span content="{{ :host.caption }}"></${t.P}-span></label>`,shadow:t.Defaults.USE_SHADOW_ROOT})],le);var ce=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};let de=class PacemCheckboxListElement extends PacemDataSourceElement{acceptValue(e){}constructor(){super(!0),this._selectedUiItems=[],this.key="_"+t.Utils.uniqueCode()}get inputFields(){return[]}propertyChangedCallback(e,t,i,a){super.propertyChangedCallback(e,t,i,a),"disabled"===e&&(this._disable.model=i)}viewActivatedCallback(){super.viewActivatedCallback(),this._disable.model=this.disabled}toggleReadonlyView(e){this._span.hidden=!e,this._repeater.hidden=e}_selectionChanged(e,t,i){if("selected"===e.detail.propertyName){let i,a=this._selectedUiItems;!0===e.detail.currentValue?a.push(this.datasource[t]):-1!==(i=a.indexOf(this.datasource[t]))&&a.splice(i,1)}}onChange(e){const i=this.value=this._selectedUiItems.map(e=>this.mapEntityToValue(e));return t.Utils.fromResult(i)}};ce([t.ViewChild(`span.${t.PCSS}-readonly`)],de.prototype,"_span",void 0),ce([t.ViewChild(t.P+"-repeater")],de.prototype,"_repeater",void 0),ce([t.ViewChild(t.P+"-data")],de.prototype,"_disable",void 0),de=ce([t.CustomElement({tagName:t.P+"-checkbox-list",template:`<${t.P}-repeater datasource="{{ :host.adaptedDatasource }}">\n <ol class="${t.PCSS}-checkbox-list ${t.PCSS}-viewfinder" pacem>\n <template>\n <li><${t.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-${t.PropertyChangeEventName}=":host._selectionChanged($event, ^index, ^item)" on-change=":host.changeHandler($event)"></${t.P}-checkbox></li>\n </template>\n </ol>\n</${t.P}-repeater><span class="${t.PCSS}-readonly"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></span><${t.P}-data></${t.P}-data><${t.P}-content></${t.P}-content>`,shadow:t.Defaults.USE_SHADOW_ROOT})],de);var he=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};let pe=class PacemChildFormPropagatorElement extends t.PacemEventTarget{propertyChangedCallback(e,i,a,r){if(super.propertyChangedCallback(e,i,a,r),!r){const i=this.property,r=this.watch,s=!t.Utils.isNullOrEmpty(i),n=!t.Utils.isNull(this.model);("watch"===e||"property"===e||"model"===e&&s&&n&&t.Utils.isArray(a)&&a.some(e=>!(i in e)||e[i]!==r)||"model"===e&&s&&n&&!t.Utils.isArray(a)&&(!(i in a)||a[i]!==r))&&this._synchronize()}}viewActivatedCallback(){super.viewActivatedCallback(),this._synchronize()}_synchronize(){const e=this.model,i=this.property,a=this.watch;if(!t.Utils.isNullOrEmpty(e)&&!t.Utils.isNullOrEmpty(i))if(t.Utils.isArray(e)){for(let t of e)t[i]=a;this.model=e.slice(0)}else e[i]=a,this.model=t.Utils.extend({},e)}};he([t.Watch({emit:!0})],pe.prototype,"model",void 0),he([t.Watch({emit:!1,converter:t.PropertyConverters.String,reflectBack:!0})],pe.prototype,"property",void 0),he([t.Watch({emit:!1})],pe.prototype,"watch",void 0),pe=he([t.CustomElement({tagName:t.P+"-childform-propagator"})],pe);let ue=class PacemChildFormElement extends PacemBaseElement{constructor(){super(...arguments),this._model=[],this._subForms=[]}get inputFields(){return[]}toggleReadonlyView(e){}onChange(e){return new Promise((e,t)=>{var i=this._modelToEntity();e(this.value=i)})}acceptValue(e){this._entityToModel(e)}getViewValue(e){return""}convertValueAttributeToProperty(e){return t.PropertyConverters.Json.convert(e,this)}propertyChangedCallback(e,t,i,a){if(super.propertyChangedCallback(e,t,i,a),"mode"===e)this._entityToModel()}_dragStart(e){var i=e.detail;const a=t.Utils.offset(i.element),r=i.floater;r.style.width=a.width+"px",r.style.height=a.height+"px"}_dragEnd(e){"array"===this.mode&&this._triggerChange()}reset(){super.reset(),this._subForms.forEach(e=>{e.setPristine()})}_itemCreate(e){const i=e.detail.index,a=this._subForms;e.detail.dom[0].childNodes.forEach(e=>{e instanceof Element&&e.localName===t.P+"-form"&&a.splice(i,a.length-i,e)})}_itemChange(e,i){"entity"===i.detail.propertyName&&t.Utils.Json.stringify(this._model[e])!==t.Utils.Json.stringify(i.detail.currentValue)&&(this._model.splice(e,1,i.detail.currentValue),this._triggerChange())}_deleteAt(e){t.avoidHandler(e.srcEvent);const i=this._model;"array"===this.mode?i.splice(e.detail,1):i.splice(0,i.length),this._triggerChange()}_addItem(e){const t=this.mode,i=this._model;"array"===t?i.push({}):i.splice(0,i.length,{}),this._triggerChange()}_triggerChange(){this.changeHandler(new Event("change"))}_entityToModel(e=this.value){if("array"===this.mode){let i=e||[];t.Utils.isArray(i)&&this._model.cloneFrom(i)}else{const i=this._model,a=i.length;1===a&&i[0]===e||(t.Utils.isNull(e)?i.splice(0,a):i.splice(0,a,e))}}_modelToEntity(e=this._model){return"array"===this.mode?t.Utils.clone(e):e&&e.length&&e[0]||null}};he([t.Watch({emit:!1,converter:t.PropertyConverters.String})],ue.prototype,"fetchCredentials",void 0),he([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],ue.prototype,"fetchHeaders",void 0),he([t.ViewChild("."+t.PCSS+"-childform")],ue.prototype,"_container",void 0),he([t.ViewChild(t.P+"-drag-drop")],ue.prototype,"_dragger",void 0),he([t.ViewChild("."+t.PCSS+"-childform-item-floater")],ue.prototype,"_floater",void 0),he([t.Watch({converter:t.PropertyConverters.String})],ue.prototype,"mode",void 0),he([t.Watch({converter:t.PropertyConverters.Boolean})],ue.prototype,"lockItems",void 0),he([t.Watch({converter:t.PropertyConverters.Json})],ue.prototype,"metadata",void 0),he([t.Watch({converter:t.PropertyConverters.Json})],ue.prototype,"_model",void 0),ue=he([t.CustomElement({tagName:t.P+"-childform",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<${t.P}-repeater datasource="{{ :host._model }}" on-itemdelete=":host._deleteAt($event)" on-${t.Components.RepeaterItemCreateEventName}=":host._itemCreate($event)">\n <div class="${t.PCSS}-childform">\n <template>\n <${t.P}-panel class="${t.PCSS}-childform-item" behaviors="{{ [::_dragger] }}">\n <${t.P}-panel class="childform-item-handle ${t.PCSS}-margin margin-right-1" hide="{{ :host.lockItems || :host.readonly || :host.mode !== 'array' || !(:host._model && :host._model.length > 1) }}"><i class="${t.PCSS}-icon drag-handle">drag_handle</i></${t.P}-panel>\n <${t.P}-panel class="childform-item-index text-small"><${t.P}-span hide="{{ !:host.readonly || :host.mode !== 'array' }}" class="${t.PCSS}-margin margin-right-1" text="{{ ^index+1 }}"></${t.P}-span></${t.P}-panel>\n <${t.P}-form entity="{{ ^item }}" fetch-headers="{{ :host.fetchHeaders }}" fetch-credentials="{{ :host.fetchCredentials }}" on-${t.PropertyChangeEventName}=":host._itemChange(^index, $event)" readonly="{{ :host.readonly }}" metadata="{{ :host.metadata }}" autogenerate="true" logger="{{ :host.logger }}"></${t.P}-form>\n <${t.P}-button tab-order="-1" class="flat circular circle-small clear ${t.PCSS}-margin margin-left-1" hide="{{ :host.lockItems || :host.readonly }}" command-name="delete" command-argument="{{ ^index }}"></${t.P}-button>\n </${t.P}-panel>\n </template>\n </div>\n <${t.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)"></${t.P}-button>\n</${t.P}-repeater>\n<div class="${t.PCSS}-childform-item-floater ${t.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<${t.P}-drag-drop floater="{{ ::_floater }}" disabled="{{ :host.lockItems }}"\n on-${t.UI.DragDropEventType.Start}=":host._dragStart($event)"\n on-${t.UI.DragDropEventType.End}=":host._dragEnd($event)" \n drop-behavior="${t.UI.DropBehavior.InsertChild}" mode="${t.UI.DragDataMode.Alias}" handle-selector=".drag-handle" drop-targets="{{ [::_container] }}"></${t.P}-drag-drop>`})],ue);var me=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};const ve={convert:(e,i)=>/\{.+\}/.test(e)?t.PropertyConverters.Json.convert(e):t.PropertyConverters.String.convert(e),convertBack:(e,i)=>"string"==typeof e?e:t.PropertyConverters.Json.convertBack(e,i)};let ge=class PacemDatetimePickerElement extends 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(e){return t.PropertyConverters.Datetime.convert(e)}connectedCallback(){super.connectedCallback();const e=new Date;let i=this.year=e.getFullYear();this.min=new Date(i-100,0,1),this.max=new Date(i+10,11,31),this.month=e.getMonth();let a=[],r=[],s=[],n=t.Utils.leftPad;for(let e=0;e<12;e++){let r=new Date(i,e,1),s=r.toLocaleString(t.Utils.lang(this),{month:"short"});a.push({value:e,date:r,label:s})}this._months=a;for(let e=0;e<24;e++)r.push(n(e,2,"0"));this._a24=r;for(let e=0;e<60;e++)s.push(n(e,2,"0"));this._a60=s}propertyChangedCallback(e,i,a,r){switch(super.propertyChangedCallback(e,i,a,r),e){case"dateValue":this.log(t.Logging.LogLevel.Log,`dateValue changed from ${i} to ${a}`),this._disassembleDate(a);break;case"min":case"max":t.Utils.isNullOrEmpty(this.min)||t.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(e){this.dateValue=t.Utils.parseDate(e)}_disassembleDate(e){if(!e)return void(this.date=void 0);"string"==typeof e&&(e=t.Utils.parseDate(e));const i=e=>t.Utils.leftPad(e,2,"0");this.year=e.getFullYear(),this.month=e.getMonth(),this.date=e.getDate(),this.hours=i(e.getHours()),this.minutes=i(e.getMinutes()),this.seconds=i(e.getSeconds())}_setupYears(){let e=[];const i=t.Utils.parseDate(this.min),a=t.Utils.parseDate(this.max);for(let t=i.getFullYear();t<=a.getFullYear();t++)e.push(t);this._years=e}onChange(e){return new Promise((e,t)=>{e(this.value=this._computeValue())})}_buildupDates(e){e&&e.stopPropagation();const i=this,a={weekday:"short",day:"numeric"},r=e=>{try{let t=+i.month;return new Date(+i.year,+i.month,e).getMonth()==t}catch(e){return!1}};var s=[];if(!t.Utils.isNullOrEmpty(i.year)&&!t.Utils.isNullOrEmpty(i.month)){let e=1;do{let r=new Date(+i.year,+i.month,e),n=r.toLocaleString(t.Utils.lang(this),a);s.push({value:e,date:r,label:n,disabled:r<this.min||r>this.max})}while(r(++e))}this._dates=s,r(+this.date)?this._buildup():this.date=""}_computeValue(){const e=this;if(t.Utils.isNullOrEmpty(e.year)||t.Utils.isNullOrEmpty(e.month)||t.Utils.isNullOrEmpty(e.date))return null;try{let t=new Date(+e.year,+e.month,+e.date);return t.setHours(+e.hours),t.setMinutes(+e.minutes),t.setSeconds(+e.seconds),t.setMilliseconds(0),Number.isNaN(t.valueOf())?null:t}catch(e){return null}}_buildup(e){e&&e.stopPropagation(),this.dateValue=this._computeValue()}getViewValue(e){const i=e;return i?t.Utils.core.date(i,this.format||("day"!=this.precision?"full":"short"),t.Utils.lang(this)):""}};me([t.ViewChild("."+t.PCSS+"-datetime-picker-year > "+t.P+"-select")],ge.prototype,"_yearel",void 0),me([t.ViewChild("."+t.PCSS+"-datetime-picker-month > "+t.P+"-select")],ge.prototype,"_monthel",void 0),me([t.ViewChild("."+t.PCSS+"-datetime-picker-date > "+t.P+"-select")],ge.prototype,"_dateel",void 0),me([t.ViewChild("."+t.PCSS+"-datetime-picker-hours > "+t.P+"-select")],ge.prototype,"_hourel",void 0),me([t.ViewChild("."+t.PCSS+"-datetime-picker-minutes > "+t.P+"-select")],ge.prototype,"_minel",void 0),me([t.ViewChild("."+t.PCSS+"-datetime-picker-seconds > "+t.P+"-select")],ge.prototype,"_secel",void 0),me([t.ViewChild(`div.${t.PCSS}-datetime-picker-fields`)],ge.prototype,"_allFields",void 0),me([t.Watch({converter:t.PropertyConverters.Datetime})],ge.prototype,"dateValue",void 0),me([t.Watch({converter:t.PropertyConverters.Datetime})],ge.prototype,"min",void 0),me([t.Watch({converter:t.PropertyConverters.Datetime})],ge.prototype,"max",void 0),me([t.Watch({converter:t.PropertyConverters.String})],ge.prototype,"precision",void 0),me([t.Watch({emit:!1,converter:ve})],ge.prototype,"format",void 0),me([t.Watch()],ge.prototype,"_dates",void 0),me([t.Watch()],ge.prototype,"_years",void 0),me([t.Watch()],ge.prototype,"year",void 0),me([t.Watch()],ge.prototype,"month",void 0),me([t.Watch()],ge.prototype,"date",void 0),me([t.Watch()],ge.prototype,"hours",void 0),me([t.Watch()],ge.prototype,"minutes",void 0),me([t.Watch()],ge.prototype,"seconds",void 0),me([t.Debounce(10)],ge.prototype,"_buildup",null),ge=me([t.CustomElement({tagName:t.P+"-datetime-picker",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<div class="${t.PCSS}-datetime-picker">\n <div class="${t.PCSS}-datetime-picker-fields ${t.PCSS}-viewfinder">\n\n <div class="${t.PCSS}-datetime-picker-year">\n <${t.P}-select value="{{ :host.year, twoway }}" placeholder="..." datasource="{{ :host._years }}">\n </${t.P}-select></div>\n\n <div class="${t.PCSS}-datetime-picker-month">\n <${t.P}-select value="{{ :host.month, twoway }}" placeholder="..." value-property="value" text-property="label" datasource="{{ :host._months }}">\n </${t.P}-select></div>\n\n <div class="${t.PCSS}-datetime-picker-date">\n <${t.P}-select value="{{ :host.date, twoway }}" placeholder="..." value-property="value" text-property="label" datasource="{{ :host._dates }}">\n </${t.P}-select></div>\n\n <${t.P}-panel class="${t.PCSS}-datetime-picker-hours" hide="{{ :host.precision === 'day' }}">\n <${t.P}-select value="{{ :host.hours, twoway }}" datasource="{{ :host._a24 }}">\n </${t.P}-select></${t.P}-panel>\n\n <${t.P}-panel class="${t.PCSS}-datetime-picker-minutes" hide="{{ :host.precision === 'day' }}">\n <${t.P}-select value="{{ :host.minutes, twoway }}" datasource="{{ :host._a60 }}">\n </${t.P}-select></${t.P}-panel>\n\n <${t.P}-panel class="${t.PCSS}-datetime-picker-seconds" hide="{{ :host.precision !== 'second' }}">\n <${t.P}-select value="{{ :host.seconds, twoway }}" datasource="{{ :host._a60 }}">\n </${t.P}-select></${t.P}-panel>\n\n </div>\n <${t.P}-panel class="${t.PCSS}-datetime-picker-preview" hide="{{ Pacem.Utils.isNullOrEmpty(:host.dateValue) || :host.precision === 'day' || :host.readonly }}">\n <dl>\n <dt>local:</dt><dd><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></dd>\n <dt>iso:</dt><dd><${t.P}-text text="{{ (:host.dateValue && :host.dateValue.toISOString()) || '' }}"></${t.P}-text></dd>\n </dl>\n </${t.P}-panel>\n <${t.P}-span class="${t.PCSS}-readonly" css-class="{{ { 'date': :host.precision === 'day', 'datetime': :host.precision !== 'day' } }}" content="{{ :host.viewValue }}" hide="{{ !:host.readonly }}"></${t.P}-span>\n</div>`})],ge);var ye=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};class PacemBaseValidatorElement extends PacemFormRelevantElement{constructor(){super()}viewActivatedCallback(){super.viewActivatedCallback(),t.Utils.addClass(this,t.PCSS+"-validator")}propertyChangedCallback(e,i,a,r){super.propertyChangedCallback(e,i,a,r);let s=this.form;switch(e){case"watch":i&&s&&s.unregisterValidator(a,this),s&&s.registerValidator(a,this);break;case"invalid":break;case"form":let e=this.watch;t.Utils.isNullOrEmpty(e)||(null!=i&&i.unregisterValidator(e,this),null!=a&&a.registerValidator(e,this));break;case"disabled":this.triggerFormFieldValidation()}}#h;triggerFormFieldValidation(){const e=this.form,i=this.watch;t.Utils.isNull(e)||t.Utils.isNullOrEmpty(i)||(cancelAnimationFrame(this.#h),this.#h=requestAnimationFrame(()=>{e.validate(i)}))}validate(e){return this.disabled?t.Utils.fromResult(!0):this.evaluate(e)}}ye([t.Watch({converter:t.PropertyConverters.Boolean})],PacemBaseValidatorElement.prototype,"invalid",void 0),ye([t.Watch({converter:t.PropertyConverters.String})],PacemBaseValidatorElement.prototype,"errorMessage",void 0),ye([t.Watch({emit:!1,reflectBack:!0,converter:t.PropertyConverters.String})],PacemBaseValidatorElement.prototype,"watch",void 0);const fe=`<${t.P}-span part="error-message" hide="{{ !:host.invalid }}" text="{{ :host.errorMessage }}"></${t.P}-span>`;function _e(e){return t.Utils.isNullOrEmpty(e)}let be=class PacemRequiredValidatorElement extends PacemBaseValidatorElement{evaluate(e){let i=!_e(e);return t.Utils.fromResult(i)}};be=ye([t.CustomElement({tagName:t.P+"-required-validator",template:fe,shadow:t.Defaults.USE_SHADOW_ROOT})],be);let Ce=class PacemRegexValidatorElement extends PacemBaseValidatorElement{propertyChangedCallback(e,t,i,a){super.propertyChangedCallback(e,t,i,a),a||"pattern"!==e||this.triggerFormFieldValidation()}evaluate(e){let i=!0,a=this.pattern;return _e(e)||(i=new RegExp(a).test(e)),t.Utils.fromResult(i)}};ye([t.Watch({emit:!1,converter:t.PropertyConverters.String})],Ce.prototype,"pattern",void 0),Ce=ye([t.CustomElement({tagName:t.P+"-regex-validator",template:fe,shadow:t.Defaults.USE_SHADOW_ROOT})],Ce);let Pe=class PacemLengthValidatorElement extends PacemBaseValidatorElement{propertyChangedCallback(e,t,i,a){super.propertyChangedCallback(e,t,i,a),a||"min"!==e&&"max"!==e||this.triggerFormFieldValidation()}evaluate(e){let i=!0;return _e(e)||(this.min>=0&&(i=i&&(e||"").toString().length>=this.min),this.max>=0&&(i=i&&(e||"").toString().length<=this.max)),t.Utils.fromResult(i)}};ye([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],Pe.prototype,"min",void 0),ye([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],Pe.prototype,"max",void 0),Pe=ye([t.CustomElement({tagName:t.P+"-length-validator",template:fe,shadow:t.Defaults.USE_SHADOW_ROOT})],Pe);let Ee=class PacemRangeValidatorElement extends PacemBaseValidatorElement{propertyChangedCallback(e,t,i,a){super.propertyChangedCallback(e,t,i,a),a||"min"!==e&&"max"!==e||this.triggerFormFieldValidation()}evaluate(e){let i=!0;if(!_e(e)){let a=e;e instanceof Date||"number"!=typeof e&&(a=t.Utils.parseDate(e))instanceof Date&&isFinite(a.valueOf())?(null!=this.min&&(i=i&&a.valueOf()>=t.Utils.parseDate(this.min).valueOf()),null!=this.max&&(i=i&&a.valueOf()<=t.Utils.parseDate(this.max).valueOf())):(null!=this.min&&(i=i&&e>=this.min),null!=this.max&&(i=i&&e<=this.max))}return t.Utils.fromResult(i)}};ye([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],Ee.prototype,"min",void 0),ye([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],Ee.prototype,"max",void 0),Ee=ye([t.CustomElement({tagName:t.P+"-range-validator",template:fe,shadow:t.Defaults.USE_SHADOW_ROOT})],Ee);let we=class PacemCompareValidatorElement extends PacemBaseValidatorElement{propertyChangedCallback(e,t,i,a){super.propertyChangedCallback(e,t,i,a),a||"operator"!==e&&"to"!==e||this.triggerFormFieldValidation()}_prepareValuesForComparison(e,i){return t.Utils.Dates.isDate(e)||t.Utils.Dates.isDate(i)?[t.Utils.parseDate(e),t.Utils.parseDate(i)]:[e,i]}evaluate(e){let i=!0,a=this.to;if(!_e(e)&&!_e(a)){const t=this._prepareValuesForComparison(e,a);switch(e=t[0],a=t[1],this.operator){case"lessOrEqual":i=e<=a;break;case"less":i=e<a;break;case"greaterOrEqual":i=e>=a;break;case"greater":i=e>a;break;case"notEqual":i=e!==a;break;default:i=e===a}}return t.Utils.fromResult(i)}};ye([t.Watch({emit:!1,converter:t.PropertyConverters.String})],we.prototype,"operator",void 0),ye([t.Watch({emit:!1,reflectBack:!0})],we.prototype,"to",void 0),we=ye([t.CustomElement({tagName:t.P+"-compare-validator",template:fe,shadow:t.Defaults.USE_SHADOW_ROOT})],we);let Se=class PacemBinaryValidatorElement extends PacemBaseValidatorElement{propertyChangedCallback(e,t,i,a){super.propertyChangedCallback(e,t,i,a),a||"pattern"!==e&&"maxSize"!==e||this.triggerFormFieldValidation()}evaluate(e){let i=!0,a=this.pattern,r=this.maxSize;if(!_e(e)){if(!t.Utils.isNullOrEmpty(a)){let t="string"==typeof e?e:e.name;i=new RegExp(a,"i").test(t)}!t.Utils.isNull(r)&&"object"==typeof e&&e.size>0&&(i=i&&e.size<=r)}return t.Utils.fromResult(i)}};ye([t.Watch({emit:!1,converter:t.PropertyConverters.String})],Se.prototype,"pattern",void 0),ye([t.Watch({emit:!1,converter:t.PropertyConverters.String})],Se.prototype,"maxSize",void 0),Se=ye([t.CustomElement({tagName:t.P+"-binary-validator",template:fe,shadow:t.Defaults.USE_SHADOW_ROOT})],Se);let ke=class PacemAsyncValidatorElement extends PacemBaseValidatorElement{constructor(){super(...arguments),this._deferredToken=null}_evaluateResult(){const e=this._fetcher.result;switch(e){case"true":return!0;case"false":return!1;default:try{let i=JSON.parse(e);return t.Utils.getApiResult(i)||!1}catch(e){return!1}}}_fetch(e){const i=this._deferredToken,a=this._fetcher;var r=this.parameters||{};r[this.watch]=e;const s={parameters:r,url:this.url,as:"text",method:this.method},n=t.Utils.jsonSortStringify(s),o=this.#p;let l=!1;if(t.Utils.isNullOrEmpty(o)||(l=n===o),l){const e=this._evaluateResult();i.resolve(e)}else t.Utils.extend(a,s),clearTimeout(this._debouncer),this._debouncer=setTimeout(()=>{a.fetch().then(e=>{const t=this._evaluateResult();i.resolve(t),this.#p=n},e=>{i.resolve(!1)})},1e3);return i.promise}#p;evaluate(e){return t.Utils.isNullOrEmpty(e)?t.Utils.fromResult(!0):(this._deferredToken=this._deferredToken=t.DeferPromise.defer(),this._fetch(e).then(e=>(this._deferredToken=null,e),e=>(this._deferredToken=null,!1)))}propertyChangedCallback(e,t,i,a){if(super.propertyChangedCallback(e,t,i,a),!a)switch(e){case"parameters":case"url":case"method":case"fetchCredentials":case"fetchHeaders":this.triggerFormFieldValidation()}}};ye([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],ke.prototype,"parameters",void 0),ye([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],ke.prototype,"fetchCredentials",void 0),ye([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],ke.prototype,"fetchHeaders",void 0),ye([t.Watch({emit:!1,converter:t.PropertyConverters.String})],ke.prototype,"url",void 0),ye([t.Watch({emit:!1,converter:t.PropertyConverters.String})],ke.prototype,"method",void 0),ye([t.ViewChild(t.P+"-fetch")],ke.prototype,"_fetcher",void 0),ke=ye([t.CustomElement({tagName:t.P+"-async-validator",template:fe+`<${t.P}-fetch autofetch="false" throttle="true" credentials="{{ :host.fetchCredentials }}" headers="{{ :host.fetchHeaders }}"></${t.P}-fetch>`,shadow:t.Defaults.USE_SHADOW_ROOT})],ke);let $e=class PacemCustomValidatorElement extends PacemBaseValidatorElement{propertyChangedCallback(e,t,i,a){super.propertyChangedCallback(e,t,i,a),a||"isValid"!==e||this.triggerFormFieldValidation()}evaluate(e){let i=!0;return _e(e)||(i=!!this.isValid),t.Utils.fromResult(i)}};ye([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],$e.prototype,"isValid",void 0),$e=ye([t.CustomElement({tagName:t.P+"-custom-validator",template:fe,shadow:t.Defaults.USE_SHADOW_ROOT})],$e);var Ue=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};function Ne(e){return new RegExp(e).source}let Oe=class PacemFormFieldElement extends PacemFormRelevantElement{constructor(e=new i.Components.UI.MarkdownService){super(),this._md=e,this._entityPropertyChangeHandler=e=>{this.dispatchEvent(new t.PropertyChangeEvent({propertyName:"entity",currentValue:this.entity}))},this._labelClickHandler=e=>{document.getElementById(this._label.htmlFor).focus()},this._key="_"+t.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(e,i,a,r){switch(super.propertyChangedCallback(e,i,a,r),e){case"readonly":this._ensureBalloon();break;case"metadata":this._ensureBalloon(),this._buildUpCss(),this._buildUpLabel(),this._buildUpField();break;case"entity":i instanceof HTMLElement&&i.removeEventListener(t.PropertyChangeEventName,this._entityPropertyChangeHandler,!1),a instanceof HTMLElement&&a.addEventListener(t.PropertyChangeEventName,this._entityPropertyChangeHandler,!1)}}disconnectedCallback(){this.entity instanceof HTMLElement&&this.entity.removeEventListener(t.PropertyChangeEventName,this._entityPropertyChangeHandler,!1),t.Utils.isNull(this._label)||this._label.removeEventListener("click",this._labelClickHandler,!1),t.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 e,a;const r=this.readonly||!1===(a=this._normalizeTooltip()).type||t.Utils.isNullOrEmpty(e=this.metadata&&this.metadata.display&&this.metadata.display.description);if(t.Utils.isNull(this._balloon)&&!r){let e=document.createElement(t.P+"-balloon");e.options={behavior:i.Components.UI.BalloonBehavior.Tooltip,trigger:a.trigger||i.Components.UI.BalloonTrigger.Hover,position:a.position||i.Components.UI.BalloonPosition.Top,hoverDelay:200,hoverTimeout:50,align:a.align||i.Components.UI.BalloonAlignment.Auto},t.Utils.addClass(e,t.PCSS+"-field-tooltip"),t.CustomElementUtils.findAncestorShell(this).appendChild(this._balloon=e)}const s=this._balloon;if(!(t.Utils.isNull(s)||(s.target=this._label,s.disabled=r))){const t=e||"";switch(a.type){case"md":case"markdown":s.innerHTML=this._md.toHtml(t);break;case"html":s.innerHTML=t;break;default:s.innerText=t}}}_buildUpCss(){const e=this.metadata?.display;if(!t.Utils.isNull(e)){if("function"==typeof e.cssClass){const{cssClassAttr:t}=e.cssClass(this,"$this","$this.entity");this.setAttribute("css-class",t)}else this.cssClass=e.cssClass;if("function"==typeof e.css){const{cssAttr:t}=e.css(this,"$this","$this.entity");this.setAttribute("css",t)}else this.css=e.css}}_buildUpLabel(){const e=this._label,i=e.firstElementChild,a=this.metadata;e.htmlFor=this._key,t.Utils.addClass(e,t.PCSS+"-label");const r=this.metadata.validators;if(r&&r.find(e=>"required"===e.type)?t.Utils.addClass(e,t.PCSS+"-required"):t.Utils.removeClass(e,t.PCSS+"-required"),t.Utils.isNull(this._balloon)||this._balloon.disabled?t.Utils.removeClass(e,t.PCSS+"-tooltip"):t.Utils.addClass(e,t.PCSS+"-tooltip"),"function"==typeof a.display?.name){const{contentAttr:e}=a.display.name(this,":host",":host.entity","::_form");i.setAttribute("content",e)}else i.removeAttribute("content"),i.content=a.display&&a.display.name||a.prop;e.setAttribute("id","label"+this._key),e.addEventListener("click",this._labelClickHandler,!1)}_isValueNullOrEmpty(e=this.entity,i=this.metadata){if(t.Utils.isNull(i))return!0;const a=i.prop.split(".");let r=e;for(let e=0;e<a.length;e++){const i=a[e];if(t.Utils.isNullOrEmpty(r&&r[i]))return!0;r=r[i]}return!1}_handleValueChange(e){if("value"===e.detail.propertyName){const i=e.detail.currentValue,a=this.metadata.prop;if(this.entity instanceof HTMLElement){let e=t.CustomElementUtils.camelToKebab(a);t.Utils.isNullOrEmpty(i)?this.entity.removeAttribute(e):this.entity.setAttribute(e,i.toString())}else this.entity[a]=i}}_adjustDependencyValue(e){return t.Utils.Dates.isDate(e)?t.Utils.Dates.parse(e).toISOString():e}_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 }}")}_apiResult(e){return t.Utils.getApiResult(e)}_buildUpField(){this._field&&this._field.remove(),this._fetcher.removeAttribute("parameters"),this._fetcher.result=this._fetcher.url=null;for(var e=this._validators.children.length-1;e>=0;e--)this._validators.children[e].remove();var i=this.metadata;let a=t.P+"-input-text",r=t.P+(i.display&&"slider"===i.display.ui?"-slider":"-input-number"),s={id:this._key,name:i.prop,readonly:"{{ :host.readonly || :host.metadata.isReadOnly || ::_form.readonly }}",value:`{{ :host.entity.${i.prop}, twoway }}`,placeholder:`${i.display&&i.display.watermark||""}`};1==i.extra?.autofocus&&(s["on-load"]="requestAnimationFrame(() => $this.focus())");let n=i.extra||{},o={},l="false",c="",d="",h="",p=[];if(!t.Utils.isNullOrEmpty(n.dependsOn))if("function"==typeof n.dependsOn){const E=n.dependsOn(this,":host",":host.entity","$this.entity"),w=E.hideAttr;if(t.Utils.isNullOrEmpty(w)||this.setAttribute("hide",w),t.Utils.isNullOrEmpty(E.disabledAttr)||(l=E.disabledAttr,t.CustomElementUtils.isBindingAttribute(l)&&(d=t.CustomElementUtils.extractBindingAttributeExpression(l))),!t.Utils.isNullOrEmpty(E.parameterAttrs)){const S=E.parameterAttrs,k=[];for(let $ in S){const U=S[$];k.push(`${$}: ${U}`),p.push({prop:U})}h=k.join(", ")}}else{p=n.dependsOn;let N={empty:[],notEqual:{}},O={empty:[],notEqual:{}},x=[];for(var u of p){let D=":host.entity."+u.prop,H="$this.entity."+u.prop;if(t.Utils.isNullOrEmpty(u.value)){if(!u.optional){let A=e=>"$pacem.isNullOrEmpty("+e+")";N.empty.push(A(D)),u.hide&&O.empty.push(A(H))}}else{let T=e=>e+" !== "+JSON.stringify(u.value);(N.notEqual[D]=N.notEqual[D]||[]).push(T(D)),u.hide&&(O.notEqual[H]=O.notEqual[H]||[]).push(T(H))}x.push(`${u.alias||u.prop}: :host._adjustDependencyValue(${D})`),u.optional||(c+=`!$pacem.isNullOrEmpty(${D}) && `)}h=x.join(", ");let V=e=>{let i="false",a="false";if(!t.Utils.isNullOrEmpty(e.notEqual)){const t=[];for(let i in e.notEqual)t.push("("+e.notEqual[i].join(" && ")+")");i="("+t.join(" || ")+")"}return t.Utils.isNullOrEmpty(e.empty)||(a="("+e.empty.join(" || ")+")"),i+" || "+a};d=V(N),l=`{{ ${d} }}`,this.setAttribute("hide",`{{ ${V(O)} }}`)}const m="fn",v=this[m]=this[m]||{},g=(e=[])=>{let i=(p||[]).map(e=>":host.entity."+e.prop).join(", ");const a="fn"+t.Utils.uniqueCode();if("function"==typeof e)v[a]=e;else{if(!t.Utils.isArray(e))throw"Unsupported source format.";v[a]=()=>e}return`{{ :host.${m}.${a}(${i}) }}`},y=new DocumentFragment;let f;if("function"==typeof i.type){var _=i.type(this,":host",":host.entity");if(-1===_.tagName.indexOf("-"))this.log(t.Logging.LogLevel.Error,`${a} is not an allowed form-field`);else{function R(e,i){if(!t.Utils.isNullOrEmpty(i))for(let r of i){if(-1===r.tagName.indexOf("-")){this.log(t.Logging.LogLevel.Error,`${r.tagName} is not an allowed child element for form-field ${a}`);continue}const i=document.createElement(r.tagName);if(!t.Utils.isNullOrEmpty(r.attrs))for(let e in r.attrs){const t=r.attrs[e];i.setAttribute(e,t)}t.Utils.isNullOrEmpty(r.children)||R(i,r.children),e.appendChild(i)}}a=_.tagName,t.Utils.extend(s,_.attrs||{}),R(y,_.children)}}else switch(f=i.display&&i.display.ui){case"contentEditable":console.warn("`contentEditable` ui hint is deprecated. Lean on `dataType` equal to 'HTML' instead."),a=t.P+"-contenteditable",y.append(ContenteditableUtils.getDefaultDashboard());break;case"snapshot":a=t.P+"-snapshot",n.width>0&&(s.width=""+n.width),n.height>0&&(s.height=""+n.height),n.quality>=0&&(s.quality=""+n.quality);break;case"chars":case"digits":case"otp":a=t.P+"-input-chars",n.charCount>0&&(s.charCount=""+n.charCount),t.Utils.isNullOrEmpty(n.inputTransform)||(s["input-transform"]=n.inputTransform);break;case"oneToMany":case"dropdown":case"radioList":case"checkboxList":case"manyToMany":"oneToMany"===f||"dropdown"===f?(a=t.P+"-select",!1!==n.preventWheel&&(s["on-wheel"]="$event.preventDefault()")):(delete s.placeholder,a=t.P+("radioList"===f?"-radio-list":"-checkbox-list")),t.Utils.isNullOrEmpty(n.textProperty)||(s["text-property"]=n.textProperty),t.Utils.isNullOrEmpty(n.disabledProperty)||(s["disabled-property"]=n.disabledProperty),t.Utils.isNullOrEmpty(n.valueProperty)||(i.isComplexType?s["compare-by"]=n.valueProperty:s["value-property"]=n.valueProperty),t.Utils.isNullOrEmpty(n.source)?(this._fetcher.id=`fetch${this._key}`,this._fetcher.url=n.sourceUrl,this._fetcher.method=n.verb,o.parameters=`{{ { ${h} } }}`,o.disabled=l,s.datasource=`{{ ${c}:host._apiResult(#fetch${this._key}.result) || null }}`):s.datasource=g(n.source);break;case"suggest":case"tags":case"autocomplete":const L="tags"===i.display.ui;a=t.P+(L?"-tags":"-suggest"),this._fetcher.id=`fetch${this._key}`,t.Utils.isNullOrEmpty(n.textProperty)||(s["text-property"]=n.textProperty);let I=`#${this._key}.value`;if(t.Utils.isNullOrEmpty(n.valueProperty)||(s["compare-by"]=n.valueProperty,L?I=`(${I} && ${I}.${n.valueProperty}) || ''`:i.isComplexType?I+=` && ${I}.${n.valueProperty}`:s["value-property"]=n.valueProperty),t.Utils.isNullOrEmpty(n.sourceUrl)?s.datasource=g(n.source):(o.url=`${n.sourceUrl}`,this._fetcher.method=n.verb,t.Utils.isNullOrEmpty(n.dependsOn)?o.parameters=`{{ {q: #${this._key}.hint || '', ${n.valueProperty||"value"}: ${I} || '' } }}`:(o.parameters=`{{ { ${h}, q: #${this._key}.hint || '', ${n.valueProperty||"value"}: ${I} || '' } }}`,o.disabled=l),s.datasource=`{{ ${c}:host._apiResult(#fetch${this._key}.result) || null }}`),L)s["allow-new"]=(!0===i.extra.allowNew).toString(),s["allow-duplicates"]=(!0===i.extra.allowDuplicates).toString();else{if(t.Utils.isNullOrEmpty(n.disabledProperty)||(s["disabled-property"]=n.disabledProperty),!t.Utils.isNullOrEmpty(n.itemtemplate)){const B=n.itemtemplate;B instanceof HTMLElement?(s.itemtemplate="{{ #"+(B.id=B.id||this._key+"_itemtmpl")+" }}",B.isConnected||this.append(B)):s.itemtemplate=B}if(!t.Utils.isNullOrEmpty(n.filterFields)){const j=n.filterFields;s["filter-fields"]=t.Utils.isArray(j)?j.join(" "):j}t.Utils.isNullOrEmpty(n.maxSuggestions)||(s["max-suggestions"]=n.maxSuggestions.toString())}break;case"calendar":a=t.P+"-calendar-picker";const F=i.display?.format??i.extra?.format;t.Utils.isNullOrEmpty(F)||(s.format="{{ "+JSON.stringify(F)+" }}"),t.Utils.isNullOrEmpty(n.disabledRanges)||(s["disabled-ranges"]="{{ "+JSON.stringify(n.disabledRanges)+" }}");break;case"dictionary":a=t.P+"-namevalue-list",s.dictionary="true";break;case"switcher":if("boolean"!==(i.type||"").toLowerCase())break;s.class="checkbox-switch";default:let W=(i.dataType||i.type||"").toLowerCase();switch(W){case"upload":a=t.P+"-upload";let M=i.extra||{};s.url=M.uploadUrl,s.parallelism=""+M.parallelism,s["chunk-size"]=""+M.chunkSize,s["max-image-width"]=""+M.maxImageWidth,s["max-image-height"]=""+M.maxImageHeight,s["select-mode"]=M.mode??"file";break;case"html":a=t.P+"-contenteditable",y.append(ContenteditableUtils.getDefaultDashboard());break;case"enumeration":a=t.P+"-radio-list",s.class=t.PCSS+"-radio-list",s["value-property"]="value",s["text-property"]="caption",s.datasource="{{ "+JSON.stringify(i.extra.enum)+" }}",delete s.placeholder;break;case"password":a=t.P+"-input-password";break;case"emailaddress":a=t.P+"-input-email";break;case"color":a=t.P+"-input-color";break;case"time":case"date":case"datetime":a=t.P+"-datetime-picker",delete s.placeholder,"datetime"===W&&(s.precision="minute");const z=i.display?.format??i.extra?.format;t.Utils.isNullOrEmpty(z)||(s.format="{{ "+JSON.stringify(z)+" }}"),t.Utils.isNullOrEmpty(n.disabledRanges)||(s["disabled-ranges"]="{{ "+JSON.stringify(n.disabledRanges)+" }}");break;case"url":a=t.P+"-input-url";break;case"phonenumber":a=t.P+"-input-tel";break;case"multilinetext":a=t.P+"-textarea";break;case"markdown":a=t.P+"-textarea-markdown";break;case"latlng":a=t.P+"-latlng",t.Utils.isNullOrEmpty(i.extra)||"object"!=typeof i.extra||t.Utils.isArray(i.extra)||(s.options=JSON.stringify(i.extra));break;case"percent":case"percentage":case"currency":let q="currency"===W?{style:"currency",currency:"EUR"}:{style:"percent",maximumFractionDigits:2},J=i.display?.format??q;s.format=JSON.stringify(J);default:switch((i.type||"").toLowerCase()){case"boolean":a=t.P+"-checkbox",s["true-value"]="{{ true }}",s["false-value"]="{{ false }}",s.caption=s.placeholder,delete s.placeholder;break;case"byte":s.min="0",s.max="255";case"int16":case"int32":case"int64":case"short":case"integer":case"int":case"long":s.step=""+(i.extra?.step??"1"),a=r;const Y=i.display?.format;t.Utils.isNullOrEmpty(Y)||(s.format=JSON.stringify(Y)),!1!==n.preventWheel&&a===t.P+"-input-number"&&(s["on-wheel"]="$event.preventDefault()");break;case"double":case"decimal":case"float":case"single":case"number":a=r,s.step=""+(i.extra?.step??"any");const G=i.display?.format;t.Utils.isNullOrEmpty(G)||(s.format=JSON.stringify(G)),!1!==n.preventWheel&&a===t.P+"-input-number"&&(s["on-wheel"]="$event.preventDefault()");break;default:if(("array"===i.type||"object"===i.type)&&!t.Utils.isNullOrEmpty(i.props)){if(a=t.P+"-childform",delete s.placeholder,s.metadata=t.Utils.Json.stringify(i.props,{functions:t.JsonFunctionConversion.Reference}),s.mode=i.type,s["lock-items"]=""+(i.extra&&i.extra.lockItems||!1),s.logger="{{ :host.logger }}",!t.Utils.isNullOrEmpty(p)){var b="";for(let K of p)b+=`<${t.P}-childform-propagator model="${s.value}" watch="{{ :host.entity.${K.prop} }}" property="${K.alias||K.prop}"></${t.P}-childform-propagator>\n`;this._container.innerHTML=b}s["fetch-credentials"]="{{ :host.fetchCredentials }}",s["fetch-headers"]="{{ :host.fetchHeaders }}"}}}}if(!t.Utils.isNullOrEmpty(i.commands)){t.Utils.addClass(this._container,t.PCSS+"-fieldgroup");const X=this._container.appendChild(document.createElement("div")),Z=this._container.appendChild(document.createElement("div"));t.Utils.addClass(X,`fieldgroup-prepend ${t.PCSS}-buttonset buttons`),t.Utils.addClass(Z,`fieldgroup-append ${t.PCSS}-buttonset buttons`);const Q=d||"false";i.commands.forEach(e=>{const a=document.createElement(t.P+"-button");a.setAttribute("icon-glyph",e.icon),a.setAttribute("command-name",e.name),e.dependsOnValue?(a.setAttribute("disabled",`{{ (${Q}) || !::_form.valid || $pacem.isNullOrEmpty(:host.entity.${i.prop}) }}`),a.setAttribute("command-argument",`{{ :host.entity.${i.prop} }}`)):a.setAttribute("disabled",l),a.setAttribute("tooltip",e.tooltip),t.Utils.isNullOrEmpty(e.cssClass)||t.Utils.addClass(a,e.cssClass.join(" ")),(e.prepend?X:Z).appendChild(a)})}t.Utils.isNullOrEmpty(i.validators)||i.validators.forEach(e=>{var r,n={},o={};switch(function(e){return"errorMessage"in e}(e)&&(n=e.params||{},o["error-message"]=e.errorMessage),function(e){return"attributes"in e&&"function"==typeof e.attributes}(e)&&t.Utils.extend(o,e.attributes(this,":host",":host.entity")),e.type){case"required":s.required="true",r=new be;break;case"length":let l=new Pe;r=l;let c=n&&n.max,d=n&&n.min;null!=c?(s.maxlength=""+(l.max=c),a===t.P+"-input-chars"&&(s.count??=""+c)):"max"in o&&(s.max=o.max),null!=d?s.minlength=""+(l.min=d):"min"in o&&(s.minlength=o.min);break;case"range":let h=new Ee;r=h;let u=n&&n.max,m=n&&n.min,v=a===t.P+"-datetime-picker";null!=u?(h.max=u,s.max="{{ "+(v?"'"+u+"'":u)+" }}"):"max"in o&&(s.max=o.max),null!=m?(h.min=m,s.min="{{ "+(v?"'"+m+"'":m)+" }}"):"min"in o&&(s.min=o.min);break;case"email":let g=new Ce;r=g,s.pattern=Ne(g.pattern=/^[\w\-\.]+@[\w\-\.]+\.[a-zA-Z0-9]{2,6}$/);break;case"regex":let y=new Ce;r=y;let f=n.pattern;f||=o.pattern,s.pattern=Ne(f),y.pattern=f;break;case"binary":let _=new Se;r=_;let b=n.pattern;null!=b?(s.pattern=Ne(b),_.pattern=b):"pattern"in o&&(s.pattern=o.pattern);let C=n&&n.maxSize;null!=C?(_.maxSize=C,s["max-size"]=""+C):"max-size"in o&&(s["max-size"]=o["max-size"]);break;case"compare":let P=new we;r=P;let E="";if("value"in n)E=JSON.stringify(n.value);else{E=`:host.entity.${"to"in n?n.to:n.toProperty}`}const w=`{{ ${E} }}`;P.setAttribute("to",w);let S=P.operator=n.operator||o.operator||"equal";if(a===t.P+"-datetime-picker")switch(S){case"lessOrEqual":case"less":s.max=w;break;case"greaterOrEqual":case"greater":s.min=w}break;case"async":let k=new ke;r=k,k.url=n.url;let $=[],U=n.dependsOn||p;$.push(`${i.prop}: :host._adjustDependencyValue(:host.entity.${i.prop})`);for(let e of U||[])$.push(`${e.alias||e.prop}: :host._adjustDependencyValue(:host.entity.${e.prop})`);k.setAttribute("parameters",`{{ { ${$.join(", ")} } }}`),k.method=n.verb||t.Net.HttpMethod.Get,k.setAttribute("fetch-credentials","{{ :host.fetchCredentials }}"),k.setAttribute("fetch-headers","{{ :host.fetchHeaders }}");break;case"custom":r=new $e;break;default:if(!t.Utils.isNullOrEmpty(e.type)&&e.type.indexOf("-")>0){const t=e.type,i=document.createElement(t);i instanceof PacemBaseValidatorElement&&(r=i)}}if(t.Utils.isNull(r))throw`Cannot generate a formfield validator based on type: ${e.type}.`;r.watch=i.prop,r.setAttribute("hide","{{ !this.invalid }}"),r.setAttribute("disabled",l);for(let e in o)r.setAttribute(e,o[e]);this._validators.appendChild(r)});let C=document.createElement(a);for(var P in s){let ee;t.Utils.isNullOrEmpty(ee=s[P])||C.setAttribute(P,ee)}for(var P in C.append(y),this._field=C,this._container.insertBefore(C,this._container.firstElementChild),o){let te;t.Utils.isNullOrEmpty(te=o[P])||this._fetcher.setAttribute(P,te)}this.dispatchEvent(new t.PropertyChangeEvent({propertyName:"field",currentValue:C}))}};Ue([t.ViewChild("label")],Oe.prototype,"_label",void 0),Ue([t.ViewChild(`div.${t.PCSS}-input-container`)],Oe.prototype,"_container",void 0),Ue([t.ViewChild(t.P+"-fetch")],Oe.prototype,"_fetcher",void 0),Ue([t.ViewChild(t.P+"-form")],Oe.prototype,"_form",void 0),Ue([t.ViewChild(t.P+"-panel."+t.PCSS+"-validators")],Oe.prototype,"_validators",void 0),Ue([t.Watch({converter:t.PropertyConverters.Json})],Oe.prototype,"metadata",void 0),Ue([t.Watch({converter:t.PropertyConverters.Json})],Oe.prototype,"fetchHeaders",void 0),Ue([t.Watch({converter:t.PropertyConverters.String})],Oe.prototype,"fetchCredentials",void 0),Ue([t.Watch({converter:t.PropertyConverters.Boolean})],Oe.prototype,"readonly",void 0),Ue([t.Watch()],Oe.prototype,"entity",void 0),Oe=Ue([t.CustomElement({tagName:t.P+"-form-field",template:`<${t.P}-form class="${t.PCSS}-field" logger="{{ :host.logger }}" \ncss-class="{{ {'${t.PCSS}-fetching': ::_fetcher.fetching, '${t.PCSS}-dirty': this.dirty, '${t.PCSS}-invalid': !this.valid, '${t.PCSS}-editable': !:host.readonly, '${t.PCSS}-readonly': :host.readonly, '${t.PCSS}-pristine': !this.dirty, '${t.PCSS}-valid': this.valid, '${t.PCSS}-has-value': !:host._isValueNullOrEmpty(:host.entity, :host.metadata) } }}">\n <label class="${t.PCSS}-label"><${t.P}-span></${t.P}-span></label>\n <div class="${t.PCSS}-input-container"></div>\n <${t.P}-fetch debounce="300" logger="{{ :host.logger }}" credentials="{{ :host.fetchCredentials }}" headers="{{ :host.fetchHeaders }}" diff-by-values="true"\n on-fetchresult=":host._broadcastFetchResult($event.detail)"></${t.P}-fetch>\n <${t.P}-panel class="${t.PCSS}-validators" hide="{{ ::_form.valid || !::_form.dirty || :host.readonly }}"></${t.P}-panel>\n</${t.P}-form>`})],Oe);var xe=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};let Ve=class PacemGeolocateElement extends PacemBaseElement{constructor(){super(...arguments),this._dragendHandler=e=>{this._reverseGeocoder.position=e.detail.position}}get inputFields(){return[]}toggleReadonlyView(e){this._setupSuggest(),this._setupMapMarker()}onChange(e){return new Promise((i,s)=>{if("success"===e.type&&e.target===this._reverseGeocoder){const r=this.#u.position,s=e.detail.sort((e,t)=>a.Maps.MapProjection.distanceBetween(e.position,r)<a.Maps.MapProjection.distanceBetween(t.position,r)?0:-1),n=s[0].position.altitude,o=t.Utils.extend({},s[0],{position:t.Utils.extend({altitude:n},r)});i(this.value=o)}else e.type===r&&e.target===this._suggest?i(this.value=this._suggest.value):i(this.value)})}fetch(e){a.Maps.LatLng.isLatLng(e)&&(this.#u.position=this._reverseGeocoder.position=e)}compareValuePropertyValues(e,t){const i=e?.position??a.Maps.LatLng.Empty,r=t?.position??a.Maps.LatLng.Empty;return a.Maps.LatLng.equals(i,r)}acceptValue(e){t.Utils.isNull(e)?this._datasource.model=[]:(this._datasource.model=[e],this._setupMapMarker()),this._setupSuggest()}getViewValue(e){return e?.fullAddress||""}convertValueAttributeToProperty(e){return t.PropertyConverters.Json.convert(e,this)}#u;viewActivatedCallback(){super.viewActivatedCallback(),this._setup()}propertyChangedCallback(e,t,i,a){if(super.propertyChangedCallback(e,t,i,a),!a)switch(e){case"adapter":this._setupAdapters(i);break;case"map":t&&this._detachMarker(t),i&&this._setupMapMarker(i);break;case"icon":this._setupMapMarker();break;case"plaeholder":this._setupSuggest();break;case"disabled":this._setupMapMarker(),this._setupSuggest()}}disconnectedCallback(){this._disposeMarker(),super.disconnectedCallback()}_setupAdapters(e=this.adapter){const i=this._geocoder,a=this._reverseGeocoder;t.Utils.isNull(i)||(i.adapter=e),t.Utils.isNull(a)||(a.adapter=e)}_setupSuggest(){const e=this._suggest;t.Utils.isNull(e)||(e.placeholder=this.placeholder??"search...",e.readonly=this.readonly,e.disabled=this.disabled,e.value=this.value)}_detachMarker(e=this.map){const i=this.#u;t.Utils.isNull(i)||i.map!==e||i.remove()}_createMarker(){const e=new a.Components.Maps.PacemMapMarkerElement;return e.addEventListener("dragend",this._dragendHandler,!1),e}_disposeMarker(){const e=this.#u;t.Utils.isNull(e)||e.removeEventListener("dragend",this._dragendHandler,!1)}_setupMapMarker(e=this.map){const i=this.#u||(this.#u=this._createMarker());i.icon=this.icon,i.draggable=!this.readonly&&!this.disabled,i.hide=this.disabled;const a=this.value;a&&a.position&&(i.position=a.position),i.map===e||t.Utils.isNull(e)||e.appendChild(i)}_setup(){this._setupAdapters(),this._setupSuggest(),this._setupMapMarker()}};xe([t.Watch({emit:!1,converter:t.PropertyConverters.Element})],Ve.prototype,"adapter",void 0),xe([t.Watch({emit:!1,converter:t.PropertyConverters.Element})],Ve.prototype,"map",void 0),xe([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],Ve.prototype,"icon",void 0),xe([t.ViewChild(t.P+"-data[ds]")],Ve.prototype,"_datasource",void 0),xe([t.ViewChild(t.P+"-suggest")],Ve.prototype,"_suggest",void 0),xe([t.ViewChild(t.P+"-map-geocode")],Ve.prototype,"_geocoder",void 0),xe([t.ViewChild(t.P+"-map-geocode[reverse]")],Ve.prototype,"_reverseGeocoder",void 0),Ve=xe([t.CustomElement({tagName:t.P+"-geolocate",shadow:!1,template:`<${t.P}-map-geocode search="{{ ::_suggest.hint }}"\n disabled="{{ (::_suggest.hint || '').length < 3 }}" on-success="::_datasource.model = $event.detail"></${t.P}-map-geocode>\n<${t.P}-map-geocode reverse on-success=":host.changeHandler($event)"></${t.P}-map-geocode>\n\n<${t.P}-data ds></${t.P}-data>\n\n<${t.P}-suggest on-change=":host.changeHandler($event)" datasource="{{ ::_datasource.model || [] }}"\n compare-by="fullAddress" text-property="fullAddress"></${t.P}-suggest>`})],Ve);var De=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};class HierarchyChangeEvent extends CustomEvent{constructor(e){super("hierarchychange",{detail:e,bubbles:!1,cancelable:!1})}}const He="hierarchy-item",Ae=He+" "+t.PCSS+"-anim anim-fade-in anim-sudden",Te="{{ { 'item-disabled' : ^item.disabled } }}",Re="pacemHierarchy",Le="item-content",Ie="item-link",Fe=Ie+" icon-rotate rotate-135",We="link",Be="item-move",je="drag_indicator",Me="parents";let ze=class PacemHierarchyElement extends PacemBaseElement{getViewValue(e){return""}convertValueAttributeToProperty(e){return t.Utils.Json.parse(e)}constructor(){super(),this.#m=new Map,this.#v=new Map,this.unlinkCaption="Delete",this._binderClickHandler=e=>{const i=e.originalEvent.type;if("mousedown"===i&&1===e.originalEvent.button){t.avoidHandler(e.originalEvent);const i=e.srcElement;this._unlink(i)}else if("click"===i||"contextmenu"===i){t.avoidHandler(e.originalEvent),this.#g=e.srcElement;const i=this._balloon;i.target={x:e.pageX,y:e.pageY},i.popup()}},this._dragInitHandler=e=>{let a=e.detail;const r=this._dragger;r.floater=document.createElement("span"),r.dropTargets=Array.from(this.#v.keys()).filter(e=>e!==a.element),t.Utils.isNull(this.#y)||this.#y.remove();const s=this.#y=new i.Components.UI.PacemBinderElement;s.from=a.element,this.#f.appendChild(s)},this._dragStartHandler=e=>{t.Utils.addClass(e.detail.element,"item-drag")},this._dragHandler=e=>{this.#y.to=e.detail.currentPosition},this._dragEndHandler=e=>{t.Utils.removeClass(e.detail.element,"item-drag"),this.#y.remove(),this.#y=null},this._dropHandler=e=>{const t=e.detail.data,i=this.#v.get(e.detail.target);this._isInAncestors(t,i)||this._isInDescendants(t,i)||this._compileHierarchy({source:t,target:i})},this._dragOverHandler=e=>{const t=e.detail.data,i=this.#v.get(e.detail.target);(i.disabled||this._isInAncestors(t,i)||this._isInDescendants(t,i))&&e.preventDefault()},this._dragOutHandler=e=>{},this._popoutHandler=e=>{this._balloon.popout()},this.#_=t.Utils.uniqueCode()}#_;#m;#y;#g;#v;#f;get inputFields(){return[]}toggleReadonlyView(e){this._dragger.disabled=e,t.Utils.isNull(this._adaptedDatasource)||this._databind()}onChange(e){return new Promise((i,a)=>{t.CustomEventUtils.isInstanceOf(e,HierarchyChangeEvent)&&i(this.value=e.detail),i(this.value)})}acceptValue(e){}viewActivatedCallback(){super.viewActivatedCallback(),this.#f=t.CustomElementUtils.findAncestorShell(this),this._setupItemTemplate(),this._setupDragger(),this._setupBalloon()}propertyChangedCallback(e,t,i,a){switch(super.propertyChangedCallback(e,t,i,a),e){case"datasource":case"textProperty":case"disabledProperty":case"valueProperty":cancelAnimationFrame(this._handle),this._handle=requestAnimationFrame(()=>{this._buildAdaptedDatasource()});break;case"itemtemplate":a||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,i=e;return(t=this.valueProperty)&&(i=e[t]),i}_mapEntityToViewValue(e){let t,i=e.toString();return(t=this.textProperty)&&(i=e[t]),i}_mapEntityToItem(e){if(null==e)throw new Error("Entity cannot be null");let i=!1;const a=this.disabledProperty;return t.Utils.isNullOrEmpty(a)||(i=e[a]||!1),{value:this._mapEntityToValue(e),viewValue:this._mapEntityToViewValue(e),disabled:i,data:e}}_unlink(e){var t;e instanceof i.Components.UI.PacemBinderElement?t=e:(e.preventDefault(),e.stopPropagation(),t=this.#g);const{parent:a,child:r}=JSON.parse(t.dataset[Re]),s=this._adaptedDatasource,n=s.find(e=>e.value===a),o=s.find(e=>e.value===r);n.disabled||o.disabled||this._compileHierarchy({source:n,target:o},!0)}_buildHierarchyItemDomId(e){return`hierarchyitem_${this.#_}_${e}`}_itemCreate(e){const t=e.detail.dom.find(e=>e instanceof HTMLElement&&e.classList.contains(He));e.detail.index;const a=e.detail.item;t.id=this._buildHierarchyItemDomId(a.value),a.disabled?t.setAttribute("behaviors","{{ [#"+this._dragger2.id+"] }}"):t.setAttribute("behaviors","{{ [#"+this._dragger.id+", #"+this._dragger2.id+"] }}");for(let e of a.parents||[]){const r=new i.Components.UI.PacemBinderElement;r.to=t,r.toAnchor=i.Components.UI.BinderAnchor.Top,r.toEnd=i.Components.UI.BinderEnd.Arrow,r.setAttribute("from","{{ #"+this._buildHierarchyItemDomId(e.value)+" }}"),r.fromAnchor=i.Components.UI.BinderAnchor.Bottom,r.cssClass=["hierarchy-binder"],r.interactive=!this.readonly&&!a.disabled&&!e.disabled,r.addEventListener(i.Components.UI.BinderInteractionEventName,this._binderClickHandler,!1),r.dataset[Re]=JSON.stringify({parent:e.value,child:a.value}),this.#m.set(a.value,r),this.#f.appendChild(r)}this.#v.has(t)||this.#v.set(t,a)}_itemRemove(e){const t=e.detail.dom.find(e=>e instanceof HTMLElement&&e.classList.contains(He)),a=e.detail.item,r=this.#m;if(r.has(a.value)){const e=r.get(a.value);e.removeEventListener(i.Components.UI.BinderInteractionEventName,this._binderClickHandler,!1),e.remove(),r.delete(a.value)}this.#v.has(t)&&this.#v.delete(t)}_setupItemTemplate(){if(this.itemtemplate instanceof HTMLTemplateElement){const e=this.itemtemplate.cloneNode(!0).content,a=document.createElement("template"),r=document.createElement(t.P+"-panel");r.className=Ae,r.setAttribute("css-class",Te);const s=new i.Components.UI.PacemIconElement;s.setAttribute("icon",je),s.className=Be,r.appendChild(s);const n=document.createElement("div");n.className=Le,n.append(e),r.appendChild(n);const o=new i.Components.UI.PacemIconElement;o.setAttribute("icon",We),o.className=Fe,r.appendChild(o),a.content.appendChild(r),this._template=a}else this._template=this._defaultTemplate}_compileHierarchy(e,i=!1){const a=t.Utils.clone(this.value||[]),r=e.source.value,s=e.target.value,n=this.parentsProperty||Me;var o=a.find(e=>e[this.valueProperty]===s);if(i){if(!t.Utils.isNull(o)){const e=o[n]||[],t=e.indexOf(r);t>=0&&e.splice(t,1)}}else t.Utils.isNull(o)&&((o={})[this.valueProperty]=s,o[n]=[],a.push(o)),o[n].push(r);this._cleanupHierarchy(a),this.changeHandler(new HierarchyChangeEvent(a))}_cleanupHierarchy(e=[]){const i=this.valueProperty,a=this.parentsProperty||Me,r=(s,n)=>{const o=e.find(e=>e[i]==n);if(t.Utils.isNull(o)||t.Utils.isNullOrEmpty(o[a]))return!1;const l=o[a];return l.indexOf(s)>=0||l.some(e=>r(s,e))};for(let t of e){const e=t[a]||[];for(let t=e.length-1;t>=0;t--){const i=e[t],a=e.filter(e=>e!==i);for(let s of a)if(r(i,s)){e.splice(t,1);break}}}}_setupDragger(){const e=this._dragger;e.id="hierarchy_link_"+this.#_,e.handleSelector="."+Ie,e.dropBehavior=t.UI.DropBehavior.None,e.spillBehavior=t.UI.DropTargetMissedBehavior.None,e.mode=t.UI.DragDataMode.Copy,e.addEventListener(t.UI.DragDropEventType.Drop,this._dropHandler,!1),e.addEventListener(t.UI.DragDropEventType.Drag,this._dragHandler,!1),e.addEventListener(t.UI.DragDropEventType.Init,this._dragInitHandler,!1),e.addEventListener(t.UI.DragDropEventType.Start,this._dragStartHandler,!1),e.addEventListener(t.UI.DragDropEventType.End,this._dragEndHandler,!1),e.addEventListener(t.UI.DragDropEventType.Over,this._dragOverHandler,!1),e.addEventListener(t.UI.DragDropEventType.Out,this._dragOutHandler,!1);const i=this._dragger2;i.id="hierarchy_move_"+this.#_,i.mode=t.UI.DragDataMode.Self,i.dropBehavior=t.UI.DropBehavior.None,i.spillBehavior=t.UI.DropTargetMissedBehavior.None,i.handleSelector="."+Be}_disposeDragger(){const e=this._dragger;t.Utils.isNull(e)||(e.removeEventListener(t.UI.DragDropEventType.Drop,this._dropHandler,!1),e.removeEventListener(t.UI.DragDropEventType.Drag,this._dragHandler,!1),e.removeEventListener(t.UI.DragDropEventType.Init,this._dragInitHandler,!1),e.removeEventListener(t.UI.DragDropEventType.Start,this._dragStartHandler,!1),e.removeEventListener(t.UI.DragDropEventType.End,this._dragEndHandler,!1),e.removeEventListener(t.UI.DragDropEventType.Over,this._dragOverHandler,!1),e.removeEventListener(t.UI.DragDropEventType.Out,this._dragOutHandler,!1))}_setupBalloon(){this._balloon=this._shellProxy.dom.find(e=>e instanceof i.Components.UI.PacemBalloonElement),window.addEventListener("mousedown",this._popoutHandler,!1)}_disposeBalloon(){window.removeEventListener("mousedown",this._popoutHandler,!1)}_isInAncestors(e,i){return!t.Utils.isNull(i)&&!t.Utils.isNullOrEmpty(i.parents)&&(i.parents.indexOf(e)>=0||i.parents.some(t=>this._isInAncestors(e,t)))}_isInDescendants(e,t){return this._isInAncestors(t,e)}_databind(){this._repeater.datasource=[];const e=this.valueProperty;if(t.Utils.isNullOrEmpty(e))throw new Error("Missing valueProperty.");const i=t.Utils.clone(this._adaptedDatasource||[]),a=this.value||[],r=this.parentsProperty||Me;for(let s of i){const n=a.find(t=>t[e]===s.value);t.Utils.isNull(n)||(s.parents=(n[r]||[]).map(e=>i.find(t=>t.value===e)).filter(e=>!t.Utils.isNull(e)))}this._databindByParents(i)}_databindByParents(e){const i=[];function a(){return i.reduce((e,t)=>e+t.length,0)}do{if(t.Utils.isNullOrEmpty(i)){const a=e.filter(e=>t.Utils.isNullOrEmpty(e.parents));i.push(a)}else{const a=Array.prototype.concat.apply([],i),r=i[i.length-1],s=e.filter(e=>!t.Utils.isNullOrEmpty(e.parents)&&(e.parents.every(e=>a.indexOf(e)>=0)&&e.parents.some(e=>r.indexOf(e)>=0)));i.push(s)}}while(a()<e.length);this._repeater.datasource=i}};De([t.ViewChild("template[default]")],ze.prototype,"_defaultTemplate",void 0),De([t.ViewChild(t.P+"-repeater")],ze.prototype,"_repeater",void 0),De([t.ViewChild(t.P+"-drag-drop")],ze.prototype,"_dragger",void 0),De([t.ViewChild(t.P+"-drag-drop[move]")],ze.prototype,"_dragger2",void 0),De([t.ViewChild(t.P+"-shell-proxy")],ze.prototype,"_shellProxy",void 0),De([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],ze.prototype,"datasource",void 0),De([t.Watch({emit:!1,converter:t.PropertyConverters.String})],ze.prototype,"valueProperty",void 0),De([t.Watch({emit:!1,converter:t.PropertyConverters.String})],ze.prototype,"textProperty",void 0),De([t.Watch({emit:!1,converter:t.PropertyConverters.String})],ze.prototype,"disabledProperty",void 0),De([t.Watch({converter:t.PropertyConverters.String})],ze.prototype,"unlinkCaption",void 0),De([t.Watch({converter:t.PropertyConverters.Json})],ze.prototype,"_adaptedDatasource",void 0),De([t.Watch({emit:!1,converter:t.PropertyConverters.Element})],ze.prototype,"itemtemplate",void 0),De([t.Watch({converter:t.PropertyConverters.Element})],ze.prototype,"_template",void 0),De([t.Watch({emit:!1,converter:t.PropertyConverters.String})],ze.prototype,"parentsProperty",void 0),ze=De([t.CustomElement({tagName:t.P+"-hierarchy",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<${t.P}-repeater>\n <template>\n <${t.P}-repeater on-${t.Components.RepeaterItemCreateEventName}=":host._itemCreate($event)" on-${t.Components.RepeaterItemRemoveEventName}=":host._itemRemove($event)" datasource="{{ ^item }}">\n <div class="hierarchy-level">\n <${t.P}-template-proxy target="{{ :host._template }}"></${t.P}-template-proxy>\n </div>\n </${t.P}-repeater>\n </template>\n </div>\n</${t.P}-repeater><${t.P}-content></${t.P}-content>\n<${t.P}-drag-drop></${t.P}-drag-drop>\n<${t.P}-drag-drop move></${t.P}-drag-drop>\n<template default>\n <${t.P}-panel class="${Ae} item-default" css-class="${Te}">\n <${t.P}-icon class="${Be}" icon="${je}"></${t.P}-icon>\n <pacem-span class="${Le}" content="{{ ^item.viewValue }}"></${t.P}-span>\n <${t.P}-icon class="${Fe}" icon="${We}"></${t.P}-icon>\n </${t.P}-panel>\n</template>\n<${t.P}-shell-proxy>\n <${t.P}-balloon options="{{ { behavior: ComponentsUI.UI.BalloonBehavior.Inert } }}">\n <${t.P}-button icon-glyph="link_off" class="${t.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()"><${t.P}-text class="${t.PCSS}-margin margin-left-1" text="{{ :host.unlinkCaption }}"></${t.P}-text></${t.P}-button>\n </${t.P}-balloon>\n</${t.P}-shell-proxy>`})],ze);var qe,Je=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};!function(e){e.Input="input",e.Blur="blur"}(qe||(qe={}));const Ye="pacem:scaffolding:input_field";class PacemBaseInputElement extends PacemBaseElement{constructor(){super(...arguments),this.debounce=!1,this.changePolicy=qe.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,i,a){if(super.propertyChangedCallback(e,t,i,a),"placeholder"===e)for(let t of this.inputFields??[])t.setAttribute(e,i)}acceptValue(e){this.inputField&&e!==this.inputField.value&&(this.inputField.value=t.Utils.isNullOrEmpty(e)?"":e)}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===qe.Blur)t(this.value);else{const e=()=>{const e=this.getValue(this.inputField.value);e!==this.value&&(this.value=e),t(e)},i=this.debounce;"number"==typeof i&&i>0?(clearTimeout(this._handle),this._handle=setTimeout(e,i)):!0===i?(cancelAnimationFrame(this._handle),this._handle=requestAnimationFrame(e)):requestAnimationFrame(e)}})}registerInputFields(e=this.inputFields){super.registerInputFields(e),t.Utils.isNull(e)||t.Utils.isArray(e)||(e=[e]);for(let i of e??[])(i instanceof HTMLInputElement||i instanceof HTMLTextAreaElement)&&"on"!==t.CustomElementUtils.getAttachedPropertyValue(i,Ye,"off")&&(t.CustomElementUtils.setAttachedPropertyValue(i,Ye,"on"),"size"in i&&(i.size=1),i.autocomplete="off",i.addEventListener("input",this.changeHandler,!1),i.addEventListener("focus",this._focusHandler,!1))}unregisterInputFields(e=this.inputFields){super.unregisterInputFields(e),t.Utils.isNull(e)||t.Utils.isArray(e)||(e=[e]);for(let i of e??[])"on"===t.CustomElementUtils.getAttachedPropertyValue(i,Ye)&&(t.CustomElementUtils.deleteAttachedPropertyValue(i,Ye),i.removeEventListener("input",this.changeHandler,!1),i.removeEventListener("focus",this._focusHandler,!1))}viewActivatedCallback(){super.viewActivatedCallback(),this.registerInputFields()}disconnectedCallback(){this.unregisterInputFields(),super.disconnectedCallback()}}Je([t.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),Je([t.Watch({emit:!1,converter:t.PropertyConverters.String})],PacemBaseInputElement.prototype,"changePolicy",void 0),Je([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],PacemBaseInputElement.prototype,"autoselect",void 0);class PacemOrdinalInputElement extends PacemBaseInputElement{convertValueAttributeToProperty(e){return parseFloat(e)}propertyChangedCallback(e,t,i,a){switch(super.propertyChangedCallback(e,t,i,a),e){case"min":case"max":case"step":null!=i?this.inputField.setAttribute(e,i):this.inputField.removeAttribute(e)}}}Je([t.Watch({converter:t.PropertyConverters.Number})],PacemOrdinalInputElement.prototype,"min",void 0),Je([t.Watch({converter:t.PropertyConverters.Number})],PacemOrdinalInputElement.prototype,"max",void 0),Je([t.Watch({converter:{convert:e=>{const t=parseFloat(e);return isNaN(t)?"any":t},convertBack:e=>e.toString()}})],PacemOrdinalInputElement.prototype,"step",void 0);class PacemTextualInputElement extends PacemBaseInputElement{convertValueAttributeToProperty(e){return e}propertyChangedCallback(e,t,i,a){switch(super.propertyChangedCallback(e,t,i,a),e){case"pattern":case"maxlength":case"minlength":null!=i?this.inputField.setAttribute(e,i):this.inputField.removeAttribute(e)}}getValue(e){return t.Utils.isNullOrEmpty(e)?null:e}getViewValue(e){return e}}Je([t.Watch({converter:t.PropertyConverters.String})],PacemTextualInputElement.prototype,"pattern",void 0),Je([t.Watch({converter:t.PropertyConverters.Number})],PacemTextualInputElement.prototype,"minlength",void 0),Je([t.Watch({converter:t.PropertyConverters.Number})],PacemTextualInputElement.prototype,"maxlength",void 0);var Ge=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};let Ke=class PacemCharsInputElement extends PacemBaseInputElement{constructor(){super(),this.charCount=6,this.inputTransform="none",this._itemCreateHandler=e=>{const{dom:t,index:i}=e.detail,a=t.find(e=>e instanceof HTMLInputElement);this.#b[i]=a,this.registerInputFields(a)},this.#b=[]}redactViewValue(e=this.value){this.viewValue=this.getViewValue(e)}getValue(e){const i=this.#b.reduce((e,i)=>e+(t.Utils.isNullOrEmpty(i.value)?" ":i.value),"");switch(this.inputTransform){case"lowercase":return i.toLowerCase();case"uppercase":return i.toUpperCase();default:return i}}getViewValue(t){const i=this.charCount;return"password"==this.inputTransform?e.Arrays.range(i).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,i,a){if(super.propertyChangedCallback(e,t,i,a),!a)switch(e){case"charCount":this._databind(),this.redactViewValue();break;case"inputTransform":this.registerInputFields(),this.value=this.getValue(this.value)}}registerInputFields(e=this.inputFields){super.registerInputFields(e),t.Utils.isNull(e)||t.Utils.isArray(e)||(e=[e]);const i=this.#b;for(let a of e??[]){const e=i.indexOf(a);t.Utils.toggleClass(a,"last-char",e===this.charCount-1),t.Utils.toggleClass(a,"first-char",0===e),t.Utils.isNullOrEmpty(a.id)&&a.setAttribute("id","code_"+e+"_"+t.Utils.uniqueCode()),a.value=this.value?.charAt(e)||"","password"===this.inputTransform?a.setAttribute("type","password"):a.setAttribute("type","text")}}acceptValue(e){const t=this.#b;if("string"==typeof e){let i=0;const a=Math.min(e.length,t.length);for(let r=0;r<a;r++)t[r].value=e.charAt(r),i++;for(let e=i;e<t.length;e++)t[e].value=""}}onChange(e){return super.onChange(e).then(i=>{const a=this.#b,r=a.indexOf(e.target);if(r>=0&&r<a.length-1){const e=a[r];if(t.Utils.isNullOrEmpty(e.value?.trim()))e.value="";else{a[r+1].focus()}}return i})}viewActivatedCallback(){super.viewActivatedCallback(),t.Utils.isNull(this.autoselect)&&(this.autoselect=!0),this._chars.addEventListener(t.Components.RepeaterItemCreateEventName,this._itemCreateHandler,!1),this._databind()}disconnectedCallback(){const e=this._chars;t.Utils.isNull(e)||e.removeEventListener(t.Components.RepeaterItemCreateEventName,this._itemCreateHandler),super.disconnectedCallback()}_databind(){const t=this.charCount,i=this.#b;i.length>t&&super.unregisterInputFields(i.splice(t)),this._chars.datasource=e.Arrays.range(t)}#b;get inputFields(){return this.#b}};Ge([t.Watch({emit:!1,reflectBack:!0,converter:t.PropertyConverters.Number})],Ke.prototype,"charCount",void 0),Ge([t.Watch({emit:!1,reflectBack:!0,converter:t.PropertyConverters.String})],Ke.prototype,"inputTransform",void 0),Ge([t.ViewChild(t.P+"-repeater")],Ke.prototype,"_chars",void 0),Ge([t.ViewChild("span."+t.PCSS+"-readonly")],Ke.prototype,"_span",void 0),Ke=Ge([t.CustomElement({tagName:t.P+"-input-chars",template:`<${t.P}-repeater class="display-flex flex-nowrap">\n <template><input type="text" class="${t.PCSS}-input flex-auto" maxlength="1" /></template>\n </${t.P}-repeater><span class="${t.PCSS}-readonly"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></span>`,shadow:t.Defaults.USE_SHADOW_ROOT})],Ke);var Xe=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};let Ze=class PacemColorInputElement extends 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(e){const i=this._alpha.valueAsNumber||parseInt(this._alpha.value),a=this._tint.value,r=this.value=this._getValue(a,i);return t.Utils.fromResult(r)}constructor(){super()}toggleReadonlyView(e){this._wrapper.hidden=e,this._span.hidden=!e}_getValue(t,i){if(isNaN(i)||100===i)return t;const a=e.Colors.parse(t);return a.a=.01*i,e.Colors.stringify(a)}_parseValue(i){const a=e.Colors.parse(i);return t.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]}};Xe([t.ViewChild("input[type=color]")],Ze.prototype,"_tint",void 0),Xe([t.ViewChild("input[type=number]")],Ze.prototype,"_alpha",void 0),Xe([t.ViewChild(`.${t.PCSS}-viewfinder`)],Ze.prototype,"_wrapper",void 0),Xe([t.ViewChild(`.${t.PCSS}-readonly`)],Ze.prototype,"_span",void 0),Ze=Xe([t.CustomElement({tagName:t.P+"-input-color",template:`<div class="${t.PCSS}-viewfinder">\n<${t.P}-panel class="${t.PCSS}-input-color" css="{{ { 'background-color': :host.viewValue } }}"><input type="color" class="${t.PCSS}-input" /></${t.P}-panel>\n<input class="${t.PCSS}-input" type="number" min="0" max="100" step="1" value="100" />\n</div>\n<${t.P}-span class="${t.PCSS}-readonly" css="{{ { 'background-color': :host.viewValue } }}"></${t.P}-span>`,shadow:t.Defaults.USE_SHADOW_ROOT})],Ze);var Qe=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};let et=class PacemEmailInputElement extends PacemTextualInputElement{toggleReadonlyView(e){this.input.hidden=e,this.anchor.hidden=!e}get inputFields(){return[this.input]}};Qe([t.ViewChild("input[type=email]")],et.prototype,"input",void 0),Qe([t.ViewChild(t.P+"-a")],et.prototype,"anchor",void 0),et=Qe([t.CustomElement({tagName:t.P+"-input-email",template:`<input type="email" class="${t.PCSS}-input ${t.PCSS}-viewfinder" />${E}<${t.P}-a class="${t.PCSS}-readonly" disabled="{{ $pacem.isNullOrEmpty(:host.value) }}" href="{{ 'mailto:'+ :host.value }}"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></${t.P}-a>`,shadow:t.Defaults.USE_SHADOW_ROOT})],et);var tt=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};const it="fileupload",at="filechange";class StoragePickEvent extends t.CustomTypedEvent{constructor(e){super("pick",e)}}class FileUploadEvent extends t.CustomTypedEvent{constructor(e){super(it,e)}}class FileChangeEvent extends t.CustomTypedEvent{constructor(e){super(at,e)}}async function rt(e,t={files:0,directories:0,size:0}){for await(let[i,a]of e.entries())if("file"===a.kind){t.files++;const e=await a.getFile();t.size+=e.size}else t.directories++,await rt(a,t);return t}let st=class PacemUploadElement extends PacemBaseElement{constructor(e=new t.Animations.TweenService){super(),this._tweener=e,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(e=this.value,i=this.uploading,a=this.selectMode??"file"){if(i)return"sync";const r=!t.Utils.isNullOrEmpty(e);switch(a){case"directory":case"directory-picker":return r?"folder":"drive_folder_upload";case"multiple":case"multiple-picker":return r?"files":"upload_file"}if(t.Utils.isNullOrEmpty(e))return"upload_file";var s=e;"object"==typeof e&&(s=e.name);const n=/\.([\w]+)(\s|$)/.exec(s);if(n&&n.length)switch(n[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(e){const i=this._localValue||e;if(t.Utils.isNullOrEmpty(i))return"";if("string"==typeof i)return i;let a="name"in i?i.name:"";t.Utils.isArray(i)&&(a=i.map(e=>e.name).join(", "));const r=this._stats;if(t.Utils.isNullOrEmpty(r))return a;const{size:s,files:n}=r;return`${a}\n(${n} file${1===n?"":"s"}, ${t.Utils.core.size(s)})`}toggleReadonlyView(e){this._setupInputElement(e)}viewActivatedCallback(){super.viewActivatedCallback(),this._setupInputElement(),this._fileupload.addEventListener("click",t.stopPropagationHandler,!1)}propertyChangedCallback(e,t,i,a){if(super.propertyChangedCallback(e,t,i,a),!a&&"selectMode"===e)this._setupInputElement()}disconnectedCallback(){this._fileupload&&this._fileupload.removeEventListener("click",t.stopPropagationHandler,!1),super.disconnectedCallback()}_setupInputElement(e=this.readonly,t=this.selectMode??"file"){const i=this._fileupload;switch(i.removeAttribute("webkitdirectory"),i.removeAttribute("multiple"),i.hidden=e,t){case"directory":i.setAttribute("webkitdirectory","true");break;case"multiple":i.setAttribute("multiple","true");break;case"directory-picker":case"file-picker":case"multiple-picker":i.hidden=!0}}_dispatchDownload(e){t.avoidHandler(e);const i=this._localValue||this.value,a=e=>{this.dispatchEvent(new CustomEvent("download",{detail:e,bubbles:!0,cancelable:!1}))};t.Utils.isNullOrEmpty(i)||("string"==typeof i?a(i):"content"in i&&!t.Utils.isNullOrEmpty(i.content)?t.Utils.download(t.Utils.dataURLToBlob("data:application/download;base64,"+i.content),i.name,i.type):"name"in i&&("kind"in i&&"file"===i.kind?i.getFile().then(e=>{t.Utils.download(e,e.name,e.type)}):a(i.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 i=this.maxSize;if(i>0&&i<e.size)return this.invalidFile=!0,!1;const a=this.pattern;return a&&!new RegExp(a,"i").test(t)?(this.invalidFile=!0,!1):(this.invalidFile=!1,!0)}upload(e,t,i){if(this._validateSingleFile(e,t))return this._upload(e,t,i)}async _upload(e,t,i){var a=this,r=a._fields;if(!e)return;!t&&e instanceof File&&(t=e.name),a.failed=!1,r.undone=!1,r.ongoing=0;const s=e,n=a.size=s.size;t=t.substring(t.lastIndexOf("\\")+1),a.percentage=0,a.complete=!1;var o={filename:t,length:n,action:"start",state:i,type:e.type};a.uploading=!0;try{var l=await a._fetch(o);if(l.ok){var c=await l.json();r.retryFrom=0,r.blob=s,r.uid=c.uid,a._manage()}else a.uploading=!1;return l}catch(e){a.uploading=!1}}async _blobToBase64(e){const i=await t.Utils.blobToDataURL(e);return i.substring(i.indexOf("base64,")+7)}async _doUpload(e,t){var i=this,a=i._fields;a.ongoing++;var r={chunk:await this._blobToBase64(e),uid:a.uid,position:t,action:"do"};try{const e=await i._fetch(r);if(e.ok){if(a.ongoing--,a.undone)return;const t=await e.json();t.percentage>this.percentage&&await i._tweenPercentage(Math.round(Math.max(1,t.percentage)),200),i.complete!=t.complete&&(i.complete=t.complete,!0===i.complete&&(i.uploading=!1,i.changeHandler(new FileUploadEvent(t))))}else a.retryFrom=t,i.failed=!0,i.uploading=!1}catch(e){a.retryFrom=t,i.failed=!0,i.uploading=!1}}_manage(){const e=this._fields,t=this.size,i=e.blob,a=this.chunkSize||e.chunkSize;var r=e.retryFrom,s=r+a;e.enqueuer=setInterval(()=>{if(r<t&&!this.failed){const t=this.parallelism||e.parallelism;if(e.ongoing>=t)return;this._doUpload(i.slice(r,s),r),s=(r=s)+a}else{this._fileupload.value="",window.clearInterval(e.enqueuer)}},100)}async _buildLocalValue(e,i=e.name,a=e){return this._localValue={name:i,size:a.size,type:e.type,lastModified:t.Utils.parseDate(e.lastModified).toISOString(),content:await this._blobToBase64(a)}}_canPick(e){return"showDirectoryPicker"in e&&(()=>{try{return e.self===e.top}catch{return!1}})()}_tryPickDirectory(){this._canPick(window)&&window.showDirectoryPicker({mode:"read"}).then(e=>{this.changeHandler(new StoragePickEvent(e))})}_tryPickFiles(e="multiple-picker"===this.selectMode,t=this.pattern){this._canPick(window)&&window.showOpenFilePicker({multiple:e}).then(e=>{this.changeHandler(new StoragePickEvent(e))})}_clickHandler(e){if(t.avoidHandler(e),!this.readonly)switch(this.selectMode){case"directory-picker":this._tryPickDirectory();break;case"file-picker":case"multiple-picker":this._tryPickFiles()}}async _mimicCompute(){this.uploading=!0,t.Utils.isNullOrEmpty(this.value)?await t.Utils.idle(250):(this.percentage=0,await t.Utils.waitForAnimationEnd(this._tuner)),await this._tweener.run(0,100,500,0,t.Animations.Easings.sineInOut,(e,t)=>{this.percentage=t}),this.percentage=0,this.uploading=!1}onChange(e){return new Promise(async(i,a)=>{if(t.CustomEventUtils.isInstanceOf(e,FileUploadEvent)){const t=this.value=e.detail.filename;this.dispatchEvent(e),i(t)}else if(t.CustomEventUtils.isInstanceOf(e,StoragePickEvent)){let t,a,r,s=e.detail;switch(this.selectMode){case"directory-picker":t=s,this._stats=await rt(t);break;case"multiple-picker":case"file-picker":r=s,1===r.length&&(s=r[0]),this._stats=await async function(e){const t={files:0,directories:0,size:0};for(let i of e){const e=await i.getFile();t.files++,t.size+=e.size}return t}(r);break;default:this._stats={directories:0,files:0,size:0}}i(this.value=this._localValue=s);const n=this._validateAll();this.dispatchEvent(new FileChangeEvent({directory:t,file:a,files:r,valid:n}))}else{let e=this._fileupload;if(0===e.files.length)this._stats={directories:0,files:0,size:0},i(this.value=null);else{const a=e.files.length;if(this._stats={directories:0,files:a,size:Array.from(e.files).reduce((e,t,i)=>e+t.size,0)},a>1){const t=Array.from(e.files);i(this.value=this._localValue=t);const a=this._validateAll();this.dispatchEvent(new FileChangeEvent({files:t,valid:a}))}else{const a=e.files[0],r=a.name;let s=a;this._validateSingleFile(a)||t.Utils.isNullOrEmpty(this.url)?(/\.(jpe?g|png)$/i.test(r)&&this.maxImageWidth>0&&this.maxImageHeight>0&&(s=await t.Utils.Images.resize(s,this.maxImageWidth,this.maxImageHeight,{quality:.8})),await this._buildLocalValue(a,r,s),t.Utils.isNullOrEmpty(this.url)?(await this._mimicCompute(),i(this.value=this._localValue)):(this._upload(s,e.value),i(this.value))):i(this.value=await this._buildLocalValue(a)),this.dispatchEvent(new FileChangeEvent({valid:!this.invalidFile,file:a}))}}}})}_fetch(e){return fetch(this.url,{method:"POST",credentials:this.fetchCredentials,headers:t.Utils.extend({Accept:"application/json","Content-Type":"application/json"},this.fetchHeaders||{}),body:JSON.stringify(e)})}async _undo(e){e.preventDefault(),e.stopPropagation();var t=this,i=t._fields,a=t._fileupload;clearInterval(i.enqueuer);var r={action:"undo",uid:i.uid};try{var s=await t._fetch(r);return s.ok&&(i.undone=!0,t.size=0,t._tweenPercentage(0,300)),s}catch(e){}finally{return a.value="",t.uploading=!1,s}}_tweenPercentage(e,i=500){const a=this.percentage;return this._tweener.run(a,e,i,0,t.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)}};tt([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],st.prototype,"fetchCredentials",void 0),tt([t.Watch({emit:!1,converter:t.PropertyConverters.String})],st.prototype,"fetchHeaders",void 0),tt([t.ViewChild("input[type=file]")],st.prototype,"_fileupload",void 0),tt([t.ViewChild(`${t.P}-tuner`)],st.prototype,"_tuner",void 0),tt([t.Watch({converter:t.PropertyConverters.String})],st.prototype,"undoCaption",void 0),tt([t.Watch({converter:t.PropertyConverters.String})],st.prototype,"retryCaption",void 0),tt([t.Watch({converter:t.PropertyConverters.String})],st.prototype,"clearCaption",void 0),tt([t.Watch({emit:!1,reflectBack:!0,converter:t.PropertyConverters.String})],st.prototype,"pattern",void 0),tt([t.Watch({emit:!1,reflectBack:!0,converter:t.PropertyConverters.String})],st.prototype,"url",void 0),tt([t.Watch({emit:!1,reflectBack:!0,converter:t.PropertyConverters.Number})],st.prototype,"maxImageWidth",void 0),tt([t.Watch({emit:!1,reflectBack:!0,converter:t.PropertyConverters.Number})],st.prototype,"parallelism",void 0),tt([t.Watch({emit:!1,reflectBack:!0,converter:t.PropertyConverters.Number})],st.prototype,"chunkSize",void 0),tt([t.Watch({emit:!1,reflectBack:!0,converter:t.PropertyConverters.Number})],st.prototype,"maxImageHeight",void 0),tt([t.Watch({emit:!1,reflectBack:!0,converter:t.PropertyConverters.Number})],st.prototype,"maxSize",void 0),tt([t.Watch({reflectBack:!0,converter:t.PropertyConverters.String})],st.prototype,"selectMode",void 0),tt([t.Watch({converter:t.PropertyConverters.Boolean})],st.prototype,"uploading",void 0),tt([t.Watch({converter:t.PropertyConverters.Number})],st.prototype,"size",void 0),tt([t.Watch({converter:t.PropertyConverters.Number})],st.prototype,"percentage",void 0),tt([t.Watch({converter:t.PropertyConverters.Boolean})],st.prototype,"complete",void 0),tt([t.Watch({converter:t.PropertyConverters.Boolean})],st.prototype,"failed",void 0),tt([t.Watch({converter:t.PropertyConverters.Boolean})],st.prototype,"invalidFile",void 0),st=tt([t.CustomElement({tagName:t.P+"-upload",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<${t.P}-button on-click=":host._dispatchDownload($event)" class="${t.PCSS}-upload ${t.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 <${t.P}-panel class="upload-button" hide="{{ (:host.uploading || :host.failed) && !$pacem.isNullOrEmpty(:host.url) }}">\n <${t.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="{{ {'${t.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="${t.PCSS}-transparent ${t.PCSS}-clickable pos-absolute absolute-left absolute-right absolute-top absolute-bottom" />\n </${t.P}-button>\n </${t.P}-panel>\n <${t.P}-panel class="upload-button" hide="{{ !:host.failed }}">\n <${t.P}-button class="button-circle button-flat" icon-glyph="refresh"\n tooltip="{{ :host.retryCaption }}" on-click=":host._retry($event)"><${t.P}-text text="{{ :host.retryCaption }}"></${t.P}-text></${t.P}-button>\n </${t.P}-panel>\n <${t.P}-panel class="upload-button" hide="{{ !:host.uploading || $pacem.isNullOrEmpty(:host.url) }}">\n <${t.P}-button class="button-circle button-flat" icon-glyph="clear" tooltip="{{ :host.undoCaption }}" \n on-click=":host._undo($event)"><${t.P}-text text="{{ :host.undoCaption }}"></${t.P}-text></${t.P}-button>\n </${t.P}-panel>\n\n <${t.P}-span tooltip="{{ :host.viewValue }}"\n hide="{{ $pacem.isNullOrEmpty(:host.value) || :host.uploading }}" class="upload-data readonly text-reset display-block ${t.PCSS}-anim text-truncate text-left ${t.PCSS}-pad pad-right-3" text="{{ :host.viewValue }}"></${t.P}-span>\n\n <${t.P}-panel class="upload-progress hit-none" hide="{{ :host.readonly || (!$pacem.isNullOrEmpty(:host.value) && !:host.uploading) }}">\n <${t.P}-tuner value="{{ :host.percentage }}" css-class="{{ {'tuner-success': !:host.invalidFile, 'tuner-error': :host.invalidFile} }}" interactive="false"></${t.P}-tuner>\n </${t.P}-panel>\n\n <${t.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)"></${t.P}-button>\n \n</${t.P}-button>`})],st);var nt=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};let ot=class PacemHiddenInputElement extends PacemTextualInputElement{constructor(){super()}toggleReadonlyView(e){}get inputFields(){return[this.input]}};nt([t.ViewChild("input[type=hidden]")],ot.prototype,"input",void 0),ot=nt([t.CustomElement({tagName:t.P+"-input-hidden",template:'<input type="hidden" />',shadow:t.Defaults.USE_SHADOW_ROOT})],ot);var lt=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};const ct=t.Utils.getUserMediaFunctions();var dt;!function(e){e.Start="start",e.Taking="taking",e.Confirm="confirm"}(dt||(dt={}));class ConfirmSnapshotEvent extends t.CustomUIEvent{constructor(e){super("confirmsnapshot",{buffer:e})}}let ht=class PacemSnapshotElement extends PacemBaseElement{constructor(){super(...arguments),this._resizeHandler=e=>{this._renderValue()},this.step=dt.Start,this._canUseWebcam=ct.length>0,this._countdown=0,this._webcamInitialized=!1,this._grabberChangeHandler=e=>{const i=this._grabber;i.files.length>0&&t.Utils.blobToDataURL(i.files[0]).then(e=>{t.Utils.loadImage(e).then(e=>{this._shutter(e)})})},this._snapshooterClickHandler=e=>{t.avoidHandler(e),this.step=dt.Taking},this._pickerClickHandler=e=>{t.avoidHandler(e),this._grabber.click()},this._takerClickHandler=e=>{t.avoidHandler(e),this._countdown=0,this._shutter()},this._timerClickHandler=e=>{t.avoidHandler(e),this._countdown=3,this._shutter()},this._confirmerClickHandler=e=>{t.avoidHandler(e),this.changeHandler(new ConfirmSnapshotEvent(this._buffer))}}get inputFields(){return[]}toggleReadonlyView(e){}onChange(e){return new Promise((i,a)=>{t.CustomEventUtils.isInstanceOf(e,ConfirmSnapshotEvent)?(i(this.value=e.detail.buffer),this.step=dt.Start):i(this.value)})}acceptValue(e){this._renderValue(e)}getViewValue(e){return e}convertValueAttributeToProperty(e){return t.PropertyConverters.String.convert(e,this)}get _getUserMedia(){return this._canUseWebcam&&ct[0]}propertyChangedCallback(e,t,i,a){switch(super.propertyChangedCallback(e,t,i,a),e){case"step":switch(i){case dt.Start:this._buffer=null;const e=this._grabber;e.value="",/safari/i.test(navigator.userAgent)||(e.type="",e.type="file");break;case dt.Taking:this._ensureWebcamRunning()}break;case"_buffer":this._renderValue(i||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 e=this._stage,i=this._player;t.Utils.isNull(e)||t.Utils.isNull(i)||(e.style.width=i.style.width=this.width&&this.width+"px"||"",e.style.height=i.style.height=this.height&&this.height+"px"||"",this._renderValue(this._buffer||this.value))}_shutter(e){const i=this,a=this._player,r=this._stage;var s,n;if(i._confirmer.disabled=!0,t.Utils.isNull(e)&&(e=i._player),e instanceof HTMLVideoElement?(s=e.videoWidth,n=e.videoHeight):(s=e.naturalWidth,n=e.naturalHeight),i._countdown<=0){var o=document.createElement("canvas");o.width=this.width||r.clientWidth,o.height=this.height||r.clientHeight;var l=o.getContext("2d");t.Utils.cropImageOntoCanvas(e,l,s,n);let c=i._root;c.insertBefore(o,a),o.className="snapshot-brightout",setTimeout(function(){c.removeChild(o)},1e3),i._refreshBuffer(o.toDataURL()).then(e=>{i._setToBeConfirmed(e),i._confirmer.disabled=!1})}else setTimeout(()=>{i._countdown--,this._shutter()},1e3)}_renderValue(e=this.value){let i=this._stage;if(!t.Utils.isNull(i)){i.width=i.clientWidth,i.height=i.clientHeight;let a=i.getContext("2d");t.Utils.isNullOrEmpty(e)?a.clearRect(0,0,i.width,i.height):t.Utils.loadImage(e).then(e=>{t.Utils.cropImageOntoCanvas(e,a,e.width,e.height)})}}_setToBeConfirmed(e){this.step=dt.Confirm,this._buffer=e}_refreshBuffer(e){var i=this._stage;let a;return i.width=i.clientWidth,i.height=i.clientHeight,this.quality>0&&(a=Math.min(1,Math.max(0,this.quality))),t.Utils.cropImage(e,i.width,i.height,a)}_ensureWebcamRunning(){if(this._canUseWebcam&&!this._webcamInitialized){var e=this;e._webcamInitialized=!0,e._getUserMedia.apply(navigator,[{video:!0},function(t){e._player.srcObject=t},function(i){e.log(t.Logging.LogLevel.Error,(i||i.message).toString())}])}}};lt([t.ViewChild("."+t.PCSS+"-snapshot")],ht.prototype,"_root",void 0),lt([t.ViewChild("canvas")],ht.prototype,"_stage",void 0),lt([t.ViewChild("input[type=file]")],ht.prototype,"_grabber",void 0),lt([t.ViewChild("video")],ht.prototype,"_player",void 0),lt([t.ViewChild(t.P+"-button.button.snapshot-upload")],ht.prototype,"_picker",void 0),lt([t.ViewChild(t.P+"-button.button.snapshot-camera")],ht.prototype,"_snapshooter",void 0),lt([t.ViewChild(t.P+"-button.button.snapshot-take")],ht.prototype,"_taker",void 0),lt([t.ViewChild(t.P+"-button.button.snapshot-timer3s")],ht.prototype,"_timer",void 0),lt([t.ViewChild(t.P+"-button.button.snapshot-confirm")],ht.prototype,"_confirmer",void 0),lt([t.Watch({converter:t.PropertyConverters.String})],ht.prototype,"step",void 0),lt([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],ht.prototype,"width",void 0),lt([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],ht.prototype,"height",void 0),lt([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],ht.prototype,"quality",void 0),lt([t.Watch()],ht.prototype,"_countdown",void 0),lt([t.Watch({emit:!1})],ht.prototype,"_buffer",void 0),ht=lt([t.CustomElement({tagName:t.P+"-snapshot",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<${t.P}-panel class="${t.PCSS}-snapshot" \ncss-class="{{ { \n'snapshot-start': :host.step === '${dt.Start}',\n'snapshot-taking': :host.step === '${dt.Taking}', \n'snapshot-confirm': :host.step === '${dt.Confirm}' } }}">\n\n <${t.P}-resize target="{{ ::_stage }}" on-resize=":host._resizeHandler($event)"></${t.P}-resize>\n\n <canvas class="${t.PCSS}-viewfinder"></canvas>\n\n <video autoplay="autoplay"></video>\n\n <input type="file" accept="image/*" />\n\n <div class="${t.PCSS}-buttonset snapshot-step step-start">\n <div class="buttonset-center">\n <${t.P}-button class="button snapshot-upload" icon-glyph="upload"></${t.P}-button>\n <${t.P}-button class="button snapshot-camera" icon-glyph="photo_camera"></${t.P}-button> \n </div>\n </div>\n\n <div class="${t.PCSS}-buttonset snapshot-step step-taking">\n <div class="buttonset-center">\n <${t.P}-button class="button snapshot-undo" icon-glyph="undo" on-click=":host.step = '${dt.Start}'"></${t.P}-button>\n <${t.P}-button class="button snapshot-take" icon-glyph="camera"></${t.P}-button>\n <${t.P}-button class="button snapshot-timer3s" icon-glyph="timer_3"></${t.P}-button>\n </div>\n </div>\n\n <div class="${t.PCSS}-buttonset snapshot-step step-confirm">\n <div class="buttonset-center">\n <${t.P}-button class="button snapshot-undo" icon-glyph="undo" on-click=":host.step = '${dt.Start}'"></${t.P}-button>\n <${t.P}-button class="button snapshot-confirm" icon-glyph="done"></${t.P}-button>\n </div>\n </div>\n\n <${t.P}-span class="snapshot-countdown" text="{{ :host._countdown }}" hide="{{ :host.step !== '${dt.Taking}' || !(:host._countdown > 0) }}"></${t.P}-span>\n <${t.P}-span hide="{{ :host._canUseWebcam }}"><${t.P}-content></${t.P}-content></${t.P}-span>\n\n</${t.P}-panel>`})],ht);var pt=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};const ut="imagefetchrequest";class ImageFetchRequestEvent extends t.CustomTypedEvent{constructor(e){super(ut,e,{bubbles:!0})}}let mt=class PacemEditImageElement extends t.Components.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(e){const i=this._uploader,a=this._thumbUploader,r=a.maxImageWidth,s=a.maxImageHeight;if(r>0&&s>0){var n=i.blob;const o=e.detail.uid;t.Utils.resizeImage(n,r,s).then(e=>{e==n?this._done(!1):a.upload(e,"thumbnail.jpg",o)})}else this._done(!1)}_done(e){e||this._imagefetch(0),this._repeater.hidden=e,this._progressbar.hidden=!e}_snapshotPropertyChangedCallback(e){if("value"===e.detail.propertyName){const i=t.Utils.dataURLToBlob(e.detail.currentValue);this._uploader.upload(i,"snapshot.jpg")}}reset(){this._snapshot.step=dt.Start}propertyChangedCallback(e,i,a,r){switch(super.propertyChangedCallback(e,i,a,r),e){case"imageSet":let e=a||{skip:0,set:[]};t.Utils.isNullOrEmpty(this._images)||0===e.skip?this._images=e.set:t.Utils.isNull(this._images)||Array.prototype.splice.apply(this._images,[e.skip,this._images.length-e.skip].concat(e.set)),this._fetching=!1;break;case"hint":r||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}))}};pt([t.Watch({converter:t.PropertyConverters.String})],mt.prototype,"uploadUrl",void 0),pt([t.Watch({converter:t.PropertyConverters.String})],mt.prototype,"hint",void 0),pt([t.Watch()],mt.prototype,"imageSet",void 0),pt([t.Watch({converter:t.PropertyConverters.String})],mt.prototype,"value",void 0),pt([t.Watch({converter:t.PropertyConverters.Number})],mt.prototype,"maxWidth",void 0),pt([t.Watch({converter:t.PropertyConverters.Number})],mt.prototype,"maxHeight",void 0),pt([t.Watch({converter:t.PropertyConverters.Number})],mt.prototype,"maxThumbnailWidth",void 0),pt([t.Watch({converter:t.PropertyConverters.Number})],mt.prototype,"maxThumbnailHeight",void 0),pt([t.Watch({converter:t.PropertyConverters.Boolean})],mt.prototype,"allowSnapshot",void 0),pt([t.Watch()],mt.prototype,"_fetching",void 0),pt([t.Watch()],mt.prototype,"_images",void 0),pt([t.ViewChild(t.P+"-repeater")],mt.prototype,"_repeater",void 0),pt([t.ViewChild(t.P+"-upload[main]")],mt.prototype,"_uploader",void 0),pt([t.ViewChild(t.P+"-upload[thumb]")],mt.prototype,"_thumbUploader",void 0),pt([t.ViewChild(t.P+"-snapshot")],mt.prototype,"_snapshot",void 0),pt([t.ViewChild(t.P+"-progressbar")],mt.prototype,"_progressbar",void 0),pt([t.Debounce(500)],mt.prototype,"_imagefetch",null),mt=pt([t.CustomElement({tagName:t.P+"-edit-image",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<${t.P}-panel class="${t.PCSS}-edit-image"\n css-class="{{ {'${t.PCSS}-snapshot': ::_snapshot.step != '${dt.Start}', '${t.PCSS}-uploading': ::_uploader.uploading, '${t.PCSS}-upload-enabled': !Pacem.Utils.isNullOrEmpty(:host.uploadUrl), '${t.PCSS}-snapshot-enabled': !Pacem.Utils.isNullOrEmpty(:host.uploadUrl) && :host.allowSnapshot} }}">\n <div>\n <${t.P}-input-search value="{{ :host.hint, twoway }}"></${t.P}-input-search>\n <${t.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-${it}=":host._uploaderFileUploadCallback($event)"\n on-${t.PropertyChangeEventName}=":host._uploaderPropertyChangedCallback($event)" hide="{{ Pacem.Utils.isNullOrEmpty(:host.uploadUrl) || ::_thumbUploader.uploading }}"></${t.P}-upload>\n <${t.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-${t.PropertyChangeEventName}=":host._thumbnailUploaderPropertyChangedCallback($event)"></${t.P}-upload>\n <${t.P}-button class="${t.PCSS}-snapshot" on-click="Pacem.avoidHandler($event); ::_snapshot.step = '${dt.Taking}'" hide="{{ Pacem.Utils.isNullOrEmpty(:host.uploadUrl) || !:host.allowSnapshot }}"></${t.P}-button>\n <${t.P}-infinite-scroller container="{{ ::_repeater }}" on-fetchmore=":host._imagefetchSuddenly()" disabled="{{ :host._fetching || :host.disabled || :host._images.length >= :host.imageSet.total }}"></${t.P}-infinite-scroller>\n <${t.P}-repeater datasource="{{ :host._images }}">\n <template>\n <${t.P}-img css-class="{{ {'${t.PCSS}-selected': ^item.src === :host.value } }}" on-click=":host.value = ^item.src" src="{{ ^item.thumb }}" adapt="contain"></${t.P}-img>\n </template>\n </${t.P}-repeater>\n <${t.P}-progressbar class="progressbar-smaller progressbar-accent" caption="{{ ::_thumbUploader.uploading ? 'thumbnail...' : 'uploading...' }}"></${t.P}-progressbar>\n </div>\n <div>\n <${t.P}-snapshot hide="{{ !:host.allowSnapshot }}" on-${t.PropertyChangeEventName}=":host._snapshotPropertyChangedCallback($event)"></${t.P}-snapshot>\n </div>\n </${t.P}-panel>`})],mt);let vt=class PacemImageInputElement extends PacemBaseElement{constructor(){super(...arguments),this._broadcastFetchRequestEventName=e=>{this.dispatchEvent(new ImageFetchRequestEvent(e.detail))},this._innerValueChangedHandler=e=>{"value"!==e.detail.propertyName||t.Utils.isNull(this._dialog)||(this._dialog.state=e.detail.currentValue)}}convertValueAttributeToProperty(e){return e}getViewValue(e){return e}get inputFields(){return[]}_clear(e){this.changeHandler(e)}onChange(e){let a=this.value;return t.CustomEventUtils.isInstanceOf(e,i.Components.UI.DialogResultEvent)&&e.detail.button===i.Components.UI.DialogButton.Ok?a=this.value=e.detail.state:e.target===this._input?a=this.value=this._input.value:e.target===this._clearBtn&&(a=this.value=void 0),t.Utils.fromResult(a)}toggleReadonlyView(e){this._input.hidden=this._editBtn.hide=this._clearBtn.hide=e}_addDialog(){var e=document.createElement(t.P+"-dialog");return e.buttons=i.Components.UI.DialogButtons.OkCancel,e.addEventListener(i.Components.UI.DialogResultEventName,this.changeHandler,!1),e.appendChild(this._addEditImage()),document.body.appendChild(e),this._dialog=e}_removeDialog(){this._removeEditImage(),t.Utils.isNull(this._dialog)||(this._dialog.removeEventListener(i.Components.UI.DialogResultEventName,this.changeHandler,!1),this._dialog.remove())}_addEditImage(){var e=document.createElement(t.P+"-edit-image");return e.disabled=!0,e.addEventListener(t.PropertyChangeEventName,this._innerValueChangedHandler,!1),e.addEventListener(ut,this._broadcastFetchRequestEventName,!1),e.uploadUrl=this.uploadUrl,e.allowSnapshot=this.allowSnapshot,e.maxWidth=this.maxWidth,e.maxHeight=this.maxHeight,e.maxThumbnailHeight=this.maxThumbnailHeight,e.maxThumbnailWidth=this.maxThumbnailWidth,this._editImage=e}_removeEditImage(){t.Utils.isNull(this._editImage)||(this._editImage.removeEventListener(t.PropertyChangeEventName,this._innerValueChangedHandler,!1),this._editImage.removeEventListener(ut,this._broadcastFetchRequestEventName,!1))}connectedCallback(){super.connectedCallback(),this._addDialog()}disconnectedCallback(){this._removeDialog(),super.disconnectedCallback()}propertyChangedCallback(e,i,a,r){switch(super.propertyChangedCallback(e,i,a,r),e){case"uploadUrl":t.Utils.isNull(this._editImage)||(this._editImage.uploadUrl=a);break;case"allowSnapshot":t.Utils.isNull(this._editImage)||(this._editImage.allowSnapshot=a);break;case"imageSet":t.Utils.isNull(this._editImage)||(this._editImage.imageSet=a);break;case"maxThumbnailHeight":t.Utils.isNull(this._editImage)||(this._editImage.maxThumbnailHeight=a);break;case"maxThumbnailWidth":t.Utils.isNull(this._editImage)||(this._editImage.maxThumbnailWidth=a);break;case"maxHeight":t.Utils.isNull(this._editImage)||(this._editImage.maxHeight=a);break;case"maxWidth":t.Utils.isNull(this._editImage)||(this._editImage.maxWidth=a)}}acceptValue(e){t.Utils.isNull(this._editImage)||(this._editImage.value=e)}_update(e){this._image.src=e}_retrieve(){return this.value}_edit(e){t.avoidHandler(e);var a=this._editImage,r=this.value;a.disabled=!1,a.reset(),a.value=r,this._dialog.open(r).then(e=>{switch(e.button){case i.Components.UI.DialogButton.Cancel:this._update(this.value);break;case i.Components.UI.DialogButton.Ok:this._update(e.state)}this._editImage.disabled=!0})}};pt([t.ViewChild(t.P+"-img")],vt.prototype,"_image",void 0),pt([t.ViewChild(t.P+"-button."+t.PCSS+"-edit")],vt.prototype,"_editBtn",void 0),pt([t.ViewChild(t.P+"-button."+t.PCSS+"-clear")],vt.prototype,"_clearBtn",void 0),pt([t.ViewChild(t.P+"-input-url")],vt.prototype,"_input",void 0),pt([t.Watch({emit:!1,converter:t.PropertyConverters.String})],vt.prototype,"uploadUrl",void 0),pt([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],vt.prototype,"imageSet",void 0),pt([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],vt.prototype,"maxWidth",void 0),pt([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],vt.prototype,"maxHeight",void 0),pt([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],vt.prototype,"maxThumbnailWidth",void 0),pt([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],vt.prototype,"maxThumbnailHeight",void 0),pt([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],vt.prototype,"allowSnapshot",void 0),vt=pt([t.CustomElement({tagName:t.P+"-input-image",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<div class="${t.PCSS}-input-image"><${t.P}-img src="{{ :host.value }}" adapt="contain"></${t.P}-img><div class="${t.PCSS}-input-image-dashboard">\n <${t.P}-button on-click=":host._edit($event)" hide="{{ :host.disabled }}" class="${t.PCSS}-edit">Edit</${t.P}-button>\n <${t.P}-button on-click=":host._clear($event)" hide="{{ :host.disabled }}" class="${t.PCSS}-clear">Clear</${t.P}-button>\n</div><${t.P}-input-url placeholder="{{ :host.placeholder }}" on-change=":host.changeHandler($event)" value="{{ :host.value }}"></${t.P}-input-url>\n\n <${t.P}-panel hide="{{ Pacem.Utils.isNullOrEmpty(:host.value) }}">\n <dl class="${t.PCSS}-input-image-preview">\n <dt>dimensions:</dt><dd><${t.P}-text text="{{ ::_image.size.width +'x'+ ::_image.size.height }}"></${t.P}-text></dd>\n <dt>size:</dt><dd><${t.P}-text text="{{ $pacem.size(::_image.size.weight) }}"></${t.P}-text></dd>\n </dl></${t.P}-panel>\n\n</div>`})],vt);var gt=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};let yt=class PacemNumberInputElement extends 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(e=this.value){const i=this.format;return t.Utils.isNullOrEmpty(i)?e.toString():new Intl.NumberFormat(t.Utils.lang(this),i).format(e)}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(!t.Utils.isNull(this._input)){this._input.removeEventListener("wheel",this.emitHandler,{capture:!1,passive:!1})}super.disconnectedCallback()}};gt([t.ViewChild("input[type=number]")],yt.prototype,"_input",void 0),gt([t.ViewChild(`span.${t.PCSS}-readonly`)],yt.prototype,"_span",void 0),gt([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],yt.prototype,"format",void 0),yt=gt([t.CustomElement({tagName:t.P+"-input-number",template:`<input type="number" class="${t.PCSS}-input ${t.PCSS}-viewfinder" /><span class="${t.PCSS}-readonly"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></span>`,shadow:t.Defaults.USE_SHADOW_ROOT})],yt);var ft=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};let _t=class PacemPasswordInputElement extends PacemTextualInputElement{constructor(){super(),this._togglerMousedownHandler=e=>{0==e.button&&(t.avoidHandler(e),this.toggleVisibility())}}get inputFields(){return[this._input]}viewActivatedCallback(){super.viewActivatedCallback();const e=this.id??"_"+t.Utils.uniqueCode(),i=this._input.id=e+"_ctrl";this._toggler.setAttribute("aria-controls",i),this._toggler.setAttribute("role","button"),this._syncToggler(),this._toggler.addEventListener("mousedown",this._togglerMousedownHandler,!1)}disconnectedCallback(){t.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(e){return t.Utils.leftPad("",Math.floor(8+3*Math.random()),"•")}};ft([t.ViewChild("input[type=password]")],_t.prototype,"_input",void 0),ft([t.ViewChild(`span.${t.PCSS}-readonly`)],_t.prototype,"_span",void 0),ft([t.ViewChild(`i.${t.PCSS}-icon.${t.PCSS}-clickable`)],_t.prototype,"_toggler",void 0),_t=ft([t.CustomElement({tagName:t.P+"-input-password",template:`<input type="password" class="${t.PCSS}-input ${t.PCSS}-viewfinder" /><i class="${t.PCSS}-icon ${t.PCSS}-clickable"></i>\n${E}<span class="${t.PCSS}-readonly"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></span>`,shadow:t.Defaults.USE_SHADOW_ROOT})],_t);var bt=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};let Ct=class PacemSearchInputElement extends PacemTextualInputElement{constructor(){super()}get inputFields(){return[this.input]}toggleReadonlyView(e){}};bt([t.ViewChild("input[type=search]")],Ct.prototype,"input",void 0),Ct=bt([t.CustomElement({tagName:t.P+"-input-search",template:'<input type="search" class="'+t.PCSS+'-input" />',shadow:t.Defaults.USE_SHADOW_ROOT})],Ct);var Pt=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};let Et=class PacemTelInputElement extends PacemTextualInputElement{constructor(){super()}toggleReadonlyView(e){this.input.hidden=e,this.anchor.hidden=!e}get inputFields(){return[this.input]}};Pt([t.ViewChild("input[type=tel]")],Et.prototype,"input",void 0),Pt([t.ViewChild(t.P+"-a")],Et.prototype,"anchor",void 0),Et=Pt([t.CustomElement({tagName:t.P+"-input-tel",template:`<input type="tel" class="${t.PCSS}-input" /><${t.P}-a class="${t.PCSS}-readonly" disabled="{{ $pacem.isNullOrEmpty(:host.value) }}" href="{{ 'tel:'+ :host.value }}"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></${t.P}-a>`,shadow:t.Defaults.USE_SHADOW_ROOT})],Et);var wt=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};let St=class PacemTextInputElement extends PacemTextualInputElement{constructor(){super()}toggleReadonlyView(e){this._span.hidden=!e,this._input.hidden=e}get inputFields(){return[this._input]}};wt([t.ViewChild("input[type=text]")],St.prototype,"_input",void 0),wt([t.ViewChild("span."+t.PCSS+"-readonly")],St.prototype,"_span",void 0),St=wt([t.CustomElement({tagName:t.P+"-input-text",template:`<input type="text" class="${t.PCSS}-input" />${E}<span class="${t.PCSS}-readonly"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></span>`,shadow:t.Defaults.USE_SHADOW_ROOT})],St);var kt=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};let $t=class PacemUrlInputElement extends PacemTextualInputElement{constructor(){super()}toggleReadonlyView(e){this.input.hidden=e,this.anchor.hidden=!e}get inputFields(){return[this.input]}};kt([t.ViewChild("input[type=url]")],$t.prototype,"input",void 0),kt([t.ViewChild(t.P+"-a")],$t.prototype,"anchor",void 0),$t=kt([t.CustomElement({tagName:t.P+"-input-url",template:`<input type="url" class="${t.PCSS}-input" />${E}<${t.P}-a class="${t.PCSS}-readonly" disabled="{{ $pacem.isNullOrEmpty(:host.value) }}" href="{{ :host.value }}" target="_blank"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></${t.P}-a>`,shadow:t.Defaults.USE_SHADOW_ROOT})],$t);var Ut=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};let Nt=class PacemLatLngElement extends 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(e){return e&&"number"==typeof e.lat&&"number"==typeof e.lng?e:a.Components.Maps.MapConsts.DEFAULT_COORDS}onChange(e){if(e&&"dragend"===e.type){var i=e;this._lat=i.detail.position.lat,this._lng=i.detail.position.lng}const a=this._lat,r=this._lng;return t.Utils.isNull(a)||t.Utils.isNull(r)?t.Utils.fromResult(this.value):t.Utils.fromResult(this.value={lat:a,lng:r})}propertyChangedCallback(e,i,a,r){if(super.propertyChangedCallback(e,i,a,r),"options"===e&&!r){const e=t.Utils.clone(a||{provider:"osm"});this._synchronizeOptions(e)}}viewActivatedCallback(){super.viewActivatedCallback(),this._synchronizeOptions()}_synchronizeOptions(e=this.options||{provider:"osm"}){const i=this._marker,a=this._map;switch(i.icon=e.icon,e&&e.provider){case"azure":this._azureAdapter.subscriptionKey=e.apiKey,a.adapter=this._azureAdapter;break;case"google":case"gmaps":this._googleAdapter.apiKey=e.apiKey,a.adapter=this._googleAdapter;break;default:t.Utils.isNullOrEmpty(e.attribution)||(this._leafletAdapter.attribution=e.attribution),t.Utils.isNullOrEmpty(e.tiles)||(this._leafletAdapter.tiles=e.tiles),a.adapter=this._leafletAdapter}delete e.provider,delete e.icon,delete e.apiKey,delete e.attribution,delete e.tiles;for(let t in e)t in a&&(a[t]=e[t])}};Ut([t.ViewChild(t.P+"-map-adapter-leaflet")],Nt.prototype,"_leafletAdapter",void 0),Ut([t.ViewChild(t.P+"-map-adapter-azure")],Nt.prototype,"_azureAdapter",void 0),Ut([t.ViewChild(t.P+"-map-adapter-google")],Nt.prototype,"_googleAdapter",void 0),Ut([t.ViewChild(t.P+"-map")],Nt.prototype,"_map",void 0),Ut([t.ViewChild(t.P+"-map-marker")],Nt.prototype,"_marker",void 0),Ut([t.ViewChild(t.P+"-input-number:nth-child(1)")],Nt.prototype,"_latInput",void 0),Ut([t.ViewChild(t.P+"-input-number:nth-child(2)")],Nt.prototype,"_lngInput",void 0),Ut([t.ViewChild(`.${t.PCSS}-latlng-fields`)],Nt.prototype,"_inputContainer",void 0),Ut([t.ViewChild(t.P+"-fetch")],Nt.prototype,"_fetcher",void 0),Ut([t.Watch({converter:t.PropertyConverters.Json,emit:!1})],Nt.prototype,"options",void 0),Ut([t.Watch()],Nt.prototype,"_lat",void 0),Ut([t.Watch()],Nt.prototype,"_lng",void 0),Nt=Ut([t.CustomElement({tagName:t.P+"-latlng",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<div class="${t.PCSS}-latlng">\n <div class="${t.PCSS}-latlng-fields ${t.PCSS}-viewfinder">\n <${t.P}-input-number class="${t.PCSS}-lat" value="{{ :host._lat, twoway }}" min="-90" max="90" step="{{ 'any' }}"></${t.P}-input-number>\n <${t.P}-input-number class="${t.PCSS}-lng" value="{{ :host._lng, twoway }}" min="-180" max="180" step="{{ 'any' }}"></${t.P}-input-number>\n </div>\n <${t.P}-panel hide="{{ Pacem.Utils.isNull(:host.value) || :host.readonly }}">\n <dl class="${t.PCSS}-latlng-preview">\n <dt>decimals:</dt><dd><${t.P}-text text="{{ :host._getViewValue(:host.value, 12) }}"></${t.P}-text></dd>\n <dt>address:</dt><dd><${t.P}-text text="{{ ::_fetcher.result.display_name || '?' }}"></${t.P}-text></dd>\n <dt>degrees:</dt><dd><${t.P}-span css-class="{{ {'${t.PCSS}-lat-north': :host._lat > 0, '${t.PCSS}-lat-south': :host._lat < 0} }}" content="{{ $pacem.decToDeg(Math.abs(:host._lat)) }}"></${t.P}-span>,\n <${t.P}-span css-class="{{ {'${t.PCSS}-lng-east': :host._lng > 0, '${t.PCSS}-lng-west': :host._lng < 0} }}" content="{{ $pacem.decToDeg(Math.abs(:host._lng)) }}"></${t.P}-span></dd>\n </dl>\n </${t.P}-panel>\n <${t.P}-span class="${t.PCSS}-readonly" hide="{{ !:host.readonly }}" content="{{ :host.viewValue + ($pacem.isNullOrEmpty(::_fetcher.result.display_name) ? '' : (' <small>'+ ::_fetcher.result.display_name +'</small>')) }}"></${t.P}-span>\n\n <${t.P}-map-adapter-leaflet></${t.P}-map-adapter-leaflet>\n <${t.P}-map-adapter-azure></${t.P}-map-adapter-azure>\n <${t.P}-map-adapter-google></${t.P}-map-adapter-google>\n\n <${t.P}-map adapter="{{ ::_adapter }}">\n <${t.P}-map-marker position="{{ :host._ensureValue(:host.value) }}" on-dragend=":host.changeHandler($event)" draggable="{{ !:host.readonly }}"></${t.P}-map-marker>\n </${t.P}-map>\n <${t.P}-fetch disabled="{{ $pacem.isNull(:host.value) }}" parameters="{{ { format: 'json', lat: :host._lat, lon: :host._lng } }}" url="https://nominatim.openstreetmap.org/reverse"></${t.P}-fetch>\n</div>`})],Nt);var Ot=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};const xt=`change-policy="${qe.Blur}" readonly="{{ :host.readonly }}"`;function Vt(e){return t.Utils.isNullOrEmpty(e&&e.name)}let Dt=class PacemNameValueListElement extends PacemBaseElement{constructor(){super(...arguments),this.inputFields=[],this._bag=[]}toggleReadonlyView(e){}onChange(e){return new Promise((e,t)=>{let i=this._bagToValue(this._bag);this.compareValuePropertyValues(i,this.value)?t():e(this.value=i)})}acceptValue(e){this._bag=this._valueToBag(e)}getViewValue(e){return""}compareValuePropertyValues(e,i){return t.Utils.Json.stringify(e)===t.Utils.Json.stringify(i)}convertValueAttributeToProperty(e){return t.PropertyConverters.Json.convert(e)}propertyChangedCallback(e,t,i,a){super.propertyChangedCallback(e,t,i,a),"dictionary"!==e||a||(this.value=this._bagToValue())}_bagToValue(e=this._bag){if(!this.dictionary){let t=[];for(let i of e||[])Vt(i)||t.find(e=>e.name===i.name&&e.value===i.value)||t.push(i);return t}let t={};for(let i of e||[])i.name in t||(t[i.name]=i.value);return t}_valueToBag(e=this.value){const i=[];if(!t.Utils.isNullOrEmpty(e)&&"object"==typeof e)if(this.dictionary&&!t.Utils.isArray(e))for(let t in e)i.push({name:t,value:e[t]});else!this.dictionary&&t.Utils.isArray(e)&&Array.prototype.splice.apply(i,[0,0].concat(e.map(e=>t.Utils.clone(e))));return t.Utils.isNullOrEmpty(i)?[{name:"",value:""}]:i}_deleteAt(e){this._bag.splice(e.detail,1),this.changeHandler(e)}_addItem(e){const i=this._bag,a=this._bag[this._bag.length-1];!t.Utils.isEmpty(i)&&Vt(a)||i.push({name:"",value:""})}};Ot([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],Dt.prototype,"dictionary",void 0),Ot([t.Watch({converter:t.PropertyConverters.Json})],Dt.prototype,"_bag",void 0),Dt=Ot([t.CustomElement({tagName:t.P+"-namevalue-list",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<${t.P}-repeater datasource="{{ :host._bag }}" on-itemdelete=":host._deleteAt($event)">\n <template>\n <div class="${t.PCSS}-fieldset ${t.PCSS}-margin margin-bottom-1">\n <div class="fieldset-auto">\n <div class="${t.PCSS}-fieldgroup">\n <${t.P}-input-text ${xt} value="{{ ^item.name, twoway }}" on-change=":host.changeHandler($event)"></${t.P}-input-text>\n <div class="fieldgroup-prepend"></div>\n </div>\n <div class="${t.PCSS}-fieldgroup">\n <${t.P}-input-text ${xt} value="{{ ^item.value, twoway }}" on-change=":host.changeHandler($event)"></${t.P}-input-text>\n <div class="fieldgroup-append">\n <${t.P}-button class="${t.PCSS}-cell cols-2 flat delete" hide="{{ :host.readonly }}" command-name="delete" command-argument="{{ ^index }}"></${t.P}-button>\n </div>\n </div>\n </div>\n </div>\n </template>\n <${t.P}-button class="flat add" hide="{{ :host.readonly }}" on-click=":host._addItem($event)"></${t.P}-button>\n</${t.P}-repeater>`})],Dt);var Ht=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};let At=class PacemPropertyPickerElement extends PacemBaseElement{get inputFields(){return[this._select]}toggleReadonlyView(e){this._select.readonly=e}onChange(e){return t.Utils.fromResult(this.value=this._select.value)}acceptValue(e){this._select.value=e}getViewValue(e){return this._select.viewValue}convertValueAttributeToProperty(e){return t.PropertyConverters.Element.convert(e)}viewActivatedCallback(){super.viewActivatedCallback(),this._databind()}propertyChangedCallback(e,t,i,a){if(super.propertyChangedCallback(e,t,i,a),!a&&"target"===e)this._databind()}_databind(){const e=[],i=(a,r,s)=>{const n=a[r];if("object"==typeof n&&null!=n&&!t.Utils.isArray(n))for(let t of Object.keys(n)){const a=s+"."+t;e.push(a),i(n,t,a)}};let a=this.target;if(!t.Utils.isNull(a)){let r=t.CustomElementUtils.getWatchedProperties(a);for(let t of r){let r=t.name;e.push(r),i(a,r,r)}}this._select.datasource=e.sort()}};Ht([t.ViewChild(t.P+"-select")],At.prototype,"_select",void 0),Ht([t.Watch({converter:t.PropertyConverters.Element})],At.prototype,"target",void 0),At=Ht([t.CustomElement({tagName:t.P+"-property-picker",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<${t.P}-select></${t.P}-select>`})],At);var Tt=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};let Rt=class PacemRadioElement extends PacemBaseElement{convertValueAttributeToProperty(e){return e}constructor(){super(),this._key="_"+t.Utils.uniqueCode()}toggleReadonlyView(e){this.span.hidden=!e,this._radio.hidden=e}get inputFields(){return[this._radio]}onChange(e){this.selected=this._radio.checked;const i=this.selected?this._radio.value:void 0;return t.Utils.fromResult(i)}viewActivatedCallback(){super.viewActivatedCallback(),this._radio.id=this._label.htmlFor=this._key}propertyChangedCallback(e,i,a,r){switch(super.propertyChangedCallback(e,i,a,r),e){case"name":this._radio.name=a;break;case"selected":(this._radio.checked=a)?t.Utils.addClass(this,t.PCSS+"-selected"):t.Utils.removeClass(this,t.PCSS+"-selected")}}acceptValue(e){this._radio.value=t.Utils.isNullOrEmpty(e)?"":e}getViewValue(e){return t.Utils.isNull(e)?"":this.caption}};Tt([t.ViewChild("input[type=radio]")],Rt.prototype,"_radio",void 0),Tt([t.ViewChild("label")],Rt.prototype,"_label",void 0),Tt([t.ViewChild(`.${t.PCSS}-readonly`)],Rt.prototype,"span",void 0),Tt([t.Watch({converter:t.PropertyConverters.String})],Rt.prototype,"caption",void 0),Tt([t.Watch({converter:t.PropertyConverters.Boolean})],Rt.prototype,"selected",void 0),Rt=Tt([t.CustomElement({tagName:t.P+"-radio",template:`<${t.P}-span class="${t.PCSS}-readonly ${t.PCSS}-radio" text="{{ :host.caption }}"></${t.P}-span><input type="radio" class="${t.PCSS}-input" /><label class="${t.PCSS}-label ${t.PCSS}-radio ${t.PCSS}-viewfinder"><${t.P}-text text="{{ :host.caption }}"></${t.P}-text></label>`,shadow:t.Defaults.USE_SHADOW_ROOT})],Rt);var Lt=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};let It=class PacemRadioListElement extends PacemDataSourceElement{acceptValue(e){}constructor(){super(),this.key="_"+t.Utils.uniqueCode()}get inputFields(){return[]}propertyChangedCallback(e,t,i,a){super.propertyChangedCallback(e,t,i,a),"disabled"===e&&(this._disable.model=i)}viewActivatedCallback(){super.viewActivatedCallback(),this._disable.model=this.disabled}toggleReadonlyView(e){this._repeater.hidden=e,this._span.hidden=!e}_selectionChanged(e,t,i){"selected"===e.detail.propertyName&&!0===e.detail.currentValue&&(this._selectedValue=this.mapEntityToValue(this.datasource[t]),this.changeHandler(e))}onChange(e){return this.value=this._selectedValue,this.databind(),t.Utils.fromResult(this._selectedValue)}};Lt([t.ViewChild(t.P+"-repeater")],It.prototype,"_repeater",void 0),Lt([t.ViewChild(t.P+"-data")],It.prototype,"_disable",void 0),Lt([t.ViewChild(`span.${t.PCSS}-readonly`)],It.prototype,"_span",void 0),It=Lt([t.CustomElement({tagName:t.P+"-radio-list",template:`<${t.P}-repeater datasource="{{ :host.adaptedDatasource }}">\n <ol class="${t.PCSS}-radio-list ${t.PCSS}-viewfinder" pacem>\n <template>\n <li><${t.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-${t.PropertyChangeEventName}=":host._selectionChanged($event, ^index, ^item)"></${t.P}-radio></li>\n </template>\n </ol>\n</${t.P}-repeater><span class="${t.PCSS}-readonly ${t.PCSS}-radio"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></span><${t.P}-data></${t.P}-data><${t.P}-content></${t.P}-content>`,shadow:t.Defaults.USE_SHADOW_ROOT})],It);var Ft=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};let Wt=class PacemSelectElement extends PacemDataSourceElement{constructor(){super(...arguments),this.emptyOption=!0}toggleReadonlyView(e){this._repeater.hidden=e,this._span.hidden=!e}get inputFields(){return[this._select]}_manageDom(e){const i=e.detail,a=i.item;let r=i.dom.find(e=>e instanceof HTMLOptionElement);r.value=a.value,r.textContent=a.viewValue,r.disabled=a.disabled,r.selected=this.isDataSourceItemSelected(a),(t.Utils.isNullOrEmpty(r.value)?t.Utils.addClass:t.Utils.removeClass).apply(this,[r,t.PCSS+"-watermark"])}onChange(e){let i,a=this._select.selectedIndex,r=this.adaptedDatasource,s=a>=0&&r[a];return i=null!=s?s.value:void 0,t.Utils.fromResult(this.value=i)}propertyChangedCallback(e,t,i,a){switch(super.propertyChangedCallback(e,t,i,a),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(e){this.emptyOption?super.handleDatasourceMismatch(e):t.Utils.isNullOrEmpty(e)?this.value=void 0:this.value=e[0].value}acceptValue(e){const i=this.adaptedDatasource,a=i&&i.filter(t=>this.isDataSourceItemSelected(t,e));if(a&&1==a.length)this._select.selectedIndex=i.indexOf(a[0]);else{this._select.value=void 0;let e=this._select.options;e.length>0&&t.Utils.isNullOrEmpty(e[0].value)&&(this._select.selectedIndex=0)}}viewActivatedCallback(){super.viewActivatedCallback();this._select.addEventListener("wheel",this.emitHandler,{capture:!1,passive:!1})}disconnectedCallback(){if(!t.Utils.isNull(this._select)){this._select.removeEventListener("wheel",this.emitHandler,{capture:!1,passive:!1})}super.disconnectedCallback()}};Ft([t.ViewChild("select")],Wt.prototype,"_select",void 0),Ft([t.ViewChild(t.P+"-repeater")],Wt.prototype,"_repeater",void 0),Ft([t.ViewChild(`span.${t.PCSS}-readonly`)],Wt.prototype,"_span",void 0),Ft([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],Wt.prototype,"emptyOption",void 0),Wt=Ft([t.CustomElement({tagName:t.P+"-select",template:`<${t.P}-repeater datasource="{{ :host.adaptedDatasource }}" on-${t.Components.RepeaterItemCreateEventName}=":host._manageDom($event)">\n <select class="${t.PCSS}-select ${t.PCSS}-viewfinder">\n <template>\n <option></option>\n </template>\n </select>\n</${t.P}-repeater><span class="${t.PCSS}-readonly"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></span><${t.P}-content></${t.P}-content>`,shadow:t.Defaults.USE_SHADOW_ROOT})],Wt);var Bt=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};let jt=class PacemSliderElement extends 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=e=>{const i=e instanceof MouseEvent?e.clientX:e.touches&&e.touches.length&&e.touches[0].clientX,a=this._trackSize;t.Utils.isNullOrEmpty(a)||this._computeAndAssignValue(i,!0)},this._keydownHandler=e=>{switch(e.keyCode){case 39:case 37:t.avoidHandler(e);let i=39===e.keyCode,a=("number"!=typeof this.step?1:this.step)*(i?1:-1),r=!1,s=e=>{r=!0,window.removeEventListener("keyup",s,!1),t.Utils.removeClass(this,"slider-keydown")};window.addEventListener("keyup",s,!1),t.Utils.addClass(this,"slider-keydown"),t.Utils.accelerateCallback(e=>{(e.cancel=r)||this._setValue(this.value+a)})}}}onChange(e){return new Promise((t,i)=>{"slide"===e.type&&t(this.value=e.detail),t(this.value)})}_draw(e=this.value){const i=this._trackSize;if(t.Utils.isNull(i))return;const a=t.Utils.isNullOrEmpty(e)?this.min:parseFloat(e),r=Math.min(1,Math.max(0,(a-this.min)/(this.max-this.min)));this._progress.style.transform=`scale(${r}, 1)`,this._thumb.style.transform=`translateX(${Math.round(r*i.width)}px)`}_format(e){const i=this.format;if(!t.Utils.isNullOrEmpty(i))return new Intl.NumberFormat(t.Utils.lang(this),i).format(e);let a="-";t.Utils.isNull(e)||(a=e.toLocaleString());let r=new CustomEvent("formatvalue",{detail:{value:e}});return this.dispatchEvent(r),t.Utils.isNull(r.detail.output)?a:r.detail.output}acceptValue(e){this._draw(e)}getViewValue(e){return this._format(e)}convertValueAttributeToProperty(e){return parseFloat(e)}toggleReadonlyView(e){this._thumb.hidden=e;const i="cursor-pointer";e?(t.Utils.removeClass(this._max,i),t.Utils.removeClass(this._min,i)):(t.Utils.addClass(this._max,i),t.Utils.addClass(this._min,i))}_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 i=this._trackSize,a=this.step;let r=(e-i.x)/i.width,s=(this.max-this.min)*r+this.min;"number"==typeof a&&(s=Math.round(s/a)*a),t?this._setValue(s):this._draw(s)}_setValue(e){isNaN(e)||t.Utils.isNull(e)?e=void 0:(!isNaN(this.min)&&e<this.min&&(e=this.min),!isNaN(this.max)&&e>this.max&&(e=this.max)),this.changeHandler(new CustomEvent("slide",{detail:e}))}connectedCallback(){super.connectedCallback(),this.addEventListener("mousedown",this._downHandler,!1),this.addEventListener("touchstart",this._downHandler,{passive:!1,capture:!1})}viewActivatedCallback(){super.viewActivatedCallback(),this._dragger.addEventListener(t.UI.DragDropEventType.Init,this._startHandler,!1),this._dragger.addEventListener(t.UI.DragDropEventType.Drag,this._dragHandler,!1),this._dragger.addEventListener(t.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 e=this._shellProxy.dom[0];t.Utils.isNull(e)||(e.target=this._thumb,e.options={trigger:i.Components.UI.BalloonTrigger.Focus,trackPosition:!0,position:i.Components.UI.BalloonPosition.Top,align:i.Components.UI.BalloonAlignment.Center,behavior:i.Components.UI.BalloonBehavior.Tooltip,hoverDelay:0,hoverTimeout:0},this._syncThumbLabel()),this._thumb.tabIndex=0}_syncThumbLabel(e=this.thumbLabel){const i=this._shellProxy.dom[0];(e?t.Utils.addClass:t.Utils.removeClass).apply(this,[this,"slider-thumblabel"]),i.disabled=!e}disconnectedCallback(){this.removeEventListener("mousedown",this._downHandler,!1),this.removeEventListener("touchstart",this._downHandler,{capture:!1}),t.Utils.isNull(this._dragger)||(this._dragger.removeEventListener(t.UI.DragDropEventType.End,this._endHandler,!1),this._dragger.removeEventListener(t.UI.DragDropEventType.Drag,this._dragHandler,!1),this._dragger.removeEventListener(t.UI.DragDropEventType.Init,this._startHandler,!1)),t.Utils.isNull(this._thumb)||this._thumb.removeEventListener("keydown",this._keydownHandler,!1),super.disconnectedCallback()}propertyChangedCallback(e,i,a,r){if(super.propertyChangedCallback(e,i,a,r),!r)switch(e){case"thumbLabel":this._syncThumbLabel(a);break;case"min":case"max":t.Utils.isNull(this._max)||t.Utils.isNull(this._min)||(this._min.text=this._format(this.min),this._max.text=this._format(this.max)),this._setValue(this.value),this._draw()}}};Bt([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],jt.prototype,"min",void 0),Bt([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],jt.prototype,"max",void 0),Bt([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],jt.prototype,"thumbLabel",void 0),Bt([t.Watch({emit:!1,converter:{convert:e=>{let t=parseFloat(e);return isNaN(t)?"any":t},convertBack:e=>(e||"").toString()}})],jt.prototype,"step",void 0),Bt([t.Watch({emit:!1,converter:t.PropertyConverters.String})],jt.prototype,"changePolicy",void 0),Bt([t.Watch({emit:!1,converter:t.PropertyConverters.Json})],jt.prototype,"format",void 0),Bt([t.ViewChild(".slider-track")],jt.prototype,"_track",void 0),Bt([t.ViewChild(".slider-progress")],jt.prototype,"_progress",void 0),Bt([t.ViewChild(".slider-thumb")],jt.prototype,"_thumb",void 0),Bt([t.ViewChild(`${t.P}-text[min]`)],jt.prototype,"_min",void 0),Bt([t.ViewChild(`${t.P}-text[max]`)],jt.prototype,"_max",void 0),Bt([t.ViewChild(`${t.P}-drag-drop`)],jt.prototype,"_dragger",void 0),Bt([t.ViewChild(`${t.P}-shell-proxy`)],jt.prototype,"_shellProxy",void 0),jt=Bt([t.CustomElement({tagName:t.P+"-slider",template:`<div class="${t.PCSS}-viewfinder ${t.PCSS}-slider"><${t.P}-text text="{{ :host._format(:host.min) }}" min></${t.P}-text>\n <div class="slider-track"><div class="slider-progress"></div></div>\n <${t.P}-panel class="${t.PCSS}-clickable slider-thumb" behaviors="{{ [::_dragger] }}">\n <div class="thumb-label"></div>\n </${t.P}-panel>\n <${t.P}-text text="{{ :host._format(:host.max) }}" max></${t.P}-text>\n <div class="slider-footer"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></div>\n </div>\n<${t.P}-drag-drop lock-timeout="0"></${t.P}-drag-drop><${t.P}-resize watch-position="true" on-${t.Components.ResizeEventName}=":host._setTrackSize($event)" target="{{ ::_track }}"></${t.P}-resize>\n<${t.P}-shell-proxy><${t.P}-balloon class="text-center"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></${t.P}-balloon></${t.P}-shell-proxy>\n`,shadow:t.Defaults.USE_SHADOW_ROOT})],jt);var Mt=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};class SuggestionSelectEvent extends t.CustomTypedEvent{constructor(e){super("suggestionselect",{selectedValue:e})}}let zt=class PacemSuggestElement extends 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=e=>{t.Utils.addClass(this._btnArrow,"rotate-180")},this._balloonPopoutHandler=e=>{t.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=e=>{this.#C&&(t.avoidHandler(e),this.#C=!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.#C=!1,this._keydownHandler=e=>{var i=!1;if(t.Utils.isNull(this.#P)){const a=this._findFirstAvailableListItem();if(!t.Utils.isNull(a))switch(e.keyCode){case 40:t.avoidHandler(e),this._focus(a);break;case 13:t.avoidHandler(e),i=!0,1===this.#E.length?this._select(a):this._focus(a)}}else{var a,r=this.#P,s=r;const n=e=>!t.Utils.isNull(e)&&"li"===e.localName&&"true"===e.dataset.pacemDisabled,o=e=>!t.Utils.isNull(e)&&"li"===e.localName&&"true"!==e.dataset.pacemDisabled;switch(e.keyCode){case 38:t.avoidHandler(e);do{if(o(s=s.previousElementSibling)){a=s;break}}while(n(s));a??=r;break;case 40:t.avoidHandler(e);do{if(o(s=s.nextElementSibling)){a=s;break}}while(n(s));a??=r;break;case 27:t.avoidHandler(e),this._undo(),this.popout();break;case 9:case 13:t.avoidHandler(e),i=!0,this._select()}this._focus(a),this.#C=i}},this._selectHandler=e=>{t.avoidHandler(e),this._select(e.currentTarget)}}get inputFields(){return[this._input]}acceptValue(e){/*!this._isTyping && */!this.allowNew&&t.Utils.isNullOrEmpty(this.datasource)||(this._input.value=this.getViewValue(e)||(this._isTyping?this._input.value:""))}getViewValue(e){var i=super.getViewValue(e);return t.Utils.isNullOrEmpty(i)&&this.allowNew&&!t.Utils.isNullOrEmpty(e)&&(i=this.mapEntityToViewValue(e)),i}onChange(e){return new Promise((t,i)=>{if("suggestionselect"===e.type){const i=e.detail.selectedValue;this.value=i,i&&this.popout(),t(i)}else t(this.value)})}viewActivatedCallback(){super.viewActivatedCallback(),this._setDropdownMode(),this._setupItemTemplate();var e=this._createBalloon();e.appendChild(this._repeater),this._checkBalloon(e);t.CustomElementUtils.findAncestorShell(this).appendChild(e),this._balloon=e,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(e,i,a,r){if(super.propertyChangedCallback(e,i,a,r),t.Utils.isNull(this._balloon))return;const s=this._isTyping;switch(e){case"adaptedDatasource":t.Utils.isNullOrEmpty(a)?this.popout():s?this.popup():this._input.value=this.getViewValue(this.value);break;case"hint":s||a===this._input.value||(this._input.value=a,this.#P=null);break;case"readonly":this._setDropdownMode();case"disabled":case"value":this._checkBalloon();break;case"itemtemplate":r||this._setupItemTemplate();break;case"allowTyping":r||this._setDropdownMode()}["adaptedDatasource","hint","value"].indexOf(e)>=0&&this._databind(),["allowTyping","value","hint"].indexOf(e)>=0&&this._syncButtons()}disconnectedCallback(){t.Utils.isNull(this._balloon)||(this._balloon.removeEventListener("popup",this._balloonPopupHandler,!1),this._balloon.removeEventListener("popout",this._balloonPopoutHandler,!1),this._balloon.remove()),t.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)),t.Utils.isNull(this._btnClear)||this._btnClear.removeEventListener("mousedown",this._clearBtnHandler,!1),t.Utils.isNull(this._btnArrow)||this._btnArrow.addEventListener("mousedown",this._toggleBtnHandler,!1),super.disconnectedCallback()}#E;_databind(){if(!t.Utils.isNull(this._repeater)){const e=this.#E=this._filter(this.adaptedDatasource,this._input.value);this._repeater.datasource=e}}_syncButtons(){t.Utils.isNull(this._btnArrow)||(this._btnArrow.hide=!1!==this.allowTyping||!t.Utils.isNullOrEmpty(this._input.value||this.value)),t.Utils.isNull(this._btnClear)||(this._btnClear.hide=this.readonly||t.Utils.isNullOrEmpty(this._input.value||this.value))}get _isTyping(){return t.Utils.is(this._input,":focus")}_undo(){this._focus(null),this.hint=this._input.value=this.getViewValue(this.value)||""}_findFirstAvailableListItem(){var e;if(!0===this._balloon.visible&&!t.Utils.isNull(e=this._repeater.querySelector("ol > li")))for(;!t.Utils.isNull(e)&&"true"===e.dataset.pacemDisabled&&"li"===e.localName;)e=e.nextElementSibling;return e}#C;_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"),i=document.createElement("li");i.append(e),t.content.appendChild(i),this._tmplProxy.target=t}else this._tmplProxy.target=this._defaultTemplate}#P;_focus(e){if(this.preventFocus)return;if(t.Utils.isNull(e))return void(this.#P=null);const i=e.parentElement.children;for(let t=0;t<i.length;t++){const a=i.item(t);if(a===e){a.dataset.pacemFocused="true",this.#P=a;const e=this._input,t=e.value=JSON.parse(a.dataset.pacemViewValue);e.setSelectionRange(t.length,t.length)}else delete a.dataset.pacemFocused}}_select(e=this.#P){const t=JSON.parse(e.dataset.pacemValue);"true"===e.dataset.pacemDisabled||this.changeHandler(new SuggestionSelectEvent(t))}_filter(e,i,a=this.value){let r=e||[];if(!t.Utils.isNullOrEmpty(i&&i.trim())){const e=i.toLowerCase().split(" ");let a=r.filter(i=>{for(let a of e){if(i.viewValue?.toLowerCase().indexOf(a)>=0)return!0;const e=this.filterFields;if(!t.Utils.isNullOrEmpty(e)){const r=i.data;if("object"==typeof r&&!t.Utils.isNullOrEmpty(r))for(let i of e){const e=i.split(".");let s=0,n=r;for(;!t.Utils.isNull(n)&&s<e.length;)n=n[e[s]],s++;if(!t.Utils.isNullOrEmpty(n)&&n.toString().toLowerCase().indexOf(a)>=0)return!0}}}return!1});r=this.allowNew&&t.Utils.isNullOrEmpty(this.valueProperty)&&t.Utils.isNullOrEmpty(this.textProperty)&&(t.Utils.isNullOrEmpty(a)||t.Utils.isNull(a.find(e=>e.viewValue===i)))?[{value:i,viewValue:i,data:i}].concat(a):a}let s=r;return!1!==this.allowTyping&&(s=r.slice(0,this.maxSuggestions||10)),this._isTyping&&this.popup(),this._balloon.style.opacity=t.Utils.isNullOrEmpty(s)?"0":"",this.log(t.Logging.LogLevel.Log,`${s.length} dropdown suggestion(s), given hint '${i}' and ${(e||[]).length} datasource items`),s}_itemCreate(e){const t=e.detail.dom.find(e=>e instanceof HTMLLIElement),i=e.detail.item;e.detail.index;const a=!0===i.disabled;t.tabIndex=a?-1:0,t.dataset.pacemValue=JSON.stringify(i.value),t.dataset.pacemViewValue=JSON.stringify(i.viewValue),t.dataset.pacemDisabled=a.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(e=100){!t.Utils.isNullOrEmpty(this.adaptedDatasource)&&t.Utils.isVisible(this)&&this._balloon?.popup(e)}popout(e=0){this.#P=null,this._balloon?.popout(e)}_checkBalloon(e=this._balloon){if(!t.Utils.isNull(e)){const i=!t.Utils.isNullOrEmpty(this.value)&&!t.Utils.isNullOrEmpty(this._input.value);e.disabled=i||this.readonly||this.disabled||!1}}_createBalloon(){const e=document.createElement(t.P+"-balloon");return t.Utils.addClass(e,"suggest dropdown"),e.options={trackPosition:!0,trigger:i.Components.UI.BalloonTrigger.Focus,position:i.Components.UI.BalloonPosition.VerticalAuto,size:i.Components.UI.BalloonSizing.Match,align:i.Components.UI.BalloonAlignment.Start,behavior:i.Components.UI.BalloonBehavior.Menu,hoverDelay:100,hoverTimeout:0},e.addEventListener("popup",this._balloonPopupHandler,!1),e.addEventListener("popout",this._balloonPopoutHandler,!1),e.target=this._input,e}};Mt([t.ViewChild("input[type=text]")],zt.prototype,"_input",void 0),Mt([t.ViewChild(t.P+"-repeater")],zt.prototype,"_repeater",void 0),Mt([t.ViewChild(`span.${t.PCSS}-readonly`)],zt.prototype,"span",void 0),Mt([t.ViewChild("template")],zt.prototype,"_defaultTemplate",void 0),Mt([t.ViewChild(t.P+"-template-proxy")],zt.prototype,"_tmplProxy",void 0),Mt([t.ViewChild(`${t.P}-button[toggle]`)],zt.prototype,"_btnArrow",void 0),Mt([t.ViewChild(`${t.P}-button[clear]`)],zt.prototype,"_btnClear",void 0),Mt([t.Watch({converter:t.PropertyConverters.String})],zt.prototype,"hint",void 0),Mt([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],zt.prototype,"maxSuggestions",void 0),Mt([t.Watch({converter:t.PropertyConverters.Boolean})],zt.prototype,"allowTyping",void 0),Mt([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],zt.prototype,"preventFocus",void 0),Mt([t.Watch({emit:!1,converter:t.PropertyConverters.Element})],zt.prototype,"itemtemplate",void 0),Mt([t.Watch({emit:!1,converter:t.PropertyConverters.StringArray})],zt.prototype,"filterFields",void 0),Mt([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],zt.prototype,"allowNew",void 0),zt=Mt([t.CustomElement({tagName:t.P+"-suggest",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<div class="${t.PCSS}-relative"><input type="text" class="${t.PCSS}-input" />\n<${t.P}-button clear tab-order="-1"\nclass="button-flat ${t.PCSS}-anim anim-pop anim-sudden anim-quick pos-absolute absolute-right absolute-top display-block ${t.PCSS}-margin margin-0" \n icon-glyph="highlight_off"></${t.P}-button>\n<${t.P}-button \nclass="button-flat icon-rotate ${t.PCSS}-anim anim-pop anim-sudden anim-quick pos-absolute absolute-right absolute-top display-block ${t.PCSS}-margin margin-0" \n icon-glyph="arrow_drop_down" tab-order="-1" toggle></${t.P}-button>\n</div>\n<span class="${t.PCSS}-readonly"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></span>\n<${t.P}-repeater on-${t.Components.RepeaterItemCreateEventName}=":host._itemCreate($event)" on-${t.Components.RepeaterItemRemoveEventName}=":host._itemRemove($event)">\n <ol>\n <${t.P}-template-proxy></${t.P}-template-proxy>\n </ol>\n</${t.P}-repeater><${t.P}-content></${t.P}-content>\n<template>\n <li><${t.P}-span content="{{ $pacem.highlight(^item.viewValue, :host.hint) }}"></${t.P}-span></li>\n</template>`})],zt);var qt=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};class TagRemoveEvent extends t.CustomTypedEvent{constructor(e){super("tagremove",{index:e})}}class TagAddEvent extends t.CustomTypedEvent{constructor(e){super("tagadd",{value:e})}}let Jt=class PacemTagElement extends t.Components.PacemElement{propertyChangedCallback(e,i,a,r){switch(super.propertyChangedCallback(e,i,a,r),e){case"readonly":let e=!!a;(e?t.Utils.addClass:t.Utils.removeClass)(this,"tag-readonly"),this._btn.disabled=this._btn.hide=e;break;case"tag":t.Utils.removeClass(this,"tag-out")}}_remove(){t.Utils.addClass(this,"tag-out"),t.Utils.addAnimationEndCallback(this,()=>{this.dispatchEvent(new Event("remove"))})}};qt([t.Watch({converter:t.PropertyConverters.String})],Jt.prototype,"tag",void 0),qt([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],Jt.prototype,"readonly",void 0),qt([t.ViewChild(t.P+"-button")],Jt.prototype,"_btn",void 0),Jt=qt([t.CustomElement({tagName:t.P+"-tag",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<${t.P}-text text="{{ :host.tag }}"></${t.P}-text>\n <${t.P}-button on-click=":host._remove()"></${t.P}-button>`})],Jt);let Yt=class PacemTagsElement extends 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(e,i,a,r){switch(super.propertyChangedCallback(e,i,a,r),e){case"datasource":case"textProperty":this._suggest[e]=a;break;case"valueProperty":if(!t.Utils.isNullOrEmpty(a))throw`Cannot set 'valueProperty' on ${this.constructor.name}s.`;break;case"value":this._tags.datasource=a}}onChange(e){return new Promise((i,a)=>{switch(e.type){case"tagremove":this._justAddedIndex=-1;const a=e.detail.index,r=t.Utils.clone(this.value),s=r.splice(a+1),n=r.splice(0,a);i(this.value=n.concat(s));break;case"tagadd":const o=e.detail.value,l=t.Utils.clone(this.value);if(!t.Utils.isNullOrEmpty(o)&&(this.allowDuplicates||t.Utils.isNullOrEmpty(l&&l.find(e=>this.mapEntityToViewValue(e)==this.mapEntityToViewValue(o))))){let e=(l||[]).concat([o]);i(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:i(this.value)}})}acceptValue(e){}};qt([t.Watch({converter:t.PropertyConverters.String})],Yt.prototype,"hint",void 0),qt([t.Watch({emit:!1,converter:t.PropertyConverters.Boolean})],Yt.prototype,"allowDuplicates",void 0),qt([t.Watch({converter:t.PropertyConverters.Boolean})],Yt.prototype,"allowNew",void 0),qt([t.Watch({converter:t.PropertyConverters.Number})],Yt.prototype,"_justAddedIndex",void 0),qt([t.ViewChild(t.P+"-suggest")],Yt.prototype,"_suggest",void 0),qt([t.ViewChild(t.P+"-repeater."+t.PCSS+"-tags")],Yt.prototype,"_tags",void 0),Yt=qt([t.CustomElement({tagName:t.P+"-tags",shadow:t.Defaults.USE_SHADOW_ROOT,template:`<${t.P}-repeater class="${t.PCSS}-tags">\n <ul class="${t.PCSS}-tags ${t.PCSS}-viewfinder ${t.PCSS}-list list-unstyled list-inline">\n <template>\n <li class="${t.PCSS}-tag">\n <${t.P}-tag on-remove=":host._tagRemove(^index)" css-class="{{ { 'tag-in': :host._justAddedIndex === ^index } }}" tag="{{ :host.mapEntityToViewValue(^item) }}" readonly="{{ :host.readonly }}"></${t.P}-tag>\n </li>\n </template>\n <li class="tag-new">\n <${t.P}-suggest logger="{{ :host.logger }}" placeholder="{{ :host.placeholder }}" allow-new="{{ :host.allowNew }}" class="${t.PCSS}-tags" on-change=":host._tagAdd($this.value)" hint="{{ :host.hint, twoway }}">\n <${t.P}-content></${t.P}-content>\n </${t.P}-suggest>\n </li>\n </ul>\n</${t.P}-repeater>`})],Yt);var Gt=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};let Kt=class PacemTextAreaElement extends 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,i,a){super.propertyChangedCallback(e,t,i,a),"rows"!==e&&"cols"!==e||this.inputField.setAttribute(e,i)}};Gt([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],Kt.prototype,"rows",void 0),Gt([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],Kt.prototype,"cols",void 0),Gt([t.ViewChild("textarea")],Kt.prototype,"_input",void 0),Gt([t.ViewChild(`span.${t.PCSS}-readonly`)],Kt.prototype,"_span",void 0),Kt=Gt([t.CustomElement({tagName:t.P+"-textarea",template:`<textarea class="${t.PCSS}-input" pacem></textarea>${E}<span class="${t.PCSS}-readonly"><${t.P}-text text="{{ :host.viewValue }}"></${t.P}-text></span>`,shadow:t.Defaults.USE_SHADOW_ROOT})],Kt);var Xt=function(e,t,i,a){var r,s=arguments.length,n=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,a);else for(var o=e.length-1;o>=0;o--)(r=e[o])&&(n=(s<3?r(n):s>3?r(t,i,n):r(t,i))||n);return s>3&&n&&Object.defineProperty(t,i,n),n};let Zt=class PacemMarkdownTextAreaElement extends PacemTextualInputElement{constructor(e=new i.Components.UI.MarkdownService){super(),this._md=e,this.rows=5,this.cols=50,this._keydownHandler=e=>{if(9===e.keyCode){const a=this.input,r=a.value;var i=a.selectionStart;a.value=r.substr(0,i)+" "+r.substr(i),t.preventDefaultHandler(e)}}}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,i,a){super.propertyChangedCallback(e,t,i,a),"rows"===e||"cols"===e?this.inputField.setAttribute(e,i):"viewValue"==e&&(this._markdown.innerHTML=i)}viewActivatedCallback(){super.viewActivatedCallback(),this.input.addEventListener("keydown",this._keydownHandler,!1)}disconnectedCallback(){this.input&&this.input.removeEventListener("keydown",this._keydownHandler,!1),super.disconnectedCallback()}};Xt([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],Zt.prototype,"rows",void 0),Xt([t.Watch({emit:!1,converter:t.PropertyConverters.Number})],Zt.prototype,"cols",void 0),Xt([t.ViewChild("textarea")],Zt.prototype,"input",void 0),Xt([t.ViewChild(`div.${t.PCSS}-readonly`)],Zt.prototype,"_markdown",void 0),Zt=Xt([t.CustomElement({tagName:t.P+"-textarea-markdown",template:`<textarea class="${t.PCSS}-input" pacem></textarea>${E}<div class="${t.PCSS}-readonly ${t.PCSS}-markdown"></div>`,shadow:t.Defaults.USE_SHADOW_ROOT})],Zt);var Qt=Object.freeze({__proto__:null,BASIC_VALIDATOR_TEMPLATE:fe,CHAR_COUNTER_CHILD:E,CONTENTELEMENT_BUTTONCOMMAND_TEMPLATE:V,CalendarDateUnselectEvent:CalendarDateUnselectEvent,get ChangePolicy(){return qe},ContenteditableDOMObserver:ContenteditableDOMObserver,ContenteditableUtils:ContenteditableUtils,DEFAULT_ATTRIBUTION:"",DEFAULT_TILES:"",FileChangeEvent:FileChangeEvent,FileChangeEventName:at,FileUploadEvent:FileUploadEvent,FileUploadEventName:it,FormEventEmitter:FormEventEmitter,FormResetEvent:FormResetEvent,FormResetEventName:v,FormSubmitEvent:FormSubmitEvent,FormSubmitEventName:m,ImageFetchRequestEvent:ImageFetchRequestEvent,ImageFetchRequestEventName:ut,get KnownExecCommand(){return F},get PacemAsyncValidatorElement(){return ke},PacemBaseElement:PacemBaseElement,PacemBaseInputElement:PacemBaseInputElement,PacemBaseValidatorElement:PacemBaseValidatorElement,get PacemBinaryValidatorElement(){return Se},get PacemCalendarMonthPickerElement(){return ie},get PacemCalendarPickerElement(){return se},get PacemCalendarYearPickerElement(){return re},get PacemCharCountElement(){return w},get PacemCharsInputElement(){return Ke},get PacemCheckboxElement(){return le},get PacemCheckboxListElement(){return de},get PacemChildFormElement(){return ue},get PacemChildFormPropagatorElement(){return pe},get PacemColorInputElement(){return Ze},get PacemCompareValidatorElement(){return we},get PacemContenteditableAlignCommandElement(){return Y},PacemContenteditableButtonCommandElement:PacemContenteditableButtonCommandElement,PacemContenteditableCommandElement:PacemContenteditableCommandElement,get PacemContenteditableElement(){return O},get PacemContenteditableExecCommandElement(){return M},get PacemContenteditableHistoryCommandElement(){return H},get PacemContenteditableImageCommandElement(){return I},get PacemContenteditableLinkCommandElement(){return T},get PacemContenteditablePlaceholderElement(){return X},get PacemContenteditableWrapCommandElement(){return Q},get PacemCustomValidatorElement(){return $e},get PacemDataItemElement(){return C},PacemDataSourceElement:PacemDataSourceElement,get PacemDatetimePickerElement(){return ge},get PacemEditImageElement(){return mt},get PacemEmailInputElement(){return et},get PacemFormElement(){return f},get PacemFormFieldElement(){return Oe},PacemFormRelevantElement:PacemFormRelevantElement,get PacemGeolocateElement(){return Ve},get PacemHiddenInputElement(){return ot},get PacemHierarchyElement(){return ze},get PacemImageInputElement(){return vt},PacemItemElement:PacemItemElement,PacemItemsContainerBaseElement:PacemItemsContainerBaseElement,get PacemLatLngElement(){return Nt},get PacemLengthValidatorElement(){return Pe},get PacemMarkdownTextAreaElement(){return Zt},PacemModelElement:PacemModelElement,get PacemNameValueListElement(){return Dt},get PacemNumberInputElement(){return yt},PacemOrdinalInputElement:PacemOrdinalInputElement,get PacemPasswordInputElement(){return _t},get PacemPropertyPickerElement(){return At},get PacemRadioElement(){return Rt},get PacemRadioListElement(){return It},get PacemRangeValidatorElement(){return Ee},get PacemRegexValidatorElement(){return Ce},get PacemRequiredValidatorElement(){return be},get PacemSearchInputElement(){return Ct},get PacemSelectElement(){return Wt},get PacemSliderElement(){return jt},get PacemSnapshotElement(){return ht},get PacemSuggestElement(){return zt},get PacemTagElement(){return Jt},get PacemTagsElement(){return Yt},get PacemTelInputElement(){return Et},get PacemTextAreaElement(){return Kt},get PacemTextInputElement(){return St},PacemTextualInputElement:PacemTextualInputElement,get PacemUploadElement(){return st},get PacemUrlInputElement(){return $t},Picture:class Picture{},get SnapshotStep(){return dt}}),ei=Object.freeze({__proto__:null,Scaffolding:Qt}),ti=Object.freeze({__proto__:null,Components:ei,Scaffolding:p});e.DeepMerger.merge(ti)}(Pacem,Pacem,Pacem,Pacem);
|
|
7
7
|
//# sourceMappingURL=pacem-scaffolding.min.js.map
|