import{r as t,h as e,d as i}from"./p-23450e8b.js";import{_ as s}from"./p-9554b2b5.js";import"./p-7183ba4d.js";const n="gl-attribute-values ion-note{font-size:14px;line-height:14px;padding-top:16px;text-align:right}";const r=class{constructor(e){t(this,e);this.options=[];this.attributeOptions=undefined;this.features=undefined;this.header=s("webmapgl.attribute-values.header");this.headerAttribute=undefined;this.labelPosition=undefined;this.limit=1;this.valueMaxWidth="200px"}componentWillLoad(){this.parseAttributeOptions()}parseFormat(t){if(typeof t!=="string")return t;let e;try{e=JSON.parse(t)}catch(i){if(/SyntaxError/.test(i)){if(["currency","decimal","percent"].indexOf(t)!==-1){e={style:t};if(t==="currency")e["currency"]="USD"}}else{throw i}}return e}parseAttributeOptions(){this.options=typeof this.attributeOptions==="string"?JSON.parse(this.attributeOptions):this.attributeOptions}getItemsForFeature(t,i){return i.filter((e=>e.name!==this.headerAttribute&&t.properties[e.name]!=undefined)).map((i=>e("ion-item",null,e("ion-label",{position:this.labelPosition},i.alias||i.name),e("ion-note",{slot:this.labelPosition!="stacked"?"end":null,"text-wrap":true,style:{"max-width":this.valueMaxWidth}},i.format?t.properties[i.name].toLocaleString({},this.parseFormat(i.format)):t.properties[i.name]))))}generateOptions(t){let e=[];for(let i in t.properties){e.push({name:i})}return e}render(){if(this.features==undefined||this.features.length===0)return null;let t=[];for(let i of this.features.slice(0,this.limit)){let s=this.headerAttribute!=undefined?i.properties[this.headerAttribute]:this.header;t.push(e("ion-item-divider",null,e("ion-label",null,s)));let n=this.options||this.generateOptions(i);Array.prototype.push.apply(t,this.getItemsForFeature(i,n))}return e("ion-list",null,t)}get el(){return i(this)}static get watchers(){return{attributeOptions:["parseAttributeOptions"]}}};r.style=n;export{r as gl_attribute_values};
//# sourceMappingURL=p-2e4a405f.entry.js.map