import{proxyCustomElement as e,HTMLElement as t,createEvent as i,h as s,transformTag as l}from"@stencil/core/internal/client";import{b as o}from"./index.esm.js";import{g as n}from"./limetype.js";import{i as r}from"./non-null.js";import{b as a}from"./_baseIsEqual.js";import{i as d,a as m,b as h}from"./_MapCache.js";function p(e){return"string"==typeof e||!m(e)&&d(e)&&"[object String]"==h(e)}const u=["string","text","phone","integer","decimal","percent","time","date","year","quarter","month","yesno","link","user","xml","option","set","file","system"],c=u.filter((e=>"system"!==e));c.push("belongsto","hasone","hasmany","hasandbelongstomany");const f=e(class extends t{constructor(e){super(),!1!==e&&this.__registerHost(),this.change=i(this,"change",7),this.propertyFields=[],this.fieldName="limetype",this.handleChange=e=>{e.stopPropagation();let t="";e.detail&&"value"in e.detail&&(t=e.detail.value),this.change.emit(t||void 0)}}componentWillLoad(){const e=this.platform.get(o.Application).getLanguage();this.collator=new Intl.Collator(e,{numeric:!0,sensitivity:"base"})}componentShouldUpdate(e,t,i){var s,l,o,n;return"formInfo"!==i||(o=null===(s=null==e?void 0:e.schema)||void 0===s?void 0:s.oneOf,n=null===(l=null==t?void 0:t.schema)||void 0===l?void 0:l.oneOf,!a(o,n))}render(){var e;const t=this.getLimeTypes().map(v);t.sort(((e,t)=>this.collator.compare(e.text,t.text)));let i=t.find((e=>e.value===this.value)),l=this.invalid;return this.value&&!i&&(l=!0,t.unshift({text:(null===(e=this.limeTypeRepository.getLimeType(this.value))||void 0===e?void 0:e.localname.singular)||this.value,value:this.value}),i=t[0]),t.unshift({text:"",value:""}),s("limel-select",{key:"20a7d5eb86c746d11ad805083be5ef9f5fd2397d",label:this.label,options:t,value:i,required:this.required,helperText:this.helperText,invalid:l,disabled:this.disabled||this.readonly,onChange:this.handleChange})}componentWillRender(){this.updatePropertyFields(this.value||"")}getLimeTypes(){var e,t;let i=this.limetypes;return(null===(t=null===(e=this.formInfo)||void 0===e?void 0:e.schema)||void 0===t?void 0:t.oneOf)&&(i=this.formInfo.schema.oneOf.map((e=>e.const)).filter(p)),i?i.map((e=>this.limeTypeRepository.getLimeType(e))).filter(r):this.limeTypeRepository.getLimeTypes()}updatePropertyFields(e){for(const t of this.propertyFields)t.limetype=e,t.allowedPropertyTypes===u&&(t.allowedPropertyTypes=c)}get limeTypeRepository(){return this.platform.get(o.LimeTypeRepository)}},[0,"limebb-limetype-field",{platform:[16],context:[16],label:[513],required:[516],readonly:[516],disabled:[516],value:[513],helperText:[513,"helper-text"],invalid:[4],limetypes:[16],propertyFields:[16],fieldName:[1,"field-name"],formInfo:[16]}]),v=e=>({text:e.localname.singular,value:e.name,icon:n(e)});function y(){"undefined"!=typeof customElements&&["limebb-limetype-field"].forEach((e=>{"limebb-limetype-field"===e&&(customElements.get(l(e))||customElements.define(l(e),f))}))}export{f as L,y as d}