(()=>{"use strict";var e={3102(e,t,r){r.d(t,{A:()=>n});const l=window.JeoLegendTypes||new class{constructor(){this.legendTypes={}}getLegendTypes(){return Object.keys(this.legendTypes)}registerLegendType(e,t){this.legendTypes[e]=t}getLegendType(e){return this.legendTypes[e]}getLegendTypeSchema(e){return this.getLegendType(e).getSchema()}};void 0===window.JeoLegendTypes&&(window.JeoLegendTypes=l);const n=l},7723(e){e.exports=window.wp.i18n}},t={};function r(l){var n=t[l];if(void 0!==n)return n.exports;var o=t[l]={exports:{}};return e[l](o,o.exports,r),o.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var l in t)r.o(t,l)&&!r.o(e,l)&&Object.defineProperty(e,l,{enumerable:!0,get:t[l]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var l=r(7723),n=r(3102);function o(e){return Boolean(e)&&"object"==typeof e&&!Array.isArray(e)}function s(e){const t={...e};return delete t.id,t}class i{constructor(e,t){const r=i.normalizeLegendType(e,t?.legend_type_options);this.__legendType=n.A.getLegendType(r),this.__legendSlug=r,this.attributes=i.normalizeAttributes(r,t)}render(e){return this.__legendType||(this.__legendType=n.A.getLegendType(this.__legendSlug)),this.attributes=i.normalizeAttributes(this.__legendSlug,this.attributes),this.__legendType&&"function"==typeof this.__legendType.render?this.__legendType.render(e,this.attributes):document.createElement("div")}static inferLegendType(e){return o(e)?Array.isArray(e.icons)?"icons":Array.isArray(e.circles)?"circles":Array.isArray(e.colors)?Object.hasOwn(e,"left_label")||Object.hasOwn(e,"right_label")?"barscale":"simple-color":"barscale":"barscale"}static normalizeLegendType(e,t){return"string"==typeof e&&e?e:i.inferLegendType(t)}static typeOptionsShape(e){return{"simple-color":{left_label:"0",right_label:"0",colors:[{label:(0,l.__)("Default label","jeowp"),color:"#ff0909"}]},icons:{icons:[{label:(0,l.__)("Default label","jeowp"),icon:null}]},circles:{color:"#000",circles:[{label:(0,l.__)("Default label","jeowp"),radius:8}]},barscale:{left_label:"0",right_label:"100",colors:[{color:"#ff0909"},{color:"#000"}]}}[e]}static normalizeTypeOptions(e,t){const r=i.normalizeLegendType(e,t),l=i.typeOptionsShape(r),n=o(t)?t:{};if(!o(l))return n;switch(r){case"barscale":{const e=function(e){return Array.isArray(e)?e.map(e=>"string"==typeof e?{color:e}:o(e)&&"string"==typeof e.color&&e.color?{...e}:null).filter(Boolean):[]}(n.colors);return{left_label:n.left_label??l.left_label,right_label:n.right_label??l.right_label,colors:e.length?e:l.colors}}case"simple-color":{const e=function(e){return Array.isArray(e)?e.map(e=>"string"==typeof e?{label:"",color:e}:o(e)&&"string"==typeof e.color&&e.color?{label:e.label||"",color:e.color}:null).filter(Boolean):[]}(n.colors);return{colors:e.length?e:l.colors}}case"icons":{const e=function(e){return Array.isArray(e)?e.map(e=>o(e)&&"string"==typeof e.icon&&e.icon?{label:e.label||"",icon:e.icon}:null).filter(Boolean):[]}(n.icons);return{icons:e.length?e:l.icons}}case"circles":{const e=function(e){return Array.isArray(e)?e.map(e=>o(e)&&void 0!==e.radius&&Number.isFinite(Number(e.radius))?{label:e.label||"",radius:Number(e.radius)}:null).filter(Boolean):[]}(n.circles);return{color:n.color??l.color,circles:e.length?e:l.circles}}default:return{...l,...n}}}static normalizeAttributes(e,t={}){const r=i.normalizeLegendType(e,t?.legend_type_options);return{...t,use_legend:Boolean(t?.use_legend),legend_title:t?.legend_title||"",legend_type_options:i.normalizeTypeOptions(r,t?.legend_type_options)}}get legendSlug(){return this.__legendSlug}get layer_id(){return this.attributes.layer_id}get options(){return this.attributes.legend_type_options}set options(e){this.attributes.legend_type_options=e}set legendType(e){return this.__legendType=n.A.getLegendType(e),this}set setlegengSlug(e){this.__legendSlug=e}static updatedLegendMeta(e){const t=i.normalizeTypeOptions(e.legendSlug,e.attributes.legend_type_options),r={};switch(e.__legendSlug){case"simple-color":r.colors=[...t.colors];break;case"icons":r.icons=[...t.icons];break;case"circles":r.circles=[...t.circles],r.color=t.color;break;case"barscale":r.left_label=t.left_label,r.right_label=t.right_label,r.colors=t.colors.map(s)}return{legend_type:e.legendSlug,legend_type_options:{...r}}}}window.JeoLegend=i})();