import{proxyCustomElement,HTMLElement,h,Host}from"@stencil/core/internal/client";import{c as classnames}from"./index2.js";import{c as consoleDevError}from"./utils.js";function initIconSpriteLocation(){const e="__VA_ICON_SPRITE_LOCATION__";globalThis.setVaIconSpriteLocation=i=>{globalThis[e]=i},globalThis.getVaIconSpriteLocation=()=>globalThis[e]||"/img/sprite.svg"}const vaIconCss=".usa-icon{display:inline-block;fill:currentColor;height:1em;position:relative;width:1em}.usa-icon--size-3{height:1.5rem;width:1.5rem}.usa-icon--size-4{height:2rem;width:2rem}.usa-icon--size-5{height:2.5rem;width:2.5rem}.usa-icon--size-6{height:3rem;width:3rem}.usa-icon--size-7{height:3.5rem;width:3.5rem}.usa-icon--size-8{height:4rem;width:4rem}.usa-icon--size-9{height:4.5rem;width:4.5rem}:host{display:inline-block;line-height:0;vertical-align:bottom}",VaIconStyle0=vaIconCss,VaIcon=proxyCustomElement(class extends HTMLElement{constructor(){super(),this.__registerHost(),this.__attachShadow(),this.fallbackSpriteLocation="/img/sprite.svg",this.icon=void 0,this.spriteLocation=void 0,this.size=void 0,this.srtext=void 0}getSize(){return this.size&&![3,4,5,6,7,8,9].includes(this.size)?(consoleDevError("Size must be an integer between 3 and 9, inclusive."),null):this.size}validateSpriteLocation(e){let i=this.fallbackSpriteLocation,t=`Invalid SVG sprite path provided to <va-icon>: ${e}`;try{const o=new URL(e,window.location.origin);return o.origin===window.location.origin&&o.pathname.endsWith(".svg")&&!e.includes("..")?i=o.pathname:consoleDevError(t),i}catch(e){return consoleDevError(t),i}}componentWillLoad(){globalThis.getVaIconSpriteLocation||initIconSpriteLocation()}render(){const{icon:e,srtext:i,spriteLocation:t}=this,o=this.getSize(),n=classnames({"usa-icon":!0,[`usa-icon--size-${o}`]:!!o}),s=this.validateSpriteLocation(t||globalThis.getVaIconSpriteLocation())+`#${e}`;return h(Host,{key:"33f66acb5b360570bbda98592bb2b3361ccbb521"},h("svg",{key:"aaeb370a5e77e4d13f5b2e9a15516a39c290e135",class:n,"aria-labelledby":i?"icon-title":null,"aria-hidden":i?null:"true",focusable:"false",role:"img"},i&&h("title",{key:"95ac6004e77a6014c0d618d09d437b6a9fd219f5",id:"icon-title"},i),h("use",{key:"b1b9c0336a2bc813ab2432b35aa0963a6be7fb94",href:s})))}static get assetsDirs(){return["../img"]}static get style(){return VaIconStyle0}},[1,"va-icon",{icon:[1],spriteLocation:[1,"sprite-location"],size:[2],srtext:[1]}]);function defineCustomElement(){"undefined"!=typeof customElements&&["va-icon"].forEach(e=>{"va-icon"===e&&(customElements.get(e)||customElements.define(e,VaIcon))})}export{VaIcon as V,defineCustomElement as d,initIconSpriteLocation as i};