@maptiler/geocoding-control 3.0.0-rc.7 → 3.0.0-rc.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/check-version.js +69 -0
  2. package/dist/check-version.d.ts +1 -0
  3. package/dist/index.js +9 -9
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.umd.js +3 -3
  6. package/dist/index.umd.js.map +1 -1
  7. package/dist/leaflet.public.js +9 -9
  8. package/dist/leaflet.public.js.map +1 -1
  9. package/dist/leaflet.public.umd.js +3 -3
  10. package/dist/leaflet.public.umd.js.map +1 -1
  11. package/dist/maplibregl.js +67 -67
  12. package/dist/maplibregl.js.map +1 -1
  13. package/dist/maplibregl.umd.js +4 -4
  14. package/dist/maplibregl.umd.js.map +1 -1
  15. package/dist/maptilersdk.js +102 -102
  16. package/dist/maptilersdk.js.map +1 -1
  17. package/dist/maptilersdk.umd.js +4 -4
  18. package/dist/maptilersdk.umd.js.map +1 -1
  19. package/dist/openlayers.public.js +11 -10
  20. package/dist/openlayers.public.js.map +1 -1
  21. package/dist/openlayers.public.umd.js +4 -4
  22. package/dist/openlayers.public.umd.js.map +1 -1
  23. package/dist/src/components/clear-icon.d.ts +1 -0
  24. package/dist/src/components/fail-icon.d.ts +1 -0
  25. package/dist/src/components/loading-icon.d.ts +1 -0
  26. package/dist/src/components/marker.d.ts +1 -0
  27. package/dist/src/components/reverse-geocoding-icon.d.ts +1 -0
  28. package/dist/src/components/search-icon.d.ts +1 -0
  29. package/dist/src/controls/maplibregl-control.d.ts +2 -7
  30. package/dist/src/controls/maplibregl-events.d.ts +2 -3
  31. package/dist/src/controls/maplibregl-options.d.ts +1 -9
  32. package/dist/src/geocoder/geocoder-feature-item.d.ts +1 -0
  33. package/dist/src/geocoder/geocoder.d.ts +1 -0
  34. package/dist/src/index.d.ts +1 -0
  35. package/dist/src/leaflet.public.d.ts +1 -0
  36. package/dist/src/maplibregl.d.ts +1 -0
  37. package/dist/src/maptilersdk.d.ts +1 -0
  38. package/dist/src/openlayers.public.d.ts +1 -0
  39. package/package.json +20 -10
@@ -176,7 +176,7 @@
176
176
  </li>
177
177
  `}};B=new WeakSet,mt=function(){return this.feature?.properties?.categories},Ke=function(){return this.feature?.place_type[0]==="reverse"},Y=function(){return this.feature?.properties?.categories?.join(", ")??this.feature?.place_type_name?.[0]??this.feature?.place_type[0]},Fi=function(){zi??=fetch(`${this.iconsBaseUrl}sprite${Wi}.json`).then(i=>i.json()).then(i=>{Ie=i}).catch(()=>{Ie=null})},Bi=function(){this.imageUrl&&this.missingIconsCache.add(this.imageUrl),Ue(this,B,Dt).call(this)},Dt=function(){Ie!==void 0?Ue(this,B,Wt).call(this):(Ue(this,B,Fi).call(this),zi?.then(()=>{Ue(this,B,Wt).call(this)}))},Wt=function(){do{if(this.index--,this.category=z(this,B,mt)?.[this.index],this.spriteIcon=this.category?Ie?.icons[this.category]:void 0,this.spriteIcon)break;this.imageUrl=this.category?this.iconsBaseUrl+this.category.replace(/ /g,"_")+".svg":void 0}while(this.index>-1&&(!this.imageUrl||this.missingIconsCache.has(this.imageUrl)))},oe.styles=Se`
178
178
  ${at(Es)}
179
- `,pe([N({type:Object})],oe.prototype,"feature",2),pe([N({type:String})],oe.prototype,"itemStyle",2),pe([N({type:String})],oe.prototype,"showPlaceType",2),pe([N({attribute:!1})],oe.prototype,"missingIconsCache",2),pe([N({type:String})],oe.prototype,"iconsBaseUrl",2),pe([ee()],oe.prototype,"category",2),pe([ee()],oe.prototype,"imageUrl",2),pe([ee()],oe.prototype,"spriteIcon",2),pe([ee()],oe.prototype,"index",2),oe=pe([_e("maptiler-geocoder-feature-item")],oe);const Ls="form{font-family:Open Sans,Ubuntu,Helvetica Neue,Arial,Helvetica,sans-serif;position:relative;background-color:#fff;z-index:10;border-radius:4px;margin:0;transition:max-width .25s;box-shadow:0 2px 5px #33335926;--color-text: #444952;--color-icon-button: #444952;pointer-events:all}form,form *,form *:after,form *:before{box-sizing:border-box}form.can-collapse{max-width:29px}form.can-collapse input::placeholder{transition:opacity .25s;opacity:0}form{width:270px;max-width:270px}form:focus-within,form:hover{width:270px;max-width:270px}form input::placeholder,form:focus-within input::placeholder,form:hover input::placeholder{opacity:1}input{font:inherit;font-size:14px;flex-grow:1;min-height:29px;background-color:transparent;color:#444952;white-space:nowrap;overflow:hidden;border:0;margin:0;padding:0}input:focus{color:#444952;outline:0;outline:none;box-shadow:none}ul,div.error,div.no-results{background-color:#fff;border-radius:4px;left:0;list-style:none;margin:0;padding:0;position:absolute;width:100%;top:calc(100% + 6px);overflow:hidden}ul{font-size:14px;line-height:16px;box-shadow:0 5px 10px #33335926}div.error,div.no-results{font:inherit;line-height:18px;font-size:12px;display:flex;gap:16px}div.error{padding:16px;font-weight:600;color:#e25041;background-color:#fbeae8}div.error div{flex-grow:1}div.error maptiler-geocode-fail-icon{flex-shrink:0;width:20px;height:20px}div.error button{flex-shrink:0}div.error button maptiler-geocode-clear-icon{--color-icon-button: #e25041}div.error button:hover maptiler-geocode-clear-icon,div.error button:active maptiler-geocode-clear-icon{--color-icon-button: inherit}div.no-results{padding:14px 24px 14px 16px;font-weight:400;color:#6b7c93;box-shadow:0 5px 10px #33335926}div.no-results maptiler-geocode-fail-icon{margin-top:4px;flex-shrink:0;width:20px;height:20px}ul.options.open-on-top{top:auto;bottom:calc(100% + 6px)}button{padding:0;margin:0;border:0;background-color:transparent;height:auto;width:auto}button:hover{background-color:transparent}button:hover,button:active{--color-icon-button: #2b8bfb}.input-group{display:flex;align-items:stretch;gap:7px;padding-inline:8px;border-radius:4px;overflow:hidden}.input-group:focus-within{outline:#2b8bfb solid 2px}.search-button{flex-shrink:0}.clear-button-container{display:flex;display:none;position:relative;align-items:stretch}.clear-button-container.displayable{display:flex;flex-shrink:0}:host(.maptiler-geocoder):not(:empty){box-shadow:none}:host(.maptiler-geocoder) .input-group{border:white solid 2px}:host(.maptiler-geocoder) .input-group:focus-within{border:#2b8bfb solid 2px;outline:0;outline:none}:host(.maptiler-geocoder) form.can-collapse{max-width:33px}:host(.maptiler-geocoder) form,:host(.maptiler-geocoder) form:focus-within,:host(.maptiler-geocoder) form:hover{width:270px;max-width:270px}:host(.leaflet-geocoder) .input-group{border:white solid 1px}:host(.leaflet-geocoder) form.can-collapse{max-width:30px}";var _s=Object.defineProperty,$s=Object.getOwnPropertyDescriptor,qi=i=>{throw TypeError(i)},O=(i,e,t,r)=>{for(var s=r>1?void 0:r?$s(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(s=(r?o(e,t,s):o(s))||s);return r&&s&&_s(e,t,s),s},zt=(i,e,t)=>e.has(i)||qi("Cannot "+t),le=(i,e,t)=>(zt(i,e,"read from private field"),t?t.call(i):e.get(i)),Ye=(i,e,t)=>e.has(i)?qi("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),qt=(i,e,t,r)=>(zt(i,e,"write to private field"),e.set(i,t),t),I=(i,e,t)=>(zt(i,e,"access private method"),t),gt,Xe,Ht,Qe,C,yt,Hi,jt,te,Vt,vt,Zt,Kt,$e,Yt,bt,ji,Xt,Vi,Zi,Ki,Yi,Xi,Qi,Ji;$.MaptilerGeocoderElement=class extends ne{constructor(){super(...arguments),Ye(this,C),this.clearListOnPick=!1,this.clearOnBlur=!1,this.collapsed=!1,this.excludeTypes=!1,this.exhaustiveReverseGeocoding=!1,this.fetchFullGeometryOnPick=!1,this.keepListOpen=!1,this.openListOnTop=!1,this.reverseActive=!1,this.searchValue="",this.selectedItemIndex=-1,this.cachedFeatures=[],this.lastSearchUrl="",this.focused=!1,this.isFeatureListVisible=!1,this.isFeatureListInteractedWith=!1,Ye(this,gt,!1),Ye(this,Xe),Ye(this,Ht,new Set),Ye(this,Qe)}firstUpdated(){qt(this,gt,!0)}setOptions(e){const t={...e};for(const r of Object.keys(t))Ms.includes(r)||delete t[r];Object.assign(this,t)}setQuery(e){I(this,C,Kt).call(this,e,{external:!0}),I(this,C,Zt).call(this)}submitQuery(e){I(this,C,Yt).call(this,e)}clearList(){I(this,C,$e).call(this),this.picked=void 0,this.selectedItemIndex=-1}focus(e){this.input.focus(e)}blur(){this.input.blur()}addEventListener(e,t,r){super.addEventListener(e,t,r)}removeEventListener(e,t,r){super.removeEventListener(e,t,r)}handleMapChange(e){qt(this,Qe,e)}handleMapClick(e){this.reverseActive&&I(this,C,ji).call(this,e)}willUpdate(e){e.has("error")&&this.error&&console.error("[MapTilerGeocodingControl] Error:",this.error),e.has("enableReverse")&&(this.reverseActive=this.enableReverse==="always"),["picked"].some(t=>e.has(t))&&this.picked&&(this.clearListOnPick&&I(this,C,$e).call(this),this.selectedItemIndex=-1),["searchValue","minLength"].some(t=>e.has(t))&&le(this,C,jt)&&(I(this,C,$e).call(this),this.error=void 0),["focused","listIsInteractedWith"].some(t=>e.has(t))&&this.clearOnBlur&&!this.focused&&!this.isFeatureListInteractedWith&&(this.searchValue=""),["selectFirst","listFeatures","selectedItemIndex","picked"].some(t=>e.has(t))&&this.selectFirst!==!1&&this.listFeatures?.length&&this.selectedItemIndex==-1&&!this.picked&&(this.selectedItemIndex=0),["listFeatures","selectedItemIndex"].some(t=>e.has(t))&&I(this,C,te).call(this,"select",{feature:le(this,C,yt)}),["picked"].some(t=>e.has(t))&&this.picked&&this.picked.id!==e.get("picked")?.id&&(this.fetchFullGeometryOnPick&&!this.picked.address&&this.picked.geometry.type==="Point"&&this.picked.place_type[0]!=="reverse"?I(this,C,bt).call(this,this.picked.id,{byId:!0}):Promise.resolve()).then(()=>{I(this,C,te).call(this,"pick",{feature:this.picked})},t=>{t&&typeof t=="object"&&"name"in t&&t.name==="AbortError"||(this.error=t,I(this,C,te).call(this,"pick",{feature:this.picked}))}),["listFeatures","focused","isFeatureListInteractedWith","keepListOpen"].some(t=>e.has(t))&&(this.isFeatureListVisible=!!this.listFeatures?.length&&(this.focused||this.isFeatureListInteractedWith||this.keepListOpen)),["isFeatureListVisible"].some(t=>e.has(t))&&(this.isFeatureListVisible?I(this,C,te).call(this,"featuresshow"):I(this,C,te).call(this,"featureshide")),["reverseActive"].some(t=>e.has(t))&&I(this,C,te).call(this,"reversetoggle",{reverse:this.reverseActive})}render(){return Z`
179
+ `,pe([N({type:Object})],oe.prototype,"feature",2),pe([N({type:String})],oe.prototype,"itemStyle",2),pe([N({type:String})],oe.prototype,"showPlaceType",2),pe([N({attribute:!1})],oe.prototype,"missingIconsCache",2),pe([N({type:String})],oe.prototype,"iconsBaseUrl",2),pe([ee()],oe.prototype,"category",2),pe([ee()],oe.prototype,"imageUrl",2),pe([ee()],oe.prototype,"spriteIcon",2),pe([ee()],oe.prototype,"index",2),oe=pe([_e("maptiler-geocoder-feature-item")],oe);const Ls="form{font-family:Open Sans,Ubuntu,Helvetica Neue,Arial,Helvetica,sans-serif;position:relative;background-color:#fff;z-index:10;border-radius:4px;margin:0;transition:max-width .25s;box-shadow:0 2px 5px #33335926;--color-text: #444952;--color-icon-button: #444952;pointer-events:all}form,form *,form *:after,form *:before{box-sizing:border-box}form.can-collapse{max-width:29px}form.can-collapse input::placeholder{transition:opacity .25s;opacity:0}form{width:270px;max-width:270px}form:focus-within,form:hover{width:270px;max-width:270px}form input::placeholder,form:focus-within input::placeholder,form:hover input::placeholder{opacity:1}input{font:inherit;font-size:14px;flex-grow:1;min-height:29px;background-color:transparent;color:#444952;white-space:nowrap;overflow:hidden;border:0;margin:0;padding:0}input:focus{color:#444952;outline:0;outline:none;box-shadow:none}ul,div.error,div.no-results{background-color:#fff;border-radius:4px;left:0;list-style:none;margin:0;padding:0;position:absolute;width:100%;top:calc(100% + 6px);overflow:hidden}ul{font-size:14px;line-height:16px;box-shadow:0 5px 10px #33335926}div.error,div.no-results{font:inherit;line-height:18px;font-size:12px;display:flex;gap:16px}div.error{padding:16px;font-weight:600;color:#e25041;background-color:#fbeae8}div.error div{flex-grow:1}div.error maptiler-geocode-fail-icon{flex-shrink:0;width:20px;height:20px}div.error button{flex-shrink:0}div.error button maptiler-geocode-clear-icon{--color-icon-button: #e25041}div.error button:hover maptiler-geocode-clear-icon,div.error button:active maptiler-geocode-clear-icon{--color-icon-button: inherit}div.no-results{padding:14px 24px 14px 16px;font-weight:400;color:#6b7c93;box-shadow:0 5px 10px #33335926}div.no-results maptiler-geocode-fail-icon{margin-top:4px;flex-shrink:0;width:20px;height:20px}ul.options.open-on-top{top:auto;bottom:calc(100% + 6px)}button{padding:0;margin:0;border:0;background-color:transparent;height:auto;width:auto}button:hover{background-color:transparent}button:hover,button:active{--color-icon-button: #2b8bfb}.input-group{display:flex;align-items:stretch;gap:7px;padding-inline:8px;border-radius:4px;overflow:hidden}.input-group:focus-within{outline:#2b8bfb solid 2px}.search-button{flex-shrink:0}.clear-button-container{display:flex;display:none;position:relative;align-items:stretch}.clear-button-container.displayable{display:flex;flex-shrink:0}:host(.maptiler-geocoder):not(:empty){box-shadow:none}:host(.maptiler-geocoder) .input-group{border:white solid 2px}:host(.maptiler-geocoder) .input-group:focus-within{border:#2b8bfb solid 2px;outline:0;outline:none}:host(.maptiler-geocoder) form.can-collapse{max-width:33px}:host(.maptiler-geocoder) form,:host(.maptiler-geocoder) form:focus-within,:host(.maptiler-geocoder) form:hover{width:270px;max-width:270px}:host(.leaflet-geocoder) .input-group{border:white solid 1px}:host(.leaflet-geocoder) form.can-collapse{max-width:30px}";var _s=Object.defineProperty,$s=Object.getOwnPropertyDescriptor,qi=i=>{throw TypeError(i)},O=(i,e,t,r)=>{for(var s=r>1?void 0:r?$s(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(s=(r?o(e,t,s):o(s))||s);return r&&s&&_s(e,t,s),s},zt=(i,e,t)=>e.has(i)||qi("Cannot "+t),le=(i,e,t)=>(zt(i,e,"read from private field"),t?t.call(i):e.get(i)),Ye=(i,e,t)=>e.has(i)?qi("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),qt=(i,e,t,r)=>(zt(i,e,"write to private field"),e.set(i,t),t),I=(i,e,t)=>(zt(i,e,"access private method"),t),gt,Xe,Ht,Qe,C,yt,Hi,jt,te,Vt,vt,Zt,Kt,$e,Yt,bt,ji,Xt,Vi,Zi,Ki,Yi,Xi,Qi,Ji;$.MaptilerGeocoderElement=class extends ne{constructor(){super(...arguments),Ye(this,C),this.clearListOnPick=!1,this.clearOnBlur=!1,this.collapsed=!1,this.excludeTypes=!1,this.exhaustiveReverseGeocoding=!1,this.fetchFullGeometryOnPick=!1,this.keepListOpen=!1,this.openListOnTop=!1,this.reverseActive=!1,this.searchValue="",this.selectedItemIndex=-1,this.cachedFeatures=[],this.lastSearchUrl="",this.focused=!1,this.isFeatureListVisible=!1,this.isFeatureListInteractedWith=!1,Ye(this,gt,!1),Ye(this,Xe),Ye(this,Ht,new Set),Ye(this,Qe)}firstUpdated(){qt(this,gt,!0)}setOptions(e){const t={...e};for(const r of Object.keys(t))Ms.includes(r)||delete t[r];Object.assign(this,t)}setQuery(e){I(this,C,Kt).call(this,e,{external:!0}),I(this,C,Zt).call(this)}submitQuery(e){I(this,C,Yt).call(this,e,{external:!0})}clearList(){I(this,C,$e).call(this),this.picked=void 0,this.selectedItemIndex=-1}focus(e){this.input.focus(e)}blur(){this.input.blur()}addEventListener(e,t,r){super.addEventListener(e,t,r)}removeEventListener(e,t,r){super.removeEventListener(e,t,r)}handleMapChange(e){qt(this,Qe,e)}handleMapClick(e){this.reverseActive&&I(this,C,ji).call(this,e)}willUpdate(e){e.has("error")&&this.error&&console.error("[MapTilerGeocodingControl] Error:",this.error),e.has("enableReverse")&&(this.reverseActive=this.enableReverse==="always"),["picked"].some(t=>e.has(t))&&this.picked&&(this.clearListOnPick&&I(this,C,$e).call(this),this.selectedItemIndex=-1),["searchValue","minLength"].some(t=>e.has(t))&&le(this,C,jt)&&(I(this,C,$e).call(this),this.error=void 0),["focused","listIsInteractedWith"].some(t=>e.has(t))&&this.clearOnBlur&&!this.focused&&!this.isFeatureListInteractedWith&&(this.searchValue=""),["selectFirst","listFeatures","selectedItemIndex","picked"].some(t=>e.has(t))&&this.selectFirst!==!1&&this.listFeatures?.length&&this.selectedItemIndex==-1&&!this.picked&&(this.selectedItemIndex=0),["listFeatures","selectedItemIndex"].some(t=>e.has(t))&&I(this,C,te).call(this,"select",{feature:le(this,C,yt)}),["picked"].some(t=>e.has(t))&&this.picked&&this.picked.id!==e.get("picked")?.id&&(this.fetchFullGeometryOnPick&&!this.picked.address&&this.picked.geometry.type==="Point"&&this.picked.place_type[0]!=="reverse"?I(this,C,bt).call(this,this.picked.id,{byId:!0}):Promise.resolve()).then(()=>{I(this,C,te).call(this,"pick",{feature:this.picked})},t=>{t&&typeof t=="object"&&"name"in t&&t.name==="AbortError"||(this.error=t,I(this,C,te).call(this,"pick",{feature:this.picked}))}),["listFeatures","focused","isFeatureListInteractedWith","keepListOpen"].some(t=>e.has(t))&&(this.isFeatureListVisible=!!this.listFeatures?.length&&(this.focused||this.isFeatureListInteractedWith||this.keepListOpen)),["isFeatureListVisible"].some(t=>e.has(t))&&(this.isFeatureListVisible?I(this,C,te).call(this,"featuresshow"):I(this,C,te).call(this,"featureshide")),["reverseActive"].some(t=>e.has(t))&&I(this,C,te).call(this,"reversetoggle",{reverse:this.reverseActive})}render(){return Z`
180
180
  <form @submit=${I(this,C,Vt)} class=${ft({"can-collapse":this.collapsed&&this.searchValue===""})}>
181
181
  <div class="input-group">
182
182
  <button
@@ -256,13 +256,13 @@
256
256
  @pointerenter=${()=>{I(this,C,Ki).call(this,t)}}
257
257
  @select=${()=>{I(this,C,Zi).call(this,e)}}
258
258
  .missingIconsCache=${le(this,Ht)}
259
- .iconsBaseUrl=${this.iconsBaseUrl??"https://cdn.maptiler.com/maptiler-geocoding-control/v3.0.0-rc.7/icons/"}
259
+ .iconsBaseUrl=${this.iconsBaseUrl??"https://cdn.maptiler.com/maptiler-geocoding-control/v3.0.0-rc.8/icons/"}
260
260
  />
261
261
  `)}
262
262
  </ul>
263
263
  `}
264
264
  </form>
