From 52a1cf6809ee743e3f6ca154299e3515999ae2ff Mon Sep 17 00:00:00 2001 From: Doxa Maps Date: Mon, 28 Sep 2026 13:30:22 +0000 Subject: [PATCH] UPG-100: the packet fetch carries language + GSEC, and region ids fold diacritics MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TWO PREPARATIONS FOR THE GENERATED PROFILE DESCRIPTION (Driver brief A1.5 col 2). 1. THE FETCH. Both packet fetch sites (:1363, :1588) requested slug,name,country_code,population,religion,image_url. describeGroup needs the language and a reachedness level, so primary_language and imb_gsec are added. Both are existing API fields — poster-wall:171 already fetches primary_language and sources.json:43 lists imb_gsec — so this adds no new API surface. Verified they survive normalizeRecords, which is non-destructive ({...raw}). GSEC and not EvangelicalLevel because GSEC is a NUMBER. EvangelicalLevel is English prose from the API ("2% or Greater but Less than 5%"), so interpolating it would leave every non-English packet half-English in its widest column. sr measured both across 12,379 rows; I re-derived the GSEC distribution independently (266/6573/269/199/1839/1428/1805) and confirmed that no GSEC description mentions 0.1%, which is why "frontier" cannot be said from this field and the wording stops at the 2% line the funnel page already states. 2. REGION IDS FOLD DIACRITICS. legend-tree.js built an id with .toLowerCase().replace(/[^a-z0-9]+/g,'-'), which DELETES a combining mark rather than folding it: Gujarāt became 'region-gujar-t', a different id from 'region-gujarat'. Nothing is broken today — the labels are regionFor()'s fixed ASCII set and nothing joins on the id — but the brief's whole point is that a fork brings its own set and names its own regions, and the first accented label would split one region in two with no error and no empty state. Same class gospel measured joining admin-to-list.json: a naive fold matched 514 of 1009 rows and lost THREE whole zones while every surviving zone still looked populated. A join that returns half is more dangerous than one that returns nothing. Fixed at the fold, not by enumerating the spellings we know. Verified behaviour-preserving: Africa -> region-africa unchanged, and Gujarāt and Gujarat now produce the same id. --- .../my-upg-100-list/data/legend-tree.js | 10 +++++++++- plugin-designs/my-upg-100-list/upg-100-list.vue | 16 ++++++++++++++-- public/dx-maps/doxa-maps-spa/manifest.json | 8 ++++---- public/dx-maps/manifest.json | 8 ++++---- .../dx-maps/my-upg-100-list/my-upg-100-list.js | 4 ++-- .../my-upg-100-list/poster-wall/index.html | 2 +- .../my-upg-100-list/upg-100-list/index.html | 2 +- .../my-upg-100-list/upg-100-mfe/index.html | 2 +- 8 files changed, 36 insertions(+), 16 deletions(-) diff --git a/plugin-designs/my-upg-100-list/data/legend-tree.js b/plugin-designs/my-upg-100-list/data/legend-tree.js index 54bf1e97b..f3228563d 100644 --- a/plugin-designs/my-upg-100-list/data/legend-tree.js +++ b/plugin-designs/my-upg-100-list/data/legend-tree.js @@ -312,7 +312,15 @@ export function buildLegendNodes(clusters, opts = {}) { .map(([label, children]) => { children.sort((a, b) => (b.count || 0) - (a.count || 0)); const node = { - id: 'region-' + label.toLowerCase().replace(/[^a-z0-9]+/g, '-'), + // ★ FOLD DIACRITICS BEFORE STRIPPING, or the mark is DELETED and the id silently becomes a + // different id: Gujarāt -> 'region-gujar-t', not 'region-gujarat'. Today's labels are the + // fixed ASCII set from regionFor(), so nothing is broken — but the brief's whole point is that + // a fork brings its OWN people-group set and names its own regions, and the first accented + // label would split one region into two with no error and no empty state. Same class gospel + // measured joining admin-to-list.json: a naive fold matched 514 of 1009 rows and lost THREE + // whole zones, while every surviving zone still looked populated. Fix the class, not the six + // spellings we happen to know. + id: 'region-' + label.normalize('NFD').replace(/\p{Mn}/gu, '').toLowerCase().replace(/[^a-z0-9]+/g, '-'), label, count: children.reduce((n, c) => n + (c.count || 0), 0), children, diff --git a/plugin-designs/my-upg-100-list/upg-100-list.vue b/plugin-designs/my-upg-100-list/upg-100-list.vue index beccc5777..e342459da 100644 --- a/plugin-designs/my-upg-100-list/upg-100-list.vue +++ b/plugin-designs/my-upg-100-list/upg-100-list.vue @@ -1360,7 +1360,13 @@ watch(packetPrints.exportState, (st) => { // membership. async function packetRecords(zone) { if (!API_BASE) throw new Error('no API configured'); - const fields = 'slug,name,country_code,population,religion,image_url'; + // ★ primary_language + imb_gsec FEED THE GENERATED PROFILE DESCRIPTION (Driver brief A1.5 col 2, + // 2026-09-28). describeGroup builds a localized sentence — who, where, what language, how reached — + // and GSEC is the only reachedness field that is a NUMBER: EvangelicalLevel is English prose from the + // API ('2% or Greater but Less than 5%'), so interpolating it would leave every non-English packet + // half-English in its widest column (sr measured this across 12,379 rows). primary_language is the + // same field poster-wall already fetches (:171), so this adds no new API surface. + const fields = 'slug,name,country_code,population,religion,image_url,primary_language,imb_gsec'; const resp = await fetch(`${API_BASE}/api/people-groups/list?fields=${fields}&lang=${packetLang()}`, { cache: 'no-store' }); if (!resp.ok) throw new Error(`people-groups fetch failed (${resp.status})`); @@ -1585,7 +1591,13 @@ async function selectionAsList() { const lists = selectedLists(); if (!lists.length) throw new Error('nothing selected'); if (!API_BASE) throw new Error('no API configured'); - const fields = 'slug,name,country_code,population,religion,image_url'; + // ★ primary_language + imb_gsec FEED THE GENERATED PROFILE DESCRIPTION (Driver brief A1.5 col 2, + // 2026-09-28). describeGroup builds a localized sentence — who, where, what language, how reached — + // and GSEC is the only reachedness field that is a NUMBER: EvangelicalLevel is English prose from the + // API ('2% or Greater but Less than 5%'), so interpolating it would leave every non-English packet + // half-English in its widest column (sr measured this across 12,379 rows). primary_language is the + // same field poster-wall already fetches (:171), so this adds no new API surface. + const fields = 'slug,name,country_code,population,religion,image_url,primary_language,imb_gsec'; const resp = await fetch(`${API_BASE}/api/people-groups/list?fields=${fields}&lang=${packetLang()}`, { cache: 'no-store' }); if (!resp.ok) throw new Error(`people-groups fetch failed (${resp.status})`); diff --git a/public/dx-maps/doxa-maps-spa/manifest.json b/public/dx-maps/doxa-maps-spa/manifest.json index 41f21965e..91dc8830b 100644 --- a/public/dx-maps/doxa-maps-spa/manifest.json +++ b/public/dx-maps/doxa-maps-spa/manifest.json @@ -838,7 +838,7 @@ "bundle": "my-upg-100-list", "scriptUrl": "./my-upg-100-list/my-upg-100-list.js", "output": "dx-maps/my-upg-100-list/my-upg-100-list.js", - "integrity": "sha384-Q6V89QI5+oh+vUZq/j9xHpXG42SsquWy5wTn5JAZAuO45L59oNwt4e3xdyIoWBg0", + "integrity": "sha384-NaOKQDpKIpAQuTR9+wvjMSfGd6ss0dEOCGVqk4CS5INgfE+elUXlyPJ4z/PhfEkX", "elements": [ "my-upg-100-list-map" ], @@ -861,7 +861,7 @@ "scriptUrl": "./my-upg-100-list/my-upg-100-list.js", "embed": { "iframe": "", - "script": "\n\n" + "script": "\n\n" } }, { @@ -877,7 +877,7 @@ "scriptUrl": "./my-upg-100-list/my-upg-100-list.js", "embed": { "iframe": "", - "script": "\n\n\n\n" + "script": "\n\n\n\n" } }, { @@ -893,7 +893,7 @@ "scriptUrl": "./my-upg-100-list/my-upg-100-list.js", "embed": { "iframe": "", - "script": "\n\n\n\n" + "script": "\n\n\n\n" } } ] diff --git a/public/dx-maps/manifest.json b/public/dx-maps/manifest.json index 41f21965e..91dc8830b 100644 --- a/public/dx-maps/manifest.json +++ b/public/dx-maps/manifest.json @@ -838,7 +838,7 @@ "bundle": "my-upg-100-list", "scriptUrl": "./my-upg-100-list/my-upg-100-list.js", "output": "dx-maps/my-upg-100-list/my-upg-100-list.js", - "integrity": "sha384-Q6V89QI5+oh+vUZq/j9xHpXG42SsquWy5wTn5JAZAuO45L59oNwt4e3xdyIoWBg0", + "integrity": "sha384-NaOKQDpKIpAQuTR9+wvjMSfGd6ss0dEOCGVqk4CS5INgfE+elUXlyPJ4z/PhfEkX", "elements": [ "my-upg-100-list-map" ], @@ -861,7 +861,7 @@ "scriptUrl": "./my-upg-100-list/my-upg-100-list.js", "embed": { "iframe": "", - "script": "\n\n" + "script": "\n\n" } }, { @@ -877,7 +877,7 @@ "scriptUrl": "./my-upg-100-list/my-upg-100-list.js", "embed": { "iframe": "", - "script": "\n\n\n\n" + "script": "\n\n\n\n" } }, { @@ -893,7 +893,7 @@ "scriptUrl": "./my-upg-100-list/my-upg-100-list.js", "embed": { "iframe": "", - "script": "\n\n\n\n" + "script": "\n\n\n\n" } } ] diff --git a/public/dx-maps/my-upg-100-list/my-upg-100-list.js b/public/dx-maps/my-upg-100-list/my-upg-100-list.js index 29a56dcf4..8ae186185 100644 --- a/public/dx-maps/my-upg-100-list/my-upg-100-list.js +++ b/public/dx-maps/my-upg-100-list/my-upg-100-list.js @@ -811,10 +811,10 @@ .mcb.dark.active{background:#4e594f;color:#92b195;} @media(max-width:767px){.mcb{width:36px;height:36px;}} .mcb--square{ border-radius:4px; } -`,"map-control-button"),(t,o)=>(q(),ae("button",{class:Ge(["mcb",{dark:e.isDark,active:e.active,"mcb--square":e.shape==="square"}]),title:e.title,"aria-label":e.title||void 0,disabled:e.disabled,onClick:o[0]||(o[0]=n=>t.$emit("click"))},[Rn(t.$slots,"default")],10,sw))}},lw={__name:"ZoomInButton",props:{map:{type:Object,default:null},isDark:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1}},setup(e){const{t}=xt(),o=e;function n(){var a;o.disabled||(a=o.map)==null||a.zoomIn()}return(a,r)=>(q(),dt(wn,{"data-control":"zoom-in","is-dark":e.isDark,disabled:e.disabled,title:me(t)("buttons.zoomIn"),onClick:n},{default:Xt(()=>[...r[0]||(r[0]=[R("span",{style:{"font-size":"20px","line-height":"1","font-weight":"600"}},"+",-1)])]),_:1},8,["is-dark","disabled","title"]))}},cw={__name:"ZoomOutButton",props:{map:{type:Object,default:null},isDark:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1}},setup(e){const{t}=xt(),o=e;function n(){var a;o.disabled||(a=o.map)==null||a.zoomOut()}return(a,r)=>(q(),dt(wn,{"data-control":"zoom-out","is-dark":e.isDark,disabled:e.disabled,title:me(t)("buttons.zoomOut"),onClick:n},{default:Xt(()=>[...r[0]||(r[0]=[R("span",{style:{"font-size":"22px","line-height":"1","font-weight":"600"}},"−",-1)])]),_:1},8,["is-dark","disabled","title"]))}},uw={__name:"LocationButton",props:{map:{type:Object,default:null},isDark:{type:Boolean,default:!1},center:{type:Array,default:()=>[20,10]},zoom:{type:Number,default:1.8},userZoom:{type:Number,default:10}},setup(e){const{t}=xt(),o=e;function n(){var r;(r=o.map)==null||r.flyTo({center:o.center,zoom:o.zoom,duration:1200})}function a(){if(o.map){if(typeof navigator>"u"||!navigator.geolocation){n();return}navigator.geolocation.getCurrentPosition(r=>{const{longitude:i,latitude:s}=r.coords;Number.isFinite(i)&&Number.isFinite(s)?o.map.flyTo({center:[i,s],zoom:o.userZoom,duration:1500}):n()},()=>n(),{enableHighAccuracy:!1,timeout:5e3,maximumAge:6e4})}}return(r,i)=>(q(),dt(wn,{"data-control":"location","is-dark":e.isDark,title:me(t)("buttons.resetView"),onClick:a},{default:Xt(()=>[...i[0]||(i[0]=[R("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor"},[R("path",{d:"M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5A2.5 2.5 0 1 1 12 6.5a2.5 2.5 0 0 1 0 5z"})],-1)])]),_:1},8,["is-dark","title"]))}},dw={key:0,xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 29 29",fill:"currentColor"},pw={key:1,xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 29 29",fill:"currentColor"},gw={__name:"FullscreenButton",props:{mapContainer:{type:Object,default:null},isDark:{type:Boolean,default:!1}},emits:["change"],setup(e,{emit:t}){const{t:o}=xt(),n=e,a=t,r=be(!1);let i=null,s=null,l=null,u=null,c=null,p=null,d=null,S=null,x=null,b=null,h=null,g=0,f=0,m=null,y=null;function _(){if(typeof document>"u")return!1;const I=typeof navigator<"u"&&navigator.userAgent||"";return/iPad|iPhone|iPod/.test(I)||I.includes("Mac")&&typeof document<"u"&&"ontouchend"in document?!1:!!(document.fullscreenEnabled||document.webkitFullscreenEnabled)}function T(){var I,M,W;return((W=(M=(I=n.mapContainer)==null?void 0:I.getRootNode)==null?void 0:M.call(I))==null?void 0:W.host)??null}function P(){var M,W;const I=(W=(M=n.mapContainer)==null?void 0:M.getRootNode)==null?void 0:W.call(M);return document.fullscreenElement||document.webkitFullscreenElement||(I&&I instanceof ShadowRoot?I.fullscreenElement:null)||null}function E(I){const M=I.requestFullscreen||I.webkitRequestFullscreen;if(!M)return Promise.reject(new Error("Fullscreen API unavailable"));const W=M.call(I);return W&&typeof W.then=="function"?W:Promise.resolve()}function v(){const I=document.exitFullscreen||document.webkitExitFullscreen;if(!I)return Promise.reject(new Error("Fullscreen API unavailable"));const M=I.call(document);return M&&typeof M.then=="function"?M:Promise.resolve()}function j(){const I=T();if(!I)return!1;if(l=I,s=I.style.cssText,I.style.position="fixed",I.style.top="0",I.style.left="0",I.style.right="0",I.style.bottom="0",I.style.width="100vw",I.style.height="100vh",I.style.height="100dvh",I.style.zIndex="2147483647",I.style.margin="0",I.style.borderRadius="0",I.style.touchAction="pan-x pan-y pinch-zoom",typeof document<"u"){g=window.scrollY||window.pageYOffset||0,f=window.scrollX||window.pageXOffset||0;const M=document.body,W=document.documentElement;u=M?M.style.overflow:null,c=W?W.style.overflow:null,p=M?M.style.position:null,d=M?M.style.top:null,S=M?M.style.left:null,x=M?M.style.width:null,b=M?M.style.touchAction:null,h=W?W.style.touchAction:null,W&&(W.style.overflow="hidden",W.style.touchAction="none"),M&&(M.style.overflow="hidden",M.style.position="fixed",M.style.top=`-${g}px`,M.style.left=`-${f}px`,M.style.width="100%",M.style.touchAction="none"),m=L=>{if(!l)return;const O=L.target;O&&(O===l||l.contains&&l.contains(O))||L.cancelable&&L.preventDefault()},y=L=>{if(!l)return;const O=L.target;O&&(O===l||l.contains&&l.contains(O))||L.cancelable&&L.preventDefault()},document.addEventListener("touchmove",m,{passive:!1,capture:!0}),document.addEventListener("wheel",y,{passive:!1,capture:!0})}return!0}function re(){if(l){if(l.style.cssText=s||"",l=null,s=null,typeof document<"u"){const I=document.body,M=document.documentElement;I&&(I.style.overflow=u??"",I.style.position=p??"",I.style.top=d??"",I.style.left=S??"",I.style.width=x??"",I.style.touchAction=b??""),M&&(M.style.overflow=c??"",M.style.touchAction=h??""),m&&(document.removeEventListener("touchmove",m,{capture:!0}),m=null),y&&(document.removeEventListener("wheel",y,{capture:!0}),y=null),typeof window<"u"&&(g||f)&&window.scrollTo(f,g)}u=null,c=null,p=null,d=null,S=null,x=null,b=null,h=null,g=0,f=0}}function Z(){typeof window>"u"||window.requestAnimationFrame(()=>{window.dispatchEvent(new Event("resize"))})}function G(){if(!_()){r.value?(re(),r.value=!1,a("change",!1)):j()&&(r.value=!0,a("change",!0)),Z();return}if(P())v().then(()=>{r.value=!1,a("change",!1)}).catch(()=>{});else{const M=T()??document.documentElement;E(M).then(()=>{r.value=!0,a("change",!0)}).catch(()=>{E(document.documentElement).then(()=>{r.value=!0,a("change",!0)}).catch(()=>{})})}}function pe(){r.value=!!P(),a("change",r.value)}return io(()=>{var M,W;document.addEventListener("fullscreenchange",pe),document.addEventListener("webkitfullscreenchange",pe);const I=(W=(M=n.mapContainer)==null?void 0:M.getRootNode)==null?void 0:W.call(M);I instanceof ShadowRoot&&(i=I,I.addEventListener("fullscreenchange",pe),I.addEventListener("webkitfullscreenchange",pe))}),Qt(()=>{document.removeEventListener("fullscreenchange",pe),document.removeEventListener("webkitfullscreenchange",pe),i&&(i.removeEventListener("fullscreenchange",pe),i.removeEventListener("webkitfullscreenchange",pe),i=null),l&&re()}),(I,M)=>(q(),dt(wn,{"data-control":"fullscreen","is-dark":e.isDark,active:r.value,title:me(o)("buttons.toggleFullscreen"),onClick:G},{default:Xt(()=>[r.value?(q(),ae("svg",pw,[...M[1]||(M[1]=[R("path",{d:"M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1h-5.5zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1v-5.5zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1v5.5zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1h5.5z"},null,-1)])])):(q(),ae("svg",dw,[...M[0]||(M[0]=[R("path",{d:"M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3h1zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16h1zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5H13zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1V7.5z"},null,-1)])]))]),_:1},8,["is-dark","active","title"]))}},hw={style:{"font-size":"16px","line-height":"1"}},fw={__name:"ThemeToggleButton",props:{isDark:{type:Boolean,default:!1}},emits:["toggle"],setup(e){const{t}=xt();return(o,n)=>me(fy)?(q(),dt(wn,{key:0,"data-control":"theme","is-dark":e.isDark,title:e.isDark?me(t)("buttons.switchToLightMode"):me(t)("buttons.switchToDarkMode"),onClick:n[0]||(n[0]=a=>o.$emit("toggle"))},{default:Xt(()=>[R("span",hw,de(e.isDark?"☀️":"🌙"),1)]),_:1},8,["is-dark","title"])):we("",!0)}},Go={mapboxGlJs:{url:"https://api.mapbox.com/mapbox-gl-js/v3.24.0/mapbox-gl.js",integrity:"sha384-tO0clamXONKwbiz7O6xJpUeyJbTSPugC+xM9clvfFvKTH3i8SmCawHGdf5quMWmZ"},mapboxGlCss:{url:"https://api.mapbox.com/mapbox-gl-js/v3.24.0/mapbox-gl.css",integrity:"sha384-rp1X/jJ9MpWPef9OimfXhOaOc4Gzs87yQvF+ajwY6X2H4PTeHNycNlLWiWvj7ehV"},maplibreGlJs:{url:"https://cdn.jsdelivr.net/npm/maplibre-gl@5.24.0/dist/maplibre-gl.js",integrity:"sha384-5+cfbwT0iiub6VsQAdn6yz16nr6sDiQoHx6tm4O8OVYXHYOxcffFmCJBL0dgdvGp"},maplibreGlCss:{url:"https://cdn.jsdelivr.net/npm/maplibre-gl@5.24.0/dist/maplibre-gl.css",integrity:"sha384-uTttxo/aOKbdE5RlD/SPzSDoDmNvGlUYPjONi2MN/b7c9HPSvW07OIuyP7uL6jxK"},mapboxGeocoderJs:{url:"https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v5.0.0/mapbox-gl-geocoder.min.js",integrity:"sha384-Lx9WK8XhZk57czwxt6B6nyaDHB5Ayrcrsu4Fw4bCp/Ot/QLOsUZ0xYqLOpOOSXZw"},mapboxGeocoderCss:{url:"https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v5.0.0/mapbox-gl-geocoder.css",integrity:"sha384-1KNhwJNCQTr0DCi/5/OnQcFytgycxTahxNZaqKbAtqmY8bUhu26qxXqvDGXXwplS"},maplibreGeocoderJs:{url:"https://cdn.jsdelivr.net/npm/@maplibre/maplibre-gl-geocoder@1.9.4/dist/maplibre-gl-geocoder.min.js",integrity:"sha384-RGV5vfoJd7alk8HE+71IyVfu19ciH1FKA15+AuXs6OeBM2npXrmTPFqG23yMiHXi"},maplibreGeocoderCss:{url:"https://cdn.jsdelivr.net/npm/@maplibre/maplibre-gl-geocoder@1.9.4/dist/maplibre-gl-geocoder.css",integrity:"sha384-UkDpPApjTpHJHpcJiSNAmbobh30W0/dmt0DoKm4V8CWYRYvQ/Jhd/ijFz0tFdVnH"},d3:{url:"https://cdn.jsdelivr.net/npm/d3@7.9.0/dist/d3.min.js",integrity:"sha384-CjloA8y00+1SDAUkjs099PVfnY2KmDC2BZnws9kh8D/lX1s46w6EPhpXdqMfjK6i"}};function za(e,t){const o=Object.values(Go).find(n=>n.url===t);return o&&(e.integrity=o.integrity,e.crossOrigin="anonymous"),e}const mw=["blocs","clusters","peopleGroups","families","languages","dialects","people","places","regions","wagfBlocks","religions"],bw={"people-groups":["blocs","clusters","peopleGroups","people","places","families","languages","dialects","regions","religions"],language:["families","languages","dialects","people","blocs","clusters","peopleGroups","places","regions","religions"],regions:["regions","wagfBlocks","places","blocs","clusters","peopleGroups","people","families","languages","dialects","religions"],religion:["religions","people","blocs","clusters","peopleGroups","places","families","languages","dialects","regions"]};function _w(e){return bw[e]||mw}const yw={blocs:3,clusters:3,peopleGroups:3,families:3,languages:3,dialects:3,people:5,places:2,regions:3,wagfBlocks:3,religions:2},ai=["peopleGroups","people","places","languages","religions"],$w={regions:[...ai,"regions","wagfBlocks"],"people-groups":[...ai,"blocs","clusters"],language:[...ai,"dialects","families"],religion:[...ai]},vw=100,ww=50,kw=25,Pw=10,fl=5,mg=20,xw=[[/ sign language$/i,"Sign Language"]];function Sw(e){if(!e||typeof e!="string")return"";const t=e.indexOf(",");return t>0?e.slice(0,t).trim():e.trim()}function Aw(e){if(!e||typeof e!="string")return null;const t=e.indexOf(",");return t>=0&&e.slice(t+1).trim()||null}function Lw(e){if(!e||typeof e!="string")return null;const t=e.split(",").map(n=>n.trim()).filter(Boolean);if(t.length>=2){const n=[...t].reverse().join(" ");if(Gt[n])return Gt[n];if(t.length>=3){const a=[t[1],t[0]].join(" ");if(Gt[a])return Gt[a]}}if(Gt[e])return Gt[e];const o=e.replace(/\s*\(.*?\)\s*$/,"").trim();if(o!==e&&Gt[o])return Gt[o];for(const[n,a]of xw)if(n.test(e))return a;return null}function bg(e,t){return{id:`doxa-section-header-${ml(e)}`,place_name:e,text:e,center:[0,0],place_type:["doxa-section-header"],geometry:{type:"Point",coordinates:[0,0]},properties:{headerLabel:e,isHeader:!0,isAllDataSection:!!t},feature:null}}function ml(e){return String(e||"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function Fe(e){return e==null?"":typeof e=="string"?e.toLowerCase():typeof e=="object"&&"label"in e?String(e.label||"").toLowerCase():typeof e=="object"&&"value"in e?String(e.value||"").toLowerCase():String(e).toLowerCase()}function ri(e){return e==null?"":typeof e=="string"?e:typeof e=="object"?e.label||e.value||"":String(e)}function Cw(e){var o,n,a,r,i;if(!Array.isArray(e))return[];const t=[];for(const s of e){if(!s)continue;const l=Number(s.latitude),u=Number(s.longitude);if(!Number.isFinite(l)||!Number.isFinite(u))continue;const c=Fe(s.name)+" "+Fe(s.displayName)+" "+Fe(s.alternateName),p=Fe(s.countryName)+" "+Fe(s.country)+" "+Fe(s.countryIso)+" "+Fe(s.countryIsoLabel),d=Fe(s.religionName)+" "+Fe(s.religion)+" "+Fe(s.religionLabel)+" "+Fe(s.religionCode),S=Fe(s.language)+" "+Fe(s.languageFamily)+" "+Fe(s.languageCode),x=Fe(s.doxaRegion)+" "+Fe(s.wagfRegion)+" "+Fe(s.wagfBlock),b=Fe(s.affinityBlock)+" "+Fe(s.affinityBlockLabel)+" "+Fe((o=s._raw)==null?void 0:o.rop1),h=Fe(s.cluster)+" "+Fe(s.clusterLabel)+" "+Fe((n=s._raw)==null?void 0:n.imb_reg_of_people_2),g=Fe(s.peopleGroup)+" "+Fe(s.peopleGroupLabel)+" "+Fe((a=s._raw)==null?void 0:a.imb_reg_of_people_25),f=((r=s._raw)==null?void 0:r.primary_language)??((i=s._raw)==null?void 0:i.PrimaryLanguage),m=f&&(typeof f=="object"?f.label||f.value:f)||ri(s.language)||ri(s.primaryLanguage)||"",y=Sw(m),_=Aw(m);t.push({feature:s,nameHay:c,countryHay:p,religionHay:d,languageHay:S,regionHay:x,haystack:c+" "+p+" "+d+" "+S+" "+x+" "+b+" "+h+" "+g,blocHay:b,clusterHay:h,pgHay:g,lat:l,lng:u,familyDerived:Lw(m)||null,languageLabel:m,baseLang:y,dialectLabel:_})}return t}function Tw(e){const t=(o,n,a)=>{const r=new Map;for(const i of e){const s=o(i);if(!s)continue;const l=r.get(s);if(l)l.count+=1,l.lngSum+=i.lng,l.latSum+=i.lat,l.memberIds.push(String(i.feature.uniqueId??i.feature.id??i.feature.slug??"")),l.minLng=Math.min(l.minLng,i.lng),l.maxLng=Math.max(l.maxLng,i.lng),l.minLat=Math.min(l.minLat,i.lat),l.maxLat=Math.max(l.maxLat,i.lat),a&&a(l,i,!1);else{const u={key:s,label:ri(n(i))||s,count:1,lngSum:i.lng,latSum:i.lat,minLng:i.lng,maxLng:i.lng,minLat:i.lat,maxLat:i.lat,memberIds:[String(i.feature.uniqueId??i.feature.id??i.feature.slug??"")]};a&&a(u,i,!0),r.set(s,u)}}for(const i of r.values())i.lng=i.lngSum/i.count,i.lat=i.latSum/i.count;return Array.from(r.values())};return{countries:t(o=>Fe(o.feature.countryName)||Fe(o.feature.country)||Fe(o.feature.countryIso),o=>o.feature.countryName||o.feature.country||o.feature.countryIso||""),families:t(o=>Fe(o.familyDerived),o=>o.familyDerived||""),languages:t(o=>Fe(o.baseLang),o=>o.baseLang||""),dialects:t(o=>o.dialectLabel?`${Fe(o.baseLang)}__${Fe(o.dialectLabel)}`:"",o=>`${o.baseLang}, ${o.dialectLabel}`,(o,n,a)=>{a?(o.originalLabels=new Set([n.languageLabel]),o.familyDerived=n.familyDerived||"",o.baseLang=n.baseLang||"",o.dialectLabel=n.dialectLabel||""):(o.originalLabels.add(n.languageLabel),!o.familyDerived&&n.familyDerived&&(o.familyDerived=n.familyDerived))}),religions:t(o=>{var n,a,r;return Fa(o.feature.religion||((a=(n=o.feature._raw)==null?void 0:n.religion)==null?void 0:a.value)||((r=o.feature._raw)==null?void 0:r.religion)||"")},o=>{var n,a,r;return il(Fa(o.feature.religion||((a=(n=o.feature._raw)==null?void 0:n.religion)==null?void 0:a.value)||((r=o.feature._raw)==null?void 0:r.religion)||""))||"Unknown"}),regions:t(o=>Fe(o.feature.doxaRegion)||Fe(o.feature.wagfRegion),o=>{var n,a;return o.feature.wagfRegionLabel||o.feature.doxaRegionLabel||((a=(n=o.feature._raw)==null?void 0:n.wagf_region)==null?void 0:a.label)||o.feature.doxaRegion||o.feature.wagfRegion||""}),wagfBlocks:t(o=>Fe(o.feature.wagfBlock),o=>{var n,a;return o.feature.wagfBlockLabel||((a=(n=o.feature._raw)==null?void 0:n.wagf_block)==null?void 0:a.label)||o.feature.wagfBlock||""}),blocs:t(o=>Fe(o.feature.affinityBlockLabel)||Fe(o.feature.affinityBlock),o=>o.feature.affinityBlockLabel||o.feature.affinityBlock||"",(o,n,a)=>{a&&(o.blocCode=n.feature.affinityBlock||"")}),clusters:t(o=>{const n=o.feature.affinityBlock||"",a=o.feature.cluster||"";return a?`${n}__${a}`:""},o=>o.feature.clusterLabel||o.feature.cluster||"",(o,n,a)=>{a&&(o.blocCode=n.feature.affinityBlock||"",o.blocLabel=n.feature.affinityBlockLabel||"",o.clusterCode=n.feature.cluster||"")}),peopleGroups:t(o=>Fe(o.feature.peopleGroup)||Fe(o.feature.peopleGroupLabel),o=>o.feature.peopleGroupLabel||o.feature.peopleGroup||o.feature.name||"",(o,n,a)=>{a&&(o.blocCode=n.feature.affinityBlock||"",o.blocLabel=n.feature.affinityBlockLabel||"",o.clusterCode=n.feature.cluster||"",o.clusterLabel=n.feature.clusterLabel||"",o.peopleGroupCode=n.feature.peopleGroup||"")})}}function Ew(e){const t=e.feature,o=t.name||t.displayName||t.slug||"Unknown",n=t.countryName||t.country||t.countryIso||"",a=t.religionName||t.religion||"",r=t.slug||t.uniqueId||ml(o+"-"+n),i=[e.lng,e.lat],s=[n,a].filter(Boolean).join(" — "),l=s?`${o}, ${s}`:o;return{id:`doxa-pg-${r}`,place_name:l,text:o,center:i,place_type:["people-group"],geometry:{type:"Point",coordinates:i},properties:{slug:r,...t},feature:t}}function wo(e,t){let o,n;switch(e){case"country":o="doxa-country",n="doxa-country-";break;case"region":o="doxa-region",n="doxa-region-";break;case"language-family":o="doxa-language-family",n="doxa-language-family-";break;case"language":o="doxa-language",n="doxa-language-";break;case"dialect":o="doxa-dialect",n="doxa-dialect-";break;case"religion":o="doxa-religion",n="doxa-religion-";break;case"affinity-bloc":o="doxa-affinity-bloc",n="doxa-affinity-bloc-";break;case"cluster":o="doxa-cluster",n="doxa-cluster-";break;case"people-group":o="doxa-people-group",n="doxa-people-group-";break;default:o="doxa",n="doxa-"}const a=ri(t.label)||t.key,r=ml(t.key),i=[t.lng,t.lat],l={"affinity-bloc":"Affinity Block",cluster:"Cluster","people-group":"PG","pg-in-country":"PGIC"}[e],u=l?`${a} (${l}) · ${t.count}`:`${a} (${t.count})`,c=t.originalLabels?Array.from(t.originalLabels):void 0,p=e==="dialect"?{familyDerived:t.familyDerived||"",baseLang:t.baseLang||"",dialectLabel:t.dialectLabel||""}:null;return{id:`${n}${r}`,place_name:u,text:a,center:i,bbox:[t.minLng,t.minLat,t.maxLng,t.maxLat],place_type:[o],geometry:{type:"Point",coordinates:i},properties:{slug:r,doxaAggregate:e,count:t.count,label:a,memberIds:t.memberIds,bounds:[t.minLng,t.minLat,t.maxLng,t.maxLat],...c?{originalLabels:c}:{},...p||{},...e==="affinity-bloc"?{blocCode:t.blocCode||""}:{},...e==="cluster"?{blocCode:t.blocCode||"",blocLabel:t.blocLabel||"",clusterCode:t.clusterCode||""}:{},...e==="people-group"?{blocCode:t.blocCode||"",blocLabel:t.blocLabel||"",clusterCode:t.clusterCode||"",clusterLabel:t.clusterLabel||"",peopleGroupCode:t.peopleGroupCode||""}:{}},feature:null}}function Rw(e={}){const{dataStore:t,dataSourceId:o,getActiveFilter:n,getActiveContext:a}=e,{t:r}=xt(),i=X(()=>{var p,d;if(!t||!t.sources)return[];if(o&&((p=t.sources[o])!=null&&p.features))return t.sources[o].features;for(const S of Object.keys(t.sources)){const x=t.sources[S];if((d=x==null?void 0:x.features)!=null&&d.length)return x.features}return[]}),s=X(()=>Cw(i.value)),l=X(()=>Tw(s.value));function u(p){const d=String(p||"").trim().toLowerCase(),S={people:[],places:[],regions:[],wagfBlocks:[],families:[],languages:[],dialects:[],religions:[],blocs:[],clusters:[],peopleGroups:[]};if(d.length<2)return S;const x=d.split(/[\s,;]+/).filter(Boolean);if(!x.length)return S;const b=s.value;if(!b.length)return S;const h=l.value,g=[];for(const M of b){let W=!0;for(const O of x)if(!M.haystack.includes(O)){W=!1;break}if(!W)continue;let L=0;x.some(O=>M.nameHay.includes(O))&&(L+=vw),x.some(O=>M.countryHay.includes(O))&&(L+=ww),x.some(O=>M.religionHay.includes(O))&&(L+=kw),x.some(O=>M.languageHay.includes(O))&&(L+=Pw),g.push({entry:M,score:L})}g.sort((M,W)=>W.score-M.score);const f=g.slice(0,fl).map(M=>Ew(M.entry)),m=M=>M.filter(W=>x.every(L=>W.key.includes(L)||Fe(W.label).includes(L))).sort((W,L)=>L.count-W.count).slice(0,fl),y=m(h.countries).map(M=>wo("country",M)),_=m(h.regions).map(M=>wo("region",M)),T=m(h.wagfBlocks).map(M=>wo("region",M)),P=m(h.families).map(M=>wo("language-family",M)),E=m(h.languages).map(M=>wo("language",M)),v=m(h.dialects).map(M=>wo("dialect",M)),j=m(h.religions).map(M=>wo("religion",M)),re=m(h.blocs).map(M=>wo("affinity-bloc",M));let Z=m(h.clusters).map(M=>wo("cluster",M)),G=m(h.peopleGroups).map(M=>wo("people-group",M));const pe=new Set(re.map(M=>Fe(M.text)));Z=Z.filter(M=>!pe.has(Fe(M.text)));const I=new Set(Z.map(M=>Fe(M.text)));return G=G.filter(M=>!pe.has(Fe(M.text))&&!I.has(Fe(M.text))),{people:f,places:y,regions:_,wagfBlocks:T,families:P,languages:E,dialects:v,religions:j,blocs:re,clusters:Z,peopleGroups:G}}function c(p){const d=typeof n=="function"?n():null,S=typeof a=="function"?a():null,x=u(p),b=_w(S),h=$w[S],g=h?Object.fromEntries(h.filter(P=>x[P]).map(P=>[P,x[P]])):x,f=b.flatMap(P=>g[P]||[]);if(!(d!=null&&d.key)||!f.length)return f.slice(0,mg);const m=[];for(const P of x.people){const E=s.value.find(j=>j.feature===P.feature);let v=!1;E&&(d.kind==="family"?v=(E.familyDerived||"").toLowerCase()===d.key.toLowerCase():d.kind==="language"&&(v=E.languageLabel.toLowerCase()===d.key.toLowerCase())),v&&m.push(P)}const y=[],_=d.key;m.length&&(y.push(bg(r("search.sections.within",{selection:_}),!1)),y.push(...m.slice(0,fl)));const T=b.flatMap(P=>(g[P]||[]).slice(0,yw[P]??3)).map(P=>({...P,properties:{...P.properties,_allDataSection:!0}}));return y.push(bg(r("search.sections.allData"),!0)),y.push(...T),y.slice(0,mg+8)}return{search:c,searchGrouped:u,index:s,aggregates:l}}const Nw={__name:"GeocoderComponent",props:{mapInstance:{type:Object,required:!1,default:null},accessToken:{type:String,required:!0},provider:{type:String,default:"mapbox"},isDark:{type:Boolean,default:!1},standalone:{type:Boolean,default:!1},placeholder:{type:String,default:""},dataSourceId:{type:String,default:""},activeContext:{type:String,default:""}},emits:["result","people-group-result","aggregate-result","clear","error"],setup(e,{expose:t,emit:o}){function n(L){return L+L.replace(/mapboxgl/g,"maplibregl")}Tt(n('.mapboxgl-ctrl-geocoder--input,.mapboxgl-ctrl-geocoder input[type="text"],.mapboxgl-ctrl-geocoder input[type="search"]{font-size:16px !important;line-height:1.3;}'),"geocoder-ios-zoom-fix"),Tt(n(".mapboxgl-ctrl-geocoder--icon-loading{display:none !important;}"),"geocoder-hide-loading"),Tt(n(".mapboxgl-ctrl-geocoder{height:35px!important;min-height:35px!important;box-sizing:border-box!important;}.mapboxgl-ctrl-geocoder--input{height:35px!important;min-height:35px!important;box-sizing:border-box!important;padding-top:0!important;padding-bottom:0!important;line-height:35px!important;}.mapboxgl-ctrl-geocoder--icon-search{top:50%!important;transform:translateY(-50%)!important;margin-top:0!important;left:7px!important;}"),"geocoder-height-35"),Tt(n(".mapboxgl-ctrl-geocoder{width:100%!important;max-width:100%!important;min-width:0!important;}@media(max-width:767px){.dg-search-band{top:0!important;left:0!important;right:0!important;width:100%!important;max-width:none!important;margin:0!important;box-sizing:border-box!important;padding:9px 14px!important;background:#fff;box-shadow:0 1px 4px rgba(0,0,0,0.10);}.dg-search-band--dark{background:#3b463d;box-shadow:0 1px 4px rgba(0,0,0,0.35);}.dg-search-band .mapboxgl-ctrl,.dg-search-band .maplibregl-ctrl{margin:0!important;float:none!important;}}.mapboxgl-ctrl-geocoder{border-radius:999px!important;background:#fff;box-shadow:0 2px 8px rgba(0,0,0,0.15)!important;transition:box-shadow .12s,border-color .12s;}.mapboxgl-ctrl-geocoder:focus-within{box-shadow:0 2px 8px rgba(0,0,0,0.15),0 0 0 3px rgba(59,70,61,0.18)!important;}.mapboxgl-ctrl-geocoder--input{border-radius:999px!important;font-size:13px!important;}.mapboxgl-ctrl-geocoder--input::placeholder{font-size:12px!important;}.mapboxgl-ctrl-geocoder--button{display:none!important;top:50%!important;bottom:auto!important;transform:translateY(-50%)!important;margin:0!important;padding:0!important;width:24px!important;height:24px!important;background:transparent!important;border:none!important;box-shadow:none!important;}.mapboxgl-ctrl-geocoder:has(.mapboxgl-ctrl-geocoder--input:not(:placeholder-shown)) .mapboxgl-ctrl-geocoder--button{display:block!important;}.mapboxgl-ctrl-geocoder--button .mapboxgl-ctrl-geocoder--icon-close{position:absolute!important;top:50%!important;left:50%!important;transform:translate(-50%,-50%)!important;margin:0!important;width:16px!important;height:16px!important;}.mapboxgl-ctrl-geocoder--suggestions,.mapboxgl-ctrl-geocoder .suggestions{z-index:1200!important;position:absolute;max-height:60vh!important;overflow-y:auto!important;}.geocoder-dark.mapboxgl-ctrl-geocoder,.dsm-dark .mapboxgl-ctrl-geocoder{background:#4e594f!important;border:1px solid rgba(255,255,255,0.14)!important;box-shadow:0 2px 8px rgba(0,0,0,0.4)!important;}.geocoder-dark.mapboxgl-ctrl-geocoder:focus-within,.dsm-dark .mapboxgl-ctrl-geocoder:focus-within{box-shadow:0 2px 8px rgba(0,0,0,0.4),0 0 0 3px rgba(115,161,127,0.22)!important;}.geocoder-dark .mapboxgl-ctrl-geocoder--input,.dsm-dark .mapboxgl-ctrl-geocoder--input{color:#F3F3F1!important;background:transparent!important;}.geocoder-dark .mapboxgl-ctrl-geocoder--input::placeholder,.dsm-dark .mapboxgl-ctrl-geocoder--input::placeholder{color:rgba(243,243,241,0.65)!important;}.geocoder-dark .mapboxgl-ctrl-geocoder--icon,.dsm-dark .mapboxgl-ctrl-geocoder .mapboxgl-ctrl-geocoder--icon{fill:rgba(243,243,241,0.75)!important;}.geocoder-dark .mapboxgl-ctrl-geocoder--button,.dsm-dark .mapboxgl-ctrl-geocoder--button{background:transparent!important;}"),"geocoder-skin");const{t:a,locale:r}=xt(),i=e,s=X(()=>/^pk\./.test(String(i.accessToken||""))),l=X(()=>i.placeholder||(i.provider==="maplibre"&&!s.value?a("search.placeholderNoPlaces"):a("search.placeholder"))),u=o,c={"&":"&","<":"<",">":">",'"':""","'":"'"};function p(L){return String(L??"").replace(/[&<>"']/g,O=>c[O])}function d(L){return L==null?"":typeof L=="string"?L:typeof L=="object"?L.label||L.value||"":String(L)}const S={"people-group":"people","doxa-people-group":"peopleGroup","doxa-affinity-bloc":"bloc","doxa-cluster":"cluster","doxa-country":"country","doxa-region":"region","doxa-language-family":"family","doxa-language":"languageKind","doxa-dialect":"dialect","doxa-religion":"religionKind"};function x(L){const O=S[L];if(!O)return"";const V=a("search.kinds."+O);return`${p(V)}`}function b(L){var ne;if(!L)return"";const O=L.place_type||[];if(O.includes("doxa-section-header"))return`
${p(((ne=L.properties)==null?void 0:ne.headerLabel)||L.text||"")}
`;if(O.includes("people-group")){const ue=L.properties||{},Pe=d(ue.name)||d(ue.displayName)||d(L.text)||"",ye=d(ue.countryName)||d(ue.country)||d(ue.countryIso)||"",Be=d(ue.language)||d(ue.primaryLanguage)||d(ue.languageFamily)||"",se=d(ue.religionName)||d(ue.religion)||"",he=a("search.labels.place"),ce=a("search.labels.language"),Se=a("search.labels.religion"),K=[];return ye&&K.push(`${p(he)} ${p(ye)}`),Be&&K.push(`${p(ce)} ${p(Be)}`),se&&K.push(`${p(Se)} ${p(se)}`),`
${x("people-group")}${p(Pe)}
`+(K.length?`
${K.join("")}
`:"")}const V=O.find(ue=>ue.startsWith("doxa-"));if(V){const ue=L.properties||{},Pe=p(d(ue.label)||L.text||""),ye=Number(ue.count)||0,Be=ye?` ${ye}`:"";return`
${x(V)}${Pe}${Be}
`}return`
${p(L.place_name||L.text||"")}
`}const h=He("dataStore",null),g=He("mapStore",null),f=He("uiStore",null);function m(){return g?g.selectedFamily?{kind:"family",key:g.selectedFamily}:g.selectedLanguage?{kind:"language",key:g.selectedLanguage}:null:null}const{search:y}=Rw({dataStore:h,dataSourceId:i.dataSourceId||void 0,getActiveFilter:m,getActiveContext:()=>i.activeContext||null}),_=cn(null),T=be(null),P={mapbox:Go.mapboxGeocoderCss.url,maplibre:Go.maplibreGeocoderCss.url},E=Go.maplibreGeocoderJs.url,v=Go.mapboxGeocoderJs.url;function j(L,O){const V=P[O]||P.mapbox;if(L.querySelector(`link[href="${V}"]`))return;const ne=document.createElement("link");ne.rel="stylesheet",ne.href=V,za(ne,V),L.prepend(ne)}async function re(L,O){if(typeof window<"u"&&window[O]||typeof document>"u")return;const V=document.querySelector(`script[src="${L}"]`);if(V){if(window[O])return;await new Promise(ne=>{V.addEventListener("load",ne,{once:!0}),V.addEventListener("error",ne,{once:!0})});return}await new Promise(ne=>{const ue=document.createElement("script");ue.src=L,za(ue,L),ue.async=!0,ue.addEventListener("load",ne,{once:!0}),ue.addEventListener("error",ne,{once:!0}),document.head.appendChild(ue)})}function Z(L=document){let O=L.activeElement;for(;O&&O.shadowRoot&&O.shadowRoot.activeElement;)O=O.shadowRoot.activeElement;return O}function G(L){const O=L==null?void 0:L._onKeyDown;typeof O=="function"&&(L._onKeyDown=function(V){const ne=Z();return!ne||ne===V.target||typeof ne.value!="string"?O.call(L,V):O.call(L,new Proxy(V,{get(ue,Pe){if(Pe==="target"||Pe==="srcElement")return ne;const ye=Reflect.get(ue,Pe);return typeof ye=="function"?ye.bind(ue):ye}}))})}async function pe(){await re(v,"MapboxGeocoder")}async function I(){if(typeof window<"u"&&window.MaplibreGeocoder||typeof document>"u")return;const L=document.querySelector(`script[src="${E}"]`);if(L){if(window.MaplibreGeocoder)return;await new Promise(O=>{L.addEventListener("load",O,{once:!0}),L.addEventListener("error",O,{once:!0})});return}await new Promise((O,V)=>{const ne=document.createElement("script");ne.src=E,ne.async=!1,ne.addEventListener("load",O,{once:!0}),ne.addEventListener("error",()=>V(new Error("[GeocoderComponent] Failed to load MapLibre geocoder")),{once:!0}),document.head.appendChild(ne)})}function M(L,O){return async V=>{const ne={features:[]};if(!/^pk\./.test(String(L||""))||!(V!=null&&V.query))return ne;try{const ue=Array.isArray(V.language)?V.language[0]:V.language||O()||"en",Pe=new URLSearchParams({access_token:L,autocomplete:"true",limit:String(V.limit||5)});ue&&Pe.set("language",ue);const ye=`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(V.query)}.json?${Pe.toString()}`,Be=await fetch(ye);if(!Be.ok)return ne;const se=await Be.json();return se&&Array.isArray(se.features)?se:ne}catch{return ne}}}io(async()=>{var ue,Pe,ye,Be,se;const L=i.provider==="maplibre";if(L){if(await I(),typeof MaplibreGeocoder>"u"){console.error("[GeocoderComponent] MaplibreGeocoder global unavailable.");return}}else if(typeof MapboxGeocoder>"u"&&(await pe(),typeof MapboxGeocoder>"u")){console.error("[GeocoderComponent] MapboxGeocoder global unavailable.");return}const O=i.mapInstance;if(!i.standalone&&!O)return;const V=i.standalone?(Pe=(ue=T.value)==null?void 0:ue.getRootNode)==null?void 0:Pe.call(ue):(se=(Be=(ye=O.getContainer)==null?void 0:ye.call(O))==null?void 0:Be.getRootNode)==null?void 0:se.call(Be);V instanceof ShadowRoot&&j(V,i.provider);const ne={marker:!1,flyTo:!i.standalone,trackProximity:!i.standalone,placeholder:l.value,language:r.value||"en",localGeocoder:y,limit:20,zoom:6,render:b};if(L){const he=typeof maplibregl<"u"?maplibregl:void 0,ce={forwardGeocode:M(i.accessToken,()=>r.value)};_.value=new MaplibreGeocoder(ce,{...ne,maplibregl:he,showResultsWhileTyping:!0,reverseGeocode:!1})}else _.value=new MapboxGeocoder({accessToken:i.accessToken,mapboxgl,...ne});if(G(_.value),_.value.on("result",he=>{var Se,K,_e,$,A,C,U,oe,le,ie,ge,w,k,B,z,Q,ee,D,J,$e,Ee,qe,ft,it,St,Et,Le,Qe,Ot,F;const ce=he==null?void 0:he.result;ce&&((Se=ce.place_type)!=null&&Se.includes("doxa-section-header")||(g&&(g.selectedRegion=null,g.selectedResource=null,g.selectedAffinityBlock=null,g.selectedDialect=null),f&&((K=f.setPrayerFilter)==null||K.call(f,null),(_e=f.setEngagementFilter)==null||_e.call(f,null),($=f.setAdoptionFilter)==null||$.call(f,null),(A=f.setReligionFilter)==null||A.call(f,null)),(C=ce.properties)!=null&&C._allDataSection&&g&&(g.selectedFamily=null,g.selectedLanguage=null),u("result",he),(U=ce.place_type)!=null&&U.includes("people-group")&&ce.feature?u("people-group-result",{type:"Feature",properties:ce.properties||ce.feature,geometry:ce.geometry||{type:"Point",coordinates:ce.center}}):((oe=ce.place_type)!=null&&oe.includes("doxa-country")||(le=ce.place_type)!=null&&le.includes("doxa-region")||(ie=ce.place_type)!=null&&ie.includes("doxa-language-family")||(ge=ce.place_type)!=null&&ge.includes("doxa-language")||(w=ce.place_type)!=null&&w.includes("doxa-dialect")||(k=ce.place_type)!=null&&k.includes("doxa-religion")||(B=ce.place_type)!=null&&B.includes("doxa-affinity-bloc")||(z=ce.place_type)!=null&&z.includes("doxa-cluster")||(Q=ce.place_type)!=null&&Q.includes("doxa-people-group"))&&u("aggregate-result",{kind:ce.place_type[0].replace(/^doxa-/,""),label:((ee=ce.properties)==null?void 0:ee.label)||ce.text,count:((D=ce.properties)==null?void 0:D.count)||0,memberIds:((J=ce.properties)==null?void 0:J.memberIds)||[],bounds:(($e=ce.properties)==null?void 0:$e.bounds)||null,center:ce.center,originalLabels:((Ee=ce.properties)==null?void 0:Ee.originalLabels)||null,familyDerived:((qe=ce.properties)==null?void 0:qe.familyDerived)||"",baseLang:((ft=ce.properties)==null?void 0:ft.baseLang)||"",dialectLabel:((it=ce.properties)==null?void 0:it.dialectLabel)||"",slug:((St=ce.properties)==null?void 0:St.slug)||null,id:ce.id||null,blocCode:((Et=ce.properties)==null?void 0:Et.blocCode)||"",blocLabel:((Le=ce.properties)==null?void 0:Le.blocLabel)||"",clusterCode:((Qe=ce.properties)==null?void 0:Qe.clusterCode)||"",clusterLabel:((Ot=ce.properties)==null?void 0:Ot.clusterLabel)||"",peopleGroupCode:((F=ce.properties)==null?void 0:F.peopleGroupCode)||"",properties:ce.properties||null})))}),_.value.on("clear",()=>u("clear")),_.value.on("error",he=>u("error",he)),i.standalone){if(T.value){const he={on(){},off(){},fire(){},getContainer:()=>T.value,getZoom:()=>0,getCenter:()=>({lng:0,lat:0}),getBounds:()=>null,flyTo(){},fitBounds(){},addControl(){},removeControl(){},hasControl:()=>!1};try{const ce=_.value.onAdd(i.mapInstance||he);ce&&T.value.appendChild(ce)}catch(ce){u("error",ce)}}}else O.addControl(_.value,"top-left"),W()});function W(){var O,V;const L=(V=(O=_.value)==null?void 0:O.container)==null?void 0:V.parentElement;L&&(L.classList.add("dg-search-band"),L.classList.toggle("dg-search-band--dark",!!i.isDark))}return ot(()=>i.isDark,()=>W()),ot(l,L=>{var ne,ue;const O=_.value;if(!O)return;const V=O._inputEl||((ue=(ne=O.container)==null?void 0:ne.querySelector)==null?void 0:ue.call(ne,"input.mapboxgl-ctrl-geocoder--input"));V&&(V.placeholder=L,V.setAttribute("placeholder",L)),O.options&&(O.options.placeholder=L)}),ot(r,L=>{const O=_.value;O!=null&&O.options&&(O.options.language=L||"en")}),Qt(()=>{var L,O;if(_.value){try{i.standalone?(O=(L=_.value).onRemove)==null||O.call(L):i.mapInstance&&i.mapInstance.removeControl(_.value)}catch{}_.value=null}}),t({geocoder:_}),(L,O)=>e.standalone?(q(),ae("div",{key:0,ref_key:"standaloneContainer",ref:T,class:"dg-standalone-geocoder"},null,512)):Rn(L.$slots,"default",{},void 0,void 0,1)}},Mw=["mapbox","maplibre"],Iw="auto";function _g(e){return e&&typeof e=="object"&&"value"in e&&!("provider"in e)&&!("profile"in e)?e.value:e}function yg(e){const t=o=>typeof o=="string"&&!!o.trim()&&!/^YOUR_/.test(o.trim());return t(e==null?void 0:e.tk)||/^https?:\/\//i.test(String((e==null?void 0:e.tokenUrl)||""))?!0:typeof window>"u"?!1:t(window.MAP_TOKEN)||t(window.__doxaMapToken)||!!window.__doxaMapTokenPending}function Fw(e,{token:t}={}){const o=_g(e);return Ow(o)||(yg(o)||yg({tk:t})?"mapbox":"maplibre")}function Ow(e){const t=_g(e),o=t==null?void 0:t.provider,n=typeof location<"u"?new URLSearchParams(location.search).get("provider"):void 0,a=typeof window<"u"?window.MAP_PROVIDER:void 0,r=String(o||n||a||Iw).toLowerCase().trim();return Mw.includes(r)?r:""}const Dw="rgba(120, 128, 134, 0.28)",$g="36px",vg=()=>{};function Gw(e,t={}){const{enabled:o=!0}=t;if(!o||!e)return vg;const n=Array.from(e.querySelectorAll(".map-scroll-edge"));if(!n.length)return vg;const a=f=>f.classList.contains("map-scroll-edge--left");for(const f of n)f.style.background=`linear-gradient(${a(f)?"to right":"to left"}, ${Dw} ${$g}, transparent ${$g})`,f.style.opacity="0",f.style.transition="opacity 0.16s ease",f.style.userSelect="none",f.style.webkitUserSelect="none";const r=f=>{f.style.opacity="1"},i=f=>{f.style.opacity="0"},s=()=>n.find(f=>!a(f))||null,l=new Set;let u=!1,c=null;const p=()=>{for(const f of n)l.has(f)||i(f)},d=()=>{const f=s();f&&(r(f),c&&clearTimeout(c),c=setTimeout(p,250))},S=()=>d(),x=f=>{if(!(f.touches&&f.touches.length===1))return;const m=f.target;m&&m.classList&&m.classList.contains("map-scroll-edge")||d()},b=()=>{c&&clearTimeout(c),p()};e.addEventListener("wheel",S,{passive:!0}),e.addEventListener("touchmove",x,{passive:!0}),e.addEventListener("touchend",b,{passive:!0}),e.addEventListener("touchcancel",b,{passive:!0});const h=()=>{u||d()};typeof window<"u"&&window.addEventListener("scroll",h,{passive:!0});const g=[];for(const f of n){const m=()=>{l.add(f),r(f)},y=()=>{l.delete(f),i(f)},_=()=>{u=!0,r(f)},T=()=>{u=!1,i(f)};f.addEventListener("mouseenter",m),f.addEventListener("mouseleave",y),f.addEventListener("touchstart",_,{passive:!0}),f.addEventListener("touchend",T,{passive:!0}),g.push(()=>{f.removeEventListener("mouseenter",m),f.removeEventListener("mouseleave",y),f.removeEventListener("touchstart",_),f.removeEventListener("touchend",T)})}return function(){c&&(clearTimeout(c),c=null),e.removeEventListener("wheel",S),e.removeEventListener("touchmove",x),e.removeEventListener("touchend",b),e.removeEventListener("touchcancel",b),typeof window<"u"&&window.removeEventListener("scroll",h);for(const m of g)m();for(const m of n)i(m)}}const zw=Object.fromEntries([{id:"midnight-glow",label:"Midnight Glow",mood:"the prayer-map dark — pins glow like embers",mapbox:"mapbox://styles/mapbox/standard",lightPreset:"night",maplibre:"https://tiles.openfreemap.org/styles/fiord",bestFor:["doxa-simple-map","my-upg-100-list"]},{id:"daylight",label:"Daylight",mood:"the same Standard world, lights on",mapbox:"mapbox://styles/mapbox/standard",lightPreset:"day",maplibre:"https://tiles.openfreemap.org/styles/liberty",bestFor:["doxa-research-map","gospel-resources"]},{id:"dawn",label:"Dawn",mood:"soft warm horizon — hopeful, quiet",mapbox:"mapbox://styles/mapbox/standard",lightPreset:"dawn",maplibre:"https://tiles.openfreemap.org/styles/positron",bestFor:["doxa-simple-map"]},{id:"dusk",label:"Dusk",mood:"blue hour — calm contrast for bright pins",mapbox:"mapbox://styles/mapbox/standard",lightPreset:"dusk",maplibre:"https://tiles.openfreemap.org/styles/fiord",bestFor:["my-upg-100-list"]},{id:"paper",label:"Paper",mood:"near-white minimal — data reads like print",mapbox:"mapbox://styles/mapbox/light-v11",maplibre:"https://tiles.openfreemap.org/styles/positron",bestFor:["research-dashboard","cities-internet"]},{id:"ink",label:"Ink",mood:"near-black minimal — maximum pin contrast",mapbox:"mapbox://styles/mapbox/dark-v11",maplibre:"https://tiles.openfreemap.org/styles/dark",bestFor:["my-upg-100-list","cities-internet"]},{id:"streetlife",label:"Street Life",mood:"full street detail — city-scale work",mapbox:"mapbox://styles/mapbox/streets-v12",maplibre:"https://tiles.openfreemap.org/styles/bright",bestFor:["cities-internet","key-cities"]},{id:"terrain",label:"Terrain",mood:"relief + parks — where people actually live",mapbox:"mapbox://styles/mapbox/outdoors-v12",maplibre:"https://tiles.openfreemap.org/styles/liberty",bestFor:["doxa-research-map","country-posters"]},{id:"satellite",label:"Satellite",mood:"imagery — the real ground",mapbox:"mapbox://styles/mapbox/satellite-v9",maplibre:"https://tiles.openfreemap.org/styles/liberty",bestFor:["country-posters"]},{id:"hybrid",label:"Hybrid",mood:"imagery + labels — orientation without losing ground truth",mapbox:"mapbox://styles/mapbox/satellite-streets-v12",maplibre:"https://tiles.openfreemap.org/styles/liberty",bestFor:["key-cities"]},{id:"wayfinder-day",label:"Wayfinder Day",mood:"high-legibility navigation palette",mapbox:"mapbox://styles/mapbox/navigation-day-v1",maplibre:"https://tiles.openfreemap.org/styles/liberty",bestFor:["gospel-resources"]},{id:"wayfinder-night",label:"Wayfinder Night",mood:"dark navigation — dashboards at night",mapbox:"mapbox://styles/mapbox/navigation-night-v1",maplibre:"https://tiles.openfreemap.org/styles/fiord",bestFor:["research-dashboard"]},{id:"galaxy",label:"Galaxy",mood:"the day side of Earth floating in space — normal land, blue oceans, black void behind the sphere",mapbox:"mapbox://styles/mapbox/standard",maplibre:"https://tiles.versatiles.org/assets/styles/colorful/style.json",bestFor:["research-dashboard","my-upg-100-list"]}].map(e=>[e.id,e]));function bl(e,t="mapbox"){if(typeof e!="string"||!e)return{style:void 0,lightPreset:void 0,paint:void 0};const o=zw[e];return o?t==="maplibre"?{style:o.maplibre,lightPreset:void 0,paint:o.paint}:{style:o.mapbox,lightPreset:o.lightPreset,paint:o.paint}:/^(mapbox:\/\/|https?:\/\/)/.test(e)?{style:e,lightPreset:void 0,paint:void 0}:{style:void 0,lightPreset:void 0,paint:void 0}}const wg={mapbox:"https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-rtl-text/v0.3.0/mapbox-gl-rtl-text.js",maplibre:"https://cdn.jsdelivr.net/npm/@mapbox/mapbox-gl-rtl-text@0.3.0/dist/mapbox-gl-rtl-text.js"};function Bw(e){return!!e&&typeof window<"u"&&e===window.maplibregl}function Uw(e){if(typeof window>"u")return!1;const t=e?[e]:[window.maplibregl,window.mapboxgl].filter(Boolean);let o=!1;for(const n of t)if(!(!n||!n.setRTLTextPlugin))try{if(Bw(n)){if(n.getRTLTextPluginStatus&&n.getRTLTextPluginStatus()!=="unavailable")continue;const a=n.setRTLTextPlugin(wg.maplibre,!0);a&&a.catch&&a.catch(()=>{})}else n.setRTLTextPlugin(wg.mapbox,null,!0);o=!0}catch{}return o}const Yn={mapbox:{global:"mapboxgl",js:Go.mapboxGlJs.url,css:Go.mapboxGlCss.url},maplibre:{global:"maplibregl",js:Go.maplibreGlJs.url,css:Go.maplibreGlCss.url}};function _l(e){var o;const t=((o=Yn[e])==null?void 0:o.global)||Yn.mapbox.global;return typeof window<"u"?window[t]:void 0}function kg(e){return(Yn[e]||Yn.mapbox).css||null}async function Hw(e){const t=Yn[e]||Yn.mapbox;if(_l(e)||typeof document>"u")return;if(!document.querySelector(`link[href="${t.css}"]`)){const n=document.createElement("link");n.rel="stylesheet",n.href=t.css,za(n,t.css),document.head.appendChild(n)}const o=document.querySelector(`script[src="${t.js}"]`);if(o){if(_l(e))return;await new Promise(n=>{o.addEventListener("load",n,{once:!0}),o.addEventListener("error",n,{once:!0})});return}await new Promise((n,a)=>{const r=document.createElement("script");r.src=t.js,za(r,t.js),r.async=!1,r.addEventListener("load",n,{once:!0}),r.addEventListener("error",()=>a(new Error(`[useMapInstance] Failed to load ${e} engine script`)),{once:!0}),document.head.appendChild(r)})}async function jw(e,t){if(!e)return;const o=e.getRootNode();if(!(o instanceof ShadowRoot))return;const n=i=>new Promise(s=>setTimeout(s,i)),a=o.querySelector(`link[href="${t}"]`);if(a){if(a.sheet)return;await Promise.race([new Promise(i=>{a.addEventListener("load",i,{once:!0}),a.addEventListener("error",i,{once:!0})}),n(2e3)]);return}const r=document.createElement("link");r.rel="stylesheet",r.href=t,za(r,t),await Promise.race([new Promise(i=>{r.addEventListener("load",i,{once:!0}),r.addEventListener("error",i,{once:!0}),o.prepend(r)}),n(2e3)])}function Vw(e,t){return`hsl(${Math.round(e*360/(t||1))}, 72%, 56%)`}function ii(e){if(typeof e.count=="number")return e.count;if(typeof e.expected_count=="number")return e.expected_count}function Pg(e){const t=parseInt(e&&e.population,10);return Number.isFinite(t)?t:0}function Ww(e,t){if(!Array.isArray(t)||t.length===0)return;const o=e&&e.selector;if(o==null)return;if(o.type==="pg_slugs"){const r=new Set(Array.isArray(o.values)?o.values:[]);let i=0;for(const s of t)s&&r.has(s.slug)&&(i+=Pg(s));return i}const n=Vn(o,t);let a=0;for(const r of t)r&&n.has(r.slug)&&(a+=Pg(r));return a}function yl(e,t={}){const o=t.deafCount??123,n=Array.isArray(t.records)?t.records:null,a=typeof t.title=="function"?(I,M)=>t.title(I)||M:(I,M)=>M,r=e.lists||[],i=e.asia_lists||[],s=e.uncovered_lists||[],l={type:"affinity_bloc",rop1:"A017"},u=i.filter(I=>I.id.startsWith("asia-india")),c=i.filter(I=>I.id.startsWith("asia-china")),p=[...r.map(I=>I.id),"deaf",...u.map(I=>I.id),...c.map(I=>I.id),...s.map(I=>I.id)],d=p.length,S=I=>Vw(p.indexOf(I),d),x=(I,M,W)=>{if(!n)return I;const L=W??(M&&M.selector);return I.pop=Ww({selector:L},n),I},b=I=>n?I.reduce((M,W)=>M+(W.pop||0),0):void 0,h=r.map(I=>x({id:I.id,zoneKey:I.id,label:a(I,I.label),...I.provinceLabel?{provinceLabel:I.provinceLabel}:{},color:S(I.id),count:ii(I)},I)),g=x({id:"deaf",zoneKey:"deaf",label:"Deaf (affinity bloc A017)",color:S("deaf"),count:o,info:"Unified deaf row — affinity bloc rop1=A017 (collapses the two deaf_lists; zero-delta vs old deaf_predicate). Population double-counts vs geographic rows (design-approved, slice 08)."},null,l),f=I=>x({id:I.id,zoneKey:I.id,label:a(I,I.label),...I.provinceLabel?{provinceLabel:I.provinceLabel}:{},color:S(I.id),count:ii(I),...Array.isArray(I.adm0)&&I.adm0.length?{adm0:I.adm0}:{},...Array.isArray(I.provinces)&&I.provinces.length?{provinces:I.provinces}:{}},I),m=u.map(f),y=c.map(f),_=I=>I.reduce((M,W)=>M+(ii(W)||0),0),T={id:"asia-india",label:"India",count:_(u),children:m},P={id:"asia-china",label:"China",count:_(c),children:y};n&&(T.pop=b(m),P.pop=b(y)),_(i),n&&b([T,P]);const E=I=>x({id:I.id,zoneKey:I.id,label:a(I,I.label),...I.provinceLabel?{provinceLabel:I.provinceLabel}:{},color:S(I.id),count:ii(I)},I),v=s.map(E);v.length>0&&(()=>{const I={id:"frontier-asia",label:"Frontier Asia (uncovered)",count:_(s),children:v};return n&&(I.pop=b(v)),I})();const j={"west-africa":"Africa",sudan:"Africa","east-africa":"Africa","central-africa":"Africa","southern-africa-islands":"Africa","maghreb-egypt":"Middle East","middle-east-core":"Middle East","uncovered-nas-a":"Central Asia",laos:"Southeast Asia + Oceania","oceania-indonesia":"Southeast Asia + Oceania","mainland-se-asia-philippines":"Southeast Asia + Oceania",brazil:"Americas","andean-caribbean":"Americas","uncovered-scatter":"Americas",europe:"Europe",deaf:"Deaf","deaf-old-world":"Deaf"},re=I=>j[I]||(String(I).startsWith("asia-india-")?"India":String(I).startsWith("asia-china-")?"China + Mongolia":"Other"),Z=[...h,g,...m,...y,...v].filter(Boolean),G=new Map;for(const I of Z){const M=re(I.id||I.zoneKey);G.has(M)||G.set(M,[]),G.get(M).push(I)}const pe=[...G.entries()].map(([I,M])=>{M.sort((L,O)=>(O.count||0)-(L.count||0));const W={id:"region-"+I.toLowerCase().replace(/[^a-z0-9]+/g,"-"),label:I,count:M.reduce((L,O)=>L+(O.count||0),0),children:M};return n&&(W.pop=b(M)),W}).sort((I,M)=>(M.count||0)-(I.count||0));return Kw(xg(pe),{withPop:!!n}),pe}function Kw(e,{withPop:t=!1}={}){const o=[];for(const n of e||[]){const a=[];(typeof n.id!="string"||!n.id)&&a.push("id"),(typeof n.zoneKey!="string"||!n.zoneKey)&&a.push("zoneKey"),(typeof n.label!="string"||!n.label)&&a.push("label"),(typeof n.color!="string"||!n.color)&&a.push("color"),typeof n.count!="number"&&a.push("count"),t&&typeof n.pop!="number"&&a.push("pop"),a.length&&o.push(`${n.id||"(no-id)"}: missing/!type [${a.join(", ")}]`)}if(o.length)throw new Error(`legend-tree L15: ${o.length} leaf node(s) violate the uniform consumer shape: +`,"map-control-button"),(t,o)=>(q(),ae("button",{class:Ge(["mcb",{dark:e.isDark,active:e.active,"mcb--square":e.shape==="square"}]),title:e.title,"aria-label":e.title||void 0,disabled:e.disabled,onClick:o[0]||(o[0]=n=>t.$emit("click"))},[Rn(t.$slots,"default")],10,sw))}},lw={__name:"ZoomInButton",props:{map:{type:Object,default:null},isDark:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1}},setup(e){const{t}=xt(),o=e;function n(){var a;o.disabled||(a=o.map)==null||a.zoomIn()}return(a,r)=>(q(),dt(wn,{"data-control":"zoom-in","is-dark":e.isDark,disabled:e.disabled,title:me(t)("buttons.zoomIn"),onClick:n},{default:Xt(()=>[...r[0]||(r[0]=[R("span",{style:{"font-size":"20px","line-height":"1","font-weight":"600"}},"+",-1)])]),_:1},8,["is-dark","disabled","title"]))}},cw={__name:"ZoomOutButton",props:{map:{type:Object,default:null},isDark:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1}},setup(e){const{t}=xt(),o=e;function n(){var a;o.disabled||(a=o.map)==null||a.zoomOut()}return(a,r)=>(q(),dt(wn,{"data-control":"zoom-out","is-dark":e.isDark,disabled:e.disabled,title:me(t)("buttons.zoomOut"),onClick:n},{default:Xt(()=>[...r[0]||(r[0]=[R("span",{style:{"font-size":"22px","line-height":"1","font-weight":"600"}},"−",-1)])]),_:1},8,["is-dark","disabled","title"]))}},uw={__name:"LocationButton",props:{map:{type:Object,default:null},isDark:{type:Boolean,default:!1},center:{type:Array,default:()=>[20,10]},zoom:{type:Number,default:1.8},userZoom:{type:Number,default:10}},setup(e){const{t}=xt(),o=e;function n(){var r;(r=o.map)==null||r.flyTo({center:o.center,zoom:o.zoom,duration:1200})}function a(){if(o.map){if(typeof navigator>"u"||!navigator.geolocation){n();return}navigator.geolocation.getCurrentPosition(r=>{const{longitude:i,latitude:s}=r.coords;Number.isFinite(i)&&Number.isFinite(s)?o.map.flyTo({center:[i,s],zoom:o.userZoom,duration:1500}):n()},()=>n(),{enableHighAccuracy:!1,timeout:5e3,maximumAge:6e4})}}return(r,i)=>(q(),dt(wn,{"data-control":"location","is-dark":e.isDark,title:me(t)("buttons.resetView"),onClick:a},{default:Xt(()=>[...i[0]||(i[0]=[R("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor"},[R("path",{d:"M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5A2.5 2.5 0 1 1 12 6.5a2.5 2.5 0 0 1 0 5z"})],-1)])]),_:1},8,["is-dark","title"]))}},dw={key:0,xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 29 29",fill:"currentColor"},pw={key:1,xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 29 29",fill:"currentColor"},gw={__name:"FullscreenButton",props:{mapContainer:{type:Object,default:null},isDark:{type:Boolean,default:!1}},emits:["change"],setup(e,{emit:t}){const{t:o}=xt(),n=e,a=t,r=be(!1);let i=null,s=null,l=null,u=null,c=null,p=null,d=null,S=null,x=null,b=null,h=null,g=0,f=0,m=null,y=null;function _(){if(typeof document>"u")return!1;const I=typeof navigator<"u"&&navigator.userAgent||"";return/iPad|iPhone|iPod/.test(I)||I.includes("Mac")&&typeof document<"u"&&"ontouchend"in document?!1:!!(document.fullscreenEnabled||document.webkitFullscreenEnabled)}function T(){var I,M,W;return((W=(M=(I=n.mapContainer)==null?void 0:I.getRootNode)==null?void 0:M.call(I))==null?void 0:W.host)??null}function P(){var M,W;const I=(W=(M=n.mapContainer)==null?void 0:M.getRootNode)==null?void 0:W.call(M);return document.fullscreenElement||document.webkitFullscreenElement||(I&&I instanceof ShadowRoot?I.fullscreenElement:null)||null}function E(I){const M=I.requestFullscreen||I.webkitRequestFullscreen;if(!M)return Promise.reject(new Error("Fullscreen API unavailable"));const W=M.call(I);return W&&typeof W.then=="function"?W:Promise.resolve()}function v(){const I=document.exitFullscreen||document.webkitExitFullscreen;if(!I)return Promise.reject(new Error("Fullscreen API unavailable"));const M=I.call(document);return M&&typeof M.then=="function"?M:Promise.resolve()}function j(){const I=T();if(!I)return!1;if(l=I,s=I.style.cssText,I.style.position="fixed",I.style.top="0",I.style.left="0",I.style.right="0",I.style.bottom="0",I.style.width="100vw",I.style.height="100vh",I.style.height="100dvh",I.style.zIndex="2147483647",I.style.margin="0",I.style.borderRadius="0",I.style.touchAction="pan-x pan-y pinch-zoom",typeof document<"u"){g=window.scrollY||window.pageYOffset||0,f=window.scrollX||window.pageXOffset||0;const M=document.body,W=document.documentElement;u=M?M.style.overflow:null,c=W?W.style.overflow:null,p=M?M.style.position:null,d=M?M.style.top:null,S=M?M.style.left:null,x=M?M.style.width:null,b=M?M.style.touchAction:null,h=W?W.style.touchAction:null,W&&(W.style.overflow="hidden",W.style.touchAction="none"),M&&(M.style.overflow="hidden",M.style.position="fixed",M.style.top=`-${g}px`,M.style.left=`-${f}px`,M.style.width="100%",M.style.touchAction="none"),m=L=>{if(!l)return;const O=L.target;O&&(O===l||l.contains&&l.contains(O))||L.cancelable&&L.preventDefault()},y=L=>{if(!l)return;const O=L.target;O&&(O===l||l.contains&&l.contains(O))||L.cancelable&&L.preventDefault()},document.addEventListener("touchmove",m,{passive:!1,capture:!0}),document.addEventListener("wheel",y,{passive:!1,capture:!0})}return!0}function re(){if(l){if(l.style.cssText=s||"",l=null,s=null,typeof document<"u"){const I=document.body,M=document.documentElement;I&&(I.style.overflow=u??"",I.style.position=p??"",I.style.top=d??"",I.style.left=S??"",I.style.width=x??"",I.style.touchAction=b??""),M&&(M.style.overflow=c??"",M.style.touchAction=h??""),m&&(document.removeEventListener("touchmove",m,{capture:!0}),m=null),y&&(document.removeEventListener("wheel",y,{capture:!0}),y=null),typeof window<"u"&&(g||f)&&window.scrollTo(f,g)}u=null,c=null,p=null,d=null,S=null,x=null,b=null,h=null,g=0,f=0}}function Z(){typeof window>"u"||window.requestAnimationFrame(()=>{window.dispatchEvent(new Event("resize"))})}function G(){if(!_()){r.value?(re(),r.value=!1,a("change",!1)):j()&&(r.value=!0,a("change",!0)),Z();return}if(P())v().then(()=>{r.value=!1,a("change",!1)}).catch(()=>{});else{const M=T()??document.documentElement;E(M).then(()=>{r.value=!0,a("change",!0)}).catch(()=>{E(document.documentElement).then(()=>{r.value=!0,a("change",!0)}).catch(()=>{})})}}function pe(){r.value=!!P(),a("change",r.value)}return io(()=>{var M,W;document.addEventListener("fullscreenchange",pe),document.addEventListener("webkitfullscreenchange",pe);const I=(W=(M=n.mapContainer)==null?void 0:M.getRootNode)==null?void 0:W.call(M);I instanceof ShadowRoot&&(i=I,I.addEventListener("fullscreenchange",pe),I.addEventListener("webkitfullscreenchange",pe))}),Qt(()=>{document.removeEventListener("fullscreenchange",pe),document.removeEventListener("webkitfullscreenchange",pe),i&&(i.removeEventListener("fullscreenchange",pe),i.removeEventListener("webkitfullscreenchange",pe),i=null),l&&re()}),(I,M)=>(q(),dt(wn,{"data-control":"fullscreen","is-dark":e.isDark,active:r.value,title:me(o)("buttons.toggleFullscreen"),onClick:G},{default:Xt(()=>[r.value?(q(),ae("svg",pw,[...M[1]||(M[1]=[R("path",{d:"M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1h-5.5zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1v-5.5zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1v5.5zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1h5.5z"},null,-1)])])):(q(),ae("svg",dw,[...M[0]||(M[0]=[R("path",{d:"M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3h1zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16h1zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5H13zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1V7.5z"},null,-1)])]))]),_:1},8,["is-dark","active","title"]))}},hw={style:{"font-size":"16px","line-height":"1"}},fw={__name:"ThemeToggleButton",props:{isDark:{type:Boolean,default:!1}},emits:["toggle"],setup(e){const{t}=xt();return(o,n)=>me(fy)?(q(),dt(wn,{key:0,"data-control":"theme","is-dark":e.isDark,title:e.isDark?me(t)("buttons.switchToLightMode"):me(t)("buttons.switchToDarkMode"),onClick:n[0]||(n[0]=a=>o.$emit("toggle"))},{default:Xt(()=>[R("span",hw,de(e.isDark?"☀️":"🌙"),1)]),_:1},8,["is-dark","title"])):we("",!0)}},Go={mapboxGlJs:{url:"https://api.mapbox.com/mapbox-gl-js/v3.24.0/mapbox-gl.js",integrity:"sha384-tO0clamXONKwbiz7O6xJpUeyJbTSPugC+xM9clvfFvKTH3i8SmCawHGdf5quMWmZ"},mapboxGlCss:{url:"https://api.mapbox.com/mapbox-gl-js/v3.24.0/mapbox-gl.css",integrity:"sha384-rp1X/jJ9MpWPef9OimfXhOaOc4Gzs87yQvF+ajwY6X2H4PTeHNycNlLWiWvj7ehV"},maplibreGlJs:{url:"https://cdn.jsdelivr.net/npm/maplibre-gl@5.24.0/dist/maplibre-gl.js",integrity:"sha384-5+cfbwT0iiub6VsQAdn6yz16nr6sDiQoHx6tm4O8OVYXHYOxcffFmCJBL0dgdvGp"},maplibreGlCss:{url:"https://cdn.jsdelivr.net/npm/maplibre-gl@5.24.0/dist/maplibre-gl.css",integrity:"sha384-uTttxo/aOKbdE5RlD/SPzSDoDmNvGlUYPjONi2MN/b7c9HPSvW07OIuyP7uL6jxK"},mapboxGeocoderJs:{url:"https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v5.0.0/mapbox-gl-geocoder.min.js",integrity:"sha384-Lx9WK8XhZk57czwxt6B6nyaDHB5Ayrcrsu4Fw4bCp/Ot/QLOsUZ0xYqLOpOOSXZw"},mapboxGeocoderCss:{url:"https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v5.0.0/mapbox-gl-geocoder.css",integrity:"sha384-1KNhwJNCQTr0DCi/5/OnQcFytgycxTahxNZaqKbAtqmY8bUhu26qxXqvDGXXwplS"},maplibreGeocoderJs:{url:"https://cdn.jsdelivr.net/npm/@maplibre/maplibre-gl-geocoder@1.9.4/dist/maplibre-gl-geocoder.min.js",integrity:"sha384-RGV5vfoJd7alk8HE+71IyVfu19ciH1FKA15+AuXs6OeBM2npXrmTPFqG23yMiHXi"},maplibreGeocoderCss:{url:"https://cdn.jsdelivr.net/npm/@maplibre/maplibre-gl-geocoder@1.9.4/dist/maplibre-gl-geocoder.css",integrity:"sha384-UkDpPApjTpHJHpcJiSNAmbobh30W0/dmt0DoKm4V8CWYRYvQ/Jhd/ijFz0tFdVnH"},d3:{url:"https://cdn.jsdelivr.net/npm/d3@7.9.0/dist/d3.min.js",integrity:"sha384-CjloA8y00+1SDAUkjs099PVfnY2KmDC2BZnws9kh8D/lX1s46w6EPhpXdqMfjK6i"}};function za(e,t){const o=Object.values(Go).find(n=>n.url===t);return o&&(e.integrity=o.integrity,e.crossOrigin="anonymous"),e}const mw=["blocs","clusters","peopleGroups","families","languages","dialects","people","places","regions","wagfBlocks","religions"],bw={"people-groups":["blocs","clusters","peopleGroups","people","places","families","languages","dialects","regions","religions"],language:["families","languages","dialects","people","blocs","clusters","peopleGroups","places","regions","religions"],regions:["regions","wagfBlocks","places","blocs","clusters","peopleGroups","people","families","languages","dialects","religions"],religion:["religions","people","blocs","clusters","peopleGroups","places","families","languages","dialects","regions"]};function _w(e){return bw[e]||mw}const yw={blocs:3,clusters:3,peopleGroups:3,families:3,languages:3,dialects:3,people:5,places:2,regions:3,wagfBlocks:3,religions:2},ai=["peopleGroups","people","places","languages","religions"],$w={regions:[...ai,"regions","wagfBlocks"],"people-groups":[...ai,"blocs","clusters"],language:[...ai,"dialects","families"],religion:[...ai]},vw=100,ww=50,kw=25,Pw=10,fl=5,mg=20,xw=[[/ sign language$/i,"Sign Language"]];function Sw(e){if(!e||typeof e!="string")return"";const t=e.indexOf(",");return t>0?e.slice(0,t).trim():e.trim()}function Aw(e){if(!e||typeof e!="string")return null;const t=e.indexOf(",");return t>=0&&e.slice(t+1).trim()||null}function Lw(e){if(!e||typeof e!="string")return null;const t=e.split(",").map(n=>n.trim()).filter(Boolean);if(t.length>=2){const n=[...t].reverse().join(" ");if(Gt[n])return Gt[n];if(t.length>=3){const a=[t[1],t[0]].join(" ");if(Gt[a])return Gt[a]}}if(Gt[e])return Gt[e];const o=e.replace(/\s*\(.*?\)\s*$/,"").trim();if(o!==e&&Gt[o])return Gt[o];for(const[n,a]of xw)if(n.test(e))return a;return null}function bg(e,t){return{id:`doxa-section-header-${ml(e)}`,place_name:e,text:e,center:[0,0],place_type:["doxa-section-header"],geometry:{type:"Point",coordinates:[0,0]},properties:{headerLabel:e,isHeader:!0,isAllDataSection:!!t},feature:null}}function ml(e){return String(e||"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function Fe(e){return e==null?"":typeof e=="string"?e.toLowerCase():typeof e=="object"&&"label"in e?String(e.label||"").toLowerCase():typeof e=="object"&&"value"in e?String(e.value||"").toLowerCase():String(e).toLowerCase()}function ri(e){return e==null?"":typeof e=="string"?e:typeof e=="object"?e.label||e.value||"":String(e)}function Cw(e){var o,n,a,r,i;if(!Array.isArray(e))return[];const t=[];for(const s of e){if(!s)continue;const l=Number(s.latitude),u=Number(s.longitude);if(!Number.isFinite(l)||!Number.isFinite(u))continue;const c=Fe(s.name)+" "+Fe(s.displayName)+" "+Fe(s.alternateName),p=Fe(s.countryName)+" "+Fe(s.country)+" "+Fe(s.countryIso)+" "+Fe(s.countryIsoLabel),d=Fe(s.religionName)+" "+Fe(s.religion)+" "+Fe(s.religionLabel)+" "+Fe(s.religionCode),S=Fe(s.language)+" "+Fe(s.languageFamily)+" "+Fe(s.languageCode),x=Fe(s.doxaRegion)+" "+Fe(s.wagfRegion)+" "+Fe(s.wagfBlock),b=Fe(s.affinityBlock)+" "+Fe(s.affinityBlockLabel)+" "+Fe((o=s._raw)==null?void 0:o.rop1),h=Fe(s.cluster)+" "+Fe(s.clusterLabel)+" "+Fe((n=s._raw)==null?void 0:n.imb_reg_of_people_2),g=Fe(s.peopleGroup)+" "+Fe(s.peopleGroupLabel)+" "+Fe((a=s._raw)==null?void 0:a.imb_reg_of_people_25),f=((r=s._raw)==null?void 0:r.primary_language)??((i=s._raw)==null?void 0:i.PrimaryLanguage),m=f&&(typeof f=="object"?f.label||f.value:f)||ri(s.language)||ri(s.primaryLanguage)||"",y=Sw(m),_=Aw(m);t.push({feature:s,nameHay:c,countryHay:p,religionHay:d,languageHay:S,regionHay:x,haystack:c+" "+p+" "+d+" "+S+" "+x+" "+b+" "+h+" "+g,blocHay:b,clusterHay:h,pgHay:g,lat:l,lng:u,familyDerived:Lw(m)||null,languageLabel:m,baseLang:y,dialectLabel:_})}return t}function Tw(e){const t=(o,n,a)=>{const r=new Map;for(const i of e){const s=o(i);if(!s)continue;const l=r.get(s);if(l)l.count+=1,l.lngSum+=i.lng,l.latSum+=i.lat,l.memberIds.push(String(i.feature.uniqueId??i.feature.id??i.feature.slug??"")),l.minLng=Math.min(l.minLng,i.lng),l.maxLng=Math.max(l.maxLng,i.lng),l.minLat=Math.min(l.minLat,i.lat),l.maxLat=Math.max(l.maxLat,i.lat),a&&a(l,i,!1);else{const u={key:s,label:ri(n(i))||s,count:1,lngSum:i.lng,latSum:i.lat,minLng:i.lng,maxLng:i.lng,minLat:i.lat,maxLat:i.lat,memberIds:[String(i.feature.uniqueId??i.feature.id??i.feature.slug??"")]};a&&a(u,i,!0),r.set(s,u)}}for(const i of r.values())i.lng=i.lngSum/i.count,i.lat=i.latSum/i.count;return Array.from(r.values())};return{countries:t(o=>Fe(o.feature.countryName)||Fe(o.feature.country)||Fe(o.feature.countryIso),o=>o.feature.countryName||o.feature.country||o.feature.countryIso||""),families:t(o=>Fe(o.familyDerived),o=>o.familyDerived||""),languages:t(o=>Fe(o.baseLang),o=>o.baseLang||""),dialects:t(o=>o.dialectLabel?`${Fe(o.baseLang)}__${Fe(o.dialectLabel)}`:"",o=>`${o.baseLang}, ${o.dialectLabel}`,(o,n,a)=>{a?(o.originalLabels=new Set([n.languageLabel]),o.familyDerived=n.familyDerived||"",o.baseLang=n.baseLang||"",o.dialectLabel=n.dialectLabel||""):(o.originalLabels.add(n.languageLabel),!o.familyDerived&&n.familyDerived&&(o.familyDerived=n.familyDerived))}),religions:t(o=>{var n,a,r;return Fa(o.feature.religion||((a=(n=o.feature._raw)==null?void 0:n.religion)==null?void 0:a.value)||((r=o.feature._raw)==null?void 0:r.religion)||"")},o=>{var n,a,r;return il(Fa(o.feature.religion||((a=(n=o.feature._raw)==null?void 0:n.religion)==null?void 0:a.value)||((r=o.feature._raw)==null?void 0:r.religion)||""))||"Unknown"}),regions:t(o=>Fe(o.feature.doxaRegion)||Fe(o.feature.wagfRegion),o=>{var n,a;return o.feature.wagfRegionLabel||o.feature.doxaRegionLabel||((a=(n=o.feature._raw)==null?void 0:n.wagf_region)==null?void 0:a.label)||o.feature.doxaRegion||o.feature.wagfRegion||""}),wagfBlocks:t(o=>Fe(o.feature.wagfBlock),o=>{var n,a;return o.feature.wagfBlockLabel||((a=(n=o.feature._raw)==null?void 0:n.wagf_block)==null?void 0:a.label)||o.feature.wagfBlock||""}),blocs:t(o=>Fe(o.feature.affinityBlockLabel)||Fe(o.feature.affinityBlock),o=>o.feature.affinityBlockLabel||o.feature.affinityBlock||"",(o,n,a)=>{a&&(o.blocCode=n.feature.affinityBlock||"")}),clusters:t(o=>{const n=o.feature.affinityBlock||"",a=o.feature.cluster||"";return a?`${n}__${a}`:""},o=>o.feature.clusterLabel||o.feature.cluster||"",(o,n,a)=>{a&&(o.blocCode=n.feature.affinityBlock||"",o.blocLabel=n.feature.affinityBlockLabel||"",o.clusterCode=n.feature.cluster||"")}),peopleGroups:t(o=>Fe(o.feature.peopleGroup)||Fe(o.feature.peopleGroupLabel),o=>o.feature.peopleGroupLabel||o.feature.peopleGroup||o.feature.name||"",(o,n,a)=>{a&&(o.blocCode=n.feature.affinityBlock||"",o.blocLabel=n.feature.affinityBlockLabel||"",o.clusterCode=n.feature.cluster||"",o.clusterLabel=n.feature.clusterLabel||"",o.peopleGroupCode=n.feature.peopleGroup||"")})}}function Ew(e){const t=e.feature,o=t.name||t.displayName||t.slug||"Unknown",n=t.countryName||t.country||t.countryIso||"",a=t.religionName||t.religion||"",r=t.slug||t.uniqueId||ml(o+"-"+n),i=[e.lng,e.lat],s=[n,a].filter(Boolean).join(" — "),l=s?`${o}, ${s}`:o;return{id:`doxa-pg-${r}`,place_name:l,text:o,center:i,place_type:["people-group"],geometry:{type:"Point",coordinates:i},properties:{slug:r,...t},feature:t}}function wo(e,t){let o,n;switch(e){case"country":o="doxa-country",n="doxa-country-";break;case"region":o="doxa-region",n="doxa-region-";break;case"language-family":o="doxa-language-family",n="doxa-language-family-";break;case"language":o="doxa-language",n="doxa-language-";break;case"dialect":o="doxa-dialect",n="doxa-dialect-";break;case"religion":o="doxa-religion",n="doxa-religion-";break;case"affinity-bloc":o="doxa-affinity-bloc",n="doxa-affinity-bloc-";break;case"cluster":o="doxa-cluster",n="doxa-cluster-";break;case"people-group":o="doxa-people-group",n="doxa-people-group-";break;default:o="doxa",n="doxa-"}const a=ri(t.label)||t.key,r=ml(t.key),i=[t.lng,t.lat],l={"affinity-bloc":"Affinity Block",cluster:"Cluster","people-group":"PG","pg-in-country":"PGIC"}[e],u=l?`${a} (${l}) · ${t.count}`:`${a} (${t.count})`,c=t.originalLabels?Array.from(t.originalLabels):void 0,p=e==="dialect"?{familyDerived:t.familyDerived||"",baseLang:t.baseLang||"",dialectLabel:t.dialectLabel||""}:null;return{id:`${n}${r}`,place_name:u,text:a,center:i,bbox:[t.minLng,t.minLat,t.maxLng,t.maxLat],place_type:[o],geometry:{type:"Point",coordinates:i},properties:{slug:r,doxaAggregate:e,count:t.count,label:a,memberIds:t.memberIds,bounds:[t.minLng,t.minLat,t.maxLng,t.maxLat],...c?{originalLabels:c}:{},...p||{},...e==="affinity-bloc"?{blocCode:t.blocCode||""}:{},...e==="cluster"?{blocCode:t.blocCode||"",blocLabel:t.blocLabel||"",clusterCode:t.clusterCode||""}:{},...e==="people-group"?{blocCode:t.blocCode||"",blocLabel:t.blocLabel||"",clusterCode:t.clusterCode||"",clusterLabel:t.clusterLabel||"",peopleGroupCode:t.peopleGroupCode||""}:{}},feature:null}}function Rw(e={}){const{dataStore:t,dataSourceId:o,getActiveFilter:n,getActiveContext:a}=e,{t:r}=xt(),i=X(()=>{var p,d;if(!t||!t.sources)return[];if(o&&((p=t.sources[o])!=null&&p.features))return t.sources[o].features;for(const S of Object.keys(t.sources)){const x=t.sources[S];if((d=x==null?void 0:x.features)!=null&&d.length)return x.features}return[]}),s=X(()=>Cw(i.value)),l=X(()=>Tw(s.value));function u(p){const d=String(p||"").trim().toLowerCase(),S={people:[],places:[],regions:[],wagfBlocks:[],families:[],languages:[],dialects:[],religions:[],blocs:[],clusters:[],peopleGroups:[]};if(d.length<2)return S;const x=d.split(/[\s,;]+/).filter(Boolean);if(!x.length)return S;const b=s.value;if(!b.length)return S;const h=l.value,g=[];for(const M of b){let W=!0;for(const O of x)if(!M.haystack.includes(O)){W=!1;break}if(!W)continue;let L=0;x.some(O=>M.nameHay.includes(O))&&(L+=vw),x.some(O=>M.countryHay.includes(O))&&(L+=ww),x.some(O=>M.religionHay.includes(O))&&(L+=kw),x.some(O=>M.languageHay.includes(O))&&(L+=Pw),g.push({entry:M,score:L})}g.sort((M,W)=>W.score-M.score);const f=g.slice(0,fl).map(M=>Ew(M.entry)),m=M=>M.filter(W=>x.every(L=>W.key.includes(L)||Fe(W.label).includes(L))).sort((W,L)=>L.count-W.count).slice(0,fl),y=m(h.countries).map(M=>wo("country",M)),_=m(h.regions).map(M=>wo("region",M)),T=m(h.wagfBlocks).map(M=>wo("region",M)),P=m(h.families).map(M=>wo("language-family",M)),E=m(h.languages).map(M=>wo("language",M)),v=m(h.dialects).map(M=>wo("dialect",M)),j=m(h.religions).map(M=>wo("religion",M)),re=m(h.blocs).map(M=>wo("affinity-bloc",M));let Z=m(h.clusters).map(M=>wo("cluster",M)),G=m(h.peopleGroups).map(M=>wo("people-group",M));const pe=new Set(re.map(M=>Fe(M.text)));Z=Z.filter(M=>!pe.has(Fe(M.text)));const I=new Set(Z.map(M=>Fe(M.text)));return G=G.filter(M=>!pe.has(Fe(M.text))&&!I.has(Fe(M.text))),{people:f,places:y,regions:_,wagfBlocks:T,families:P,languages:E,dialects:v,religions:j,blocs:re,clusters:Z,peopleGroups:G}}function c(p){const d=typeof n=="function"?n():null,S=typeof a=="function"?a():null,x=u(p),b=_w(S),h=$w[S],g=h?Object.fromEntries(h.filter(P=>x[P]).map(P=>[P,x[P]])):x,f=b.flatMap(P=>g[P]||[]);if(!(d!=null&&d.key)||!f.length)return f.slice(0,mg);const m=[];for(const P of x.people){const E=s.value.find(j=>j.feature===P.feature);let v=!1;E&&(d.kind==="family"?v=(E.familyDerived||"").toLowerCase()===d.key.toLowerCase():d.kind==="language"&&(v=E.languageLabel.toLowerCase()===d.key.toLowerCase())),v&&m.push(P)}const y=[],_=d.key;m.length&&(y.push(bg(r("search.sections.within",{selection:_}),!1)),y.push(...m.slice(0,fl)));const T=b.flatMap(P=>(g[P]||[]).slice(0,yw[P]??3)).map(P=>({...P,properties:{...P.properties,_allDataSection:!0}}));return y.push(bg(r("search.sections.allData"),!0)),y.push(...T),y.slice(0,mg+8)}return{search:c,searchGrouped:u,index:s,aggregates:l}}const Nw={__name:"GeocoderComponent",props:{mapInstance:{type:Object,required:!1,default:null},accessToken:{type:String,required:!0},provider:{type:String,default:"mapbox"},isDark:{type:Boolean,default:!1},standalone:{type:Boolean,default:!1},placeholder:{type:String,default:""},dataSourceId:{type:String,default:""},activeContext:{type:String,default:""}},emits:["result","people-group-result","aggregate-result","clear","error"],setup(e,{expose:t,emit:o}){function n(L){return L+L.replace(/mapboxgl/g,"maplibregl")}Tt(n('.mapboxgl-ctrl-geocoder--input,.mapboxgl-ctrl-geocoder input[type="text"],.mapboxgl-ctrl-geocoder input[type="search"]{font-size:16px !important;line-height:1.3;}'),"geocoder-ios-zoom-fix"),Tt(n(".mapboxgl-ctrl-geocoder--icon-loading{display:none !important;}"),"geocoder-hide-loading"),Tt(n(".mapboxgl-ctrl-geocoder{height:35px!important;min-height:35px!important;box-sizing:border-box!important;}.mapboxgl-ctrl-geocoder--input{height:35px!important;min-height:35px!important;box-sizing:border-box!important;padding-top:0!important;padding-bottom:0!important;line-height:35px!important;}.mapboxgl-ctrl-geocoder--icon-search{top:50%!important;transform:translateY(-50%)!important;margin-top:0!important;left:7px!important;}"),"geocoder-height-35"),Tt(n(".mapboxgl-ctrl-geocoder{width:100%!important;max-width:100%!important;min-width:0!important;}@media(max-width:767px){.dg-search-band{top:0!important;left:0!important;right:0!important;width:100%!important;max-width:none!important;margin:0!important;box-sizing:border-box!important;padding:9px 14px!important;background:#fff;box-shadow:0 1px 4px rgba(0,0,0,0.10);}.dg-search-band--dark{background:#3b463d;box-shadow:0 1px 4px rgba(0,0,0,0.35);}.dg-search-band .mapboxgl-ctrl,.dg-search-band .maplibregl-ctrl{margin:0!important;float:none!important;}}.mapboxgl-ctrl-geocoder{border-radius:999px!important;background:#fff;box-shadow:0 2px 8px rgba(0,0,0,0.15)!important;transition:box-shadow .12s,border-color .12s;}.mapboxgl-ctrl-geocoder:focus-within{box-shadow:0 2px 8px rgba(0,0,0,0.15),0 0 0 3px rgba(59,70,61,0.18)!important;}.mapboxgl-ctrl-geocoder--input{border-radius:999px!important;font-size:13px!important;}.mapboxgl-ctrl-geocoder--input::placeholder{font-size:12px!important;}.mapboxgl-ctrl-geocoder--button{display:none!important;top:50%!important;bottom:auto!important;transform:translateY(-50%)!important;margin:0!important;padding:0!important;width:24px!important;height:24px!important;background:transparent!important;border:none!important;box-shadow:none!important;}.mapboxgl-ctrl-geocoder:has(.mapboxgl-ctrl-geocoder--input:not(:placeholder-shown)) .mapboxgl-ctrl-geocoder--button{display:block!important;}.mapboxgl-ctrl-geocoder--button .mapboxgl-ctrl-geocoder--icon-close{position:absolute!important;top:50%!important;left:50%!important;transform:translate(-50%,-50%)!important;margin:0!important;width:16px!important;height:16px!important;}.mapboxgl-ctrl-geocoder--suggestions,.mapboxgl-ctrl-geocoder .suggestions{z-index:1200!important;position:absolute;max-height:60vh!important;overflow-y:auto!important;}.geocoder-dark.mapboxgl-ctrl-geocoder,.dsm-dark .mapboxgl-ctrl-geocoder{background:#4e594f!important;border:1px solid rgba(255,255,255,0.14)!important;box-shadow:0 2px 8px rgba(0,0,0,0.4)!important;}.geocoder-dark.mapboxgl-ctrl-geocoder:focus-within,.dsm-dark .mapboxgl-ctrl-geocoder:focus-within{box-shadow:0 2px 8px rgba(0,0,0,0.4),0 0 0 3px rgba(115,161,127,0.22)!important;}.geocoder-dark .mapboxgl-ctrl-geocoder--input,.dsm-dark .mapboxgl-ctrl-geocoder--input{color:#F3F3F1!important;background:transparent!important;}.geocoder-dark .mapboxgl-ctrl-geocoder--input::placeholder,.dsm-dark .mapboxgl-ctrl-geocoder--input::placeholder{color:rgba(243,243,241,0.65)!important;}.geocoder-dark .mapboxgl-ctrl-geocoder--icon,.dsm-dark .mapboxgl-ctrl-geocoder .mapboxgl-ctrl-geocoder--icon{fill:rgba(243,243,241,0.75)!important;}.geocoder-dark .mapboxgl-ctrl-geocoder--button,.dsm-dark .mapboxgl-ctrl-geocoder--button{background:transparent!important;}"),"geocoder-skin");const{t:a,locale:r}=xt(),i=e,s=X(()=>/^pk\./.test(String(i.accessToken||""))),l=X(()=>i.placeholder||(i.provider==="maplibre"&&!s.value?a("search.placeholderNoPlaces"):a("search.placeholder"))),u=o,c={"&":"&","<":"<",">":">",'"':""","'":"'"};function p(L){return String(L??"").replace(/[&<>"']/g,O=>c[O])}function d(L){return L==null?"":typeof L=="string"?L:typeof L=="object"?L.label||L.value||"":String(L)}const S={"people-group":"people","doxa-people-group":"peopleGroup","doxa-affinity-bloc":"bloc","doxa-cluster":"cluster","doxa-country":"country","doxa-region":"region","doxa-language-family":"family","doxa-language":"languageKind","doxa-dialect":"dialect","doxa-religion":"religionKind"};function x(L){const O=S[L];if(!O)return"";const V=a("search.kinds."+O);return`${p(V)}`}function b(L){var ne;if(!L)return"";const O=L.place_type||[];if(O.includes("doxa-section-header"))return`
${p(((ne=L.properties)==null?void 0:ne.headerLabel)||L.text||"")}
`;if(O.includes("people-group")){const ue=L.properties||{},Pe=d(ue.name)||d(ue.displayName)||d(L.text)||"",ye=d(ue.countryName)||d(ue.country)||d(ue.countryIso)||"",Be=d(ue.language)||d(ue.primaryLanguage)||d(ue.languageFamily)||"",se=d(ue.religionName)||d(ue.religion)||"",he=a("search.labels.place"),ce=a("search.labels.language"),Se=a("search.labels.religion"),K=[];return ye&&K.push(`${p(he)} ${p(ye)}`),Be&&K.push(`${p(ce)} ${p(Be)}`),se&&K.push(`${p(Se)} ${p(se)}`),`
${x("people-group")}${p(Pe)}
`+(K.length?`
${K.join("")}
`:"")}const V=O.find(ue=>ue.startsWith("doxa-"));if(V){const ue=L.properties||{},Pe=p(d(ue.label)||L.text||""),ye=Number(ue.count)||0,Be=ye?` ${ye}`:"";return`
${x(V)}${Pe}${Be}
`}return`
${p(L.place_name||L.text||"")}
`}const h=He("dataStore",null),g=He("mapStore",null),f=He("uiStore",null);function m(){return g?g.selectedFamily?{kind:"family",key:g.selectedFamily}:g.selectedLanguage?{kind:"language",key:g.selectedLanguage}:null:null}const{search:y}=Rw({dataStore:h,dataSourceId:i.dataSourceId||void 0,getActiveFilter:m,getActiveContext:()=>i.activeContext||null}),_=cn(null),T=be(null),P={mapbox:Go.mapboxGeocoderCss.url,maplibre:Go.maplibreGeocoderCss.url},E=Go.maplibreGeocoderJs.url,v=Go.mapboxGeocoderJs.url;function j(L,O){const V=P[O]||P.mapbox;if(L.querySelector(`link[href="${V}"]`))return;const ne=document.createElement("link");ne.rel="stylesheet",ne.href=V,za(ne,V),L.prepend(ne)}async function re(L,O){if(typeof window<"u"&&window[O]||typeof document>"u")return;const V=document.querySelector(`script[src="${L}"]`);if(V){if(window[O])return;await new Promise(ne=>{V.addEventListener("load",ne,{once:!0}),V.addEventListener("error",ne,{once:!0})});return}await new Promise(ne=>{const ue=document.createElement("script");ue.src=L,za(ue,L),ue.async=!0,ue.addEventListener("load",ne,{once:!0}),ue.addEventListener("error",ne,{once:!0}),document.head.appendChild(ue)})}function Z(L=document){let O=L.activeElement;for(;O&&O.shadowRoot&&O.shadowRoot.activeElement;)O=O.shadowRoot.activeElement;return O}function G(L){const O=L==null?void 0:L._onKeyDown;typeof O=="function"&&(L._onKeyDown=function(V){const ne=Z();return!ne||ne===V.target||typeof ne.value!="string"?O.call(L,V):O.call(L,new Proxy(V,{get(ue,Pe){if(Pe==="target"||Pe==="srcElement")return ne;const ye=Reflect.get(ue,Pe);return typeof ye=="function"?ye.bind(ue):ye}}))})}async function pe(){await re(v,"MapboxGeocoder")}async function I(){if(typeof window<"u"&&window.MaplibreGeocoder||typeof document>"u")return;const L=document.querySelector(`script[src="${E}"]`);if(L){if(window.MaplibreGeocoder)return;await new Promise(O=>{L.addEventListener("load",O,{once:!0}),L.addEventListener("error",O,{once:!0})});return}await new Promise((O,V)=>{const ne=document.createElement("script");ne.src=E,ne.async=!1,ne.addEventListener("load",O,{once:!0}),ne.addEventListener("error",()=>V(new Error("[GeocoderComponent] Failed to load MapLibre geocoder")),{once:!0}),document.head.appendChild(ne)})}function M(L,O){return async V=>{const ne={features:[]};if(!/^pk\./.test(String(L||""))||!(V!=null&&V.query))return ne;try{const ue=Array.isArray(V.language)?V.language[0]:V.language||O()||"en",Pe=new URLSearchParams({access_token:L,autocomplete:"true",limit:String(V.limit||5)});ue&&Pe.set("language",ue);const ye=`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(V.query)}.json?${Pe.toString()}`,Be=await fetch(ye);if(!Be.ok)return ne;const se=await Be.json();return se&&Array.isArray(se.features)?se:ne}catch{return ne}}}io(async()=>{var ue,Pe,ye,Be,se;const L=i.provider==="maplibre";if(L){if(await I(),typeof MaplibreGeocoder>"u"){console.error("[GeocoderComponent] MaplibreGeocoder global unavailable.");return}}else if(typeof MapboxGeocoder>"u"&&(await pe(),typeof MapboxGeocoder>"u")){console.error("[GeocoderComponent] MapboxGeocoder global unavailable.");return}const O=i.mapInstance;if(!i.standalone&&!O)return;const V=i.standalone?(Pe=(ue=T.value)==null?void 0:ue.getRootNode)==null?void 0:Pe.call(ue):(se=(Be=(ye=O.getContainer)==null?void 0:ye.call(O))==null?void 0:Be.getRootNode)==null?void 0:se.call(Be);V instanceof ShadowRoot&&j(V,i.provider);const ne={marker:!1,flyTo:!i.standalone,trackProximity:!i.standalone,placeholder:l.value,language:r.value||"en",localGeocoder:y,limit:20,zoom:6,render:b};if(L){const he=typeof maplibregl<"u"?maplibregl:void 0,ce={forwardGeocode:M(i.accessToken,()=>r.value)};_.value=new MaplibreGeocoder(ce,{...ne,maplibregl:he,showResultsWhileTyping:!0,reverseGeocode:!1})}else _.value=new MapboxGeocoder({accessToken:i.accessToken,mapboxgl,...ne});if(G(_.value),_.value.on("result",he=>{var Se,K,_e,$,A,C,U,oe,le,ie,ge,w,k,B,z,Q,ee,D,J,$e,Ee,qe,ft,it,St,Et,Le,Qe,Ot,F;const ce=he==null?void 0:he.result;ce&&((Se=ce.place_type)!=null&&Se.includes("doxa-section-header")||(g&&(g.selectedRegion=null,g.selectedResource=null,g.selectedAffinityBlock=null,g.selectedDialect=null),f&&((K=f.setPrayerFilter)==null||K.call(f,null),(_e=f.setEngagementFilter)==null||_e.call(f,null),($=f.setAdoptionFilter)==null||$.call(f,null),(A=f.setReligionFilter)==null||A.call(f,null)),(C=ce.properties)!=null&&C._allDataSection&&g&&(g.selectedFamily=null,g.selectedLanguage=null),u("result",he),(U=ce.place_type)!=null&&U.includes("people-group")&&ce.feature?u("people-group-result",{type:"Feature",properties:ce.properties||ce.feature,geometry:ce.geometry||{type:"Point",coordinates:ce.center}}):((oe=ce.place_type)!=null&&oe.includes("doxa-country")||(le=ce.place_type)!=null&&le.includes("doxa-region")||(ie=ce.place_type)!=null&&ie.includes("doxa-language-family")||(ge=ce.place_type)!=null&&ge.includes("doxa-language")||(w=ce.place_type)!=null&&w.includes("doxa-dialect")||(k=ce.place_type)!=null&&k.includes("doxa-religion")||(B=ce.place_type)!=null&&B.includes("doxa-affinity-bloc")||(z=ce.place_type)!=null&&z.includes("doxa-cluster")||(Q=ce.place_type)!=null&&Q.includes("doxa-people-group"))&&u("aggregate-result",{kind:ce.place_type[0].replace(/^doxa-/,""),label:((ee=ce.properties)==null?void 0:ee.label)||ce.text,count:((D=ce.properties)==null?void 0:D.count)||0,memberIds:((J=ce.properties)==null?void 0:J.memberIds)||[],bounds:(($e=ce.properties)==null?void 0:$e.bounds)||null,center:ce.center,originalLabels:((Ee=ce.properties)==null?void 0:Ee.originalLabels)||null,familyDerived:((qe=ce.properties)==null?void 0:qe.familyDerived)||"",baseLang:((ft=ce.properties)==null?void 0:ft.baseLang)||"",dialectLabel:((it=ce.properties)==null?void 0:it.dialectLabel)||"",slug:((St=ce.properties)==null?void 0:St.slug)||null,id:ce.id||null,blocCode:((Et=ce.properties)==null?void 0:Et.blocCode)||"",blocLabel:((Le=ce.properties)==null?void 0:Le.blocLabel)||"",clusterCode:((Qe=ce.properties)==null?void 0:Qe.clusterCode)||"",clusterLabel:((Ot=ce.properties)==null?void 0:Ot.clusterLabel)||"",peopleGroupCode:((F=ce.properties)==null?void 0:F.peopleGroupCode)||"",properties:ce.properties||null})))}),_.value.on("clear",()=>u("clear")),_.value.on("error",he=>u("error",he)),i.standalone){if(T.value){const he={on(){},off(){},fire(){},getContainer:()=>T.value,getZoom:()=>0,getCenter:()=>({lng:0,lat:0}),getBounds:()=>null,flyTo(){},fitBounds(){},addControl(){},removeControl(){},hasControl:()=>!1};try{const ce=_.value.onAdd(i.mapInstance||he);ce&&T.value.appendChild(ce)}catch(ce){u("error",ce)}}}else O.addControl(_.value,"top-left"),W()});function W(){var O,V;const L=(V=(O=_.value)==null?void 0:O.container)==null?void 0:V.parentElement;L&&(L.classList.add("dg-search-band"),L.classList.toggle("dg-search-band--dark",!!i.isDark))}return ot(()=>i.isDark,()=>W()),ot(l,L=>{var ne,ue;const O=_.value;if(!O)return;const V=O._inputEl||((ue=(ne=O.container)==null?void 0:ne.querySelector)==null?void 0:ue.call(ne,"input.mapboxgl-ctrl-geocoder--input"));V&&(V.placeholder=L,V.setAttribute("placeholder",L)),O.options&&(O.options.placeholder=L)}),ot(r,L=>{const O=_.value;O!=null&&O.options&&(O.options.language=L||"en")}),Qt(()=>{var L,O;if(_.value){try{i.standalone?(O=(L=_.value).onRemove)==null||O.call(L):i.mapInstance&&i.mapInstance.removeControl(_.value)}catch{}_.value=null}}),t({geocoder:_}),(L,O)=>e.standalone?(q(),ae("div",{key:0,ref_key:"standaloneContainer",ref:T,class:"dg-standalone-geocoder"},null,512)):Rn(L.$slots,"default",{},void 0,void 0,1)}},Mw=["mapbox","maplibre"],Iw="auto";function _g(e){return e&&typeof e=="object"&&"value"in e&&!("provider"in e)&&!("profile"in e)?e.value:e}function yg(e){const t=o=>typeof o=="string"&&!!o.trim()&&!/^YOUR_/.test(o.trim());return t(e==null?void 0:e.tk)||/^https?:\/\//i.test(String((e==null?void 0:e.tokenUrl)||""))?!0:typeof window>"u"?!1:t(window.MAP_TOKEN)||t(window.__doxaMapToken)||!!window.__doxaMapTokenPending}function Fw(e,{token:t}={}){const o=_g(e);return Ow(o)||(yg(o)||yg({tk:t})?"mapbox":"maplibre")}function Ow(e){const t=_g(e),o=t==null?void 0:t.provider,n=typeof location<"u"?new URLSearchParams(location.search).get("provider"):void 0,a=typeof window<"u"?window.MAP_PROVIDER:void 0,r=String(o||n||a||Iw).toLowerCase().trim();return Mw.includes(r)?r:""}const Dw="rgba(120, 128, 134, 0.28)",$g="36px",vg=()=>{};function Gw(e,t={}){const{enabled:o=!0}=t;if(!o||!e)return vg;const n=Array.from(e.querySelectorAll(".map-scroll-edge"));if(!n.length)return vg;const a=f=>f.classList.contains("map-scroll-edge--left");for(const f of n)f.style.background=`linear-gradient(${a(f)?"to right":"to left"}, ${Dw} ${$g}, transparent ${$g})`,f.style.opacity="0",f.style.transition="opacity 0.16s ease",f.style.userSelect="none",f.style.webkitUserSelect="none";const r=f=>{f.style.opacity="1"},i=f=>{f.style.opacity="0"},s=()=>n.find(f=>!a(f))||null,l=new Set;let u=!1,c=null;const p=()=>{for(const f of n)l.has(f)||i(f)},d=()=>{const f=s();f&&(r(f),c&&clearTimeout(c),c=setTimeout(p,250))},S=()=>d(),x=f=>{if(!(f.touches&&f.touches.length===1))return;const m=f.target;m&&m.classList&&m.classList.contains("map-scroll-edge")||d()},b=()=>{c&&clearTimeout(c),p()};e.addEventListener("wheel",S,{passive:!0}),e.addEventListener("touchmove",x,{passive:!0}),e.addEventListener("touchend",b,{passive:!0}),e.addEventListener("touchcancel",b,{passive:!0});const h=()=>{u||d()};typeof window<"u"&&window.addEventListener("scroll",h,{passive:!0});const g=[];for(const f of n){const m=()=>{l.add(f),r(f)},y=()=>{l.delete(f),i(f)},_=()=>{u=!0,r(f)},T=()=>{u=!1,i(f)};f.addEventListener("mouseenter",m),f.addEventListener("mouseleave",y),f.addEventListener("touchstart",_,{passive:!0}),f.addEventListener("touchend",T,{passive:!0}),g.push(()=>{f.removeEventListener("mouseenter",m),f.removeEventListener("mouseleave",y),f.removeEventListener("touchstart",_),f.removeEventListener("touchend",T)})}return function(){c&&(clearTimeout(c),c=null),e.removeEventListener("wheel",S),e.removeEventListener("touchmove",x),e.removeEventListener("touchend",b),e.removeEventListener("touchcancel",b),typeof window<"u"&&window.removeEventListener("scroll",h);for(const m of g)m();for(const m of n)i(m)}}const zw=Object.fromEntries([{id:"midnight-glow",label:"Midnight Glow",mood:"the prayer-map dark — pins glow like embers",mapbox:"mapbox://styles/mapbox/standard",lightPreset:"night",maplibre:"https://tiles.openfreemap.org/styles/fiord",bestFor:["doxa-simple-map","my-upg-100-list"]},{id:"daylight",label:"Daylight",mood:"the same Standard world, lights on",mapbox:"mapbox://styles/mapbox/standard",lightPreset:"day",maplibre:"https://tiles.openfreemap.org/styles/liberty",bestFor:["doxa-research-map","gospel-resources"]},{id:"dawn",label:"Dawn",mood:"soft warm horizon — hopeful, quiet",mapbox:"mapbox://styles/mapbox/standard",lightPreset:"dawn",maplibre:"https://tiles.openfreemap.org/styles/positron",bestFor:["doxa-simple-map"]},{id:"dusk",label:"Dusk",mood:"blue hour — calm contrast for bright pins",mapbox:"mapbox://styles/mapbox/standard",lightPreset:"dusk",maplibre:"https://tiles.openfreemap.org/styles/fiord",bestFor:["my-upg-100-list"]},{id:"paper",label:"Paper",mood:"near-white minimal — data reads like print",mapbox:"mapbox://styles/mapbox/light-v11",maplibre:"https://tiles.openfreemap.org/styles/positron",bestFor:["research-dashboard","cities-internet"]},{id:"ink",label:"Ink",mood:"near-black minimal — maximum pin contrast",mapbox:"mapbox://styles/mapbox/dark-v11",maplibre:"https://tiles.openfreemap.org/styles/dark",bestFor:["my-upg-100-list","cities-internet"]},{id:"streetlife",label:"Street Life",mood:"full street detail — city-scale work",mapbox:"mapbox://styles/mapbox/streets-v12",maplibre:"https://tiles.openfreemap.org/styles/bright",bestFor:["cities-internet","key-cities"]},{id:"terrain",label:"Terrain",mood:"relief + parks — where people actually live",mapbox:"mapbox://styles/mapbox/outdoors-v12",maplibre:"https://tiles.openfreemap.org/styles/liberty",bestFor:["doxa-research-map","country-posters"]},{id:"satellite",label:"Satellite",mood:"imagery — the real ground",mapbox:"mapbox://styles/mapbox/satellite-v9",maplibre:"https://tiles.openfreemap.org/styles/liberty",bestFor:["country-posters"]},{id:"hybrid",label:"Hybrid",mood:"imagery + labels — orientation without losing ground truth",mapbox:"mapbox://styles/mapbox/satellite-streets-v12",maplibre:"https://tiles.openfreemap.org/styles/liberty",bestFor:["key-cities"]},{id:"wayfinder-day",label:"Wayfinder Day",mood:"high-legibility navigation palette",mapbox:"mapbox://styles/mapbox/navigation-day-v1",maplibre:"https://tiles.openfreemap.org/styles/liberty",bestFor:["gospel-resources"]},{id:"wayfinder-night",label:"Wayfinder Night",mood:"dark navigation — dashboards at night",mapbox:"mapbox://styles/mapbox/navigation-night-v1",maplibre:"https://tiles.openfreemap.org/styles/fiord",bestFor:["research-dashboard"]},{id:"galaxy",label:"Galaxy",mood:"the day side of Earth floating in space — normal land, blue oceans, black void behind the sphere",mapbox:"mapbox://styles/mapbox/standard",maplibre:"https://tiles.versatiles.org/assets/styles/colorful/style.json",bestFor:["research-dashboard","my-upg-100-list"]}].map(e=>[e.id,e]));function bl(e,t="mapbox"){if(typeof e!="string"||!e)return{style:void 0,lightPreset:void 0,paint:void 0};const o=zw[e];return o?t==="maplibre"?{style:o.maplibre,lightPreset:void 0,paint:o.paint}:{style:o.mapbox,lightPreset:o.lightPreset,paint:o.paint}:/^(mapbox:\/\/|https?:\/\/)/.test(e)?{style:e,lightPreset:void 0,paint:void 0}:{style:void 0,lightPreset:void 0,paint:void 0}}const wg={mapbox:"https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-rtl-text/v0.3.0/mapbox-gl-rtl-text.js",maplibre:"https://cdn.jsdelivr.net/npm/@mapbox/mapbox-gl-rtl-text@0.3.0/dist/mapbox-gl-rtl-text.js"};function Bw(e){return!!e&&typeof window<"u"&&e===window.maplibregl}function Uw(e){if(typeof window>"u")return!1;const t=e?[e]:[window.maplibregl,window.mapboxgl].filter(Boolean);let o=!1;for(const n of t)if(!(!n||!n.setRTLTextPlugin))try{if(Bw(n)){if(n.getRTLTextPluginStatus&&n.getRTLTextPluginStatus()!=="unavailable")continue;const a=n.setRTLTextPlugin(wg.maplibre,!0);a&&a.catch&&a.catch(()=>{})}else n.setRTLTextPlugin(wg.mapbox,null,!0);o=!0}catch{}return o}const Yn={mapbox:{global:"mapboxgl",js:Go.mapboxGlJs.url,css:Go.mapboxGlCss.url},maplibre:{global:"maplibregl",js:Go.maplibreGlJs.url,css:Go.maplibreGlCss.url}};function _l(e){var o;const t=((o=Yn[e])==null?void 0:o.global)||Yn.mapbox.global;return typeof window<"u"?window[t]:void 0}function kg(e){return(Yn[e]||Yn.mapbox).css||null}async function Hw(e){const t=Yn[e]||Yn.mapbox;if(_l(e)||typeof document>"u")return;if(!document.querySelector(`link[href="${t.css}"]`)){const n=document.createElement("link");n.rel="stylesheet",n.href=t.css,za(n,t.css),document.head.appendChild(n)}const o=document.querySelector(`script[src="${t.js}"]`);if(o){if(_l(e))return;await new Promise(n=>{o.addEventListener("load",n,{once:!0}),o.addEventListener("error",n,{once:!0})});return}await new Promise((n,a)=>{const r=document.createElement("script");r.src=t.js,za(r,t.js),r.async=!1,r.addEventListener("load",n,{once:!0}),r.addEventListener("error",()=>a(new Error(`[useMapInstance] Failed to load ${e} engine script`)),{once:!0}),document.head.appendChild(r)})}async function jw(e,t){if(!e)return;const o=e.getRootNode();if(!(o instanceof ShadowRoot))return;const n=i=>new Promise(s=>setTimeout(s,i)),a=o.querySelector(`link[href="${t}"]`);if(a){if(a.sheet)return;await Promise.race([new Promise(i=>{a.addEventListener("load",i,{once:!0}),a.addEventListener("error",i,{once:!0})}),n(2e3)]);return}const r=document.createElement("link");r.rel="stylesheet",r.href=t,za(r,t),await Promise.race([new Promise(i=>{r.addEventListener("load",i,{once:!0}),r.addEventListener("error",i,{once:!0}),o.prepend(r)}),n(2e3)])}function Vw(e,t){return`hsl(${Math.round(e*360/(t||1))}, 72%, 56%)`}function ii(e){if(typeof e.count=="number")return e.count;if(typeof e.expected_count=="number")return e.expected_count}function Pg(e){const t=parseInt(e&&e.population,10);return Number.isFinite(t)?t:0}function Ww(e,t){if(!Array.isArray(t)||t.length===0)return;const o=e&&e.selector;if(o==null)return;if(o.type==="pg_slugs"){const r=new Set(Array.isArray(o.values)?o.values:[]);let i=0;for(const s of t)s&&r.has(s.slug)&&(i+=Pg(s));return i}const n=Vn(o,t);let a=0;for(const r of t)r&&n.has(r.slug)&&(a+=Pg(r));return a}function yl(e,t={}){const o=t.deafCount??123,n=Array.isArray(t.records)?t.records:null,a=typeof t.title=="function"?(I,M)=>t.title(I)||M:(I,M)=>M,r=e.lists||[],i=e.asia_lists||[],s=e.uncovered_lists||[],l={type:"affinity_bloc",rop1:"A017"},u=i.filter(I=>I.id.startsWith("asia-india")),c=i.filter(I=>I.id.startsWith("asia-china")),p=[...r.map(I=>I.id),"deaf",...u.map(I=>I.id),...c.map(I=>I.id),...s.map(I=>I.id)],d=p.length,S=I=>Vw(p.indexOf(I),d),x=(I,M,W)=>{if(!n)return I;const L=W??(M&&M.selector);return I.pop=Ww({selector:L},n),I},b=I=>n?I.reduce((M,W)=>M+(W.pop||0),0):void 0,h=r.map(I=>x({id:I.id,zoneKey:I.id,label:a(I,I.label),...I.provinceLabel?{provinceLabel:I.provinceLabel}:{},color:S(I.id),count:ii(I)},I)),g=x({id:"deaf",zoneKey:"deaf",label:"Deaf (affinity bloc A017)",color:S("deaf"),count:o,info:"Unified deaf row — affinity bloc rop1=A017 (collapses the two deaf_lists; zero-delta vs old deaf_predicate). Population double-counts vs geographic rows (design-approved, slice 08)."},null,l),f=I=>x({id:I.id,zoneKey:I.id,label:a(I,I.label),...I.provinceLabel?{provinceLabel:I.provinceLabel}:{},color:S(I.id),count:ii(I),...Array.isArray(I.adm0)&&I.adm0.length?{adm0:I.adm0}:{},...Array.isArray(I.provinces)&&I.provinces.length?{provinces:I.provinces}:{}},I),m=u.map(f),y=c.map(f),_=I=>I.reduce((M,W)=>M+(ii(W)||0),0),T={id:"asia-india",label:"India",count:_(u),children:m},P={id:"asia-china",label:"China",count:_(c),children:y};n&&(T.pop=b(m),P.pop=b(y)),_(i),n&&b([T,P]);const E=I=>x({id:I.id,zoneKey:I.id,label:a(I,I.label),...I.provinceLabel?{provinceLabel:I.provinceLabel}:{},color:S(I.id),count:ii(I)},I),v=s.map(E);v.length>0&&(()=>{const I={id:"frontier-asia",label:"Frontier Asia (uncovered)",count:_(s),children:v};return n&&(I.pop=b(v)),I})();const j={"west-africa":"Africa",sudan:"Africa","east-africa":"Africa","central-africa":"Africa","southern-africa-islands":"Africa","maghreb-egypt":"Middle East","middle-east-core":"Middle East","uncovered-nas-a":"Central Asia",laos:"Southeast Asia + Oceania","oceania-indonesia":"Southeast Asia + Oceania","mainland-se-asia-philippines":"Southeast Asia + Oceania",brazil:"Americas","andean-caribbean":"Americas","uncovered-scatter":"Americas",europe:"Europe",deaf:"Deaf","deaf-old-world":"Deaf"},re=I=>j[I]||(String(I).startsWith("asia-india-")?"India":String(I).startsWith("asia-china-")?"China + Mongolia":"Other"),Z=[...h,g,...m,...y,...v].filter(Boolean),G=new Map;for(const I of Z){const M=re(I.id||I.zoneKey);G.has(M)||G.set(M,[]),G.get(M).push(I)}const pe=[...G.entries()].map(([I,M])=>{M.sort((L,O)=>(O.count||0)-(L.count||0));const W={id:"region-"+I.normalize("NFD").replace(new RegExp("\\p{Mn}","gu"),"").toLowerCase().replace(/[^a-z0-9]+/g,"-"),label:I,count:M.reduce((L,O)=>L+(O.count||0),0),children:M};return n&&(W.pop=b(M)),W}).sort((I,M)=>(M.count||0)-(I.count||0));return Kw(xg(pe),{withPop:!!n}),pe}function Kw(e,{withPop:t=!1}={}){const o=[];for(const n of e||[]){const a=[];(typeof n.id!="string"||!n.id)&&a.push("id"),(typeof n.zoneKey!="string"||!n.zoneKey)&&a.push("zoneKey"),(typeof n.label!="string"||!n.label)&&a.push("label"),(typeof n.color!="string"||!n.color)&&a.push("color"),typeof n.count!="number"&&a.push("count"),t&&typeof n.pop!="number"&&a.push("pop"),a.length&&o.push(`${n.id||"(no-id)"}: missing/!type [${a.join(", ")}]`)}if(o.length)throw new Error(`legend-tree L15: ${o.length} leaf node(s) violate the uniform consumer shape: `+o.join(` `));return!0}function xg(e){const t=[],o=n=>{for(const a of n)a.children&&a.children.length?o(a.children):t.push(a)};return o(e||[]),t}const Sg=()=>({type:"FeatureCollection",features:[]});function qw(e,t){const o=Vn(e.selector,t),n=new Set;for(const a of t)a&&o.has(a.slug)&&a.country_code&&n.add(a.country_code);return n}function Yw(e){return typeof e.id=="string"&&e.id.startsWith("asia-")}function $l(e,t){return{type:"Feature",properties:{...e.properties||{},zoneKey:t.zoneKey??t.id,zoneColor:t.color??t.zoneColor??"#888",zoneLabel:t.label,...t.id==="deaf"?{hatch:!0}:{}},geometry:e.geometry}}function Jw(e,t){const{records:o=[],adm0:n,adm1Ind:a,adm1Chn:r}=t||{},i=Sg();if(Yw(e)){const l=[a,r].filter(Boolean);for(const u of l)for(const c of u.features||[])c.properties&&c.properties.listId===e.id&&i.features.push($l(c,e));if(Array.isArray(e.adm0)&&e.adm0.length&&n){const u=new Set(e.adm0);for(const c of n.features||[])c.properties&&u.has(c.properties.iso3)&&i.features.push($l(c,e))}return i}if(!e.selector)return i;const s=qw(e,o);if(n&&s.size)for(const l of n.features||[])l.properties&&s.has(l.properties.iso3)&&i.features.push($l(l,e));return i}function Zw(e,t){const o=Sg(),n=new Map;for(const a of e){if(a.id==="deaf"){n.set(a.zoneKey??a.id,0);continue}const r=Jw(a,t);n.set(a.zoneKey??a.id,r.features.length);for(const i of r.features)o.features.push(i)}return{tapestry:o,perZone:n}}const Xw={"andean-caribbean":"#f9a51f","asia-china-tibet-autonomous-region":"#00f0c8","asia-china-yunnan-province":"#22ddff","asia-frontier-nas-a":"#ff1744","asia-india-andhra-pradesh":"#22ddff","asia-india-assam":"#22ddff","asia-india-chhattisgarh":"#536dfe","asia-india-gujarat":"#536dfe","asia-india-karnataka":"#536dfe","asia-india-kerala":"#2196ff","asia-india-madhya-pradesh":"#2196ff","asia-india-maharashtra":"#2196ff","asia-india-odisha":"#2196ff","asia-india-rajasthan":"#22ddff","asia-india-tamil-nadu":"#7c4dff","asia-india-uttarakhand":"#536dfe","asia-india-west-bengal":"#22ddff",brazil:"#f4c57b","central-africa":"#c20001",deaf:"#18ffff","east-africa":"#ef3410",europe:"#34cb74",laos:"#7c4dff","maghreb-egypt":"#602f74","mainland-se-asia-philippines":"#ff1744","middle-east-core":"#bc8bd0","oceania-indonesia":"#ee892f","southern-africa-islands":"#e75556",sudan:"#e69e93","uncovered-central-asia":"#ff8a00","uncovered-himalaya":"#ff6d00","uncovered-japan":"#ffc400","uncovered-mongolia":"#76ff03","uncovered-nas-a":"#ff1744","uncovered-nepal":"#ffea00","uncovered-sa-west":"#ff1744","uncovered-scatter":"#eeff41","west-africa":"#edcac9"};function Qw(e,t){const o=Xw[e];return typeof o=="string"&&o?o:t}const si={"Andaman and Nicobar Islands":9,"Andhra Pradesh":81,"Arunāchal Pradesh":7,Assam:15,Bihār:18,Chandīgarh:1,Chhattīsgarh:24,Delhi:1,"Dādra and Nagar Haveli and Damān and Diu":1,Goa:5,Gujarāt:90,Haryāna:4,"Himāchal Pradesh":20,"Jammu and Kashmīr":33,Jhārkhand:9,Karnātaka:81,Kerala:72,Ladākh:6,Lakshadweep:1,"Madhya Pradesh":33,Mahārāshtra:54,Manipur:5,Meghālaya:2,Odisha:64,Puducherry:5,Punjab:4,Rājasthān:48,Sikkim:1,"Tamil Nādu":64,Telangāna:26,Tripura:11,"Uttar Pradesh":23,Uttarākhand:7,"West Bengal":30,"Gansu Province":3,"Guangxi Zhuang Autonomous Region":6,"Guizhou Province":34,"Hainan Province":3,"Heilongjiang Province":2,"Hunan Province":5,"Inner Mongolia Autonomous Region":3,"Qinghai Province":3,"Sichuan Province":12,"Tibet Autonomous Region":13,"Xinjiang Uyghur Autonomous Region":7,"Yunnan Province":61},Ag={ABW:1,AFG:21,AGO:10,ALB:1,AND:1,ARE:2,ARM:1,ASM:1,ATG:1,AZE:3,BEN:9,BFA:8,BGD:3,BGR:1,BHR:2,BHS:1,BIH:1,BLM:1,BLR:1,BMU:1,BOL:1,BRA:103,BRB:1,BRN:5,BTN:13,CAF:1,CHN:154,CIV:2,CMR:8,COD:9,COG:2,COK:1,COL:27,COM:3,CUB:1,CUW:1,CYM:1,CYP:1,CZE:1,DJI:1,DMA:1,DZA:17,ECU:1,EGY:3,ERI:8,ESP:1,ETH:29,FIN:1,FJI:1,FRO:1,FSM:1,GAB:2,GEO:1,GGY:1,GHA:1,GIN:13,GLP:1,GMB:3,GNB:3,GNQ:1,GRC:1,GRD:1,GUF:2,GUM:1,GUY:1,IDN:36,IRN:20,IRQ:8,ISL:1,ISR:4,JAM:1,JOR:3,JPN:6,KAZ:1,KEN:5,KGZ:2,KHM:1,KIR:1,KWT:1,LAO:95,LBN:4,LBR:2,LBY:15,LCA:1,LIE:1,LKA:1,LUX:1,MAR:4,MDV:1,MHL:1,MLI:13,MLT:1,MMR:7,MNE:1,MNG:1,MNP:1,MOZ:4,MRT:3,MSR:1,MUS:1,MWI:1,MYS:12,MYT:1,NAM:6,NCL:1,NER:2,NGA:38,NIU:1,NPL:34,NZL:1,OMN:7,PAK:24,PAN:1,PER:10,PHL:1,PLW:1,PNG:1,PRK:1,PRY:1,PSE:4,PYF:1,QAT:3,RUS:21,SAU:3,SDN:105,SEN:1,SHN:1,SLB:1,SLE:2,SMR:1,SOM:9,SSD:22,STP:1,SUR:2,SWE:2,SWZ:1,SYR:5,TCA:1,TCD:53,TGO:6,THA:8,TJK:3,TON:1,TUN:2,TUR:3,TZA:16,UGA:6,USA:3,UZB:1,VCT:1,VEN:6,VGB:1,VIR:1,VNM:16,VUT:1,WLF:1,WSM:1,YEM:9,ZAF:2,ZMB:6,ZWE:3},Ba={ABW:"Aruba",IND:"India",AFG:"Afghanistan",AGO:"Angola",ALB:"Albania",AND:"Andorra",ARE:"United Arab Emirates",ARM:"Armenia",ASM:"American Samoa",ATG:"Antigua and Barbuda",AZE:"Azerbaijan",BEN:"Benin",BFA:"Burkina Faso",BGD:"Bangladesh",BGR:"Bulgaria",BHR:"Bahrain",BHS:"Bahamas",BIH:"Bosnia and Herzegovina",BLM:"Saint Barthélemy",BLR:"Belarus",BMU:"Bermuda",BOL:"Bolivia",BRA:"Brazil",BRB:"Barbados",BRN:"Brunei",BTN:"Bhutan",CAF:"Central African Republic",CHN:"China",CIV:"Côte d'Ivoire",CMR:"Cameroon",COD:"DR Congo",COG:"Congo",COK:"Cook Islands",COL:"Colombia",COM:"Comoros",CUB:"Cuba",CUW:"Curaçao",CYM:"Cayman Islands",CYP:"Cyprus",CZE:"Czechia",DJI:"Djibouti",DMA:"Dominica",DZA:"Algeria",ECU:"Ecuador",EGY:"Egypt",ERI:"Eritrea",ESP:"Spain",ETH:"Ethiopia",FIN:"Finland",FJI:"Fiji",FRO:"Faroe Islands",FSM:"Micronesia",GAB:"Gabon",GEO:"Georgia",GGY:"Guernsey",GHA:"Ghana",GIN:"Guinea",GLP:"Guadeloupe",GMB:"Gambia",GNB:"Guinea-Bissau",GNQ:"Equatorial Guinea",GRC:"Greece",GRD:"Grenada",GUF:"French Guiana",GUM:"Guam",GUY:"Guyana",IDN:"Indonesia",IRN:"Iran",IRQ:"Iraq",ISL:"Iceland",ISR:"Israel",JAM:"Jamaica",JOR:"Jordan",JPN:"Japan",KAZ:"Kazakhstan",KEN:"Kenya",KGZ:"Kyrgyzstan",KHM:"Cambodia",KIR:"Kiribati",KWT:"Kuwait",LAO:"Laos",LBN:"Lebanon",LBR:"Liberia",LBY:"Libya",LCA:"Saint Lucia",LIE:"Liechtenstein",LKA:"Sri Lanka",LUX:"Luxembourg",MAR:"Morocco",MDV:"Maldives",MHL:"Marshall Islands",MLI:"Mali",MLT:"Malta",MMR:"Myanmar",MNE:"Montenegro",MNG:"Mongolia",MNP:"Northern Mariana Islands",MOZ:"Mozambique",MRT:"Mauritania",MSR:"Montserrat",MUS:"Mauritius",MWI:"Malawi",MYS:"Malaysia",MYT:"Mayotte",NAM:"Namibia",NCL:"New Caledonia",NER:"Niger",NGA:"Nigeria",NIU:"Niue",NPL:"Nepal",NZL:"New Zealand",OMN:"Oman",PAK:"Pakistan",PAN:"Panama",PER:"Peru",PHL:"Philippines",PLW:"Palau",PNG:"Papua New Guinea",PRK:"North Korea",PRY:"Paraguay",PSE:"Palestine",PYF:"French Polynesia",QAT:"Qatar",RUS:"Russia",SAU:"Saudi Arabia",SDN:"Sudan",SEN:"Senegal",SHN:"Saint Helena",SLB:"Solomon Islands",SLE:"Sierra Leone",SMR:"San Marino",SOM:"Somalia",SSD:"South Sudan",STP:"São Tomé and Príncipe",SUR:"Suriname",SWE:"Sweden",SWZ:"Eswatini",SYR:"Syria",TCA:"Turks and Caicos Islands",TCD:"Chad",TGO:"Togo",THA:"Thailand",TJK:"Tajikistan",TON:"Tonga",TUN:"Tunisia",TUR:"Turkey",TZA:"Tanzania",UGA:"Uganda",USA:"United States",UZB:"Uzbekistan",VCT:"Saint Vincent and the Grenadines",VEN:"Venezuela",VGB:"British Virgin Islands",VIR:"U.S. Virgin Islands",VNM:"Vietnam",VUT:"Vanuatu",WLF:"Wallis and Futuna",WSM:"Samoa",YEM:"Yemen",ZAF:"South Africa",ZMB:"Zambia",ZWE:"Zimbabwe"};function Lg(e){const t={...Ba};for(const o of e||[]){const n=o&&o.country_code,a=o&&o.country_code_label;n&&a&&(t[n]=a)}return t}function Cg(e,t={}){if(!e||typeof e!="object")return null;const o=t.nameMap||Ba;if(e.shapeName){const n=String(e.shapeName),a=Object.prototype.hasOwnProperty.call(si,n)?si[n]:null;return{key:"adm1:"+n,name:n,count:a,kind:"adm1"}}if(e.iso3){const n=String(e.iso3),a=o[n]||Ba[n]||n,r=Object.prototype.hasOwnProperty.call(Ag,n)?Ag[n]:null;return{key:"adm0:"+n,name:a,count:r,kind:"adm0"}}return null}function ek(e,t={}){const o=Array.isArray(e)?e:[],n=o.map(l=>l.name),a=o.reduce((l,u)=>l+(Number(u.count)||0),0),r=t&&typeof t.color=="string"&&t.color?t.color:"",i=n.join(", ")+" — "+a+" UUPG"+(r?" · "+r:""),s=o.map(l=>l.name+" "+(Number(l.count)||0)).join(", ");return i+` -`+s}function Jn(e){return String(e??"").normalize("NFD").replace(/[̀-ͯ]/g,"").toLowerCase().trim()}function tk(e){return Jn(e).split(/[\s,;]+/).filter(Boolean)}function ok(e={}){const{records:t=[],leafZones:o=[],adm1Counts:n={},iso3Names:a={},countryNameMap:r=null}=e,i=[],s=new Set;for(const u of t){if(!u)continue;const c=u.slug;if(!c||s.has(c))continue;const p=Number(u.latitude),d=Number(u.longitude);if(!Number.isFinite(p)||!Number.isFinite(d))continue;const S=u.name||c;s.add(c),i.push({label:S,kind:"pg",target:{type:"pg",slug:c,lng:d,lat:p},_hay:Jn(S)})}for(const u of o){if(!u)continue;const c=u.zoneKey||u.id,p=u.label||c;c&&i.push({label:p,kind:"zone",target:{type:"zone",zoneId:c},_hay:Jn(p)})}for(const u of Object.keys(n))i.push({label:u,kind:"territory",target:{type:"territory",shapeName:u},_hay:Jn(u)});const l=r||a;for(const u of Object.keys(a)){const c=l&&l[u]||a[u]||u;i.push({label:c,kind:"territory",target:{type:"territory",shapeName:u,iso3:!0},_hay:Jn(c)})}return i}const nk={zone:0,territory:1,pg:2};function ak(e={}){const{records:t=[],leafZones:o=[],adm1Counts:n={},iso3Names:a={},countryNameMap:r=null,centroidFor:i=null}=e,s=[];for(const c of t)c&&s.push(c);const l=(c,p,d)=>!p||!Number.isFinite(p[0])||!Number.isFinite(p[1])?null:{name:c,slug:d.__synthSlug,latitude:p[1],longitude:p[0],...d};for(const c of o){if(!c)continue;const p=c.zoneKey||c.id,d=c.label||p;if(!p)continue;const S=typeof i=="function"?i(b=>b&&b.properties&&b.properties.zoneKey===p):null,x=l(d,S,{__upgKind:"zone",__zoneId:p,__synthSlug:`__zone__${p}`});x&&s.push(x)}for(const c of Object.keys(n)){const p=typeof i=="function"?i(S=>S&&S.properties&&S.properties.shapeName===c):null,d=l(c,p,{__upgKind:"territory",__shapeName:c,__synthSlug:`__terr__${c}`});d&&s.push(d)}const u=r||a;for(const c of Object.keys(a)){const p=u&&u[c]||a[c]||c,d=typeof i=="function"?i(x=>x&&x.properties&&x.properties.iso3===c):null,S=l(p,d,{__upgKind:"territory",__shapeName:c,__synthSlug:`__terr__${c}`});S&&s.push(S)}return s}function Tg(e,t,o={}){const n=o.limit??8,a=tk(t);if(!a.length)return[];const r=a[0],i=[];for(const s of e){let l=!0;for(const p of a)if(!s._hay.includes(p)){l=!1;break}if(!l)continue;const u=s._hay.startsWith(r)?0:1,c=s._hay===Jn(t)?-1:0;i.push({e:s,starts:u,exact:c,kr:nk[s.kind]??9,len:s._hay.length})}return i.sort((s,l)=>s.exact-l.exact||s.starts-l.starts||s.kr-l.kr||s.len-l.len),i.slice(0,n).map(s=>s.e)}const Eg=new Set;function rk(e,t){var a,r;const o=e.getSource(t);if(!o)return[];let n=o._data??((r=(a=o.serialize)==null?void 0:a.call(o))==null?void 0:r.data);if(n&&typeof n=="object"&&!Array.isArray(n)){if(n.geojson!==void 0)n=n.geojson;else if(n.url!==void 0)return Eg.has(t)||(Eg.add(t),console.warn(`[pin-selection] source "${t}" is remote (url); its features cannot be read locally, so nothing can be selected from it.`)),[]}return n?Array.isArray(n==null?void 0:n.features)?n.features:(n==null?void 0:n.type)==="Feature"?[n]:[]:[]}const ik={class:"upg-root"},sk={key:0,class:"upg-map-err"},lk={class:"upg-legend-desktop-slot"},ck={class:"upg-legend-mobile-slot"},uk={class:"upg-detail-desktop-slot"},dk={key:4,class:"upg-hud"},pk={class:"upg-hud-hint"},gk={key:0,class:"upg-hud-head"},hk={class:"upg-hud-total"},fk={key:1,class:"upg-hud-names"},mk={key:2,class:"upg-hud-actions"},bk=["disabled"],_k=["disabled"],yk={key:3,class:"upg-hud-flash"},$k={class:"upg-status"},vl="upg-search",Rg=1,vk="people-groups",Ng=8,wl=123,wk=Object.freeze(Object.defineProperty({__proto__:null,default:{__name:"upg-100-list",setup(e){const t=tp(()=>yt(()=>Promise.resolve().then(()=>j1),void 0)),o=He("mapboxToken",be("")),n=He("profileConfig",be(null));function a(){var N,H;return((N=n.value)==null?void 0:N.instanceId)||((H=n.value)==null?void 0:H.profile)||"upg-100-list"}const r=Fw(n),i=r==="maplibre",s=X(()=>{var N;return((N=n==null?void 0:n.value)==null?void 0:N.search)===!1?!1:r==="mapbox"}),l=X(()=>{var H;const N=(H=n.value)==null?void 0:H.edgeScrollAffordance;return N==null?!0:!(N===!1||N==="false")}),u=He("dataStore",null),c=He("uiStore",null),p=be(null),d=be("loading…"),S=be(""),x=cn([]),b=be(null),h=cn(null),g=be(!1),f=S$("my-upg-100-list");f.theme.value="light",A$(f);const m=be([]),y=X(()=>m.value.reduce((N,H)=>N+(Number(H.count)||0),0)),_=X(()=>m.value.length),T=be("");let P=null;const E=be(!1);function v(N){const H=N===void 0?!E.value:!!N;return H===E.value||(E.value=H,L&&(L.getCanvas().style.cursor=""),C()),H}function j(){v()}ot([E,g],()=>{Wt(()=>St())});function re(N){if(!N)return;const H=m.value,Y=H.findIndex(fe=>fe.key===N.key);Y>=0?m.value=H.filter((fe,Ae)=>Ae!==Y):m.value=[...H,N],C(),T.value=""}const Z=be(""),G=be("");function pe(N){const H=/^#?([0-9a-fA-F]{6})$/.exec(String(N||"").trim());if(!H)return;const Y="#"+H[1].toLowerCase();Z.value=Z.value===Y?"":Y,C()}const I=be(null),M=X(()=>[{id:"upg100Region",label:se("tabs.upg100Region"),info:se("legend.tabInfo.upg100Region")},{id:"upg100Zone",label:se("tabs.upg100Zone"),info:se("legend.tabInfo.upg100Zone")}]);let W=[],L=null,O=null,V=[],ne=null,ue=null,Pe=null;const ye=typeof window<"u"&&window.MAP_APP_API_URL||void 0||"",{locale:Be,t:se}=xt(),he=X(()=>se("legend.title.upg100List")),ce=X(()=>se("legend.title.batchSelect")),Se=X(()=>se("search.upg100Placeholder"));Tt(`.upg-root{position:absolute;inset:0;background:#0a1410;color:#e5e7eb;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif}.upg-map{position:absolute;inset:0}.upg-map-err{position:absolute;left:0;right:0;top:50%;transform:translateY(-50%);z-index:1;pointer-events:none;text-align:center;padding:0 24px;font:13px/1.5 -apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;color:#9aa7b8}.upg-map-err strong{display:block;font-size:14px;color:#cbd5e1;margin-bottom:4px}.map-scroll-edge{position:absolute;top:0;bottom:0;width:40px;z-index:2;touch-action:pan-y;pointer-events:auto;background:transparent}.map-scroll-edge--left{left:0}.map-scroll-edge--right{right:0}.upg-legend-desktop-slot{--stl-top:8px}.upg-legend-mobile-slot{display:none}@media(max-width:767px){.upg-legend-mobile-slot{display:block}.upg-legend-desktop-slot{display:none}.upg-detail-desktop-slot{display:none}}.upg-status{position:absolute;bottom:10px;right:10px;z-index:5;font:10px/1 ui-monospace,monospace;color:#9aa7b8;background:rgba(10,14,21,.82);padding:6px 10px;border-radius:8px}.upg-detail-panel{position:absolute;top:60px;right:8px;bottom:10px;width:340px;max-width:calc(100vw - 16px);z-index:6;background:#fff;border-radius:12px;box-shadow:0 8px 28px rgba(0,0,0,.45);overflow:hidden;display:flex;flex-direction:column;animation:upgPanelIn .18s ease}.upg-detail-panel.dark{background:#1a1a2e}@keyframes upgPanelIn{from{transform:translateX(16px);opacity:0}to{transform:translateX(0);opacity:1}}@media(max-width:480px){.upg-detail-panel{top:auto;left:8px;right:8px;width:auto;height:55vh}}.upg-hud{position:absolute;bottom:34px;right:10px;z-index:6;min-width:150px;font:11px/1.35 ui-monospace,monospace;color:#e5e7eb;background:rgba(10,20,16,.92);border:1px solid rgba(110,231,183,.35);border-radius:10px;padding:8px 10px;box-shadow:0 4px 16px rgba(0,0,0,.4)}.upg-hud-head{display:flex;align-items:baseline;gap:6px;white-space:nowrap}.upg-hud-total{font-size:15px;font-weight:700;color:#6ee7b7}.upg-hud-band{margin-inline-start:auto;font-size:9px;color:#9aa7b8}.upg-hud-band.ok{color:#6ee7b7}.upg-hud-names{margin-top:5px;max-height:84px;overflow:auto;font-size:10px;color:#cbd5e1;line-height:1.45;word-break:break-word}.upg-hud-actions{display:flex;gap:6px;margin-top:7px}.upg-hud-btn{flex:1;cursor:pointer;border:1px solid rgba(110,231,183,.4);background:rgba(16,185,129,.18);color:#d1fae5;font:12px/1 ui-monospace,monospace;padding:0 10px;min-height:40px;border-radius:8px}.upg-hud-btn:hover{background:rgba(16,185,129,.32)}.upg-hud-btn.clear{background:rgba(148,163,184,.12);border-color:rgba(148,163,184,.4);color:#cbd5e1}.upg-hud-flash{margin-top:5px;font-size:9px;color:#6ee7b7;min-height:11px}.upg-hud-hint{margin-top:4px;font-size:9px;color:#64748b}.upg-hud-swatches{display:flex;gap:6px;margin-top:7px;align-items:center;flex-wrap:wrap}.upg-swatch{width:40px;height:40px;border-radius:9px;cursor:pointer;padding:0;border:1px solid rgba(255,255,255,.3)}.upg-swatch.active{outline:2px solid #fff;outline-offset:1px}.upg-hex{width:84px;min-height:40px;background:rgba(148,163,184,.12);border:1px solid rgba(148,163,184,.4);color:#cbd5e1;font:12px/1 ui-monospace,monospace;padding:0 8px;border-radius:8px}@media(max-width:480px){.upg-hud{left:8px;right:8px;min-width:0;bottom:30px;max-height:48vh;overflow:auto}}.map-toolbar .mcb.upg-batch-on{background:#10b981!important;color:#04241a!important;box-shadow:0 0 0 2px rgba(52,211,153,.45),0 1px 4px rgba(0,0,0,0.2)!important}.map-toolbar .mcb.upg-batch-on.dark{border-color:#34d399!important}.upg-batch-row{position:relative;background:rgba(16,185,129,.16)!important;opacity:1!important;box-shadow:inset 3px 0 0 0 #10b981}.upg-batch-row .stl-name{color:#065f46!important;font-weight:700}.stl-panel[data-theme="dark"] .upg-batch-row .stl-name,.upg-batch-row.dark .stl-name{color:#6ee7b7!important}.upg-batch-row .stl-dot{box-shadow:0 0 0 2px #10b981}.mapboxgl-ctrl-top-left{top:12px!important;left:8px!important;width:380px!important;max-width:380px!important;z-index:1200!important}.mapboxgl-ctrl-top-left .mapboxgl-ctrl{margin:0!important;float:none!important}.stl-panel{--stl-top:8px!important}.upg-root:has(.mapboxgl-ctrl-geocoder) .stl-panel{--stl-top:58px!important}[dir="rtl"] .upg-detail-panel{right:auto!important;left:8px!important}.dg-main{font:13px/1.3 ui-monospace,monospace}.dg-meta{margin-top:2px;font-size:11px;color:#475569;display:flex;flex-wrap:wrap;gap:8px}.dg-field strong{font-weight:700}.dg-section-header-item{padding:4px 8px;font:10px/1.2 ui-monospace,monospace;letter-spacing:.06em;text-transform:uppercase;color:#94a3b8;pointer-events:none}`);function K(N){const H=[];for(const Y of N)H.push(Y.zoneKey,Qw(Y.zoneKey,Y.color));return["match",["get","zoneKey"],...H,"#9ca3af"]}function _e(){if(L.getSource("tapestry")&&L.getLayer("tapestry-fill")&&L.getLayer("tapestry-line"))return;L.getSource("tapestry")||L.addSource("tapestry",{type:"geojson",data:O});const N=g.value?.45:.3,H=g.value?.65:.45;if(L.getLayer("tapestry-fill")||L.addLayer({id:"tapestry-fill",type:"fill",source:"tapestry",paint:{"fill-color":ne,"fill-opacity":["case",["==",["get","zoneKey"],"deaf"],N,H]}}),L.getLayer("tapestry-line")||L.addLayer({id:"tapestry-line",type:"line",source:"tapestry",paint:{"line-color":ne,"line-width":1.2,"line-opacity":.9}}),nn){const Y=nn;Wt(()=>{nn===Y&&Wa(Y)})}}function $(){!L||!L.getSource("tapestry")||L.getLayer("upg-sel-fill")||(L.addLayer({id:"upg-sel-fill",type:"fill",source:"tapestry",filter:["boolean",!1],paint:{"fill-color":"#f59e0b","fill-opacity":.28}}),L.addLayer({id:"upg-sel-line",type:"line",source:"tapestry",filter:["boolean",!1],paint:{"line-color":"#fbbf24","line-width":2.4,"line-opacity":.95}}))}function A(){const N=[],H=[],Y=[];for(const Ae of m.value)Ae.kind==="adm1"?N.push(Ae.name):Ae.kind==="adm0"?H.push(Ae.key.slice(5)):Ae.kind==="zone"&&Y.push(Ae.key.slice(5));const fe=[];return N.length&&fe.push(["in",["get","shapeName"],["literal",N]]),H.length&&fe.push(["in",["get","iso3"],["literal",H]]),Y.length&&fe.push(["in",["get","zoneKey"],["literal",Y]]),fe.length?fe.length===1?fe[0]:["any",...fe]:["boolean",!1]}function C(){if(St(),!L||!L.getLayer("upg-sel-fill"))return;const N=E.value?A():["boolean",!1];L.setFilter("upg-sel-fill",N),L.setFilter("upg-sel-line",N);const H=Z.value;L.setPaintProperty("upg-sel-fill","fill-color",H||"#f59e0b"),L.setPaintProperty("upg-sel-fill","fill-opacity",H?.55:.28),L.setPaintProperty("upg-sel-line","line-color",H||"#fbbf24")}let U=null,oe=!1;function le(){if(!(!L||!L.getLayer("tapestry-fill"))){if(U)try{L.off("click","tapestry-fill",U)}catch{}U=N=>{const H=N&&N.features&&N.features[0];if(H&&E.value){const Y=Cg(H.properties,{nameMap:P});if(!Y){console.warn("[batch-select] clicked feature has no shapeName/iso3",H.properties);return}Y.count==null&&console.warn("[batch-select] no UUPG count for territory",Y.name,H.properties),re(Y)}},L.on("click","tapestry-fill",U),oe||(L.on("mouseenter","tapestry-fill",()=>{L&&(L.getCanvas().style.cursor=E.value?"crosshair":"")}),L.on("mouseleave","tapestry-fill",()=>{L&&(L.getCanvas().style.cursor="")}),oe=!0)}}function ie(){m.value=[],T.value="",Z.value="",G.value="",C()}function ge(N){if(u&&typeof u.cacheSourceData=="function"){const H=ak({records:N,leafZones:V,adm1Counts:si,iso3Names:Ba,countryNameMap:P,centroidFor:Y=>{const fe=J(Y);return fe?[(fe[0][0]+fe[1][0])/2,(fe[0][1]+fe[1][1])/2]:null}});u.cacheSourceData(vl,{normalizedData:H})}W=ok({records:N,leafZones:V,adm1Counts:si,iso3Names:Ba,countryNameMap:P}),typeof window<"u"&&(window.__UPG_SEARCH__={size:()=>W.length,counts:()=>{const H={pg:0,zone:0,territory:0};for(const Y of W)H[Y.kind]=(H[Y.kind]||0)+1;return H},query:H=>Tg(W,H,{limit:Ng}).map(Y=>({label:Y.label,kind:Y.kind,target:Y.target})),select:H=>{const Y=Tg(W,H,{limit:Ng})[0];return Y?(z(Y.target),{label:Y.label,kind:Y.kind,target:Y.target}):null},feedSize:()=>{const H=u&&u.sources&&u.sources[vl];return H&&Array.isArray(H.features)&&H.features.length||0},localGeocoder:H=>{const Y=I.value&&I.value.geocoder,fe=Y&&Y.options&&Y.options.localGeocoder;return fe?fe(H).map(Ae=>Ae&&Ae.place_name):null}},(window.__UPG_SEARCHES__||(window.__UPG_SEARCHES__={}))[a()]=window.__UPG_SEARCH__)}function w(N){const H=N&&N.properties||{},Y=H.__upgKind;if(Y==="zone")ee(H.__zoneId);else if(Y==="territory")D(H.__shapeName);else{const fe=N&&N.geometry,Ae=fe&&Array.isArray(fe.coordinates)?fe.coordinates:null;Ae&&Number.isFinite(Ae[0])&&Number.isFinite(Ae[1])&&L&&L.flyTo({center:[Ae[0],Ae[1]],zoom:6,duration:800}),Q(H.slug)}}function k(N){if(!N||!L)return;const H=new Set(N.memberIds||[]);if(!H.size)return;let Y=[];try{Y=L.querySourceFeatures("upg").filter(Je=>{const ke=Je.properties||{};return H.has(ke.slug)||H.has(ke.id)||H.has(ke.peopleGroupId)})}catch{return}if(!Y.length)return;let fe=180,Ae=90,je=-180,Ke=-90,De=!1;for(const Je of Y){const ke=Je.geometry&&Je.geometry.coordinates;!Array.isArray(ke)||!Number.isFinite(ke[0])||!Number.isFinite(ke[1])||(ke[0]je&&(je=ke[0]),ke[1]Ke&&(Ke=ke[1]),De=!0)}De&&L.fitBounds([[fe,Ae],[je,Ke]],{padding:60,duration:800,maxZoom:6})}function B(){Zn(null),c&&typeof c.selectPeopleGroup=="function"&&c.selectPeopleGroup(null)}function z(N){!N||!L||(N.type==="pg"?(Number.isFinite(N.lng)&&Number.isFinite(N.lat)&&L.flyTo({center:[N.lng,N.lat],zoom:6,duration:800}),Q(N.slug)):N.type==="zone"?ee(N.zoneId):N.type==="territory"&&D(N.shapeName))}function Q(N){if(!N||!c||typeof c.selectPeopleGroup!="function")return;const Y=rk(L,"upg").find(fe=>fe.properties&&fe.properties.slug===N);Y&&c.selectPeopleGroup(Y)}function ee(N){if(!N||!L||!O)return;const H=J(Y=>Y.properties&&Y.properties.zoneKey===N);H&&L.fitBounds(H,{padding:40,duration:800,maxZoom:6})}function D(N){if(!N||!L||!O)return;const H=J(Y=>{const fe=Y.properties||{};return fe.shapeName===N||fe.iso3===N});H&&L.fitBounds(H,{padding:40,duration:800,maxZoom:6})}function J(N){let H=180,Y=90,fe=-180,Ae=-90,je=!1;const Ke=De=>{if(typeof De[0]=="number"){const[Je,ke]=De;Jefe&&(fe=Je),keAe&&(Ae=ke),je=!0;return}for(const Je of De)Ke(Je)};for(const De of O.features)N(De)&&Ke(De.geometry.coordinates);return je?[[H,Y],[fe,Ae]]:null}function $e(N){const H=new Set,Y=fe=>{fe.children&&fe.children.length?fe.children.forEach(Y):H.add(fe.zoneKey??fe.id)};return Y(N),H}let Ee=null;function qe(N){if(![...$e(N)].length)return;const Y=[],fe=De=>{De.children&&De.children.length?De.children.forEach(fe):Y.push(De)};fe(N);const Ae=m.value,je=new Set(Ae.filter(De=>De.kind==="zone").map(De=>De.key));if(Y.every(De=>je.has("zone:"+(De.zoneKey??De.id)))){const De=new Set(Y.map(Je=>"zone:"+(Je.zoneKey??Je.id)));m.value=Ae.filter(Je=>!De.has(Je.key))}else{const De=Y.filter(Je=>!je.has("zone:"+(Je.zoneKey??Je.id))).map(Je=>({key:"zone:"+(Je.zoneKey??Je.id),name:Je.label||Je.id,count:Number(Je.count)||0,kind:"zone"}));m.value=[...Ae,...De]}C(),T.value=""}function ft(){const N=new Set;for(const H of m.value)H.kind==="zone"&&N.add(H.key.slice(5));return N}function it(){const N=new Map,H=Y=>{const fe=$e(Y);Y.label&&N.set(Y.label,fe),Y.children&&Y.children.length&&Y.children.forEach(H)};for(const Y of x.value)H(Y);return N}function St(){if(typeof document>"u")return;const N=document.querySelector("my-upg-100-list-map"),Y=(N&&N.shadowRoot||document).querySelectorAll(".stl-row");if(!Y.length)return;if(!E.value){Y.forEach(Ke=>Ke.classList.remove("upg-batch-row"));return}const fe=ft(),Ae=it(),je=g.value;Y.forEach(Ke=>{const De=Ke.querySelector(".stl-name"),Je=De?De.textContent.trim():"",ke=Je&&Ae.get(Je),Ue=!!(ke&&ke.size&&[...ke].every(st=>fe.has(st)));Ke.classList.toggle("upg-batch-row",Ue),Ke.classList.toggle("dark",Ue&&je)})}let Et=null;function Le(){if(typeof document>"u"||Et)return;const N=document.querySelector("my-upg-100-list-map"),Y=(N&&N.shadowRoot||document).querySelector(".stl-rows");Y&&(Et=new MutationObserver(()=>{requestAnimationFrame(()=>St())}),Et.observe(Y,{childList:!0,subtree:!0}))}Ut("onSemanticTreeSelect",Zn),Ut("onLegendExport",Qe);async function Qe(N){const H=b.value;if(!H)return;if(N==="packet"){await Ie(H);return}const Y=Re().find(fe=>fe.id===H)||{id:H};await Ot.printPoster(Y)}const Ot=rp({records:N=>F(N),lang:()=>zo(),label:N=>(N==null?void 0:N.label)||(N==null?void 0:N.id)||"",assetsBase:()=>Un(n.value),downloadPrefix:"doxa-upg-100"});ot(Ot.exportState,N=>{if(!N){/packet/i.test(d.value)&&(d.value="");return}if(N.phase==="error"){Ce(se("messages.packetFailed",{reason:N.message}),4e3);return}d.value=N.phase==="done"?"":`${N.message}…`});async function F(N){if(!ye)throw new Error("no API configured");const Y=await fetch(`${ye}/api/people-groups/list?fields=slug,name,country_code,population,religion,image_url&lang=${zo()}`,{cache:"no-store"});if(!Y.ok)throw new Error(`people-groups fetch failed (${Y.status})`);const fe=Na(await Ea(Ma(await Y.json()),n));let Ae;if(N.selector&&N.selector.type==="pg_slugs")Ae=new Set(N.selector.values||[]);else{const{evaluate:je}=await yt(async()=>{const{evaluate:Ke}=await Promise.resolve().then(()=>Ls);return{evaluate:Ke}},void 0);Ae=new Set(je(N.selector,fe))}return fe.filter(je=>Ae.has(je.slug)).sort((je,Ke)=>String(je.name).localeCompare(String(Ke.name),zo()))}async function te(N,H){try{const Y=Un(n.value),fe=await(await fetch(`${Y}/posters/${N}.html`,{cache:"force-cache"})).text(),Ae=fe.match(//);return Ae?`
${Ae[0]}
`:""}catch{return""}}function xe(N,H,Y){N.value=H,setTimeout(()=>{N.value===H&&(N.value="")},Y)}const Ce=(N,H)=>xe(d,N,H);async function Ie(N){const H=Re().find(je=>je.id===N);if(!H)return;const[{createPacketRenderer:Y},fe]=await Promise.all([yt(()=>Promise.resolve().then(()=>Sl),void 0),yt(()=>Promise.resolve().then(()=>Ha),void 0).then(je=>je.default||je)]),Ae=Y({strings:fe,lang:zo()});await Ot.printPacket(H,{mapSvg:await te(N,Ae),funnel:await At()})}function at(){return gp(jr(n))}function Re(){const N=at();return[...N.lists||[],...N.asia_lists||[],...N.uncovered_lists||[]]}async function At(){var N;try{const H=(await yt(async()=>{const{default:je}=await Promise.resolve().then(()=>uP);return{default:je}},void 0)).default;if(!H||!Array.isArray(H.steps)||!H.steps.length)return null;const Y=jr(n),fe=Number(H.steps[H.steps.length-1].groups)||0;if(Y===Ta)return{...H,listCount:Re().length,listTotal:fe};let Ae=0;try{const je=Un(n.value),Ke=await fetch(`${je}/people-groups/lists/${Y}.json`);if(Ke.ok){const De=await Ke.json();Ae=Number((N=De==null?void 0:De.counts)==null?void 0:N.doxa)||(Array.isArray(De==null?void 0:De.slugs)?De.slugs.length:0)}}catch{}return{...H,listTotal:Ae,listId:Y,listLabel:(op(Y)||{}).label||Y}}catch{return null}}const mt=be(!1);function qt(){const N=m.value.filter(Y=>Y.kind==="zone").map(Y=>String(Y.key).replace(/^zone:/,"")),H=new Map(Re().map(Y=>[Y.id,Y]));return N.map(Y=>H.get(Y)).filter(Boolean)}let ja=null;async function dP(){if(!ja){const N=await yt(()=>Promise.resolve().then(()=>Ha),void 0).then(H=>H.default||H);ja={...N.en||{},...N[zo()]||{}}}return ja}function th(N,H){return N?String(N).replace(/\{(\w+)\}/g,(Y,fe)=>H[fe]!=null?String(H[fe]):Y):null}async function pP(){const N=qt();if(!N.length)throw new Error("nothing selected");if(!ye)throw new Error("no API configured");const Y=await fetch(`${ye}/api/people-groups/list?fields=slug,name,country_code,population,religion,image_url&lang=${zo()}`,{cache:"no-store"});if(!Y.ok)throw new Error(`people-groups fetch failed (${Y.status})`);const fe=Na(await Ea(Ma(await Y.json()),n)),{evaluate:Ae}=await yt(async()=>{const{evaluate:Ue}=await Promise.resolve().then(()=>Ls);return{evaluate:Ue}},void 0),je=new Set;for(const Ue of N)if(Ue.selector&&Ue.selector.type==="pg_slugs")for(const st of Ue.selector.values||[])je.add(st);else for(const st of Ae(Ue.selector,fe))je.add(st);const Ke=N.map(Ue=>Ue.label||Ue.id),De=await dP(),Je=(Ue,st)=>th(De.zone_join,{a:Ue,b:st})??`${Ue} + ${st}`;return{id:"selection",label:Ke.length<=3?Ke.reduce(Je):th(De.zone_join_more,{a:Ke.slice(0,2).reduce(Je),n:Ke.length-2})??`${Ke.slice(0,2).join(" + ")} +${Ke.length-2} more`,count:je.size,selector:{type:"pg_slugs",values:[...je]}}}async function gP(){if(!mt.value){mt.value=!0;try{const N=await pP(),[{createPacketRenderer:H},Y]=await Promise.all([yt(()=>Promise.resolve().then(()=>Sl),void 0),yt(()=>Promise.resolve().then(()=>Ha),void 0).then(De=>De.default||De)]),fe=H({strings:Y,lang:zo()}),Ae=qt(),je=Ae.length===1?await te(Ae[0].id,fe):"",Ke=await At();await Ot.printPacket(N,{mapSvg:je,funnel:Ke&&Ae.length===1?Ke:Ke?{...Ke,listCount:0}:null})}catch(N){Ce(se("messages.selectionPacketFailed",{reason:String((N==null?void 0:N.message)||N).slice(0,90)}),4e3)}finally{mt.value=!1}}}async function hP(){if(!mt.value){mt.value=!0;try{const N=qt();if(!N.length)throw new Error("nothing selected");if(N.length>1){Ce(se("messages.posterOneTerritory",{count:N.length}),5e3);return}await Ot.printPoster(N[0])}catch(N){Ce(se("messages.selectionPosterFailed",{reason:String((N==null?void 0:N.message)||N).slice(0,90)}),4e3)}finally{mt.value=!1}}}function zo(){const N=Be&&(Be.value??Be);return typeof N=="string"&&N||"en"}function Zn(N){if(!L||!L.getLayer("tapestry-fill"))return!1;if(E.value)return N&&qe(N),!0;if(!N)return Ee=null,b.value=null,L.setFilter("tapestry-fill",null),L.setFilter("tapestry-line",null),L.setPaintProperty("upg-pins","circle-opacity",1),!0;Ee=N;const H=[...$e(N)];b.value=H.length===1?H[0]:N.id??null;const Y=["in",["get","zoneKey"],["literal",H]];L.setFilter("tapestry-fill",Y),L.setFilter("tapestry-line",Y),L.getLayer("upg-pins")&&L.setPaintProperty("upg-pins","circle-opacity",["case",["in",["get","zoneKey"],["literal",H]],.95,.05]);const fe=J(Ae=>H.includes(Ae.properties.zoneKey));return fe&&L.fitBounds(fe,{padding:40,duration:700,maxZoom:6}),!0}function Al(){L&&(typeof Pe=="function"&&Pe(),O&&(_e(),$(),le(),C(),b.value&&L.getLayer("tapestry-fill")&&Zn(Ee)))}function fP(){L&&(g.value=!g.value,f.theme.value=g.value?"dark":"light",L.setStyle(g.value?bl("ink",r).style||"mapbox://styles/mapbox/dark-v11":bl("paper",r).style||"mapbox://styles/mapbox/light-v11"),L.once("style.load",Al))}function oh(){!L||!L.getLayer("upg-pins")||(L.on("click","upg-pins",N=>{const H=N&&N.features&&N.features[0];H&&c&&typeof c.selectPeopleGroup=="function"&&c.selectPeopleGroup(H)}),L.on("mouseenter","upg-pins",()=>{L&&(L.getCanvas().style.cursor="pointer")}),L.on("mouseleave","upg-pins",()=>{L&&(L.getCanvas().style.cursor="")}))}let Va=null,nn,Xn=null;function ci(N,H){var Y,fe,Ae;try{const je=(Ae=(fe=(Y=p.value)==null?void 0:Y.getRootNode)==null?void 0:fe.call(Y))==null?void 0:Ae.host;if(!je)return;je.setAttribute("data-doxa-select-zone-state",N),H&&je.setAttribute("data-doxa-select-zone-applied",String(H))}catch{}}function Wa(N){if(!N)return Zn(null),nn=void 0,ci("cleared",""),!0;const H=nh(x.value,N);return H?Zn(H)?(nn=void 0,ci("applied",N),!0):(nn=N,ci("applied-but-no-selection",N),!1):(nn=N,ci("unresolved",N),!1)}function mP(N){var Y;const H=((Y=N==null?void 0:N.detail)==null?void 0:Y.listId)??null;Wa(H)}function nh(N,H){for(const Y of N||[]){if((Y.zoneKey||Y.id)===H)return Y;const fe=Y.children&&nh(Y.children,H);if(fe)return fe}return null}function bP(){const N=at(),H=yl(N,{deafCount:wl});x.value=H,V=xg(H);const Y={};for(const fe of N.lists||[])Y[fe.id]=fe.selector;for(const fe of N.asia_lists||[])Y[fe.id]=fe.selector;for(const fe of N.uncovered_lists||[])Y[fe.id]=fe.selector;Y.deaf={type:"affinity_bloc",rop1:"A017"};for(const fe of V)fe.selector=Y[fe.id];ne=K(V)}async function ah(){if(ye)try{const H=await fetch(`${ye}/api/people-groups/list?fields=slug,name,country_code,wagf_region,wagf_block,rop1,population,latitude,longitude&lang=${zo()}`,{cache:"no-store"});if(!H.ok)throw new Error(`list ${H.status}`);const Y=Na(await Ea(Ma(await H.json()),n));P=Lg(Y),x.value=yl(at(),{deafCount:wl,records:Y})}catch{}}io(async()=>{var Ae,je,Ke,De,Je;bP();try{await Hw(r)}catch{}const N=_l(r);N&&Uw(N);const H=(o==null?void 0:o.value)||((Ae=n==null?void 0:n.value)==null?void 0:Ae.tk)||"";if(!N){console.warn(`[upg-100-list] ${r} engine global is missing — refusing to substitute another engine. A page that asked for the keyless engine must not silently receive the token-gated one.`),d.value=`⚠ ${se("messages.engineNotLoaded")}`,S.value=se("messages.engineNotLoadedDetail",{engine:i?"MapLibre":"Mapbox"}),ah();return}if(!i){if(!H){d.value=`⚠ ${se("messages.noMapboxToken")}`,S.value=se("messages.noMapboxTokenDetail"),ah();return}N.accessToken=H}try{const ke=kg(r);ke&&await jw(p.value,ke)}catch{}try{const ke=!i&&p.value&&p.value.getRootNode();if(ke instanceof ShadowRoot){const Ue=kg("mapbox");if(Ue&&!ke.querySelector(`link[href="${Ue}"]`)){const st=document.createElement("link");st.rel="stylesheet",st.href=Ue,ke.prepend(st)}}}catch{}L=new N.Map({container:p.value,style:bl("paper",r).style||"mapbox://styles/mapbox/light-v11",center:[35,20],zoom:1.5,projection:"mercator"}),h.value=L,ue=Gw(((je=p.value)==null?void 0:je.parentElement)||null,{enabled:l.value}),typeof window<"u"&&(window.__UPG_MAP__=L,(window.__UPG_MAPS__||(window.__UPG_MAPS__={}))[a()]=L),window.__UPG_SELECT__={get list(){return m.value.map(ke=>({...ke}))},get total(){return y.value},get count(){return _.value},get color(){return Z.value},get batchMode(){return E.value},setColor:ke=>pe(ke),setBatchMode:ke=>v(ke),clipboardText:()=>ek(m.value,{color:Z.value}),clear:()=>ie(),toggleByProps:ke=>{const Ue=Cg(ke,{nameMap:P});return Ue?(re(Ue),{...Ue}):null},toggleLegendRow:ke=>{const Ue=an=>{for(const bt of an){if(bt.label===ke)return bt;if(bt.children&&bt.children.length){const zt=Ue(bt.children);if(zt)return zt}}return null},st=Ue(x.value);return st?(qe(st),{label:st.label,zoneKeys:[...$e(st)]}):null},markedLegendRows:()=>{if(typeof document>"u")return[];const ke=document.querySelector("my-upg-100-list-map");return[...(ke&&ke.shadowRoot||document).querySelectorAll(".stl-row.upg-batch-row .stl-name")].map(st=>st.textContent.trim())},highlightFeatureCount:()=>{if(!L||!O||!L.getLayer("upg-sel-fill"))return-1;const ke=new Set,Ue=new Set,st=new Set;for(const bt of m.value)bt.kind==="zone"?ke.add(bt.key.slice(5)):bt.kind==="adm1"?Ue.add(bt.name):bt.kind==="adm0"&&st.add(bt.key.slice(5));let an=0;for(const bt of O.features){const zt=bt.properties||{};(ke.has(zt.zoneKey)||Ue.has(zt.shapeName)||st.has(zt.iso3))&&an++}return an},zoneKeysForRow:ke=>{const Ue=an=>{for(const bt of an){if(bt.label===ke)return bt;if(bt.children&&bt.children.length){const zt=Ue(bt.children);if(zt)return zt}}return null},st=Ue(x.value);return st?[...$e(st)]:null}},(window.__UPG_SELECTS__||(window.__UPG_SELECTS__={}))[a()]=window.__UPG_SELECT__;try{d.value=se("messages.loadingBoundaries");const ke=Ve=>`${Un(n.value)}/boundaries/${Ve}`,Ue=Ve=>fetch(ke(Ve)).then(Rt=>{if(!Rt.ok)throw new Error(`boundary fetch ${Rt.status} ${Ve}`);return Rt.json()});if(!ye)throw new Error("No API base configured — set window.MAP_APP_API_URL or VITE_API_BASE_URL. Failing closed (no default host).");const an=fetch(`${ye}/api/people-groups/list?fields=slug,name,country_code,wagf_region,wagf_block,rop1,population,latitude,longitude&lang=${zo()}`).then(Ve=>{if(!Ve.ok)throw new Error(`list ${Ve.status}`);return Ve.json()}),bt={adm0:Ue("world-adm0-web.geojson"),adm1Chn:Ue("gb-CHN-ADM1.geojson"),adm1Ind:Ue("gb-IND-ADM1-web.geojson")};d.value=se("messages.fetchingUupgs",{n:2106});const zt=Na(await Ea(Ma(await an),n));P=Lg(zt),x.value=yl(at(),{deafCount:wl,records:zt});const Ll=[],Ka={},{evaluate:yP}=await yt(async()=>{const{evaluate:Ve}=await Promise.resolve().then(()=>Ls);return{evaluate:Ve}},void 0);for(const Ve of V)if(Ve.selector&&Ve.selector.type==="pg_slugs")for(const Rt of Ve.selector.values||[])Rt in Ka||(Ka[Rt]=Ve.zoneKey);else try{for(const Rt of yP(Ve.selector,zt))Rt in Ka||(Ka[Rt]=Ve.zoneKey)}catch(Rt){console.warn("zone selector skipped",Ve.id,Rt&&Rt.message)}for(const Ve of zt){const Rt=Number(Ve.latitude),Tl=Number(Ve.longitude);!isFinite(Rt)||!isFinite(Tl)||Ll.push({type:"Feature",geometry:{type:"Point",coordinates:[Tl,Rt]},properties:{slug:Ve.slug,zoneKey:Ka[Ve.slug]||"",name:Ve.name||Ve.slug||"",population:Ve.population??0,countryName:Ve.country_code_label||"",country:Ve.country_code||""}})}const $P=ln({type:"FeatureCollection",features:Ll});Pe=()=>{if(!(L.getSource("upg")&&L.getLayer("upg-pins"))){if(L.getSource("upg")||L.addSource("upg",{type:"geojson",data:$P}),L.getLayer("upg-pins")){oh();return}L.addLayer({id:"upg-pins",type:"circle",source:"upg",paint:{"circle-radius":["interpolate",["linear"],["zoom"],1,5,4,6.5,8,9],"circle-color":ne,"circle-opacity":1,"circle-stroke-width":["interpolate",["linear"],["zoom"],1,1.8,8,2],"circle-stroke-color":"rgba(15,20,25,0.9)"}}),oh()}};const rh=()=>{try{Al()}catch(Ve){console.warn("early pin paint skipped",Ve&&Ve.message)}};L.isStyleLoaded()?rh():L.once("style.load",rh),d.value=se("messages.loadingBoundaries");const[vP,wP]=await Promise.all([bt.adm0,bt.adm1Chn]),kP=await bt.adm1Ind,{tapestry:PP,perZone:xP}=Zw(V,{records:zt,adm0:vP,adm1Ind:kP,adm1Chn:wP});O=ln(PP),ge(zt);let Cl=!0;const Qn=()=>{Cl&&(Cl=!1,L.off("style.load",Qn),L.off("idle",Qn),Al())};if(L.isStyleLoaded())Qn();else{L.once("style.load",Qn),L.once("idle",Qn);const Ve=setInterval(()=>{if(!Cl||!L){clearInterval(Ve);return}let Rt=!1;try{Rt=L.isStyleLoaded()}catch{clearInterval(Ve);return}Rt&&(clearInterval(Ve),Qn())},120);setTimeout(()=>clearInterval(Ve),15e3)}const ih=[...xP.entries()].filter(([Ve])=>Ve!=="deaf"),SP=ih.filter(([,Ve])=>Ve>=1).length;d.value=se("messages.mapStatusCounts",{polys:O.features.length,zones:SP,total:ih.length,pins:Ll.length})}catch(ke){d.value="⚠ "+(ke&&ke.message?ke.message:String(ke))}let Y=0;const fe=()=>{const ke=typeof document<"u"&&document.querySelector("my-upg-100-list-map"),Ue=ke&&ke.shadowRoot||(typeof document<"u"?document:null);if(Ue&&Ue.querySelector(".stl-rows")){Le(),St();return}Y++<40&&setTimeout(fe,250)};fe();{const ke=(Je=(De=(Ke=p.value)==null?void 0:Ke.getRootNode)==null?void 0:De.call(Ke))==null?void 0:Je.host;if(ke){Va=mP,ke.addEventListener("doxa:select-zone",Va);const Ue=ke.getAttribute("select-zone");Ue&&Wa(Ue),Xn=new MutationObserver(()=>{Wa(ke.getAttribute("select-zone")||null)}),Xn.observe(ke,{attributes:!0,attributeFilter:["select-zone"]})}}});const _P=()=>{var N,H,Y;try{return((Y=(H=(N=p.value)==null?void 0:N.getRootNode)==null?void 0:H.call(N))==null?void 0:Y.host)||null}catch{return null}};return ot([x,h],()=>{Wt(()=>{var H;const N=((H=_P())==null?void 0:H.getAttribute("select-zone"))||nn||null;N&&Wa(N)})}),Qt(()=>{var N,H,Y;if(Xn==null||Xn.disconnect(),Xn=null,Va){const fe=(Y=(H=(N=p.value)==null?void 0:N.getRootNode)==null?void 0:H.call(N))==null?void 0:Y.host;fe==null||fe.removeEventListener("doxa:select-zone",Va),Va=null}if(Et){try{Et.disconnect()}catch{}Et=null}if(ue){try{ue()}catch{}ue=null}L&&(L.remove(),L=null),O=null}),(N,H)=>{var Y;return q(),ae("div",ik,[R("div",{ref_key:"mapEl",ref:p,class:"upg-map"},null,512),S.value?(q(),ae("div",sk,[R("strong",null,de(me(se)("messages.mapUnavailable")),1),wt(de(S.value),1)])):we("",!0),l.value?(q(),ae(ze,{key:1},[H[0]||(H[0]=R("div",{class:"map-scroll-edge map-scroll-edge--left"},null,-1)),H[1]||(H[1]=R("div",{class:"map-scroll-edge map-scroll-edge--right"},null,-1))],64)):we("",!0),h.value&&s.value?(q(),dt(Nw,{key:2,ref_key:"geocoderRef",ref:I,"map-instance":h.value,"access-token":me(o)||((Y=me(n))==null?void 0:Y.tk)||"","data-source-id":vl,"is-dark":g.value,placeholder:Se.value,"active-context":vk,onPeopleGroupResult:w,onAggregateResult:k,onClear:B},null,8,["map-instance","access-token","is-dark","placeholder"])):we("",!0),h.value?(q(),dt(iw,{key:3,"has-geocoder":s.value},{default:Xt(()=>[tt(lw,{map:h.value,"is-dark":g.value},null,8,["map","is-dark"]),tt(cw,{map:h.value,"is-dark":g.value},null,8,["map","is-dark"]),tt(uw,{map:h.value,"is-dark":g.value},null,8,["map","is-dark"]),tt(gw,{"map-container":p.value,"is-dark":g.value},null,8,["map-container","is-dark"]),tt(fw,{"is-dark":g.value,onToggle:fP},null,8,["is-dark"]),tt(wn,{"is-dark":g.value,active:E.value,class:Ge({"upg-batch-on":E.value}),"aria-pressed":E.value?"true":"false",title:ce.value,onClick:j},{default:Xt(()=>[...H[2]||(H[2]=[R("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[R("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),R("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),R("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),R("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1"})],-1)])]),_:1},8,["is-dark","active","class","aria-pressed","title"])]),_:1},8,["has-geocoder"])):we("",!0),R("div",lk,[x.value.length?(q(),dt(yp,{key:0,nodes:x.value,tabs:M.value,"default-tab":Rg,columns:["count","pop"],title:he.value,"export-enabled":!0,onSelect:Zn,onExport:Qe},null,8,["nodes","tabs","title"])):we("",!0)]),R("div",ck,[x.value.length?(q(),dt(rw,{key:0,"legend-type":"upg-100",nodes:x.value,tabs:M.value,"default-tab":Rg,columns:["count","pop"],"column-label":"UPG 100",title:he.value,"is-dark":g.value,"popup-action":"pray"},null,8,["nodes","tabs","title","is-dark"])):we("",!0)]),R("div",uk,[me(c)&&me(c).selectedPeopleGroup?(q(),ae("div",{key:0,class:Ge(["upg-detail-panel pg-detail-root",{dark:g.value}])},[tt(me(t),{peopleGroup:me(c).selectedPeopleGroup,dark:g.value,action:"pray"},null,8,["peopleGroup","dark"])],2)):we("",!0)]),E.value?(q(),ae("div",dk,[R("div",pk,de(me(se)("messages.tapTerritoriesHint")),1),_.value?(q(),ae("div",gk,[R("span",null,de(me(se)("messages.territoriesSelected",{count:_.value}))+" ·",1),R("span",hk,de(y.value)+" UUPG",1),R("span",{class:Ge(["upg-hud-band",{ok:y.value>=50&&y.value<=100}])},de(y.value>=50&&y.value<=100?"✓ 50–100 band":"band 50–100"),3)])):we("",!0),_.value?(q(),ae("div",fk,de(m.value.map(fe=>fe.name).join(", ")),1)):we("",!0),_.value?(q(),ae("div",mk,[R("button",{class:"upg-hud-btn make",disabled:mt.value,onClick:gP},de(me(se)("buttons.prayerList")),9,bk),R("button",{class:"upg-hud-btn make",disabled:mt.value,onClick:hP},de(me(se)("buttons.posterMap")),9,_k),R("button",{class:"upg-hud-btn clear",onClick:ie},de(me(se)("buttons.clearSelection")),1)])):we("",!0),_.value?(q(),ae("div",yk,de(T.value),1)):we("",!0)])):we("",!0),R("div",$k,de(d.value),1)])}}}},Symbol.toStringTag,{value:"Module"})),kk=` +`+s}function Jn(e){return String(e??"").normalize("NFD").replace(/[̀-ͯ]/g,"").toLowerCase().trim()}function tk(e){return Jn(e).split(/[\s,;]+/).filter(Boolean)}function ok(e={}){const{records:t=[],leafZones:o=[],adm1Counts:n={},iso3Names:a={},countryNameMap:r=null}=e,i=[],s=new Set;for(const u of t){if(!u)continue;const c=u.slug;if(!c||s.has(c))continue;const p=Number(u.latitude),d=Number(u.longitude);if(!Number.isFinite(p)||!Number.isFinite(d))continue;const S=u.name||c;s.add(c),i.push({label:S,kind:"pg",target:{type:"pg",slug:c,lng:d,lat:p},_hay:Jn(S)})}for(const u of o){if(!u)continue;const c=u.zoneKey||u.id,p=u.label||c;c&&i.push({label:p,kind:"zone",target:{type:"zone",zoneId:c},_hay:Jn(p)})}for(const u of Object.keys(n))i.push({label:u,kind:"territory",target:{type:"territory",shapeName:u},_hay:Jn(u)});const l=r||a;for(const u of Object.keys(a)){const c=l&&l[u]||a[u]||u;i.push({label:c,kind:"territory",target:{type:"territory",shapeName:u,iso3:!0},_hay:Jn(c)})}return i}const nk={zone:0,territory:1,pg:2};function ak(e={}){const{records:t=[],leafZones:o=[],adm1Counts:n={},iso3Names:a={},countryNameMap:r=null,centroidFor:i=null}=e,s=[];for(const c of t)c&&s.push(c);const l=(c,p,d)=>!p||!Number.isFinite(p[0])||!Number.isFinite(p[1])?null:{name:c,slug:d.__synthSlug,latitude:p[1],longitude:p[0],...d};for(const c of o){if(!c)continue;const p=c.zoneKey||c.id,d=c.label||p;if(!p)continue;const S=typeof i=="function"?i(b=>b&&b.properties&&b.properties.zoneKey===p):null,x=l(d,S,{__upgKind:"zone",__zoneId:p,__synthSlug:`__zone__${p}`});x&&s.push(x)}for(const c of Object.keys(n)){const p=typeof i=="function"?i(S=>S&&S.properties&&S.properties.shapeName===c):null,d=l(c,p,{__upgKind:"territory",__shapeName:c,__synthSlug:`__terr__${c}`});d&&s.push(d)}const u=r||a;for(const c of Object.keys(a)){const p=u&&u[c]||a[c]||c,d=typeof i=="function"?i(x=>x&&x.properties&&x.properties.iso3===c):null,S=l(p,d,{__upgKind:"territory",__shapeName:c,__synthSlug:`__terr__${c}`});S&&s.push(S)}return s}function Tg(e,t,o={}){const n=o.limit??8,a=tk(t);if(!a.length)return[];const r=a[0],i=[];for(const s of e){let l=!0;for(const p of a)if(!s._hay.includes(p)){l=!1;break}if(!l)continue;const u=s._hay.startsWith(r)?0:1,c=s._hay===Jn(t)?-1:0;i.push({e:s,starts:u,exact:c,kr:nk[s.kind]??9,len:s._hay.length})}return i.sort((s,l)=>s.exact-l.exact||s.starts-l.starts||s.kr-l.kr||s.len-l.len),i.slice(0,n).map(s=>s.e)}const Eg=new Set;function rk(e,t){var a,r;const o=e.getSource(t);if(!o)return[];let n=o._data??((r=(a=o.serialize)==null?void 0:a.call(o))==null?void 0:r.data);if(n&&typeof n=="object"&&!Array.isArray(n)){if(n.geojson!==void 0)n=n.geojson;else if(n.url!==void 0)return Eg.has(t)||(Eg.add(t),console.warn(`[pin-selection] source "${t}" is remote (url); its features cannot be read locally, so nothing can be selected from it.`)),[]}return n?Array.isArray(n==null?void 0:n.features)?n.features:(n==null?void 0:n.type)==="Feature"?[n]:[]:[]}const ik={class:"upg-root"},sk={key:0,class:"upg-map-err"},lk={class:"upg-legend-desktop-slot"},ck={class:"upg-legend-mobile-slot"},uk={class:"upg-detail-desktop-slot"},dk={key:4,class:"upg-hud"},pk={class:"upg-hud-hint"},gk={key:0,class:"upg-hud-head"},hk={class:"upg-hud-total"},fk={key:1,class:"upg-hud-names"},mk={key:2,class:"upg-hud-actions"},bk=["disabled"],_k=["disabled"],yk={key:3,class:"upg-hud-flash"},$k={class:"upg-status"},vl="upg-search",Rg=1,vk="people-groups",Ng=8,wl=123,wk=Object.freeze(Object.defineProperty({__proto__:null,default:{__name:"upg-100-list",setup(e){const t=tp(()=>yt(()=>Promise.resolve().then(()=>j1),void 0)),o=He("mapboxToken",be("")),n=He("profileConfig",be(null));function a(){var N,H;return((N=n.value)==null?void 0:N.instanceId)||((H=n.value)==null?void 0:H.profile)||"upg-100-list"}const r=Fw(n),i=r==="maplibre",s=X(()=>{var N;return((N=n==null?void 0:n.value)==null?void 0:N.search)===!1?!1:r==="mapbox"}),l=X(()=>{var H;const N=(H=n.value)==null?void 0:H.edgeScrollAffordance;return N==null?!0:!(N===!1||N==="false")}),u=He("dataStore",null),c=He("uiStore",null),p=be(null),d=be("loading…"),S=be(""),x=cn([]),b=be(null),h=cn(null),g=be(!1),f=S$("my-upg-100-list");f.theme.value="light",A$(f);const m=be([]),y=X(()=>m.value.reduce((N,H)=>N+(Number(H.count)||0),0)),_=X(()=>m.value.length),T=be("");let P=null;const E=be(!1);function v(N){const H=N===void 0?!E.value:!!N;return H===E.value||(E.value=H,L&&(L.getCanvas().style.cursor=""),C()),H}function j(){v()}ot([E,g],()=>{Wt(()=>St())});function re(N){if(!N)return;const H=m.value,Y=H.findIndex(fe=>fe.key===N.key);Y>=0?m.value=H.filter((fe,Ae)=>Ae!==Y):m.value=[...H,N],C(),T.value=""}const Z=be(""),G=be("");function pe(N){const H=/^#?([0-9a-fA-F]{6})$/.exec(String(N||"").trim());if(!H)return;const Y="#"+H[1].toLowerCase();Z.value=Z.value===Y?"":Y,C()}const I=be(null),M=X(()=>[{id:"upg100Region",label:se("tabs.upg100Region"),info:se("legend.tabInfo.upg100Region")},{id:"upg100Zone",label:se("tabs.upg100Zone"),info:se("legend.tabInfo.upg100Zone")}]);let W=[],L=null,O=null,V=[],ne=null,ue=null,Pe=null;const ye=typeof window<"u"&&window.MAP_APP_API_URL||void 0||"",{locale:Be,t:se}=xt(),he=X(()=>se("legend.title.upg100List")),ce=X(()=>se("legend.title.batchSelect")),Se=X(()=>se("search.upg100Placeholder"));Tt(`.upg-root{position:absolute;inset:0;background:#0a1410;color:#e5e7eb;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif}.upg-map{position:absolute;inset:0}.upg-map-err{position:absolute;left:0;right:0;top:50%;transform:translateY(-50%);z-index:1;pointer-events:none;text-align:center;padding:0 24px;font:13px/1.5 -apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;color:#9aa7b8}.upg-map-err strong{display:block;font-size:14px;color:#cbd5e1;margin-bottom:4px}.map-scroll-edge{position:absolute;top:0;bottom:0;width:40px;z-index:2;touch-action:pan-y;pointer-events:auto;background:transparent}.map-scroll-edge--left{left:0}.map-scroll-edge--right{right:0}.upg-legend-desktop-slot{--stl-top:8px}.upg-legend-mobile-slot{display:none}@media(max-width:767px){.upg-legend-mobile-slot{display:block}.upg-legend-desktop-slot{display:none}.upg-detail-desktop-slot{display:none}}.upg-status{position:absolute;bottom:10px;right:10px;z-index:5;font:10px/1 ui-monospace,monospace;color:#9aa7b8;background:rgba(10,14,21,.82);padding:6px 10px;border-radius:8px}.upg-detail-panel{position:absolute;top:60px;right:8px;bottom:10px;width:340px;max-width:calc(100vw - 16px);z-index:6;background:#fff;border-radius:12px;box-shadow:0 8px 28px rgba(0,0,0,.45);overflow:hidden;display:flex;flex-direction:column;animation:upgPanelIn .18s ease}.upg-detail-panel.dark{background:#1a1a2e}@keyframes upgPanelIn{from{transform:translateX(16px);opacity:0}to{transform:translateX(0);opacity:1}}@media(max-width:480px){.upg-detail-panel{top:auto;left:8px;right:8px;width:auto;height:55vh}}.upg-hud{position:absolute;bottom:34px;right:10px;z-index:6;min-width:150px;font:11px/1.35 ui-monospace,monospace;color:#e5e7eb;background:rgba(10,20,16,.92);border:1px solid rgba(110,231,183,.35);border-radius:10px;padding:8px 10px;box-shadow:0 4px 16px rgba(0,0,0,.4)}.upg-hud-head{display:flex;align-items:baseline;gap:6px;white-space:nowrap}.upg-hud-total{font-size:15px;font-weight:700;color:#6ee7b7}.upg-hud-band{margin-inline-start:auto;font-size:9px;color:#9aa7b8}.upg-hud-band.ok{color:#6ee7b7}.upg-hud-names{margin-top:5px;max-height:84px;overflow:auto;font-size:10px;color:#cbd5e1;line-height:1.45;word-break:break-word}.upg-hud-actions{display:flex;gap:6px;margin-top:7px}.upg-hud-btn{flex:1;cursor:pointer;border:1px solid rgba(110,231,183,.4);background:rgba(16,185,129,.18);color:#d1fae5;font:12px/1 ui-monospace,monospace;padding:0 10px;min-height:40px;border-radius:8px}.upg-hud-btn:hover{background:rgba(16,185,129,.32)}.upg-hud-btn.clear{background:rgba(148,163,184,.12);border-color:rgba(148,163,184,.4);color:#cbd5e1}.upg-hud-flash{margin-top:5px;font-size:9px;color:#6ee7b7;min-height:11px}.upg-hud-hint{margin-top:4px;font-size:9px;color:#64748b}.upg-hud-swatches{display:flex;gap:6px;margin-top:7px;align-items:center;flex-wrap:wrap}.upg-swatch{width:40px;height:40px;border-radius:9px;cursor:pointer;padding:0;border:1px solid rgba(255,255,255,.3)}.upg-swatch.active{outline:2px solid #fff;outline-offset:1px}.upg-hex{width:84px;min-height:40px;background:rgba(148,163,184,.12);border:1px solid rgba(148,163,184,.4);color:#cbd5e1;font:12px/1 ui-monospace,monospace;padding:0 8px;border-radius:8px}@media(max-width:480px){.upg-hud{left:8px;right:8px;min-width:0;bottom:30px;max-height:48vh;overflow:auto}}.map-toolbar .mcb.upg-batch-on{background:#10b981!important;color:#04241a!important;box-shadow:0 0 0 2px rgba(52,211,153,.45),0 1px 4px rgba(0,0,0,0.2)!important}.map-toolbar .mcb.upg-batch-on.dark{border-color:#34d399!important}.upg-batch-row{position:relative;background:rgba(16,185,129,.16)!important;opacity:1!important;box-shadow:inset 3px 0 0 0 #10b981}.upg-batch-row .stl-name{color:#065f46!important;font-weight:700}.stl-panel[data-theme="dark"] .upg-batch-row .stl-name,.upg-batch-row.dark .stl-name{color:#6ee7b7!important}.upg-batch-row .stl-dot{box-shadow:0 0 0 2px #10b981}.mapboxgl-ctrl-top-left{top:12px!important;left:8px!important;width:380px!important;max-width:380px!important;z-index:1200!important}.mapboxgl-ctrl-top-left .mapboxgl-ctrl{margin:0!important;float:none!important}.stl-panel{--stl-top:8px!important}.upg-root:has(.mapboxgl-ctrl-geocoder) .stl-panel{--stl-top:58px!important}[dir="rtl"] .upg-detail-panel{right:auto!important;left:8px!important}.dg-main{font:13px/1.3 ui-monospace,monospace}.dg-meta{margin-top:2px;font-size:11px;color:#475569;display:flex;flex-wrap:wrap;gap:8px}.dg-field strong{font-weight:700}.dg-section-header-item{padding:4px 8px;font:10px/1.2 ui-monospace,monospace;letter-spacing:.06em;text-transform:uppercase;color:#94a3b8;pointer-events:none}`);function K(N){const H=[];for(const Y of N)H.push(Y.zoneKey,Qw(Y.zoneKey,Y.color));return["match",["get","zoneKey"],...H,"#9ca3af"]}function _e(){if(L.getSource("tapestry")&&L.getLayer("tapestry-fill")&&L.getLayer("tapestry-line"))return;L.getSource("tapestry")||L.addSource("tapestry",{type:"geojson",data:O});const N=g.value?.45:.3,H=g.value?.65:.45;if(L.getLayer("tapestry-fill")||L.addLayer({id:"tapestry-fill",type:"fill",source:"tapestry",paint:{"fill-color":ne,"fill-opacity":["case",["==",["get","zoneKey"],"deaf"],N,H]}}),L.getLayer("tapestry-line")||L.addLayer({id:"tapestry-line",type:"line",source:"tapestry",paint:{"line-color":ne,"line-width":1.2,"line-opacity":.9}}),nn){const Y=nn;Wt(()=>{nn===Y&&Wa(Y)})}}function $(){!L||!L.getSource("tapestry")||L.getLayer("upg-sel-fill")||(L.addLayer({id:"upg-sel-fill",type:"fill",source:"tapestry",filter:["boolean",!1],paint:{"fill-color":"#f59e0b","fill-opacity":.28}}),L.addLayer({id:"upg-sel-line",type:"line",source:"tapestry",filter:["boolean",!1],paint:{"line-color":"#fbbf24","line-width":2.4,"line-opacity":.95}}))}function A(){const N=[],H=[],Y=[];for(const Ae of m.value)Ae.kind==="adm1"?N.push(Ae.name):Ae.kind==="adm0"?H.push(Ae.key.slice(5)):Ae.kind==="zone"&&Y.push(Ae.key.slice(5));const fe=[];return N.length&&fe.push(["in",["get","shapeName"],["literal",N]]),H.length&&fe.push(["in",["get","iso3"],["literal",H]]),Y.length&&fe.push(["in",["get","zoneKey"],["literal",Y]]),fe.length?fe.length===1?fe[0]:["any",...fe]:["boolean",!1]}function C(){if(St(),!L||!L.getLayer("upg-sel-fill"))return;const N=E.value?A():["boolean",!1];L.setFilter("upg-sel-fill",N),L.setFilter("upg-sel-line",N);const H=Z.value;L.setPaintProperty("upg-sel-fill","fill-color",H||"#f59e0b"),L.setPaintProperty("upg-sel-fill","fill-opacity",H?.55:.28),L.setPaintProperty("upg-sel-line","line-color",H||"#fbbf24")}let U=null,oe=!1;function le(){if(!(!L||!L.getLayer("tapestry-fill"))){if(U)try{L.off("click","tapestry-fill",U)}catch{}U=N=>{const H=N&&N.features&&N.features[0];if(H&&E.value){const Y=Cg(H.properties,{nameMap:P});if(!Y){console.warn("[batch-select] clicked feature has no shapeName/iso3",H.properties);return}Y.count==null&&console.warn("[batch-select] no UUPG count for territory",Y.name,H.properties),re(Y)}},L.on("click","tapestry-fill",U),oe||(L.on("mouseenter","tapestry-fill",()=>{L&&(L.getCanvas().style.cursor=E.value?"crosshair":"")}),L.on("mouseleave","tapestry-fill",()=>{L&&(L.getCanvas().style.cursor="")}),oe=!0)}}function ie(){m.value=[],T.value="",Z.value="",G.value="",C()}function ge(N){if(u&&typeof u.cacheSourceData=="function"){const H=ak({records:N,leafZones:V,adm1Counts:si,iso3Names:Ba,countryNameMap:P,centroidFor:Y=>{const fe=J(Y);return fe?[(fe[0][0]+fe[1][0])/2,(fe[0][1]+fe[1][1])/2]:null}});u.cacheSourceData(vl,{normalizedData:H})}W=ok({records:N,leafZones:V,adm1Counts:si,iso3Names:Ba,countryNameMap:P}),typeof window<"u"&&(window.__UPG_SEARCH__={size:()=>W.length,counts:()=>{const H={pg:0,zone:0,territory:0};for(const Y of W)H[Y.kind]=(H[Y.kind]||0)+1;return H},query:H=>Tg(W,H,{limit:Ng}).map(Y=>({label:Y.label,kind:Y.kind,target:Y.target})),select:H=>{const Y=Tg(W,H,{limit:Ng})[0];return Y?(z(Y.target),{label:Y.label,kind:Y.kind,target:Y.target}):null},feedSize:()=>{const H=u&&u.sources&&u.sources[vl];return H&&Array.isArray(H.features)&&H.features.length||0},localGeocoder:H=>{const Y=I.value&&I.value.geocoder,fe=Y&&Y.options&&Y.options.localGeocoder;return fe?fe(H).map(Ae=>Ae&&Ae.place_name):null}},(window.__UPG_SEARCHES__||(window.__UPG_SEARCHES__={}))[a()]=window.__UPG_SEARCH__)}function w(N){const H=N&&N.properties||{},Y=H.__upgKind;if(Y==="zone")ee(H.__zoneId);else if(Y==="territory")D(H.__shapeName);else{const fe=N&&N.geometry,Ae=fe&&Array.isArray(fe.coordinates)?fe.coordinates:null;Ae&&Number.isFinite(Ae[0])&&Number.isFinite(Ae[1])&&L&&L.flyTo({center:[Ae[0],Ae[1]],zoom:6,duration:800}),Q(H.slug)}}function k(N){if(!N||!L)return;const H=new Set(N.memberIds||[]);if(!H.size)return;let Y=[];try{Y=L.querySourceFeatures("upg").filter(Je=>{const ke=Je.properties||{};return H.has(ke.slug)||H.has(ke.id)||H.has(ke.peopleGroupId)})}catch{return}if(!Y.length)return;let fe=180,Ae=90,je=-180,Ke=-90,De=!1;for(const Je of Y){const ke=Je.geometry&&Je.geometry.coordinates;!Array.isArray(ke)||!Number.isFinite(ke[0])||!Number.isFinite(ke[1])||(ke[0]je&&(je=ke[0]),ke[1]Ke&&(Ke=ke[1]),De=!0)}De&&L.fitBounds([[fe,Ae],[je,Ke]],{padding:60,duration:800,maxZoom:6})}function B(){Zn(null),c&&typeof c.selectPeopleGroup=="function"&&c.selectPeopleGroup(null)}function z(N){!N||!L||(N.type==="pg"?(Number.isFinite(N.lng)&&Number.isFinite(N.lat)&&L.flyTo({center:[N.lng,N.lat],zoom:6,duration:800}),Q(N.slug)):N.type==="zone"?ee(N.zoneId):N.type==="territory"&&D(N.shapeName))}function Q(N){if(!N||!c||typeof c.selectPeopleGroup!="function")return;const Y=rk(L,"upg").find(fe=>fe.properties&&fe.properties.slug===N);Y&&c.selectPeopleGroup(Y)}function ee(N){if(!N||!L||!O)return;const H=J(Y=>Y.properties&&Y.properties.zoneKey===N);H&&L.fitBounds(H,{padding:40,duration:800,maxZoom:6})}function D(N){if(!N||!L||!O)return;const H=J(Y=>{const fe=Y.properties||{};return fe.shapeName===N||fe.iso3===N});H&&L.fitBounds(H,{padding:40,duration:800,maxZoom:6})}function J(N){let H=180,Y=90,fe=-180,Ae=-90,je=!1;const Ke=De=>{if(typeof De[0]=="number"){const[Je,ke]=De;Jefe&&(fe=Je),keAe&&(Ae=ke),je=!0;return}for(const Je of De)Ke(Je)};for(const De of O.features)N(De)&&Ke(De.geometry.coordinates);return je?[[H,Y],[fe,Ae]]:null}function $e(N){const H=new Set,Y=fe=>{fe.children&&fe.children.length?fe.children.forEach(Y):H.add(fe.zoneKey??fe.id)};return Y(N),H}let Ee=null;function qe(N){if(![...$e(N)].length)return;const Y=[],fe=De=>{De.children&&De.children.length?De.children.forEach(fe):Y.push(De)};fe(N);const Ae=m.value,je=new Set(Ae.filter(De=>De.kind==="zone").map(De=>De.key));if(Y.every(De=>je.has("zone:"+(De.zoneKey??De.id)))){const De=new Set(Y.map(Je=>"zone:"+(Je.zoneKey??Je.id)));m.value=Ae.filter(Je=>!De.has(Je.key))}else{const De=Y.filter(Je=>!je.has("zone:"+(Je.zoneKey??Je.id))).map(Je=>({key:"zone:"+(Je.zoneKey??Je.id),name:Je.label||Je.id,count:Number(Je.count)||0,kind:"zone"}));m.value=[...Ae,...De]}C(),T.value=""}function ft(){const N=new Set;for(const H of m.value)H.kind==="zone"&&N.add(H.key.slice(5));return N}function it(){const N=new Map,H=Y=>{const fe=$e(Y);Y.label&&N.set(Y.label,fe),Y.children&&Y.children.length&&Y.children.forEach(H)};for(const Y of x.value)H(Y);return N}function St(){if(typeof document>"u")return;const N=document.querySelector("my-upg-100-list-map"),Y=(N&&N.shadowRoot||document).querySelectorAll(".stl-row");if(!Y.length)return;if(!E.value){Y.forEach(Ke=>Ke.classList.remove("upg-batch-row"));return}const fe=ft(),Ae=it(),je=g.value;Y.forEach(Ke=>{const De=Ke.querySelector(".stl-name"),Je=De?De.textContent.trim():"",ke=Je&&Ae.get(Je),Ue=!!(ke&&ke.size&&[...ke].every(st=>fe.has(st)));Ke.classList.toggle("upg-batch-row",Ue),Ke.classList.toggle("dark",Ue&&je)})}let Et=null;function Le(){if(typeof document>"u"||Et)return;const N=document.querySelector("my-upg-100-list-map"),Y=(N&&N.shadowRoot||document).querySelector(".stl-rows");Y&&(Et=new MutationObserver(()=>{requestAnimationFrame(()=>St())}),Et.observe(Y,{childList:!0,subtree:!0}))}Ut("onSemanticTreeSelect",Zn),Ut("onLegendExport",Qe);async function Qe(N){const H=b.value;if(!H)return;if(N==="packet"){await Ie(H);return}const Y=Re().find(fe=>fe.id===H)||{id:H};await Ot.printPoster(Y)}const Ot=rp({records:N=>F(N),lang:()=>zo(),label:N=>(N==null?void 0:N.label)||(N==null?void 0:N.id)||"",assetsBase:()=>Un(n.value),downloadPrefix:"doxa-upg-100"});ot(Ot.exportState,N=>{if(!N){/packet/i.test(d.value)&&(d.value="");return}if(N.phase==="error"){Ce(se("messages.packetFailed",{reason:N.message}),4e3);return}d.value=N.phase==="done"?"":`${N.message}…`});async function F(N){if(!ye)throw new Error("no API configured");const Y=await fetch(`${ye}/api/people-groups/list?fields=slug,name,country_code,population,religion,image_url,primary_language,imb_gsec&lang=${zo()}`,{cache:"no-store"});if(!Y.ok)throw new Error(`people-groups fetch failed (${Y.status})`);const fe=Na(await Ea(Ma(await Y.json()),n));let Ae;if(N.selector&&N.selector.type==="pg_slugs")Ae=new Set(N.selector.values||[]);else{const{evaluate:je}=await yt(async()=>{const{evaluate:Ke}=await Promise.resolve().then(()=>Ls);return{evaluate:Ke}},void 0);Ae=new Set(je(N.selector,fe))}return fe.filter(je=>Ae.has(je.slug)).sort((je,Ke)=>String(je.name).localeCompare(String(Ke.name),zo()))}async function te(N,H){try{const Y=Un(n.value),fe=await(await fetch(`${Y}/posters/${N}.html`,{cache:"force-cache"})).text(),Ae=fe.match(//);return Ae?`
${Ae[0]}
`:""}catch{return""}}function xe(N,H,Y){N.value=H,setTimeout(()=>{N.value===H&&(N.value="")},Y)}const Ce=(N,H)=>xe(d,N,H);async function Ie(N){const H=Re().find(je=>je.id===N);if(!H)return;const[{createPacketRenderer:Y},fe]=await Promise.all([yt(()=>Promise.resolve().then(()=>Sl),void 0),yt(()=>Promise.resolve().then(()=>Ha),void 0).then(je=>je.default||je)]),Ae=Y({strings:fe,lang:zo()});await Ot.printPacket(H,{mapSvg:await te(N,Ae),funnel:await At()})}function at(){return gp(jr(n))}function Re(){const N=at();return[...N.lists||[],...N.asia_lists||[],...N.uncovered_lists||[]]}async function At(){var N;try{const H=(await yt(async()=>{const{default:je}=await Promise.resolve().then(()=>uP);return{default:je}},void 0)).default;if(!H||!Array.isArray(H.steps)||!H.steps.length)return null;const Y=jr(n),fe=Number(H.steps[H.steps.length-1].groups)||0;if(Y===Ta)return{...H,listCount:Re().length,listTotal:fe};let Ae=0;try{const je=Un(n.value),Ke=await fetch(`${je}/people-groups/lists/${Y}.json`);if(Ke.ok){const De=await Ke.json();Ae=Number((N=De==null?void 0:De.counts)==null?void 0:N.doxa)||(Array.isArray(De==null?void 0:De.slugs)?De.slugs.length:0)}}catch{}return{...H,listTotal:Ae,listId:Y,listLabel:(op(Y)||{}).label||Y}}catch{return null}}const mt=be(!1);function qt(){const N=m.value.filter(Y=>Y.kind==="zone").map(Y=>String(Y.key).replace(/^zone:/,"")),H=new Map(Re().map(Y=>[Y.id,Y]));return N.map(Y=>H.get(Y)).filter(Boolean)}let ja=null;async function dP(){if(!ja){const N=await yt(()=>Promise.resolve().then(()=>Ha),void 0).then(H=>H.default||H);ja={...N.en||{},...N[zo()]||{}}}return ja}function th(N,H){return N?String(N).replace(/\{(\w+)\}/g,(Y,fe)=>H[fe]!=null?String(H[fe]):Y):null}async function pP(){const N=qt();if(!N.length)throw new Error("nothing selected");if(!ye)throw new Error("no API configured");const Y=await fetch(`${ye}/api/people-groups/list?fields=slug,name,country_code,population,religion,image_url,primary_language,imb_gsec&lang=${zo()}`,{cache:"no-store"});if(!Y.ok)throw new Error(`people-groups fetch failed (${Y.status})`);const fe=Na(await Ea(Ma(await Y.json()),n)),{evaluate:Ae}=await yt(async()=>{const{evaluate:Ue}=await Promise.resolve().then(()=>Ls);return{evaluate:Ue}},void 0),je=new Set;for(const Ue of N)if(Ue.selector&&Ue.selector.type==="pg_slugs")for(const st of Ue.selector.values||[])je.add(st);else for(const st of Ae(Ue.selector,fe))je.add(st);const Ke=N.map(Ue=>Ue.label||Ue.id),De=await dP(),Je=(Ue,st)=>th(De.zone_join,{a:Ue,b:st})??`${Ue} + ${st}`;return{id:"selection",label:Ke.length<=3?Ke.reduce(Je):th(De.zone_join_more,{a:Ke.slice(0,2).reduce(Je),n:Ke.length-2})??`${Ke.slice(0,2).join(" + ")} +${Ke.length-2} more`,count:je.size,selector:{type:"pg_slugs",values:[...je]}}}async function gP(){if(!mt.value){mt.value=!0;try{const N=await pP(),[{createPacketRenderer:H},Y]=await Promise.all([yt(()=>Promise.resolve().then(()=>Sl),void 0),yt(()=>Promise.resolve().then(()=>Ha),void 0).then(De=>De.default||De)]),fe=H({strings:Y,lang:zo()}),Ae=qt(),je=Ae.length===1?await te(Ae[0].id,fe):"",Ke=await At();await Ot.printPacket(N,{mapSvg:je,funnel:Ke&&Ae.length===1?Ke:Ke?{...Ke,listCount:0}:null})}catch(N){Ce(se("messages.selectionPacketFailed",{reason:String((N==null?void 0:N.message)||N).slice(0,90)}),4e3)}finally{mt.value=!1}}}async function hP(){if(!mt.value){mt.value=!0;try{const N=qt();if(!N.length)throw new Error("nothing selected");if(N.length>1){Ce(se("messages.posterOneTerritory",{count:N.length}),5e3);return}await Ot.printPoster(N[0])}catch(N){Ce(se("messages.selectionPosterFailed",{reason:String((N==null?void 0:N.message)||N).slice(0,90)}),4e3)}finally{mt.value=!1}}}function zo(){const N=Be&&(Be.value??Be);return typeof N=="string"&&N||"en"}function Zn(N){if(!L||!L.getLayer("tapestry-fill"))return!1;if(E.value)return N&&qe(N),!0;if(!N)return Ee=null,b.value=null,L.setFilter("tapestry-fill",null),L.setFilter("tapestry-line",null),L.setPaintProperty("upg-pins","circle-opacity",1),!0;Ee=N;const H=[...$e(N)];b.value=H.length===1?H[0]:N.id??null;const Y=["in",["get","zoneKey"],["literal",H]];L.setFilter("tapestry-fill",Y),L.setFilter("tapestry-line",Y),L.getLayer("upg-pins")&&L.setPaintProperty("upg-pins","circle-opacity",["case",["in",["get","zoneKey"],["literal",H]],.95,.05]);const fe=J(Ae=>H.includes(Ae.properties.zoneKey));return fe&&L.fitBounds(fe,{padding:40,duration:700,maxZoom:6}),!0}function Al(){L&&(typeof Pe=="function"&&Pe(),O&&(_e(),$(),le(),C(),b.value&&L.getLayer("tapestry-fill")&&Zn(Ee)))}function fP(){L&&(g.value=!g.value,f.theme.value=g.value?"dark":"light",L.setStyle(g.value?bl("ink",r).style||"mapbox://styles/mapbox/dark-v11":bl("paper",r).style||"mapbox://styles/mapbox/light-v11"),L.once("style.load",Al))}function oh(){!L||!L.getLayer("upg-pins")||(L.on("click","upg-pins",N=>{const H=N&&N.features&&N.features[0];H&&c&&typeof c.selectPeopleGroup=="function"&&c.selectPeopleGroup(H)}),L.on("mouseenter","upg-pins",()=>{L&&(L.getCanvas().style.cursor="pointer")}),L.on("mouseleave","upg-pins",()=>{L&&(L.getCanvas().style.cursor="")}))}let Va=null,nn,Xn=null;function ci(N,H){var Y,fe,Ae;try{const je=(Ae=(fe=(Y=p.value)==null?void 0:Y.getRootNode)==null?void 0:fe.call(Y))==null?void 0:Ae.host;if(!je)return;je.setAttribute("data-doxa-select-zone-state",N),H&&je.setAttribute("data-doxa-select-zone-applied",String(H))}catch{}}function Wa(N){if(!N)return Zn(null),nn=void 0,ci("cleared",""),!0;const H=nh(x.value,N);return H?Zn(H)?(nn=void 0,ci("applied",N),!0):(nn=N,ci("applied-but-no-selection",N),!1):(nn=N,ci("unresolved",N),!1)}function mP(N){var Y;const H=((Y=N==null?void 0:N.detail)==null?void 0:Y.listId)??null;Wa(H)}function nh(N,H){for(const Y of N||[]){if((Y.zoneKey||Y.id)===H)return Y;const fe=Y.children&&nh(Y.children,H);if(fe)return fe}return null}function bP(){const N=at(),H=yl(N,{deafCount:wl});x.value=H,V=xg(H);const Y={};for(const fe of N.lists||[])Y[fe.id]=fe.selector;for(const fe of N.asia_lists||[])Y[fe.id]=fe.selector;for(const fe of N.uncovered_lists||[])Y[fe.id]=fe.selector;Y.deaf={type:"affinity_bloc",rop1:"A017"};for(const fe of V)fe.selector=Y[fe.id];ne=K(V)}async function ah(){if(ye)try{const H=await fetch(`${ye}/api/people-groups/list?fields=slug,name,country_code,wagf_region,wagf_block,rop1,population,latitude,longitude&lang=${zo()}`,{cache:"no-store"});if(!H.ok)throw new Error(`list ${H.status}`);const Y=Na(await Ea(Ma(await H.json()),n));P=Lg(Y),x.value=yl(at(),{deafCount:wl,records:Y})}catch{}}io(async()=>{var Ae,je,Ke,De,Je;bP();try{await Hw(r)}catch{}const N=_l(r);N&&Uw(N);const H=(o==null?void 0:o.value)||((Ae=n==null?void 0:n.value)==null?void 0:Ae.tk)||"";if(!N){console.warn(`[upg-100-list] ${r} engine global is missing — refusing to substitute another engine. A page that asked for the keyless engine must not silently receive the token-gated one.`),d.value=`⚠ ${se("messages.engineNotLoaded")}`,S.value=se("messages.engineNotLoadedDetail",{engine:i?"MapLibre":"Mapbox"}),ah();return}if(!i){if(!H){d.value=`⚠ ${se("messages.noMapboxToken")}`,S.value=se("messages.noMapboxTokenDetail"),ah();return}N.accessToken=H}try{const ke=kg(r);ke&&await jw(p.value,ke)}catch{}try{const ke=!i&&p.value&&p.value.getRootNode();if(ke instanceof ShadowRoot){const Ue=kg("mapbox");if(Ue&&!ke.querySelector(`link[href="${Ue}"]`)){const st=document.createElement("link");st.rel="stylesheet",st.href=Ue,ke.prepend(st)}}}catch{}L=new N.Map({container:p.value,style:bl("paper",r).style||"mapbox://styles/mapbox/light-v11",center:[35,20],zoom:1.5,projection:"mercator"}),h.value=L,ue=Gw(((je=p.value)==null?void 0:je.parentElement)||null,{enabled:l.value}),typeof window<"u"&&(window.__UPG_MAP__=L,(window.__UPG_MAPS__||(window.__UPG_MAPS__={}))[a()]=L),window.__UPG_SELECT__={get list(){return m.value.map(ke=>({...ke}))},get total(){return y.value},get count(){return _.value},get color(){return Z.value},get batchMode(){return E.value},setColor:ke=>pe(ke),setBatchMode:ke=>v(ke),clipboardText:()=>ek(m.value,{color:Z.value}),clear:()=>ie(),toggleByProps:ke=>{const Ue=Cg(ke,{nameMap:P});return Ue?(re(Ue),{...Ue}):null},toggleLegendRow:ke=>{const Ue=an=>{for(const bt of an){if(bt.label===ke)return bt;if(bt.children&&bt.children.length){const zt=Ue(bt.children);if(zt)return zt}}return null},st=Ue(x.value);return st?(qe(st),{label:st.label,zoneKeys:[...$e(st)]}):null},markedLegendRows:()=>{if(typeof document>"u")return[];const ke=document.querySelector("my-upg-100-list-map");return[...(ke&&ke.shadowRoot||document).querySelectorAll(".stl-row.upg-batch-row .stl-name")].map(st=>st.textContent.trim())},highlightFeatureCount:()=>{if(!L||!O||!L.getLayer("upg-sel-fill"))return-1;const ke=new Set,Ue=new Set,st=new Set;for(const bt of m.value)bt.kind==="zone"?ke.add(bt.key.slice(5)):bt.kind==="adm1"?Ue.add(bt.name):bt.kind==="adm0"&&st.add(bt.key.slice(5));let an=0;for(const bt of O.features){const zt=bt.properties||{};(ke.has(zt.zoneKey)||Ue.has(zt.shapeName)||st.has(zt.iso3))&&an++}return an},zoneKeysForRow:ke=>{const Ue=an=>{for(const bt of an){if(bt.label===ke)return bt;if(bt.children&&bt.children.length){const zt=Ue(bt.children);if(zt)return zt}}return null},st=Ue(x.value);return st?[...$e(st)]:null}},(window.__UPG_SELECTS__||(window.__UPG_SELECTS__={}))[a()]=window.__UPG_SELECT__;try{d.value=se("messages.loadingBoundaries");const ke=Ve=>`${Un(n.value)}/boundaries/${Ve}`,Ue=Ve=>fetch(ke(Ve)).then(Rt=>{if(!Rt.ok)throw new Error(`boundary fetch ${Rt.status} ${Ve}`);return Rt.json()});if(!ye)throw new Error("No API base configured — set window.MAP_APP_API_URL or VITE_API_BASE_URL. Failing closed (no default host).");const an=fetch(`${ye}/api/people-groups/list?fields=slug,name,country_code,wagf_region,wagf_block,rop1,population,latitude,longitude&lang=${zo()}`).then(Ve=>{if(!Ve.ok)throw new Error(`list ${Ve.status}`);return Ve.json()}),bt={adm0:Ue("world-adm0-web.geojson"),adm1Chn:Ue("gb-CHN-ADM1.geojson"),adm1Ind:Ue("gb-IND-ADM1-web.geojson")};d.value=se("messages.fetchingUupgs",{n:2106});const zt=Na(await Ea(Ma(await an),n));P=Lg(zt),x.value=yl(at(),{deafCount:wl,records:zt});const Ll=[],Ka={},{evaluate:yP}=await yt(async()=>{const{evaluate:Ve}=await Promise.resolve().then(()=>Ls);return{evaluate:Ve}},void 0);for(const Ve of V)if(Ve.selector&&Ve.selector.type==="pg_slugs")for(const Rt of Ve.selector.values||[])Rt in Ka||(Ka[Rt]=Ve.zoneKey);else try{for(const Rt of yP(Ve.selector,zt))Rt in Ka||(Ka[Rt]=Ve.zoneKey)}catch(Rt){console.warn("zone selector skipped",Ve.id,Rt&&Rt.message)}for(const Ve of zt){const Rt=Number(Ve.latitude),Tl=Number(Ve.longitude);!isFinite(Rt)||!isFinite(Tl)||Ll.push({type:"Feature",geometry:{type:"Point",coordinates:[Tl,Rt]},properties:{slug:Ve.slug,zoneKey:Ka[Ve.slug]||"",name:Ve.name||Ve.slug||"",population:Ve.population??0,countryName:Ve.country_code_label||"",country:Ve.country_code||""}})}const $P=ln({type:"FeatureCollection",features:Ll});Pe=()=>{if(!(L.getSource("upg")&&L.getLayer("upg-pins"))){if(L.getSource("upg")||L.addSource("upg",{type:"geojson",data:$P}),L.getLayer("upg-pins")){oh();return}L.addLayer({id:"upg-pins",type:"circle",source:"upg",paint:{"circle-radius":["interpolate",["linear"],["zoom"],1,5,4,6.5,8,9],"circle-color":ne,"circle-opacity":1,"circle-stroke-width":["interpolate",["linear"],["zoom"],1,1.8,8,2],"circle-stroke-color":"rgba(15,20,25,0.9)"}}),oh()}};const rh=()=>{try{Al()}catch(Ve){console.warn("early pin paint skipped",Ve&&Ve.message)}};L.isStyleLoaded()?rh():L.once("style.load",rh),d.value=se("messages.loadingBoundaries");const[vP,wP]=await Promise.all([bt.adm0,bt.adm1Chn]),kP=await bt.adm1Ind,{tapestry:PP,perZone:xP}=Zw(V,{records:zt,adm0:vP,adm1Ind:kP,adm1Chn:wP});O=ln(PP),ge(zt);let Cl=!0;const Qn=()=>{Cl&&(Cl=!1,L.off("style.load",Qn),L.off("idle",Qn),Al())};if(L.isStyleLoaded())Qn();else{L.once("style.load",Qn),L.once("idle",Qn);const Ve=setInterval(()=>{if(!Cl||!L){clearInterval(Ve);return}let Rt=!1;try{Rt=L.isStyleLoaded()}catch{clearInterval(Ve);return}Rt&&(clearInterval(Ve),Qn())},120);setTimeout(()=>clearInterval(Ve),15e3)}const ih=[...xP.entries()].filter(([Ve])=>Ve!=="deaf"),SP=ih.filter(([,Ve])=>Ve>=1).length;d.value=se("messages.mapStatusCounts",{polys:O.features.length,zones:SP,total:ih.length,pins:Ll.length})}catch(ke){d.value="⚠ "+(ke&&ke.message?ke.message:String(ke))}let Y=0;const fe=()=>{const ke=typeof document<"u"&&document.querySelector("my-upg-100-list-map"),Ue=ke&&ke.shadowRoot||(typeof document<"u"?document:null);if(Ue&&Ue.querySelector(".stl-rows")){Le(),St();return}Y++<40&&setTimeout(fe,250)};fe();{const ke=(Je=(De=(Ke=p.value)==null?void 0:Ke.getRootNode)==null?void 0:De.call(Ke))==null?void 0:Je.host;if(ke){Va=mP,ke.addEventListener("doxa:select-zone",Va);const Ue=ke.getAttribute("select-zone");Ue&&Wa(Ue),Xn=new MutationObserver(()=>{Wa(ke.getAttribute("select-zone")||null)}),Xn.observe(ke,{attributes:!0,attributeFilter:["select-zone"]})}}});const _P=()=>{var N,H,Y;try{return((Y=(H=(N=p.value)==null?void 0:N.getRootNode)==null?void 0:H.call(N))==null?void 0:Y.host)||null}catch{return null}};return ot([x,h],()=>{Wt(()=>{var H;const N=((H=_P())==null?void 0:H.getAttribute("select-zone"))||nn||null;N&&Wa(N)})}),Qt(()=>{var N,H,Y;if(Xn==null||Xn.disconnect(),Xn=null,Va){const fe=(Y=(H=(N=p.value)==null?void 0:N.getRootNode)==null?void 0:H.call(N))==null?void 0:Y.host;fe==null||fe.removeEventListener("doxa:select-zone",Va),Va=null}if(Et){try{Et.disconnect()}catch{}Et=null}if(ue){try{ue()}catch{}ue=null}L&&(L.remove(),L=null),O=null}),(N,H)=>{var Y;return q(),ae("div",ik,[R("div",{ref_key:"mapEl",ref:p,class:"upg-map"},null,512),S.value?(q(),ae("div",sk,[R("strong",null,de(me(se)("messages.mapUnavailable")),1),wt(de(S.value),1)])):we("",!0),l.value?(q(),ae(ze,{key:1},[H[0]||(H[0]=R("div",{class:"map-scroll-edge map-scroll-edge--left"},null,-1)),H[1]||(H[1]=R("div",{class:"map-scroll-edge map-scroll-edge--right"},null,-1))],64)):we("",!0),h.value&&s.value?(q(),dt(Nw,{key:2,ref_key:"geocoderRef",ref:I,"map-instance":h.value,"access-token":me(o)||((Y=me(n))==null?void 0:Y.tk)||"","data-source-id":vl,"is-dark":g.value,placeholder:Se.value,"active-context":vk,onPeopleGroupResult:w,onAggregateResult:k,onClear:B},null,8,["map-instance","access-token","is-dark","placeholder"])):we("",!0),h.value?(q(),dt(iw,{key:3,"has-geocoder":s.value},{default:Xt(()=>[tt(lw,{map:h.value,"is-dark":g.value},null,8,["map","is-dark"]),tt(cw,{map:h.value,"is-dark":g.value},null,8,["map","is-dark"]),tt(uw,{map:h.value,"is-dark":g.value},null,8,["map","is-dark"]),tt(gw,{"map-container":p.value,"is-dark":g.value},null,8,["map-container","is-dark"]),tt(fw,{"is-dark":g.value,onToggle:fP},null,8,["is-dark"]),tt(wn,{"is-dark":g.value,active:E.value,class:Ge({"upg-batch-on":E.value}),"aria-pressed":E.value?"true":"false",title:ce.value,onClick:j},{default:Xt(()=>[...H[2]||(H[2]=[R("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[R("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),R("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),R("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),R("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1"})],-1)])]),_:1},8,["is-dark","active","class","aria-pressed","title"])]),_:1},8,["has-geocoder"])):we("",!0),R("div",lk,[x.value.length?(q(),dt(yp,{key:0,nodes:x.value,tabs:M.value,"default-tab":Rg,columns:["count","pop"],title:he.value,"export-enabled":!0,onSelect:Zn,onExport:Qe},null,8,["nodes","tabs","title"])):we("",!0)]),R("div",ck,[x.value.length?(q(),dt(rw,{key:0,"legend-type":"upg-100",nodes:x.value,tabs:M.value,"default-tab":Rg,columns:["count","pop"],"column-label":"UPG 100",title:he.value,"is-dark":g.value,"popup-action":"pray"},null,8,["nodes","tabs","title","is-dark"])):we("",!0)]),R("div",uk,[me(c)&&me(c).selectedPeopleGroup?(q(),ae("div",{key:0,class:Ge(["upg-detail-panel pg-detail-root",{dark:g.value}])},[tt(me(t),{peopleGroup:me(c).selectedPeopleGroup,dark:g.value,action:"pray"},null,8,["peopleGroup","dark"])],2)):we("",!0)]),E.value?(q(),ae("div",dk,[R("div",pk,de(me(se)("messages.tapTerritoriesHint")),1),_.value?(q(),ae("div",gk,[R("span",null,de(me(se)("messages.territoriesSelected",{count:_.value}))+" ·",1),R("span",hk,de(y.value)+" UUPG",1),R("span",{class:Ge(["upg-hud-band",{ok:y.value>=50&&y.value<=100}])},de(y.value>=50&&y.value<=100?"✓ 50–100 band":"band 50–100"),3)])):we("",!0),_.value?(q(),ae("div",fk,de(m.value.map(fe=>fe.name).join(", ")),1)):we("",!0),_.value?(q(),ae("div",mk,[R("button",{class:"upg-hud-btn make",disabled:mt.value,onClick:gP},de(me(se)("buttons.prayerList")),9,bk),R("button",{class:"upg-hud-btn make",disabled:mt.value,onClick:hP},de(me(se)("buttons.posterMap")),9,_k),R("button",{class:"upg-hud-btn clear",onClick:ie},de(me(se)("buttons.clearSelection")),1)])):we("",!0),_.value?(q(),ae("div",yk,de(T.value),1)):we("",!0)])):we("",!0),R("div",$k,de(d.value),1)])}}}},Symbol.toStringTag,{value:"Module"})),kk=` .pane-col{ position:absolute; inset:0; overflow-y:auto; overflow-x:hidden; scroll-snap-type:y mandatory; scroll-behavior:smooth; diff --git a/public/dx-maps/my-upg-100-list/poster-wall/index.html b/public/dx-maps/my-upg-100-list/poster-wall/index.html index 5933a2528..4bd1a2aa0 100644 --- a/public/dx-maps/my-upg-100-list/poster-wall/index.html +++ b/public/dx-maps/my-upg-100-list/poster-wall/index.html @@ -32,7 +32,7 @@ - + - + - +