import{p as t,H as s,h as e,a as n}from"./index.js";import{p as o}from"./p-CQvUntGY.js";import{C as i}from"./p-U40vKHrs.js";import{S as r}from"./p-BcQO4NH2.js";import{a,i as c,b as l}from"./p-DrPpH_9c.js";import{g as h}from"./p-DKo9A5gq.js";import{v as u}from"./p-BKP-F1qP.js";o(r,["_XS","_S","_M","_L","_XL","_2XL","_3XL","_4XL","_5XL"]);const f=o(i,["DEFAULT","PRIMARY","SECONDARY","NEUTRAL","ERROR","SUCCESS","WARNING","DISABLED","WHITE","BLACK"]);var m;(function(t){t["BASIC"]="basic";t["COMPLEX"]="complex";t["COLORED"]="colored"})(m||(m={}));const p={root:"gov-icon"};const d="4.6.0";const v=()=>d;const g={};const w={};const y=t=>t.startsWith("http://")||t.startsWith("https://");const C=(t,s,e)=>{if(y(t)){return`${t}/${e}/${s}.svg?v=${v()}`}return`${t}/${e}/${s}.svg`+`?v=${v()}`};async function I({name:t,type:s}){const e=s+"-"+t;if(g[e]){return g[e]}if(!w[e]){w[e]=fetch(C(a(),t,s)).then((t=>{if(t.status===200){return t.text()}else{throw new Error("Gov Icon doesn't exists")}}))}const n=await w[e];g[e]=n;return n}const D=(t,s,e)=>{if(!c){return}let n="";document.cookie=`${t}=${encodeURIComponent(s)}${n}; path=/`};const E=t=>{if(!c){return null}const s=t+"=";const e=document.cookie.split(";");for(let t=0;t<e.length;t++){let n=e[t].trim();if(n.startsWith(s)){return decodeURIComponent(n.substring(s.length))}}return null};const L=t=>{try{const s=new DOMParser;const e=s.parseFromString(t,"image/svg+xml");const n=e.querySelector("parsererror");if(n){return false}const o=e.documentElement;if(o.tagName.toLowerCase()!=="svg"){return false}return true}catch(t){return false}};const S=t(class t extends s{constructor(){super();this.__registerHost();this.name=null;this.type="components";this.visible=false;this.error=false;this.h=h(this.host)}validateSize(t){u(r,t,p.root)}validateColor(t){u(f,t,p.root)}async loadIconPathData(){const{name:t,visible:s}=this;if(!t||!s){return}await this.loadIcon()}connectedCallback(){if(l()){this.visible=true;this.loadIconPathData().finally()}else{this.waitUntilVisible((async()=>{this.visible=true;await this.loadIconPathData()}))}}disconnectedCallback(){if(this.intersectionObserver){this.intersectionObserver.disconnect();this.intersectionObserver=null}}async componentWillLoad(){this.validateSize(this.size);this.validateColor(this.color);await this.loadIconPathData()}waitUntilVisible(t){if(typeof window==="undefined"||!window.IntersectionObserver){t();return}this.intersectionObserver=new IntersectionObserver((s=>{s.forEach((s=>{if(s.isIntersecting){if(this.intersectionObserver){this.intersectionObserver.disconnect();this.intersectionObserver=null}t()}}))}),{rootMargin:"50px"});this.intersectionObserver.observe(this.host)}async loadIcon(){try{const{name:t,type:s}=this;const e=await I({name:t,type:s});const n=L(e);this.host.innerHTML=n?e:null}catch(t){this.host.innerHTML="";this.error=true}}render(){if(this.error){return null}return e(n,{class:this.h.classes(p.root),size:this.size,color:this.color})}static get assetsDirs(){return["assets"]}get host(){return this}static get watchers(){return{size:["validateSize"],color:["validateColor"],name:["loadIconPathData"]}}},[0,"gov-icon",{size:[513],color:[513],name:[513],type:[513],visible:[32],error:[32]},undefined,{size:["validateSize"],color:["validateColor"],name:["loadIconPathData"]}]);function $(){if(typeof customElements==="undefined"){return}const t=["gov-icon"];t.forEach((t=>{switch(t){case"gov-icon":if(!customElements.get(t)){customElements.define(t,S)}break}}))}$();export{S as G,$ as d,E as g,D as s};
//# sourceMappingURL=p-BJnSrRNH.js.map