265
- `}},gt=new WeakMap,Xe=new WeakMap,Ht=new WeakMap,Qe=new WeakMap,C=new WeakSet,yt=function(){return this.listFeatures?.[this.selectedItemIndex]},Hi=function(){return this.abortController!==void 0},jt=function(){return this.searchValue.length<(this.minLength??2)},te=function(i,...[e]){le(this,gt)&&this.dispatchEvent(new CustomEvent(i,{bubbles:!0,composed:!0,detail:e}))},Vt=function(i){i?.preventDefault(),this.focused=!1,clearTimeout(le(this,Xe)),this.selectedItemIndex>-1&&this.listFeatures?(this.picked=this.listFeatures[this.selectedItemIndex],this.searchValue=this.picked.place_type[0]==="reverse"?this.picked.place_name:this.picked.place_name.replace(/,.*/,""),this.error=void 0,this.selectedItemIndex=-1):this.searchValue&&I(this,C,bt).call(this,this.searchValue,{exact:!0,external:i===void 0}).then(()=>{this.picked=void 0}).catch(e=>this.error=e)},vt=function(i){try{return hs(i,6)}catch{return!1}},Zt=function(){setTimeout(()=>{this.input.focus(),this.focused=!0,this.input.select()})},Kt=function(i,{external:e=!1}={}){if(this.searchValue=i,I(this,C,te).call(this,"querychange",{query:this.searchValue,reverseCoords:I(this,C,vt).call(this,i)}),this.error=void 0,this.picked=void 0,this.showResultsWhileTyping!==!1){if(clearTimeout(le(this,Xe)),le(this,C,jt))return;const t=this.searchValue;qt(this,Xe,window.setTimeout(()=>{I(this,C,bt).call(this,t,{external:e}).catch(r=>this.error=r)},this.debounceSearch??200))}else I(this,C,$e).call(this)},$e=function(){this.listFeatures!==void 0&&(this.listFeatures=void 0,I(this,C,te).call(this,"featuresclear"))},Yt=function(i){this.searchValue=i,I(this,C,te).call(this,"querychange",{query:this.searchValue,reverseCoords:I(this,C,vt).call(this,i)}),this.selectedItemIndex=-1,I(this,C,Vt).call(this)},bt=async function(i,{byId:e=!1,exact:t=!1,external:r=!1}={}){this.error=void 0,this.abortController?.abort();const s=new AbortController;this.abortController=s;try{const n=this.apiUrl??"https://api.maptiler.com/geocoding",o=I(this,C,vt).call(this,i),l=new URL(n+"/"+encodeURIComponent(o?`${o.decimalLongitude},${o.decimalLatitude}`:i)+".json"),u=l.searchParams;this.language!==void 0&&u.set("language",Array.isArray(this.language)?this.language.join(","):this.language??"");const[f]=le(this,Qe)??[void 0];let x=(!o||this.reverseGeocodingTypes===void 0?this.types:this.reverseGeocodingTypes)?.map(G=>typeof G=="string"?G:f===void 0||(G[0]??0)<=f&&f<(G[1]??1/0)?G[2]:void 0).filter(G=>G!==void 0);x&&(x=[...new Set(x)],u.set("types",x.join(",")));const w=!o||this.reverseGeocodingExcludeTypes===void 0?this.excludeTypes:this.reverseGeocodingExcludeTypes;if(w&&u.set("excludeTypes",String(w)),this.bbox&&u.set("bbox",this.bbox.map(G=>G.toFixed(6)).join(",")),this.country&&u.set("country",Array.isArray(this.country)?this.country.join(","):this.country),this.worldview&&u.set("worldview",this.worldview),!e&&!o){const G=this.proximity??[{type:"server-geolocation"}],L=await ys(le(this,Qe),G,s);L&&u.set("proximity",L),(t||this.showResultsWhileTyping===!1)&&u.set("autocomplete","false"),u.set("fuzzyMatch",String(this.fuzzyMatch!==!1))}const _=this.limit??5,M=this.reverseGeocodingLimit??_;M>1&&x?.length!==1&&console.warn("[MapTilerGeocodingControl] Warning: For reverse geocoding when limit > 1 then types must contain single value."),o?(M===1||this.exhaustiveReverseGeocoding||x?.length===1)&&u.set("limit",String(M)):u.set("limit",String(_)),this.apiKey&&u.set("key",this.apiKey),this.adjustUrl?.(l);const T=l.searchParams.get("types")===""&&l.searchParams.get("excludeTypes")!=="true",R=l.toString();if(R===this.lastSearchUrl){e?(this.clearListOnPick&&I(this,C,$e).call(this),this.picked=this.cachedFeatures[0]):(this.listFeatures=this.cachedFeatures,I(this,C,te).call(this,"featureslisted",{features:this.listFeatures,external:r}),this.listFeatures[this.selectedItemIndex]?.id!==le(this,C,yt)?.id&&(this.selectedItemIndex=-1));return}I(this,C,te).call(this,"request",{urlObj:l}),this.lastSearchUrl=R;let U;if(T)U={type:"FeatureCollection",features:[]};else{const G=await fetch(R,{signal:s.signal,...this.fetchParameters});if(!G.ok)throw new Error(await G.text());U=await G.json()}I(this,C,te).call(this,"response",{url:R,featureCollection:U}),e?(this.clearListOnPick&&I(this,C,$e).call(this),this.picked=U.features[0],this.cachedFeatures=[this.picked]):(this.listFeatures=U.features.filter(this.filter??(()=>!0)),o&&this.listFeatures.unshift({type:"Feature",properties:{},id:`reverse_${o.decimalLongitude}_${o.decimalLatitude}`,text:`${o.decimalLatitude}, ${o.decimalLongitude}`,place_name:o.toCoordinateFormat("DMS"),place_type:["reverse"],place_type_name:["reverse"],center:[o.decimalLongitude,o.decimalLatitude],bbox:[o.decimalLongitude,o.decimalLatitude,o.decimalLongitude,o.decimalLatitude],geometry:{type:"Point",coordinates:[o.decimalLongitude,o.decimalLatitude]}}),I(this,C,te).call(this,"featureslisted",{features:this.listFeatures,external:r}),this.cachedFeatures=this.listFeatures,this.listFeatures[this.selectedItemIndex]?.id!==le(this,C,yt)?.id&&(this.selectedItemIndex=-1),o&&this.input.focus())}catch(n){if(n&&typeof n=="object"&&"name"in n&&n.name==="AbortError")return;throw n}finally{s===this.abortController&&(this.abortController=void 0)}},ji=function(i){this.reverseActive=this.enableReverse==="always",I(this,C,$e).call(this),this.picked=void 0,I(this,C,Yt).call(this,`${i[1].toFixed(6)}, ${gs(i[0],[-180,180],!0).toFixed(6)}`),I(this,C,Zt).call(this)},Xt=function(i){if(!this.listFeatures)return;const e=i.key==="ArrowDown"?1:i.key==="ArrowUp"?-1:0;e&&(this.input.focus(),this.focused=!0,i.preventDefault(),this.picked&&this.selectedItemIndex===-1&&(this.selectedItemIndex=this.listFeatures.findIndex(t=>t.id===this.picked?.id)),this.selectedItemIndex===(this.picked||this.selectFirst!==!1?0:-1)&&e===-1&&(this.selectedItemIndex=this.listFeatures.length),this.selectedItemIndex+=e,this.selectedItemIndex>=this.listFeatures.length&&(this.selectedItemIndex=-1),this.selectedItemIndex<0&&(this.picked||this.selectFirst!==!1)&&(this.selectedItemIndex=0))},Vi=function(i){I(this,C,Kt).call(this,i.target.value)},Zi=function(i){(!this.picked||this.picked.id!==i.id)&&(this.picked=i,this.searchValue=i.place_name)},Ki=function(i){this.selectedItemIndex=i},Yi=function(){(!this.selectFirst||this.picked)&&(this.selectedItemIndex=-1),this.isFeatureListInteractedWith&&(this.isFeatureListInteractedWith=!1)},Xi=function(){this.isFeatureListInteractedWith=!0},Qi=function(){setTimeout(()=>{this.isFeatureListInteractedWith=!1})},Ji=function(){this.searchValue="",I(this,C,te).call(this,"queryclear"),this.picked=void 0,this.input.focus()},$.MaptilerGeocoderElement.styles=Se`
265
+ `}},gt=new WeakMap,Xe=new WeakMap,Ht=new WeakMap,Qe=new WeakMap,C=new WeakSet,yt=function(){return this.listFeatures?.[this.selectedItemIndex]},Hi=function(){return this.abortController!==void 0},jt=function(){return this.searchValue.length<(this.minLength??2)},te=function(i,...[e]){le(this,gt)&&this.dispatchEvent(new CustomEvent(i,{bubbles:!0,composed:!0,detail:e}))},Vt=function(i,{external:e=!1}={}){i?.preventDefault(),this.focused=!1,clearTimeout(le(this,Xe)),this.selectedItemIndex>-1&&this.listFeatures?(this.picked=this.listFeatures[this.selectedItemIndex],this.searchValue=this.picked.place_type[0]==="reverse"?this.picked.place_name:this.picked.place_name.replace(/,.*/,""),this.error=void 0,this.selectedItemIndex=-1):this.searchValue&&I(this,C,bt).call(this,this.searchValue,{exact:!0,external:e}).then(()=>{this.picked=void 0}).catch(t=>this.error=t)},vt=function(i){try{return hs(i,6)}catch{return!1}},Zt=function(){setTimeout(()=>{this.input.focus(),this.focused=!0,this.input.select()})},Kt=function(i,{external:e=!1}={}){if(this.searchValue=i,I(this,C,te).call(this,"querychange",{query:this.searchValue,reverseCoords:I(this,C,vt).call(this,i)}),this.error=void 0,this.picked=void 0,this.showResultsWhileTyping!==!1){if(clearTimeout(le(this,Xe)),le(this,C,jt))return;const t=this.searchValue;qt(this,Xe,window.setTimeout(()=>{I(this,C,bt).call(this,t,{external:e}).catch(r=>this.error=r)},this.debounceSearch??200))}else I(this,C,$e).call(this)},$e=function(){this.listFeatures!==void 0&&(this.listFeatures=void 0,I(this,C,te).call(this,"featuresclear"))},Yt=function(i,{external:e=!1}={}){this.searchValue=i,I(this,C,te).call(this,"querychange",{query:this.searchValue,reverseCoords:I(this,C,vt).call(this,i)}),this.selectedItemIndex=-1,I(this,C,Vt).call(this,void 0,{external:e})},bt=async function(i,{byId:e=!1,exact:t=!1,external:r=!1}={}){this.error=void 0,this.abortController?.abort();const s=new AbortController;this.abortController=s;try{const n=this.apiUrl??"https://api.maptiler.com/geocoding",o=I(this,C,vt).call(this,i),l=new URL(n+"/"+encodeURIComponent(o?`${o.decimalLongitude},${o.decimalLatitude}`:i)+".json"),u=l.searchParams;this.language!==void 0&&u.set("language",Array.isArray(this.language)?this.language.join(","):this.language??"");const[f]=le(this,Qe)??[void 0];let x=(!o||this.reverseGeocodingTypes===void 0?this.types:this.reverseGeocodingTypes)?.map(G=>typeof G=="string"?G:f===void 0||(G[0]??0)<=f&&f<(G[1]??1/0)?G[2]:void 0).filter(G=>G!==void 0);x&&(x=[...new Set(x)],u.set("types",x.join(",")));const w=!o||this.reverseGeocodingExcludeTypes===void 0?this.excludeTypes:this.reverseGeocodingExcludeTypes;if(w&&u.set("excludeTypes",String(w)),this.bbox&&u.set("bbox",this.bbox.map(G=>G.toFixed(6)).join(",")),this.country&&u.set("country",Array.isArray(this.country)?this.country.join(","):this.country),this.worldview&&u.set("worldview",this.worldview),!e&&!o){const G=this.proximity??[{type:"server-geolocation"}],L=await ys(le(this,Qe),G,s);L&&u.set("proximity",L),(t||this.showResultsWhileTyping===!1)&&u.set("autocomplete","false"),u.set("fuzzyMatch",String(this.fuzzyMatch!==!1))}const _=this.limit??5,M=this.reverseGeocodingLimit??_;M>1&&x?.length!==1&&console.warn("[MapTilerGeocodingControl] Warning: For reverse geocoding when limit > 1 then types must contain single value."),o?(M===1||this.exhaustiveReverseGeocoding||x?.length===1)&&u.set("limit",String(M)):u.set("limit",String(_)),this.apiKey&&u.set("key",this.apiKey),this.adjustUrl?.(l);const T=l.searchParams.get("types")===""&&l.searchParams.get("excludeTypes")!=="true",R=l.toString();if(R===this.lastSearchUrl){e?(this.clearListOnPick&&I(this,C,$e).call(this),this.picked=this.cachedFeatures[0]):(this.listFeatures=this.cachedFeatures,I(this,C,te).call(this,"featureslisted",{features:this.listFeatures,external:r}),this.listFeatures[this.selectedItemIndex]?.id!==le(this,C,yt)?.id&&(this.selectedItemIndex=-1));return}I(this,C,te).call(this,"request",{urlObj:l}),this.lastSearchUrl=R;let U;if(T)U={type:"FeatureCollection",features:[]};else{const G=await fetch(R,{signal:s.signal,...this.fetchParameters});if(!G.ok)throw new Error(await G.text());U=await G.json()}I(this,C,te).call(this,"response",{url:R,featureCollection:U}),e?(this.clearListOnPick&&I(this,C,$e).call(this),this.picked=U.features[0],this.cachedFeatures=[this.picked]):(this.listFeatures=U.features.filter(this.filter??(()=>!0)),o&&this.listFeatures.unshift({type:"Feature",properties:{},id:`reverse_${o.decimalLongitude}_${o.decimalLatitude}`,place_name:`${o.decimalLatitude}, ${o.decimalLongitude}`,text:o.toCoordinateFormat("DMS"),place_type:["reverse"],place_type_name:["reverse"],center:[o.decimalLongitude,o.decimalLatitude],bbox:[o.decimalLongitude,o.decimalLatitude,o.decimalLongitude,o.decimalLatitude],geometry:{type:"Point",coordinates:[o.decimalLongitude,o.decimalLatitude]}}),I(this,C,te).call(this,"featureslisted",{features:this.listFeatures,external:r}),this.cachedFeatures=this.listFeatures,this.listFeatures[this.selectedItemIndex]?.id!==le(this,C,yt)?.id&&(this.selectedItemIndex=-1),o&&this.input.focus())}catch(n){if(n&&typeof n=="object"&&"name"in n&&n.name==="AbortError")return;throw n}finally{s===this.abortController&&(this.abortController=void 0)}},ji=function(i){this.reverseActive=this.enableReverse==="always",I(this,C,$e).call(this),this.picked=void 0,I(this,C,Yt).call(this,`${i[1].toFixed(6)}, ${gs(i[0],[-180,180],!0).toFixed(6)}`),I(this,C,Zt).call(this)},Xt=function(i){if(!this.listFeatures)return;const e=i.key==="ArrowDown"?1:i.key==="ArrowUp"?-1:0;e&&(this.input.focus(),this.focused=!0,i.preventDefault(),this.picked&&this.selectedItemIndex===-1&&(this.selectedItemIndex=this.listFeatures.findIndex(t=>t.id===this.picked?.id)),this.selectedItemIndex===(this.picked||this.selectFirst!==!1?0:-1)&&e===-1&&(this.selectedItemIndex=this.listFeatures.length),this.selectedItemIndex+=e,this.selectedItemIndex>=this.listFeatures.length&&(this.selectedItemIndex=-1),this.selectedItemIndex<0&&(this.picked||this.selectFirst!==!1)&&(this.selectedItemIndex=0))},Vi=function(i){I(this,C,Kt).call(this,i.target.value)},Zi=function(i){(!this.picked||this.picked.id!==i.id)&&(this.picked=i,this.searchValue=i.place_name)},Ki=function(i){this.selectedItemIndex=i},Yi=function(){(!this.selectFirst||this.picked)&&(this.selectedItemIndex=-1),this.isFeatureListInteractedWith&&(this.isFeatureListInteractedWith=!1)},Xi=function(){this.isFeatureListInteractedWith=!0},Qi=function(){setTimeout(()=>{this.isFeatureListInteractedWith=!1})},Ji=function(){this.searchValue="",I(this,C,te).call(this,"queryclear"),this.picked=void 0,this.input.focus()},$.MaptilerGeocoderElement.styles=Se`
266
266
  ${at(Ls)}
267
267
  `,O([N({attribute:!1})],$.MaptilerGeocoderElement.prototype,"adjustUrl",2),O([N({type:String})],$.MaptilerGeocoderElement.prototype,"apiKey",2),O([N({type:String})],$.MaptilerGeocoderElement.prototype,"apiUrl",2),O([N({type:Array})],$.MaptilerGeocoderElement.prototype,"bbox",2),O([N({type:String})],$.MaptilerGeocoderElement.prototype,"clearButtonTitle",2),O([N({type:Boolean})],$.MaptilerGeocoderElement.prototype,"clearListOnPick",2),O([N({type:Boolean})],$.MaptilerGeocoderElement.prototype,"clearOnBlur",2),O([N({type:Boolean})],$.MaptilerGeocoderElement.prototype,"collapsed",2),O([N({attribute:!1})],$.MaptilerGeocoderElement.prototype,"country",2),O([N({type:Number})],$.MaptilerGeocoderElement.prototype,"debounceSearch",2),O([N({type:String})],$.MaptilerGeocoderElement.prototype,"enableReverse",2),O([N({type:String})],$.MaptilerGeocoderElement.prototype,"errorMessage",2),O([N({type:Boolean})],$.MaptilerGeocoderElement.prototype,"excludeTypes",2),O([N({type:Boolean})],$.MaptilerGeocoderElement.prototype,"exhaustiveReverseGeocoding",2),O([N({type:Boolean})],$.MaptilerGeocoderElement.prototype,"fetchFullGeometryOnPick",2),O([N({type:Object})],$.MaptilerGeocoderElement.prototype,"fetchParameters",2),O([N({attribute:!1})],$.MaptilerGeocoderElement.prototype,"filter",2),O([N({type:Object})],$.MaptilerGeocoderElement.prototype,"fuzzyMatch",2),O([N({type:String})],$.MaptilerGeocoderElement.prototype,"iconsBaseUrl",2),O([N({type:Boolean})],$.MaptilerGeocoderElement.prototype,"keepListOpen",2),O([N({attribute:!1})],$.MaptilerGeocoderElement.prototype,"language",2),O([N({type:Number})],$.MaptilerGeocoderElement.prototype,"limit",2),O([N({type:Number})],$.MaptilerGeocoderElement.prototype,"minLength",2),O([N({type:String})],$.MaptilerGeocoderElement.prototype,"noResultsMessage",2),O([N({type:Boolean})],$.MaptilerGeocoderElement.prototype,"openListOnTop",2),O([N({type:String})],$.MaptilerGeocoderElement.prototype,"placeholder",2),O([N({type:Array})],$.MaptilerGeocoderElement.prototype,"proximity",2),O([N({type:Boolean})],$.MaptilerGeocoderElement.prototype,"reverseActive",2),O([N({type:String})],$.MaptilerGeocoderElement.prototype,"reverseButtonTitle",2),O([N({type:Object})],$.MaptilerGeocoderElement.prototype,"reverseGeocodingExcludeTypes",2),O([N({type:Number})],$.MaptilerGeocoderElement.prototype,"reverseGeocodingLimit",2),O([N({type:Array})],$.MaptilerGeocoderElement.prototype,"reverseGeocodingTypes",2),O([N({type:Object})],$.MaptilerGeocoderElement.prototype,"selectFirst",2),O([N({type:String})],$.MaptilerGeocoderElement.prototype,"showPlaceType",2),O([N({type:Object})],$.MaptilerGeocoderElement.prototype,"showResultsWhileTyping",2),O([N({type:Array})],$.MaptilerGeocoderElement.prototype,"types",2),O([N({type:String})],$.MaptilerGeocoderElement.prototype,"worldview",2),O([zr("input")],$.MaptilerGeocoderElement.prototype,"input",2),O([ee()],$.MaptilerGeocoderElement.prototype,"searchValue",2),O([ee()],$.MaptilerGeocoderElement.prototype,"listFeatures",2),O([ee()],$.MaptilerGeocoderElement.prototype,"selectedItemIndex",2),O([ee()],$.MaptilerGeocoderElement.prototype,"picked",2),O([ee()],$.MaptilerGeocoderElement.prototype,"cachedFeatures",2),O([ee()],$.MaptilerGeocoderElement.prototype,"lastSearchUrl",2),O([ee()],$.MaptilerGeocoderElement.prototype,"error",2),O([ee()],$.MaptilerGeocoderElement.prototype,"abortController",2),O([ee()],$.MaptilerGeocoderElement.prototype,"focused",2),O([ee()],$.MaptilerGeocoderElement.prototype,"isFeatureListVisible",2),O([ee()],$.MaptilerGeocoderElement.prototype,"isFeatureListInteractedWith",2),$.MaptilerGeocoderElement=O([_e("maptiler-geocoder")],$.MaptilerGeocoderElement);const Ms=["adjustUrl","apiKey","apiUrl","bbox","clearButtonTitle","clearListOnPick","clearOnBlur","collapsed","country","debounceSearch","enableReverse","errorMessage","excludeTypes","reverseGeocodingExcludeTypes","exhaustiveReverseGeocoding","fetchParameters","fetchFullGeometryOnPick","filter","fuzzyMatch","iconsBaseUrl","keepListOpen","language","limit","reverseGeocodingLimit","minLength","noResultsMessage","openListOnTop","placeholder","proximity","reverseActive","reverseButtonTitle","selectFirst","showPlaceType","showResultsWhileTyping","types","reverseGeocodingTypes","worldview"],Ts="svg{display:block;fill:var(--maptiler-geocode-marker-fill, #3170fe);stroke:var(--maptiler-geocode-marker-stroke, #3170fe);height:30px}:host(.marker-selected){z-index:2}:host(.marker-selected) svg path{fill:var(--maptiler-geocode-marker-selected-fill, #98b7ff);stroke:var(--maptiler-geocode-marker-selected-stroke, #3170fe)}:host(.marker-reverse) svg path{fill:var(--maptiler-geocode-marker-reverse-fill, silver);stroke:var(--maptiler-geocode-marker-reverse-stroke, gray)}:host(.marker-interactive){cursor:pointer!important}:host(.marker-fuzzy) svg path{fill:var(--maptiler-geocode-marker-fuzzy-fill, silver);stroke:var(--maptiler-geocode-marker-fuzzy-stroke, gray)}:host(.marker-fuzzy.marker-selected) svg path{fill:var(--maptiler-geocode-marker-selected-fuzzy-fill, #ddd);stroke:var(--maptiler-geocode-marker-selected-fuzzy-stroke, silver)}";var As=Object.getOwnPropertyDescriptor,Cs=(i,e,t,r)=>{for(var s=r>1?void 0:r?As(e,t):e,n=i.length-1,o;n>=0;n--)(o=i[n])&&(s=o(s)||s);return s};$.MaptilerGeocodeMarkerElement=class extends ne{render(){return qe`
268
268
  <svg
@@ -277,5 +277,5 @@
277
277
  </svg>
278
278
  `}},$.MaptilerGeocodeMarkerElement.styles=Se`
279
279
  ${at(Ts)}
