import{r as t,c as s,h as i}from"./p-c87337b7.js";import"./p-74149bb1.js";import{b as e,c as h}from"./p-d3e7a4f4.js";const r=class{constructor(i){t(this,i),this.allowed=[],this.editing=void 0,this.change=s(this,"change",7)}get allowedArray(){return this.allowedArrayValue||(this.allowedArrayValue=Array.isArray(this.allowed)?this.allowed:this.allowed.split(" ")),this.allowedArrayValue}get address(){return"string"==typeof this.value&&(this.value=JSON.parse(this.value)),this.value}get addresses(){return e.is(this.address)?{primary:this.address}:Object.assign({},this.address)}onChange(t){if(e.is(t.detail)){this.editing=void 0;const s=t.detail.type;let i;delete t.detail.type,"primary"==s&&e.is(this.address)?i=Object.assign({},t.detail):(i=Object.assign({},this.addresses),i[s]=t.detail),this.change.emit(this.value=i)}}onTrigger(t){if("add"==t.detail.name&&"string"!=typeof this.value){const s=this.addresses,i=e.create("SE"),h=t.detail.value;s[h]=i,this.value=s,this.editing=h}}render(){const t=this.allowedArray.filter(t=>h.is(this.address)?null==this.address[t]:"primary"!=t);return[e.is(this.address)?i("smoothly-address",{editable:this.editable,value:this.address,onChange:t=>this.onChange(t)}):h.map(this.address,(t,s)=>i("smoothly-address",{mode:t==this.editing?"edit":"display",editable:this.editable,type:t,value:s,onChange:t=>this.onChange(t)})),t.map(t=>i("smoothly-trigger",{color:"primary",fill:"clear",name:"add",value:t},"+",t))]}static get style(){return".sc-smoothly-addresses-h{display:block}smoothly-trigger.sc-smoothly-addresses{display:inline-block;margin:5px}"}};export{r as smoothly_addresses};