@descope/web-components-ui 3.1.4 → 3.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- "use strict";(self.webpackChunk_descope_web_components_ui=self.webpackChunk_descope_web_components_ui||[]).push([[3521],{80522(e,o,t){t.r(o),t.d(o,{CodeSnippetClass:()=>le,componentName:()=>n});var r=t(75780),l=t(25964),s=t(79365),c=t(9696),a=t(97810),p=t(81365);const n=(0,a.xE)("code-snippet");class i extends((0,p.q)({componentName:n,baseSelector:":host > code"})){static get observedAttributes(){return["lang","inline"]}constructor(){super(),this.attachShadow({mode:"open"}).innerHTML='\n <code class="hljs"></code>\n ',(0,l.fz)("\n :host {\n display: inline-block;\n width: 100%;\n }\n code {\n display: block;\n width: 100%;\n min-height: 1em;\n overflow-x: scroll;\n overflow-y: scroll;\n }\n pre {\n margin: 0;\n }\n ",this)}init(){super.init?.(),this.lang=this.getAttribute("lang"),this.isInline="true"===this.getAttribute("inline"),(0,a.Ge)(this,this.#e.bind(this))}get contentNode(){return this.shadowRoot.querySelector(this.baseSelector)}attributeChangedCallback(e,o,t){super.attributeChangedCallback?.(e,o,t),o!==t&&("inline"===e&&(this.isInline=t),"lang"===e&&(this.lang=t),this.#e())}#e(){const e=(e=>{const o=document.createElement("textarea");return o.innerHTML=e,o.value})(this.textContent),o=this.lang;if(!o)return void(this.contentNode.textContent=e);const{value:t}=r.A.highlight(e,{language:o});var l;this.contentNode.innerHTML=(l=t,this.isInline?l:`<pre>${l}</pre>`)}}const{root:h,docTag:u,keyword:d,metaKeyword:y,templateTag:C,templateVariable:m,type:g,variableLanguage:T,title:x,titleClass:b,titleClassInherited:j,titleFunction:k,attr:w,attribute:v,literal:_,meta:f,number:I,operator:S,variable:A,selectorAttr:q,selectorClass:E,selectorId:L,regexp:N,string:F,metaString:V,builtIn:B,symbol:H,comment:K,code:M,formula:P,name:z,quote:R,selectorTag:G,selectorPseudo:O,subst:Q,section:Z,bullet:$,emphasis:D,strong:J,addition:U,deletion:W,charEscape:X,link:Y,params:ee,property:oe,punctuation:te,tag:re}={root:{selector:()=>".hljs"},docTag:{selector:()=>".hljs-doctag"},keyword:{selector:()=>".hljs-keyword"},metaKeyword:{selector:()=>".hljs-meta .hljs-keyword"},templateTag:{selector:()=>".hljs-template-tag"},templateVariable:{selector:()=>".hljs-template-variable"},type:{selector:()=>".hljs-type"},variableLanguage:{selector:()=>".hljs-variable.language"},title:{selector:()=>".hljs-title"},titleClass:{selector:()=>".hljs-title.class_"},titleClassInherited:{selector:()=>".hljs-title.class_.inherited__"},titleFunction:{selector:()=>".hljs-title.function_"},attr:{selector:()=>".hljs-attr"},attribute:{selector:()=>".hljs-attribute"},literal:{selector:()=>".hljs-literal"},meta:{selector:()=>".hljs-meta"},number:{selector:()=>".hljs-number"},operator:{selector:()=>".hljs-operator"},variable:{selector:()=>".hljs-variable"},selectorAttr:{selector:()=>".hljs-selector-attr"},selectorClass:{selector:()=>".hljs-selector-class"},selectorId:{selector:()=>".hljs-selector-id"},regexp:{selector:()=>".hljs-regexp"},string:{selector:()=>".hljs-string"},metaString:{selector:()=>".hljs-meta .hljs-string"},builtIn:{selector:()=>".hljs-built_in"},symbol:{selector:()=>".hljs-symbol"},comment:{selector:()=>".hljs-comment"},code:{selector:()=>".hljs-code"},formula:{selector:()=>".hljs-formula"},name:{selector:()=>".hljs-name"},quote:{selector:()=>".hljs-quote"},selectorTag:{selector:()=>".hljs-selector-tag"},selectorPseudo:{selector:()=>".hljs-selector-pseudo"},subst:{selector:()=>".hljs-subst"},section:{selector:()=>".hljs-section"},bullet:{selector:()=>".hljs-bullet"},emphasis:{selector:()=>".hljs-emphasis"},strong:{selector:()=>".hljs-strong"},addition:{selector:()=>".hljs-addition"},deletion:{selector:()=>".hljs-deletion"},charEscape:{selector:()=>".hljs-char.escape"},link:{selector:()=>".hljs-link"},params:{selector:()=>".hljs-params"},property:{selector:()=>".hljs-property"},punctuation:{selector:()=>".hljs-punctuation"},tag:{selector:()=>".hljs-tag"}},le=(0,c.Zz)((0,s.RF)({mappings:{rootBgColor:{...h,property:"background-color"},rootTextColor:{...h,property:"color"},docTagTextColor:{...u,property:"color"},keywordTextColor:{...d,property:"color"},metaKeywordTextColor:{...y,property:"color"},templateTagTextColor:{...C,property:"color"},templateVariableTextColor:{...m,property:"color"},typeTextColor:{...g,property:"color"},variableLanguageTextColor:{...T,property:"color"},titleTextColor:{...x,property:"color"},titleClassTextColor:{...b,property:"color"},titleClassInheritedTextColor:{...j,property:"color"},titleFunctionTextColor:{...k,property:"color"},attrTextColor:{...w,property:"color"},attributeTextColor:{...v,property:"color"},literalTextColor:{..._,property:"color"},metaTextColor:{...f,property:"color"},numberTextColor:{...I,property:"color"},operatorTextColor:{...S,property:"color"},variableTextColor:{...A,property:"color"},selectorAttrTextColor:{...q,property:"color"},selectorClassTextColor:{...E,property:"color"},selectorIdTextColor:{...L,property:"color"},regexpTextColor:{...N,property:"color"},stringTextColor:{...F,property:"color"},metaStringTextColor:{...V,property:"color"},builtInTextColor:{...B,property:"color"},symbolTextColor:{...H,property:"color"},commentTextColor:{...K,property:"color"},codeTextColor:{...M,property:"color"},formulaTextColor:{...P,property:"color"},nameTextColor:{...z,property:"color"},quoteTextColor:{...R,property:"color"},selectorTagTextColor:{...G,property:"color"},selectorPseudoTextColor:{...O,property:"color"},substTextColor:{...Q,property:"color"},sectionTextColor:{...Z,property:"color"},bulletTextColor:{...$,property:"color"},emphasisTextColor:{...D,property:"color"},strongTextColor:{...J,property:"color"},additionTextColor:{...U,property:"color"},additionBgColor:{...U,property:"background-color"},deletionTextColor:{...W,property:"color"},deletionBgColor:{...W,property:"background-color"},charEscapeTextColor:{...X,property:"color"},linkTextColor:{...Y,property:"color"},paramsTextColor:{...ee,property:"color"},propertyTextColor:{...oe,property:"color"},punctuationTextColor:{...te,property:"color"},tagTextColor:{...re,property:"color"}}}),s.VO,s.tQ)(i);customElements.define(n,le)}}]);
1
+ (self.webpackChunk_descope_web_components_ui=self.webpackChunk_descope_web_components_ui||[]).push([[1202,3521,6724],{25828(t){t.exports="data:image/svg+xml;base64,PHN2ZyBjbGFzcz0iY2hlY2staWNvbiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgc3Ryb2tlPSJjdXJyZW50Q29sb3IiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIj4gPHBvbHlsaW5lIHBvaW50cz0iMjAgNiA5IDE3IDQgMTIiPjwvcG9seWxpbmU+IDwvc3ZnPiA="},71957(t){t.exports="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiPiA8cmVjdCB4PSI5IiB5PSI5IiB3aWR0aD0iMTMiIGhlaWdodD0iMTMiIHJ4PSIyIiByeT0iMiI+PC9yZWN0PiA8cGF0aCBkPSJNNSAxNUg0YTIgMiAwIDAgMS0yLTJWNGEyIDIgMCAwIDEgMi0yaDlhMiAyIDAgMCAxIDIgMnYxIj48L3BhdGg+IDwvc3ZnPiA="},98538(t,e,o){"use strict";o.d(e,{S:()=>c,T:()=>i});var r=o(88961),l=o(25964),s=o(8512),n=o(63200);const i=(0,l.xE)("icon"),c=(0,n.Zz)((0,r.RF)({mappings:{fill:[{},{property:s.q.cssVarList.fill}]}}),r.VO,r.tQ)((0,r.tz)({slots:[],wrappedEleName:"descope-image",style:()=>"\n :host {\n display: inline-flex;\n max-height: 100%;\n }\n ",excludeAttrsSync:["tabindex","class","style"],componentName:i}))},56737(t,e,o){"use strict";o.r(e),o.d(e,{IconClass:()=>r.S,componentName:()=>r.T}),o(53455);var r=o(98538);customElements.define(r.T,r.S)},8512(t,e,o){"use strict";o.d(e,{T:()=>c,q:()=>d});var r=o(88961),l=o(72270),s=o(63200),n=o(25964),i=o(18782);const c=(0,n.xE)("image"),a=["src","src-dark"];class p extends((0,l.qu)({componentName:c,baseSelector:"slot"})){static get observedAttributes(){return a}constructor(){super(),this.attachShadow({mode:"open"}).innerHTML="\n\t\t<slot></slot>\n\t",(0,n.fz)("\n\t\t\t:host {\n\t\t\t\tdisplay: inline-flex;\n\t\t\t}\n :host > slot {\n width: 100%;\n height: 100%;\n\t\t\t\tbox-sizing: border-box;\n\t\t\t\tdisplay: flex;\n\t\t\t\toverflow: hidden;\n\t\t\t}\n\n ::slotted(*) {\n width: 100%;\n\t\t\t}\n\n .hidden {\n display: none;\n }\n ",this)}init(){super.init?.(),this.toggleVisibility(this.getSrc)}onThemeChange(){this.renderImage()}toggleVisibility(t){t?this.classList.remove("hidden"):this.classList.add("hidden")}get altText(){return this.getAttribute("alt")||""}get legacySrc(){return this.getAttribute("src")}get themeSrc(){return this.getAttribute(`src-${this.currentThemeName}`)}get getSrc(){return this.themeSrc||this.legacySrc}updateFillColor(t){[t,...t.querySelectorAll("*[fill]")].forEach(t=>{t.setAttribute("fill",`var(${d.cssVarList.fill}, ${t.getAttribute("fill")||"''"})`)})}renderImage(){this.toggleVisibility(this.getSrc),(0,i.m)(this.getSrc,this.altText).then(t=>{this.innerHTML="",t&&(this.updateFillColor(t),this.appendChild(t))})}shouldRender(t){const e=this.getAttribute(t);return this.getSrc===e}attributeChangedCallback(t,e,o){super.attributeChangedCallback?.(t,e,o),e!==o&&this.shouldRender(t)&&this.renderImage()}}const d=(0,s.Zz)((0,r.RF)({mappings:{fill:{},height:{selector:()=>":host"},width:{selector:()=>":host"}}}),r.VO,r.tQ)(p)},18782(t,e,o){"use strict";o.d(e,{m:()=>s});var r=o(25414);const l=t=>{const e=r.A.sanitize(t,{USE_PROFILES:{svg:!0,svgFilters:!0},ADD_TAGS:["image"],FORBID_TAGS:["defs"]});return(new DOMParser).parseFromString(e,"image/svg+xml").querySelector("svg")},s=async(t,e)=>{try{let o;if((t=>t.startsWith("data:image/svg+xml;base64,"))(t)){const e=atob(t.slice(26));o=l(e)}else if("svg"===(t=>{const e=t.match(/\.([0-9a-z]+)(?:[\\?#]|$)/i);return e?e[1]:null})(t)){const e=await fetch(t),r=await e.text();o=l(r)}else o=((t,e)=>{const o=document.createElement("img");return o.setAttribute("src",t),o.setAttribute("alt",e),o})(t,e);return o.style.setProperty("max-width","100%"),o.style.setProperty("max-height","100%"),o}catch{return null}}},53455(t,e,o){"use strict";o.r(e),o.d(e,{ImageClass:()=>r.q,componentName:()=>r.T});var r=o(8512);customElements.define(r.T,r.q)},80522(t,e,o){"use strict";o.r(e),o.d(e,{CodeSnippetClass:()=>pt,componentName:()=>y}),o(56737);var r=o(75780),l=o(25964),s=o(79365),n=o(9696),i=o(97810),c=o(81365);const a=t=>{const e=document.createElement("textarea");return e.innerHTML=t,e.value};var p=o(71957),d=o.n(p),h=o(25828),u=o.n(h);const y=(0,i.xE)("code-snippet");class g extends((0,c.q)({componentName:y,baseSelector:":host > .wrapper"})){static get observedAttributes(){return["lang","inline","copy-button"]}constructor(){super(),this.attachShadow({mode:"open"}).innerHTML='\n <div class="wrapper">\n <code class="hljs"></code>\n </div>\n ',(0,l.fz)("\n :host {\n display: inline-block;\n width: 100%;\n }\n .wrapper {\n position: relative;\n width: 100%;\n }\n code {\n display: block;\n width: 100%;\n min-height: 1em;\n overflow-x: scroll;\n overflow-y: scroll;\n }\n pre {\n margin: 0;\n }\n .copy-btn {\n position: absolute;\n top: 8px;\n right: 8px;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 0;\n border-style: solid;\n cursor: pointer;\n opacity: 0;\n transition: opacity 150ms ease, background 150ms ease;\n }\n .wrapper:hover .copy-btn,\n .copy-btn:focus-visible {\n opacity: 1;\n }\n .copy-btn descope-icon {\n width: 16px;\n height: 16px;\n pointer-events: none;\n flex-shrink: 0;\n }\n .copy-btn .check-icon {\n display: none;\n }\n .copy-btn.copied .check-icon {\n display: block;\n }\n .copy-btn.copied descope-icon:not(.check-icon) {\n display: none;\n }\n ",this)}init(){super.init?.(),this.lang=this.getAttribute("lang"),this.isInline="true"===this.getAttribute("inline"),"true"===this.getAttribute("copy-button")&&this.#t(),(0,i.Ge)(this,this.#e.bind(this))}get contentNode(){return this.shadowRoot.querySelector("code")}attributeChangedCallback(t,e,o){super.attributeChangedCallback?.(t,e,o),e!==o&&("inline"===t&&(this.isInline=o),"lang"===t&&(this.lang=o),"copy-button"===t&&("true"===o?this.#t():this.#o()),this.#e())}#t(){if(this.shadowRoot.querySelector(".copy-btn"))return;const t=document.createElement("button");t.className="copy-btn",t.type="button",t.setAttribute("aria-label","Copy code");const e=document.createElement("descope-icon");e.setAttribute("src",d());const o=document.createElement("descope-icon");o.setAttribute("src",u()),o.classList.add("check-icon"),t.appendChild(e),t.appendChild(o),t.addEventListener("click",()=>this.#r()),this.shadowRoot.querySelector(".wrapper").appendChild(t)}#o(){this.shadowRoot.querySelector(".copy-btn")?.remove()}#r(){const t=this.shadowRoot.querySelector(".copy-btn");navigator.clipboard.writeText(a(this.textContent)).then(()=>{t.classList.add("copied"),setTimeout(()=>t.classList.remove("copied"),2e3)}).catch(()=>{})}#e(){const t=a(this.textContent),e=this.lang;if(!e)return void(this.contentNode.textContent=t);const{value:o}=r.A.highlight(t,{language:e});var l;this.contentNode.innerHTML=(l=o,this.isInline?l:`<pre>${l}</pre>`)}}const m={selector:()=>".copy-btn"},{root:b,docTag:C,keyword:x,metaKeyword:T,templateTag:I,templateVariable:v,type:j,variableLanguage:S,title:w,titleClass:A,titleClassInherited:k,titleFunction:f,attr:B,attribute:M,literal:N,meta:D,number:P,operator:L,variable:H,selectorAttr:R,selectorClass:W,selectorId:E,regexp:Z,string:z,metaString:q,builtIn:_,symbol:F,comment:G,code:J,formula:V,name:Q,quote:Y,selectorTag:O,selectorPseudo:U,subst:$,section:X,bullet:K,emphasis:tt,strong:et,addition:ot,deletion:rt,charEscape:lt,link:st,params:nt,property:it,punctuation:ct,tag:at}={root:{selector:()=>".hljs"},docTag:{selector:()=>".hljs-doctag"},keyword:{selector:()=>".hljs-keyword"},metaKeyword:{selector:()=>".hljs-meta .hljs-keyword"},templateTag:{selector:()=>".hljs-template-tag"},templateVariable:{selector:()=>".hljs-template-variable"},type:{selector:()=>".hljs-type"},variableLanguage:{selector:()=>".hljs-variable.language"},title:{selector:()=>".hljs-title"},titleClass:{selector:()=>".hljs-title.class_"},titleClassInherited:{selector:()=>".hljs-title.class_.inherited__"},titleFunction:{selector:()=>".hljs-title.function_"},attr:{selector:()=>".hljs-attr"},attribute:{selector:()=>".hljs-attribute"},literal:{selector:()=>".hljs-literal"},meta:{selector:()=>".hljs-meta"},number:{selector:()=>".hljs-number"},operator:{selector:()=>".hljs-operator"},variable:{selector:()=>".hljs-variable"},selectorAttr:{selector:()=>".hljs-selector-attr"},selectorClass:{selector:()=>".hljs-selector-class"},selectorId:{selector:()=>".hljs-selector-id"},regexp:{selector:()=>".hljs-regexp"},string:{selector:()=>".hljs-string"},metaString:{selector:()=>".hljs-meta .hljs-string"},builtIn:{selector:()=>".hljs-built_in"},symbol:{selector:()=>".hljs-symbol"},comment:{selector:()=>".hljs-comment"},code:{selector:()=>".hljs-code"},formula:{selector:()=>".hljs-formula"},name:{selector:()=>".hljs-name"},quote:{selector:()=>".hljs-quote"},selectorTag:{selector:()=>".hljs-selector-tag"},selectorPseudo:{selector:()=>".hljs-selector-pseudo"},subst:{selector:()=>".hljs-subst"},section:{selector:()=>".hljs-section"},bullet:{selector:()=>".hljs-bullet"},emphasis:{selector:()=>".hljs-emphasis"},strong:{selector:()=>".hljs-strong"},addition:{selector:()=>".hljs-addition"},deletion:{selector:()=>".hljs-deletion"},charEscape:{selector:()=>".hljs-char.escape"},link:{selector:()=>".hljs-link"},params:{selector:()=>".hljs-params"},property:{selector:()=>".hljs-property"},punctuation:{selector:()=>".hljs-punctuation"},tag:{selector:()=>".hljs-tag"}},pt=(0,n.Zz)((0,s.RF)({mappings:{rootBgColor:{...b,property:"background-color"},rootTextColor:{...b,property:"color"},docTagTextColor:{...C,property:"color"},keywordTextColor:{...x,property:"color"},metaKeywordTextColor:{...T,property:"color"},templateTagTextColor:{...I,property:"color"},templateVariableTextColor:{...v,property:"color"},typeTextColor:{...j,property:"color"},variableLanguageTextColor:{...S,property:"color"},titleTextColor:{...w,property:"color"},titleClassTextColor:{...A,property:"color"},titleClassInheritedTextColor:{...k,property:"color"},titleFunctionTextColor:{...f,property:"color"},attrTextColor:{...B,property:"color"},attributeTextColor:{...M,property:"color"},literalTextColor:{...N,property:"color"},metaTextColor:{...D,property:"color"},numberTextColor:{...P,property:"color"},operatorTextColor:{...L,property:"color"},variableTextColor:{...H,property:"color"},selectorAttrTextColor:{...R,property:"color"},selectorClassTextColor:{...W,property:"color"},selectorIdTextColor:{...E,property:"color"},regexpTextColor:{...Z,property:"color"},stringTextColor:{...z,property:"color"},metaStringTextColor:{...q,property:"color"},builtInTextColor:{..._,property:"color"},symbolTextColor:{...F,property:"color"},commentTextColor:{...G,property:"color"},codeTextColor:{...J,property:"color"},formulaTextColor:{...V,property:"color"},nameTextColor:{...Q,property:"color"},quoteTextColor:{...Y,property:"color"},selectorTagTextColor:{...O,property:"color"},selectorPseudoTextColor:{...U,property:"color"},substTextColor:{...$,property:"color"},sectionTextColor:{...X,property:"color"},bulletTextColor:{...K,property:"color"},emphasisTextColor:{...tt,property:"color"},strongTextColor:{...et,property:"color"},additionTextColor:{...ot,property:"color"},additionBgColor:{...ot,property:"background-color"},deletionTextColor:{...rt,property:"color"},deletionBgColor:{...rt,property:"background-color"},charEscapeTextColor:{...lt,property:"color"},linkTextColor:{...st,property:"color"},paramsTextColor:{...nt,property:"color"},propertyTextColor:{...it,property:"color"},punctuationTextColor:{...ct,property:"color"},tagTextColor:{...at,property:"color"},copyButtonSize:[{...m,property:"width"},{...m,property:"height"}],copyButtonBorderRadius:{...m,property:"border-radius"},copyButtonBorderWidth:{...m,property:"border-width"},copyButtonBorderColor:{...m,property:"border-color"},copyButtonBgColor:{...m,property:"background-color"},copyButtonHoverBgColor:{selector:()=>".copy-btn:hover",property:"background-color"},copyButtonColor:{...m,property:"color"}}}),s.VO,s.tQ)(g);customElements.define(y,pt)}}]);
2
2
  //# sourceMappingURL=descope-code-snippet-index-js.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"descope-code-snippet-index-js.js","mappings":"uQAAO,MCQMA,GAAgB,QAAiB,gBAE9C,MAAMC,WAAoB,EAAAC,EAAA,GAAgB,CAAEF,gBAAeG,aAAc,kBACvE,6BAAWC,GACT,MAAO,CAAC,OAAQ,SAClB,CAEA,WAAAC,GACEC,QAEAC,KAAKC,aAAa,CAAEC,KAAM,SAAUC,UAAY,0CAIhD,QACE,6RAgBAH,KAEJ,CAEA,IAAAI,GACEL,MAAMK,SAENJ,KAAKK,KAAOL,KAAKM,aAAa,QAC9BN,KAAKO,SAA2C,SAAhCP,KAAKM,aAAa,WAElC,QAAgBN,KAAMA,MAAK,EAAeQ,KAAKR,MACjD,CAEA,eAAIS,GACF,OAAOT,KAAKU,WAAWC,cAAcX,KAAKJ,aAC5C,CAEA,wBAAAgB,CAAyBC,EAAUC,EAAUC,GAC3ChB,MAAMa,2BAA2BC,EAAUC,EAAUC,GAEjDD,IAAaC,IACE,WAAbF,IACFb,KAAKO,SAAWQ,GAGD,SAAbF,IACFb,KAAKK,KAAOU,GAGdf,MAAK,IAET,CAEA,KACE,MAAMgB,EDzEY,CAACC,IACrB,MAAMC,EAAMC,SAASC,cAAc,YAEnC,OADAF,EAAIf,UAAYc,EACTC,EAAIG,OCsESC,CAAOtB,KAAKuB,aACxBC,EAAWxB,KAAK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KnD,EAAMgB,SAAU,SACpCoC,iBAAkB,IAAKnD,EAASe,SAAU,SAC1CqC,cAAe,IAAK,EAAMrC,SAAU,SACpCsC,eAAgB,IAAKnD,EAAOa,SAAU,SACtCuC,qBAAsB,IAAKnD,EAAaY,SAAU,SAClDwC,wBAAyB,IAAKnD,EAAgBW,SAAU,SACxDyC,eAAgB,IAAKnD,EAAOU,SAAU,SACtC0C,iBAAkB,IAAKnD,EAASS,SAAU,SAC1C2C,gBAAiB,IAAKnD,EAAQQ,SAAU,SACxC4C,kBAAmB,IAAKnD,EAAUO,SAAU,SAC5C6C,gBAAiB,IAAKnD,EAAQM,SAAU,SACxC8C,kBAAmB,IAAKnD,EAAUK,SAAU,SAC5C+C,gBAAiB,IAAKpD,EAAUK,SAAU,oBAC1CgD,kBAAmB,IAAKpD,EAAUI,SAAU,SAC5CiD,gBAAiB,IAAKrD,EAAUI,SAAU,oBAC1CkD,oBAAqB,IAAKrD,EAAYG,SAAU,SAChDmD,cAAe,IAAK,EAAMnD,SAAU,SACpCoD,gBAAiB,IAAKrD,GAAQC,SAAU,SACxCqD,kBAAmB,IAAKrD,GAAUA,SAAU,SAC5CsD,qBAAsB,IAAKrD,GAAaD,SAAU,SAClDuD,aAAc,IAAKrD,GAAKF,SAAU,YAGtC,KACA,KAxD8B,CAyD9B7E,GChPFqI,eAAeC,OAAOvI,EAAekF,G","sources":["webpack://@descope/web-components-ui/./src/components/descope-code-snippet/helpers.js","webpack://@descope/web-components-ui/./src/components/descope-code-snippet/CodeSnippetClass.js","webpack://@descope/web-components-ui/./src/components/descope-code-snippet/index.js"],"sourcesContent":["export const decode = (input) => {\n const txt = document.createElement('textarea');\n txt.innerHTML = input;\n return txt.value;\n};\n\nexport const tpl = (input, inline) => (inline ? input : `<pre>${input}</pre>`);\n","import hljs from 'highlight.js';\nimport { injectStyle } from '@descope-ui/common/components-helpers';\nimport { createStyleMixin, draggableMixin, componentNameValidationMixin } from '../../mixins';\nimport { compose } from '../../helpers';\nimport { getComponentName, observeChildren } from '../../helpers/componentHelpers';\nimport { createBaseClass } from '../../baseClasses/createBaseClass';\nimport { decode, tpl } from './helpers';\n\nexport const componentName = getComponentName('code-snippet');\n\nclass CodeSnippet extends createBaseClass({ componentName, baseSelector: ':host > code' }) {\n static get observedAttributes() {\n return ['lang', 'inline'];\n }\n\n constructor() {\n super();\n\n this.attachShadow({ mode: 'open' }).innerHTML = `\n <code class=\"hljs\"></code>\n `;\n\n injectStyle(\n `\n :host {\n display: inline-block;\n width: 100%;\n }\n code {\n display: block;\n width: 100%;\n min-height: 1em;\n overflow-x: scroll;\n overflow-y: scroll;\n }\n pre {\n margin: 0;\n }\n `,\n this\n );\n }\n\n init() {\n super.init?.();\n\n this.lang = this.getAttribute('lang');\n this.isInline = this.getAttribute('inline') === 'true';\n\n observeChildren(this, this.#renderSnippet.bind(this));\n }\n\n get contentNode() {\n return this.shadowRoot.querySelector(this.baseSelector);\n }\n\n attributeChangedCallback(attrName, oldValue, newValue) {\n super.attributeChangedCallback?.(attrName, oldValue, newValue);\n\n if (oldValue !== newValue) {\n if (attrName === 'inline') {\n this.isInline = newValue;\n }\n\n if (attrName === 'lang') {\n this.lang = newValue;\n }\n\n this.#renderSnippet();\n }\n }\n\n #renderSnippet() {\n const sanitized = decode(this.textContent);\n const language = this.lang;\n\n if (!language) {\n this.contentNode.textContent = sanitized;\n return;\n }\n\n const { value: highlighted } = hljs.highlight(sanitized, { language });\n\n this.contentNode.innerHTML = tpl(highlighted, this.isInline);\n }\n}\n\nconst {\n root,\n docTag,\n keyword,\n metaKeyword,\n templateTag,\n templateVariable,\n type,\n variableLanguage,\n title,\n titleClass,\n titleClassInherited,\n titleFunction,\n attr,\n attribute,\n literal,\n meta,\n number,\n operator,\n variable,\n selectorAttr,\n selectorClass,\n selectorId,\n regexp,\n string,\n metaString,\n builtIn,\n symbol,\n comment,\n code,\n formula,\n name,\n quote,\n selectorTag,\n selectorPseudo,\n subst,\n section,\n bullet,\n emphasis,\n strong,\n addition,\n deletion,\n charEscape,\n link,\n params,\n property,\n punctuation,\n tag,\n} = {\n root: { selector: () => '.hljs' },\n docTag: { selector: () => '.hljs-doctag' },\n keyword: { selector: () => '.hljs-keyword' },\n metaKeyword: { selector: () => '.hljs-meta .hljs-keyword' },\n templateTag: { selector: () => '.hljs-template-tag' },\n templateVariable: { selector: () => '.hljs-template-variable' },\n type: { selector: () => '.hljs-type' },\n variableLanguage: { selector: () => '.hljs-variable.language' },\n title: { selector: () => '.hljs-title' },\n titleClass: { selector: () => '.hljs-title.class_' },\n titleClassInherited: { selector: () => '.hljs-title.class_.inherited__' },\n titleFunction: { selector: () => '.hljs-title.function_' },\n attr: { selector: () => '.hljs-attr' },\n attribute: { selector: () => '.hljs-attribute' },\n literal: { selector: () => '.hljs-literal' },\n meta: { selector: () => '.hljs-meta' },\n number: { selector: () => '.hljs-number' },\n operator: { selector: () => '.hljs-operator' },\n variable: { selector: () => '.hljs-variable' },\n selectorAttr: { selector: () => '.hljs-selector-attr' },\n selectorClass: { selector: () => '.hljs-selector-class' },\n selectorId: { selector: () => '.hljs-selector-id' },\n regexp: { selector: () => '.hljs-regexp' },\n string: { selector: () => '.hljs-string' },\n metaString: { selector: () => '.hljs-meta .hljs-string' },\n builtIn: { selector: () => '.hljs-built_in' },\n symbol: { selector: () => '.hljs-symbol' },\n comment: { selector: () => '.hljs-comment' },\n code: { selector: () => '.hljs-code' },\n formula: { selector: () => '.hljs-formula' },\n name: { selector: () => '.hljs-name' },\n quote: { selector: () => '.hljs-quote' },\n selectorTag: { selector: () => '.hljs-selector-tag' },\n selectorPseudo: { selector: () => '.hljs-selector-pseudo' },\n subst: { selector: () => '.hljs-subst' },\n section: { selector: () => '.hljs-section' },\n bullet: { selector: () => '.hljs-bullet' },\n emphasis: { selector: () => '.hljs-emphasis' },\n strong: { selector: () => '.hljs-strong' },\n addition: { selector: () => '.hljs-addition' },\n deletion: { selector: () => '.hljs-deletion' },\n charEscape: { selector: () => '.hljs-char.escape' },\n link: { selector: () => '.hljs-link' },\n params: { selector: () => '.hljs-params' },\n property: { selector: () => '.hljs-property' },\n punctuation: { selector: () => '.hljs-punctuation' },\n tag: { selector: () => '.hljs-tag' },\n};\n\nexport const CodeSnippetClass = compose(\n createStyleMixin({\n mappings: {\n rootBgColor: { ...root, property: 'background-color' },\n rootTextColor: { ...root, property: 'color' },\n docTagTextColor: { ...docTag, property: 'color' },\n keywordTextColor: { ...keyword, property: 'color' },\n metaKeywordTextColor: { ...metaKeyword, property: 'color' },\n templateTagTextColor: { ...templateTag, property: 'color' },\n templateVariableTextColor: { ...templateVariable, property: 'color' },\n typeTextColor: { ...type, property: 'color' },\n variableLanguageTextColor: { ...variableLanguage, property: 'color' },\n titleTextColor: { ...title, property: 'color' },\n titleClassTextColor: { ...titleClass, property: 'color' },\n titleClassInheritedTextColor: { ...titleClassInherited, property: 'color' },\n titleFunctionTextColor: { ...titleFunction, property: 'color' },\n attrTextColor: { ...attr, property: 'color' },\n attributeTextColor: { ...attribute, property: 'color' },\n literalTextColor: { ...literal, property: 'color' },\n metaTextColor: { ...meta, property: 'color' },\n numberTextColor: { ...number, property: 'color' },\n operatorTextColor: { ...operator, property: 'color' },\n variableTextColor: { ...variable, property: 'color' },\n selectorAttrTextColor: { ...selectorAttr, property: 'color' },\n selectorClassTextColor: { ...selectorClass, property: 'color' },\n selectorIdTextColor: { ...selectorId, property: 'color' },\n regexpTextColor: { ...regexp, property: 'color' },\n stringTextColor: { ...string, property: 'color' },\n metaStringTextColor: { ...metaString, property: 'color' },\n builtInTextColor: { ...builtIn, property: 'color' },\n symbolTextColor: { ...symbol, property: 'color' },\n commentTextColor: { ...comment, property: 'color' },\n codeTextColor: { ...code, property: 'color' },\n formulaTextColor: { ...formula, property: 'color' },\n nameTextColor: { ...name, property: 'color' },\n quoteTextColor: { ...quote, property: 'color' },\n selectorTagTextColor: { ...selectorTag, property: 'color' },\n selectorPseudoTextColor: { ...selectorPseudo, property: 'color' },\n substTextColor: { ...subst, property: 'color' },\n sectionTextColor: { ...section, property: 'color' },\n bulletTextColor: { ...bullet, property: 'color' },\n emphasisTextColor: { ...emphasis, property: 'color' },\n strongTextColor: { ...strong, property: 'color' },\n additionTextColor: { ...addition, property: 'color' },\n additionBgColor: { ...addition, property: 'background-color' },\n deletionTextColor: { ...deletion, property: 'color' },\n deletionBgColor: { ...deletion, property: 'background-color' },\n charEscapeTextColor: { ...charEscape, property: 'color' },\n linkTextColor: { ...link, property: 'color' },\n paramsTextColor: { ...params, property: 'color' },\n propertyTextColor: { ...property, property: 'color' },\n punctuationTextColor: { ...punctuation, property: 'color' },\n tagTextColor: { ...tag, property: 'color' },\n },\n }),\n draggableMixin,\n componentNameValidationMixin\n)(CodeSnippet);\n","import { componentName, CodeSnippetClass } from './CodeSnippetClass';\n\ncustomElements.define(componentName, CodeSnippetClass);\n\nexport { CodeSnippetClass, componentName };\n"],"names":["componentName","CodeSnippet","createBaseClass","baseSelector","observedAttributes","constructor","super","this","attachShadow","mode","innerHTML","init","lang","getAttribute","isInline","bind","contentNode","shadowRoot","querySelector","attributeChangedCallback","attrName","oldValue","newValue","sanitized","input","txt","document","createElement","value","decode","textContent","language","highlighted","highlight","root","docTag","keyword","metaKeyword","templateTag","templateVariable","type","variableLanguage","title","titleClass","titleClassInherited","titleFunction","attr","attribute","literal","meta","number","operator","variable","selectorAttr","selectorClass","selectorId","regexp","string","metaString","builtIn","symbol","comment","code","formula","name","quote","selectorTag","selectorPseudo","subst","section","bullet","emphasis","strong","addition","deletion","charEscape","link","params","property","punctuation","tag","selector","CodeSnippetClass","mappings","rootBgColor","rootTextColor","docTagTextColor","keywordTextColor","metaKeywordTextColor","templateTagTextColor","templateVariableTextColor","typeTextColor","variableLanguageTextColor","titleTextColor","titleClassTextColor","titleClassInheritedTextColor","titleFunctionTextColor","attrTextColor","attributeTextColor","literalTextColor","metaTextColor","numberTextColor","operatorTextColor","variableTextColor","selectorAttrTextColor","selectorClassTextColor","selectorIdTextColor","regexpTextColor","stringTextColor","metaStringTextColor","builtInTextColor","symbolTextColor","commentTextColor","codeTextColor","formulaTextColor","nameTextColor","quoteTextColor","selectorTagTextColor","selectorPseudoTextColor","substTextColor","sectionTextColor","bulletTextColor","emphasisTextColor","strongTextColor","additionTextColor","additionBgColor","deletionTextColor","deletionBgColor","charEscapeTextColor","linkTextColor","paramsTextColor","propertyTextColor","punctuationTextColor","tagTextColor","customElements","define"],"sourceRoot":""}
1
+ {"version":3,"file":"descope-code-snippet-index-js.js","mappings":"+HAAAA,EAAOC,QAAU,gX,WCAjBD,EAAOC,QAAU,gd,oGCUV,MAAMC,GAAgB,QAAiB,QAEjCC,GAAY,SACvB,QAAiB,CACfC,SAAU,CACRC,KAAM,CAAC,CAAC,EAAG,CAAEC,SAAU,IAAWC,WAAWF,UAGjD,KACA,KAPuB,EASvB,QAAY,CACVG,MAAO,GACPC,eAAgB,gBAChBC,MAAO,IAAM,6FAMbC,iBAAkB,CAAC,WAAY,QAAS,SACxCT,kB,4GC3BJU,eAAeC,OAAO,IAAe,I,+GCQ9B,MAAMX,GAAgB,QAAiB,SAExCY,EAAW,CAAC,MAAO,YAEzB,MAAMC,WAAiB,QAAgB,CACrCb,gBACAc,aAAc,UAEd,6BAAWC,GACT,OAAOH,CACT,CAEA,WAAAI,GACEC,QAEAC,KAAKC,aAAa,CAAEC,KAAM,SAAUC,UAAY,2BAIhD,QACE,6UAoBAH,KAEJ,CAEA,IAAAI,GACEL,MAAMK,SACNJ,KAAKK,iBAAiBL,KAAKM,OAC7B,CAEA,aAAAC,GACEP,KAAKQ,aACP,CAEA,gBAAAH,CAAiBI,GACXA,EACFT,KAAKU,UAAUC,OAAO,UAEtBX,KAAKU,UAAUE,IAAI,SAEvB,CAEA,WAAIC,GACF,OAAOb,KAAKc,aAAa,QAAU,EACrC,CAEA,aAAIC,GACF,OAAOf,KAAKc,aAAa,MAC3B,CAEA,YAAIE,GACF,OAAOhB,KAAKc,aAAa,OAAOd,KAAKiB,mBACvC,CAEA,UAAIX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M,gBAAiB,IAAKhD,EAAQhJ,SAAU,SACxCiM,kBAAmB,IAAKhD,GAAUjJ,SAAU,SAC5CkM,gBAAiB,IAAKhD,GAAQlJ,SAAU,SACxCmM,kBAAmB,IAAKhD,GAAUnJ,SAAU,SAC5CoM,gBAAiB,IAAKjD,GAAUnJ,SAAU,oBAC1CqM,kBAAmB,IAAKjD,GAAUpJ,SAAU,SAC5CsM,gBAAiB,IAAKlD,GAAUpJ,SAAU,oBAC1CuM,oBAAqB,IAAKlD,GAAYrJ,SAAU,SAChDwM,cAAe,IAAK,GAAMxM,SAAU,SACpCyM,gBAAiB,IAAKlD,GAAQvJ,SAAU,SACxC0M,kBAAmB,IAAK1M,GAAUA,SAAU,SAC5C2M,qBAAsB,IAAKnD,GAAaxJ,SAAU,SAClD4M,aAAc,IAAKnD,GAAKzJ,SAAU,SAClC6M,eAAgB,CACd,IAAKjG,EAAS5G,SAAU,SACxB,IAAK4G,EAAS5G,SAAU,WAE1B8M,uBAAwB,IAAKlG,EAAS5G,SAAU,iBAChD+M,sBAAuB,IAAKnG,EAAS5G,SAAU,gBAC/CgN,sBAAuB,IAAKpG,EAAS5G,SAAU,gBAC/CiN,kBAAmB,IAAKrG,EAAS5G,SAAU,oBAC3CkN,uBAAwB,CAAEhK,SAAU,IAAM,kBAAmBlD,SAAU,oBACvEmN,gBAAiB,IAAKvG,EAAS5G,SAAU,YAG7C,KACA,KAlE8B,CAmE9BqF,GCvVF/E,eAAeC,OAAOX,EAAe8J,G","sources":["webpack://@descope/web-components-ui/./src/components/descope-code-snippet/check-icon.svg","webpack://@descope/web-components-ui/./src/components/descope-code-snippet/copy-icon.svg","webpack://@descope/web-components-ui/../components/descope-icon/src/component/IconClass.js","webpack://@descope/web-components-ui/../components/descope-icon/src/component/index.js","webpack://@descope/web-components-ui/../components/descope-image/src/component/ImageClass.js","webpack://@descope/web-components-ui/../components/descope-image/src/component/helpers.js","webpack://@descope/web-components-ui/../components/descope-image/src/component/index.js","webpack://@descope/web-components-ui/./src/components/descope-code-snippet/helpers.js","webpack://@descope/web-components-ui/./src/components/descope-code-snippet/CodeSnippetClass.js","webpack://@descope/web-components-ui/./src/components/descope-code-snippet/index.js"],"sourcesContent":["module.exports = \"data:image/svg+xml;base64,PHN2ZyBjbGFzcz0iY2hlY2staWNvbiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgc3Ryb2tlPSJjdXJyZW50Q29sb3IiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIj4gPHBvbHlsaW5lIHBvaW50cz0iMjAgNiA5IDE3IDQgMTIiPjwvcG9seWxpbmU+IDwvc3ZnPiA=\"","module.exports = \"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiPiA8cmVjdCB4PSI5IiB5PSI5IiB3aWR0aD0iMTMiIGhlaWdodD0iMTMiIHJ4PSIyIiByeT0iMiI+PC9yZWN0PiA8cGF0aCBkPSJNNSAxNUg0YTIgMiAwIDAgMS0yLTJWNGEyIDIgMCAwIDEgMi0yaDlhMiAyIDAgMCAxIDIgMnYxIj48L3BhdGg+IDwvc3ZnPiA=\"","import {\n componentNameValidationMixin,\n createProxy,\n createStyleMixin,\n draggableMixin,\n} from '@descope-ui/common/components-mixins';\nimport { getComponentName } from '@descope-ui/common/components-helpers';\nimport { ImageClass } from '@descope-ui/descope-image/class';\nimport { compose } from '@descope-ui/common/utils';\n\nexport const componentName = getComponentName('icon');\n\nexport const IconClass = compose(\n createStyleMixin({\n mappings: {\n fill: [{}, { property: ImageClass.cssVarList.fill }],\n },\n }),\n draggableMixin,\n componentNameValidationMixin,\n)(\n createProxy({\n slots: [],\n wrappedEleName: 'descope-image',\n style: () => `\n :host {\n display: inline-flex;\n max-height: 100%;\n }\n `,\n excludeAttrsSync: ['tabindex', 'class', 'style'],\n componentName,\n }),\n);\n","import '@descope-ui/descope-image';\n\nimport { componentName, IconClass } from './IconClass';\n\ncustomElements.define(componentName, IconClass);\n\nexport { IconClass, componentName };\n","/* eslint-disable no-use-before-define */\nimport {\n createStyleMixin,\n draggableMixin,\n componentNameValidationMixin,\n} from '@descope-ui/common/components-mixins';\nimport { createBaseClass } from '@descope-ui/common/base-classes';\nimport { compose } from '@descope-ui/common/utils';\nimport { getComponentName } from '@descope-ui/common/components-helpers';\nimport { createImage } from './helpers';\nimport { injectStyle } from '@descope-ui/common/components-helpers';\n\nexport const componentName = getComponentName('image');\n\nconst srcAttrs = ['src', 'src-dark'];\n\nclass RawImage extends createBaseClass({\n componentName,\n baseSelector: 'slot',\n}) {\n static get observedAttributes() {\n return srcAttrs;\n }\n\n constructor() {\n super();\n\n this.attachShadow({ mode: 'open' }).innerHTML = `\n\t\t<slot></slot>\n\t`;\n\n injectStyle(\n `\n\t\t\t:host {\n\t\t\t\tdisplay: inline-flex;\n\t\t\t}\n :host > slot {\n width: 100%;\n height: 100%;\n\t\t\t\tbox-sizing: border-box;\n\t\t\t\tdisplay: flex;\n\t\t\t\toverflow: hidden;\n\t\t\t}\n\n ::slotted(*) {\n width: 100%;\n\t\t\t}\n\n .hidden {\n display: none;\n }\n `,\n this,\n );\n }\n\n init() {\n super.init?.();\n this.toggleVisibility(this.getSrc);\n }\n\n onThemeChange() {\n this.renderImage();\n }\n\n toggleVisibility(isVisible) {\n if (isVisible) {\n this.classList.remove('hidden');\n } else {\n this.classList.add('hidden');\n }\n }\n\n get altText() {\n return this.getAttribute('alt') || '';\n }\n\n get legacySrc() {\n return this.getAttribute('src');\n }\n\n get themeSrc() {\n return this.getAttribute(`src-${this.currentThemeName}`);\n }\n\n get getSrc() {\n return this.themeSrc || this.legacySrc;\n }\n\n // in order to fill an SVG with `currentColor` override all of its `fill` and `path` nodes\n // with the value from the `st-fill` attribute\n // eslint-disable-next-line class-methods-use-this\n updateFillColor(node) {\n // set fill to root node and all its relevant selectors\n const elementsToReplace = [node, ...node.querySelectorAll('*[fill]')];\n\n elementsToReplace.forEach((ele) => {\n ele.setAttribute(\n 'fill',\n `var(${ImageClass.cssVarList.fill}, ${ele.getAttribute('fill') || \"''\"})`,\n );\n });\n }\n\n renderImage() {\n this.toggleVisibility(this.getSrc);\n\n createImage(this.getSrc, this.altText).then((res) => {\n this.innerHTML = '';\n if (res) {\n this.updateFillColor(res);\n this.appendChild(res);\n }\n });\n }\n\n // render only when src attribute matches current theme\n shouldRender(src) {\n const srcVal = this.getAttribute(src);\n return this.getSrc === srcVal;\n }\n\n attributeChangedCallback(attrName, oldValue, newValue) {\n super.attributeChangedCallback?.(attrName, oldValue, newValue);\n\n if (oldValue === newValue) return;\n\n if (this.shouldRender(attrName)) {\n this.renderImage();\n }\n }\n}\n\nexport const ImageClass = compose(\n createStyleMixin({\n mappings: {\n fill: {},\n height: { selector: () => ':host' },\n width: { selector: () => ':host' },\n },\n }),\n draggableMixin,\n componentNameValidationMixin,\n)(RawImage);\n","import DOMPurify from 'dompurify';\n\nconst getFileExtension = (path) => {\n const match = path.match(/\\.([0-9a-z]+)(?:[\\\\?#]|$)/i);\n return match ? match[1] : null;\n};\n\nconst base64Prefix = 'data:image/svg+xml;base64,';\n\nconst isBase64Svg = (src) => src.startsWith(base64Prefix);\n\nconst createImgEle = (src, altText) => {\n const ele = document.createElement('img');\n ele.setAttribute('src', src);\n ele.setAttribute('alt', altText);\n return ele;\n};\n\nconst createSvgEle = (text) => {\n // we want to purify the SVG to avoid XSS attacks\n const clean = DOMPurify.sanitize(text, {\n USE_PROFILES: { svg: true, svgFilters: true },\n // allow image to render\n ADD_TAGS: ['image'],\n // forbid interactiviy via `use` tags (which are sanitized by default)\n FORBID_TAGS: ['defs']\n });\n\n const parser = new DOMParser();\n const ele = parser\n .parseFromString(clean, 'image/svg+xml')\n .querySelector('svg');\n return ele;\n};\n\nexport const createImage = async (src, altText) => {\n try {\n let ele;\n if (isBase64Svg(src)) {\n // handle base64 source\n const svgXml = atob(src.slice(base64Prefix.length));\n ele = createSvgEle(svgXml);\n } else if (getFileExtension(src) === 'svg') {\n // handle urls\n const fetchedSrc = await fetch(src);\n const text = await fetchedSrc.text();\n ele = createSvgEle(text);\n } else {\n // handle binary\n ele = createImgEle(src, altText);\n }\n\n ele.style.setProperty('max-width', '100%');\n ele.style.setProperty('max-height', '100%');\n\n return ele;\n } catch {\n return null;\n }\n};\n","import { componentName, ImageClass } from './ImageClass';\n\ncustomElements.define(componentName, ImageClass);\n\nexport { ImageClass, componentName };\n","export const decode = (input) => {\n const txt = document.createElement('textarea');\n txt.innerHTML = input;\n return txt.value;\n};\n\nexport const tpl = (input, inline) => (inline ? input : `<pre>${input}</pre>`);\n","import hljs from 'highlight.js';\nimport { injectStyle } from '@descope-ui/common/components-helpers';\nimport { createStyleMixin, draggableMixin, componentNameValidationMixin } from '../../mixins';\nimport { compose } from '../../helpers';\nimport { getComponentName, observeChildren } from '../../helpers/componentHelpers';\nimport { createBaseClass } from '../../baseClasses/createBaseClass';\nimport { decode, tpl } from './helpers';\nimport copyIconSrc from './copy-icon.svg';\nimport checkIconSrc from './check-icon.svg';\n\nexport const componentName = getComponentName('code-snippet');\n\nclass CodeSnippet extends createBaseClass({ componentName, baseSelector: ':host > .wrapper' }) {\n static get observedAttributes() {\n return ['lang', 'inline', 'copy-button'];\n }\n\n constructor() {\n super();\n\n this.attachShadow({ mode: 'open' }).innerHTML = `\n <div class=\"wrapper\">\n <code class=\"hljs\"></code>\n </div>\n `;\n\n injectStyle(\n `\n :host {\n display: inline-block;\n width: 100%;\n }\n .wrapper {\n position: relative;\n width: 100%;\n }\n code {\n display: block;\n width: 100%;\n min-height: 1em;\n overflow-x: scroll;\n overflow-y: scroll;\n }\n pre {\n margin: 0;\n }\n .copy-btn {\n position: absolute;\n top: 8px;\n right: 8px;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 0;\n border-style: solid;\n cursor: pointer;\n opacity: 0;\n transition: opacity 150ms ease, background 150ms ease;\n }\n .wrapper:hover .copy-btn,\n .copy-btn:focus-visible {\n opacity: 1;\n }\n .copy-btn descope-icon {\n width: 16px;\n height: 16px;\n pointer-events: none;\n flex-shrink: 0;\n }\n .copy-btn .check-icon {\n display: none;\n }\n .copy-btn.copied .check-icon {\n display: block;\n }\n .copy-btn.copied descope-icon:not(.check-icon) {\n display: none;\n }\n `,\n this\n );\n }\n\n init() {\n super.init?.();\n\n this.lang = this.getAttribute('lang');\n this.isInline = this.getAttribute('inline') === 'true';\n\n if (this.getAttribute('copy-button') === 'true') {\n this.#initCopyButton();\n }\n\n observeChildren(this, this.#renderSnippet.bind(this));\n }\n\n get contentNode() {\n return this.shadowRoot.querySelector('code');\n }\n\n attributeChangedCallback(attrName, oldValue, newValue) {\n super.attributeChangedCallback?.(attrName, oldValue, newValue);\n\n if (oldValue !== newValue) {\n if (attrName === 'inline') {\n this.isInline = newValue;\n }\n\n if (attrName === 'lang') {\n this.lang = newValue;\n }\n\n if (attrName === 'copy-button') {\n if (newValue === 'true') {\n this.#initCopyButton();\n } else {\n this.#destroyCopyButton();\n }\n }\n\n this.#renderSnippet();\n }\n }\n\n // ── Copy button ────────────────────────────────────────────────────────────\n\n #initCopyButton() {\n if (this.shadowRoot.querySelector('.copy-btn')) return;\n\n const btn = document.createElement('button');\n btn.className = 'copy-btn';\n btn.type = 'button';\n btn.setAttribute('aria-label', 'Copy code');\n const copyIcon = document.createElement('descope-icon');\n copyIcon.setAttribute('src', copyIconSrc);\n\n const checkIcon = document.createElement('descope-icon');\n checkIcon.setAttribute('src', checkIconSrc);\n checkIcon.classList.add('check-icon');\n\n btn.appendChild(copyIcon);\n btn.appendChild(checkIcon);\n btn.addEventListener('click', () => this.#handleCopyClick());\n\n this.shadowRoot.querySelector('.wrapper').appendChild(btn);\n }\n\n #destroyCopyButton() {\n this.shadowRoot.querySelector('.copy-btn')?.remove();\n }\n\n #handleCopyClick() {\n const btn = this.shadowRoot.querySelector('.copy-btn');\n navigator.clipboard\n .writeText(decode(this.textContent))\n .then(() => {\n btn.classList.add('copied');\n setTimeout(() => btn.classList.remove('copied'), 2000);\n })\n .catch(() => {});\n }\n\n // ── Snippet rendering ──────────────────────────────────────────────────────\n\n #renderSnippet() {\n const sanitized = decode(this.textContent);\n const language = this.lang;\n\n if (!language) {\n this.contentNode.textContent = sanitized;\n return;\n }\n\n const { value: highlighted } = hljs.highlight(sanitized, { language });\n\n this.contentNode.innerHTML = tpl(highlighted, this.isInline);\n }\n}\n\nconst copyBtn = { selector: () => '.copy-btn' };\n\nconst {\n root,\n docTag,\n keyword,\n metaKeyword,\n templateTag,\n templateVariable,\n type,\n variableLanguage,\n title,\n titleClass,\n titleClassInherited,\n titleFunction,\n attr,\n attribute,\n literal,\n meta,\n number,\n operator,\n variable,\n selectorAttr,\n selectorClass,\n selectorId,\n regexp,\n string,\n metaString,\n builtIn,\n symbol,\n comment,\n code,\n formula,\n name,\n quote,\n selectorTag,\n selectorPseudo,\n subst,\n section,\n bullet,\n emphasis,\n strong,\n addition,\n deletion,\n charEscape,\n link,\n params,\n property,\n punctuation,\n tag,\n} = {\n root: { selector: () => '.hljs' },\n docTag: { selector: () => '.hljs-doctag' },\n keyword: { selector: () => '.hljs-keyword' },\n metaKeyword: { selector: () => '.hljs-meta .hljs-keyword' },\n templateTag: { selector: () => '.hljs-template-tag' },\n templateVariable: { selector: () => '.hljs-template-variable' },\n type: { selector: () => '.hljs-type' },\n variableLanguage: { selector: () => '.hljs-variable.language' },\n title: { selector: () => '.hljs-title' },\n titleClass: { selector: () => '.hljs-title.class_' },\n titleClassInherited: { selector: () => '.hljs-title.class_.inherited__' },\n titleFunction: { selector: () => '.hljs-title.function_' },\n attr: { selector: () => '.hljs-attr' },\n attribute: { selector: () => '.hljs-attribute' },\n literal: { selector: () => '.hljs-literal' },\n meta: { selector: () => '.hljs-meta' },\n number: { selector: () => '.hljs-number' },\n operator: { selector: () => '.hljs-operator' },\n variable: { selector: () => '.hljs-variable' },\n selectorAttr: { selector: () => '.hljs-selector-attr' },\n selectorClass: { selector: () => '.hljs-selector-class' },\n selectorId: { selector: () => '.hljs-selector-id' },\n regexp: { selector: () => '.hljs-regexp' },\n string: { selector: () => '.hljs-string' },\n metaString: { selector: () => '.hljs-meta .hljs-string' },\n builtIn: { selector: () => '.hljs-built_in' },\n symbol: { selector: () => '.hljs-symbol' },\n comment: { selector: () => '.hljs-comment' },\n code: { selector: () => '.hljs-code' },\n formula: { selector: () => '.hljs-formula' },\n name: { selector: () => '.hljs-name' },\n quote: { selector: () => '.hljs-quote' },\n selectorTag: { selector: () => '.hljs-selector-tag' },\n selectorPseudo: { selector: () => '.hljs-selector-pseudo' },\n subst: { selector: () => '.hljs-subst' },\n section: { selector: () => '.hljs-section' },\n bullet: { selector: () => '.hljs-bullet' },\n emphasis: { selector: () => '.hljs-emphasis' },\n strong: { selector: () => '.hljs-strong' },\n addition: { selector: () => '.hljs-addition' },\n deletion: { selector: () => '.hljs-deletion' },\n charEscape: { selector: () => '.hljs-char.escape' },\n link: { selector: () => '.hljs-link' },\n params: { selector: () => '.hljs-params' },\n property: { selector: () => '.hljs-property' },\n punctuation: { selector: () => '.hljs-punctuation' },\n tag: { selector: () => '.hljs-tag' },\n};\n\nexport const CodeSnippetClass = compose(\n createStyleMixin({\n mappings: {\n rootBgColor: { ...root, property: 'background-color' },\n rootTextColor: { ...root, property: 'color' },\n docTagTextColor: { ...docTag, property: 'color' },\n keywordTextColor: { ...keyword, property: 'color' },\n metaKeywordTextColor: { ...metaKeyword, property: 'color' },\n templateTagTextColor: { ...templateTag, property: 'color' },\n templateVariableTextColor: { ...templateVariable, property: 'color' },\n typeTextColor: { ...type, property: 'color' },\n variableLanguageTextColor: { ...variableLanguage, property: 'color' },\n titleTextColor: { ...title, property: 'color' },\n titleClassTextColor: { ...titleClass, property: 'color' },\n titleClassInheritedTextColor: { ...titleClassInherited, property: 'color' },\n titleFunctionTextColor: { ...titleFunction, property: 'color' },\n attrTextColor: { ...attr, property: 'color' },\n attributeTextColor: { ...attribute, property: 'color' },\n literalTextColor: { ...literal, property: 'color' },\n metaTextColor: { ...meta, property: 'color' },\n numberTextColor: { ...number, property: 'color' },\n operatorTextColor: { ...operator, property: 'color' },\n variableTextColor: { ...variable, property: 'color' },\n selectorAttrTextColor: { ...selectorAttr, property: 'color' },\n selectorClassTextColor: { ...selectorClass, property: 'color' },\n selectorIdTextColor: { ...selectorId, property: 'color' },\n regexpTextColor: { ...regexp, property: 'color' },\n stringTextColor: { ...string, property: 'color' },\n metaStringTextColor: { ...metaString, property: 'color' },\n builtInTextColor: { ...builtIn, property: 'color' },\n symbolTextColor: { ...symbol, property: 'color' },\n commentTextColor: { ...comment, property: 'color' },\n codeTextColor: { ...code, property: 'color' },\n formulaTextColor: { ...formula, property: 'color' },\n nameTextColor: { ...name, property: 'color' },\n quoteTextColor: { ...quote, property: 'color' },\n selectorTagTextColor: { ...selectorTag, property: 'color' },\n selectorPseudoTextColor: { ...selectorPseudo, property: 'color' },\n substTextColor: { ...subst, property: 'color' },\n sectionTextColor: { ...section, property: 'color' },\n bulletTextColor: { ...bullet, property: 'color' },\n emphasisTextColor: { ...emphasis, property: 'color' },\n strongTextColor: { ...strong, property: 'color' },\n additionTextColor: { ...addition, property: 'color' },\n additionBgColor: { ...addition, property: 'background-color' },\n deletionTextColor: { ...deletion, property: 'color' },\n deletionBgColor: { ...deletion, property: 'background-color' },\n charEscapeTextColor: { ...charEscape, property: 'color' },\n linkTextColor: { ...link, property: 'color' },\n paramsTextColor: { ...params, property: 'color' },\n propertyTextColor: { ...property, property: 'color' },\n punctuationTextColor: { ...punctuation, property: 'color' },\n tagTextColor: { ...tag, property: 'color' },\n copyButtonSize: [\n { ...copyBtn, property: 'width' },\n { ...copyBtn, property: 'height' },\n ],\n copyButtonBorderRadius: { ...copyBtn, property: 'border-radius' },\n copyButtonBorderWidth: { ...copyBtn, property: 'border-width' },\n copyButtonBorderColor: { ...copyBtn, property: 'border-color' },\n copyButtonBgColor: { ...copyBtn, property: 'background-color' },\n copyButtonHoverBgColor: { selector: () => '.copy-btn:hover', property: 'background-color' },\n copyButtonColor: { ...copyBtn, property: 'color' },\n },\n }),\n draggableMixin,\n componentNameValidationMixin\n)(CodeSnippet);\n","import '@descope-ui/descope-icon';\nimport { componentName, CodeSnippetClass } from './CodeSnippetClass';\n\ncustomElements.define(componentName, CodeSnippetClass);\n\nexport { CodeSnippetClass, componentName };\n"],"names":["module","exports","componentName","IconClass","mappings","fill","property","cssVarList","slots","wrappedEleName","style","excludeAttrsSync","customElements","define","srcAttrs","RawImage","baseSelector","observedAttributes","constructor","super","this","attachShadow","mode","innerHTML","init","toggleVisibility","getSrc","onThemeChange","renderImage","isVisible","classList","remove","add","altText","getAttribute","legacySrc","themeSrc","currentThemeName","updateFillColor","node","querySelectorAll","forEach","ele","setAttribute","ImageClass","then","res","appendChild","shouldRender","src","srcVal","attributeChangedCallback","attrName","oldValue","newValue","height","selector","width","createSvgEle","text","clean","sanitize","USE_PROFILES","svg","svgFilters","ADD_TAGS","FORBID_TAGS","DOMParser","parseFromString","querySelector","createImage","async","startsWith","isBase64Svg","svgXml","atob","slice","base64Prefix","path","match","getFileExtension","fetchedSrc","fetch","document","createElement","createImgEle","setProperty","decode","input","txt","value","CodeSnippet","createBaseClass","lang","isInline","bind","contentNode","shadowRoot","btn","className","type","copyIcon","checkIcon","addEventListener","navigator","clipboard","writeText","textContent","setTimeout","catch","sanitized","language","highlighted","highlight","copyBtn","root","docTag","keyword","metaKeyword","templateTag","templateVariable","variableLanguage","title","titleClass","titleClassInherited","titleFunction","attr","attribute","literal","meta","number","operator","variable","selectorAttr","selectorClass","selectorId","regexp","string","metaString","builtIn","symbol","comment","code","formula","name","quote","selectorTag","selectorPseudo","subst","section","bullet","emphasis","strong","addition","deletion","charEscape","link","params","punctuation","tag","CodeSnippetClass","rootBgColor","rootTextColor","docTagTextColor","keywordTextColor","metaKeywordTextColor","templateTagTextColor","templateVariableTextColor","typeTextColor","variableLanguageTextColor","titleTextColor","titleClassTextColor","titleClassInheritedTextColor","titleFunctionTextColor","attrTextColor","attributeTextColor","literalTextColor","metaTextColor","numberTextColor","operatorTextColor","variableTextColor","selectorAttrTextColor","selectorClassTextColor","selectorIdTextColor","regexpTextColor","stringTextColor","metaStringTextColor","builtInTextColor","symbolTextColor","commentTextColor","codeTextColor","formulaTextColor","nameTextColor","quoteTextColor","selectorTagTextColor","selectorPseudoTextColor","substTextColor","sectionTextColor","bulletTextColor","emphasisTextColor","strongTextColor","additionTextColor","additionBgColor","deletionTextColor","deletionBgColor","charEscapeTextColor","linkTextColor","paramsTextColor","propertyTextColor","punctuationTextColor","tagTextColor","copyButtonSize","copyButtonBorderRadius","copyButtonBorderWidth","copyButtonBorderColor","copyButtonBgColor","copyButtonHoverBgColor","copyButtonColor"],"sourceRoot":""}
@@ -1,2 +1,2 @@
1
- "use strict";(self.webpackChunk_descope_web_components_ui=self.webpackChunk_descope_web_components_ui||[]).push([[2478],{68749(i,t,e){e.r(t),e.d(t,{CountrySubdivisionCityFieldClass:()=>L,componentName:()=>$}),e(25003),e(27092);var s=e(72270),o=e(25964),n=e(63200);const r=async i=>{const t=await fetch(i);if(!t.ok)throw new Error(`[dataService] ${t.status} ${i}`);const e=await t.json();return e.data??e},a=async i=>r(`${i}/countries.json`),l=async(i,t)=>{try{return(await r(`${t}/countries/${i}/subdivisions.json`)).map(({code:i,...t})=>({...t,state_code:i}))}catch{return[]}},u=async(i,t,e)=>r(`${e}/countries/${i}/subdivisions/${t}/cities.json`),d=async i=>{const t=new URL("../labels.json",`${i}/`).href;return r(t)},h=async(i,t)=>r(`${t}/countries/${i}/cities.json`),c=(0,o.xE)("country-subdivision-city-field-internal"),b=Symbol("selecting"),y=({name:i,translations:t={}},e)=>e&&(t[e]||t[e.split("-")[0]])||i,p=i=>i?String(i).replace(/[&<>"']/g,i=>`&#${i.charCodeAt(0)};`):"",m=({name:i,iso2:t,iso3:e,translations:s,lang:o})=>{const n=y({name:i,translations:s},o),r=[n,t,e];n!==i&&r.push(i);const a=p(t),l=p(r.join(" ")),u=p(n);return`<div data-id="${a}" data-name="${l}" data-label="${u}">${u}</div>`},v=({name:i,state_code:t,translations:e,lang:s})=>{const o=y({name:i,translations:e},s),n=[o,t];o!==i&&n.push(i);const r=p(t),a=p(n.join(" ")),l=p(o);return`<div data-id="${r}" data-name="${a}" data-label="${l}">${l}</div>`},C=({name:i})=>{const t=p(i),e=p(i);return`<div data-id="${t}" data-name="${e}">${e}</div>`},g=i=>`<descope-combo-box id="${i}" item-label-path="data-name" item-value-path="data-id" allow-custom-value="false"></descope-combo-box>`,x=(0,s.yc)({componentName:c,baseSelector:""}),f=["disabled","readonly","size","bordered"],B=["hide-country","hide-subdivision","hide-city"],S=[...f,"label-type","country-label","subdivision-label","city-label",...B,"default-country","allowed-countries","pinned-countries","country-placeholder","subdivision-placeholder","city-placeholder","required","invalid","data-source-base-url","lang"],V=(0,n.Zz)()(class extends x{static get observedAttributes(){return[].concat(x.observedAttributes||[],S)}#i;#t;#e;#s=!1;#o=!1;#n=new Map;#r=null;#a=null;#l=null;#u=null;constructor(){super(),this.innerHTML=`\n <div class="wrapper">\n ${g("country-combo")}\n ${g("subdivision-combo")}\n ${g("city-combo")}\n </div>\n `,this.#i=this.querySelector("#country-combo"),this.#t=this.querySelector("#subdivision-combo"),this.#e=this.querySelector("#city-combo"),this.#d(),this.#h()}get#c(){return"true"===this.getAttribute("hide-country")}get#b(){return"true"===this.getAttribute("hide-subdivision")}get#y(){return"true"===this.getAttribute("hide-city")}get#p(){return!this.#m}get#m(){return this.getAttribute("data-source-base-url")||void 0}get#v(){const i=this.getAttribute("lang")||void 0;if(i)try{return Intl.getCanonicalLocales(i),i}catch{return}}get#C(){return this.getAttribute("default-country")?.toUpperCase()||void 0}get#g(){return this.getAttribute("subdivision-label")||void 0}get#x(){return this.getAttribute("subdivision-placeholder")||void 0}get#f(){return(this.getAttribute("allowed-countries")||"").split(",").map(i=>i.trim().toUpperCase()).filter(Boolean)}get#B(){return(this.getAttribute("pinned-countries")||"").split(",").map(i=>i.trim().toUpperCase()).filter(Boolean)}get#S(){return[this.#i,this.#t,this.#e]}get value(){return{country:this.#c?this.#C:this.#i.value||void 0,subdivision:!this.#b&&this.#s&&this.#t.value||void 0,city:!this.#y&&this.#o&&this.#e.value||void 0}}set value(i){if(!i)return;let t;try{t="string"==typeof i?JSON.parse(i):i}catch{return}this.#u={...t},this.#m&&this.#V()}init(){this.addEventListener("focus",i=>{if(i.isTrusted){const i=this.#S.find(i=>!i.classList.contains(`${c}-hidden`)&&!i.checkValidity());(i||this.#A())?.focus()}}),super.init?.(),this.#w(),this.#$(),this.#E(),this.#H()}#H(){this.#i.renderItem=m,this.#t.renderItem=v,this.#e.renderItem=C}attributeChangedCallback(i,t,e){if(super.attributeChangedCallback?.(i,t,e),t!==e)if("required"===i)this.#I();else if(B.includes(i)||"data-source-base-url"===i)this.#w(),"data-source-base-url"===i&&this.#E();else if("default-country"===i){const i=e?.toUpperCase();if(i&&i!==e)return void this.setAttribute("default-country",i);i&&this.#n.size?this.#L(i):i&&this.#c&&this.#T()}else"lang"===i?this.#U():"invalid"===i?"true"===e&&this.#R():"allowed-countries"===i||"pinned-countries"===i?this.#c||(this.#r?this.#F(this.#r):this.#T()):"country-label"===i?this.#O(this.#i,"label",e):"subdivision-label"===i?this.#O(this.#t,"label",e):"city-label"===i&&this.#O(this.#e,"label",e)}getValidity(){if(!this.isRequired)return{};const i=!this.#c&&!this.#i.value,t=!this.#b&&(this.#p||this.#s)&&!this.#t.value,e=!this.#y&&(this.#p||this.#o)&&!this.#e.value;return i||t||e?{valueMissing:!0}:{}}#R(){for(const i of[...this.#S].reverse())i.classList.contains(`${c}-hidden`)||i.checkValidity()||i.reportValidity()}#d(){[this.#i,this.#t].forEach(i=>{i.customValueTransformFn=t=>{const e=i.baseElement?.items?.find(i=>i["data-name"]===t);return e?.getAttribute("data-label")??t}})}#h(){this.#S.forEach(i=>{(0,o.EA)(this,i,{includeAttrs:[...f,"label-type"]})}),(0,o.EA)(this,this.#i,{includeAttrs:["default-country"],mapAttrs:{"default-country":"default-value"}}),[[this.#i,"country-placeholder"],[this.#t,"subdivision-placeholder"],[this.#e,"city-placeholder"]].forEach(([i,t])=>{(0,o.EA)(this,i,{includeAttrs:[t],mapAttrs:{[t]:"placeholder"}})})}#$(){this.#i.addEventListener("input",()=>this.#q()),this.#t.addEventListener("input",()=>this.#D()),this.#e.addEventListener("input",()=>this.#N()),this.handleFocusEventsDispatching(this.#S)}#E(){this.#m&&(this.#u?this.#V():this.#c&&!this.#C||this.#T())}async#V(){const{country:i,subdivision:t,city:e}=this.#u,s=!!t&&!this.#b,o=!!e&&!this.#y,n=this.#r??a(this.#m),r=this.#l??d(this.#m),c=s&&i?l(i,this.#m):null,y=o&&i?s&&t?u(i,t,this.#m):h(i,this.#m):null,[p,m,v,C]=(await Promise.allSettled([n,r,c,y])).map(i=>"fulfilled"===i.status?i.value:null);if(!this.#u)return;m&&(this.#l=m);const g=[];p&&(this.#r||(this.#r=p,this.#F(p)),i&&!this.#c&&g.push([this.#i,i]));const x=i?this.#n.get(i):null;x?.subdivisionType&&this.#M(x.subdivisionType),v&&(this.#a=v,this.#s=v.length>0,v.length>0&&(this.#t.data=v.map(i=>({...i,lang:this.#v})),t&&g.push([this.#t,t]))),C&&(this.#o=C.length>0,C.length>0&&(this.#e.data=C,e&&g.push([this.#e,e]))),this.#w(),this.#u=b,setTimeout(()=>{if(this.#u===b){for(const[i,t]of g){const e=i.items?.find(i=>i["data-id"]===t);e&&(i.selectedItem=e)}this.#u=null}})}#q(){this.#u!==b&&(this.#u=null,this.#k(),this.#_(),this.#L(this.#i.value),this.#N())}#D(){if(this.#u===b)return;this.#u=null;const i=this.#t.value;if(this.#_(),!this.#y&&i){const t=this.#i.value;t&&this.#P(t,i)}this.#N()}#L(i){if(!i)return;const t=this.#n.get(i);if(!t)return;const{hasSubdivisions:e,subdivisionType:s}=t;!this.#b&&e?(this.#M(s),this.#j(i)):this.#y||this.#P(i)}#M(i){const t=this.#z(i);this.#g||this.#O(this.#t,"label",t||null),this.#x||this.#O(this.#t,"placeholder",t||null)}#z(i){const t=this.#l?.subdivisionTypes,e=t?.[i]??t?._fallback;if(!e)return i;const s=this.#v;return s&&(e[s]||e[s.split("-")[0]])||e.en||i}async#W(){try{this.#l=await d(this.#m)}catch{}}async#T(){if(this.#m){this.#i.setAttribute("loading","true");try{const[i]=await Promise.all([a(this.#m),this.#W()]);this.#r=i,this.#F(i),!this.#u&&this.#C&&this.#L(this.#C)}catch(i){console.error(`[${c}] Failed to load countries`,i)}finally{this.#i.removeAttribute("loading")}}}async#j(i){this.#G(this.#t,!0),this.#t.setAttribute("loading","true");try{const t=await l(i,this.#m);this.#a=t,this.#s=t.length>0,this.#w(),t.length>0?this.#t.data=t.map(i=>({...i,lang:this.#v})):this.#y||this.#P(i)}catch(t){console.error(`[${c}] Failed to load subdivisions for ${i}`,t),this.#s=!1,this.#Z()}finally{this.#t.removeAttribute("loading")}}async#P(i,t){this.#e.setAttribute("loading","true");try{const e=await(t?u(i,t,this.#m):h(i,this.#m));this.#o=e.length>0,this.#w(),e.length>0&&(this.#e.data=e)}catch(e){console.error(`[${c}] Failed to load cities for ${i}${t?`/${t}`:""}`,e)}finally{this.#e.removeAttribute("loading")}}#U(){if(this.#r){const i=this.#i.value;this.#F(this.#r),i&&this.#J(this.#i,i)}if(this.#a&&this.#s){const i=this.#t.value;this.#t.data=this.#a.map(i=>({...i,lang:this.#v})),i&&this.#J(this.#t,i)}const i=this.#i.value;if(i){const t=this.#n.get(i);t?.subdivisionType&&this.#M(t.subdivisionType)}}#F(i){const t=this.#Q(i);this.#i.data=t.map(i=>({...i,lang:this.#v})),this.#n=new Map(i.map(i=>[i.iso2,i]))}#Q(i){const t=this.#f,e=this.#B;let s=t.length?i.filter(i=>t.includes(i.iso2)):[...i];return s.sort((i,t)=>y(i,this.#v).localeCompare(y(t,this.#v),this.#v)),e.length?[...e.map(i=>s.find(t=>t.iso2===i)).filter(Boolean),...s.filter(i=>!e.includes(i.iso2))]:s}#Z(){this.#G(this.#i,!this.#c),this.#G(this.#t,!this.#b&&(this.#p||this.#s)),this.#G(this.#e,!this.#y&&(this.#p||this.#o))}#G(i,t){i?.classList.toggle(`${c}-hidden`,!t)}#I(){const i=this.hasAttribute("required")?"true":null;this.#O(this.#i,"required",this.#c?null:i),this.#O(this.#t,"required",this.#b||!this.#p&&!this.#s?null:i),this.#O(this.#e,"required",this.#y||!this.#p&&!this.#o?null:i)}#w(){this.#Z(),this.#I(),this.setCustomValidity("")}#k(){this.#t.value="",this.#t.data=[],this.#s=!1,this.#g||this.#t.removeAttribute("label"),this.#x||this.#t.removeAttribute("placeholder"),this.#w()}#_(){this.#e.value="",this.#e.data=[],this.#o=!1,this.#w()}#N(){this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0}))}#O(i,t,e){e?i.setAttribute(t,e):i.removeAttribute(t)}#A(){return this.#S.find(i=>!i.classList.contains(`${c}-hidden`))}#J(i,t){setTimeout(()=>{const e=i.items?.find(i=>i["data-id"]===t);e&&(i.selectedItem=e)})}});customElements.define(c,V);var A=e(88961),w=e(86365);const $=(0,o.xE)("country-subdivision-city-field"),E={selector:()=>":host"},H={selector:`${c} > .wrapper`},I={selector:`${c} > .wrapper > descope-combo-box`},L=(0,n.Zz)((0,A.RF)({componentNameOverride:(0,o.xE)("input-wrapper")}),(0,A.RF)({mappings:{hostWidth:{...E,property:"width"},hostDirection:[{...E,property:"direction"},{...I,property:w.C.cssVarList.hostDirection}],flexDirection:{...H,property:"flex-direction"},flexGap:{...H,property:"gap"},itemAlignment:{...H,property:"align-items"},itemMinWidth:{...I,property:"min-width"},itemFlexGrow:{...I,property:"flex-grow"},itemWidth:{...I,property:w.C.cssVarList.hostWidth}}}),A.VO,(0,A.OZ)({proxyProps:["value"],inputEvent:"input",proxyParentValidation:!0}),A.tQ,i=>class extends i{init(){super.init?.();const i=document.createElement("template");i.innerHTML=`\n <${c}\n tabindex="-1"\n ></${c}>\n `,this.baseElement.appendChild(i.content.cloneNode(!0)),this.inputElement=this.shadowRoot.querySelector(c),(0,o.EA)(this,this.inputElement,{includeAttrs:["size","bordered","required","label-type","disabled","readonly","hide-country","hide-subdivision","hide-city","default-country","allowed-countries","pinned-countries","country-label","subdivision-label","city-label","country-placeholder","subdivision-placeholder","city-placeholder","data-source-base-url","lang","invalid"]}),(0,o.Gh)(this,this.inputElement,{includeAttrs:["invalid"]})}})((0,A.tz)({slots:[],wrappedEleName:"vaadin-custom-field",style:()=>`\n :host {\n display: inline-flex;\n max-width: 100%;\n }\n vaadin-custom-field {\n line-height: unset;\n width: 100%;\n }\n\n ${c} {\n display: inline-block;\n box-sizing: border-box;\n user-select: none;\n width: 100%;\n max-width: 100%;\n }\n\n ${c} > .wrapper {\n display: flex;\n width: 100%;\n flex-wrap: wrap;\n }\n\n .${c}-hidden {\n display: none;\n }\n\n`,excludeAttrsSync:["tabindex","style","error-message"],componentName:$}));customElements.define($,L)}}]);
1
+ "use strict";(self.webpackChunk_descope_web_components_ui=self.webpackChunk_descope_web_components_ui||[]).push([[2478],{68749(i,t,e){e.r(t),e.d(t,{CountrySubdivisionCityFieldClass:()=>L,componentName:()=>w}),e(25003),e(27092);var s=e(72270),o=e(25964),n=e(63200);const a=async i=>{const t=await fetch(i);if(!t.ok)throw new Error(`[dataService] ${t.status} ${i}`);const e=await t.json();return e.data??e},r=async i=>a(`${i}/countries.json`),l=async(i,t)=>{try{return(await a(`${t}/countries/${i}/subdivisions.json`)).map(({code:i,...t})=>({...t,state_code:i}))}catch{return[]}},d=async(i,t,e)=>a(`${e}/countries/${i}/subdivisions/${t}/cities.json`),u=async i=>{const t=new URL("../labels.json",`${i}/`).href;return a(t)},h=async(i,t)=>a(`${t}/countries/${i}/cities.json`),c=(0,o.xE)("country-subdivision-city-field-internal"),b=Symbol("selecting"),y=({name:i,translations:t={}},e)=>e&&(t[e]||t[e.split("-")[0]])||i,m=i=>i?String(i).replace(/[&<>"']/g,i=>`&#${i.charCodeAt(0)};`):"",p=({name:i,iso2:t,iso3:e,translations:s,lang:o})=>{const n=y({name:i,translations:s},o),a=[n,t,e];n!==i&&a.push(i);const r=m(t),l=m(a.join(" ")),d=m(n);return`<div data-id="${r}" data-name="${l}" data-label="${d}">${d}</div>`},C=({name:i,state_code:t,translations:e,lang:s})=>{const o=y({name:i,translations:e},s),n=[o,t];o!==i&&n.push(i);const a=m(t),r=m(n.join(" ")),l=m(o);return`<div data-id="${a}" data-name="${r}" data-label="${l}">${l}</div>`},v=({name:i,translations:t,lang:e})=>{const s=y({name:i,translations:t},e),o=[s];s!==i&&o.push(i);const n=m(i),a=m(o.join(" ")),r=m(s);return`<div data-id="${n}" data-name="${a}" data-label="${r}">${r}</div>`},g=i=>`<descope-combo-box id="${i}" item-label-path="data-name" item-value-path="data-id" allow-custom-value="false"></descope-combo-box>`,x=(0,s.yc)({componentName:c,baseSelector:""}),f=["disabled","readonly","size","bordered"],B=["hide-country","hide-subdivision","hide-city"],V=[...f,"label-type","country-label","subdivision-label","city-label",...B,"default-country","allowed-countries","pinned-countries","country-placeholder","subdivision-placeholder","city-placeholder","required","invalid","data-source-base-url","lang"],S=(0,n.Zz)()(class extends x{static get observedAttributes(){return[].concat(x.observedAttributes||[],V)}#i;#t;#e;#s=!1;#o=!1;#n=new Map;#a=null;#r=null;#l=null;#d=null;#u=null;constructor(){super(),this.innerHTML=`\n <div class="wrapper">\n ${g("country-combo")}\n ${g("subdivision-combo")}\n ${g("city-combo")}\n </div>\n `,this.#i=this.querySelector("#country-combo"),this.#t=this.querySelector("#subdivision-combo"),this.#e=this.querySelector("#city-combo"),this.#h(),this.#c()}get#b(){return"true"===this.getAttribute("hide-country")}get#y(){return"true"===this.getAttribute("hide-subdivision")}get#m(){return"true"===this.getAttribute("hide-city")}get#p(){return!this.#C}get#C(){return this.getAttribute("data-source-base-url")||void 0}get#v(){const i=this.getAttribute("lang")||void 0;if(i)try{const[t]=Intl.getCanonicalLocales(i);return t}catch{return}}get#g(){return this.getAttribute("default-country")?.toUpperCase()||void 0}get#x(){return this.getAttribute("subdivision-label")||void 0}get#f(){return this.getAttribute("subdivision-placeholder")||void 0}get#B(){return(this.getAttribute("allowed-countries")||"").split(",").map(i=>i.trim().toUpperCase()).filter(Boolean)}get#V(){return(this.getAttribute("pinned-countries")||"").split(",").map(i=>i.trim().toUpperCase()).filter(Boolean)}get#S(){return[this.#i,this.#t,this.#e]}get value(){return{country:this.#b?this.#g:this.#i.value||void 0,subdivision:!this.#y&&this.#s&&this.#t.value||void 0,city:!this.#m&&this.#o&&this.#e.value||void 0}}set value(i){if(!i)return;let t;try{t="string"==typeof i?JSON.parse(i):i}catch{return}this.#u={...t},this.#C&&this.#A()}init(){this.addEventListener("focus",i=>{if(i.isTrusted){const i=this.#S.find(i=>!i.classList.contains(`${c}-hidden`)&&!i.checkValidity());(i||this.#$())?.focus()}}),super.init?.(),this.#w(),this.#E(),this.#H(),this.#I()}#I(){this.#i.renderItem=p,this.#t.renderItem=C,this.#e.renderItem=v}attributeChangedCallback(i,t,e){if(super.attributeChangedCallback?.(i,t,e),t!==e)if("required"===i)this.#L();else if(B.includes(i)||"data-source-base-url"===i)this.#w(),"data-source-base-url"===i&&this.#H();else if("default-country"===i){const i=e?.toUpperCase();if(i&&i!==e)return void this.setAttribute("default-country",i);i&&this.#n.size?this.#T(i):i&&this.#b&&this.#U()}else"lang"===i?this.#R():"invalid"===i?"true"===e&&this.#F():"allowed-countries"===i||"pinned-countries"===i?this.#b||(this.#a?this.#O(this.#a):this.#U()):"country-label"===i?this.#q(this.#i,"label",e):"subdivision-label"===i?this.#q(this.#t,"label",e):"city-label"===i&&this.#q(this.#e,"label",e)}getValidity(){if(!this.isRequired)return{};const i=!this.#b&&!this.#i.value,t=!this.#y&&(this.#p||this.#s)&&!this.#t.value,e=!this.#m&&(this.#p||this.#o)&&!this.#e.value;return i||t||e?{valueMissing:!0}:{}}#F(){for(const i of[...this.#S].reverse())i.classList.contains(`${c}-hidden`)||i.checkValidity()||i.reportValidity()}#h(){[this.#i,this.#t,this.#e].forEach(i=>{i.customValueTransformFn=t=>{const e=i.baseElement?.items?.find(i=>i["data-name"]===t);return e?.getAttribute("data-label")??t}})}#c(){this.#S.forEach(i=>{(0,o.EA)(this,i,{includeAttrs:[...f,"label-type"]})}),(0,o.EA)(this,this.#i,{includeAttrs:["default-country"],mapAttrs:{"default-country":"default-value"}}),[[this.#i,"country-placeholder"],[this.#t,"subdivision-placeholder"],[this.#e,"city-placeholder"]].forEach(([i,t])=>{(0,o.EA)(this,i,{includeAttrs:[t],mapAttrs:{[t]:"placeholder"}})})}#E(){this.#i.addEventListener("input",()=>this.#D()),this.#t.addEventListener("input",()=>this.#N()),this.#e.addEventListener("input",()=>this.#M()),this.handleFocusEventsDispatching(this.#S)}#H(){this.#C&&(this.#u?this.#A():this.#b&&!this.#g||this.#U())}async#A(){const{country:i,subdivision:t,city:e}=this.#u,s=!!t&&!this.#y,o=!!e&&!this.#m,n=this.#a??r(this.#C),a=this.#d??u(this.#C),c=s&&i?l(i,this.#C):null,y=o&&i?s&&t?d(i,t,this.#C):h(i,this.#C):null,[m,p,C,v]=(await Promise.allSettled([n,a,c,y])).map(i=>"fulfilled"===i.status?i.value:null);if(!this.#u)return;p&&(this.#d=p);const g=[];m&&(this.#a||(this.#a=m,this.#O(m)),i&&!this.#b&&g.push([this.#i,i]));const x=i?this.#n.get(i):null;x?.subdivisionType&&this.#k(x.subdivisionType),C&&(this.#r=C,this.#s=C.length>0,C.length>0&&(this.#t.data=C.map(i=>({...i,lang:this.#v})),t&&g.push([this.#t,t]))),v&&(this.#o=v.length>0,v.length>0&&(this.#l=v,this.#e.data=v.map(i=>({...i,lang:this.#v})),e&&g.push([this.#e,e]))),this.#w(),this.#u=b,setTimeout(()=>{if(this.#u===b){for(const[i,t]of g){const e=i.items?.find(i=>i["data-id"]===t);e&&(i.selectedItem=e)}this.#u=null}})}#D(){this.#u!==b&&(this.#u=null,this.#_(),this.#P(),this.#T(this.#i.value),this.#M())}#N(){if(this.#u===b)return;this.#u=null;const i=this.#t.value;if(this.#P(),!this.#m&&i){const t=this.#i.value;t&&this.#j(t,i)}this.#M()}#T(i){if(!i)return;const t=this.#n.get(i);if(!t)return;const{hasSubdivisions:e,subdivisionType:s}=t;!this.#y&&e?(this.#k(s),this.#z(i)):this.#m||this.#j(i)}#k(i){const t=this.#W(i);this.#x||this.#q(this.#t,"label",t||null),this.#f||this.#q(this.#t,"placeholder",t||null)}#W(i){const t=this.#d?.subdivisionTypes,e=t?.[i]??t?._fallback;if(!e)return i;const s=this.#v;return s&&(e[s]||e[s.split("-")[0]])||e.en||i}async#G(){try{this.#d=await u(this.#C)}catch{}}async#U(){if(this.#C){this.#i.setAttribute("loading","true");try{const[i]=await Promise.all([r(this.#C),this.#G()]);this.#a=i,this.#O(i),!this.#u&&this.#g&&this.#T(this.#g)}catch(i){console.error(`[${c}] Failed to load countries`,i)}finally{this.#i.removeAttribute("loading")}}}async#z(i){this.#Z(this.#t,!0),this.#t.setAttribute("loading","true");try{const t=await l(i,this.#C);this.#r=t,this.#s=t.length>0,this.#w(),t.length>0?this.#t.data=t.map(i=>({...i,lang:this.#v})):this.#m||this.#j(i)}catch(t){console.error(`[${c}] Failed to load subdivisions for ${i}`,t),this.#s=!1,this.#J()}finally{this.#t.removeAttribute("loading")}}async#j(i,t){this.#e.setAttribute("loading","true");try{const e=await(t?d(i,t,this.#C):h(i,this.#C));this.#o=e.length>0,this.#w(),e.length>0&&(this.#l=e,this.#e.data=e.map(i=>({...i,lang:this.#v})))}catch(e){console.error(`[${c}] Failed to load cities for ${i}${t?`/${t}`:""}`,e)}finally{this.#e.removeAttribute("loading")}}#R(){if(this.#a){const i=this.#i.value;this.#O(this.#a),i&&this.#Q(this.#i,i)}if(this.#r&&this.#s){const i=this.#t.value;this.#t.data=this.#r.map(i=>({...i,lang:this.#v})),i&&this.#Q(this.#t,i)}if(this.#l&&this.#o){const i=this.#e.value;this.#e.data=this.#l.map(i=>({...i,lang:this.#v})),i&&this.#Q(this.#e,i)}const i=this.#i.value;if(i){const t=this.#n.get(i);t?.subdivisionType&&this.#k(t.subdivisionType)}}#O(i){const t=this.#K(i);this.#i.data=t.map(i=>({...i,lang:this.#v})),this.#n=new Map(i.map(i=>[i.iso2,i]))}#K(i){const t=this.#B,e=this.#V;let s=t.length?i.filter(i=>t.includes(i.iso2)):[...i];return s.sort((i,t)=>y(i,this.#v).localeCompare(y(t,this.#v),this.#v)),e.length?[...e.map(i=>s.find(t=>t.iso2===i)).filter(Boolean),...s.filter(i=>!e.includes(i.iso2))]:s}#J(){this.#Z(this.#i,!this.#b),this.#Z(this.#t,!this.#y&&(this.#p||this.#s)),this.#Z(this.#e,!this.#m&&(this.#p||this.#o))}#Z(i,t){i?.classList.toggle(`${c}-hidden`,!t)}#L(){const i=this.hasAttribute("required")?"true":null;this.#q(this.#i,"required",this.#b?null:i),this.#q(this.#t,"required",this.#y||!this.#p&&!this.#s?null:i),this.#q(this.#e,"required",this.#m||!this.#p&&!this.#o?null:i)}#w(){this.#J(),this.#L(),this.setCustomValidity("")}#_(){this.#t.value="",this.#t.data=[],this.#s=!1,this.#x||this.#t.removeAttribute("label"),this.#f||this.#t.removeAttribute("placeholder"),this.#w()}#P(){this.#e.value="",this.#e.data=[],this.#l=null,this.#o=!1,this.#w()}#M(){this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0}))}#q(i,t,e){e?i.setAttribute(t,e):i.removeAttribute(t)}#$(){return this.#S.find(i=>!i.classList.contains(`${c}-hidden`))}#Q(i,t){setTimeout(()=>{const e=i.items?.find(i=>i["data-id"]===t);e&&(i.selectedItem=e)})}});customElements.define(c,S);var A=e(88961),$=e(86365);const w=(0,o.xE)("country-subdivision-city-field"),E={selector:()=>":host"},H={selector:`${c} > .wrapper`},I={selector:`${c} > .wrapper > descope-combo-box`},L=(0,n.Zz)((0,A.RF)({componentNameOverride:(0,o.xE)("input-wrapper")}),(0,A.RF)({mappings:{hostWidth:{...E,property:"width"},hostDirection:[{...E,property:"direction"},{...I,property:$.C.cssVarList.hostDirection}],flexDirection:{...H,property:"flex-direction"},flexGap:{...H,property:"gap"},itemAlignment:{...H,property:"align-items"},itemMinWidth:{...I,property:"min-width"},itemFlexGrow:{...I,property:"flex-grow"},itemWidth:{...I,property:$.C.cssVarList.hostWidth}}}),A.VO,(0,A.OZ)({proxyProps:["value"],inputEvent:"input",proxyParentValidation:!0}),A.tQ,i=>class extends i{init(){super.init?.();const i=document.createElement("template");i.innerHTML=`\n <${c}\n tabindex="-1"\n ></${c}>\n `,this.baseElement.appendChild(i.content.cloneNode(!0)),this.inputElement=this.shadowRoot.querySelector(c),(0,o.EA)(this,this.inputElement,{includeAttrs:["size","bordered","required","label-type","disabled","readonly","hide-country","hide-subdivision","hide-city","default-country","allowed-countries","pinned-countries","country-label","subdivision-label","city-label","country-placeholder","subdivision-placeholder","city-placeholder","data-source-base-url","lang","invalid"]}),(0,o.Gh)(this,this.inputElement,{includeAttrs:["invalid"]})}})((0,A.tz)({slots:[],wrappedEleName:"vaadin-custom-field",style:()=>`\n :host {\n display: inline-flex;\n max-width: 100%;\n }\n vaadin-custom-field {\n line-height: unset;\n width: 100%;\n }\n\n ${c} {\n display: inline-block;\n box-sizing: border-box;\n user-select: none;\n width: 100%;\n max-width: 100%;\n }\n\n ${c} > .wrapper {\n display: flex;\n width: 100%;\n flex-wrap: wrap;\n }\n\n .${c}-hidden {\n display: none;\n }\n\n`,excludeAttrsSync:["tabindex","style","error-message"],componentName:w}));customElements.define(w,L)}}]);
2
2
  //# sourceMappingURL=descope-country-subdivision-city-field.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"descope-country-subdivision-city-field.js","mappings":"wQASA,MAAMA,EAAYC,MAAOC,IACvB,MAAMC,QAAiBC,MAAMF,GAC7B,IAAKC,EAASE,GAAI,MAAM,IAAIC,MAAM,iBAAiBH,EAASI,UAAUL,KACtE,MAAMM,QAAaL,EAASK,OAE5B,OAAOA,EAAKC,MAAQD,GAGTE,EAAiBT,MAAOU,GACnCX,EAAU,GAAGW,oBAKFC,EAAoBX,MAAOY,EAAaF,KACnD,IAIE,aAHmBX,EACjB,GAAGW,eAAqBE,wBALvBC,IAAI,EAAGC,UAASC,MAAW,IAAMA,EAAMC,WAAYF,IAQxD,CAAE,MAEA,MAAO,EACT,GAGWG,EAAcjB,MAAOY,EAAaM,EAAWR,IACxDX,EACE,GAAGW,eAAqBE,kBAA4BM,iBAK3CC,EAAcnB,MAAOU,IAChC,MAAMU,EAAY,IAAIC,IAAI,iBAAkB,GAAGX,MAAYY,KAC3D,OAAOvB,EAAUqB,IAGNG,EAAwBvB,MAAOY,EAAaF,IACvDX,EAAU,GAAGW,eAAqBE,iBClCvBY,GAAgB,QAC3B,2CAKIC,EAAYC,OAAO,aAInBC,EAAqB,EAAGC,OAAMC,eAAe,CAAC,GAAKC,IAClDA,IACED,EAAaC,IAASD,EAAaC,EAAKC,MAAM,KAAK,MADxCH,EAMdI,EAAcC,GACbA,EACEC,OAAOD,GAAKE,QAAQ,WAAaC,GAAM,KAAKA,EAAEC,WAAW,OAD/C,GAMbC,EAAc,EAAGV,OAAMW,OAAMC,OAAMX,eAAcC,WACrD,MAAMW,EAAcd,EAAmB,CAAEC,OAAMC,gBAAgBC,GACzDY,EAAc,CAACD,EAAaF,EAAMC,GACpCC,IAAgBb,GAAMc,EAAYC,KAAKf,GAC3C,MAAMgB,EAAcZ,EAAWO,GACzBM,EAAqBb,EAAWU,EAAYI,KAAK,MACjDC,EAAef,EAAWS,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Y4F,YAAYH,EAASI,QAAQC,WAAU,IAExDhJ,KAAKiJ,aAAejJ,KAAKkJ,WAAWhJ,cAClC,IAGF,QAAaF,KAAMA,KAAKiJ,aAAc,CACpC5F,aAAc,CACZ,OACA,WACA,WACA,aACA,WACA,WACA,eACA,mBACA,YACA,kBACA,oBACA,mBACA,gBACA,oBACA,aACA,sBACA,0BACA,mBACA,uBACA,OACA,cAKJ,QAAUrD,KAAMA,KAAKiJ,aAAc,CAAE5F,aAAc,CAAC,YACtD,GAa4C,EAkC9C,QAAY,CACV8F,MAAO,GACPC,eAAgB,sBAChBC,MAAO,IAAM,mJAUb,0IAQA,yFAMC,0CAKDC,iBAAkB,CAAC,WAAY,QAAS,iBACxChM,cAAa,KCxIjB4J,eAAeC,OAAO,EAAeK,E","sources":["webpack://@descope/web-components-ui/../components/descope-country-subdivision-city-field/src/data/dataService.js","webpack://@descope/web-components-ui/../components/descope-country-subdivision-city-field/src/component/descope-country-subdivision-city-field-internal/CountrySubdivisionCityFieldInternal.js","webpack://@descope/web-components-ui/../components/descope-country-subdivision-city-field/src/component/descope-country-subdivision-city-field-internal/index.js","webpack://@descope/web-components-ui/../components/descope-country-subdivision-city-field/src/component/CountrySubdivisionCityFieldClass.js","webpack://@descope/web-components-ui/../components/descope-country-subdivision-city-field/src/component/index.js"],"sourcesContent":["// Data service for country/subdivision/city data.\n//\n// Fetches from the CDN/S3 baseUrl. The URL structure (relative to baseUrl):\n// <baseUrl>/countries.json\n// <baseUrl>/countries/{iso2}/subdivisions.json\n// <baseUrl>/countries/{iso2}/subdivisions/{state_code}/cities.json\n// <baseUrl>/countries/{iso2}/cities.json (all cities for a country, used when subdivision is hidden)\n// <parent-of-baseUrl>/labels.json (shared labels/translations, one level up)\n\nconst fetchJson = async (url) => {\n const response = await fetch(url);\n if (!response.ok) throw new Error(`[dataService] ${response.status} ${url}`);\n const json = await response.json();\n // All files use a { data: [...] } envelope\n return json.data ?? json;\n};\n\nexport const fetchCountries = async (baseUrl) =>\n fetchJson(`${baseUrl}/countries.json`);\n\nconst normalizeSubdivisions = (data) =>\n data.map(({ code, ...rest }) => ({ ...rest, state_code: code }));\n\nexport const fetchSubdivisions = async (countryIso2, baseUrl) => {\n try {\n const data = await fetchJson(\n `${baseUrl}/countries/${countryIso2}/subdivisions.json`,\n );\n return normalizeSubdivisions(data);\n } catch {\n // No subdivisions file means the country has no subdivisions\n return [];\n }\n};\n\nexport const fetchCities = async (countryIso2, stateCode, baseUrl) =>\n fetchJson(\n `${baseUrl}/countries/${countryIso2}/subdivisions/${stateCode}/cities.json`,\n );\n\n// labels.json sits one directory above the language-specific base URL\n// e.g. baseUrl = \".../address/en\" → labels URL = \".../address/labels.json\"\nexport const fetchLabels = async (baseUrl) => {\n const labelsUrl = new URL('../labels.json', `${baseUrl}/`).href;\n return fetchJson(labelsUrl);\n};\n\nexport const fetchCitiesForCountry = async (countryIso2, baseUrl) =>\n fetchJson(`${baseUrl}/countries/${countryIso2}/cities.json`);\n","import { createBaseInputClass } from '@descope-ui/common/base-classes';\nimport {\n getComponentName,\n forwardAttrs,\n} from '@descope-ui/common/components-helpers';\nimport { compose } from '@descope-ui/common/utils';\nimport {\n fetchCountries,\n fetchSubdivisions,\n fetchCities,\n fetchCitiesForCountry,\n fetchLabels,\n} from '../../data/dataService';\n\nexport const componentName = getComponentName(\n 'country-subdivision-city-field-internal',\n);\n\n// Sentinel used in #pendingValue to signal that programmatic item selection is in progress.\n// Prevents cascade-clearing logic in input handlers from firing during programmatic selection.\nconst SELECTING = Symbol('selecting');\n\n// --- Translation ---\n\nconst resolveTranslation = ({ name, translations = {} }, lang) => {\n if (!lang) return name;\n return translations[lang] || translations[lang.split('-')[0]] || name;\n};\n\n// --- HTML Escaping ---\n\nconst escapeHtml = (str) => {\n if (!str) return '';\n return String(str).replace(/[&<>\"']/g, (c) => `&#${c.charCodeAt(0)};`);\n};\n\n// --- Item renderers ---\n\nconst countryItem = ({ name, iso2, iso3, translations, lang }) => {\n const displayName = resolveTranslation({ name, translations }, lang);\n const searchTerms = [displayName, iso2, iso3];\n if (displayName !== name) searchTerms.push(name);\n const escapedIso2 = escapeHtml(iso2);\n const escapedSearchTerms = escapeHtml(searchTerms.join(' '));\n const escapedLabel = escapeHtml(displayName);\n return `<div data-id=\"${escapedIso2}\" data-name=\"${escapedSearchTerms}\" data-label=\"${escapedLabel}\">${escapedLabel}</div>`;\n};\n\nconst subdivisionItem = ({ name, state_code, translations, lang }) => {\n const displayName = resolveTranslation({ name, translations }, lang);\n const searchTerms = [displayName, state_code];\n if (displayName !== name) searchTerms.push(name);\n const escapedStateCode = escapeHtml(state_code);\n const escapedSearchTerms = escapeHtml(searchTerms.join(' '));\n const escapedLabel = escapeHtml(displayName);\n return `<div data-id=\"${escapedStateCode}\" data-name=\"${escapedSearchTerms}\" data-label=\"${escapedLabel}\">${escapedLabel}</div>`;\n};\n\nconst cityItem = ({ name }) => {\n const escapedId = escapeHtml(name);\n const escapedName = escapeHtml(name);\n return `<div data-id=\"${escapedId}\" data-name=\"${escapedName}\">${escapedName}</div>`;\n};\n\nconst comboBoxHTML = (id) =>\n `<descope-combo-box id=\"${id}\" item-label-path=\"data-name\" item-value-path=\"data-id\" allow-custom-value=\"false\"></descope-combo-box>`;\n\n// --- Base class ---\n\nconst BaseInputClass = createBaseInputClass({\n componentName,\n baseSelector: '',\n});\n\nconst commonAttrs = ['disabled', 'readonly', 'size', 'bordered'];\nconst labelTypeAttrs = [\n 'label-type',\n 'country-label',\n 'subdivision-label',\n 'city-label',\n];\nconst visibilityAttrs = ['hide-country', 'hide-subdivision', 'hide-city'];\nconst countryConfigAttrs = [\n 'default-country',\n 'allowed-countries',\n 'pinned-countries',\n];\nconst placeholderAttrs = [\n 'country-placeholder',\n 'subdivision-placeholder',\n 'city-placeholder',\n];\nconst observedAttrs = [\n ...commonAttrs,\n ...labelTypeAttrs,\n ...visibilityAttrs,\n ...countryConfigAttrs,\n ...placeholderAttrs,\n 'required',\n 'invalid',\n 'data-source-base-url',\n 'lang',\n];\n\nclass RawCountrySubdivisionCityFieldInternal extends BaseInputClass {\n static get observedAttributes() {\n return [].concat(BaseInputClass.observedAttributes || [], observedAttrs);\n }\n\n #countryComboBox;\n #subdivisionComboBox;\n #cityComboBox;\n\n // Whether the subdivision/city field should be shown (data was found for selected country/subdivision)\n #subdivisionVisible = false;\n #cityVisible = false;\n\n // iso2 → country object (populated after countries are loaded)\n #countriesMap = new Map();\n #cachedCountries = null;\n #cachedSubdivisions = null;\n #labels = null;\n\n // Value requested programmatically before data has loaded.\n // Applied incrementally as each cascade layer (countries → subdivisions → cities) loads.\n #pendingValue = null;\n\n constructor() {\n super();\n\n this.innerHTML = `\n <div class=\"wrapper\">\n ${comboBoxHTML('country-combo')}\n ${comboBoxHTML('subdivision-combo')}\n ${comboBoxHTML('city-combo')}\n </div>\n `;\n\n this.#countryComboBox = this.querySelector('#country-combo');\n this.#subdivisionComboBox = this.querySelector('#subdivision-combo');\n this.#cityComboBox = this.querySelector('#city-combo');\n\n this.#setupValueTransform();\n this.#setupAttrForwarding();\n }\n\n // --- Attribute getters ---\n\n get #isHideCountry() {\n return this.getAttribute('hide-country') === 'true';\n }\n get #isHideSubdivision() {\n return this.getAttribute('hide-subdivision') === 'true';\n }\n get #isHideCity() {\n return this.getAttribute('hide-city') === 'true';\n }\n get #isNoDataSource() {\n return !this.#baseUrl;\n }\n get #baseUrl() {\n return this.getAttribute('data-source-base-url') || undefined;\n }\n get #lang() {\n const lang = this.getAttribute('lang') || undefined;\n if (!lang) return undefined;\n try {\n Intl.getCanonicalLocales(lang);\n return lang;\n } catch {\n return undefined; // invalid BCP47 tag — fall back to English\n }\n }\n get #defaultCountry() {\n return this.getAttribute('default-country')?.toUpperCase() || undefined;\n }\n get #subdivisionLabel() {\n return this.getAttribute('subdivision-label') || undefined;\n }\n get #subdivisionPlaceholder() {\n return this.getAttribute('subdivision-placeholder') || undefined;\n }\n\n get #allowedCountries() {\n return (this.getAttribute('allowed-countries') || '')\n .split(',')\n .map((c) => c.trim().toUpperCase())\n .filter(Boolean);\n }\n\n get #pinnedCountries() {\n return (this.getAttribute('pinned-countries') || '')\n .split(',')\n .map((c) => c.trim().toUpperCase())\n .filter(Boolean);\n }\n\n get #allCombos() {\n return [\n this.#countryComboBox,\n this.#subdivisionComboBox,\n this.#cityComboBox,\n ];\n }\n\n // --- Value ---\n\n get value() {\n const country = this.#isHideCountry\n ? this.#defaultCountry\n : this.#countryComboBox.value || undefined;\n\n const subdivision =\n !this.#isHideSubdivision && this.#subdivisionVisible\n ? this.#subdivisionComboBox.value || undefined\n : undefined;\n\n const city =\n !this.#isHideCity && this.#cityVisible\n ? this.#cityComboBox.value || undefined\n : undefined;\n\n return { country, subdivision, city };\n }\n\n set value(val) {\n if (!val) return;\n let parsed;\n try {\n parsed = typeof val === 'string' ? JSON.parse(val) : val;\n } catch {\n // Invalid JSON — silently ignore to prevent component crash\n return;\n }\n this.#pendingValue = { ...parsed };\n if (this.#baseUrl) this.#loadForPendingValue();\n }\n\n // --- Lifecycle ---\n\n init() {\n this.addEventListener('focus', (e) => {\n if (e.isTrusted) {\n const firstInvalidCombo = this.#allCombos.find(\n (combo) =>\n !combo.classList.contains(`${componentName}-hidden`) &&\n !combo.checkValidity(),\n );\n (firstInvalidCombo || this.#getFirstVisibleCombo())?.focus();\n }\n });\n\n super.init?.();\n\n this.#refreshState();\n this.#setupChangeListeners();\n this.#initData();\n this.#setCombosItemRenderers();\n }\n\n #setCombosItemRenderers() {\n this.#countryComboBox.renderItem = countryItem;\n this.#subdivisionComboBox.renderItem = subdivisionItem;\n this.#cityComboBox.renderItem = cityItem;\n }\n\n attributeChangedCallback(attrName, oldValue, newValue) {\n super.attributeChangedCallback?.(attrName, oldValue, newValue);\n\n if (oldValue === newValue) return;\n\n if (attrName === 'required') {\n this.#updateRequiredOnCombos();\n } else if (\n visibilityAttrs.includes(attrName) ||\n attrName === 'data-source-base-url'\n ) {\n this.#refreshState();\n if (attrName === 'data-source-base-url') this.#initData();\n } else if (attrName === 'default-country') {\n const upper = newValue?.toUpperCase();\n if (upper && upper !== newValue) {\n this.setAttribute('default-country', upper);\n return;\n }\n if (upper && this.#countriesMap.size) {\n this.#onCountrySelected(upper); // countries already loaded — trigger immediately\n } else if (upper && this.#isHideCountry) {\n // hide-country mode: countries may not have been loaded yet (e.g. no default-country at init).\n // Kick off loading now; #loadCountries will call #onCountrySelected once done.\n this.#loadCountries();\n }\n } else if (attrName === 'lang') {\n this.#rerenderOnLangChange();\n } else if (attrName === 'invalid') {\n if (newValue === 'true') this.#handleInvalidCombos();\n } else if (\n attrName === 'allowed-countries' ||\n attrName === 'pinned-countries'\n ) {\n if (!this.#isHideCountry) {\n // Re-render from cache if available to avoid a race condition between two simultaneous\n // fetch calls (one from data-source-base-url, one from the filter attribute change).\n if (this.#cachedCountries) {\n this.#renderCountryItems(this.#cachedCountries);\n } else {\n this.#loadCountries();\n }\n }\n } else if (attrName === 'country-label') {\n this.#setOrRemoveAttr(this.#countryComboBox, 'label', newValue);\n } else if (attrName === 'subdivision-label') {\n this.#setOrRemoveAttr(this.#subdivisionComboBox, 'label', newValue);\n } else if (attrName === 'city-label') {\n this.#setOrRemoveAttr(this.#cityComboBox, 'label', newValue);\n }\n }\n\n // --- Validation ---\n\n getValidity() {\n if (!this.isRequired) return {};\n\n const countryMissing = !this.#isHideCountry && !this.#countryComboBox.value;\n const subdivisionMissing =\n !this.#isHideSubdivision &&\n (this.#isNoDataSource || this.#subdivisionVisible) &&\n !this.#subdivisionComboBox.value;\n const cityMissing =\n !this.#isHideCity &&\n (this.#isNoDataSource || this.#cityVisible) &&\n !this.#cityComboBox.value;\n\n return countryMissing || subdivisionMissing || cityMissing\n ? { valueMissing: true }\n : {};\n }\n\n // Show validation errors on the specific combos that are missing a value.\n // Iterate in reverse so reportValidity's focus() lands on the first invalid combo last.\n #handleInvalidCombos() {\n for (const combo of [...this.#allCombos].reverse()) {\n if (combo.classList.contains(`${componentName}-hidden`)) continue;\n if (!combo.checkValidity()) combo.reportValidity();\n }\n }\n\n // --- Setup ---\n\n #setupValueTransform() {\n // Display only the item name in the input, while data-name includes ISO codes for search\n [this.#countryComboBox, this.#subdivisionComboBox].forEach((combo) => {\n \n combo.customValueTransformFn = (val) => {\n const item = combo.baseElement?.items?.find(\n (i) => i['data-name'] === val,\n );\n return item?.getAttribute('data-label') ?? val;\n };\n });\n }\n\n #setupAttrForwarding() {\n // Forward common attrs and label-type to all combos\n this.#allCombos.forEach((combo) => {\n forwardAttrs(this, combo, {\n includeAttrs: [...commonAttrs, 'label-type'],\n });\n });\n\n // Forward default-country as default-value to let the combo box handle initial selection\n forwardAttrs(this, this.#countryComboBox, {\n includeAttrs: ['default-country'],\n mapAttrs: { 'default-country': 'default-value' },\n });\n\n // Forward per-field placeholders\n [\n [this.#countryComboBox, 'country-placeholder'],\n [this.#subdivisionComboBox, 'subdivision-placeholder'],\n [this.#cityComboBox, 'city-placeholder'],\n ].forEach(([combo, attr]) => {\n forwardAttrs(this, combo, {\n includeAttrs: [attr],\n mapAttrs: { [attr]: 'placeholder' },\n });\n });\n }\n\n #setupChangeListeners() {\n // descope-combo-box dispatches 'input' (not 'change') on selection\n this.#countryComboBox.addEventListener('input', () =>\n this.#handleCountryChange(),\n );\n this.#subdivisionComboBox.addEventListener('input', () =>\n this.#handleSubdivisionChange(),\n );\n this.#cityComboBox.addEventListener('input', () =>\n this.#dispatchInputEvent(),\n );\n\n this.handleFocusEventsDispatching(this.#allCombos);\n }\n\n #initData() {\n // baseUrl is forwarded by the outer component after this element is connected;\n // wait for the attributeChangedCallback('data-source-base-url') to re-trigger.\n if (!this.#baseUrl) return;\n\n if (this.#pendingValue) {\n this.#loadForPendingValue();\n return;\n }\n\n if (!this.#isHideCountry || this.#defaultCountry) {\n // Load countries to populate #countriesMap even when hide-country=true, so that\n // #onCountrySelected can apply the correct subdivision type label for the default country.\n this.#loadCountries();\n }\n }\n\n // --- Programmatic value loading (parallel fetch) ---\n\n async #loadForPendingValue() {\n const {\n country: pendingCountry,\n subdivision: pendingSubdivision,\n city: pendingCity,\n } = this.#pendingValue;\n\n const shouldLoadSubdivisions =\n !!pendingSubdivision && !this.#isHideSubdivision;\n const shouldLoadCities = !!pendingCity && !this.#isHideCity;\n\n const countriesPromise =\n this.#cachedCountries ?? fetchCountries(this.#baseUrl);\n const labelsPromise = this.#labels ?? fetchLabels(this.#baseUrl);\n const subdivisionsPromise =\n shouldLoadSubdivisions && pendingCountry\n ? fetchSubdivisions(pendingCountry, this.#baseUrl)\n : null;\n const citiesPromise =\n shouldLoadCities && pendingCountry\n ? shouldLoadSubdivisions && pendingSubdivision\n ? fetchCities(pendingCountry, pendingSubdivision, this.#baseUrl)\n : fetchCitiesForCountry(pendingCountry, this.#baseUrl)\n : null;\n\n // Fetch everything in parallel; null entries resolve immediately as null\n const [countries, labels, subdivisions, cities] = (\n await Promise.allSettled([\n countriesPromise,\n labelsPromise,\n subdivisionsPromise,\n citiesPromise,\n ])\n ).map((result) => (result.status === 'fulfilled' ? result.value : null));\n\n // Cancelled by a subsequent set value call or user interaction\n if (!this.#pendingValue) return;\n\n if (labels) this.#labels = labels;\n\n // Collect items to select — do this before rendering so we can batch-select below\n const toSelect = [];\n\n if (countries) {\n if (!this.#cachedCountries) {\n this.#cachedCountries = countries;\n this.#renderCountryItems(countries);\n }\n if (pendingCountry && !this.#isHideCountry)\n toSelect.push([this.#countryComboBox, pendingCountry]);\n }\n\n const countryObj = pendingCountry\n ? this.#countriesMap.get(pendingCountry)\n : null;\n if (countryObj?.subdivisionType)\n this.#applySubdivisionType(countryObj.subdivisionType);\n\n if (subdivisions) {\n this.#cachedSubdivisions = subdivisions;\n this.#subdivisionVisible = subdivisions.length > 0;\n if (subdivisions.length > 0) {\n this.#subdivisionComboBox.data = subdivisions.map((s) => ({\n ...s,\n lang: this.#lang,\n }));\n if (pendingSubdivision)\n toSelect.push([this.#subdivisionComboBox, pendingSubdivision]);\n }\n }\n\n if (cities) {\n this.#cityVisible = cities.length > 0;\n if (cities.length > 0) {\n this.#cityComboBox.data = cities;\n if (pendingCity) toSelect.push([this.#cityComboBox, pendingCity]);\n }\n }\n\n this.#refreshState();\n\n // Apply all selections in one batch. #pendingValue is set to SELECTING so that\n // input events fired by selectedItem= don't trigger cascade-clearing in change handlers.\n this.#pendingValue = SELECTING;\n setTimeout(() => {\n if (this.#pendingValue !== SELECTING) return; // cancelled by a new set value call\n for (const [combo, id] of toSelect) {\n const item = combo.items?.find((i) => i['data-id'] === id);\n if (item) combo.selectedItem = item;\n }\n this.#pendingValue = null;\n });\n }\n\n // --- Change handlers ---\n\n #handleCountryChange() {\n if (this.#pendingValue === SELECTING) return; // programmatic selection in progress\n this.#pendingValue = null; // cancel any in-flight fetch\n this.#resetSubdivision();\n this.#resetCity();\n this.#onCountrySelected(this.#countryComboBox.value);\n this.#dispatchInputEvent();\n }\n\n #handleSubdivisionChange() {\n if (this.#pendingValue === SELECTING) return; // programmatic selection in progress\n this.#pendingValue = null; // cancel any in-flight fetch\n const subdivisionCode = this.#subdivisionComboBox.value;\n this.#resetCity();\n\n if (!this.#isHideCity && subdivisionCode) {\n const countryIso2 = this.#countryComboBox.value;\n if (countryIso2) this.#loadCities(countryIso2, subdivisionCode);\n }\n this.#dispatchInputEvent();\n }\n\n // --- Country selection ---\n\n #onCountrySelected(countryIso2) {\n if (!countryIso2) return;\n\n const country = this.#countriesMap.get(countryIso2);\n if (!country) return;\n\n const { hasSubdivisions, subdivisionType } = country;\n\n if (!this.#isHideSubdivision && hasSubdivisions) {\n this.#applySubdivisionType(subdivisionType);\n this.#loadSubdivisions(countryIso2);\n } else if (!this.#isHideCity) {\n this.#loadCities(countryIso2);\n }\n }\n\n // Apply subdivisionType as label/placeholder, but only when not overridden by an explicit attribute.\n #applySubdivisionType(subdivisionType) {\n const label = this.#resolveSubdivisionTypeLabel(subdivisionType);\n if (!this.#subdivisionLabel)\n this.#setOrRemoveAttr(this.#subdivisionComboBox, 'label', label || null);\n if (!this.#subdivisionPlaceholder)\n this.#setOrRemoveAttr(\n this.#subdivisionComboBox,\n 'placeholder',\n label || null,\n );\n }\n\n #resolveSubdivisionTypeLabel(subdivisionType) {\n const types = this.#labels?.subdivisionTypes;\n const entry = types?.[subdivisionType] ?? types?._fallback;\n if (!entry) return subdivisionType;\n const lang = this.#lang;\n return (\n (lang && (entry[lang] || entry[lang.split('-')[0]])) ||\n entry.en ||\n subdivisionType\n );\n }\n\n // --- Data loading ---\n\n async #loadLabels() {\n try {\n this.#labels = await fetchLabels(this.#baseUrl);\n } catch {\n // Labels are optional; fall back to raw subdivisionType name\n }\n }\n\n async #loadCountries() {\n if (!this.#baseUrl) return;\n this.#countryComboBox.setAttribute('loading', 'true');\n try {\n const [countries] = await Promise.all([\n fetchCountries(this.#baseUrl),\n this.#loadLabels(),\n ]);\n this.#cachedCountries = countries;\n this.#renderCountryItems(countries);\n // Skip defaultCountry if a programmatic set value is in flight\n if (!this.#pendingValue && this.#defaultCountry)\n this.#onCountrySelected(this.#defaultCountry);\n } catch (e) {\n \n console.error(`[${componentName}] Failed to load countries`, e);\n } finally {\n this.#countryComboBox.removeAttribute('loading');\n }\n }\n\n async #loadSubdivisions(countryIso2) {\n this.#setVisible(this.#subdivisionComboBox, true);\n this.#subdivisionComboBox.setAttribute('loading', 'true');\n try {\n const subdivisions = await fetchSubdivisions(countryIso2, this.#baseUrl);\n this.#cachedSubdivisions = subdivisions;\n this.#subdivisionVisible = subdivisions.length > 0;\n this.#refreshState();\n\n if (subdivisions.length > 0) {\n this.#subdivisionComboBox.data = subdivisions.map((s) => ({\n ...s,\n lang: this.#lang,\n }));\n } else if (!this.#isHideCity) {\n this.#loadCities(countryIso2);\n }\n } catch (e) {\n \n console.error(\n `[${componentName}] Failed to load subdivisions for ${countryIso2}`,\n e,\n );\n this.#subdivisionVisible = false;\n this.#applyVisibility();\n } finally {\n this.#subdivisionComboBox.removeAttribute('loading');\n }\n }\n\n // stateCode is optional: when omitted, loads all cities for the country\n async #loadCities(countryIso2, stateCode) {\n this.#cityComboBox.setAttribute('loading', 'true');\n try {\n const cities = await (stateCode\n ? fetchCities(countryIso2, stateCode, this.#baseUrl)\n : fetchCitiesForCountry(countryIso2, this.#baseUrl));\n this.#cityVisible = cities.length > 0;\n this.#refreshState();\n if (cities.length > 0) {\n this.#cityComboBox.data = cities;\n }\n } catch (e) {\n \n console.error(\n `[${componentName}] Failed to load cities for ${countryIso2}${stateCode ? `/${stateCode}` : ''}`,\n e,\n );\n } finally {\n this.#cityComboBox.removeAttribute('loading');\n }\n }\n\n #rerenderOnLangChange() {\n if (this.#cachedCountries) {\n const prevCountry = this.#countryComboBox.value;\n this.#renderCountryItems(this.#cachedCountries);\n if (prevCountry) this.#selectItemById(this.#countryComboBox, prevCountry);\n }\n if (this.#cachedSubdivisions && this.#subdivisionVisible) {\n const prevSubdivision = this.#subdivisionComboBox.value;\n this.#subdivisionComboBox.data = this.#cachedSubdivisions.map((s) => ({\n ...s,\n lang: this.#lang,\n }));\n if (prevSubdivision)\n this.#selectItemById(this.#subdivisionComboBox, prevSubdivision);\n }\n // Re-apply translated subdivision type label for the new lang\n const currentIso2 = this.#countryComboBox.value;\n if (currentIso2) {\n const country = this.#countriesMap.get(currentIso2);\n if (country?.subdivisionType)\n this.#applySubdivisionType(country.subdivisionType);\n }\n }\n\n // --- Country item rendering ---\n\n #renderCountryItems(countries) {\n const result = this.#applyCountryFilters(countries);\n this.#countryComboBox.data = result.map((c) => ({\n ...c,\n // Include the translated name in the data for search purposes, but not in the label which is rendered by renderItem\n lang: this.#lang,\n }));\n this.#countriesMap = new Map(countries.map((c) => [c.iso2, c]));\n }\n\n #applyCountryFilters(countries) {\n const allowed = this.#allowedCountries;\n const pinned = this.#pinnedCountries;\n\n let filtered = allowed.length\n ? countries.filter((c) => allowed.includes(c.iso2))\n : [...countries];\n\n filtered.sort((a, b) =>\n resolveTranslation(a, this.#lang).localeCompare(\n resolveTranslation(b, this.#lang),\n this.#lang,\n ),\n );\n\n if (!pinned.length) return filtered;\n\n const pinnedItems = pinned\n .map((iso2) => filtered.find((c) => c.iso2 === iso2))\n .filter(Boolean);\n const rest = filtered.filter((c) => !pinned.includes(c.iso2));\n return [...pinnedItems, ...rest];\n }\n\n // --- Visibility & required ---\n\n #applyVisibility() {\n this.#setVisible(this.#countryComboBox, !this.#isHideCountry);\n this.#setVisible(\n this.#subdivisionComboBox,\n !this.#isHideSubdivision &&\n (this.#isNoDataSource || this.#subdivisionVisible),\n );\n this.#setVisible(\n this.#cityComboBox,\n !this.#isHideCity && (this.#isNoDataSource || this.#cityVisible),\n );\n }\n\n #setVisible(el, visible) {\n el?.classList.toggle(`${componentName}-hidden`, !visible);\n }\n\n #updateRequiredOnCombos() {\n const required = this.hasAttribute('required') ? 'true' : null;\n this.#setOrRemoveAttr(\n this.#countryComboBox,\n 'required',\n !this.#isHideCountry ? required : null,\n );\n this.#setOrRemoveAttr(\n this.#subdivisionComboBox,\n 'required',\n !this.#isHideSubdivision &&\n (this.#isNoDataSource || this.#subdivisionVisible)\n ? required\n : null,\n );\n this.#setOrRemoveAttr(\n this.#cityComboBox,\n 'required',\n !this.#isHideCity && (this.#isNoDataSource || this.#cityVisible)\n ? required\n : null,\n );\n }\n\n #refreshState() {\n this.#applyVisibility();\n this.#updateRequiredOnCombos();\n // Re-evaluate validity so that the form knows when newly-visible required fields become empty.\n // e.g. subdivision becomes required after a country with states is selected.\n this.setCustomValidity('');\n }\n\n // --- Reset helpers ---\n\n #resetSubdivision() {\n this.#subdivisionComboBox.value = '';\n this.#subdivisionComboBox.data = [];\n this.#subdivisionVisible = false;\n // Clear any dynamically set label/placeholder from subdivisionType\n if (!this.#subdivisionLabel)\n this.#subdivisionComboBox.removeAttribute('label');\n if (!this.#subdivisionPlaceholder)\n this.#subdivisionComboBox.removeAttribute('placeholder');\n this.#refreshState();\n }\n\n #resetCity() {\n this.#cityComboBox.value = '';\n this.#cityComboBox.data = [];\n this.#cityVisible = false;\n this.#refreshState();\n }\n\n // --- Utility helpers ---\n\n #dispatchInputEvent() {\n this.dispatchEvent(new Event('input', { bubbles: true, composed: true }));\n }\n\n #setOrRemoveAttr(el, attr, value) {\n if (value) el.setAttribute(attr, value);\n else el.removeAttribute(attr);\n }\n\n #getFirstVisibleCombo() {\n return this.#allCombos.find(\n (combo) => !combo.classList.contains(`${componentName}-hidden`),\n );\n }\n\n #selectItemById(comboBox, id) {\n // Defer the lookup so MutationObserver has time to populate comboBox.items\n setTimeout(() => {\n const item = comboBox.items?.find((i) => i['data-id'] === id);\n if (item) comboBox.selectedItem = item;\n });\n }\n}\n\nexport const CountrySubdivisionCityFieldInternal = compose()(\n RawCountrySubdivisionCityFieldInternal,\n);\n","import {\n CountrySubdivisionCityFieldInternal,\n componentName,\n} from './CountrySubdivisionCityFieldInternal';\n\ncustomElements.define(componentName, CountrySubdivisionCityFieldInternal);\n","import {\n createStyleMixin,\n draggableMixin,\n createProxy,\n proxyInputMixin,\n componentNameValidationMixin,\n} from '@descope-ui/common/components-mixins';\nimport {\n getComponentName,\n forwardAttrs,\n syncAttrs,\n} from '@descope-ui/common/components-helpers';\nimport { compose } from '@descope-ui/common/utils';\nimport { ComboBoxClass } from '@descope-ui/descope-combo-box/class';\nimport { componentName as descopeInternalComponentName } from './descope-country-subdivision-city-field-internal/CountrySubdivisionCityFieldInternal';\n\nexport const componentName = getComponentName('country-subdivision-city-field');\n\nconst customMixin = (superclass) =>\n class CountrySubdivisionCityFieldMixinClass extends superclass {\n init() {\n super.init?.();\n\n const template = document.createElement('template');\n\n template.innerHTML = `\n <${descopeInternalComponentName}\n tabindex=\"-1\"\n ></${descopeInternalComponentName}>\n `;\n\n this.baseElement.appendChild(template.content.cloneNode(true));\n\n this.inputElement = this.shadowRoot.querySelector(\n descopeInternalComponentName,\n );\n\n forwardAttrs(this, this.inputElement, {\n includeAttrs: [\n 'size',\n 'bordered',\n 'required',\n 'label-type',\n 'disabled',\n 'readonly',\n 'hide-country',\n 'hide-subdivision',\n 'hide-city',\n 'default-country',\n 'allowed-countries',\n 'pinned-countries',\n 'country-label',\n 'subdivision-label',\n 'city-label',\n 'country-placeholder',\n 'subdivision-placeholder',\n 'city-placeholder',\n 'data-source-base-url',\n 'lang',\n 'invalid',\n ],\n });\n\n // Sync invalid attribute bidirectionally so external validation feedback propagates\n syncAttrs(this, this.inputElement, { includeAttrs: ['invalid'] });\n }\n };\n\nconst host = { selector: () => ':host' };\n\nconst internalWrapper = {\n selector: `${descopeInternalComponentName} > .wrapper`,\n};\n\nconst internalComboBoxes = {\n selector: `${descopeInternalComponentName} > .wrapper > descope-combo-box`,\n};\n\nexport const CountrySubdivisionCityFieldClass = compose(\n createStyleMixin({\n componentNameOverride: getComponentName('input-wrapper'),\n }),\n createStyleMixin({\n mappings: {\n hostWidth: { ...host, property: 'width' },\n hostDirection: [\n { ...host, property: 'direction' },\n {\n ...internalComboBoxes,\n property: ComboBoxClass.cssVarList.hostDirection,\n },\n ],\n flexDirection: { ...internalWrapper, property: 'flex-direction' },\n flexGap: { ...internalWrapper, property: 'gap' },\n itemAlignment: { ...internalWrapper, property: 'align-items' },\n itemMinWidth: { ...internalComboBoxes, property: 'min-width' },\n itemFlexGrow: { ...internalComboBoxes, property: 'flex-grow' },\n itemWidth: {\n ...internalComboBoxes,\n property: ComboBoxClass.cssVarList.hostWidth,\n },\n },\n }),\n draggableMixin,\n proxyInputMixin({\n proxyProps: ['value'],\n inputEvent: 'input',\n proxyParentValidation: true,\n }),\n componentNameValidationMixin,\n customMixin,\n)(\n createProxy({\n slots: [],\n wrappedEleName: 'vaadin-custom-field',\n style: () => `\n :host {\n display: inline-flex;\n max-width: 100%;\n }\n vaadin-custom-field {\n line-height: unset;\n width: 100%;\n }\n\n ${descopeInternalComponentName} {\n display: inline-block;\n box-sizing: border-box;\n user-select: none;\n width: 100%;\n max-width: 100%;\n }\n\n ${descopeInternalComponentName} > .wrapper {\n display: flex;\n width: 100%;\n flex-wrap: wrap;\n }\n\n .${descopeInternalComponentName}-hidden {\n display: none;\n }\n\n`,\n excludeAttrsSync: ['tabindex', 'style', 'error-message'],\n componentName,\n }),\n);\n","import '@vaadin/custom-field';\nimport '@descope-ui/descope-combo-box';\nimport './descope-country-subdivision-city-field-internal';\n\nimport {\n componentName,\n CountrySubdivisionCityFieldClass,\n} from './CountrySubdivisionCityFieldClass';\n\ncustomElements.define(componentName, CountrySubdivisionCityFieldClass);\n\nexport { CountrySubdivisionCityFieldClass, componentName };\n"],"names":["fetchJson","async","url","response","fetch","ok","Error","status","json","data","fetchCountries","baseUrl","fetchSubdivisions","countryIso2","map","code","rest","state_code","fetchCities","stateCode","fetchLabels","labelsUrl","URL","href","fetchCitiesForCountry","componentName","SELECTING","Symbol","resolveTranslation","name","translations","lang","split","escapeHtml","str","String","replace","c","charCodeAt","countryItem","iso2","iso3","displayName","searchTerms","push","escapedIso2","escapedSearchTerms","join","escapedLabel","subdivisionItem","escapedStateCode","cityItem","escapedId","escapedName","comboBoxHTML","id","BaseInputClass","baseSelector","commonAttrs","visibilityAttrs","observedAttrs","CountrySubdivisionCityFieldInternal","observedAttributes","concat","Map","constructor","super","this","innerHTML","querySelector","getAttribute","undefined","Intl","getCanonicalLocales","toUpperCase","trim","filter","Boolean","value","country","subdivision","city","val","parsed","JSON","parse","init","addEventListener","e","isTrusted","firstInvalidCombo","find","combo","classList","contains","checkValidity","focus","renderItem","attributeChangedCallback","attrName","oldValue","newValue","includes","upper","setAttribute","size","getValidity","isRequired","countryMissing","subdivisionMissing","cityMissing","valueMissing","reverse","reportValidity","forEach","customValueTransformFn","item","baseElement","items","i","includeAttrs","mapAttrs","attr","handleFocusEventsDispatching","pendingCountry","pendingSubdivision","pendingCity","shouldLoadSubdivisions","shouldLoadCities","countriesPromise","labelsPromise","subdivisionsPromise","citiesPromise","countries","labels","subdivisions","cities","Promise","allSettled","result","toSelect","countryObj","get","subdivisionType","length","s","setTimeout","selectedItem","subdivisionCode","hasSubdivisions","label","types","subdivisionTypes","entry","_fallback","en","all","console","error","removeAttribute","prevCountry","prevSubdivision","currentIso2","allowed","pinned","filtered","sort","a","b","localeCompare","el","visible","toggle","required","hasAttribute","setCustomValidity","dispatchEvent","Event","bubbles","composed","comboBox","customElements","define","host","selector","internalWrapper","internalComboBoxes","CountrySubdivisionCityFieldClass","componentNameOverride","mappings","hostWidth","property","hostDirection","ComboBoxClass","C","cssVarList","flexDirection","flexGap","itemAlignment","itemMinWidth","itemFlexGrow","itemWidth","proxyProps","inputEvent","proxyParentValidation","superclass","template","document","createElement","appendChild","content","cloneNode","inputElement","shadowRoot","slots","wrappedEleName","style","excludeAttrsSync"],"sourceRoot":""}
1
+ {"version":3,"file":"descope-country-subdivision-city-field.js","mappings":"wQASA,MAAMA,EAAYC,MAAOC,IACvB,MAAMC,QAAiBC,MAAMF,GAC7B,IAAKC,EAASE,GAAI,MAAM,IAAIC,MAAM,iBAAiBH,EAASI,UAAUL,KACtE,MAAMM,QAAaL,EAASK,OAE5B,OAAOA,EAAKC,MAAQD,GAGTE,EAAiBT,MAAOU,GACnCX,EAAU,GAAGW,oBAKFC,EAAoBX,MAAOY,EAAaF,KACnD,IAIE,aAHmBX,EACjB,GAAGW,eAAqBE,wBALvBC,IAAI,EAAGC,UAASC,MAAW,IAAMA,EAAMC,WAAYF,IAQxD,CAAE,MAEA,MAAO,EACT,GAGWG,EAAcjB,MAAOY,EAAaM,EAAWR,IACxDX,EACE,GAAGW,eAAqBE,kBAA4BM,iBAK3CC,EAAcnB,MAAOU,IAChC,MAAMU,EAAY,IAAIC,IAAI,iBAAkB,GAAGX,MAAYY,KAC3D,OAAOvB,EAAUqB,IAGNG,EAAwBvB,MAAOY,EAAaF,IACvDX,EAAU,GAAGW,eAAqBE,iBClCvBY,GAAgB,QAC3B,2CAKIC,EAAYC,OAAO,aAInBC,EAAqB,EAAGC,OAAMC,eAAe,CAAC,GAAKC,IAClDA,IACED,EAAaC,IAASD,EAAaC,EAAKC,MAAM,KAAK,MADxCH,EAMdI,EAAcC,GACbA,EACEC,OAAOD,GAAKE,QAAQ,WAAaC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,GACPC,eAAgB,sBAChBC,MAAO,IAAM,mJAUb,0IAQA,yFAMC,0CAKDC,iBAAkB,CAAC,WAAY,QAAS,iBACxCjM,cAAa,KCxIjB6J,eAAeC,OAAO,EAAeK,E","sources":["webpack://@descope/web-components-ui/../components/descope-country-subdivision-city-field/src/data/dataService.js","webpack://@descope/web-components-ui/../components/descope-country-subdivision-city-field/src/component/descope-country-subdivision-city-field-internal/CountrySubdivisionCityFieldInternal.js","webpack://@descope/web-components-ui/../components/descope-country-subdivision-city-field/src/component/descope-country-subdivision-city-field-internal/index.js","webpack://@descope/web-components-ui/../components/descope-country-subdivision-city-field/src/component/CountrySubdivisionCityFieldClass.js","webpack://@descope/web-components-ui/../components/descope-country-subdivision-city-field/src/component/index.js"],"sourcesContent":["// Data service for country/subdivision/city data.\n//\n// Fetches from the CDN/S3 baseUrl. The URL structure (relative to baseUrl):\n// <baseUrl>/countries.json\n// <baseUrl>/countries/{iso2}/subdivisions.json\n// <baseUrl>/countries/{iso2}/subdivisions/{state_code}/cities.json\n// <baseUrl>/countries/{iso2}/cities.json (all cities for a country, used when subdivision is hidden)\n// <parent-of-baseUrl>/labels.json (shared labels/translations, one level up)\n\nconst fetchJson = async (url) => {\n const response = await fetch(url);\n if (!response.ok) throw new Error(`[dataService] ${response.status} ${url}`);\n const json = await response.json();\n // All files use a { data: [...] } envelope\n return json.data ?? json;\n};\n\nexport const fetchCountries = async (baseUrl) =>\n fetchJson(`${baseUrl}/countries.json`);\n\nconst normalizeSubdivisions = (data) =>\n data.map(({ code, ...rest }) => ({ ...rest, state_code: code }));\n\nexport const fetchSubdivisions = async (countryIso2, baseUrl) => {\n try {\n const data = await fetchJson(\n `${baseUrl}/countries/${countryIso2}/subdivisions.json`,\n );\n return normalizeSubdivisions(data);\n } catch {\n // No subdivisions file means the country has no subdivisions\n return [];\n }\n};\n\nexport const fetchCities = async (countryIso2, stateCode, baseUrl) =>\n fetchJson(\n `${baseUrl}/countries/${countryIso2}/subdivisions/${stateCode}/cities.json`,\n );\n\n// labels.json sits one directory above the language-specific base URL\n// e.g. baseUrl = \".../address/en\" → labels URL = \".../address/labels.json\"\nexport const fetchLabels = async (baseUrl) => {\n const labelsUrl = new URL('../labels.json', `${baseUrl}/`).href;\n return fetchJson(labelsUrl);\n};\n\nexport const fetchCitiesForCountry = async (countryIso2, baseUrl) =>\n fetchJson(`${baseUrl}/countries/${countryIso2}/cities.json`);\n","import { createBaseInputClass } from '@descope-ui/common/base-classes';\nimport {\n getComponentName,\n forwardAttrs,\n} from '@descope-ui/common/components-helpers';\nimport { compose } from '@descope-ui/common/utils';\nimport {\n fetchCountries,\n fetchSubdivisions,\n fetchCities,\n fetchCitiesForCountry,\n fetchLabels,\n} from '../../data/dataService';\n\nexport const componentName = getComponentName(\n 'country-subdivision-city-field-internal',\n);\n\n// Sentinel used in #pendingValue to signal that programmatic item selection is in progress.\n// Prevents cascade-clearing logic in input handlers from firing during programmatic selection.\nconst SELECTING = Symbol('selecting');\n\n// --- Translation ---\n\nconst resolveTranslation = ({ name, translations = {} }, lang) => {\n if (!lang) return name;\n return translations[lang] || translations[lang.split('-')[0]] || name;\n};\n\n// --- HTML Escaping ---\n\nconst escapeHtml = (str) => {\n if (!str) return '';\n return String(str).replace(/[&<>\"']/g, (c) => `&#${c.charCodeAt(0)};`);\n};\n\n// --- Item renderers ---\n\nconst countryItem = ({ name, iso2, iso3, translations, lang }) => {\n const displayName = resolveTranslation({ name, translations }, lang);\n const searchTerms = [displayName, iso2, iso3];\n if (displayName !== name) searchTerms.push(name);\n const escapedIso2 = escapeHtml(iso2);\n const escapedSearchTerms = escapeHtml(searchTerms.join(' '));\n const escapedLabel = escapeHtml(displayName);\n return `<div data-id=\"${escapedIso2}\" data-name=\"${escapedSearchTerms}\" data-label=\"${escapedLabel}\">${escapedLabel}</div>`;\n};\n\nconst subdivisionItem = ({ name, state_code, translations, lang }) => {\n const displayName = resolveTranslation({ name, translations }, lang);\n const searchTerms = [displayName, state_code];\n if (displayName !== name) searchTerms.push(name);\n const escapedStateCode = escapeHtml(state_code);\n const escapedSearchTerms = escapeHtml(searchTerms.join(' '));\n const escapedLabel = escapeHtml(displayName);\n return `<div data-id=\"${escapedStateCode}\" data-name=\"${escapedSearchTerms}\" data-label=\"${escapedLabel}\">${escapedLabel}</div>`;\n};\n\nconst cityItem = ({ name, translations, lang }) => {\n const displayName = resolveTranslation({ name, translations }, lang);\n const searchTerms = [displayName];\n if (displayName !== name) searchTerms.push(name);\n const escapedId = escapeHtml(name);\n const escapedSearchTerms = escapeHtml(searchTerms.join(' '));\n const escapedLabel = escapeHtml(displayName);\n return `<div data-id=\"${escapedId}\" data-name=\"${escapedSearchTerms}\" data-label=\"${escapedLabel}\">${escapedLabel}</div>`;\n};\n\nconst comboBoxHTML = (id) =>\n `<descope-combo-box id=\"${id}\" item-label-path=\"data-name\" item-value-path=\"data-id\" allow-custom-value=\"false\"></descope-combo-box>`;\n\n// --- Base class ---\n\nconst BaseInputClass = createBaseInputClass({\n componentName,\n baseSelector: '',\n});\n\nconst commonAttrs = ['disabled', 'readonly', 'size', 'bordered'];\nconst labelTypeAttrs = [\n 'label-type',\n 'country-label',\n 'subdivision-label',\n 'city-label',\n];\nconst visibilityAttrs = ['hide-country', 'hide-subdivision', 'hide-city'];\nconst countryConfigAttrs = [\n 'default-country',\n 'allowed-countries',\n 'pinned-countries',\n];\nconst placeholderAttrs = [\n 'country-placeholder',\n 'subdivision-placeholder',\n 'city-placeholder',\n];\nconst observedAttrs = [\n ...commonAttrs,\n ...labelTypeAttrs,\n ...visibilityAttrs,\n ...countryConfigAttrs,\n ...placeholderAttrs,\n 'required',\n 'invalid',\n 'data-source-base-url',\n 'lang',\n];\n\nclass RawCountrySubdivisionCityFieldInternal extends BaseInputClass {\n static get observedAttributes() {\n return [].concat(BaseInputClass.observedAttributes || [], observedAttrs);\n }\n\n #countryComboBox;\n #subdivisionComboBox;\n #cityComboBox;\n\n // Whether the subdivision/city field should be shown (data was found for selected country/subdivision)\n #subdivisionVisible = false;\n #cityVisible = false;\n\n // iso2 → country object (populated after countries are loaded)\n #countriesMap = new Map();\n #cachedCountries = null;\n #cachedSubdivisions = null;\n #cachedCities = null;\n #labels = null;\n\n // Value requested programmatically before data has loaded.\n // Applied incrementally as each cascade layer (countries → subdivisions → cities) loads.\n #pendingValue = null;\n\n constructor() {\n super();\n\n this.innerHTML = `\n <div class=\"wrapper\">\n ${comboBoxHTML('country-combo')}\n ${comboBoxHTML('subdivision-combo')}\n ${comboBoxHTML('city-combo')}\n </div>\n `;\n\n this.#countryComboBox = this.querySelector('#country-combo');\n this.#subdivisionComboBox = this.querySelector('#subdivision-combo');\n this.#cityComboBox = this.querySelector('#city-combo');\n\n this.#setupValueTransform();\n this.#setupAttrForwarding();\n }\n\n // --- Attribute getters ---\n\n get #isHideCountry() {\n return this.getAttribute('hide-country') === 'true';\n }\n get #isHideSubdivision() {\n return this.getAttribute('hide-subdivision') === 'true';\n }\n get #isHideCity() {\n return this.getAttribute('hide-city') === 'true';\n }\n get #isNoDataSource() {\n return !this.#baseUrl;\n }\n get #baseUrl() {\n return this.getAttribute('data-source-base-url') || undefined;\n }\n get #lang() {\n const lang = this.getAttribute('lang') || undefined;\n if (!lang) return undefined;\n try {\n const [canonical] = Intl.getCanonicalLocales(lang);\n return canonical;\n } catch {\n return undefined; // invalid BCP47 tag — fall back to English\n }\n }\n get #defaultCountry() {\n return this.getAttribute('default-country')?.toUpperCase() || undefined;\n }\n get #subdivisionLabel() {\n return this.getAttribute('subdivision-label') || undefined;\n }\n get #subdivisionPlaceholder() {\n return this.getAttribute('subdivision-placeholder') || undefined;\n }\n\n get #allowedCountries() {\n return (this.getAttribute('allowed-countries') || '')\n .split(',')\n .map((c) => c.trim().toUpperCase())\n .filter(Boolean);\n }\n\n get #pinnedCountries() {\n return (this.getAttribute('pinned-countries') || '')\n .split(',')\n .map((c) => c.trim().toUpperCase())\n .filter(Boolean);\n }\n\n get #allCombos() {\n return [\n this.#countryComboBox,\n this.#subdivisionComboBox,\n this.#cityComboBox,\n ];\n }\n\n // --- Value ---\n\n get value() {\n const country = this.#isHideCountry\n ? this.#defaultCountry\n : this.#countryComboBox.value || undefined;\n\n const subdivision =\n !this.#isHideSubdivision && this.#subdivisionVisible\n ? this.#subdivisionComboBox.value || undefined\n : undefined;\n\n const city =\n !this.#isHideCity && this.#cityVisible\n ? this.#cityComboBox.value || undefined\n : undefined;\n\n return { country, subdivision, city };\n }\n\n set value(val) {\n if (!val) return;\n let parsed;\n try {\n parsed = typeof val === 'string' ? JSON.parse(val) : val;\n } catch {\n // Invalid JSON — silently ignore to prevent component crash\n return;\n }\n this.#pendingValue = { ...parsed };\n if (this.#baseUrl) this.#loadForPendingValue();\n }\n\n // --- Lifecycle ---\n\n init() {\n this.addEventListener('focus', (e) => {\n if (e.isTrusted) {\n const firstInvalidCombo = this.#allCombos.find(\n (combo) =>\n !combo.classList.contains(`${componentName}-hidden`) &&\n !combo.checkValidity(),\n );\n (firstInvalidCombo || this.#getFirstVisibleCombo())?.focus();\n }\n });\n\n super.init?.();\n\n this.#refreshState();\n this.#setupChangeListeners();\n this.#initData();\n this.#setCombosItemRenderers();\n }\n\n #setCombosItemRenderers() {\n this.#countryComboBox.renderItem = countryItem;\n this.#subdivisionComboBox.renderItem = subdivisionItem;\n this.#cityComboBox.renderItem = cityItem;\n }\n\n attributeChangedCallback(attrName, oldValue, newValue) {\n super.attributeChangedCallback?.(attrName, oldValue, newValue);\n\n if (oldValue === newValue) return;\n\n if (attrName === 'required') {\n this.#updateRequiredOnCombos();\n } else if (\n visibilityAttrs.includes(attrName) ||\n attrName === 'data-source-base-url'\n ) {\n this.#refreshState();\n if (attrName === 'data-source-base-url') this.#initData();\n } else if (attrName === 'default-country') {\n const upper = newValue?.toUpperCase();\n if (upper && upper !== newValue) {\n this.setAttribute('default-country', upper);\n return;\n }\n if (upper && this.#countriesMap.size) {\n this.#onCountrySelected(upper); // countries already loaded — trigger immediately\n } else if (upper && this.#isHideCountry) {\n // hide-country mode: countries may not have been loaded yet (e.g. no default-country at init).\n // Kick off loading now; #loadCountries will call #onCountrySelected once done.\n this.#loadCountries();\n }\n } else if (attrName === 'lang') {\n this.#rerenderOnLangChange();\n } else if (attrName === 'invalid') {\n if (newValue === 'true') this.#handleInvalidCombos();\n } else if (\n attrName === 'allowed-countries' ||\n attrName === 'pinned-countries'\n ) {\n if (!this.#isHideCountry) {\n // Re-render from cache if available to avoid a race condition between two simultaneous\n // fetch calls (one from data-source-base-url, one from the filter attribute change).\n if (this.#cachedCountries) {\n this.#renderCountryItems(this.#cachedCountries);\n } else {\n this.#loadCountries();\n }\n }\n } else if (attrName === 'country-label') {\n this.#setOrRemoveAttr(this.#countryComboBox, 'label', newValue);\n } else if (attrName === 'subdivision-label') {\n this.#setOrRemoveAttr(this.#subdivisionComboBox, 'label', newValue);\n } else if (attrName === 'city-label') {\n this.#setOrRemoveAttr(this.#cityComboBox, 'label', newValue);\n }\n }\n\n // --- Validation ---\n\n getValidity() {\n if (!this.isRequired) return {};\n\n const countryMissing = !this.#isHideCountry && !this.#countryComboBox.value;\n const subdivisionMissing =\n !this.#isHideSubdivision &&\n (this.#isNoDataSource || this.#subdivisionVisible) &&\n !this.#subdivisionComboBox.value;\n const cityMissing =\n !this.#isHideCity &&\n (this.#isNoDataSource || this.#cityVisible) &&\n !this.#cityComboBox.value;\n\n return countryMissing || subdivisionMissing || cityMissing\n ? { valueMissing: true }\n : {};\n }\n\n // Show validation errors on the specific combos that are missing a value.\n // Iterate in reverse so reportValidity's focus() lands on the first invalid combo last.\n #handleInvalidCombos() {\n for (const combo of [...this.#allCombos].reverse()) {\n if (combo.classList.contains(`${componentName}-hidden`)) continue;\n if (!combo.checkValidity()) combo.reportValidity();\n }\n }\n\n // --- Setup ---\n\n #setupValueTransform() {\n // Display only the item name in the input, while data-name includes ISO codes for search\n [\n this.#countryComboBox,\n this.#subdivisionComboBox,\n this.#cityComboBox,\n ].forEach((combo) => {\n combo.customValueTransformFn = (val) => {\n const item = combo.baseElement?.items?.find(\n (i) => i['data-name'] === val,\n );\n return item?.getAttribute('data-label') ?? val;\n };\n });\n }\n\n #setupAttrForwarding() {\n // Forward common attrs and label-type to all combos\n this.#allCombos.forEach((combo) => {\n forwardAttrs(this, combo, {\n includeAttrs: [...commonAttrs, 'label-type'],\n });\n });\n\n // Forward default-country as default-value to let the combo box handle initial selection\n forwardAttrs(this, this.#countryComboBox, {\n includeAttrs: ['default-country'],\n mapAttrs: { 'default-country': 'default-value' },\n });\n\n // Forward per-field placeholders\n [\n [this.#countryComboBox, 'country-placeholder'],\n [this.#subdivisionComboBox, 'subdivision-placeholder'],\n [this.#cityComboBox, 'city-placeholder'],\n ].forEach(([combo, attr]) => {\n forwardAttrs(this, combo, {\n includeAttrs: [attr],\n mapAttrs: { [attr]: 'placeholder' },\n });\n });\n }\n\n #setupChangeListeners() {\n // descope-combo-box dispatches 'input' (not 'change') on selection\n this.#countryComboBox.addEventListener('input', () =>\n this.#handleCountryChange(),\n );\n this.#subdivisionComboBox.addEventListener('input', () =>\n this.#handleSubdivisionChange(),\n );\n this.#cityComboBox.addEventListener('input', () =>\n this.#dispatchInputEvent(),\n );\n\n this.handleFocusEventsDispatching(this.#allCombos);\n }\n\n #initData() {\n // baseUrl is forwarded by the outer component after this element is connected;\n // wait for the attributeChangedCallback('data-source-base-url') to re-trigger.\n if (!this.#baseUrl) return;\n\n if (this.#pendingValue) {\n this.#loadForPendingValue();\n return;\n }\n\n if (!this.#isHideCountry || this.#defaultCountry) {\n // Load countries to populate #countriesMap even when hide-country=true, so that\n // #onCountrySelected can apply the correct subdivision type label for the default country.\n this.#loadCountries();\n }\n }\n\n // --- Programmatic value loading (parallel fetch) ---\n\n async #loadForPendingValue() {\n const {\n country: pendingCountry,\n subdivision: pendingSubdivision,\n city: pendingCity,\n } = this.#pendingValue;\n\n const shouldLoadSubdivisions =\n !!pendingSubdivision && !this.#isHideSubdivision;\n const shouldLoadCities = !!pendingCity && !this.#isHideCity;\n\n const countriesPromise =\n this.#cachedCountries ?? fetchCountries(this.#baseUrl);\n const labelsPromise = this.#labels ?? fetchLabels(this.#baseUrl);\n const subdivisionsPromise =\n shouldLoadSubdivisions && pendingCountry\n ? fetchSubdivisions(pendingCountry, this.#baseUrl)\n : null;\n const citiesPromise =\n shouldLoadCities && pendingCountry\n ? shouldLoadSubdivisions && pendingSubdivision\n ? fetchCities(pendingCountry, pendingSubdivision, this.#baseUrl)\n : fetchCitiesForCountry(pendingCountry, this.#baseUrl)\n : null;\n\n // Fetch everything in parallel; null entries resolve immediately as null\n const [countries, labels, subdivisions, cities] = (\n await Promise.allSettled([\n countriesPromise,\n labelsPromise,\n subdivisionsPromise,\n citiesPromise,\n ])\n ).map((result) => (result.status === 'fulfilled' ? result.value : null));\n\n // Cancelled by a subsequent set value call or user interaction\n if (!this.#pendingValue) return;\n\n if (labels) this.#labels = labels;\n\n // Collect items to select — do this before rendering so we can batch-select below\n const toSelect = [];\n\n if (countries) {\n if (!this.#cachedCountries) {\n this.#cachedCountries = countries;\n this.#renderCountryItems(countries);\n }\n if (pendingCountry && !this.#isHideCountry)\n toSelect.push([this.#countryComboBox, pendingCountry]);\n }\n\n const countryObj = pendingCountry\n ? this.#countriesMap.get(pendingCountry)\n : null;\n if (countryObj?.subdivisionType)\n this.#applySubdivisionType(countryObj.subdivisionType);\n\n if (subdivisions) {\n this.#cachedSubdivisions = subdivisions;\n this.#subdivisionVisible = subdivisions.length > 0;\n if (subdivisions.length > 0) {\n this.#subdivisionComboBox.data = subdivisions.map((s) => ({\n ...s,\n lang: this.#lang,\n }));\n if (pendingSubdivision)\n toSelect.push([this.#subdivisionComboBox, pendingSubdivision]);\n }\n }\n\n if (cities) {\n this.#cityVisible = cities.length > 0;\n if (cities.length > 0) {\n this.#cachedCities = cities;\n this.#cityComboBox.data = cities.map((c) => ({\n ...c,\n lang: this.#lang,\n }));\n if (pendingCity) toSelect.push([this.#cityComboBox, pendingCity]);\n }\n }\n\n this.#refreshState();\n\n // Apply all selections in one batch. #pendingValue is set to SELECTING so that\n // input events fired by selectedItem= don't trigger cascade-clearing in change handlers.\n this.#pendingValue = SELECTING;\n setTimeout(() => {\n if (this.#pendingValue !== SELECTING) return; // cancelled by a new set value call\n for (const [combo, id] of toSelect) {\n const item = combo.items?.find((i) => i['data-id'] === id);\n if (item) combo.selectedItem = item;\n }\n this.#pendingValue = null;\n });\n }\n\n // --- Change handlers ---\n\n #handleCountryChange() {\n if (this.#pendingValue === SELECTING) return; // programmatic selection in progress\n this.#pendingValue = null; // cancel any in-flight fetch\n this.#resetSubdivision();\n this.#resetCity();\n this.#onCountrySelected(this.#countryComboBox.value);\n this.#dispatchInputEvent();\n }\n\n #handleSubdivisionChange() {\n if (this.#pendingValue === SELECTING) return; // programmatic selection in progress\n this.#pendingValue = null; // cancel any in-flight fetch\n const subdivisionCode = this.#subdivisionComboBox.value;\n this.#resetCity();\n\n if (!this.#isHideCity && subdivisionCode) {\n const countryIso2 = this.#countryComboBox.value;\n if (countryIso2) this.#loadCities(countryIso2, subdivisionCode);\n }\n this.#dispatchInputEvent();\n }\n\n // --- Country selection ---\n\n #onCountrySelected(countryIso2) {\n if (!countryIso2) return;\n\n const country = this.#countriesMap.get(countryIso2);\n if (!country) return;\n\n const { hasSubdivisions, subdivisionType } = country;\n\n if (!this.#isHideSubdivision && hasSubdivisions) {\n this.#applySubdivisionType(subdivisionType);\n this.#loadSubdivisions(countryIso2);\n } else if (!this.#isHideCity) {\n this.#loadCities(countryIso2);\n }\n }\n\n // Apply subdivisionType as label/placeholder, but only when not overridden by an explicit attribute.\n #applySubdivisionType(subdivisionType) {\n const label = this.#resolveSubdivisionTypeLabel(subdivisionType);\n if (!this.#subdivisionLabel)\n this.#setOrRemoveAttr(this.#subdivisionComboBox, 'label', label || null);\n if (!this.#subdivisionPlaceholder)\n this.#setOrRemoveAttr(\n this.#subdivisionComboBox,\n 'placeholder',\n label || null,\n );\n }\n\n #resolveSubdivisionTypeLabel(subdivisionType) {\n const types = this.#labels?.subdivisionTypes;\n const entry = types?.[subdivisionType] ?? types?._fallback;\n if (!entry) return subdivisionType;\n const lang = this.#lang;\n return (\n (lang && (entry[lang] || entry[lang.split('-')[0]])) ||\n entry.en ||\n subdivisionType\n );\n }\n\n // --- Data loading ---\n\n async #loadLabels() {\n try {\n this.#labels = await fetchLabels(this.#baseUrl);\n } catch {\n // Labels are optional; fall back to raw subdivisionType name\n }\n }\n\n async #loadCountries() {\n if (!this.#baseUrl) return;\n this.#countryComboBox.setAttribute('loading', 'true');\n try {\n const [countries] = await Promise.all([\n fetchCountries(this.#baseUrl),\n this.#loadLabels(),\n ]);\n this.#cachedCountries = countries;\n this.#renderCountryItems(countries);\n // Skip defaultCountry if a programmatic set value is in flight\n if (!this.#pendingValue && this.#defaultCountry)\n this.#onCountrySelected(this.#defaultCountry);\n } catch (e) {\n console.error(`[${componentName}] Failed to load countries`, e);\n } finally {\n this.#countryComboBox.removeAttribute('loading');\n }\n }\n\n async #loadSubdivisions(countryIso2) {\n this.#setVisible(this.#subdivisionComboBox, true);\n this.#subdivisionComboBox.setAttribute('loading', 'true');\n try {\n const subdivisions = await fetchSubdivisions(countryIso2, this.#baseUrl);\n this.#cachedSubdivisions = subdivisions;\n this.#subdivisionVisible = subdivisions.length > 0;\n this.#refreshState();\n\n if (subdivisions.length > 0) {\n this.#subdivisionComboBox.data = subdivisions.map((s) => ({\n ...s,\n lang: this.#lang,\n }));\n } else if (!this.#isHideCity) {\n this.#loadCities(countryIso2);\n }\n } catch (e) {\n console.error(\n `[${componentName}] Failed to load subdivisions for ${countryIso2}`,\n e,\n );\n this.#subdivisionVisible = false;\n this.#applyVisibility();\n } finally {\n this.#subdivisionComboBox.removeAttribute('loading');\n }\n }\n\n // stateCode is optional: when omitted, loads all cities for the country\n async #loadCities(countryIso2, stateCode) {\n this.#cityComboBox.setAttribute('loading', 'true');\n try {\n const cities = await (stateCode\n ? fetchCities(countryIso2, stateCode, this.#baseUrl)\n : fetchCitiesForCountry(countryIso2, this.#baseUrl));\n this.#cityVisible = cities.length > 0;\n this.#refreshState();\n if (cities.length > 0) {\n this.#cachedCities = cities;\n this.#cityComboBox.data = cities.map((c) => ({\n ...c,\n lang: this.#lang,\n }));\n }\n } catch (e) {\n console.error(\n `[${componentName}] Failed to load cities for ${countryIso2}${stateCode ? `/${stateCode}` : ''}`,\n e,\n );\n } finally {\n this.#cityComboBox.removeAttribute('loading');\n }\n }\n\n #rerenderOnLangChange() {\n if (this.#cachedCountries) {\n const prevCountry = this.#countryComboBox.value;\n this.#renderCountryItems(this.#cachedCountries);\n if (prevCountry) this.#selectItemById(this.#countryComboBox, prevCountry);\n }\n if (this.#cachedSubdivisions && this.#subdivisionVisible) {\n const prevSubdivision = this.#subdivisionComboBox.value;\n this.#subdivisionComboBox.data = this.#cachedSubdivisions.map((s) => ({\n ...s,\n lang: this.#lang,\n }));\n if (prevSubdivision)\n this.#selectItemById(this.#subdivisionComboBox, prevSubdivision);\n }\n if (this.#cachedCities && this.#cityVisible) {\n const prevCity = this.#cityComboBox.value;\n this.#cityComboBox.data = this.#cachedCities.map((c) => ({\n ...c,\n lang: this.#lang,\n }));\n if (prevCity) this.#selectItemById(this.#cityComboBox, prevCity);\n }\n // Re-apply translated subdivision type label for the new lang\n const currentIso2 = this.#countryComboBox.value;\n if (currentIso2) {\n const country = this.#countriesMap.get(currentIso2);\n if (country?.subdivisionType)\n this.#applySubdivisionType(country.subdivisionType);\n }\n }\n\n // --- Country item rendering ---\n\n #renderCountryItems(countries) {\n const result = this.#applyCountryFilters(countries);\n this.#countryComboBox.data = result.map((c) => ({\n ...c,\n // Include the translated name in the data for search purposes, but not in the label which is rendered by renderItem\n lang: this.#lang,\n }));\n this.#countriesMap = new Map(countries.map((c) => [c.iso2, c]));\n }\n\n #applyCountryFilters(countries) {\n const allowed = this.#allowedCountries;\n const pinned = this.#pinnedCountries;\n\n let filtered = allowed.length\n ? countries.filter((c) => allowed.includes(c.iso2))\n : [...countries];\n\n filtered.sort((a, b) =>\n resolveTranslation(a, this.#lang).localeCompare(\n resolveTranslation(b, this.#lang),\n this.#lang,\n ),\n );\n\n if (!pinned.length) return filtered;\n\n const pinnedItems = pinned\n .map((iso2) => filtered.find((c) => c.iso2 === iso2))\n .filter(Boolean);\n const rest = filtered.filter((c) => !pinned.includes(c.iso2));\n return [...pinnedItems, ...rest];\n }\n\n // --- Visibility & required ---\n\n #applyVisibility() {\n this.#setVisible(this.#countryComboBox, !this.#isHideCountry);\n this.#setVisible(\n this.#subdivisionComboBox,\n !this.#isHideSubdivision &&\n (this.#isNoDataSource || this.#subdivisionVisible),\n );\n this.#setVisible(\n this.#cityComboBox,\n !this.#isHideCity && (this.#isNoDataSource || this.#cityVisible),\n );\n }\n\n #setVisible(el, visible) {\n el?.classList.toggle(`${componentName}-hidden`, !visible);\n }\n\n #updateRequiredOnCombos() {\n const required = this.hasAttribute('required') ? 'true' : null;\n this.#setOrRemoveAttr(\n this.#countryComboBox,\n 'required',\n !this.#isHideCountry ? required : null,\n );\n this.#setOrRemoveAttr(\n this.#subdivisionComboBox,\n 'required',\n !this.#isHideSubdivision &&\n (this.#isNoDataSource || this.#subdivisionVisible)\n ? required\n : null,\n );\n this.#setOrRemoveAttr(\n this.#cityComboBox,\n 'required',\n !this.#isHideCity && (this.#isNoDataSource || this.#cityVisible)\n ? required\n : null,\n );\n }\n\n #refreshState() {\n this.#applyVisibility();\n this.#updateRequiredOnCombos();\n // Re-evaluate validity so that the form knows when newly-visible required fields become empty.\n // e.g. subdivision becomes required after a country with states is selected.\n this.setCustomValidity('');\n }\n\n // --- Reset helpers ---\n\n #resetSubdivision() {\n this.#subdivisionComboBox.value = '';\n this.#subdivisionComboBox.data = [];\n this.#subdivisionVisible = false;\n // Clear any dynamically set label/placeholder from subdivisionType\n if (!this.#subdivisionLabel)\n this.#subdivisionComboBox.removeAttribute('label');\n if (!this.#subdivisionPlaceholder)\n this.#subdivisionComboBox.removeAttribute('placeholder');\n this.#refreshState();\n }\n\n #resetCity() {\n this.#cityComboBox.value = '';\n this.#cityComboBox.data = [];\n this.#cachedCities = null;\n this.#cityVisible = false;\n this.#refreshState();\n }\n\n // --- Utility helpers ---\n\n #dispatchInputEvent() {\n this.dispatchEvent(new Event('input', { bubbles: true, composed: true }));\n }\n\n #setOrRemoveAttr(el, attr, value) {\n if (value) el.setAttribute(attr, value);\n else el.removeAttribute(attr);\n }\n\n #getFirstVisibleCombo() {\n return this.#allCombos.find(\n (combo) => !combo.classList.contains(`${componentName}-hidden`),\n );\n }\n\n #selectItemById(comboBox, id) {\n // Defer the lookup so MutationObserver has time to populate comboBox.items\n setTimeout(() => {\n const item = comboBox.items?.find((i) => i['data-id'] === id);\n if (item) comboBox.selectedItem = item;\n });\n }\n}\n\nexport const CountrySubdivisionCityFieldInternal = compose()(\n RawCountrySubdivisionCityFieldInternal,\n);\n","import {\n CountrySubdivisionCityFieldInternal,\n componentName,\n} from './CountrySubdivisionCityFieldInternal';\n\ncustomElements.define(componentName, CountrySubdivisionCityFieldInternal);\n","import {\n createStyleMixin,\n draggableMixin,\n createProxy,\n proxyInputMixin,\n componentNameValidationMixin,\n} from '@descope-ui/common/components-mixins';\nimport {\n getComponentName,\n forwardAttrs,\n syncAttrs,\n} from '@descope-ui/common/components-helpers';\nimport { compose } from '@descope-ui/common/utils';\nimport { ComboBoxClass } from '@descope-ui/descope-combo-box/class';\nimport { componentName as descopeInternalComponentName } from './descope-country-subdivision-city-field-internal/CountrySubdivisionCityFieldInternal';\n\nexport const componentName = getComponentName('country-subdivision-city-field');\n\nconst customMixin = (superclass) =>\n class CountrySubdivisionCityFieldMixinClass extends superclass {\n init() {\n super.init?.();\n\n const template = document.createElement('template');\n\n template.innerHTML = `\n <${descopeInternalComponentName}\n tabindex=\"-1\"\n ></${descopeInternalComponentName}>\n `;\n\n this.baseElement.appendChild(template.content.cloneNode(true));\n\n this.inputElement = this.shadowRoot.querySelector(\n descopeInternalComponentName,\n );\n\n forwardAttrs(this, this.inputElement, {\n includeAttrs: [\n 'size',\n 'bordered',\n 'required',\n 'label-type',\n 'disabled',\n 'readonly',\n 'hide-country',\n 'hide-subdivision',\n 'hide-city',\n 'default-country',\n 'allowed-countries',\n 'pinned-countries',\n 'country-label',\n 'subdivision-label',\n 'city-label',\n 'country-placeholder',\n 'subdivision-placeholder',\n 'city-placeholder',\n 'data-source-base-url',\n 'lang',\n 'invalid',\n ],\n });\n\n // Sync invalid attribute bidirectionally so external validation feedback propagates\n syncAttrs(this, this.inputElement, { includeAttrs: ['invalid'] });\n }\n };\n\nconst host = { selector: () => ':host' };\n\nconst internalWrapper = {\n selector: `${descopeInternalComponentName} > .wrapper`,\n};\n\nconst internalComboBoxes = {\n selector: `${descopeInternalComponentName} > .wrapper > descope-combo-box`,\n};\n\nexport const CountrySubdivisionCityFieldClass = compose(\n createStyleMixin({\n componentNameOverride: getComponentName('input-wrapper'),\n }),\n createStyleMixin({\n mappings: {\n hostWidth: { ...host, property: 'width' },\n hostDirection: [\n { ...host, property: 'direction' },\n {\n ...internalComboBoxes,\n property: ComboBoxClass.cssVarList.hostDirection,\n },\n ],\n flexDirection: { ...internalWrapper, property: 'flex-direction' },\n flexGap: { ...internalWrapper, property: 'gap' },\n itemAlignment: { ...internalWrapper, property: 'align-items' },\n itemMinWidth: { ...internalComboBoxes, property: 'min-width' },\n itemFlexGrow: { ...internalComboBoxes, property: 'flex-grow' },\n itemWidth: {\n ...internalComboBoxes,\n property: ComboBoxClass.cssVarList.hostWidth,\n },\n },\n }),\n draggableMixin,\n proxyInputMixin({\n proxyProps: ['value'],\n inputEvent: 'input',\n proxyParentValidation: true,\n }),\n componentNameValidationMixin,\n customMixin,\n)(\n createProxy({\n slots: [],\n wrappedEleName: 'vaadin-custom-field',\n style: () => `\n :host {\n display: inline-flex;\n max-width: 100%;\n }\n vaadin-custom-field {\n line-height: unset;\n width: 100%;\n }\n\n ${descopeInternalComponentName} {\n display: inline-block;\n box-sizing: border-box;\n user-select: none;\n width: 100%;\n max-width: 100%;\n }\n\n ${descopeInternalComponentName} > .wrapper {\n display: flex;\n width: 100%;\n flex-wrap: wrap;\n }\n\n .${descopeInternalComponentName}-hidden {\n display: none;\n }\n\n`,\n excludeAttrsSync: ['tabindex', 'style', 'error-message'],\n componentName,\n }),\n);\n","import '@vaadin/custom-field';\nimport '@descope-ui/descope-combo-box';\nimport './descope-country-subdivision-city-field-internal';\n\nimport {\n componentName,\n CountrySubdivisionCityFieldClass,\n} from './CountrySubdivisionCityFieldClass';\n\ncustomElements.define(componentName, CountrySubdivisionCityFieldClass);\n\nexport { CountrySubdivisionCityFieldClass, componentName };\n"],"names":["fetchJson","async","url","response","fetch","ok","Error","status","json","data","fetchCountries","baseUrl","fetchSubdivisions","countryIso2","map","code","rest","state_code","fetchCities","stateCode","fetchLabels","labelsUrl","URL","href","fetchCitiesForCountry","componentName","SELECTING","Symbol","resolveTranslation","name","translations","lang","split","escapeHtml","str","String","replace","c","charCodeAt","countryItem","iso2","iso3","displayName","searchTerms","push","escapedIso2","escapedSearchTerms","join","escapedLabel","subdivisionItem","escapedStateCode","cityItem","escapedId","comboBoxHTML","id","BaseInputClass","baseSelector","commonAttrs","visibilityAttrs","observedAttrs","CountrySubdivisionCityFieldInternal","observedAttributes","concat","Map","constructor","super","this","innerHTML","querySelector","getAttribute","undefined","canonical","Intl","getCanonicalLocales","toUpperCase","trim","filter","Boolean","value","country","subdivision","city","val","parsed","JSON","parse","init","addEventListener","e","isTrusted","firstInvalidCombo","find","combo","classList","contains","checkValidity","focus","renderItem","attributeChangedCallback","attrName","oldValue","newValue","includes","upper","setAttribute","size","getValidity","isRequired","countryMissing","subdivisionMissing","cityMissing","valueMissing","reverse","reportValidity","forEach","customValueTransformFn","item","baseElement","items","i","includeAttrs","mapAttrs","attr","handleFocusEventsDispatching","pendingCountry","pendingSubdivision","pendingCity","shouldLoadSubdivisions","shouldLoadCities","countriesPromise","labelsPromise","subdivisionsPromise","citiesPromise","countries","labels","subdivisions","cities","Promise","allSettled","result","toSelect","countryObj","get","subdivisionType","length","s","setTimeout","selectedItem","subdivisionCode","hasSubdivisions","label","types","subdivisionTypes","entry","_fallback","en","all","console","error","removeAttribute","prevCountry","prevSubdivision","prevCity","currentIso2","allowed","pinned","filtered","sort","a","b","localeCompare","el","visible","toggle","required","hasAttribute","setCustomValidity","dispatchEvent","Event","bubbles","composed","comboBox","customElements","define","host","selector","internalWrapper","internalComboBoxes","CountrySubdivisionCityFieldClass","componentNameOverride","mappings","hostWidth","property","hostDirection","ComboBoxClass","C","cssVarList","flexDirection","flexGap","itemAlignment","itemMinWidth","itemFlexGrow","itemWidth","proxyProps","inputEvent","proxyParentValidation","superclass","template","document","createElement","appendChild","content","cloneNode","inputElement","shadowRoot","slots","wrappedEleName","style","excludeAttrsSync"],"sourceRoot":""}