280
- `,$.MaptilerGeocodeMarkerElement=Cs([_e("maptiler-geocode-marker")],$.MaptilerGeocodeMarkerElement);function Je(i,e,t={}){const r={type:"Feature"};return(t.id===0||t.id)&&(r.id=t.id),t.bbox&&(r.bbox=t.bbox),r.properties=e||{},r.geometry=i,r}function Qt(i,e,t={}){for(const s of i){if(s.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(s[s.length-1].length!==s[0].length)throw new Error("First and last Position are not equivalent.");for(let n=0;n<s[s.length-1].length;n++)if(s[s.length-1][n]!==s[0][n])throw new Error("First and last Position are not equivalent.")}return Je({type:"Polygon",coordinates:i},e,t)}function et(i,e={}){const t={type:"FeatureCollection"};return e.id&&(t.id=e.id),e.bbox&&(t.bbox=e.bbox),t.features=i,t}function er(i,e,t={}){return Je({type:"MultiPolygon",coordinates:i},e,t)}var ks=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,Jt=Math.ceil,ae=Math.floor,re="[BigNumber Error] ",tr=re+"Number primitive has more than 15 significant digits: ",fe=1e14,P=14,ei=9007199254740991,ti=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],Me=1e7,X=1e9;function ir(i){var e,t,r,s=L.prototype={constructor:L,toString:null,valueOf:null},n=new L(1),o=20,l=4,u=-7,f=21,x=-1e7,w=1e7,_=!1,M=1,T=0,R={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},U="0123456789abcdefghijklmnopqrstuvwxyz",G=!0;function L(a,c){var h,v,p,g,E,d,m,b,y=this;if(!(y instanceof L))return new L(a,c);if(c==null){if(a&&a._isBigNumber===!0){y.s=a.s,!a.c||a.e>w?y.c=y.e=null:a.e<x?y.c=[y.e=0]:(y.e=a.e,y.c=a.c.slice());return}if((d=typeof a=="number")&&a*0==0){if(y.s=1/a<0?(a=-a,-1):1,a===~~a){for(g=0,E=a;E>=10;E/=10,g++);g>w?y.c=y.e=null:(y.e=g,y.c=[a]);return}b=String(a)}else{if(!ks.test(b=String(a)))return r(y,b,d);y.s=b.charCodeAt(0)==45?(b=b.slice(1),-1):1}(g=b.indexOf("."))>-1&&(b=b.replace(".","")),(E=b.search(/e/i))>0?(g<0&&(g=E),g+=+b.slice(E+1),b=b.substring(0,E)):g<0&&(g=b.length)}else{if(q(c,2,U.length,"Base"),c==10&&G)return y=new L(a),ue(y,o+y.e+1,l);if(b=String(a),d=typeof a=="number"){if(a*0!=0)return r(y,b,d,c);if(y.s=1/a<0?(b=b.slice(1),-1):1,L.DEBUG&&b.replace(/^0\.0*|\./,"").length>15)throw Error(tr+a)}else y.s=b.charCodeAt(0)===45?(b=b.slice(1),-1):1;for(h=U.slice(0,c),g=E=0,m=b.length;E<m;E++)if(h.indexOf(v=b.charAt(E))<0){if(v=="."){if(E>g){g=m;continue}}else if(!p&&(b==b.toUpperCase()&&(b=b.toLowerCase())||b==b.toLowerCase()&&(b=b.toUpperCase()))){p=!0,E=-1,g=0;continue}return r(y,String(a),d,c)}d=!1,b=t(b,c,10,y.s),(g=b.indexOf("."))>-1?b=b.replace(".",""):g=b.length}for(E=0;b.charCodeAt(E)===48;E++);for(m=b.length;b.charCodeAt(--m)===48;);if(b=b.slice(E,++m)){if(m-=E,d&&L.DEBUG&&m>15&&(a>ei||a!==ae(a)))throw Error(tr+y.s*a);if((g=g-E-1)>w)y.c=y.e=null;else if(g<x)y.c=[y.e=0];else{if(y.e=g,y.c=[],E=(g+1)%P,g<0&&(E+=P),E<m){for(E&&y.c.push(+b.slice(0,E)),m-=P;E<m;)y.c.push(+b.slice(E,E+=P));E=P-(b=b.slice(E)).length}else E-=m;for(;E--;b+="0");y.c.push(+b)}}else y.c=[y.e=0]}L.clone=ir,L.ROUND_UP=0,L.ROUND_DOWN=1,L.ROUND_CEIL=2,L.ROUND_FLOOR=3,L.ROUND_HALF_UP=4,L.ROUND_HALF_DOWN=5,L.ROUND_HALF_EVEN=6,L.ROUND_HALF_CEIL=7,L.ROUND_HALF_FLOOR=8,L.EUCLID=9,L.config=L.set=function(a){var c,h;if(a!=null)if(typeof a=="object"){if(a.hasOwnProperty(c="DECIMAL_PLACES")&&(h=a[c],q(h,0,X,c),o=h),a.hasOwnProperty(c="ROUNDING_MODE")&&(h=a[c],q(h,0,8,c),l=h),a.hasOwnProperty(c="EXPONENTIAL_AT")&&(h=a[c],h&&h.pop?(q(h[0],-X,0,c),q(h[1],0,X,c),u=h[0],f=h[1]):(q(h,-X,X,c),u=-(f=h<0?-h:h))),a.hasOwnProperty(c="RANGE"))if(h=a[c],h&&h.pop)q(h[0],-X,-1,c),q(h[1],1,X,c),x=h[0],w=h[1];else if(q(h,-X,X,c),h)x=-(w=h<0?-h:h);else throw Error(re+c+" cannot be zero: "+h);if(a.hasOwnProperty(c="CRYPTO"))if(h=a[c],h===!!h)if(h)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))_=h;else throw _=!h,Error(re+"crypto unavailable");else _=h;else throw Error(re+c+" not true or false: "+h);if(a.hasOwnProperty(c="MODULO_MODE")&&(h=a[c],q(h,0,9,c),M=h),a.hasOwnProperty(c="POW_PRECISION")&&(h=a[c],q(h,0,X,c),T=h),a.hasOwnProperty(c="FORMAT"))if(h=a[c],typeof h=="object")R=h;else throw Error(re+c+" not an object: "+h);if(a.hasOwnProperty(c="ALPHABET"))if(h=a[c],typeof h=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(h))G=h.slice(0,10)=="0123456789",U=h;else throw Error(re+c+" invalid: "+h)}else throw Error(re+"Object expected: "+a);return{DECIMAL_PLACES:o,ROUNDING_MODE:l,EXPONENTIAL_AT:[u,f],RANGE:[x,w],CRYPTO:_,MODULO_MODE:M,POW_PRECISION:T,FORMAT:R,ALPHABET:U}},L.isBigNumber=function(a){if(!a||a._isBigNumber!==!0)return!1;if(!L.DEBUG)return!0;var c,h,v=a.c,p=a.e,g=a.s;e:if({}.toString.call(v)=="[object Array]"){if((g===1||g===-1)&&p>=-X&&p<=X&&p===ae(p)){if(v[0]===0){if(p===0&&v.length===1)return!0;break e}if(c=(p+1)%P,c<1&&(c+=P),String(v[0]).length==c){for(c=0;c<v.length;c++)if(h=v[c],h<0||h>=fe||h!==ae(h))break e;if(h!==0)return!0}}}else if(v===null&&p===null&&(g===null||g===1||g===-1))return!0;throw Error(re+"Invalid BigNumber: "+a)},L.maximum=L.max=function(){return se(arguments,-1)},L.minimum=L.min=function(){return se(arguments,1)},L.random=(function(){var a=9007199254740992,c=Math.random()*a&2097151?function(){return ae(Math.random()*a)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(h){var v,p,g,E,d,m=0,b=[],y=new L(n);if(h==null?h=o:q(h,0,X),E=Jt(h/P),_)if(crypto.getRandomValues){for(v=crypto.getRandomValues(new Uint32Array(E*=2));m<E;)d=v[m]*131072+(v[m+1]>>>11),d>=9e15?(p=crypto.getRandomValues(new Uint32Array(2)),v[m]=p[0],v[m+1]=p[1]):(b.push(d%1e14),m+=2);m=E/2}else if(crypto.randomBytes){for(v=crypto.randomBytes(E*=7);m<E;)d=(v[m]&31)*281474976710656+v[m+1]*1099511627776+v[m+2]*4294967296+v[m+3]*16777216+(v[m+4]<<16)+(v[m+5]<<8)+v[m+6],d>=9e15?crypto.randomBytes(7).copy(v,m):(b.push(d%1e14),m+=7);m=E/7}else throw _=!1,Error(re+"crypto unavailable");if(!_)for(;m<E;)d=c(),d<9e15&&(b[m++]=d%1e14);for(E=b[--m],h%=P,E&&h&&(d=ti[P-h],b[m]=ae(E/d)*d);b[m]===0;b.pop(),m--);if(m<0)b=[g=0];else{for(g=-1;b[0]===0;b.splice(0,1),g-=P);for(m=1,d=b[0];d>=10;d/=10,m++);m<P&&(g-=P-m)}return y.e=g,y.c=b,y}})(),L.sum=function(){for(var a=1,c=arguments,h=new L(c[0]);a<c.length;)h=h.plus(c[a++]);return h},t=(function(){var a="0123456789";function c(h,v,p,g){for(var E,d=[0],m,b=0,y=h.length;b<y;){for(m=d.length;m--;d[m]*=v);for(d[0]+=g.indexOf(h.charAt(b++)),E=0;E<d.length;E++)d[E]>p-1&&(d[E+1]==null&&(d[E+1]=0),d[E+1]+=d[E]/p|0,d[E]%=p)}return d.reverse()}return function(h,v,p,g,E){var d,m,b,y,S,A,k,D,H=h.indexOf("."),K=o,F=l;for(H>=0&&(y=T,T=0,h=h.replace(".",""),D=new L(v),A=D.pow(h.length-H),T=y,D.c=c(Ee(he(A.c),A.e,"0"),10,p,a),D.e=D.c.length),k=c(h,v,p,E?(d=U,a):(d=a,U)),b=y=k.length;k[--y]==0;k.pop());if(!k[0])return d.charAt(0);if(H<0?--b:(A.c=k,A.e=b,A.s=g,A=e(A,D,K,F,p),k=A.c,S=A.r,b=A.e),m=b+K+1,H=k[m],y=p/2,S=S||m<0||k[m+1]!=null,S=F<4?(H!=null||S)&&(F==0||F==(A.s<0?3:2)):H>y||H==y&&(F==4||S||F==6&&k[m-1]&1||F==(A.s<0?8:7)),m<1||!k[0])h=S?Ee(d.charAt(1),-K,d.charAt(0)):d.charAt(0);else{if(k.length=m,S)for(--p;++k[--m]>p;)k[m]=0,m||(++b,k=[1].concat(k));for(y=k.length;!k[--y];);for(H=0,h="";H<=y;h+=d.charAt(k[H++]));h=Ee(h,b,d.charAt(0))}return h}})(),e=(function(){function a(v,p,g){var E,d,m,b,y=0,S=v.length,A=p%Me,k=p/Me|0;for(v=v.slice();S--;)m=v[S]%Me,b=v[S]/Me|0,E=k*m+b*A,d=A*m+E%Me*Me+y,y=(d/g|0)+(E/Me|0)+k*b,v[S]=d%g;return y&&(v=[y].concat(v)),v}function c(v,p,g,E){var d,m;if(g!=E)m=g>E?1:-1;else for(d=m=0;d<g;d++)if(v[d]!=p[d]){m=v[d]>p[d]?1:-1;break}return m}function h(v,p,g,E){for(var d=0;g--;)v[g]-=d,d=v[g]<p[g]?1:0,v[g]=d*E+v[g]-p[g];for(;!v[0]&&v.length>1;v.splice(0,1));}return function(v,p,g,E,d){var m,b,y,S,A,k,D,H,K,F,W,J,Mt,ai,ci,ve,nt,de=v.s==p.s?1:-1,ie=v.c,j=p.c;if(!ie||!ie[0]||!j||!j[0])return new L(!v.s||!p.s||(ie?j&&ie[0]==j[0]:!j)?NaN:ie&&ie[0]==0||!j?de*0:de/0);for(H=new L(de),K=H.c=[],b=v.e-p.e,de=g+b+1,d||(d=fe,b=ce(v.e/P)-ce(p.e/P),de=de/P|0),y=0;j[y]==(ie[y]||0);y++);if(j[y]>(ie[y]||0)&&b--,de<0)K.push(1),S=!0;else{for(ai=ie.length,ve=j.length,y=0,de+=2,A=ae(d/(j[0]+1)),A>1&&(j=a(j,A,d),ie=a(ie,A,d),ve=j.length,ai=ie.length),Mt=ve,F=ie.slice(0,ve),W=F.length;W<ve;F[W++]=0);nt=j.slice(),nt=[0].concat(nt),ci=j[0],j[1]>=d/2&&ci++;do{if(A=0,m=c(j,F,ve,W),m<0){if(J=F[0],ve!=W&&(J=J*d+(F[1]||0)),A=ae(J/ci),A>1)for(A>=d&&(A=d-1),k=a(j,A,d),D=k.length,W=F.length;c(k,F,D,W)==1;)A--,h(k,ve<D?nt:j,D,d),D=k.length,m=1;else A==0&&(m=A=1),k=j.slice(),D=k.length;if(D<W&&(k=[0].concat(k)),h(F,k,W,d),W=F.length,m==-1)for(;c(j,F,ve,W)<1;)A++,h(F,ve<W?nt:j,W,d),W=F.length}else m===0&&(A++,F=[0]);K[y++]=A,F[0]?F[W++]=ie[Mt]||0:(F=[ie[Mt]],W=1)}while((Mt++<ai||F[0]!=null)&&de--);S=F[0]!=null,K[0]||K.splice(0,1)}if(d==fe){for(y=1,de=K[0];de>=10;de/=10,y++);ue(H,g+(H.e=y+b*P-1)+1,E,S)}else H.e=b,H.r=+S;return H}})();function Q(a,c,h,v){var p,g,E,d,m;if(h==null?h=l:q(h,0,8),!a.c)return a.toString();if(p=a.c[0],E=a.e,c==null)m=he(a.c),m=v==1||v==2&&(E<=u||E>=f)?wt(m,E):Ee(m,E,"0");else if(a=ue(new L(a),c,h),g=a.e,m=he(a.c),d=m.length,v==1||v==2&&(c<=g||g<=u)){for(;d<c;m+="0",d++);m=wt(m,g)}else if(c-=E+(v===2&&g>E),m=Ee(m,g,"0"),g+1>d){if(--c>0)for(m+=".";c--;m+="0");}else if(c+=g-d,c>0)for(g+1==d&&(m+=".");c--;m+="0");return a.s<0&&p?"-"+m:m}function se(a,c){for(var h,v,p=1,g=new L(a[0]);p<a.length;p++)v=new L(a[p]),(!v.s||(h=Ne(g,v))===c||h===0&&g.s===c)&&(g=v);return g}function ye(a,c,h){for(var v=1,p=c.length;!c[--p];c.pop());for(p=c[0];p>=10;p/=10,v++);return(h=v+h*P-1)>w?a.c=a.e=null:h<x?a.c=[a.e=0]:(a.e=h,a.c=c),a}r=(function(){var a=/^(-?)0([xbo])(?=\w[\w.]*$)/i,c=/^([^.]+)\.$/,h=/^\.([^.]+)$/,v=/^-?(Infinity|NaN)$/,p=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(g,E,d,m){var b,y=d?E:E.replace(p,"");if(v.test(y))g.s=isNaN(y)?null:y<0?-1:1;else{if(!d&&(y=y.replace(a,function(S,A,k){return b=(k=k.toLowerCase())=="x"?16:k=="b"?2:8,!m||m==b?A:S}),m&&(b=m,y=y.replace(c,"$1").replace(h,"0.$1")),E!=y))return new L(y,b);if(L.DEBUG)throw Error(re+"Not a"+(m?" base "+m:"")+" number: "+E);g.s=null}g.c=g.e=null}})();function ue(a,c,h,v){var p,g,E,d,m,b,y,S=a.c,A=ti;if(S){e:{for(p=1,d=S[0];d>=10;d/=10,p++);if(g=c-p,g<0)g+=P,E=c,m=S[b=0],y=ae(m/A[p-E-1]%10);else if(b=Jt((g+1)/P),b>=S.length)if(v){for(;S.length<=b;S.push(0));m=y=0,p=1,g%=P,E=g-P+1}else break e;else{for(m=d=S[b],p=1;d>=10;d/=10,p++);g%=P,E=g-P+p,y=E<0?0:ae(m/A[p-E-1]%10)}if(v=v||c<0||S[b+1]!=null||(E<0?m:m%A[p-E-1]),v=h<4?(y||v)&&(h==0||h==(a.s<0?3:2)):y>5||y==5&&(h==4||v||h==6&&(g>0?E>0?m/A[p-E]:0:S[b-1])%10&1||h==(a.s<0?8:7)),c<1||!S[0])return S.length=0,v?(c-=a.e+1,S[0]=A[(P-c%P)%P],a.e=-c||0):S[0]=a.e=0,a;if(g==0?(S.length=b,d=1,b--):(S.length=b+1,d=A[P-g],S[b]=E>0?ae(m/A[p-E]%A[E])*d:0),v)for(;;)if(b==0){for(g=1,E=S[0];E>=10;E/=10,g++);for(E=S[0]+=d,d=1;E>=10;E/=10,d++);g!=d&&(a.e++,S[0]==fe&&(S[0]=1));break}else{if(S[b]+=d,S[b]!=fe)break;S[b--]=0,d=1}for(g=S.length;S[--g]===0;S.pop());}a.e>w?a.c=a.e=null:a.e<x&&(a.c=[a.e=0])}return a}function xe(a){var c,h=a.e;return h===null?a.toString():(c=he(a.c),c=h<=u||h>=f?wt(c,h):Ee(c,h,"0"),a.s<0?"-"+c:c)}return s.absoluteValue=s.abs=function(){var a=new L(this);return a.s<0&&(a.s=1),a},s.comparedTo=function(a,c){return Ne(this,new L(a,c))},s.decimalPlaces=s.dp=function(a,c){var h,v,p,g=this;if(a!=null)return q(a,0,X),c==null?c=l:q(c,0,8),ue(new L(g),a+g.e+1,c);if(!(h=g.c))return null;if(v=((p=h.length-1)-ce(this.e/P))*P,p=h[p])for(;p%10==0;p/=10,v--);return v<0&&(v=0),v},s.dividedBy=s.div=function(a,c){return e(this,new L(a,c),o,l)},s.dividedToIntegerBy=s.idiv=function(a,c){return e(this,new L(a,c),0,1)},s.exponentiatedBy=s.pow=function(a,c){var h,v,p,g,E,d,m,b,y,S=this;if(a=new L(a),a.c&&!a.isInteger())throw Error(re+"Exponent not an integer: "+xe(a));if(c!=null&&(c=new L(c)),d=a.e>14,!S.c||!S.c[0]||S.c[0]==1&&!S.e&&S.c.length==1||!a.c||!a.c[0])return y=new L(Math.pow(+xe(S),d?a.s*(2-Et(a)):+xe(a))),c?y.mod(c):y;if(m=a.s<0,c){if(c.c?!c.c[0]:!c.s)return new L(NaN);v=!m&&S.isInteger()&&c.isInteger(),v&&(S=S.mod(c))}else{if(a.e>9&&(S.e>0||S.e<-1||(S.e==0?S.c[0]>1||d&&S.c[1]>=24e7:S.c[0]<8e13||d&&S.c[0]<=9999975e7)))return g=S.s<0&&Et(a)?-0:0,S.e>-1&&(g=1/g),new L(m?1/g:g);T&&(g=Jt(T/P+2))}for(d?(h=new L(.5),m&&(a.s=1),b=Et(a)):(p=Math.abs(+xe(a)),b=p%2),y=new L(n);;){if(b){if(y=y.times(S),!y.c)break;g?y.c.length>g&&(y.c.length=g):v&&(y=y.mod(c))}if(p){if(p=ae(p/2),p===0)break;b=p%2}else if(a=a.times(h),ue(a,a.e+1,1),a.e>14)b=Et(a);else{if(p=+xe(a),p===0)break;b=p%2}S=S.times(S),g?S.c&&S.c.length>g&&(S.c.length=g):v&&(S=S.mod(c))}return v?y:(m&&(y=n.div(y)),c?y.mod(c):g?ue(y,T,l,E):y)},s.integerValue=function(a){var c=new L(this);return a==null?a=l:q(a,0,8),ue(c,c.e+1,a)},s.isEqualTo=s.eq=function(a,c){return Ne(this,new L(a,c))===0},s.isFinite=function(){return!!this.c},s.isGreaterThan=s.gt=function(a,c){return Ne(this,new L(a,c))>0},s.isGreaterThanOrEqualTo=s.gte=function(a,c){return(c=Ne(this,new L(a,c)))===1||c===0},s.isInteger=function(){return!!this.c&&ce(this.e/P)>this.c.length-2},s.isLessThan=s.lt=function(a,c){return Ne(this,new L(a,c))<0},s.isLessThanOrEqualTo=s.lte=function(a,c){return(c=Ne(this,new L(a,c)))===-1||c===0},s.isNaN=function(){return!this.s},s.isNegative=function(){return this.s<0},s.isPositive=function(){return this.s>0},s.isZero=function(){return!!this.c&&this.c[0]==0},s.minus=function(a,c){var h,v,p,g,E=this,d=E.s;if(a=new L(a,c),c=a.s,!d||!c)return new L(NaN);if(d!=c)return a.s=-c,E.plus(a);var m=E.e/P,b=a.e/P,y=E.c,S=a.c;if(!m||!b){if(!y||!S)return y?(a.s=-c,a):new L(S?E:NaN);if(!y[0]||!S[0])return S[0]?(a.s=-c,a):new L(y[0]?E:l==3?-0:0)}if(m=ce(m),b=ce(b),y=y.slice(),d=m-b){for((g=d<0)?(d=-d,p=y):(b=m,p=S),p.reverse(),c=d;c--;p.push(0));p.reverse()}else for(v=(g=(d=y.length)<(c=S.length))?d:c,d=c=0;c<v;c++)if(y[c]!=S[c]){g=y[c]<S[c];break}if(g&&(p=y,y=S,S=p,a.s=-a.s),c=(v=S.length)-(h=y.length),c>0)for(;c--;y[h++]=0);for(c=fe-1;v>d;){if(y[--v]<S[v]){for(h=v;h&&!y[--h];y[h]=c);--y[h],y[v]+=fe}y[v]-=S[v]}for(;y[0]==0;y.splice(0,1),--b);return y[0]?ye(a,y,b):(a.s=l==3?-1:1,a.c=[a.e=0],a)},s.modulo=s.mod=function(a,c){var h,v,p=this;return a=new L(a,c),!p.c||!a.s||a.c&&!a.c[0]?new L(NaN):!a.c||p.c&&!p.c[0]?new L(p):(M==9?(v=a.s,a.s=1,h=e(p,a,0,3),a.s=v,h.s*=v):h=e(p,a,0,M),a=p.minus(h.times(a)),!a.c[0]&&M==1&&(a.s=p.s),a)},s.multipliedBy=s.times=function(a,c){var h,v,p,g,E,d,m,b,y,S,A,k,D,H,K,F=this,W=F.c,J=(a=new L(a,c)).c;if(!W||!J||!W[0]||!J[0])return!F.s||!a.s||W&&!W[0]&&!J||J&&!J[0]&&!W?a.c=a.e=a.s=null:(a.s*=F.s,!W||!J?a.c=a.e=null:(a.c=[0],a.e=0)),a;for(v=ce(F.e/P)+ce(a.e/P),a.s*=F.s,m=W.length,S=J.length,m<S&&(D=W,W=J,J=D,p=m,m=S,S=p),p=m+S,D=[];p--;D.push(0));for(H=fe,K=Me,p=S;--p>=0;){for(h=0,A=J[p]%K,k=J[p]/K|0,E=m,g=p+E;g>p;)b=W[--E]%K,y=W[E]/K|0,d=k*b+y*A,b=A*b+d%K*K+D[g]+h,h=(b/H|0)+(d/K|0)+k*y,D[g--]=b%H;D[g]=h}return h?++v:D.splice(0,1),ye(a,D,v)},s.negated=function(){var a=new L(this);return a.s=-a.s||null,a},s.plus=function(a,c){var h,v=this,p=v.s;if(a=new L(a,c),c=a.s,!p||!c)return new L(NaN);if(p!=c)return a.s=-c,v.minus(a);var g=v.e/P,E=a.e/P,d=v.c,m=a.c;if(!g||!E){if(!d||!m)return new L(p/0);if(!d[0]||!m[0])return m[0]?a:new L(d[0]?v:p*0)}if(g=ce(g),E=ce(E),d=d.slice(),p=g-E){for(p>0?(E=g,h=m):(p=-p,h=d),h.reverse();p--;h.push(0));h.reverse()}for(p=d.length,c=m.length,p-c<0&&(h=m,m=d,d=h,c=p),p=0;c;)p=(d[--c]=d[c]+m[c]+p)/fe|0,d[c]=fe===d[c]?0:d[c]%fe;return p&&(d=[p].concat(d),++E),ye(a,d,E)},s.precision=s.sd=function(a,c){var h,v,p,g=this;if(a!=null&&a!==!!a)return q(a,1,X),c==null?c=l:q(c,0,8),ue(new L(g),a,c);if(!(h=g.c))return null;if(p=h.length-1,v=p*P+1,p=h[p]){for(;p%10==0;p/=10,v--);for(p=h[0];p>=10;p/=10,v++);}return a&&g.e+1>v&&(v=g.e+1),v},s.shiftedBy=function(a){return q(a,-ei,ei),this.times("1e"+a)},s.squareRoot=s.sqrt=function(){var a,c,h,v,p,g=this,E=g.c,d=g.s,m=g.e,b=o+4,y=new L("0.5");if(d!==1||!E||!E[0])return new L(!d||d<0&&(!E||E[0])?NaN:E?g:1/0);if(d=Math.sqrt(+xe(g)),d==0||d==1/0?(c=he(E),(c.length+m)%2==0&&(c+="0"),d=Math.sqrt(+c),m=ce((m+1)/2)-(m<0||m%2),d==1/0?c="5e"+m:(c=d.toExponential(),c=c.slice(0,c.indexOf("e")+1)+m),h=new L(c)):h=new L(d+""),h.c[0]){for(m=h.e,d=m+b,d<3&&(d=0);;)if(p=h,h=y.times(p.plus(e(g,p,b,1))),he(p.c).slice(0,d)===(c=he(h.c)).slice(0,d))if(h.e<m&&--d,c=c.slice(d-3,d+1),c=="9999"||!v&&c=="4999"){if(!v&&(ue(p,p.e+o+2,0),p.times(p).eq(g))){h=p;break}b+=4,d+=4,v=1}else{(!+c||!+c.slice(1)&&c.charAt(0)=="5")&&(ue(h,h.e+o+2,1),a=!h.times(h).eq(g));break}}return ue(h,h.e+o+1,l,a)},s.toExponential=function(a,c){return a!=null&&(q(a,0,X),a++),Q(this,a,c,1)},s.toFixed=function(a,c){return a!=null&&(q(a,0,X),a=a+this.e+1),Q(this,a,c)},s.toFormat=function(a,c,h){var v,p=this;if(h==null)a!=null&&c&&typeof c=="object"?(h=c,c=null):a&&typeof a=="object"?(h=a,a=c=null):h=R;else if(typeof h!="object")throw Error(re+"Argument not an object: "+h);if(v=p.toFixed(a,c),p.c){var g,E=v.split("."),d=+h.groupSize,m=+h.secondaryGroupSize,b=h.groupSeparator||"",y=E[0],S=E[1],A=p.s<0,k=A?y.slice(1):y,D=k.length;if(m&&(g=d,d=m,m=g,D-=g),d>0&&D>0){for(g=D%d||d,y=k.substr(0,g);g<D;g+=d)y+=b+k.substr(g,d);m>0&&(y+=b+k.slice(g)),A&&(y="-"+y)}v=S?y+(h.decimalSeparator||"")+((m=+h.fractionGroupSize)?S.replace(new RegExp("\\d{"+m+"}\\B","g"),"$&"+(h.fractionGroupSeparator||"")):S):y}return(h.prefix||"")+v+(h.suffix||"")},s.toFraction=function(a){var c,h,v,p,g,E,d,m,b,y,S,A,k=this,D=k.c;if(a!=null&&(d=new L(a),!d.isInteger()&&(d.c||d.s!==1)||d.lt(n)))throw Error(re+"Argument "+(d.isInteger()?"out of range: ":"not an integer: ")+xe(d));if(!D)return new L(k);for(c=new L(n),b=h=new L(n),v=m=new L(n),A=he(D),g=c.e=A.length-k.e-1,c.c[0]=ti[(E=g%P)<0?P+E:E],a=!a||d.comparedTo(c)>0?g>0?c:b:d,E=w,w=1/0,d=new L(A),m.c[0]=0;y=e(d,c,0,1),p=h.plus(y.times(v)),p.comparedTo(a)!=1;)h=v,v=p,b=m.plus(y.times(p=b)),m=p,c=d.minus(y.times(p=c)),d=p;return p=e(a.minus(h),v,0,1),m=m.plus(p.times(b)),h=h.plus(p.times(v)),m.s=b.s=k.s,g=g*2,S=e(b,v,g,l).minus(k).abs().comparedTo(e(m,h,g,l).minus(k).abs())<1?[b,v]:[m,h],w=E,S},s.toNumber=function(){return+xe(this)},s.toPrecision=function(a,c){return a!=null&&q(a,1,X),Q(this,a,c,2)},s.toString=function(a){var c,h=this,v=h.s,p=h.e;return p===null?v?(c="Infinity",v<0&&(c="-"+c)):c="NaN":(a==null?c=p<=u||p>=f?wt(he(h.c),p):Ee(he(h.c),p,"0"):a===10&&G?(h=ue(new L(h),o+p+1,l),c=Ee(he(h.c),h.e,"0")):(q(a,2,U.length,"Base"),c=t(Ee(he(h.c),p,"0"),10,a,v,!0)),v<0&&h.c[0]&&(c="-"+c)),c},s.valueOf=s.toJSON=function(){return xe(this)},s._isBigNumber=!0,s[Symbol.toStringTag]="BigNumber",s[Symbol.for("nodejs.util.inspect.custom")]=s.valueOf,i!=null&&L.set(i),L}function ce(i){var e=i|0;return i>0||i===e?e:e-1}function he(i){for(var e,t,r=1,s=i.length,n=i[0]+"";r<s;){for(e=i[r++]+"",t=P-e.length;t--;e="0"+e);n+=e}for(s=n.length;n.charCodeAt(--s)===48;);return n.slice(0,s+1||1)}function Ne(i,e){var t,r,s=i.c,n=e.c,o=i.s,l=e.s,u=i.e,f=e.e;if(!o||!l)return null;if(t=s&&!s[0],r=n&&!n[0],t||r)return t?r?0:-l:o;if(o!=l)return o;if(t=o<0,r=u==f,!s||!n)return r?0:!s^t?1:-1;if(!r)return u>f^t?1:-1;for(l=(u=s.length)<(f=n.length)?u:f,o=0;o<l;o++)if(s[o]!=n[o])return s[o]>n[o]^t?1:-1;return u==f?0:u>f^t?1:-1}function q(i,e,t,r){if(i<e||i>t||i!==ae(i))throw Error(re+(r||"Argument")+(typeof i=="number"?i<e||i>t?" out of range: ":" not an integer: ":" not a primitive number: ")+String(i))}function Et(i){var e=i.c.length-1;return ce(i.e/P)==e&&i.c[e]%2!=0}function wt(i,e){return(i.length>1?i.charAt(0)+"."+i.slice(1):i)+(e<0?"e":"e+")+e}function Ee(i,e,t){var r,s;if(e<0){for(s=t+".";++e;s+=t);i=s+i}else if(r=i.length,++e>r){for(s=t,e-=r;--e;s+=t);i+=s}else e<r&&(i=i.slice(0,e)+"."+i.slice(e));return i}var me=ir(),Os=class{key;left=null;right=null;constructor(i){this.key=i}},tt=class extends Os{constructor(i){super(i)}},Is=class{size=0;modificationCount=0;splayCount=0;splay(i){const e=this.root;if(e==null)return this.compare(i,i),-1;let t=null,r=null,s=null,n=null,o=e;const l=this.compare;let u;for(;;)if(u=l(o.key,i),u>0){let f=o.left;if(f==null||(u=l(f.key,i),u>0&&(o.left=f.right,f.right=o,o=f,f=o.left,f==null)))break;t==null?r=o:t.left=o,t=o,o=f}else if(u<0){let f=o.right;if(f==null||(u=l(f.key,i),u<0&&(o.right=f.left,f.left=o,o=f,f=o.right,f==null)))break;s==null?n=o:s.right=o,s=o,o=f}else break;return s!=null&&(s.right=o.left,o.left=n),t!=null&&(t.left=o.right,o.right=r),this.root!==o&&(this.root=o,this.splayCount++),u}splayMin(i){let e=i,t=e.left;for(;t!=null;){const r=t;e.left=r.right,r.right=e,e=r,t=e.left}return e}splayMax(i){let e=i,t=e.right;for(;t!=null;){const r=t;e.right=r.left,r.left=e,e=r,t=e.right}return e}_delete(i){if(this.root==null||this.splay(i)!=0)return null;let t=this.root;const r=t,s=t.left;if(this.size--,s==null)this.root=t.right;else{const n=t.right;t=this.splayMax(s),t.right=n,this.root=t}return this.modificationCount++,r}addNewRoot(i,e){this.size++,this.modificationCount++;const t=this.root;if(t==null){this.root=i;return}e<0?(i.left=t,i.right=t.right,t.right=null):(i.right=t,i.left=t.left,t.left=null),this.root=i}_first(){const i=this.root;return i==null?null:(this.root=this.splayMin(i),this.root)}_last(){const i=this.root;return i==null?null:(this.root=this.splayMax(i),this.root)}clear(){this.root=null,this.size=0,this.modificationCount++}has(i){return this.validKey(i)&&this.splay(i)==0}defaultCompare(){return(i,e)=>i<e?-1:i>e?1:0}wrap(){return{getRoot:()=>this.root,setRoot:i=>{this.root=i},getSize:()=>this.size,getModificationCount:()=>this.modificationCount,getSplayCount:()=>this.splayCount,setSplayCount:i=>{this.splayCount=i},splay:i=>this.splay(i),has:i=>this.has(i)}}},xt=class ot extends Is{root=null;compare;validKey;constructor(e,t){super(),this.compare=e??this.defaultCompare(),this.validKey=t??(r=>r!=null&&r!=null)}delete(e){return this.validKey(e)?this._delete(e)!=null:!1}deleteAll(e){for(const t of e)this.delete(t)}forEach(e){const t=this[Symbol.iterator]();let r;for(;r=t.next(),!r.done;)e(r.value,r.value,this)}add(e){const t=this.splay(e);return t!=0&&this.addNewRoot(new tt(e),t),this}addAndReturn(e){const t=this.splay(e);return t!=0&&this.addNewRoot(new tt(e),t),this.root.key}addAll(e){for(const t of e)this.add(t)}isEmpty(){return this.root==null}isNotEmpty(){return this.root!=null}single(){if(this.size==0)throw"Bad state: No element";if(this.size>1)throw"Bad state: Too many element";return this.root.key}first(){if(this.size==0)throw"Bad state: No element";return this._first().key}last(){if(this.size==0)throw"Bad state: No element";return this._last().key}lastBefore(e){if(e==null)throw"Invalid arguments(s)";if(this.root==null)return null;if(this.splay(e)<0)return this.root.key;let r=this.root.left;if(r==null)return null;let s=r.right;for(;s!=null;)r=s,s=r.right;return r.key}firstAfter(e){if(e==null)throw"Invalid arguments(s)";if(this.root==null)return null;if(this.splay(e)>0)return this.root.key;let r=this.root.right;if(r==null)return null;let s=r.left;for(;s!=null;)r=s,s=r.left;return r.key}retainAll(e){const t=new ot(this.compare,this.validKey),r=this.modificationCount;for(const s of e){if(r!=this.modificationCount)throw"Concurrent modification during iteration.";this.validKey(s)&&this.splay(s)==0&&t.add(this.root.key)}t.size!=this.size&&(this.root=t.root,this.size=t.size,this.modificationCount++)}lookup(e){return!this.validKey(e)||this.splay(e)!=0?null:this.root.key}intersection(e){const t=new ot(this.compare,this.validKey);for(const r of this)e.has(r)&&t.add(r);return t}difference(e){const t=new ot(this.compare,this.validKey);for(const r of this)e.has(r)||t.add(r);return t}union(e){const t=this.clone();return t.addAll(e),t}clone(){const e=new ot(this.compare,this.validKey);return e.size=this.size,e.root=this.copyNode(this.root),e}copyNode(e){if(e==null)return null;function t(s,n){let o,l;do{if(o=s.left,l=s.right,o!=null){const u=new tt(o.key);n.left=u,t(o,u)}if(l!=null){const u=new tt(l.key);n.right=u,s=l,n=u}}while(l!=null)}const r=new tt(e.key);return t(e,r),r}toSet(){return this.clone()}entries(){return new Ps(this.wrap())}keys(){return this[Symbol.iterator]()}undefined(){return this[Symbol.iterator]()}[Symbol.iterator](){return new Ns(this.wrap())}[Symbol.toStringTag]="[object Set]"},rr=class{tree;path=new Array;modificationCount=null;splayCount;constructor(i){this.tree=i,this.splayCount=i.getSplayCount()}[Symbol.iterator](){return this}next(){return this.moveNext()?{done:!1,value:this.current()}:{done:!0,value:null}}current(){if(!this.path.length)return null;const i=this.path[this.path.length-1];return this.getValue(i)}rebuildPath(i){this.path.splice(0,this.path.length),this.tree.splay(i),this.path.push(this.tree.getRoot()),this.splayCount=this.tree.getSplayCount()}findLeftMostDescendent(i){for(;i!=null;)this.path.push(i),i=i.left}moveNext(){if(this.modificationCount!=this.tree.getModificationCount()){if(this.modificationCount==null){this.modificationCount=this.tree.getModificationCount();let t=this.tree.getRoot();for(;t!=null;)this.path.push(t),t=t.left;return this.path.length>0}throw"Concurrent modification during iteration."}if(!this.path.length)return!1;this.splayCount!=this.tree.getSplayCount()&&this.rebuildPath(this.path[this.path.length-1].key);let i=this.path[this.path.length-1],e=i.right;if(e!=null){for(;e!=null;)this.path.push(e),e=e.left;return!0}for(this.path.pop();this.path.length&&this.path[this.path.length-1].right===i;)i=this.path.pop();return this.path.length>0}},Ns=class extends rr{getValue(i){return i.key}},Ps=class extends rr{getValue(i){return[i.key,i.key]}},sr=i=>()=>i,ii=i=>{const e=i?(t,r)=>r.minus(t).abs().isLessThanOrEqualTo(i):sr(!1);return(t,r)=>e(t,r)?0:t.comparedTo(r)};function Rs(i){const e=i?(t,r,s,n,o)=>t.exponentiatedBy(2).isLessThanOrEqualTo(n.minus(r).exponentiatedBy(2).plus(o.minus(s).exponentiatedBy(2)).times(i)):sr(!1);return(t,r,s)=>{const n=t.x,o=t.y,l=s.x,u=s.y,f=o.minus(u).times(r.x.minus(l)).minus(n.minus(l).times(r.y.minus(u)));return e(f,n,o,l,u)?0:f.comparedTo(0)}}var Gs=i=>i,Us=i=>{if(i){const e=new xt(ii(i)),t=new xt(ii(i)),r=(n,o)=>o.addAndReturn(n),s=n=>({x:r(n.x,e),y:r(n.y,t)});return s({x:new me(0),y:new me(0)}),s}return Gs},ri=i=>({set:e=>{we=ri(e)},reset:()=>ri(i),compare:ii(i),snap:Us(i),orient:Rs(i)}),we=ri(),it=(i,e)=>i.ll.x.isLessThanOrEqualTo(e.x)&&e.x.isLessThanOrEqualTo(i.ur.x)&&i.ll.y.isLessThanOrEqualTo(e.y)&&e.y.isLessThanOrEqualTo(i.ur.y),si=(i,e)=>{if(e.ur.x.isLessThan(i.ll.x)||i.ur.x.isLessThan(e.ll.x)||e.ur.y.isLessThan(i.ll.y)||i.ur.y.isLessThan(e.ll.y))return null;const t=i.ll.x.isLessThan(e.ll.x)?e.ll.x:i.ll.x,r=i.ur.x.isLessThan(e.ur.x)?i.ur.x:e.ur.x,s=i.ll.y.isLessThan(e.ll.y)?e.ll.y:i.ll.y,n=i.ur.y.isLessThan(e.ur.y)?i.ur.y:e.ur.y;return{ll:{x:t,y:s},ur:{x:r,y:n}}},St=(i,e)=>i.x.times(e.y).minus(i.y.times(e.x)),nr=(i,e)=>i.x.times(e.x).plus(i.y.times(e.y)),Lt=i=>nr(i,i).sqrt(),Fs=(i,e,t)=>{const r={x:e.x.minus(i.x),y:e.y.minus(i.y)},s={x:t.x.minus(i.x),y:t.y.minus(i.y)};return St(s,r).div(Lt(s)).div(Lt(r))},Bs=(i,e,t)=>{const r={x:e.x.minus(i.x),y:e.y.minus(i.y)},s={x:t.x.minus(i.x),y:t.y.minus(i.y)};return nr(s,r).div(Lt(s)).div(Lt(r))},or=(i,e,t)=>e.y.isZero()?null:{x:i.x.plus(e.x.div(e.y).times(t.minus(i.y))),y:t},lr=(i,e,t)=>e.x.isZero()?null:{x:t,y:i.y.plus(e.y.div(e.x).times(t.minus(i.x)))},Ds=(i,e,t,r)=>{if(e.x.isZero())return lr(t,r,i.x);if(r.x.isZero())return lr(i,e,t.x);if(e.y.isZero())return or(t,r,i.y);if(r.y.isZero())return or(i,e,t.y);const s=St(e,r);if(s.isZero())return null;const n={x:t.x.minus(i.x),y:t.y.minus(i.y)},o=St(n,e).div(s),l=St(n,r).div(s),u=i.x.plus(l.times(e.x)),f=t.x.plus(o.times(r.x)),x=i.y.plus(l.times(e.y)),w=t.y.plus(o.times(r.y)),_=u.plus(f).div(2),M=x.plus(w).div(2);return{x:_,y:M}},ge=class vr{point;isLeft;segment;otherSE;consumedBy;static compare(e,t){const r=vr.comparePoints(e.point,t.point);return r!==0?r:(e.point!==t.point&&e.link(t),e.isLeft!==t.isLeft?e.isLeft?1:-1:$t.compare(e.segment,t.segment))}static comparePoints(e,t){return e.x.isLessThan(t.x)?-1:e.x.isGreaterThan(t.x)?1:e.y.isLessThan(t.y)?-1:e.y.isGreaterThan(t.y)?1:0}constructor(e,t){e.events===void 0?e.events=[this]:e.events.push(this),this.point=e,this.isLeft=t}link(e){if(e.point===this.point)throw new Error("Tried to link already linked events");const t=e.point.events;for(let r=0,s=t.length;r<s;r++){const n=t[r];this.point.events.push(n),n.point=this.point}this.checkForConsuming()}checkForConsuming(){const e=this.point.events.length;for(let t=0;t<e;t++){const r=this.point.events[t];if(r.segment.consumedBy===void 0)for(let s=t+1;s<e;s++){const n=this.point.events[s];n.consumedBy===void 0&&r.otherSE.point.events===n.otherSE.point.events&&r.segment.consume(n.segment)}}}getAvailableLinkedEvents(){const e=[];for(let t=0,r=this.point.events.length;t<r;t++){const s=this.point.events[t];s!==this&&!s.segment.ringOut&&s.segment.isInResult()&&e.push(s)}return e}getLeftmostComparator(e){const t=new Map,r=s=>{const n=s.otherSE;t.set(s,{sine:Fs(this.point,e.point,n.point),cosine:Bs(this.point,e.point,n.point)})};return(s,n)=>{t.has(s)||r(s),t.has(n)||r(n);const{sine:o,cosine:l}=t.get(s),{sine:u,cosine:f}=t.get(n);return o.isGreaterThanOrEqualTo(0)&&u.isGreaterThanOrEqualTo(0)?l.isLessThan(f)?1:l.isGreaterThan(f)?-1:0:o.isLessThan(0)&&u.isLessThan(0)?l.isLessThan(f)?-1:l.isGreaterThan(f)?1:0:u.isLessThan(o)?-1:u.isGreaterThan(o)?1:0}}},Ws=class hi{events;poly;_isExteriorRing;_enclosingRing;static factory(e){const t=[];for(let r=0,s=e.length;r<s;r++){const n=e[r];if(!n.isInResult()||n.ringOut)continue;let o=null,l=n.leftSE,u=n.rightSE;const f=[l],x=l.point,w=[];for(;o=l,l=u,f.push(l),l.point!==x;)for(;;){const _=l.getAvailableLinkedEvents();if(_.length===0){const R=f[0].point,U=f[f.length-1].point;throw new Error(`Unable to complete output ring starting at [${R.x}, ${R.y}]. Last matching segment found ends at [${U.x}, ${U.y}].`)}if(_.length===1){u=_[0].otherSE;break}let M=null;for(let R=0,U=w.length;R<U;R++)if(w[R].point===l.point){M=R;break}if(M!==null){const R=w.splice(M)[0],U=f.splice(R.index);U.unshift(U[0].otherSE),t.push(new hi(U.reverse()));continue}w.push({index:f.length,point:l.point});const T=l.getLeftmostComparator(o);u=_.sort(T)[0].otherSE;break}t.push(new hi(f))}return t}constructor(e){this.events=e;for(let t=0,r=e.length;t<r;t++)e[t].segment.ringOut=this;this.poly=null}getGeom(){let e=this.events[0].point;const t=[e];for(let f=1,x=this.events.length-1;f<x;f++){const w=this.events[f].point,_=this.events[f+1].point;we.orient(w,e,_)!==0&&(t.push(w),e=w)}if(t.length===1)return null;const r=t[0],s=t[1];we.orient(r,e,s)===0&&t.shift(),t.push(t[0]);const n=this.isExteriorRing()?1:-1,o=this.isExteriorRing()?0:t.length-1,l=this.isExteriorRing()?t.length:-1,u=[];for(let f=o;f!=l;f+=n)u.push([t[f].x.toNumber(),t[f].y.toNumber()]);return u}isExteriorRing(){if(this._isExteriorRing===void 0){const e=this.enclosingRing();this._isExteriorRing=e?!e.isExteriorRing():!0}return this._isExteriorRing}enclosingRing(){return this._enclosingRing===void 0&&(this._enclosingRing=this._calcEnclosingRing()),this._enclosingRing}_calcEnclosingRing(){let e=this.events[0];for(let s=1,n=this.events.length;s<n;s++){const o=this.events[s];ge.compare(e,o)>0&&(e=o)}let t=e.segment.prevInResult(),r=t?t.prevInResult():null;for(;;){if(!t)return null;if(!r)return t.ringOut;if(r.ringOut!==t.ringOut)return r.ringOut?.enclosingRing()!==t.ringOut?t.ringOut:t.ringOut?.enclosingRing();t=r.prevInResult(),r=t?t.prevInResult():null}}},ar=class{exteriorRing;interiorRings;constructor(i){this.exteriorRing=i,i.poly=this,this.interiorRings=[]}addInterior(i){this.interiorRings.push(i),i.poly=this}getGeom(){const i=this.exteriorRing.getGeom();if(i===null)return null;const e=[i];for(let t=0,r=this.interiorRings.length;t<r;t++){const s=this.interiorRings[t].getGeom();s!==null&&e.push(s)}return e}},zs=class{rings;polys;constructor(i){this.rings=i,this.polys=this._composePolys(i)}getGeom(){const i=[];for(let e=0,t=this.polys.length;e<t;e++){const r=this.polys[e].getGeom();r!==null&&i.push(r)}return i}_composePolys(i){const e=[];for(let t=0,r=i.length;t<r;t++){const s=i[t];if(!s.poly)if(s.isExteriorRing())e.push(new ar(s));else{const n=s.enclosingRing();n?.poly||e.push(new ar(n)),n?.poly?.addInterior(s)}}return e}},qs=class{queue;tree;segments;constructor(i,e=$t.compare){this.queue=i,this.tree=new xt(e),this.segments=[]}process(i){const e=i.segment,t=[];if(i.consumedBy)return i.isLeft?this.queue.delete(i.otherSE):this.tree.delete(e),t;i.isLeft&&this.tree.add(e);let r=e,s=e;do r=this.tree.lastBefore(r);while(r!=null&&r.consumedBy!=null);do s=this.tree.firstAfter(s);while(s!=null&&s.consumedBy!=null);if(i.isLeft){let n=null;if(r){const l=r.getIntersection(e);if(l!==null&&(e.isAnEndpoint(l)||(n=l),!r.isAnEndpoint(l))){const u=this._splitSafely(r,l);for(let f=0,x=u.length;f<x;f++)t.push(u[f])}}let o=null;if(s){const l=s.getIntersection(e);if(l!==null&&(e.isAnEndpoint(l)||(o=l),!s.isAnEndpoint(l))){const u=this._splitSafely(s,l);for(let f=0,x=u.length;f<x;f++)t.push(u[f])}}if(n!==null||o!==null){let l=null;n===null?l=o:o===null?l=n:l=ge.comparePoints(n,o)<=0?n:o,this.queue.delete(e.rightSE),t.push(e.rightSE);const u=e.split(l);for(let f=0,x=u.length;f<x;f++)t.push(u[f])}t.length>0?(this.tree.delete(e),t.push(i)):(this.segments.push(e),e.prev=r)}else{if(r&&s){const n=r.getIntersection(s);if(n!==null){if(!r.isAnEndpoint(n)){const o=this._splitSafely(r,n);for(let l=0,u=o.length;l<u;l++)t.push(o[l])}if(!s.isAnEndpoint(n)){const o=this._splitSafely(s,n);for(let l=0,u=o.length;l<u;l++)t.push(o[l])}}}this.tree.delete(e)}return t}_splitSafely(i,e){this.tree.delete(i);const t=i.rightSE;this.queue.delete(t);const r=i.split(e);return r.push(t),i.consumedBy===void 0&&this.tree.add(i),r}},Hs=class{type;numMultiPolys;run(i,e,t){rt.type=i;const r=[new hr(e,!0)];for(let f=0,x=t.length;f<x;f++)r.push(new hr(t[f],!1));if(rt.numMultiPolys=r.length,rt.type==="difference"){const f=r[0];let x=1;for(;x<r.length;)si(r[x].bbox,f.bbox)!==null?x++:r.splice(x,1)}if(rt.type==="intersection")for(let f=0,x=r.length;f<x;f++){const w=r[f];for(let _=f+1,M=r.length;_<M;_++)if(si(w.bbox,r[_].bbox)===null)return[]}const s=new xt(ge.compare);for(let f=0,x=r.length;f<x;f++){const w=r[f].getSweepEvents();for(let _=0,M=w.length;_<M;_++)s.add(w[_])}const n=new qs(s);let o=null;for(s.size!=0&&(o=s.first(),s.delete(o));o;){const f=n.process(o);for(let x=0,w=f.length;x<w;x++){const _=f[x];_.consumedBy===void 0&&s.add(_)}s.size!=0?(o=s.first(),s.delete(o)):o=null}we.reset();const l=Ws.factory(n.segments);return new zs(l).getGeom()}},rt=new Hs,_t=rt,js=0,$t=class Tt{id;leftSE;rightSE;rings;windings;ringOut;consumedBy;prev;_prevInResult;_beforeState;_afterState;_isInResult;static compare(e,t){const r=e.leftSE.point.x,s=t.leftSE.point.x,n=e.rightSE.point.x,o=t.rightSE.point.x;if(o.isLessThan(r))return 1;if(n.isLessThan(s))return-1;const l=e.leftSE.point.y,u=t.leftSE.point.y,f=e.rightSE.point.y,x=t.rightSE.point.y;if(r.isLessThan(s)){if(u.isLessThan(l)&&u.isLessThan(f))return 1;if(u.isGreaterThan(l)&&u.isGreaterThan(f))return-1;const w=e.comparePoint(t.leftSE.point);if(w<0)return 1;if(w>0)return-1;const _=t.comparePoint(e.rightSE.point);return _!==0?_:-1}if(r.isGreaterThan(s)){if(l.isLessThan(u)&&l.isLessThan(x))return-1;if(l.isGreaterThan(u)&&l.isGreaterThan(x))return 1;const w=t.comparePoint(e.leftSE.point);if(w!==0)return w;const _=e.comparePoint(t.rightSE.point);return _<0?1:_>0?-1:1}if(l.isLessThan(u))return-1;if(l.isGreaterThan(u))return 1;if(n.isLessThan(o)){const w=t.comparePoint(e.rightSE.point);if(w!==0)return w}if(n.isGreaterThan(o)){const w=e.comparePoint(t.rightSE.point);if(w<0)return 1;if(w>0)return-1}if(!n.eq(o)){const w=f.minus(l),_=n.minus(r),M=x.minus(u),T=o.minus(s);if(w.isGreaterThan(_)&&M.isLessThan(T))return 1;if(w.isLessThan(_)&&M.isGreaterThan(T))return-1}return n.isGreaterThan(o)?1:n.isLessThan(o)||f.isLessThan(x)?-1:f.isGreaterThan(x)?1:e.id<t.id?-1:e.id>t.id?1:0}constructor(e,t,r,s){this.id=++js,this.leftSE=e,e.segment=this,e.otherSE=t,this.rightSE=t,t.segment=this,t.otherSE=e,this.rings=r,this.windings=s}static fromRing(e,t,r){let s,n,o;const l=ge.comparePoints(e,t);if(l<0)s=e,n=t,o=1;else if(l>0)s=t,n=e,o=-1;else throw new Error(`Tried to create degenerate segment at [${e.x}, ${e.y}]`);const u=new ge(s,!0),f=new ge(n,!1);return new Tt(u,f,[r],[o])}replaceRightSE(e){this.rightSE=e,this.rightSE.segment=this,this.rightSE.otherSE=this.leftSE,this.leftSE.otherSE=this.rightSE}bbox(){const e=this.leftSE.point.y,t=this.rightSE.point.y;return{ll:{x:this.leftSE.point.x,y:e.isLessThan(t)?e:t},ur:{x:this.rightSE.point.x,y:e.isGreaterThan(t)?e:t}}}vector(){return{x:this.rightSE.point.x.minus(this.leftSE.point.x),y:this.rightSE.point.y.minus(this.leftSE.point.y)}}isAnEndpoint(e){return e.x.eq(this.leftSE.point.x)&&e.y.eq(this.leftSE.point.y)||e.x.eq(this.rightSE.point.x)&&e.y.eq(this.rightSE.point.y)}comparePoint(e){return we.orient(this.leftSE.point,e,this.rightSE.point)}getIntersection(e){const t=this.bbox(),r=e.bbox(),s=si(t,r);if(s===null)return null;const n=this.leftSE.point,o=this.rightSE.point,l=e.leftSE.point,u=e.rightSE.point,f=it(t,l)&&this.comparePoint(l)===0,x=it(r,n)&&e.comparePoint(n)===0,w=it(t,u)&&this.comparePoint(u)===0,_=it(r,o)&&e.comparePoint(o)===0;if(x&&f)return _&&!w?o:!_&&w?u:null;if(x)return w&&n.x.eq(u.x)&&n.y.eq(u.y)?null:n;if(f)return _&&o.x.eq(l.x)&&o.y.eq(l.y)?null:l;if(_&&w)return null;if(_)return o;if(w)return u;const M=Ds(n,this.vector(),l,e.vector());return M===null||!it(s,M)?null:we.snap(M)}split(e){const t=[],r=e.events!==void 0,s=new ge(e,!0),n=new ge(e,!1),o=this.rightSE;this.replaceRightSE(n),t.push(n),t.push(s);const l=new Tt(s,o,this.rings.slice(),this.windings.slice());return ge.comparePoints(l.leftSE.point,l.rightSE.point)>0&&l.swapEvents(),ge.comparePoints(this.leftSE.point,this.rightSE.point)>0&&this.swapEvents(),r&&(s.checkForConsuming(),n.checkForConsuming()),t}swapEvents(){const e=this.rightSE;this.rightSE=this.leftSE,this.leftSE=e,this.leftSE.isLeft=!0,this.rightSE.isLeft=!1;for(let t=0,r=this.windings.length;t<r;t++)this.windings[t]*=-1}consume(e){let t=this,r=e;for(;t.consumedBy;)t=t.consumedBy;for(;r.consumedBy;)r=r.consumedBy;const s=Tt.compare(t,r);if(s!==0){if(s>0){const n=t;t=r,r=n}if(t.prev===r){const n=t;t=r,r=n}for(let n=0,o=r.rings.length;n<o;n++){const l=r.rings[n],u=r.windings[n],f=t.rings.indexOf(l);f===-1?(t.rings.push(l),t.windings.push(u)):t.windings[f]+=u}r.rings=null,r.windings=null,r.consumedBy=t,r.leftSE.consumedBy=t.leftSE,r.rightSE.consumedBy=t.rightSE}}prevInResult(){return this._prevInResult!==void 0?this._prevInResult:(this.prev?this.prev.isInResult()?this._prevInResult=this.prev:this._prevInResult=this.prev.prevInResult():this._prevInResult=null,this._prevInResult)}beforeState(){if(this._beforeState!==void 0)return this._beforeState;if(!this.prev)this._beforeState={rings:[],windings:[],multiPolys:[]};else{const e=this.prev.consumedBy||this.prev;this._beforeState=e.afterState()}return this._beforeState}afterState(){if(this._afterState!==void 0)return this._afterState;const e=this.beforeState();this._afterState={rings:e.rings.slice(0),windings:e.windings.slice(0),multiPolys:[]};const t=this._afterState.rings,r=this._afterState.windings,s=this._afterState.multiPolys;for(let l=0,u=this.rings.length;l<u;l++){const f=this.rings[l],x=this.windings[l],w=t.indexOf(f);w===-1?(t.push(f),r.push(x)):r[w]+=x}const n=[],o=[];for(let l=0,u=t.length;l<u;l++){if(r[l]===0)continue;const f=t[l],x=f.poly;if(o.indexOf(x)===-1)if(f.isExterior)n.push(x);else{o.indexOf(x)===-1&&o.push(x);const w=n.indexOf(f.poly);w!==-1&&n.splice(w,1)}}for(let l=0,u=n.length;l<u;l++){const f=n[l].multiPoly;s.indexOf(f)===-1&&s.push(f)}return this._afterState}isInResult(){if(this.consumedBy)return!1;if(this._isInResult!==void 0)return this._isInResult;const e=this.beforeState().multiPolys,t=this.afterState().multiPolys;switch(_t.type){case"union":{const r=e.length===0,s=t.length===0;this._isInResult=r!==s;break}case"intersection":{let r,s;e.length<t.length?(r=e.length,s=t.length):(r=t.length,s=e.length),this._isInResult=s===_t.numMultiPolys&&r<s;break}case"xor":{const r=Math.abs(e.length-t.length);this._isInResult=r%2===1;break}case"difference":{const r=s=>s.length===1&&s[0].isSubject;this._isInResult=r(e)!==r(t);break}}return this._isInResult}},cr=class{poly;isExterior;segments;bbox;constructor(i,e,t){if(!Array.isArray(i)||i.length===0)throw new Error("Input geometry is not a valid Polygon or MultiPolygon");if(this.poly=e,this.isExterior=t,this.segments=[],typeof i[0][0]!="number"||typeof i[0][1]!="number")throw new Error("Input geometry is not a valid Polygon or MultiPolygon");const r=we.snap({x:new me(i[0][0]),y:new me(i[0][1])});this.bbox={ll:{x:r.x,y:r.y},ur:{x:r.x,y:r.y}};let s=r;for(let n=1,o=i.length;n<o;n++){if(typeof i[n][0]!="number"||typeof i[n][1]!="number")throw new Error("Input geometry is not a valid Polygon or MultiPolygon");const l=we.snap({x:new me(i[n][0]),y:new me(i[n][1])});l.x.eq(s.x)&&l.y.eq(s.y)||(this.segments.push($t.fromRing(s,l,this)),l.x.isLessThan(this.bbox.ll.x)&&(this.bbox.ll.x=l.x),l.y.isLessThan(this.bbox.ll.y)&&(this.bbox.ll.y=l.y),l.x.isGreaterThan(this.bbox.ur.x)&&(this.bbox.ur.x=l.x),l.y.isGreaterThan(this.bbox.ur.y)&&(this.bbox.ur.y=l.y),s=l)}(!r.x.eq(s.x)||!r.y.eq(s.y))&&this.segments.push($t.fromRing(s,r,this))}getSweepEvents(){const i=[];for(let e=0,t=this.segments.length;e<t;e++){const r=this.segments[e];i.push(r.leftSE),i.push(r.rightSE)}return i}},Vs=class{multiPoly;exteriorRing;interiorRings;bbox;constructor(i,e){if(!Array.isArray(i))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");this.exteriorRing=new cr(i[0],this,!0),this.bbox={ll:{x:this.exteriorRing.bbox.ll.x,y:this.exteriorRing.bbox.ll.y},ur:{x:this.exteriorRing.bbox.ur.x,y:this.exteriorRing.bbox.ur.y}},this.interiorRings=[];for(let t=1,r=i.length;t<r;t++){const s=new cr(i[t],this,!1);s.bbox.ll.x.isLessThan(this.bbox.ll.x)&&(this.bbox.ll.x=s.bbox.ll.x),s.bbox.ll.y.isLessThan(this.bbox.ll.y)&&(this.bbox.ll.y=s.bbox.ll.y),s.bbox.ur.x.isGreaterThan(this.bbox.ur.x)&&(this.bbox.ur.x=s.bbox.ur.x),s.bbox.ur.y.isGreaterThan(this.bbox.ur.y)&&(this.bbox.ur.y=s.bbox.ur.y),this.interiorRings.push(s)}this.multiPoly=e}getSweepEvents(){const i=this.exteriorRing.getSweepEvents();for(let e=0,t=this.interiorRings.length;e<t;e++){const r=this.interiorRings[e].getSweepEvents();for(let s=0,n=r.length;s<n;s++)i.push(r[s])}return i}},hr=class{isSubject;polys;bbox;constructor(i,e){if(!Array.isArray(i))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");try{typeof i[0][0][0]=="number"&&(i=[i])}catch{}this.polys=[],this.bbox={ll:{x:new me(Number.POSITIVE_INFINITY),y:new me(Number.POSITIVE_INFINITY)},ur:{x:new me(Number.NEGATIVE_INFINITY),y:new me(Number.NEGATIVE_INFINITY)}};for(let t=0,r=i.length;t<r;t++){const s=new Vs(i[t],this);s.bbox.ll.x.isLessThan(this.bbox.ll.x)&&(this.bbox.ll.x=s.bbox.ll.x),s.bbox.ll.y.isLessThan(this.bbox.ll.y)&&(this.bbox.ll.y=s.bbox.ll.y),s.bbox.ur.x.isGreaterThan(this.bbox.ur.x)&&(this.bbox.ur.x=s.bbox.ur.x),s.bbox.ur.y.isGreaterThan(this.bbox.ur.y)&&(this.bbox.ur.y=s.bbox.ur.y),this.polys.push(s)}this.isSubject=e}getSweepEvents(){const i=[];for(let e=0,t=this.polys.length;e<t;e++){const r=this.polys[e].getSweepEvents();for(let s=0,n=r.length;s<n;s++)i.push(r[s])}return i}},Zs=(i,...e)=>_t.run("union",i,e),Ks=(i,...e)=>_t.run("difference",i,e);we.set;function ur(i,e,t){if(i!==null)for(var r,s,n,o,l,u,f,x=0,w=0,_,M=i.type,T=M==="FeatureCollection",R=M==="Feature",U=T?i.features.length:1,G=0;G<U;G++){f=T?i.features[G].geometry:R?i.geometry:i,_=f?f.type==="GeometryCollection":!1,l=_?f.geometries.length:1;for(var L=0;L<l;L++){var Q=0,se=0;if(o=_?f.geometries[L]:f,o!==null){u=o.coordinates;var ye=o.type;switch(x=0,ye){case null:break;case"Point":if(e(u,w,G,Q,se)===!1)return!1;w++,Q++;break;case"LineString":case"MultiPoint":for(r=0;r<u.length;r++){if(e(u[r],w,G,Q,se)===!1)return!1;w++,ye==="MultiPoint"&&Q++}ye==="LineString"&&Q++;break;case"Polygon":case"MultiLineString":for(r=0;r<u.length;r++){for(s=0;s<u[r].length-x;s++){if(e(u[r][s],w,G,Q,se)===!1)return!1;w++}ye==="MultiLineString"&&Q++,ye==="Polygon"&&se++}ye==="Polygon"&&Q++;break;case"MultiPolygon":for(r=0;r<u.length;r++){for(se=0,s=0;s<u[r].length;s++){for(n=0;n<u[r][s].length-x;n++){if(e(u[r][s][n],w,G,Q,se)===!1)return!1;w++}se++}Q++}break;case"GeometryCollection":for(r=0;r<o.geometries.length;r++)if(ur(o.geometries[r],e)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function ni(i,e){var t,r,s,n,o,l,u,f,x,w,_=0,M=i.type==="FeatureCollection",T=i.type==="Feature",R=M?i.features.length:1;for(t=0;t<R;t++){for(l=M?i.features[t].geometry:T?i.geometry:i,f=M?i.features[t].properties:T?i.properties:{},x=M?i.features[t].bbox:T?i.bbox:void 0,w=M?i.features[t].id:T?i.id:void 0,u=l?l.type==="GeometryCollection":!1,o=u?l.geometries.length:1,s=0;s<o;s++){if(n=u?l.geometries[s]:l,n===null){if(e(null,_,f,x,w)===!1)return!1;continue}switch(n.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":{if(e(n,_,f,x,w)===!1)return!1;break}case"GeometryCollection":{for(r=0;r<n.geometries.length;r++)if(e(n.geometries[r],_,f,x,w)===!1)return!1;break}default:throw new Error("Unknown Geometry Type")}}_++}}function Ys(i,e){ni(i,function(t,r,s,n,o){var l=t===null?null:t.type;switch(l){case null:case"Point":case"LineString":case"Polygon":return e(Je(t,s,{bbox:n,id:o}),r,0)===!1?!1:void 0}var u;switch(l){case"MultiPoint":u="Point";break;case"MultiLineString":u="LineString";break;case"MultiPolygon":u="Polygon";break}for(var f=0;f<t.coordinates.length;f++){var x=t.coordinates[f],w={type:u,coordinates:x};if(e(Je(w,s),r,f)===!1)return!1}})}function Xs(i,e={}){const t=[];if(ni(i,s=>{t.push(s.coordinates)}),t.length<2)throw new Error("Must have at least 2 geometries");const r=Zs(t[0],...t.slice(1));return r.length===0?null:r.length===1?Qt(r[0],e.properties):er(r,e.properties)}var dr=Xs;function Qs(i,e={}){if(i.bbox!=null&&e.recompute!==!0)return i.bbox;const t=[1/0,1/0,-1/0,-1/0];return ur(i,r=>{t[0]>r[0]&&(t[0]=r[0]),t[1]>r[1]&&(t[1]=r[1]),t[2]<r[0]&&(t[2]=r[0]),t[3]<r[1]&&(t[3]=r[1])}),t}var fr=Qs;function Js(i){const e=[];if(ni(i,s=>{e.push(s.coordinates)}),e.length<2)throw new Error("Must have at least two features");const t=i.features[0].properties||{},r=Ks(e[0],...e.slice(1));return r.length===0?null:r.length===1?Qt(r[0],t):er(r,t)}var en=Js;function tn(i){if(!i)throw new Error("geojson is required");var e=[];return Ys(i,function(t){e.push(t)}),et(e)}var rn=tn;function pr(i){const e=en(et([Qt([[[180,90],[-180,90],[-180,-90],[180,-90],[180,90]]]),i]));if(!e)return;e.properties={isMask:!0};const t=pt(fr(i)),r=(t[2]-t[0])/360/1e3,s=t[0]<-180,n=t[2]>180,o=rn(i);if(o.features.length>1&&(s||n))for(const l of o.features){const u=pt(fr(l));if(n&&u[0]<-180+r)for(const f of l.geometry.coordinates)for(const x of f)x[0]+=360-r;if(s&&u[2]>180-r)for(const f of l.geometry.coordinates)for(const x of f)x[0]-=360-r}return et([o.features.length<2?i:dr(o)??i,e])}const mr={continental_marine:4,country:4,major_landform:8,region:5,subregion:6,county:7,joint_municipality:8,joint_submunicipality:9,municipality:10,municipal_district:11,locality:12,neighbourhood:13,place:14,postal_code:14,road:16,poi:17,address:18,"poi.peak":15,"poi.shop":18,"poi.cafe":18,"poi.restaurant":18,"poi.aerodrome":13},gr={fill:{paint:{"fill-color":"#000","fill-opacity":.1},filter:["all",["==",["geometry-type"],"Polygon"],["has","isMask"]]},line:{layout:{"line-cap":"square"},paint:{"line-width":["case",["==",["geometry-type"],"Polygon"],2,3],"line-dasharray":[1,1],"line-color":"#3170fe"},filter:["!",["has","isMask"]]}},st="mtlr-gc-full-geom",oi="mtlr-gc-full-geom-fill",li="mtlr-gc-full-geom-line",sn=Te.Evented,nn=Te.Marker,on=Te.Popup;class yr extends sn{#e={};#t;#i;constructor(e={}){super(),this.setOptions(e)}onAdd(e){this.#t=e,this.#i=e._container.ownerDocument.createElement("maptiler-geocoder"),this.#i.classList.add("maplibregl-geocoder"),this.#v(),this.#x();const t=e._container.ownerDocument.createElement("div");return t.classList.add("maplibregl-ctrl-geocoder","maplibregl-ctrl","maplibregl-ctrl-group"),t.style.position="relative",t.style.zIndex="3",t.appendChild(this.#i),setTimeout(()=>this.#i?.setOptions({openListOnTop:t.matches(".maplibregl-ctrl-bottom-left *, .maplibregl-ctrl-bottom-right *")})),t}onRemove(){this.#S(),this.#t=void 0,this.#i=void 0}getOptions(){return{...this.#e}}setOptions(e){Object.assign(this.#e,e),this.#v()}setQuery(e){this.#i?.setQuery(e)}submitQuery(e){this.#i?.submitQuery(e)}clearMap(){this.#n=[],this.#u(void 0,void 0)}clearList(){this.#i?.clearList()}setReverseMode(e){this.setOptions({reverseActive:e})}focus(e){this.#i?.focus(e)}blur(){this.#i?.blur()}#l=new Map;#c;#s;#n;#o;#m;#g={reversetoggle:e=>{const t=this.#t?.getCanvasContainer();t&&(t.style.cursor=e.detail.reverse?"crosshair":""),this.#r("reversetoggle",e.detail)},querychange:e=>{const t=e.detail.reverseCoords;this.#w(t?[t.decimalLongitude,t.decimalLatitude]:void 0),this.#r("querychange",e.detail)},queryclear:()=>{this.#w(void 0),this.#r("queryclear")},request:e=>{this.#r("request",e.detail)},response:e=>{this.#r("response",e.detail)},select:e=>{const t=e.detail.feature;t&&this.#d&&this.#e.flyToSelected&&this.#b(t.center,this.#h(t)),this.#n&&t&&this.#T(t),this.#r("select",e.detail)},pick:e=>{const t=e.detail.feature;t&&t.id!==this.#m&&this.#d&&(this.#L(t),this.#u(this.#n,t)),this.#m=t?.id,this.#r("pick",e.detail)},featuresshow:()=>{this.#r("featuresshow")},featureshide:()=>{this.#r("featureshide")},featureslisted:e=>{const t=e.detail.features;this.#n=t,this.#u(this.#n,void 0),this.#_(e),this.#r("featureslisted",e.detail)},featuresclear:()=>{this.#n=void 0,this.#u(void 0,void 0),this.#r("featuresclear")},focusin:()=>{this.#r("focusin")},focusout:()=>{this.#r("focusout")}};#y={render:()=>{const e=this.#t?.getZoom(),t=this.#t?.getCenter();this.#i?.handleMapChange(e&&t?[e,t.lng,t.lat]:void 0)},click:e=>{this.#i?.handleMapClick([e.lngLat.lng,e.lngLat.lat])},styledata:()=>{setTimeout(()=>{this.#o&&this.#f()})}};#v(){this.#i&&(this.#i.setOptions(this.#e),this.#i.fetchFullGeometryOnPick=this.#e.pickedResultStyle!=="marker-only")}#x(){if(!(!this.#i||!this.#t)){for(const[e,t]of Object.entries(this.#g))this.#i.addEventListener(e,t);for(const[e,t]of Object.entries(this.#y))this.#t.on(e,t)}}#S(){if(!(!this.#i||!this.#t)){for(const[e,t]of Object.entries(this.#g))this.#i.removeEventListener(e,t);for(const[e,t]of Object.entries(this.#y))this.#t.off(e,t)}}#r(e,t){return super.fire({type:e,...t??{}})}#L(e){e.bbox[0]===e.bbox[2]&&e.bbox[1]===e.bbox[3]?this.#b(e.center,this.#h(e)):this.#E(pt(e.bbox),50,this.#h(e))}#_({detail:{features:e,external:t}}){if(!e||e.length===0||!this.#d||this.#e.flyToFeatures===!1||this.#e.flyToFeatures==="never"||!t&&(this.#e.flyToFeatures===void 0||this.#e.flyToFeatures==="external"))return;const r=e.every(o=>o.matching_text),s=e.reduce((o,l)=>r||!l.matching_text?[Math.min(o[0],l.bbox[0]),Math.min(o[1],l.bbox[1]),Math.max(o[2],l.bbox[2]),Math.max(o[3],l.bbox[3])]:o,[180,90,-180,-90]),n=e.map(o=>this.#h(o)).filter(o=>o!==void 0).reduce((o,l)=>o===void 0?l:Math.max(o,l),void 0);this.#E(pt(s),50,n)}#h(e){if(e.bbox[0]!==e.bbox[2]||e.bbox[1]!==e.bbox[3])return;const t=e.id.replace(/\..*/,""),r=this.#e.zoom??mr;return(Array.isArray(e.properties?.categories)?e.properties.categories.reduce((s,n)=>{const o=r[t+"."+n];return s===void 0?o:o===void 0?s:Math.max(s,o)},void 0):void 0)??r[t]}get#d(){return!!this.#e.flyTo||this.#e.flyTo===void 0}get#$(){return typeof this.#e.flyTo=="boolean"?{}:this.#e.flyTo}get#M(){return typeof this.#e.flyTo=="boolean"?{}:this.#e.flyTo}#b(e,t){this.#t?.flyTo({center:e,...t?{zoom:t}:{},...this.#$})}#E(e,t,r){this.#t?.fitBounds([[e[0],e[1]],[e[2],e[3]]],{padding:t,...r?{maxZoom:r}:{},...this.#M})}#w(e){if(!(this.#e.marker===!1||this.#e.marker===null||!this.#t)){if(!e){this.#s?.remove(),this.#s=void 0;return}this.#s||(this.#e.marker instanceof Function?this.#s=this.#e.marker(this.#t)??void 0:(this.#s=this.#p(this.#e.marker).setLngLat(e).addTo(this.#t),this.#s.getElement().classList.add("marker-reverse"))),this.#s?.setLngLat(e)}}#u(e,t){if(!this.#t)return;for(const s of this.#l.undefined())s.remove();this.#l=new Map,this.#a(void 0);const r=()=>{if(!t||!this.#t||this.#e.marker===!1||this.#e.marker===null)return;const s=this.#e.marker instanceof Function?this.#e.marker(this.#t,t):this.#p(this.#e.marker).setLngLat(t.center).addTo(this.#t);s&&this.#l.set(t,s)};if(t?.geometry.type==="GeometryCollection"){const s=t.geometry.geometries.filter(n=>n.type==="Polygon"||n.type==="MultiPolygon");if(s.length>0){const n=dr(et(s.map(o=>Je(o))));if(n){const o=pr({...t,geometry:n.geometry});o&&this.#a(o)}}else{const n=t.geometry.geometries.filter(o=>o.type==="LineString"||o.type==="MultiLineString");n.length>0&&this.#a({...t,geometry:{type:"GeometryCollection",geometries:n}})}}else if(t?.geometry.type.endsWith("Polygon")){const s=pr(t);s&&this.#a(s),this.#e.pickedResultStyle==="full-geometry-including-polygon-center-marker"&&r()}else t?.geometry.type.endsWith("LineString")?this.#a(t):t?.geometry.type.endsWith("Point")&&r();if(this.#e.showResultMarkers!==!1&&this.#e.showResultMarkers!==null)for(const s of e??[]){if(s.id===t?.id||s.place_type.includes("reverse"))continue;let n;if(this.#e.showResultMarkers instanceof Function){if(n=this.#e.showResultMarkers(this.#t,s),!n)continue}else n=this.#p(this.#e.showResultMarkers).setLngLat(s.center).setPopup(new on({offset:[1,-27],closeButton:!1,closeOnMove:!0,className:"maptiler-gc-popup"}).setText(s.place_type[0]==="reverse"?s.place_name:s.place_name.replace(/,.*/,""))).addTo(this.#t),n.getElement().classList.add("marker-interactive");const o=n.getElement();o.addEventListener("click",l=>{l.stopPropagation(),this.#r("markerclick",{feature:s,marker:n})}),o.addEventListener("mouseenter",()=>{this.#r("markermouseenter",{feature:s,marker:n}),n.togglePopup()}),o.addEventListener("mouseleave",()=>{this.#r("markermouseleave",{feature:s,marker:n}),n.togglePopup()}),o.classList.toggle("marker-fuzzy",!!s.matching_text),this.#l.set(s,n)}}#T(e){this.#c?.getElement().classList.toggle("marker-selected",!1),this.#c=void 0,this.#e.markerOnSelected!==!1&&(this.#c=this.#l.get(e),this.#c?.getElement().classList.toggle("marker-selected",!0))}#f(){if(!this.#t?.loaded){this.#t?.once("load",()=>{this.#f()});return}const e=this.#A(),t=this.#t.getSource(st);!e?.fill&&!e?.line||!t&&!this.#o||(t?t.setData(this.#o??et([])):this.#o&&this.#t.addSource(st,{type:"geojson",data:this.#o}),!this.#t.getLayer(oi)&&e.fill&&this.#t.addLayer({...e.fill,id:oi,type:"fill",source:st}),!this.#t.getLayer(li)&&e.line&&this.#t.addLayer({...e.line,id:li,type:"line",source:st}))}#a(e){this.#o=e,this.#f()}#p(e){return typeof e!="object"&&(e={element:this.#t?._container.ownerDocument.createElement("maptiler-geocode-marker"),offset:[1,-13]}),new nn(e)}#A(){const{fullGeometryStyle:e}=this.#e;if(e===!0||e===void 0)return gr;if(!(e===!1||e===null))return e}}$.DEFAULT_GEOMETRY_STYLE=gr,$.GeocodingControl=yr,$.MaplibreglGeocodingControl=yr,$.RESULT_LAYER_FILL=oi,$.RESULT_LAYER_LINE=li,$.RESULT_SOURCE=st,$.ZOOM_DEFAULTS=mr,Object.defineProperty($,Symbol.toStringTag,{value:"Module"})}));
280
+ `,$.MaptilerGeocodeMarkerElement=Cs([_e("maptiler-geocode-marker")],$.MaptilerGeocodeMarkerElement);function Je(i,e,t={}){const r={type:"Feature"};return(t.id===0||t.id)&&(r.id=t.id),t.bbox&&(r.bbox=t.bbox),r.properties=e||{},r.geometry=i,r}function Qt(i,e,t={}){for(const s of i){if(s.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");if(s[s.length-1].length!==s[0].length)throw new Error("First and last Position are not equivalent.");for(let n=0;n<s[s.length-1].length;n++)if(s[s.length-1][n]!==s[0][n])throw new Error("First and last Position are not equivalent.")}return Je({type:"Polygon",coordinates:i},e,t)}function et(i,e={}){const t={type:"FeatureCollection"};return e.id&&(t.id=e.id),e.bbox&&(t.bbox=e.bbox),t.features=i,t}function er(i,e,t={}){return Je({type:"MultiPolygon",coordinates:i},e,t)}var ks=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,Jt=Math.ceil,ae=Math.floor,re="[BigNumber Error] ",tr=re+"Number primitive has more than 15 significant digits: ",fe=1e14,P=14,ei=9007199254740991,ti=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],Me=1e7,X=1e9;function ir(i){var e,t,r,s=L.prototype={constructor:L,toString:null,valueOf:null},n=new L(1),o=20,l=4,u=-7,f=21,x=-1e7,w=1e7,_=!1,M=1,T=0,R={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},U="0123456789abcdefghijklmnopqrstuvwxyz",G=!0;function L(a,c){var h,v,p,g,E,d,m,b,y=this;if(!(y instanceof L))return new L(a,c);if(c==null){if(a&&a._isBigNumber===!0){y.s=a.s,!a.c||a.e>w?y.c=y.e=null:a.e<x?y.c=[y.e=0]:(y.e=a.e,y.c=a.c.slice());return}if((d=typeof a=="number")&&a*0==0){if(y.s=1/a<0?(a=-a,-1):1,a===~~a){for(g=0,E=a;E>=10;E/=10,g++);g>w?y.c=y.e=null:(y.e=g,y.c=[a]);return}b=String(a)}else{if(!ks.test(b=String(a)))return r(y,b,d);y.s=b.charCodeAt(0)==45?(b=b.slice(1),-1):1}(g=b.indexOf("."))>-1&&(b=b.replace(".","")),(E=b.search(/e/i))>0?(g<0&&(g=E),g+=+b.slice(E+1),b=b.substring(0,E)):g<0&&(g=b.length)}else{if(q(c,2,U.length,"Base"),c==10&&G)return y=new L(a),ue(y,o+y.e+1,l);if(b=String(a),d=typeof a=="number"){if(a*0!=0)return r(y,b,d,c);if(y.s=1/a<0?(b=b.slice(1),-1):1,L.DEBUG&&b.replace(/^0\.0*|\./,"").length>15)throw Error(tr+a)}else y.s=b.charCodeAt(0)===45?(b=b.slice(1),-1):1;for(h=U.slice(0,c),g=E=0,m=b.length;E<m;E++)if(h.indexOf(v=b.charAt(E))<0){if(v=="."){if(E>g){g=m;continue}}else if(!p&&(b==b.toUpperCase()&&(b=b.toLowerCase())||b==b.toLowerCase()&&(b=b.toUpperCase()))){p=!0,E=-1,g=0;continue}return r(y,String(a),d,c)}d=!1,b=t(b,c,10,y.s),(g=b.indexOf("."))>-1?b=b.replace(".",""):g=b.length}for(E=0;b.charCodeAt(E)===48;E++);for(m=b.length;b.charCodeAt(--m)===48;);if(b=b.slice(E,++m)){if(m-=E,d&&L.DEBUG&&m>15&&(a>ei||a!==ae(a)))throw Error(tr+y.s*a);if((g=g-E-1)>w)y.c=y.e=null;else if(g<x)y.c=[y.e=0];else{if(y.e=g,y.c=[],E=(g+1)%P,g<0&&(E+=P),E<m){for(E&&y.c.push(+b.slice(0,E)),m-=P;E<m;)y.c.push(+b.slice(E,E+=P));E=P-(b=b.slice(E)).length}else E-=m;for(;E--;b+="0");y.c.push(+b)}}else y.c=[y.e=0]}L.clone=ir,L.ROUND_UP=0,L.ROUND_DOWN=1,L.ROUND_CEIL=2,L.ROUND_FLOOR=3,L.ROUND_HALF_UP=4,L.ROUND_HALF_DOWN=5,L.ROUND_HALF_EVEN=6,L.ROUND_HALF_CEIL=7,L.ROUND_HALF_FLOOR=8,L.EUCLID=9,L.config=L.set=function(a){var c,h;if(a!=null)if(typeof a=="object"){if(a.hasOwnProperty(c="DECIMAL_PLACES")&&(h=a[c],q(h,0,X,c),o=h),a.hasOwnProperty(c="ROUNDING_MODE")&&(h=a[c],q(h,0,8,c),l=h),a.hasOwnProperty(c="EXPONENTIAL_AT")&&(h=a[c],h&&h.pop?(q(h[0],-X,0,c),q(h[1],0,X,c),u=h[0],f=h[1]):(q(h,-X,X,c),u=-(f=h<0?-h:h))),a.hasOwnProperty(c="RANGE"))if(h=a[c],h&&h.pop)q(h[0],-X,-1,c),q(h[1],1,X,c),x=h[0],w=h[1];else if(q(h,-X,X,c),h)x=-(w=h<0?-h:h);else throw Error(re+c+" cannot be zero: "+h);if(a.hasOwnProperty(c="CRYPTO"))if(h=a[c],h===!!h)if(h)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))_=h;else throw _=!h,Error(re+"crypto unavailable");else _=h;else throw Error(re+c+" not true or false: "+h);if(a.hasOwnProperty(c="MODULO_MODE")&&(h=a[c],q(h,0,9,c),M=h),a.hasOwnProperty(c="POW_PRECISION")&&(h=a[c],q(h,0,X,c),T=h),a.hasOwnProperty(c="FORMAT"))if(h=a[c],typeof h=="object")R=h;else throw Error(re+c+" not an object: "+h);if(a.hasOwnProperty(c="ALPHABET"))if(h=a[c],typeof h=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(h))G=h.slice(0,10)=="0123456789",U=h;else throw Error(re+c+" invalid: "+h)}else throw Error(re+"Object expected: "+a);return{DECIMAL_PLACES:o,ROUNDING_MODE:l,EXPONENTIAL_AT:[u,f],RANGE:[x,w],CRYPTO:_,MODULO_MODE:M,POW_PRECISION:T,FORMAT:R,ALPHABET:U}},L.isBigNumber=function(a){if(!a||a._isBigNumber!==!0)return!1;if(!L.DEBUG)return!0;var c,h,v=a.c,p=a.e,g=a.s;e:if({}.toString.call(v)=="[object Array]"){if((g===1||g===-1)&&p>=-X&&p<=X&&p===ae(p)){if(v[0]===0){if(p===0&&v.length===1)return!0;break e}if(c=(p+1)%P,c<1&&(c+=P),String(v[0]).length==c){for(c=0;c<v.length;c++)if(h=v[c],h<0||h>=fe||h!==ae(h))break e;if(h!==0)return!0}}}else if(v===null&&p===null&&(g===null||g===1||g===-1))return!0;throw Error(re+"Invalid BigNumber: "+a)},L.maximum=L.max=function(){return se(arguments,-1)},L.minimum=L.min=function(){return se(arguments,1)},L.random=(function(){var a=9007199254740992,c=Math.random()*a&2097151?function(){return ae(Math.random()*a)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(h){var v,p,g,E,d,m=0,b=[],y=new L(n);if(h==null?h=o:q(h,0,X),E=Jt(h/P),_)if(crypto.getRandomValues){for(v=crypto.getRandomValues(new Uint32Array(E*=2));m<E;)d=v[m]*131072+(v[m+1]>>>11),d>=9e15?(p=crypto.getRandomValues(new Uint32Array(2)),v[m]=p[0],v[m+1]=p[1]):(b.push(d%1e14),m+=2);m=E/2}else if(crypto.randomBytes){for(v=crypto.randomBytes(E*=7);m<E;)d=(v[m]&31)*281474976710656+v[m+1]*1099511627776+v[m+2]*4294967296+v[m+3]*16777216+(v[m+4]<<16)+(v[m+5]<<8)+v[m+6],d>=9e15?crypto.randomBytes(7).copy(v,m):(b.push(d%1e14),m+=7);m=E/7}else throw _=!1,Error(re+"crypto unavailable");if(!_)for(;m<E;)d=c(),d<9e15&&(b[m++]=d%1e14);for(E=b[--m],h%=P,E&&h&&(d=ti[P-h],b[m]=ae(E/d)*d);b[m]===0;b.pop(),m--);if(m<0)b=[g=0];else{for(g=-1;b[0]===0;b.splice(0,1),g-=P);for(m=1,d=b[0];d>=10;d/=10,m++);m<P&&(g-=P-m)}return y.e=g,y.c=b,y}})(),L.sum=function(){for(var a=1,c=arguments,h=new L(c[0]);a<c.length;)h=h.plus(c[a++]);return h},t=(function(){var a="0123456789";function c(h,v,p,g){for(var E,d=[0],m,b=0,y=h.length;b<y;){for(m=d.length;m--;d[m]*=v);for(d[0]+=g.indexOf(h.charAt(b++)),E=0;E<d.length;E++)d[E]>p-1&&(d[E+1]==null&&(d[E+1]=0),d[E+1]+=d[E]/p|0,d[E]%=p)}return d.reverse()}return function(h,v,p,g,E){var d,m,b,y,S,A,k,D,H=h.indexOf("."),K=o,F=l;for(H>=0&&(y=T,T=0,h=h.replace(".",""),D=new L(v),A=D.pow(h.length-H),T=y,D.c=c(Ee(he(A.c),A.e,"0"),10,p,a),D.e=D.c.length),k=c(h,v,p,E?(d=U,a):(d=a,U)),b=y=k.length;k[--y]==0;k.pop());if(!k[0])return d.charAt(0);if(H<0?--b:(A.c=k,A.e=b,A.s=g,A=e(A,D,K,F,p),k=A.c,S=A.r,b=A.e),m=b+K+1,H=k[m],y=p/2,S=S||m<0||k[m+1]!=null,S=F<4?(H!=null||S)&&(F==0||F==(A.s<0?3:2)):H>y||H==y&&(F==4||S||F==6&&k[m-1]&1||F==(A.s<0?8:7)),m<1||!k[0])h=S?Ee(d.charAt(1),-K,d.charAt(0)):d.charAt(0);else{if(k.length=m,S)for(--p;++k[--m]>p;)k[m]=0,m||(++b,k=[1].concat(k));for(y=k.length;!k[--y];);for(H=0,h="";H<=y;h+=d.charAt(k[H++]));h=Ee(h,b,d.charAt(0))}return h}})(),e=(function(){function a(v,p,g){var E,d,m,b,y=0,S=v.length,A=p%Me,k=p/Me|0;for(v=v.slice();S--;)m=v[S]%Me,b=v[S]/Me|0,E=k*m+b*A,d=A*m+E%Me*Me+y,y=(d/g|0)+(E/Me|0)+k*b,v[S]=d%g;return y&&(v=[y].concat(v)),v}function c(v,p,g,E){var d,m;if(g!=E)m=g>E?1:-1;else for(d=m=0;d<g;d++)if(v[d]!=p[d]){m=v[d]>p[d]?1:-1;break}return m}function h(v,p,g,E){for(var d=0;g--;)v[g]-=d,d=v[g]<p[g]?1:0,v[g]=d*E+v[g]-p[g];for(;!v[0]&&v.length>1;v.splice(0,1));}return function(v,p,g,E,d){var m,b,y,S,A,k,D,H,K,F,W,J,Mt,ai,ci,ve,nt,de=v.s==p.s?1:-1,ie=v.c,j=p.c;if(!ie||!ie[0]||!j||!j[0])return new L(!v.s||!p.s||(ie?j&&ie[0]==j[0]:!j)?NaN:ie&&ie[0]==0||!j?de*0:de/0);for(H=new L(de),K=H.c=[],b=v.e-p.e,de=g+b+1,d||(d=fe,b=ce(v.e/P)-ce(p.e/P),de=de/P|0),y=0;j[y]==(ie[y]||0);y++);if(j[y]>(ie[y]||0)&&b--,de<0)K.push(1),S=!0;else{for(ai=ie.length,ve=j.length,y=0,de+=2,A=ae(d/(j[0]+1)),A>1&&(j=a(j,A,d),ie=a(ie,A,d),ve=j.length,ai=ie.length),Mt=ve,F=ie.slice(0,ve),W=F.length;W<ve;F[W++]=0);nt=j.slice(),nt=[0].concat(nt),ci=j[0],j[1]>=d/2&&ci++;do{if(A=0,m=c(j,F,ve,W),m<0){if(J=F[0],ve!=W&&(J=J*d+(F[1]||0)),A=ae(J/ci),A>1)for(A>=d&&(A=d-1),k=a(j,A,d),D=k.length,W=F.length;c(k,F,D,W)==1;)A--,h(k,ve<D?nt:j,D,d),D=k.length,m=1;else A==0&&(m=A=1),k=j.slice(),D=k.length;if(D<W&&(k=[0].concat(k)),h(F,k,W,d),W=F.length,m==-1)for(;c(j,F,ve,W)<1;)A++,h(F,ve<W?nt:j,W,d),W=F.length}else m===0&&(A++,F=[0]);K[y++]=A,F[0]?F[W++]=ie[Mt]||0:(F=[ie[Mt]],W=1)}while((Mt++<ai||F[0]!=null)&&de--);S=F[0]!=null,K[0]||K.splice(0,1)}if(d==fe){for(y=1,de=K[0];de>=10;de/=10,y++);ue(H,g+(H.e=y+b*P-1)+1,E,S)}else H.e=b,H.r=+S;return H}})();function Q(a,c,h,v){var p,g,E,d,m;if(h==null?h=l:q(h,0,8),!a.c)return a.toString();if(p=a.c[0],E=a.e,c==null)m=he(a.c),m=v==1||v==2&&(E<=u||E>=f)?wt(m,E):Ee(m,E,"0");else if(a=ue(new L(a),c,h),g=a.e,m=he(a.c),d=m.length,v==1||v==2&&(c<=g||g<=u)){for(;d<c;m+="0",d++);m=wt(m,g)}else if(c-=E+(v===2&&g>E),m=Ee(m,g,"0"),g+1>d){if(--c>0)for(m+=".";c--;m+="0");}else if(c+=g-d,c>0)for(g+1==d&&(m+=".");c--;m+="0");return a.s<0&&p?"-"+m:m}function se(a,c){for(var h,v,p=1,g=new L(a[0]);p<a.length;p++)v=new L(a[p]),(!v.s||(h=Ne(g,v))===c||h===0&&g.s===c)&&(g=v);return g}function ye(a,c,h){for(var v=1,p=c.length;!c[--p];c.pop());for(p=c[0];p>=10;p/=10,v++);return(h=v+h*P-1)>w?a.c=a.e=null:h<x?a.c=[a.e=0]:(a.e=h,a.c=c),a}r=(function(){var a=/^(-?)0([xbo])(?=\w[\w.]*$)/i,c=/^([^.]+)\.$/,h=/^\.([^.]+)$/,v=/^-?(Infinity|NaN)$/,p=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(g,E,d,m){var b,y=d?E:E.replace(p,"");if(v.test(y))g.s=isNaN(y)?null:y<0?-1:1;else{if(!d&&(y=y.replace(a,function(S,A,k){return b=(k=k.toLowerCase())=="x"?16:k=="b"?2:8,!m||m==b?A:S}),m&&(b=m,y=y.replace(c,"$1").replace(h,"0.$1")),E!=y))return new L(y,b);if(L.DEBUG)throw Error(re+"Not a"+(m?" base "+m:"")+" number: "+E);g.s=null}g.c=g.e=null}})();function ue(a,c,h,v){var p,g,E,d,m,b,y,S=a.c,A=ti;if(S){e:{for(p=1,d=S[0];d>=10;d/=10,p++);if(g=c-p,g<0)g+=P,E=c,m=S[b=0],y=ae(m/A[p-E-1]%10);else if(b=Jt((g+1)/P),b>=S.length)if(v){for(;S.length<=b;S.push(0));m=y=0,p=1,g%=P,E=g-P+1}else break e;else{for(m=d=S[b],p=1;d>=10;d/=10,p++);g%=P,E=g-P+p,y=E<0?0:ae(m/A[p-E-1]%10)}if(v=v||c<0||S[b+1]!=null||(E<0?m:m%A[p-E-1]),v=h<4?(y||v)&&(h==0||h==(a.s<0?3:2)):y>5||y==5&&(h==4||v||h==6&&(g>0?E>0?m/A[p-E]:0:S[b-1])%10&1||h==(a.s<0?8:7)),c<1||!S[0])return S.length=0,v?(c-=a.e+1,S[0]=A[(P-c%P)%P],a.e=-c||0):S[0]=a.e=0,a;if(g==0?(S.length=b,d=1,b--):(S.length=b+1,d=A[P-g],S[b]=E>0?ae(m/A[p-E]%A[E])*d:0),v)for(;;)if(b==0){for(g=1,E=S[0];E>=10;E/=10,g++);for(E=S[0]+=d,d=1;E>=10;E/=10,d++);g!=d&&(a.e++,S[0]==fe&&(S[0]=1));break}else{if(S[b]+=d,S[b]!=fe)break;S[b--]=0,d=1}for(g=S.length;S[--g]===0;S.pop());}a.e>w?a.c=a.e=null:a.e<x&&(a.c=[a.e=0])}return a}function xe(a){var c,h=a.e;return h===null?a.toString():(c=he(a.c),c=h<=u||h>=f?wt(c,h):Ee(c,h,"0"),a.s<0?"-"+c:c)}return s.absoluteValue=s.abs=function(){var a=new L(this);return a.s<0&&(a.s=1),a},s.comparedTo=function(a,c){return Ne(this,new L(a,c))},s.decimalPlaces=s.dp=function(a,c){var h,v,p,g=this;if(a!=null)return q(a,0,X),c==null?c=l:q(c,0,8),ue(new L(g),a+g.e+1,c);if(!(h=g.c))return null;if(v=((p=h.length-1)-ce(this.e/P))*P,p=h[p])for(;p%10==0;p/=10,v--);return v<0&&(v=0),v},s.dividedBy=s.div=function(a,c){return e(this,new L(a,c),o,l)},s.dividedToIntegerBy=s.idiv=function(a,c){return e(this,new L(a,c),0,1)},s.exponentiatedBy=s.pow=function(a,c){var h,v,p,g,E,d,m,b,y,S=this;if(a=new L(a),a.c&&!a.isInteger())throw Error(re+"Exponent not an integer: "+xe(a));if(c!=null&&(c=new L(c)),d=a.e>14,!S.c||!S.c[0]||S.c[0]==1&&!S.e&&S.c.length==1||!a.c||!a.c[0])return y=new L(Math.pow(+xe(S),d?a.s*(2-Et(a)):+xe(a))),c?y.mod(c):y;if(m=a.s<0,c){if(c.c?!c.c[0]:!c.s)return new L(NaN);v=!m&&S.isInteger()&&c.isInteger(),v&&(S=S.mod(c))}else{if(a.e>9&&(S.e>0||S.e<-1||(S.e==0?S.c[0]>1||d&&S.c[1]>=24e7:S.c[0]<8e13||d&&S.c[0]<=9999975e7)))return g=S.s<0&&Et(a)?-0:0,S.e>-1&&(g=1/g),new L(m?1/g:g);T&&(g=Jt(T/P+2))}for(d?(h=new L(.5),m&&(a.s=1),b=Et(a)):(p=Math.abs(+xe(a)),b=p%2),y=new L(n);;){if(b){if(y=y.times(S),!y.c)break;g?y.c.length>g&&(y.c.length=g):v&&(y=y.mod(c))}if(p){if(p=ae(p/2),p===0)break;b=p%2}else if(a=a.times(h),ue(a,a.e+1,1),a.e>14)b=Et(a);else{if(p=+xe(a),p===0)break;b=p%2}S=S.times(S),g?S.c&&S.c.length>g&&(S.c.length=g):v&&(S=S.mod(c))}return v?y:(m&&(y=n.div(y)),c?y.mod(c):g?ue(y,T,l,E):y)},s.integerValue=function(a){var c=new L(this);return a==null?a=l:q(a,0,8),ue(c,c.e+1,a)},s.isEqualTo=s.eq=function(a,c){return Ne(this,new L(a,c))===0},s.isFinite=function(){return!!this.c},s.isGreaterThan=s.gt=function(a,c){return Ne(this,new L(a,c))>0},s.isGreaterThanOrEqualTo=s.gte=function(a,c){return(c=Ne(this,new L(a,c)))===1||c===0},s.isInteger=function(){return!!this.c&&ce(this.e/P)>this.c.length-2},s.isLessThan=s.lt=function(a,c){return Ne(this,new L(a,c))<0},s.isLessThanOrEqualTo=s.lte=function(a,c){return(c=Ne(this,new L(a,c)))===-1||c===0},s.isNaN=function(){return!this.s},s.isNegative=function(){return this.s<0},s.isPositive=function(){return this.s>0},s.isZero=function(){return!!this.c&&this.c[0]==0},s.minus=function(a,c){var h,v,p,g,E=this,d=E.s;if(a=new L(a,c),c=a.s,!d||!c)return new L(NaN);if(d!=c)return a.s=-c,E.plus(a);var m=E.e/P,b=a.e/P,y=E.c,S=a.c;if(!m||!b){if(!y||!S)return y?(a.s=-c,a):new L(S?E:NaN);if(!y[0]||!S[0])return S[0]?(a.s=-c,a):new L(y[0]?E:l==3?-0:0)}if(m=ce(m),b=ce(b),y=y.slice(),d=m-b){for((g=d<0)?(d=-d,p=y):(b=m,p=S),p.reverse(),c=d;c--;p.push(0));p.reverse()}else for(v=(g=(d=y.length)<(c=S.length))?d:c,d=c=0;c<v;c++)if(y[c]!=S[c]){g=y[c]<S[c];break}if(g&&(p=y,y=S,S=p,a.s=-a.s),c=(v=S.length)-(h=y.length),c>0)for(;c--;y[h++]=0);for(c=fe-1;v>d;){if(y[--v]<S[v]){for(h=v;h&&!y[--h];y[h]=c);--y[h],y[v]+=fe}y[v]-=S[v]}for(;y[0]==0;y.splice(0,1),--b);return y[0]?ye(a,y,b):(a.s=l==3?-1:1,a.c=[a.e=0],a)},s.modulo=s.mod=function(a,c){var h,v,p=this;return a=new L(a,c),!p.c||!a.s||a.c&&!a.c[0]?new L(NaN):!a.c||p.c&&!p.c[0]?new L(p):(M==9?(v=a.s,a.s=1,h=e(p,a,0,3),a.s=v,h.s*=v):h=e(p,a,0,M),a=p.minus(h.times(a)),!a.c[0]&&M==1&&(a.s=p.s),a)},s.multipliedBy=s.times=function(a,c){var h,v,p,g,E,d,m,b,y,S,A,k,D,H,K,F=this,W=F.c,J=(a=new L(a,c)).c;if(!W||!J||!W[0]||!J[0])return!F.s||!a.s||W&&!W[0]&&!J||J&&!J[0]&&!W?a.c=a.e=a.s=null:(a.s*=F.s,!W||!J?a.c=a.e=null:(a.c=[0],a.e=0)),a;for(v=ce(F.e/P)+ce(a.e/P),a.s*=F.s,m=W.length,S=J.length,m<S&&(D=W,W=J,J=D,p=m,m=S,S=p),p=m+S,D=[];p--;D.push(0));for(H=fe,K=Me,p=S;--p>=0;){for(h=0,A=J[p]%K,k=J[p]/K|0,E=m,g=p+E;g>p;)b=W[--E]%K,y=W[E]/K|0,d=k*b+y*A,b=A*b+d%K*K+D[g]+h,h=(b/H|0)+(d/K|0)+k*y,D[g--]=b%H;D[g]=h}return h?++v:D.splice(0,1),ye(a,D,v)},s.negated=function(){var a=new L(this);return a.s=-a.s||null,a},s.plus=function(a,c){var h,v=this,p=v.s;if(a=new L(a,c),c=a.s,!p||!c)return new L(NaN);if(p!=c)return a.s=-c,v.minus(a);var g=v.e/P,E=a.e/P,d=v.c,m=a.c;if(!g||!E){if(!d||!m)return new L(p/0);if(!d[0]||!m[0])return m[0]?a:new L(d[0]?v:p*0)}if(g=ce(g),E=ce(E),d=d.slice(),p=g-E){for(p>0?(E=g,h=m):(p=-p,h=d),h.reverse();p--;h.push(0));h.reverse()}for(p=d.length,c=m.length,p-c<0&&(h=m,m=d,d=h,c=p),p=0;c;)p=(d[--c]=d[c]+m[c]+p)/fe|0,d[c]=fe===d[c]?0:d[c]%fe;return p&&(d=[p].concat(d),++E),ye(a,d,E)},s.precision=s.sd=function(a,c){var h,v,p,g=this;if(a!=null&&a!==!!a)return q(a,1,X),c==null?c=l:q(c,0,8),ue(new L(g),a,c);if(!(h=g.c))return null;if(p=h.length-1,v=p*P+1,p=h[p]){for(;p%10==0;p/=10,v--);for(p=h[0];p>=10;p/=10,v++);}return a&&g.e+1>v&&(v=g.e+1),v},s.shiftedBy=function(a){return q(a,-ei,ei),this.times("1e"+a)},s.squareRoot=s.sqrt=function(){var a,c,h,v,p,g=this,E=g.c,d=g.s,m=g.e,b=o+4,y=new L("0.5");if(d!==1||!E||!E[0])return new L(!d||d<0&&(!E||E[0])?NaN:E?g:1/0);if(d=Math.sqrt(+xe(g)),d==0||d==1/0?(c=he(E),(c.length+m)%2==0&&(c+="0"),d=Math.sqrt(+c),m=ce((m+1)/2)-(m<0||m%2),d==1/0?c="5e"+m:(c=d.toExponential(),c=c.slice(0,c.indexOf("e")+1)+m),h=new L(c)):h=new L(d+""),h.c[0]){for(m=h.e,d=m+b,d<3&&(d=0);;)if(p=h,h=y.times(p.plus(e(g,p,b,1))),he(p.c).slice(0,d)===(c=he(h.c)).slice(0,d))if(h.e<m&&--d,c=c.slice(d-3,d+1),c=="9999"||!v&&c=="4999"){if(!v&&(ue(p,p.e+o+2,0),p.times(p).eq(g))){h=p;break}b+=4,d+=4,v=1}else{(!+c||!+c.slice(1)&&c.charAt(0)=="5")&&(ue(h,h.e+o+2,1),a=!h.times(h).eq(g));break}}return ue(h,h.e+o+1,l,a)},s.toExponential=function(a,c){return a!=null&&(q(a,0,X),a++),Q(this,a,c,1)},s.toFixed=function(a,c){return a!=null&&(q(a,0,X),a=a+this.e+1),Q(this,a,c)},s.toFormat=function(a,c,h){var v,p=this;if(h==null)a!=null&&c&&typeof c=="object"?(h=c,c=null):a&&typeof a=="object"?(h=a,a=c=null):h=R;else if(typeof h!="object")throw Error(re+"Argument not an object: "+h);if(v=p.toFixed(a,c),p.c){var g,E=v.split("."),d=+h.groupSize,m=+h.secondaryGroupSize,b=h.groupSeparator||"",y=E[0],S=E[1],A=p.s<0,k=A?y.slice(1):y,D=k.length;if(m&&(g=d,d=m,m=g,D-=g),d>0&&D>0){for(g=D%d||d,y=k.substr(0,g);g<D;g+=d)y+=b+k.substr(g,d);m>0&&(y+=b+k.slice(g)),A&&(y="-"+y)}v=S?y+(h.decimalSeparator||"")+((m=+h.fractionGroupSize)?S.replace(new RegExp("\\d{"+m+"}\\B","g"),"$&"+(h.fractionGroupSeparator||"")):S):y}return(h.prefix||"")+v+(h.suffix||"")},s.toFraction=function(a){var c,h,v,p,g,E,d,m,b,y,S,A,k=this,D=k.c;if(a!=null&&(d=new L(a),!d.isInteger()&&(d.c||d.s!==1)||d.lt(n)))throw Error(re+"Argument "+(d.isInteger()?"out of range: ":"not an integer: ")+xe(d));if(!D)return new L(k);for(c=new L(n),b=h=new L(n),v=m=new L(n),A=he(D),g=c.e=A.length-k.e-1,c.c[0]=ti[(E=g%P)<0?P+E:E],a=!a||d.comparedTo(c)>0?g>0?c:b:d,E=w,w=1/0,d=new L(A),m.c[0]=0;y=e(d,c,0,1),p=h.plus(y.times(v)),p.comparedTo(a)!=1;)h=v,v=p,b=m.plus(y.times(p=b)),m=p,c=d.minus(y.times(p=c)),d=p;return p=e(a.minus(h),v,0,1),m=m.plus(p.times(b)),h=h.plus(p.times(v)),m.s=b.s=k.s,g=g*2,S=e(b,v,g,l).minus(k).abs().comparedTo(e(m,h,g,l).minus(k).abs())<1?[b,v]:[m,h],w=E,S},s.toNumber=function(){return+xe(this)},s.toPrecision=function(a,c){return a!=null&&q(a,1,X),Q(this,a,c,2)},s.toString=function(a){var c,h=this,v=h.s,p=h.e;return p===null?v?(c="Infinity",v<0&&(c="-"+c)):c="NaN":(a==null?c=p<=u||p>=f?wt(he(h.c),p):Ee(he(h.c),p,"0"):a===10&&G?(h=ue(new L(h),o+p+1,l),c=Ee(he(h.c),h.e,"0")):(q(a,2,U.length,"Base"),c=t(Ee(he(h.c),p,"0"),10,a,v,!0)),v<0&&h.c[0]&&(c="-"+c)),c},s.valueOf=s.toJSON=function(){return xe(this)},s._isBigNumber=!0,s[Symbol.toStringTag]="BigNumber",s[Symbol.for("nodejs.util.inspect.custom")]=s.valueOf,i!=null&&L.set(i),L}function ce(i){var e=i|0;return i>0||i===e?e:e-1}function he(i){for(var e,t,r=1,s=i.length,n=i[0]+"";r<s;){for(e=i[r++]+"",t=P-e.length;t--;e="0"+e);n+=e}for(s=n.length;n.charCodeAt(--s)===48;);return n.slice(0,s+1||1)}function Ne(i,e){var t,r,s=i.c,n=e.c,o=i.s,l=e.s,u=i.e,f=e.e;if(!o||!l)return null;if(t=s&&!s[0],r=n&&!n[0],t||r)return t?r?0:-l:o;if(o!=l)return o;if(t=o<0,r=u==f,!s||!n)return r?0:!s^t?1:-1;if(!r)return u>f^t?1:-1;for(l=(u=s.length)<(f=n.length)?u:f,o=0;o<l;o++)if(s[o]!=n[o])return s[o]>n[o]^t?1:-1;return u==f?0:u>f^t?1:-1}function q(i,e,t,r){if(i<e||i>t||i!==ae(i))throw Error(re+(r||"Argument")+(typeof i=="number"?i<e||i>t?" out of range: ":" not an integer: ":" not a primitive number: ")+String(i))}function Et(i){var e=i.c.length-1;return ce(i.e/P)==e&&i.c[e]%2!=0}function wt(i,e){return(i.length>1?i.charAt(0)+"."+i.slice(1):i)+(e<0?"e":"e+")+e}function Ee(i,e,t){var r,s;if(e<0){for(s=t+".";++e;s+=t);i=s+i}else if(r=i.length,++e>r){for(s=t,e-=r;--e;s+=t);i+=s}else e<r&&(i=i.slice(0,e)+"."+i.slice(e));return i}var me=ir(),Os=class{key;left=null;right=null;constructor(i){this.key=i}},tt=class extends Os{constructor(i){super(i)}},Is=class{size=0;modificationCount=0;splayCount=0;splay(i){const e=this.root;if(e==null)return this.compare(i,i),-1;let t=null,r=null,s=null,n=null,o=e;const l=this.compare;let u;for(;;)if(u=l(o.key,i),u>0){let f=o.left;if(f==null||(u=l(f.key,i),u>0&&(o.left=f.right,f.right=o,o=f,f=o.left,f==null)))break;t==null?r=o:t.left=o,t=o,o=f}else if(u<0){let f=o.right;if(f==null||(u=l(f.key,i),u<0&&(o.right=f.left,f.left=o,o=f,f=o.right,f==null)))break;s==null?n=o:s.right=o,s=o,o=f}else break;return s!=null&&(s.right=o.left,o.left=n),t!=null&&(t.left=o.right,o.right=r),this.root!==o&&(this.root=o,this.splayCount++),u}splayMin(i){let e=i,t=e.left;for(;t!=null;){const r=t;e.left=r.right,r.right=e,e=r,t=e.left}return e}splayMax(i){let e=i,t=e.right;for(;t!=null;){const r=t;e.right=r.left,r.left=e,e=r,t=e.right}return e}_delete(i){if(this.root==null||this.splay(i)!=0)return null;let t=this.root;const r=t,s=t.left;if(this.size--,s==null)this.root=t.right;else{const n=t.right;t=this.splayMax(s),t.right=n,this.root=t}return this.modificationCount++,r}addNewRoot(i,e){this.size++,this.modificationCount++;const t=this.root;if(t==null){this.root=i;return}e<0?(i.left=t,i.right=t.right,t.right=null):(i.right=t,i.left=t.left,t.left=null),this.root=i}_first(){const i=this.root;return i==null?null:(this.root=this.splayMin(i),this.root)}_last(){const i=this.root;return i==null?null:(this.root=this.splayMax(i),this.root)}clear(){this.root=null,this.size=0,this.modificationCount++}has(i){return this.validKey(i)&&this.splay(i)==0}defaultCompare(){return(i,e)=>i<e?-1:i>e?1:0}wrap(){return{getRoot:()=>this.root,setRoot:i=>{this.root=i},getSize:()=>this.size,getModificationCount:()=>this.modificationCount,getSplayCount:()=>this.splayCount,setSplayCount:i=>{this.splayCount=i},splay:i=>this.splay(i),has:i=>this.has(i)}}},xt=class ot extends Is{root=null;compare;validKey;constructor(e,t){super(),this.compare=e??this.defaultCompare(),this.validKey=t??(r=>r!=null&&r!=null)}delete(e){return this.validKey(e)?this._delete(e)!=null:!1}deleteAll(e){for(const t of e)this.delete(t)}forEach(e){const t=this[Symbol.iterator]();let r;for(;r=t.next(),!r.done;)e(r.value,r.value,this)}add(e){const t=this.splay(e);return t!=0&&this.addNewRoot(new tt(e),t),this}addAndReturn(e){const t=this.splay(e);return t!=0&&this.addNewRoot(new tt(e),t),this.root.key}addAll(e){for(const t of e)this.add(t)}isEmpty(){return this.root==null}isNotEmpty(){return this.root!=null}single(){if(this.size==0)throw"Bad state: No element";if(this.size>1)throw"Bad state: Too many element";return this.root.key}first(){if(this.size==0)throw"Bad state: No element";return this._first().key}last(){if(this.size==0)throw"Bad state: No element";return this._last().key}lastBefore(e){if(e==null)throw"Invalid arguments(s)";if(this.root==null)return null;if(this.splay(e)<0)return this.root.key;let r=this.root.left;if(r==null)return null;let s=r.right;for(;s!=null;)r=s,s=r.right;return r.key}firstAfter(e){if(e==null)throw"Invalid arguments(s)";if(this.root==null)return null;if(this.splay(e)>0)return this.root.key;let r=this.root.right;if(r==null)return null;let s=r.left;for(;s!=null;)r=s,s=r.left;return r.key}retainAll(e){const t=new ot(this.compare,this.validKey),r=this.modificationCount;for(const s of e){if(r!=this.modificationCount)throw"Concurrent modification during iteration.";this.validKey(s)&&this.splay(s)==0&&t.add(this.root.key)}t.size!=this.size&&(this.root=t.root,this.size=t.size,this.modificationCount++)}lookup(e){return!this.validKey(e)||this.splay(e)!=0?null:this.root.key}intersection(e){const t=new ot(this.compare,this.validKey);for(const r of this)e.has(r)&&t.add(r);return t}difference(e){const t=new ot(this.compare,this.validKey);for(const r of this)e.has(r)||t.add(r);return t}union(e){const t=this.clone();return t.addAll(e),t}clone(){const e=new ot(this.compare,this.validKey);return e.size=this.size,e.root=this.copyNode(this.root),e}copyNode(e){if(e==null)return null;function t(s,n){let o,l;do{if(o=s.left,l=s.right,o!=null){const u=new tt(o.key);n.left=u,t(o,u)}if(l!=null){const u=new tt(l.key);n.right=u,s=l,n=u}}while(l!=null)}const r=new tt(e.key);return t(e,r),r}toSet(){return this.clone()}entries(){return new Ps(this.wrap())}keys(){return this[Symbol.iterator]()}undefined(){return this[Symbol.iterator]()}[Symbol.iterator](){return new Ns(this.wrap())}[Symbol.toStringTag]="[object Set]"},rr=class{tree;path=new Array;modificationCount=null;splayCount;constructor(i){this.tree=i,this.splayCount=i.getSplayCount()}[Symbol.iterator](){return this}next(){return this.moveNext()?{done:!1,value:this.current()}:{done:!0,value:null}}current(){if(!this.path.length)return null;const i=this.path[this.path.length-1];return this.getValue(i)}rebuildPath(i){this.path.splice(0,this.path.length),this.tree.splay(i),this.path.push(this.tree.getRoot()),this.splayCount=this.tree.getSplayCount()}findLeftMostDescendent(i){for(;i!=null;)this.path.push(i),i=i.left}moveNext(){if(this.modificationCount!=this.tree.getModificationCount()){if(this.modificationCount==null){this.modificationCount=this.tree.getModificationCount();let t=this.tree.getRoot();for(;t!=null;)this.path.push(t),t=t.left;return this.path.length>0}throw"Concurrent modification during iteration."}if(!this.path.length)return!1;this.splayCount!=this.tree.getSplayCount()&&this.rebuildPath(this.path[this.path.length-1].key);let i=this.path[this.path.length-1],e=i.right;if(e!=null){for(;e!=null;)this.path.push(e),e=e.left;return!0}for(this.path.pop();this.path.length&&this.path[this.path.length-1].right===i;)i=this.path.pop();return this.path.length>0}},Ns=class extends rr{getValue(i){return i.key}},Ps=class extends rr{getValue(i){return[i.key,i.key]}},sr=i=>()=>i,ii=i=>{const e=i?(t,r)=>r.minus(t).abs().isLessThanOrEqualTo(i):sr(!1);return(t,r)=>e(t,r)?0:t.comparedTo(r)};function Rs(i){const e=i?(t,r,s,n,o)=>t.exponentiatedBy(2).isLessThanOrEqualTo(n.minus(r).exponentiatedBy(2).plus(o.minus(s).exponentiatedBy(2)).times(i)):sr(!1);return(t,r,s)=>{const n=t.x,o=t.y,l=s.x,u=s.y,f=o.minus(u).times(r.x.minus(l)).minus(n.minus(l).times(r.y.minus(u)));return e(f,n,o,l,u)?0:f.comparedTo(0)}}var Gs=i=>i,Us=i=>{if(i){const e=new xt(ii(i)),t=new xt(ii(i)),r=(n,o)=>o.addAndReturn(n),s=n=>({x:r(n.x,e),y:r(n.y,t)});return s({x:new me(0),y:new me(0)}),s}return Gs},ri=i=>({set:e=>{we=ri(e)},reset:()=>ri(i),compare:ii(i),snap:Us(i),orient:Rs(i)}),we=ri(),it=(i,e)=>i.ll.x.isLessThanOrEqualTo(e.x)&&e.x.isLessThanOrEqualTo(i.ur.x)&&i.ll.y.isLessThanOrEqualTo(e.y)&&e.y.isLessThanOrEqualTo(i.ur.y),si=(i,e)=>{if(e.ur.x.isLessThan(i.ll.x)||i.ur.x.isLessThan(e.ll.x)||e.ur.y.isLessThan(i.ll.y)||i.ur.y.isLessThan(e.ll.y))return null;const t=i.ll.x.isLessThan(e.ll.x)?e.ll.x:i.ll.x,r=i.ur.x.isLessThan(e.ur.x)?i.ur.x:e.ur.x,s=i.ll.y.isLessThan(e.ll.y)?e.ll.y:i.ll.y,n=i.ur.y.isLessThan(e.ur.y)?i.ur.y:e.ur.y;return{ll:{x:t,y:s},ur:{x:r,y:n}}},St=(i,e)=>i.x.times(e.y).minus(i.y.times(e.x)),nr=(i,e)=>i.x.times(e.x).plus(i.y.times(e.y)),Lt=i=>nr(i,i).sqrt(),Fs=(i,e,t)=>{const r={x:e.x.minus(i.x),y:e.y.minus(i.y)},s={x:t.x.minus(i.x),y:t.y.minus(i.y)};return St(s,r).div(Lt(s)).div(Lt(r))},Bs=(i,e,t)=>{const r={x:e.x.minus(i.x),y:e.y.minus(i.y)},s={x:t.x.minus(i.x),y:t.y.minus(i.y)};return nr(s,r).div(Lt(s)).div(Lt(r))},or=(i,e,t)=>e.y.isZero()?null:{x:i.x.plus(e.x.div(e.y).times(t.minus(i.y))),y:t},lr=(i,e,t)=>e.x.isZero()?null:{x:t,y:i.y.plus(e.y.div(e.x).times(t.minus(i.x)))},Ds=(i,e,t,r)=>{if(e.x.isZero())return lr(t,r,i.x);if(r.x.isZero())return lr(i,e,t.x);if(e.y.isZero())return or(t,r,i.y);if(r.y.isZero())return or(i,e,t.y);const s=St(e,r);if(s.isZero())return null;const n={x:t.x.minus(i.x),y:t.y.minus(i.y)},o=St(n,e).div(s),l=St(n,r).div(s),u=i.x.plus(l.times(e.x)),f=t.x.plus(o.times(r.x)),x=i.y.plus(l.times(e.y)),w=t.y.plus(o.times(r.y)),_=u.plus(f).div(2),M=x.plus(w).div(2);return{x:_,y:M}},ge=class vr{point;isLeft;segment;otherSE;consumedBy;static compare(e,t){const r=vr.comparePoints(e.point,t.point);return r!==0?r:(e.point!==t.point&&e.link(t),e.isLeft!==t.isLeft?e.isLeft?1:-1:$t.compare(e.segment,t.segment))}static comparePoints(e,t){return e.x.isLessThan(t.x)?-1:e.x.isGreaterThan(t.x)?1:e.y.isLessThan(t.y)?-1:e.y.isGreaterThan(t.y)?1:0}constructor(e,t){e.events===void 0?e.events=[this]:e.events.push(this),this.point=e,this.isLeft=t}link(e){if(e.point===this.point)throw new Error("Tried to link already linked events");const t=e.point.events;for(let r=0,s=t.length;r<s;r++){const n=t[r];this.point.events.push(n),n.point=this.point}this.checkForConsuming()}checkForConsuming(){const e=this.point.events.length;for(let t=0;t<e;t++){const r=this.point.events[t];if(r.segment.consumedBy===void 0)for(let s=t+1;s<e;s++){const n=this.point.events[s];n.consumedBy===void 0&&r.otherSE.point.events===n.otherSE.point.events&&r.segment.consume(n.segment)}}}getAvailableLinkedEvents(){const e=[];for(let t=0,r=this.point.events.length;t<r;t++){const s=this.point.events[t];s!==this&&!s.segment.ringOut&&s.segment.isInResult()&&e.push(s)}return e}getLeftmostComparator(e){const t=new Map,r=s=>{const n=s.otherSE;t.set(s,{sine:Fs(this.point,e.point,n.point),cosine:Bs(this.point,e.point,n.point)})};return(s,n)=>{t.has(s)||r(s),t.has(n)||r(n);const{sine:o,cosine:l}=t.get(s),{sine:u,cosine:f}=t.get(n);return o.isGreaterThanOrEqualTo(0)&&u.isGreaterThanOrEqualTo(0)?l.isLessThan(f)?1:l.isGreaterThan(f)?-1:0:o.isLessThan(0)&&u.isLessThan(0)?l.isLessThan(f)?-1:l.isGreaterThan(f)?1:0:u.isLessThan(o)?-1:u.isGreaterThan(o)?1:0}}},Ws=class hi{events;poly;_isExteriorRing;_enclosingRing;static factory(e){const t=[];for(let r=0,s=e.length;r<s;r++){const n=e[r];if(!n.isInResult()||n.ringOut)continue;let o=null,l=n.leftSE,u=n.rightSE;const f=[l],x=l.point,w=[];for(;o=l,l=u,f.push(l),l.point!==x;)for(;;){const _=l.getAvailableLinkedEvents();if(_.length===0){const R=f[0].point,U=f[f.length-1].point;throw new Error(`Unable to complete output ring starting at [${R.x}, ${R.y}]. Last matching segment found ends at [${U.x}, ${U.y}].`)}if(_.length===1){u=_[0].otherSE;break}let M=null;for(let R=0,U=w.length;R<U;R++)if(w[R].point===l.point){M=R;break}if(M!==null){const R=w.splice(M)[0],U=f.splice(R.index);U.unshift(U[0].otherSE),t.push(new hi(U.reverse()));continue}w.push({index:f.length,point:l.point});const T=l.getLeftmostComparator(o);u=_.sort(T)[0].otherSE;break}t.push(new hi(f))}return t}constructor(e){this.events=e;for(let t=0,r=e.length;t<r;t++)e[t].segment.ringOut=this;this.poly=null}getGeom(){let e=this.events[0].point;const t=[e];for(let f=1,x=this.events.length-1;f<x;f++){const w=this.events[f].point,_=this.events[f+1].point;we.orient(w,e,_)!==0&&(t.push(w),e=w)}if(t.length===1)return null;const r=t[0],s=t[1];we.orient(r,e,s)===0&&t.shift(),t.push(t[0]);const n=this.isExteriorRing()?1:-1,o=this.isExteriorRing()?0:t.length-1,l=this.isExteriorRing()?t.length:-1,u=[];for(let f=o;f!=l;f+=n)u.push([t[f].x.toNumber(),t[f].y.toNumber()]);return u}isExteriorRing(){if(this._isExteriorRing===void 0){const e=this.enclosingRing();this._isExteriorRing=e?!e.isExteriorRing():!0}return this._isExteriorRing}enclosingRing(){return this._enclosingRing===void 0&&(this._enclosingRing=this._calcEnclosingRing()),this._enclosingRing}_calcEnclosingRing(){let e=this.events[0];for(let s=1,n=this.events.length;s<n;s++){const o=this.events[s];ge.compare(e,o)>0&&(e=o)}let t=e.segment.prevInResult(),r=t?t.prevInResult():null;for(;;){if(!t)return null;if(!r)return t.ringOut;if(r.ringOut!==t.ringOut)return r.ringOut?.enclosingRing()!==t.ringOut?t.ringOut:t.ringOut?.enclosingRing();t=r.prevInResult(),r=t?t.prevInResult():null}}},ar=class{exteriorRing;interiorRings;constructor(i){this.exteriorRing=i,i.poly=this,this.interiorRings=[]}addInterior(i){this.interiorRings.push(i),i.poly=this}getGeom(){const i=this.exteriorRing.getGeom();if(i===null)return null;const e=[i];for(let t=0,r=this.interiorRings.length;t<r;t++){const s=this.interiorRings[t].getGeom();s!==null&&e.push(s)}return e}},zs=class{rings;polys;constructor(i){this.rings=i,this.polys=this._composePolys(i)}getGeom(){const i=[];for(let e=0,t=this.polys.length;e<t;e++){const r=this.polys[e].getGeom();r!==null&&i.push(r)}return i}_composePolys(i){const e=[];for(let t=0,r=i.length;t<r;t++){const s=i[t];if(!s.poly)if(s.isExteriorRing())e.push(new ar(s));else{const n=s.enclosingRing();n?.poly||e.push(new ar(n)),n?.poly?.addInterior(s)}}return e}},qs=class{queue;tree;segments;constructor(i,e=$t.compare){this.queue=i,this.tree=new xt(e),this.segments=[]}process(i){const e=i.segment,t=[];if(i.consumedBy)return i.isLeft?this.queue.delete(i.otherSE):this.tree.delete(e),t;i.isLeft&&this.tree.add(e);let r=e,s=e;do r=this.tree.lastBefore(r);while(r!=null&&r.consumedBy!=null);do s=this.tree.firstAfter(s);while(s!=null&&s.consumedBy!=null);if(i.isLeft){let n=null;if(r){const l=r.getIntersection(e);if(l!==null&&(e.isAnEndpoint(l)||(n=l),!r.isAnEndpoint(l))){const u=this._splitSafely(r,l);for(let f=0,x=u.length;f<x;f++)t.push(u[f])}}let o=null;if(s){const l=s.getIntersection(e);if(l!==null&&(e.isAnEndpoint(l)||(o=l),!s.isAnEndpoint(l))){const u=this._splitSafely(s,l);for(let f=0,x=u.length;f<x;f++)t.push(u[f])}}if(n!==null||o!==null){let l=null;n===null?l=o:o===null?l=n:l=ge.comparePoints(n,o)<=0?n:o,this.queue.delete(e.rightSE),t.push(e.rightSE);const u=e.split(l);for(let f=0,x=u.length;f<x;f++)t.push(u[f])}t.length>0?(this.tree.delete(e),t.push(i)):(this.segments.push(e),e.prev=r)}else{if(r&&s){const n=r.getIntersection(s);if(n!==null){if(!r.isAnEndpoint(n)){const o=this._splitSafely(r,n);for(let l=0,u=o.length;l<u;l++)t.push(o[l])}if(!s.isAnEndpoint(n)){const o=this._splitSafely(s,n);for(let l=0,u=o.length;l<u;l++)t.push(o[l])}}}this.tree.delete(e)}return t}_splitSafely(i,e){this.tree.delete(i);const t=i.rightSE;this.queue.delete(t);const r=i.split(e);return r.push(t),i.consumedBy===void 0&&this.tree.add(i),r}},Hs=class{type;numMultiPolys;run(i,e,t){rt.type=i;const r=[new hr(e,!0)];for(let f=0,x=t.length;f<x;f++)r.push(new hr(t[f],!1));if(rt.numMultiPolys=r.length,rt.type==="difference"){const f=r[0];let x=1;for(;x<r.length;)si(r[x].bbox,f.bbox)!==null?x++:r.splice(x,1)}if(rt.type==="intersection")for(let f=0,x=r.length;f<x;f++){const w=r[f];for(let _=f+1,M=r.length;_<M;_++)if(si(w.bbox,r[_].bbox)===null)return[]}const s=new xt(ge.compare);for(let f=0,x=r.length;f<x;f++){const w=r[f].getSweepEvents();for(let _=0,M=w.length;_<M;_++)s.add(w[_])}const n=new qs(s);let o=null;for(s.size!=0&&(o=s.first(),s.delete(o));o;){const f=n.process(o);for(let x=0,w=f.length;x<w;x++){const _=f[x];_.consumedBy===void 0&&s.add(_)}s.size!=0?(o=s.first(),s.delete(o)):o=null}we.reset();const l=Ws.factory(n.segments);return new zs(l).getGeom()}},rt=new Hs,_t=rt,js=0,$t=class Tt{id;leftSE;rightSE;rings;windings;ringOut;consumedBy;prev;_prevInResult;_beforeState;_afterState;_isInResult;static compare(e,t){const r=e.leftSE.point.x,s=t.leftSE.point.x,n=e.rightSE.point.x,o=t.rightSE.point.x;if(o.isLessThan(r))return 1;if(n.isLessThan(s))return-1;const l=e.leftSE.point.y,u=t.leftSE.point.y,f=e.rightSE.point.y,x=t.rightSE.point.y;if(r.isLessThan(s)){if(u.isLessThan(l)&&u.isLessThan(f))return 1;if(u.isGreaterThan(l)&&u.isGreaterThan(f))return-1;const w=e.comparePoint(t.leftSE.point);if(w<0)return 1;if(w>0)return-1;const _=t.comparePoint(e.rightSE.point);return _!==0?_:-1}if(r.isGreaterThan(s)){if(l.isLessThan(u)&&l.isLessThan(x))return-1;if(l.isGreaterThan(u)&&l.isGreaterThan(x))return 1;const w=t.comparePoint(e.leftSE.point);if(w!==0)return w;const _=e.comparePoint(t.rightSE.point);return _<0?1:_>0?-1:1}if(l.isLessThan(u))return-1;if(l.isGreaterThan(u))return 1;if(n.isLessThan(o)){const w=t.comparePoint(e.rightSE.point);if(w!==0)return w}if(n.isGreaterThan(o)){const w=e.comparePoint(t.rightSE.point);if(w<0)return 1;if(w>0)return-1}if(!n.eq(o)){const w=f.minus(l),_=n.minus(r),M=x.minus(u),T=o.minus(s);if(w.isGreaterThan(_)&&M.isLessThan(T))return 1;if(w.isLessThan(_)&&M.isGreaterThan(T))return-1}return n.isGreaterThan(o)?1:n.isLessThan(o)||f.isLessThan(x)?-1:f.isGreaterThan(x)?1:e.id<t.id?-1:e.id>t.id?1:0}constructor(e,t,r,s){this.id=++js,this.leftSE=e,e.segment=this,e.otherSE=t,this.rightSE=t,t.segment=this,t.otherSE=e,this.rings=r,this.windings=s}static fromRing(e,t,r){let s,n,o;const l=ge.comparePoints(e,t);if(l<0)s=e,n=t,o=1;else if(l>0)s=t,n=e,o=-1;else throw new Error(`Tried to create degenerate segment at [${e.x}, ${e.y}]`);const u=new ge(s,!0),f=new ge(n,!1);return new Tt(u,f,[r],[o])}replaceRightSE(e){this.rightSE=e,this.rightSE.segment=this,this.rightSE.otherSE=this.leftSE,this.leftSE.otherSE=this.rightSE}bbox(){const e=this.leftSE.point.y,t=this.rightSE.point.y;return{ll:{x:this.leftSE.point.x,y:e.isLessThan(t)?e:t},ur:{x:this.rightSE.point.x,y:e.isGreaterThan(t)?e:t}}}vector(){return{x:this.rightSE.point.x.minus(this.leftSE.point.x),y:this.rightSE.point.y.minus(this.leftSE.point.y)}}isAnEndpoint(e){return e.x.eq(this.leftSE.point.x)&&e.y.eq(this.leftSE.point.y)||e.x.eq(this.rightSE.point.x)&&e.y.eq(this.rightSE.point.y)}comparePoint(e){return we.orient(this.leftSE.point,e,this.rightSE.point)}getIntersection(e){const t=this.bbox(),r=e.bbox(),s=si(t,r);if(s===null)return null;const n=this.leftSE.point,o=this.rightSE.point,l=e.leftSE.point,u=e.rightSE.point,f=it(t,l)&&this.comparePoint(l)===0,x=it(r,n)&&e.comparePoint(n)===0,w=it(t,u)&&this.comparePoint(u)===0,_=it(r,o)&&e.comparePoint(o)===0;if(x&&f)return _&&!w?o:!_&&w?u:null;if(x)return w&&n.x.eq(u.x)&&n.y.eq(u.y)?null:n;if(f)return _&&o.x.eq(l.x)&&o.y.eq(l.y)?null:l;if(_&&w)return null;if(_)return o;if(w)return u;const M=Ds(n,this.vector(),l,e.vector());return M===null||!it(s,M)?null:we.snap(M)}split(e){const t=[],r=e.events!==void 0,s=new ge(e,!0),n=new ge(e,!1),o=this.rightSE;this.replaceRightSE(n),t.push(n),t.push(s);const l=new Tt(s,o,this.rings.slice(),this.windings.slice());return ge.comparePoints(l.leftSE.point,l.rightSE.point)>0&&l.swapEvents(),ge.comparePoints(this.leftSE.point,this.rightSE.point)>0&&this.swapEvents(),r&&(s.checkForConsuming(),n.checkForConsuming()),t}swapEvents(){const e=this.rightSE;this.rightSE=this.leftSE,this.leftSE=e,this.leftSE.isLeft=!0,this.rightSE.isLeft=!1;for(let t=0,r=this.windings.length;t<r;t++)this.windings[t]*=-1}consume(e){let t=this,r=e;for(;t.consumedBy;)t=t.consumedBy;for(;r.consumedBy;)r=r.consumedBy;const s=Tt.compare(t,r);if(s!==0){if(s>0){const n=t;t=r,r=n}if(t.prev===r){const n=t;t=r,r=n}for(let n=0,o=r.rings.length;n<o;n++){const l=r.rings[n],u=r.windings[n],f=t.rings.indexOf(l);f===-1?(t.rings.push(l),t.windings.push(u)):t.windings[f]+=u}r.rings=null,r.windings=null,r.consumedBy=t,r.leftSE.consumedBy=t.leftSE,r.rightSE.consumedBy=t.rightSE}}prevInResult(){return this._prevInResult!==void 0?this._prevInResult:(this.prev?this.prev.isInResult()?this._prevInResult=this.prev:this._prevInResult=this.prev.prevInResult():this._prevInResult=null,this._prevInResult)}beforeState(){if(this._beforeState!==void 0)return this._beforeState;if(!this.prev)this._beforeState={rings:[],windings:[],multiPolys:[]};else{const e=this.prev.consumedBy||this.prev;this._beforeState=e.afterState()}return this._beforeState}afterState(){if(this._afterState!==void 0)return this._afterState;const e=this.beforeState();this._afterState={rings:e.rings.slice(0),windings:e.windings.slice(0),multiPolys:[]};const t=this._afterState.rings,r=this._afterState.windings,s=this._afterState.multiPolys;for(let l=0,u=this.rings.length;l<u;l++){const f=this.rings[l],x=this.windings[l],w=t.indexOf(f);w===-1?(t.push(f),r.push(x)):r[w]+=x}const n=[],o=[];for(let l=0,u=t.length;l<u;l++){if(r[l]===0)continue;const f=t[l],x=f.poly;if(o.indexOf(x)===-1)if(f.isExterior)n.push(x);else{o.indexOf(x)===-1&&o.push(x);const w=n.indexOf(f.poly);w!==-1&&n.splice(w,1)}}for(let l=0,u=n.length;l<u;l++){const f=n[l].multiPoly;s.indexOf(f)===-1&&s.push(f)}return this._afterState}isInResult(){if(this.consumedBy)return!1;if(this._isInResult!==void 0)return this._isInResult;const e=this.beforeState().multiPolys,t=this.afterState().multiPolys;switch(_t.type){case"union":{const r=e.length===0,s=t.length===0;this._isInResult=r!==s;break}case"intersection":{let r,s;e.length<t.length?(r=e.length,s=t.length):(r=t.length,s=e.length),this._isInResult=s===_t.numMultiPolys&&r<s;break}case"xor":{const r=Math.abs(e.length-t.length);this._isInResult=r%2===1;break}case"difference":{const r=s=>s.length===1&&s[0].isSubject;this._isInResult=r(e)!==r(t);break}}return this._isInResult}},cr=class{poly;isExterior;segments;bbox;constructor(i,e,t){if(!Array.isArray(i)||i.length===0)throw new Error("Input geometry is not a valid Polygon or MultiPolygon");if(this.poly=e,this.isExterior=t,this.segments=[],typeof i[0][0]!="number"||typeof i[0][1]!="number")throw new Error("Input geometry is not a valid Polygon or MultiPolygon");const r=we.snap({x:new me(i[0][0]),y:new me(i[0][1])});this.bbox={ll:{x:r.x,y:r.y},ur:{x:r.x,y:r.y}};let s=r;for(let n=1,o=i.length;n<o;n++){if(typeof i[n][0]!="number"||typeof i[n][1]!="number")throw new Error("Input geometry is not a valid Polygon or MultiPolygon");const l=we.snap({x:new me(i[n][0]),y:new me(i[n][1])});l.x.eq(s.x)&&l.y.eq(s.y)||(this.segments.push($t.fromRing(s,l,this)),l.x.isLessThan(this.bbox.ll.x)&&(this.bbox.ll.x=l.x),l.y.isLessThan(this.bbox.ll.y)&&(this.bbox.ll.y=l.y),l.x.isGreaterThan(this.bbox.ur.x)&&(this.bbox.ur.x=l.x),l.y.isGreaterThan(this.bbox.ur.y)&&(this.bbox.ur.y=l.y),s=l)}(!r.x.eq(s.x)||!r.y.eq(s.y))&&this.segments.push($t.fromRing(s,r,this))}getSweepEvents(){const i=[];for(let e=0,t=this.segments.length;e<t;e++){const r=this.segments[e];i.push(r.leftSE),i.push(r.rightSE)}return i}},Vs=class{multiPoly;exteriorRing;interiorRings;bbox;constructor(i,e){if(!Array.isArray(i))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");this.exteriorRing=new cr(i[0],this,!0),this.bbox={ll:{x:this.exteriorRing.bbox.ll.x,y:this.exteriorRing.bbox.ll.y},ur:{x:this.exteriorRing.bbox.ur.x,y:this.exteriorRing.bbox.ur.y}},this.interiorRings=[];for(let t=1,r=i.length;t<r;t++){const s=new cr(i[t],this,!1);s.bbox.ll.x.isLessThan(this.bbox.ll.x)&&(this.bbox.ll.x=s.bbox.ll.x),s.bbox.ll.y.isLessThan(this.bbox.ll.y)&&(this.bbox.ll.y=s.bbox.ll.y),s.bbox.ur.x.isGreaterThan(this.bbox.ur.x)&&(this.bbox.ur.x=s.bbox.ur.x),s.bbox.ur.y.isGreaterThan(this.bbox.ur.y)&&(this.bbox.ur.y=s.bbox.ur.y),this.interiorRings.push(s)}this.multiPoly=e}getSweepEvents(){const i=this.exteriorRing.getSweepEvents();for(let e=0,t=this.interiorRings.length;e<t;e++){const r=this.interiorRings[e].getSweepEvents();for(let s=0,n=r.length;s<n;s++)i.push(r[s])}return i}},hr=class{isSubject;polys;bbox;constructor(i,e){if(!Array.isArray(i))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");try{typeof i[0][0][0]=="number"&&(i=[i])}catch{}this.polys=[],this.bbox={ll:{x:new me(Number.POSITIVE_INFINITY),y:new me(Number.POSITIVE_INFINITY)},ur:{x:new me(Number.NEGATIVE_INFINITY),y:new me(Number.NEGATIVE_INFINITY)}};for(let t=0,r=i.length;t<r;t++){const s=new Vs(i[t],this);s.bbox.ll.x.isLessThan(this.bbox.ll.x)&&(this.bbox.ll.x=s.bbox.ll.x),s.bbox.ll.y.isLessThan(this.bbox.ll.y)&&(this.bbox.ll.y=s.bbox.ll.y),s.bbox.ur.x.isGreaterThan(this.bbox.ur.x)&&(this.bbox.ur.x=s.bbox.ur.x),s.bbox.ur.y.isGreaterThan(this.bbox.ur.y)&&(this.bbox.ur.y=s.bbox.ur.y),this.polys.push(s)}this.isSubject=e}getSweepEvents(){const i=[];for(let e=0,t=this.polys.length;e<t;e++){const r=this.polys[e].getSweepEvents();for(let s=0,n=r.length;s<n;s++)i.push(r[s])}return i}},Zs=(i,...e)=>_t.run("union",i,e),Ks=(i,...e)=>_t.run("difference",i,e);we.set;function ur(i,e,t){if(i!==null)for(var r,s,n,o,l,u,f,x=0,w=0,_,M=i.type,T=M==="FeatureCollection",R=M==="Feature",U=T?i.features.length:1,G=0;G<U;G++){f=T?i.features[G].geometry:R?i.geometry:i,_=f?f.type==="GeometryCollection":!1,l=_?f.geometries.length:1;for(var L=0;L<l;L++){var Q=0,se=0;if(o=_?f.geometries[L]:f,o!==null){u=o.coordinates;var ye=o.type;switch(x=0,ye){case null:break;case"Point":if(e(u,w,G,Q,se)===!1)return!1;w++,Q++;break;case"LineString":case"MultiPoint":for(r=0;r<u.length;r++){if(e(u[r],w,G,Q,se)===!1)return!1;w++,ye==="MultiPoint"&&Q++}ye==="LineString"&&Q++;break;case"Polygon":case"MultiLineString":for(r=0;r<u.length;r++){for(s=0;s<u[r].length-x;s++){if(e(u[r][s],w,G,Q,se)===!1)return!1;w++}ye==="MultiLineString"&&Q++,ye==="Polygon"&&se++}ye==="Polygon"&&Q++;break;case"MultiPolygon":for(r=0;r<u.length;r++){for(se=0,s=0;s<u[r].length;s++){for(n=0;n<u[r][s].length-x;n++){if(e(u[r][s][n],w,G,Q,se)===!1)return!1;w++}se++}Q++}break;case"GeometryCollection":for(r=0;r<o.geometries.length;r++)if(ur(o.geometries[r],e)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function ni(i,e){var t,r,s,n,o,l,u,f,x,w,_=0,M=i.type==="FeatureCollection",T=i.type==="Feature",R=M?i.features.length:1;for(t=0;t<R;t++){for(l=M?i.features[t].geometry:T?i.geometry:i,f=M?i.features[t].properties:T?i.properties:{},x=M?i.features[t].bbox:T?i.bbox:void 0,w=M?i.features[t].id:T?i.id:void 0,u=l?l.type==="GeometryCollection":!1,o=u?l.geometries.length:1,s=0;s<o;s++){if(n=u?l.geometries[s]:l,n===null){if(e(null,_,f,x,w)===!1)return!1;continue}switch(n.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":{if(e(n,_,f,x,w)===!1)return!1;break}case"GeometryCollection":{for(r=0;r<n.geometries.length;r++)if(e(n.geometries[r],_,f,x,w)===!1)return!1;break}default:throw new Error("Unknown Geometry Type")}}_++}}function Ys(i,e){ni(i,function(t,r,s,n,o){var l=t===null?null:t.type;switch(l){case null:case"Point":case"LineString":case"Polygon":return e(Je(t,s,{bbox:n,id:o}),r,0)===!1?!1:void 0}var u;switch(l){case"MultiPoint":u="Point";break;case"MultiLineString":u="LineString";break;case"MultiPolygon":u="Polygon";break}for(var f=0;f<t.coordinates.length;f++){var x=t.coordinates[f],w={type:u,coordinates:x};if(e(Je(w,s),r,f)===!1)return!1}})}function Xs(i,e={}){const t=[];if(ni(i,s=>{t.push(s.coordinates)}),t.length<2)throw new Error("Must have at least 2 geometries");const r=Zs(t[0],...t.slice(1));return r.length===0?null:r.length===1?Qt(r[0],e.properties):er(r,e.properties)}var dr=Xs;function Qs(i,e={}){if(i.bbox!=null&&e.recompute!==!0)return i.bbox;const t=[1/0,1/0,-1/0,-1/0];return ur(i,r=>{t[0]>r[0]&&(t[0]=r[0]),t[1]>r[1]&&(t[1]=r[1]),t[2]<r[0]&&(t[2]=r[0]),t[3]<r[1]&&(t[3]=r[1])}),t}var fr=Qs;function Js(i){const e=[];if(ni(i,s=>{e.push(s.coordinates)}),e.length<2)throw new Error("Must have at least two features");const t=i.features[0].properties||{},r=Ks(e[0],...e.slice(1));return r.length===0?null:r.length===1?Qt(r[0],t):er(r,t)}var en=Js;function tn(i){if(!i)throw new Error("geojson is required");var e=[];return Ys(i,function(t){e.push(t)}),et(e)}var rn=tn;function pr(i){const e=en(et([Qt([[[180,90],[-180,90],[-180,-90],[180,-90],[180,90]]]),i]));if(!e)return;e.properties={isMask:!0};const t=pt(fr(i)),r=(t[2]-t[0])/360/1e3,s=t[0]<-180,n=t[2]>180,o=rn(i);if(o.features.length>1&&(s||n))for(const l of o.features){const u=pt(fr(l));if(n&&u[0]<-180+r)for(const f of l.geometry.coordinates)for(const x of f)x[0]+=360-r;if(s&&u[2]>180-r)for(const f of l.geometry.coordinates)for(const x of f)x[0]-=360-r}return et([o.features.length<2?i:dr(o)??i,e])}const mr={continental_marine:4,country:4,major_landform:8,region:5,subregion:6,county:7,joint_municipality:8,joint_submunicipality:9,municipality:10,municipal_district:11,locality:12,neighbourhood:13,place:14,postal_code:14,road:16,poi:17,address:18,"poi.peak":15,"poi.shop":18,"poi.cafe":18,"poi.restaurant":18,"poi.aerodrome":13},gr={fill:{paint:{"fill-color":"#000","fill-opacity":.1},filter:["all",["==",["geometry-type"],"Polygon"],["has","isMask"]]},line:{layout:{"line-cap":"square"},paint:{"line-width":["case",["==",["geometry-type"],"Polygon"],2,3],"line-dasharray":[1,1],"line-color":"#3170fe"},filter:["!",["has","isMask"]]}},st="mtlr-gc-full-geom",oi="mtlr-gc-full-geom-fill",li="mtlr-gc-full-geom-line";class yr extends Te.Evented{#e={};#t;#i;constructor(e={}){super(),this.setOptions(e)}onAdd(e){this.#t=e,this.#i=e._container.ownerDocument.createElement("maptiler-geocoder"),this.#i.classList.add("maplibregl-geocoder"),this.#v(),this.#x();const t=e._container.ownerDocument.createElement("div");return t.classList.add("maplibregl-ctrl-geocoder","maplibregl-ctrl","maplibregl-ctrl-group"),t.style.position="relative",t.style.zIndex="3",t.appendChild(this.#i),setTimeout(()=>this.#i?.setOptions({openListOnTop:t.matches(".maplibregl-ctrl-bottom-left *, .maplibregl-ctrl-bottom-right *")})),t}onRemove(){this.#S(),this.#t=void 0,this.#i=void 0}getOptions(){return{...this.#e}}setOptions(e){Object.assign(this.#e,e),this.#v()}setQuery(e){this.#i?.setQuery(e)}submitQuery(e){this.#i?.submitQuery(e)}clearMap(){this.#n=[],this.#u(void 0,void 0)}clearList(){this.#i?.clearList()}setReverseMode(e){this.setOptions({reverseActive:e})}focus(e){this.#i?.focus(e)}blur(){this.#i?.blur()}#l=new Map;#c;#s;#n;#o;#m;#g={reversetoggle:e=>{const t=this.#t?.getCanvasContainer();t&&(t.style.cursor=e.detail.reverse?"crosshair":""),this.#r("reversetoggle",e.detail)},querychange:e=>{const t=e.detail.reverseCoords;this.#w(t?[t.decimalLongitude,t.decimalLatitude]:void 0),this.#r("querychange",e.detail)},queryclear:()=>{this.#w(void 0),this.#r("queryclear")},request:e=>{this.#r("request",e.detail)},response:e=>{this.#r("response",e.detail)},select:e=>{const t=e.detail.feature;t&&this.#d&&this.#e.flyToSelected&&this.#b(t.center,this.#h(t)),this.#n&&t&&this.#T(t),this.#r("select",e.detail)},pick:e=>{const t=e.detail.feature;t&&t.id!==this.#m&&this.#d&&(this.#L(t),this.#u(this.#n,t)),this.#m=t?.id,this.#r("pick",e.detail)},featuresshow:()=>{this.#r("featuresshow")},featureshide:()=>{this.#r("featureshide")},featureslisted:e=>{const t=e.detail.features;this.#n=t,this.#u(this.#n,void 0),this.#_(e),this.#r("featureslisted",e.detail)},featuresclear:()=>{this.#n=void 0,this.#u(void 0,void 0),this.#r("featuresclear")},focusin:()=>{this.#r("focusin")},focusout:()=>{this.#r("focusout")}};#y={render:()=>{const e=this.#t?.getZoom(),t=this.#t?.getCenter();this.#i?.handleMapChange(e&&t?[e,t.lng,t.lat]:void 0)},click:e=>{this.#i?.handleMapClick([e.lngLat.lng,e.lngLat.lat])},styledata:()=>{setTimeout(()=>{this.#o&&this.#f()})}};#v(){this.#i&&(this.#i.setOptions(this.#e),this.#i.fetchFullGeometryOnPick=this.#e.pickedResultStyle!=="marker-only")}#x(){if(!(!this.#i||!this.#t)){for(const[e,t]of Object.entries(this.#g))this.#i.addEventListener(e,t);for(const[e,t]of Object.entries(this.#y))this.#t.on(e,t)}}#S(){if(!(!this.#i||!this.#t)){for(const[e,t]of Object.entries(this.#g))this.#i.removeEventListener(e,t);for(const[e,t]of Object.entries(this.#y))this.#t.off(e,t)}}#r(e,t){return super.fire({type:e,...t??{}})}#L(e){e.bbox[0]===e.bbox[2]&&e.bbox[1]===e.bbox[3]?this.#b(e.center,this.#h(e)):this.#E(pt(e.bbox),50,this.#h(e))}#_({detail:{features:e,external:t}}){if(!e||e.length===0||!this.#d||this.#e.flyToFeatures===!1||this.#e.flyToFeatures==="never"||!t&&(this.#e.flyToFeatures===void 0||this.#e.flyToFeatures==="external"))return;const r=e.every(o=>o.matching_text),s=e.reduce((o,l)=>r||!l.matching_text?[Math.min(o[0],l.bbox[0]),Math.min(o[1],l.bbox[1]),Math.max(o[2],l.bbox[2]),Math.max(o[3],l.bbox[3])]:o,[180,90,-180,-90]),n=e.map(o=>this.#h(o)).filter(o=>o!==void 0).reduce((o,l)=>o===void 0?l:Math.max(o,l),void 0);this.#E(pt(s),50,n)}#h(e){if(e.bbox[0]!==e.bbox[2]||e.bbox[1]!==e.bbox[3])return;const t=e.id.replace(/\..*/,""),r=this.#e.zoom??mr;return(Array.isArray(e.properties?.categories)?e.properties.categories.reduce((s,n)=>{const o=r[t+"."+n];return s===void 0?o:o===void 0?s:Math.max(s,o)},void 0):void 0)??r[t]}get#d(){return!!this.#e.flyTo||this.#e.flyTo===void 0}get#$(){return typeof this.#e.flyTo=="boolean"?{}:this.#e.flyTo}get#M(){return typeof this.#e.flyTo=="boolean"?{}:this.#e.flyTo}#b(e,t){this.#t?.flyTo({center:e,...t?{zoom:t}:{},...this.#$})}#E(e,t,r){this.#t?.fitBounds([[e[0],e[1]],[e[2],e[3]]],{padding:t,...r?{maxZoom:r}:{},...this.#M})}#w(e){if(!(this.#e.marker===!1||this.#e.marker===null||!this.#t)){if(!e){this.#s?.remove(),this.#s=void 0;return}this.#s||(this.#e.marker instanceof Function?this.#s=this.#e.marker(this.#t)??void 0:(this.#s=this.#p(this.#e.marker).setLngLat(e).addTo(this.#t),this.#s.getElement().classList.add("marker-reverse"))),this.#s?.setLngLat(e)}}#u(e,t){if(!this.#t)return;for(const s of this.#l.undefined())s.remove();this.#l=new Map,this.#a(void 0);const r=()=>{if(!t||!this.#t||this.#e.marker===!1||this.#e.marker===null)return;const s=this.#e.marker instanceof Function?this.#e.marker(this.#t,t):this.#p(this.#e.marker).setLngLat(t.center).addTo(this.#t);s&&this.#l.set(t,s)};if(t?.geometry.type==="GeometryCollection"){const s=t.geometry.geometries.filter(n=>n.type==="Polygon"||n.type==="MultiPolygon");if(s.length>0){const n=dr(et(s.map(o=>Je(o))));if(n){const o=pr({...t,geometry:n.geometry});o&&this.#a(o)}}else{const n=t.geometry.geometries.filter(o=>o.type==="LineString"||o.type==="MultiLineString");n.length>0&&this.#a({...t,geometry:{type:"GeometryCollection",geometries:n}})}}else if(t?.geometry.type.endsWith("Polygon")){const s=pr(t);s&&this.#a(s),this.#e.pickedResultStyle==="full-geometry-including-polygon-center-marker"&&r()}else t?.geometry.type.endsWith("LineString")?this.#a(t):t?.geometry.type.endsWith("Point")&&r();if(this.#e.showResultMarkers!==!1&&this.#e.showResultMarkers!==null)for(const s of e??[]){if(s.id===t?.id||s.place_type.includes("reverse"))continue;let n;if(this.#e.showResultMarkers instanceof Function){if(n=this.#e.showResultMarkers(this.#t,s),!n)continue}else n=this.#p(this.#e.showResultMarkers).setLngLat(s.center).setPopup(new Te.Popup({offset:[1,-27],closeButton:!1,closeOnMove:!0,className:"maptiler-gc-popup"}).setText(s.place_type[0]==="reverse"?s.place_name:s.place_name.replace(/,.*/,""))).addTo(this.#t),n.getElement().classList.add("marker-interactive");const o=n.getElement();o.addEventListener("click",l=>{l.stopPropagation(),this.#r("markerclick",{feature:s,marker:n})}),o.addEventListener("mouseenter",()=>{this.#r("markermouseenter",{feature:s,marker:n}),n.togglePopup()}),o.addEventListener("mouseleave",()=>{this.#r("markermouseleave",{feature:s,marker:n}),n.togglePopup()}),o.classList.toggle("marker-fuzzy",!!s.matching_text),this.#l.set(s,n)}}#T(e){this.#c?.getElement().classList.toggle("marker-selected",!1),this.#c=void 0,this.#e.markerOnSelected!==!1&&(this.#c=this.#l.get(e),this.#c?.getElement().classList.toggle("marker-selected",!0))}#f(){if(!this.#t?.loaded){this.#t?.once("load",()=>{this.#f()});return}const e=this.#A(),t=this.#t.getSource(st);!e?.fill&&!e?.line||!t&&!this.#o||(t?t.setData(this.#o??et([])):this.#o&&this.#t.addSource(st,{type:"geojson",data:this.#o}),!this.#t.getLayer(oi)&&e.fill&&this.#t.addLayer({...e.fill,id:oi,type:"fill",source:st}),!this.#t.getLayer(li)&&e.line&&this.#t.addLayer({...e.line,id:li,type:"line",source:st}))}#a(e){this.#o=e,this.#f()}#p(e){return typeof e!="object"&&(e={element:this.#t?._container.ownerDocument.createElement("maptiler-geocode-marker"),offset:[1,-13]}),new Te.Marker(e)}#A(){const{fullGeometryStyle:e}=this.#e;if(e===!0||e===void 0)return gr;if(!(e===!1||e===null))return e}}$.DEFAULT_GEOMETRY_STYLE=gr,$.GeocodingControl=yr,$.MaplibreglGeocodingControl=yr,$.RESULT_LAYER_FILL=oi,$.RESULT_LAYER_LINE=li,$.RESULT_SOURCE=st,$.ZOOM_DEFAULTS=mr,Object.defineProperty($,Symbol.toStringTag,{value:"Module"})}));
281
281
  //# sourceMappingURL=maplibregl.umd.js.map