1"use strict";(self.webpackChunktwilio_com_frontend=self.webpackChunktwilio_com_frontend||[]).push([[216],{3216:function(e,t,r){r.d(t,{registerPricingTypeAhaeadSelector:function(){return d}});var n=r(7519);const a=["us","in","au","gb","ca","br","fr","de","jp"];function i(e){const{typeAheadDropdown:t,country:r,index:a,currentInput:i,typeAheadCurrentText:o}=e,{name:c,flag:s,countryUrl:u}=r,d=i?function(e,t){const r=new RegExp(t,"gi");return e.replace(r,`<em>${t}</em>`)}(c,i):c,l=document.createElement("li"),p=document.createElement(c===o?"p":"a"),f=document.createElement("span"),h=document.createElement("img"),m=document.createElement("span");0===a&&p.classList.add("active"),c!==o&&(p.href=u),c===o&&p.setAttribute("aria-current","page"),h.src=s.source,h.setAttribute("alt",""),f.classList.add("pricing-type-ahead-flag"),f.setAttribute("role","presentation"),f.appendChild(h),m.classList.add("pricing-type-ahead-location"),m.innerHTML=n.A.sanitize(d),p.classList.add("pricing-type-ahead-option"),p.appendChild(f),p.appendChild(m),l.appendChild(p),t.appendChild(l),p.addEventListener("keydown",e=>{if(!e.shiftKey&&"Tab"===e.key){const e=t.querySelectorAll("li").length;if(a===e-1){const e=t?.closest(".pricing-type-ahead-select")?.querySelector("input");if(!e)return;e.value="",e.classList.remove("focus"),t.setAttribute("aria-hidden","true")}}})}function o(e,t,r,n){if(t.querySelectorAll("li").forEach(e=>e.remove()),r&&n){const a=r?.querySelector("input")?.value??"";c(e).forEach((e,r)=>{i({typeAheadDropdown:t,country:e,index:r,currentInput:a,typeAheadCurrentText:n})})}}function c(e){return[...e.filter(e=>a.includes(e.isoCode)).sort((e,t)=>a.indexOf(e.isoCode)-a.indexOf(t.isoCode)),...e.filter(e=>!a.includes(e.isoCode)).sort((e,t)=>e.name&&t.name?e.name.toLowerCase().trim().localeCompare(t.name.toLowerCase().trim()):0)]}function s(e,t,r){const n=t.querySelectorAll("li"),a=n.length;if(a<2)return;const i=t.querySelector(".active"),o=i?.parentElement;if(!o)return;const c=o.parentElement?.children??[],s=Array.from(c).indexOf(o),u="up"===e?s-1:s+1;if("up"===e&&0===s||"down"===e&&s===a-1)return;const d=n[u]?.querySelector(".pricing-type-ahead-option"),l=r===d?.innerHTML?"page":"true";i.classList.remove("active"),i.removeAttribute("aria-current"),d?.classList.add("active"),d?.setAttribute("aria-current",l),n[u]?.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})}function u(e,t){e.value="",e.classList.remove("focus"),t?.setAttribute("aria-hidden","true")}function d(){document.querySelectorAll(".pricing-type-ahead-selector").forEach(e=>{const t=e.querySelector("input"),r=e.querySelector(".pricing-type-ahead-dropdown"),n=e.querySelector(".pricing-type-ahead-current"),a=n?.querySelector(".pricing-type-ahead-location")?.innerHTML??"",{countries:d,maxLength:l}=e.dataset;if(!d||!l)return;const p=JSON.parse(d);r&&t&&(t.addEventListener("focusin",()=>{t.value="",t.classList.add("focus"),r?.setAttribute("aria-hidden","false"),r&&o(p,r,e,a)}),t.addEventListener("focusout",e=>{e.relatedTarget&&e.relatedTarget instanceof HTMLElement&&e.relatedTarget.classList.contains("pricing-type-ahead-option")||u(t,r)}),t.addEventListener("input",t=>{const n=t.currentTarget.value,s=new Set(function(e,t){return e.filter(e=>e.isoCode.toLowerCase()===t.toLowerCase()).map(e=>e)}(p,n).concat(function(e,t){return e.filter(e=>!!e.name&&e.name.toLowerCase().startsWith(t.toLowerCase()))}(p,n),function(e,t){return e.filter(e=>!!e.name&&e.name.toLowerCase().includes(t.toLowerCase()))}(p,n)));r?.setAttribute("aria-hidden",0===s.size?"true":"false"),r&&o(p,r,e),s.size&&c(Array.from(s.values())).forEach((e,t)=>i({typeAheadDropdown:r,country:e,index:t,currentInput:n,typeAheadCurrentText:a}))}),a&&t.addEventListener("keydown",e=>function(e,t,r){const n=e?.querySelector(".active"),a=n?.getAttribute("href");switch(r.key){case"ArrowUp":case"Up":r.preventDefault(),s("up",e,t);break;case"ArrowDown":case"Down":r.preventDefault(),s("down",e,t);break;case"Enter":if(!n&&!a)break;n?.click()}}(r,a,e)),r.addEventListener("mouseover",e=>{if(!(e.target&&e.target instanceof HTMLElement&&e.target.classList.contains("pricing-type-ahead-option")))return;const t=r.querySelector(".active");t?.classList.remove("active"),e.target.classList.add("active")}),window.addEventListener("click",e=>{e.target.closest(".pricing-type-ahead-selector")||"true"===r.getAttribute("aria-hidden")||u(t,r)}))})}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.