var hI=Object.defineProperty;var dI=(d,e,n)=>e in d?hI(d,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):d[e]=n;var rf=(d,e,n)=>(dI(d,typeof e!="symbol"?e+"":e,n),n);import fI from"./DatasetPageQuery.graphql.dda2e01a.js";import{c as A_,j as C_,A as I_,F as P_,J as L_,K as vm,a as yi,d as kf,g as Ye,M as bm,N as pI,P as Aa,Q as Qo,U as s_,W as qx,X as mI,Y as gI,Z as R_,_ as Zx,$ as Xx,a0 as $x,a1 as DM,a2 as Yx,q as Ca,a3 as md,a4 as zM,a5 as _I,a6 as yI,a7 as xI,a8 as vI,a9 as gd,aa as kM,ab as ox,ac as bI,L as eh,ad as wI,ae as OM,af as FM,m as p_,ag as BM,ah as NM,ai as UM,e as SI,aj as VM,ak as Jx,al as Kx,k as Qx,am as ev,an as MI,ao as Su,ap as ep,aq as tv,ar as EI,as as TI,at as nv,au as AI,av as dw,aw as fw,ax as CI,ay as II,az as PI,aA as GM,aB as jM,aC as LI,aD as RI,aE as DI,aF as zI,aG as kI,aH as OI,aI as FI,aJ as BI,R as fn,aK as NI,aL as a0,aM as WM,aN as pw,aO as UI,aP as VI,aQ as GI,aR as jI,aS as WI,aT as HI,aU as qI,aV as pg,aW as ZI,aX as XI,aY as $I,aZ as YI,a_ as JI,a$ as KI,T as QI,b0 as mw,b1 as eP,b2 as tP,b3 as nP,b4 as iP,b5 as Tf,b6 as HM,b7 as rP,b8 as D_,b9 as sP,t as oP,ba as aP,E as gw,r as lP,bb as cP,bc as uP,bd as hP,O as dP,be as fP,S as pP}from"./index.6894b23b.js";import{N as mP,S as gP}from"./Nav.57642b04.js";function _P(d,e){for(var n=0;n<e.length;n++){const a=e[n];if(typeof a!="string"&&!Array.isArray(a)){for(const c in a)if(c!=="default"&&!(c in d)){const f=Object.getOwnPropertyDescriptor(a,c);f&&Object.defineProperty(d,c,f.get?f:{enumerable:!0,get:()=>a[c]})}}}return Object.freeze(Object.defineProperty(d,Symbol.toStringTag,{value:"Module"}))}const qM=A_(C_.jsx("path",{d:"M5 15H3v4c0 1.1.9 2 2 2h4v-2H5v-4zM5 5h4V3H5c-1.1 0-2 .9-2 2v4h2V5zm14-2h-4v2h4v4h2V5c0-1.1-.9-2-2-2zm0 16h-4v2h4c1.1 0 2-.9 2-2v-4h-2v4zM12 8c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm0 6c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2z"}),"CenterFocusWeak"),yP=A_(C_.jsx("path",{d:"M17 5h-2V3h2v2zm-2 16h2v-2.59L19.59 21 21 19.59 18.41 17H21v-2h-6v6zm4-12h2V7h-2v2zm0 4h2v-2h-2v2zm-8 8h2v-2h-2v2zM7 5h2V3H7v2zM3 17h2v-2H3v2zm2 4v-2H3c0 1.1.9 2 2 2zM19 3v2h2c0-1.1-.9-2-2-2zm-8 2h2V3h-2v2zM3 9h2V7H3v2zm4 12h2v-2H7v2zm-4-8h2v-2H3v2zm0-8h2V3c-1.1 0-2 .9-2 2z"}),"HighlightAlt"),xP=A_(C_.jsx("path",{d:"M10 9h4V6h3l-5-5-5 5h3v3zm-1 1H6V7l-5 5 5 5v-3h3v-4zm14 2-5-5v3h-3v4h3v3l5-5zm-9 3h-4v3H7l5 5 5-5h-3v-3z"}),"OpenWith"),ZM=A_(C_.jsx("path",{d:"M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z"}),"Warning");var iv={},vP=L_.exports;Object.defineProperty(iv,"__esModule",{value:!0});var rv=iv.default=void 0,bP=vP(I_()),l0=P_(),wP=(0,bP.default)([(0,l0.jsx)("circle",{cx:"7",cy:"14",r:"3"},"0"),(0,l0.jsx)("circle",{cx:"11",cy:"6",r:"3"},"1"),(0,l0.jsx)("circle",{cx:"16.6",cy:"17.6",r:"3"},"2")],"ScatterPlot");rv=iv.default=wP;async function SP(d){return z_(await vm()("POST","/embeddings/selection",d))}async function MP(d){return z_(await vm()("POST","/embeddings/extended-stage",d))}async function EP(d){return z_(await vm()("POST","/embeddings/color-by-choices",d))}async function TP({datasetName:d,brainKey:e,view:n,labelField:a,slices:c}){const f=await vm()("POST","/embeddings/plot",{datasetName:d,brainKey:e,view:n,labelField:a,slices:c});return z_(f)}function z_(d){if(!d||!d.error)return d;throw new Error((d==null?void 0:d.error)||"Unknown error fetching embeddings plot data.")}function AP(){const d=yi(kf),[e]=wm(),[n,a]=Ye.exports.useState(!1),[c,f]=Ye.exports.useState(null),[m,i]=Ye.exports.useState(null);return Ye.exports.useEffect(()=>{e&&(a(!0),EP({datasetName:d,brainKey:e}).then(w=>{a(!1),f(["uncolored",...w.fields])}).catch(w=>{a(!1),i(w)}))},[d,e]),{availableFields:c,isLoading:n}}const sv=()=>Aa("colorByField",null);function CP(){yi(bm),yi(pI);const[d,e]=sv(),{availableFields:n,isLoading:a}=AP();return{label:d,handlers:{onSelect(f){f==="uncolored"&&(f=null),e(f)},value:d,toKey:f=>f,useSearch:f=>({values:n&&n.filter(m=>m.toLowerCase().includes(f.toLowerCase()))})},isLoading:a,canSelect:!a&&n&&n.length>0}}const wm=()=>Aa("brainResult",null);function IP(){const[d,e]=wm(),n=yi(bm),[a,c]=sv();return{handlers:{onSelect(m){e(m),c(null)},value:d,useSearch:m=>({values:PP(n).filter(i=>i.toLowerCase().includes(m.toLowerCase()))})},brainKey:d,canSelect:LP(n)>0,hasSelection:d!==null}}function PP(d){return d.brainMethods.filter(XM).map(e=>e.key)}function LP(d){return((d==null?void 0:d.brainMethods)||[]).filter(XM).length}function XM(d){return d.config.cls.includes("fiftyone.brain.visualization")}const RP=Qo.div`
  margin: 0;
  height: 100%;
  width: 100%;
  position: relative;
`,DP=Qo.div`
  display: flex;
  gap: 1rem;
  position: absolute;
  top: 1rem;
  display: flex;
  column-gap: 1rem;
  z-index: 999;
  padding: 0 1rem;
  > div {
    display: flex;
    column-gap: 1rem;
  }
`,sf=Qo(s_)`
  display: flex;
  color: var(--fo-palette-primary-plainColor);
  align-items: center;
  cursor: pointer;
  border-bottom: 1px var(--fo-palette-primary-plainColor) solid;
  background: var(--fo-palette-neutral-softBg);
  border-top-left-radius: 3px;
  border-top-right-radius: 3px;
  padding: 0.25rem;
`,zP=Qo.ul`
  position: absolute;
  top: 3rem;
  z-index: 999;
  list-style: none;
  padding-inline-start: 0;
  background: var(--fo-palette-background-level1);
  > li {
    margin: 1rem 0;
  }
`,kP=Qo.li`
  display: flex;
  column-gap: 1rem;
  color: var(--fo-palette-text-plainColor);
  padding: 0 2.5rem 0 1rem;
  border-radius: 3px;
  list-style: none;
  svg {
    position: relative;
    top: 3px;
  }
`,OP=Qo.div`
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  cursor: pointer;
`;function ov(){const[d,e]=Aa("warnings",{warnings:[]},!0),{warnings:n}=d,a=Array.isArray(n)&&n.length>0,c=f=>{e(m=>f(m||{warnings:[]}))};return{hasWarnings:a,items:n,visible:a&&d.visible,count:Array.isArray(n)?n.length:null,show(){c(f=>({...f,visible:!0}))},hide(){c(f=>({...f,visible:!1,userHidden:!0}))},clear(){c(f=>({...f,warnings:null}))},add(f){c(m=>({...m,visible:!0,warnings:[...m.warnings||[],f]}))}}}function FP(){const d=ov();return d.visible?React.createElement(zP,null,React.createElement(OP,null,React.createElement(qx,{onClick:d.hide})),d.items.map(e=>React.createElement(kP,null,React.createElement("div",null,React.createElement(ZM,null)),React.createElement("div",null,e)))):null}class yu{constructor(e,n,a){this.r=e,this.g=n,this.b=a}static fromCSSRGBValues(e,n,a){return new yu(e/255,n/255,a/255)}setBrightness(e){const n=this.getBrightness(),a=e-n;return new yu(this.r+a,this.g+a,this.b+a)}getBrightness(){return(this.r+this.g+this.b)/3}toCSSRGBString(){return`rgb(${this.r*255}, ${this.g*255}, ${this.b*255})`}}const _w={name:["AliceBlue","AntiqueWhite","Aqua","Aquamarine","Azure","Beige","Bisque","Black","BlanchedAlmond","Blue","BlueViolet","Brown","BurlyWood","CadetBlue","Chartreuse","Chocolate","Coral","CornflowerBlue","Cornsilk","Crimson","Cyan","DarkBlue","DarkCyan","DarkGoldenRod","DarkGray","DarkGrey","DarkGreen","DarkKhaki","DarkMagenta","DarkOliveGreen","DarkOrange","DarkOrchid","DarkRed","DarkSalmon","DarkSeaGreen","DarkSlateBlue","DarkSlateGray","DarkSlateGrey","DarkTurquoise","DarkViolet","DeepPink","DeepSkyBlue","DimGray","DimGrey","DodgerBlue","FireBrick","FloralWhite","ForestGreen","Fuchsia","Gainsboro","GhostWhite","Gold","GoldenRod","Gray","Grey","Green","GreenYellow","HoneyDew","HotPink","IndianRed","Indigo","Ivory","Khaki","Lavender","LavenderBlush","LawnGreen","LemonChiffon","LightBlue","LightCoral","LightCyan","LightGoldenRodYellow","LightGray","LightGrey","LightGreen","LightPink","LightSalmon","LightSeaGreen","LightSkyBlue","LightSlateGray","LightSlateGrey","LightSteelBlue","LightYellow","Lime","LimeGreen","Linen","Magenta","Maroon","MediumAquaMarine","MediumBlue","MediumOrchid","MediumPurple","MediumSeaGreen","MediumSlateBlue","MediumSpringGreen","MediumTurquoise","MediumVioletRed","MidnightBlue","MintCream","MistyRose","Moccasin","NavajoWhite","Navy","OldLace","Olive","OliveDrab","Orange","OrangeRed","Orchid","PaleGoldenRod","PaleGreen","PaleTurquoise","PaleVioletRed","PapayaWhip","PeachPuff","Peru","Pink","Plum","PowderBlue","Purple","RebeccaPurple","Red","RosyBrown","RoyalBlue","SaddleBrown","Salmon","SandyBrown","SeaGreen","SeaShell","Sienna","Silver","SkyBlue","SlateBlue","SlateGray","SlateGrey","Snow","SpringGreen","SteelBlue","Tan","Teal","Thistle","Tomato","Turquoise","Violet","Wheat","White","WhiteSmoke","Yellow","YellowGreen"],hex:["#f0f8ff","#faebd7","#00ffff","#7fffd4","#f0ffff","#f5f5dc","#ffe4c4","#000000","#ffebcd","#0000ff","#8a2be2","#a52a2a","#deb887","#5f9ea0","#7fff00","#d2691e","#ff7f50","#6495ed","#fff8dc","#dc143c","#00ffff","#00008b","#008b8b","#b8860b","#a9a9a9","#a9a9a9","#006400","#bdb76b","#8b008b","#556b2f","#ff8c00","#9932cc","#8b0000","#e9967a","#8fbc8f","#483d8b","#2f4f4f","#2f4f4f","#00ced1","#9400d3","#ff1493","#00bfff","#696969","#696969","#1e90ff","#b22222","#fffaf0","#228b22","#ff00ff","#dcdcdc","#f8f8ff","#ffd700","#daa520","#808080","#808080","#008000","#adff2f","#f0fff0","#ff69b4","#cd5c5c","#4b0082","#fffff0","#f0e68c","#e6e6fa","#fff0f5","#7cfc00","#fffacd","#add8e6","#f08080","#e0ffff","#fafad2","#d3d3d3","#d3d3d3","#90ee90","#ffb6c1","#ffa07a","#20b2aa","#87cefa","#778899","#778899","#b0c4de","#ffffe0","#00ff00","#32cd32","#faf0e6","#ff00ff","#800000","#66cdaa","#0000cd","#ba55d3","#9370db","#3cb371","#7b68ee","#00fa9a","#48d1cc","#c71585","#191970","#f5fffa","#ffe4e1","#ffe4b5","#ffdead","#000080","#fdf5e6","#808000","#6b8e23","#ffa500","#ff4500","#da70d6","#eee8aa","#98fb98","#afeeee","#db7093","#ffefd5","#ffdab9","#cd853f","#ffc0cb","#dda0dd","#b0e0e6","#800080","#663399","#ff0000","#bc8f8f","#4169e1","#8b4513","#fa8072","#f4a460","#2e8b57","#fff5ee","#a0522d","#c0c0c0","#87ceeb","#6a5acd","#708090","#708090","#fffafa","#00ff7f","#4682b4","#d2b48c","#008080","#d8bfd8","#ff6347","#40e0d0","#ee82ee","#f5deb3","#ffffff","#f5f5f5","#ffff00","#9acd32"]};function yw(d,e,n){for(var a=0;a<d.length;a++)if(d[a][e]===n)return a;return null}function BP(d,e){let n=yw(d,"id",e);return n==null&&(n=yw(d,"sample_id",e)),n}function NP(d,e){return d.localeCompare(e)}const av=35,UP=new RegExp(`.{1,${av}}(\\s|$)`,"g"),VP=new RegExp(`.{1,${av}}`,"g");function GP(d,e,n,a,c,f,m){const i=e==="categorical",w=e==="continuous",E=e==="uncolored";return Object.entries(d).sort((C,T)=>NP(C[0],T[0])).map(jP).map(([C,T])=>{var B,F;const I=a!=null&&a.length?a.map(H=>BP(T,H)).filter(H=>H!==null):null,k=(F=(B=WP(C,m))!=null?B:$M(n(C)))!=null?F:new yu(255,165,0),O=f.map((H,Y)=>{const K=yu.fromCSSRGBValues(...H);return[Y/(f.length-1),K.toCSSRGBString()]});return{x:T.map(H=>H.points[0]),y:T.map(H=>H.points[1]),ids:T.map(H=>H.id),type:"scattergl",mode:"markers",marker:{autocolorscale:!w,colorscale:O,color:i?k.toCSSRGBString():E?null:T.map(H=>H.label),size:6,colorbar:i||E?void 0:{lenmode:"fraction",x:1,y:.5}},name:C,selectedpoints:I,selected:{marker:{opacity:1,size:c==="selected"?10:6,color:c==="selected"?"orange":void 0}},unselected:{marker:{opacity:.2}}}})}const jP=([d,e])=>{if(d&&d.length>av){let n=d.match(UP);n.length===1&&(n=d.match(VP)),d=n.join("<br />")}return[d,e]},WP=(d,e)=>{var a;if(!e||!e.valueColors)return null;const n=(a=e.valueColors.find(c=>c.value===d))==null?void 0:a.color;return $M(n)},$M=d=>{if(Array.isArray(d))return yu.fromCSSRGBValues(...d);if(!mI(d))return null;if(d.startsWith("#")){const n=xw(d);return yu.fromCSSRGBValues(n.r,n.g,n.b)}if(d.startsWith("rgb")){const n=d.split("(")[1].split(")")[0].split(",");return yu.fromCSSRGBValues(parseInt(n[0]),parseInt(n[1]),parseInt(n[2]))}const e=_w.name.map(n=>n.toLowerCase()).indexOf(d);if(e>-1){const n=xw(_w.hex[e]);return yu.fromCSSRGBValues(n.r,n.g,n.b)}return null};function xw(d){const e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(d);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:null}function c0(d,e,n=[]){Ye.exports.useEffect(()=>{const a=c=>{c.key===d&&e(!0)};return document.addEventListener("keydown",a),()=>{document.removeEventListener("keydown",a)}},[d,...n])}function HP(){const d=yi(gI),e=yi(kf),[n,a]=wm(),[c]=sv(),f=yi(R_),m=yi(Zx(!1)),i=yi(Xx),[w,E]=Aa("loadedPlot",null,!0),[C,T]=Aa("loadingPlot",!0,!0),[I,k]=Aa("loadingPlotError",null,!0),O=$x(DM),B=ov();Ye.exports.useEffect(()=>{O(null),T(!0),TP({datasetName:e,filters:i,brainKey:n,view:f,labelField:c,slices:m}).catch(F=>{k(F)}).then(F=>{if(!F||!F.index_size){(F==null?void 0:F.index_size)===0&&B.add("No samples in the current view.");return}const H=F.index_size-F.available_count,Y=F.missing_count;F.index_size;const K=F.patches_field?"patches":"samples";B.clear(),Y>0&&B.add(`${Y} ${K} in the current view do not have corresponding embeddings.`),H>0&&B.add(`${H} embeddings in the index correspond to samples not in the current view`),k(null),E(F)}).finally(()=>T(!1))},[e,n,c,f,d,m,i])}function qP(){yi(kf);const[d]=wm(),e=yi(bm);return d&&e?e.brainMethods.find(a=>a.key===d):null}const ax="embe@fiftyone/embeddingsddings";function lv(){var ne;const d=qP(),e=(ne=d==null?void 0:d.config)==null?void 0:ne.patchesField,n=Yx(),[{selection:a,scope:c},f]=Ca(md),[m,i]=Ca(zM),[w,E]=Aa("plotSelection",[],!0),C=yi(_I(e)),T=yi(yI);function I(le){i(new Set),f({selection:le,scope:ax}),le===null&&k()}function k(){n(),E(null),i(new Set)}let O=null;const B=Array.from(m),F=Array.from(C),H=Array.from(T);let Y=null;return!e&&H&&H.length?(Y=H,O="selected"):F&&F.length?(Y=F,O="selected"):B&&B.length?(Y=B,O="selected"):w&&w.length?(Y=w,O="plot"):a&&a.length&&(Y=a,O="extended"),{setPlotSelection:E,handleSelected:I,clearSelection:k,resolvedSelection:Y,hasSelection:Y!==null,selectionStyle:O,selectionIsExternal:c!==ax}}function ZP(){const{setPlotSelection:d}=lv(),e=yi(kf),n=yi(zM),[a]=wm(),c=yi(R_),[f]=Aa("loadedPlot",null,!0),m=yi(Xx),i=yi(xI),{selection:w}=yi(md),E=yi(Zx(!1));Ye.exports.useEffect(()=>{f&&SP({datasetName:e,brainKey:a,view:c,filters:m,extended:w?i:null,extendedSelection:w,slices:E}).then(T=>{let I=null;T.selected?I=T.selected:n&&n.size&&(I=Array.from(n)),d(I)})},[e,a,c,m,w,n])}function XP(){const d=yi(kf),e=yi(R_),[n]=Aa("loadedPlot",null,!0),a=$x(DM),{selection:c}=yi(md),f=vI(({snapshot:i})=>async()=>i.getPromise(kf)),m=yi(Zx(!1));Ye.exports.useEffect(()=>{n&&Array.isArray(c)&&MP({datasetName:d,view:e,patchesField:n.patches_field,selection:c,slices:m}).then(async i=>{await f()===d&&a({[i._cls]:i.kwargs})})},[d,n==null?void 0:n.patches_field,e,c])}function $P({clearSelection:d,setPlotSelection:e}){const[n]=Aa("loadedPlot",null,!0),[a]=Aa("loadingPlot",!0,!0),[c]=Aa("loadingPlotError",null,!0);return HP(),ZP(),XP(),{...n||{},isLoading:a,error:c}}const YM=()=>Aa("zoomRevision",1,!0);function JM(){const[d,e]=YM();return()=>{e(a=>typeof a=="number"?a+1:2)}}function YP({labelSelectorLoading:d,labelField:e,bounds:n,plotSelection:a}){var Re,ke,Xe;const c=gd(),f=yi(kM),m=yi(ox).fields,i=yi(ox),w=yi(bI).scale,E=(Xe=(ke=(Re=i.colorscales.find(St=>St.path===e))==null?void 0:Re.rgb)!=null?ke:i.defaultColorscale.rgb)!=null?Xe:w,C=Ye.exports.useMemo(()=>m==null?void 0:m.find(St=>{var Je;return e==null?void 0:e.includes((Je=St==null?void 0:St.path)!=null?Je:"")}),[m,e]),{resolvedSelection:T,clearSelection:I,hasSelection:k,handleSelected:O,selectionStyle:B}=a,[F]=YM(),H=JM(),{isLoading:Y,traces:K,style:ne,error:le}=$P(a),[fe,Ae]=Aa("dragMode","lasso",!0);if(c0("s",()=>Ae("lasso")),c0("g",()=>Ae("pan")),c0("Escape",()=>{k?I():H()},[k]),le)return React.createElement(eh,null,le.message);if(d||Y||!K)return React.createElement(eh,null,"Pixelating...");const oe=GP(K,ne,f,T,B,E,C),ce=ne==="categorical";return React.createElement("div",{style:{height:"100%"},"data-cy":"embeddings-plot-container"},(n==null?void 0:n.width)&&React.createElement(wI,{data:oe,style:{zIndex:1},onSelected:(St,Je)=>{var Nt;if(!St||((Nt=St==null?void 0:St.points)==null?void 0:Nt.length)===0)return;const It={},ft=[];for(const Fe of St.points)It[Fe.fullData.name]||(It[Fe.fullData.name]=[]),It[Fe.fullData.name].push(Fe.id),ft.push(Fe.id);O(ft)},onDeselect:()=>{O(null)},config:{scrollZoom:!0,displaylogo:!1,responsive:!0,displayModeBar:!1},layout:{dragmode:fe,uirevision:F,font:{family:"var(--fo-fontFamily-body)",size:14},showlegend:ce,width:n.width,height:n.height,hovermode:!1,xaxis:{showgrid:!1,zeroline:!1,visible:!1},yaxis:{showgrid:!1,zeroline:!1,visible:!1,scaleanchor:"x",scaleratio:1},autosize:!0,margin:{t:0,l:0,b:0,r:0,pad:0},paper_bgcolor:"rgba(0,0,0,0)",plot_bgcolor:"rgba(0,0,0,0)",legend:{x:1,y:1,bgcolor:c.background.level1,font:{color:c.text.secondary}}}}))}const vw=({value:d})=>React.createElement(React.Fragment,null,d);function JP({containerHeight:d,dimensions:e}){const n=Ye.exports.useRef(),a=gd(),c=JM(),f=IP(),m=CP(),i=f.canSelect,w=f.hasSelection,E=lv(),[C,T]=Aa("dragMode","lasso",!0),I=ov(),k=OM(),O=FM("https://docs.voxel51.com");Ye.exports.useEffect(()=>{k(()=>{E.clearSelection()})},[k,E]);const B={background:a.neutral.softBg,borderTopLeftRadius:3,borderTopRightRadius:3,padding:"0.25rem"};return i?React.createElement(RP,{ref:n,"data-cy":"embeddings-container"},React.createElement(DP,null,React.createElement("div",null,React.createElement(p_,{cy:"embeddings",...f.handlers,placeholder:"Select brain key",overflow:!0,component:vw,resultsPlacement:"bottom-start",containerStyle:B}),f.hasSelection&&!m.isLoading&&React.createElement(p_,{cy:"embeddings-colorby",...m.handlers,placeholder:"Color by",overflow:!0,component:vw,resultsPlacement:"bottom-start",containerStyle:B}),!E.selectionIsExternal&&React.createElement(sf,{to:E.clearSelection,title:"Clear selection (Esc)"},React.createElement(qx,null)),w&&React.createElement(Ye.exports.Fragment,null,React.createElement(sf,{to:()=>c(),title:"Reset zoom (Esc)"},React.createElement(qM,null)),React.createElement(sf,{cy:"embeddings-plot-option-lasso",style:{opacity:C!=="lasso"?.5:1},to:()=>T("lasso"),title:"Select (s)"},React.createElement(yP,null)),React.createElement(sf,{style:{opacity:C!=="pan"?.5:1},to:()=>T("pan"),title:"Pan (g)"},React.createElement(xP,null)),I.count>0&&React.createElement(sf,{to:()=>I.show(),title:"Warnings"},React.createElement(ZM,{style:{marginRight:"0.5rem"}}),I.count),React.createElement(FP,null),React.createElement(sf,{href:"https://docs.voxel51.com/user_guide/app.html#embeddings-panel",title:"Help",to:O,target:"_blank"},React.createElement(BM,null))),React.createElement(NM,{place:UM.EMBEDDINGS_ACTIONS}))),w&&React.createElement(YP,{labelSelectorLoading:m.isLoading,plotSelection:E,bounds:e.bounds,el:n,brainKey:f.brainKey,labelField:m.label,containerHeight:d})):React.createElement(eh,{style:{background:a.background.mediaSpace}},React.createElement(KP,{style:{textAlign:"center"}},React.createElement("h3",null,"No embeddings visualizations found."),React.createElement("p",null,React.createElement(SI,{style:{color:a.text.primary},href:"https://docs.voxel51.com/user_guide/app.html#embeddings-panel"},"Learn more")," ","about using this feature.")))}const KP=Qo.div`
  text-align: center;
`;function QP(){const{selection:d,scope:e}=yi(md),n=lv();return e!==ax?null:React.createElement(VM,{selectionCount:d==null?void 0:d.length.toString(),onClickSelection:n.clearSelection})}Jx({name:"Embeddings",label:"Embeddings",component:JP,type:Kx.Panel,activator:()=>!0,Icon:rv,panelOptions:{TabIndicator:QP}});/**
 * @license
 * Copyright 2010-2022 Three.js Authors
 * SPDX-License-Identifier: MIT
 */const k_="141",jh={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},Wh={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},KM=0,lx=1,QM=2,eL=3,eE=0,O_=1,Kp=2,Xh=3,od=0,fl=1,ad=2,tE=1,tL=2,bu=0,ed=1,cx=2,ux=3,hx=4,nE=5,qh=100,iE=101,rE=102,dx=103,fx=104,sE=200,oE=201,aE=202,lE=203,cv=204,uv=205,cE=206,uE=207,hE=208,dE=209,fE=210,pE=0,mE=1,gE=2,m_=3,_E=4,yE=5,xE=6,vE=7,Sm=0,bE=1,wE=2,sc=0,SE=1,ME=2,EE=3,hv=4,TE=5,F_=300,rh=301,sh=302,nm=303,im=304,tp=306,rm=1e3,Ta=1001,sm=1002,uo=1003,g_=1004,nL=1004,__=1005,iL=1005,qs=1006,dv=1007,rL=1007,_d=1008,sL=1008,wu=1009,AE=1010,CE=1011,fv=1012,IE=1013,th=1014,xu=1015,Of=1016,PE=1017,LE=1018,td=1020,RE=1021,DE=1022,Qa=1023,zE=1024,kE=1025,ih=1026,ld=1027,OE=1028,FE=1029,BE=1030,NE=1031,UE=1033,o_=33776,a_=33777,l_=33778,c_=33779,px=35840,mx=35841,gx=35842,_x=35843,VE=36196,yx=37492,xx=37496,vx=37808,bx=37809,wx=37810,Sx=37811,Mx=37812,Ex=37813,Tx=37814,Ax=37815,Cx=37816,Ix=37817,Px=37818,Lx=37819,Rx=37820,Dx=37821,zx=36492,GE=2200,jE=2201,WE=2202,om=2300,am=2301,u_=2302,$h=2400,Yh=2401,lm=2402,B_=2500,pv=2501,oL=0,aL=1,lL=2,oh=3e3,hs=3001,HE=3200,qE=3201,yd=0,ZE=1,cL="",Nc="srgb",nh="srgb-linear",uL=0,h_=7680,hL=7681,dL=7682,fL=7683,pL=34055,mL=34056,gL=5386,_L=512,yL=513,xL=514,vL=515,bL=516,wL=517,SL=518,XE=519,y_=35044,ML=35048,EL=35040,TL=35045,AL=35049,CL=35041,IL=35046,PL=35050,LL=35042,RL="100",kx="300 es",x_=1035;class Mu{addEventListener(e,n){this._listeners===void 0&&(this._listeners={});const a=this._listeners;a[e]===void 0&&(a[e]=[]),a[e].indexOf(n)===-1&&a[e].push(n)}hasEventListener(e,n){if(this._listeners===void 0)return!1;const a=this._listeners;return a[e]!==void 0&&a[e].indexOf(n)!==-1}removeEventListener(e,n){if(this._listeners===void 0)return;const c=this._listeners[e];if(c!==void 0){const f=c.indexOf(n);f!==-1&&c.splice(f,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const a=this._listeners[e.type];if(a!==void 0){e.target=this;const c=a.slice(0);for(let f=0,m=c.length;f<m;f++)c[f].call(this,e);e.target=null}}}const Yo=[];for(let d=0;d<256;d++)Yo[d]=(d<16?"0":"")+d.toString(16);let bw=1234567;const nd=Math.PI/180,cm=180/Math.PI;function pl(){const d=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0,a=Math.random()*4294967295|0;return(Yo[d&255]+Yo[d>>8&255]+Yo[d>>16&255]+Yo[d>>24&255]+"-"+Yo[e&255]+Yo[e>>8&255]+"-"+Yo[e>>16&15|64]+Yo[e>>24&255]+"-"+Yo[n&63|128]+Yo[n>>8&255]+"-"+Yo[n>>16&255]+Yo[n>>24&255]+Yo[a&255]+Yo[a>>8&255]+Yo[a>>16&255]+Yo[a>>24&255]).toLowerCase()}function Zs(d,e,n){return Math.max(e,Math.min(n,d))}function mv(d,e){return(d%e+e)%e}function DL(d,e,n,a,c){return a+(d-e)*(c-a)/(n-e)}function zL(d,e,n){return d!==e?(n-d)/(e-d):0}function Qp(d,e,n){return(1-n)*d+n*e}function kL(d,e,n,a){return Qp(d,e,1-Math.exp(-n*a))}function OL(d,e=1){return e-Math.abs(mv(d,e*2)-e)}function FL(d,e,n){return d<=e?0:d>=n?1:(d=(d-e)/(n-e),d*d*(3-2*d))}function BL(d,e,n){return d<=e?0:d>=n?1:(d=(d-e)/(n-e),d*d*d*(d*(d*6-15)+10))}function NL(d,e){return d+Math.floor(Math.random()*(e-d+1))}function UL(d,e){return d+Math.random()*(e-d)}function VL(d){return d*(.5-Math.random())}function GL(d){d!==void 0&&(bw=d);let e=bw+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function jL(d){return d*nd}function WL(d){return d*cm}function Ox(d){return(d&d-1)===0&&d!==0}function $E(d){return Math.pow(2,Math.ceil(Math.log(d)/Math.LN2))}function v_(d){return Math.pow(2,Math.floor(Math.log(d)/Math.LN2))}function HL(d,e,n,a,c){const f=Math.cos,m=Math.sin,i=f(n/2),w=m(n/2),E=f((e+a)/2),C=m((e+a)/2),T=f((e-a)/2),I=m((e-a)/2),k=f((a-e)/2),O=m((a-e)/2);switch(c){case"XYX":d.set(i*C,w*T,w*I,i*E);break;case"YZY":d.set(w*I,i*C,w*T,i*E);break;case"ZXZ":d.set(w*T,w*I,i*C,i*E);break;case"XZX":d.set(i*C,w*O,w*k,i*E);break;case"YXY":d.set(w*k,i*C,w*O,i*E);break;case"ZYZ":d.set(w*O,w*k,i*C,i*E);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+c)}}function qL(d,e){switch(e.constructor){case Float32Array:return d;case Uint16Array:return d/65535;case Uint8Array:return d/255;case Int16Array:return Math.max(d/32767,-1);case Int8Array:return Math.max(d/127,-1);default:throw new Error("Invalid component type.")}}function ZL(d,e){switch(e.constructor){case Float32Array:return d;case Uint16Array:return Math.round(d*65535);case Uint8Array:return Math.round(d*255);case Int16Array:return Math.round(d*32767);case Int8Array:return Math.round(d*127);default:throw new Error("Invalid component type.")}}var XL=Object.freeze({__proto__:null,DEG2RAD:nd,RAD2DEG:cm,generateUUID:pl,clamp:Zs,euclideanModulo:mv,mapLinear:DL,inverseLerp:zL,lerp:Qp,damp:kL,pingpong:OL,smoothstep:FL,smootherstep:BL,randInt:NL,randFloat:UL,randFloatSpread:VL,seededRandom:GL,degToRad:jL,radToDeg:WL,isPowerOfTwo:Ox,ceilPowerOfTwo:$E,floorPowerOfTwo:v_,setQuaternionFromProperEuler:HL,normalize:ZL,denormalize:qL});class tn{constructor(e=0,n=0){this.isVector2=!0,this.x=e,this.y=n}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,n){return this.x=e,this.y=n,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e,n){return n!==void 0?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,n)):(this.x+=e.x,this.y+=e.y,this)}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this}sub(e,n){return n!==void 0?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,n)):(this.x-=e.x,this.y-=e.y,this)}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const n=this.x,a=this.y,c=e.elements;return this.x=c[0]*n+c[3]*a+c[6],this.y=c[1]*n+c[4]*a+c[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this}clampLength(e,n){const a=this.length();return this.divideScalar(a||1).multiplyScalar(Math.max(e,Math.min(n,a)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,a=this.y-e.y;return n*n+a*a}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this}lerpVectors(e,n,a){return this.x=e.x+(n.x-e.x)*a,this.y=e.y+(n.y-e.y)*a,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e}fromBufferAttribute(e,n,a){return a!==void 0&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(n),this.y=e.getY(n),this}rotateAround(e,n){const a=Math.cos(n),c=Math.sin(n),f=this.x-e.x,m=this.y-e.y;return this.x=f*a-m*c+e.x,this.y=f*c+m*a+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class kl{constructor(){this.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}set(e,n,a,c,f,m,i,w,E){const C=this.elements;return C[0]=e,C[1]=c,C[2]=i,C[3]=n,C[4]=f,C[5]=w,C[6]=a,C[7]=m,C[8]=E,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const n=this.elements,a=e.elements;return n[0]=a[0],n[1]=a[1],n[2]=a[2],n[3]=a[3],n[4]=a[4],n[5]=a[5],n[6]=a[6],n[7]=a[7],n[8]=a[8],this}extractBasis(e,n,a){return e.setFromMatrix3Column(this,0),n.setFromMatrix3Column(this,1),a.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const n=e.elements;return this.set(n[0],n[4],n[8],n[1],n[5],n[9],n[2],n[6],n[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const a=e.elements,c=n.elements,f=this.elements,m=a[0],i=a[3],w=a[6],E=a[1],C=a[4],T=a[7],I=a[2],k=a[5],O=a[8],B=c[0],F=c[3],H=c[6],Y=c[1],K=c[4],ne=c[7],le=c[2],fe=c[5],Ae=c[8];return f[0]=m*B+i*Y+w*le,f[3]=m*F+i*K+w*fe,f[6]=m*H+i*ne+w*Ae,f[1]=E*B+C*Y+T*le,f[4]=E*F+C*K+T*fe,f[7]=E*H+C*ne+T*Ae,f[2]=I*B+k*Y+O*le,f[5]=I*F+k*K+O*fe,f[8]=I*H+k*ne+O*Ae,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=e,n[4]*=e,n[7]*=e,n[2]*=e,n[5]*=e,n[8]*=e,this}determinant(){const e=this.elements,n=e[0],a=e[1],c=e[2],f=e[3],m=e[4],i=e[5],w=e[6],E=e[7],C=e[8];return n*m*C-n*i*E-a*f*C+a*i*w+c*f*E-c*m*w}invert(){const e=this.elements,n=e[0],a=e[1],c=e[2],f=e[3],m=e[4],i=e[5],w=e[6],E=e[7],C=e[8],T=C*m-i*E,I=i*w-C*f,k=E*f-m*w,O=n*T+a*I+c*k;if(O===0)return this.set(0,0,0,0,0,0,0,0,0);const B=1/O;return e[0]=T*B,e[1]=(c*E-C*a)*B,e[2]=(i*a-c*m)*B,e[3]=I*B,e[4]=(C*n-c*w)*B,e[5]=(c*f-i*n)*B,e[6]=k*B,e[7]=(a*w-E*n)*B,e[8]=(m*n-a*f)*B,this}transpose(){let e;const n=this.elements;return e=n[1],n[1]=n[3],n[3]=e,e=n[2],n[2]=n[6],n[6]=e,e=n[5],n[5]=n[7],n[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const n=this.elements;return e[0]=n[0],e[1]=n[3],e[2]=n[6],e[3]=n[1],e[4]=n[4],e[5]=n[7],e[6]=n[2],e[7]=n[5],e[8]=n[8],this}setUvTransform(e,n,a,c,f,m,i){const w=Math.cos(f),E=Math.sin(f);return this.set(a*w,a*E,-a*(w*m+E*i)+m+e,-c*E,c*w,-c*(-E*m+w*i)+i+n,0,0,1),this}scale(e,n){const a=this.elements;return a[0]*=e,a[3]*=e,a[6]*=e,a[1]*=n,a[4]*=n,a[7]*=n,this}rotate(e){const n=Math.cos(e),a=Math.sin(e),c=this.elements,f=c[0],m=c[3],i=c[6],w=c[1],E=c[4],C=c[7];return c[0]=n*f+a*w,c[3]=n*m+a*E,c[6]=n*i+a*C,c[1]=-a*f+n*w,c[4]=-a*m+n*E,c[7]=-a*i+n*C,this}translate(e,n){const a=this.elements;return a[0]+=e*a[2],a[3]+=e*a[5],a[6]+=e*a[8],a[1]+=n*a[2],a[4]+=n*a[5],a[7]+=n*a[8],this}equals(e){const n=this.elements,a=e.elements;for(let c=0;c<9;c++)if(n[c]!==a[c])return!1;return!0}fromArray(e,n=0){for(let a=0;a<9;a++)this.elements[a]=e[a+n];return this}toArray(e=[],n=0){const a=this.elements;return e[n]=a[0],e[n+1]=a[1],e[n+2]=a[2],e[n+3]=a[3],e[n+4]=a[4],e[n+5]=a[5],e[n+6]=a[6],e[n+7]=a[7],e[n+8]=a[8],e}clone(){return new this.constructor().fromArray(this.elements)}}function YE(d){for(let e=d.length-1;e>=0;--e)if(d[e]>65535)return!0;return!1}const $L={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function If(d,e){return new $L[d](e)}function um(d){return document.createElementNS("http://www.w3.org/1999/xhtml",d)}function id(d){return d<.04045?d*.0773993808:Math.pow(d*.9478672986+.0521327014,2.4)}function d_(d){return d<.0031308?d*12.92:1.055*Math.pow(d,.41666)-.055}const u0={[Nc]:{[nh]:id},[nh]:{[Nc]:d_}},Dl={legacyMode:!0,get workingColorSpace(){return nh},set workingColorSpace(d){console.warn("THREE.ColorManagement: .workingColorSpace is readonly.")},convert:function(d,e,n){if(this.legacyMode||e===n||!e||!n)return d;if(u0[e]&&u0[e][n]!==void 0){const a=u0[e][n];return d.r=a(d.r),d.g=a(d.g),d.b=a(d.b),d}throw new Error("Unsupported color space conversion.")},fromWorkingColorSpace:function(d,e){return this.convert(d,this.workingColorSpace,e)},toWorkingColorSpace:function(d,e){return this.convert(d,e,this.workingColorSpace)}},JE={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Eo={r:0,g:0,b:0},Ql={h:0,s:0,l:0},mg={h:0,s:0,l:0};function h0(d,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?d+(e-d)*6*n:n<1/2?e:n<2/3?d+(e-d)*6*(2/3-n):d}function gg(d,e){return e.r=d.r,e.g=d.g,e.b=d.b,e}class Kn{constructor(e,n,a){return this.isColor=!0,this.r=1,this.g=1,this.b=1,n===void 0&&a===void 0?this.set(e):this.setRGB(e,n,a)}set(e){return e&&e.isColor?this.copy(e):typeof e=="number"?this.setHex(e):typeof e=="string"&&this.setStyle(e),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,n=Nc){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Dl.toWorkingColorSpace(this,n),this}setRGB(e,n,a,c=nh){return this.r=e,this.g=n,this.b=a,Dl.toWorkingColorSpace(this,c),this}setHSL(e,n,a,c=nh){if(e=mv(e,1),n=Zs(n,0,1),a=Zs(a,0,1),n===0)this.r=this.g=this.b=a;else{const f=a<=.5?a*(1+n):a+n-a*n,m=2*a-f;this.r=h0(m,f,e+1/3),this.g=h0(m,f,e),this.b=h0(m,f,e-1/3)}return Dl.toWorkingColorSpace(this,c),this}setStyle(e,n=Nc){function a(f){f!==void 0&&parseFloat(f)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let c;if(c=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(e)){let f;const m=c[1],i=c[2];switch(m){case"rgb":case"rgba":if(f=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(i))return this.r=Math.min(255,parseInt(f[1],10))/255,this.g=Math.min(255,parseInt(f[2],10))/255,this.b=Math.min(255,parseInt(f[3],10))/255,Dl.toWorkingColorSpace(this,n),a(f[4]),this;if(f=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(i))return this.r=Math.min(100,parseInt(f[1],10))/100,this.g=Math.min(100,parseInt(f[2],10))/100,this.b=Math.min(100,parseInt(f[3],10))/100,Dl.toWorkingColorSpace(this,n),a(f[4]),this;break;case"hsl":case"hsla":if(f=/^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(i)){const w=parseFloat(f[1])/360,E=parseInt(f[2],10)/100,C=parseInt(f[3],10)/100;return a(f[4]),this.setHSL(w,E,C,n)}break}}else if(c=/^\#([A-Fa-f\d]+)$/.exec(e)){const f=c[1],m=f.length;if(m===3)return this.r=parseInt(f.charAt(0)+f.charAt(0),16)/255,this.g=parseInt(f.charAt(1)+f.charAt(1),16)/255,this.b=parseInt(f.charAt(2)+f.charAt(2),16)/255,Dl.toWorkingColorSpace(this,n),this;if(m===6)return this.r=parseInt(f.charAt(0)+f.charAt(1),16)/255,this.g=parseInt(f.charAt(2)+f.charAt(3),16)/255,this.b=parseInt(f.charAt(4)+f.charAt(5),16)/255,Dl.toWorkingColorSpace(this,n),this}return e&&e.length>0?this.setColorName(e,n):this}setColorName(e,n=Nc){const a=JE[e.toLowerCase()];return a!==void 0?this.setHex(a,n):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=id(e.r),this.g=id(e.g),this.b=id(e.b),this}copyLinearToSRGB(e){return this.r=d_(e.r),this.g=d_(e.g),this.b=d_(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Nc){return Dl.fromWorkingColorSpace(gg(this,Eo),e),Zs(Eo.r*255,0,255)<<16^Zs(Eo.g*255,0,255)<<8^Zs(Eo.b*255,0,255)<<0}getHexString(e=Nc){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,n=nh){Dl.fromWorkingColorSpace(gg(this,Eo),n);const a=Eo.r,c=Eo.g,f=Eo.b,m=Math.max(a,c,f),i=Math.min(a,c,f);let w,E;const C=(i+m)/2;if(i===m)w=0,E=0;else{const T=m-i;switch(E=C<=.5?T/(m+i):T/(2-m-i),m){case a:w=(c-f)/T+(c<f?6:0);break;case c:w=(f-a)/T+2;break;case f:w=(a-c)/T+4;break}w/=6}return e.h=w,e.s=E,e.l=C,e}getRGB(e,n=nh){return Dl.fromWorkingColorSpace(gg(this,Eo),n),e.r=Eo.r,e.g=Eo.g,e.b=Eo.b,e}getStyle(e=Nc){return Dl.fromWorkingColorSpace(gg(this,Eo),e),e!==Nc?`color(${e} ${Eo.r} ${Eo.g} ${Eo.b})`:`rgb(${Eo.r*255|0},${Eo.g*255|0},${Eo.b*255|0})`}offsetHSL(e,n,a){return this.getHSL(Ql),Ql.h+=e,Ql.s+=n,Ql.l+=a,this.setHSL(Ql.h,Ql.s,Ql.l),this}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,n){return this.r=e.r+n.r,this.g=e.g+n.g,this.b=e.b+n.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,n){return this.r+=(e.r-this.r)*n,this.g+=(e.g-this.g)*n,this.b+=(e.b-this.b)*n,this}lerpColors(e,n,a){return this.r=e.r+(n.r-e.r)*a,this.g=e.g+(n.g-e.g)*a,this.b=e.b+(n.b-e.b)*a,this}lerpHSL(e,n){this.getHSL(Ql),e.getHSL(mg);const a=Qp(Ql.h,mg.h,n),c=Qp(Ql.s,mg.s,n),f=Qp(Ql.l,mg.l,n);return this.setHSL(a,c,f),this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,n=0){return this.r=e[n],this.g=e[n+1],this.b=e[n+2],this}toArray(e=[],n=0){return e[n]=this.r,e[n+1]=this.g,e[n+2]=this.b,e}fromBufferAttribute(e,n){return this.r=e.getX(n),this.g=e.getY(n),this.b=e.getZ(n),e.normalized===!0&&(this.r/=255,this.g/=255,this.b/=255),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}Kn.NAMES=JE;let of;class gv{static getDataURL(e){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{of===void 0&&(of=um("canvas")),of.width=e.width,of.height=e.height;const a=of.getContext("2d");e instanceof ImageData?a.putImageData(e,0,0):a.drawImage(e,0,0,e.width,e.height),n=of}return n.width>2048||n.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),n.toDataURL("image/jpeg",.6)):n.toDataURL("image/png")}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const n=um("canvas");n.width=e.width,n.height=e.height;const a=n.getContext("2d");a.drawImage(e,0,0,e.width,e.height);const c=a.getImageData(0,0,e.width,e.height),f=c.data;for(let m=0;m<f.length;m++)f[m]=id(f[m]/255)*255;return a.putImageData(c,0,0),n}else if(e.data){const n=e.data.slice(0);for(let a=0;a<n.length;a++)n instanceof Uint8Array||n instanceof Uint8ClampedArray?n[a]=Math.floor(id(n[a]/255)*255):n[a]=id(n[a]);return{data:n,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}class Jh{constructor(e=null){this.isSource=!0,this.uuid=pl(),this.data=e,this.version=0}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const a={uuid:this.uuid,url:""},c=this.data;if(c!==null){let f;if(Array.isArray(c)){f=[];for(let m=0,i=c.length;m<i;m++)c[m].isDataTexture?f.push(d0(c[m].image)):f.push(d0(c[m]))}else f=d0(c);a.url=f}return n||(e.images[this.uuid]=a),a}}function d0(d){return typeof HTMLImageElement<"u"&&d instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&d instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&d instanceof ImageBitmap?gv.getDataURL(d):d.data?{data:Array.prototype.slice.call(d.data),width:d.width,height:d.height,type:d.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let YL=0;class ho extends Mu{constructor(e=ho.DEFAULT_IMAGE,n=ho.DEFAULT_MAPPING,a=Ta,c=Ta,f=qs,m=_d,i=Qa,w=wu,E=1,C=oh){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:YL++}),this.uuid=pl(),this.name="",this.source=new Jh(e),this.mipmaps=[],this.mapping=n,this.wrapS=a,this.wrapT=c,this.magFilter=f,this.minFilter=m,this.anisotropy=E,this.format=i,this.internalFormat=null,this.type=w,this.offset=new tn(0,0),this.repeat=new tn(1,1),this.center=new tn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new kl,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=C,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.encoding=e.encoding,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){const n=e===void 0||typeof e=="string";if(!n&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const a={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return JSON.stringify(this.userData)!=="{}"&&(a.userData=this.userData),n||(e.textures[this.uuid]=a),a}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==F_)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case rm:e.x=e.x-Math.floor(e.x);break;case Ta:e.x=e.x<0?0:1;break;case sm:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case rm:e.y=e.y-Math.floor(e.y);break;case Ta:e.y=e.y<0?0:1;break;case sm:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}}ho.DEFAULT_IMAGE=null;ho.DEFAULT_MAPPING=F_;class Wr{constructor(e=0,n=0,a=0,c=1){this.isVector4=!0,this.x=e,this.y=n,this.z=a,this.w=c}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,n,a,c){return this.x=e,this.y=n,this.z=a,this.w=c,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;case 3:this.w=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e,n){return n!==void 0?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,n)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this)}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this.w=e.w+n.w,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this.w+=e.w*n,this}sub(e,n){return n!==void 0?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,n)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this)}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this.w=e.w-n.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const n=this.x,a=this.y,c=this.z,f=this.w,m=e.elements;return this.x=m[0]*n+m[4]*a+m[8]*c+m[12]*f,this.y=m[1]*n+m[5]*a+m[9]*c+m[13]*f,this.z=m[2]*n+m[6]*a+m[10]*c+m[14]*f,this.w=m[3]*n+m[7]*a+m[11]*c+m[15]*f,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const n=Math.sqrt(1-e.w*e.w);return n<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/n,this.y=e.y/n,this.z=e.z/n),this}setAxisAngleFromRotationMatrix(e){let n,a,c,f;const w=e.elements,E=w[0],C=w[4],T=w[8],I=w[1],k=w[5],O=w[9],B=w[2],F=w[6],H=w[10];if(Math.abs(C-I)<.01&&Math.abs(T-B)<.01&&Math.abs(O-F)<.01){if(Math.abs(C+I)<.1&&Math.abs(T+B)<.1&&Math.abs(O+F)<.1&&Math.abs(E+k+H-3)<.1)return this.set(1,0,0,0),this;n=Math.PI;const K=(E+1)/2,ne=(k+1)/2,le=(H+1)/2,fe=(C+I)/4,Ae=(T+B)/4,oe=(O+F)/4;return K>ne&&K>le?K<.01?(a=0,c=.707106781,f=.707106781):(a=Math.sqrt(K),c=fe/a,f=Ae/a):ne>le?ne<.01?(a=.707106781,c=0,f=.707106781):(c=Math.sqrt(ne),a=fe/c,f=oe/c):le<.01?(a=.707106781,c=.707106781,f=0):(f=Math.sqrt(le),a=Ae/f,c=oe/f),this.set(a,c,f,n),this}let Y=Math.sqrt((F-O)*(F-O)+(T-B)*(T-B)+(I-C)*(I-C));return Math.abs(Y)<.001&&(Y=1),this.x=(F-O)/Y,this.y=(T-B)/Y,this.z=(I-C)/Y,this.w=Math.acos((E+k+H-1)/2),this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this.w=Math.max(e.w,Math.min(n.w,this.w)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this.w=Math.max(e,Math.min(n,this.w)),this}clampLength(e,n){const a=this.length();return this.divideScalar(a||1).multiplyScalar(Math.max(e,Math.min(n,a)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this.w+=(e.w-this.w)*n,this}lerpVectors(e,n,a){return this.x=e.x+(n.x-e.x)*a,this.y=e.y+(n.y-e.y)*a,this.z=e.z+(n.z-e.z)*a,this.w=e.w+(n.w-e.w)*a,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this.w=e[n+3],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e[n+3]=this.w,e}fromBufferAttribute(e,n,a){return a!==void 0&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this.w=e.getW(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class ml extends Mu{constructor(e,n,a={}){super(),this.isWebGLRenderTarget=!0,this.width=e,this.height=n,this.depth=1,this.scissor=new Wr(0,0,e,n),this.scissorTest=!1,this.viewport=new Wr(0,0,e,n);const c={width:e,height:n,depth:1};this.texture=new ho(c,a.mapping,a.wrapS,a.wrapT,a.magFilter,a.minFilter,a.format,a.type,a.anisotropy,a.encoding),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=a.generateMipmaps!==void 0?a.generateMipmaps:!1,this.texture.internalFormat=a.internalFormat!==void 0?a.internalFormat:null,this.texture.minFilter=a.minFilter!==void 0?a.minFilter:qs,this.depthBuffer=a.depthBuffer!==void 0?a.depthBuffer:!0,this.stencilBuffer=a.stencilBuffer!==void 0?a.stencilBuffer:!1,this.depthTexture=a.depthTexture!==void 0?a.depthTexture:null,this.samples=a.samples!==void 0?a.samples:0}setSize(e,n,a=1){(this.width!==e||this.height!==n||this.depth!==a)&&(this.width=e,this.height=n,this.depth=a,this.texture.image.width=e,this.texture.image.height=n,this.texture.image.depth=a,this.dispose()),this.viewport.set(0,0,e,n),this.scissor.set(0,0,e,n)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;const n=Object.assign({},e.texture.image);return this.texture.source=new Jh(n),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Mm extends ho{constructor(e=null,n=1,a=1,c=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:n,height:a,depth:c},this.magFilter=uo,this.minFilter=uo,this.wrapR=Ta,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class JL extends ml{constructor(e,n,a){super(e,n),this.isWebGLArrayRenderTarget=!0,this.depth=a,this.texture=new Mm(null,e,n,a),this.texture.isRenderTargetTexture=!0}}class N_ extends ho{constructor(e=null,n=1,a=1,c=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:n,height:a,depth:c},this.magFilter=uo,this.minFilter=uo,this.wrapR=Ta,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class KL extends ml{constructor(e,n,a){super(e,n),this.isWebGL3DRenderTarget=!0,this.depth=a,this.texture=new N_(null,e,n,a),this.texture.isRenderTargetTexture=!0}}class QL extends ml{constructor(e,n,a,c={}){super(e,n,c),this.isWebGLMultipleRenderTargets=!0;const f=this.texture;this.texture=[];for(let m=0;m<a;m++)this.texture[m]=f.clone(),this.texture[m].isRenderTargetTexture=!0}setSize(e,n,a=1){if(this.width!==e||this.height!==n||this.depth!==a){this.width=e,this.height=n,this.depth=a;for(let c=0,f=this.texture.length;c<f;c++)this.texture[c].image.width=e,this.texture[c].image.height=n,this.texture[c].image.depth=a;this.dispose()}return this.viewport.set(0,0,e,n),this.scissor.set(0,0,e,n),this}copy(e){this.dispose(),this.width=e.width,this.height=e.height,this.depth=e.depth,this.viewport.set(0,0,this.width,this.height),this.scissor.set(0,0,this.width,this.height),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.texture.length=0;for(let n=0,a=e.texture.length;n<a;n++)this.texture[n]=e.texture[n].clone(),this.texture[n].isRenderTargetTexture=!0;return this}}class Ko{constructor(e=0,n=0,a=0,c=1){this.isQuaternion=!0,this._x=e,this._y=n,this._z=a,this._w=c}static slerp(e,n,a,c){return console.warn("THREE.Quaternion: Static .slerp() has been deprecated. Use qm.slerpQuaternions( qa, qb, t ) instead."),a.slerpQuaternions(e,n,c)}static slerpFlat(e,n,a,c,f,m,i){let w=a[c+0],E=a[c+1],C=a[c+2],T=a[c+3];const I=f[m+0],k=f[m+1],O=f[m+2],B=f[m+3];if(i===0){e[n+0]=w,e[n+1]=E,e[n+2]=C,e[n+3]=T;return}if(i===1){e[n+0]=I,e[n+1]=k,e[n+2]=O,e[n+3]=B;return}if(T!==B||w!==I||E!==k||C!==O){let F=1-i;const H=w*I+E*k+C*O+T*B,Y=H>=0?1:-1,K=1-H*H;if(K>Number.EPSILON){const le=Math.sqrt(K),fe=Math.atan2(le,H*Y);F=Math.sin(F*fe)/le,i=Math.sin(i*fe)/le}const ne=i*Y;if(w=w*F+I*ne,E=E*F+k*ne,C=C*F+O*ne,T=T*F+B*ne,F===1-i){const le=1/Math.sqrt(w*w+E*E+C*C+T*T);w*=le,E*=le,C*=le,T*=le}}e[n]=w,e[n+1]=E,e[n+2]=C,e[n+3]=T}static multiplyQuaternionsFlat(e,n,a,c,f,m){const i=a[c],w=a[c+1],E=a[c+2],C=a[c+3],T=f[m],I=f[m+1],k=f[m+2],O=f[m+3];return e[n]=i*O+C*T+w*k-E*I,e[n+1]=w*O+C*I+E*T-i*k,e[n+2]=E*O+C*k+i*I-w*T,e[n+3]=C*O-i*T-w*I-E*k,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,n,a,c){return this._x=e,this._y=n,this._z=a,this._w=c,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,n){if(!(e&&e.isEuler))throw new Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");const a=e._x,c=e._y,f=e._z,m=e._order,i=Math.cos,w=Math.sin,E=i(a/2),C=i(c/2),T=i(f/2),I=w(a/2),k=w(c/2),O=w(f/2);switch(m){case"XYZ":this._x=I*C*T+E*k*O,this._y=E*k*T-I*C*O,this._z=E*C*O+I*k*T,this._w=E*C*T-I*k*O;break;case"YXZ":this._x=I*C*T+E*k*O,this._y=E*k*T-I*C*O,this._z=E*C*O-I*k*T,this._w=E*C*T+I*k*O;break;case"ZXY":this._x=I*C*T-E*k*O,this._y=E*k*T+I*C*O,this._z=E*C*O+I*k*T,this._w=E*C*T-I*k*O;break;case"ZYX":this._x=I*C*T-E*k*O,this._y=E*k*T+I*C*O,this._z=E*C*O-I*k*T,this._w=E*C*T+I*k*O;break;case"YZX":this._x=I*C*T+E*k*O,this._y=E*k*T+I*C*O,this._z=E*C*O-I*k*T,this._w=E*C*T-I*k*O;break;case"XZY":this._x=I*C*T-E*k*O,this._y=E*k*T-I*C*O,this._z=E*C*O+I*k*T,this._w=E*C*T+I*k*O;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+m)}return n!==!1&&this._onChangeCallback(),this}setFromAxisAngle(e,n){const a=n/2,c=Math.sin(a);return this._x=e.x*c,this._y=e.y*c,this._z=e.z*c,this._w=Math.cos(a),this._onChangeCallback(),this}setFromRotationMatrix(e){const n=e.elements,a=n[0],c=n[4],f=n[8],m=n[1],i=n[5],w=n[9],E=n[2],C=n[6],T=n[10],I=a+i+T;if(I>0){const k=.5/Math.sqrt(I+1);this._w=.25/k,this._x=(C-w)*k,this._y=(f-E)*k,this._z=(m-c)*k}else if(a>i&&a>T){const k=2*Math.sqrt(1+a-i-T);this._w=(C-w)/k,this._x=.25*k,this._y=(c+m)/k,this._z=(f+E)/k}else if(i>T){const k=2*Math.sqrt(1+i-a-T);this._w=(f-E)/k,this._x=(c+m)/k,this._y=.25*k,this._z=(w+C)/k}else{const k=2*Math.sqrt(1+T-a-i);this._w=(m-c)/k,this._x=(f+E)/k,this._y=(w+C)/k,this._z=.25*k}return this._onChangeCallback(),this}setFromUnitVectors(e,n){let a=e.dot(n)+1;return a<Number.EPSILON?(a=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=a):(this._x=0,this._y=-e.z,this._z=e.y,this._w=a)):(this._x=e.y*n.z-e.z*n.y,this._y=e.z*n.x-e.x*n.z,this._z=e.x*n.y-e.y*n.x,this._w=a),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Zs(this.dot(e),-1,1)))}rotateTowards(e,n){const a=this.angleTo(e);if(a===0)return this;const c=Math.min(1,n/a);return this.slerp(e,c),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e,n){return n!==void 0?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,n)):this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,n){const a=e._x,c=e._y,f=e._z,m=e._w,i=n._x,w=n._y,E=n._z,C=n._w;return this._x=a*C+m*i+c*E-f*w,this._y=c*C+m*w+f*i-a*E,this._z=f*C+m*E+a*w-c*i,this._w=m*C-a*i-c*w-f*E,this._onChangeCallback(),this}slerp(e,n){if(n===0)return this;if(n===1)return this.copy(e);const a=this._x,c=this._y,f=this._z,m=this._w;let i=m*e._w+a*e._x+c*e._y+f*e._z;if(i<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,i=-i):this.copy(e),i>=1)return this._w=m,this._x=a,this._y=c,this._z=f,this;const w=1-i*i;if(w<=Number.EPSILON){const k=1-n;return this._w=k*m+n*this._w,this._x=k*a+n*this._x,this._y=k*c+n*this._y,this._z=k*f+n*this._z,this.normalize(),this._onChangeCallback(),this}const E=Math.sqrt(w),C=Math.atan2(E,i),T=Math.sin((1-n)*C)/E,I=Math.sin(n*C)/E;return this._w=m*T+this._w*I,this._x=a*T+this._x*I,this._y=c*T+this._y*I,this._z=f*T+this._z*I,this._onChangeCallback(),this}slerpQuaternions(e,n,a){return this.copy(e).slerp(n,a)}random(){const e=Math.random(),n=Math.sqrt(1-e),a=Math.sqrt(e),c=2*Math.PI*Math.random(),f=2*Math.PI*Math.random();return this.set(n*Math.cos(c),a*Math.sin(f),a*Math.cos(f),n*Math.sin(c))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,n=0){return this._x=e[n],this._y=e[n+1],this._z=e[n+2],this._w=e[n+3],this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._w,e}fromBufferAttribute(e,n){return this._x=e.getX(n),this._y=e.getY(n),this._z=e.getZ(n),this._w=e.getW(n),this}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Me{constructor(e=0,n=0,a=0){this.isVector3=!0,this.x=e,this.y=n,this.z=a}set(e,n,a){return a===void 0&&(a=this.z),this.x=e,this.y=n,this.z=a,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,n){switch(e){case 0:this.x=n;break;case 1:this.y=n;break;case 2:this.z=n;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e,n){return n!==void 0?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,n)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this)}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,n){return this.x=e.x+n.x,this.y=e.y+n.y,this.z=e.z+n.z,this}addScaledVector(e,n){return this.x+=e.x*n,this.y+=e.y*n,this.z+=e.z*n,this}sub(e,n){return n!==void 0?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,n)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this)}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,n){return this.x=e.x-n.x,this.y=e.y-n.y,this.z=e.z-n.z,this}multiply(e,n){return n!==void 0?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(e,n)):(this.x*=e.x,this.y*=e.y,this.z*=e.z,this)}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,n){return this.x=e.x*n.x,this.y=e.y*n.y,this.z=e.z*n.z,this}applyEuler(e){return e&&e.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(ww.setFromEuler(e))}applyAxisAngle(e,n){return this.applyQuaternion(ww.setFromAxisAngle(e,n))}applyMatrix3(e){const n=this.x,a=this.y,c=this.z,f=e.elements;return this.x=f[0]*n+f[3]*a+f[6]*c,this.y=f[1]*n+f[4]*a+f[7]*c,this.z=f[2]*n+f[5]*a+f[8]*c,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const n=this.x,a=this.y,c=this.z,f=e.elements,m=1/(f[3]*n+f[7]*a+f[11]*c+f[15]);return this.x=(f[0]*n+f[4]*a+f[8]*c+f[12])*m,this.y=(f[1]*n+f[5]*a+f[9]*c+f[13])*m,this.z=(f[2]*n+f[6]*a+f[10]*c+f[14])*m,this}applyQuaternion(e){const n=this.x,a=this.y,c=this.z,f=e.x,m=e.y,i=e.z,w=e.w,E=w*n+m*c-i*a,C=w*a+i*n-f*c,T=w*c+f*a-m*n,I=-f*n-m*a-i*c;return this.x=E*w+I*-f+C*-i-T*-m,this.y=C*w+I*-m+T*-f-E*-i,this.z=T*w+I*-i+E*-m-C*-f,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const n=this.x,a=this.y,c=this.z,f=e.elements;return this.x=f[0]*n+f[4]*a+f[8]*c,this.y=f[1]*n+f[5]*a+f[9]*c,this.z=f[2]*n+f[6]*a+f[10]*c,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,n){return this.x=Math.max(e.x,Math.min(n.x,this.x)),this.y=Math.max(e.y,Math.min(n.y,this.y)),this.z=Math.max(e.z,Math.min(n.z,this.z)),this}clampScalar(e,n){return this.x=Math.max(e,Math.min(n,this.x)),this.y=Math.max(e,Math.min(n,this.y)),this.z=Math.max(e,Math.min(n,this.z)),this}clampLength(e,n){const a=this.length();return this.divideScalar(a||1).multiplyScalar(Math.max(e,Math.min(n,a)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,n){return this.x+=(e.x-this.x)*n,this.y+=(e.y-this.y)*n,this.z+=(e.z-this.z)*n,this}lerpVectors(e,n,a){return this.x=e.x+(n.x-e.x)*a,this.y=e.y+(n.y-e.y)*a,this.z=e.z+(n.z-e.z)*a,this}cross(e,n){return n!==void 0?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,n)):this.crossVectors(this,e)}crossVectors(e,n){const a=e.x,c=e.y,f=e.z,m=n.x,i=n.y,w=n.z;return this.x=c*w-f*i,this.y=f*m-a*w,this.z=a*i-c*m,this}projectOnVector(e){const n=e.lengthSq();if(n===0)return this.set(0,0,0);const a=e.dot(this)/n;return this.copy(e).multiplyScalar(a)}projectOnPlane(e){return f0.copy(this).projectOnVector(e),this.sub(f0)}reflect(e){return this.sub(f0.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const n=Math.sqrt(this.lengthSq()*e.lengthSq());if(n===0)return Math.PI/2;const a=this.dot(e)/n;return Math.acos(Zs(a,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const n=this.x-e.x,a=this.y-e.y,c=this.z-e.z;return n*n+a*a+c*c}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,n,a){const c=Math.sin(n)*e;return this.x=c*Math.sin(a),this.y=Math.cos(n)*e,this.z=c*Math.cos(a),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,n,a){return this.x=e*Math.sin(n),this.y=a,this.z=e*Math.cos(n),this}setFromMatrixPosition(e){const n=e.elements;return this.x=n[12],this.y=n[13],this.z=n[14],this}setFromMatrixScale(e){const n=this.setFromMatrixColumn(e,0).length(),a=this.setFromMatrixColumn(e,1).length(),c=this.setFromMatrixColumn(e,2).length();return this.x=n,this.y=a,this.z=c,this}setFromMatrixColumn(e,n){return this.fromArray(e.elements,n*4)}setFromMatrix3Column(e,n){return this.fromArray(e.elements,n*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,n=0){return this.x=e[n],this.y=e[n+1],this.z=e[n+2],this}toArray(e=[],n=0){return e[n]=this.x,e[n+1]=this.y,e[n+2]=this.z,e}fromBufferAttribute(e,n,a){return a!==void 0&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(n),this.y=e.getY(n),this.z=e.getZ(n),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=(Math.random()-.5)*2,n=Math.random()*Math.PI*2,a=Math.sqrt(1-e**2);return this.x=a*Math.cos(n),this.y=a*Math.sin(n),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const f0=new Me,ww=new Ko;class xd{constructor(e=new Me(1/0,1/0,1/0),n=new Me(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=n}set(e,n){return this.min.copy(e),this.max.copy(n),this}setFromArray(e){let n=1/0,a=1/0,c=1/0,f=-1/0,m=-1/0,i=-1/0;for(let w=0,E=e.length;w<E;w+=3){const C=e[w],T=e[w+1],I=e[w+2];C<n&&(n=C),T<a&&(a=T),I<c&&(c=I),C>f&&(f=C),T>m&&(m=T),I>i&&(i=I)}return this.min.set(n,a,c),this.max.set(f,m,i),this}setFromBufferAttribute(e){let n=1/0,a=1/0,c=1/0,f=-1/0,m=-1/0,i=-1/0;for(let w=0,E=e.count;w<E;w++){const C=e.getX(w),T=e.getY(w),I=e.getZ(w);C<n&&(n=C),T<a&&(a=T),I<c&&(c=I),C>f&&(f=C),T>m&&(m=T),I>i&&(i=I)}return this.min.set(n,a,c),this.max.set(f,m,i),this}setFromPoints(e){this.makeEmpty();for(let n=0,a=e.length;n<a;n++)this.expandByPoint(e[n]);return this}setFromCenterAndSize(e,n){const a=zh.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(a),this.max.copy(e).add(a),this}setFromObject(e,n=!1){return this.makeEmpty(),this.expandByObject(e,n)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,n=!1){e.updateWorldMatrix(!1,!1);const a=e.geometry;if(a!==void 0)if(n&&a.attributes!=null&&a.attributes.position!==void 0){const f=a.attributes.position;for(let m=0,i=f.count;m<i;m++)zh.fromBufferAttribute(f,m).applyMatrix4(e.matrixWorld),this.expandByPoint(zh)}else a.boundingBox===null&&a.computeBoundingBox(),p0.copy(a.boundingBox),p0.applyMatrix4(e.matrixWorld),this.union(p0);const c=e.children;for(let f=0,m=c.length;f<m;f++)this.expandByObject(c[f],n);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,n){return n.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,zh),zh.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let n,a;return e.normal.x>0?(n=e.normal.x*this.min.x,a=e.normal.x*this.max.x):(n=e.normal.x*this.max.x,a=e.normal.x*this.min.x),e.normal.y>0?(n+=e.normal.y*this.min.y,a+=e.normal.y*this.max.y):(n+=e.normal.y*this.max.y,a+=e.normal.y*this.min.y),e.normal.z>0?(n+=e.normal.z*this.min.z,a+=e.normal.z*this.max.z):(n+=e.normal.z*this.max.z,a+=e.normal.z*this.min.z),n<=-e.constant&&a>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Vp),_g.subVectors(this.max,Vp),af.subVectors(e.a,Vp),lf.subVectors(e.b,Vp),cf.subVectors(e.c,Vp),qu.subVectors(lf,af),Zu.subVectors(cf,lf),kh.subVectors(af,cf);let n=[0,-qu.z,qu.y,0,-Zu.z,Zu.y,0,-kh.z,kh.y,qu.z,0,-qu.x,Zu.z,0,-Zu.x,kh.z,0,-kh.x,-qu.y,qu.x,0,-Zu.y,Zu.x,0,-kh.y,kh.x,0];return!m0(n,af,lf,cf,_g)||(n=[1,0,0,0,1,0,0,0,1],!m0(n,af,lf,cf,_g))?!1:(yg.crossVectors(qu,Zu),n=[yg.x,yg.y,yg.z],m0(n,af,lf,cf,_g))}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return zh.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return this.getCenter(e.center),e.radius=this.getSize(zh).length()*.5,e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(hu[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),hu[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),hu[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),hu[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),hu[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),hu[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),hu[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),hu[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(hu),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const hu=[new Me,new Me,new Me,new Me,new Me,new Me,new Me,new Me],zh=new Me,p0=new xd,af=new Me,lf=new Me,cf=new Me,qu=new Me,Zu=new Me,kh=new Me,Vp=new Me,_g=new Me,yg=new Me,Oh=new Me;function m0(d,e,n,a,c){for(let f=0,m=d.length-3;f<=m;f+=3){Oh.fromArray(d,f);const i=c.x*Math.abs(Oh.x)+c.y*Math.abs(Oh.y)+c.z*Math.abs(Oh.z),w=e.dot(Oh),E=n.dot(Oh),C=a.dot(Oh);if(Math.max(-Math.max(w,E,C),Math.min(w,E,C))>i)return!1}return!0}const e3=new xd,Sw=new Me,xg=new Me,g0=new Me;class vd{constructor(e=new Me,n=-1){this.center=e,this.radius=n}set(e,n){return this.center.copy(e),this.radius=n,this}setFromPoints(e,n){const a=this.center;n!==void 0?a.copy(n):e3.setFromPoints(e).getCenter(a);let c=0;for(let f=0,m=e.length;f<m;f++)c=Math.max(c,a.distanceToSquared(e[f]));return this.radius=Math.sqrt(c),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const n=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=n*n}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,n){const a=this.center.distanceToSquared(e);return n.copy(e),a>this.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){g0.subVectors(e,this.center);const n=g0.lengthSq();if(n>this.radius*this.radius){const a=Math.sqrt(n),c=(a-this.radius)*.5;this.center.add(g0.multiplyScalar(c/a)),this.radius+=c}return this}union(e){return this.center.equals(e.center)===!0?xg.set(0,0,1).multiplyScalar(e.radius):xg.subVectors(e.center,this.center).normalize().multiplyScalar(e.radius),this.expandByPoint(Sw.copy(e.center).add(xg)),this.expandByPoint(Sw.copy(e.center).sub(xg)),this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}}const du=new Me,_0=new Me,vg=new Me,Xu=new Me,y0=new Me,bg=new Me,x0=new Me;class np{constructor(e=new Me,n=new Me(0,0,-1)){this.origin=e,this.direction=n}set(e,n){return this.origin.copy(e),this.direction.copy(n),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,n){return n.copy(this.direction).multiplyScalar(e).add(this.origin)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,du)),this}closestPointToPoint(e,n){n.subVectors(e,this.origin);const a=n.dot(this.direction);return a<0?n.copy(this.origin):n.copy(this.direction).multiplyScalar(a).add(this.origin)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const n=du.subVectors(e,this.origin).dot(this.direction);return n<0?this.origin.distanceToSquared(e):(du.copy(this.direction).multiplyScalar(n).add(this.origin),du.distanceToSquared(e))}distanceSqToSegment(e,n,a,c){_0.copy(e).add(n).multiplyScalar(.5),vg.copy(n).sub(e).normalize(),Xu.copy(this.origin).sub(_0);const f=e.distanceTo(n)*.5,m=-this.direction.dot(vg),i=Xu.dot(this.direction),w=-Xu.dot(vg),E=Xu.lengthSq(),C=Math.abs(1-m*m);let T,I,k,O;if(C>0)if(T=m*w-i,I=m*i-w,O=f*C,T>=0)if(I>=-O)if(I<=O){const B=1/C;T*=B,I*=B,k=T*(T+m*I+2*i)+I*(m*T+I+2*w)+E}else I=f,T=Math.max(0,-(m*I+i)),k=-T*T+I*(I+2*w)+E;else I=-f,T=Math.max(0,-(m*I+i)),k=-T*T+I*(I+2*w)+E;else I<=-O?(T=Math.max(0,-(-m*f+i)),I=T>0?-f:Math.min(Math.max(-f,-w),f),k=-T*T+I*(I+2*w)+E):I<=O?(T=0,I=Math.min(Math.max(-f,-w),f),k=I*(I+2*w)+E):(T=Math.max(0,-(m*f+i)),I=T>0?f:Math.min(Math.max(-f,-w),f),k=-T*T+I*(I+2*w)+E);else I=m>0?-f:f,T=Math.max(0,-(m*I+i)),k=-T*T+I*(I+2*w)+E;return a&&a.copy(this.direction).multiplyScalar(T).add(this.origin),c&&c.copy(vg).multiplyScalar(I).add(_0),k}intersectSphere(e,n){du.subVectors(e.center,this.origin);const a=du.dot(this.direction),c=du.dot(du)-a*a,f=e.radius*e.radius;if(c>f)return null;const m=Math.sqrt(f-c),i=a-m,w=a+m;return i<0&&w<0?null:i<0?this.at(w,n):this.at(i,n)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const n=e.normal.dot(this.direction);if(n===0)return e.distanceToPoint(this.origin)===0?0:null;const a=-(this.origin.dot(e.normal)+e.constant)/n;return a>=0?a:null}intersectPlane(e,n){const a=this.distanceToPlane(e);return a===null?null:this.at(a,n)}intersectsPlane(e){const n=e.distanceToPoint(this.origin);return n===0||e.normal.dot(this.direction)*n<0}intersectBox(e,n){let a,c,f,m,i,w;const E=1/this.direction.x,C=1/this.direction.y,T=1/this.direction.z,I=this.origin;return E>=0?(a=(e.min.x-I.x)*E,c=(e.max.x-I.x)*E):(a=(e.max.x-I.x)*E,c=(e.min.x-I.x)*E),C>=0?(f=(e.min.y-I.y)*C,m=(e.max.y-I.y)*C):(f=(e.max.y-I.y)*C,m=(e.min.y-I.y)*C),a>m||f>c||((f>a||a!==a)&&(a=f),(m<c||c!==c)&&(c=m),T>=0?(i=(e.min.z-I.z)*T,w=(e.max.z-I.z)*T):(i=(e.max.z-I.z)*T,w=(e.min.z-I.z)*T),a>w||i>c)||((i>a||a!==a)&&(a=i),(w<c||c!==c)&&(c=w),c<0)?null:this.at(a>=0?a:c,n)}intersectsBox(e){return this.intersectBox(e,du)!==null}intersectTriangle(e,n,a,c,f){y0.subVectors(n,e),bg.subVectors(a,e),x0.crossVectors(y0,bg);let m=this.direction.dot(x0),i;if(m>0){if(c)return null;i=1}else if(m<0)i=-1,m=-m;else return null;Xu.subVectors(this.origin,e);const w=i*this.direction.dot(bg.crossVectors(Xu,bg));if(w<0)return null;const E=i*this.direction.dot(y0.cross(Xu));if(E<0||w+E>m)return null;const C=-i*Xu.dot(x0);return C<0?null:this.at(C/m,f)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class sr{constructor(){this.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}set(e,n,a,c,f,m,i,w,E,C,T,I,k,O,B,F){const H=this.elements;return H[0]=e,H[4]=n,H[8]=a,H[12]=c,H[1]=f,H[5]=m,H[9]=i,H[13]=w,H[2]=E,H[6]=C,H[10]=T,H[14]=I,H[3]=k,H[7]=O,H[11]=B,H[15]=F,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new sr().fromArray(this.elements)}copy(e){const n=this.elements,a=e.elements;return n[0]=a[0],n[1]=a[1],n[2]=a[2],n[3]=a[3],n[4]=a[4],n[5]=a[5],n[6]=a[6],n[7]=a[7],n[8]=a[8],n[9]=a[9],n[10]=a[10],n[11]=a[11],n[12]=a[12],n[13]=a[13],n[14]=a[14],n[15]=a[15],this}copyPosition(e){const n=this.elements,a=e.elements;return n[12]=a[12],n[13]=a[13],n[14]=a[14],this}setFromMatrix3(e){const n=e.elements;return this.set(n[0],n[3],n[6],0,n[1],n[4],n[7],0,n[2],n[5],n[8],0,0,0,0,1),this}extractBasis(e,n,a){return e.setFromMatrixColumn(this,0),n.setFromMatrixColumn(this,1),a.setFromMatrixColumn(this,2),this}makeBasis(e,n,a){return this.set(e.x,n.x,a.x,0,e.y,n.y,a.y,0,e.z,n.z,a.z,0,0,0,0,1),this}extractRotation(e){const n=this.elements,a=e.elements,c=1/uf.setFromMatrixColumn(e,0).length(),f=1/uf.setFromMatrixColumn(e,1).length(),m=1/uf.setFromMatrixColumn(e,2).length();return n[0]=a[0]*c,n[1]=a[1]*c,n[2]=a[2]*c,n[3]=0,n[4]=a[4]*f,n[5]=a[5]*f,n[6]=a[6]*f,n[7]=0,n[8]=a[8]*m,n[9]=a[9]*m,n[10]=a[10]*m,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromEuler(e){e&&e.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");const n=this.elements,a=e.x,c=e.y,f=e.z,m=Math.cos(a),i=Math.sin(a),w=Math.cos(c),E=Math.sin(c),C=Math.cos(f),T=Math.sin(f);if(e.order==="XYZ"){const I=m*C,k=m*T,O=i*C,B=i*T;n[0]=w*C,n[4]=-w*T,n[8]=E,n[1]=k+O*E,n[5]=I-B*E,n[9]=-i*w,n[2]=B-I*E,n[6]=O+k*E,n[10]=m*w}else if(e.order==="YXZ"){const I=w*C,k=w*T,O=E*C,B=E*T;n[0]=I+B*i,n[4]=O*i-k,n[8]=m*E,n[1]=m*T,n[5]=m*C,n[9]=-i,n[2]=k*i-O,n[6]=B+I*i,n[10]=m*w}else if(e.order==="ZXY"){const I=w*C,k=w*T,O=E*C,B=E*T;n[0]=I-B*i,n[4]=-m*T,n[8]=O+k*i,n[1]=k+O*i,n[5]=m*C,n[9]=B-I*i,n[2]=-m*E,n[6]=i,n[10]=m*w}else if(e.order==="ZYX"){const I=m*C,k=m*T,O=i*C,B=i*T;n[0]=w*C,n[4]=O*E-k,n[8]=I*E+B,n[1]=w*T,n[5]=B*E+I,n[9]=k*E-O,n[2]=-E,n[6]=i*w,n[10]=m*w}else if(e.order==="YZX"){const I=m*w,k=m*E,O=i*w,B=i*E;n[0]=w*C,n[4]=B-I*T,n[8]=O*T+k,n[1]=T,n[5]=m*C,n[9]=-i*C,n[2]=-E*C,n[6]=k*T+O,n[10]=I-B*T}else if(e.order==="XZY"){const I=m*w,k=m*E,O=i*w,B=i*E;n[0]=w*C,n[4]=-T,n[8]=E*C,n[1]=I*T+B,n[5]=m*C,n[9]=k*T-O,n[2]=O*T-k,n[6]=i*C,n[10]=B*T+I}return n[3]=0,n[7]=0,n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,this}makeRotationFromQuaternion(e){return this.compose(t3,e,n3)}lookAt(e,n,a){const c=this.elements;return ul.subVectors(e,n),ul.lengthSq()===0&&(ul.z=1),ul.normalize(),$u.crossVectors(a,ul),$u.lengthSq()===0&&(Math.abs(a.z)===1?ul.x+=1e-4:ul.z+=1e-4,ul.normalize(),$u.crossVectors(a,ul)),$u.normalize(),wg.crossVectors(ul,$u),c[0]=$u.x,c[4]=wg.x,c[8]=ul.x,c[1]=$u.y,c[5]=wg.y,c[9]=ul.y,c[2]=$u.z,c[6]=wg.z,c[10]=ul.z,this}multiply(e,n){return n!==void 0?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(e,n)):this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,n){const a=e.elements,c=n.elements,f=this.elements,m=a[0],i=a[4],w=a[8],E=a[12],C=a[1],T=a[5],I=a[9],k=a[13],O=a[2],B=a[6],F=a[10],H=a[14],Y=a[3],K=a[7],ne=a[11],le=a[15],fe=c[0],Ae=c[4],oe=c[8],ce=c[12],Re=c[1],ke=c[5],Xe=c[9],St=c[13],Je=c[2],It=c[6],ft=c[10],Nt=c[14],Fe=c[3],it=c[7],tt=c[11],Et=c[15];return f[0]=m*fe+i*Re+w*Je+E*Fe,f[4]=m*Ae+i*ke+w*It+E*it,f[8]=m*oe+i*Xe+w*ft+E*tt,f[12]=m*ce+i*St+w*Nt+E*Et,f[1]=C*fe+T*Re+I*Je+k*Fe,f[5]=C*Ae+T*ke+I*It+k*it,f[9]=C*oe+T*Xe+I*ft+k*tt,f[13]=C*ce+T*St+I*Nt+k*Et,f[2]=O*fe+B*Re+F*Je+H*Fe,f[6]=O*Ae+B*ke+F*It+H*it,f[10]=O*oe+B*Xe+F*ft+H*tt,f[14]=O*ce+B*St+F*Nt+H*Et,f[3]=Y*fe+K*Re+ne*Je+le*Fe,f[7]=Y*Ae+K*ke+ne*It+le*it,f[11]=Y*oe+K*Xe+ne*ft+le*tt,f[15]=Y*ce+K*St+ne*Nt+le*Et,this}multiplyScalar(e){const n=this.elements;return n[0]*=e,n[4]*=e,n[8]*=e,n[12]*=e,n[1]*=e,n[5]*=e,n[9]*=e,n[13]*=e,n[2]*=e,n[6]*=e,n[10]*=e,n[14]*=e,n[3]*=e,n[7]*=e,n[11]*=e,n[15]*=e,this}determinant(){const e=this.elements,n=e[0],a=e[4],c=e[8],f=e[12],m=e[1],i=e[5],w=e[9],E=e[13],C=e[2],T=e[6],I=e[10],k=e[14],O=e[3],B=e[7],F=e[11],H=e[15];return O*(+f*w*T-c*E*T-f*i*I+a*E*I+c*i*k-a*w*k)+B*(+n*w*k-n*E*I+f*m*I-c*m*k+c*E*C-f*w*C)+F*(+n*E*T-n*i*k-f*m*T+a*m*k+f*i*C-a*E*C)+H*(-c*i*C-n*w*T+n*i*I+c*m*T-a*m*I+a*w*C)}transpose(){const e=this.elements;let n;return n=e[1],e[1]=e[4],e[4]=n,n=e[2],e[2]=e[8],e[8]=n,n=e[6],e[6]=e[9],e[9]=n,n=e[3],e[3]=e[12],e[12]=n,n=e[7],e[7]=e[13],e[13]=n,n=e[11],e[11]=e[14],e[14]=n,this}setPosition(e,n,a){const c=this.elements;return e.isVector3?(c[12]=e.x,c[13]=e.y,c[14]=e.z):(c[12]=e,c[13]=n,c[14]=a),this}invert(){const e=this.elements,n=e[0],a=e[1],c=e[2],f=e[3],m=e[4],i=e[5],w=e[6],E=e[7],C=e[8],T=e[9],I=e[10],k=e[11],O=e[12],B=e[13],F=e[14],H=e[15],Y=T*F*E-B*I*E+B*w*k-i*F*k-T*w*H+i*I*H,K=O*I*E-C*F*E-O*w*k+m*F*k+C*w*H-m*I*H,ne=C*B*E-O*T*E+O*i*k-m*B*k-C*i*H+m*T*H,le=O*T*w-C*B*w-O*i*I+m*B*I+C*i*F-m*T*F,fe=n*Y+a*K+c*ne+f*le;if(fe===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const Ae=1/fe;return e[0]=Y*Ae,e[1]=(B*I*f-T*F*f-B*c*k+a*F*k+T*c*H-a*I*H)*Ae,e[2]=(i*F*f-B*w*f+B*c*E-a*F*E-i*c*H+a*w*H)*Ae,e[3]=(T*w*f-i*I*f-T*c*E+a*I*E+i*c*k-a*w*k)*Ae,e[4]=K*Ae,e[5]=(C*F*f-O*I*f+O*c*k-n*F*k-C*c*H+n*I*H)*Ae,e[6]=(O*w*f-m*F*f-O*c*E+n*F*E+m*c*H-n*w*H)*Ae,e[7]=(m*I*f-C*w*f+C*c*E-n*I*E-m*c*k+n*w*k)*Ae,e[8]=ne*Ae,e[9]=(O*T*f-C*B*f-O*a*k+n*B*k+C*a*H-n*T*H)*Ae,e[10]=(m*B*f-O*i*f+O*a*E-n*B*E-m*a*H+n*i*H)*Ae,e[11]=(C*i*f-m*T*f-C*a*E+n*T*E+m*a*k-n*i*k)*Ae,e[12]=le*Ae,e[13]=(C*B*c-O*T*c+O*a*I-n*B*I-C*a*F+n*T*F)*Ae,e[14]=(O*i*c-m*B*c-O*a*w+n*B*w+m*a*F-n*i*F)*Ae,e[15]=(m*T*c-C*i*c+C*a*w-n*T*w-m*a*I+n*i*I)*Ae,this}scale(e){const n=this.elements,a=e.x,c=e.y,f=e.z;return n[0]*=a,n[4]*=c,n[8]*=f,n[1]*=a,n[5]*=c,n[9]*=f,n[2]*=a,n[6]*=c,n[10]*=f,n[3]*=a,n[7]*=c,n[11]*=f,this}getMaxScaleOnAxis(){const e=this.elements,n=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],a=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],c=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(n,a,c))}makeTranslation(e,n,a){return this.set(1,0,0,e,0,1,0,n,0,0,1,a,0,0,0,1),this}makeRotationX(e){const n=Math.cos(e),a=Math.sin(e);return this.set(1,0,0,0,0,n,-a,0,0,a,n,0,0,0,0,1),this}makeRotationY(e){const n=Math.cos(e),a=Math.sin(e);return this.set(n,0,a,0,0,1,0,0,-a,0,n,0,0,0,0,1),this}makeRotationZ(e){const n=Math.cos(e),a=Math.sin(e);return this.set(n,-a,0,0,a,n,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,n){const a=Math.cos(n),c=Math.sin(n),f=1-a,m=e.x,i=e.y,w=e.z,E=f*m,C=f*i;return this.set(E*m+a,E*i-c*w,E*w+c*i,0,E*i+c*w,C*i+a,C*w-c*m,0,E*w-c*i,C*w+c*m,f*w*w+a,0,0,0,0,1),this}makeScale(e,n,a){return this.set(e,0,0,0,0,n,0,0,0,0,a,0,0,0,0,1),this}makeShear(e,n,a,c,f,m){return this.set(1,a,f,0,e,1,m,0,n,c,1,0,0,0,0,1),this}compose(e,n,a){const c=this.elements,f=n._x,m=n._y,i=n._z,w=n._w,E=f+f,C=m+m,T=i+i,I=f*E,k=f*C,O=f*T,B=m*C,F=m*T,H=i*T,Y=w*E,K=w*C,ne=w*T,le=a.x,fe=a.y,Ae=a.z;return c[0]=(1-(B+H))*le,c[1]=(k+ne)*le,c[2]=(O-K)*le,c[3]=0,c[4]=(k-ne)*fe,c[5]=(1-(I+H))*fe,c[6]=(F+Y)*fe,c[7]=0,c[8]=(O+K)*Ae,c[9]=(F-Y)*Ae,c[10]=(1-(I+B))*Ae,c[11]=0,c[12]=e.x,c[13]=e.y,c[14]=e.z,c[15]=1,this}decompose(e,n,a){const c=this.elements;let f=uf.set(c[0],c[1],c[2]).length();const m=uf.set(c[4],c[5],c[6]).length(),i=uf.set(c[8],c[9],c[10]).length();this.determinant()<0&&(f=-f),e.x=c[12],e.y=c[13],e.z=c[14],ec.copy(this);const E=1/f,C=1/m,T=1/i;return ec.elements[0]*=E,ec.elements[1]*=E,ec.elements[2]*=E,ec.elements[4]*=C,ec.elements[5]*=C,ec.elements[6]*=C,ec.elements[8]*=T,ec.elements[9]*=T,ec.elements[10]*=T,n.setFromRotationMatrix(ec),a.x=f,a.y=m,a.z=i,this}makePerspective(e,n,a,c,f,m){m===void 0&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");const i=this.elements,w=2*f/(n-e),E=2*f/(a-c),C=(n+e)/(n-e),T=(a+c)/(a-c),I=-(m+f)/(m-f),k=-2*m*f/(m-f);return i[0]=w,i[4]=0,i[8]=C,i[12]=0,i[1]=0,i[5]=E,i[9]=T,i[13]=0,i[2]=0,i[6]=0,i[10]=I,i[14]=k,i[3]=0,i[7]=0,i[11]=-1,i[15]=0,this}makeOrthographic(e,n,a,c,f,m){const i=this.elements,w=1/(n-e),E=1/(a-c),C=1/(m-f),T=(n+e)*w,I=(a+c)*E,k=(m+f)*C;return i[0]=2*w,i[4]=0,i[8]=0,i[12]=-T,i[1]=0,i[5]=2*E,i[9]=0,i[13]=-I,i[2]=0,i[6]=0,i[10]=-2*C,i[14]=-k,i[3]=0,i[7]=0,i[11]=0,i[15]=1,this}equals(e){const n=this.elements,a=e.elements;for(let c=0;c<16;c++)if(n[c]!==a[c])return!1;return!0}fromArray(e,n=0){for(let a=0;a<16;a++)this.elements[a]=e[a+n];return this}toArray(e=[],n=0){const a=this.elements;return e[n]=a[0],e[n+1]=a[1],e[n+2]=a[2],e[n+3]=a[3],e[n+4]=a[4],e[n+5]=a[5],e[n+6]=a[6],e[n+7]=a[7],e[n+8]=a[8],e[n+9]=a[9],e[n+10]=a[10],e[n+11]=a[11],e[n+12]=a[12],e[n+13]=a[13],e[n+14]=a[14],e[n+15]=a[15],e}}const uf=new Me,ec=new sr,t3=new Me(0,0,0),n3=new Me(1,1,1),$u=new Me,wg=new Me,ul=new Me,Mw=new sr,Ew=new Ko;class ip{constructor(e=0,n=0,a=0,c=ip.DefaultOrder){this.isEuler=!0,this._x=e,this._y=n,this._z=a,this._order=c}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,n,a,c=this._order){return this._x=e,this._y=n,this._z=a,this._order=c,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,n=this._order,a=!0){const c=e.elements,f=c[0],m=c[4],i=c[8],w=c[1],E=c[5],C=c[9],T=c[2],I=c[6],k=c[10];switch(n){case"XYZ":this._y=Math.asin(Zs(i,-1,1)),Math.abs(i)<.9999999?(this._x=Math.atan2(-C,k),this._z=Math.atan2(-m,f)):(this._x=Math.atan2(I,E),this._z=0);break;case"YXZ":this._x=Math.asin(-Zs(C,-1,1)),Math.abs(C)<.9999999?(this._y=Math.atan2(i,k),this._z=Math.atan2(w,E)):(this._y=Math.atan2(-T,f),this._z=0);break;case"ZXY":this._x=Math.asin(Zs(I,-1,1)),Math.abs(I)<.9999999?(this._y=Math.atan2(-T,k),this._z=Math.atan2(-m,E)):(this._y=0,this._z=Math.atan2(w,f));break;case"ZYX":this._y=Math.asin(-Zs(T,-1,1)),Math.abs(T)<.9999999?(this._x=Math.atan2(I,k),this._z=Math.atan2(w,f)):(this._x=0,this._z=Math.atan2(-m,E));break;case"YZX":this._z=Math.asin(Zs(w,-1,1)),Math.abs(w)<.9999999?(this._x=Math.atan2(-C,E),this._y=Math.atan2(-T,f)):(this._x=0,this._y=Math.atan2(i,k));break;case"XZY":this._z=Math.asin(-Zs(m,-1,1)),Math.abs(m)<.9999999?(this._x=Math.atan2(I,E),this._y=Math.atan2(i,f)):(this._x=Math.atan2(-C,k),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+n)}return this._order=n,a===!0&&this._onChangeCallback(),this}setFromQuaternion(e,n,a){return Mw.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Mw,n,a)}setFromVector3(e,n=this._order){return this.set(e.x,e.y,e.z,n)}reorder(e){return Ew.setFromEuler(this),this.setFromQuaternion(Ew,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],n=0){return e[n]=this._x,e[n+1]=this._y,e[n+2]=this._z,e[n+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}toVector3(){console.error("THREE.Euler: .toVector3() has been removed. Use Vector3.setFromEuler() instead")}}ip.DefaultOrder="XYZ";ip.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];class rd{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let i3=0;const Tw=new Me,hf=new Ko,fu=new sr,Sg=new Me,Gp=new Me,r3=new Me,s3=new Ko,Aw=new Me(1,0,0),Cw=new Me(0,1,0),Iw=new Me(0,0,1),o3={type:"added"},Pw={type:"removed"};class kr extends Mu{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:i3++}),this.uuid=pl(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=kr.DefaultUp.clone();const e=new Me,n=new ip,a=new Ko,c=new Me(1,1,1);function f(){a.setFromEuler(n,!1)}function m(){n.setFromQuaternion(a,void 0,!1)}n._onChange(f),a._onChange(m),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:n},quaternion:{configurable:!0,enumerable:!0,value:a},scale:{configurable:!0,enumerable:!0,value:c},modelViewMatrix:{value:new sr},normalMatrix:{value:new kl}}),this.matrix=new sr,this.matrixWorld=new sr,this.matrixAutoUpdate=kr.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.layers=new rd,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,n){this.quaternion.setFromAxisAngle(e,n)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,n){return hf.setFromAxisAngle(e,n),this.quaternion.multiply(hf),this}rotateOnWorldAxis(e,n){return hf.setFromAxisAngle(e,n),this.quaternion.premultiply(hf),this}rotateX(e){return this.rotateOnAxis(Aw,e)}rotateY(e){return this.rotateOnAxis(Cw,e)}rotateZ(e){return this.rotateOnAxis(Iw,e)}translateOnAxis(e,n){return Tw.copy(e).applyQuaternion(this.quaternion),this.position.add(Tw.multiplyScalar(n)),this}translateX(e){return this.translateOnAxis(Aw,e)}translateY(e){return this.translateOnAxis(Cw,e)}translateZ(e){return this.translateOnAxis(Iw,e)}localToWorld(e){return e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return e.applyMatrix4(fu.copy(this.matrixWorld).invert())}lookAt(e,n,a){e.isVector3?Sg.copy(e):Sg.set(e,n,a);const c=this.parent;this.updateWorldMatrix(!0,!1),Gp.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?fu.lookAt(Gp,Sg,this.up):fu.lookAt(Sg,Gp,this.up),this.quaternion.setFromRotationMatrix(fu),c&&(fu.extractRotation(c.matrixWorld),hf.setFromRotationMatrix(fu),this.quaternion.premultiply(hf.invert()))}add(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.add(arguments[n]);return this}return e===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.parent!==null&&e.parent.remove(e),e.parent=this,this.children.push(e),e.dispatchEvent(o3)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let a=0;a<arguments.length;a++)this.remove(arguments[a]);return this}const n=this.children.indexOf(e);return n!==-1&&(e.parent=null,this.children.splice(n,1),e.dispatchEvent(Pw)),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){for(let e=0;e<this.children.length;e++){const n=this.children[e];n.parent=null,n.dispatchEvent(Pw)}return this.children.length=0,this}attach(e){return this.updateWorldMatrix(!0,!1),fu.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),fu.multiply(e.parent.matrixWorld)),e.applyMatrix4(fu),this.add(e),e.updateWorldMatrix(!1,!0),this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,n){if(this[e]===n)return this;for(let a=0,c=this.children.length;a<c;a++){const m=this.children[a].getObjectByProperty(e,n);if(m!==void 0)return m}}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Gp,e,r3),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Gp,s3,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const n=this.matrixWorld.elements;return e.set(n[8],n[9],n[10]).normalize()}raycast(){}traverse(e){e(this);const n=this.children;for(let a=0,c=n.length;a<c;a++)n[a].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const n=this.children;for(let a=0,c=n.length;a<c;a++)n[a].traverseVisible(e)}traverseAncestors(e){const n=this.parent;n!==null&&(e(n),n.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);const n=this.children;for(let a=0,c=n.length;a<c;a++)n[a].updateMatrixWorld(e)}updateWorldMatrix(e,n){const a=this.parent;if(e===!0&&a!==null&&a.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),n===!0){const c=this.children;for(let f=0,m=c.length;f<m;f++)c[f].updateWorldMatrix(!1,!0)}}toJSON(e){const n=e===void 0||typeof e=="string",a={};n&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},a.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});const c={};c.uuid=this.uuid,c.type=this.type,this.name!==""&&(c.name=this.name),this.castShadow===!0&&(c.castShadow=!0),this.receiveShadow===!0&&(c.receiveShadow=!0),this.visible===!1&&(c.visible=!1),this.frustumCulled===!1&&(c.frustumCulled=!1),this.renderOrder!==0&&(c.renderOrder=this.renderOrder),JSON.stringify(this.userData)!=="{}"&&(c.userData=this.userData),c.layers=this.layers.mask,c.matrix=this.matrix.toArray(),this.matrixAutoUpdate===!1&&(c.matrixAutoUpdate=!1),this.isInstancedMesh&&(c.type="InstancedMesh",c.count=this.count,c.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(c.instanceColor=this.instanceColor.toJSON()));function f(i,w){return i[w.uuid]===void 0&&(i[w.uuid]=w.toJSON(e)),w.uuid}if(this.isScene)this.background&&(this.background.isColor?c.background=this.background.toJSON():this.background.isTexture&&(c.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&(c.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){c.geometry=f(e.geometries,this.geometry);const i=this.geometry.parameters;if(i!==void 0&&i.shapes!==void 0){const w=i.shapes;if(Array.isArray(w))for(let E=0,C=w.length;E<C;E++){const T=w[E];f(e.shapes,T)}else f(e.shapes,w)}}if(this.isSkinnedMesh&&(c.bindMode=this.bindMode,c.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(f(e.skeletons,this.skeleton),c.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const i=[];for(let w=0,E=this.material.length;w<E;w++)i.push(f(e.materials,this.material[w]));c.material=i}else c.material=f(e.materials,this.material);if(this.children.length>0){c.children=[];for(let i=0;i<this.children.length;i++)c.children.push(this.children[i].toJSON(e).object)}if(this.animations.length>0){c.animations=[];for(let i=0;i<this.animations.length;i++){const w=this.animations[i];c.animations.push(f(e.animations,w))}}if(n){const i=m(e.geometries),w=m(e.materials),E=m(e.textures),C=m(e.images),T=m(e.shapes),I=m(e.skeletons),k=m(e.animations),O=m(e.nodes);i.length>0&&(a.geometries=i),w.length>0&&(a.materials=w),E.length>0&&(a.textures=E),C.length>0&&(a.images=C),T.length>0&&(a.shapes=T),I.length>0&&(a.skeletons=I),k.length>0&&(a.animations=k),O.length>0&&(a.nodes=O)}return a.object=c,a;function m(i){const w=[];for(const E in i){const C=i[E];delete C.metadata,w.push(C)}return w}}clone(e){return new this.constructor().copy(this,e)}copy(e,n=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),n===!0)for(let a=0;a<e.children.length;a++){const c=e.children[a];this.add(c.clone())}return this}}kr.DefaultUp=new Me(0,1,0);kr.DefaultMatrixAutoUpdate=!0;const tc=new Me,pu=new Me,v0=new Me,mu=new Me,df=new Me,ff=new Me,Lw=new Me,b0=new Me,w0=new Me,S0=new Me;class zl{constructor(e=new Me,n=new Me,a=new Me){this.a=e,this.b=n,this.c=a}static getNormal(e,n,a,c){c.subVectors(a,n),tc.subVectors(e,n),c.cross(tc);const f=c.lengthSq();return f>0?c.multiplyScalar(1/Math.sqrt(f)):c.set(0,0,0)}static getBarycoord(e,n,a,c,f){tc.subVectors(c,n),pu.subVectors(a,n),v0.subVectors(e,n);const m=tc.dot(tc),i=tc.dot(pu),w=tc.dot(v0),E=pu.dot(pu),C=pu.dot(v0),T=m*E-i*i;if(T===0)return f.set(-2,-1,-1);const I=1/T,k=(E*w-i*C)*I,O=(m*C-i*w)*I;return f.set(1-k-O,O,k)}static containsPoint(e,n,a,c){return this.getBarycoord(e,n,a,c,mu),mu.x>=0&&mu.y>=0&&mu.x+mu.y<=1}static getUV(e,n,a,c,f,m,i,w){return this.getBarycoord(e,n,a,c,mu),w.set(0,0),w.addScaledVector(f,mu.x),w.addScaledVector(m,mu.y),w.addScaledVector(i,mu.z),w}static isFrontFacing(e,n,a,c){return tc.subVectors(a,n),pu.subVectors(e,n),tc.cross(pu).dot(c)<0}set(e,n,a){return this.a.copy(e),this.b.copy(n),this.c.copy(a),this}setFromPointsAndIndices(e,n,a,c){return this.a.copy(e[n]),this.b.copy(e[a]),this.c.copy(e[c]),this}setFromAttributeAndIndices(e,n,a,c){return this.a.fromBufferAttribute(e,n),this.b.fromBufferAttribute(e,a),this.c.fromBufferAttribute(e,c),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return tc.subVectors(this.c,this.b),pu.subVectors(this.a,this.b),tc.cross(pu).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return zl.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,n){return zl.getBarycoord(e,this.a,this.b,this.c,n)}getUV(e,n,a,c,f){return zl.getUV(e,this.a,this.b,this.c,n,a,c,f)}containsPoint(e){return zl.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return zl.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,n){const a=this.a,c=this.b,f=this.c;let m,i;df.subVectors(c,a),ff.subVectors(f,a),b0.subVectors(e,a);const w=df.dot(b0),E=ff.dot(b0);if(w<=0&&E<=0)return n.copy(a);w0.subVectors(e,c);const C=df.dot(w0),T=ff.dot(w0);if(C>=0&&T<=C)return n.copy(c);const I=w*T-C*E;if(I<=0&&w>=0&&C<=0)return m=w/(w-C),n.copy(a).addScaledVector(df,m);S0.subVectors(e,f);const k=df.dot(S0),O=ff.dot(S0);if(O>=0&&k<=O)return n.copy(f);const B=k*E-w*O;if(B<=0&&E>=0&&O<=0)return i=E/(E-O),n.copy(a).addScaledVector(ff,i);const F=C*O-k*T;if(F<=0&&T-C>=0&&k-O>=0)return Lw.subVectors(f,c),i=(T-C)/(T-C+(k-O)),n.copy(c).addScaledVector(Lw,i);const H=1/(F+B+I);return m=B*H,i=I*H,n.copy(a).addScaledVector(df,m).addScaledVector(ff,i)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let a3=0;class fo extends Mu{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:a3++}),this.uuid=pl(),this.name="",this.type="Material",this.blending=ed,this.side=od,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=cv,this.blendDst=uv,this.blendEquation=qh,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=m_,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=XE,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=h_,this.stencilZFail=h_,this.stencilZPass=h_,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const n in e){const a=e[n];if(a===void 0){console.warn("THREE.Material: '"+n+"' parameter is undefined.");continue}if(n==="shading"){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=a===tE;continue}const c=this[n];if(c===void 0){console.warn("THREE."+this.type+": '"+n+"' is not a property of this material.");continue}c&&c.isColor?c.set(a):c&&c.isVector3&&a&&a.isVector3?c.copy(a):this[n]=a}}toJSON(e){const n=e===void 0||typeof e=="string";n&&(e={textures:{},images:{}});const a={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};a.uuid=this.uuid,a.type=this.type,this.name!==""&&(a.name=this.name),this.color&&this.color.isColor&&(a.color=this.color.getHex()),this.roughness!==void 0&&(a.roughness=this.roughness),this.metalness!==void 0&&(a.metalness=this.metalness),this.sheen!==void 0&&(a.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(a.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(a.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(a.emissive=this.emissive.getHex()),this.emissiveIntensity&&this.emissiveIntensity!==1&&(a.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(a.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(a.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(a.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(a.shininess=this.shininess),this.clearcoat!==void 0&&(a.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(a.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(a.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(a.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(a.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,a.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.iridescence!==void 0&&(a.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(a.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(a.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(a.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(a.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(a.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(a.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(a.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(a.lightMap=this.lightMap.toJSON(e).uuid,a.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(a.aoMap=this.aoMap.toJSON(e).uuid,a.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(a.bumpMap=this.bumpMap.toJSON(e).uuid,a.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(a.normalMap=this.normalMap.toJSON(e).uuid,a.normalMapType=this.normalMapType,a.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(a.displacementMap=this.displacementMap.toJSON(e).uuid,a.displacementScale=this.displacementScale,a.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(a.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(a.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(a.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(a.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(a.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(a.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(a.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(a.combine=this.combine)),this.envMapIntensity!==void 0&&(a.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(a.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(a.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(a.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(a.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(a.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(a.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(a.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&(a.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(a.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(a.size=this.size),this.shadowSide!==null&&(a.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(a.sizeAttenuation=this.sizeAttenuation),this.blending!==ed&&(a.blending=this.blending),this.side!==od&&(a.side=this.side),this.vertexColors&&(a.vertexColors=!0),this.opacity<1&&(a.opacity=this.opacity),this.transparent===!0&&(a.transparent=this.transparent),a.depthFunc=this.depthFunc,a.depthTest=this.depthTest,a.depthWrite=this.depthWrite,a.colorWrite=this.colorWrite,a.stencilWrite=this.stencilWrite,a.stencilWriteMask=this.stencilWriteMask,a.stencilFunc=this.stencilFunc,a.stencilRef=this.stencilRef,a.stencilFuncMask=this.stencilFuncMask,a.stencilFail=this.stencilFail,a.stencilZFail=this.stencilZFail,a.stencilZPass=this.stencilZPass,this.rotation!==void 0&&this.rotation!==0&&(a.rotation=this.rotation),this.polygonOffset===!0&&(a.polygonOffset=!0),this.polygonOffsetFactor!==0&&(a.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(a.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(a.linewidth=this.linewidth),this.dashSize!==void 0&&(a.dashSize=this.dashSize),this.gapSize!==void 0&&(a.gapSize=this.gapSize),this.scale!==void 0&&(a.scale=this.scale),this.dithering===!0&&(a.dithering=!0),this.alphaTest>0&&(a.alphaTest=this.alphaTest),this.alphaToCoverage===!0&&(a.alphaToCoverage=this.alphaToCoverage),this.premultipliedAlpha===!0&&(a.premultipliedAlpha=this.premultipliedAlpha),this.wireframe===!0&&(a.wireframe=this.wireframe),this.wireframeLinewidth>1&&(a.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(a.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(a.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(a.flatShading=this.flatShading),this.visible===!1&&(a.visible=!1),this.toneMapped===!1&&(a.toneMapped=!1),this.fog===!1&&(a.fog=!1),JSON.stringify(this.userData)!=="{}"&&(a.userData=this.userData);function c(f){const m=[];for(const i in f){const w=f[i];delete w.metadata,m.push(w)}return m}if(n){const f=c(e.textures),m=c(e.images);f.length>0&&(a.textures=f),m.length>0&&(a.images=m)}return a}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const n=e.clippingPlanes;let a=null;if(n!==null){const c=n.length;a=new Array(c);for(let f=0;f!==c;++f)a[f]=n[f].clone()}return this.clippingPlanes=a,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}get vertexTangents(){return console.warn("THREE."+this.type+": .vertexTangents has been removed."),!1}set vertexTangents(e){console.warn("THREE."+this.type+": .vertexTangents has been removed.")}}fo.fromType=function(){return null};class uh extends fo{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Kn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Sm,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const co=new Me,Mg=new tn;class Yr{constructor(e,n,a){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=n,this.count=e!==void 0?e.length/n:0,this.normalized=a===!0,this.usage=y_,this.updateRange={offset:0,count:-1},this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this}copyAt(e,n,a){e*=this.itemSize,a*=n.itemSize;for(let c=0,f=this.itemSize;c<f;c++)this.array[e+c]=n.array[a+c];return this}copyArray(e){return this.array.set(e),this}copyColorsArray(e){const n=this.array;let a=0;for(let c=0,f=e.length;c<f;c++){let m=e[c];m===void 0&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",c),m=new Kn),n[a++]=m.r,n[a++]=m.g,n[a++]=m.b}return this}copyVector2sArray(e){const n=this.array;let a=0;for(let c=0,f=e.length;c<f;c++){let m=e[c];m===void 0&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",c),m=new tn),n[a++]=m.x,n[a++]=m.y}return this}copyVector3sArray(e){const n=this.array;let a=0;for(let c=0,f=e.length;c<f;c++){let m=e[c];m===void 0&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",c),m=new Me),n[a++]=m.x,n[a++]=m.y,n[a++]=m.z}return this}copyVector4sArray(e){const n=this.array;let a=0;for(let c=0,f=e.length;c<f;c++){let m=e[c];m===void 0&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",c),m=new Wr),n[a++]=m.x,n[a++]=m.y,n[a++]=m.z,n[a++]=m.w}return this}applyMatrix3(e){if(this.itemSize===2)for(let n=0,a=this.count;n<a;n++)Mg.fromBufferAttribute(this,n),Mg.applyMatrix3(e),this.setXY(n,Mg.x,Mg.y);else if(this.itemSize===3)for(let n=0,a=this.count;n<a;n++)co.fromBufferAttribute(this,n),co.applyMatrix3(e),this.setXYZ(n,co.x,co.y,co.z);return this}applyMatrix4(e){for(let n=0,a=this.count;n<a;n++)co.fromBufferAttribute(this,n),co.applyMatrix4(e),this.setXYZ(n,co.x,co.y,co.z);return this}applyNormalMatrix(e){for(let n=0,a=this.count;n<a;n++)co.fromBufferAttribute(this,n),co.applyNormalMatrix(e),this.setXYZ(n,co.x,co.y,co.z);return this}transformDirection(e){for(let n=0,a=this.count;n<a;n++)co.fromBufferAttribute(this,n),co.transformDirection(e),this.setXYZ(n,co.x,co.y,co.z);return this}set(e,n=0){return this.array.set(e,n),this}getX(e){return this.array[e*this.itemSize]}setX(e,n){return this.array[e*this.itemSize]=n,this}getY(e){return this.array[e*this.itemSize+1]}setY(e,n){return this.array[e*this.itemSize+1]=n,this}getZ(e){return this.array[e*this.itemSize+2]}setZ(e,n){return this.array[e*this.itemSize+2]=n,this}getW(e){return this.array[e*this.itemSize+3]}setW(e,n){return this.array[e*this.itemSize+3]=n,this}setXY(e,n,a){return e*=this.itemSize,this.array[e+0]=n,this.array[e+1]=a,this}setXYZ(e,n,a,c){return e*=this.itemSize,this.array[e+0]=n,this.array[e+1]=a,this.array[e+2]=c,this}setXYZW(e,n,a,c,f){return e*=this.itemSize,this.array[e+0]=n,this.array[e+1]=a,this.array[e+2]=c,this.array[e+3]=f,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.prototype.slice.call(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==y_&&(e.usage=this.usage),(this.updateRange.offset!==0||this.updateRange.count!==-1)&&(e.updateRange=this.updateRange),e}}class l3 extends Yr{constructor(e,n,a){super(new Int8Array(e),n,a)}}class c3 extends Yr{constructor(e,n,a){super(new Uint8Array(e),n,a)}}class u3 extends Yr{constructor(e,n,a){super(new Uint8ClampedArray(e),n,a)}}class h3 extends Yr{constructor(e,n,a){super(new Int16Array(e),n,a)}}class _v extends Yr{constructor(e,n,a){super(new Uint16Array(e),n,a)}}class d3 extends Yr{constructor(e,n,a){super(new Int32Array(e),n,a)}}class yv extends Yr{constructor(e,n,a){super(new Uint32Array(e),n,a)}}class f3 extends Yr{constructor(e,n,a){super(new Uint16Array(e),n,a),this.isFloat16BufferAttribute=!0}}class hi extends Yr{constructor(e,n,a){super(new Float32Array(e),n,a)}}class p3 extends Yr{constructor(e,n,a){super(new Float64Array(e),n,a)}}let m3=0;const Rl=new sr,M0=new kr,pf=new Me,hl=new xd,jp=new xd,No=new Me;class qi extends Mu{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:m3++}),this.uuid=pl(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(YE(e)?yv:_v)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,n){return this.attributes[e]=n,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,n,a=0){this.groups.push({start:e,count:n,materialIndex:a})}clearGroups(){this.groups=[]}setDrawRange(e,n){this.drawRange.start=e,this.drawRange.count=n}applyMatrix4(e){const n=this.attributes.position;n!==void 0&&(n.applyMatrix4(e),n.needsUpdate=!0);const a=this.attributes.normal;if(a!==void 0){const f=new kl().getNormalMatrix(e);a.applyNormalMatrix(f),a.needsUpdate=!0}const c=this.attributes.tangent;return c!==void 0&&(c.transformDirection(e),c.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return Rl.makeRotationFromQuaternion(e),this.applyMatrix4(Rl),this}rotateX(e){return Rl.makeRotationX(e),this.applyMatrix4(Rl),this}rotateY(e){return Rl.makeRotationY(e),this.applyMatrix4(Rl),this}rotateZ(e){return Rl.makeRotationZ(e),this.applyMatrix4(Rl),this}translate(e,n,a){return Rl.makeTranslation(e,n,a),this.applyMatrix4(Rl),this}scale(e,n,a){return Rl.makeScale(e,n,a),this.applyMatrix4(Rl),this}lookAt(e){return M0.lookAt(e),M0.updateMatrix(),this.applyMatrix4(M0.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(pf).negate(),this.translate(pf.x,pf.y,pf.z),this}setFromPoints(e){const n=[];for(let a=0,c=e.length;a<c;a++){const f=e[a];n.push(f.x,f.y,f.z||0)}return this.setAttribute("position",new hi(n,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new xd);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingBox.set(new Me(-1/0,-1/0,-1/0),new Me(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),n)for(let a=0,c=n.length;a<c;a++){const f=n[a];hl.setFromBufferAttribute(f),this.morphTargetsRelative?(No.addVectors(this.boundingBox.min,hl.min),this.boundingBox.expandByPoint(No),No.addVectors(this.boundingBox.max,hl.max),this.boundingBox.expandByPoint(No)):(this.boundingBox.expandByPoint(hl.min),this.boundingBox.expandByPoint(hl.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new vd);const e=this.attributes.position,n=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error('THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),this.boundingSphere.set(new Me,1/0);return}if(e){const a=this.boundingSphere.center;if(hl.setFromBufferAttribute(e),n)for(let f=0,m=n.length;f<m;f++){const i=n[f];jp.setFromBufferAttribute(i),this.morphTargetsRelative?(No.addVectors(hl.min,jp.min),hl.expandByPoint(No),No.addVectors(hl.max,jp.max),hl.expandByPoint(No)):(hl.expandByPoint(jp.min),hl.expandByPoint(jp.max))}hl.getCenter(a);let c=0;for(let f=0,m=e.count;f<m;f++)No.fromBufferAttribute(e,f),c=Math.max(c,a.distanceToSquared(No));if(n)for(let f=0,m=n.length;f<m;f++){const i=n[f],w=this.morphTargetsRelative;for(let E=0,C=i.count;E<C;E++)No.fromBufferAttribute(i,E),w&&(pf.fromBufferAttribute(e,E),No.add(pf)),c=Math.max(c,a.distanceToSquared(No))}this.boundingSphere.radius=Math.sqrt(c),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,n=this.attributes;if(e===null||n.position===void 0||n.normal===void 0||n.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const a=e.array,c=n.position.array,f=n.normal.array,m=n.uv.array,i=c.length/3;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Yr(new Float32Array(4*i),4));const w=this.getAttribute("tangent").array,E=[],C=[];for(let Re=0;Re<i;Re++)E[Re]=new Me,C[Re]=new Me;const T=new Me,I=new Me,k=new Me,O=new tn,B=new tn,F=new tn,H=new Me,Y=new Me;function K(Re,ke,Xe){T.fromArray(c,Re*3),I.fromArray(c,ke*3),k.fromArray(c,Xe*3),O.fromArray(m,Re*2),B.fromArray(m,ke*2),F.fromArray(m,Xe*2),I.sub(T),k.sub(T),B.sub(O),F.sub(O);const St=1/(B.x*F.y-F.x*B.y);!isFinite(St)||(H.copy(I).multiplyScalar(F.y).addScaledVector(k,-B.y).multiplyScalar(St),Y.copy(k).multiplyScalar(B.x).addScaledVector(I,-F.x).multiplyScalar(St),E[Re].add(H),E[ke].add(H),E[Xe].add(H),C[Re].add(Y),C[ke].add(Y),C[Xe].add(Y))}let ne=this.groups;ne.length===0&&(ne=[{start:0,count:a.length}]);for(let Re=0,ke=ne.length;Re<ke;++Re){const Xe=ne[Re],St=Xe.start,Je=Xe.count;for(let It=St,ft=St+Je;It<ft;It+=3)K(a[It+0],a[It+1],a[It+2])}const le=new Me,fe=new Me,Ae=new Me,oe=new Me;function ce(Re){Ae.fromArray(f,Re*3),oe.copy(Ae);const ke=E[Re];le.copy(ke),le.sub(Ae.multiplyScalar(Ae.dot(ke))).normalize(),fe.crossVectors(oe,ke);const St=fe.dot(C[Re])<0?-1:1;w[Re*4]=le.x,w[Re*4+1]=le.y,w[Re*4+2]=le.z,w[Re*4+3]=St}for(let Re=0,ke=ne.length;Re<ke;++Re){const Xe=ne[Re],St=Xe.start,Je=Xe.count;for(let It=St,ft=St+Je;It<ft;It+=3)ce(a[It+0]),ce(a[It+1]),ce(a[It+2])}}computeVertexNormals(){const e=this.index,n=this.getAttribute("position");if(n!==void 0){let a=this.getAttribute("normal");if(a===void 0)a=new Yr(new Float32Array(n.count*3),3),this.setAttribute("normal",a);else for(let I=0,k=a.count;I<k;I++)a.setXYZ(I,0,0,0);const c=new Me,f=new Me,m=new Me,i=new Me,w=new Me,E=new Me,C=new Me,T=new Me;if(e)for(let I=0,k=e.count;I<k;I+=3){const O=e.getX(I+0),B=e.getX(I+1),F=e.getX(I+2);c.fromBufferAttribute(n,O),f.fromBufferAttribute(n,B),m.fromBufferAttribute(n,F),C.subVectors(m,f),T.subVectors(c,f),C.cross(T),i.fromBufferAttribute(a,O),w.fromBufferAttribute(a,B),E.fromBufferAttribute(a,F),i.add(C),w.add(C),E.add(C),a.setXYZ(O,i.x,i.y,i.z),a.setXYZ(B,w.x,w.y,w.z),a.setXYZ(F,E.x,E.y,E.z)}else for(let I=0,k=n.count;I<k;I+=3)c.fromBufferAttribute(n,I+0),f.fromBufferAttribute(n,I+1),m.fromBufferAttribute(n,I+2),C.subVectors(m,f),T.subVectors(c,f),C.cross(T),a.setXYZ(I+0,C.x,C.y,C.z),a.setXYZ(I+1,C.x,C.y,C.z),a.setXYZ(I+2,C.x,C.y,C.z);this.normalizeNormals(),a.needsUpdate=!0}}merge(e,n){if(!(e&&e.isBufferGeometry)){console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.",e);return}n===void 0&&(n=0,console.warn("THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge."));const a=this.attributes;for(const c in a){if(e.attributes[c]===void 0)continue;const m=a[c].array,i=e.attributes[c],w=i.array,E=i.itemSize*n,C=Math.min(w.length,m.length-E);for(let T=0,I=E;T<C;T++,I++)m[I]=w[T]}return this}normalizeNormals(){const e=this.attributes.normal;for(let n=0,a=e.count;n<a;n++)No.fromBufferAttribute(e,n),No.normalize(),e.setXYZ(n,No.x,No.y,No.z)}toNonIndexed(){function e(i,w){const E=i.array,C=i.itemSize,T=i.normalized,I=new E.constructor(w.length*C);let k=0,O=0;for(let B=0,F=w.length;B<F;B++){i.isInterleavedBufferAttribute?k=w[B]*i.data.stride+i.offset:k=w[B]*C;for(let H=0;H<C;H++)I[O++]=E[k++]}return new Yr(I,C,T)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const n=new qi,a=this.index.array,c=this.attributes;for(const i in c){const w=c[i],E=e(w,a);n.setAttribute(i,E)}const f=this.morphAttributes;for(const i in f){const w=[],E=f[i];for(let C=0,T=E.length;C<T;C++){const I=E[C],k=e(I,a);w.push(k)}n.morphAttributes[i]=w}n.morphTargetsRelative=this.morphTargetsRelative;const m=this.groups;for(let i=0,w=m.length;i<w;i++){const E=m[i];n.addGroup(E.start,E.count,E.materialIndex)}return n}toJSON(){const e={metadata:{version:4.5,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const w=this.parameters;for(const E in w)w[E]!==void 0&&(e[E]=w[E]);return e}e.data={attributes:{}};const n=this.index;n!==null&&(e.data.index={type:n.array.constructor.name,array:Array.prototype.slice.call(n.array)});const a=this.attributes;for(const w in a){const E=a[w];e.data.attributes[w]=E.toJSON(e.data)}const c={};let f=!1;for(const w in this.morphAttributes){const E=this.morphAttributes[w],C=[];for(let T=0,I=E.length;T<I;T++){const k=E[T];C.push(k.toJSON(e.data))}C.length>0&&(c[w]=C,f=!0)}f&&(e.data.morphAttributes=c,e.data.morphTargetsRelative=this.morphTargetsRelative);const m=this.groups;m.length>0&&(e.data.groups=JSON.parse(JSON.stringify(m)));const i=this.boundingSphere;return i!==null&&(e.data.boundingSphere={center:i.center.toArray(),radius:i.radius}),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const n={};this.name=e.name;const a=e.index;a!==null&&this.setIndex(a.clone(n));const c=e.attributes;for(const E in c){const C=c[E];this.setAttribute(E,C.clone(n))}const f=e.morphAttributes;for(const E in f){const C=[],T=f[E];for(let I=0,k=T.length;I<k;I++)C.push(T[I].clone(n));this.morphAttributes[E]=C}this.morphTargetsRelative=e.morphTargetsRelative;const m=e.groups;for(let E=0,C=m.length;E<C;E++){const T=m[E];this.addGroup(T.start,T.count,T.materialIndex)}const i=e.boundingBox;i!==null&&(this.boundingBox=i.clone());const w=e.boundingSphere;return w!==null&&(this.boundingSphere=w.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,e.parameters!==void 0&&(this.parameters=Object.assign({},e.parameters)),this}dispose(){this.dispatchEvent({type:"dispose"})}}const Rw=new sr,mf=new np,E0=new vd,Yu=new Me,Ju=new Me,Ku=new Me,T0=new Me,A0=new Me,C0=new Me,Eg=new Me,Tg=new Me,Ag=new Me,Cg=new tn,Ig=new tn,Pg=new tn,I0=new Me,Lg=new Me;class Jo extends kr{constructor(e=new qi,n=new uh){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=n,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=e.material,this.geometry=e.geometry,this}updateMorphTargets(){const n=this.geometry.morphAttributes,a=Object.keys(n);if(a.length>0){const c=n[a[0]];if(c!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let f=0,m=c.length;f<m;f++){const i=c[f].name||String(f);this.morphTargetInfluences.push(0),this.morphTargetDictionary[i]=f}}}}raycast(e,n){const a=this.geometry,c=this.material,f=this.matrixWorld;if(c===void 0||(a.boundingSphere===null&&a.computeBoundingSphere(),E0.copy(a.boundingSphere),E0.applyMatrix4(f),e.ray.intersectsSphere(E0)===!1)||(Rw.copy(f).invert(),mf.copy(e.ray).applyMatrix4(Rw),a.boundingBox!==null&&mf.intersectsBox(a.boundingBox)===!1))return;let m;const i=a.index,w=a.attributes.position,E=a.morphAttributes.position,C=a.morphTargetsRelative,T=a.attributes.uv,I=a.attributes.uv2,k=a.groups,O=a.drawRange;if(i!==null)if(Array.isArray(c))for(let B=0,F=k.length;B<F;B++){const H=k[B],Y=c[H.materialIndex],K=Math.max(H.start,O.start),ne=Math.min(i.count,Math.min(H.start+H.count,O.start+O.count));for(let le=K,fe=ne;le<fe;le+=3){const Ae=i.getX(le),oe=i.getX(le+1),ce=i.getX(le+2);m=Rg(this,Y,e,mf,w,E,C,T,I,Ae,oe,ce),m&&(m.faceIndex=Math.floor(le/3),m.face.materialIndex=H.materialIndex,n.push(m))}}else{const B=Math.max(0,O.start),F=Math.min(i.count,O.start+O.count);for(let H=B,Y=F;H<Y;H+=3){const K=i.getX(H),ne=i.getX(H+1),le=i.getX(H+2);m=Rg(this,c,e,mf,w,E,C,T,I,K,ne,le),m&&(m.faceIndex=Math.floor(H/3),n.push(m))}}else if(w!==void 0)if(Array.isArray(c))for(let B=0,F=k.length;B<F;B++){const H=k[B],Y=c[H.materialIndex],K=Math.max(H.start,O.start),ne=Math.min(w.count,Math.min(H.start+H.count,O.start+O.count));for(let le=K,fe=ne;le<fe;le+=3){const Ae=le,oe=le+1,ce=le+2;m=Rg(this,Y,e,mf,w,E,C,T,I,Ae,oe,ce),m&&(m.faceIndex=Math.floor(le/3),m.face.materialIndex=H.materialIndex,n.push(m))}}else{const B=Math.max(0,O.start),F=Math.min(w.count,O.start+O.count);for(let H=B,Y=F;H<Y;H+=3){const K=H,ne=H+1,le=H+2;m=Rg(this,c,e,mf,w,E,C,T,I,K,ne,le),m&&(m.faceIndex=Math.floor(H/3),n.push(m))}}}}function g3(d,e,n,a,c,f,m,i){let w;if(e.side===fl?w=a.intersectTriangle(m,f,c,!0,i):w=a.intersectTriangle(c,f,m,e.side!==ad,i),w===null)return null;Lg.copy(i),Lg.applyMatrix4(d.matrixWorld);const E=n.ray.origin.distanceTo(Lg);return E<n.near||E>n.far?null:{distance:E,point:Lg.clone(),object:d}}function Rg(d,e,n,a,c,f,m,i,w,E,C,T){Yu.fromBufferAttribute(c,E),Ju.fromBufferAttribute(c,C),Ku.fromBufferAttribute(c,T);const I=d.morphTargetInfluences;if(f&&I){Eg.set(0,0,0),Tg.set(0,0,0),Ag.set(0,0,0);for(let O=0,B=f.length;O<B;O++){const F=I[O],H=f[O];F!==0&&(T0.fromBufferAttribute(H,E),A0.fromBufferAttribute(H,C),C0.fromBufferAttribute(H,T),m?(Eg.addScaledVector(T0,F),Tg.addScaledVector(A0,F),Ag.addScaledVector(C0,F)):(Eg.addScaledVector(T0.sub(Yu),F),Tg.addScaledVector(A0.sub(Ju),F),Ag.addScaledVector(C0.sub(Ku),F)))}Yu.add(Eg),Ju.add(Tg),Ku.add(Ag)}d.isSkinnedMesh&&(d.boneTransform(E,Yu),d.boneTransform(C,Ju),d.boneTransform(T,Ku));const k=g3(d,e,n,a,Yu,Ju,Ku,I0);if(k){i&&(Cg.fromBufferAttribute(i,E),Ig.fromBufferAttribute(i,C),Pg.fromBufferAttribute(i,T),k.uv=zl.getUV(I0,Yu,Ju,Ku,Cg,Ig,Pg,new tn)),w&&(Cg.fromBufferAttribute(w,E),Ig.fromBufferAttribute(w,C),Pg.fromBufferAttribute(w,T),k.uv2=zl.getUV(I0,Yu,Ju,Ku,Cg,Ig,Pg,new tn));const O={a:E,b:C,c:T,normal:new Me,materialIndex:0};zl.getNormal(Yu,Ju,Ku,O.normal),k.face=O}return k}class Vc extends qi{constructor(e=1,n=1,a=1,c=1,f=1,m=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:n,depth:a,widthSegments:c,heightSegments:f,depthSegments:m};const i=this;c=Math.floor(c),f=Math.floor(f),m=Math.floor(m);const w=[],E=[],C=[],T=[];let I=0,k=0;O("z","y","x",-1,-1,a,n,e,m,f,0),O("z","y","x",1,-1,a,n,-e,m,f,1),O("x","z","y",1,1,e,a,n,c,m,2),O("x","z","y",1,-1,e,a,-n,c,m,3),O("x","y","z",1,-1,e,n,a,c,f,4),O("x","y","z",-1,-1,e,n,-a,c,f,5),this.setIndex(w),this.setAttribute("position",new hi(E,3)),this.setAttribute("normal",new hi(C,3)),this.setAttribute("uv",new hi(T,2));function O(B,F,H,Y,K,ne,le,fe,Ae,oe,ce){const Re=ne/Ae,ke=le/oe,Xe=ne/2,St=le/2,Je=fe/2,It=Ae+1,ft=oe+1;let Nt=0,Fe=0;const it=new Me;for(let tt=0;tt<ft;tt++){const Et=tt*ke-St;for(let xt=0;xt<It;xt++){const Pt=xt*Re-Xe;it[B]=Pt*Y,it[F]=Et*K,it[H]=Je,E.push(it.x,it.y,it.z),it[B]=0,it[F]=0,it[H]=fe>0?1:-1,C.push(it.x,it.y,it.z),T.push(xt/Ae),T.push(1-tt/oe),Nt+=1}}for(let tt=0;tt<oe;tt++)for(let Et=0;Et<Ae;Et++){const xt=I+Et+It*tt,Pt=I+Et+It*(tt+1),ln=I+(Et+1)+It*(tt+1),pn=I+(Et+1)+It*tt;w.push(xt,Pt,pn),w.push(Pt,ln,pn),Fe+=6}i.addGroup(k,Fe,ce),k+=Fe,I+=Nt}}static fromJSON(e){return new Vc(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function Ff(d){const e={};for(const n in d){e[n]={};for(const a in d[n]){const c=d[n][a];c&&(c.isColor||c.isMatrix3||c.isMatrix4||c.isVector2||c.isVector3||c.isVector4||c.isTexture||c.isQuaternion)?e[n][a]=c.clone():Array.isArray(c)?e[n][a]=c.slice():e[n][a]=c}}return e}function ua(d){const e={};for(let n=0;n<d.length;n++){const a=Ff(d[n]);for(const c in a)e[c]=a[c]}return e}const KE={clone:Ff,merge:ua};var _3=`void main() {
	gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,y3=`void main() {
	gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
}`;class Gc extends fo{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader=_3,this.fragmentShader=y3,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&(e.attributes!==void 0&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(e))}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Ff(e.uniforms),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const n=super.toJSON(e);n.glslVersion=this.glslVersion,n.uniforms={};for(const c in this.uniforms){const m=this.uniforms[c].value;m&&m.isTexture?n.uniforms[c]={type:"t",value:m.toJSON(e).uuid}:m&&m.isColor?n.uniforms[c]={type:"c",value:m.getHex()}:m&&m.isVector2?n.uniforms[c]={type:"v2",value:m.toArray()}:m&&m.isVector3?n.uniforms[c]={type:"v3",value:m.toArray()}:m&&m.isVector4?n.uniforms[c]={type:"v4",value:m.toArray()}:m&&m.isMatrix3?n.uniforms[c]={type:"m3",value:m.toArray()}:m&&m.isMatrix4?n.uniforms[c]={type:"m4",value:m.toArray()}:n.uniforms[c]={value:m}}Object.keys(this.defines).length>0&&(n.defines=this.defines),n.vertexShader=this.vertexShader,n.fragmentShader=this.fragmentShader;const a={};for(const c in this.extensions)this.extensions[c]===!0&&(a[c]=!0);return Object.keys(a).length>0&&(n.extensions=a),n}}class Em extends kr{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new sr,this.projectionMatrix=new sr,this.projectionMatrixInverse=new sr}copy(e,n){return super.copy(e,n),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const n=this.matrixWorld.elements;return e.set(-n[8],-n[9],-n[10]).normalize()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,n){super.updateWorldMatrix(e,n),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}class ks extends Em{constructor(e=50,n=1,a=.1,c=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=a,this.far=c,this.focus=10,this.aspect=n,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,n){return super.copy(e,n),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const n=.5*this.getFilmHeight()/e;this.fov=cm*2*Math.atan(n),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(nd*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return cm*2*Math.atan(Math.tan(nd*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,n,a,c,f,m){this.aspect=e/n,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=a,this.view.offsetY=c,this.view.width=f,this.view.height=m,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let n=e*Math.tan(nd*.5*this.fov)/this.zoom,a=2*n,c=this.aspect*a,f=-.5*c;const m=this.view;if(this.view!==null&&this.view.enabled){const w=m.fullWidth,E=m.fullHeight;f+=m.offsetX*c/w,n-=m.offsetY*a/E,c*=m.width/w,a*=m.height/E}const i=this.filmOffset;i!==0&&(f+=e*i/this.getFilmWidth()),this.projectionMatrix.makePerspective(f,f+c,n,n-a,e,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.fov=this.fov,n.object.zoom=this.zoom,n.object.near=this.near,n.object.far=this.far,n.object.focus=this.focus,n.object.aspect=this.aspect,this.view!==null&&(n.object.view=Object.assign({},this.view)),n.object.filmGauge=this.filmGauge,n.object.filmOffset=this.filmOffset,n}}const gf=90,_f=1;class QE extends kr{constructor(e,n,a){if(super(),this.type="CubeCamera",a.isWebGLCubeRenderTarget!==!0){console.error("THREE.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.");return}this.renderTarget=a;const c=new ks(gf,_f,e,n);c.layers=this.layers,c.up.set(0,-1,0),c.lookAt(new Me(1,0,0)),this.add(c);const f=new ks(gf,_f,e,n);f.layers=this.layers,f.up.set(0,-1,0),f.lookAt(new Me(-1,0,0)),this.add(f);const m=new ks(gf,_f,e,n);m.layers=this.layers,m.up.set(0,0,1),m.lookAt(new Me(0,1,0)),this.add(m);const i=new ks(gf,_f,e,n);i.layers=this.layers,i.up.set(0,0,-1),i.lookAt(new Me(0,-1,0)),this.add(i);const w=new ks(gf,_f,e,n);w.layers=this.layers,w.up.set(0,-1,0),w.lookAt(new Me(0,0,1)),this.add(w);const E=new ks(gf,_f,e,n);E.layers=this.layers,E.up.set(0,-1,0),E.lookAt(new Me(0,0,-1)),this.add(E)}update(e,n){this.parent===null&&this.updateMatrixWorld();const a=this.renderTarget,[c,f,m,i,w,E]=this.children,C=e.getRenderTarget(),T=e.toneMapping,I=e.xr.enabled;e.toneMapping=sc,e.xr.enabled=!1;const k=a.texture.generateMipmaps;a.texture.generateMipmaps=!1,e.setRenderTarget(a,0),e.render(n,c),e.setRenderTarget(a,1),e.render(n,f),e.setRenderTarget(a,2),e.render(n,m),e.setRenderTarget(a,3),e.render(n,i),e.setRenderTarget(a,4),e.render(n,w),a.texture.generateMipmaps=k,e.setRenderTarget(a,5),e.render(n,E),e.setRenderTarget(C),e.toneMapping=T,e.xr.enabled=I,a.texture.needsPMREMUpdate=!0}}class Tm extends ho{constructor(e,n,a,c,f,m,i,w,E,C){e=e!==void 0?e:[],n=n!==void 0?n:rh,super(e,n,a,c,f,m,i,w,E,C),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class eT extends ml{constructor(e,n={}){super(e,e,n),this.isWebGLCubeRenderTarget=!0;const a={width:e,height:e,depth:1},c=[a,a,a,a,a,a];this.texture=new Tm(c,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.encoding),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=n.generateMipmaps!==void 0?n.generateMipmaps:!1,this.texture.minFilter=n.minFilter!==void 0?n.minFilter:qs}fromEquirectangularTexture(e,n){this.texture.type=n.type,this.texture.encoding=n.encoding,this.texture.generateMipmaps=n.generateMipmaps,this.texture.minFilter=n.minFilter,this.texture.magFilter=n.magFilter;const a={uniforms:{tEquirect:{value:null}},vertexShader:`

				varying vec3 vWorldDirection;

				vec3 transformDirection( in vec3 dir, in mat4 matrix ) {

					return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );

				}

				void main() {

					vWorldDirection = transformDirection( position, modelMatrix );

					#include <begin_vertex>
					#include <project_vertex>

				}
			`,fragmentShader:`

				uniform sampler2D tEquirect;

				varying vec3 vWorldDirection;

				#include <common>

				void main() {

					vec3 direction = normalize( vWorldDirection );

					vec2 sampleUV = equirectUv( direction );

					gl_FragColor = texture2D( tEquirect, sampleUV );

				}
			`},c=new Vc(5,5,5),f=new Gc({name:"CubemapFromEquirect",uniforms:Ff(a.uniforms),vertexShader:a.vertexShader,fragmentShader:a.fragmentShader,side:fl,blending:bu});f.uniforms.tEquirect.value=n;const m=new Jo(c,f),i=n.minFilter;return n.minFilter===_d&&(n.minFilter=qs),new QE(1,10,this).update(e,m),n.minFilter=i,m.geometry.dispose(),m.material.dispose(),this}clear(e,n,a,c){const f=e.getRenderTarget();for(let m=0;m<6;m++)e.setRenderTarget(this,m),e.clear(n,a,c);e.setRenderTarget(f)}}const P0=new Me,x3=new Me,v3=new kl;class _u{constructor(e=new Me(1,0,0),n=0){this.isPlane=!0,this.normal=e,this.constant=n}set(e,n){return this.normal.copy(e),this.constant=n,this}setComponents(e,n,a,c){return this.normal.set(e,n,a),this.constant=c,this}setFromNormalAndCoplanarPoint(e,n){return this.normal.copy(e),this.constant=-n.dot(this.normal),this}setFromCoplanarPoints(e,n,a){const c=P0.subVectors(a,n).cross(x3.subVectors(e,n)).normalize();return this.setFromNormalAndCoplanarPoint(c,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,n){return n.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)}intersectLine(e,n){const a=e.delta(P0),c=this.normal.dot(a);if(c===0)return this.distanceToPoint(e.start)===0?n.copy(e.start):null;const f=-(e.start.dot(this.normal)+this.constant)/c;return f<0||f>1?null:n.copy(a).multiplyScalar(f).add(e.start)}intersectsLine(e){const n=this.distanceToPoint(e.start),a=this.distanceToPoint(e.end);return n<0&&a>0||a<0&&n>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,n){const a=n||v3.getNormalMatrix(e),c=this.coplanarPoint(P0).applyMatrix4(e),f=this.normal.applyMatrix3(a).normalize();return this.constant=-c.dot(f),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const yf=new vd,Dg=new Me;class U_{constructor(e=new _u,n=new _u,a=new _u,c=new _u,f=new _u,m=new _u){this.planes=[e,n,a,c,f,m]}set(e,n,a,c,f,m){const i=this.planes;return i[0].copy(e),i[1].copy(n),i[2].copy(a),i[3].copy(c),i[4].copy(f),i[5].copy(m),this}copy(e){const n=this.planes;for(let a=0;a<6;a++)n[a].copy(e.planes[a]);return this}setFromProjectionMatrix(e){const n=this.planes,a=e.elements,c=a[0],f=a[1],m=a[2],i=a[3],w=a[4],E=a[5],C=a[6],T=a[7],I=a[8],k=a[9],O=a[10],B=a[11],F=a[12],H=a[13],Y=a[14],K=a[15];return n[0].setComponents(i-c,T-w,B-I,K-F).normalize(),n[1].setComponents(i+c,T+w,B+I,K+F).normalize(),n[2].setComponents(i+f,T+E,B+k,K+H).normalize(),n[3].setComponents(i-f,T-E,B-k,K-H).normalize(),n[4].setComponents(i-m,T-C,B-O,K-Y).normalize(),n[5].setComponents(i+m,T+C,B+O,K+Y).normalize(),this}intersectsObject(e){const n=e.geometry;return n.boundingSphere===null&&n.computeBoundingSphere(),yf.copy(n.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(yf)}intersectsSprite(e){return yf.center.set(0,0,0),yf.radius=.7071067811865476,yf.applyMatrix4(e.matrixWorld),this.intersectsSphere(yf)}intersectsSphere(e){const n=this.planes,a=e.center,c=-e.radius;for(let f=0;f<6;f++)if(n[f].distanceToPoint(a)<c)return!1;return!0}intersectsBox(e){const n=this.planes;for(let a=0;a<6;a++){const c=n[a];if(Dg.x=c.normal.x>0?e.max.x:e.min.x,Dg.y=c.normal.y>0?e.max.y:e.min.y,Dg.z=c.normal.z>0?e.max.z:e.min.z,c.distanceToPoint(Dg)<0)return!1}return!0}containsPoint(e){const n=this.planes;for(let a=0;a<6;a++)if(n[a].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function tT(){let d=null,e=!1,n=null,a=null;function c(f,m){n(f,m),a=d.requestAnimationFrame(c)}return{start:function(){e!==!0&&n!==null&&(a=d.requestAnimationFrame(c),e=!0)},stop:function(){d.cancelAnimationFrame(a),e=!1},setAnimationLoop:function(f){n=f},setContext:function(f){d=f}}}function b3(d,e){const n=e.isWebGL2,a=new WeakMap;function c(E,C){const T=E.array,I=E.usage,k=d.createBuffer();d.bindBuffer(C,k),d.bufferData(C,T,I),E.onUploadCallback();let O;if(T instanceof Float32Array)O=5126;else if(T instanceof Uint16Array)if(E.isFloat16BufferAttribute)if(n)O=5131;else throw new Error("THREE.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");else O=5123;else if(T instanceof Int16Array)O=5122;else if(T instanceof Uint32Array)O=5125;else if(T instanceof Int32Array)O=5124;else if(T instanceof Int8Array)O=5120;else if(T instanceof Uint8Array)O=5121;else if(T instanceof Uint8ClampedArray)O=5121;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+T);return{buffer:k,type:O,bytesPerElement:T.BYTES_PER_ELEMENT,version:E.version}}function f(E,C,T){const I=C.array,k=C.updateRange;d.bindBuffer(T,E),k.count===-1?d.bufferSubData(T,0,I):(n?d.bufferSubData(T,k.offset*I.BYTES_PER_ELEMENT,I,k.offset,k.count):d.bufferSubData(T,k.offset*I.BYTES_PER_ELEMENT,I.subarray(k.offset,k.offset+k.count)),k.count=-1)}function m(E){return E.isInterleavedBufferAttribute&&(E=E.data),a.get(E)}function i(E){E.isInterleavedBufferAttribute&&(E=E.data);const C=a.get(E);C&&(d.deleteBuffer(C.buffer),a.delete(E))}function w(E,C){if(E.isGLBufferAttribute){const I=a.get(E);(!I||I.version<E.version)&&a.set(E,{buffer:E.buffer,type:E.type,bytesPerElement:E.elementSize,version:E.version});return}E.isInterleavedBufferAttribute&&(E=E.data);const T=a.get(E);T===void 0?a.set(E,c(E,C)):T.version<E.version&&(f(T.buffer,E,C),T.version=E.version)}return{get:m,remove:i,update:w}}class cd extends qi{constructor(e=1,n=1,a=1,c=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:n,widthSegments:a,heightSegments:c};const f=e/2,m=n/2,i=Math.floor(a),w=Math.floor(c),E=i+1,C=w+1,T=e/i,I=n/w,k=[],O=[],B=[],F=[];for(let H=0;H<C;H++){const Y=H*I-m;for(let K=0;K<E;K++){const ne=K*T-f;O.push(ne,-Y,0),B.push(0,0,1),F.push(K/i),F.push(1-H/w)}}for(let H=0;H<w;H++)for(let Y=0;Y<i;Y++){const K=Y+E*H,ne=Y+E*(H+1),le=Y+1+E*(H+1),fe=Y+1+E*H;k.push(K,ne,fe),k.push(ne,le,fe)}this.setIndex(k),this.setAttribute("position",new hi(O,3)),this.setAttribute("normal",new hi(B,3)),this.setAttribute("uv",new hi(F,2))}static fromJSON(e){return new cd(e.width,e.height,e.widthSegments,e.heightSegments)}}var w3=`#ifdef USE_ALPHAMAP
	diffuseColor.a *= texture2D( alphaMap, vUv ).g;
#endif`,S3=`#ifdef USE_ALPHAMAP
	uniform sampler2D alphaMap;
#endif`,M3=`#ifdef USE_ALPHATEST
	if ( diffuseColor.a < alphaTest ) discard;
#endif`,E3=`#ifdef USE_ALPHATEST
	uniform float alphaTest;
#endif`,T3=`#ifdef USE_AOMAP
	float ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;
	reflectedLight.indirectDiffuse *= ambientOcclusion;
	#if defined( USE_ENVMAP ) && defined( STANDARD )
		float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );
		reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
	#endif
#endif`,A3=`#ifdef USE_AOMAP
	uniform sampler2D aoMap;
	uniform float aoMapIntensity;
#endif`,C3="vec3 transformed = vec3( position );",I3=`vec3 objectNormal = vec3( normal );
#ifdef USE_TANGENT
	vec3 objectTangent = vec3( tangent.xyz );
#endif`,P3=`vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
	return RECIPROCAL_PI * diffuseColor;
}
vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
	float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
	return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
}
float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
	float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
	return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
}
vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
    float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
    float x2 = x * x;
    float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
    return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
}
float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
	float a2 = pow2( alpha );
	float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
	float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
	return 0.5 / max( gv + gl, EPSILON );
}
float D_GGX( const in float alpha, const in float dotNH ) {
	float a2 = pow2( alpha );
	float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
	return RECIPROCAL_PI * a2 / pow2( denom );
}
vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float roughness ) {
	float alpha = pow2( roughness );
	vec3 halfDir = normalize( lightDir + viewDir );
	float dotNL = saturate( dot( normal, lightDir ) );
	float dotNV = saturate( dot( normal, viewDir ) );
	float dotNH = saturate( dot( normal, halfDir ) );
	float dotVH = saturate( dot( viewDir, halfDir ) );
	vec3 F = F_Schlick( f0, f90, dotVH );
	float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
	float D = D_GGX( alpha, dotNH );
	return F * ( V * D );
}
#ifdef USE_IRIDESCENCE
vec3 BRDF_GGX_Iridescence( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float iridescence, const in vec3 iridescenceFresnel, const in float roughness ) {
	float alpha = pow2( roughness );
	vec3 halfDir = normalize( lightDir + viewDir );
	float dotNL = saturate( dot( normal, lightDir ) );
	float dotNV = saturate( dot( normal, viewDir ) );
	float dotNH = saturate( dot( normal, halfDir ) );
	float dotVH = saturate( dot( viewDir, halfDir ) );
	vec3 F = mix(F_Schlick( f0, f90, dotVH ), iridescenceFresnel, iridescence);
	float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
	float D = D_GGX( alpha, dotNH );
	return F * ( V * D );
}
#endif
vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
	const float LUT_SIZE = 64.0;
	const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
	const float LUT_BIAS = 0.5 / LUT_SIZE;
	float dotNV = saturate( dot( N, V ) );
	vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
	uv = uv * LUT_SCALE + LUT_BIAS;
	return uv;
}
float LTC_ClippedSphereFormFactor( const in vec3 f ) {
	float l = length( f );
	return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
}
vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
	float x = dot( v1, v2 );
	float y = abs( x );
	float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
	float b = 3.4175940 + ( 4.1616724 + y ) * y;
	float v = a / b;
	float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
	return cross( v1, v2 ) * theta_sintheta;
}
vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
	vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
	vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
	vec3 lightNormal = cross( v1, v2 );
	if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
	vec3 T1, T2;
	T1 = normalize( V - N * dot( V, N ) );
	T2 = - cross( N, T1 );
	mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
	vec3 coords[ 4 ];
	coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
	coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
	coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
	coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
	coords[ 0 ] = normalize( coords[ 0 ] );
	coords[ 1 ] = normalize( coords[ 1 ] );
	coords[ 2 ] = normalize( coords[ 2 ] );
	coords[ 3 ] = normalize( coords[ 3 ] );
	vec3 vectorFormFactor = vec3( 0.0 );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
	vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
	float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
	return vec3( result );
}
float G_BlinnPhong_Implicit( ) {
	return 0.25;
}
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
	return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
}
vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
	vec3 halfDir = normalize( lightDir + viewDir );
	float dotNH = saturate( dot( normal, halfDir ) );
	float dotVH = saturate( dot( viewDir, halfDir ) );
	vec3 F = F_Schlick( specularColor, 1.0, dotVH );
	float G = G_BlinnPhong_Implicit( );
	float D = D_BlinnPhong( shininess, dotNH );
	return F * ( G * D );
}
#if defined( USE_SHEEN )
float D_Charlie( float roughness, float dotNH ) {
	float alpha = pow2( roughness );
	float invAlpha = 1.0 / alpha;
	float cos2h = dotNH * dotNH;
	float sin2h = max( 1.0 - cos2h, 0.0078125 );
	return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
}
float V_Neubelt( float dotNV, float dotNL ) {
	return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
}
vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
	vec3 halfDir = normalize( lightDir + viewDir );
	float dotNL = saturate( dot( normal, lightDir ) );
	float dotNV = saturate( dot( normal, viewDir ) );
	float dotNH = saturate( dot( normal, halfDir ) );
	float D = D_Charlie( sheenRoughness, dotNH );
	float V = V_Neubelt( dotNV, dotNL );
	return sheenColor * ( D * V );
}
#endif`,L3=`#ifdef USE_IRIDESCENCE
const mat3 XYZ_TO_REC709 = mat3(
    3.2404542, -0.9692660,  0.0556434,
   -1.5371385,  1.8760108, -0.2040259,
   -0.4985314,  0.0415560,  1.0572252
);
vec3 Fresnel0ToIor( vec3 fresnel0 ) {
   vec3 sqrtF0 = sqrt( fresnel0 );
   return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
}
vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
   return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
}
float IorToFresnel0( float transmittedIor, float incidentIor ) {
   return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
}
vec3 evalSensitivity( float OPD, vec3 shift ) {
   float phase = 2.0 * PI * OPD * 1.0e-9;
   vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
   vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
   vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
   vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( -pow2( phase ) * var );
   xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[0] ) * exp( -4.5282e+09 * pow2( phase ) );
   xyz /= 1.0685e-7;
   vec3 srgb = XYZ_TO_REC709 * xyz;
   return srgb;
}
vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
   vec3 I;
   float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
   float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
   float cosTheta2Sq = 1.0 - sinTheta2Sq;
   if ( cosTheta2Sq < 0.0 ) {
       return vec3( 1.0 );
   }
   float cosTheta2 = sqrt( cosTheta2Sq );
   float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
   float R12 = F_Schlick( R0, 1.0, cosTheta1 );
   float R21 = R12;
   float T121 = 1.0 - R12;
   float phi12 = 0.0;
   if ( iridescenceIOR < outsideIOR ) phi12 = PI;
   float phi21 = PI - phi12;
   vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) );   vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
   vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
   vec3 phi23 = vec3( 0.0 );
   if ( baseIOR[0] < iridescenceIOR ) phi23[0] = PI;
   if ( baseIOR[1] < iridescenceIOR ) phi23[1] = PI;
   if ( baseIOR[2] < iridescenceIOR ) phi23[2] = PI;
   float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
   vec3 phi = vec3( phi21 ) + phi23;
   vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
   vec3 r123 = sqrt( R123 );
   vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
   vec3 C0 = R12 + Rs;
   I = C0;
   vec3 Cm = Rs - T121;
   for ( int m = 1; m <= 2; ++m ) {
       Cm *= r123;
       vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
       I += Cm * Sm;
   }
   return max( I, vec3( 0.0 ) );
}
#endif`,R3=`#ifdef USE_BUMPMAP
	uniform sampler2D bumpMap;
	uniform float bumpScale;
	vec2 dHdxy_fwd() {
		vec2 dSTdx = dFdx( vUv );
		vec2 dSTdy = dFdy( vUv );
		float Hll = bumpScale * texture2D( bumpMap, vUv ).x;
		float dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;
		float dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;
		return vec2( dBx, dBy );
	}
	vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
		vec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );
		vec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );
		vec3 vN = surf_norm;
		vec3 R1 = cross( vSigmaY, vN );
		vec3 R2 = cross( vN, vSigmaX );
		float fDet = dot( vSigmaX, R1 ) * faceDirection;
		vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
		return normalize( abs( fDet ) * surf_norm - vGrad );
	}
#endif`,D3=`#if NUM_CLIPPING_PLANES > 0
	vec4 plane;
	#pragma unroll_loop_start
	for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
		plane = clippingPlanes[ i ];
		if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
	}
	#pragma unroll_loop_end
	#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
		bool clipped = true;
		#pragma unroll_loop_start
		for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
			plane = clippingPlanes[ i ];
			clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
		}
		#pragma unroll_loop_end
		if ( clipped ) discard;
	#endif
#endif`,z3=`#if NUM_CLIPPING_PLANES > 0
	varying vec3 vClipPosition;
	uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
#endif`,k3=`#if NUM_CLIPPING_PLANES > 0
	varying vec3 vClipPosition;
#endif`,O3=`#if NUM_CLIPPING_PLANES > 0
	vClipPosition = - mvPosition.xyz;
#endif`,F3=`#if defined( USE_COLOR_ALPHA )
	diffuseColor *= vColor;
#elif defined( USE_COLOR )
	diffuseColor.rgb *= vColor;
#endif`,B3=`#if defined( USE_COLOR_ALPHA )
	varying vec4 vColor;
#elif defined( USE_COLOR )
	varying vec3 vColor;
#endif`,N3=`#if defined( USE_COLOR_ALPHA )
	varying vec4 vColor;
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
	varying vec3 vColor;
#endif`,U3=`#if defined( USE_COLOR_ALPHA )
	vColor = vec4( 1.0 );
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
	vColor = vec3( 1.0 );
#endif
#ifdef USE_COLOR
	vColor *= color;
#endif
#ifdef USE_INSTANCING_COLOR
	vColor.xyz *= instanceColor.xyz;
#endif`,V3=`#define PI 3.141592653589793
#define PI2 6.283185307179586
#define PI_HALF 1.5707963267948966
#define RECIPROCAL_PI 0.3183098861837907
#define RECIPROCAL_PI2 0.15915494309189535
#define EPSILON 1e-6
#ifndef saturate
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
#define whiteComplement( a ) ( 1.0 - saturate( a ) )
float pow2( const in float x ) { return x*x; }
vec3 pow2( const in vec3 x ) { return x*x; }
float pow3( const in float x ) { return x*x*x; }
float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
float average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }
highp float rand( const in vec2 uv ) {
	const highp float a = 12.9898, b = 78.233, c = 43758.5453;
	highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
	return fract( sin( sn ) * c );
}
#ifdef HIGH_PRECISION
	float precisionSafeLength( vec3 v ) { return length( v ); }
#else
	float precisionSafeLength( vec3 v ) {
		float maxComponent = max3( abs( v ) );
		return length( v / maxComponent ) * maxComponent;
	}
#endif
struct IncidentLight {
	vec3 color;
	vec3 direction;
	bool visible;
};
struct ReflectedLight {
	vec3 directDiffuse;
	vec3 directSpecular;
	vec3 indirectDiffuse;
	vec3 indirectSpecular;
};
struct GeometricContext {
	vec3 position;
	vec3 normal;
	vec3 viewDir;
#ifdef USE_CLEARCOAT
	vec3 clearcoatNormal;
#endif
};
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
	return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
}
vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
	return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
}
mat3 transposeMat3( const in mat3 m ) {
	mat3 tmp;
	tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
	tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
	tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
	return tmp;
}
float linearToRelativeLuminance( const in vec3 color ) {
	vec3 weights = vec3( 0.2126, 0.7152, 0.0722 );
	return dot( weights, color.rgb );
}
bool isPerspectiveMatrix( mat4 m ) {
	return m[ 2 ][ 3 ] == - 1.0;
}
vec2 equirectUv( in vec3 dir ) {
	float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
	float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
	return vec2( u, v );
}`,G3=`#ifdef ENVMAP_TYPE_CUBE_UV
	#define cubeUV_minMipLevel 4.0
	#define cubeUV_minTileSize 16.0
	float getFace( vec3 direction ) {
		vec3 absDirection = abs( direction );
		float face = - 1.0;
		if ( absDirection.x > absDirection.z ) {
			if ( absDirection.x > absDirection.y )
				face = direction.x > 0.0 ? 0.0 : 3.0;
			else
				face = direction.y > 0.0 ? 1.0 : 4.0;
		} else {
			if ( absDirection.z > absDirection.y )
				face = direction.z > 0.0 ? 2.0 : 5.0;
			else
				face = direction.y > 0.0 ? 1.0 : 4.0;
		}
		return face;
	}
	vec2 getUV( vec3 direction, float face ) {
		vec2 uv;
		if ( face == 0.0 ) {
			uv = vec2( direction.z, direction.y ) / abs( direction.x );
		} else if ( face == 1.0 ) {
			uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
		} else if ( face == 2.0 ) {
			uv = vec2( - direction.x, direction.y ) / abs( direction.z );
		} else if ( face == 3.0 ) {
			uv = vec2( - direction.z, direction.y ) / abs( direction.x );
		} else if ( face == 4.0 ) {
			uv = vec2( - direction.x, direction.z ) / abs( direction.y );
		} else {
			uv = vec2( direction.x, direction.y ) / abs( direction.z );
		}
		return 0.5 * ( uv + 1.0 );
	}
	vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
		float face = getFace( direction );
		float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
		mipInt = max( mipInt, cubeUV_minMipLevel );
		float faceSize = exp2( mipInt );
		vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
		if ( face > 2.0 ) {
			uv.y += faceSize;
			face -= 3.0;
		}
		uv.x += face * faceSize;
		uv.x += filterInt * 3.0 * cubeUV_minTileSize;
		uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
		uv.x *= CUBEUV_TEXEL_WIDTH;
		uv.y *= CUBEUV_TEXEL_HEIGHT;
		#ifdef texture2DGradEXT
			return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
		#else
			return texture2D( envMap, uv ).rgb;
		#endif
	}
	#define r0 1.0
	#define v0 0.339
	#define m0 - 2.0
	#define r1 0.8
	#define v1 0.276
	#define m1 - 1.0
	#define r4 0.4
	#define v4 0.046
	#define m4 2.0
	#define r5 0.305
	#define v5 0.016
	#define m5 3.0
	#define r6 0.21
	#define v6 0.0038
	#define m6 4.0
	float roughnessToMip( float roughness ) {
		float mip = 0.0;
		if ( roughness >= r1 ) {
			mip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0;
		} else if ( roughness >= r4 ) {
			mip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1;
		} else if ( roughness >= r5 ) {
			mip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4;
		} else if ( roughness >= r6 ) {
			mip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5;
		} else {
			mip = - 2.0 * log2( 1.16 * roughness );		}
		return mip;
	}
	vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
		float mip = clamp( roughnessToMip( roughness ), m0, CUBEUV_MAX_MIP );
		float mipF = fract( mip );
		float mipInt = floor( mip );
		vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
		if ( mipF == 0.0 ) {
			return vec4( color0, 1.0 );
		} else {
			vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
			return vec4( mix( color0, color1, mipF ), 1.0 );
		}
	}
#endif`,j3=`vec3 transformedNormal = objectNormal;
#ifdef USE_INSTANCING
	mat3 m = mat3( instanceMatrix );
	transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );
	transformedNormal = m * transformedNormal;
#endif
transformedNormal = normalMatrix * transformedNormal;
#ifdef FLIP_SIDED
	transformedNormal = - transformedNormal;
#endif
#ifdef USE_TANGENT
	vec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;
	#ifdef FLIP_SIDED
		transformedTangent = - transformedTangent;
	#endif
#endif`,W3=`#ifdef USE_DISPLACEMENTMAP
	uniform sampler2D displacementMap;
	uniform float displacementScale;
	uniform float displacementBias;
#endif`,H3=`#ifdef USE_DISPLACEMENTMAP
	transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );
#endif`,q3=`#ifdef USE_EMISSIVEMAP
	vec4 emissiveColor = texture2D( emissiveMap, vUv );
	totalEmissiveRadiance *= emissiveColor.rgb;
#endif`,Z3=`#ifdef USE_EMISSIVEMAP
	uniform sampler2D emissiveMap;
#endif`,X3="gl_FragColor = linearToOutputTexel( gl_FragColor );",$3=`vec4 LinearToLinear( in vec4 value ) {
	return value;
}
vec4 LinearTosRGB( in vec4 value ) {
	return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
}`,Y3=`#ifdef USE_ENVMAP
	#ifdef ENV_WORLDPOS
		vec3 cameraToFrag;
		if ( isOrthographic ) {
			cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
		} else {
			cameraToFrag = normalize( vWorldPosition - cameraPosition );
		}
		vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
		#ifdef ENVMAP_MODE_REFLECTION
			vec3 reflectVec = reflect( cameraToFrag, worldNormal );
		#else
			vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
		#endif
	#else
		vec3 reflectVec = vReflect;
	#endif
	#ifdef ENVMAP_TYPE_CUBE
		vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
	#elif defined( ENVMAP_TYPE_CUBE_UV )
		vec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );
	#else
		vec4 envColor = vec4( 0.0 );
	#endif
	#ifdef ENVMAP_BLENDING_MULTIPLY
		outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
	#elif defined( ENVMAP_BLENDING_MIX )
		outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
	#elif defined( ENVMAP_BLENDING_ADD )
		outgoingLight += envColor.xyz * specularStrength * reflectivity;
	#endif
#endif`,J3=`#ifdef USE_ENVMAP
	uniform float envMapIntensity;
	uniform float flipEnvMap;
	#ifdef ENVMAP_TYPE_CUBE
		uniform samplerCube envMap;
	#else
		uniform sampler2D envMap;
	#endif
	
#endif`,K3=`#ifdef USE_ENVMAP
	uniform float reflectivity;
	#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )
		#define ENV_WORLDPOS
	#endif
	#ifdef ENV_WORLDPOS
		varying vec3 vWorldPosition;
		uniform float refractionRatio;
	#else
		varying vec3 vReflect;
	#endif
#endif`,Q3=`#ifdef USE_ENVMAP
	#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )
		#define ENV_WORLDPOS
	#endif
	#ifdef ENV_WORLDPOS
		
		varying vec3 vWorldPosition;
	#else
		varying vec3 vReflect;
		uniform float refractionRatio;
	#endif
#endif`,eR=`#ifdef USE_ENVMAP
	#ifdef ENV_WORLDPOS
		vWorldPosition = worldPosition.xyz;
	#else
		vec3 cameraToVertex;
		if ( isOrthographic ) {
			cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
		} else {
			cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
		}
		vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
		#ifdef ENVMAP_MODE_REFLECTION
			vReflect = reflect( cameraToVertex, worldNormal );
		#else
			vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
		#endif
	#endif
#endif`,tR=`#ifdef USE_FOG
	vFogDepth = - mvPosition.z;
#endif`,nR=`#ifdef USE_FOG
	varying float vFogDepth;
#endif`,iR=`#ifdef USE_FOG
	#ifdef FOG_EXP2
		float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
	#else
		float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
	#endif
	gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
#endif`,rR=`#ifdef USE_FOG
	uniform vec3 fogColor;
	varying float vFogDepth;
	#ifdef FOG_EXP2
		uniform float fogDensity;
	#else
		uniform float fogNear;
		uniform float fogFar;
	#endif
#endif`,sR=`#ifdef USE_GRADIENTMAP
	uniform sampler2D gradientMap;
#endif
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
	float dotNL = dot( normal, lightDirection );
	vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
	#ifdef USE_GRADIENTMAP
		return vec3( texture2D( gradientMap, coord ).r );
	#else
		return ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );
	#endif
}`,oR=`#ifdef USE_LIGHTMAP
	vec4 lightMapTexel = texture2D( lightMap, vUv2 );
	vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
	reflectedLight.indirectDiffuse += lightMapIrradiance;
#endif`,aR=`#ifdef USE_LIGHTMAP
	uniform sampler2D lightMap;
	uniform float lightMapIntensity;
#endif`,lR=`vec3 diffuse = vec3( 1.0 );
GeometricContext geometry;
geometry.position = mvPosition.xyz;
geometry.normal = normalize( transformedNormal );
geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );
GeometricContext backGeometry;
backGeometry.position = geometry.position;
backGeometry.normal = -geometry.normal;
backGeometry.viewDir = geometry.viewDir;
vLightFront = vec3( 0.0 );
vIndirectFront = vec3( 0.0 );
#ifdef DOUBLE_SIDED
	vLightBack = vec3( 0.0 );
	vIndirectBack = vec3( 0.0 );
#endif
IncidentLight directLight;
float dotNL;
vec3 directLightColor_Diffuse;
vIndirectFront += getAmbientLightIrradiance( ambientLightColor );
vIndirectFront += getLightProbeIrradiance( lightProbe, geometry.normal );
#ifdef DOUBLE_SIDED
	vIndirectBack += getAmbientLightIrradiance( ambientLightColor );
	vIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry.normal );
#endif
#if NUM_POINT_LIGHTS > 0
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
		getPointLightInfo( pointLights[ i ], geometry, directLight );
		dotNL = dot( geometry.normal, directLight.direction );
		directLightColor_Diffuse = directLight.color;
		vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
		#ifdef DOUBLE_SIDED
			vLightBack += saturate( - dotNL ) * directLightColor_Diffuse;
		#endif
	}
	#pragma unroll_loop_end
#endif
#if NUM_SPOT_LIGHTS > 0
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
		getSpotLightInfo( spotLights[ i ], geometry, directLight );
		dotNL = dot( geometry.normal, directLight.direction );
		directLightColor_Diffuse = directLight.color;
		vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
		#ifdef DOUBLE_SIDED
			vLightBack += saturate( - dotNL ) * directLightColor_Diffuse;
		#endif
	}
	#pragma unroll_loop_end
#endif
#if NUM_DIR_LIGHTS > 0
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
		getDirectionalLightInfo( directionalLights[ i ], geometry, directLight );
		dotNL = dot( geometry.normal, directLight.direction );
		directLightColor_Diffuse = directLight.color;
		vLightFront += saturate( dotNL ) * directLightColor_Diffuse;
		#ifdef DOUBLE_SIDED
			vLightBack += saturate( - dotNL ) * directLightColor_Diffuse;
		#endif
	}
	#pragma unroll_loop_end
#endif
#if NUM_HEMI_LIGHTS > 0
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
		vIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );
		#ifdef DOUBLE_SIDED
			vIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry.normal );
		#endif
	}
	#pragma unroll_loop_end
#endif`,cR=`uniform bool receiveShadow;
uniform vec3 ambientLightColor;
uniform vec3 lightProbe[ 9 ];
vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
	float x = normal.x, y = normal.y, z = normal.z;
	vec3 result = shCoefficients[ 0 ] * 0.886227;
	result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
	result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
	result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
	result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
	result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
	result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
	result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
	result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
	return result;
}
vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
	vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
	vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
	return irradiance;
}
vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
	vec3 irradiance = ambientLightColor;
	return irradiance;
}
float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
	#if defined ( PHYSICALLY_CORRECT_LIGHTS )
		float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
		if ( cutoffDistance > 0.0 ) {
			distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
		}
		return distanceFalloff;
	#else
		if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
			return pow( saturate( - lightDistance / cutoffDistance + 1.0 ), decayExponent );
		}
		return 1.0;
	#endif
}
float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
	return smoothstep( coneCosine, penumbraCosine, angleCosine );
}
#if NUM_DIR_LIGHTS > 0
	struct DirectionalLight {
		vec3 direction;
		vec3 color;
	};
	uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
	void getDirectionalLightInfo( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light ) {
		light.color = directionalLight.color;
		light.direction = directionalLight.direction;
		light.visible = true;
	}
#endif
#if NUM_POINT_LIGHTS > 0
	struct PointLight {
		vec3 position;
		vec3 color;
		float distance;
		float decay;
	};
	uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
	void getPointLightInfo( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light ) {
		vec3 lVector = pointLight.position - geometry.position;
		light.direction = normalize( lVector );
		float lightDistance = length( lVector );
		light.color = pointLight.color;
		light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
		light.visible = ( light.color != vec3( 0.0 ) );
	}
#endif
#if NUM_SPOT_LIGHTS > 0
	struct SpotLight {
		vec3 position;
		vec3 direction;
		vec3 color;
		float distance;
		float decay;
		float coneCos;
		float penumbraCos;
	};
	uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
	void getSpotLightInfo( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light ) {
		vec3 lVector = spotLight.position - geometry.position;
		light.direction = normalize( lVector );
		float angleCos = dot( light.direction, spotLight.direction );
		float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
		if ( spotAttenuation > 0.0 ) {
			float lightDistance = length( lVector );
			light.color = spotLight.color * spotAttenuation;
			light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
			light.visible = ( light.color != vec3( 0.0 ) );
		} else {
			light.color = vec3( 0.0 );
			light.visible = false;
		}
	}
#endif
#if NUM_RECT_AREA_LIGHTS > 0
	struct RectAreaLight {
		vec3 color;
		vec3 position;
		vec3 halfWidth;
		vec3 halfHeight;
	};
	uniform sampler2D ltc_1;	uniform sampler2D ltc_2;
	uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
#endif
#if NUM_HEMI_LIGHTS > 0
	struct HemisphereLight {
		vec3 direction;
		vec3 skyColor;
		vec3 groundColor;
	};
	uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
	vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
		float dotNL = dot( normal, hemiLight.direction );
		float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
		vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
		return irradiance;
	}
#endif`,uR=`#if defined( USE_ENVMAP )
	vec3 getIBLIrradiance( const in vec3 normal ) {
		#if defined( ENVMAP_TYPE_CUBE_UV )
			vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
			vec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );
			return PI * envMapColor.rgb * envMapIntensity;
		#else
			return vec3( 0.0 );
		#endif
	}
	vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
		#if defined( ENVMAP_TYPE_CUBE_UV )
			vec3 reflectVec = reflect( - viewDir, normal );
			reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );
			reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
			vec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );
			return envMapColor.rgb * envMapIntensity;
		#else
			return vec3( 0.0 );
		#endif
	}
#endif`,hR=`ToonMaterial material;
material.diffuseColor = diffuseColor.rgb;`,dR=`varying vec3 vViewPosition;
struct ToonMaterial {
	vec3 diffuseColor;
};
void RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
	vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;
	reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct				RE_Direct_Toon
#define RE_IndirectDiffuse		RE_IndirectDiffuse_Toon
#define Material_LightProbeLOD( material )	(0)`,fR=`BlinnPhongMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularColor = specular;
material.specularShininess = shininess;
material.specularStrength = specularStrength;`,pR=`varying vec3 vViewPosition;
struct BlinnPhongMaterial {
	vec3 diffuseColor;
	vec3 specularColor;
	float specularShininess;
	float specularStrength;
};
void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
	float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
	vec3 irradiance = dotNL * directLight.color;
	reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
	reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess ) * material.specularStrength;
}
void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct				RE_Direct_BlinnPhong
#define RE_IndirectDiffuse		RE_IndirectDiffuse_BlinnPhong
#define Material_LightProbeLOD( material )	(0)`,mR=`PhysicalMaterial material;
material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );
float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
material.roughness = min( material.roughness, 1.0 );
#ifdef IOR
	#ifdef SPECULAR
		float specularIntensityFactor = specularIntensity;
		vec3 specularColorFactor = specularColor;
		#ifdef USE_SPECULARINTENSITYMAP
			specularIntensityFactor *= texture2D( specularIntensityMap, vUv ).a;
		#endif
		#ifdef USE_SPECULARCOLORMAP
			specularColorFactor *= texture2D( specularColorMap, vUv ).rgb;
		#endif
		material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
	#else
		float specularIntensityFactor = 1.0;
		vec3 specularColorFactor = vec3( 1.0 );
		material.specularF90 = 1.0;
	#endif
	material.specularColor = mix( min( pow2( ( ior - 1.0 ) / ( ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
#else
	material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
	material.specularF90 = 1.0;
#endif
#ifdef USE_CLEARCOAT
	material.clearcoat = clearcoat;
	material.clearcoatRoughness = clearcoatRoughness;
	material.clearcoatF0 = vec3( 0.04 );
	material.clearcoatF90 = 1.0;
	#ifdef USE_CLEARCOATMAP
		material.clearcoat *= texture2D( clearcoatMap, vUv ).x;
	#endif
	#ifdef USE_CLEARCOAT_ROUGHNESSMAP
		material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;
	#endif
	material.clearcoat = saturate( material.clearcoat );	material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
	material.clearcoatRoughness += geometryRoughness;
	material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
#endif
#ifdef USE_IRIDESCENCE
	material.iridescence = iridescence;
	material.iridescenceIOR = iridescenceIOR;
	#ifdef USE_IRIDESCENCEMAP
		material.iridescence *= texture2D( iridescenceMap, vUv ).r;
	#endif
	#ifdef USE_IRIDESCENCE_THICKNESSMAP
		material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vUv ).g + iridescenceThicknessMinimum;
	#else
		material.iridescenceThickness = iridescenceThicknessMaximum;
	#endif
#endif
#ifdef USE_SHEEN
	material.sheenColor = sheenColor;
	#ifdef USE_SHEENCOLORMAP
		material.sheenColor *= texture2D( sheenColorMap, vUv ).rgb;
	#endif
	material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
	#ifdef USE_SHEENROUGHNESSMAP
		material.sheenRoughness *= texture2D( sheenRoughnessMap, vUv ).a;
	#endif
#endif`,gR=`struct PhysicalMaterial {
	vec3 diffuseColor;
	float roughness;
	vec3 specularColor;
	float specularF90;
	#ifdef USE_CLEARCOAT
		float clearcoat;
		float clearcoatRoughness;
		vec3 clearcoatF0;
		float clearcoatF90;
	#endif
	#ifdef USE_IRIDESCENCE
		float iridescence;
		float iridescenceIOR;
		float iridescenceThickness;
		vec3 iridescenceFresnel;
		vec3 iridescenceF0;
	#endif
	#ifdef USE_SHEEN
		vec3 sheenColor;
		float sheenRoughness;
	#endif
};
vec3 clearcoatSpecular = vec3( 0.0 );
vec3 sheenSpecular = vec3( 0.0 );
float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness) {
	float dotNV = saturate( dot( normal, viewDir ) );
	float r2 = roughness * roughness;
	float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
	float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
	float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
	return saturate( DG * RECIPROCAL_PI );
}
vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
	float dotNV = saturate( dot( normal, viewDir ) );
	const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
	const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
	vec4 r = roughness * c0 + c1;
	float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
	vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
	return fab;
}
vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
	vec2 fab = DFGApprox( normal, viewDir, roughness );
	return specularColor * fab.x + specularF90 * fab.y;
}
#ifdef USE_IRIDESCENCE
void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
#else
void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
#endif
	vec2 fab = DFGApprox( normal, viewDir, roughness );
	#ifdef USE_IRIDESCENCE
		vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
	#else
		vec3 Fr = specularColor;
	#endif
	vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
	float Ess = fab.x + fab.y;
	float Ems = 1.0 - Ess;
	vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619;	vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
	singleScatter += FssEss;
	multiScatter += Fms * Ems;
}
#if NUM_RECT_AREA_LIGHTS > 0
	void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
		vec3 normal = geometry.normal;
		vec3 viewDir = geometry.viewDir;
		vec3 position = geometry.position;
		vec3 lightPos = rectAreaLight.position;
		vec3 halfWidth = rectAreaLight.halfWidth;
		vec3 halfHeight = rectAreaLight.halfHeight;
		vec3 lightColor = rectAreaLight.color;
		float roughness = material.roughness;
		vec3 rectCoords[ 4 ];
		rectCoords[ 0 ] = lightPos + halfWidth - halfHeight;		rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
		rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
		rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
		vec2 uv = LTC_Uv( normal, viewDir, roughness );
		vec4 t1 = texture2D( ltc_1, uv );
		vec4 t2 = texture2D( ltc_2, uv );
		mat3 mInv = mat3(
			vec3( t1.x, 0, t1.y ),
			vec3(    0, 1,    0 ),
			vec3( t1.z, 0, t1.w )
		);
		vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
		reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
		reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
	}
#endif
void RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
	float dotNL = saturate( dot( geometry.normal, directLight.direction ) );
	vec3 irradiance = dotNL * directLight.color;
	#ifdef USE_CLEARCOAT
		float dotNLcc = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );
		vec3 ccIrradiance = dotNLcc * directLight.color;
		clearcoatSpecular += ccIrradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
	#endif
	#ifdef USE_SHEEN
		sheenSpecular += irradiance * BRDF_Sheen( directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness );
	#endif
	#ifdef USE_IRIDESCENCE
		reflectedLight.directSpecular += irradiance * BRDF_GGX_Iridescence( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness );
	#else
		reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness );
	#endif
	reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
	reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
	#ifdef USE_CLEARCOAT
		clearcoatSpecular += clearcoatRadiance * EnvironmentBRDF( geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
	#endif
	#ifdef USE_SHEEN
		sheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF( geometry.normal, geometry.viewDir, material.sheenRoughness );
	#endif
	vec3 singleScattering = vec3( 0.0 );
	vec3 multiScattering = vec3( 0.0 );
	vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
	#ifdef USE_IRIDESCENCE
		computeMultiscatteringIridescence( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
	#else
		computeMultiscattering( geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
	#endif
	vec3 totalScattering = singleScattering + multiScattering;
	vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
	reflectedLight.indirectSpecular += radiance * singleScattering;
	reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
	reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
}
#define RE_Direct				RE_Direct_Physical
#define RE_Direct_RectArea		RE_Direct_RectArea_Physical
#define RE_IndirectDiffuse		RE_IndirectDiffuse_Physical
#define RE_IndirectSpecular		RE_IndirectSpecular_Physical
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
	return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
}`,_R=`
GeometricContext geometry;
geometry.position = - vViewPosition;
geometry.normal = normal;
geometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
#ifdef USE_CLEARCOAT
	geometry.clearcoatNormal = clearcoatNormal;
#endif
#ifdef USE_IRIDESCENCE
float dotNVi = saturate( dot( normal, geometry.viewDir ) );
if ( material.iridescenceThickness == 0.0 ) {
	material.iridescence = 0.0;
} else {
	material.iridescence = saturate( material.iridescence );
}
if ( material.iridescence > 0.0 ) {
	material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
	material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
}
#endif
IncidentLight directLight;
#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
	PointLight pointLight;
	#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
	PointLightShadow pointLightShadow;
	#endif
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
		pointLight = pointLights[ i ];
		getPointLightInfo( pointLight, geometry, directLight );
		#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
		pointLightShadow = pointLightShadows[ i ];
		directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
		#endif
		RE_Direct( directLight, geometry, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
	SpotLight spotLight;
	#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
	SpotLightShadow spotLightShadow;
	#endif
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
		spotLight = spotLights[ i ];
		getSpotLightInfo( spotLight, geometry, directLight );
		#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
		spotLightShadow = spotLightShadows[ i ];
		directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;
		#endif
		RE_Direct( directLight, geometry, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
	DirectionalLight directionalLight;
	#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
	DirectionalLightShadow directionalLightShadow;
	#endif
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
		directionalLight = directionalLights[ i ];
		getDirectionalLightInfo( directionalLight, geometry, directLight );
		#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
		directionalLightShadow = directionalLightShadows[ i ];
		directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
		#endif
		RE_Direct( directLight, geometry, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
	RectAreaLight rectAreaLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
		rectAreaLight = rectAreaLights[ i ];
		RE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );
	}
	#pragma unroll_loop_end
#endif
#if defined( RE_IndirectDiffuse )
	vec3 iblIrradiance = vec3( 0.0 );
	vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
	irradiance += getLightProbeIrradiance( lightProbe, geometry.normal );
	#if ( NUM_HEMI_LIGHTS > 0 )
		#pragma unroll_loop_start
		for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
			irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry.normal );
		}
		#pragma unroll_loop_end
	#endif
#endif
#if defined( RE_IndirectSpecular )
	vec3 radiance = vec3( 0.0 );
	vec3 clearcoatRadiance = vec3( 0.0 );
#endif`,yR=`#if defined( RE_IndirectDiffuse )
	#ifdef USE_LIGHTMAP
		vec4 lightMapTexel = texture2D( lightMap, vUv2 );
		vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
		irradiance += lightMapIrradiance;
	#endif
	#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
		iblIrradiance += getIBLIrradiance( geometry.normal );
	#endif
#endif
#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
	radiance += getIBLRadiance( geometry.viewDir, geometry.normal, material.roughness );
	#ifdef USE_CLEARCOAT
		clearcoatRadiance += getIBLRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness );
	#endif
#endif`,xR=`#if defined( RE_IndirectDiffuse )
	RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );
#endif
#if defined( RE_IndirectSpecular )
	RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );
#endif`,vR=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
	gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
#endif`,bR=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
	uniform float logDepthBufFC;
	varying float vFragDepth;
	varying float vIsPerspective;
#endif`,wR=`#ifdef USE_LOGDEPTHBUF
	#ifdef USE_LOGDEPTHBUF_EXT
		varying float vFragDepth;
		varying float vIsPerspective;
	#else
		uniform float logDepthBufFC;
	#endif
#endif`,SR=`#ifdef USE_LOGDEPTHBUF
	#ifdef USE_LOGDEPTHBUF_EXT
		vFragDepth = 1.0 + gl_Position.w;
		vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
	#else
		if ( isPerspectiveMatrix( projectionMatrix ) ) {
			gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;
			gl_Position.z *= gl_Position.w;
		}
	#endif
#endif`,MR=`#ifdef USE_MAP
	vec4 sampledDiffuseColor = texture2D( map, vUv );
	#ifdef DECODE_VIDEO_TEXTURE
		sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );
	#endif
	diffuseColor *= sampledDiffuseColor;
#endif`,ER=`#ifdef USE_MAP
	uniform sampler2D map;
#endif`,TR=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
	vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
#endif
#ifdef USE_MAP
	diffuseColor *= texture2D( map, uv );
#endif
#ifdef USE_ALPHAMAP
	diffuseColor.a *= texture2D( alphaMap, uv ).g;
#endif`,AR=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
	uniform mat3 uvTransform;
#endif
#ifdef USE_MAP
	uniform sampler2D map;
#endif
#ifdef USE_ALPHAMAP
	uniform sampler2D alphaMap;
#endif`,CR=`float metalnessFactor = metalness;
#ifdef USE_METALNESSMAP
	vec4 texelMetalness = texture2D( metalnessMap, vUv );
	metalnessFactor *= texelMetalness.b;
#endif`,IR=`#ifdef USE_METALNESSMAP
	uniform sampler2D metalnessMap;
#endif`,PR=`#if defined( USE_MORPHCOLORS ) && defined( MORPHTARGETS_TEXTURE )
	vColor *= morphTargetBaseInfluence;
	for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
		#if defined( USE_COLOR_ALPHA )
			if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
		#elif defined( USE_COLOR )
			if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
		#endif
	}
#endif`,LR=`#ifdef USE_MORPHNORMALS
	objectNormal *= morphTargetBaseInfluence;
	#ifdef MORPHTARGETS_TEXTURE
		for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
			if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
		}
	#else
		objectNormal += morphNormal0 * morphTargetInfluences[ 0 ];
		objectNormal += morphNormal1 * morphTargetInfluences[ 1 ];
		objectNormal += morphNormal2 * morphTargetInfluences[ 2 ];
		objectNormal += morphNormal3 * morphTargetInfluences[ 3 ];
	#endif
#endif`,RR=`#ifdef USE_MORPHTARGETS
	uniform float morphTargetBaseInfluence;
	#ifdef MORPHTARGETS_TEXTURE
		uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
		uniform sampler2DArray morphTargetsTexture;
		uniform ivec2 morphTargetsTextureSize;
		vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
			int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
			int y = texelIndex / morphTargetsTextureSize.x;
			int x = texelIndex - y * morphTargetsTextureSize.x;
			ivec3 morphUV = ivec3( x, y, morphTargetIndex );
			return texelFetch( morphTargetsTexture, morphUV, 0 );
		}
	#else
		#ifndef USE_MORPHNORMALS
			uniform float morphTargetInfluences[ 8 ];
		#else
			uniform float morphTargetInfluences[ 4 ];
		#endif
	#endif
#endif`,DR=`#ifdef USE_MORPHTARGETS
	transformed *= morphTargetBaseInfluence;
	#ifdef MORPHTARGETS_TEXTURE
		for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
			if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
		}
	#else
		transformed += morphTarget0 * morphTargetInfluences[ 0 ];
		transformed += morphTarget1 * morphTargetInfluences[ 1 ];
		transformed += morphTarget2 * morphTargetInfluences[ 2 ];
		transformed += morphTarget3 * morphTargetInfluences[ 3 ];
		#ifndef USE_MORPHNORMALS
			transformed += morphTarget4 * morphTargetInfluences[ 4 ];
			transformed += morphTarget5 * morphTargetInfluences[ 5 ];
			transformed += morphTarget6 * morphTargetInfluences[ 6 ];
			transformed += morphTarget7 * morphTargetInfluences[ 7 ];
		#endif
	#endif
#endif`,zR=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
#ifdef FLAT_SHADED
	vec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );
	vec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );
	vec3 normal = normalize( cross( fdx, fdy ) );
#else
	vec3 normal = normalize( vNormal );
	#ifdef DOUBLE_SIDED
		normal = normal * faceDirection;
	#endif
	#ifdef USE_TANGENT
		vec3 tangent = normalize( vTangent );
		vec3 bitangent = normalize( vBitangent );
		#ifdef DOUBLE_SIDED
			tangent = tangent * faceDirection;
			bitangent = bitangent * faceDirection;
		#endif
		#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )
			mat3 vTBN = mat3( tangent, bitangent, normal );
		#endif
	#endif
#endif
vec3 geometryNormal = normal;`,kR=`#ifdef OBJECTSPACE_NORMALMAP
	normal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;
	#ifdef FLIP_SIDED
		normal = - normal;
	#endif
	#ifdef DOUBLE_SIDED
		normal = normal * faceDirection;
	#endif
	normal = normalize( normalMatrix * normal );
#elif defined( TANGENTSPACE_NORMALMAP )
	vec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;
	mapN.xy *= normalScale;
	#ifdef USE_TANGENT
		normal = normalize( vTBN * mapN );
	#else
		normal = perturbNormal2Arb( - vViewPosition, normal, mapN, faceDirection );
	#endif
#elif defined( USE_BUMPMAP )
	normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
#endif`,OR=`#ifndef FLAT_SHADED
	varying vec3 vNormal;
	#ifdef USE_TANGENT
		varying vec3 vTangent;
		varying vec3 vBitangent;
	#endif
#endif`,FR=`#ifndef FLAT_SHADED
	varying vec3 vNormal;
	#ifdef USE_TANGENT
		varying vec3 vTangent;
		varying vec3 vBitangent;
	#endif
#endif`,BR=`#ifndef FLAT_SHADED
	vNormal = normalize( transformedNormal );
	#ifdef USE_TANGENT
		vTangent = normalize( transformedTangent );
		vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
	#endif
#endif`,NR=`#ifdef USE_NORMALMAP
	uniform sampler2D normalMap;
	uniform vec2 normalScale;
#endif
#ifdef OBJECTSPACE_NORMALMAP
	uniform mat3 normalMatrix;
#endif
#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )
	vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection ) {
		vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );
		vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );
		vec2 st0 = dFdx( vUv.st );
		vec2 st1 = dFdy( vUv.st );
		vec3 N = surf_norm;
		vec3 q1perp = cross( q1, N );
		vec3 q0perp = cross( N, q0 );
		vec3 T = q1perp * st0.x + q0perp * st1.x;
		vec3 B = q1perp * st0.y + q0perp * st1.y;
		float det = max( dot( T, T ), dot( B, B ) );
		float scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det );
		return normalize( T * ( mapN.x * scale ) + B * ( mapN.y * scale ) + N * mapN.z );
	}
#endif`,UR=`#ifdef USE_CLEARCOAT
	vec3 clearcoatNormal = geometryNormal;
#endif`,VR=`#ifdef USE_CLEARCOAT_NORMALMAP
	vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;
	clearcoatMapN.xy *= clearcoatNormalScale;
	#ifdef USE_TANGENT
		clearcoatNormal = normalize( vTBN * clearcoatMapN );
	#else
		clearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection );
	#endif
#endif`,GR=`#ifdef USE_CLEARCOATMAP
	uniform sampler2D clearcoatMap;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
	uniform sampler2D clearcoatRoughnessMap;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
	uniform sampler2D clearcoatNormalMap;
	uniform vec2 clearcoatNormalScale;
#endif`,jR=`#ifdef USE_IRIDESCENCEMAP
	uniform sampler2D iridescenceMap;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
	uniform sampler2D iridescenceThicknessMap;
#endif`,WR=`#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
#ifdef USE_TRANSMISSION
diffuseColor.a *= transmissionAlpha + 0.1;
#endif
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,HR=`vec3 packNormalToRGB( const in vec3 normal ) {
	return normalize( normal ) * 0.5 + 0.5;
}
vec3 unpackRGBToNormal( const in vec3 rgb ) {
	return 2.0 * rgb.xyz - 1.0;
}
const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;
const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );
const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );
const float ShiftRight8 = 1. / 256.;
vec4 packDepthToRGBA( const in float v ) {
	vec4 r = vec4( fract( v * PackFactors ), v );
	r.yzw -= r.xyz * ShiftRight8;	return r * PackUpscale;
}
float unpackRGBAToDepth( const in vec4 v ) {
	return dot( v, UnpackFactors );
}
vec4 pack2HalfToRGBA( vec2 v ) {
	vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
	return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
}
vec2 unpackRGBATo2Half( vec4 v ) {
	return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
}
float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
	return ( viewZ + near ) / ( near - far );
}
float orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {
	return linearClipZ * ( near - far ) - near;
}
float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
	return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
}
float perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {
	return ( near * far ) / ( ( far - near ) * invClipZ - far );
}`,qR=`#ifdef PREMULTIPLIED_ALPHA
	gl_FragColor.rgb *= gl_FragColor.a;
#endif`,ZR=`vec4 mvPosition = vec4( transformed, 1.0 );
#ifdef USE_INSTANCING
	mvPosition = instanceMatrix * mvPosition;
#endif
mvPosition = modelViewMatrix * mvPosition;
gl_Position = projectionMatrix * mvPosition;`,XR=`#ifdef DITHERING
	gl_FragColor.rgb = dithering( gl_FragColor.rgb );
#endif`,$R=`#ifdef DITHERING
	vec3 dithering( vec3 color ) {
		float grid_position = rand( gl_FragCoord.xy );
		vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
		dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
		return color + dither_shift_RGB;
	}
#endif`,YR=`float roughnessFactor = roughness;
#ifdef USE_ROUGHNESSMAP
	vec4 texelRoughness = texture2D( roughnessMap, vUv );
	roughnessFactor *= texelRoughness.g;
#endif`,JR=`#ifdef USE_ROUGHNESSMAP
	uniform sampler2D roughnessMap;
#endif`,KR=`#ifdef USE_SHADOWMAP
	#if NUM_DIR_LIGHT_SHADOWS > 0
		uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
		varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
		struct DirectionalLightShadow {
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
	#endif
	#if NUM_SPOT_LIGHT_SHADOWS > 0
		uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
		varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];
		struct SpotLightShadow {
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
		uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
		varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
		struct PointLightShadow {
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
			float shadowCameraNear;
			float shadowCameraFar;
		};
		uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
	#endif
	float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
		return step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );
	}
	vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
		return unpackRGBATo2Half( texture2D( shadow, uv ) );
	}
	float VSMShadow (sampler2D shadow, vec2 uv, float compare ){
		float occlusion = 1.0;
		vec2 distribution = texture2DDistribution( shadow, uv );
		float hard_shadow = step( compare , distribution.x );
		if (hard_shadow != 1.0 ) {
			float distance = compare - distribution.x ;
			float variance = max( 0.00000, distribution.y * distribution.y );
			float softness_probability = variance / (variance + distance * distance );			softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );			occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
		}
		return occlusion;
	}
	float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
		float shadow = 1.0;
		shadowCoord.xyz /= shadowCoord.w;
		shadowCoord.z += shadowBias;
		bvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );
		bool inFrustum = all( inFrustumVec );
		bvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );
		bool frustumTest = all( frustumTestVec );
		if ( frustumTest ) {
		#if defined( SHADOWMAP_TYPE_PCF )
			vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
			float dx0 = - texelSize.x * shadowRadius;
			float dy0 = - texelSize.y * shadowRadius;
			float dx1 = + texelSize.x * shadowRadius;
			float dy1 = + texelSize.y * shadowRadius;
			float dx2 = dx0 / 2.0;
			float dy2 = dy0 / 2.0;
			float dx3 = dx1 / 2.0;
			float dy3 = dy1 / 2.0;
			shadow = (
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
			) * ( 1.0 / 17.0 );
		#elif defined( SHADOWMAP_TYPE_PCF_SOFT )
			vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
			float dx = texelSize.x;
			float dy = texelSize.y;
			vec2 uv = shadowCoord.xy;
			vec2 f = fract( uv * shadowMapSize + 0.5 );
			uv -= f * texelSize;
			shadow = (
				texture2DCompare( shadowMap, uv, shadowCoord.z ) +
				texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
				texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
				texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
				mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), 
					 texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
					 f.x ) +
				mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), 
					 texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
					 f.x ) +
				mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), 
					 texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
					 f.y ) +
				mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), 
					 texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
					 f.y ) +
				mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), 
						  texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
						  f.x ),
					 mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), 
						  texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
						  f.x ),
					 f.y )
			) * ( 1.0 / 9.0 );
		#elif defined( SHADOWMAP_TYPE_VSM )
			shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
		#else
			shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
		#endif
		}
		return shadow;
	}
	vec2 cubeToUV( vec3 v, float texelSizeY ) {
		vec3 absV = abs( v );
		float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
		absV *= scaleToCube;
		v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
		vec2 planar = v.xy;
		float almostATexel = 1.5 * texelSizeY;
		float almostOne = 1.0 - almostATexel;
		if ( absV.z >= almostOne ) {
			if ( v.z > 0.0 )
				planar.x = 4.0 - v.x;
		} else if ( absV.x >= almostOne ) {
			float signX = sign( v.x );
			planar.x = v.z * signX + 2.0 * signX;
		} else if ( absV.y >= almostOne ) {
			float signY = sign( v.y );
			planar.x = v.x + 2.0 * signY + 2.0;
			planar.y = v.z * signY - 2.0;
		}
		return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
	}
	float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
		vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
		vec3 lightToPosition = shadowCoord.xyz;
		float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );		dp += shadowBias;
		vec3 bd3D = normalize( lightToPosition );
		#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
			vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
			return (
				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
				texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
				texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
			) * ( 1.0 / 9.0 );
		#else
			return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
		#endif
	}
#endif`,QR=`#ifdef USE_SHADOWMAP
	#if NUM_DIR_LIGHT_SHADOWS > 0
		uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
		varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
		struct DirectionalLightShadow {
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
	#endif
	#if NUM_SPOT_LIGHT_SHADOWS > 0
		uniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];
		varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];
		struct SpotLightShadow {
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
		};
		uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
		uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
		varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
		struct PointLightShadow {
			float shadowBias;
			float shadowNormalBias;
			float shadowRadius;
			vec2 shadowMapSize;
			float shadowCameraNear;
			float shadowCameraFar;
		};
		uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
	#endif
#endif`,eD=`#ifdef USE_SHADOWMAP
	#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0
		vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
		vec4 shadowWorldPosition;
	#endif
	#if NUM_DIR_LIGHT_SHADOWS > 0
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
		shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
		vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
	}
	#pragma unroll_loop_end
	#endif
	#if NUM_SPOT_LIGHT_SHADOWS > 0
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
		shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );
		vSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition;
	}
	#pragma unroll_loop_end
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
		shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
		vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
	}
	#pragma unroll_loop_end
	#endif
#endif`,tD=`float getShadowMask() {
	float shadow = 1.0;
	#ifdef USE_SHADOWMAP
	#if NUM_DIR_LIGHT_SHADOWS > 0
	DirectionalLightShadow directionalLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
		directionalLight = directionalLightShadows[ i ];
		shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
	}
	#pragma unroll_loop_end
	#endif
	#if NUM_SPOT_LIGHT_SHADOWS > 0
	SpotLightShadow spotLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
		spotLight = spotLightShadows[ i ];
		shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;
	}
	#pragma unroll_loop_end
	#endif
	#if NUM_POINT_LIGHT_SHADOWS > 0
	PointLightShadow pointLight;
	#pragma unroll_loop_start
	for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
		pointLight = pointLightShadows[ i ];
		shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
	}
	#pragma unroll_loop_end
	#endif
	#endif
	return shadow;
}`,nD=`#ifdef USE_SKINNING
	mat4 boneMatX = getBoneMatrix( skinIndex.x );
	mat4 boneMatY = getBoneMatrix( skinIndex.y );
	mat4 boneMatZ = getBoneMatrix( skinIndex.z );
	mat4 boneMatW = getBoneMatrix( skinIndex.w );
#endif`,iD=`#ifdef USE_SKINNING
	uniform mat4 bindMatrix;
	uniform mat4 bindMatrixInverse;
	uniform highp sampler2D boneTexture;
	uniform int boneTextureSize;
	mat4 getBoneMatrix( const in float i ) {
		float j = i * 4.0;
		float x = mod( j, float( boneTextureSize ) );
		float y = floor( j / float( boneTextureSize ) );
		float dx = 1.0 / float( boneTextureSize );
		float dy = 1.0 / float( boneTextureSize );
		y = dy * ( y + 0.5 );
		vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );
		vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );
		vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );
		vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );
		mat4 bone = mat4( v1, v2, v3, v4 );
		return bone;
	}
#endif`,rD=`#ifdef USE_SKINNING
	vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
	vec4 skinned = vec4( 0.0 );
	skinned += boneMatX * skinVertex * skinWeight.x;
	skinned += boneMatY * skinVertex * skinWeight.y;
	skinned += boneMatZ * skinVertex * skinWeight.z;
	skinned += boneMatW * skinVertex * skinWeight.w;
	transformed = ( bindMatrixInverse * skinned ).xyz;
#endif`,sD=`#ifdef USE_SKINNING
	mat4 skinMatrix = mat4( 0.0 );
	skinMatrix += skinWeight.x * boneMatX;
	skinMatrix += skinWeight.y * boneMatY;
	skinMatrix += skinWeight.z * boneMatZ;
	skinMatrix += skinWeight.w * boneMatW;
	skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
	objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
	#ifdef USE_TANGENT
		objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
	#endif
#endif`,oD=`float specularStrength;
#ifdef USE_SPECULARMAP
	vec4 texelSpecular = texture2D( specularMap, vUv );
	specularStrength = texelSpecular.r;
#else
	specularStrength = 1.0;
#endif`,aD=`#ifdef USE_SPECULARMAP
	uniform sampler2D specularMap;
#endif`,lD=`#if defined( TONE_MAPPING )
	gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
#endif`,cD=`#ifndef saturate
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
uniform float toneMappingExposure;
vec3 LinearToneMapping( vec3 color ) {
	return toneMappingExposure * color;
}
vec3 ReinhardToneMapping( vec3 color ) {
	color *= toneMappingExposure;
	return saturate( color / ( vec3( 1.0 ) + color ) );
}
vec3 OptimizedCineonToneMapping( vec3 color ) {
	color *= toneMappingExposure;
	color = max( vec3( 0.0 ), color - 0.004 );
	return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
}
vec3 RRTAndODTFit( vec3 v ) {
	vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
	vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
	return a / b;
}
vec3 ACESFilmicToneMapping( vec3 color ) {
	const mat3 ACESInputMat = mat3(
		vec3( 0.59719, 0.07600, 0.02840 ),		vec3( 0.35458, 0.90834, 0.13383 ),
		vec3( 0.04823, 0.01566, 0.83777 )
	);
	const mat3 ACESOutputMat = mat3(
		vec3(  1.60475, -0.10208, -0.00327 ),		vec3( -0.53108,  1.10813, -0.07276 ),
		vec3( -0.07367, -0.00605,  1.07602 )
	);
	color *= toneMappingExposure / 0.6;
	color = ACESInputMat * color;
	color = RRTAndODTFit( color );
	color = ACESOutputMat * color;
	return saturate( color );
}
vec3 CustomToneMapping( vec3 color ) { return color; }`,uD=`#ifdef USE_TRANSMISSION
	float transmissionAlpha = 1.0;
	float transmissionFactor = transmission;
	float thicknessFactor = thickness;
	#ifdef USE_TRANSMISSIONMAP
		transmissionFactor *= texture2D( transmissionMap, vUv ).r;
	#endif
	#ifdef USE_THICKNESSMAP
		thicknessFactor *= texture2D( thicknessMap, vUv ).g;
	#endif
	vec3 pos = vWorldPosition;
	vec3 v = normalize( cameraPosition - pos );
	vec3 n = inverseTransformDirection( normal, viewMatrix );
	vec4 transmission = getIBLVolumeRefraction(
		n, v, roughnessFactor, material.diffuseColor, material.specularColor, material.specularF90,
		pos, modelMatrix, viewMatrix, projectionMatrix, ior, thicknessFactor,
		attenuationColor, attenuationDistance );
	totalDiffuse = mix( totalDiffuse, transmission.rgb, transmissionFactor );
	transmissionAlpha = mix( transmissionAlpha, transmission.a, transmissionFactor );
#endif`,hD=`#ifdef USE_TRANSMISSION
	uniform float transmission;
	uniform float thickness;
	uniform float attenuationDistance;
	uniform vec3 attenuationColor;
	#ifdef USE_TRANSMISSIONMAP
		uniform sampler2D transmissionMap;
	#endif
	#ifdef USE_THICKNESSMAP
		uniform sampler2D thicknessMap;
	#endif
	uniform vec2 transmissionSamplerSize;
	uniform sampler2D transmissionSamplerMap;
	uniform mat4 modelMatrix;
	uniform mat4 projectionMatrix;
	varying vec3 vWorldPosition;
	vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
		vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
		vec3 modelScale;
		modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
		modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
		modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
		return normalize( refractionVector ) * thickness * modelScale;
	}
	float applyIorToRoughness( const in float roughness, const in float ior ) {
		return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
	}
	vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
		float framebufferLod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
		#ifdef texture2DLodEXT
			return texture2DLodEXT( transmissionSamplerMap, fragCoord.xy, framebufferLod );
		#else
			return texture2D( transmissionSamplerMap, fragCoord.xy, framebufferLod );
		#endif
	}
	vec3 applyVolumeAttenuation( const in vec3 radiance, const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
		if ( attenuationDistance == 0.0 ) {
			return radiance;
		} else {
			vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
			vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance );			return transmittance * radiance;
		}
	}
	vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
		const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
		const in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,
		const in vec3 attenuationColor, const in float attenuationDistance ) {
		vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
		vec3 refractedRayExit = position + transmissionRay;
		vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
		vec2 refractionCoords = ndcPos.xy / ndcPos.w;
		refractionCoords += 1.0;
		refractionCoords /= 2.0;
		vec4 transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
		vec3 attenuatedColor = applyVolumeAttenuation( transmittedLight.rgb, length( transmissionRay ), attenuationColor, attenuationDistance );
		vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
		return vec4( ( 1.0 - F ) * attenuatedColor * diffuseColor, transmittedLight.a );
	}
#endif`,dD=`#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )
	varying vec2 vUv;
#endif`,fD=`#ifdef USE_UV
	#ifdef UVS_VERTEX_ONLY
		vec2 vUv;
	#else
		varying vec2 vUv;
	#endif
	uniform mat3 uvTransform;
#endif`,pD=`#ifdef USE_UV
	vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
#endif`,mD=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
	varying vec2 vUv2;
#endif`,gD=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
	attribute vec2 uv2;
	varying vec2 vUv2;
	uniform mat3 uv2Transform;
#endif`,_D=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
	vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;
#endif`,yD=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION )
	vec4 worldPosition = vec4( transformed, 1.0 );
	#ifdef USE_INSTANCING
		worldPosition = instanceMatrix * worldPosition;
	#endif
	worldPosition = modelMatrix * worldPosition;
#endif`;const xD=`varying vec2 vUv;
uniform mat3 uvTransform;
void main() {
	vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
	gl_Position = vec4( position.xy, 1.0, 1.0 );
}`,vD=`uniform sampler2D t2D;
varying vec2 vUv;
void main() {
	gl_FragColor = texture2D( t2D, vUv );
	#ifdef DECODE_VIDEO_TEXTURE
		gl_FragColor = vec4( mix( pow( gl_FragColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), gl_FragColor.rgb * 0.0773993808, vec3( lessThanEqual( gl_FragColor.rgb, vec3( 0.04045 ) ) ) ), gl_FragColor.w );
	#endif
	#include <tonemapping_fragment>
	#include <encodings_fragment>
}`,bD=`varying vec3 vWorldDirection;
#include <common>
void main() {
	vWorldDirection = transformDirection( position, modelMatrix );
	#include <begin_vertex>
	#include <project_vertex>
	gl_Position.z = gl_Position.w;
}`,wD=`#include <envmap_common_pars_fragment>
uniform float opacity;
varying vec3 vWorldDirection;
#include <cube_uv_reflection_fragment>
void main() {
	vec3 vReflect = vWorldDirection;
	#include <envmap_fragment>
	gl_FragColor = envColor;
	gl_FragColor.a *= opacity;
	#include <tonemapping_fragment>
	#include <encodings_fragment>
}`,SD=`#include <common>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
varying vec2 vHighPrecisionZW;
void main() {
	#include <uv_vertex>
	#include <skinbase_vertex>
	#ifdef USE_DISPLACEMENTMAP
		#include <beginnormal_vertex>
		#include <morphnormal_vertex>
		#include <skinnormal_vertex>
	#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vHighPrecisionZW = gl_Position.zw;
}`,MD=`#if DEPTH_PACKING == 3200
	uniform float opacity;
#endif
#include <common>
#include <packing>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
varying vec2 vHighPrecisionZW;
void main() {
	#include <clipping_planes_fragment>
	vec4 diffuseColor = vec4( 1.0 );
	#if DEPTH_PACKING == 3200
		diffuseColor.a = opacity;
	#endif
	#include <map_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <logdepthbuf_fragment>
	float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;
	#if DEPTH_PACKING == 3200
		gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
	#elif DEPTH_PACKING == 3201
		gl_FragColor = packDepthToRGBA( fragCoordZ );
	#endif
}`,ED=`#define DISTANCE
varying vec3 vWorldPosition;
#include <common>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <skinbase_vertex>
	#ifdef USE_DISPLACEMENTMAP
		#include <beginnormal_vertex>
		#include <morphnormal_vertex>
		#include <skinnormal_vertex>
	#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <worldpos_vertex>
	#include <clipping_planes_vertex>
	vWorldPosition = worldPosition.xyz;
}`,TD=`#define DISTANCE
uniform vec3 referencePosition;
uniform float nearDistance;
uniform float farDistance;
varying vec3 vWorldPosition;
#include <common>
#include <packing>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <clipping_planes_pars_fragment>
void main () {
	#include <clipping_planes_fragment>
	vec4 diffuseColor = vec4( 1.0 );
	#include <map_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	float dist = length( vWorldPosition - referencePosition );
	dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
	dist = saturate( dist );
	gl_FragColor = packDepthToRGBA( dist );
}`,AD=`varying vec3 vWorldDirection;
#include <common>
void main() {
	vWorldDirection = transformDirection( position, modelMatrix );
	#include <begin_vertex>
	#include <project_vertex>
}`,CD=`uniform sampler2D tEquirect;
varying vec3 vWorldDirection;
#include <common>
void main() {
	vec3 direction = normalize( vWorldDirection );
	vec2 sampleUV = equirectUv( direction );
	gl_FragColor = texture2D( tEquirect, sampleUV );
	#include <tonemapping_fragment>
	#include <encodings_fragment>
}`,ID=`uniform float scale;
attribute float lineDistance;
varying float vLineDistance;
#include <common>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	vLineDistance = scale * lineDistance;
	#include <color_vertex>
	#include <morphcolor_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <fog_vertex>
}`,PD=`uniform vec3 diffuse;
uniform float opacity;
uniform float dashSize;
uniform float totalSize;
varying float vLineDistance;
#include <common>
#include <color_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	#include <clipping_planes_fragment>
	if ( mod( vLineDistance, totalSize ) > dashSize ) {
		discard;
	}
	vec3 outgoingLight = vec3( 0.0 );
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <logdepthbuf_fragment>
	#include <color_fragment>
	outgoingLight = diffuseColor.rgb;
	#include <output_fragment>
	#include <tonemapping_fragment>
	#include <encodings_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
}`,LD=`#include <common>
#include <uv_pars_vertex>
#include <uv2_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <uv2_vertex>
	#include <color_vertex>
	#include <morphcolor_vertex>
	#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
		#include <beginnormal_vertex>
		#include <morphnormal_vertex>
		#include <skinbase_vertex>
		#include <skinnormal_vertex>
		#include <defaultnormal_vertex>
	#endif
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <worldpos_vertex>
	#include <envmap_vertex>
	#include <fog_vertex>
}`,RD=`uniform vec3 diffuse;
uniform float opacity;
#ifndef FLAT_SHADED
	varying vec3 vNormal;
#endif
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <uv2_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <cube_uv_reflection_fragment>
#include <fog_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	#include <clipping_planes_fragment>
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <specularmap_fragment>
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	#ifdef USE_LIGHTMAP
		vec4 lightMapTexel = texture2D( lightMap, vUv2 );
		reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
	#else
		reflectedLight.indirectDiffuse += vec3( 1.0 );
	#endif
	#include <aomap_fragment>
	reflectedLight.indirectDiffuse *= diffuseColor.rgb;
	vec3 outgoingLight = reflectedLight.indirectDiffuse;
	#include <envmap_fragment>
	#include <output_fragment>
	#include <tonemapping_fragment>
	#include <encodings_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,DD=`#define LAMBERT
varying vec3 vLightFront;
varying vec3 vIndirectFront;
#ifdef DOUBLE_SIDED
	varying vec3 vLightBack;
	varying vec3 vIndirectBack;
#endif
#include <common>
#include <uv_pars_vertex>
#include <uv2_pars_vertex>
#include <envmap_pars_vertex>
#include <bsdfs>
#include <lights_pars_begin>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <uv2_vertex>
	#include <color_vertex>
	#include <morphcolor_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <worldpos_vertex>
	#include <envmap_vertex>
	#include <lights_lambert_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`,zD=`uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
varying vec3 vLightFront;
varying vec3 vIndirectFront;
#ifdef DOUBLE_SIDED
	varying vec3 vLightBack;
	varying vec3 vIndirectBack;
#endif
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <uv2_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <cube_uv_reflection_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <fog_pars_fragment>
#include <shadowmap_pars_fragment>
#include <shadowmask_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	#include <clipping_planes_fragment>
	vec4 diffuseColor = vec4( diffuse, opacity );
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <specularmap_fragment>
	#include <emissivemap_fragment>
	#ifdef DOUBLE_SIDED
		reflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;
	#else
		reflectedLight.indirectDiffuse += vIndirectFront;
	#endif
	#include <lightmap_fragment>
	reflectedLight.indirectDiffuse *= BRDF_Lambert( diffuseColor.rgb );
	#ifdef DOUBLE_SIDED
		reflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;
	#else
		reflectedLight.directDiffuse = vLightFront;
	#endif
	reflectedLight.directDiffuse *= BRDF_Lambert( diffuseColor.rgb ) * getShadowMask();
	#include <aomap_fragment>
	vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
	#include <envmap_fragment>
	#include <output_fragment>
	#include <tonemapping_fragment>
	#include <encodings_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,kD=`#define MATCAP
varying vec3 vViewPosition;
#include <common>
#include <uv_pars_vertex>
#include <color_pars_vertex>
#include <displacementmap_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <color_vertex>
	#include <morphcolor_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <fog_vertex>
	vViewPosition = - mvPosition.xyz;
}`,OD=`#define MATCAP
uniform vec3 diffuse;
uniform float opacity;
uniform sampler2D matcap;
varying vec3 vViewPosition;
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <fog_pars_fragment>
#include <normal_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	#include <clipping_planes_fragment>
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	vec3 viewDir = normalize( vViewPosition );
	vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
	vec3 y = cross( viewDir, x );
	vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
	#ifdef USE_MATCAP
		vec4 matcapColor = texture2D( matcap, uv );
	#else
		vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
	#endif
	vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
	#include <output_fragment>
	#include <tonemapping_fragment>
	#include <encodings_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,FD=`#define NORMAL
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )
	varying vec3 vViewPosition;
#endif
#include <common>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )
	vViewPosition = - mvPosition.xyz;
#endif
}`,BD=`#define NORMAL
uniform float opacity;
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )
	varying vec3 vViewPosition;
#endif
#include <packing>
#include <uv_pars_fragment>
#include <normal_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	#include <clipping_planes_fragment>
	#include <logdepthbuf_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	gl_FragColor = vec4( packNormalToRGB( normal ), opacity );
	#ifdef OPAQUE
		gl_FragColor.a = 1.0;
	#endif
}`,ND=`#define PHONG
varying vec3 vViewPosition;
#include <common>
#include <uv_pars_vertex>
#include <uv2_pars_vertex>
#include <displacementmap_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <uv2_vertex>
	#include <color_vertex>
	#include <morphcolor_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <envmap_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`,UD=`#define PHONG
uniform vec3 diffuse;
uniform vec3 emissive;
uniform vec3 specular;
uniform float shininess;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <uv2_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <cube_uv_reflection_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_phong_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	#include <clipping_planes_fragment>
	vec4 diffuseColor = vec4( diffuse, opacity );
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <specularmap_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_phong_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
	#include <envmap_fragment>
	#include <output_fragment>
	#include <tonemapping_fragment>
	#include <encodings_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,VD=`#define STANDARD
varying vec3 vViewPosition;
#ifdef USE_TRANSMISSION
	varying vec3 vWorldPosition;
#endif
#include <common>
#include <uv_pars_vertex>
#include <uv2_pars_vertex>
#include <displacementmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <uv2_vertex>
	#include <color_vertex>
	#include <morphcolor_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
#ifdef USE_TRANSMISSION
	vWorldPosition = worldPosition.xyz;
#endif
}`,GD=`#define STANDARD
#ifdef PHYSICAL
	#define IOR
	#define SPECULAR
#endif
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float roughness;
uniform float metalness;
uniform float opacity;
#ifdef IOR
	uniform float ior;
#endif
#ifdef SPECULAR
	uniform float specularIntensity;
	uniform vec3 specularColor;
	#ifdef USE_SPECULARINTENSITYMAP
		uniform sampler2D specularIntensityMap;
	#endif
	#ifdef USE_SPECULARCOLORMAP
		uniform sampler2D specularColorMap;
	#endif
#endif
#ifdef USE_CLEARCOAT
	uniform float clearcoat;
	uniform float clearcoatRoughness;
#endif
#ifdef USE_IRIDESCENCE
	uniform float iridescence;
	uniform float iridescenceIOR;
	uniform float iridescenceThicknessMinimum;
	uniform float iridescenceThicknessMaximum;
#endif
#ifdef USE_SHEEN
	uniform vec3 sheenColor;
	uniform float sheenRoughness;
	#ifdef USE_SHEENCOLORMAP
		uniform sampler2D sheenColorMap;
	#endif
	#ifdef USE_SHEENROUGHNESSMAP
		uniform sampler2D sheenRoughnessMap;
	#endif
#endif
varying vec3 vViewPosition;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <uv2_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <bsdfs>
#include <iridescence_fragment>
#include <cube_uv_reflection_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_physical_pars_fragment>
#include <fog_pars_fragment>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_physical_pars_fragment>
#include <transmission_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <clearcoat_pars_fragment>
#include <iridescence_pars_fragment>
#include <roughnessmap_pars_fragment>
#include <metalnessmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	#include <clipping_planes_fragment>
	vec4 diffuseColor = vec4( diffuse, opacity );
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <roughnessmap_fragment>
	#include <metalnessmap_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <clearcoat_normal_fragment_begin>
	#include <clearcoat_normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_physical_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
	vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
	#include <transmission_fragment>
	vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
	#ifdef USE_SHEEN
		float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
		outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular;
	#endif
	#ifdef USE_CLEARCOAT
		float dotNVcc = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );
		vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
		outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + clearcoatSpecular * material.clearcoat;
	#endif
	#include <output_fragment>
	#include <tonemapping_fragment>
	#include <encodings_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,jD=`#define TOON
varying vec3 vViewPosition;
#include <common>
#include <uv_pars_vertex>
#include <uv2_pars_vertex>
#include <displacementmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	#include <uv2_vertex>
	#include <color_vertex>
	#include <morphcolor_vertex>
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <normal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <displacementmap_vertex>
	#include <project_vertex>
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	vViewPosition = - mvPosition.xyz;
	#include <worldpos_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`,WD=`#define TOON
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <uv2_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <gradientmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_toon_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	#include <clipping_planes_fragment>
	vec4 diffuseColor = vec4( diffuse, opacity );
	ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
	vec3 totalEmissiveRadiance = emissive;
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <color_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	#include <normal_fragment_begin>
	#include <normal_fragment_maps>
	#include <emissivemap_fragment>
	#include <lights_toon_fragment>
	#include <lights_fragment_begin>
	#include <lights_fragment_maps>
	#include <lights_fragment_end>
	#include <aomap_fragment>
	vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
	#include <output_fragment>
	#include <tonemapping_fragment>
	#include <encodings_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
	#include <dithering_fragment>
}`,HD=`uniform float size;
uniform float scale;
#include <common>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <color_vertex>
	#include <morphcolor_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <project_vertex>
	gl_PointSize = size;
	#ifdef USE_SIZEATTENUATION
		bool isPerspective = isPerspectiveMatrix( projectionMatrix );
		if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
	#endif
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <worldpos_vertex>
	#include <fog_vertex>
}`,qD=`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <color_pars_fragment>
#include <map_particle_pars_fragment>
#include <alphatest_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	#include <clipping_planes_fragment>
	vec3 outgoingLight = vec3( 0.0 );
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <logdepthbuf_fragment>
	#include <map_particle_fragment>
	#include <color_fragment>
	#include <alphatest_fragment>
	outgoingLight = diffuseColor.rgb;
	#include <output_fragment>
	#include <tonemapping_fragment>
	#include <encodings_fragment>
	#include <fog_fragment>
	#include <premultiplied_alpha_fragment>
}`,ZD=`#include <common>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
void main() {
	#include <beginnormal_vertex>
	#include <morphnormal_vertex>
	#include <skinbase_vertex>
	#include <skinnormal_vertex>
	#include <defaultnormal_vertex>
	#include <begin_vertex>
	#include <morphtarget_vertex>
	#include <skinning_vertex>
	#include <project_vertex>
	#include <worldpos_vertex>
	#include <shadowmap_vertex>
	#include <fog_vertex>
}`,XD=`uniform vec3 color;
uniform float opacity;
#include <common>
#include <packing>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <shadowmap_pars_fragment>
#include <shadowmask_pars_fragment>
void main() {
	gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
	#include <tonemapping_fragment>
	#include <encodings_fragment>
	#include <fog_fragment>
}`,$D=`uniform float rotation;
uniform vec2 center;
#include <common>
#include <uv_pars_vertex>
#include <fog_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
	#include <uv_vertex>
	vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
	vec2 scale;
	scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
	scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
	#ifndef USE_SIZEATTENUATION
		bool isPerspective = isPerspectiveMatrix( projectionMatrix );
		if ( isPerspective ) scale *= - mvPosition.z;
	#endif
	vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
	vec2 rotatedPosition;
	rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
	rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
	mvPosition.xy += rotatedPosition;
	gl_Position = projectionMatrix * mvPosition;
	#include <logdepthbuf_vertex>
	#include <clipping_planes_vertex>
	#include <fog_vertex>
}`,YD=`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
	#include <clipping_planes_fragment>
	vec3 outgoingLight = vec3( 0.0 );
	vec4 diffuseColor = vec4( diffuse, opacity );
	#include <logdepthbuf_fragment>
	#include <map_fragment>
	#include <alphamap_fragment>
	#include <alphatest_fragment>
	outgoingLight = diffuseColor.rgb;
	#include <output_fragment>
	#include <tonemapping_fragment>
	#include <encodings_fragment>
	#include <fog_fragment>
}`,cr={alphamap_fragment:w3,alphamap_pars_fragment:S3,alphatest_fragment:M3,alphatest_pars_fragment:E3,aomap_fragment:T3,aomap_pars_fragment:A3,begin_vertex:C3,beginnormal_vertex:I3,bsdfs:P3,iridescence_fragment:L3,bumpmap_pars_fragment:R3,clipping_planes_fragment:D3,clipping_planes_pars_fragment:z3,clipping_planes_pars_vertex:k3,clipping_planes_vertex:O3,color_fragment:F3,color_pars_fragment:B3,color_pars_vertex:N3,color_vertex:U3,common:V3,cube_uv_reflection_fragment:G3,defaultnormal_vertex:j3,displacementmap_pars_vertex:W3,displacementmap_vertex:H3,emissivemap_fragment:q3,emissivemap_pars_fragment:Z3,encodings_fragment:X3,encodings_pars_fragment:$3,envmap_fragment:Y3,envmap_common_pars_fragment:J3,envmap_pars_fragment:K3,envmap_pars_vertex:Q3,envmap_physical_pars_fragment:uR,envmap_vertex:eR,fog_vertex:tR,fog_pars_vertex:nR,fog_fragment:iR,fog_pars_fragment:rR,gradientmap_pars_fragment:sR,lightmap_fragment:oR,lightmap_pars_fragment:aR,lights_lambert_vertex:lR,lights_pars_begin:cR,lights_toon_fragment:hR,lights_toon_pars_fragment:dR,lights_phong_fragment:fR,lights_phong_pars_fragment:pR,lights_physical_fragment:mR,lights_physical_pars_fragment:gR,lights_fragment_begin:_R,lights_fragment_maps:yR,lights_fragment_end:xR,logdepthbuf_fragment:vR,logdepthbuf_pars_fragment:bR,logdepthbuf_pars_vertex:wR,logdepthbuf_vertex:SR,map_fragment:MR,map_pars_fragment:ER,map_particle_fragment:TR,map_particle_pars_fragment:AR,metalnessmap_fragment:CR,metalnessmap_pars_fragment:IR,morphcolor_vertex:PR,morphnormal_vertex:LR,morphtarget_pars_vertex:RR,morphtarget_vertex:DR,normal_fragment_begin:zR,normal_fragment_maps:kR,normal_pars_fragment:OR,normal_pars_vertex:FR,normal_vertex:BR,normalmap_pars_fragment:NR,clearcoat_normal_fragment_begin:UR,clearcoat_normal_fragment_maps:VR,clearcoat_pars_fragment:GR,iridescence_pars_fragment:jR,output_fragment:WR,packing:HR,premultiplied_alpha_fragment:qR,project_vertex:ZR,dithering_fragment:XR,dithering_pars_fragment:$R,roughnessmap_fragment:YR,roughnessmap_pars_fragment:JR,shadowmap_pars_fragment:KR,shadowmap_pars_vertex:QR,shadowmap_vertex:eD,shadowmask_pars_fragment:tD,skinbase_vertex:nD,skinning_pars_vertex:iD,skinning_vertex:rD,skinnormal_vertex:sD,specularmap_fragment:oD,specularmap_pars_fragment:aD,tonemapping_fragment:lD,tonemapping_pars_fragment:cD,transmission_fragment:uD,transmission_pars_fragment:hD,uv_pars_fragment:dD,uv_pars_vertex:fD,uv_vertex:pD,uv2_pars_fragment:mD,uv2_pars_vertex:gD,uv2_vertex:_D,worldpos_vertex:yD,background_vert:xD,background_frag:vD,cube_vert:bD,cube_frag:wD,depth_vert:SD,depth_frag:MD,distanceRGBA_vert:ED,distanceRGBA_frag:TD,equirect_vert:AD,equirect_frag:CD,linedashed_vert:ID,linedashed_frag:PD,meshbasic_vert:LD,meshbasic_frag:RD,meshlambert_vert:DD,meshlambert_frag:zD,meshmatcap_vert:kD,meshmatcap_frag:OD,meshnormal_vert:FD,meshnormal_frag:BD,meshphong_vert:ND,meshphong_frag:UD,meshphysical_vert:VD,meshphysical_frag:GD,meshtoon_vert:jD,meshtoon_frag:WD,points_vert:HD,points_frag:qD,shadow_vert:ZD,shadow_frag:XD,sprite_vert:$D,sprite_frag:YD},jn={common:{diffuse:{value:new Kn(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new kl},uv2Transform:{value:new kl},alphaMap:{value:null},alphaTest:{value:0}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new tn(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Kn(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new Kn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new kl}},sprite:{diffuse:{value:new Kn(16777215)},opacity:{value:1},center:{value:new tn(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new kl}}},rc={basic:{uniforms:ua([jn.common,jn.specularmap,jn.envmap,jn.aomap,jn.lightmap,jn.fog]),vertexShader:cr.meshbasic_vert,fragmentShader:cr.meshbasic_frag},lambert:{uniforms:ua([jn.common,jn.specularmap,jn.envmap,jn.aomap,jn.lightmap,jn.emissivemap,jn.fog,jn.lights,{emissive:{value:new Kn(0)}}]),vertexShader:cr.meshlambert_vert,fragmentShader:cr.meshlambert_frag},phong:{uniforms:ua([jn.common,jn.specularmap,jn.envmap,jn.aomap,jn.lightmap,jn.emissivemap,jn.bumpmap,jn.normalmap,jn.displacementmap,jn.fog,jn.lights,{emissive:{value:new Kn(0)},specular:{value:new Kn(1118481)},shininess:{value:30}}]),vertexShader:cr.meshphong_vert,fragmentShader:cr.meshphong_frag},standard:{uniforms:ua([jn.common,jn.envmap,jn.aomap,jn.lightmap,jn.emissivemap,jn.bumpmap,jn.normalmap,jn.displacementmap,jn.roughnessmap,jn.metalnessmap,jn.fog,jn.lights,{emissive:{value:new Kn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:cr.meshphysical_vert,fragmentShader:cr.meshphysical_frag},toon:{uniforms:ua([jn.common,jn.aomap,jn.lightmap,jn.emissivemap,jn.bumpmap,jn.normalmap,jn.displacementmap,jn.gradientmap,jn.fog,jn.lights,{emissive:{value:new Kn(0)}}]),vertexShader:cr.meshtoon_vert,fragmentShader:cr.meshtoon_frag},matcap:{uniforms:ua([jn.common,jn.bumpmap,jn.normalmap,jn.displacementmap,jn.fog,{matcap:{value:null}}]),vertexShader:cr.meshmatcap_vert,fragmentShader:cr.meshmatcap_frag},points:{uniforms:ua([jn.points,jn.fog]),vertexShader:cr.points_vert,fragmentShader:cr.points_frag},dashed:{uniforms:ua([jn.common,jn.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:cr.linedashed_vert,fragmentShader:cr.linedashed_frag},depth:{uniforms:ua([jn.common,jn.displacementmap]),vertexShader:cr.depth_vert,fragmentShader:cr.depth_frag},normal:{uniforms:ua([jn.common,jn.bumpmap,jn.normalmap,jn.displacementmap,{opacity:{value:1}}]),vertexShader:cr.meshnormal_vert,fragmentShader:cr.meshnormal_frag},sprite:{uniforms:ua([jn.sprite,jn.fog]),vertexShader:cr.sprite_vert,fragmentShader:cr.sprite_frag},background:{uniforms:{uvTransform:{value:new kl},t2D:{value:null}},vertexShader:cr.background_vert,fragmentShader:cr.background_frag},cube:{uniforms:ua([jn.envmap,{opacity:{value:1}}]),vertexShader:cr.cube_vert,fragmentShader:cr.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:cr.equirect_vert,fragmentShader:cr.equirect_frag},distanceRGBA:{uniforms:ua([jn.common,jn.displacementmap,{referencePosition:{value:new Me},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:cr.distanceRGBA_vert,fragmentShader:cr.distanceRGBA_frag},shadow:{uniforms:ua([jn.lights,jn.fog,{color:{value:new Kn(0)},opacity:{value:1}}]),vertexShader:cr.shadow_vert,fragmentShader:cr.shadow_frag}};rc.physical={uniforms:ua([rc.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new tn(1,1)},clearcoatNormalMap:{value:null},iridescence:{value:0},iridescenceMap:{value:null},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},sheen:{value:0},sheenColor:{value:new Kn(0)},sheenColorMap:{value:null},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new tn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new Kn(0)},specularIntensity:{value:1},specularIntensityMap:{value:null},specularColor:{value:new Kn(1,1,1)},specularColorMap:{value:null}}]),vertexShader:cr.meshphysical_vert,fragmentShader:cr.meshphysical_frag};function JD(d,e,n,a,c,f){const m=new Kn(0);let i=c===!0?0:1,w,E,C=null,T=0,I=null;function k(B,F){let H=!1,Y=F.isScene===!0?F.background:null;Y&&Y.isTexture&&(Y=e.get(Y));const K=d.xr,ne=K.getSession&&K.getSession();ne&&ne.environmentBlendMode==="additive"&&(Y=null),Y===null?O(m,i):Y&&Y.isColor&&(O(Y,1),H=!0),(d.autoClear||H)&&d.clear(d.autoClearColor,d.autoClearDepth,d.autoClearStencil),Y&&(Y.isCubeTexture||Y.mapping===tp)?(E===void 0&&(E=new Jo(new Vc(1,1,1),new Gc({name:"BackgroundCubeMaterial",uniforms:Ff(rc.cube.uniforms),vertexShader:rc.cube.vertexShader,fragmentShader:rc.cube.fragmentShader,side:fl,depthTest:!1,depthWrite:!1,fog:!1})),E.geometry.deleteAttribute("normal"),E.geometry.deleteAttribute("uv"),E.onBeforeRender=function(le,fe,Ae){this.matrixWorld.copyPosition(Ae.matrixWorld)},Object.defineProperty(E.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),a.update(E)),E.material.uniforms.envMap.value=Y,E.material.uniforms.flipEnvMap.value=Y.isCubeTexture&&Y.isRenderTargetTexture===!1?-1:1,(C!==Y||T!==Y.version||I!==d.toneMapping)&&(E.material.needsUpdate=!0,C=Y,T=Y.version,I=d.toneMapping),E.layers.enableAll(),B.unshift(E,E.geometry,E.material,0,0,null)):Y&&Y.isTexture&&(w===void 0&&(w=new Jo(new cd(2,2),new Gc({name:"BackgroundMaterial",uniforms:Ff(rc.background.uniforms),vertexShader:rc.background.vertexShader,fragmentShader:rc.background.fragmentShader,side:od,depthTest:!1,depthWrite:!1,fog:!1})),w.geometry.deleteAttribute("normal"),Object.defineProperty(w.material,"map",{get:function(){return this.uniforms.t2D.value}}),a.update(w)),w.material.uniforms.t2D.value=Y,Y.matrixAutoUpdate===!0&&Y.updateMatrix(),w.material.uniforms.uvTransform.value.copy(Y.matrix),(C!==Y||T!==Y.version||I!==d.toneMapping)&&(w.material.needsUpdate=!0,C=Y,T=Y.version,I=d.toneMapping),w.layers.enableAll(),B.unshift(w,w.geometry,w.material,0,0,null))}function O(B,F){n.buffers.color.setClear(B.r,B.g,B.b,F,f)}return{getClearColor:function(){return m},setClearColor:function(B,F=1){m.set(B),i=F,O(m,i)},getClearAlpha:function(){return i},setClearAlpha:function(B){i=B,O(m,i)},render:k}}function KD(d,e,n,a){const c=d.getParameter(34921),f=a.isWebGL2?null:e.get("OES_vertex_array_object"),m=a.isWebGL2||f!==null,i={},w=F(null);let E=w,C=!1;function T(Je,It,ft,Nt,Fe){let it=!1;if(m){const tt=B(Nt,ft,It);E!==tt&&(E=tt,k(E.object)),it=H(Je,Nt,ft,Fe),it&&Y(Je,Nt,ft,Fe)}else{const tt=It.wireframe===!0;(E.geometry!==Nt.id||E.program!==ft.id||E.wireframe!==tt)&&(E.geometry=Nt.id,E.program=ft.id,E.wireframe=tt,it=!0)}Fe!==null&&n.update(Fe,34963),(it||C)&&(C=!1,oe(Je,It,ft,Nt),Fe!==null&&d.bindBuffer(34963,n.get(Fe).buffer))}function I(){return a.isWebGL2?d.createVertexArray():f.createVertexArrayOES()}function k(Je){return a.isWebGL2?d.bindVertexArray(Je):f.bindVertexArrayOES(Je)}function O(Je){return a.isWebGL2?d.deleteVertexArray(Je):f.deleteVertexArrayOES(Je)}function B(Je,It,ft){const Nt=ft.wireframe===!0;let Fe=i[Je.id];Fe===void 0&&(Fe={},i[Je.id]=Fe);let it=Fe[It.id];it===void 0&&(it={},Fe[It.id]=it);let tt=it[Nt];return tt===void 0&&(tt=F(I()),it[Nt]=tt),tt}function F(Je){const It=[],ft=[],Nt=[];for(let Fe=0;Fe<c;Fe++)It[Fe]=0,ft[Fe]=0,Nt[Fe]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:It,enabledAttributes:ft,attributeDivisors:Nt,object:Je,attributes:{},index:null}}function H(Je,It,ft,Nt){const Fe=E.attributes,it=It.attributes;let tt=0;const Et=ft.getAttributes();for(const xt in Et)if(Et[xt].location>=0){const ln=Fe[xt];let pn=it[xt];if(pn===void 0&&(xt==="instanceMatrix"&&Je.instanceMatrix&&(pn=Je.instanceMatrix),xt==="instanceColor"&&Je.instanceColor&&(pn=Je.instanceColor)),ln===void 0||ln.attribute!==pn||pn&&ln.data!==pn.data)return!0;tt++}return E.attributesNum!==tt||E.index!==Nt}function Y(Je,It,ft,Nt){const Fe={},it=It.attributes;let tt=0;const Et=ft.getAttributes();for(const xt in Et)if(Et[xt].location>=0){let ln=it[xt];ln===void 0&&(xt==="instanceMatrix"&&Je.instanceMatrix&&(ln=Je.instanceMatrix),xt==="instanceColor"&&Je.instanceColor&&(ln=Je.instanceColor));const pn={};pn.attribute=ln,ln&&ln.data&&(pn.data=ln.data),Fe[xt]=pn,tt++}E.attributes=Fe,E.attributesNum=tt,E.index=Nt}function K(){const Je=E.newAttributes;for(let It=0,ft=Je.length;It<ft;It++)Je[It]=0}function ne(Je){le(Je,0)}function le(Je,It){const ft=E.newAttributes,Nt=E.enabledAttributes,Fe=E.attributeDivisors;ft[Je]=1,Nt[Je]===0&&(d.enableVertexAttribArray(Je),Nt[Je]=1),Fe[Je]!==It&&((a.isWebGL2?d:e.get("ANGLE_instanced_arrays"))[a.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](Je,It),Fe[Je]=It)}function fe(){const Je=E.newAttributes,It=E.enabledAttributes;for(let ft=0,Nt=It.length;ft<Nt;ft++)It[ft]!==Je[ft]&&(d.disableVertexAttribArray(ft),It[ft]=0)}function Ae(Je,It,ft,Nt,Fe,it){a.isWebGL2===!0&&(ft===5124||ft===5125)?d.vertexAttribIPointer(Je,It,ft,Fe,it):d.vertexAttribPointer(Je,It,ft,Nt,Fe,it)}function oe(Je,It,ft,Nt){if(a.isWebGL2===!1&&(Je.isInstancedMesh||Nt.isInstancedBufferGeometry)&&e.get("ANGLE_instanced_arrays")===null)return;K();const Fe=Nt.attributes,it=ft.getAttributes(),tt=It.defaultAttributeValues;for(const Et in it){const xt=it[Et];if(xt.location>=0){let Pt=Fe[Et];if(Pt===void 0&&(Et==="instanceMatrix"&&Je.instanceMatrix&&(Pt=Je.instanceMatrix),Et==="instanceColor"&&Je.instanceColor&&(Pt=Je.instanceColor)),Pt!==void 0){const ln=Pt.normalized,pn=Pt.itemSize,Mt=n.get(Pt);if(Mt===void 0)continue;const ei=Mt.buffer,oi=Mt.type,Wn=Mt.bytesPerElement;if(Pt.isInterleavedBufferAttribute){const jt=Pt.data,mn=jt.stride,qt=Pt.offset;if(jt.isInstancedInterleavedBuffer){for(let Dt=0;Dt<xt.locationSize;Dt++)le(xt.location+Dt,jt.meshPerAttribute);Je.isInstancedMesh!==!0&&Nt._maxInstanceCount===void 0&&(Nt._maxInstanceCount=jt.meshPerAttribute*jt.count)}else for(let Dt=0;Dt<xt.locationSize;Dt++)ne(xt.location+Dt);d.bindBuffer(34962,ei);for(let Dt=0;Dt<xt.locationSize;Dt++)Ae(xt.location+Dt,pn/xt.locationSize,oi,ln,mn*Wn,(qt+pn/xt.locationSize*Dt)*Wn)}else{if(Pt.isInstancedBufferAttribute){for(let jt=0;jt<xt.locationSize;jt++)le(xt.location+jt,Pt.meshPerAttribute);Je.isInstancedMesh!==!0&&Nt._maxInstanceCount===void 0&&(Nt._maxInstanceCount=Pt.meshPerAttribute*Pt.count)}else for(let jt=0;jt<xt.locationSize;jt++)ne(xt.location+jt);d.bindBuffer(34962,ei);for(let jt=0;jt<xt.locationSize;jt++)Ae(xt.location+jt,pn/xt.locationSize,oi,ln,pn*Wn,pn/xt.locationSize*jt*Wn)}}else if(tt!==void 0){const ln=tt[Et];if(ln!==void 0)switch(ln.length){case 2:d.vertexAttrib2fv(xt.location,ln);break;case 3:d.vertexAttrib3fv(xt.location,ln);break;case 4:d.vertexAttrib4fv(xt.location,ln);break;default:d.vertexAttrib1fv(xt.location,ln)}}}}fe()}function ce(){Xe();for(const Je in i){const It=i[Je];for(const ft in It){const Nt=It[ft];for(const Fe in Nt)O(Nt[Fe].object),delete Nt[Fe];delete It[ft]}delete i[Je]}}function Re(Je){if(i[Je.id]===void 0)return;const It=i[Je.id];for(const ft in It){const Nt=It[ft];for(const Fe in Nt)O(Nt[Fe].object),delete Nt[Fe];delete It[ft]}delete i[Je.id]}function ke(Je){for(const It in i){const ft=i[It];if(ft[Je.id]===void 0)continue;const Nt=ft[Je.id];for(const Fe in Nt)O(Nt[Fe].object),delete Nt[Fe];delete ft[Je.id]}}function Xe(){St(),C=!0,E!==w&&(E=w,k(E.object))}function St(){w.geometry=null,w.program=null,w.wireframe=!1}return{setup:T,reset:Xe,resetDefaultState:St,dispose:ce,releaseStatesOfGeometry:Re,releaseStatesOfProgram:ke,initAttributes:K,enableAttribute:ne,disableUnusedAttributes:fe}}function QD(d,e,n,a){const c=a.isWebGL2;let f;function m(E){f=E}function i(E,C){d.drawArrays(f,E,C),n.update(C,f,1)}function w(E,C,T){if(T===0)return;let I,k;if(c)I=d,k="drawArraysInstanced";else if(I=e.get("ANGLE_instanced_arrays"),k="drawArraysInstancedANGLE",I===null){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}I[k](f,E,C,T),n.update(C,f,T)}this.setMode=m,this.render=i,this.renderInstances=w}function ez(d,e,n){let a;function c(){if(a!==void 0)return a;if(e.has("EXT_texture_filter_anisotropic")===!0){const Ae=e.get("EXT_texture_filter_anisotropic");a=d.getParameter(Ae.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else a=0;return a}function f(Ae){if(Ae==="highp"){if(d.getShaderPrecisionFormat(35633,36338).precision>0&&d.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";Ae="mediump"}return Ae==="mediump"&&d.getShaderPrecisionFormat(35633,36337).precision>0&&d.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}const m=typeof WebGL2RenderingContext<"u"&&d instanceof WebGL2RenderingContext||typeof WebGL2ComputeRenderingContext<"u"&&d instanceof WebGL2ComputeRenderingContext;let i=n.precision!==void 0?n.precision:"highp";const w=f(i);w!==i&&(console.warn("THREE.WebGLRenderer:",i,"not supported, using",w,"instead."),i=w);const E=m||e.has("WEBGL_draw_buffers"),C=n.logarithmicDepthBuffer===!0,T=d.getParameter(34930),I=d.getParameter(35660),k=d.getParameter(3379),O=d.getParameter(34076),B=d.getParameter(34921),F=d.getParameter(36347),H=d.getParameter(36348),Y=d.getParameter(36349),K=I>0,ne=m||e.has("OES_texture_float"),le=K&&ne,fe=m?d.getParameter(36183):0;return{isWebGL2:m,drawBuffers:E,getMaxAnisotropy:c,getMaxPrecision:f,precision:i,logarithmicDepthBuffer:C,maxTextures:T,maxVertexTextures:I,maxTextureSize:k,maxCubemapSize:O,maxAttributes:B,maxVertexUniforms:F,maxVaryings:H,maxFragmentUniforms:Y,vertexTextures:K,floatFragmentTextures:ne,floatVertexTextures:le,maxSamples:fe}}function tz(d){const e=this;let n=null,a=0,c=!1,f=!1;const m=new _u,i=new kl,w={value:null,needsUpdate:!1};this.uniform=w,this.numPlanes=0,this.numIntersection=0,this.init=function(T,I,k){const O=T.length!==0||I||a!==0||c;return c=I,n=C(T,k,0),a=T.length,O},this.beginShadows=function(){f=!0,C(null)},this.endShadows=function(){f=!1,E()},this.setState=function(T,I,k){const O=T.clippingPlanes,B=T.clipIntersection,F=T.clipShadows,H=d.get(T);if(!c||O===null||O.length===0||f&&!F)f?C(null):E();else{const Y=f?0:a,K=Y*4;let ne=H.clippingState||null;w.value=ne,ne=C(O,I,K,k);for(let le=0;le!==K;++le)ne[le]=n[le];H.clippingState=ne,this.numIntersection=B?this.numPlanes:0,this.numPlanes+=Y}};function E(){w.value!==n&&(w.value=n,w.needsUpdate=a>0),e.numPlanes=a,e.numIntersection=0}function C(T,I,k,O){const B=T!==null?T.length:0;let F=null;if(B!==0){if(F=w.value,O!==!0||F===null){const H=k+B*4,Y=I.matrixWorldInverse;i.getNormalMatrix(Y),(F===null||F.length<H)&&(F=new Float32Array(H));for(let K=0,ne=k;K!==B;++K,ne+=4)m.copy(T[K]).applyMatrix4(Y,i),m.normal.toArray(F,ne),F[ne+3]=m.constant}w.value=F,w.needsUpdate=!0}return e.numPlanes=B,e.numIntersection=0,F}}function nz(d){let e=new WeakMap;function n(m,i){return i===nm?m.mapping=rh:i===im&&(m.mapping=sh),m}function a(m){if(m&&m.isTexture&&m.isRenderTargetTexture===!1){const i=m.mapping;if(i===nm||i===im)if(e.has(m)){const w=e.get(m).texture;return n(w,m.mapping)}else{const w=m.image;if(w&&w.height>0){const E=new eT(w.height/2);return E.fromEquirectangularTexture(d,m),e.set(m,E),m.addEventListener("dispose",c),n(E.texture,m.mapping)}else return null}}return m}function c(m){const i=m.target;i.removeEventListener("dispose",c);const w=e.get(i);w!==void 0&&(e.delete(i),w.dispose())}function f(){e=new WeakMap}return{get:a,dispose:f}}class vu extends Em{constructor(e=-1,n=1,a=1,c=-1,f=.1,m=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=n,this.top=a,this.bottom=c,this.near=f,this.far=m,this.updateProjectionMatrix()}copy(e,n){return super.copy(e,n),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,n,a,c,f,m){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=n,this.view.offsetX=a,this.view.offsetY=c,this.view.width=f,this.view.height=m,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),n=(this.top-this.bottom)/(2*this.zoom),a=(this.right+this.left)/2,c=(this.top+this.bottom)/2;let f=a-e,m=a+e,i=c+n,w=c-n;if(this.view!==null&&this.view.enabled){const E=(this.right-this.left)/this.view.fullWidth/this.zoom,C=(this.top-this.bottom)/this.view.fullHeight/this.zoom;f+=E*this.view.offsetX,m=f+E*this.view.width,i-=C*this.view.offsetY,w=i-C*this.view.height}this.projectionMatrix.makeOrthographic(f,m,i,w,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const n=super.toJSON(e);return n.object.zoom=this.zoom,n.object.left=this.left,n.object.right=this.right,n.object.top=this.top,n.object.bottom=this.bottom,n.object.near=this.near,n.object.far=this.far,this.view!==null&&(n.object.view=Object.assign({},this.view)),n}}const Pf=4,Dw=[.125,.215,.35,.446,.526,.582],Zh=20,L0=new vu,zw=new Kn;let R0=null;const Hh=(1+Math.sqrt(5))/2,xf=1/Hh,kw=[new Me(1,1,1),new Me(-1,1,1),new Me(1,1,-1),new Me(-1,1,-1),new Me(0,Hh,xf),new Me(0,Hh,-xf),new Me(xf,0,Hh),new Me(-xf,0,Hh),new Me(Hh,xf,0),new Me(-Hh,xf,0)];class Fx{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,n=0,a=.1,c=100){R0=this._renderer.getRenderTarget(),this._setSize(256);const f=this._allocateTargets();return f.depthBuffer=!0,this._sceneToCubeUV(e,a,c,f),n>0&&this._blur(f,0,0,n),this._applyPMREM(f),this._cleanup(f),f}fromEquirectangular(e,n=null){return this._fromTexture(e,n)}fromCubemap(e,n=null){return this._fromTexture(e,n)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=Bw(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Fw(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose()}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(R0),e.scissorTest=!1,zg(e,0,0,e.width,e.height)}_fromTexture(e,n){e.mapping===rh||e.mapping===sh?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),R0=this._renderer.getRenderTarget();const a=n||this._allocateTargets();return this._textureToCubeUV(e,a),this._applyPMREM(a),this._cleanup(a),a}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),n=4*this._cubeSize,a={magFilter:qs,minFilter:qs,generateMipmaps:!1,type:Of,format:Qa,encoding:oh,depthBuffer:!1},c=Ow(e,n,a);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Ow(e,n,a);const{_lodMax:f}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=iz(f)),this._blurMaterial=rz(f,e,n)}return c}_compileMaterial(e){const n=new Jo(this._lodPlanes[0],e);this._renderer.compile(n,L0)}_sceneToCubeUV(e,n,a,c){const i=new ks(90,1,n,a),w=[1,-1,1,1,1,1],E=[1,1,1,-1,-1,-1],C=this._renderer,T=C.autoClear,I=C.toneMapping;C.getClearColor(zw),C.toneMapping=sc,C.autoClear=!1;const k=new uh({name:"PMREM.Background",side:fl,depthWrite:!1,depthTest:!1}),O=new Jo(new Vc,k);let B=!1;const F=e.background;F?F.isColor&&(k.color.copy(F),e.background=null,B=!0):(k.color.copy(zw),B=!0);for(let H=0;H<6;H++){const Y=H%3;Y===0?(i.up.set(0,w[H],0),i.lookAt(E[H],0,0)):Y===1?(i.up.set(0,0,w[H]),i.lookAt(0,E[H],0)):(i.up.set(0,w[H],0),i.lookAt(0,0,E[H]));const K=this._cubeSize;zg(c,Y*K,H>2?K:0,K,K),C.setRenderTarget(c),B&&C.render(O,i),C.render(e,i)}O.geometry.dispose(),O.material.dispose(),C.toneMapping=I,C.autoClear=T,e.background=F}_textureToCubeUV(e,n){const a=this._renderer,c=e.mapping===rh||e.mapping===sh;c?(this._cubemapMaterial===null&&(this._cubemapMaterial=Bw()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Fw());const f=c?this._cubemapMaterial:this._equirectMaterial,m=new Jo(this._lodPlanes[0],f),i=f.uniforms;i.envMap.value=e;const w=this._cubeSize;zg(n,0,0,3*w,2*w),a.setRenderTarget(n),a.render(m,L0)}_applyPMREM(e){const n=this._renderer,a=n.autoClear;n.autoClear=!1;for(let c=1;c<this._lodPlanes.length;c++){const f=Math.sqrt(this._sigmas[c]*this._sigmas[c]-this._sigmas[c-1]*this._sigmas[c-1]),m=kw[(c-1)%kw.length];this._blur(e,c-1,c,f,m)}n.autoClear=a}_blur(e,n,a,c,f){const m=this._pingPongRenderTarget;this._halfBlur(e,m,n,a,c,"latitudinal",f),this._halfBlur(m,e,a,a,c,"longitudinal",f)}_halfBlur(e,n,a,c,f,m,i){const w=this._renderer,E=this._blurMaterial;m!=="latitudinal"&&m!=="longitudinal"&&console.error("blur direction must be either latitudinal or longitudinal!");const C=3,T=new Jo(this._lodPlanes[c],E),I=E.uniforms,k=this._sizeLods[a]-1,O=isFinite(f)?Math.PI/(2*k):2*Math.PI/(2*Zh-1),B=f/O,F=isFinite(f)?1+Math.floor(C*B):Zh;F>Zh&&console.warn(`sigmaRadians, ${f}, is too large and will clip, as it requested ${F} samples when the maximum is set to ${Zh}`);const H=[];let Y=0;for(let Ae=0;Ae<Zh;++Ae){const oe=Ae/B,ce=Math.exp(-oe*oe/2);H.push(ce),Ae===0?Y+=ce:Ae<F&&(Y+=2*ce)}for(let Ae=0;Ae<H.length;Ae++)H[Ae]=H[Ae]/Y;I.envMap.value=e.texture,I.samples.value=F,I.weights.value=H,I.latitudinal.value=m==="latitudinal",i&&(I.poleAxis.value=i);const{_lodMax:K}=this;I.dTheta.value=O,I.mipInt.value=K-a;const ne=this._sizeLods[c],le=3*ne*(c>K-Pf?c-K+Pf:0),fe=4*(this._cubeSize-ne);zg(n,le,fe,3*ne,2*ne),w.setRenderTarget(n),w.render(T,L0)}}function iz(d){const e=[],n=[],a=[];let c=d;const f=d-Pf+1+Dw.length;for(let m=0;m<f;m++){const i=Math.pow(2,c);n.push(i);let w=1/i;m>d-Pf?w=Dw[m-d+Pf-1]:m===0&&(w=0),a.push(w);const E=1/(i-2),C=-E,T=1+E,I=[C,C,T,C,T,T,C,C,T,T,C,T],k=6,O=6,B=3,F=2,H=1,Y=new Float32Array(B*O*k),K=new Float32Array(F*O*k),ne=new Float32Array(H*O*k);for(let fe=0;fe<k;fe++){const Ae=fe%3*2/3-1,oe=fe>2?0:-1,ce=[Ae,oe,0,Ae+2/3,oe,0,Ae+2/3,oe+1,0,Ae,oe,0,Ae+2/3,oe+1,0,Ae,oe+1,0];Y.set(ce,B*O*fe),K.set(I,F*O*fe);const Re=[fe,fe,fe,fe,fe,fe];ne.set(Re,H*O*fe)}const le=new qi;le.setAttribute("position",new Yr(Y,B)),le.setAttribute("uv",new Yr(K,F)),le.setAttribute("faceIndex",new Yr(ne,H)),e.push(le),c>Pf&&c--}return{lodPlanes:e,sizeLods:n,sigmas:a}}function Ow(d,e,n){const a=new ml(d,e,n);return a.texture.mapping=tp,a.texture.name="PMREM.cubeUv",a.scissorTest=!0,a}function zg(d,e,n,a,c){d.viewport.set(e,n,a,c),d.scissor.set(e,n,a,c)}function rz(d,e,n){const a=new Float32Array(Zh),c=new Me(0,1,0);return new Gc({name:"SphericalGaussianBlur",defines:{n:Zh,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/n,CUBEUV_MAX_MIP:`${d}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:a},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:c}},vertexShader:xv(),fragmentShader:`

			precision mediump float;
			precision mediump int;

			varying vec3 vOutputDirection;

			uniform sampler2D envMap;
			uniform int samples;
			uniform float weights[ n ];
			uniform bool latitudinal;
			uniform float dTheta;
			uniform float mipInt;
			uniform vec3 poleAxis;

			#define ENVMAP_TYPE_CUBE_UV
			#include <cube_uv_reflection_fragment>

			vec3 getSample( float theta, vec3 axis ) {

				float cosTheta = cos( theta );
				// Rodrigues' axis-angle rotation
				vec3 sampleDirection = vOutputDirection * cosTheta
					+ cross( axis, vOutputDirection ) * sin( theta )
					+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );

				return bilinearCubeUV( envMap, sampleDirection, mipInt );

			}

			void main() {

				vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );

				if ( all( equal( axis, vec3( 0.0 ) ) ) ) {

					axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );

				}

				axis = normalize( axis );

				gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
				gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );

				for ( int i = 1; i < n; i++ ) {

					if ( i >= samples ) {

						break;

					}

					float theta = dTheta * float( i );
					gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
					gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );

				}

			}
		`,blending:bu,depthTest:!1,depthWrite:!1})}function Fw(){return new Gc({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:xv(),fragmentShader:`

			precision mediump float;
			precision mediump int;

			varying vec3 vOutputDirection;

			uniform sampler2D envMap;

			#include <common>

			void main() {

				vec3 outputDirection = normalize( vOutputDirection );
				vec2 uv = equirectUv( outputDirection );

				gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );

			}
		`,blending:bu,depthTest:!1,depthWrite:!1})}function Bw(){return new Gc({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:xv(),fragmentShader:`

			precision mediump float;
			precision mediump int;

			uniform float flipEnvMap;

			varying vec3 vOutputDirection;

			uniform samplerCube envMap;

			void main() {

				gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );

			}
		`,blending:bu,depthTest:!1,depthWrite:!1})}function xv(){return`

		precision mediump float;
		precision mediump int;

		attribute float faceIndex;

		varying vec3 vOutputDirection;

		// RH coordinate system; PMREM face-indexing convention
		vec3 getDirection( vec2 uv, float face ) {

			uv = 2.0 * uv - 1.0;

			vec3 direction = vec3( uv, 1.0 );

			if ( face == 0.0 ) {

				direction = direction.zyx; // ( 1, v, u ) pos x

			} else if ( face == 1.0 ) {

				direction = direction.xzy;
				direction.xz *= -1.0; // ( -u, 1, -v ) pos y

			} else if ( face == 2.0 ) {

				direction.x *= -1.0; // ( -u, v, 1 ) pos z

			} else if ( face == 3.0 ) {

				direction = direction.zyx;
				direction.xz *= -1.0; // ( -1, v, -u ) neg x

			} else if ( face == 4.0 ) {

				direction = direction.xzy;
				direction.xy *= -1.0; // ( -u, -1, v ) neg y

			} else if ( face == 5.0 ) {

				direction.z *= -1.0; // ( u, v, -1 ) neg z

			}

			return direction;

		}

		void main() {

			vOutputDirection = getDirection( uv, faceIndex );
			gl_Position = vec4( position, 1.0 );

		}
	`}function sz(d){let e=new WeakMap,n=null;function a(i){if(i&&i.isTexture){const w=i.mapping,E=w===nm||w===im,C=w===rh||w===sh;if(E||C)if(i.isRenderTargetTexture&&i.needsPMREMUpdate===!0){i.needsPMREMUpdate=!1;let T=e.get(i);return n===null&&(n=new Fx(d)),T=E?n.fromEquirectangular(i,T):n.fromCubemap(i,T),e.set(i,T),T.texture}else{if(e.has(i))return e.get(i).texture;{const T=i.image;if(E&&T&&T.height>0||C&&T&&c(T)){n===null&&(n=new Fx(d));const I=E?n.fromEquirectangular(i):n.fromCubemap(i);return e.set(i,I),i.addEventListener("dispose",f),I.texture}else return null}}}return i}function c(i){let w=0;const E=6;for(let C=0;C<E;C++)i[C]!==void 0&&w++;return w===E}function f(i){const w=i.target;w.removeEventListener("dispose",f);const E=e.get(w);E!==void 0&&(e.delete(w),E.dispose())}function m(){e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:a,dispose:m}}function oz(d){const e={};function n(a){if(e[a]!==void 0)return e[a];let c;switch(a){case"WEBGL_depth_texture":c=d.getExtension("WEBGL_depth_texture")||d.getExtension("MOZ_WEBGL_depth_texture")||d.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":c=d.getExtension("EXT_texture_filter_anisotropic")||d.getExtension("MOZ_EXT_texture_filter_anisotropic")||d.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":c=d.getExtension("WEBGL_compressed_texture_s3tc")||d.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||d.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":c=d.getExtension("WEBGL_compressed_texture_pvrtc")||d.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:c=d.getExtension(a)}return e[a]=c,c}return{has:function(a){return n(a)!==null},init:function(a){a.isWebGL2?n("EXT_color_buffer_float"):(n("WEBGL_depth_texture"),n("OES_texture_float"),n("OES_texture_half_float"),n("OES_texture_half_float_linear"),n("OES_standard_derivatives"),n("OES_element_index_uint"),n("OES_vertex_array_object"),n("ANGLE_instanced_arrays")),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture")},get:function(a){const c=n(a);return c===null&&console.warn("THREE.WebGLRenderer: "+a+" extension not supported."),c}}}function az(d,e,n,a){const c={},f=new WeakMap;function m(T){const I=T.target;I.index!==null&&e.remove(I.index);for(const O in I.attributes)e.remove(I.attributes[O]);I.removeEventListener("dispose",m),delete c[I.id];const k=f.get(I);k&&(e.remove(k),f.delete(I)),a.releaseStatesOfGeometry(I),I.isInstancedBufferGeometry===!0&&delete I._maxInstanceCount,n.memory.geometries--}function i(T,I){return c[I.id]===!0||(I.addEventListener("dispose",m),c[I.id]=!0,n.memory.geometries++),I}function w(T){const I=T.attributes;for(const O in I)e.update(I[O],34962);const k=T.morphAttributes;for(const O in k){const B=k[O];for(let F=0,H=B.length;F<H;F++)e.update(B[F],34962)}}function E(T){const I=[],k=T.index,O=T.attributes.position;let B=0;if(k!==null){const Y=k.array;B=k.version;for(let K=0,ne=Y.length;K<ne;K+=3){const le=Y[K+0],fe=Y[K+1],Ae=Y[K+2];I.push(le,fe,fe,Ae,Ae,le)}}else{const Y=O.array;B=O.version;for(let K=0,ne=Y.length/3-1;K<ne;K+=3){const le=K+0,fe=K+1,Ae=K+2;I.push(le,fe,fe,Ae,Ae,le)}}const F=new(YE(I)?yv:_v)(I,1);F.version=B;const H=f.get(T);H&&e.remove(H),f.set(T,F)}function C(T){const I=f.get(T);if(I){const k=T.index;k!==null&&I.version<k.version&&E(T)}else E(T);return f.get(T)}return{get:i,update:w,getWireframeAttribute:C}}function lz(d,e,n,a){const c=a.isWebGL2;let f;function m(I){f=I}let i,w;function E(I){i=I.type,w=I.bytesPerElement}function C(I,k){d.drawElements(f,k,i,I*w),n.update(k,f,1)}function T(I,k,O){if(O===0)return;let B,F;if(c)B=d,F="drawElementsInstanced";else if(B=e.get("ANGLE_instanced_arrays"),F="drawElementsInstancedANGLE",B===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}B[F](f,k,i,I*w,O),n.update(k,f,O)}this.setMode=m,this.setIndex=E,this.render=C,this.renderInstances=T}function cz(d){const e={geometries:0,textures:0},n={frame:0,calls:0,triangles:0,points:0,lines:0};function a(f,m,i){switch(n.calls++,m){case 4:n.triangles+=i*(f/3);break;case 1:n.lines+=i*(f/2);break;case 3:n.lines+=i*(f-1);break;case 2:n.lines+=i*f;break;case 0:n.points+=i*f;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",m);break}}function c(){n.frame++,n.calls=0,n.triangles=0,n.points=0,n.lines=0}return{memory:e,render:n,programs:null,autoReset:!0,reset:c,update:a}}function uz(d,e){return d[0]-e[0]}function hz(d,e){return Math.abs(e[1])-Math.abs(d[1])}function D0(d,e){let n=1;const a=e.isInterleavedBufferAttribute?e.data.array:e.array;a instanceof Int8Array?n=127:a instanceof Int16Array?n=32767:a instanceof Int32Array?n=2147483647:console.error("THREE.WebGLMorphtargets: Unsupported morph attribute data type: ",a),d.divideScalar(n)}function dz(d,e,n){const a={},c=new Float32Array(8),f=new WeakMap,m=new Wr,i=[];for(let E=0;E<8;E++)i[E]=[E,0];function w(E,C,T,I){const k=E.morphTargetInfluences;if(e.isWebGL2===!0){const O=C.morphAttributes.position||C.morphAttributes.normal||C.morphAttributes.color,B=O!==void 0?O.length:0;let F=f.get(C);if(F===void 0||F.count!==B){let It=function(){St.dispose(),f.delete(C),C.removeEventListener("dispose",It)};F!==void 0&&F.texture.dispose();const K=C.morphAttributes.position!==void 0,ne=C.morphAttributes.normal!==void 0,le=C.morphAttributes.color!==void 0,fe=C.morphAttributes.position||[],Ae=C.morphAttributes.normal||[],oe=C.morphAttributes.color||[];let ce=0;K===!0&&(ce=1),ne===!0&&(ce=2),le===!0&&(ce=3);let Re=C.attributes.position.count*ce,ke=1;Re>e.maxTextureSize&&(ke=Math.ceil(Re/e.maxTextureSize),Re=e.maxTextureSize);const Xe=new Float32Array(Re*ke*4*B),St=new Mm(Xe,Re,ke,B);St.type=xu,St.needsUpdate=!0;const Je=ce*4;for(let ft=0;ft<B;ft++){const Nt=fe[ft],Fe=Ae[ft],it=oe[ft],tt=Re*ke*4*ft;for(let Et=0;Et<Nt.count;Et++){const xt=Et*Je;K===!0&&(m.fromBufferAttribute(Nt,Et),Nt.normalized===!0&&D0(m,Nt),Xe[tt+xt+0]=m.x,Xe[tt+xt+1]=m.y,Xe[tt+xt+2]=m.z,Xe[tt+xt+3]=0),ne===!0&&(m.fromBufferAttribute(Fe,Et),Fe.normalized===!0&&D0(m,Fe),Xe[tt+xt+4]=m.x,Xe[tt+xt+5]=m.y,Xe[tt+xt+6]=m.z,Xe[tt+xt+7]=0),le===!0&&(m.fromBufferAttribute(it,Et),it.normalized===!0&&D0(m,it),Xe[tt+xt+8]=m.x,Xe[tt+xt+9]=m.y,Xe[tt+xt+10]=m.z,Xe[tt+xt+11]=it.itemSize===4?m.w:1)}}F={count:B,texture:St,size:new tn(Re,ke)},f.set(C,F),C.addEventListener("dispose",It)}let H=0;for(let K=0;K<k.length;K++)H+=k[K];const Y=C.morphTargetsRelative?1:1-H;I.getUniforms().setValue(d,"morphTargetBaseInfluence",Y),I.getUniforms().setValue(d,"morphTargetInfluences",k),I.getUniforms().setValue(d,"morphTargetsTexture",F.texture,n),I.getUniforms().setValue(d,"morphTargetsTextureSize",F.size)}else{const O=k===void 0?0:k.length;let B=a[C.id];if(B===void 0||B.length!==O){B=[];for(let ne=0;ne<O;ne++)B[ne]=[ne,0];a[C.id]=B}for(let ne=0;ne<O;ne++){const le=B[ne];le[0]=ne,le[1]=k[ne]}B.sort(hz);for(let ne=0;ne<8;ne++)ne<O&&B[ne][1]?(i[ne][0]=B[ne][0],i[ne][1]=B[ne][1]):(i[ne][0]=Number.MAX_SAFE_INTEGER,i[ne][1]=0);i.sort(uz);const F=C.morphAttributes.position,H=C.morphAttributes.normal;let Y=0;for(let ne=0;ne<8;ne++){const le=i[ne],fe=le[0],Ae=le[1];fe!==Number.MAX_SAFE_INTEGER&&Ae?(F&&C.getAttribute("morphTarget"+ne)!==F[fe]&&C.setAttribute("morphTarget"+ne,F[fe]),H&&C.getAttribute("morphNormal"+ne)!==H[fe]&&C.setAttribute("morphNormal"+ne,H[fe]),c[ne]=Ae,Y+=Ae):(F&&C.hasAttribute("morphTarget"+ne)===!0&&C.deleteAttribute("morphTarget"+ne),H&&C.hasAttribute("morphNormal"+ne)===!0&&C.deleteAttribute("morphNormal"+ne),c[ne]=0)}const K=C.morphTargetsRelative?1:1-Y;I.getUniforms().setValue(d,"morphTargetBaseInfluence",K),I.getUniforms().setValue(d,"morphTargetInfluences",c)}}return{update:w}}function fz(d,e,n,a){let c=new WeakMap;function f(w){const E=a.render.frame,C=w.geometry,T=e.get(w,C);return c.get(T)!==E&&(e.update(T),c.set(T,E)),w.isInstancedMesh&&(w.hasEventListener("dispose",i)===!1&&w.addEventListener("dispose",i),n.update(w.instanceMatrix,34962),w.instanceColor!==null&&n.update(w.instanceColor,34962)),T}function m(){c=new WeakMap}function i(w){const E=w.target;E.removeEventListener("dispose",i),n.remove(E.instanceMatrix),E.instanceColor!==null&&n.remove(E.instanceColor)}return{update:f,dispose:m}}const nT=new ho,iT=new Mm,rT=new N_,sT=new Tm,Nw=[],Uw=[],Vw=new Float32Array(16),Gw=new Float32Array(9),jw=new Float32Array(4);function rp(d,e,n){const a=d[0];if(a<=0||a>0)return d;const c=e*n;let f=Nw[c];if(f===void 0&&(f=new Float32Array(c),Nw[c]=f),e!==0){a.toArray(f,0);for(let m=1,i=0;m!==e;++m)i+=n,d[m].toArray(f,i)}return f}function Ia(d,e){if(d.length!==e.length)return!1;for(let n=0,a=d.length;n<a;n++)if(d[n]!==e[n])return!1;return!0}function Pa(d,e){for(let n=0,a=e.length;n<a;n++)d[n]=e[n]}function V_(d,e){let n=Uw[e];n===void 0&&(n=new Int32Array(e),Uw[e]=n);for(let a=0;a!==e;++a)n[a]=d.allocateTextureUnit();return n}function pz(d,e){const n=this.cache;n[0]!==e&&(d.uniform1f(this.addr,e),n[0]=e)}function mz(d,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y)&&(d.uniform2f(this.addr,e.x,e.y),n[0]=e.x,n[1]=e.y);else{if(Ia(n,e))return;d.uniform2fv(this.addr,e),Pa(n,e)}}function gz(d,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z)&&(d.uniform3f(this.addr,e.x,e.y,e.z),n[0]=e.x,n[1]=e.y,n[2]=e.z);else if(e.r!==void 0)(n[0]!==e.r||n[1]!==e.g||n[2]!==e.b)&&(d.uniform3f(this.addr,e.r,e.g,e.b),n[0]=e.r,n[1]=e.g,n[2]=e.b);else{if(Ia(n,e))return;d.uniform3fv(this.addr,e),Pa(n,e)}}function _z(d,e){const n=this.cache;if(e.x!==void 0)(n[0]!==e.x||n[1]!==e.y||n[2]!==e.z||n[3]!==e.w)&&(d.uniform4f(this.addr,e.x,e.y,e.z,e.w),n[0]=e.x,n[1]=e.y,n[2]=e.z,n[3]=e.w);else{if(Ia(n,e))return;d.uniform4fv(this.addr,e),Pa(n,e)}}function yz(d,e){const n=this.cache,a=e.elements;if(a===void 0){if(Ia(n,e))return;d.uniformMatrix2fv(this.addr,!1,e),Pa(n,e)}else{if(Ia(n,a))return;jw.set(a),d.uniformMatrix2fv(this.addr,!1,jw),Pa(n,a)}}function xz(d,e){const n=this.cache,a=e.elements;if(a===void 0){if(Ia(n,e))return;d.uniformMatrix3fv(this.addr,!1,e),Pa(n,e)}else{if(Ia(n,a))return;Gw.set(a),d.uniformMatrix3fv(this.addr,!1,Gw),Pa(n,a)}}function vz(d,e){const n=this.cache,a=e.elements;if(a===void 0){if(Ia(n,e))return;d.uniformMatrix4fv(this.addr,!1,e),Pa(n,e)}else{if(Ia(n,a))return;Vw.set(a),d.uniformMatrix4fv(this.addr,!1,Vw),Pa(n,a)}}function bz(d,e){const n=this.cache;n[0]!==e&&(d.uniform1i(this.addr,e),n[0]=e)}function wz(d,e){const n=this.cache;Ia(n,e)||(d.uniform2iv(this.addr,e),Pa(n,e))}function Sz(d,e){const n=this.cache;Ia(n,e)||(d.uniform3iv(this.addr,e),Pa(n,e))}function Mz(d,e){const n=this.cache;Ia(n,e)||(d.uniform4iv(this.addr,e),Pa(n,e))}function Ez(d,e){const n=this.cache;n[0]!==e&&(d.uniform1ui(this.addr,e),n[0]=e)}function Tz(d,e){const n=this.cache;Ia(n,e)||(d.uniform2uiv(this.addr,e),Pa(n,e))}function Az(d,e){const n=this.cache;Ia(n,e)||(d.uniform3uiv(this.addr,e),Pa(n,e))}function Cz(d,e){const n=this.cache;Ia(n,e)||(d.uniform4uiv(this.addr,e),Pa(n,e))}function Iz(d,e,n){const a=this.cache,c=n.allocateTextureUnit();a[0]!==c&&(d.uniform1i(this.addr,c),a[0]=c),n.setTexture2D(e||nT,c)}function Pz(d,e,n){const a=this.cache,c=n.allocateTextureUnit();a[0]!==c&&(d.uniform1i(this.addr,c),a[0]=c),n.setTexture3D(e||rT,c)}function Lz(d,e,n){const a=this.cache,c=n.allocateTextureUnit();a[0]!==c&&(d.uniform1i(this.addr,c),a[0]=c),n.setTextureCube(e||sT,c)}function Rz(d,e,n){const a=this.cache,c=n.allocateTextureUnit();a[0]!==c&&(d.uniform1i(this.addr,c),a[0]=c),n.setTexture2DArray(e||iT,c)}function Dz(d){switch(d){case 5126:return pz;case 35664:return mz;case 35665:return gz;case 35666:return _z;case 35674:return yz;case 35675:return xz;case 35676:return vz;case 5124:case 35670:return bz;case 35667:case 35671:return wz;case 35668:case 35672:return Sz;case 35669:case 35673:return Mz;case 5125:return Ez;case 36294:return Tz;case 36295:return Az;case 36296:return Cz;case 35678:case 36198:case 36298:case 36306:case 35682:return Iz;case 35679:case 36299:case 36307:return Pz;case 35680:case 36300:case 36308:case 36293:return Lz;case 36289:case 36303:case 36311:case 36292:return Rz}}function zz(d,e){d.uniform1fv(this.addr,e)}function kz(d,e){const n=rp(e,this.size,2);d.uniform2fv(this.addr,n)}function Oz(d,e){const n=rp(e,this.size,3);d.uniform3fv(this.addr,n)}function Fz(d,e){const n=rp(e,this.size,4);d.uniform4fv(this.addr,n)}function Bz(d,e){const n=rp(e,this.size,4);d.uniformMatrix2fv(this.addr,!1,n)}function Nz(d,e){const n=rp(e,this.size,9);d.uniformMatrix3fv(this.addr,!1,n)}function Uz(d,e){const n=rp(e,this.size,16);d.uniformMatrix4fv(this.addr,!1,n)}function Vz(d,e){d.uniform1iv(this.addr,e)}function Gz(d,e){d.uniform2iv(this.addr,e)}function jz(d,e){d.uniform3iv(this.addr,e)}function Wz(d,e){d.uniform4iv(this.addr,e)}function Hz(d,e){d.uniform1uiv(this.addr,e)}function qz(d,e){d.uniform2uiv(this.addr,e)}function Zz(d,e){d.uniform3uiv(this.addr,e)}function Xz(d,e){d.uniform4uiv(this.addr,e)}function $z(d,e,n){const a=e.length,c=V_(n,a);d.uniform1iv(this.addr,c);for(let f=0;f!==a;++f)n.setTexture2D(e[f]||nT,c[f])}function Yz(d,e,n){const a=e.length,c=V_(n,a);d.uniform1iv(this.addr,c);for(let f=0;f!==a;++f)n.setTexture3D(e[f]||rT,c[f])}function Jz(d,e,n){const a=e.length,c=V_(n,a);d.uniform1iv(this.addr,c);for(let f=0;f!==a;++f)n.setTextureCube(e[f]||sT,c[f])}function Kz(d,e,n){const a=e.length,c=V_(n,a);d.uniform1iv(this.addr,c);for(let f=0;f!==a;++f)n.setTexture2DArray(e[f]||iT,c[f])}function Qz(d){switch(d){case 5126:return zz;case 35664:return kz;case 35665:return Oz;case 35666:return Fz;case 35674:return Bz;case 35675:return Nz;case 35676:return Uz;case 5124:case 35670:return Vz;case 35667:case 35671:return Gz;case 35668:case 35672:return jz;case 35669:case 35673:return Wz;case 5125:return Hz;case 36294:return qz;case 36295:return Zz;case 36296:return Xz;case 35678:case 36198:case 36298:case 36306:case 35682:return $z;case 35679:case 36299:case 36307:return Yz;case 35680:case 36300:case 36308:case 36293:return Jz;case 36289:case 36303:case 36311:case 36292:return Kz}}class ek{constructor(e,n,a){this.id=e,this.addr=a,this.cache=[],this.setValue=Dz(n.type)}}class tk{constructor(e,n,a){this.id=e,this.addr=a,this.cache=[],this.size=n.size,this.setValue=Qz(n.type)}}class nk{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,n,a){const c=this.seq;for(let f=0,m=c.length;f!==m;++f){const i=c[f];i.setValue(e,n[i.id],a)}}}const z0=/(\w+)(\])?(\[|\.)?/g;function Ww(d,e){d.seq.push(e),d.map[e.id]=e}function ik(d,e,n){const a=d.name,c=a.length;for(z0.lastIndex=0;;){const f=z0.exec(a),m=z0.lastIndex;let i=f[1];const w=f[2]==="]",E=f[3];if(w&&(i=i|0),E===void 0||E==="["&&m+2===c){Ww(n,E===void 0?new ek(i,d,e):new tk(i,d,e));break}else{let T=n.map[i];T===void 0&&(T=new nk(i),Ww(n,T)),n=T}}}class f_{constructor(e,n){this.seq=[],this.map={};const a=e.getProgramParameter(n,35718);for(let c=0;c<a;++c){const f=e.getActiveUniform(n,c),m=e.getUniformLocation(n,f.name);ik(f,m,this)}}setValue(e,n,a,c){const f=this.map[n];f!==void 0&&f.setValue(e,a,c)}setOptional(e,n,a){const c=n[a];c!==void 0&&this.setValue(e,a,c)}static upload(e,n,a,c){for(let f=0,m=n.length;f!==m;++f){const i=n[f],w=a[i.id];w.needsUpdate!==!1&&i.setValue(e,w.value,c)}}static seqWithValue(e,n){const a=[];for(let c=0,f=e.length;c!==f;++c){const m=e[c];m.id in n&&a.push(m)}return a}}function Hw(d,e,n){const a=d.createShader(e);return d.shaderSource(a,n),d.compileShader(a),a}let rk=0;function sk(d,e){const n=d.split(`
`),a=[],c=Math.max(e-6,0),f=Math.min(e+6,n.length);for(let m=c;m<f;m++){const i=m+1;a.push(`${i===e?">":" "} ${i}: ${n[m]}`)}return a.join(`
`)}function ok(d){switch(d){case oh:return["Linear","( value )"];case hs:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",d),["Linear","( value )"]}}function qw(d,e,n){const a=d.getShaderParameter(e,35713),c=d.getShaderInfoLog(e).trim();if(a&&c==="")return"";const f=/ERROR: 0:(\d+)/.exec(c);if(f){const m=parseInt(f[1]);return n.toUpperCase()+`

`+c+`

`+sk(d.getShaderSource(e),m)}else return c}function ak(d,e){const n=ok(e);return"vec4 "+d+"( vec4 value ) { return LinearTo"+n[0]+n[1]+"; }"}function lk(d,e){let n;switch(e){case SE:n="Linear";break;case ME:n="Reinhard";break;case EE:n="OptimizedCineon";break;case hv:n="ACESFilmic";break;case TE:n="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),n="Linear"}return"vec3 "+d+"( vec3 color ) { return "+n+"ToneMapping( color ); }"}function ck(d){return[d.extensionDerivatives||!!d.envMapCubeUVHeight||d.bumpMap||d.tangentSpaceNormalMap||d.clearcoatNormalMap||d.flatShading||d.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(d.extensionFragDepth||d.logarithmicDepthBuffer)&&d.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",d.extensionDrawBuffers&&d.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(d.extensionShaderTextureLOD||d.envMap||d.transmission)&&d.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Jp).join(`
`)}function uk(d){const e=[];for(const n in d){const a=d[n];a!==!1&&e.push("#define "+n+" "+a)}return e.join(`
`)}function hk(d,e){const n={},a=d.getProgramParameter(e,35721);for(let c=0;c<a;c++){const f=d.getActiveAttrib(e,c),m=f.name;let i=1;f.type===35674&&(i=2),f.type===35675&&(i=3),f.type===35676&&(i=4),n[m]={type:f.type,location:d.getAttribLocation(e,m),locationSize:i}}return n}function Jp(d){return d!==""}function Zw(d,e){return d.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function Xw(d,e){return d.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const dk=/^[ \t]*#include +<([\w\d./]+)>/gm;function Bx(d){return d.replace(dk,fk)}function fk(d,e){const n=cr[e];if(n===void 0)throw new Error("Can not resolve #include <"+e+">");return Bx(n)}const pk=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,mk=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function $w(d){return d.replace(mk,oT).replace(pk,gk)}function gk(d,e,n,a){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),oT(d,e,n,a)}function oT(d,e,n,a){let c="";for(let f=parseInt(e);f<parseInt(n);f++)c+=a.replace(/\[\s*i\s*\]/g,"[ "+f+" ]").replace(/UNROLLED_LOOP_INDEX/g,f);return c}function Yw(d){let e="precision "+d.precision+` float;
precision `+d.precision+" int;";return d.precision==="highp"?e+=`
#define HIGH_PRECISION`:d.precision==="mediump"?e+=`
#define MEDIUM_PRECISION`:d.precision==="lowp"&&(e+=`
#define LOW_PRECISION`),e}function _k(d){let e="SHADOWMAP_TYPE_BASIC";return d.shadowMapType===O_?e="SHADOWMAP_TYPE_PCF":d.shadowMapType===Kp?e="SHADOWMAP_TYPE_PCF_SOFT":d.shadowMapType===Xh&&(e="SHADOWMAP_TYPE_VSM"),e}function yk(d){let e="ENVMAP_TYPE_CUBE";if(d.envMap)switch(d.envMapMode){case rh:case sh:e="ENVMAP_TYPE_CUBE";break;case tp:e="ENVMAP_TYPE_CUBE_UV";break}return e}function xk(d){let e="ENVMAP_MODE_REFLECTION";if(d.envMap)switch(d.envMapMode){case sh:e="ENVMAP_MODE_REFRACTION";break}return e}function vk(d){let e="ENVMAP_BLENDING_NONE";if(d.envMap)switch(d.combine){case Sm:e="ENVMAP_BLENDING_MULTIPLY";break;case bE:e="ENVMAP_BLENDING_MIX";break;case wE:e="ENVMAP_BLENDING_ADD";break}return e}function bk(d){const e=d.envMapCubeUVHeight;if(e===null)return null;const n=Math.log2(e)-2,a=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,n),7*16)),texelHeight:a,maxMip:n}}function wk(d,e,n,a){const c=d.getContext(),f=n.defines;let m=n.vertexShader,i=n.fragmentShader;const w=_k(n),E=yk(n),C=xk(n),T=vk(n),I=bk(n),k=n.isWebGL2?"":ck(n),O=uk(f),B=c.createProgram();let F,H,Y=n.glslVersion?"#version "+n.glslVersion+`
`:"";n.isRawShaderMaterial?(F=[O].filter(Jp).join(`
`),F.length>0&&(F+=`
`),H=[k,O].filter(Jp).join(`
`),H.length>0&&(H+=`
`)):(F=[Yw(n),"#define SHADER_NAME "+n.shaderName,O,n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.supportsVertexTextures?"#define VERTEX_TEXTURES":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+C:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.displacementMap&&n.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",n.specularColorMap?"#define USE_SPECULARCOLORMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEENCOLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&n.flatShading===!1?"#define USE_MORPHNORMALS":"",n.morphColors&&n.isWebGL2?"#define USE_MORPHCOLORS":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+w:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING","	attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR","	attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT","	attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )","	attribute vec4 color;","#elif defined( USE_COLOR )","	attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )","	attribute vec3 morphTarget0;","	attribute vec3 morphTarget1;","	attribute vec3 morphTarget2;","	attribute vec3 morphTarget3;","	#ifdef USE_MORPHNORMALS","		attribute vec3 morphNormal0;","		attribute vec3 morphNormal1;","		attribute vec3 morphNormal2;","		attribute vec3 morphNormal3;","	#else","		attribute vec3 morphTarget4;","		attribute vec3 morphTarget5;","		attribute vec3 morphTarget6;","		attribute vec3 morphTarget7;","	#endif","#endif","#ifdef USE_SKINNING","	attribute vec4 skinIndex;","	attribute vec4 skinWeight;","#endif",`
`].filter(Jp).join(`
`),H=[k,Yw(n),"#define SHADER_NAME "+n.shaderName,O,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+E:"",n.envMap?"#define "+C:"",n.envMap?"#define "+T:"",I?"#define CUBEUV_TEXEL_WIDTH "+I.texelWidth:"",I?"#define CUBEUV_TEXEL_HEIGHT "+I.texelHeight:"",I?"#define CUBEUV_MAX_MIP "+I.maxMip+".0":"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",n.specularColorMap?"#define USE_SPECULARCOLORMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEENCOLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+w:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==sc?"#define TONE_MAPPING":"",n.toneMapping!==sc?cr.tonemapping_pars_fragment:"",n.toneMapping!==sc?lk("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque?"#define OPAQUE":"",cr.encodings_pars_fragment,ak("linearToOutputTexel",n.outputEncoding),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",`
`].filter(Jp).join(`
`)),m=Bx(m),m=Zw(m,n),m=Xw(m,n),i=Bx(i),i=Zw(i,n),i=Xw(i,n),m=$w(m),i=$w(i),n.isWebGL2&&n.isRawShaderMaterial!==!0&&(Y=`#version 300 es
`,F=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
`)+`
`+F,H=["#define varying in",n.glslVersion===kx?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===kx?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
`)+`
`+H);const K=Y+F+m,ne=Y+H+i,le=Hw(c,35633,K),fe=Hw(c,35632,ne);if(c.attachShader(B,le),c.attachShader(B,fe),n.index0AttributeName!==void 0?c.bindAttribLocation(B,0,n.index0AttributeName):n.morphTargets===!0&&c.bindAttribLocation(B,0,"position"),c.linkProgram(B),d.debug.checkShaderErrors){const ce=c.getProgramInfoLog(B).trim(),Re=c.getShaderInfoLog(le).trim(),ke=c.getShaderInfoLog(fe).trim();let Xe=!0,St=!0;if(c.getProgramParameter(B,35714)===!1){Xe=!1;const Je=qw(c,le,"vertex"),It=qw(c,fe,"fragment");console.error("THREE.WebGLProgram: Shader Error "+c.getError()+" - VALIDATE_STATUS "+c.getProgramParameter(B,35715)+`

Program Info Log: `+ce+`
`+Je+`
`+It)}else ce!==""?console.warn("THREE.WebGLProgram: Program Info Log:",ce):(Re===""||ke==="")&&(St=!1);St&&(this.diagnostics={runnable:Xe,programLog:ce,vertexShader:{log:Re,prefix:F},fragmentShader:{log:ke,prefix:H}})}c.deleteShader(le),c.deleteShader(fe);let Ae;this.getUniforms=function(){return Ae===void 0&&(Ae=new f_(c,B)),Ae};let oe;return this.getAttributes=function(){return oe===void 0&&(oe=hk(c,B)),oe},this.destroy=function(){a.releaseStatesOfProgram(this),c.deleteProgram(B),this.program=void 0},this.name=n.shaderName,this.id=rk++,this.cacheKey=e,this.usedTimes=1,this.program=B,this.vertexShader=le,this.fragmentShader=fe,this}let Sk=0;class Mk{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const n=e.vertexShader,a=e.fragmentShader,c=this._getShaderStage(n),f=this._getShaderStage(a),m=this._getShaderCacheForMaterial(e);return m.has(c)===!1&&(m.add(c),c.usedTimes++),m.has(f)===!1&&(m.add(f),f.usedTimes++),this}remove(e){const n=this.materialCache.get(e);for(const a of n)a.usedTimes--,a.usedTimes===0&&this.shaderCache.delete(a.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const n=this.materialCache;return n.has(e)===!1&&n.set(e,new Set),n.get(e)}_getShaderStage(e){const n=this.shaderCache;if(n.has(e)===!1){const a=new Ek(e);n.set(e,a)}return n.get(e)}}class Ek{constructor(e){this.id=Sk++,this.code=e,this.usedTimes=0}}function Tk(d,e,n,a,c,f,m){const i=new rd,w=new Mk,E=[],C=c.isWebGL2,T=c.logarithmicDepthBuffer,I=c.vertexTextures;let k=c.precision;const O={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function B(oe,ce,Re,ke,Xe){const St=ke.fog,Je=Xe.geometry,It=oe.isMeshStandardMaterial?ke.environment:null,ft=(oe.isMeshStandardMaterial?n:e).get(oe.envMap||It),Nt=!!ft&&ft.mapping===tp?ft.image.height:null,Fe=O[oe.type];oe.precision!==null&&(k=c.getMaxPrecision(oe.precision),k!==oe.precision&&console.warn("THREE.WebGLProgram.getParameters:",oe.precision,"not supported, using",k,"instead."));const it=Je.morphAttributes.position||Je.morphAttributes.normal||Je.morphAttributes.color,tt=it!==void 0?it.length:0;let Et=0;Je.morphAttributes.position!==void 0&&(Et=1),Je.morphAttributes.normal!==void 0&&(Et=2),Je.morphAttributes.color!==void 0&&(Et=3);let xt,Pt,ln,pn;if(Fe){const mn=rc[Fe];xt=mn.vertexShader,Pt=mn.fragmentShader}else xt=oe.vertexShader,Pt=oe.fragmentShader,w.update(oe),ln=w.getVertexShaderID(oe),pn=w.getFragmentShaderID(oe);const Mt=d.getRenderTarget(),ei=oe.alphaTest>0,oi=oe.clearcoat>0,Wn=oe.iridescence>0;return{isWebGL2:C,shaderID:Fe,shaderName:oe.type,vertexShader:xt,fragmentShader:Pt,defines:oe.defines,customVertexShaderID:ln,customFragmentShaderID:pn,isRawShaderMaterial:oe.isRawShaderMaterial===!0,glslVersion:oe.glslVersion,precision:k,instancing:Xe.isInstancedMesh===!0,instancingColor:Xe.isInstancedMesh===!0&&Xe.instanceColor!==null,supportsVertexTextures:I,outputEncoding:Mt===null?d.outputEncoding:Mt.isXRRenderTarget===!0?Mt.texture.encoding:oh,map:!!oe.map,matcap:!!oe.matcap,envMap:!!ft,envMapMode:ft&&ft.mapping,envMapCubeUVHeight:Nt,lightMap:!!oe.lightMap,aoMap:!!oe.aoMap,emissiveMap:!!oe.emissiveMap,bumpMap:!!oe.bumpMap,normalMap:!!oe.normalMap,objectSpaceNormalMap:oe.normalMapType===ZE,tangentSpaceNormalMap:oe.normalMapType===yd,decodeVideoTexture:!!oe.map&&oe.map.isVideoTexture===!0&&oe.map.encoding===hs,clearcoat:oi,clearcoatMap:oi&&!!oe.clearcoatMap,clearcoatRoughnessMap:oi&&!!oe.clearcoatRoughnessMap,clearcoatNormalMap:oi&&!!oe.clearcoatNormalMap,iridescence:Wn,iridescenceMap:Wn&&!!oe.iridescenceMap,iridescenceThicknessMap:Wn&&!!oe.iridescenceThicknessMap,displacementMap:!!oe.displacementMap,roughnessMap:!!oe.roughnessMap,metalnessMap:!!oe.metalnessMap,specularMap:!!oe.specularMap,specularIntensityMap:!!oe.specularIntensityMap,specularColorMap:!!oe.specularColorMap,opaque:oe.transparent===!1&&oe.blending===ed,alphaMap:!!oe.alphaMap,alphaTest:ei,gradientMap:!!oe.gradientMap,sheen:oe.sheen>0,sheenColorMap:!!oe.sheenColorMap,sheenRoughnessMap:!!oe.sheenRoughnessMap,transmission:oe.transmission>0,transmissionMap:!!oe.transmissionMap,thicknessMap:!!oe.thicknessMap,combine:oe.combine,vertexTangents:!!oe.normalMap&&!!Je.attributes.tangent,vertexColors:oe.vertexColors,vertexAlphas:oe.vertexColors===!0&&!!Je.attributes.color&&Je.attributes.color.itemSize===4,vertexUvs:!!oe.map||!!oe.bumpMap||!!oe.normalMap||!!oe.specularMap||!!oe.alphaMap||!!oe.emissiveMap||!!oe.roughnessMap||!!oe.metalnessMap||!!oe.clearcoatMap||!!oe.clearcoatRoughnessMap||!!oe.clearcoatNormalMap||!!oe.iridescenceMap||!!oe.iridescenceThicknessMap||!!oe.displacementMap||!!oe.transmissionMap||!!oe.thicknessMap||!!oe.specularIntensityMap||!!oe.specularColorMap||!!oe.sheenColorMap||!!oe.sheenRoughnessMap,uvsVertexOnly:!(!!oe.map||!!oe.bumpMap||!!oe.normalMap||!!oe.specularMap||!!oe.alphaMap||!!oe.emissiveMap||!!oe.roughnessMap||!!oe.metalnessMap||!!oe.clearcoatNormalMap||!!oe.iridescenceMap||!!oe.iridescenceThicknessMap||oe.transmission>0||!!oe.transmissionMap||!!oe.thicknessMap||!!oe.specularIntensityMap||!!oe.specularColorMap||oe.sheen>0||!!oe.sheenColorMap||!!oe.sheenRoughnessMap)&&!!oe.displacementMap,fog:!!St,useFog:oe.fog===!0,fogExp2:St&&St.isFogExp2,flatShading:!!oe.flatShading,sizeAttenuation:oe.sizeAttenuation,logarithmicDepthBuffer:T,skinning:Xe.isSkinnedMesh===!0,morphTargets:Je.morphAttributes.position!==void 0,morphNormals:Je.morphAttributes.normal!==void 0,morphColors:Je.morphAttributes.color!==void 0,morphTargetsCount:tt,morphTextureStride:Et,numDirLights:ce.directional.length,numPointLights:ce.point.length,numSpotLights:ce.spot.length,numRectAreaLights:ce.rectArea.length,numHemiLights:ce.hemi.length,numDirLightShadows:ce.directionalShadowMap.length,numPointLightShadows:ce.pointShadowMap.length,numSpotLightShadows:ce.spotShadowMap.length,numClippingPlanes:m.numPlanes,numClipIntersection:m.numIntersection,dithering:oe.dithering,shadowMapEnabled:d.shadowMap.enabled&&Re.length>0,shadowMapType:d.shadowMap.type,toneMapping:oe.toneMapped?d.toneMapping:sc,physicallyCorrectLights:d.physicallyCorrectLights,premultipliedAlpha:oe.premultipliedAlpha,doubleSided:oe.side===ad,flipSided:oe.side===fl,useDepthPacking:!!oe.depthPacking,depthPacking:oe.depthPacking||0,index0AttributeName:oe.index0AttributeName,extensionDerivatives:oe.extensions&&oe.extensions.derivatives,extensionFragDepth:oe.extensions&&oe.extensions.fragDepth,extensionDrawBuffers:oe.extensions&&oe.extensions.drawBuffers,extensionShaderTextureLOD:oe.extensions&&oe.extensions.shaderTextureLOD,rendererExtensionFragDepth:C||a.has("EXT_frag_depth"),rendererExtensionDrawBuffers:C||a.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:C||a.has("EXT_shader_texture_lod"),customProgramCacheKey:oe.customProgramCacheKey()}}function F(oe){const ce=[];if(oe.shaderID?ce.push(oe.shaderID):(ce.push(oe.customVertexShaderID),ce.push(oe.customFragmentShaderID)),oe.defines!==void 0)for(const Re in oe.defines)ce.push(Re),ce.push(oe.defines[Re]);return oe.isRawShaderMaterial===!1&&(H(ce,oe),Y(ce,oe),ce.push(d.outputEncoding)),ce.push(oe.customProgramCacheKey),ce.join()}function H(oe,ce){oe.push(ce.precision),oe.push(ce.outputEncoding),oe.push(ce.envMapMode),oe.push(ce.envMapCubeUVHeight),oe.push(ce.combine),oe.push(ce.vertexUvs),oe.push(ce.fogExp2),oe.push(ce.sizeAttenuation),oe.push(ce.morphTargetsCount),oe.push(ce.morphAttributeCount),oe.push(ce.numDirLights),oe.push(ce.numPointLights),oe.push(ce.numSpotLights),oe.push(ce.numHemiLights),oe.push(ce.numRectAreaLights),oe.push(ce.numDirLightShadows),oe.push(ce.numPointLightShadows),oe.push(ce.numSpotLightShadows),oe.push(ce.shadowMapType),oe.push(ce.toneMapping),oe.push(ce.numClippingPlanes),oe.push(ce.numClipIntersection),oe.push(ce.depthPacking)}function Y(oe,ce){i.disableAll(),ce.isWebGL2&&i.enable(0),ce.supportsVertexTextures&&i.enable(1),ce.instancing&&i.enable(2),ce.instancingColor&&i.enable(3),ce.map&&i.enable(4),ce.matcap&&i.enable(5),ce.envMap&&i.enable(6),ce.lightMap&&i.enable(7),ce.aoMap&&i.enable(8),ce.emissiveMap&&i.enable(9),ce.bumpMap&&i.enable(10),ce.normalMap&&i.enable(11),ce.objectSpaceNormalMap&&i.enable(12),ce.tangentSpaceNormalMap&&i.enable(13),ce.clearcoat&&i.enable(14),ce.clearcoatMap&&i.enable(15),ce.clearcoatRoughnessMap&&i.enable(16),ce.clearcoatNormalMap&&i.enable(17),ce.iridescence&&i.enable(18),ce.iridescenceMap&&i.enable(19),ce.iridescenceThicknessMap&&i.enable(20),ce.displacementMap&&i.enable(21),ce.specularMap&&i.enable(22),ce.roughnessMap&&i.enable(23),ce.metalnessMap&&i.enable(24),ce.gradientMap&&i.enable(25),ce.alphaMap&&i.enable(26),ce.alphaTest&&i.enable(27),ce.vertexColors&&i.enable(28),ce.vertexAlphas&&i.enable(29),ce.vertexUvs&&i.enable(30),ce.vertexTangents&&i.enable(31),ce.uvsVertexOnly&&i.enable(32),ce.fog&&i.enable(33),oe.push(i.mask),i.disableAll(),ce.useFog&&i.enable(0),ce.flatShading&&i.enable(1),ce.logarithmicDepthBuffer&&i.enable(2),ce.skinning&&i.enable(3),ce.morphTargets&&i.enable(4),ce.morphNormals&&i.enable(5),ce.morphColors&&i.enable(6),ce.premultipliedAlpha&&i.enable(7),ce.shadowMapEnabled&&i.enable(8),ce.physicallyCorrectLights&&i.enable(9),ce.doubleSided&&i.enable(10),ce.flipSided&&i.enable(11),ce.useDepthPacking&&i.enable(12),ce.dithering&&i.enable(13),ce.specularIntensityMap&&i.enable(14),ce.specularColorMap&&i.enable(15),ce.transmission&&i.enable(16),ce.transmissionMap&&i.enable(17),ce.thicknessMap&&i.enable(18),ce.sheen&&i.enable(19),ce.sheenColorMap&&i.enable(20),ce.sheenRoughnessMap&&i.enable(21),ce.decodeVideoTexture&&i.enable(22),ce.opaque&&i.enable(23),oe.push(i.mask)}function K(oe){const ce=O[oe.type];let Re;if(ce){const ke=rc[ce];Re=KE.clone(ke.uniforms)}else Re=oe.uniforms;return Re}function ne(oe,ce){let Re;for(let ke=0,Xe=E.length;ke<Xe;ke++){const St=E[ke];if(St.cacheKey===ce){Re=St,++Re.usedTimes;break}}return Re===void 0&&(Re=new wk(d,ce,oe,f),E.push(Re)),Re}function le(oe){if(--oe.usedTimes===0){const ce=E.indexOf(oe);E[ce]=E[E.length-1],E.pop(),oe.destroy()}}function fe(oe){w.remove(oe)}function Ae(){w.dispose()}return{getParameters:B,getProgramCacheKey:F,getUniforms:K,acquireProgram:ne,releaseProgram:le,releaseShaderCache:fe,programs:E,dispose:Ae}}function Ak(){let d=new WeakMap;function e(f){let m=d.get(f);return m===void 0&&(m={},d.set(f,m)),m}function n(f){d.delete(f)}function a(f,m,i){d.get(f)[m]=i}function c(){d=new WeakMap}return{get:e,remove:n,update:a,dispose:c}}function Ck(d,e){return d.groupOrder!==e.groupOrder?d.groupOrder-e.groupOrder:d.renderOrder!==e.renderOrder?d.renderOrder-e.renderOrder:d.material.id!==e.material.id?d.material.id-e.material.id:d.z!==e.z?d.z-e.z:d.id-e.id}function Jw(d,e){return d.groupOrder!==e.groupOrder?d.groupOrder-e.groupOrder:d.renderOrder!==e.renderOrder?d.renderOrder-e.renderOrder:d.z!==e.z?e.z-d.z:d.id-e.id}function Kw(){const d=[];let e=0;const n=[],a=[],c=[];function f(){e=0,n.length=0,a.length=0,c.length=0}function m(T,I,k,O,B,F){let H=d[e];return H===void 0?(H={id:T.id,object:T,geometry:I,material:k,groupOrder:O,renderOrder:T.renderOrder,z:B,group:F},d[e]=H):(H.id=T.id,H.object=T,H.geometry=I,H.material=k,H.groupOrder=O,H.renderOrder=T.renderOrder,H.z=B,H.group=F),e++,H}function i(T,I,k,O,B,F){const H=m(T,I,k,O,B,F);k.transmission>0?a.push(H):k.transparent===!0?c.push(H):n.push(H)}function w(T,I,k,O,B,F){const H=m(T,I,k,O,B,F);k.transmission>0?a.unshift(H):k.transparent===!0?c.unshift(H):n.unshift(H)}function E(T,I){n.length>1&&n.sort(T||Ck),a.length>1&&a.sort(I||Jw),c.length>1&&c.sort(I||Jw)}function C(){for(let T=e,I=d.length;T<I;T++){const k=d[T];if(k.id===null)break;k.id=null,k.object=null,k.geometry=null,k.material=null,k.group=null}}return{opaque:n,transmissive:a,transparent:c,init:f,push:i,unshift:w,finish:C,sort:E}}function Ik(){let d=new WeakMap;function e(a,c){let f;return d.has(a)===!1?(f=new Kw,d.set(a,[f])):c>=d.get(a).length?(f=new Kw,d.get(a).push(f)):f=d.get(a)[c],f}function n(){d=new WeakMap}return{get:e,dispose:n}}function Pk(){const d={};return{get:function(e){if(d[e.id]!==void 0)return d[e.id];let n;switch(e.type){case"DirectionalLight":n={direction:new Me,color:new Kn};break;case"SpotLight":n={position:new Me,direction:new Me,color:new Kn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Me,color:new Kn,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Me,skyColor:new Kn,groundColor:new Kn};break;case"RectAreaLight":n={color:new Kn,position:new Me,halfWidth:new Me,halfHeight:new Me};break}return d[e.id]=n,n}}}function Lk(){const d={};return{get:function(e){if(d[e.id]!==void 0)return d[e.id];let n;switch(e.type){case"DirectionalLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new tn};break;case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new tn};break;case"PointLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new tn,shadowCameraNear:1,shadowCameraFar:1e3};break}return d[e.id]=n,n}}}let Rk=0;function Dk(d,e){return(e.castShadow?1:0)-(d.castShadow?1:0)}function zk(d,e){const n=new Pk,a=Lk(),c={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[]};for(let C=0;C<9;C++)c.probe.push(new Me);const f=new Me,m=new sr,i=new sr;function w(C,T){let I=0,k=0,O=0;for(let ce=0;ce<9;ce++)c.probe[ce].set(0,0,0);let B=0,F=0,H=0,Y=0,K=0,ne=0,le=0,fe=0;C.sort(Dk);const Ae=T!==!0?Math.PI:1;for(let ce=0,Re=C.length;ce<Re;ce++){const ke=C[ce],Xe=ke.color,St=ke.intensity,Je=ke.distance,It=ke.shadow&&ke.shadow.map?ke.shadow.map.texture:null;if(ke.isAmbientLight)I+=Xe.r*St*Ae,k+=Xe.g*St*Ae,O+=Xe.b*St*Ae;else if(ke.isLightProbe)for(let ft=0;ft<9;ft++)c.probe[ft].addScaledVector(ke.sh.coefficients[ft],St);else if(ke.isDirectionalLight){const ft=n.get(ke);if(ft.color.copy(ke.color).multiplyScalar(ke.intensity*Ae),ke.castShadow){const Nt=ke.shadow,Fe=a.get(ke);Fe.shadowBias=Nt.bias,Fe.shadowNormalBias=Nt.normalBias,Fe.shadowRadius=Nt.radius,Fe.shadowMapSize=Nt.mapSize,c.directionalShadow[B]=Fe,c.directionalShadowMap[B]=It,c.directionalShadowMatrix[B]=ke.shadow.matrix,ne++}c.directional[B]=ft,B++}else if(ke.isSpotLight){const ft=n.get(ke);if(ft.position.setFromMatrixPosition(ke.matrixWorld),ft.color.copy(Xe).multiplyScalar(St*Ae),ft.distance=Je,ft.coneCos=Math.cos(ke.angle),ft.penumbraCos=Math.cos(ke.angle*(1-ke.penumbra)),ft.decay=ke.decay,ke.castShadow){const Nt=ke.shadow,Fe=a.get(ke);Fe.shadowBias=Nt.bias,Fe.shadowNormalBias=Nt.normalBias,Fe.shadowRadius=Nt.radius,Fe.shadowMapSize=Nt.mapSize,c.spotShadow[H]=Fe,c.spotShadowMap[H]=It,c.spotShadowMatrix[H]=ke.shadow.matrix,fe++}c.spot[H]=ft,H++}else if(ke.isRectAreaLight){const ft=n.get(ke);ft.color.copy(Xe).multiplyScalar(St),ft.halfWidth.set(ke.width*.5,0,0),ft.halfHeight.set(0,ke.height*.5,0),c.rectArea[Y]=ft,Y++}else if(ke.isPointLight){const ft=n.get(ke);if(ft.color.copy(ke.color).multiplyScalar(ke.intensity*Ae),ft.distance=ke.distance,ft.decay=ke.decay,ke.castShadow){const Nt=ke.shadow,Fe=a.get(ke);Fe.shadowBias=Nt.bias,Fe.shadowNormalBias=Nt.normalBias,Fe.shadowRadius=Nt.radius,Fe.shadowMapSize=Nt.mapSize,Fe.shadowCameraNear=Nt.camera.near,Fe.shadowCameraFar=Nt.camera.far,c.pointShadow[F]=Fe,c.pointShadowMap[F]=It,c.pointShadowMatrix[F]=ke.shadow.matrix,le++}c.point[F]=ft,F++}else if(ke.isHemisphereLight){const ft=n.get(ke);ft.skyColor.copy(ke.color).multiplyScalar(St*Ae),ft.groundColor.copy(ke.groundColor).multiplyScalar(St*Ae),c.hemi[K]=ft,K++}}Y>0&&(e.isWebGL2||d.has("OES_texture_float_linear")===!0?(c.rectAreaLTC1=jn.LTC_FLOAT_1,c.rectAreaLTC2=jn.LTC_FLOAT_2):d.has("OES_texture_half_float_linear")===!0?(c.rectAreaLTC1=jn.LTC_HALF_1,c.rectAreaLTC2=jn.LTC_HALF_2):console.error("THREE.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),c.ambient[0]=I,c.ambient[1]=k,c.ambient[2]=O;const oe=c.hash;(oe.directionalLength!==B||oe.pointLength!==F||oe.spotLength!==H||oe.rectAreaLength!==Y||oe.hemiLength!==K||oe.numDirectionalShadows!==ne||oe.numPointShadows!==le||oe.numSpotShadows!==fe)&&(c.directional.length=B,c.spot.length=H,c.rectArea.length=Y,c.point.length=F,c.hemi.length=K,c.directionalShadow.length=ne,c.directionalShadowMap.length=ne,c.pointShadow.length=le,c.pointShadowMap.length=le,c.spotShadow.length=fe,c.spotShadowMap.length=fe,c.directionalShadowMatrix.length=ne,c.pointShadowMatrix.length=le,c.spotShadowMatrix.length=fe,oe.directionalLength=B,oe.pointLength=F,oe.spotLength=H,oe.rectAreaLength=Y,oe.hemiLength=K,oe.numDirectionalShadows=ne,oe.numPointShadows=le,oe.numSpotShadows=fe,c.version=Rk++)}function E(C,T){let I=0,k=0,O=0,B=0,F=0;const H=T.matrixWorldInverse;for(let Y=0,K=C.length;Y<K;Y++){const ne=C[Y];if(ne.isDirectionalLight){const le=c.directional[I];le.direction.setFromMatrixPosition(ne.matrixWorld),f.setFromMatrixPosition(ne.target.matrixWorld),le.direction.sub(f),le.direction.transformDirection(H),I++}else if(ne.isSpotLight){const le=c.spot[O];le.position.setFromMatrixPosition(ne.matrixWorld),le.position.applyMatrix4(H),le.direction.setFromMatrixPosition(ne.matrixWorld),f.setFromMatrixPosition(ne.target.matrixWorld),le.direction.sub(f),le.direction.transformDirection(H),O++}else if(ne.isRectAreaLight){const le=c.rectArea[B];le.position.setFromMatrixPosition(ne.matrixWorld),le.position.applyMatrix4(H),i.identity(),m.copy(ne.matrixWorld),m.premultiply(H),i.extractRotation(m),le.halfWidth.set(ne.width*.5,0,0),le.halfHeight.set(0,ne.height*.5,0),le.halfWidth.applyMatrix4(i),le.halfHeight.applyMatrix4(i),B++}else if(ne.isPointLight){const le=c.point[k];le.position.setFromMatrixPosition(ne.matrixWorld),le.position.applyMatrix4(H),k++}else if(ne.isHemisphereLight){const le=c.hemi[F];le.direction.setFromMatrixPosition(ne.matrixWorld),le.direction.transformDirection(H),F++}}}return{setup:w,setupView:E,state:c}}function Qw(d,e){const n=new zk(d,e),a=[],c=[];function f(){a.length=0,c.length=0}function m(T){a.push(T)}function i(T){c.push(T)}function w(T){n.setup(a,T)}function E(T){n.setupView(a,T)}return{init:f,state:{lightsArray:a,shadowsArray:c,lights:n},setupLights:w,setupLightsView:E,pushLight:m,pushShadow:i}}function kk(d,e){let n=new WeakMap;function a(f,m=0){let i;return n.has(f)===!1?(i=new Qw(d,e),n.set(f,[i])):m>=n.get(f).length?(i=new Qw(d,e),n.get(f).push(i)):i=n.get(f)[m],i}function c(){n=new WeakMap}return{get:a,dispose:c}}class vv extends fo{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=HE,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class bv extends fo{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.referencePosition=new Me,this.nearDistance=1,this.farDistance=1e3,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}const Ok=`void main() {
	gl_Position = vec4( position, 1.0 );
}`,Fk=`uniform sampler2D shadow_pass;
uniform vec2 resolution;
uniform float radius;
#include <packing>
void main() {
	const float samples = float( VSM_SAMPLES );
	float mean = 0.0;
	float squared_mean = 0.0;
	float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
	float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
	for ( float i = 0.0; i < samples; i ++ ) {
		float uvOffset = uvStart + i * uvStride;
		#ifdef HORIZONTAL_PASS
			vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
			mean += distribution.x;
			squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
		#else
			float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
			mean += depth;
			squared_mean += depth * depth;
		#endif
	}
	mean = mean / samples;
	squared_mean = squared_mean / samples;
	float std_dev = sqrt( squared_mean - mean * mean );
	gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
}`;function Bk(d,e,n){let a=new U_;const c=new tn,f=new tn,m=new Wr,i=new vv({depthPacking:qE}),w=new bv,E={},C=n.maxTextureSize,T={0:fl,1:od,2:ad},I=new Gc({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new tn},radius:{value:4}},vertexShader:Ok,fragmentShader:Fk}),k=I.clone();k.defines.HORIZONTAL_PASS=1;const O=new qi;O.setAttribute("position",new Yr(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const B=new Jo(O,I),F=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=O_,this.render=function(ne,le,fe){if(F.enabled===!1||F.autoUpdate===!1&&F.needsUpdate===!1||ne.length===0)return;const Ae=d.getRenderTarget(),oe=d.getActiveCubeFace(),ce=d.getActiveMipmapLevel(),Re=d.state;Re.setBlending(bu),Re.buffers.color.setClear(1,1,1,1),Re.buffers.depth.setTest(!0),Re.setScissorTest(!1);for(let ke=0,Xe=ne.length;ke<Xe;ke++){const St=ne[ke],Je=St.shadow;if(Je===void 0){console.warn("THREE.WebGLShadowMap:",St,"has no shadow.");continue}if(Je.autoUpdate===!1&&Je.needsUpdate===!1)continue;c.copy(Je.mapSize);const It=Je.getFrameExtents();if(c.multiply(It),f.copy(Je.mapSize),(c.x>C||c.y>C)&&(c.x>C&&(f.x=Math.floor(C/It.x),c.x=f.x*It.x,Je.mapSize.x=f.x),c.y>C&&(f.y=Math.floor(C/It.y),c.y=f.y*It.y,Je.mapSize.y=f.y)),Je.map===null&&!Je.isPointLightShadow&&this.type===Xh&&(Je.map=new ml(c.x,c.y),Je.map.texture.name=St.name+".shadowMap",Je.mapPass=new ml(c.x,c.y),Je.camera.updateProjectionMatrix()),Je.map===null){const Nt={minFilter:uo,magFilter:uo,format:Qa};Je.map=new ml(c.x,c.y,Nt),Je.map.texture.name=St.name+".shadowMap",Je.camera.updateProjectionMatrix()}d.setRenderTarget(Je.map),d.clear();const ft=Je.getViewportCount();for(let Nt=0;Nt<ft;Nt++){const Fe=Je.getViewport(Nt);m.set(f.x*Fe.x,f.y*Fe.y,f.x*Fe.z,f.y*Fe.w),Re.viewport(m),Je.updateMatrices(St,Nt),a=Je.getFrustum(),K(le,fe,Je.camera,St,this.type)}!Je.isPointLightShadow&&this.type===Xh&&H(Je,fe),Je.needsUpdate=!1}F.needsUpdate=!1,d.setRenderTarget(Ae,oe,ce)};function H(ne,le){const fe=e.update(B);I.defines.VSM_SAMPLES!==ne.blurSamples&&(I.defines.VSM_SAMPLES=ne.blurSamples,k.defines.VSM_SAMPLES=ne.blurSamples,I.needsUpdate=!0,k.needsUpdate=!0),I.uniforms.shadow_pass.value=ne.map.texture,I.uniforms.resolution.value=ne.mapSize,I.uniforms.radius.value=ne.radius,d.setRenderTarget(ne.mapPass),d.clear(),d.renderBufferDirect(le,null,fe,I,B,null),k.uniforms.shadow_pass.value=ne.mapPass.texture,k.uniforms.resolution.value=ne.mapSize,k.uniforms.radius.value=ne.radius,d.setRenderTarget(ne.map),d.clear(),d.renderBufferDirect(le,null,fe,k,B,null)}function Y(ne,le,fe,Ae,oe,ce){let Re=null;const ke=fe.isPointLight===!0?ne.customDistanceMaterial:ne.customDepthMaterial;if(ke!==void 0?Re=ke:Re=fe.isPointLight===!0?w:i,d.localClippingEnabled&&le.clipShadows===!0&&le.clippingPlanes.length!==0||le.displacementMap&&le.displacementScale!==0||le.alphaMap&&le.alphaTest>0){const Xe=Re.uuid,St=le.uuid;let Je=E[Xe];Je===void 0&&(Je={},E[Xe]=Je);let It=Je[St];It===void 0&&(It=Re.clone(),Je[St]=It),Re=It}return Re.visible=le.visible,Re.wireframe=le.wireframe,ce===Xh?Re.side=le.shadowSide!==null?le.shadowSide:le.side:Re.side=le.shadowSide!==null?le.shadowSide:T[le.side],Re.alphaMap=le.alphaMap,Re.alphaTest=le.alphaTest,Re.clipShadows=le.clipShadows,Re.clippingPlanes=le.clippingPlanes,Re.clipIntersection=le.clipIntersection,Re.displacementMap=le.displacementMap,Re.displacementScale=le.displacementScale,Re.displacementBias=le.displacementBias,Re.wireframeLinewidth=le.wireframeLinewidth,Re.linewidth=le.linewidth,fe.isPointLight===!0&&Re.isMeshDistanceMaterial===!0&&(Re.referencePosition.setFromMatrixPosition(fe.matrixWorld),Re.nearDistance=Ae,Re.farDistance=oe),Re}function K(ne,le,fe,Ae,oe){if(ne.visible===!1)return;if(ne.layers.test(le.layers)&&(ne.isMesh||ne.isLine||ne.isPoints)&&(ne.castShadow||ne.receiveShadow&&oe===Xh)&&(!ne.frustumCulled||a.intersectsObject(ne))){ne.modelViewMatrix.multiplyMatrices(fe.matrixWorldInverse,ne.matrixWorld);const ke=e.update(ne),Xe=ne.material;if(Array.isArray(Xe)){const St=ke.groups;for(let Je=0,It=St.length;Je<It;Je++){const ft=St[Je],Nt=Xe[ft.materialIndex];if(Nt&&Nt.visible){const Fe=Y(ne,Nt,Ae,fe.near,fe.far,oe);d.renderBufferDirect(fe,null,ke,Fe,ne,ft)}}}else if(Xe.visible){const St=Y(ne,Xe,Ae,fe.near,fe.far,oe);d.renderBufferDirect(fe,null,ke,St,ne,null)}}const Re=ne.children;for(let ke=0,Xe=Re.length;ke<Xe;ke++)K(Re[ke],le,fe,Ae,oe)}}function Nk(d,e,n){const a=n.isWebGL2;function c(){let Ze=!1;const Tn=new Wr;let bn=null;const We=new Wr(0,0,0,0);return{setMask:function(bt){bn!==bt&&!Ze&&(d.colorMask(bt,bt,bt,bt),bn=bt)},setLocked:function(bt){Ze=bt},setClear:function(bt,un,ue,te,se){se===!0&&(bt*=te,un*=te,ue*=te),Tn.set(bt,un,ue,te),We.equals(Tn)===!1&&(d.clearColor(bt,un,ue,te),We.copy(Tn))},reset:function(){Ze=!1,bn=null,We.set(-1,0,0,0)}}}function f(){let Ze=!1,Tn=null,bn=null,We=null;return{setTest:function(bt){bt?pn(2929):Mt(2929)},setMask:function(bt){Tn!==bt&&!Ze&&(d.depthMask(bt),Tn=bt)},setFunc:function(bt){if(bn!==bt){if(bt)switch(bt){case pE:d.depthFunc(512);break;case mE:d.depthFunc(519);break;case gE:d.depthFunc(513);break;case m_:d.depthFunc(515);break;case _E:d.depthFunc(514);break;case yE:d.depthFunc(518);break;case xE:d.depthFunc(516);break;case vE:d.depthFunc(517);break;default:d.depthFunc(515)}else d.depthFunc(515);bn=bt}},setLocked:function(bt){Ze=bt},setClear:function(bt){We!==bt&&(d.clearDepth(bt),We=bt)},reset:function(){Ze=!1,Tn=null,bn=null,We=null}}}function m(){let Ze=!1,Tn=null,bn=null,We=null,bt=null,un=null,ue=null,te=null,se=null;return{setTest:function(ye){Ze||(ye?pn(2960):Mt(2960))},setMask:function(ye){Tn!==ye&&!Ze&&(d.stencilMask(ye),Tn=ye)},setFunc:function(ye,De,je){(bn!==ye||We!==De||bt!==je)&&(d.stencilFunc(ye,De,je),bn=ye,We=De,bt=je)},setOp:function(ye,De,je){(un!==ye||ue!==De||te!==je)&&(d.stencilOp(ye,De,je),un=ye,ue=De,te=je)},setLocked:function(ye){Ze=ye},setClear:function(ye){se!==ye&&(d.clearStencil(ye),se=ye)},reset:function(){Ze=!1,Tn=null,bn=null,We=null,bt=null,un=null,ue=null,te=null,se=null}}}const i=new c,w=new f,E=new m;let C={},T={},I=new WeakMap,k=[],O=null,B=!1,F=null,H=null,Y=null,K=null,ne=null,le=null,fe=null,Ae=!1,oe=null,ce=null,Re=null,ke=null,Xe=null;const St=d.getParameter(35661);let Je=!1,It=0;const ft=d.getParameter(7938);ft.indexOf("WebGL")!==-1?(It=parseFloat(/^WebGL (\d)/.exec(ft)[1]),Je=It>=1):ft.indexOf("OpenGL ES")!==-1&&(It=parseFloat(/^OpenGL ES (\d)/.exec(ft)[1]),Je=It>=2);let Nt=null,Fe={};const it=d.getParameter(3088),tt=d.getParameter(2978),Et=new Wr().fromArray(it),xt=new Wr().fromArray(tt);function Pt(Ze,Tn,bn){const We=new Uint8Array(4),bt=d.createTexture();d.bindTexture(Ze,bt),d.texParameteri(Ze,10241,9728),d.texParameteri(Ze,10240,9728);for(let un=0;un<bn;un++)d.texImage2D(Tn+un,0,6408,1,1,0,6408,5121,We);return bt}const ln={};ln[3553]=Pt(3553,3553,1),ln[34067]=Pt(34067,34069,6),i.setClear(0,0,0,1),w.setClear(1),E.setClear(0),pn(2929),w.setFunc(m_),gn(!1),wn(lx),pn(2884),qt(bu);function pn(Ze){C[Ze]!==!0&&(d.enable(Ze),C[Ze]=!0)}function Mt(Ze){C[Ze]!==!1&&(d.disable(Ze),C[Ze]=!1)}function ei(Ze,Tn){return T[Ze]!==Tn?(d.bindFramebuffer(Ze,Tn),T[Ze]=Tn,a&&(Ze===36009&&(T[36160]=Tn),Ze===36160&&(T[36009]=Tn)),!0):!1}function oi(Ze,Tn){let bn=k,We=!1;if(Ze)if(bn=I.get(Tn),bn===void 0&&(bn=[],I.set(Tn,bn)),Ze.isWebGLMultipleRenderTargets){const bt=Ze.texture;if(bn.length!==bt.length||bn[0]!==36064){for(let un=0,ue=bt.length;un<ue;un++)bn[un]=36064+un;bn.length=bt.length,We=!0}}else bn[0]!==36064&&(bn[0]=36064,We=!0);else bn[0]!==1029&&(bn[0]=1029,We=!0);We&&(n.isWebGL2?d.drawBuffers(bn):e.get("WEBGL_draw_buffers").drawBuffersWEBGL(bn))}function Wn(Ze){return O!==Ze?(d.useProgram(Ze),O=Ze,!0):!1}const jt={[qh]:32774,[iE]:32778,[rE]:32779};if(a)jt[dx]=32775,jt[fx]=32776;else{const Ze=e.get("EXT_blend_minmax");Ze!==null&&(jt[dx]=Ze.MIN_EXT,jt[fx]=Ze.MAX_EXT)}const mn={[sE]:0,[oE]:1,[aE]:768,[cv]:770,[fE]:776,[hE]:774,[cE]:772,[lE]:769,[uv]:771,[dE]:775,[uE]:773};function qt(Ze,Tn,bn,We,bt,un,ue,te){if(Ze===bu){B===!0&&(Mt(3042),B=!1);return}if(B===!1&&(pn(3042),B=!0),Ze!==nE){if(Ze!==F||te!==Ae){if((H!==qh||ne!==qh)&&(d.blendEquation(32774),H=qh,ne=qh),te)switch(Ze){case ed:d.blendFuncSeparate(1,771,1,771);break;case cx:d.blendFunc(1,1);break;case ux:d.blendFuncSeparate(0,769,0,1);break;case hx:d.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",Ze);break}else switch(Ze){case ed:d.blendFuncSeparate(770,771,1,771);break;case cx:d.blendFunc(770,1);break;case ux:d.blendFuncSeparate(0,769,0,1);break;case hx:d.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",Ze);break}Y=null,K=null,le=null,fe=null,F=Ze,Ae=te}return}bt=bt||Tn,un=un||bn,ue=ue||We,(Tn!==H||bt!==ne)&&(d.blendEquationSeparate(jt[Tn],jt[bt]),H=Tn,ne=bt),(bn!==Y||We!==K||un!==le||ue!==fe)&&(d.blendFuncSeparate(mn[bn],mn[We],mn[un],mn[ue]),Y=bn,K=We,le=un,fe=ue),F=Ze,Ae=null}function Dt(Ze,Tn){Ze.side===ad?Mt(2884):pn(2884);let bn=Ze.side===fl;Tn&&(bn=!bn),gn(bn),Ze.blending===ed&&Ze.transparent===!1?qt(bu):qt(Ze.blending,Ze.blendEquation,Ze.blendSrc,Ze.blendDst,Ze.blendEquationAlpha,Ze.blendSrcAlpha,Ze.blendDstAlpha,Ze.premultipliedAlpha),w.setFunc(Ze.depthFunc),w.setTest(Ze.depthTest),w.setMask(Ze.depthWrite),i.setMask(Ze.colorWrite);const We=Ze.stencilWrite;E.setTest(We),We&&(E.setMask(Ze.stencilWriteMask),E.setFunc(Ze.stencilFunc,Ze.stencilRef,Ze.stencilFuncMask),E.setOp(Ze.stencilFail,Ze.stencilZFail,Ze.stencilZPass)),rn(Ze.polygonOffset,Ze.polygonOffsetFactor,Ze.polygonOffsetUnits),Ze.alphaToCoverage===!0?pn(32926):Mt(32926)}function gn(Ze){oe!==Ze&&(Ze?d.frontFace(2304):d.frontFace(2305),oe=Ze)}function wn(Ze){Ze!==KM?(pn(2884),Ze!==ce&&(Ze===lx?d.cullFace(1029):Ze===QM?d.cullFace(1028):d.cullFace(1032))):Mt(2884),ce=Ze}function Yt(Ze){Ze!==Re&&(Je&&d.lineWidth(Ze),Re=Ze)}function rn(Ze,Tn,bn){Ze?(pn(32823),(ke!==Tn||Xe!==bn)&&(d.polygonOffset(Tn,bn),ke=Tn,Xe=bn)):Mt(32823)}function dn(Ze){Ze?pn(3089):Mt(3089)}function Mn(Ze){Ze===void 0&&(Ze=33984+St-1),Nt!==Ze&&(d.activeTexture(Ze),Nt=Ze)}function li(Ze,Tn){Nt===null&&Mn();let bn=Fe[Nt];bn===void 0&&(bn={type:void 0,texture:void 0},Fe[Nt]=bn),(bn.type!==Ze||bn.texture!==Tn)&&(d.bindTexture(Ze,Tn||ln[Ze]),bn.type=Ze,bn.texture=Tn)}function ti(){const Ze=Fe[Nt];Ze!==void 0&&Ze.type!==void 0&&(d.bindTexture(Ze.type,null),Ze.type=void 0,Ze.texture=void 0)}function Ie(){try{d.compressedTexImage2D.apply(d,arguments)}catch(Ze){console.error("THREE.WebGLState:",Ze)}}function xe(){try{d.texSubImage2D.apply(d,arguments)}catch(Ze){console.error("THREE.WebGLState:",Ze)}}function Tt(){try{d.texSubImage3D.apply(d,arguments)}catch(Ze){console.error("THREE.WebGLState:",Ze)}}function hn(){try{d.compressedTexSubImage2D.apply(d,arguments)}catch(Ze){console.error("THREE.WebGLState:",Ze)}}function _n(){try{d.texStorage2D.apply(d,arguments)}catch(Ze){console.error("THREE.WebGLState:",Ze)}}function Sn(){try{d.texStorage3D.apply(d,arguments)}catch(Ze){console.error("THREE.WebGLState:",Ze)}}function ri(){try{d.texImage2D.apply(d,arguments)}catch(Ze){console.error("THREE.WebGLState:",Ze)}}function kt(){try{d.texImage3D.apply(d,arguments)}catch(Ze){console.error("THREE.WebGLState:",Ze)}}function Hn(Ze){Et.equals(Ze)===!1&&(d.scissor(Ze.x,Ze.y,Ze.z,Ze.w),Et.copy(Ze))}function On(Ze){xt.equals(Ze)===!1&&(d.viewport(Ze.x,Ze.y,Ze.z,Ze.w),xt.copy(Ze))}function Fn(){d.disable(3042),d.disable(2884),d.disable(2929),d.disable(32823),d.disable(3089),d.disable(2960),d.disable(32926),d.blendEquation(32774),d.blendFunc(1,0),d.blendFuncSeparate(1,0,1,0),d.colorMask(!0,!0,!0,!0),d.clearColor(0,0,0,0),d.depthMask(!0),d.depthFunc(513),d.clearDepth(1),d.stencilMask(4294967295),d.stencilFunc(519,0,4294967295),d.stencilOp(7680,7680,7680),d.clearStencil(0),d.cullFace(1029),d.frontFace(2305),d.polygonOffset(0,0),d.activeTexture(33984),d.bindFramebuffer(36160,null),a===!0&&(d.bindFramebuffer(36009,null),d.bindFramebuffer(36008,null)),d.useProgram(null),d.lineWidth(1),d.scissor(0,0,d.canvas.width,d.canvas.height),d.viewport(0,0,d.canvas.width,d.canvas.height),C={},Nt=null,Fe={},T={},I=new WeakMap,k=[],O=null,B=!1,F=null,H=null,Y=null,K=null,ne=null,le=null,fe=null,Ae=!1,oe=null,ce=null,Re=null,ke=null,Xe=null,Et.set(0,0,d.canvas.width,d.canvas.height),xt.set(0,0,d.canvas.width,d.canvas.height),i.reset(),w.reset(),E.reset()}return{buffers:{color:i,depth:w,stencil:E},enable:pn,disable:Mt,bindFramebuffer:ei,drawBuffers:oi,useProgram:Wn,setBlending:qt,setMaterial:Dt,setFlipSided:gn,setCullFace:wn,setLineWidth:Yt,setPolygonOffset:rn,setScissorTest:dn,activeTexture:Mn,bindTexture:li,unbindTexture:ti,compressedTexImage2D:Ie,texImage2D:ri,texImage3D:kt,texStorage2D:_n,texStorage3D:Sn,texSubImage2D:xe,texSubImage3D:Tt,compressedTexSubImage2D:hn,scissor:Hn,viewport:On,reset:Fn}}function Uk(d,e,n,a,c,f,m){const i=c.isWebGL2,w=c.maxTextures,E=c.maxCubemapSize,C=c.maxTextureSize,T=c.maxSamples,I=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,k=/OculusBrowser/g.test(navigator.userAgent),O=new WeakMap;let B;const F=new WeakMap;let H=!1;try{H=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function Y(Ie,xe){return H?new OffscreenCanvas(Ie,xe):um("canvas")}function K(Ie,xe,Tt,hn){let _n=1;if((Ie.width>hn||Ie.height>hn)&&(_n=hn/Math.max(Ie.width,Ie.height)),_n<1||xe===!0)if(typeof HTMLImageElement<"u"&&Ie instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&Ie instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&Ie instanceof ImageBitmap){const Sn=xe?v_:Math.floor,ri=Sn(_n*Ie.width),kt=Sn(_n*Ie.height);B===void 0&&(B=Y(ri,kt));const Hn=Tt?Y(ri,kt):B;return Hn.width=ri,Hn.height=kt,Hn.getContext("2d").drawImage(Ie,0,0,ri,kt),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+Ie.width+"x"+Ie.height+") to ("+ri+"x"+kt+")."),Hn}else return"data"in Ie&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+Ie.width+"x"+Ie.height+")."),Ie;return Ie}function ne(Ie){return Ox(Ie.width)&&Ox(Ie.height)}function le(Ie){return i?!1:Ie.wrapS!==Ta||Ie.wrapT!==Ta||Ie.minFilter!==uo&&Ie.minFilter!==qs}function fe(Ie,xe){return Ie.generateMipmaps&&xe&&Ie.minFilter!==uo&&Ie.minFilter!==qs}function Ae(Ie){d.generateMipmap(Ie)}function oe(Ie,xe,Tt,hn,_n=!1){if(i===!1)return xe;if(Ie!==null){if(d[Ie]!==void 0)return d[Ie];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+Ie+"'")}let Sn=xe;return xe===6403&&(Tt===5126&&(Sn=33326),Tt===5131&&(Sn=33325),Tt===5121&&(Sn=33321)),xe===33319&&(Tt===5126&&(Sn=33328),Tt===5131&&(Sn=33327),Tt===5121&&(Sn=33323)),xe===6408&&(Tt===5126&&(Sn=34836),Tt===5131&&(Sn=34842),Tt===5121&&(Sn=hn===hs&&_n===!1?35907:32856),Tt===32819&&(Sn=32854),Tt===32820&&(Sn=32855)),(Sn===33325||Sn===33326||Sn===33327||Sn===33328||Sn===34842||Sn===34836)&&e.get("EXT_color_buffer_float"),Sn}function ce(Ie,xe,Tt){return fe(Ie,Tt)===!0||Ie.isFramebufferTexture&&Ie.minFilter!==uo&&Ie.minFilter!==qs?Math.log2(Math.max(xe.width,xe.height))+1:Ie.mipmaps!==void 0&&Ie.mipmaps.length>0?Ie.mipmaps.length:Ie.isCompressedTexture&&Array.isArray(Ie.image)?xe.mipmaps.length:1}function Re(Ie){return Ie===uo||Ie===g_||Ie===__?9728:9729}function ke(Ie){const xe=Ie.target;xe.removeEventListener("dispose",ke),St(xe),xe.isVideoTexture&&O.delete(xe)}function Xe(Ie){const xe=Ie.target;xe.removeEventListener("dispose",Xe),It(xe)}function St(Ie){const xe=a.get(Ie);if(xe.__webglInit===void 0)return;const Tt=Ie.source,hn=F.get(Tt);if(hn){const _n=hn[xe.__cacheKey];_n.usedTimes--,_n.usedTimes===0&&Je(Ie),Object.keys(hn).length===0&&F.delete(Tt)}a.remove(Ie)}function Je(Ie){const xe=a.get(Ie);d.deleteTexture(xe.__webglTexture);const Tt=Ie.source,hn=F.get(Tt);delete hn[xe.__cacheKey],m.memory.textures--}function It(Ie){const xe=Ie.texture,Tt=a.get(Ie),hn=a.get(xe);if(hn.__webglTexture!==void 0&&(d.deleteTexture(hn.__webglTexture),m.memory.textures--),Ie.depthTexture&&Ie.depthTexture.dispose(),Ie.isWebGLCubeRenderTarget)for(let _n=0;_n<6;_n++)d.deleteFramebuffer(Tt.__webglFramebuffer[_n]),Tt.__webglDepthbuffer&&d.deleteRenderbuffer(Tt.__webglDepthbuffer[_n]);else{if(d.deleteFramebuffer(Tt.__webglFramebuffer),Tt.__webglDepthbuffer&&d.deleteRenderbuffer(Tt.__webglDepthbuffer),Tt.__webglMultisampledFramebuffer&&d.deleteFramebuffer(Tt.__webglMultisampledFramebuffer),Tt.__webglColorRenderbuffer)for(let _n=0;_n<Tt.__webglColorRenderbuffer.length;_n++)Tt.__webglColorRenderbuffer[_n]&&d.deleteRenderbuffer(Tt.__webglColorRenderbuffer[_n]);Tt.__webglDepthRenderbuffer&&d.deleteRenderbuffer(Tt.__webglDepthRenderbuffer)}if(Ie.isWebGLMultipleRenderTargets)for(let _n=0,Sn=xe.length;_n<Sn;_n++){const ri=a.get(xe[_n]);ri.__webglTexture&&(d.deleteTexture(ri.__webglTexture),m.memory.textures--),a.remove(xe[_n])}a.remove(xe),a.remove(Ie)}let ft=0;function Nt(){ft=0}function Fe(){const Ie=ft;return Ie>=w&&console.warn("THREE.WebGLTextures: Trying to use "+Ie+" texture units while this GPU supports only "+w),ft+=1,Ie}function it(Ie){const xe=[];return xe.push(Ie.wrapS),xe.push(Ie.wrapT),xe.push(Ie.magFilter),xe.push(Ie.minFilter),xe.push(Ie.anisotropy),xe.push(Ie.internalFormat),xe.push(Ie.format),xe.push(Ie.type),xe.push(Ie.generateMipmaps),xe.push(Ie.premultiplyAlpha),xe.push(Ie.flipY),xe.push(Ie.unpackAlignment),xe.push(Ie.encoding),xe.join()}function tt(Ie,xe){const Tt=a.get(Ie);if(Ie.isVideoTexture&&li(Ie),Ie.isRenderTargetTexture===!1&&Ie.version>0&&Tt.__version!==Ie.version){const hn=Ie.image;if(hn===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(hn.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{oi(Tt,Ie,xe);return}}n.activeTexture(33984+xe),n.bindTexture(3553,Tt.__webglTexture)}function Et(Ie,xe){const Tt=a.get(Ie);if(Ie.version>0&&Tt.__version!==Ie.version){oi(Tt,Ie,xe);return}n.activeTexture(33984+xe),n.bindTexture(35866,Tt.__webglTexture)}function xt(Ie,xe){const Tt=a.get(Ie);if(Ie.version>0&&Tt.__version!==Ie.version){oi(Tt,Ie,xe);return}n.activeTexture(33984+xe),n.bindTexture(32879,Tt.__webglTexture)}function Pt(Ie,xe){const Tt=a.get(Ie);if(Ie.version>0&&Tt.__version!==Ie.version){Wn(Tt,Ie,xe);return}n.activeTexture(33984+xe),n.bindTexture(34067,Tt.__webglTexture)}const ln={[rm]:10497,[Ta]:33071,[sm]:33648},pn={[uo]:9728,[g_]:9984,[__]:9986,[qs]:9729,[dv]:9985,[_d]:9987};function Mt(Ie,xe,Tt){if(Tt?(d.texParameteri(Ie,10242,ln[xe.wrapS]),d.texParameteri(Ie,10243,ln[xe.wrapT]),(Ie===32879||Ie===35866)&&d.texParameteri(Ie,32882,ln[xe.wrapR]),d.texParameteri(Ie,10240,pn[xe.magFilter]),d.texParameteri(Ie,10241,pn[xe.minFilter])):(d.texParameteri(Ie,10242,33071),d.texParameteri(Ie,10243,33071),(Ie===32879||Ie===35866)&&d.texParameteri(Ie,32882,33071),(xe.wrapS!==Ta||xe.wrapT!==Ta)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),d.texParameteri(Ie,10240,Re(xe.magFilter)),d.texParameteri(Ie,10241,Re(xe.minFilter)),xe.minFilter!==uo&&xe.minFilter!==qs&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),e.has("EXT_texture_filter_anisotropic")===!0){const hn=e.get("EXT_texture_filter_anisotropic");if(xe.type===xu&&e.has("OES_texture_float_linear")===!1||i===!1&&xe.type===Of&&e.has("OES_texture_half_float_linear")===!1)return;(xe.anisotropy>1||a.get(xe).__currentAnisotropy)&&(d.texParameterf(Ie,hn.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(xe.anisotropy,c.getMaxAnisotropy())),a.get(xe).__currentAnisotropy=xe.anisotropy)}}function ei(Ie,xe){let Tt=!1;Ie.__webglInit===void 0&&(Ie.__webglInit=!0,xe.addEventListener("dispose",ke));const hn=xe.source;let _n=F.get(hn);_n===void 0&&(_n={},F.set(hn,_n));const Sn=it(xe);if(Sn!==Ie.__cacheKey){_n[Sn]===void 0&&(_n[Sn]={texture:d.createTexture(),usedTimes:0},m.memory.textures++,Tt=!0),_n[Sn].usedTimes++;const ri=_n[Ie.__cacheKey];ri!==void 0&&(_n[Ie.__cacheKey].usedTimes--,ri.usedTimes===0&&Je(xe)),Ie.__cacheKey=Sn,Ie.__webglTexture=_n[Sn].texture}return Tt}function oi(Ie,xe,Tt){let hn=3553;xe.isDataArrayTexture&&(hn=35866),xe.isData3DTexture&&(hn=32879);const _n=ei(Ie,xe),Sn=xe.source;if(n.activeTexture(33984+Tt),n.bindTexture(hn,Ie.__webglTexture),Sn.version!==Sn.__currentVersion||_n===!0){d.pixelStorei(37440,xe.flipY),d.pixelStorei(37441,xe.premultiplyAlpha),d.pixelStorei(3317,xe.unpackAlignment),d.pixelStorei(37443,0);const ri=le(xe)&&ne(xe.image)===!1;let kt=K(xe.image,ri,!1,C);kt=ti(xe,kt);const Hn=ne(kt)||i,On=f.convert(xe.format,xe.encoding);let Fn=f.convert(xe.type),Ze=oe(xe.internalFormat,On,Fn,xe.encoding,xe.isVideoTexture);Mt(hn,xe,Hn);let Tn;const bn=xe.mipmaps,We=i&&xe.isVideoTexture!==!0,bt=Sn.__currentVersion===void 0||_n===!0,un=ce(xe,kt,Hn);if(xe.isDepthTexture)Ze=6402,i?xe.type===xu?Ze=36012:xe.type===th?Ze=33190:xe.type===td?Ze=35056:Ze=33189:xe.type===xu&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),xe.format===ih&&Ze===6402&&xe.type!==fv&&xe.type!==th&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),xe.type=th,Fn=f.convert(xe.type)),xe.format===ld&&Ze===6402&&(Ze=34041,xe.type!==td&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),xe.type=td,Fn=f.convert(xe.type))),bt&&(We?n.texStorage2D(3553,1,Ze,kt.width,kt.height):n.texImage2D(3553,0,Ze,kt.width,kt.height,0,On,Fn,null));else if(xe.isDataTexture)if(bn.length>0&&Hn){We&&bt&&n.texStorage2D(3553,un,Ze,bn[0].width,bn[0].height);for(let ue=0,te=bn.length;ue<te;ue++)Tn=bn[ue],We?n.texSubImage2D(3553,ue,0,0,Tn.width,Tn.height,On,Fn,Tn.data):n.texImage2D(3553,ue,Ze,Tn.width,Tn.height,0,On,Fn,Tn.data);xe.generateMipmaps=!1}else We?(bt&&n.texStorage2D(3553,un,Ze,kt.width,kt.height),n.texSubImage2D(3553,0,0,0,kt.width,kt.height,On,Fn,kt.data)):n.texImage2D(3553,0,Ze,kt.width,kt.height,0,On,Fn,kt.data);else if(xe.isCompressedTexture){We&&bt&&n.texStorage2D(3553,un,Ze,bn[0].width,bn[0].height);for(let ue=0,te=bn.length;ue<te;ue++)Tn=bn[ue],xe.format!==Qa?On!==null?We?n.compressedTexSubImage2D(3553,ue,0,0,Tn.width,Tn.height,On,Tn.data):n.compressedTexImage2D(3553,ue,Ze,Tn.width,Tn.height,0,Tn.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):We?n.texSubImage2D(3553,ue,0,0,Tn.width,Tn.height,On,Fn,Tn.data):n.texImage2D(3553,ue,Ze,Tn.width,Tn.height,0,On,Fn,Tn.data)}else if(xe.isDataArrayTexture)We?(bt&&n.texStorage3D(35866,un,Ze,kt.width,kt.height,kt.depth),n.texSubImage3D(35866,0,0,0,0,kt.width,kt.height,kt.depth,On,Fn,kt.data)):n.texImage3D(35866,0,Ze,kt.width,kt.height,kt.depth,0,On,Fn,kt.data);else if(xe.isData3DTexture)We?(bt&&n.texStorage3D(32879,un,Ze,kt.width,kt.height,kt.depth),n.texSubImage3D(32879,0,0,0,0,kt.width,kt.height,kt.depth,On,Fn,kt.data)):n.texImage3D(32879,0,Ze,kt.width,kt.height,kt.depth,0,On,Fn,kt.data);else if(xe.isFramebufferTexture){if(bt)if(We)n.texStorage2D(3553,un,Ze,kt.width,kt.height);else{let ue=kt.width,te=kt.height;for(let se=0;se<un;se++)n.texImage2D(3553,se,Ze,ue,te,0,On,Fn,null),ue>>=1,te>>=1}}else if(bn.length>0&&Hn){We&&bt&&n.texStorage2D(3553,un,Ze,bn[0].width,bn[0].height);for(let ue=0,te=bn.length;ue<te;ue++)Tn=bn[ue],We?n.texSubImage2D(3553,ue,0,0,On,Fn,Tn):n.texImage2D(3553,ue,Ze,On,Fn,Tn);xe.generateMipmaps=!1}else We?(bt&&n.texStorage2D(3553,un,Ze,kt.width,kt.height),n.texSubImage2D(3553,0,0,0,On,Fn,kt)):n.texImage2D(3553,0,Ze,On,Fn,kt);fe(xe,Hn)&&Ae(hn),Sn.__currentVersion=Sn.version,xe.onUpdate&&xe.onUpdate(xe)}Ie.__version=xe.version}function Wn(Ie,xe,Tt){if(xe.image.length!==6)return;const hn=ei(Ie,xe),_n=xe.source;if(n.activeTexture(33984+Tt),n.bindTexture(34067,Ie.__webglTexture),_n.version!==_n.__currentVersion||hn===!0){d.pixelStorei(37440,xe.flipY),d.pixelStorei(37441,xe.premultiplyAlpha),d.pixelStorei(3317,xe.unpackAlignment),d.pixelStorei(37443,0);const Sn=xe.isCompressedTexture||xe.image[0].isCompressedTexture,ri=xe.image[0]&&xe.image[0].isDataTexture,kt=[];for(let ue=0;ue<6;ue++)!Sn&&!ri?kt[ue]=K(xe.image[ue],!1,!0,E):kt[ue]=ri?xe.image[ue].image:xe.image[ue],kt[ue]=ti(xe,kt[ue]);const Hn=kt[0],On=ne(Hn)||i,Fn=f.convert(xe.format,xe.encoding),Ze=f.convert(xe.type),Tn=oe(xe.internalFormat,Fn,Ze,xe.encoding),bn=i&&xe.isVideoTexture!==!0,We=_n.__currentVersion===void 0||hn===!0;let bt=ce(xe,Hn,On);Mt(34067,xe,On);let un;if(Sn){bn&&We&&n.texStorage2D(34067,bt,Tn,Hn.width,Hn.height);for(let ue=0;ue<6;ue++){un=kt[ue].mipmaps;for(let te=0;te<un.length;te++){const se=un[te];xe.format!==Qa?Fn!==null?bn?n.compressedTexSubImage2D(34069+ue,te,0,0,se.width,se.height,Fn,se.data):n.compressedTexImage2D(34069+ue,te,Tn,se.width,se.height,0,se.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):bn?n.texSubImage2D(34069+ue,te,0,0,se.width,se.height,Fn,Ze,se.data):n.texImage2D(34069+ue,te,Tn,se.width,se.height,0,Fn,Ze,se.data)}}}else{un=xe.mipmaps,bn&&We&&(un.length>0&&bt++,n.texStorage2D(34067,bt,Tn,kt[0].width,kt[0].height));for(let ue=0;ue<6;ue++)if(ri){bn?n.texSubImage2D(34069+ue,0,0,0,kt[ue].width,kt[ue].height,Fn,Ze,kt[ue].data):n.texImage2D(34069+ue,0,Tn,kt[ue].width,kt[ue].height,0,Fn,Ze,kt[ue].data);for(let te=0;te<un.length;te++){const ye=un[te].image[ue].image;bn?n.texSubImage2D(34069+ue,te+1,0,0,ye.width,ye.height,Fn,Ze,ye.data):n.texImage2D(34069+ue,te+1,Tn,ye.width,ye.height,0,Fn,Ze,ye.data)}}else{bn?n.texSubImage2D(34069+ue,0,0,0,Fn,Ze,kt[ue]):n.texImage2D(34069+ue,0,Tn,Fn,Ze,kt[ue]);for(let te=0;te<un.length;te++){const se=un[te];bn?n.texSubImage2D(34069+ue,te+1,0,0,Fn,Ze,se.image[ue]):n.texImage2D(34069+ue,te+1,Tn,Fn,Ze,se.image[ue])}}}fe(xe,On)&&Ae(34067),_n.__currentVersion=_n.version,xe.onUpdate&&xe.onUpdate(xe)}Ie.__version=xe.version}function jt(Ie,xe,Tt,hn,_n){const Sn=f.convert(Tt.format,Tt.encoding),ri=f.convert(Tt.type),kt=oe(Tt.internalFormat,Sn,ri,Tt.encoding);a.get(xe).__hasExternalTextures||(_n===32879||_n===35866?n.texImage3D(_n,0,kt,xe.width,xe.height,xe.depth,0,Sn,ri,null):n.texImage2D(_n,0,kt,xe.width,xe.height,0,Sn,ri,null)),n.bindFramebuffer(36160,Ie),Mn(xe)?I.framebufferTexture2DMultisampleEXT(36160,hn,_n,a.get(Tt).__webglTexture,0,dn(xe)):d.framebufferTexture2D(36160,hn,_n,a.get(Tt).__webglTexture,0),n.bindFramebuffer(36160,null)}function mn(Ie,xe,Tt){if(d.bindRenderbuffer(36161,Ie),xe.depthBuffer&&!xe.stencilBuffer){let hn=33189;if(Tt||Mn(xe)){const _n=xe.depthTexture;_n&&_n.isDepthTexture&&(_n.type===xu?hn=36012:_n.type===th&&(hn=33190));const Sn=dn(xe);Mn(xe)?I.renderbufferStorageMultisampleEXT(36161,Sn,hn,xe.width,xe.height):d.renderbufferStorageMultisample(36161,Sn,hn,xe.width,xe.height)}else d.renderbufferStorage(36161,hn,xe.width,xe.height);d.framebufferRenderbuffer(36160,36096,36161,Ie)}else if(xe.depthBuffer&&xe.stencilBuffer){const hn=dn(xe);Tt&&Mn(xe)===!1?d.renderbufferStorageMultisample(36161,hn,35056,xe.width,xe.height):Mn(xe)?I.renderbufferStorageMultisampleEXT(36161,hn,35056,xe.width,xe.height):d.renderbufferStorage(36161,34041,xe.width,xe.height),d.framebufferRenderbuffer(36160,33306,36161,Ie)}else{const hn=xe.isWebGLMultipleRenderTargets===!0?xe.texture:[xe.texture];for(let _n=0;_n<hn.length;_n++){const Sn=hn[_n],ri=f.convert(Sn.format,Sn.encoding),kt=f.convert(Sn.type),Hn=oe(Sn.internalFormat,ri,kt,Sn.encoding),On=dn(xe);Tt&&Mn(xe)===!1?d.renderbufferStorageMultisample(36161,On,Hn,xe.width,xe.height):Mn(xe)?I.renderbufferStorageMultisampleEXT(36161,On,Hn,xe.width,xe.height):d.renderbufferStorage(36161,Hn,xe.width,xe.height)}}d.bindRenderbuffer(36161,null)}function qt(Ie,xe){if(xe&&xe.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(36160,Ie),!(xe.depthTexture&&xe.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!a.get(xe.depthTexture).__webglTexture||xe.depthTexture.image.width!==xe.width||xe.depthTexture.image.height!==xe.height)&&(xe.depthTexture.image.width=xe.width,xe.depthTexture.image.height=xe.height,xe.depthTexture.needsUpdate=!0),tt(xe.depthTexture,0);const hn=a.get(xe.depthTexture).__webglTexture,_n=dn(xe);if(xe.depthTexture.format===ih)Mn(xe)?I.framebufferTexture2DMultisampleEXT(36160,36096,3553,hn,0,_n):d.framebufferTexture2D(36160,36096,3553,hn,0);else if(xe.depthTexture.format===ld)Mn(xe)?I.framebufferTexture2DMultisampleEXT(36160,33306,3553,hn,0,_n):d.framebufferTexture2D(36160,33306,3553,hn,0);else throw new Error("Unknown depthTexture format")}function Dt(Ie){const xe=a.get(Ie),Tt=Ie.isWebGLCubeRenderTarget===!0;if(Ie.depthTexture&&!xe.__autoAllocateDepthBuffer){if(Tt)throw new Error("target.depthTexture not supported in Cube render targets");qt(xe.__webglFramebuffer,Ie)}else if(Tt){xe.__webglDepthbuffer=[];for(let hn=0;hn<6;hn++)n.bindFramebuffer(36160,xe.__webglFramebuffer[hn]),xe.__webglDepthbuffer[hn]=d.createRenderbuffer(),mn(xe.__webglDepthbuffer[hn],Ie,!1)}else n.bindFramebuffer(36160,xe.__webglFramebuffer),xe.__webglDepthbuffer=d.createRenderbuffer(),mn(xe.__webglDepthbuffer,Ie,!1);n.bindFramebuffer(36160,null)}function gn(Ie,xe,Tt){const hn=a.get(Ie);xe!==void 0&&jt(hn.__webglFramebuffer,Ie,Ie.texture,36064,3553),Tt!==void 0&&Dt(Ie)}function wn(Ie){const xe=Ie.texture,Tt=a.get(Ie),hn=a.get(xe);Ie.addEventListener("dispose",Xe),Ie.isWebGLMultipleRenderTargets!==!0&&(hn.__webglTexture===void 0&&(hn.__webglTexture=d.createTexture()),hn.__version=xe.version,m.memory.textures++);const _n=Ie.isWebGLCubeRenderTarget===!0,Sn=Ie.isWebGLMultipleRenderTargets===!0,ri=ne(Ie)||i;if(_n){Tt.__webglFramebuffer=[];for(let kt=0;kt<6;kt++)Tt.__webglFramebuffer[kt]=d.createFramebuffer()}else{if(Tt.__webglFramebuffer=d.createFramebuffer(),Sn)if(c.drawBuffers){const kt=Ie.texture;for(let Hn=0,On=kt.length;Hn<On;Hn++){const Fn=a.get(kt[Hn]);Fn.__webglTexture===void 0&&(Fn.__webglTexture=d.createTexture(),m.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(i&&Ie.samples>0&&Mn(Ie)===!1){const kt=Sn?xe:[xe];Tt.__webglMultisampledFramebuffer=d.createFramebuffer(),Tt.__webglColorRenderbuffer=[],n.bindFramebuffer(36160,Tt.__webglMultisampledFramebuffer);for(let Hn=0;Hn<kt.length;Hn++){const On=kt[Hn];Tt.__webglColorRenderbuffer[Hn]=d.createRenderbuffer(),d.bindRenderbuffer(36161,Tt.__webglColorRenderbuffer[Hn]);const Fn=f.convert(On.format,On.encoding),Ze=f.convert(On.type),Tn=oe(On.internalFormat,Fn,Ze,On.encoding),bn=dn(Ie);d.renderbufferStorageMultisample(36161,bn,Tn,Ie.width,Ie.height),d.framebufferRenderbuffer(36160,36064+Hn,36161,Tt.__webglColorRenderbuffer[Hn])}d.bindRenderbuffer(36161,null),Ie.depthBuffer&&(Tt.__webglDepthRenderbuffer=d.createRenderbuffer(),mn(Tt.__webglDepthRenderbuffer,Ie,!0)),n.bindFramebuffer(36160,null)}}if(_n){n.bindTexture(34067,hn.__webglTexture),Mt(34067,xe,ri);for(let kt=0;kt<6;kt++)jt(Tt.__webglFramebuffer[kt],Ie,xe,36064,34069+kt);fe(xe,ri)&&Ae(34067),n.unbindTexture()}else if(Sn){const kt=Ie.texture;for(let Hn=0,On=kt.length;Hn<On;Hn++){const Fn=kt[Hn],Ze=a.get(Fn);n.bindTexture(3553,Ze.__webglTexture),Mt(3553,Fn,ri),jt(Tt.__webglFramebuffer,Ie,Fn,36064+Hn,3553),fe(Fn,ri)&&Ae(3553)}n.unbindTexture()}else{let kt=3553;(Ie.isWebGL3DRenderTarget||Ie.isWebGLArrayRenderTarget)&&(i?kt=Ie.isWebGL3DRenderTarget?32879:35866:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),n.bindTexture(kt,hn.__webglTexture),Mt(kt,xe,ri),jt(Tt.__webglFramebuffer,Ie,xe,36064,kt),fe(xe,ri)&&Ae(kt),n.unbindTexture()}Ie.depthBuffer&&Dt(Ie)}function Yt(Ie){const xe=ne(Ie)||i,Tt=Ie.isWebGLMultipleRenderTargets===!0?Ie.texture:[Ie.texture];for(let hn=0,_n=Tt.length;hn<_n;hn++){const Sn=Tt[hn];if(fe(Sn,xe)){const ri=Ie.isWebGLCubeRenderTarget?34067:3553,kt=a.get(Sn).__webglTexture;n.bindTexture(ri,kt),Ae(ri),n.unbindTexture()}}}function rn(Ie){if(i&&Ie.samples>0&&Mn(Ie)===!1){const xe=Ie.isWebGLMultipleRenderTargets?Ie.texture:[Ie.texture],Tt=Ie.width,hn=Ie.height;let _n=16384;const Sn=[],ri=Ie.stencilBuffer?33306:36096,kt=a.get(Ie),Hn=Ie.isWebGLMultipleRenderTargets===!0;if(Hn)for(let On=0;On<xe.length;On++)n.bindFramebuffer(36160,kt.__webglMultisampledFramebuffer),d.framebufferRenderbuffer(36160,36064+On,36161,null),n.bindFramebuffer(36160,kt.__webglFramebuffer),d.framebufferTexture2D(36009,36064+On,3553,null,0);n.bindFramebuffer(36008,kt.__webglMultisampledFramebuffer),n.bindFramebuffer(36009,kt.__webglFramebuffer);for(let On=0;On<xe.length;On++){Sn.push(36064+On),Ie.depthBuffer&&Sn.push(ri);const Fn=kt.__ignoreDepthValues!==void 0?kt.__ignoreDepthValues:!1;if(Fn===!1&&(Ie.depthBuffer&&(_n|=256),Ie.stencilBuffer&&(_n|=1024)),Hn&&d.framebufferRenderbuffer(36008,36064,36161,kt.__webglColorRenderbuffer[On]),Fn===!0&&(d.invalidateFramebuffer(36008,[ri]),d.invalidateFramebuffer(36009,[ri])),Hn){const Ze=a.get(xe[On]).__webglTexture;d.framebufferTexture2D(36009,36064,3553,Ze,0)}d.blitFramebuffer(0,0,Tt,hn,0,0,Tt,hn,_n,9728),k&&d.invalidateFramebuffer(36008,Sn)}if(n.bindFramebuffer(36008,null),n.bindFramebuffer(36009,null),Hn)for(let On=0;On<xe.length;On++){n.bindFramebuffer(36160,kt.__webglMultisampledFramebuffer),d.framebufferRenderbuffer(36160,36064+On,36161,kt.__webglColorRenderbuffer[On]);const Fn=a.get(xe[On]).__webglTexture;n.bindFramebuffer(36160,kt.__webglFramebuffer),d.framebufferTexture2D(36009,36064+On,3553,Fn,0)}n.bindFramebuffer(36009,kt.__webglMultisampledFramebuffer)}}function dn(Ie){return Math.min(T,Ie.samples)}function Mn(Ie){const xe=a.get(Ie);return i&&Ie.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&xe.__useRenderToTexture!==!1}function li(Ie){const xe=m.render.frame;O.get(Ie)!==xe&&(O.set(Ie,xe),Ie.update())}function ti(Ie,xe){const Tt=Ie.encoding,hn=Ie.format,_n=Ie.type;return Ie.isCompressedTexture===!0||Ie.isVideoTexture===!0||Ie.format===x_||Tt!==oh&&(Tt===hs?i===!1?e.has("EXT_sRGB")===!0&&hn===Qa?(Ie.format=x_,Ie.minFilter=qs,Ie.generateMipmaps=!1):xe=gv.sRGBToLinear(xe):(hn!==Qa||_n!==wu)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture encoding:",Tt)),xe}this.allocateTextureUnit=Fe,this.resetTextureUnits=Nt,this.setTexture2D=tt,this.setTexture2DArray=Et,this.setTexture3D=xt,this.setTextureCube=Pt,this.rebindTextures=gn,this.setupRenderTarget=wn,this.updateRenderTargetMipmap=Yt,this.updateMultisampleRenderTarget=rn,this.setupDepthRenderbuffer=Dt,this.setupFrameBufferTexture=jt,this.useMultisampledRTT=Mn}function aT(d,e,n){const a=n.isWebGL2;function c(f,m=null){let i;if(f===wu)return 5121;if(f===PE)return 32819;if(f===LE)return 32820;if(f===AE)return 5120;if(f===CE)return 5122;if(f===fv)return 5123;if(f===IE)return 5124;if(f===th)return 5125;if(f===xu)return 5126;if(f===Of)return a?5131:(i=e.get("OES_texture_half_float"),i!==null?i.HALF_FLOAT_OES:null);if(f===RE)return 6406;if(f===Qa)return 6408;if(f===zE)return 6409;if(f===kE)return 6410;if(f===ih)return 6402;if(f===ld)return 34041;if(f===OE)return 6403;if(f===DE)return console.warn("THREE.WebGLRenderer: THREE.RGBFormat has been removed. Use THREE.RGBAFormat instead. https://github.com/mrdoob/three.js/pull/23228"),6408;if(f===x_)return i=e.get("EXT_sRGB"),i!==null?i.SRGB_ALPHA_EXT:null;if(f===FE)return 36244;if(f===BE)return 33319;if(f===NE)return 33320;if(f===UE)return 36249;if(f===o_||f===a_||f===l_||f===c_)if(m===hs)if(i=e.get("WEBGL_compressed_texture_s3tc_srgb"),i!==null){if(f===o_)return i.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(f===a_)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(f===l_)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(f===c_)return i.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(i=e.get("WEBGL_compressed_texture_s3tc"),i!==null){if(f===o_)return i.COMPRESSED_RGB_S3TC_DXT1_EXT;if(f===a_)return i.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(f===l_)return i.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(f===c_)return i.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(f===px||f===mx||f===gx||f===_x)if(i=e.get("WEBGL_compressed_texture_pvrtc"),i!==null){if(f===px)return i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(f===mx)return i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(f===gx)return i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(f===_x)return i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(f===VE)return i=e.get("WEBGL_compressed_texture_etc1"),i!==null?i.COMPRESSED_RGB_ETC1_WEBGL:null;if(f===yx||f===xx)if(i=e.get("WEBGL_compressed_texture_etc"),i!==null){if(f===yx)return m===hs?i.COMPRESSED_SRGB8_ETC2:i.COMPRESSED_RGB8_ETC2;if(f===xx)return m===hs?i.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:i.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(f===vx||f===bx||f===wx||f===Sx||f===Mx||f===Ex||f===Tx||f===Ax||f===Cx||f===Ix||f===Px||f===Lx||f===Rx||f===Dx)if(i=e.get("WEBGL_compressed_texture_astc"),i!==null){if(f===vx)return m===hs?i.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:i.COMPRESSED_RGBA_ASTC_4x4_KHR;if(f===bx)return m===hs?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:i.COMPRESSED_RGBA_ASTC_5x4_KHR;if(f===wx)return m===hs?i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:i.COMPRESSED_RGBA_ASTC_5x5_KHR;if(f===Sx)return m===hs?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:i.COMPRESSED_RGBA_ASTC_6x5_KHR;if(f===Mx)return m===hs?i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:i.COMPRESSED_RGBA_ASTC_6x6_KHR;if(f===Ex)return m===hs?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:i.COMPRESSED_RGBA_ASTC_8x5_KHR;if(f===Tx)return m===hs?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:i.COMPRESSED_RGBA_ASTC_8x6_KHR;if(f===Ax)return m===hs?i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:i.COMPRESSED_RGBA_ASTC_8x8_KHR;if(f===Cx)return m===hs?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:i.COMPRESSED_RGBA_ASTC_10x5_KHR;if(f===Ix)return m===hs?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:i.COMPRESSED_RGBA_ASTC_10x6_KHR;if(f===Px)return m===hs?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:i.COMPRESSED_RGBA_ASTC_10x8_KHR;if(f===Lx)return m===hs?i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:i.COMPRESSED_RGBA_ASTC_10x10_KHR;if(f===Rx)return m===hs?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:i.COMPRESSED_RGBA_ASTC_12x10_KHR;if(f===Dx)return m===hs?i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:i.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(f===zx)if(i=e.get("EXT_texture_compression_bptc"),i!==null){if(f===zx)return m===hs?i.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:i.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;return f===td?a?34042:(i=e.get("WEBGL_depth_texture"),i!==null?i.UNSIGNED_INT_24_8_WEBGL:null):d[f]!==void 0?d[f]:null}return{convert:c}}class lT extends ks{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class Lf extends kr{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Vk={type:"move"};class k0{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Lf,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Lf,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Me,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Me),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Lf,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Me,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Me),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,n,a){let c=null,f=null,m=null;const i=this._targetRay,w=this._grip,E=this._hand;if(e&&n.session.visibilityState!=="visible-blurred")if(i!==null&&(c=n.getPose(e.targetRaySpace,a),c!==null&&(i.matrix.fromArray(c.transform.matrix),i.matrix.decompose(i.position,i.rotation,i.scale),c.linearVelocity?(i.hasLinearVelocity=!0,i.linearVelocity.copy(c.linearVelocity)):i.hasLinearVelocity=!1,c.angularVelocity?(i.hasAngularVelocity=!0,i.angularVelocity.copy(c.angularVelocity)):i.hasAngularVelocity=!1,this.dispatchEvent(Vk))),E&&e.hand){m=!0;for(const B of e.hand.values()){const F=n.getJointPose(B,a);if(E.joints[B.jointName]===void 0){const Y=new Lf;Y.matrixAutoUpdate=!1,Y.visible=!1,E.joints[B.jointName]=Y,E.add(Y)}const H=E.joints[B.jointName];F!==null&&(H.matrix.fromArray(F.transform.matrix),H.matrix.decompose(H.position,H.rotation,H.scale),H.jointRadius=F.radius),H.visible=F!==null}const C=E.joints["index-finger-tip"],T=E.joints["thumb-tip"],I=C.position.distanceTo(T.position),k=.02,O=.005;E.inputState.pinching&&I>k+O?(E.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!E.inputState.pinching&&I<=k-O&&(E.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else w!==null&&e.gripSpace&&(f=n.getPose(e.gripSpace,a),f!==null&&(w.matrix.fromArray(f.transform.matrix),w.matrix.decompose(w.position,w.rotation,w.scale),f.linearVelocity?(w.hasLinearVelocity=!0,w.linearVelocity.copy(f.linearVelocity)):w.hasLinearVelocity=!1,f.angularVelocity?(w.hasAngularVelocity=!0,w.angularVelocity.copy(f.angularVelocity)):w.hasAngularVelocity=!1));return i!==null&&(i.visible=c!==null),w!==null&&(w.visible=f!==null),E!==null&&(E.visible=m!==null),this}}class cT extends ho{constructor(e,n,a,c,f,m,i,w,E,C){if(C=C!==void 0?C:ih,C!==ih&&C!==ld)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");a===void 0&&C===ih&&(a=th),a===void 0&&C===ld&&(a=td),super(null,c,f,m,i,w,C,a,E),this.isDepthTexture=!0,this.image={width:e,height:n},this.magFilter=i!==void 0?i:uo,this.minFilter=w!==void 0?w:uo,this.flipY=!1,this.generateMipmaps=!1}}class Gk extends Mu{constructor(e,n){super();const a=this;let c=null,f=1,m=null,i="local-floor",w=null,E=null,C=null,T=null,I=null,k=null;const O=n.getContextAttributes();let B=null,F=null;const H=[],Y=new Map,K=new ks;K.layers.enable(1),K.viewport=new Wr;const ne=new ks;ne.layers.enable(2),ne.viewport=new Wr;const le=[K,ne],fe=new lT;fe.layers.enable(1),fe.layers.enable(2);let Ae=null,oe=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(it){let tt=H[it];return tt===void 0&&(tt=new k0,H[it]=tt),tt.getTargetRaySpace()},this.getControllerGrip=function(it){let tt=H[it];return tt===void 0&&(tt=new k0,H[it]=tt),tt.getGripSpace()},this.getHand=function(it){let tt=H[it];return tt===void 0&&(tt=new k0,H[it]=tt),tt.getHandSpace()};function ce(it){const tt=Y.get(it.inputSource);tt!==void 0&&tt.dispatchEvent({type:it.type,data:it.inputSource})}function Re(){c.removeEventListener("select",ce),c.removeEventListener("selectstart",ce),c.removeEventListener("selectend",ce),c.removeEventListener("squeeze",ce),c.removeEventListener("squeezestart",ce),c.removeEventListener("squeezeend",ce),c.removeEventListener("end",Re),c.removeEventListener("inputsourceschange",ke),Y.forEach(function(it,tt){it!==void 0&&it.disconnect(tt)}),Y.clear(),Ae=null,oe=null,e.setRenderTarget(B),I=null,T=null,C=null,c=null,F=null,Fe.stop(),a.isPresenting=!1,a.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(it){f=it,a.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(it){i=it,a.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return w||m},this.setReferenceSpace=function(it){w=it},this.getBaseLayer=function(){return T!==null?T:I},this.getBinding=function(){return C},this.getFrame=function(){return k},this.getSession=function(){return c},this.setSession=async function(it){if(c=it,c!==null){if(B=e.getRenderTarget(),c.addEventListener("select",ce),c.addEventListener("selectstart",ce),c.addEventListener("selectend",ce),c.addEventListener("squeeze",ce),c.addEventListener("squeezestart",ce),c.addEventListener("squeezeend",ce),c.addEventListener("end",Re),c.addEventListener("inputsourceschange",ke),O.xrCompatible!==!0&&await n.makeXRCompatible(),c.renderState.layers===void 0||e.capabilities.isWebGL2===!1){const tt={antialias:c.renderState.layers===void 0?O.antialias:!0,alpha:O.alpha,depth:O.depth,stencil:O.stencil,framebufferScaleFactor:f};I=new XRWebGLLayer(c,n,tt),c.updateRenderState({baseLayer:I}),F=new ml(I.framebufferWidth,I.framebufferHeight,{format:Qa,type:wu,encoding:e.outputEncoding})}else{let tt=null,Et=null,xt=null;O.depth&&(xt=O.stencil?35056:33190,tt=O.stencil?ld:ih,Et=O.stencil?td:th);const Pt={colorFormat:e.outputEncoding===hs?35907:32856,depthFormat:xt,scaleFactor:f};C=new XRWebGLBinding(c,n),T=C.createProjectionLayer(Pt),c.updateRenderState({layers:[T]}),F=new ml(T.textureWidth,T.textureHeight,{format:Qa,type:wu,depthTexture:new cT(T.textureWidth,T.textureHeight,Et,void 0,void 0,void 0,void 0,void 0,void 0,tt),stencilBuffer:O.stencil,encoding:e.outputEncoding,samples:O.antialias?4:0});const ln=e.properties.get(F);ln.__ignoreDepthValues=T.ignoreDepthValues}F.isXRRenderTarget=!0,this.setFoveation(1),w=null,m=await c.requestReferenceSpace(i),Fe.setContext(c),Fe.start(),a.isPresenting=!0,a.dispatchEvent({type:"sessionstart"})}};function ke(it){const tt=c.inputSources;for(let Et=0;Et<tt.length;Et++){const xt=tt[Et].handedness==="right"?1:0;Y.set(tt[Et],H[xt])}for(let Et=0;Et<it.removed.length;Et++){const xt=it.removed[Et],Pt=Y.get(xt);Pt&&(Pt.dispatchEvent({type:"disconnected",data:xt}),Y.delete(xt))}for(let Et=0;Et<it.added.length;Et++){const xt=it.added[Et],Pt=Y.get(xt);Pt&&Pt.dispatchEvent({type:"connected",data:xt})}}const Xe=new Me,St=new Me;function Je(it,tt,Et){Xe.setFromMatrixPosition(tt.matrixWorld),St.setFromMatrixPosition(Et.matrixWorld);const xt=Xe.distanceTo(St),Pt=tt.projectionMatrix.elements,ln=Et.projectionMatrix.elements,pn=Pt[14]/(Pt[10]-1),Mt=Pt[14]/(Pt[10]+1),ei=(Pt[9]+1)/Pt[5],oi=(Pt[9]-1)/Pt[5],Wn=(Pt[8]-1)/Pt[0],jt=(ln[8]+1)/ln[0],mn=pn*Wn,qt=pn*jt,Dt=xt/(-Wn+jt),gn=Dt*-Wn;tt.matrixWorld.decompose(it.position,it.quaternion,it.scale),it.translateX(gn),it.translateZ(Dt),it.matrixWorld.compose(it.position,it.quaternion,it.scale),it.matrixWorldInverse.copy(it.matrixWorld).invert();const wn=pn+Dt,Yt=Mt+Dt,rn=mn-gn,dn=qt+(xt-gn),Mn=ei*Mt/Yt*wn,li=oi*Mt/Yt*wn;it.projectionMatrix.makePerspective(rn,dn,Mn,li,wn,Yt)}function It(it,tt){tt===null?it.matrixWorld.copy(it.matrix):it.matrixWorld.multiplyMatrices(tt.matrixWorld,it.matrix),it.matrixWorldInverse.copy(it.matrixWorld).invert()}this.updateCamera=function(it){if(c===null)return;fe.near=ne.near=K.near=it.near,fe.far=ne.far=K.far=it.far,(Ae!==fe.near||oe!==fe.far)&&(c.updateRenderState({depthNear:fe.near,depthFar:fe.far}),Ae=fe.near,oe=fe.far);const tt=it.parent,Et=fe.cameras;It(fe,tt);for(let Pt=0;Pt<Et.length;Pt++)It(Et[Pt],tt);fe.matrixWorld.decompose(fe.position,fe.quaternion,fe.scale),it.position.copy(fe.position),it.quaternion.copy(fe.quaternion),it.scale.copy(fe.scale),it.matrix.copy(fe.matrix),it.matrixWorld.copy(fe.matrixWorld);const xt=it.children;for(let Pt=0,ln=xt.length;Pt<ln;Pt++)xt[Pt].updateMatrixWorld(!0);Et.length===2?Je(fe,K,ne):fe.projectionMatrix.copy(K.projectionMatrix)},this.getCamera=function(){return fe},this.getFoveation=function(){if(T!==null)return T.fixedFoveation;if(I!==null)return I.fixedFoveation},this.setFoveation=function(it){T!==null&&(T.fixedFoveation=it),I!==null&&I.fixedFoveation!==void 0&&(I.fixedFoveation=it)};let ft=null;function Nt(it,tt){if(E=tt.getViewerPose(w||m),k=tt,E!==null){const xt=E.views;I!==null&&(e.setRenderTargetFramebuffer(F,I.framebuffer),e.setRenderTarget(F));let Pt=!1;xt.length!==fe.cameras.length&&(fe.cameras.length=0,Pt=!0);for(let ln=0;ln<xt.length;ln++){const pn=xt[ln];let Mt=null;if(I!==null)Mt=I.getViewport(pn);else{const oi=C.getViewSubImage(T,pn);Mt=oi.viewport,ln===0&&(e.setRenderTargetTextures(F,oi.colorTexture,T.ignoreDepthValues?void 0:oi.depthStencilTexture),e.setRenderTarget(F))}let ei=le[ln];ei===void 0&&(ei=new ks,ei.layers.enable(ln),ei.viewport=new Wr,le[ln]=ei),ei.matrix.fromArray(pn.transform.matrix),ei.projectionMatrix.fromArray(pn.projectionMatrix),ei.viewport.set(Mt.x,Mt.y,Mt.width,Mt.height),ln===0&&fe.matrix.copy(ei.matrix),Pt===!0&&fe.cameras.push(ei)}}const Et=c.inputSources;for(let xt=0;xt<H.length;xt++){const Pt=Et[xt],ln=Y.get(Pt);ln!==void 0&&ln.update(Pt,tt,w||m)}ft&&ft(it,tt),k=null}const Fe=new tT;Fe.setAnimationLoop(Nt),this.setAnimationLoop=function(it){ft=it},this.dispose=function(){}}}function jk(d,e){function n(B,F){B.fogColor.value.copy(F.color),F.isFog?(B.fogNear.value=F.near,B.fogFar.value=F.far):F.isFogExp2&&(B.fogDensity.value=F.density)}function a(B,F,H,Y,K){F.isMeshBasicMaterial||F.isMeshLambertMaterial?c(B,F):F.isMeshToonMaterial?(c(B,F),C(B,F)):F.isMeshPhongMaterial?(c(B,F),E(B,F)):F.isMeshStandardMaterial?(c(B,F),T(B,F),F.isMeshPhysicalMaterial&&I(B,F,K)):F.isMeshMatcapMaterial?(c(B,F),k(B,F)):F.isMeshDepthMaterial?c(B,F):F.isMeshDistanceMaterial?(c(B,F),O(B,F)):F.isMeshNormalMaterial?c(B,F):F.isLineBasicMaterial?(f(B,F),F.isLineDashedMaterial&&m(B,F)):F.isPointsMaterial?i(B,F,H,Y):F.isSpriteMaterial?w(B,F):F.isShadowMaterial?(B.color.value.copy(F.color),B.opacity.value=F.opacity):F.isShaderMaterial&&(F.uniformsNeedUpdate=!1)}function c(B,F){B.opacity.value=F.opacity,F.color&&B.diffuse.value.copy(F.color),F.emissive&&B.emissive.value.copy(F.emissive).multiplyScalar(F.emissiveIntensity),F.map&&(B.map.value=F.map),F.alphaMap&&(B.alphaMap.value=F.alphaMap),F.bumpMap&&(B.bumpMap.value=F.bumpMap,B.bumpScale.value=F.bumpScale,F.side===fl&&(B.bumpScale.value*=-1)),F.displacementMap&&(B.displacementMap.value=F.displacementMap,B.displacementScale.value=F.displacementScale,B.displacementBias.value=F.displacementBias),F.emissiveMap&&(B.emissiveMap.value=F.emissiveMap),F.normalMap&&(B.normalMap.value=F.normalMap,B.normalScale.value.copy(F.normalScale),F.side===fl&&B.normalScale.value.negate()),F.specularMap&&(B.specularMap.value=F.specularMap),F.alphaTest>0&&(B.alphaTest.value=F.alphaTest);const H=e.get(F).envMap;if(H&&(B.envMap.value=H,B.flipEnvMap.value=H.isCubeTexture&&H.isRenderTargetTexture===!1?-1:1,B.reflectivity.value=F.reflectivity,B.ior.value=F.ior,B.refractionRatio.value=F.refractionRatio),F.lightMap){B.lightMap.value=F.lightMap;const ne=d.physicallyCorrectLights!==!0?Math.PI:1;B.lightMapIntensity.value=F.lightMapIntensity*ne}F.aoMap&&(B.aoMap.value=F.aoMap,B.aoMapIntensity.value=F.aoMapIntensity);let Y;F.map?Y=F.map:F.specularMap?Y=F.specularMap:F.displacementMap?Y=F.displacementMap:F.normalMap?Y=F.normalMap:F.bumpMap?Y=F.bumpMap:F.roughnessMap?Y=F.roughnessMap:F.metalnessMap?Y=F.metalnessMap:F.alphaMap?Y=F.alphaMap:F.emissiveMap?Y=F.emissiveMap:F.clearcoatMap?Y=F.clearcoatMap:F.clearcoatNormalMap?Y=F.clearcoatNormalMap:F.clearcoatRoughnessMap?Y=F.clearcoatRoughnessMap:F.iridescenceMap?Y=F.iridescenceMap:F.iridescenceThicknessMap?Y=F.iridescenceThicknessMap:F.specularIntensityMap?Y=F.specularIntensityMap:F.specularColorMap?Y=F.specularColorMap:F.transmissionMap?Y=F.transmissionMap:F.thicknessMap?Y=F.thicknessMap:F.sheenColorMap?Y=F.sheenColorMap:F.sheenRoughnessMap&&(Y=F.sheenRoughnessMap),Y!==void 0&&(Y.isWebGLRenderTarget&&(Y=Y.texture),Y.matrixAutoUpdate===!0&&Y.updateMatrix(),B.uvTransform.value.copy(Y.matrix));let K;F.aoMap?K=F.aoMap:F.lightMap&&(K=F.lightMap),K!==void 0&&(K.isWebGLRenderTarget&&(K=K.texture),K.matrixAutoUpdate===!0&&K.updateMatrix(),B.uv2Transform.value.copy(K.matrix))}function f(B,F){B.diffuse.value.copy(F.color),B.opacity.value=F.opacity}function m(B,F){B.dashSize.value=F.dashSize,B.totalSize.value=F.dashSize+F.gapSize,B.scale.value=F.scale}function i(B,F,H,Y){B.diffuse.value.copy(F.color),B.opacity.value=F.opacity,B.size.value=F.size*H,B.scale.value=Y*.5,F.map&&(B.map.value=F.map),F.alphaMap&&(B.alphaMap.value=F.alphaMap),F.alphaTest>0&&(B.alphaTest.value=F.alphaTest);let K;F.map?K=F.map:F.alphaMap&&(K=F.alphaMap),K!==void 0&&(K.matrixAutoUpdate===!0&&K.updateMatrix(),B.uvTransform.value.copy(K.matrix))}function w(B,F){B.diffuse.value.copy(F.color),B.opacity.value=F.opacity,B.rotation.value=F.rotation,F.map&&(B.map.value=F.map),F.alphaMap&&(B.alphaMap.value=F.alphaMap),F.alphaTest>0&&(B.alphaTest.value=F.alphaTest);let H;F.map?H=F.map:F.alphaMap&&(H=F.alphaMap),H!==void 0&&(H.matrixAutoUpdate===!0&&H.updateMatrix(),B.uvTransform.value.copy(H.matrix))}function E(B,F){B.specular.value.copy(F.specular),B.shininess.value=Math.max(F.shininess,1e-4)}function C(B,F){F.gradientMap&&(B.gradientMap.value=F.gradientMap)}function T(B,F){B.roughness.value=F.roughness,B.metalness.value=F.metalness,F.roughnessMap&&(B.roughnessMap.value=F.roughnessMap),F.metalnessMap&&(B.metalnessMap.value=F.metalnessMap),e.get(F).envMap&&(B.envMapIntensity.value=F.envMapIntensity)}function I(B,F,H){B.ior.value=F.ior,F.sheen>0&&(B.sheenColor.value.copy(F.sheenColor).multiplyScalar(F.sheen),B.sheenRoughness.value=F.sheenRoughness,F.sheenColorMap&&(B.sheenColorMap.value=F.sheenColorMap),F.sheenRoughnessMap&&(B.sheenRoughnessMap.value=F.sheenRoughnessMap)),F.clearcoat>0&&(B.clearcoat.value=F.clearcoat,B.clearcoatRoughness.value=F.clearcoatRoughness,F.clearcoatMap&&(B.clearcoatMap.value=F.clearcoatMap),F.clearcoatRoughnessMap&&(B.clearcoatRoughnessMap.value=F.clearcoatRoughnessMap),F.clearcoatNormalMap&&(B.clearcoatNormalScale.value.copy(F.clearcoatNormalScale),B.clearcoatNormalMap.value=F.clearcoatNormalMap,F.side===fl&&B.clearcoatNormalScale.value.negate())),F.iridescence>0&&(B.iridescence.value=F.iridescence,B.iridescenceIOR.value=F.iridescenceIOR,B.iridescenceThicknessMinimum.value=F.iridescenceThicknessRange[0],B.iridescenceThicknessMaximum.value=F.iridescenceThicknessRange[1],F.iridescenceMap&&(B.iridescenceMap.value=F.iridescenceMap),F.iridescenceThicknessMap&&(B.iridescenceThicknessMap.value=F.iridescenceThicknessMap)),F.transmission>0&&(B.transmission.value=F.transmission,B.transmissionSamplerMap.value=H.texture,B.transmissionSamplerSize.value.set(H.width,H.height),F.transmissionMap&&(B.transmissionMap.value=F.transmissionMap),B.thickness.value=F.thickness,F.thicknessMap&&(B.thicknessMap.value=F.thicknessMap),B.attenuationDistance.value=F.attenuationDistance,B.attenuationColor.value.copy(F.attenuationColor)),B.specularIntensity.value=F.specularIntensity,B.specularColor.value.copy(F.specularColor),F.specularIntensityMap&&(B.specularIntensityMap.value=F.specularIntensityMap),F.specularColorMap&&(B.specularColorMap.value=F.specularColorMap)}function k(B,F){F.matcap&&(B.matcap.value=F.matcap)}function O(B,F){B.referencePosition.value.copy(F.referencePosition),B.nearDistance.value=F.nearDistance,B.farDistance.value=F.farDistance}return{refreshFogUniforms:n,refreshMaterialUniforms:a}}function Wk(){const d=um("canvas");return d.style.display="block",d}function wv(d={}){this.isWebGLRenderer=!0;const e=d.canvas!==void 0?d.canvas:Wk(),n=d.context!==void 0?d.context:null,a=d.depth!==void 0?d.depth:!0,c=d.stencil!==void 0?d.stencil:!0,f=d.antialias!==void 0?d.antialias:!1,m=d.premultipliedAlpha!==void 0?d.premultipliedAlpha:!0,i=d.preserveDrawingBuffer!==void 0?d.preserveDrawingBuffer:!1,w=d.powerPreference!==void 0?d.powerPreference:"default",E=d.failIfMajorPerformanceCaveat!==void 0?d.failIfMajorPerformanceCaveat:!1;let C;n!==null?C=n.getContextAttributes().alpha:C=d.alpha!==void 0?d.alpha:!1;let T=null,I=null;const k=[],O=[];this.domElement=e,this.debug={checkShaderErrors:!0},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=oh,this.physicallyCorrectLights=!1,this.toneMapping=sc,this.toneMappingExposure=1,Object.defineProperties(this,{gammaFactor:{get:function(){return console.warn("THREE.WebGLRenderer: .gammaFactor has been removed."),2},set:function(){console.warn("THREE.WebGLRenderer: .gammaFactor has been removed.")}}});const B=this;let F=!1,H=0,Y=0,K=null,ne=-1,le=null;const fe=new Wr,Ae=new Wr;let oe=null,ce=e.width,Re=e.height,ke=1,Xe=null,St=null;const Je=new Wr(0,0,ce,Re),It=new Wr(0,0,ce,Re);let ft=!1;const Nt=new U_;let Fe=!1,it=!1,tt=null;const Et=new sr,xt=new tn,Pt=new Me,ln={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function pn(){return K===null?ke:1}let Mt=n;function ei(ve,Qe){for(let lt=0;lt<ve.length;lt++){const mt=ve[lt],Gt=e.getContext(mt,Qe);if(Gt!==null)return Gt}return null}try{const ve={alpha:!0,depth:a,stencil:c,antialias:f,premultipliedAlpha:m,preserveDrawingBuffer:i,powerPreference:w,failIfMajorPerformanceCaveat:E};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${k_}`),e.addEventListener("webglcontextlost",Ze,!1),e.addEventListener("webglcontextrestored",Tn,!1),e.addEventListener("webglcontextcreationerror",bn,!1),Mt===null){const Qe=["webgl2","webgl","experimental-webgl"];if(B.isWebGL1Renderer===!0&&Qe.shift(),Mt=ei(Qe,ve),Mt===null)throw ei(Qe)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}Mt.getShaderPrecisionFormat===void 0&&(Mt.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(ve){throw console.error("THREE.WebGLRenderer: "+ve.message),ve}let oi,Wn,jt,mn,qt,Dt,gn,wn,Yt,rn,dn,Mn,li,ti,Ie,xe,Tt,hn,_n,Sn,ri,kt,Hn;function On(){oi=new oz(Mt),Wn=new ez(Mt,oi,d),oi.init(Wn),kt=new aT(Mt,oi,Wn),jt=new Nk(Mt,oi,Wn),mn=new cz,qt=new Ak,Dt=new Uk(Mt,oi,jt,qt,Wn,kt,mn),gn=new nz(B),wn=new sz(B),Yt=new b3(Mt,Wn),Hn=new KD(Mt,oi,Yt,Wn),rn=new az(Mt,Yt,mn,Hn),dn=new fz(Mt,rn,Yt,mn),_n=new dz(Mt,Wn,Dt),xe=new tz(qt),Mn=new Tk(B,gn,wn,oi,Wn,Hn,xe),li=new jk(B,qt),ti=new Ik,Ie=new kk(oi,Wn),hn=new JD(B,gn,jt,dn,C,m),Tt=new Bk(B,dn,Wn),Sn=new QD(Mt,oi,mn,Wn),ri=new lz(Mt,oi,mn,Wn),mn.programs=Mn.programs,B.capabilities=Wn,B.extensions=oi,B.properties=qt,B.renderLists=ti,B.shadowMap=Tt,B.state=jt,B.info=mn}On();const Fn=new Gk(B,Mt);this.xr=Fn,this.getContext=function(){return Mt},this.getContextAttributes=function(){return Mt.getContextAttributes()},this.forceContextLoss=function(){const ve=oi.get("WEBGL_lose_context");ve&&ve.loseContext()},this.forceContextRestore=function(){const ve=oi.get("WEBGL_lose_context");ve&&ve.restoreContext()},this.getPixelRatio=function(){return ke},this.setPixelRatio=function(ve){ve!==void 0&&(ke=ve,this.setSize(ce,Re,!1))},this.getSize=function(ve){return ve.set(ce,Re)},this.setSize=function(ve,Qe,lt){if(Fn.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}ce=ve,Re=Qe,e.width=Math.floor(ve*ke),e.height=Math.floor(Qe*ke),lt!==!1&&(e.style.width=ve+"px",e.style.height=Qe+"px"),this.setViewport(0,0,ve,Qe)},this.getDrawingBufferSize=function(ve){return ve.set(ce*ke,Re*ke).floor()},this.setDrawingBufferSize=function(ve,Qe,lt){ce=ve,Re=Qe,ke=lt,e.width=Math.floor(ve*lt),e.height=Math.floor(Qe*lt),this.setViewport(0,0,ve,Qe)},this.getCurrentViewport=function(ve){return ve.copy(fe)},this.getViewport=function(ve){return ve.copy(Je)},this.setViewport=function(ve,Qe,lt,mt){ve.isVector4?Je.set(ve.x,ve.y,ve.z,ve.w):Je.set(ve,Qe,lt,mt),jt.viewport(fe.copy(Je).multiplyScalar(ke).floor())},this.getScissor=function(ve){return ve.copy(It)},this.setScissor=function(ve,Qe,lt,mt){ve.isVector4?It.set(ve.x,ve.y,ve.z,ve.w):It.set(ve,Qe,lt,mt),jt.scissor(Ae.copy(It).multiplyScalar(ke).floor())},this.getScissorTest=function(){return ft},this.setScissorTest=function(ve){jt.setScissorTest(ft=ve)},this.setOpaqueSort=function(ve){Xe=ve},this.setTransparentSort=function(ve){St=ve},this.getClearColor=function(ve){return ve.copy(hn.getClearColor())},this.setClearColor=function(){hn.setClearColor.apply(hn,arguments)},this.getClearAlpha=function(){return hn.getClearAlpha()},this.setClearAlpha=function(){hn.setClearAlpha.apply(hn,arguments)},this.clear=function(ve=!0,Qe=!0,lt=!0){let mt=0;ve&&(mt|=16384),Qe&&(mt|=256),lt&&(mt|=1024),Mt.clear(mt)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){e.removeEventListener("webglcontextlost",Ze,!1),e.removeEventListener("webglcontextrestored",Tn,!1),e.removeEventListener("webglcontextcreationerror",bn,!1),ti.dispose(),Ie.dispose(),qt.dispose(),gn.dispose(),wn.dispose(),dn.dispose(),Hn.dispose(),Mn.dispose(),Fn.dispose(),Fn.removeEventListener("sessionstart",se),Fn.removeEventListener("sessionend",ye),tt&&(tt.dispose(),tt=null),De.stop()};function Ze(ve){ve.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),F=!0}function Tn(){console.log("THREE.WebGLRenderer: Context Restored."),F=!1;const ve=mn.autoReset,Qe=Tt.enabled,lt=Tt.autoUpdate,mt=Tt.needsUpdate,Gt=Tt.type;On(),mn.autoReset=ve,Tt.enabled=Qe,Tt.autoUpdate=lt,Tt.needsUpdate=mt,Tt.type=Gt}function bn(ve){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",ve.statusMessage)}function We(ve){const Qe=ve.target;Qe.removeEventListener("dispose",We),bt(Qe)}function bt(ve){un(ve),qt.remove(ve)}function un(ve){const Qe=qt.get(ve).programs;Qe!==void 0&&(Qe.forEach(function(lt){Mn.releaseProgram(lt)}),ve.isShaderMaterial&&Mn.releaseShaderCache(ve))}this.renderBufferDirect=function(ve,Qe,lt,mt,Gt,$n){Qe===null&&(Qe=ln);const Yn=Gt.isMesh&&Gt.matrixWorld.determinant()<0,bi=Kt(ve,Qe,lt,mt,Gt);jt.setMaterial(mt,Yn);let ui=lt.index;const ai=lt.attributes.position;if(ui===null){if(ai===void 0||ai.count===0)return}else if(ui.count===0)return;let Ni=1;mt.wireframe===!0&&(ui=rn.getWireframeAttribute(lt),Ni=2),Hn.setup(Gt,mt,bi,lt,ui);let Qi,Cr=Sn;ui!==null&&(Qi=Yt.get(ui),Cr=ri,Cr.setIndex(Qi));const ki=ui!==null?ui.count:ai.count,ea=lt.drawRange.start*Ni,Xs=lt.drawRange.count*Ni,$s=$n!==null?$n.start*Ni:0,Vi=$n!==null?$n.count*Ni:1/0,Ur=Math.max(ea,$s),er=Math.min(ki,ea+Xs,$s+Vi)-1,tr=Math.max(0,er-Ur+1);if(tr!==0){if(Gt.isMesh)mt.wireframe===!0?(jt.setLineWidth(mt.wireframeLinewidth*pn()),Cr.setMode(1)):Cr.setMode(4);else if(Gt.isLine){let po=mt.linewidth;po===void 0&&(po=1),jt.setLineWidth(po*pn()),Gt.isLineSegments?Cr.setMode(1):Gt.isLineLoop?Cr.setMode(2):Cr.setMode(3)}else Gt.isPoints?Cr.setMode(0):Gt.isSprite&&Cr.setMode(4);if(Gt.isInstancedMesh)Cr.renderInstances(Ur,tr,Gt.count);else if(lt.isInstancedBufferGeometry){const po=Math.min(lt.instanceCount,lt._maxInstanceCount);Cr.renderInstances(Ur,tr,po)}else Cr.render(Ur,tr)}},this.compile=function(ve,Qe){I=Ie.get(ve),I.init(),O.push(I),ve.traverseVisible(function(lt){lt.isLight&&lt.layers.test(Qe.layers)&&(I.pushLight(lt),lt.castShadow&&I.pushShadow(lt))}),I.setupLights(B.physicallyCorrectLights),ve.traverse(function(lt){const mt=lt.material;if(mt)if(Array.isArray(mt))for(let Gt=0;Gt<mt.length;Gt++){const $n=mt[Gt];Zt($n,ve,lt)}else Zt(mt,ve,lt)}),O.pop(),I=null};let ue=null;function te(ve){ue&&ue(ve)}function se(){De.stop()}function ye(){De.start()}const De=new tT;De.setAnimationLoop(te),typeof self<"u"&&De.setContext(self),this.setAnimationLoop=function(ve){ue=ve,Fn.setAnimationLoop(ve),ve===null?De.stop():De.start()},Fn.addEventListener("sessionstart",se),Fn.addEventListener("sessionend",ye),this.render=function(ve,Qe){if(Qe!==void 0&&Qe.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(F===!0)return;ve.autoUpdate===!0&&ve.updateMatrixWorld(),Qe.parent===null&&Qe.updateMatrixWorld(),Fn.enabled===!0&&Fn.isPresenting===!0&&(Fn.cameraAutoUpdate===!0&&Fn.updateCamera(Qe),Qe=Fn.getCamera()),ve.isScene===!0&&ve.onBeforeRender(B,ve,Qe,K),I=Ie.get(ve,O.length),I.init(),O.push(I),Et.multiplyMatrices(Qe.projectionMatrix,Qe.matrixWorldInverse),Nt.setFromProjectionMatrix(Et),it=this.localClippingEnabled,Fe=xe.init(this.clippingPlanes,it,Qe),T=ti.get(ve,k.length),T.init(),k.push(T),je(ve,Qe,0,B.sortObjects),T.finish(),B.sortObjects===!0&&T.sort(Xe,St),Fe===!0&&xe.beginShadows();const lt=I.state.shadowsArray;if(Tt.render(lt,ve,Qe),Fe===!0&&xe.endShadows(),this.info.autoReset===!0&&this.info.reset(),hn.render(T,ve),I.setupLights(B.physicallyCorrectLights),Qe.isArrayCamera){const mt=Qe.cameras;for(let Gt=0,$n=mt.length;Gt<$n;Gt++){const Yn=mt[Gt];rt(T,ve,Yn,Yn.viewport)}}else rt(T,ve,Qe);K!==null&&(Dt.updateMultisampleRenderTarget(K),Dt.updateRenderTargetMipmap(K)),ve.isScene===!0&&ve.onAfterRender(B,ve,Qe),Hn.resetDefaultState(),ne=-1,le=null,O.pop(),O.length>0?I=O[O.length-1]:I=null,k.pop(),k.length>0?T=k[k.length-1]:T=null};function je(ve,Qe,lt,mt){if(ve.visible===!1)return;if(ve.layers.test(Qe.layers)){if(ve.isGroup)lt=ve.renderOrder;else if(ve.isLOD)ve.autoUpdate===!0&&ve.update(Qe);else if(ve.isLight)I.pushLight(ve),ve.castShadow&&I.pushShadow(ve);else if(ve.isSprite){if(!ve.frustumCulled||Nt.intersectsSprite(ve)){mt&&Pt.setFromMatrixPosition(ve.matrixWorld).applyMatrix4(Et);const Yn=dn.update(ve),bi=ve.material;bi.visible&&T.push(ve,Yn,bi,lt,Pt.z,null)}}else if((ve.isMesh||ve.isLine||ve.isPoints)&&(ve.isSkinnedMesh&&ve.skeleton.frame!==mn.render.frame&&(ve.skeleton.update(),ve.skeleton.frame=mn.render.frame),!ve.frustumCulled||Nt.intersectsObject(ve))){mt&&Pt.setFromMatrixPosition(ve.matrixWorld).applyMatrix4(Et);const Yn=dn.update(ve),bi=ve.material;if(Array.isArray(bi)){const ui=Yn.groups;for(let ai=0,Ni=ui.length;ai<Ni;ai++){const Qi=ui[ai],Cr=bi[Qi.materialIndex];Cr&&Cr.visible&&T.push(ve,Yn,Cr,lt,Pt.z,Qi)}}else bi.visible&&T.push(ve,Yn,bi,lt,Pt.z,null)}}const $n=ve.children;for(let Yn=0,bi=$n.length;Yn<bi;Yn++)je($n[Yn],Qe,lt,mt)}function rt(ve,Qe,lt,mt){const Gt=ve.opaque,$n=ve.transmissive,Yn=ve.transparent;I.setupLightsView(lt),$n.length>0&&st(Gt,Qe,lt),mt&&jt.viewport(fe.copy(mt)),Gt.length>0&&He(Gt,Qe,lt),$n.length>0&&He($n,Qe,lt),Yn.length>0&&He(Yn,Qe,lt),jt.buffers.depth.setTest(!0),jt.buffers.depth.setMask(!0),jt.buffers.color.setMask(!0),jt.setPolygonOffset(!1)}function st(ve,Qe,lt){const mt=Wn.isWebGL2;tt===null&&(tt=new ml(1,1,{generateMipmaps:!0,type:oi.has("EXT_color_buffer_half_float")?Of:wu,minFilter:_d,samples:mt&&f===!0?4:0})),B.getDrawingBufferSize(xt),mt?tt.setSize(xt.x,xt.y):tt.setSize(v_(xt.x),v_(xt.y));const Gt=B.getRenderTarget();B.setRenderTarget(tt),B.clear();const $n=B.toneMapping;B.toneMapping=sc,He(ve,Qe,lt),B.toneMapping=$n,Dt.updateMultisampleRenderTarget(tt),Dt.updateRenderTargetMipmap(tt),B.setRenderTarget(Gt)}function He(ve,Qe,lt){const mt=Qe.isScene===!0?Qe.overrideMaterial:null;for(let Gt=0,$n=ve.length;Gt<$n;Gt++){const Yn=ve[Gt],bi=Yn.object,ui=Yn.geometry,ai=mt===null?Yn.material:mt,Ni=Yn.group;bi.layers.test(lt.layers)&&pt(bi,Qe,lt,ui,ai,Ni)}}function pt(ve,Qe,lt,mt,Gt,$n){ve.onBeforeRender(B,Qe,lt,mt,Gt,$n),ve.modelViewMatrix.multiplyMatrices(lt.matrixWorldInverse,ve.matrixWorld),ve.normalMatrix.getNormalMatrix(ve.modelViewMatrix),Gt.onBeforeRender(B,Qe,lt,mt,ve,$n),Gt.transparent===!0&&Gt.side===ad?(Gt.side=fl,Gt.needsUpdate=!0,B.renderBufferDirect(lt,Qe,mt,Gt,ve,$n),Gt.side=od,Gt.needsUpdate=!0,B.renderBufferDirect(lt,Qe,mt,Gt,ve,$n),Gt.side=ad):B.renderBufferDirect(lt,Qe,mt,Gt,ve,$n),ve.onAfterRender(B,Qe,lt,mt,Gt,$n)}function Zt(ve,Qe,lt){Qe.isScene!==!0&&(Qe=ln);const mt=qt.get(ve),Gt=I.state.lights,$n=I.state.shadowsArray,Yn=Gt.state.version,bi=Mn.getParameters(ve,Gt.state,$n,Qe,lt),ui=Mn.getProgramCacheKey(bi);let ai=mt.programs;mt.environment=ve.isMeshStandardMaterial?Qe.environment:null,mt.fog=Qe.fog,mt.envMap=(ve.isMeshStandardMaterial?wn:gn).get(ve.envMap||mt.environment),ai===void 0&&(ve.addEventListener("dispose",We),ai=new Map,mt.programs=ai);let Ni=ai.get(ui);if(Ni!==void 0){if(mt.currentProgram===Ni&&mt.lightsStateVersion===Yn)return on(ve,bi),Ni}else bi.uniforms=Mn.getUniforms(ve),ve.onBuild(lt,bi,B),ve.onBeforeCompile(bi,B),Ni=Mn.acquireProgram(bi,ui),ai.set(ui,Ni),mt.uniforms=bi.uniforms;const Qi=mt.uniforms;(!ve.isShaderMaterial&&!ve.isRawShaderMaterial||ve.clipping===!0)&&(Qi.clippingPlanes=xe.uniform),on(ve,bi),mt.needsLights=ci(ve),mt.lightsStateVersion=Yn,mt.needsLights&&(Qi.ambientLightColor.value=Gt.state.ambient,Qi.lightProbe.value=Gt.state.probe,Qi.directionalLights.value=Gt.state.directional,Qi.directionalLightShadows.value=Gt.state.directionalShadow,Qi.spotLights.value=Gt.state.spot,Qi.spotLightShadows.value=Gt.state.spotShadow,Qi.rectAreaLights.value=Gt.state.rectArea,Qi.ltc_1.value=Gt.state.rectAreaLTC1,Qi.ltc_2.value=Gt.state.rectAreaLTC2,Qi.pointLights.value=Gt.state.point,Qi.pointLightShadows.value=Gt.state.pointShadow,Qi.hemisphereLights.value=Gt.state.hemi,Qi.directionalShadowMap.value=Gt.state.directionalShadowMap,Qi.directionalShadowMatrix.value=Gt.state.directionalShadowMatrix,Qi.spotShadowMap.value=Gt.state.spotShadowMap,Qi.spotShadowMatrix.value=Gt.state.spotShadowMatrix,Qi.pointShadowMap.value=Gt.state.pointShadowMap,Qi.pointShadowMatrix.value=Gt.state.pointShadowMatrix);const Cr=Ni.getUniforms(),ki=f_.seqWithValue(Cr.seq,Qi);return mt.currentProgram=Ni,mt.uniformsList=ki,Ni}function on(ve,Qe){const lt=qt.get(ve);lt.outputEncoding=Qe.outputEncoding,lt.instancing=Qe.instancing,lt.skinning=Qe.skinning,lt.morphTargets=Qe.morphTargets,lt.morphNormals=Qe.morphNormals,lt.morphColors=Qe.morphColors,lt.morphTargetsCount=Qe.morphTargetsCount,lt.numClippingPlanes=Qe.numClippingPlanes,lt.numIntersection=Qe.numClipIntersection,lt.vertexAlphas=Qe.vertexAlphas,lt.vertexTangents=Qe.vertexTangents,lt.toneMapping=Qe.toneMapping}function Kt(ve,Qe,lt,mt,Gt){Qe.isScene!==!0&&(Qe=ln),Dt.resetTextureUnits();const $n=Qe.fog,Yn=mt.isMeshStandardMaterial?Qe.environment:null,bi=K===null?B.outputEncoding:K.isXRRenderTarget===!0?K.texture.encoding:oh,ui=(mt.isMeshStandardMaterial?wn:gn).get(mt.envMap||Yn),ai=mt.vertexColors===!0&&!!lt.attributes.color&&lt.attributes.color.itemSize===4,Ni=!!mt.normalMap&&!!lt.attributes.tangent,Qi=!!lt.morphAttributes.position,Cr=!!lt.morphAttributes.normal,ki=!!lt.morphAttributes.color,ea=mt.toneMapped?B.toneMapping:sc,Xs=lt.morphAttributes.position||lt.morphAttributes.normal||lt.morphAttributes.color,$s=Xs!==void 0?Xs.length:0,Vi=qt.get(mt),Ur=I.state.lights;if(Fe===!0&&(it===!0||ve!==le)){const Ci=ve===le&&mt.id===ne;xe.setState(mt,ve,Ci)}let er=!1;mt.version===Vi.__version?(Vi.needsLights&&Vi.lightsStateVersion!==Ur.state.version||Vi.outputEncoding!==bi||Gt.isInstancedMesh&&Vi.instancing===!1||!Gt.isInstancedMesh&&Vi.instancing===!0||Gt.isSkinnedMesh&&Vi.skinning===!1||!Gt.isSkinnedMesh&&Vi.skinning===!0||Vi.envMap!==ui||mt.fog===!0&&Vi.fog!==$n||Vi.numClippingPlanes!==void 0&&(Vi.numClippingPlanes!==xe.numPlanes||Vi.numIntersection!==xe.numIntersection)||Vi.vertexAlphas!==ai||Vi.vertexTangents!==Ni||Vi.morphTargets!==Qi||Vi.morphNormals!==Cr||Vi.morphColors!==ki||Vi.toneMapping!==ea||Wn.isWebGL2===!0&&Vi.morphTargetsCount!==$s)&&(er=!0):(er=!0,Vi.__version=mt.version);let tr=Vi.currentProgram;er===!0&&(tr=Zt(mt,Qe,Gt));let po=!1,Es=!1,Ir=!1;const Zi=tr.getUniforms(),ct=Vi.uniforms;if(jt.useProgram(tr.program)&&(po=!0,Es=!0,Ir=!0),mt.id!==ne&&(ne=mt.id,Es=!0),po||le!==ve){if(Zi.setValue(Mt,"projectionMatrix",ve.projectionMatrix),Wn.logarithmicDepthBuffer&&Zi.setValue(Mt,"logDepthBufFC",2/(Math.log(ve.far+1)/Math.LN2)),le!==ve&&(le=ve,Es=!0,Ir=!0),mt.isShaderMaterial||mt.isMeshPhongMaterial||mt.isMeshToonMaterial||mt.isMeshStandardMaterial||mt.envMap){const Ci=Zi.map.cameraPosition;Ci!==void 0&&Ci.setValue(Mt,Pt.setFromMatrixPosition(ve.matrixWorld))}(mt.isMeshPhongMaterial||mt.isMeshToonMaterial||mt.isMeshLambertMaterial||mt.isMeshBasicMaterial||mt.isMeshStandardMaterial||mt.isShaderMaterial)&&Zi.setValue(Mt,"isOrthographic",ve.isOrthographicCamera===!0),(mt.isMeshPhongMaterial||mt.isMeshToonMaterial||mt.isMeshLambertMaterial||mt.isMeshBasicMaterial||mt.isMeshStandardMaterial||mt.isShaderMaterial||mt.isShadowMaterial||Gt.isSkinnedMesh)&&Zi.setValue(Mt,"viewMatrix",ve.matrixWorldInverse)}if(Gt.isSkinnedMesh){Zi.setOptional(Mt,Gt,"bindMatrix"),Zi.setOptional(Mt,Gt,"bindMatrixInverse");const Ci=Gt.skeleton;Ci&&(Wn.floatVertexTextures?(Ci.boneTexture===null&&Ci.computeBoneTexture(),Zi.setValue(Mt,"boneTexture",Ci.boneTexture,Dt),Zi.setValue(Mt,"boneTextureSize",Ci.boneTextureSize)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}const Ri=lt.morphAttributes;return(Ri.position!==void 0||Ri.normal!==void 0||Ri.color!==void 0&&Wn.isWebGL2===!0)&&_n.update(Gt,lt,mt,tr),(Es||Vi.receiveShadow!==Gt.receiveShadow)&&(Vi.receiveShadow=Gt.receiveShadow,Zi.setValue(Mt,"receiveShadow",Gt.receiveShadow)),Es&&(Zi.setValue(Mt,"toneMappingExposure",B.toneMappingExposure),Vi.needsLights&&xi(ct,Ir),$n&&mt.fog===!0&&li.refreshFogUniforms(ct,$n),li.refreshMaterialUniforms(ct,mt,ke,Re,tt),f_.upload(Mt,Vi.uniformsList,ct,Dt)),mt.isShaderMaterial&&mt.uniformsNeedUpdate===!0&&(f_.upload(Mt,Vi.uniformsList,ct,Dt),mt.uniformsNeedUpdate=!1),mt.isSpriteMaterial&&Zi.setValue(Mt,"center",Gt.center),Zi.setValue(Mt,"modelViewMatrix",Gt.modelViewMatrix),Zi.setValue(Mt,"normalMatrix",Gt.normalMatrix),Zi.setValue(Mt,"modelMatrix",Gt.matrixWorld),tr}function xi(ve,Qe){ve.ambientLightColor.needsUpdate=Qe,ve.lightProbe.needsUpdate=Qe,ve.directionalLights.needsUpdate=Qe,ve.directionalLightShadows.needsUpdate=Qe,ve.pointLights.needsUpdate=Qe,ve.pointLightShadows.needsUpdate=Qe,ve.spotLights.needsUpdate=Qe,ve.spotLightShadows.needsUpdate=Qe,ve.rectAreaLights.needsUpdate=Qe,ve.hemisphereLights.needsUpdate=Qe}function ci(ve){return ve.isMeshLambertMaterial||ve.isMeshToonMaterial||ve.isMeshPhongMaterial||ve.isMeshStandardMaterial||ve.isShadowMaterial||ve.isShaderMaterial&&ve.lights===!0}this.getActiveCubeFace=function(){return H},this.getActiveMipmapLevel=function(){return Y},this.getRenderTarget=function(){return K},this.setRenderTargetTextures=function(ve,Qe,lt){qt.get(ve.texture).__webglTexture=Qe,qt.get(ve.depthTexture).__webglTexture=lt;const mt=qt.get(ve);mt.__hasExternalTextures=!0,mt.__hasExternalTextures&&(mt.__autoAllocateDepthBuffer=lt===void 0,mt.__autoAllocateDepthBuffer||oi.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),mt.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(ve,Qe){const lt=qt.get(ve);lt.__webglFramebuffer=Qe,lt.__useDefaultFramebuffer=Qe===void 0},this.setRenderTarget=function(ve,Qe=0,lt=0){K=ve,H=Qe,Y=lt;let mt=!0;if(ve){const ui=qt.get(ve);ui.__useDefaultFramebuffer!==void 0?(jt.bindFramebuffer(36160,null),mt=!1):ui.__webglFramebuffer===void 0?Dt.setupRenderTarget(ve):ui.__hasExternalTextures&&Dt.rebindTextures(ve,qt.get(ve.texture).__webglTexture,qt.get(ve.depthTexture).__webglTexture)}let Gt=null,$n=!1,Yn=!1;if(ve){const ui=ve.texture;(ui.isData3DTexture||ui.isDataArrayTexture)&&(Yn=!0);const ai=qt.get(ve).__webglFramebuffer;ve.isWebGLCubeRenderTarget?(Gt=ai[Qe],$n=!0):Wn.isWebGL2&&ve.samples>0&&Dt.useMultisampledRTT(ve)===!1?Gt=qt.get(ve).__webglMultisampledFramebuffer:Gt=ai,fe.copy(ve.viewport),Ae.copy(ve.scissor),oe=ve.scissorTest}else fe.copy(Je).multiplyScalar(ke).floor(),Ae.copy(It).multiplyScalar(ke).floor(),oe=ft;if(jt.bindFramebuffer(36160,Gt)&&Wn.drawBuffers&&mt&&jt.drawBuffers(ve,Gt),jt.viewport(fe),jt.scissor(Ae),jt.setScissorTest(oe),$n){const ui=qt.get(ve.texture);Mt.framebufferTexture2D(36160,36064,34069+Qe,ui.__webglTexture,lt)}else if(Yn){const ui=qt.get(ve.texture),ai=Qe||0;Mt.framebufferTextureLayer(36160,36064,ui.__webglTexture,lt||0,ai)}ne=-1},this.readRenderTargetPixels=function(ve,Qe,lt,mt,Gt,$n,Yn){if(!(ve&&ve.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let bi=qt.get(ve).__webglFramebuffer;if(ve.isWebGLCubeRenderTarget&&Yn!==void 0&&(bi=bi[Yn]),bi){jt.bindFramebuffer(36160,bi);try{const ui=ve.texture,ai=ui.format,Ni=ui.type;if(ai!==Qa&&kt.convert(ai)!==Mt.getParameter(35739)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}const Qi=Ni===Of&&(oi.has("EXT_color_buffer_half_float")||Wn.isWebGL2&&oi.has("EXT_color_buffer_float"));if(Ni!==wu&&kt.convert(Ni)!==Mt.getParameter(35738)&&!(Ni===xu&&(Wn.isWebGL2||oi.has("OES_texture_float")||oi.has("WEBGL_color_buffer_float")))&&!Qi){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Qe>=0&&Qe<=ve.width-mt&&lt>=0&&lt<=ve.height-Gt&&Mt.readPixels(Qe,lt,mt,Gt,kt.convert(ai),kt.convert(Ni),$n)}finally{const ui=K!==null?qt.get(K).__webglFramebuffer:null;jt.bindFramebuffer(36160,ui)}}},this.copyFramebufferToTexture=function(ve,Qe,lt=0){const mt=Math.pow(2,-lt),Gt=Math.floor(Qe.image.width*mt),$n=Math.floor(Qe.image.height*mt);Dt.setTexture2D(Qe,0),Mt.copyTexSubImage2D(3553,lt,0,0,ve.x,ve.y,Gt,$n),jt.unbindTexture()},this.copyTextureToTexture=function(ve,Qe,lt,mt=0){const Gt=Qe.image.width,$n=Qe.image.height,Yn=kt.convert(lt.format),bi=kt.convert(lt.type);Dt.setTexture2D(lt,0),Mt.pixelStorei(37440,lt.flipY),Mt.pixelStorei(37441,lt.premultiplyAlpha),Mt.pixelStorei(3317,lt.unpackAlignment),Qe.isDataTexture?Mt.texSubImage2D(3553,mt,ve.x,ve.y,Gt,$n,Yn,bi,Qe.image.data):Qe.isCompressedTexture?Mt.compressedTexSubImage2D(3553,mt,ve.x,ve.y,Qe.mipmaps[0].width,Qe.mipmaps[0].height,Yn,Qe.mipmaps[0].data):Mt.texSubImage2D(3553,mt,ve.x,ve.y,Yn,bi,Qe.image),mt===0&&lt.generateMipmaps&&Mt.generateMipmap(3553),jt.unbindTexture()},this.copyTextureToTexture3D=function(ve,Qe,lt,mt,Gt=0){if(B.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}const $n=ve.max.x-ve.min.x+1,Yn=ve.max.y-ve.min.y+1,bi=ve.max.z-ve.min.z+1,ui=kt.convert(mt.format),ai=kt.convert(mt.type);let Ni;if(mt.isData3DTexture)Dt.setTexture3D(mt,0),Ni=32879;else if(mt.isDataArrayTexture)Dt.setTexture2DArray(mt,0),Ni=35866;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}Mt.pixelStorei(37440,mt.flipY),Mt.pixelStorei(37441,mt.premultiplyAlpha),Mt.pixelStorei(3317,mt.unpackAlignment);const Qi=Mt.getParameter(3314),Cr=Mt.getParameter(32878),ki=Mt.getParameter(3316),ea=Mt.getParameter(3315),Xs=Mt.getParameter(32877),$s=lt.isCompressedTexture?lt.mipmaps[0]:lt.image;Mt.pixelStorei(3314,$s.width),Mt.pixelStorei(32878,$s.height),Mt.pixelStorei(3316,ve.min.x),Mt.pixelStorei(3315,ve.min.y),Mt.pixelStorei(32877,ve.min.z),lt.isDataTexture||lt.isData3DTexture?Mt.texSubImage3D(Ni,Gt,Qe.x,Qe.y,Qe.z,$n,Yn,bi,ui,ai,$s.data):lt.isCompressedTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),Mt.compressedTexSubImage3D(Ni,Gt,Qe.x,Qe.y,Qe.z,$n,Yn,bi,ui,$s.data)):Mt.texSubImage3D(Ni,Gt,Qe.x,Qe.y,Qe.z,$n,Yn,bi,ui,ai,$s),Mt.pixelStorei(3314,Qi),Mt.pixelStorei(32878,Cr),Mt.pixelStorei(3316,ki),Mt.pixelStorei(3315,ea),Mt.pixelStorei(32877,Xs),Gt===0&&mt.generateMipmaps&&Mt.generateMipmap(Ni),jt.unbindTexture()},this.initTexture=function(ve){Dt.setTexture2D(ve,0),jt.unbindTexture()},this.resetState=function(){H=0,Y=0,K=null,jt.reset(),Hn.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}class uT extends wv{}uT.prototype.isWebGL1Renderer=!0;class G_{constructor(e,n=25e-5){this.isFogExp2=!0,this.name="",this.color=new Kn(e),this.density=n}clone(){return new G_(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}class j_{constructor(e,n=1,a=1e3){this.isFog=!0,this.name="",this.color=new Kn(e),this.near=n,this.far=a}clone(){return new j_(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}class b_ extends kr{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,n){return super.copy(e,n),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const n=super.toJSON(e);return this.fog!==null&&(n.object.fog=this.fog.toJSON()),n}}class W_{constructor(e,n){this.isInterleavedBuffer=!0,this.array=e,this.stride=n,this.count=e!==void 0?e.length/n:0,this.usage=y_,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=pl()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,n,a){e*=this.stride,a*=n.stride;for(let c=0,f=this.stride;c<f;c++)this.array[e+c]=n.array[a+c];return this}set(e,n=0){return this.array.set(e,n),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=pl()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const n=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),a=new this.constructor(n,this.stride);return a.setUsage(this.usage),a}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=pl()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.prototype.slice.call(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const Ea=new Me;class ud{constructor(e,n,a,c=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=n,this.offset=a,this.normalized=c===!0}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let n=0,a=this.data.count;n<a;n++)Ea.fromBufferAttribute(this,n),Ea.applyMatrix4(e),this.setXYZ(n,Ea.x,Ea.y,Ea.z);return this}applyNormalMatrix(e){for(let n=0,a=this.count;n<a;n++)Ea.fromBufferAttribute(this,n),Ea.applyNormalMatrix(e),this.setXYZ(n,Ea.x,Ea.y,Ea.z);return this}transformDirection(e){for(let n=0,a=this.count;n<a;n++)Ea.fromBufferAttribute(this,n),Ea.transformDirection(e),this.setXYZ(n,Ea.x,Ea.y,Ea.z);return this}setX(e,n){return this.data.array[e*this.data.stride+this.offset]=n,this}setY(e,n){return this.data.array[e*this.data.stride+this.offset+1]=n,this}setZ(e,n){return this.data.array[e*this.data.stride+this.offset+2]=n,this}setW(e,n){return this.data.array[e*this.data.stride+this.offset+3]=n,this}getX(e){return this.data.array[e*this.data.stride+this.offset]}getY(e){return this.data.array[e*this.data.stride+this.offset+1]}getZ(e){return this.data.array[e*this.data.stride+this.offset+2]}getW(e){return this.data.array[e*this.data.stride+this.offset+3]}setXY(e,n,a){return e=e*this.data.stride+this.offset,this.data.array[e+0]=n,this.data.array[e+1]=a,this}setXYZ(e,n,a,c){return e=e*this.data.stride+this.offset,this.data.array[e+0]=n,this.data.array[e+1]=a,this.data.array[e+2]=c,this}setXYZW(e,n,a,c,f){return e=e*this.data.stride+this.offset,this.data.array[e+0]=n,this.data.array[e+1]=a,this.data.array[e+2]=c,this.data.array[e+3]=f,this}clone(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.clone(): Cloning an interlaved buffer attribute will deinterleave buffer data.");const n=[];for(let a=0;a<this.count;a++){const c=a*this.data.stride+this.offset;for(let f=0;f<this.itemSize;f++)n.push(this.data.array[c+f])}return new Yr(new this.array.constructor(n),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new ud(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.InterleavedBufferAttribute.toJSON(): Serializing an interlaved buffer attribute will deinterleave buffer data.");const n=[];for(let a=0;a<this.count;a++){const c=a*this.data.stride+this.offset;for(let f=0;f<this.itemSize;f++)n.push(this.data.array[c+f])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:n,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class Sv extends fo{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Kn(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let vf;const Wp=new Me,bf=new Me,wf=new Me,Sf=new tn,Hp=new tn,hT=new sr,kg=new Me,qp=new Me,Og=new Me,eS=new tn,O0=new tn,tS=new tn;class dT extends kr{constructor(e){if(super(),this.isSprite=!0,this.type="Sprite",vf===void 0){vf=new qi;const n=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),a=new W_(n,5);vf.setIndex([0,1,2,0,2,3]),vf.setAttribute("position",new ud(a,3,0,!1)),vf.setAttribute("uv",new ud(a,2,3,!1))}this.geometry=vf,this.material=e!==void 0?e:new Sv,this.center=new tn(.5,.5)}raycast(e,n){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),bf.setFromMatrixScale(this.matrixWorld),hT.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),wf.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&bf.multiplyScalar(-wf.z);const a=this.material.rotation;let c,f;a!==0&&(f=Math.cos(a),c=Math.sin(a));const m=this.center;Fg(kg.set(-.5,-.5,0),wf,m,bf,c,f),Fg(qp.set(.5,-.5,0),wf,m,bf,c,f),Fg(Og.set(.5,.5,0),wf,m,bf,c,f),eS.set(0,0),O0.set(1,0),tS.set(1,1);let i=e.ray.intersectTriangle(kg,qp,Og,!1,Wp);if(i===null&&(Fg(qp.set(-.5,.5,0),wf,m,bf,c,f),O0.set(0,1),i=e.ray.intersectTriangle(kg,Og,qp,!1,Wp),i===null))return;const w=e.ray.origin.distanceTo(Wp);w<e.near||w>e.far||n.push({distance:w,point:Wp.clone(),uv:zl.getUV(Wp,kg,qp,Og,eS,O0,tS,new tn),face:null,object:this})}copy(e,n){return super.copy(e,n),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function Fg(d,e,n,a,c,f){Sf.subVectors(d,n).addScalar(.5).multiply(a),c!==void 0?(Hp.x=f*Sf.x-c*Sf.y,Hp.y=c*Sf.x+f*Sf.y):Hp.copy(Sf),d.copy(e),d.x+=Hp.x,d.y+=Hp.y,d.applyMatrix4(hT)}const Bg=new Me,nS=new Me;class fT extends kr{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const n=e.levels;for(let a=0,c=n.length;a<c;a++){const f=n[a];this.addLevel(f.object.clone(),f.distance)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,n=0){n=Math.abs(n);const a=this.levels;let c;for(c=0;c<a.length&&!(n<a[c].distance);c++);return a.splice(c,0,{distance:n,object:e}),this.add(e),this}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){const n=this.levels;if(n.length>0){let a,c;for(a=1,c=n.length;a<c&&!(e<n[a].distance);a++);return n[a-1].object}return null}raycast(e,n){if(this.levels.length>0){Bg.setFromMatrixPosition(this.matrixWorld);const c=e.ray.origin.distanceTo(Bg);this.getObjectForDistance(c).raycast(e,n)}}update(e){const n=this.levels;if(n.length>1){Bg.setFromMatrixPosition(e.matrixWorld),nS.setFromMatrixPosition(this.matrixWorld);const a=Bg.distanceTo(nS)/e.zoom;n[0].object.visible=!0;let c,f;for(c=1,f=n.length;c<f&&a>=n[c].distance;c++)n[c-1].object.visible=!1,n[c].object.visible=!0;for(this._currentLevel=c-1;c<f;c++)n[c].object.visible=!1}}toJSON(e){const n=super.toJSON(e);this.autoUpdate===!1&&(n.object.autoUpdate=!1),n.object.levels=[];const a=this.levels;for(let c=0,f=a.length;c<f;c++){const m=a[c];n.object.levels.push({object:m.object.uuid,distance:m.distance})}return n}}const iS=new Me,rS=new Wr,sS=new Wr,Hk=new Me,oS=new sr;class pT extends Jo{constructor(e,n){super(e,n),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new sr,this.bindMatrixInverse=new sr}copy(e,n){return super.copy(e,n),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,this}bind(e,n){this.skeleton=e,n===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),n=this.matrixWorld),this.bindMatrix.copy(n),this.bindMatrixInverse.copy(n).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new Wr,n=this.geometry.attributes.skinWeight;for(let a=0,c=n.count;a<c;a++){e.fromBufferAttribute(n,a);const f=1/e.manhattanLength();f!==1/0?e.multiplyScalar(f):e.set(1,0,0,0),n.setXYZW(a,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode==="attached"?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode==="detached"?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}boneTransform(e,n){const a=this.skeleton,c=this.geometry;rS.fromBufferAttribute(c.attributes.skinIndex,e),sS.fromBufferAttribute(c.attributes.skinWeight,e),iS.copy(n).applyMatrix4(this.bindMatrix),n.set(0,0,0);for(let f=0;f<4;f++){const m=sS.getComponent(f);if(m!==0){const i=rS.getComponent(f);oS.multiplyMatrices(a.bones[i].matrixWorld,a.boneInverses[i]),n.addScaledVector(Hk.copy(iS).applyMatrix4(oS),m)}}return n.applyMatrix4(this.bindMatrixInverse)}}class Mv extends kr{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Df extends ho{constructor(e=null,n=1,a=1,c,f,m,i,w,E=uo,C=uo,T,I){super(null,m,i,w,E,C,c,f,T,I),this.isDataTexture=!0,this.image={data:e,width:n,height:a},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const aS=new sr,qk=new sr;class H_{constructor(e=[],n=[]){this.uuid=pl(),this.bones=e.slice(0),this.boneInverses=n,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}init(){const e=this.bones,n=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),n.length===0)this.calculateInverses();else if(e.length!==n.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let a=0,c=this.bones.length;a<c;a++)this.boneInverses.push(new sr)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,n=this.bones.length;e<n;e++){const a=new sr;this.bones[e]&&a.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(a)}}pose(){for(let e=0,n=this.bones.length;e<n;e++){const a=this.bones[e];a&&a.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,n=this.bones.length;e<n;e++){const a=this.bones[e];a&&(a.parent&&a.parent.isBone?(a.matrix.copy(a.parent.matrixWorld).invert(),a.matrix.multiply(a.matrixWorld)):a.matrix.copy(a.matrixWorld),a.matrix.decompose(a.position,a.quaternion,a.scale))}}update(){const e=this.bones,n=this.boneInverses,a=this.boneMatrices,c=this.boneTexture;for(let f=0,m=e.length;f<m;f++){const i=e[f]?e[f].matrixWorld:qk;aS.multiplyMatrices(i,n[f]),aS.toArray(a,f*16)}c!==null&&(c.needsUpdate=!0)}clone(){return new H_(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=$E(e),e=Math.max(e,4);const n=new Float32Array(e*e*4);n.set(this.boneMatrices);const a=new Df(n,e,e,Qa,xu);return a.needsUpdate=!0,this.boneMatrices=n,this.boneTexture=a,this.boneTextureSize=e,this}getBoneByName(e){for(let n=0,a=this.bones.length;n<a;n++){const c=this.bones[n];if(c.name===e)return c}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,n){this.uuid=e.uuid;for(let a=0,c=e.bones.length;a<c;a++){const f=e.bones[a];let m=n[f];m===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",f),m=new Mv),this.bones.push(m),this.boneInverses.push(new sr().fromArray(e.boneInverses[a]))}return this.init(),this}toJSON(){const e={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const n=this.bones,a=this.boneInverses;for(let c=0,f=n.length;c<f;c++){const m=n[c];e.bones.push(m.uuid);const i=a[c];e.boneInverses.push(i.toArray())}return e}}class Bf extends Yr{constructor(e,n,a,c=1){typeof a=="number"&&(c=a,a=!1,console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.")),super(e,n,a),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=c}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const lS=new sr,cS=new sr,Ng=[],Zp=new Jo;class mT extends Jo{constructor(e,n,a){super(e,n),this.isInstancedMesh=!0,this.instanceMatrix=new Bf(new Float32Array(a*16),16),this.instanceColor=null,this.count=a,this.frustumCulled=!1}copy(e,n){return super.copy(e,n),this.instanceMatrix.copy(e.instanceMatrix),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,this}getColorAt(e,n){n.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,n){n.fromArray(this.instanceMatrix.array,e*16)}raycast(e,n){const a=this.matrixWorld,c=this.count;if(Zp.geometry=this.geometry,Zp.material=this.material,Zp.material!==void 0)for(let f=0;f<c;f++){this.getMatrixAt(f,lS),cS.multiplyMatrices(a,lS),Zp.matrixWorld=cS,Zp.raycast(e,Ng);for(let m=0,i=Ng.length;m<i;m++){const w=Ng[m];w.instanceId=f,w.object=this,n.push(w)}Ng.length=0}}setColorAt(e,n){this.instanceColor===null&&(this.instanceColor=new Bf(new Float32Array(this.instanceMatrix.count*3),3)),n.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,n){n.toArray(this.instanceMatrix.array,e*16)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}}class La extends fo{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Kn(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const uS=new Me,hS=new Me,dS=new sr,F0=new np,Ug=new vd;class ah extends kr{constructor(e=new qi,n=new La){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=n,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,a=[0];for(let c=1,f=n.count;c<f;c++)uS.fromBufferAttribute(n,c-1),hS.fromBufferAttribute(n,c),a[c]=a[c-1],a[c]+=uS.distanceTo(hS);e.setAttribute("lineDistance",new hi(a,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,n){const a=this.geometry,c=this.matrixWorld,f=e.params.Line.threshold,m=a.drawRange;if(a.boundingSphere===null&&a.computeBoundingSphere(),Ug.copy(a.boundingSphere),Ug.applyMatrix4(c),Ug.radius+=f,e.ray.intersectsSphere(Ug)===!1)return;dS.copy(c).invert(),F0.copy(e.ray).applyMatrix4(dS);const i=f/((this.scale.x+this.scale.y+this.scale.z)/3),w=i*i,E=new Me,C=new Me,T=new Me,I=new Me,k=this.isLineSegments?2:1,O=a.index,F=a.attributes.position;if(O!==null){const H=Math.max(0,m.start),Y=Math.min(O.count,m.start+m.count);for(let K=H,ne=Y-1;K<ne;K+=k){const le=O.getX(K),fe=O.getX(K+1);if(E.fromBufferAttribute(F,le),C.fromBufferAttribute(F,fe),F0.distanceSqToSegment(E,C,I,T)>w)continue;I.applyMatrix4(this.matrixWorld);const oe=e.ray.origin.distanceTo(I);oe<e.near||oe>e.far||n.push({distance:oe,point:T.clone().applyMatrix4(this.matrixWorld),index:K,face:null,faceIndex:null,object:this})}}else{const H=Math.max(0,m.start),Y=Math.min(F.count,m.start+m.count);for(let K=H,ne=Y-1;K<ne;K+=k){if(E.fromBufferAttribute(F,K),C.fromBufferAttribute(F,K+1),F0.distanceSqToSegment(E,C,I,T)>w)continue;I.applyMatrix4(this.matrixWorld);const fe=e.ray.origin.distanceTo(I);fe<e.near||fe>e.far||n.push({distance:fe,point:T.clone().applyMatrix4(this.matrixWorld),index:K,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const n=this.geometry.morphAttributes,a=Object.keys(n);if(a.length>0){const c=n[a[0]];if(c!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let f=0,m=c.length;f<m;f++){const i=c[f].name||String(f);this.morphTargetInfluences.push(0),this.morphTargetDictionary[i]=f}}}}}const fS=new Me,pS=new Me;class Hc extends ah{constructor(e,n){super(e,n),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const n=e.attributes.position,a=[];for(let c=0,f=n.count;c<f;c+=2)fS.fromBufferAttribute(n,c),pS.fromBufferAttribute(n,c+1),a[c]=c===0?0:a[c-1],a[c+1]=a[c]+fS.distanceTo(pS);e.setAttribute("lineDistance",new hi(a,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class gT extends ah{constructor(e,n){super(e,n),this.isLineLoop=!0,this.type="LineLoop"}}class q_ extends fo{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Kn(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const mS=new sr,Nx=new np,Vg=new vd,Gg=new Me;class Ev extends kr{constructor(e=new qi,n=new q_){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=n,this.updateMorphTargets()}copy(e,n){return super.copy(e,n),this.material=e.material,this.geometry=e.geometry,this}raycast(e,n){const a=this.geometry,c=this.matrixWorld,f=e.params.Points.threshold,m=a.drawRange;if(a.boundingSphere===null&&a.computeBoundingSphere(),Vg.copy(a.boundingSphere),Vg.applyMatrix4(c),Vg.radius+=f,e.ray.intersectsSphere(Vg)===!1)return;mS.copy(c).invert(),Nx.copy(e.ray).applyMatrix4(mS);const i=f/((this.scale.x+this.scale.y+this.scale.z)/3),w=i*i,E=a.index,T=a.attributes.position;if(E!==null){const I=Math.max(0,m.start),k=Math.min(E.count,m.start+m.count);for(let O=I,B=k;O<B;O++){const F=E.getX(O);Gg.fromBufferAttribute(T,F),gS(Gg,F,w,c,e,n,this)}}else{const I=Math.max(0,m.start),k=Math.min(T.count,m.start+m.count);for(let O=I,B=k;O<B;O++)Gg.fromBufferAttribute(T,O),gS(Gg,O,w,c,e,n,this)}}updateMorphTargets(){const n=this.geometry.morphAttributes,a=Object.keys(n);if(a.length>0){const c=n[a[0]];if(c!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let f=0,m=c.length;f<m;f++){const i=c[f].name||String(f);this.morphTargetInfluences.push(0),this.morphTargetDictionary[i]=f}}}}}function gS(d,e,n,a,c,f,m){const i=Nx.distanceSqToPoint(d);if(i<n){const w=new Me;Nx.closestPointToPoint(d,w),w.applyMatrix4(a);const E=c.ray.origin.distanceTo(w);if(E<c.near||E>c.far)return;f.push({distance:E,distanceToRay:Math.sqrt(i),point:w,index:e,face:null,object:m})}}class Zk extends ho{constructor(e,n,a,c,f,m,i,w,E){super(e,n,a,c,f,m,i,w,E),this.isVideoTexture=!0,this.minFilter=m!==void 0?m:qs,this.magFilter=f!==void 0?f:qs,this.generateMipmaps=!1;const C=this;function T(){C.needsUpdate=!0,e.requestVideoFrameCallback(T)}"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback(T)}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class Xk extends ho{constructor(e,n,a){super({width:e,height:n}),this.isFramebufferTexture=!0,this.format=a,this.magFilter=uo,this.minFilter=uo,this.generateMipmaps=!1,this.needsUpdate=!0}}class _T extends ho{constructor(e,n,a,c,f,m,i,w,E,C,T,I){super(null,m,i,w,E,C,c,f,T,I),this.isCompressedTexture=!0,this.image={width:n,height:a},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class yT extends ho{constructor(e,n,a,c,f,m,i,w,E){super(e,n,a,c,f,m,i,w,E),this.isCanvasTexture=!0,this.needsUpdate=!0}}class oc{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,n){const a=this.getUtoTmapping(e);return this.getPoint(a,n)}getPoints(e=5){const n=[];for(let a=0;a<=e;a++)n.push(this.getPoint(a/e));return n}getSpacedPoints(e=5){const n=[];for(let a=0;a<=e;a++)n.push(this.getPointAt(a/e));return n}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const n=[];let a,c=this.getPoint(0),f=0;n.push(0);for(let m=1;m<=e;m++)a=this.getPoint(m/e),f+=a.distanceTo(c),n.push(f),c=a;return this.cacheArcLengths=n,n}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,n){const a=this.getLengths();let c=0;const f=a.length;let m;n?m=n:m=e*a[f-1];let i=0,w=f-1,E;for(;i<=w;)if(c=Math.floor(i+(w-i)/2),E=a[c]-m,E<0)i=c+1;else if(E>0)w=c-1;else{w=c;break}if(c=w,a[c]===m)return c/(f-1);const C=a[c],I=a[c+1]-C,k=(m-C)/I;return(c+k)/(f-1)}getTangent(e,n){let c=e-1e-4,f=e+1e-4;c<0&&(c=0),f>1&&(f=1);const m=this.getPoint(c),i=this.getPoint(f),w=n||(m.isVector2?new tn:new Me);return w.copy(i).sub(m).normalize(),w}getTangentAt(e,n){const a=this.getUtoTmapping(e);return this.getTangent(a,n)}computeFrenetFrames(e,n){const a=new Me,c=[],f=[],m=[],i=new Me,w=new sr;for(let k=0;k<=e;k++){const O=k/e;c[k]=this.getTangentAt(O,new Me)}f[0]=new Me,m[0]=new Me;let E=Number.MAX_VALUE;const C=Math.abs(c[0].x),T=Math.abs(c[0].y),I=Math.abs(c[0].z);C<=E&&(E=C,a.set(1,0,0)),T<=E&&(E=T,a.set(0,1,0)),I<=E&&a.set(0,0,1),i.crossVectors(c[0],a).normalize(),f[0].crossVectors(c[0],i),m[0].crossVectors(c[0],f[0]);for(let k=1;k<=e;k++){if(f[k]=f[k-1].clone(),m[k]=m[k-1].clone(),i.crossVectors(c[k-1],c[k]),i.length()>Number.EPSILON){i.normalize();const O=Math.acos(Zs(c[k-1].dot(c[k]),-1,1));f[k].applyMatrix4(w.makeRotationAxis(i,O))}m[k].crossVectors(c[k],f[k])}if(n===!0){let k=Math.acos(Zs(f[0].dot(f[e]),-1,1));k/=e,c[0].dot(i.crossVectors(f[0],f[e]))>0&&(k=-k);for(let O=1;O<=e;O++)f[O].applyMatrix4(w.makeRotationAxis(c[O],k*O)),m[O].crossVectors(c[O],f[O])}return{tangents:c,normals:f,binormals:m}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Z_ extends oc{constructor(e=0,n=0,a=1,c=1,f=0,m=Math.PI*2,i=!1,w=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=n,this.xRadius=a,this.yRadius=c,this.aStartAngle=f,this.aEndAngle=m,this.aClockwise=i,this.aRotation=w}getPoint(e,n){const a=n||new tn,c=Math.PI*2;let f=this.aEndAngle-this.aStartAngle;const m=Math.abs(f)<Number.EPSILON;for(;f<0;)f+=c;for(;f>c;)f-=c;f<Number.EPSILON&&(m?f=0:f=c),this.aClockwise===!0&&!m&&(f===c?f=-c:f=f-c);const i=this.aStartAngle+e*f;let w=this.aX+this.xRadius*Math.cos(i),E=this.aY+this.yRadius*Math.sin(i);if(this.aRotation!==0){const C=Math.cos(this.aRotation),T=Math.sin(this.aRotation),I=w-this.aX,k=E-this.aY;w=I*C-k*T+this.aX,E=I*T+k*C+this.aY}return a.set(w,E)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}class xT extends Z_{constructor(e,n,a,c,f,m){super(e,n,a,a,c,f,m),this.isArcCurve=!0,this.type="ArcCurve"}}function Tv(){let d=0,e=0,n=0,a=0;function c(f,m,i,w){d=f,e=i,n=-3*f+3*m-2*i-w,a=2*f-2*m+i+w}return{initCatmullRom:function(f,m,i,w,E){c(m,i,E*(i-f),E*(w-m))},initNonuniformCatmullRom:function(f,m,i,w,E,C,T){let I=(m-f)/E-(i-f)/(E+C)+(i-m)/C,k=(i-m)/C-(w-m)/(C+T)+(w-i)/T;I*=C,k*=C,c(m,i,I,k)},calc:function(f){const m=f*f,i=m*f;return d+e*f+n*m+a*i}}}const jg=new Me,B0=new Tv,N0=new Tv,U0=new Tv;class vT extends oc{constructor(e=[],n=!1,a="centripetal",c=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=n,this.curveType=a,this.tension=c}getPoint(e,n=new Me){const a=n,c=this.points,f=c.length,m=(f-(this.closed?0:1))*e;let i=Math.floor(m),w=m-i;this.closed?i+=i>0?0:(Math.floor(Math.abs(i)/f)+1)*f:w===0&&i===f-1&&(i=f-2,w=1);let E,C;this.closed||i>0?E=c[(i-1)%f]:(jg.subVectors(c[0],c[1]).add(c[0]),E=jg);const T=c[i%f],I=c[(i+1)%f];if(this.closed||i+2<f?C=c[(i+2)%f]:(jg.subVectors(c[f-1],c[f-2]).add(c[f-1]),C=jg),this.curveType==="centripetal"||this.curveType==="chordal"){const k=this.curveType==="chordal"?.5:.25;let O=Math.pow(E.distanceToSquared(T),k),B=Math.pow(T.distanceToSquared(I),k),F=Math.pow(I.distanceToSquared(C),k);B<1e-4&&(B=1),O<1e-4&&(O=B),F<1e-4&&(F=B),B0.initNonuniformCatmullRom(E.x,T.x,I.x,C.x,O,B,F),N0.initNonuniformCatmullRom(E.y,T.y,I.y,C.y,O,B,F),U0.initNonuniformCatmullRom(E.z,T.z,I.z,C.z,O,B,F)}else this.curveType==="catmullrom"&&(B0.initCatmullRom(E.x,T.x,I.x,C.x,this.tension),N0.initCatmullRom(E.y,T.y,I.y,C.y,this.tension),U0.initCatmullRom(E.z,T.z,I.z,C.z,this.tension));return a.set(B0.calc(w),N0.calc(w),U0.calc(w)),a}copy(e){super.copy(e),this.points=[];for(let n=0,a=e.points.length;n<a;n++){const c=e.points[n];this.points.push(c.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let n=0,a=this.points.length;n<a;n++){const c=this.points[n];e.points.push(c.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let n=0,a=e.points.length;n<a;n++){const c=e.points[n];this.points.push(new Me().fromArray(c))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function _S(d,e,n,a,c){const f=(a-e)*.5,m=(c-n)*.5,i=d*d,w=d*i;return(2*n-2*a+f+m)*w+(-3*n+3*a-2*f-m)*i+f*d+n}function $k(d,e){const n=1-d;return n*n*e}function Yk(d,e){return 2*(1-d)*d*e}function Jk(d,e){return d*d*e}function em(d,e,n,a){return $k(d,e)+Yk(d,n)+Jk(d,a)}function Kk(d,e){const n=1-d;return n*n*n*e}function Qk(d,e){const n=1-d;return 3*n*n*d*e}function eO(d,e){return 3*(1-d)*d*d*e}function tO(d,e){return d*d*d*e}function tm(d,e,n,a,c){return Kk(d,e)+Qk(d,n)+eO(d,a)+tO(d,c)}class Av extends oc{constructor(e=new tn,n=new tn,a=new tn,c=new tn){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=n,this.v2=a,this.v3=c}getPoint(e,n=new tn){const a=n,c=this.v0,f=this.v1,m=this.v2,i=this.v3;return a.set(tm(e,c.x,f.x,m.x,i.x),tm(e,c.y,f.y,m.y,i.y)),a}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class bT extends oc{constructor(e=new Me,n=new Me,a=new Me,c=new Me){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=n,this.v2=a,this.v3=c}getPoint(e,n=new Me){const a=n,c=this.v0,f=this.v1,m=this.v2,i=this.v3;return a.set(tm(e,c.x,f.x,m.x,i.x),tm(e,c.y,f.y,m.y,i.y),tm(e,c.z,f.z,m.z,i.z)),a}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class X_ extends oc{constructor(e=new tn,n=new tn){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=n}getPoint(e,n=new tn){const a=n;return e===1?a.copy(this.v2):(a.copy(this.v2).sub(this.v1),a.multiplyScalar(e).add(this.v1)),a}getPointAt(e,n){return this.getPoint(e,n)}getTangent(e,n){const a=n||new tn;return a.copy(this.v2).sub(this.v1).normalize(),a}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class wT extends oc{constructor(e=new Me,n=new Me){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=n}getPoint(e,n=new Me){const a=n;return e===1?a.copy(this.v2):(a.copy(this.v2).sub(this.v1),a.multiplyScalar(e).add(this.v1)),a}getPointAt(e,n){return this.getPoint(e,n)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Cv extends oc{constructor(e=new tn,n=new tn,a=new tn){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=n,this.v2=a}getPoint(e,n=new tn){const a=n,c=this.v0,f=this.v1,m=this.v2;return a.set(em(e,c.x,f.x,m.x),em(e,c.y,f.y,m.y)),a}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Iv extends oc{constructor(e=new Me,n=new Me,a=new Me){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=n,this.v2=a}getPoint(e,n=new Me){const a=n,c=this.v0,f=this.v1,m=this.v2;return a.set(em(e,c.x,f.x,m.x),em(e,c.y,f.y,m.y),em(e,c.z,f.z,m.z)),a}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Pv extends oc{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,n=new tn){const a=n,c=this.points,f=(c.length-1)*e,m=Math.floor(f),i=f-m,w=c[m===0?m:m-1],E=c[m],C=c[m>c.length-2?c.length-1:m+1],T=c[m>c.length-3?c.length-1:m+2];return a.set(_S(i,w.x,E.x,C.x,T.x),_S(i,w.y,E.y,C.y,T.y)),a}copy(e){super.copy(e),this.points=[];for(let n=0,a=e.points.length;n<a;n++){const c=e.points[n];this.points.push(c.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let n=0,a=this.points.length;n<a;n++){const c=this.points[n];e.points.push(c.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let n=0,a=e.points.length;n<a;n++){const c=e.points[n];this.points.push(new tn().fromArray(c))}return this}}var Lv=Object.freeze({__proto__:null,ArcCurve:xT,CatmullRomCurve3:vT,CubicBezierCurve:Av,CubicBezierCurve3:bT,EllipseCurve:Z_,LineCurve:X_,LineCurve3:wT,QuadraticBezierCurve:Cv,QuadraticBezierCurve3:Iv,SplineCurve:Pv});class ST extends oc{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),n=this.curves[this.curves.length-1].getPoint(1);e.equals(n)||this.curves.push(new X_(n,e))}getPoint(e,n){const a=e*this.getLength(),c=this.getCurveLengths();let f=0;for(;f<c.length;){if(c[f]>=a){const m=c[f]-a,i=this.curves[f],w=i.getLength(),E=w===0?0:1-m/w;return i.getPointAt(E,n)}f++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let n=0;for(let a=0,c=this.curves.length;a<c;a++)n+=this.curves[a].getLength(),e.push(n);return this.cacheLengths=e,e}getSpacedPoints(e=40){const n=[];for(let a=0;a<=e;a++)n.push(this.getPoint(a/e));return this.autoClose&&n.push(n[0]),n}getPoints(e=12){const n=[];let a;for(let c=0,f=this.curves;c<f.length;c++){const m=f[c],i=m.isEllipseCurve?e*2:m.isLineCurve||m.isLineCurve3?1:m.isSplineCurve?e*m.points.length:e,w=m.getPoints(i);for(let E=0;E<w.length;E++){const C=w[E];a&&a.equals(C)||(n.push(C),a=C)}}return this.autoClose&&n.length>1&&!n[n.length-1].equals(n[0])&&n.push(n[0]),n}copy(e){super.copy(e),this.curves=[];for(let n=0,a=e.curves.length;n<a;n++){const c=e.curves[n];this.curves.push(c.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let n=0,a=this.curves.length;n<a;n++){const c=this.curves[n];e.curves.push(c.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let n=0,a=e.curves.length;n<a;n++){const c=e.curves[n];this.curves.push(new Lv[c.type]().fromJSON(c))}return this}}class hm extends ST{constructor(e){super(),this.type="Path",this.currentPoint=new tn,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let n=1,a=e.length;n<a;n++)this.lineTo(e[n].x,e[n].y);return this}moveTo(e,n){return this.currentPoint.set(e,n),this}lineTo(e,n){const a=new X_(this.currentPoint.clone(),new tn(e,n));return this.curves.push(a),this.currentPoint.set(e,n),this}quadraticCurveTo(e,n,a,c){const f=new Cv(this.currentPoint.clone(),new tn(e,n),new tn(a,c));return this.curves.push(f),this.currentPoint.set(a,c),this}bezierCurveTo(e,n,a,c,f,m){const i=new Av(this.currentPoint.clone(),new tn(e,n),new tn(a,c),new tn(f,m));return this.curves.push(i),this.currentPoint.set(f,m),this}splineThru(e){const n=[this.currentPoint.clone()].concat(e),a=new Pv(n);return this.curves.push(a),this.currentPoint.copy(e[e.length-1]),this}arc(e,n,a,c,f,m){const i=this.currentPoint.x,w=this.currentPoint.y;return this.absarc(e+i,n+w,a,c,f,m),this}absarc(e,n,a,c,f,m){return this.absellipse(e,n,a,a,c,f,m),this}ellipse(e,n,a,c,f,m,i,w){const E=this.currentPoint.x,C=this.currentPoint.y;return this.absellipse(e+E,n+C,a,c,f,m,i,w),this}absellipse(e,n,a,c,f,m,i,w){const E=new Z_(e,n,a,c,f,m,i,w);if(this.curves.length>0){const T=E.getPoint(0);T.equals(this.currentPoint)||this.lineTo(T.x,T.y)}this.curves.push(E);const C=E.getPoint(1);return this.currentPoint.copy(C),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class hd extends qi{constructor(e=[new tn(0,.5),new tn(.5,0),new tn(0,-.5)],n=12,a=0,c=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:n,phiStart:a,phiLength:c},n=Math.floor(n),c=Zs(c,0,Math.PI*2);const f=[],m=[],i=[],w=[],E=[],C=1/n,T=new Me,I=new tn,k=new Me,O=new Me,B=new Me;let F=0,H=0;for(let Y=0;Y<=e.length-1;Y++)switch(Y){case 0:F=e[Y+1].x-e[Y].x,H=e[Y+1].y-e[Y].y,k.x=H*1,k.y=-F,k.z=H*0,B.copy(k),k.normalize(),w.push(k.x,k.y,k.z);break;case e.length-1:w.push(B.x,B.y,B.z);break;default:F=e[Y+1].x-e[Y].x,H=e[Y+1].y-e[Y].y,k.x=H*1,k.y=-F,k.z=H*0,O.copy(k),k.x+=B.x,k.y+=B.y,k.z+=B.z,k.normalize(),w.push(k.x,k.y,k.z),B.copy(O)}for(let Y=0;Y<=n;Y++){const K=a+Y*C*c,ne=Math.sin(K),le=Math.cos(K);for(let fe=0;fe<=e.length-1;fe++){T.x=e[fe].x*ne,T.y=e[fe].y,T.z=e[fe].x*le,m.push(T.x,T.y,T.z),I.x=Y/n,I.y=fe/(e.length-1),i.push(I.x,I.y);const Ae=w[3*fe+0]*ne,oe=w[3*fe+1],ce=w[3*fe+0]*le;E.push(Ae,oe,ce)}}for(let Y=0;Y<n;Y++)for(let K=0;K<e.length-1;K++){const ne=K+Y*e.length,le=ne,fe=ne+e.length,Ae=ne+e.length+1,oe=ne+1;f.push(le,fe,oe),f.push(Ae,oe,fe)}this.setIndex(f),this.setAttribute("position",new hi(m,3)),this.setAttribute("uv",new hi(i,2)),this.setAttribute("normal",new hi(E,3))}static fromJSON(e){return new hd(e.points,e.segments,e.phiStart,e.phiLength)}}class Nf extends hd{constructor(e=1,n=1,a=4,c=8){const f=new hm;f.absarc(0,-n/2,e,Math.PI*1.5,0),f.absarc(0,n/2,e,0,Math.PI*.5),super(f.getPoints(a),c),this.type="CapsuleGeometry",this.parameters={radius:e,height:n,capSegments:a,radialSegments:c}}static fromJSON(e){return new Nf(e.radius,e.length,e.capSegments,e.radialSegments)}}class Uf extends qi{constructor(e=1,n=8,a=0,c=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:n,thetaStart:a,thetaLength:c},n=Math.max(3,n);const f=[],m=[],i=[],w=[],E=new Me,C=new tn;m.push(0,0,0),i.push(0,0,1),w.push(.5,.5);for(let T=0,I=3;T<=n;T++,I+=3){const k=a+T/n*c;E.x=e*Math.cos(k),E.y=e*Math.sin(k),m.push(E.x,E.y,E.z),i.push(0,0,1),C.x=(m[I]/e+1)/2,C.y=(m[I+1]/e+1)/2,w.push(C.x,C.y)}for(let T=1;T<=n;T++)f.push(T,T+1,0);this.setIndex(f),this.setAttribute("position",new hi(m,3)),this.setAttribute("normal",new hi(i,3)),this.setAttribute("uv",new hi(w,2))}static fromJSON(e){return new Uf(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class lh extends qi{constructor(e=1,n=1,a=1,c=8,f=1,m=!1,i=0,w=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:n,height:a,radialSegments:c,heightSegments:f,openEnded:m,thetaStart:i,thetaLength:w};const E=this;c=Math.floor(c),f=Math.floor(f);const C=[],T=[],I=[],k=[];let O=0;const B=[],F=a/2;let H=0;Y(),m===!1&&(e>0&&K(!0),n>0&&K(!1)),this.setIndex(C),this.setAttribute("position",new hi(T,3)),this.setAttribute("normal",new hi(I,3)),this.setAttribute("uv",new hi(k,2));function Y(){const ne=new Me,le=new Me;let fe=0;const Ae=(n-e)/a;for(let oe=0;oe<=f;oe++){const ce=[],Re=oe/f,ke=Re*(n-e)+e;for(let Xe=0;Xe<=c;Xe++){const St=Xe/c,Je=St*w+i,It=Math.sin(Je),ft=Math.cos(Je);le.x=ke*It,le.y=-Re*a+F,le.z=ke*ft,T.push(le.x,le.y,le.z),ne.set(It,Ae,ft).normalize(),I.push(ne.x,ne.y,ne.z),k.push(St,1-Re),ce.push(O++)}B.push(ce)}for(let oe=0;oe<c;oe++)for(let ce=0;ce<f;ce++){const Re=B[ce][oe],ke=B[ce+1][oe],Xe=B[ce+1][oe+1],St=B[ce][oe+1];C.push(Re,ke,St),C.push(ke,Xe,St),fe+=6}E.addGroup(H,fe,0),H+=fe}function K(ne){const le=O,fe=new tn,Ae=new Me;let oe=0;const ce=ne===!0?e:n,Re=ne===!0?1:-1;for(let Xe=1;Xe<=c;Xe++)T.push(0,F*Re,0),I.push(0,Re,0),k.push(.5,.5),O++;const ke=O;for(let Xe=0;Xe<=c;Xe++){const Je=Xe/c*w+i,It=Math.cos(Je),ft=Math.sin(Je);Ae.x=ce*ft,Ae.y=F*Re,Ae.z=ce*It,T.push(Ae.x,Ae.y,Ae.z),I.push(0,Re,0),fe.x=It*.5+.5,fe.y=ft*.5*Re+.5,k.push(fe.x,fe.y),O++}for(let Xe=0;Xe<c;Xe++){const St=le+Xe,Je=ke+Xe;ne===!0?C.push(Je,Je+1,St):C.push(Je+1,Je,St),oe+=3}E.addGroup(H,oe,ne===!0?1:2),H+=oe}}static fromJSON(e){return new lh(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Vf extends lh{constructor(e=1,n=1,a=8,c=1,f=!1,m=0,i=Math.PI*2){super(0,e,n,a,c,f,m,i),this.type="ConeGeometry",this.parameters={radius:e,height:n,radialSegments:a,heightSegments:c,openEnded:f,thetaStart:m,thetaLength:i}}static fromJSON(e){return new Vf(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class jc extends qi{constructor(e=[],n=[],a=1,c=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:n,radius:a,detail:c};const f=[],m=[];i(c),E(a),C(),this.setAttribute("position",new hi(f,3)),this.setAttribute("normal",new hi(f.slice(),3)),this.setAttribute("uv",new hi(m,2)),c===0?this.computeVertexNormals():this.normalizeNormals();function i(Y){const K=new Me,ne=new Me,le=new Me;for(let fe=0;fe<n.length;fe+=3)k(n[fe+0],K),k(n[fe+1],ne),k(n[fe+2],le),w(K,ne,le,Y)}function w(Y,K,ne,le){const fe=le+1,Ae=[];for(let oe=0;oe<=fe;oe++){Ae[oe]=[];const ce=Y.clone().lerp(ne,oe/fe),Re=K.clone().lerp(ne,oe/fe),ke=fe-oe;for(let Xe=0;Xe<=ke;Xe++)Xe===0&&oe===fe?Ae[oe][Xe]=ce:Ae[oe][Xe]=ce.clone().lerp(Re,Xe/ke)}for(let oe=0;oe<fe;oe++)for(let ce=0;ce<2*(fe-oe)-1;ce++){const Re=Math.floor(ce/2);ce%2===0?(I(Ae[oe][Re+1]),I(Ae[oe+1][Re]),I(Ae[oe][Re])):(I(Ae[oe][Re+1]),I(Ae[oe+1][Re+1]),I(Ae[oe+1][Re]))}}function E(Y){const K=new Me;for(let ne=0;ne<f.length;ne+=3)K.x=f[ne+0],K.y=f[ne+1],K.z=f[ne+2],K.normalize().multiplyScalar(Y),f[ne+0]=K.x,f[ne+1]=K.y,f[ne+2]=K.z}function C(){const Y=new Me;for(let K=0;K<f.length;K+=3){Y.x=f[K+0],Y.y=f[K+1],Y.z=f[K+2];const ne=F(Y)/2/Math.PI+.5,le=H(Y)/Math.PI+.5;m.push(ne,1-le)}O(),T()}function T(){for(let Y=0;Y<m.length;Y+=6){const K=m[Y+0],ne=m[Y+2],le=m[Y+4],fe=Math.max(K,ne,le),Ae=Math.min(K,ne,le);fe>.9&&Ae<.1&&(K<.2&&(m[Y+0]+=1),ne<.2&&(m[Y+2]+=1),le<.2&&(m[Y+4]+=1))}}function I(Y){f.push(Y.x,Y.y,Y.z)}function k(Y,K){const ne=Y*3;K.x=e[ne+0],K.y=e[ne+1],K.z=e[ne+2]}function O(){const Y=new Me,K=new Me,ne=new Me,le=new Me,fe=new tn,Ae=new tn,oe=new tn;for(let ce=0,Re=0;ce<f.length;ce+=9,Re+=6){Y.set(f[ce+0],f[ce+1],f[ce+2]),K.set(f[ce+3],f[ce+4],f[ce+5]),ne.set(f[ce+6],f[ce+7],f[ce+8]),fe.set(m[Re+0],m[Re+1]),Ae.set(m[Re+2],m[Re+3]),oe.set(m[Re+4],m[Re+5]),le.copy(Y).add(K).add(ne).divideScalar(3);const ke=F(le);B(fe,Re+0,Y,ke),B(Ae,Re+2,K,ke),B(oe,Re+4,ne,ke)}}function B(Y,K,ne,le){le<0&&Y.x===1&&(m[K]=Y.x-1),ne.x===0&&ne.z===0&&(m[K]=le/2/Math.PI+.5)}function F(Y){return Math.atan2(Y.z,-Y.x)}function H(Y){return Math.atan2(-Y.y,Math.sqrt(Y.x*Y.x+Y.z*Y.z))}}static fromJSON(e){return new jc(e.vertices,e.indices,e.radius,e.details)}}class Gf extends jc{constructor(e=1,n=0){const a=(1+Math.sqrt(5))/2,c=1/a,f=[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-c,-a,0,-c,a,0,c,-a,0,c,a,-c,-a,0,-c,a,0,c,-a,0,c,a,0,-a,0,-c,a,0,-c,-a,0,c,a,0,c],m=[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9];super(f,m,e,n),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:n}}static fromJSON(e){return new Gf(e.radius,e.detail)}}const Wg=new Me,Hg=new Me,V0=new Me,qg=new zl;class MT extends qi{constructor(e=null,n=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:n},e!==null){const c=Math.pow(10,4),f=Math.cos(nd*n),m=e.getIndex(),i=e.getAttribute("position"),w=m?m.count:i.count,E=[0,0,0],C=["a","b","c"],T=new Array(3),I={},k=[];for(let O=0;O<w;O+=3){m?(E[0]=m.getX(O),E[1]=m.getX(O+1),E[2]=m.getX(O+2)):(E[0]=O,E[1]=O+1,E[2]=O+2);const{a:B,b:F,c:H}=qg;if(B.fromBufferAttribute(i,E[0]),F.fromBufferAttribute(i,E[1]),H.fromBufferAttribute(i,E[2]),qg.getNormal(V0),T[0]=`${Math.round(B.x*c)},${Math.round(B.y*c)},${Math.round(B.z*c)}`,T[1]=`${Math.round(F.x*c)},${Math.round(F.y*c)},${Math.round(F.z*c)}`,T[2]=`${Math.round(H.x*c)},${Math.round(H.y*c)},${Math.round(H.z*c)}`,!(T[0]===T[1]||T[1]===T[2]||T[2]===T[0]))for(let Y=0;Y<3;Y++){const K=(Y+1)%3,ne=T[Y],le=T[K],fe=qg[C[Y]],Ae=qg[C[K]],oe=`${ne}_${le}`,ce=`${le}_${ne}`;ce in I&&I[ce]?(V0.dot(I[ce].normal)<=f&&(k.push(fe.x,fe.y,fe.z),k.push(Ae.x,Ae.y,Ae.z)),I[ce]=null):oe in I||(I[oe]={index0:E[Y],index1:E[K],normal:V0.clone()})}}for(const O in I)if(I[O]){const{index0:B,index1:F}=I[O];Wg.fromBufferAttribute(i,B),Hg.fromBufferAttribute(i,F),k.push(Wg.x,Wg.y,Wg.z),k.push(Hg.x,Hg.y,Hg.z)}this.setAttribute("position",new hi(k,3))}}}class sd extends hm{constructor(e){super(e),this.uuid=pl(),this.type="Shape",this.holes=[]}getPointsHoles(e){const n=[];for(let a=0,c=this.holes.length;a<c;a++)n[a]=this.holes[a].getPoints(e);return n}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let n=0,a=e.holes.length;n<a;n++){const c=e.holes[n];this.holes.push(c.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let n=0,a=this.holes.length;n<a;n++){const c=this.holes[n];e.holes.push(c.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let n=0,a=e.holes.length;n<a;n++){const c=e.holes[n];this.holes.push(new hm().fromJSON(c))}return this}}const nO={triangulate:function(d,e,n=2){const a=e&&e.length,c=a?e[0]*n:d.length;let f=ET(d,0,c,n,!0);const m=[];if(!f||f.next===f.prev)return m;let i,w,E,C,T,I,k;if(a&&(f=aO(d,e,f,n)),d.length>80*n){i=E=d[0],w=C=d[1];for(let O=n;O<c;O+=n)T=d[O],I=d[O+1],T<i&&(i=T),I<w&&(w=I),T>E&&(E=T),I>C&&(C=I);k=Math.max(E-i,C-w),k=k!==0?1/k:0}return dm(f,m,n,i,w,k),m}};function ET(d,e,n,a,c){let f,m;if(c===yO(d,e,n,a)>0)for(f=e;f<n;f+=a)m=yS(f,d[f],d[f+1],m);else for(f=n-a;f>=e;f-=a)m=yS(f,d[f],d[f+1],m);return m&&$_(m,m.next)&&(pm(m),m=m.next),m}function ch(d,e){if(!d)return d;e||(e=d);let n=d,a;do if(a=!1,!n.steiner&&($_(n,n.next)||Ms(n.prev,n,n.next)===0)){if(pm(n),n=e=n.prev,n===n.next)break;a=!0}else n=n.next;while(a||n!==e);return e}function dm(d,e,n,a,c,f,m){if(!d)return;!m&&f&&dO(d,a,c,f);let i=d,w,E;for(;d.prev!==d.next;){if(w=d.prev,E=d.next,f?rO(d,a,c,f):iO(d)){e.push(w.i/n),e.push(d.i/n),e.push(E.i/n),pm(d),d=E.next,i=E.next;continue}if(d=E,d===i){m?m===1?(d=sO(ch(d),e,n),dm(d,e,n,a,c,f,2)):m===2&&oO(d,e,n,a,c,f):dm(ch(d),e,n,a,c,f,1);break}}}function iO(d){const e=d.prev,n=d,a=d.next;if(Ms(e,n,a)>=0)return!1;let c=d.next.next;for(;c!==d.prev;){if(Rf(e.x,e.y,n.x,n.y,a.x,a.y,c.x,c.y)&&Ms(c.prev,c,c.next)>=0)return!1;c=c.next}return!0}function rO(d,e,n,a){const c=d.prev,f=d,m=d.next;if(Ms(c,f,m)>=0)return!1;const i=c.x<f.x?c.x<m.x?c.x:m.x:f.x<m.x?f.x:m.x,w=c.y<f.y?c.y<m.y?c.y:m.y:f.y<m.y?f.y:m.y,E=c.x>f.x?c.x>m.x?c.x:m.x:f.x>m.x?f.x:m.x,C=c.y>f.y?c.y>m.y?c.y:m.y:f.y>m.y?f.y:m.y,T=Ux(i,w,e,n,a),I=Ux(E,C,e,n,a);let k=d.prevZ,O=d.nextZ;for(;k&&k.z>=T&&O&&O.z<=I;){if(k!==d.prev&&k!==d.next&&Rf(c.x,c.y,f.x,f.y,m.x,m.y,k.x,k.y)&&Ms(k.prev,k,k.next)>=0||(k=k.prevZ,O!==d.prev&&O!==d.next&&Rf(c.x,c.y,f.x,f.y,m.x,m.y,O.x,O.y)&&Ms(O.prev,O,O.next)>=0))return!1;O=O.nextZ}for(;k&&k.z>=T;){if(k!==d.prev&&k!==d.next&&Rf(c.x,c.y,f.x,f.y,m.x,m.y,k.x,k.y)&&Ms(k.prev,k,k.next)>=0)return!1;k=k.prevZ}for(;O&&O.z<=I;){if(O!==d.prev&&O!==d.next&&Rf(c.x,c.y,f.x,f.y,m.x,m.y,O.x,O.y)&&Ms(O.prev,O,O.next)>=0)return!1;O=O.nextZ}return!0}function sO(d,e,n){let a=d;do{const c=a.prev,f=a.next.next;!$_(c,f)&&TT(c,a,a.next,f)&&fm(c,f)&&fm(f,c)&&(e.push(c.i/n),e.push(a.i/n),e.push(f.i/n),pm(a),pm(a.next),a=d=f),a=a.next}while(a!==d);return ch(a)}function oO(d,e,n,a,c,f){let m=d;do{let i=m.next.next;for(;i!==m.prev;){if(m.i!==i.i&&mO(m,i)){let w=AT(m,i);m=ch(m,m.next),w=ch(w,w.next),dm(m,e,n,a,c,f),dm(w,e,n,a,c,f);return}i=i.next}m=m.next}while(m!==d)}function aO(d,e,n,a){const c=[];let f,m,i,w,E;for(f=0,m=e.length;f<m;f++)i=e[f]*a,w=f<m-1?e[f+1]*a:d.length,E=ET(d,i,w,a,!1),E===E.next&&(E.steiner=!0),c.push(pO(E));for(c.sort(lO),f=0;f<c.length;f++)cO(c[f],n),n=ch(n,n.next);return n}function lO(d,e){return d.x-e.x}function cO(d,e){if(e=uO(d,e),e){const n=AT(e,d);ch(e,e.next),ch(n,n.next)}}function uO(d,e){let n=e;const a=d.x,c=d.y;let f=-1/0,m;do{if(c<=n.y&&c>=n.next.y&&n.next.y!==n.y){const I=n.x+(c-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(I<=a&&I>f){if(f=I,I===a){if(c===n.y)return n;if(c===n.next.y)return n.next}m=n.x<n.next.x?n:n.next}}n=n.next}while(n!==e);if(!m)return null;if(a===f)return m;const i=m,w=m.x,E=m.y;let C=1/0,T;n=m;do a>=n.x&&n.x>=w&&a!==n.x&&Rf(c<E?a:f,c,w,E,c<E?f:a,c,n.x,n.y)&&(T=Math.abs(c-n.y)/(a-n.x),fm(n,d)&&(T<C||T===C&&(n.x>m.x||n.x===m.x&&hO(m,n)))&&(m=n,C=T)),n=n.next;while(n!==i);return m}function hO(d,e){return Ms(d.prev,d,e.prev)<0&&Ms(e.next,d,d.next)<0}function dO(d,e,n,a){let c=d;do c.z===null&&(c.z=Ux(c.x,c.y,e,n,a)),c.prevZ=c.prev,c.nextZ=c.next,c=c.next;while(c!==d);c.prevZ.nextZ=null,c.prevZ=null,fO(c)}function fO(d){let e,n,a,c,f,m,i,w,E=1;do{for(n=d,d=null,f=null,m=0;n;){for(m++,a=n,i=0,e=0;e<E&&(i++,a=a.nextZ,!!a);e++);for(w=E;i>0||w>0&&a;)i!==0&&(w===0||!a||n.z<=a.z)?(c=n,n=n.nextZ,i--):(c=a,a=a.nextZ,w--),f?f.nextZ=c:d=c,c.prevZ=f,f=c;n=a}f.nextZ=null,E*=2}while(m>1);return d}function Ux(d,e,n,a,c){return d=32767*(d-n)*c,e=32767*(e-a)*c,d=(d|d<<8)&16711935,d=(d|d<<4)&252645135,d=(d|d<<2)&858993459,d=(d|d<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,d|e<<1}function pO(d){let e=d,n=d;do(e.x<n.x||e.x===n.x&&e.y<n.y)&&(n=e),e=e.next;while(e!==d);return n}function Rf(d,e,n,a,c,f,m,i){return(c-m)*(e-i)-(d-m)*(f-i)>=0&&(d-m)*(a-i)-(n-m)*(e-i)>=0&&(n-m)*(f-i)-(c-m)*(a-i)>=0}function mO(d,e){return d.next.i!==e.i&&d.prev.i!==e.i&&!gO(d,e)&&(fm(d,e)&&fm(e,d)&&_O(d,e)&&(Ms(d.prev,d,e.prev)||Ms(d,e.prev,e))||$_(d,e)&&Ms(d.prev,d,d.next)>0&&Ms(e.prev,e,e.next)>0)}function Ms(d,e,n){return(e.y-d.y)*(n.x-e.x)-(e.x-d.x)*(n.y-e.y)}function $_(d,e){return d.x===e.x&&d.y===e.y}function TT(d,e,n,a){const c=Xg(Ms(d,e,n)),f=Xg(Ms(d,e,a)),m=Xg(Ms(n,a,d)),i=Xg(Ms(n,a,e));return!!(c!==f&&m!==i||c===0&&Zg(d,n,e)||f===0&&Zg(d,a,e)||m===0&&Zg(n,d,a)||i===0&&Zg(n,e,a))}function Zg(d,e,n){return e.x<=Math.max(d.x,n.x)&&e.x>=Math.min(d.x,n.x)&&e.y<=Math.max(d.y,n.y)&&e.y>=Math.min(d.y,n.y)}function Xg(d){return d>0?1:d<0?-1:0}function gO(d,e){let n=d;do{if(n.i!==d.i&&n.next.i!==d.i&&n.i!==e.i&&n.next.i!==e.i&&TT(n,n.next,d,e))return!0;n=n.next}while(n!==d);return!1}function fm(d,e){return Ms(d.prev,d,d.next)<0?Ms(d,e,d.next)>=0&&Ms(d,d.prev,e)>=0:Ms(d,e,d.prev)<0||Ms(d,d.next,e)<0}function _O(d,e){let n=d,a=!1;const c=(d.x+e.x)/2,f=(d.y+e.y)/2;do n.y>f!=n.next.y>f&&n.next.y!==n.y&&c<(n.next.x-n.x)*(f-n.y)/(n.next.y-n.y)+n.x&&(a=!a),n=n.next;while(n!==d);return a}function AT(d,e){const n=new Vx(d.i,d.x,d.y),a=new Vx(e.i,e.x,e.y),c=d.next,f=e.prev;return d.next=e,e.prev=d,n.next=c,c.prev=n,a.next=n,n.prev=a,f.next=a,a.prev=f,a}function yS(d,e,n,a){const c=new Vx(d,e,n);return a?(c.next=a.next,c.prev=a,a.next.prev=c,a.next=c):(c.prev=c,c.next=c),c}function pm(d){d.next.prev=d.prev,d.prev.next=d.next,d.prevZ&&(d.prevZ.nextZ=d.nextZ),d.nextZ&&(d.nextZ.prevZ=d.prevZ)}function Vx(d,e,n){this.i=d,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function yO(d,e,n,a){let c=0;for(let f=e,m=n-a;f<n;f+=a)c+=(d[m]-d[f])*(d[f+1]+d[m+1]),m=f;return c}class Uc{static area(e){const n=e.length;let a=0;for(let c=n-1,f=0;f<n;c=f++)a+=e[c].x*e[f].y-e[f].x*e[c].y;return a*.5}static isClockWise(e){return Uc.area(e)<0}static triangulateShape(e,n){const a=[],c=[],f=[];xS(e),vS(a,e);let m=e.length;n.forEach(xS);for(let w=0;w<n.length;w++)c.push(m),m+=n[w].length,vS(a,n[w]);const i=nO.triangulate(a,c);for(let w=0;w<i.length;w+=3)f.push(i.slice(w,w+3));return f}}function xS(d){const e=d.length;e>2&&d[e-1].equals(d[0])&&d.pop()}function vS(d,e){for(let n=0;n<e.length;n++)d.push(e[n].x),d.push(e[n].y)}class jf extends qi{constructor(e=new sd([new tn(.5,.5),new tn(-.5,.5),new tn(-.5,-.5),new tn(.5,-.5)]),n={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:n},e=Array.isArray(e)?e:[e];const a=this,c=[],f=[];for(let i=0,w=e.length;i<w;i++){const E=e[i];m(E)}this.setAttribute("position",new hi(c,3)),this.setAttribute("uv",new hi(f,2)),this.computeVertexNormals();function m(i){const w=[],E=n.curveSegments!==void 0?n.curveSegments:12,C=n.steps!==void 0?n.steps:1;let T=n.depth!==void 0?n.depth:1,I=n.bevelEnabled!==void 0?n.bevelEnabled:!0,k=n.bevelThickness!==void 0?n.bevelThickness:.2,O=n.bevelSize!==void 0?n.bevelSize:k-.1,B=n.bevelOffset!==void 0?n.bevelOffset:0,F=n.bevelSegments!==void 0?n.bevelSegments:3;const H=n.extrudePath,Y=n.UVGenerator!==void 0?n.UVGenerator:xO;n.amount!==void 0&&(console.warn("THREE.ExtrudeBufferGeometry: amount has been renamed to depth."),T=n.amount);let K,ne=!1,le,fe,Ae,oe;H&&(K=H.getSpacedPoints(C),ne=!0,I=!1,le=H.computeFrenetFrames(C,!1),fe=new Me,Ae=new Me,oe=new Me),I||(F=0,k=0,O=0,B=0);const ce=i.extractPoints(E);let Re=ce.shape;const ke=ce.holes;if(!Uc.isClockWise(Re)){Re=Re.reverse();for(let qt=0,Dt=ke.length;qt<Dt;qt++){const gn=ke[qt];Uc.isClockWise(gn)&&(ke[qt]=gn.reverse())}}const St=Uc.triangulateShape(Re,ke),Je=Re;for(let qt=0,Dt=ke.length;qt<Dt;qt++){const gn=ke[qt];Re=Re.concat(gn)}function It(qt,Dt,gn){return Dt||console.error("THREE.ExtrudeGeometry: vec does not exist"),Dt.clone().multiplyScalar(gn).add(qt)}const ft=Re.length,Nt=St.length;function Fe(qt,Dt,gn){let wn,Yt,rn;const dn=qt.x-Dt.x,Mn=qt.y-Dt.y,li=gn.x-qt.x,ti=gn.y-qt.y,Ie=dn*dn+Mn*Mn,xe=dn*ti-Mn*li;if(Math.abs(xe)>Number.EPSILON){const Tt=Math.sqrt(Ie),hn=Math.sqrt(li*li+ti*ti),_n=Dt.x-Mn/Tt,Sn=Dt.y+dn/Tt,ri=gn.x-ti/hn,kt=gn.y+li/hn,Hn=((ri-_n)*ti-(kt-Sn)*li)/(dn*ti-Mn*li);wn=_n+dn*Hn-qt.x,Yt=Sn+Mn*Hn-qt.y;const On=wn*wn+Yt*Yt;if(On<=2)return new tn(wn,Yt);rn=Math.sqrt(On/2)}else{let Tt=!1;dn>Number.EPSILON?li>Number.EPSILON&&(Tt=!0):dn<-Number.EPSILON?li<-Number.EPSILON&&(Tt=!0):Math.sign(Mn)===Math.sign(ti)&&(Tt=!0),Tt?(wn=-Mn,Yt=dn,rn=Math.sqrt(Ie)):(wn=dn,Yt=Mn,rn=Math.sqrt(Ie/2))}return new tn(wn/rn,Yt/rn)}const it=[];for(let qt=0,Dt=Je.length,gn=Dt-1,wn=qt+1;qt<Dt;qt++,gn++,wn++)gn===Dt&&(gn=0),wn===Dt&&(wn=0),it[qt]=Fe(Je[qt],Je[gn],Je[wn]);const tt=[];let Et,xt=it.concat();for(let qt=0,Dt=ke.length;qt<Dt;qt++){const gn=ke[qt];Et=[];for(let wn=0,Yt=gn.length,rn=Yt-1,dn=wn+1;wn<Yt;wn++,rn++,dn++)rn===Yt&&(rn=0),dn===Yt&&(dn=0),Et[wn]=Fe(gn[wn],gn[rn],gn[dn]);tt.push(Et),xt=xt.concat(Et)}for(let qt=0;qt<F;qt++){const Dt=qt/F,gn=k*Math.cos(Dt*Math.PI/2),wn=O*Math.sin(Dt*Math.PI/2)+B;for(let Yt=0,rn=Je.length;Yt<rn;Yt++){const dn=It(Je[Yt],it[Yt],wn);ei(dn.x,dn.y,-gn)}for(let Yt=0,rn=ke.length;Yt<rn;Yt++){const dn=ke[Yt];Et=tt[Yt];for(let Mn=0,li=dn.length;Mn<li;Mn++){const ti=It(dn[Mn],Et[Mn],wn);ei(ti.x,ti.y,-gn)}}}const Pt=O+B;for(let qt=0;qt<ft;qt++){const Dt=I?It(Re[qt],xt[qt],Pt):Re[qt];ne?(Ae.copy(le.normals[0]).multiplyScalar(Dt.x),fe.copy(le.binormals[0]).multiplyScalar(Dt.y),oe.copy(K[0]).add(Ae).add(fe),ei(oe.x,oe.y,oe.z)):ei(Dt.x,Dt.y,0)}for(let qt=1;qt<=C;qt++)for(let Dt=0;Dt<ft;Dt++){const gn=I?It(Re[Dt],xt[Dt],Pt):Re[Dt];ne?(Ae.copy(le.normals[qt]).multiplyScalar(gn.x),fe.copy(le.binormals[qt]).multiplyScalar(gn.y),oe.copy(K[qt]).add(Ae).add(fe),ei(oe.x,oe.y,oe.z)):ei(gn.x,gn.y,T/C*qt)}for(let qt=F-1;qt>=0;qt--){const Dt=qt/F,gn=k*Math.cos(Dt*Math.PI/2),wn=O*Math.sin(Dt*Math.PI/2)+B;for(let Yt=0,rn=Je.length;Yt<rn;Yt++){const dn=It(Je[Yt],it[Yt],wn);ei(dn.x,dn.y,T+gn)}for(let Yt=0,rn=ke.length;Yt<rn;Yt++){const dn=ke[Yt];Et=tt[Yt];for(let Mn=0,li=dn.length;Mn<li;Mn++){const ti=It(dn[Mn],Et[Mn],wn);ne?ei(ti.x,ti.y+K[C-1].y,K[C-1].x+gn):ei(ti.x,ti.y,T+gn)}}}ln(),pn();function ln(){const qt=c.length/3;if(I){let Dt=0,gn=ft*Dt;for(let wn=0;wn<Nt;wn++){const Yt=St[wn];oi(Yt[2]+gn,Yt[1]+gn,Yt[0]+gn)}Dt=C+F*2,gn=ft*Dt;for(let wn=0;wn<Nt;wn++){const Yt=St[wn];oi(Yt[0]+gn,Yt[1]+gn,Yt[2]+gn)}}else{for(let Dt=0;Dt<Nt;Dt++){const gn=St[Dt];oi(gn[2],gn[1],gn[0])}for(let Dt=0;Dt<Nt;Dt++){const gn=St[Dt];oi(gn[0]+ft*C,gn[1]+ft*C,gn[2]+ft*C)}}a.addGroup(qt,c.length/3-qt,0)}function pn(){const qt=c.length/3;let Dt=0;Mt(Je,Dt),Dt+=Je.length;for(let gn=0,wn=ke.length;gn<wn;gn++){const Yt=ke[gn];Mt(Yt,Dt),Dt+=Yt.length}a.addGroup(qt,c.length/3-qt,1)}function Mt(qt,Dt){let gn=qt.length;for(;--gn>=0;){const wn=gn;let Yt=gn-1;Yt<0&&(Yt=qt.length-1);for(let rn=0,dn=C+F*2;rn<dn;rn++){const Mn=ft*rn,li=ft*(rn+1),ti=Dt+wn+Mn,Ie=Dt+Yt+Mn,xe=Dt+Yt+li,Tt=Dt+wn+li;Wn(ti,Ie,xe,Tt)}}}function ei(qt,Dt,gn){w.push(qt),w.push(Dt),w.push(gn)}function oi(qt,Dt,gn){jt(qt),jt(Dt),jt(gn);const wn=c.length/3,Yt=Y.generateTopUV(a,c,wn-3,wn-2,wn-1);mn(Yt[0]),mn(Yt[1]),mn(Yt[2])}function Wn(qt,Dt,gn,wn){jt(qt),jt(Dt),jt(wn),jt(Dt),jt(gn),jt(wn);const Yt=c.length/3,rn=Y.generateSideWallUV(a,c,Yt-6,Yt-3,Yt-2,Yt-1);mn(rn[0]),mn(rn[1]),mn(rn[3]),mn(rn[1]),mn(rn[2]),mn(rn[3])}function jt(qt){c.push(w[qt*3+0]),c.push(w[qt*3+1]),c.push(w[qt*3+2])}function mn(qt){f.push(qt.x),f.push(qt.y)}}}toJSON(){const e=super.toJSON(),n=this.parameters.shapes,a=this.parameters.options;return vO(n,a,e)}static fromJSON(e,n){const a=[];for(let f=0,m=e.shapes.length;f<m;f++){const i=n[e.shapes[f]];a.push(i)}const c=e.options.extrudePath;return c!==void 0&&(e.options.extrudePath=new Lv[c.type]().fromJSON(c)),new jf(a,e.options)}}const xO={generateTopUV:function(d,e,n,a,c){const f=e[n*3],m=e[n*3+1],i=e[a*3],w=e[a*3+1],E=e[c*3],C=e[c*3+1];return[new tn(f,m),new tn(i,w),new tn(E,C)]},generateSideWallUV:function(d,e,n,a,c,f){const m=e[n*3],i=e[n*3+1],w=e[n*3+2],E=e[a*3],C=e[a*3+1],T=e[a*3+2],I=e[c*3],k=e[c*3+1],O=e[c*3+2],B=e[f*3],F=e[f*3+1],H=e[f*3+2];return Math.abs(i-C)<Math.abs(m-E)?[new tn(m,1-w),new tn(E,1-T),new tn(I,1-O),new tn(B,1-H)]:[new tn(i,1-w),new tn(C,1-T),new tn(k,1-O),new tn(F,1-H)]}};function vO(d,e,n){if(n.shapes=[],Array.isArray(d))for(let a=0,c=d.length;a<c;a++){const f=d[a];n.shapes.push(f.uuid)}else n.shapes.push(d.uuid);return n.options=Object.assign({},e),e.extrudePath!==void 0&&(n.options.extrudePath=e.extrudePath.toJSON()),n}class Wf extends jc{constructor(e=1,n=0){const a=(1+Math.sqrt(5))/2,c=[-1,a,0,1,a,0,-1,-a,0,1,-a,0,0,-1,a,0,1,a,0,-1,-a,0,1,-a,a,0,-1,a,0,1,-a,0,-1,-a,0,1],f=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(c,f,e,n),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:n}}static fromJSON(e){return new Wf(e.radius,e.detail)}}class dd extends jc{constructor(e=1,n=0){const a=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],c=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(a,c,e,n),this.type="OctahedronGeometry",this.parameters={radius:e,detail:n}}static fromJSON(e){return new dd(e.radius,e.detail)}}class Hf extends qi{constructor(e=.5,n=1,a=8,c=1,f=0,m=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:n,thetaSegments:a,phiSegments:c,thetaStart:f,thetaLength:m},a=Math.max(3,a),c=Math.max(1,c);const i=[],w=[],E=[],C=[];let T=e;const I=(n-e)/c,k=new Me,O=new tn;for(let B=0;B<=c;B++){for(let F=0;F<=a;F++){const H=f+F/a*m;k.x=T*Math.cos(H),k.y=T*Math.sin(H),w.push(k.x,k.y,k.z),E.push(0,0,1),O.x=(k.x/n+1)/2,O.y=(k.y/n+1)/2,C.push(O.x,O.y)}T+=I}for(let B=0;B<c;B++){const F=B*(a+1);for(let H=0;H<a;H++){const Y=H+F,K=Y,ne=Y+a+1,le=Y+a+2,fe=Y+1;i.push(K,ne,fe),i.push(ne,le,fe)}}this.setIndex(i),this.setAttribute("position",new hi(w,3)),this.setAttribute("normal",new hi(E,3)),this.setAttribute("uv",new hi(C,2))}static fromJSON(e){return new Hf(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class qf extends qi{constructor(e=new sd([new tn(0,.5),new tn(-.5,-.5),new tn(.5,-.5)]),n=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:n};const a=[],c=[],f=[],m=[];let i=0,w=0;if(Array.isArray(e)===!1)E(e);else for(let C=0;C<e.length;C++)E(e[C]),this.addGroup(i,w,C),i+=w,w=0;this.setIndex(a),this.setAttribute("position",new hi(c,3)),this.setAttribute("normal",new hi(f,3)),this.setAttribute("uv",new hi(m,2));function E(C){const T=c.length/3,I=C.extractPoints(n);let k=I.shape;const O=I.holes;Uc.isClockWise(k)===!1&&(k=k.reverse());for(let F=0,H=O.length;F<H;F++){const Y=O[F];Uc.isClockWise(Y)===!0&&(O[F]=Y.reverse())}const B=Uc.triangulateShape(k,O);for(let F=0,H=O.length;F<H;F++){const Y=O[F];k=k.concat(Y)}for(let F=0,H=k.length;F<H;F++){const Y=k[F];c.push(Y.x,Y.y,0),f.push(0,0,1),m.push(Y.x,Y.y)}for(let F=0,H=B.length;F<H;F++){const Y=B[F],K=Y[0]+T,ne=Y[1]+T,le=Y[2]+T;a.push(K,ne,le),w+=3}}}toJSON(){const e=super.toJSON(),n=this.parameters.shapes;return bO(n,e)}static fromJSON(e,n){const a=[];for(let c=0,f=e.shapes.length;c<f;c++){const m=n[e.shapes[c]];a.push(m)}return new qf(a,e.curveSegments)}}function bO(d,e){if(e.shapes=[],Array.isArray(d))for(let n=0,a=d.length;n<a;n++){const c=d[n];e.shapes.push(c.uuid)}else e.shapes.push(d.uuid);return e}class fd extends qi{constructor(e=1,n=32,a=16,c=0,f=Math.PI*2,m=0,i=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:n,heightSegments:a,phiStart:c,phiLength:f,thetaStart:m,thetaLength:i},n=Math.max(3,Math.floor(n)),a=Math.max(2,Math.floor(a));const w=Math.min(m+i,Math.PI);let E=0;const C=[],T=new Me,I=new Me,k=[],O=[],B=[],F=[];for(let H=0;H<=a;H++){const Y=[],K=H/a;let ne=0;H==0&&m==0?ne=.5/n:H==a&&w==Math.PI&&(ne=-.5/n);for(let le=0;le<=n;le++){const fe=le/n;T.x=-e*Math.cos(c+fe*f)*Math.sin(m+K*i),T.y=e*Math.cos(m+K*i),T.z=e*Math.sin(c+fe*f)*Math.sin(m+K*i),O.push(T.x,T.y,T.z),I.copy(T).normalize(),B.push(I.x,I.y,I.z),F.push(fe+ne,1-K),Y.push(E++)}C.push(Y)}for(let H=0;H<a;H++)for(let Y=0;Y<n;Y++){const K=C[H][Y+1],ne=C[H][Y],le=C[H+1][Y],fe=C[H+1][Y+1];(H!==0||m>0)&&k.push(K,ne,fe),(H!==a-1||w<Math.PI)&&k.push(ne,le,fe)}this.setIndex(k),this.setAttribute("position",new hi(O,3)),this.setAttribute("normal",new hi(B,3)),this.setAttribute("uv",new hi(F,2))}static fromJSON(e){return new fd(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class Zf extends jc{constructor(e=1,n=0){const a=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],c=[2,1,0,0,3,2,1,3,0,2,3,1];super(a,c,e,n),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:n}}static fromJSON(e){return new Zf(e.radius,e.detail)}}class Xf extends qi{constructor(e=1,n=.4,a=8,c=6,f=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:n,radialSegments:a,tubularSegments:c,arc:f},a=Math.floor(a),c=Math.floor(c);const m=[],i=[],w=[],E=[],C=new Me,T=new Me,I=new Me;for(let k=0;k<=a;k++)for(let O=0;O<=c;O++){const B=O/c*f,F=k/a*Math.PI*2;T.x=(e+n*Math.cos(F))*Math.cos(B),T.y=(e+n*Math.cos(F))*Math.sin(B),T.z=n*Math.sin(F),i.push(T.x,T.y,T.z),C.x=e*Math.cos(B),C.y=e*Math.sin(B),I.subVectors(T,C).normalize(),w.push(I.x,I.y,I.z),E.push(O/c),E.push(k/a)}for(let k=1;k<=a;k++)for(let O=1;O<=c;O++){const B=(c+1)*k+O-1,F=(c+1)*(k-1)+O-1,H=(c+1)*(k-1)+O,Y=(c+1)*k+O;m.push(B,F,Y),m.push(F,H,Y)}this.setIndex(m),this.setAttribute("position",new hi(i,3)),this.setAttribute("normal",new hi(w,3)),this.setAttribute("uv",new hi(E,2))}static fromJSON(e){return new Xf(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class $f extends qi{constructor(e=1,n=.4,a=64,c=8,f=2,m=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:n,tubularSegments:a,radialSegments:c,p:f,q:m},a=Math.floor(a),c=Math.floor(c);const i=[],w=[],E=[],C=[],T=new Me,I=new Me,k=new Me,O=new Me,B=new Me,F=new Me,H=new Me;for(let K=0;K<=a;++K){const ne=K/a*f*Math.PI*2;Y(ne,f,m,e,k),Y(ne+.01,f,m,e,O),F.subVectors(O,k),H.addVectors(O,k),B.crossVectors(F,H),H.crossVectors(B,F),B.normalize(),H.normalize();for(let le=0;le<=c;++le){const fe=le/c*Math.PI*2,Ae=-n*Math.cos(fe),oe=n*Math.sin(fe);T.x=k.x+(Ae*H.x+oe*B.x),T.y=k.y+(Ae*H.y+oe*B.y),T.z=k.z+(Ae*H.z+oe*B.z),w.push(T.x,T.y,T.z),I.subVectors(T,k).normalize(),E.push(I.x,I.y,I.z),C.push(K/a),C.push(le/c)}}for(let K=1;K<=a;K++)for(let ne=1;ne<=c;ne++){const le=(c+1)*(K-1)+(ne-1),fe=(c+1)*K+(ne-1),Ae=(c+1)*K+ne,oe=(c+1)*(K-1)+ne;i.push(le,fe,oe),i.push(fe,Ae,oe)}this.setIndex(i),this.setAttribute("position",new hi(w,3)),this.setAttribute("normal",new hi(E,3)),this.setAttribute("uv",new hi(C,2));function Y(K,ne,le,fe,Ae){const oe=Math.cos(K),ce=Math.sin(K),Re=le/ne*K,ke=Math.cos(Re);Ae.x=fe*(2+ke)*.5*oe,Ae.y=fe*(2+ke)*ce*.5,Ae.z=fe*Math.sin(Re)*.5}}static fromJSON(e){return new $f(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class Yf extends qi{constructor(e=new Iv(new Me(-1,-1,0),new Me(-1,1,0),new Me(1,1,0)),n=64,a=1,c=8,f=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:n,radius:a,radialSegments:c,closed:f};const m=e.computeFrenetFrames(n,f);this.tangents=m.tangents,this.normals=m.normals,this.binormals=m.binormals;const i=new Me,w=new Me,E=new tn;let C=new Me;const T=[],I=[],k=[],O=[];B(),this.setIndex(O),this.setAttribute("position",new hi(T,3)),this.setAttribute("normal",new hi(I,3)),this.setAttribute("uv",new hi(k,2));function B(){for(let K=0;K<n;K++)F(K);F(f===!1?n:0),Y(),H()}function F(K){C=e.getPointAt(K/n,C);const ne=m.normals[K],le=m.binormals[K];for(let fe=0;fe<=c;fe++){const Ae=fe/c*Math.PI*2,oe=Math.sin(Ae),ce=-Math.cos(Ae);w.x=ce*ne.x+oe*le.x,w.y=ce*ne.y+oe*le.y,w.z=ce*ne.z+oe*le.z,w.normalize(),I.push(w.x,w.y,w.z),i.x=C.x+a*w.x,i.y=C.y+a*w.y,i.z=C.z+a*w.z,T.push(i.x,i.y,i.z)}}function H(){for(let K=1;K<=n;K++)for(let ne=1;ne<=c;ne++){const le=(c+1)*(K-1)+(ne-1),fe=(c+1)*K+(ne-1),Ae=(c+1)*K+ne,oe=(c+1)*(K-1)+ne;O.push(le,fe,oe),O.push(fe,Ae,oe)}}function Y(){for(let K=0;K<=n;K++)for(let ne=0;ne<=c;ne++)E.x=K/n,E.y=ne/c,k.push(E.x,E.y)}}toJSON(){const e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new Yf(new Lv[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class CT extends qi{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const n=[],a=new Set,c=new Me,f=new Me;if(e.index!==null){const m=e.attributes.position,i=e.index;let w=e.groups;w.length===0&&(w=[{start:0,count:i.count,materialIndex:0}]);for(let E=0,C=w.length;E<C;++E){const T=w[E],I=T.start,k=T.count;for(let O=I,B=I+k;O<B;O+=3)for(let F=0;F<3;F++){const H=i.getX(O+F),Y=i.getX(O+(F+1)%3);c.fromBufferAttribute(m,H),f.fromBufferAttribute(m,Y),bS(c,f,a)===!0&&(n.push(c.x,c.y,c.z),n.push(f.x,f.y,f.z))}}}else{const m=e.attributes.position;for(let i=0,w=m.count/3;i<w;i++)for(let E=0;E<3;E++){const C=3*i+E,T=3*i+(E+1)%3;c.fromBufferAttribute(m,C),f.fromBufferAttribute(m,T),bS(c,f,a)===!0&&(n.push(c.x,c.y,c.z),n.push(f.x,f.y,f.z))}}this.setAttribute("position",new hi(n,3))}}}function bS(d,e,n){const a=`${d.x},${d.y},${d.z}-${e.x},${e.y},${e.z}`,c=`${e.x},${e.y},${e.z}-${d.x},${d.y},${d.z}`;return n.has(a)===!0||n.has(c)===!0?!1:(n.add(a),n.add(c),!0)}var wS=Object.freeze({__proto__:null,BoxGeometry:Vc,BoxBufferGeometry:Vc,CapsuleGeometry:Nf,CapsuleBufferGeometry:Nf,CircleGeometry:Uf,CircleBufferGeometry:Uf,ConeGeometry:Vf,ConeBufferGeometry:Vf,CylinderGeometry:lh,CylinderBufferGeometry:lh,DodecahedronGeometry:Gf,DodecahedronBufferGeometry:Gf,EdgesGeometry:MT,ExtrudeGeometry:jf,ExtrudeBufferGeometry:jf,IcosahedronGeometry:Wf,IcosahedronBufferGeometry:Wf,LatheGeometry:hd,LatheBufferGeometry:hd,OctahedronGeometry:dd,OctahedronBufferGeometry:dd,PlaneGeometry:cd,PlaneBufferGeometry:cd,PolyhedronGeometry:jc,PolyhedronBufferGeometry:jc,RingGeometry:Hf,RingBufferGeometry:Hf,ShapeGeometry:qf,ShapeBufferGeometry:qf,SphereGeometry:fd,SphereBufferGeometry:fd,TetrahedronGeometry:Zf,TetrahedronBufferGeometry:Zf,TorusGeometry:Xf,TorusBufferGeometry:Xf,TorusKnotGeometry:$f,TorusKnotBufferGeometry:$f,TubeGeometry:Yf,TubeBufferGeometry:Yf,WireframeGeometry:CT});class IT extends fo{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new Kn(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}}class PT extends Gc{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Rv extends fo{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new Kn(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Kn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=yd,this.normalScale=new tn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class LT extends Rv{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new tn(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Zs(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(n){this.ior=(1+.4*n)/(1-.4*n)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Kn(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=0,this.attenuationColor=new Kn(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Kn(1,1,1),this.specularColorMap=null,this._sheen=0,this._clearcoat=0,this._iridescence=0,this._transmission=0,this.setValues(e)}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class RT extends fo{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Kn(16777215),this.specular=new Kn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Kn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=yd,this.normalScale=new tn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Sm,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class DT extends fo{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Kn(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Kn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=yd,this.normalScale=new tn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class zT extends fo{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=yd,this.normalScale=new tn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class kT extends fo{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Kn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Kn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Sm,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class OT extends fo{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Kn(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=yd,this.normalScale=new tn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class FT extends La{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}const wO={ShadowMaterial:IT,SpriteMaterial:Sv,RawShaderMaterial:PT,ShaderMaterial:Gc,PointsMaterial:q_,MeshPhysicalMaterial:LT,MeshStandardMaterial:Rv,MeshPhongMaterial:RT,MeshToonMaterial:DT,MeshNormalMaterial:zT,MeshLambertMaterial:kT,MeshDepthMaterial:vv,MeshDistanceMaterial:bv,MeshBasicMaterial:uh,MeshMatcapMaterial:OT,LineDashedMaterial:FT,LineBasicMaterial:La,Material:fo};fo.fromType=function(d){return new wO[d]};const rs={arraySlice:function(d,e,n){return rs.isTypedArray(d)?new d.constructor(d.subarray(e,n!==void 0?n:d.length)):d.slice(e,n)},convertArray:function(d,e,n){return!d||!n&&d.constructor===e?d:typeof e.BYTES_PER_ELEMENT=="number"?new e(d):Array.prototype.slice.call(d)},isTypedArray:function(d){return ArrayBuffer.isView(d)&&!(d instanceof DataView)},getKeyframeOrder:function(d){function e(c,f){return d[c]-d[f]}const n=d.length,a=new Array(n);for(let c=0;c!==n;++c)a[c]=c;return a.sort(e),a},sortedArray:function(d,e,n){const a=d.length,c=new d.constructor(a);for(let f=0,m=0;m!==a;++f){const i=n[f]*e;for(let w=0;w!==e;++w)c[m++]=d[i+w]}return c},flattenJSON:function(d,e,n,a){let c=1,f=d[0];for(;f!==void 0&&f[a]===void 0;)f=d[c++];if(f===void 0)return;let m=f[a];if(m!==void 0)if(Array.isArray(m))do m=f[a],m!==void 0&&(e.push(f.time),n.push.apply(n,m)),f=d[c++];while(f!==void 0);else if(m.toArray!==void 0)do m=f[a],m!==void 0&&(e.push(f.time),m.toArray(n,n.length)),f=d[c++];while(f!==void 0);else do m=f[a],m!==void 0&&(e.push(f.time),n.push(m)),f=d[c++];while(f!==void 0)},subclip:function(d,e,n,a,c=30){const f=d.clone();f.name=e;const m=[];for(let w=0;w<f.tracks.length;++w){const E=f.tracks[w],C=E.getValueSize(),T=[],I=[];for(let k=0;k<E.times.length;++k){const O=E.times[k]*c;if(!(O<n||O>=a)){T.push(E.times[k]);for(let B=0;B<C;++B)I.push(E.values[k*C+B])}}T.length!==0&&(E.times=rs.convertArray(T,E.times.constructor),E.values=rs.convertArray(I,E.values.constructor),m.push(E))}f.tracks=m;let i=1/0;for(let w=0;w<f.tracks.length;++w)i>f.tracks[w].times[0]&&(i=f.tracks[w].times[0]);for(let w=0;w<f.tracks.length;++w)f.tracks[w].shift(-1*i);return f.resetDuration(),f},makeClipAdditive:function(d,e=0,n=d,a=30){a<=0&&(a=30);const c=n.tracks.length,f=e/a;for(let m=0;m<c;++m){const i=n.tracks[m],w=i.ValueTypeName;if(w==="bool"||w==="string")continue;const E=d.tracks.find(function(H){return H.name===i.name&&H.ValueTypeName===w});if(E===void 0)continue;let C=0;const T=i.getValueSize();i.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(C=T/3);let I=0;const k=E.getValueSize();E.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(I=k/3);const O=i.times.length-1;let B;if(f<=i.times[0]){const H=C,Y=T-C;B=rs.arraySlice(i.values,H,Y)}else if(f>=i.times[O]){const H=O*T+C,Y=H+T-C;B=rs.arraySlice(i.values,H,Y)}else{const H=i.createInterpolant(),Y=C,K=T-C;H.evaluate(f),B=rs.arraySlice(H.resultBuffer,Y,K)}w==="quaternion"&&new Ko().fromArray(B).normalize().conjugate().toArray(B);const F=E.times.length;for(let H=0;H<F;++H){const Y=H*k+I;if(w==="quaternion")Ko.multiplyQuaternionsFlat(E.values,Y,B,0,E.values,Y);else{const K=k-I*2;for(let ne=0;ne<K;++ne)E.values[Y+ne]-=B[ne]}}}return d.blendMode=pv,d}};class Am{constructor(e,n,a,c){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=c!==void 0?c:new n.constructor(a),this.sampleValues=n,this.valueSize=a,this.settings=null,this.DefaultSettings_={}}evaluate(e){const n=this.parameterPositions;let a=this._cachedIndex,c=n[a],f=n[a-1];e:{t:{let m;n:{i:if(!(e<c)){for(let i=a+2;;){if(c===void 0){if(e<f)break i;return a=n.length,this._cachedIndex=a,this.copySampleValue_(a-1)}if(a===i)break;if(f=c,c=n[++a],e<c)break t}m=n.length;break n}if(!(e>=f)){const i=n[1];e<i&&(a=2,f=i);for(let w=a-2;;){if(f===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(a===w)break;if(c=f,f=n[--a-1],e>=f)break t}m=a,a=0;break n}break e}for(;a<m;){const i=a+m>>>1;e<n[i]?m=i:a=i+1}if(c=n[a],f=n[a-1],f===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(c===void 0)return a=n.length,this._cachedIndex=a,this.copySampleValue_(a-1)}this._cachedIndex=a,this.intervalChanged_(a,f,c)}return this.interpolate_(a,f,e,c)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const n=this.resultBuffer,a=this.sampleValues,c=this.valueSize,f=e*c;for(let m=0;m!==c;++m)n[m]=a[f+m];return n}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class BT extends Am{constructor(e,n,a,c){super(e,n,a,c),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:$h,endingEnd:$h}}intervalChanged_(e,n,a){const c=this.parameterPositions;let f=e-2,m=e+1,i=c[f],w=c[m];if(i===void 0)switch(this.getSettings_().endingStart){case Yh:f=e,i=2*n-a;break;case lm:f=c.length-2,i=n+c[f]-c[f+1];break;default:f=e,i=a}if(w===void 0)switch(this.getSettings_().endingEnd){case Yh:m=e,w=2*a-n;break;case lm:m=1,w=a+c[1]-c[0];break;default:m=e-1,w=n}const E=(a-n)*.5,C=this.valueSize;this._weightPrev=E/(n-i),this._weightNext=E/(w-a),this._offsetPrev=f*C,this._offsetNext=m*C}interpolate_(e,n,a,c){const f=this.resultBuffer,m=this.sampleValues,i=this.valueSize,w=e*i,E=w-i,C=this._offsetPrev,T=this._offsetNext,I=this._weightPrev,k=this._weightNext,O=(a-n)/(c-n),B=O*O,F=B*O,H=-I*F+2*I*B-I*O,Y=(1+I)*F+(-1.5-2*I)*B+(-.5+I)*O+1,K=(-1-k)*F+(1.5+k)*B+.5*O,ne=k*F-k*B;for(let le=0;le!==i;++le)f[le]=H*m[C+le]+Y*m[E+le]+K*m[w+le]+ne*m[T+le];return f}}class Dv extends Am{constructor(e,n,a,c){super(e,n,a,c)}interpolate_(e,n,a,c){const f=this.resultBuffer,m=this.sampleValues,i=this.valueSize,w=e*i,E=w-i,C=(a-n)/(c-n),T=1-C;for(let I=0;I!==i;++I)f[I]=m[E+I]*T+m[w+I]*C;return f}}class NT extends Am{constructor(e,n,a,c){super(e,n,a,c)}interpolate_(e){return this.copySampleValue_(e-1)}}class ac{constructor(e,n,a,c){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(n===void 0||n.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=rs.convertArray(n,this.TimeBufferType),this.values=rs.convertArray(a,this.ValueBufferType),this.setInterpolation(c||this.DefaultInterpolation)}static toJSON(e){const n=e.constructor;let a;if(n.toJSON!==this.toJSON)a=n.toJSON(e);else{a={name:e.name,times:rs.convertArray(e.times,Array),values:rs.convertArray(e.values,Array)};const c=e.getInterpolation();c!==e.DefaultInterpolation&&(a.interpolation=c)}return a.type=e.ValueTypeName,a}InterpolantFactoryMethodDiscrete(e){return new NT(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Dv(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new BT(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let n;switch(e){case om:n=this.InterpolantFactoryMethodDiscrete;break;case am:n=this.InterpolantFactoryMethodLinear;break;case u_:n=this.InterpolantFactoryMethodSmooth;break}if(n===void 0){const a="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(a);return console.warn("THREE.KeyframeTrack:",a),this}return this.createInterpolant=n,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return om;case this.InterpolantFactoryMethodLinear:return am;case this.InterpolantFactoryMethodSmooth:return u_}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const n=this.times;for(let a=0,c=n.length;a!==c;++a)n[a]+=e}return this}scale(e){if(e!==1){const n=this.times;for(let a=0,c=n.length;a!==c;++a)n[a]*=e}return this}trim(e,n){const a=this.times,c=a.length;let f=0,m=c-1;for(;f!==c&&a[f]<e;)++f;for(;m!==-1&&a[m]>n;)--m;if(++m,f!==0||m!==c){f>=m&&(m=Math.max(m,1),f=m-1);const i=this.getValueSize();this.times=rs.arraySlice(a,f,m),this.values=rs.arraySlice(this.values,f*i,m*i)}return this}validate(){let e=!0;const n=this.getValueSize();n-Math.floor(n)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const a=this.times,c=this.values,f=a.length;f===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let m=null;for(let i=0;i!==f;i++){const w=a[i];if(typeof w=="number"&&isNaN(w)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,i,w),e=!1;break}if(m!==null&&m>w){console.error("THREE.KeyframeTrack: Out of order keys.",this,i,w,m),e=!1;break}m=w}if(c!==void 0&&rs.isTypedArray(c))for(let i=0,w=c.length;i!==w;++i){const E=c[i];if(isNaN(E)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,i,E),e=!1;break}}return e}optimize(){const e=rs.arraySlice(this.times),n=rs.arraySlice(this.values),a=this.getValueSize(),c=this.getInterpolation()===u_,f=e.length-1;let m=1;for(let i=1;i<f;++i){let w=!1;const E=e[i],C=e[i+1];if(E!==C&&(i!==1||E!==e[0]))if(c)w=!0;else{const T=i*a,I=T-a,k=T+a;for(let O=0;O!==a;++O){const B=n[T+O];if(B!==n[I+O]||B!==n[k+O]){w=!0;break}}}if(w){if(i!==m){e[m]=e[i];const T=i*a,I=m*a;for(let k=0;k!==a;++k)n[I+k]=n[T+k]}++m}}if(f>0){e[m]=e[f];for(let i=f*a,w=m*a,E=0;E!==a;++E)n[w+E]=n[i+E];++m}return m!==e.length?(this.times=rs.arraySlice(e,0,m),this.values=rs.arraySlice(n,0,m*a)):(this.times=e,this.values=n),this}clone(){const e=rs.arraySlice(this.times,0),n=rs.arraySlice(this.values,0),a=this.constructor,c=new a(this.name,e,n);return c.createInterpolant=this.createInterpolant,c}}ac.prototype.TimeBufferType=Float32Array;ac.prototype.ValueBufferType=Float32Array;ac.prototype.DefaultInterpolation=am;class bd extends ac{}bd.prototype.ValueTypeName="bool";bd.prototype.ValueBufferType=Array;bd.prototype.DefaultInterpolation=om;bd.prototype.InterpolantFactoryMethodLinear=void 0;bd.prototype.InterpolantFactoryMethodSmooth=void 0;class zv extends ac{}zv.prototype.ValueTypeName="color";class mm extends ac{}mm.prototype.ValueTypeName="number";class UT extends Am{constructor(e,n,a,c){super(e,n,a,c)}interpolate_(e,n,a,c){const f=this.resultBuffer,m=this.sampleValues,i=this.valueSize,w=(a-n)/(c-n);let E=e*i;for(let C=E+i;E!==C;E+=4)Ko.slerpFlat(f,0,m,E-i,m,E,w);return f}}class sp extends ac{InterpolantFactoryMethodLinear(e){return new UT(this.times,this.values,this.getValueSize(),e)}}sp.prototype.ValueTypeName="quaternion";sp.prototype.DefaultInterpolation=am;sp.prototype.InterpolantFactoryMethodSmooth=void 0;class wd extends ac{}wd.prototype.ValueTypeName="string";wd.prototype.ValueBufferType=Array;wd.prototype.DefaultInterpolation=om;wd.prototype.InterpolantFactoryMethodLinear=void 0;wd.prototype.InterpolantFactoryMethodSmooth=void 0;class gm extends ac{}gm.prototype.ValueTypeName="vector";class _m{constructor(e,n=-1,a,c=B_){this.name=e,this.tracks=a,this.duration=n,this.blendMode=c,this.uuid=pl(),this.duration<0&&this.resetDuration()}static parse(e){const n=[],a=e.tracks,c=1/(e.fps||1);for(let m=0,i=a.length;m!==i;++m)n.push(MO(a[m]).scale(c));const f=new this(e.name,e.duration,n,e.blendMode);return f.uuid=e.uuid,f}static toJSON(e){const n=[],a=e.tracks,c={name:e.name,duration:e.duration,tracks:n,uuid:e.uuid,blendMode:e.blendMode};for(let f=0,m=a.length;f!==m;++f)n.push(ac.toJSON(a[f]));return c}static CreateFromMorphTargetSequence(e,n,a,c){const f=n.length,m=[];for(let i=0;i<f;i++){let w=[],E=[];w.push((i+f-1)%f,i,(i+1)%f),E.push(0,1,0);const C=rs.getKeyframeOrder(w);w=rs.sortedArray(w,1,C),E=rs.sortedArray(E,1,C),!c&&w[0]===0&&(w.push(f),E.push(E[0])),m.push(new mm(".morphTargetInfluences["+n[i].name+"]",w,E).scale(1/a))}return new this(e,-1,m)}static findByName(e,n){let a=e;if(!Array.isArray(e)){const c=e;a=c.geometry&&c.geometry.animations||c.animations}for(let c=0;c<a.length;c++)if(a[c].name===n)return a[c];return null}static CreateClipsFromMorphTargetSequences(e,n,a){const c={},f=/^([\w-]*?)([\d]+)$/;for(let i=0,w=e.length;i<w;i++){const E=e[i],C=E.name.match(f);if(C&&C.length>1){const T=C[1];let I=c[T];I||(c[T]=I=[]),I.push(E)}}const m=[];for(const i in c)m.push(this.CreateFromMorphTargetSequence(i,c[i],n,a));return m}static parseAnimation(e,n){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const a=function(T,I,k,O,B){if(k.length!==0){const F=[],H=[];rs.flattenJSON(k,F,H,O),F.length!==0&&B.push(new T(I,F,H))}},c=[],f=e.name||"default",m=e.fps||30,i=e.blendMode;let w=e.length||-1;const E=e.hierarchy||[];for(let T=0;T<E.length;T++){const I=E[T].keys;if(!(!I||I.length===0))if(I[0].morphTargets){const k={};let O;for(O=0;O<I.length;O++)if(I[O].morphTargets)for(let B=0;B<I[O].morphTargets.length;B++)k[I[O].morphTargets[B]]=-1;for(const B in k){const F=[],H=[];for(let Y=0;Y!==I[O].morphTargets.length;++Y){const K=I[O];F.push(K.time),H.push(K.morphTarget===B?1:0)}c.push(new mm(".morphTargetInfluence["+B+"]",F,H))}w=k.length*m}else{const k=".bones["+n[T].name+"]";a(gm,k+".position",I,"pos",c),a(sp,k+".quaternion",I,"rot",c),a(gm,k+".scale",I,"scl",c)}}return c.length===0?null:new this(f,w,c,i)}resetDuration(){const e=this.tracks;let n=0;for(let a=0,c=e.length;a!==c;++a){const f=this.tracks[a];n=Math.max(n,f.times[f.times.length-1])}return this.duration=n,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let n=0;n<this.tracks.length;n++)e=e&&this.tracks[n].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let n=0;n<this.tracks.length;n++)e.push(this.tracks[n].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function SO(d){switch(d.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return mm;case"vector":case"vector2":case"vector3":case"vector4":return gm;case"color":return zv;case"quaternion":return sp;case"bool":case"boolean":return bd;case"string":return wd}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+d)}function MO(d){if(d.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=SO(d.type);if(d.times===void 0){const n=[],a=[];rs.flattenJSON(d.keys,n,a,"value"),d.times=n,d.values=a}return e.parse!==void 0?e.parse(d):new e(d.name,d.times,d.values,d.interpolation)}const pd={enabled:!1,files:{},add:function(d,e){this.enabled!==!1&&(this.files[d]=e)},get:function(d){if(this.enabled!==!1)return this.files[d]},remove:function(d){delete this.files[d]},clear:function(){this.files={}}};class kv{constructor(e,n,a){const c=this;let f=!1,m=0,i=0,w;const E=[];this.onStart=void 0,this.onLoad=e,this.onProgress=n,this.onError=a,this.itemStart=function(C){i++,f===!1&&c.onStart!==void 0&&c.onStart(C,m,i),f=!0},this.itemEnd=function(C){m++,c.onProgress!==void 0&&c.onProgress(C,m,i),m===i&&(f=!1,c.onLoad!==void 0&&c.onLoad())},this.itemError=function(C){c.onError!==void 0&&c.onError(C)},this.resolveURL=function(C){return w?w(C):C},this.setURLModifier=function(C){return w=C,this},this.addHandler=function(C,T){return E.push(C,T),this},this.removeHandler=function(C){const T=E.indexOf(C);return T!==-1&&E.splice(T,2),this},this.getHandler=function(C){for(let T=0,I=E.length;T<I;T+=2){const k=E[T],O=E[T+1];if(k.global&&(k.lastIndex=0),k.test(C))return O}return null}}}const VT=new kv;class el{constructor(e){this.manager=e!==void 0?e:VT,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,n){const a=this;return new Promise(function(c,f){a.load(e,c,n,f)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}const gu={};class Wc extends el{constructor(e){super(e)}load(e,n,a,c){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const f=pd.get(e);if(f!==void 0)return this.manager.itemStart(e),setTimeout(()=>{n&&n(f),this.manager.itemEnd(e)},0),f;if(gu[e]!==void 0){gu[e].push({onLoad:n,onProgress:a,onError:c});return}gu[e]=[],gu[e].push({onLoad:n,onProgress:a,onError:c});const m=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),i=this.mimeType,w=this.responseType;fetch(m).then(E=>{if(E.status===200||E.status===0){if(E.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||E.body===void 0||E.body.getReader===void 0)return E;const C=gu[e],T=E.body.getReader(),I=E.headers.get("Content-Length"),k=I?parseInt(I):0,O=k!==0;let B=0;const F=new ReadableStream({start(H){Y();function Y(){T.read().then(({done:K,value:ne})=>{if(K)H.close();else{B+=ne.byteLength;const le=new ProgressEvent("progress",{lengthComputable:O,loaded:B,total:k});for(let fe=0,Ae=C.length;fe<Ae;fe++){const oe=C[fe];oe.onProgress&&oe.onProgress(le)}H.enqueue(ne),Y()}})}}});return new Response(F)}else throw Error(`fetch for "${E.url}" responded with ${E.status}: ${E.statusText}`)}).then(E=>{switch(w){case"arraybuffer":return E.arrayBuffer();case"blob":return E.blob();case"document":return E.text().then(C=>new DOMParser().parseFromString(C,i));case"json":return E.json();default:if(i===void 0)return E.text();{const T=/charset="?([^;"\s]*)"?/i.exec(i),I=T&&T[1]?T[1].toLowerCase():void 0,k=new TextDecoder(I);return E.arrayBuffer().then(O=>k.decode(O))}}}).then(E=>{pd.add(e,E);const C=gu[e];delete gu[e];for(let T=0,I=C.length;T<I;T++){const k=C[T];k.onLoad&&k.onLoad(E)}}).catch(E=>{const C=gu[e];if(C===void 0)throw this.manager.itemError(e),E;delete gu[e];for(let T=0,I=C.length;T<I;T++){const k=C[T];k.onError&&k.onError(E)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class EO extends el{constructor(e){super(e)}load(e,n,a,c){const f=this,m=new Wc(this.manager);m.setPath(this.path),m.setRequestHeader(this.requestHeader),m.setWithCredentials(this.withCredentials),m.load(e,function(i){try{n(f.parse(JSON.parse(i)))}catch(w){c?c(w):console.error(w),f.manager.itemError(e)}},a,c)}parse(e){const n=[];for(let a=0;a<e.length;a++){const c=_m.parse(e[a]);n.push(c)}return n}}class TO extends el{constructor(e){super(e)}load(e,n,a,c){const f=this,m=[],i=new _T,w=new Wc(this.manager);w.setPath(this.path),w.setResponseType("arraybuffer"),w.setRequestHeader(this.requestHeader),w.setWithCredentials(f.withCredentials);let E=0;function C(T){w.load(e[T],function(I){const k=f.parse(I,!0);m[T]={width:k.width,height:k.height,format:k.format,mipmaps:k.mipmaps},E+=1,E===6&&(k.mipmapCount===1&&(i.minFilter=qs),i.image=m,i.format=k.format,i.needsUpdate=!0,n&&n(i))},a,c)}if(Array.isArray(e))for(let T=0,I=e.length;T<I;++T)C(T);else w.load(e,function(T){const I=f.parse(T,!0);if(I.isCubemap){const k=I.mipmaps.length/I.mipmapCount;for(let O=0;O<k;O++){m[O]={mipmaps:[]};for(let B=0;B<I.mipmapCount;B++)m[O].mipmaps.push(I.mipmaps[O*I.mipmapCount+B]),m[O].format=I.format,m[O].width=I.width,m[O].height=I.height}i.image=m}else i.image.width=I.width,i.image.height=I.height,i.mipmaps=I.mipmaps;I.mipmapCount===1&&(i.minFilter=qs),i.format=I.format,i.needsUpdate=!0,n&&n(i)},a,c);return i}}class ym extends el{constructor(e){super(e)}load(e,n,a,c){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const f=this,m=pd.get(e);if(m!==void 0)return f.manager.itemStart(e),setTimeout(function(){n&&n(m),f.manager.itemEnd(e)},0),m;const i=um("img");function w(){C(),pd.add(e,this),n&&n(this),f.manager.itemEnd(e)}function E(T){C(),c&&c(T),f.manager.itemError(e),f.manager.itemEnd(e)}function C(){i.removeEventListener("load",w,!1),i.removeEventListener("error",E,!1)}return i.addEventListener("load",w,!1),i.addEventListener("error",E,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(i.crossOrigin=this.crossOrigin),f.manager.itemStart(e),i.src=e,i}}class AO extends el{constructor(e){super(e)}load(e,n,a,c){const f=new Tm,m=new ym(this.manager);m.setCrossOrigin(this.crossOrigin),m.setPath(this.path);let i=0;function w(E){m.load(e[E],function(C){f.images[E]=C,i++,i===6&&(f.needsUpdate=!0,n&&n(f))},void 0,c)}for(let E=0;E<e.length;++E)w(E);return f}}class CO extends el{constructor(e){super(e)}load(e,n,a,c){const f=this,m=new Df,i=new Wc(this.manager);return i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setPath(this.path),i.setWithCredentials(f.withCredentials),i.load(e,function(w){const E=f.parse(w);!E||(E.image!==void 0?m.image=E.image:E.data!==void 0&&(m.image.width=E.width,m.image.height=E.height,m.image.data=E.data),m.wrapS=E.wrapS!==void 0?E.wrapS:Ta,m.wrapT=E.wrapT!==void 0?E.wrapT:Ta,m.magFilter=E.magFilter!==void 0?E.magFilter:qs,m.minFilter=E.minFilter!==void 0?E.minFilter:qs,m.anisotropy=E.anisotropy!==void 0?E.anisotropy:1,E.encoding!==void 0&&(m.encoding=E.encoding),E.flipY!==void 0&&(m.flipY=E.flipY),E.format!==void 0&&(m.format=E.format),E.type!==void 0&&(m.type=E.type),E.mipmaps!==void 0&&(m.mipmaps=E.mipmaps,m.minFilter=_d),E.mipmapCount===1&&(m.minFilter=qs),E.generateMipmaps!==void 0&&(m.generateMipmaps=E.generateMipmaps),m.needsUpdate=!0,n&&n(m,E))},a,c),m}}class IO extends el{constructor(e){super(e)}load(e,n,a,c){const f=new ho,m=new ym(this.manager);return m.setCrossOrigin(this.crossOrigin),m.setPath(this.path),m.load(e,function(i){f.image=i,f.needsUpdate=!0,n!==void 0&&n(f)},a,c),f}}class hh extends kr{constructor(e,n=1){super(),this.isLight=!0,this.type="Light",this.color=new Kn(e),this.intensity=n}dispose(){}copy(e,n){return super.copy(e,n),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const n=super.toJSON(e);return n.object.color=this.color.getHex(),n.object.intensity=this.intensity,this.groundColor!==void 0&&(n.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(n.object.distance=this.distance),this.angle!==void 0&&(n.object.angle=this.angle),this.decay!==void 0&&(n.object.decay=this.decay),this.penumbra!==void 0&&(n.object.penumbra=this.penumbra),this.shadow!==void 0&&(n.object.shadow=this.shadow.toJSON()),n}}class GT extends hh{constructor(e,n,a){super(e,a),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(kr.DefaultUp),this.updateMatrix(),this.groundColor=new Kn(n)}copy(e,n){return super.copy(e,n),this.groundColor.copy(e.groundColor),this}}const SS=new sr,MS=new Me,ES=new Me;class Ov{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new tn(512,512),this.map=null,this.mapPass=null,this.matrix=new sr,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new U_,this._frameExtents=new tn(1,1),this._viewportCount=1,this._viewports=[new Wr(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const n=this.camera,a=this.matrix;MS.setFromMatrixPosition(e.matrixWorld),n.position.copy(MS),ES.setFromMatrixPosition(e.target.matrixWorld),n.lookAt(ES),n.updateMatrixWorld(),SS.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(SS),a.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),a.multiply(n.projectionMatrix),a.multiply(n.matrixWorldInverse)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class PO extends Ov{constructor(){super(new ks(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(e){const n=this.camera,a=cm*2*e.angle*this.focus,c=this.mapSize.width/this.mapSize.height,f=e.distance||n.far;(a!==n.fov||c!==n.aspect||f!==n.far)&&(n.fov=a,n.aspect=c,n.far=f,n.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class jT extends hh{constructor(e,n,a=0,c=Math.PI/3,f=0,m=1){super(e,n),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(kr.DefaultUp),this.updateMatrix(),this.target=new kr,this.distance=a,this.angle=c,this.penumbra=f,this.decay=m,this.shadow=new PO}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){this.shadow.dispose()}copy(e,n){return super.copy(e,n),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}const TS=new sr,Xp=new Me,G0=new Me;class LO extends Ov{constructor(){super(new ks(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new tn(4,2),this._viewportCount=6,this._viewports=[new Wr(2,1,1,1),new Wr(0,1,1,1),new Wr(3,1,1,1),new Wr(1,1,1,1),new Wr(3,0,1,1),new Wr(1,0,1,1)],this._cubeDirections=[new Me(1,0,0),new Me(-1,0,0),new Me(0,0,1),new Me(0,0,-1),new Me(0,1,0),new Me(0,-1,0)],this._cubeUps=[new Me(0,1,0),new Me(0,1,0),new Me(0,1,0),new Me(0,1,0),new Me(0,0,1),new Me(0,0,-1)]}updateMatrices(e,n=0){const a=this.camera,c=this.matrix,f=e.distance||a.far;f!==a.far&&(a.far=f,a.updateProjectionMatrix()),Xp.setFromMatrixPosition(e.matrixWorld),a.position.copy(Xp),G0.copy(a.position),G0.add(this._cubeDirections[n]),a.up.copy(this._cubeUps[n]),a.lookAt(G0),a.updateMatrixWorld(),c.makeTranslation(-Xp.x,-Xp.y,-Xp.z),TS.multiplyMatrices(a.projectionMatrix,a.matrixWorldInverse),this._frustum.setFromProjectionMatrix(TS)}}class WT extends hh{constructor(e,n,a=0,c=1){super(e,n),this.isPointLight=!0,this.type="PointLight",this.distance=a,this.decay=c,this.shadow=new LO}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,n){return super.copy(e,n),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class RO extends Ov{constructor(){super(new vu(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class HT extends hh{constructor(e,n){super(e,n),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(kr.DefaultUp),this.updateMatrix(),this.target=new kr,this.shadow=new RO}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class qT extends hh{constructor(e,n){super(e,n),this.isAmbientLight=!0,this.type="AmbientLight"}}class ZT extends hh{constructor(e,n,a=10,c=10){super(e,n),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=a,this.height=c}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const n=super.toJSON(e);return n.object.width=this.width,n.object.height=this.height,n}}class XT{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new Me)}set(e){for(let n=0;n<9;n++)this.coefficients[n].copy(e[n]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,n){const a=e.x,c=e.y,f=e.z,m=this.coefficients;return n.copy(m[0]).multiplyScalar(.282095),n.addScaledVector(m[1],.488603*c),n.addScaledVector(m[2],.488603*f),n.addScaledVector(m[3],.488603*a),n.addScaledVector(m[4],1.092548*(a*c)),n.addScaledVector(m[5],1.092548*(c*f)),n.addScaledVector(m[6],.315392*(3*f*f-1)),n.addScaledVector(m[7],1.092548*(a*f)),n.addScaledVector(m[8],.546274*(a*a-c*c)),n}getIrradianceAt(e,n){const a=e.x,c=e.y,f=e.z,m=this.coefficients;return n.copy(m[0]).multiplyScalar(.886227),n.addScaledVector(m[1],2*.511664*c),n.addScaledVector(m[2],2*.511664*f),n.addScaledVector(m[3],2*.511664*a),n.addScaledVector(m[4],2*.429043*a*c),n.addScaledVector(m[5],2*.429043*c*f),n.addScaledVector(m[6],.743125*f*f-.247708),n.addScaledVector(m[7],2*.429043*a*f),n.addScaledVector(m[8],.429043*(a*a-c*c)),n}add(e){for(let n=0;n<9;n++)this.coefficients[n].add(e.coefficients[n]);return this}addScaledSH(e,n){for(let a=0;a<9;a++)this.coefficients[a].addScaledVector(e.coefficients[a],n);return this}scale(e){for(let n=0;n<9;n++)this.coefficients[n].multiplyScalar(e);return this}lerp(e,n){for(let a=0;a<9;a++)this.coefficients[a].lerp(e.coefficients[a],n);return this}equals(e){for(let n=0;n<9;n++)if(!this.coefficients[n].equals(e.coefficients[n]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,n=0){const a=this.coefficients;for(let c=0;c<9;c++)a[c].fromArray(e,n+c*3);return this}toArray(e=[],n=0){const a=this.coefficients;for(let c=0;c<9;c++)a[c].toArray(e,n+c*3);return e}static getBasisAt(e,n){const a=e.x,c=e.y,f=e.z;n[0]=.282095,n[1]=.488603*c,n[2]=.488603*f,n[3]=.488603*a,n[4]=1.092548*a*c,n[5]=1.092548*c*f,n[6]=.315392*(3*f*f-1),n[7]=1.092548*a*f,n[8]=.546274*(a*a-c*c)}}class Y_ extends hh{constructor(e=new XT,n=1){super(void 0,n),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){const n=super.toJSON(e);return n.object.sh=this.sh.toArray(),n}}class $T extends el{constructor(e){super(e),this.textures={}}load(e,n,a,c){const f=this,m=new Wc(f.manager);m.setPath(f.path),m.setRequestHeader(f.requestHeader),m.setWithCredentials(f.withCredentials),m.load(e,function(i){try{n(f.parse(JSON.parse(i)))}catch(w){c?c(w):console.error(w),f.manager.itemError(e)}},a,c)}parse(e){const n=this.textures;function a(f){return n[f]===void 0&&console.warn("THREE.MaterialLoader: Undefined texture",f),n[f]}const c=fo.fromType(e.type);if(e.uuid!==void 0&&(c.uuid=e.uuid),e.name!==void 0&&(c.name=e.name),e.color!==void 0&&c.color!==void 0&&c.color.setHex(e.color),e.roughness!==void 0&&(c.roughness=e.roughness),e.metalness!==void 0&&(c.metalness=e.metalness),e.sheen!==void 0&&(c.sheen=e.sheen),e.sheenColor!==void 0&&(c.sheenColor=new Kn().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(c.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&c.emissive!==void 0&&c.emissive.setHex(e.emissive),e.specular!==void 0&&c.specular!==void 0&&c.specular.setHex(e.specular),e.specularIntensity!==void 0&&(c.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&c.specularColor!==void 0&&c.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(c.shininess=e.shininess),e.clearcoat!==void 0&&(c.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(c.clearcoatRoughness=e.clearcoatRoughness),e.iridescence!==void 0&&(c.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(c.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(c.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(c.transmission=e.transmission),e.thickness!==void 0&&(c.thickness=e.thickness),e.attenuationDistance!==void 0&&(c.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&c.attenuationColor!==void 0&&c.attenuationColor.setHex(e.attenuationColor),e.fog!==void 0&&(c.fog=e.fog),e.flatShading!==void 0&&(c.flatShading=e.flatShading),e.blending!==void 0&&(c.blending=e.blending),e.combine!==void 0&&(c.combine=e.combine),e.side!==void 0&&(c.side=e.side),e.shadowSide!==void 0&&(c.shadowSide=e.shadowSide),e.opacity!==void 0&&(c.opacity=e.opacity),e.transparent!==void 0&&(c.transparent=e.transparent),e.alphaTest!==void 0&&(c.alphaTest=e.alphaTest),e.depthTest!==void 0&&(c.depthTest=e.depthTest),e.depthWrite!==void 0&&(c.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(c.colorWrite=e.colorWrite),e.stencilWrite!==void 0&&(c.stencilWrite=e.stencilWrite),e.stencilWriteMask!==void 0&&(c.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(c.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(c.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(c.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(c.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(c.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(c.stencilZPass=e.stencilZPass),e.wireframe!==void 0&&(c.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(c.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(c.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(c.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(c.rotation=e.rotation),e.linewidth!==1&&(c.linewidth=e.linewidth),e.dashSize!==void 0&&(c.dashSize=e.dashSize),e.gapSize!==void 0&&(c.gapSize=e.gapSize),e.scale!==void 0&&(c.scale=e.scale),e.polygonOffset!==void 0&&(c.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(c.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(c.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(c.dithering=e.dithering),e.alphaToCoverage!==void 0&&(c.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(c.premultipliedAlpha=e.premultipliedAlpha),e.visible!==void 0&&(c.visible=e.visible),e.toneMapped!==void 0&&(c.toneMapped=e.toneMapped),e.userData!==void 0&&(c.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?c.vertexColors=e.vertexColors>0:c.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const f in e.uniforms){const m=e.uniforms[f];switch(c.uniforms[f]={},m.type){case"t":c.uniforms[f].value=a(m.value);break;case"c":c.uniforms[f].value=new Kn().setHex(m.value);break;case"v2":c.uniforms[f].value=new tn().fromArray(m.value);break;case"v3":c.uniforms[f].value=new Me().fromArray(m.value);break;case"v4":c.uniforms[f].value=new Wr().fromArray(m.value);break;case"m3":c.uniforms[f].value=new kl().fromArray(m.value);break;case"m4":c.uniforms[f].value=new sr().fromArray(m.value);break;default:c.uniforms[f].value=m.value}}if(e.defines!==void 0&&(c.defines=e.defines),e.vertexShader!==void 0&&(c.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(c.fragmentShader=e.fragmentShader),e.extensions!==void 0)for(const f in e.extensions)c.extensions[f]=e.extensions[f];if(e.shading!==void 0&&(c.flatShading=e.shading===1),e.size!==void 0&&(c.size=e.size),e.sizeAttenuation!==void 0&&(c.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(c.map=a(e.map)),e.matcap!==void 0&&(c.matcap=a(e.matcap)),e.alphaMap!==void 0&&(c.alphaMap=a(e.alphaMap)),e.bumpMap!==void 0&&(c.bumpMap=a(e.bumpMap)),e.bumpScale!==void 0&&(c.bumpScale=e.bumpScale),e.normalMap!==void 0&&(c.normalMap=a(e.normalMap)),e.normalMapType!==void 0&&(c.normalMapType=e.normalMapType),e.normalScale!==void 0){let f=e.normalScale;Array.isArray(f)===!1&&(f=[f,f]),c.normalScale=new tn().fromArray(f)}return e.displacementMap!==void 0&&(c.displacementMap=a(e.displacementMap)),e.displacementScale!==void 0&&(c.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(c.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(c.roughnessMap=a(e.roughnessMap)),e.metalnessMap!==void 0&&(c.metalnessMap=a(e.metalnessMap)),e.emissiveMap!==void 0&&(c.emissiveMap=a(e.emissiveMap)),e.emissiveIntensity!==void 0&&(c.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(c.specularMap=a(e.specularMap)),e.specularIntensityMap!==void 0&&(c.specularIntensityMap=a(e.specularIntensityMap)),e.specularColorMap!==void 0&&(c.specularColorMap=a(e.specularColorMap)),e.envMap!==void 0&&(c.envMap=a(e.envMap)),e.envMapIntensity!==void 0&&(c.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(c.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(c.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(c.lightMap=a(e.lightMap)),e.lightMapIntensity!==void 0&&(c.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(c.aoMap=a(e.aoMap)),e.aoMapIntensity!==void 0&&(c.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(c.gradientMap=a(e.gradientMap)),e.clearcoatMap!==void 0&&(c.clearcoatMap=a(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(c.clearcoatRoughnessMap=a(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(c.clearcoatNormalMap=a(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(c.clearcoatNormalScale=new tn().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(c.iridescenceMap=a(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(c.iridescenceThicknessMap=a(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(c.transmissionMap=a(e.transmissionMap)),e.thicknessMap!==void 0&&(c.thicknessMap=a(e.thicknessMap)),e.sheenColorMap!==void 0&&(c.sheenColorMap=a(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(c.sheenRoughnessMap=a(e.sheenRoughnessMap)),c}setTextures(e){return this.textures=e,this}}class w_{static decodeText(e){if(typeof TextDecoder<"u")return new TextDecoder().decode(e);let n="";for(let a=0,c=e.length;a<c;a++)n+=String.fromCharCode(e[a]);try{return decodeURIComponent(escape(n))}catch{return n}}static extractUrlBase(e){const n=e.lastIndexOf("/");return n===-1?"./":e.slice(0,n+1)}static resolveURL(e,n){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(n)&&/^\//.test(e)&&(n=n.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:n+e)}}class YT extends qi{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}clone(){return new this.constructor().copy(this)}toJSON(){const e=super.toJSON(this);return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class JT extends el{constructor(e){super(e)}load(e,n,a,c){const f=this,m=new Wc(f.manager);m.setPath(f.path),m.setRequestHeader(f.requestHeader),m.setWithCredentials(f.withCredentials),m.load(e,function(i){try{n(f.parse(JSON.parse(i)))}catch(w){c?c(w):console.error(w),f.manager.itemError(e)}},a,c)}parse(e){const n={},a={};function c(k,O){if(n[O]!==void 0)return n[O];const F=k.interleavedBuffers[O],H=f(k,F.buffer),Y=If(F.type,H),K=new W_(Y,F.stride);return K.uuid=F.uuid,n[O]=K,K}function f(k,O){if(a[O]!==void 0)return a[O];const F=k.arrayBuffers[O],H=new Uint32Array(F).buffer;return a[O]=H,H}const m=e.isInstancedBufferGeometry?new YT:new qi,i=e.data.index;if(i!==void 0){const k=If(i.type,i.array);m.setIndex(new Yr(k,1))}const w=e.data.attributes;for(const k in w){const O=w[k];let B;if(O.isInterleavedBufferAttribute){const F=c(e.data,O.data);B=new ud(F,O.itemSize,O.offset,O.normalized)}else{const F=If(O.type,O.array),H=O.isInstancedBufferAttribute?Bf:Yr;B=new H(F,O.itemSize,O.normalized)}O.name!==void 0&&(B.name=O.name),O.usage!==void 0&&B.setUsage(O.usage),O.updateRange!==void 0&&(B.updateRange.offset=O.updateRange.offset,B.updateRange.count=O.updateRange.count),m.setAttribute(k,B)}const E=e.data.morphAttributes;if(E)for(const k in E){const O=E[k],B=[];for(let F=0,H=O.length;F<H;F++){const Y=O[F];let K;if(Y.isInterleavedBufferAttribute){const ne=c(e.data,Y.data);K=new ud(ne,Y.itemSize,Y.offset,Y.normalized)}else{const ne=If(Y.type,Y.array);K=new Yr(ne,Y.itemSize,Y.normalized)}Y.name!==void 0&&(K.name=Y.name),B.push(K)}m.morphAttributes[k]=B}e.data.morphTargetsRelative&&(m.morphTargetsRelative=!0);const T=e.data.groups||e.data.drawcalls||e.data.offsets;if(T!==void 0)for(let k=0,O=T.length;k!==O;++k){const B=T[k];m.addGroup(B.start,B.count,B.materialIndex)}const I=e.data.boundingSphere;if(I!==void 0){const k=new Me;I.center!==void 0&&k.fromArray(I.center),m.boundingSphere=new vd(k,I.radius)}return e.name&&(m.name=e.name),e.userData&&(m.userData=e.userData),m}}class DO extends el{constructor(e){super(e)}load(e,n,a,c){const f=this,m=this.path===""?w_.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||m;const i=new Wc(this.manager);i.setPath(this.path),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,function(w){let E=null;try{E=JSON.parse(w)}catch(T){c!==void 0&&c(T),console.error("THREE:ObjectLoader: Can't parse "+e+".",T.message);return}const C=E.metadata;if(C===void 0||C.type===void 0||C.type.toLowerCase()==="geometry"){console.error("THREE.ObjectLoader: Can't load "+e);return}f.parse(E,n)},a,c)}async loadAsync(e,n){const a=this,c=this.path===""?w_.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||c;const f=new Wc(this.manager);f.setPath(this.path),f.setRequestHeader(this.requestHeader),f.setWithCredentials(this.withCredentials);const m=await f.loadAsync(e,n),i=JSON.parse(m),w=i.metadata;if(w===void 0||w.type===void 0||w.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+e);return await a.parseAsync(i)}parse(e,n){const a=this.parseAnimations(e.animations),c=this.parseShapes(e.shapes),f=this.parseGeometries(e.geometries,c),m=this.parseImages(e.images,function(){n!==void 0&&n(E)}),i=this.parseTextures(e.textures,m),w=this.parseMaterials(e.materials,i),E=this.parseObject(e.object,f,w,i,a),C=this.parseSkeletons(e.skeletons,E);if(this.bindSkeletons(E,C),n!==void 0){let T=!1;for(const I in m)if(m[I].data instanceof HTMLImageElement){T=!0;break}T===!1&&n(E)}return E}async parseAsync(e){const n=this.parseAnimations(e.animations),a=this.parseShapes(e.shapes),c=this.parseGeometries(e.geometries,a),f=await this.parseImagesAsync(e.images),m=this.parseTextures(e.textures,f),i=this.parseMaterials(e.materials,m),w=this.parseObject(e.object,c,i,m,n),E=this.parseSkeletons(e.skeletons,w);return this.bindSkeletons(w,E),w}parseShapes(e){const n={};if(e!==void 0)for(let a=0,c=e.length;a<c;a++){const f=new sd().fromJSON(e[a]);n[f.uuid]=f}return n}parseSkeletons(e,n){const a={},c={};if(n.traverse(function(f){f.isBone&&(c[f.uuid]=f)}),e!==void 0)for(let f=0,m=e.length;f<m;f++){const i=new H_().fromJSON(e[f],c);a[i.uuid]=i}return a}parseGeometries(e,n){const a={};if(e!==void 0){const c=new JT;for(let f=0,m=e.length;f<m;f++){let i;const w=e[f];switch(w.type){case"BufferGeometry":case"InstancedBufferGeometry":i=c.parse(w);break;case"Geometry":console.error("THREE.ObjectLoader: The legacy Geometry type is no longer supported.");break;default:w.type in wS?i=wS[w.type].fromJSON(w,n):console.warn(`THREE.ObjectLoader: Unsupported geometry type "${w.type}"`)}i.uuid=w.uuid,w.name!==void 0&&(i.name=w.name),i.isBufferGeometry===!0&&w.userData!==void 0&&(i.userData=w.userData),a[w.uuid]=i}}return a}parseMaterials(e,n){const a={},c={};if(e!==void 0){const f=new $T;f.setTextures(n);for(let m=0,i=e.length;m<i;m++){const w=e[m];if(w.type==="MultiMaterial"){const E=[];for(let C=0;C<w.materials.length;C++){const T=w.materials[C];a[T.uuid]===void 0&&(a[T.uuid]=f.parse(T)),E.push(a[T.uuid])}c[w.uuid]=E}else a[w.uuid]===void 0&&(a[w.uuid]=f.parse(w)),c[w.uuid]=a[w.uuid]}}return c}parseAnimations(e){const n={};if(e!==void 0)for(let a=0;a<e.length;a++){const c=e[a],f=_m.parse(c);n[f.uuid]=f}return n}parseImages(e,n){const a=this,c={};let f;function m(w){return a.manager.itemStart(w),f.load(w,function(){a.manager.itemEnd(w)},void 0,function(){a.manager.itemError(w),a.manager.itemEnd(w)})}function i(w){if(typeof w=="string"){const E=w,C=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(E)?E:a.resourcePath+E;return m(C)}else return w.data?{data:If(w.type,w.data),width:w.width,height:w.height}:null}if(e!==void 0&&e.length>0){const w=new kv(n);f=new ym(w),f.setCrossOrigin(this.crossOrigin);for(let E=0,C=e.length;E<C;E++){const T=e[E],I=T.url;if(Array.isArray(I)){const k=[];for(let O=0,B=I.length;O<B;O++){const F=I[O],H=i(F);H!==null&&(H instanceof HTMLImageElement?k.push(H):k.push(new Df(H.data,H.width,H.height)))}c[T.uuid]=new Jh(k)}else{const k=i(T.url);c[T.uuid]=new Jh(k)}}}return c}async parseImagesAsync(e){const n=this,a={};let c;async function f(m){if(typeof m=="string"){const i=m,w=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(i)?i:n.resourcePath+i;return await c.loadAsync(w)}else return m.data?{data:If(m.type,m.data),width:m.width,height:m.height}:null}if(e!==void 0&&e.length>0){c=new ym(this.manager),c.setCrossOrigin(this.crossOrigin);for(let m=0,i=e.length;m<i;m++){const w=e[m],E=w.url;if(Array.isArray(E)){const C=[];for(let T=0,I=E.length;T<I;T++){const k=E[T],O=await f(k);O!==null&&(O instanceof HTMLImageElement?C.push(O):C.push(new Df(O.data,O.width,O.height)))}a[w.uuid]=new Jh(C)}else{const C=await f(w.url);a[w.uuid]=new Jh(C)}}}return a}parseTextures(e,n){function a(f,m){return typeof f=="number"?f:(console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",f),m[f])}const c={};if(e!==void 0)for(let f=0,m=e.length;f<m;f++){const i=e[f];i.image===void 0&&console.warn('THREE.ObjectLoader: No "image" specified for',i.uuid),n[i.image]===void 0&&console.warn("THREE.ObjectLoader: Undefined image",i.image);const w=n[i.image],E=w.data;let C;Array.isArray(E)?(C=new Tm,E.length===6&&(C.needsUpdate=!0)):(E&&E.data?C=new Df:C=new ho,E&&(C.needsUpdate=!0)),C.source=w,C.uuid=i.uuid,i.name!==void 0&&(C.name=i.name),i.mapping!==void 0&&(C.mapping=a(i.mapping,zO)),i.offset!==void 0&&C.offset.fromArray(i.offset),i.repeat!==void 0&&C.repeat.fromArray(i.repeat),i.center!==void 0&&C.center.fromArray(i.center),i.rotation!==void 0&&(C.rotation=i.rotation),i.wrap!==void 0&&(C.wrapS=a(i.wrap[0],AS),C.wrapT=a(i.wrap[1],AS)),i.format!==void 0&&(C.format=i.format),i.type!==void 0&&(C.type=i.type),i.encoding!==void 0&&(C.encoding=i.encoding),i.minFilter!==void 0&&(C.minFilter=a(i.minFilter,CS)),i.magFilter!==void 0&&(C.magFilter=a(i.magFilter,CS)),i.anisotropy!==void 0&&(C.anisotropy=i.anisotropy),i.flipY!==void 0&&(C.flipY=i.flipY),i.premultiplyAlpha!==void 0&&(C.premultiplyAlpha=i.premultiplyAlpha),i.unpackAlignment!==void 0&&(C.unpackAlignment=i.unpackAlignment),i.userData!==void 0&&(C.userData=i.userData),c[i.uuid]=C}return c}parseObject(e,n,a,c,f){let m;function i(I){return n[I]===void 0&&console.warn("THREE.ObjectLoader: Undefined geometry",I),n[I]}function w(I){if(I!==void 0){if(Array.isArray(I)){const k=[];for(let O=0,B=I.length;O<B;O++){const F=I[O];a[F]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",F),k.push(a[F])}return k}return a[I]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",I),a[I]}}function E(I){return c[I]===void 0&&console.warn("THREE.ObjectLoader: Undefined texture",I),c[I]}let C,T;switch(e.type){case"Scene":m=new b_,e.background!==void 0&&(Number.isInteger(e.background)?m.background=new Kn(e.background):m.background=E(e.background)),e.environment!==void 0&&(m.environment=E(e.environment)),e.fog!==void 0&&(e.fog.type==="Fog"?m.fog=new j_(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(m.fog=new G_(e.fog.color,e.fog.density)));break;case"PerspectiveCamera":m=new ks(e.fov,e.aspect,e.near,e.far),e.focus!==void 0&&(m.focus=e.focus),e.zoom!==void 0&&(m.zoom=e.zoom),e.filmGauge!==void 0&&(m.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(m.filmOffset=e.filmOffset),e.view!==void 0&&(m.view=Object.assign({},e.view));break;case"OrthographicCamera":m=new vu(e.left,e.right,e.top,e.bottom,e.near,e.far),e.zoom!==void 0&&(m.zoom=e.zoom),e.view!==void 0&&(m.view=Object.assign({},e.view));break;case"AmbientLight":m=new qT(e.color,e.intensity);break;case"DirectionalLight":m=new HT(e.color,e.intensity);break;case"PointLight":m=new WT(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":m=new ZT(e.color,e.intensity,e.width,e.height);break;case"SpotLight":m=new jT(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);break;case"HemisphereLight":m=new GT(e.color,e.groundColor,e.intensity);break;case"LightProbe":m=new Y_().fromJSON(e);break;case"SkinnedMesh":C=i(e.geometry),T=w(e.material),m=new pT(C,T),e.bindMode!==void 0&&(m.bindMode=e.bindMode),e.bindMatrix!==void 0&&m.bindMatrix.fromArray(e.bindMatrix),e.skeleton!==void 0&&(m.skeleton=e.skeleton);break;case"Mesh":C=i(e.geometry),T=w(e.material),m=new Jo(C,T);break;case"InstancedMesh":C=i(e.geometry),T=w(e.material);const I=e.count,k=e.instanceMatrix,O=e.instanceColor;m=new mT(C,T,I),m.instanceMatrix=new Bf(new Float32Array(k.array),16),O!==void 0&&(m.instanceColor=new Bf(new Float32Array(O.array),O.itemSize));break;case"LOD":m=new fT;break;case"Line":m=new ah(i(e.geometry),w(e.material));break;case"LineLoop":m=new gT(i(e.geometry),w(e.material));break;case"LineSegments":m=new Hc(i(e.geometry),w(e.material));break;case"PointCloud":case"Points":m=new Ev(i(e.geometry),w(e.material));break;case"Sprite":m=new dT(w(e.material));break;case"Group":m=new Lf;break;case"Bone":m=new Mv;break;default:m=new kr}if(m.uuid=e.uuid,e.name!==void 0&&(m.name=e.name),e.matrix!==void 0?(m.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(m.matrixAutoUpdate=e.matrixAutoUpdate),m.matrixAutoUpdate&&m.matrix.decompose(m.position,m.quaternion,m.scale)):(e.position!==void 0&&m.position.fromArray(e.position),e.rotation!==void 0&&m.rotation.fromArray(e.rotation),e.quaternion!==void 0&&m.quaternion.fromArray(e.quaternion),e.scale!==void 0&&m.scale.fromArray(e.scale)),e.castShadow!==void 0&&(m.castShadow=e.castShadow),e.receiveShadow!==void 0&&(m.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.bias!==void 0&&(m.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(m.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(m.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&m.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(m.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(m.visible=e.visible),e.frustumCulled!==void 0&&(m.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(m.renderOrder=e.renderOrder),e.userData!==void 0&&(m.userData=e.userData),e.layers!==void 0&&(m.layers.mask=e.layers),e.children!==void 0){const I=e.children;for(let k=0;k<I.length;k++)m.add(this.parseObject(I[k],n,a,c,f))}if(e.animations!==void 0){const I=e.animations;for(let k=0;k<I.length;k++){const O=I[k];m.animations.push(f[O])}}if(e.type==="LOD"){e.autoUpdate!==void 0&&(m.autoUpdate=e.autoUpdate);const I=e.levels;for(let k=0;k<I.length;k++){const O=I[k],B=m.getObjectByProperty("uuid",O.object);B!==void 0&&m.addLevel(B,O.distance)}}return m}bindSkeletons(e,n){Object.keys(n).length!==0&&e.traverse(function(a){if(a.isSkinnedMesh===!0&&a.skeleton!==void 0){const c=n[a.skeleton];c===void 0?console.warn("THREE.ObjectLoader: No skeleton found with UUID:",a.skeleton):a.bind(c,a.bindMatrix)}})}setTexturePath(e){return console.warn("THREE.ObjectLoader: .setTexturePath() has been renamed to .setResourcePath()."),this.setResourcePath(e)}}const zO={UVMapping:F_,CubeReflectionMapping:rh,CubeRefractionMapping:sh,EquirectangularReflectionMapping:nm,EquirectangularRefractionMapping:im,CubeUVReflectionMapping:tp},AS={RepeatWrapping:rm,ClampToEdgeWrapping:Ta,MirroredRepeatWrapping:sm},CS={NearestFilter:uo,NearestMipmapNearestFilter:g_,NearestMipmapLinearFilter:__,LinearFilter:qs,LinearMipmapNearestFilter:dv,LinearMipmapLinearFilter:_d};class kO extends el{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&console.warn("THREE.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,n,a,c){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const f=this,m=pd.get(e);if(m!==void 0)return f.manager.itemStart(e),setTimeout(function(){n&&n(m),f.manager.itemEnd(e)},0),m;const i={};i.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",i.headers=this.requestHeader,fetch(e,i).then(function(w){return w.blob()}).then(function(w){return createImageBitmap(w,Object.assign(f.options,{colorSpaceConversion:"none"}))}).then(function(w){pd.add(e,w),n&&n(w),f.manager.itemEnd(e)}).catch(function(w){c&&c(w),f.manager.itemError(e),f.manager.itemEnd(e)}),f.manager.itemStart(e)}}let $g;const Fv={getContext:function(){return $g===void 0&&($g=new(window.AudioContext||window.webkitAudioContext)),$g},setContext:function(d){$g=d}};class OO extends el{constructor(e){super(e)}load(e,n,a,c){const f=this,m=new Wc(this.manager);m.setResponseType("arraybuffer"),m.setPath(this.path),m.setRequestHeader(this.requestHeader),m.setWithCredentials(this.withCredentials),m.load(e,function(i){try{const w=i.slice(0);Fv.getContext().decodeAudioData(w,function(C){n(C)})}catch(w){c?c(w):console.error(w),f.manager.itemError(e)}},a,c)}}class FO extends Y_{constructor(e,n,a=1){super(void 0,a),this.isHemisphereLightProbe=!0;const c=new Kn().set(e),f=new Kn().set(n),m=new Me(c.r,c.g,c.b),i=new Me(f.r,f.g,f.b),w=Math.sqrt(Math.PI),E=w*Math.sqrt(.75);this.sh.coefficients[0].copy(m).add(i).multiplyScalar(w),this.sh.coefficients[1].copy(m).sub(i).multiplyScalar(E)}}class BO extends Y_{constructor(e,n=1){super(void 0,n),this.isAmbientLightProbe=!0;const a=new Kn().set(e);this.sh.coefficients[0].set(a.r,a.g,a.b).multiplyScalar(2*Math.sqrt(Math.PI))}}const IS=new sr,PS=new sr,Fh=new sr;class NO{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new ks,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new ks,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const n=this._cache;if(n.focus!==e.focus||n.fov!==e.fov||n.aspect!==e.aspect*this.aspect||n.near!==e.near||n.far!==e.far||n.zoom!==e.zoom||n.eyeSep!==this.eyeSep){n.focus=e.focus,n.fov=e.fov,n.aspect=e.aspect*this.aspect,n.near=e.near,n.far=e.far,n.zoom=e.zoom,n.eyeSep=this.eyeSep,Fh.copy(e.projectionMatrix);const c=n.eyeSep/2,f=c*n.near/n.focus,m=n.near*Math.tan(nd*n.fov*.5)/n.zoom;let i,w;PS.elements[12]=-c,IS.elements[12]=c,i=-m*n.aspect+f,w=m*n.aspect+f,Fh.elements[0]=2*n.near/(w-i),Fh.elements[8]=(w+i)/(w-i),this.cameraL.projectionMatrix.copy(Fh),i=-m*n.aspect-f,w=m*n.aspect-f,Fh.elements[0]=2*n.near/(w-i),Fh.elements[8]=(w+i)/(w-i),this.cameraR.projectionMatrix.copy(Fh)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(PS),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(IS)}}class Bv{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=LS(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const n=LS();e=(n-this.oldTime)/1e3,this.oldTime=n,this.elapsedTime+=e}return e}}function LS(){return(typeof performance>"u"?Date:performance).now()}const Bh=new Me,RS=new Ko,UO=new Me,Nh=new Me;class VO extends kr{constructor(){super(),this.type="AudioListener",this.context=Fv.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Bv}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);const n=this.context.listener,a=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Bh,RS,UO),Nh.set(0,0,-1).applyQuaternion(RS),n.positionX){const c=this.context.currentTime+this.timeDelta;n.positionX.linearRampToValueAtTime(Bh.x,c),n.positionY.linearRampToValueAtTime(Bh.y,c),n.positionZ.linearRampToValueAtTime(Bh.z,c),n.forwardX.linearRampToValueAtTime(Nh.x,c),n.forwardY.linearRampToValueAtTime(Nh.y,c),n.forwardZ.linearRampToValueAtTime(Nh.z,c),n.upX.linearRampToValueAtTime(a.x,c),n.upY.linearRampToValueAtTime(a.y,c),n.upZ.linearRampToValueAtTime(a.z,c)}else n.setPosition(Bh.x,Bh.y,Bh.z),n.setOrientation(Nh.x,Nh.y,Nh.z,a.x,a.y,a.z)}}class KT extends kr{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;const n=this.context.createBufferSource();return n.buffer=this.buffer,n.loop=this.loop,n.loopStart=this.loopStart,n.loopEnd=this.loopEnd,n.onended=this.onEnded.bind(this),n.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=n,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this._progress=0,this.source.stop(),this.source.onended=null,this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,n=this.filters.length;e<n;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,n=this.filters.length;e<n;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}getFilters(){return this.filters}setFilters(e){return e||(e=[]),this._connected===!0?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){if(this.detune=e,this.source.detune!==void 0)return this.isPlaying===!0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.playbackRate=e,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return this.hasPlaybackControl===!1?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){console.warn("THREE.Audio: this Audio has no playback control.");return}return this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}}const Uh=new Me,DS=new Ko,GO=new Me,Vh=new Me;class jO extends KT{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}disconnect(){super.disconnect(),this.panner.disconnect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(e){return this.panner.refDistance=e,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(e){return this.panner.rolloffFactor=e,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(e){return this.panner.distanceModel=e,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(e){return this.panner.maxDistance=e,this}setDirectionalCone(e,n,a){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=n,this.panner.coneOuterGain=a,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(Uh,DS,GO),Vh.set(0,0,1).applyQuaternion(DS);const n=this.panner;if(n.positionX){const a=this.context.currentTime+this.listener.timeDelta;n.positionX.linearRampToValueAtTime(Uh.x,a),n.positionY.linearRampToValueAtTime(Uh.y,a),n.positionZ.linearRampToValueAtTime(Uh.z,a),n.orientationX.linearRampToValueAtTime(Vh.x,a),n.orientationY.linearRampToValueAtTime(Vh.y,a),n.orientationZ.linearRampToValueAtTime(Vh.z,a)}else n.setPosition(Uh.x,Uh.y,Uh.z),n.setOrientation(Vh.x,Vh.y,Vh.z)}}class WO{constructor(e,n=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=n,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0;const n=this.getFrequencyData();for(let a=0;a<n.length;a++)e+=n[a];return e/n.length}}class QT{constructor(e,n,a){this.binding=e,this.valueSize=a;let c,f,m;switch(n){case"quaternion":c=this._slerp,f=this._slerpAdditive,m=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(a*6),this._workIndex=5;break;case"string":case"bool":c=this._select,f=this._select,m=this._setAdditiveIdentityOther,this.buffer=new Array(a*5);break;default:c=this._lerp,f=this._lerpAdditive,m=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(a*5)}this._mixBufferRegion=c,this._mixBufferRegionAdditive=f,this._setIdentity=m,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,n){const a=this.buffer,c=this.valueSize,f=e*c+c;let m=this.cumulativeWeight;if(m===0){for(let i=0;i!==c;++i)a[f+i]=a[i];m=n}else{m+=n;const i=n/m;this._mixBufferRegion(a,f,0,i,c)}this.cumulativeWeight=m}accumulateAdditive(e){const n=this.buffer,a=this.valueSize,c=a*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(n,c,0,e,a),this.cumulativeWeightAdditive+=e}apply(e){const n=this.valueSize,a=this.buffer,c=e*n+n,f=this.cumulativeWeight,m=this.cumulativeWeightAdditive,i=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,f<1){const w=n*this._origIndex;this._mixBufferRegion(a,c,w,1-f,n)}m>0&&this._mixBufferRegionAdditive(a,c,this._addIndex*n,1,n);for(let w=n,E=n+n;w!==E;++w)if(a[w]!==a[w+n]){i.setValue(a,c);break}}saveOriginalState(){const e=this.binding,n=this.buffer,a=this.valueSize,c=a*this._origIndex;e.getValue(n,c);for(let f=a,m=c;f!==m;++f)n[f]=n[c+f%a];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,n=e+this.valueSize;for(let a=e;a<n;a++)this.buffer[a]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const e=this._origIndex*this.valueSize,n=this._addIndex*this.valueSize;for(let a=0;a<this.valueSize;a++)this.buffer[n+a]=this.buffer[e+a]}_select(e,n,a,c,f){if(c>=.5)for(let m=0;m!==f;++m)e[n+m]=e[a+m]}_slerp(e,n,a,c){Ko.slerpFlat(e,n,e,n,e,a,c)}_slerpAdditive(e,n,a,c,f){const m=this._workIndex*f;Ko.multiplyQuaternionsFlat(e,m,e,n,e,a),Ko.slerpFlat(e,n,e,n,e,m,c)}_lerp(e,n,a,c,f){const m=1-c;for(let i=0;i!==f;++i){const w=n+i;e[w]=e[w]*m+e[a+i]*c}}_lerpAdditive(e,n,a,c,f){for(let m=0;m!==f;++m){const i=n+m;e[i]=e[i]+e[a+m]*c}}}const Nv="\\[\\]\\.:\\/",HO=new RegExp("["+Nv+"]","g"),Uv="[^"+Nv+"]",qO="[^"+Nv.replace("\\.","")+"]",ZO=/((?:WC+[\/:])*)/.source.replace("WC",Uv),XO=/(WCOD+)?/.source.replace("WCOD",qO),$O=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Uv),YO=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Uv),JO=new RegExp("^"+ZO+XO+$O+YO+"$"),KO=["material","materials","bones"];class QO{constructor(e,n,a){const c=a||wr.parseTrackName(n);this._targetGroup=e,this._bindings=e.subscribe_(n,c)}getValue(e,n){this.bind();const a=this._targetGroup.nCachedObjects_,c=this._bindings[a];c!==void 0&&c.getValue(e,n)}setValue(e,n){const a=this._bindings;for(let c=this._targetGroup.nCachedObjects_,f=a.length;c!==f;++c)a[c].setValue(e,n)}bind(){const e=this._bindings;for(let n=this._targetGroup.nCachedObjects_,a=e.length;n!==a;++n)e[n].bind()}unbind(){const e=this._bindings;for(let n=this._targetGroup.nCachedObjects_,a=e.length;n!==a;++n)e[n].unbind()}}class wr{constructor(e,n,a){this.path=n,this.parsedPath=a||wr.parseTrackName(n),this.node=wr.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,n,a){return e&&e.isAnimationObjectGroup?new wr.Composite(e,n,a):new wr(e,n,a)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(HO,"")}static parseTrackName(e){const n=JO.exec(e);if(n===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const a={nodeName:n[2],objectName:n[3],objectIndex:n[4],propertyName:n[5],propertyIndex:n[6]},c=a.nodeName&&a.nodeName.lastIndexOf(".");if(c!==void 0&&c!==-1){const f=a.nodeName.substring(c+1);KO.indexOf(f)!==-1&&(a.nodeName=a.nodeName.substring(0,c),a.objectName=f)}if(a.propertyName===null||a.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return a}static findNode(e,n){if(n===void 0||n===""||n==="."||n===-1||n===e.name||n===e.uuid)return e;if(e.skeleton){const a=e.skeleton.getBoneByName(n);if(a!==void 0)return a}if(e.children){const a=function(f){for(let m=0;m<f.length;m++){const i=f[m];if(i.name===n||i.uuid===n)return i;const w=a(i.children);if(w)return w}return null},c=a(e.children);if(c)return c}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,n){e[n]=this.targetObject[this.propertyName]}_getValue_array(e,n){const a=this.resolvedProperty;for(let c=0,f=a.length;c!==f;++c)e[n++]=a[c]}_getValue_arrayElement(e,n){e[n]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,n){this.resolvedProperty.toArray(e,n)}_setValue_direct(e,n){this.targetObject[this.propertyName]=e[n]}_setValue_direct_setNeedsUpdate(e,n){this.targetObject[this.propertyName]=e[n],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,n){this.targetObject[this.propertyName]=e[n],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,n){const a=this.resolvedProperty;for(let c=0,f=a.length;c!==f;++c)a[c]=e[n++]}_setValue_array_setNeedsUpdate(e,n){const a=this.resolvedProperty;for(let c=0,f=a.length;c!==f;++c)a[c]=e[n++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,n){const a=this.resolvedProperty;for(let c=0,f=a.length;c!==f;++c)a[c]=e[n++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,n){this.resolvedProperty[this.propertyIndex]=e[n]}_setValue_arrayElement_setNeedsUpdate(e,n){this.resolvedProperty[this.propertyIndex]=e[n],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,n){this.resolvedProperty[this.propertyIndex]=e[n],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,n){this.resolvedProperty.fromArray(e,n)}_setValue_fromArray_setNeedsUpdate(e,n){this.resolvedProperty.fromArray(e,n),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,n){this.resolvedProperty.fromArray(e,n),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,n){this.bind(),this.getValue(e,n)}_setValue_unbound(e,n){this.bind(),this.setValue(e,n)}bind(){let e=this.node;const n=this.parsedPath,a=n.objectName,c=n.propertyName;let f=n.propertyIndex;if(e||(e=wr.findNode(this.rootNode,n.nodeName)||this.rootNode,this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.error("THREE.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");return}if(a){let E=n.objectIndex;switch(a){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let C=0;C<e.length;C++)if(e[C].name===E){E=C;break}break;default:if(e[a]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[a]}if(E!==void 0){if(e[E]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[E]}}const m=e[c];if(m===void 0){const E=n.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+E+"."+c+" but it wasn't found.",e);return}let i=this.Versioning.None;this.targetObject=e,e.needsUpdate!==void 0?i=this.Versioning.NeedsUpdate:e.matrixWorldNeedsUpdate!==void 0&&(i=this.Versioning.MatrixWorldNeedsUpdate);let w=this.BindingType.Direct;if(f!==void 0){if(c==="morphTargetInfluences"){if(!e.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[f]!==void 0&&(f=e.morphTargetDictionary[f])}w=this.BindingType.ArrayElement,this.resolvedProperty=m,this.propertyIndex=f}else m.fromArray!==void 0&&m.toArray!==void 0?(w=this.BindingType.HasFromToArray,this.resolvedProperty=m):Array.isArray(m)?(w=this.BindingType.EntireArray,this.resolvedProperty=m):this.propertyName=c;this.getValue=this.GetterByBindingType[w],this.setValue=this.SetterByBindingTypeAndVersioning[w][i]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}wr.Composite=QO;wr.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};wr.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};wr.prototype.GetterByBindingType=[wr.prototype._getValue_direct,wr.prototype._getValue_array,wr.prototype._getValue_arrayElement,wr.prototype._getValue_toArray];wr.prototype.SetterByBindingTypeAndVersioning=[[wr.prototype._setValue_direct,wr.prototype._setValue_direct_setNeedsUpdate,wr.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[wr.prototype._setValue_array,wr.prototype._setValue_array_setNeedsUpdate,wr.prototype._setValue_array_setMatrixWorldNeedsUpdate],[wr.prototype._setValue_arrayElement,wr.prototype._setValue_arrayElement_setNeedsUpdate,wr.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[wr.prototype._setValue_fromArray,wr.prototype._setValue_fromArray_setNeedsUpdate,wr.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class eF{constructor(){this.isAnimationObjectGroup=!0,this.uuid=pl(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const e={};this._indicesByUUID=e;for(let a=0,c=arguments.length;a!==c;++a)e[arguments[a].uuid]=a;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const n=this;this.stats={objects:{get total(){return n._objects.length},get inUse(){return this.total-n.nCachedObjects_}},get bindingsPerObject(){return n._bindings.length}}}add(){const e=this._objects,n=this._indicesByUUID,a=this._paths,c=this._parsedPaths,f=this._bindings,m=f.length;let i,w=e.length,E=this.nCachedObjects_;for(let C=0,T=arguments.length;C!==T;++C){const I=arguments[C],k=I.uuid;let O=n[k];if(O===void 0){O=w++,n[k]=O,e.push(I);for(let B=0,F=m;B!==F;++B)f[B].push(new wr(I,a[B],c[B]))}else if(O<E){i=e[O];const B=--E,F=e[B];n[F.uuid]=O,e[O]=F,n[k]=B,e[B]=I;for(let H=0,Y=m;H!==Y;++H){const K=f[H],ne=K[B];let le=K[O];K[O]=ne,le===void 0&&(le=new wr(I,a[H],c[H])),K[B]=le}}else e[O]!==i&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=E}remove(){const e=this._objects,n=this._indicesByUUID,a=this._bindings,c=a.length;let f=this.nCachedObjects_;for(let m=0,i=arguments.length;m!==i;++m){const w=arguments[m],E=w.uuid,C=n[E];if(C!==void 0&&C>=f){const T=f++,I=e[T];n[I.uuid]=C,e[C]=I,n[E]=T,e[T]=w;for(let k=0,O=c;k!==O;++k){const B=a[k],F=B[T],H=B[C];B[C]=F,B[T]=H}}}this.nCachedObjects_=f}uncache(){const e=this._objects,n=this._indicesByUUID,a=this._bindings,c=a.length;let f=this.nCachedObjects_,m=e.length;for(let i=0,w=arguments.length;i!==w;++i){const E=arguments[i],C=E.uuid,T=n[C];if(T!==void 0)if(delete n[C],T<f){const I=--f,k=e[I],O=--m,B=e[O];n[k.uuid]=T,e[T]=k,n[B.uuid]=I,e[I]=B,e.pop();for(let F=0,H=c;F!==H;++F){const Y=a[F],K=Y[I],ne=Y[O];Y[T]=K,Y[I]=ne,Y.pop()}}else{const I=--m,k=e[I];I>0&&(n[k.uuid]=T),e[T]=k,e.pop();for(let O=0,B=c;O!==B;++O){const F=a[O];F[T]=F[I],F.pop()}}}this.nCachedObjects_=f}subscribe_(e,n){const a=this._bindingsIndicesByPath;let c=a[e];const f=this._bindings;if(c!==void 0)return f[c];const m=this._paths,i=this._parsedPaths,w=this._objects,E=w.length,C=this.nCachedObjects_,T=new Array(E);c=f.length,a[e]=c,m.push(e),i.push(n),f.push(T);for(let I=C,k=w.length;I!==k;++I){const O=w[I];T[I]=new wr(O,e,n)}return T}unsubscribe_(e){const n=this._bindingsIndicesByPath,a=n[e];if(a!==void 0){const c=this._paths,f=this._parsedPaths,m=this._bindings,i=m.length-1,w=m[i],E=e[i];n[E]=a,m[a]=w,m.pop(),f[a]=f[i],f.pop(),c[a]=c[i],c.pop()}}}class tF{constructor(e,n,a=null,c=n.blendMode){this._mixer=e,this._clip=n,this._localRoot=a,this.blendMode=c;const f=n.tracks,m=f.length,i=new Array(m),w={endingStart:$h,endingEnd:$h};for(let E=0;E!==m;++E){const C=f[E].createInterpolant(null);i[E]=C,C.settings=w}this._interpolantSettings=w,this._interpolants=i,this._propertyBindings=new Array(m),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=jE,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,n){return this.loop=e,this.repetitions=n,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,n,a){if(e.fadeOut(n),this.fadeIn(n),a){const c=this._clip.duration,f=e._clip.duration,m=f/c,i=c/f;e.warp(1,m,n),this.warp(i,1,n)}return this}crossFadeTo(e,n,a){return e.crossFadeFrom(this,n,a)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,n,a){const c=this._mixer,f=c.time,m=this.timeScale;let i=this._timeScaleInterpolant;i===null&&(i=c._lendControlInterpolant(),this._timeScaleInterpolant=i);const w=i.parameterPositions,E=i.sampleValues;return w[0]=f,w[1]=f+a,E[0]=e/m,E[1]=n/m,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,n,a,c){if(!this.enabled){this._updateWeight(e);return}const f=this._startTime;if(f!==null){const w=(e-f)*a;if(w<0||a===0)return;this._startTime=null,n=a*w}n*=this._updateTimeScale(e);const m=this._updateTime(n),i=this._updateWeight(e);if(i>0){const w=this._interpolants,E=this._propertyBindings;switch(this.blendMode){case pv:for(let C=0,T=w.length;C!==T;++C)w[C].evaluate(m),E[C].accumulateAdditive(i);break;case B_:default:for(let C=0,T=w.length;C!==T;++C)w[C].evaluate(m),E[C].accumulate(c,i)}}}_updateWeight(e){let n=0;if(this.enabled){n=this.weight;const a=this._weightInterpolant;if(a!==null){const c=a.evaluate(e)[0];n*=c,e>a.parameterPositions[1]&&(this.stopFading(),c===0&&(this.enabled=!1))}}return this._effectiveWeight=n,n}_updateTimeScale(e){let n=0;if(!this.paused){n=this.timeScale;const a=this._timeScaleInterpolant;if(a!==null){const c=a.evaluate(e)[0];n*=c,e>a.parameterPositions[1]&&(this.stopWarping(),n===0?this.paused=!0:this.timeScale=n)}}return this._effectiveTimeScale=n,n}_updateTime(e){const n=this._clip.duration,a=this.loop;let c=this.time+e,f=this._loopCount;const m=a===WE;if(e===0)return f===-1?c:m&&(f&1)===1?n-c:c;if(a===GE){f===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(c>=n)c=n;else if(c<0)c=0;else{this.time=c;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=c,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(f===-1&&(e>=0?(f=0,this._setEndings(!0,this.repetitions===0,m)):this._setEndings(this.repetitions===0,!0,m)),c>=n||c<0){const i=Math.floor(c/n);c-=n*i,f+=Math.abs(i);const w=this.repetitions-f;if(w<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,c=e>0?n:0,this.time=c,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(w===1){const E=e<0;this._setEndings(E,!E,m)}else this._setEndings(!1,!1,m);this._loopCount=f,this.time=c,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:i})}}else this.time=c;if(m&&(f&1)===1)return n-c}return c}_setEndings(e,n,a){const c=this._interpolantSettings;a?(c.endingStart=Yh,c.endingEnd=Yh):(e?c.endingStart=this.zeroSlopeAtStart?Yh:$h:c.endingStart=lm,n?c.endingEnd=this.zeroSlopeAtEnd?Yh:$h:c.endingEnd=lm)}_scheduleFading(e,n,a){const c=this._mixer,f=c.time;let m=this._weightInterpolant;m===null&&(m=c._lendControlInterpolant(),this._weightInterpolant=m);const i=m.parameterPositions,w=m.sampleValues;return i[0]=f,w[0]=n,i[1]=f+e,w[1]=a,this}}const nF=new Float32Array(1);class iF extends Mu{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,n){const a=e._localRoot||this._root,c=e._clip.tracks,f=c.length,m=e._propertyBindings,i=e._interpolants,w=a.uuid,E=this._bindingsByRootAndName;let C=E[w];C===void 0&&(C={},E[w]=C);for(let T=0;T!==f;++T){const I=c[T],k=I.name;let O=C[k];if(O!==void 0)++O.referenceCount,m[T]=O;else{if(O=m[T],O!==void 0){O._cacheIndex===null&&(++O.referenceCount,this._addInactiveBinding(O,w,k));continue}const B=n&&n._propertyBindings[T].binding.parsedPath;O=new QT(wr.create(a,k,B),I.ValueTypeName,I.getValueSize()),++O.referenceCount,this._addInactiveBinding(O,w,k),m[T]=O}i[T].resultBuffer=O.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const a=(e._localRoot||this._root).uuid,c=e._clip.uuid,f=this._actionsByClip[c];this._bindAction(e,f&&f.knownActions[0]),this._addInactiveAction(e,c,a)}const n=e._propertyBindings;for(let a=0,c=n.length;a!==c;++a){const f=n[a];f.useCount++===0&&(this._lendBinding(f),f.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const n=e._propertyBindings;for(let a=0,c=n.length;a!==c;++a){const f=n[a];--f.useCount===0&&(f.restoreOriginalState(),this._takeBackBinding(f))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const n=e._cacheIndex;return n!==null&&n<this._nActiveActions}_addInactiveAction(e,n,a){const c=this._actions,f=this._actionsByClip;let m=f[n];if(m===void 0)m={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,f[n]=m;else{const i=m.knownActions;e._byClipCacheIndex=i.length,i.push(e)}e._cacheIndex=c.length,c.push(e),m.actionByRoot[a]=e}_removeInactiveAction(e){const n=this._actions,a=n[n.length-1],c=e._cacheIndex;a._cacheIndex=c,n[c]=a,n.pop(),e._cacheIndex=null;const f=e._clip.uuid,m=this._actionsByClip,i=m[f],w=i.knownActions,E=w[w.length-1],C=e._byClipCacheIndex;E._byClipCacheIndex=C,w[C]=E,w.pop(),e._byClipCacheIndex=null;const T=i.actionByRoot,I=(e._localRoot||this._root).uuid;delete T[I],w.length===0&&delete m[f],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const n=e._propertyBindings;for(let a=0,c=n.length;a!==c;++a){const f=n[a];--f.referenceCount===0&&this._removeInactiveBinding(f)}}_lendAction(e){const n=this._actions,a=e._cacheIndex,c=this._nActiveActions++,f=n[c];e._cacheIndex=c,n[c]=e,f._cacheIndex=a,n[a]=f}_takeBackAction(e){const n=this._actions,a=e._cacheIndex,c=--this._nActiveActions,f=n[c];e._cacheIndex=c,n[c]=e,f._cacheIndex=a,n[a]=f}_addInactiveBinding(e,n,a){const c=this._bindingsByRootAndName,f=this._bindings;let m=c[n];m===void 0&&(m={},c[n]=m),m[a]=e,e._cacheIndex=f.length,f.push(e)}_removeInactiveBinding(e){const n=this._bindings,a=e.binding,c=a.rootNode.uuid,f=a.path,m=this._bindingsByRootAndName,i=m[c],w=n[n.length-1],E=e._cacheIndex;w._cacheIndex=E,n[E]=w,n.pop(),delete i[f],Object.keys(i).length===0&&delete m[c]}_lendBinding(e){const n=this._bindings,a=e._cacheIndex,c=this._nActiveBindings++,f=n[c];e._cacheIndex=c,n[c]=e,f._cacheIndex=a,n[a]=f}_takeBackBinding(e){const n=this._bindings,a=e._cacheIndex,c=--this._nActiveBindings,f=n[c];e._cacheIndex=c,n[c]=e,f._cacheIndex=a,n[a]=f}_lendControlInterpolant(){const e=this._controlInterpolants,n=this._nActiveControlInterpolants++;let a=e[n];return a===void 0&&(a=new Dv(new Float32Array(2),new Float32Array(2),1,nF),a.__cacheIndex=n,e[n]=a),a}_takeBackControlInterpolant(e){const n=this._controlInterpolants,a=e.__cacheIndex,c=--this._nActiveControlInterpolants,f=n[c];e.__cacheIndex=c,n[c]=e,f.__cacheIndex=a,n[a]=f}clipAction(e,n,a){const c=n||this._root,f=c.uuid;let m=typeof e=="string"?_m.findByName(c,e):e;const i=m!==null?m.uuid:e,w=this._actionsByClip[i];let E=null;if(a===void 0&&(m!==null?a=m.blendMode:a=B_),w!==void 0){const T=w.actionByRoot[f];if(T!==void 0&&T.blendMode===a)return T;E=w.knownActions[0],m===null&&(m=E._clip)}if(m===null)return null;const C=new tF(this,m,n,a);return this._bindAction(C,E),this._addInactiveAction(C,i,f),C}existingAction(e,n){const a=n||this._root,c=a.uuid,f=typeof e=="string"?_m.findByName(a,e):e,m=f?f.uuid:e,i=this._actionsByClip[m];return i!==void 0&&i.actionByRoot[c]||null}stopAllAction(){const e=this._actions,n=this._nActiveActions;for(let a=n-1;a>=0;--a)e[a].stop();return this}update(e){e*=this.timeScale;const n=this._actions,a=this._nActiveActions,c=this.time+=e,f=Math.sign(e),m=this._accuIndex^=1;for(let E=0;E!==a;++E)n[E]._update(c,e,f,m);const i=this._bindings,w=this._nActiveBindings;for(let E=0;E!==w;++E)i[E].apply(m);return this}setTime(e){this.time=0;for(let n=0;n<this._actions.length;n++)this._actions[n].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const n=this._actions,a=e.uuid,c=this._actionsByClip,f=c[a];if(f!==void 0){const m=f.knownActions;for(let i=0,w=m.length;i!==w;++i){const E=m[i];this._deactivateAction(E);const C=E._cacheIndex,T=n[n.length-1];E._cacheIndex=null,E._byClipCacheIndex=null,T._cacheIndex=C,n[C]=T,n.pop(),this._removeInactiveBindingsForAction(E)}delete c[a]}}uncacheRoot(e){const n=e.uuid,a=this._actionsByClip;for(const m in a){const i=a[m].actionByRoot,w=i[n];w!==void 0&&(this._deactivateAction(w),this._removeInactiveAction(w))}const c=this._bindingsByRootAndName,f=c[n];if(f!==void 0)for(const m in f){const i=f[m];i.restoreOriginalState(),this._removeInactiveBinding(i)}}uncacheAction(e,n){const a=this.existingAction(e,n);a!==null&&(this._deactivateAction(a),this._removeInactiveAction(a))}}class Vv{constructor(e){typeof e=="string"&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),e=arguments[1]),this.value=e}clone(){return new Vv(this.value.clone===void 0?this.value:this.value.clone())}}class rF extends W_{constructor(e,n,a=1){super(e,n),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=a}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const n=super.clone(e);return n.meshPerAttribute=this.meshPerAttribute,n}toJSON(e){const n=super.toJSON(e);return n.isInstancedInterleavedBuffer=!0,n.meshPerAttribute=this.meshPerAttribute,n}}class sF{constructor(e,n,a,c,f){this.isGLBufferAttribute=!0,this.buffer=e,this.type=n,this.itemSize=a,this.elementSize=c,this.count=f,this.version=0}set needsUpdate(e){e===!0&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,n){return this.type=e,this.elementSize=n,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}}class e2{constructor(e,n,a=0,c=1/0){this.ray=new np(e,n),this.near=a,this.far=c,this.camera=null,this.layers=new rd,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,n){this.ray.set(e,n)}setFromCamera(e,n){n.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(n.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(n).sub(this.ray.origin).normalize(),this.camera=n):n.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(n.near+n.far)/(n.near-n.far)).unproject(n),this.ray.direction.set(0,0,-1).transformDirection(n.matrixWorld),this.camera=n):console.error("THREE.Raycaster: Unsupported camera type: "+n.type)}intersectObject(e,n=!0,a=[]){return Gx(e,this,a,n),a.sort(zS),a}intersectObjects(e,n=!0,a=[]){for(let c=0,f=e.length;c<f;c++)Gx(e[c],this,a,n);return a.sort(zS),a}}function zS(d,e){return d.distance-e.distance}function Gx(d,e,n,a){if(d.layers.test(e.layers)&&d.raycast(e,n),a===!0){const c=d.children;for(let f=0,m=c.length;f<m;f++)Gx(c[f],e,n,!0)}}class jx{constructor(e=1,n=0,a=0){return this.radius=e,this.phi=n,this.theta=a,this}set(e,n,a){return this.radius=e,this.phi=n,this.theta=a,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,n,a){return this.radius=Math.sqrt(e*e+n*n+a*a),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,a),this.phi=Math.acos(Zs(n/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class oF{constructor(e=1,n=0,a=0){return this.radius=e,this.theta=n,this.y=a,this}set(e,n,a){return this.radius=e,this.theta=n,this.y=a,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,n,a){return this.radius=Math.sqrt(e*e+a*a),this.theta=Math.atan2(e,a),this.y=n,this}clone(){return new this.constructor().copy(this)}}const kS=new tn;class aF{constructor(e=new tn(1/0,1/0),n=new tn(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=n}set(e,n){return this.min.copy(e),this.max.copy(n),this}setFromPoints(e){this.makeEmpty();for(let n=0,a=e.length;n<a;n++)this.expandByPoint(e[n]);return this}setFromCenterAndSize(e,n){const a=kS.copy(n).multiplyScalar(.5);return this.min.copy(e).sub(a),this.max.copy(e).add(a),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,n){return n.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)}clampPoint(e,n){return n.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return kS.copy(e).clamp(this.min,this.max).sub(e).length()}intersect(e){return this.min.max(e.min),this.max.min(e.max),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const OS=new Me,Yg=new Me;class lF{constructor(e=new Me,n=new Me){this.start=e,this.end=n}set(e,n){return this.start.copy(e),this.end.copy(n),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,n){return this.delta(n).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,n){OS.subVectors(e,this.start),Yg.subVectors(this.end,this.start);const a=Yg.dot(Yg);let f=Yg.dot(OS)/a;return n&&(f=Zs(f,0,1)),f}closestPointToPoint(e,n,a){const c=this.closestPointToPointParameter(e,n);return this.delta(a).multiplyScalar(c).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const FS=new Me;class cF extends kr{constructor(e,n){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n;const a=new qi,c=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let m=0,i=1,w=32;m<w;m++,i++){const E=m/w*Math.PI*2,C=i/w*Math.PI*2;c.push(Math.cos(E),Math.sin(E),1,Math.cos(C),Math.sin(C),1)}a.setAttribute("position",new hi(c,3));const f=new La({fog:!1,toneMapped:!1});this.cone=new Hc(a,f),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateMatrixWorld();const e=this.light.distance?this.light.distance:1e3,n=e*Math.tan(this.light.angle);this.cone.scale.set(n,n,e),FS.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(FS),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const Qu=new Me,Jg=new sr,j0=new sr;class uF extends Hc{constructor(e){const n=t2(e),a=new qi,c=[],f=[],m=new Kn(0,0,1),i=new Kn(0,1,0);for(let E=0;E<n.length;E++){const C=n[E];C.parent&&C.parent.isBone&&(c.push(0,0,0),c.push(0,0,0),f.push(m.r,m.g,m.b),f.push(i.r,i.g,i.b))}a.setAttribute("position",new hi(c,3)),a.setAttribute("color",new hi(f,3));const w=new La({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(a,w),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=n,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){const n=this.bones,a=this.geometry,c=a.getAttribute("position");j0.copy(this.root.matrixWorld).invert();for(let f=0,m=0;f<n.length;f++){const i=n[f];i.parent&&i.parent.isBone&&(Jg.multiplyMatrices(j0,i.matrixWorld),Qu.setFromMatrixPosition(Jg),c.setXYZ(m,Qu.x,Qu.y,Qu.z),Jg.multiplyMatrices(j0,i.parent.matrixWorld),Qu.setFromMatrixPosition(Jg),c.setXYZ(m+1,Qu.x,Qu.y,Qu.z),m+=2)}a.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}}function t2(d){const e=[];d.isBone===!0&&e.push(d);for(let n=0;n<d.children.length;n++)e.push.apply(e,t2(d.children[n]));return e}class hF extends Jo{constructor(e,n,a){const c=new fd(n,4,2),f=new uh({wireframe:!0,fog:!1,toneMapped:!1});super(c,f),this.light=e,this.light.updateMatrixWorld(),this.color=a,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}}const dF=new Me,BS=new Kn,NS=new Kn;class fF extends kr{constructor(e,n,a){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=a;const c=new dd(n);c.rotateY(Math.PI*.5),this.material=new uh({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);const f=c.getAttribute("position"),m=new Float32Array(f.count*3);c.setAttribute("color",new Yr(m,3)),this.add(new Jo(c,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const e=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{const n=e.geometry.getAttribute("color");BS.copy(this.light.color),NS.copy(this.light.groundColor);for(let a=0,c=n.count;a<c;a++){const f=a<c/2?BS:NS;n.setXYZ(a,f.r,f.g,f.b)}n.needsUpdate=!0}e.lookAt(dF.setFromMatrixPosition(this.light.matrixWorld).negate())}}class pF extends Hc{constructor(e=10,n=10,a=4473924,c=8947848){a=new Kn(a),c=new Kn(c);const f=n/2,m=e/n,i=e/2,w=[],E=[];for(let I=0,k=0,O=-i;I<=n;I++,O+=m){w.push(-i,0,O,i,0,O),w.push(O,0,-i,O,0,i);const B=I===f?a:c;B.toArray(E,k),k+=3,B.toArray(E,k),k+=3,B.toArray(E,k),k+=3,B.toArray(E,k),k+=3}const C=new qi;C.setAttribute("position",new hi(w,3)),C.setAttribute("color",new hi(E,3));const T=new La({vertexColors:!0,toneMapped:!1});super(C,T),this.type="GridHelper"}}class mF extends Hc{constructor(e=10,n=16,a=8,c=64,f=4473924,m=8947848){f=new Kn(f),m=new Kn(m);const i=[],w=[];for(let T=0;T<=n;T++){const I=T/n*(Math.PI*2),k=Math.sin(I)*e,O=Math.cos(I)*e;i.push(0,0,0),i.push(k,0,O);const B=T&1?f:m;w.push(B.r,B.g,B.b),w.push(B.r,B.g,B.b)}for(let T=0;T<=a;T++){const I=T&1?f:m,k=e-e/a*T;for(let O=0;O<c;O++){let B=O/c*(Math.PI*2),F=Math.sin(B)*k,H=Math.cos(B)*k;i.push(F,0,H),w.push(I.r,I.g,I.b),B=(O+1)/c*(Math.PI*2),F=Math.sin(B)*k,H=Math.cos(B)*k,i.push(F,0,H),w.push(I.r,I.g,I.b)}}const E=new qi;E.setAttribute("position",new hi(i,3)),E.setAttribute("color",new hi(w,3));const C=new La({vertexColors:!0,toneMapped:!1});super(E,C),this.type="PolarGridHelper"}}const US=new Me,Kg=new Me,VS=new Me;class gF extends kr{constructor(e,n,a){super(),this.light=e,this.light.updateMatrixWorld(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=a,n===void 0&&(n=1);let c=new qi;c.setAttribute("position",new hi([-n,n,0,n,n,0,n,-n,0,-n,-n,0,-n,n,0],3));const f=new La({fog:!1,toneMapped:!1});this.lightPlane=new ah(c,f),this.add(this.lightPlane),c=new qi,c.setAttribute("position",new hi([0,0,0,0,0,1],3)),this.targetLine=new ah(c,f),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){US.setFromMatrixPosition(this.light.matrixWorld),Kg.setFromMatrixPosition(this.light.target.matrixWorld),VS.subVectors(Kg,US),this.lightPlane.lookAt(Kg),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(Kg),this.targetLine.scale.z=VS.length()}}const Qg=new Me,zs=new Em;class _F extends Hc{constructor(e){const n=new qi,a=new La({color:16777215,vertexColors:!0,toneMapped:!1}),c=[],f=[],m={},i=new Kn(16755200),w=new Kn(16711680),E=new Kn(43775),C=new Kn(16777215),T=new Kn(3355443);I("n1","n2",i),I("n2","n4",i),I("n4","n3",i),I("n3","n1",i),I("f1","f2",i),I("f2","f4",i),I("f4","f3",i),I("f3","f1",i),I("n1","f1",i),I("n2","f2",i),I("n3","f3",i),I("n4","f4",i),I("p","n1",w),I("p","n2",w),I("p","n3",w),I("p","n4",w),I("u1","u2",E),I("u2","u3",E),I("u3","u1",E),I("c","t",C),I("p","c",T),I("cn1","cn2",T),I("cn3","cn4",T),I("cf1","cf2",T),I("cf3","cf4",T);function I(O,B,F){k(O,F),k(B,F)}function k(O,B){c.push(0,0,0),f.push(B.r,B.g,B.b),m[O]===void 0&&(m[O]=[]),m[O].push(c.length/3-1)}n.setAttribute("position",new hi(c,3)),n.setAttribute("color",new hi(f,3)),super(n,a),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=m,this.update()}update(){const e=this.geometry,n=this.pointMap,a=1,c=1;zs.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Hs("c",n,e,zs,0,0,-1),Hs("t",n,e,zs,0,0,1),Hs("n1",n,e,zs,-a,-c,-1),Hs("n2",n,e,zs,a,-c,-1),Hs("n3",n,e,zs,-a,c,-1),Hs("n4",n,e,zs,a,c,-1),Hs("f1",n,e,zs,-a,-c,1),Hs("f2",n,e,zs,a,-c,1),Hs("f3",n,e,zs,-a,c,1),Hs("f4",n,e,zs,a,c,1),Hs("u1",n,e,zs,a*.7,c*1.1,-1),Hs("u2",n,e,zs,-a*.7,c*1.1,-1),Hs("u3",n,e,zs,0,c*2,-1),Hs("cf1",n,e,zs,-a,0,1),Hs("cf2",n,e,zs,a,0,1),Hs("cf3",n,e,zs,0,-c,1),Hs("cf4",n,e,zs,0,c,1),Hs("cn1",n,e,zs,-a,0,-1),Hs("cn2",n,e,zs,a,0,-1),Hs("cn3",n,e,zs,0,-c,-1),Hs("cn4",n,e,zs,0,c,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function Hs(d,e,n,a,c,f,m){Qg.set(c,f,m).unproject(a);const i=e[d];if(i!==void 0){const w=n.getAttribute("position");for(let E=0,C=i.length;E<C;E++)w.setXYZ(i[E],Qg.x,Qg.y,Qg.z)}}const e_=new xd;class yF extends Hc{constructor(e,n=16776960){const a=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),c=new Float32Array(8*3),f=new qi;f.setIndex(new Yr(a,1)),f.setAttribute("position",new Yr(c,3)),super(f,new La({color:n,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(e){if(e!==void 0&&console.warn("THREE.BoxHelper: .update() has no longer arguments."),this.object!==void 0&&e_.setFromObject(this.object),e_.isEmpty())return;const n=e_.min,a=e_.max,c=this.geometry.attributes.position,f=c.array;f[0]=a.x,f[1]=a.y,f[2]=a.z,f[3]=n.x,f[4]=a.y,f[5]=a.z,f[6]=n.x,f[7]=n.y,f[8]=a.z,f[9]=a.x,f[10]=n.y,f[11]=a.z,f[12]=a.x,f[13]=a.y,f[14]=n.z,f[15]=n.x,f[16]=a.y,f[17]=n.z,f[18]=n.x,f[19]=n.y,f[20]=n.z,f[21]=a.x,f[22]=n.y,f[23]=n.z,c.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,n){return super.copy(e,n),this.object=e.object,this}}class xF extends Hc{constructor(e,n=16776960){const a=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),c=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],f=new qi;f.setIndex(new Yr(a,1)),f.setAttribute("position",new hi(c,3)),super(f,new La({color:n,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){const n=this.box;n.isEmpty()||(n.getCenter(this.position),n.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}}class vF extends ah{constructor(e,n=1,a=16776960){const c=a,f=[1,-1,1,-1,1,1,-1,-1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,0,0,1,0,0,0],m=new qi;m.setAttribute("position",new hi(f,3)),m.computeBoundingSphere(),super(m,new La({color:c,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=n;const i=[1,1,1,-1,1,1,-1,-1,1,1,1,1,-1,-1,1,1,-1,1],w=new qi;w.setAttribute("position",new hi(i,3)),w.computeBoundingSphere(),this.add(new Jo(w,new uh({color:c,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){let n=-this.plane.constant;Math.abs(n)<1e-8&&(n=1e-8),this.scale.set(.5*this.size,.5*this.size,n),this.children[0].material.side=n<0?fl:od,this.lookAt(this.plane.normal),super.updateMatrixWorld(e)}}const GS=new Me;let t_,W0;class bF extends kr{constructor(e=new Me(0,0,1),n=new Me(0,0,0),a=1,c=16776960,f=a*.2,m=f*.2){super(),this.type="ArrowHelper",t_===void 0&&(t_=new qi,t_.setAttribute("position",new hi([0,0,0,0,1,0],3)),W0=new lh(0,.5,1,5,1),W0.translate(0,-.5,0)),this.position.copy(n),this.line=new ah(t_,new La({color:c,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Jo(W0,new uh({color:c,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(a,f,m)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{GS.set(e.z,0,-e.x).normalize();const n=Math.acos(e.y);this.quaternion.setFromAxisAngle(GS,n)}}setLength(e,n=e*.2,a=n*.2){this.line.scale.set(1,Math.max(1e-4,e-n),1),this.line.updateMatrix(),this.cone.scale.set(a,n,a),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}}class wF extends Hc{constructor(e=1){const n=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],a=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],c=new qi;c.setAttribute("position",new hi(n,3)),c.setAttribute("color",new hi(a,3));const f=new La({vertexColors:!0,toneMapped:!1});super(c,f),this.type="AxesHelper"}setColors(e,n,a){const c=new Kn,f=this.geometry.attributes.color.array;return c.set(e),c.toArray(f,0),c.toArray(f,3),c.set(n),c.toArray(f,6),c.toArray(f,9),c.set(a),c.toArray(f,12),c.toArray(f,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class SF{constructor(){this.type="ShapePath",this.color=new Kn,this.subPaths=[],this.currentPath=null}moveTo(e,n){return this.currentPath=new hm,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,n),this}lineTo(e,n){return this.currentPath.lineTo(e,n),this}quadraticCurveTo(e,n,a,c){return this.currentPath.quadraticCurveTo(e,n,a,c),this}bezierCurveTo(e,n,a,c,f,m){return this.currentPath.bezierCurveTo(e,n,a,c,f,m),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e,n){function a(Y){const K=[];for(let ne=0,le=Y.length;ne<le;ne++){const fe=Y[ne],Ae=new sd;Ae.curves=fe.curves,K.push(Ae)}return K}function c(Y,K){const ne=K.length;let le=!1;for(let fe=ne-1,Ae=0;Ae<ne;fe=Ae++){let oe=K[fe],ce=K[Ae],Re=ce.x-oe.x,ke=ce.y-oe.y;if(Math.abs(ke)>Number.EPSILON){if(ke<0&&(oe=K[Ae],Re=-Re,ce=K[fe],ke=-ke),Y.y<oe.y||Y.y>ce.y)continue;if(Y.y===oe.y){if(Y.x===oe.x)return!0}else{const Xe=ke*(Y.x-oe.x)-Re*(Y.y-oe.y);if(Xe===0)return!0;if(Xe<0)continue;le=!le}}else{if(Y.y!==oe.y)continue;if(ce.x<=Y.x&&Y.x<=oe.x||oe.x<=Y.x&&Y.x<=ce.x)return!0}}return le}const f=Uc.isClockWise,m=this.subPaths;if(m.length===0)return[];if(n===!0)return a(m);let i,w,E;const C=[];if(m.length===1)return w=m[0],E=new sd,E.curves=w.curves,C.push(E),C;let T=!f(m[0].getPoints());T=e?!T:T;const I=[],k=[];let O=[],B=0,F;k[B]=void 0,O[B]=[];for(let Y=0,K=m.length;Y<K;Y++)w=m[Y],F=w.getPoints(),i=f(F),i=e?!i:i,i?(!T&&k[B]&&B++,k[B]={s:new sd,p:F},k[B].s.curves=w.curves,T&&B++,O[B]=[]):O[B].push({h:w,p:F[0]});if(!k[0])return a(m);if(k.length>1){let Y=!1,K=0;for(let ne=0,le=k.length;ne<le;ne++)I[ne]=[];for(let ne=0,le=k.length;ne<le;ne++){const fe=O[ne];for(let Ae=0;Ae<fe.length;Ae++){const oe=fe[Ae];let ce=!0;for(let Re=0;Re<k.length;Re++)c(oe.p,k[Re].p)&&(ne!==Re&&K++,ce?(ce=!1,I[Re].push(oe)):Y=!0);ce&&I[ne].push(oe)}}K>0&&Y===!1&&(O=I)}let H;for(let Y=0,K=k.length;Y<K;Y++){E=k[Y].s,C.push(E),H=O[Y];for(let ne=0,le=H.length;ne<le;ne++)E.holes.push(H[ne].h)}return C}}class MF{static toHalfFloat(e){Math.abs(e)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),e=Zs(e,-65504,65504),jS[0]=e;const n=WS[0],a=n>>23&511;return nc[a]+((n&8388607)>>ic[a])}static fromHalfFloat(e){const n=e>>10;return WS[0]=Gv[i2[n]+(e&1023)]+op[n],jS[0]}}const n2=new ArrayBuffer(4),jS=new Float32Array(n2),WS=new Uint32Array(n2),nc=new Uint32Array(512),ic=new Uint32Array(512);for(let d=0;d<256;++d){const e=d-127;e<-27?(nc[d]=0,nc[d|256]=32768,ic[d]=24,ic[d|256]=24):e<-14?(nc[d]=1024>>-e-14,nc[d|256]=1024>>-e-14|32768,ic[d]=-e-1,ic[d|256]=-e-1):e<=15?(nc[d]=e+15<<10,nc[d|256]=e+15<<10|32768,ic[d]=13,ic[d|256]=13):e<128?(nc[d]=31744,nc[d|256]=64512,ic[d]=24,ic[d|256]=24):(nc[d]=31744,nc[d|256]=64512,ic[d]=13,ic[d|256]=13)}const Gv=new Uint32Array(2048),op=new Uint32Array(64),i2=new Uint32Array(64);for(let d=1;d<1024;++d){let e=d<<13,n=0;for(;(e&8388608)===0;)e<<=1,n-=8388608;e&=-8388609,n+=947912704,Gv[d]=e|n}for(let d=1024;d<2048;++d)Gv[d]=939524096+(d-1024<<13);for(let d=1;d<31;++d)op[d]=d<<23;op[31]=1199570944;op[32]=2147483648;for(let d=33;d<63;++d)op[d]=2147483648+(d-32<<23);op[63]=3347054592;for(let d=1;d<64;++d)d!==32&&(i2[d]=1024);class EF extends qi{constructor(){console.error("THREE.ParametricGeometry has been moved to /examples/jsm/geometries/ParametricGeometry.js"),super()}}class TF extends qi{constructor(){console.error("THREE.TextGeometry has been moved to /examples/jsm/geometries/TextGeometry.js"),super()}}function AF(){console.error("THREE.FontLoader has been moved to /examples/jsm/loaders/FontLoader.js")}function CF(){console.error("THREE.Font has been moved to /examples/jsm/loaders/FontLoader.js")}function IF(){console.error("THREE.ImmediateRenderObject has been removed.")}class PF extends ml{constructor(e,n,a){console.error('THREE.WebGLMultisampleRenderTarget has been removed. Use a normal render target and set the "samples" property to greater 0 to enable multisampling.'),super(e,n,a),this.samples=4}}class LF extends Mm{constructor(e,n,a,c){console.warn("THREE.DataTexture2DArray has been renamed to DataArrayTexture."),super(e,n,a,c)}}class RF extends N_{constructor(e,n,a,c){console.warn("THREE.DataTexture3D has been renamed to Data3DTexture."),super(e,n,a,c)}}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:k_}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=k_);const DF=Object.freeze(Object.defineProperty({__proto__:null,ACESFilmicToneMapping:hv,AddEquation:qh,AddOperation:wE,AdditiveAnimationBlendMode:pv,AdditiveBlending:cx,AlphaFormat:RE,AlwaysDepth:mE,AlwaysStencilFunc:XE,AmbientLight:qT,AmbientLightProbe:BO,AnimationClip:_m,AnimationLoader:EO,AnimationMixer:iF,AnimationObjectGroup:eF,AnimationUtils:rs,ArcCurve:xT,ArrayCamera:lT,ArrowHelper:bF,Audio:KT,AudioAnalyser:WO,AudioContext:Fv,AudioListener:VO,AudioLoader:OO,AxesHelper:wF,BackSide:fl,BasicDepthPacking:HE,BasicShadowMap:eE,Bone:Mv,BooleanKeyframeTrack:bd,Box2:aF,Box3:xd,Box3Helper:xF,BoxBufferGeometry:Vc,BoxGeometry:Vc,BoxHelper:yF,BufferAttribute:Yr,BufferGeometry:qi,BufferGeometryLoader:JT,ByteType:AE,Cache:pd,Camera:Em,CameraHelper:_F,CanvasTexture:yT,CapsuleBufferGeometry:Nf,CapsuleGeometry:Nf,CatmullRomCurve3:vT,CineonToneMapping:EE,CircleBufferGeometry:Uf,CircleGeometry:Uf,ClampToEdgeWrapping:Ta,Clock:Bv,Color:Kn,ColorKeyframeTrack:zv,ColorManagement:Dl,CompressedTexture:_T,CompressedTextureLoader:TO,ConeBufferGeometry:Vf,ConeGeometry:Vf,CubeCamera:QE,CubeReflectionMapping:rh,CubeRefractionMapping:sh,CubeTexture:Tm,CubeTextureLoader:AO,CubeUVReflectionMapping:tp,CubicBezierCurve:Av,CubicBezierCurve3:bT,CubicInterpolant:BT,CullFaceBack:lx,CullFaceFront:QM,CullFaceFrontBack:eL,CullFaceNone:KM,Curve:oc,CurvePath:ST,CustomBlending:nE,CustomToneMapping:TE,CylinderBufferGeometry:lh,CylinderGeometry:lh,Cylindrical:oF,Data3DTexture:N_,DataArrayTexture:Mm,DataTexture:Df,DataTexture2DArray:LF,DataTexture3D:RF,DataTextureLoader:CO,DataUtils:MF,DecrementStencilOp:fL,DecrementWrapStencilOp:mL,DefaultLoadingManager:VT,DepthFormat:ih,DepthStencilFormat:ld,DepthTexture:cT,DirectionalLight:HT,DirectionalLightHelper:gF,DiscreteInterpolant:NT,DodecahedronBufferGeometry:Gf,DodecahedronGeometry:Gf,DoubleSide:ad,DstAlphaFactor:cE,DstColorFactor:hE,DynamicCopyUsage:PL,DynamicDrawUsage:ML,DynamicReadUsage:AL,EdgesGeometry:MT,EllipseCurve:Z_,EqualDepth:_E,EqualStencilFunc:xL,EquirectangularReflectionMapping:nm,EquirectangularRefractionMapping:im,Euler:ip,EventDispatcher:Mu,ExtrudeBufferGeometry:jf,ExtrudeGeometry:jf,FileLoader:Wc,FlatShading:tE,Float16BufferAttribute:f3,Float32BufferAttribute:hi,Float64BufferAttribute:p3,FloatType:xu,Fog:j_,FogExp2:G_,Font:CF,FontLoader:AF,FramebufferTexture:Xk,FrontSide:od,Frustum:U_,GLBufferAttribute:sF,GLSL1:RL,GLSL3:kx,GreaterDepth:xE,GreaterEqualDepth:yE,GreaterEqualStencilFunc:SL,GreaterStencilFunc:bL,GridHelper:pF,Group:Lf,HalfFloatType:Of,HemisphereLight:GT,HemisphereLightHelper:fF,HemisphereLightProbe:FO,IcosahedronBufferGeometry:Wf,IcosahedronGeometry:Wf,ImageBitmapLoader:kO,ImageLoader:ym,ImageUtils:gv,ImmediateRenderObject:IF,IncrementStencilOp:dL,IncrementWrapStencilOp:pL,InstancedBufferAttribute:Bf,InstancedBufferGeometry:YT,InstancedInterleavedBuffer:rF,InstancedMesh:mT,Int16BufferAttribute:h3,Int32BufferAttribute:d3,Int8BufferAttribute:l3,IntType:IE,InterleavedBuffer:W_,InterleavedBufferAttribute:ud,Interpolant:Am,InterpolateDiscrete:om,InterpolateLinear:am,InterpolateSmooth:u_,InvertStencilOp:gL,KeepStencilOp:h_,KeyframeTrack:ac,LOD:fT,LatheBufferGeometry:hd,LatheGeometry:hd,Layers:rd,LessDepth:gE,LessEqualDepth:m_,LessEqualStencilFunc:vL,LessStencilFunc:yL,Light:hh,LightProbe:Y_,Line:ah,Line3:lF,LineBasicMaterial:La,LineCurve:X_,LineCurve3:wT,LineDashedMaterial:FT,LineLoop:gT,LineSegments:Hc,LinearEncoding:oh,LinearFilter:qs,LinearInterpolant:Dv,LinearMipMapLinearFilter:sL,LinearMipMapNearestFilter:rL,LinearMipmapLinearFilter:_d,LinearMipmapNearestFilter:dv,LinearSRGBColorSpace:nh,LinearToneMapping:SE,Loader:el,LoaderUtils:w_,LoadingManager:kv,LoopOnce:GE,LoopPingPong:WE,LoopRepeat:jE,LuminanceAlphaFormat:kE,LuminanceFormat:zE,MOUSE:jh,Material:fo,MaterialLoader:$T,MathUtils:XL,Matrix3:kl,Matrix4:sr,MaxEquation:fx,Mesh:Jo,MeshBasicMaterial:uh,MeshDepthMaterial:vv,MeshDistanceMaterial:bv,MeshLambertMaterial:kT,MeshMatcapMaterial:OT,MeshNormalMaterial:zT,MeshPhongMaterial:RT,MeshPhysicalMaterial:LT,MeshStandardMaterial:Rv,MeshToonMaterial:DT,MinEquation:dx,MirroredRepeatWrapping:sm,MixOperation:bE,MultiplyBlending:hx,MultiplyOperation:Sm,NearestFilter:uo,NearestMipMapLinearFilter:iL,NearestMipMapNearestFilter:nL,NearestMipmapLinearFilter:__,NearestMipmapNearestFilter:g_,NeverDepth:pE,NeverStencilFunc:_L,NoBlending:bu,NoColorSpace:cL,NoToneMapping:sc,NormalAnimationBlendMode:B_,NormalBlending:ed,NotEqualDepth:vE,NotEqualStencilFunc:wL,NumberKeyframeTrack:mm,Object3D:kr,ObjectLoader:DO,ObjectSpaceNormalMap:ZE,OctahedronBufferGeometry:dd,OctahedronGeometry:dd,OneFactor:oE,OneMinusDstAlphaFactor:uE,OneMinusDstColorFactor:dE,OneMinusSrcAlphaFactor:uv,OneMinusSrcColorFactor:lE,OrthographicCamera:vu,PCFShadowMap:O_,PCFSoftShadowMap:Kp,PMREMGenerator:Fx,ParametricGeometry:EF,Path:hm,PerspectiveCamera:ks,Plane:_u,PlaneBufferGeometry:cd,PlaneGeometry:cd,PlaneHelper:vF,PointLight:WT,PointLightHelper:hF,Points:Ev,PointsMaterial:q_,PolarGridHelper:mF,PolyhedronBufferGeometry:jc,PolyhedronGeometry:jc,PositionalAudio:jO,PropertyBinding:wr,PropertyMixer:QT,QuadraticBezierCurve:Cv,QuadraticBezierCurve3:Iv,Quaternion:Ko,QuaternionKeyframeTrack:sp,QuaternionLinearInterpolant:UT,REVISION:k_,RGBADepthPacking:qE,RGBAFormat:Qa,RGBAIntegerFormat:UE,RGBA_ASTC_10x10_Format:Lx,RGBA_ASTC_10x5_Format:Cx,RGBA_ASTC_10x6_Format:Ix,RGBA_ASTC_10x8_Format:Px,RGBA_ASTC_12x10_Format:Rx,RGBA_ASTC_12x12_Format:Dx,RGBA_ASTC_4x4_Format:vx,RGBA_ASTC_5x4_Format:bx,RGBA_ASTC_5x5_Format:wx,RGBA_ASTC_6x5_Format:Sx,RGBA_ASTC_6x6_Format:Mx,RGBA_ASTC_8x5_Format:Ex,RGBA_ASTC_8x6_Format:Tx,RGBA_ASTC_8x8_Format:Ax,RGBA_BPTC_Format:zx,RGBA_ETC2_EAC_Format:xx,RGBA_PVRTC_2BPPV1_Format:_x,RGBA_PVRTC_4BPPV1_Format:gx,RGBA_S3TC_DXT1_Format:a_,RGBA_S3TC_DXT3_Format:l_,RGBA_S3TC_DXT5_Format:c_,RGBFormat:DE,RGB_ETC1_Format:VE,RGB_ETC2_Format:yx,RGB_PVRTC_2BPPV1_Format:mx,RGB_PVRTC_4BPPV1_Format:px,RGB_S3TC_DXT1_Format:o_,RGFormat:BE,RGIntegerFormat:NE,RawShaderMaterial:PT,Ray:np,Raycaster:e2,RectAreaLight:ZT,RedFormat:OE,RedIntegerFormat:FE,ReinhardToneMapping:ME,RepeatWrapping:rm,ReplaceStencilOp:hL,ReverseSubtractEquation:rE,RingBufferGeometry:Hf,RingGeometry:Hf,SRGBColorSpace:Nc,Scene:b_,ShaderChunk:cr,ShaderLib:rc,ShaderMaterial:Gc,ShadowMaterial:IT,Shape:sd,ShapeBufferGeometry:qf,ShapeGeometry:qf,ShapePath:SF,ShapeUtils:Uc,ShortType:CE,Skeleton:H_,SkeletonHelper:uF,SkinnedMesh:pT,SmoothShading:tL,Source:Jh,Sphere:vd,SphereBufferGeometry:fd,SphereGeometry:fd,Spherical:jx,SphericalHarmonics3:XT,SplineCurve:Pv,SpotLight:jT,SpotLightHelper:cF,Sprite:dT,SpriteMaterial:Sv,SrcAlphaFactor:cv,SrcAlphaSaturateFactor:fE,SrcColorFactor:aE,StaticCopyUsage:IL,StaticDrawUsage:y_,StaticReadUsage:TL,StereoCamera:NO,StreamCopyUsage:LL,StreamDrawUsage:EL,StreamReadUsage:CL,StringKeyframeTrack:wd,SubtractEquation:iE,SubtractiveBlending:ux,TOUCH:Wh,TangentSpaceNormalMap:yd,TetrahedronBufferGeometry:Zf,TetrahedronGeometry:Zf,TextGeometry:TF,Texture:ho,TextureLoader:IO,TorusBufferGeometry:Xf,TorusGeometry:Xf,TorusKnotBufferGeometry:$f,TorusKnotGeometry:$f,Triangle:zl,TriangleFanDrawMode:lL,TriangleStripDrawMode:aL,TrianglesDrawMode:oL,TubeBufferGeometry:Yf,TubeGeometry:Yf,UVMapping:F_,Uint16BufferAttribute:_v,Uint32BufferAttribute:yv,Uint8BufferAttribute:c3,Uint8ClampedBufferAttribute:u3,Uniform:Vv,UniformsLib:jn,UniformsUtils:KE,UnsignedByteType:wu,UnsignedInt248Type:td,UnsignedIntType:th,UnsignedShort4444Type:PE,UnsignedShort5551Type:LE,UnsignedShortType:fv,VSMShadowMap:Xh,Vector2:tn,Vector3:Me,Vector4:Wr,VectorKeyframeTrack:gm,VideoTexture:Zk,WebGL1Renderer:uT,WebGL3DRenderTarget:KL,WebGLArrayRenderTarget:JL,WebGLCubeRenderTarget:eT,WebGLMultipleRenderTargets:QL,WebGLMultisampleRenderTarget:PF,WebGLRenderTarget:ml,WebGLRenderer:wv,WebGLUtils:aT,WireframeGeometry:CT,WrapAroundEnding:lm,ZeroCurvatureEnding:$h,ZeroFactor:sE,ZeroSlopeEnding:Yh,ZeroStencilOp:uL,_SRGBAFormat:x_,sRGBEncoding:hs},Symbol.toStringTag,{value:"Module"}));var Kh={exports:{}},Sd={};/**
 * @license React
 * react-reconciler-constants.production.min.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */Sd.ConcurrentRoot=1;Sd.ContinuousEventPriority=4;Sd.DefaultEventPriority=16;Sd.DiscreteEventPriority=1;Sd.IdleEventPriority=536870912;Sd.LegacyRoot=0;(function(d){d.exports=Sd})(Kh);function zF(d){let e;const n=new Set,a=(E,C)=>{const T=typeof E=="function"?E(e):E;if(T!==e){const I=e;e=C?T:Object.assign({},e,T),n.forEach(k=>k(e,I))}},c=()=>e,f=(E,C=c,T=Object.is)=>{console.warn("[DEPRECATED] Please use `subscribeWithSelector` middleware");let I=C(e);function k(){const O=C(e);if(!T(I,O)){const B=I;E(I=O,B)}}return n.add(k),()=>n.delete(k)},w={setState:a,getState:c,subscribe:(E,C,T)=>C||T?f(E,C,T):(n.add(E),()=>n.delete(E)),destroy:()=>n.clear()};return e=d(a,c,w),w}const kF=typeof window>"u"||!window.navigator||/ServerSideRendering|^Deno\//.test(window.navigator.userAgent),HS=kF?Ye.exports.useEffect:Ye.exports.useLayoutEffect;function OF(d){const e=typeof d=="function"?zF(d):d,n=(a=e.getState,c=Object.is)=>{const[,f]=Ye.exports.useReducer(F=>F+1,0),m=e.getState(),i=Ye.exports.useRef(m),w=Ye.exports.useRef(a),E=Ye.exports.useRef(c),C=Ye.exports.useRef(!1),T=Ye.exports.useRef();T.current===void 0&&(T.current=a(m));let I,k=!1;(i.current!==m||w.current!==a||E.current!==c||C.current)&&(I=a(m),k=!c(T.current,I)),HS(()=>{k&&(T.current=I),i.current=m,w.current=a,E.current=c,C.current=!1});const O=Ye.exports.useRef(m);HS(()=>{const F=()=>{try{const Y=e.getState(),K=w.current(Y);E.current(T.current,K)||(i.current=Y,T.current=K,f())}catch{C.current=!0,f()}},H=e.subscribe(F);return e.getState()!==O.current&&F(),H},[]);const B=k?I:T.current;return Ye.exports.useDebugValue(B),B};return Object.assign(n,e),n[Symbol.iterator]=function(){console.warn("[useStore, api] = create() is deprecated and will be removed in v4");const a=[n,e];return{next(){const c=a.length<=0;return{value:a.shift(),done:c}}}},n}var r2={exports:{}},S_={exports:{}},s2={};/**
 * @license React
 * scheduler.production.min.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */(function(d){function e(Fe,it){var tt=Fe.length;Fe.push(it);e:for(;0<tt;){var Et=tt-1>>>1,xt=Fe[Et];if(0<c(xt,it))Fe[Et]=it,Fe[tt]=xt,tt=Et;else break e}}function n(Fe){return Fe.length===0?null:Fe[0]}function a(Fe){if(Fe.length===0)return null;var it=Fe[0],tt=Fe.pop();if(tt!==it){Fe[0]=tt;e:for(var Et=0,xt=Fe.length,Pt=xt>>>1;Et<Pt;){var ln=2*(Et+1)-1,pn=Fe[ln],Mt=ln+1,ei=Fe[Mt];if(0>c(pn,tt))Mt<xt&&0>c(ei,pn)?(Fe[Et]=ei,Fe[Mt]=tt,Et=Mt):(Fe[Et]=pn,Fe[ln]=tt,Et=ln);else if(Mt<xt&&0>c(ei,tt))Fe[Et]=ei,Fe[Mt]=tt,Et=Mt;else break e}}return it}function c(Fe,it){var tt=Fe.sortIndex-it.sortIndex;return tt!==0?tt:Fe.id-it.id}if(typeof performance=="object"&&typeof performance.now=="function"){var f=performance;d.unstable_now=function(){return f.now()}}else{var m=Date,i=m.now();d.unstable_now=function(){return m.now()-i}}var w=[],E=[],C=1,T=null,I=3,k=!1,O=!1,B=!1,F=typeof setTimeout=="function"?setTimeout:null,H=typeof clearTimeout=="function"?clearTimeout:null,Y=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function K(Fe){for(var it=n(E);it!==null;){if(it.callback===null)a(E);else if(it.startTime<=Fe)a(E),it.sortIndex=it.expirationTime,e(w,it);else break;it=n(E)}}function ne(Fe){if(B=!1,K(Fe),!O)if(n(w)!==null)O=!0,ft(le);else{var it=n(E);it!==null&&Nt(ne,it.startTime-Fe)}}function le(Fe,it){O=!1,B&&(B=!1,H(oe),oe=-1),k=!0;var tt=I;try{for(K(it),T=n(w);T!==null&&(!(T.expirationTime>it)||Fe&&!ke());){var Et=T.callback;if(typeof Et=="function"){T.callback=null,I=T.priorityLevel;var xt=Et(T.expirationTime<=it);it=d.unstable_now(),typeof xt=="function"?T.callback=xt:T===n(w)&&a(w),K(it)}else a(w);T=n(w)}if(T!==null)var Pt=!0;else{var ln=n(E);ln!==null&&Nt(ne,ln.startTime-it),Pt=!1}return Pt}finally{T=null,I=tt,k=!1}}var fe=!1,Ae=null,oe=-1,ce=5,Re=-1;function ke(){return!(d.unstable_now()-Re<ce)}function Xe(){if(Ae!==null){var Fe=d.unstable_now();Re=Fe;var it=!0;try{it=Ae(!0,Fe)}finally{it?St():(fe=!1,Ae=null)}}else fe=!1}var St;if(typeof Y=="function")St=function(){Y(Xe)};else if(typeof MessageChannel<"u"){var Je=new MessageChannel,It=Je.port2;Je.port1.onmessage=Xe,St=function(){It.postMessage(null)}}else St=function(){F(Xe,0)};function ft(Fe){Ae=Fe,fe||(fe=!0,St())}function Nt(Fe,it){oe=F(function(){Fe(d.unstable_now())},it)}d.unstable_IdlePriority=5,d.unstable_ImmediatePriority=1,d.unstable_LowPriority=4,d.unstable_NormalPriority=3,d.unstable_Profiling=null,d.unstable_UserBlockingPriority=2,d.unstable_cancelCallback=function(Fe){Fe.callback=null},d.unstable_continueExecution=function(){O||k||(O=!0,ft(le))},d.unstable_forceFrameRate=function(Fe){0>Fe||125<Fe?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):ce=0<Fe?Math.floor(1e3/Fe):5},d.unstable_getCurrentPriorityLevel=function(){return I},d.unstable_getFirstCallbackNode=function(){return n(w)},d.unstable_next=function(Fe){switch(I){case 1:case 2:case 3:var it=3;break;default:it=I}var tt=I;I=it;try{return Fe()}finally{I=tt}},d.unstable_pauseExecution=function(){},d.unstable_requestPaint=function(){},d.unstable_runWithPriority=function(Fe,it){switch(Fe){case 1:case 2:case 3:case 4:case 5:break;default:Fe=3}var tt=I;I=Fe;try{return it()}finally{I=tt}},d.unstable_scheduleCallback=function(Fe,it,tt){var Et=d.unstable_now();switch(typeof tt=="object"&&tt!==null?(tt=tt.delay,tt=typeof tt=="number"&&0<tt?Et+tt:Et):tt=Et,Fe){case 1:var xt=-1;break;case 2:xt=250;break;case 5:xt=1073741823;break;case 4:xt=1e4;break;default:xt=5e3}return xt=tt+xt,Fe={id:C++,callback:it,priorityLevel:Fe,startTime:tt,expirationTime:xt,sortIndex:-1},tt>Et?(Fe.sortIndex=tt,e(E,Fe),n(w)===null&&Fe===n(E)&&(B?(H(oe),oe=-1):B=!0,Nt(ne,tt-Et))):(Fe.sortIndex=xt,e(w,Fe),O||k||(O=!0,ft(le))),Fe},d.unstable_shouldYield=ke,d.unstable_wrapCallback=function(Fe){var it=I;return function(){var tt=I;I=it;try{return Fe.apply(this,arguments)}finally{I=tt}}}})(s2);(function(d){d.exports=s2})(S_);/**
 * @license React
 * react-reconciler.production.min.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var FF=function(e){var n={},a=Ye.exports,c=S_.exports,f=Object.assign;function m(_){for(var x="https://reactjs.org/docs/error-decoder.html?invariant="+_,L=1;L<arguments.length;L++)x+="&args[]="+encodeURIComponent(arguments[L]);return"Minified React error #"+_+"; visit "+x+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var i=a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,w=Symbol.for("react.element"),E=Symbol.for("react.portal"),C=Symbol.for("react.fragment"),T=Symbol.for("react.strict_mode"),I=Symbol.for("react.profiler"),k=Symbol.for("react.provider"),O=Symbol.for("react.context"),B=Symbol.for("react.forward_ref"),F=Symbol.for("react.suspense"),H=Symbol.for("react.suspense_list"),Y=Symbol.for("react.memo"),K=Symbol.for("react.lazy"),ne=Symbol.for("react.offscreen"),le=Symbol.iterator;function fe(_){return _===null||typeof _!="object"?null:(_=le&&_[le]||_["@@iterator"],typeof _=="function"?_:null)}function Ae(_){if(_==null)return null;if(typeof _=="function")return _.displayName||_.name||null;if(typeof _=="string")return _;switch(_){case C:return"Fragment";case E:return"Portal";case I:return"Profiler";case T:return"StrictMode";case F:return"Suspense";case H:return"SuspenseList"}if(typeof _=="object")switch(_.$$typeof){case O:return(_.displayName||"Context")+".Consumer";case k:return(_._context.displayName||"Context")+".Provider";case B:var x=_.render;return _=_.displayName,_||(_=x.displayName||x.name||"",_=_!==""?"ForwardRef("+_+")":"ForwardRef"),_;case Y:return x=_.displayName||null,x!==null?x:Ae(_.type)||"Memo";case K:x=_._payload,_=_._init;try{return Ae(_(x))}catch{}}return null}function oe(_){var x=_.type;switch(_.tag){case 24:return"Cache";case 9:return(x.displayName||"Context")+".Consumer";case 10:return(x._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return _=x.render,_=_.displayName||_.name||"",x.displayName||(_!==""?"ForwardRef("+_+")":"ForwardRef");case 7:return"Fragment";case 5:return x;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Ae(x);case 8:return x===T?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof x=="function")return x.displayName||x.name||null;if(typeof x=="string")return x}return null}function ce(_){var x=_,L=_;if(_.alternate)for(;x.return;)x=x.return;else{_=x;do x=_,(x.flags&4098)!==0&&(L=x.return),_=x.return;while(_)}return x.tag===3?L:null}function Re(_){if(ce(_)!==_)throw Error(m(188))}function ke(_){var x=_.alternate;if(!x){if(x=ce(_),x===null)throw Error(m(188));return x!==_?null:_}for(var L=_,N=x;;){var Z=L.return;if(Z===null)break;var ee=Z.alternate;if(ee===null){if(N=Z.return,N!==null){L=N;continue}break}if(Z.child===ee.child){for(ee=Z.child;ee;){if(ee===L)return Re(Z),_;if(ee===N)return Re(Z),x;ee=ee.sibling}throw Error(m(188))}if(L.return!==N.return)L=Z,N=ee;else{for(var Pe=!1,at=Z.child;at;){if(at===L){Pe=!0,L=Z,N=ee;break}if(at===N){Pe=!0,N=Z,L=ee;break}at=at.sibling}if(!Pe){for(at=ee.child;at;){if(at===L){Pe=!0,L=ee,N=Z;break}if(at===N){Pe=!0,N=ee,L=Z;break}at=at.sibling}if(!Pe)throw Error(m(189))}}if(L.alternate!==N)throw Error(m(190))}if(L.tag!==3)throw Error(m(188));return L.stateNode.current===L?_:x}function Xe(_){return _=ke(_),_!==null?St(_):null}function St(_){if(_.tag===5||_.tag===6)return _;for(_=_.child;_!==null;){var x=St(_);if(x!==null)return x;_=_.sibling}return null}function Je(_){if(_.tag===5||_.tag===6)return _;for(_=_.child;_!==null;){if(_.tag!==4){var x=Je(_);if(x!==null)return x}_=_.sibling}return null}var It=Array.isArray,ft=e.getPublicInstance,Nt=e.getRootHostContext,Fe=e.getChildHostContext,it=e.prepareForCommit,tt=e.resetAfterCommit,Et=e.createInstance,xt=e.appendInitialChild,Pt=e.finalizeInitialChildren,ln=e.prepareUpdate,pn=e.shouldSetTextContent,Mt=e.createTextInstance,ei=e.scheduleTimeout,oi=e.cancelTimeout,Wn=e.noTimeout,jt=e.isPrimaryRenderer,mn=e.supportsMutation,qt=e.supportsPersistence,Dt=e.supportsHydration,gn=e.getInstanceFromNode,wn=e.preparePortalMount,Yt=e.getCurrentEventPriority,rn=e.detachDeletedInstance,dn=e.supportsMicrotasks,Mn=e.scheduleMicrotask,li=e.supportsTestSelectors,ti=e.findFiberRoot,Ie=e.getBoundingRect,xe=e.getTextContent,Tt=e.isHiddenSubtree,hn=e.matchAccessibilityRole,_n=e.setFocusIfFocusable,Sn=e.setupIntersectionObserver,ri=e.appendChild,kt=e.appendChildToContainer,Hn=e.commitTextUpdate,On=e.commitMount,Fn=e.commitUpdate,Ze=e.insertBefore,Tn=e.insertInContainerBefore,bn=e.removeChild,We=e.removeChildFromContainer,bt=e.resetTextContent,un=e.hideInstance,ue=e.hideTextInstance,te=e.unhideInstance,se=e.unhideTextInstance,ye=e.clearContainer,De=e.cloneInstance,je=e.createContainerChildSet,rt=e.appendChildToContainerChildSet,st=e.finalizeContainerChildren,He=e.replaceContainerChildren,pt=e.cloneHiddenInstance,Zt=e.cloneHiddenTextInstance,on=e.canHydrateInstance,Kt=e.canHydrateTextInstance,xi=e.canHydrateSuspenseInstance,ci=e.isSuspenseInstancePending,ve=e.isSuspenseInstanceFallback,Qe=e.registerSuspenseInstanceRetry,lt=e.getNextHydratableSibling,mt=e.getFirstHydratableChild,Gt=e.getFirstHydratableChildWithinContainer,$n=e.getFirstHydratableChildWithinSuspenseInstance,Yn=e.hydrateInstance,bi=e.hydrateTextInstance,ui=e.hydrateSuspenseInstance,ai=e.getNextHydratableInstanceAfterSuspenseInstance,Ni=e.commitHydratedContainer,Qi=e.commitHydratedSuspenseInstance,Cr=e.clearSuspenseBoundary,ki=e.clearSuspenseBoundaryFromContainer,ea=e.shouldDeleteUnhydratedTailInstances,Xs=e.didNotMatchHydratedContainerTextInstance,$s=e.didNotMatchHydratedTextInstance,Vi;function Ur(_){if(Vi===void 0)try{throw Error()}catch(L){var x=L.stack.trim().match(/\n( *(at )?)/);Vi=x&&x[1]||""}return`
`+Vi+_}var er=!1;function tr(_,x){if(!_||er)return"";er=!0;var L=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(x)if(x=function(){throw Error()},Object.defineProperty(x.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(x,[])}catch(Cn){var N=Cn}Reflect.construct(_,[],x)}else{try{x.call()}catch(Cn){N=Cn}_.call(x.prototype)}else{try{throw Error()}catch(Cn){N=Cn}_()}}catch(Cn){if(Cn&&N&&typeof Cn.stack=="string"){for(var Z=Cn.stack.split(`
`),ee=N.stack.split(`
`),Pe=Z.length-1,at=ee.length-1;1<=Pe&&0<=at&&Z[Pe]!==ee[at];)at--;for(;1<=Pe&&0<=at;Pe--,at--)if(Z[Pe]!==ee[at]){if(Pe!==1||at!==1)do if(Pe--,at--,0>at||Z[Pe]!==ee[at]){var Ut=`
`+Z[Pe].replace(" at new "," at ");return _.displayName&&Ut.includes("<anonymous>")&&(Ut=Ut.replace("<anonymous>",_.displayName)),Ut}while(1<=Pe&&0<=at);break}}}finally{er=!1,Error.prepareStackTrace=L}return(_=_?_.displayName||_.name:"")?Ur(_):""}var po=Object.prototype.hasOwnProperty,Es=[],Ir=-1;function Zi(_){return{current:_}}function ct(_){0>Ir||(_.current=Es[Ir],Es[Ir]=null,Ir--)}function Ri(_,x){Ir++,Es[Ir]=_.current,_.current=x}var Ci={},nr=Zi(Ci),Os=Zi(!1),Ts=Ci;function Ra(_,x){var L=_.type.contextTypes;if(!L)return Ci;var N=_.stateNode;if(N&&N.__reactInternalMemoizedUnmaskedChildContext===x)return N.__reactInternalMemoizedMaskedChildContext;var Z={},ee;for(ee in L)Z[ee]=x[ee];return N&&(_=_.stateNode,_.__reactInternalMemoizedUnmaskedChildContext=x,_.__reactInternalMemoizedMaskedChildContext=Z),Z}function As(_){return _=_.childContextTypes,_!=null}function Uo(){ct(Os),ct(nr)}function En(_,x,L){if(nr.current!==Ci)throw Error(m(168));Ri(nr,x),Ri(Os,L)}function Oi(_,x,L){var N=_.stateNode;if(x=x.childContextTypes,typeof N.getChildContext!="function")return L;N=N.getChildContext();for(var Z in N)if(!(Z in x))throw Error(m(108,oe(_)||"Unknown",Z));return f({},L,N)}function Mi(_){return _=(_=_.stateNode)&&_.__reactInternalMemoizedMergedChildContext||Ci,Ts=nr.current,Ri(nr,_),Ri(Os,Os.current),!0}function Ys(_,x,L){var N=_.stateNode;if(!N)throw Error(m(169));L?(_=Oi(_,x,Ts),N.__reactInternalMemoizedMergedChildContext=_,ct(Os),ct(nr),Ri(nr,_)):ct(Os),Ri(Os,L)}var Hr=Math.clz32?Math.clz32:W,Ei=Math.log,D=Math.LN2;function W(_){return _>>>=0,_===0?32:31-(Ei(_)/D|0)|0}var ae=64,Ce=4194304;function Oe(_){switch(_&-_){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return _&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return _&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return _}}function qe(_,x){var L=_.pendingLanes;if(L===0)return 0;var N=0,Z=_.suspendedLanes,ee=_.pingedLanes,Pe=L&268435455;if(Pe!==0){var at=Pe&~Z;at!==0?N=Oe(at):(ee&=Pe,ee!==0&&(N=Oe(ee)))}else Pe=L&~Z,Pe!==0?N=Oe(Pe):ee!==0&&(N=Oe(ee));if(N===0)return 0;if(x!==0&&x!==N&&(x&Z)===0&&(Z=N&-N,ee=x&-x,Z>=ee||Z===16&&(ee&4194240)!==0))return x;if((N&4)!==0&&(N|=L&16),x=_.entangledLanes,x!==0)for(_=_.entanglements,x&=N;0<x;)L=31-Hr(x),Z=1<<L,N|=_[L],x&=~Z;return N}function nt(_,x){switch(_){case 1:case 2:case 4:return x+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return x+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function en(_,x){for(var L=_.suspendedLanes,N=_.pingedLanes,Z=_.expirationTimes,ee=_.pendingLanes;0<ee;){var Pe=31-Hr(ee),at=1<<Pe,Ut=Z[Pe];Ut===-1?((at&L)===0||(at&N)!==0)&&(Z[Pe]=nt(at,x)):Ut<=x&&(_.expiredLanes|=at),ee&=~at}}function cn(_){return _=_.pendingLanes&-1073741825,_!==0?_:_&1073741824?1073741824:0}function Ln(_){for(var x=[],L=0;31>L;L++)x.push(_);return x}function Pn(_,x,L){_.pendingLanes|=x,x!==536870912&&(_.suspendedLanes=0,_.pingedLanes=0),_=_.eventTimes,x=31-Hr(x),_[x]=L}function xn(_,x){var L=_.pendingLanes&~x;_.pendingLanes=x,_.suspendedLanes=0,_.pingedLanes=0,_.expiredLanes&=x,_.mutableReadLanes&=x,_.entangledLanes&=x,x=_.entanglements;var N=_.eventTimes;for(_=_.expirationTimes;0<L;){var Z=31-Hr(L),ee=1<<Z;x[Z]=0,N[Z]=-1,_[Z]=-1,L&=~ee}}function mi(_,x){var L=_.entangledLanes|=x;for(_=_.entanglements;L;){var N=31-Hr(L),Z=1<<N;Z&x|_[N]&x&&(_[N]|=x),L&=~Z}}var di=0;function vi(_){return _&=-_,1<_?4<_?(_&268435455)!==0?16:536870912:4:1}var Ji=c.unstable_scheduleCallback,zt=c.unstable_cancelCallback,Xn=c.unstable_shouldYield,ur=c.unstable_requestPaint,wi=c.unstable_now,or=c.unstable_ImmediatePriority,lc=c.unstable_UserBlockingPriority,tl=c.unstable_NormalPriority,Si=c.unstable_IdlePriority,ha=null,To=null;function Fs(_){if(To&&typeof To.onCommitFiberRoot=="function")try{To.onCommitFiberRoot(ha,_,void 0,(_.current.flags&128)===128)}catch{}}function os(_,x){return _===x&&(_!==0||1/_===1/x)||_!==_&&x!==x}var mo=typeof Object.is=="function"?Object.is:os,Ao=null,Js=!1,Vo=!1;function gl(_){Ao===null?Ao=[_]:Ao.push(_)}function dh(_){Js=!0,gl(_)}function Co(){if(!Vo&&Ao!==null){Vo=!0;var _=0,x=di;try{var L=Ao;for(di=1;_<L.length;_++){var N=L[_];do N=N(!0);while(N!==null)}Ao=null,Js=!1}catch(Z){throw Ao!==null&&(Ao=Ao.slice(_+1)),Ji(or,Co),Z}finally{di=x,Vo=!1}}return null}var _l=i.ReactCurrentBatchConfig;function Ks(_,x){if(mo(_,x))return!0;if(typeof _!="object"||_===null||typeof x!="object"||x===null)return!1;var L=Object.keys(_),N=Object.keys(x);if(L.length!==N.length)return!1;for(N=0;N<L.length;N++){var Z=L[N];if(!po.call(x,Z)||!mo(_[Z],x[Z]))return!1}return!0}function cc(_){switch(_.tag){case 5:return Ur(_.type);case 16:return Ur("Lazy");case 13:return Ur("Suspense");case 19:return Ur("SuspenseList");case 0:case 2:case 15:return _=tr(_.type,!1),_;case 11:return _=tr(_.type.render,!1),_;case 1:return _=tr(_.type,!0),_;default:return""}}function as(_,x){if(_&&_.defaultProps){x=f({},x),_=_.defaultProps;for(var L in _)x[L]===void 0&&(x[L]=_[L]);return x}return x}var Io=Zi(null),Da=null,ds=null,za=null;function da(){za=ds=Da=null}function Bs(_,x,L){jt?(Ri(Io,x._currentValue),x._currentValue=L):(Ri(Io,x._currentValue2),x._currentValue2=L)}function Ol(_){var x=Io.current;ct(Io),jt?_._currentValue=x:_._currentValue2=x}function nl(_,x,L){for(;_!==null;){var N=_.alternate;if((_.childLanes&x)!==x?(_.childLanes|=x,N!==null&&(N.childLanes|=x)):N!==null&&(N.childLanes&x)!==x&&(N.childLanes|=x),_===L)break;_=_.return}}function ka(_,x){Da=_,za=ds=null,_=_.dependencies,_!==null&&_.firstContext!==null&&((_.lanes&x)!==0&&(Do=!0),_.firstContext=null)}function Ns(_){var x=jt?_._currentValue:_._currentValue2;if(za!==_)if(_={context:_,memoizedValue:x,next:null},ds===null){if(Da===null)throw Error(m(308));ds=_,Da.dependencies={lanes:0,firstContext:_}}else ds=ds.next=_;return x}var ls=null,Bi=!1;function uc(_){_.updateQueue={baseState:_.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function hc(_,x){_=_.updateQueue,x.updateQueue===_&&(x.updateQueue={baseState:_.baseState,firstBaseUpdate:_.firstBaseUpdate,lastBaseUpdate:_.lastBaseUpdate,shared:_.shared,effects:_.effects})}function Cs(_,x){return{eventTime:_,lane:x,tag:0,payload:null,callback:null,next:null}}function Go(_,x){var L=_.updateQueue;L!==null&&(L=L.shared,zn!==null&&(_.mode&1)!==0&&(Ct&2)===0?(_=L.interleaved,_===null?(x.next=x,ls===null?ls=[L]:ls.push(L)):(x.next=_.next,_.next=x),L.interleaved=x):(_=L.pending,_===null?x.next=x:(x.next=_.next,_.next=x),L.pending=x))}function Fl(_,x,L){if(x=x.updateQueue,x!==null&&(x=x.shared,(L&4194240)!==0)){var N=x.lanes;N&=_.pendingLanes,L|=N,x.lanes=L,mi(_,L)}}function dc(_,x){var L=_.updateQueue,N=_.alternate;if(N!==null&&(N=N.updateQueue,L===N)){var Z=null,ee=null;if(L=L.firstBaseUpdate,L!==null){do{var Pe={eventTime:L.eventTime,lane:L.lane,tag:L.tag,payload:L.payload,callback:L.callback,next:null};ee===null?Z=ee=Pe:ee=ee.next=Pe,L=L.next}while(L!==null);ee===null?Z=ee=x:ee=ee.next=x}else Z=ee=x;L={baseState:N.baseState,firstBaseUpdate:Z,lastBaseUpdate:ee,shared:N.shared,effects:N.effects},_.updateQueue=L;return}_=L.lastBaseUpdate,_===null?L.firstBaseUpdate=x:_.next=x,L.lastBaseUpdate=x}function jo(_,x,L,N){var Z=_.updateQueue;Bi=!1;var ee=Z.firstBaseUpdate,Pe=Z.lastBaseUpdate,at=Z.shared.pending;if(at!==null){Z.shared.pending=null;var Ut=at,Cn=Ut.next;Ut.next=null,Pe===null?ee=Cn:Pe.next=Cn,Pe=Ut;var Qn=_.alternate;Qn!==null&&(Qn=Qn.updateQueue,at=Qn.lastBaseUpdate,at!==Pe&&(at===null?Qn.firstBaseUpdate=Cn:at.next=Cn,Qn.lastBaseUpdate=Ut))}if(ee!==null){var Fi=Z.baseState;Pe=0,Qn=Cn=Ut=null,at=ee;do{var _i=at.lane,Ki=at.eventTime;if((N&_i)===_i){Qn!==null&&(Qn=Qn.next={eventTime:Ki,lane:0,tag:at.tag,payload:at.payload,callback:at.callback,next:null});e:{var fi=_,br=at;switch(_i=x,Ki=L,br.tag){case 1:if(fi=br.payload,typeof fi=="function"){Fi=fi.call(Ki,Fi,_i);break e}Fi=fi;break e;case 3:fi.flags=fi.flags&-65537|128;case 0:if(fi=br.payload,_i=typeof fi=="function"?fi.call(Ki,Fi,_i):fi,_i==null)break e;Fi=f({},Fi,_i);break e;case 2:Bi=!0}}at.callback!==null&&at.lane!==0&&(_.flags|=64,_i=Z.effects,_i===null?Z.effects=[at]:_i.push(at))}else Ki={eventTime:Ki,lane:_i,tag:at.tag,payload:at.payload,callback:at.callback,next:null},Qn===null?(Cn=Qn=Ki,Ut=Fi):Qn=Qn.next=Ki,Pe|=_i;if(at=at.next,at===null){if(at=Z.shared.pending,at===null)break;_i=at,at=_i.next,_i.next=null,Z.lastBaseUpdate=_i,Z.shared.pending=null}}while(1);if(Qn===null&&(Ut=Fi),Z.baseState=Ut,Z.firstBaseUpdate=Cn,Z.lastBaseUpdate=Qn,x=Z.shared.interleaved,x!==null){Z=x;do Pe|=Z.lane,Z=Z.next;while(Z!==x)}else ee===null&&(Z.shared.lanes=0);$i|=Pe,_.lanes=Pe,_.memoizedState=Fi}}function fa(_,x,L){if(_=x.effects,x.effects=null,_!==null)for(x=0;x<_.length;x++){var N=_[x],Z=N.callback;if(Z!==null){if(N.callback=null,N=L,typeof Z!="function")throw Error(m(191,Z));Z.call(N)}}}var pa=new a.Component().refs;function go(_,x,L,N){x=_.memoizedState,L=L(N,x),L=L==null?x:f({},x,L),_.memoizedState=L,_.lanes===0&&(_.updateQueue.baseState=L)}var Po={isMounted:function(_){return(_=_._reactInternals)?ce(_)===_:!1},enqueueSetState:function(_,x,L){_=_._reactInternals;var N=Xr(),Z=wo(_),ee=Cs(N,Z);ee.payload=x,L!=null&&(ee.callback=L),Go(_,ee),x=Ls(_,Z,N),x!==null&&Fl(x,_,Z)},enqueueReplaceState:function(_,x,L){_=_._reactInternals;var N=Xr(),Z=wo(_),ee=Cs(N,Z);ee.tag=1,ee.payload=x,L!=null&&(ee.callback=L),Go(_,ee),x=Ls(_,Z,N),x!==null&&Fl(x,_,Z)},enqueueForceUpdate:function(_,x){_=_._reactInternals;var L=Xr(),N=wo(_),Z=Cs(L,N);Z.tag=2,x!=null&&(Z.callback=x),Go(_,Z),x=Ls(_,N,L),x!==null&&Fl(x,_,N)}};function ma(_,x,L,N,Z,ee,Pe){return _=_.stateNode,typeof _.shouldComponentUpdate=="function"?_.shouldComponentUpdate(N,ee,Pe):x.prototype&&x.prototype.isPureReactComponent?!Ks(L,N)||!Ks(Z,ee):!0}function qc(_,x,L){var N=!1,Z=Ci,ee=x.contextType;return typeof ee=="object"&&ee!==null?ee=Ns(ee):(Z=As(x)?Ts:nr.current,N=x.contextTypes,ee=(N=N!=null)?Ra(_,Z):Ci),x=new x(L,ee),_.memoizedState=x.state!==null&&x.state!==void 0?x.state:null,x.updater=Po,_.stateNode=x,x._reactInternals=_,N&&(_=_.stateNode,_.__reactInternalMemoizedUnmaskedChildContext=Z,_.__reactInternalMemoizedMaskedChildContext=ee),x}function yl(_,x,L,N){_=x.state,typeof x.componentWillReceiveProps=="function"&&x.componentWillReceiveProps(L,N),typeof x.UNSAFE_componentWillReceiveProps=="function"&&x.UNSAFE_componentWillReceiveProps(L,N),x.state!==_&&Po.enqueueReplaceState(x,x.state,null)}function Bl(_,x,L,N){var Z=_.stateNode;Z.props=L,Z.state=_.memoizedState,Z.refs=pa,uc(_);var ee=x.contextType;typeof ee=="object"&&ee!==null?Z.context=Ns(ee):(ee=As(x)?Ts:nr.current,Z.context=Ra(_,ee)),Z.state=_.memoizedState,ee=x.getDerivedStateFromProps,typeof ee=="function"&&(go(_,x,ee,L),Z.state=_.memoizedState),typeof x.getDerivedStateFromProps=="function"||typeof Z.getSnapshotBeforeUpdate=="function"||typeof Z.UNSAFE_componentWillMount!="function"&&typeof Z.componentWillMount!="function"||(x=Z.state,typeof Z.componentWillMount=="function"&&Z.componentWillMount(),typeof Z.UNSAFE_componentWillMount=="function"&&Z.UNSAFE_componentWillMount(),x!==Z.state&&Po.enqueueReplaceState(Z,Z.state,null),jo(_,L,Z,N),Z.state=_.memoizedState),typeof Z.componentDidMount=="function"&&(_.flags|=4194308)}var Oa=[],ga=0,Fa=null,Ba=0,gi=[],Or=0,Qs=null,eo=1,fs="";function _o(_,x){Oa[ga++]=Ba,Oa[ga++]=Fa,Fa=_,Ba=x}function il(_,x,L){gi[Or++]=eo,gi[Or++]=fs,gi[Or++]=Qs,Qs=_;var N=eo;_=fs;var Z=32-Hr(N)-1;N&=~(1<<Z),L+=1;var ee=32-Hr(x)+Z;if(30<ee){var Pe=Z-Z%5;ee=(N&(1<<Pe)-1).toString(32),N>>=Pe,Z-=Pe,eo=1<<32-Hr(x)+Z|L<<Z|N,fs=ee+_}else eo=1<<ee|L<<Z|N,fs=_}function rl(_){_.return!==null&&(_o(_,1),il(_,1,0))}function fc(_){for(;_===Fa;)Fa=Oa[--ga],Oa[ga]=null,Ba=Oa[--ga],Oa[ga]=null;for(;_===Qs;)Qs=gi[--Or],gi[Or]=null,fs=gi[--Or],gi[Or]=null,eo=gi[--Or],gi[Or]=null}var to=null,Us=null,Sr=!1,Na=!1,Vs=null;function xl(_,x){var L=wa(5,null,null,0);L.elementType="DELETED",L.stateNode=x,L.return=_,x=_.deletions,x===null?(_.deletions=[L],_.flags|=16):x.push(L)}function Ua(_,x){switch(_.tag){case 5:return x=on(x,_.type,_.pendingProps),x!==null?(_.stateNode=x,to=_,Us=mt(x),!0):!1;case 6:return x=Kt(x,_.pendingProps),x!==null?(_.stateNode=x,to=_,Us=null,!0):!1;case 13:if(x=xi(x),x!==null){var L=Qs!==null?{id:eo,overflow:fs}:null;return _.memoizedState={dehydrated:x,treeContext:L,retryLane:1073741824},L=wa(18,null,null,0),L.stateNode=x,L.return=_,_.child=L,to=_,Us=null,!0}return!1;default:return!1}}function Zc(_){return(_.mode&1)!==0&&(_.flags&128)===0}function no(_){if(Sr){var x=Us;if(x){var L=x;if(!Ua(_,x)){if(Zc(_))throw Error(m(418));x=lt(L);var N=to;x&&Ua(_,x)?xl(N,L):(_.flags=_.flags&-4097|2,Sr=!1,to=_)}}else{if(Zc(_))throw Error(m(418));_.flags=_.flags&-4097|2,Sr=!1,to=_}}}function sl(_){for(_=_.return;_!==null&&_.tag!==5&&_.tag!==3&&_.tag!==13;)_=_.return;to=_}function yo(_){if(!Dt||_!==to)return!1;if(!Sr)return sl(_),Sr=!0,!1;if(_.tag!==3&&(_.tag!==5||ea(_.type)&&!pn(_.type,_.memoizedProps))){var x=Us;if(x){if(Zc(_)){for(_=Us;_;)_=lt(_);throw Error(m(418))}for(;x;)xl(_,x),x=lt(x)}}if(sl(_),_.tag===13){if(!Dt)throw Error(m(316));if(_=_.memoizedState,_=_!==null?_.dehydrated:null,!_)throw Error(m(317));Us=ai(_)}else Us=to?lt(_.stateNode):null;return!0}function Wo(){Dt&&(Us=to=null,Na=Sr=!1)}function Nl(_){Vs===null?Vs=[_]:Vs.push(_)}function ps(_,x,L){if(_=L.ref,_!==null&&typeof _!="function"&&typeof _!="object"){if(L._owner){if(L=L._owner,L){if(L.tag!==1)throw Error(m(309));var N=L.stateNode}if(!N)throw Error(m(147,_));var Z=N,ee=""+_;return x!==null&&x.ref!==null&&typeof x.ref=="function"&&x.ref._stringRef===ee?x.ref:(x=function(Pe){var at=Z.refs;at===pa&&(at=Z.refs={}),Pe===null?delete at[ee]:at[ee]=Pe},x._stringRef=ee,x)}if(typeof _!="string")throw Error(m(284));if(!L._owner)throw Error(m(290,_))}return _}function _a(_,x){throw _=Object.prototype.toString.call(x),Error(m(31,_==="[object Object]"?"object with keys {"+Object.keys(x).join(", ")+"}":_))}function Ul(_){var x=_._init;return x(_._payload)}function vl(_){function x(wt,Ke){if(_){var Vt=wt.deletions;Vt===null?(wt.deletions=[Ke],wt.flags|=16):Vt.push(Ke)}}function L(wt,Ke){if(!_)return null;for(;Ke!==null;)x(wt,Ke),Ke=Ke.sibling;return null}function N(wt,Ke){for(wt=new Map;Ke!==null;)Ke.key!==null?wt.set(Ke.key,Ke):wt.set(Ke.index,Ke),Ke=Ke.sibling;return wt}function Z(wt,Ke){return wt=Cc(wt,Ke),wt.index=0,wt.sibling=null,wt}function ee(wt,Ke,Vt){return wt.index=Vt,_?(Vt=wt.alternate,Vt!==null?(Vt=Vt.index,Vt<Ke?(wt.flags|=2,Ke):Vt):(wt.flags|=2,Ke)):(wt.flags|=1048576,Ke)}function Pe(wt){return _&&wt.alternate===null&&(wt.flags|=2),wt}function at(wt,Ke,Vt,Un){return Ke===null||Ke.tag!==6?(Ke=Fu(Vt,wt.mode,Un),Ke.return=wt,Ke):(Ke=Z(Ke,Vt),Ke.return=wt,Ke)}function Ut(wt,Ke,Vt,Un){var Jn=Vt.type;return Jn===C?Qn(wt,Ke,Vt.props.children,Un,Vt.key):Ke!==null&&(Ke.elementType===Jn||typeof Jn=="object"&&Jn!==null&&Jn.$$typeof===K&&Ul(Jn)===Ke.type)?(Un=Z(Ke,Vt.props),Un.ref=ps(wt,Ke,Vt),Un.return=wt,Un):(Un=jr(Vt.type,Vt.key,Vt.props,null,wt.mode,Un),Un.ref=ps(wt,Ke,Vt),Un.return=wt,Un)}function Cn(wt,Ke,Vt,Un){return Ke===null||Ke.tag!==4||Ke.stateNode.containerInfo!==Vt.containerInfo||Ke.stateNode.implementation!==Vt.implementation?(Ke=Oo(Vt,wt.mode,Un),Ke.return=wt,Ke):(Ke=Z(Ke,Vt.children||[]),Ke.return=wt,Ke)}function Qn(wt,Ke,Vt,Un,Jn){return Ke===null||Ke.tag!==7?(Ke=Zn(Vt,wt.mode,Un,Jn),Ke.return=wt,Ke):(Ke=Z(Ke,Vt),Ke.return=wt,Ke)}function Fi(wt,Ke,Vt){if(typeof Ke=="string"&&Ke!==""||typeof Ke=="number")return Ke=Fu(""+Ke,wt.mode,Vt),Ke.return=wt,Ke;if(typeof Ke=="object"&&Ke!==null){switch(Ke.$$typeof){case w:return Vt=jr(Ke.type,Ke.key,Ke.props,null,wt.mode,Vt),Vt.ref=ps(wt,null,Ke),Vt.return=wt,Vt;case E:return Ke=Oo(Ke,wt.mode,Vt),Ke.return=wt,Ke;case K:var Un=Ke._init;return Fi(wt,Un(Ke._payload),Vt)}if(It(Ke)||fe(Ke))return Ke=Zn(Ke,wt.mode,Vt,null),Ke.return=wt,Ke;_a(wt,Ke)}return null}function _i(wt,Ke,Vt,Un){var Jn=Ke!==null?Ke.key:null;if(typeof Vt=="string"&&Vt!==""||typeof Vt=="number")return Jn!==null?null:at(wt,Ke,""+Vt,Un);if(typeof Vt=="object"&&Vt!==null){switch(Vt.$$typeof){case w:return Vt.key===Jn?Ut(wt,Ke,Vt,Un):null;case E:return Vt.key===Jn?Cn(wt,Ke,Vt,Un):null;case K:return Jn=Vt._init,_i(wt,Ke,Jn(Vt._payload),Un)}if(It(Vt)||fe(Vt))return Jn!==null?null:Qn(wt,Ke,Vt,Un,null);_a(wt,Vt)}return null}function Ki(wt,Ke,Vt,Un,Jn){if(typeof Un=="string"&&Un!==""||typeof Un=="number")return wt=wt.get(Vt)||null,at(Ke,wt,""+Un,Jn);if(typeof Un=="object"&&Un!==null){switch(Un.$$typeof){case w:return wt=wt.get(Un.key===null?Vt:Un.key)||null,Ut(Ke,wt,Un,Jn);case E:return wt=wt.get(Un.key===null?Vt:Un.key)||null,Cn(Ke,wt,Un,Jn);case K:var Yi=Un._init;return Ki(wt,Ke,Vt,Yi(Un._payload),Jn)}if(It(Un)||fe(Un))return wt=wt.get(Vt)||null,Qn(Ke,wt,Un,Jn,null);_a(Ke,Un)}return null}function fi(wt,Ke,Vt,Un){for(var Jn=null,Yi=null,Hi=Ke,_r=Ke=0,Ws=null;Hi!==null&&_r<Vt.length;_r++){Hi.index>_r?(Ws=Hi,Hi=null):Ws=Hi.sibling;var rr=_i(wt,Hi,Vt[_r],Un);if(rr===null){Hi===null&&(Hi=Ws);break}_&&Hi&&rr.alternate===null&&x(wt,Hi),Ke=ee(rr,Ke,_r),Yi===null?Jn=rr:Yi.sibling=rr,Yi=rr,Hi=Ws}if(_r===Vt.length)return L(wt,Hi),Sr&&_o(wt,_r),Jn;if(Hi===null){for(;_r<Vt.length;_r++)Hi=Fi(wt,Vt[_r],Un),Hi!==null&&(Ke=ee(Hi,Ke,_r),Yi===null?Jn=Hi:Yi.sibling=Hi,Yi=Hi);return Sr&&_o(wt,_r),Jn}for(Hi=N(wt,Hi);_r<Vt.length;_r++)Ws=Ki(Hi,wt,_r,Vt[_r],Un),Ws!==null&&(_&&Ws.alternate!==null&&Hi.delete(Ws.key===null?_r:Ws.key),Ke=ee(Ws,Ke,_r),Yi===null?Jn=Ws:Yi.sibling=Ws,Yi=Ws);return _&&Hi.forEach(function(Zl){return x(wt,Zl)}),Sr&&_o(wt,_r),Jn}function br(wt,Ke,Vt,Un){var Jn=fe(Vt);if(typeof Jn!="function")throw Error(m(150));if(Vt=Jn.call(Vt),Vt==null)throw Error(m(151));for(var Yi=Jn=null,Hi=Ke,_r=Ke=0,Ws=null,rr=Vt.next();Hi!==null&&!rr.done;_r++,rr=Vt.next()){Hi.index>_r?(Ws=Hi,Hi=null):Ws=Hi.sibling;var Zl=_i(wt,Hi,rr.value,Un);if(Zl===null){Hi===null&&(Hi=Ws);break}_&&Hi&&Zl.alternate===null&&x(wt,Hi),Ke=ee(Zl,Ke,_r),Yi===null?Jn=Zl:Yi.sibling=Zl,Yi=Zl,Hi=Ws}if(rr.done)return L(wt,Hi),Sr&&_o(wt,_r),Jn;if(Hi===null){for(;!rr.done;_r++,rr=Vt.next())rr=Fi(wt,rr.value,Un),rr!==null&&(Ke=ee(rr,Ke,_r),Yi===null?Jn=rr:Yi.sibling=rr,Yi=rr);return Sr&&_o(wt,_r),Jn}for(Hi=N(wt,Hi);!rr.done;_r++,rr=Vt.next())rr=Ki(Hi,wt,_r,rr.value,Un),rr!==null&&(_&&rr.alternate!==null&&Hi.delete(rr.key===null?_r:rr.key),Ke=ee(rr,Ke,_r),Yi===null?Jn=rr:Yi.sibling=rr,Yi=rr);return _&&Hi.forEach(function(zm){return x(wt,zm)}),Sr&&_o(wt,_r),Jn}function ns(wt,Ke,Vt,Un){if(typeof Vt=="object"&&Vt!==null&&Vt.type===C&&Vt.key===null&&(Vt=Vt.props.children),typeof Vt=="object"&&Vt!==null){switch(Vt.$$typeof){case w:e:{for(var Jn=Vt.key,Yi=Ke;Yi!==null;){if(Yi.key===Jn){if(Jn=Vt.type,Jn===C){if(Yi.tag===7){L(wt,Yi.sibling),Ke=Z(Yi,Vt.props.children),Ke.return=wt,wt=Ke;break e}}else if(Yi.elementType===Jn||typeof Jn=="object"&&Jn!==null&&Jn.$$typeof===K&&Ul(Jn)===Yi.type){L(wt,Yi.sibling),Ke=Z(Yi,Vt.props),Ke.ref=ps(wt,Yi,Vt),Ke.return=wt,wt=Ke;break e}L(wt,Yi);break}else x(wt,Yi);Yi=Yi.sibling}Vt.type===C?(Ke=Zn(Vt.props.children,wt.mode,Un,Vt.key),Ke.return=wt,wt=Ke):(Un=jr(Vt.type,Vt.key,Vt.props,null,wt.mode,Un),Un.ref=ps(wt,Ke,Vt),Un.return=wt,wt=Un)}return Pe(wt);case E:e:{for(Yi=Vt.key;Ke!==null;){if(Ke.key===Yi)if(Ke.tag===4&&Ke.stateNode.containerInfo===Vt.containerInfo&&Ke.stateNode.implementation===Vt.implementation){L(wt,Ke.sibling),Ke=Z(Ke,Vt.children||[]),Ke.return=wt,wt=Ke;break e}else{L(wt,Ke);break}else x(wt,Ke);Ke=Ke.sibling}Ke=Oo(Vt,wt.mode,Un),Ke.return=wt,wt=Ke}return Pe(wt);case K:return Yi=Vt._init,ns(wt,Ke,Yi(Vt._payload),Un)}if(It(Vt))return fi(wt,Ke,Vt,Un);if(fe(Vt))return br(wt,Ke,Vt,Un);_a(wt,Vt)}return typeof Vt=="string"&&Vt!==""||typeof Vt=="number"?(Vt=""+Vt,Ke!==null&&Ke.tag===6?(L(wt,Ke.sibling),Ke=Z(Ke,Vt),Ke.return=wt,wt=Ke):(L(wt,Ke),Ke=Fu(Vt,wt.mode,Un),Ke.return=wt,wt=Ke),Pe(wt)):L(wt,Ke)}return ns}var Va=vl(!0),Ga=vl(!1),bl={},io=Zi(bl),ot=Zi(bl),At=Zi(bl);function yn(_){if(_===bl)throw Error(m(174));return _}function ni(_,x){Ri(At,x),Ri(ot,_),Ri(io,bl),_=Nt(x),ct(io),Ri(io,_)}function fr(){ct(io),ct(ot),ct(At)}function Wi(_){var x=yn(At.current),L=yn(io.current);x=Fe(L,_.type,x),L!==x&&(Ri(ot,_),Ri(io,x))}function Pr(_){ot.current===_&&(ct(io),ct(ot))}var Ti=Zi(0);function Gs(_){for(var x=_;x!==null;){if(x.tag===13){var L=x.memoizedState;if(L!==null&&(L=L.dehydrated,L===null||ci(L)||ve(L)))return x}else if(x.tag===19&&x.memoizedProps.revealOrder!==void 0){if((x.flags&128)!==0)return x}else if(x.child!==null){x.child.return=x,x=x.child;continue}if(x===_)break;for(;x.sibling===null;){if(x.return===null||x.return===_)return null;x=x.return}x.sibling.return=x.return,x=x.sibling}return null}var Fr=[];function Vr(){for(var _=0;_<Fr.length;_++){var x=Fr[_];jt?x._workInProgressVersionPrimary=null:x._workInProgressVersionSecondary=null}Fr.length=0}var cs=i.ReactCurrentDispatcher,Jr=i.ReactCurrentBatchConfig,Kr=0,pr=null,qr=null,Zr=null,ta=!1,Lo=!1,Ho=0,Eu=0;function ms(){throw Error(m(321))}function Xi(_,x){if(x===null)return!1;for(var L=0;L<x.length&&L<_.length;L++)if(!mo(_[L],x[L]))return!1;return!0}function ir(_,x,L,N,Z,ee){if(Kr=ee,pr=x,x.memoizedState=null,x.updateQueue=null,x.lanes=0,cs.current=_===null||_.memoizedState===null?Cu:xc,_=L(N,Z),Lo){ee=0;do{if(Lo=!1,Ho=0,25<=ee)throw Error(m(301));ee+=1,Zr=qr=null,x.updateQueue=null,cs.current=fh,_=L(N,Z)}while(Lo)}if(cs.current=Kc,x=qr!==null&&qr.next!==null,Kr=0,Zr=qr=pr=null,ta=!1,x)throw Error(m(300));return _}function gs(){var _=Ho!==0;return Ho=0,_}function Qr(){var _={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Zr===null?pr.memoizedState=Zr=_:Zr=Zr.next=_,Zr}function xo(){if(qr===null){var _=pr.alternate;_=_!==null?_.memoizedState:null}else _=qr.next;var x=Zr===null?pr.memoizedState:Zr.next;if(x!==null)Zr=x,qr=_;else{if(_===null)throw Error(m(310));qr=_,_={memoizedState:qr.memoizedState,baseState:qr.baseState,baseQueue:qr.baseQueue,queue:qr.queue,next:null},Zr===null?pr.memoizedState=Zr=_:Zr=Zr.next=_}return Zr}function Br(_,x){return typeof x=="function"?x(_):x}function _s(_){var x=xo(),L=x.queue;if(L===null)throw Error(m(311));L.lastRenderedReducer=_;var N=qr,Z=N.baseQueue,ee=L.pending;if(ee!==null){if(Z!==null){var Pe=Z.next;Z.next=ee.next,ee.next=Pe}N.baseQueue=Z=ee,L.pending=null}if(Z!==null){ee=Z.next,N=N.baseState;var at=Pe=null,Ut=null,Cn=ee;do{var Qn=Cn.lane;if((Kr&Qn)===Qn)Ut!==null&&(Ut=Ut.next={lane:0,action:Cn.action,hasEagerState:Cn.hasEagerState,eagerState:Cn.eagerState,next:null}),N=Cn.hasEagerState?Cn.eagerState:_(N,Cn.action);else{var Fi={lane:Qn,action:Cn.action,hasEagerState:Cn.hasEagerState,eagerState:Cn.eagerState,next:null};Ut===null?(at=Ut=Fi,Pe=N):Ut=Ut.next=Fi,pr.lanes|=Qn,$i|=Qn}Cn=Cn.next}while(Cn!==null&&Cn!==ee);Ut===null?Pe=N:Ut.next=at,mo(N,x.memoizedState)||(Do=!0),x.memoizedState=N,x.baseState=Pe,x.baseQueue=Ut,L.lastRenderedState=N}if(_=L.interleaved,_!==null){Z=_;do ee=Z.lane,pr.lanes|=ee,$i|=ee,Z=Z.next;while(Z!==_)}else Z===null&&(L.lanes=0);return[x.memoizedState,L.dispatch]}function ro(_){var x=xo(),L=x.queue;if(L===null)throw Error(m(311));L.lastRenderedReducer=_;var N=L.dispatch,Z=L.pending,ee=x.memoizedState;if(Z!==null){L.pending=null;var Pe=Z=Z.next;do ee=_(ee,Pe.action),Pe=Pe.next;while(Pe!==Z);mo(ee,x.memoizedState)||(Do=!0),x.memoizedState=ee,x.baseQueue===null&&(x.baseState=ee),L.lastRenderedState=ee}return[ee,N]}function ya(){}function Gi(_,x){var L=pr,N=xo(),Z=x(),ee=!mo(N.memoizedState,Z);if(ee&&(N.memoizedState=Z,Do=!0),N=N.queue,ja(wl.bind(null,L,N,_),[_]),N.getSnapshot!==x||ee||Zr!==null&&Zr.memoizedState.tag&1){if(L.flags|=2048,Zo(9,xa.bind(null,L,N,Z,x),void 0,null),zn===null)throw Error(m(349));(Kr&30)!==0||qo(L,x,Z)}return Z}function qo(_,x,L){_.flags|=16384,_={getSnapshot:x,value:L},x=pr.updateQueue,x===null?(x={lastEffect:null,stores:null},pr.updateQueue=x,x.stores=[_]):(L=x.stores,L===null?x.stores=[_]:L.push(_))}function xa(_,x,L,N){x.value=L,x.getSnapshot=N,na(x)&&Ls(_,1,-1)}function wl(_,x,L){return L(function(){na(x)&&Ls(_,1,-1)})}function na(_){var x=_.getSnapshot;_=_.value;try{var L=x();return!mo(_,L)}catch{return!0}}function Sl(_){var x=Qr();return typeof _=="function"&&(_=_()),x.memoizedState=x.baseState=_,_={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Br,lastRenderedState:_},x.queue=_,_=_.dispatch=Is.bind(null,pr,_),[x.memoizedState,_]}function Zo(_,x,L,N){return _={tag:_,create:x,destroy:L,deps:N,next:null},x=pr.updateQueue,x===null?(x={lastEffect:null,stores:null},pr.updateQueue=x,x.lastEffect=_.next=_):(L=x.lastEffect,L===null?x.lastEffect=_.next=_:(N=L.next,L.next=_,_.next=N,x.lastEffect=_)),_}function vo(){return xo().memoizedState}function Ml(_,x,L,N){var Z=Qr();pr.flags|=_,Z.memoizedState=Zo(1|x,L,void 0,N===void 0?null:N)}function ia(_,x,L,N){var Z=xo();N=N===void 0?null:N;var ee=void 0;if(qr!==null){var Pe=qr.memoizedState;if(ee=Pe.destroy,N!==null&&Xi(N,Pe.deps)){Z.memoizedState=Zo(x,L,ee,N);return}}pr.flags|=_,Z.memoizedState=Zo(1|x,L,ee,N)}function Xo(_,x){return Ml(8390656,8,_,x)}function ja(_,x){return ia(2048,8,_,x)}function Tu(_,x){return ia(4,2,_,x)}function pc(_,x){return ia(4,4,_,x)}function mc(_,x){if(typeof x=="function")return _=_(),x(_),function(){x(null)};if(x!=null)return _=_(),x.current=_,function(){x.current=null}}function Xc(_,x,L){return L=L!=null?L.concat([_]):null,ia(4,4,mc.bind(null,x,_),L)}function gc(){}function Dn(_,x){var L=xo();x=x===void 0?null:x;var N=L.memoizedState;return N!==null&&x!==null&&Xi(x,N[1])?N[0]:(L.memoizedState=[_,x],_)}function ra(_,x){var L=xo();x=x===void 0?null:x;var N=L.memoizedState;return N!==null&&x!==null&&Xi(x,N[1])?N[0]:(_=_(),L.memoizedState=[_,x],_)}function Td(_,x){var L=di;di=L!==0&&4>L?L:4,_(!0);var N=Jr.transition;Jr.transition={};try{_(!1),x()}finally{di=L,Jr.transition=N}}function _c(){return xo().memoizedState}function $c(_,x,L){var N=wo(_);L={lane:N,action:L,hasEagerState:!1,eagerState:null,next:null},yc(_)?Yc(x,L):(Au(_,x,L),L=Xr(),_=Ls(_,N,L),_!==null&&Jc(_,x,N))}function Is(_,x,L){var N=wo(_),Z={lane:N,action:L,hasEagerState:!1,eagerState:null,next:null};if(yc(_))Yc(x,Z);else{Au(_,x,Z);var ee=_.alternate;if(_.lanes===0&&(ee===null||ee.lanes===0)&&(ee=x.lastRenderedReducer,ee!==null))try{var Pe=x.lastRenderedState,at=ee(Pe,L);if(Z.hasEagerState=!0,Z.eagerState=at,mo(at,Pe))return}catch{}finally{}L=Xr(),_=Ls(_,N,L),_!==null&&Jc(_,x,N)}}function yc(_){var x=_.alternate;return _===pr||x!==null&&x===pr}function Yc(_,x){Lo=ta=!0;var L=_.pending;L===null?x.next=x:(x.next=L.next,L.next=x),_.pending=x}function Au(_,x,L){zn!==null&&(_.mode&1)!==0&&(Ct&2)===0?(_=x.interleaved,_===null?(L.next=L,ls===null?ls=[x]:ls.push(x)):(L.next=_.next,_.next=L),x.interleaved=L):(_=x.pending,_===null?L.next=L:(L.next=_.next,_.next=L),x.pending=L)}function Jc(_,x,L){if((L&4194240)!==0){var N=x.lanes;N&=_.pendingLanes,L|=N,x.lanes=L,mi(_,L)}}var Kc={readContext:Ns,useCallback:ms,useContext:ms,useEffect:ms,useImperativeHandle:ms,useInsertionEffect:ms,useLayoutEffect:ms,useMemo:ms,useReducer:ms,useRef:ms,useState:ms,useDebugValue:ms,useDeferredValue:ms,useTransition:ms,useMutableSource:ms,useSyncExternalStore:ms,useId:ms,unstable_isNewReconciler:!1},Cu={readContext:Ns,useCallback:function(_,x){return Qr().memoizedState=[_,x===void 0?null:x],_},useContext:Ns,useEffect:Xo,useImperativeHandle:function(_,x,L){return L=L!=null?L.concat([_]):null,Ml(4194308,4,mc.bind(null,x,_),L)},useLayoutEffect:function(_,x){return Ml(4194308,4,_,x)},useInsertionEffect:function(_,x){return Ml(4,2,_,x)},useMemo:function(_,x){var L=Qr();return x=x===void 0?null:x,_=_(),L.memoizedState=[_,x],_},useReducer:function(_,x,L){var N=Qr();return x=L!==void 0?L(x):x,N.memoizedState=N.baseState=x,_={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:_,lastRenderedState:x},N.queue=_,_=_.dispatch=$c.bind(null,pr,_),[N.memoizedState,_]},useRef:function(_){var x=Qr();return _={current:_},x.memoizedState=_},useState:Sl,useDebugValue:gc,useDeferredValue:function(_){var x=Sl(_),L=x[0],N=x[1];return Xo(function(){var Z=Jr.transition;Jr.transition={};try{N(_)}finally{Jr.transition=Z}},[_]),L},useTransition:function(){var _=Sl(!1),x=_[0];return _=Td.bind(null,_[1]),Qr().memoizedState=_,[x,_]},useMutableSource:function(){},useSyncExternalStore:function(_,x,L){var N=pr,Z=Qr();if(Sr){if(L===void 0)throw Error(m(407));L=L()}else{if(L=x(),zn===null)throw Error(m(349));(Kr&30)!==0||qo(N,x,L)}Z.memoizedState=L;var ee={value:L,getSnapshot:x};return Z.queue=ee,Xo(wl.bind(null,N,ee,_),[_]),N.flags|=2048,Zo(9,xa.bind(null,N,ee,L,x),void 0,null),L},useId:function(){var _=Qr(),x=zn.identifierPrefix;if(Sr){var L=fs,N=eo;L=(N&~(1<<32-Hr(N)-1)).toString(32)+L,x=":"+x+"R"+L,L=Ho++,0<L&&(x+="H"+L.toString(32)),x+=":"}else L=Eu++,x=":"+x+"r"+L.toString(32)+":";return _.memoizedState=x},unstable_isNewReconciler:!1},xc={readContext:Ns,useCallback:Dn,useContext:Ns,useEffect:ja,useImperativeHandle:Xc,useInsertionEffect:Tu,useLayoutEffect:pc,useMemo:ra,useReducer:_s,useRef:vo,useState:function(){return _s(Br)},useDebugValue:gc,useDeferredValue:function(_){var x=_s(Br),L=x[0],N=x[1];return ja(function(){var Z=Jr.transition;Jr.transition={};try{N(_)}finally{Jr.transition=Z}},[_]),L},useTransition:function(){var _=_s(Br)[0],x=xo().memoizedState;return[_,x]},useMutableSource:ya,useSyncExternalStore:Gi,useId:_c,unstable_isNewReconciler:!1},fh={readContext:Ns,useCallback:Dn,useContext:Ns,useEffect:ja,useImperativeHandle:Xc,useInsertionEffect:Tu,useLayoutEffect:pc,useMemo:ra,useReducer:ro,useRef:vo,useState:function(){return ro(Br)},useDebugValue:gc,useDeferredValue:function(_){var x=ro(Br),L=x[0],N=x[1];return ja(function(){var Z=Jr.transition;Jr.transition={};try{N(_)}finally{Jr.transition=Z}},[_]),L},useTransition:function(){var _=ro(Br)[0],x=xo().memoizedState;return[_,x]},useMutableSource:ya,useSyncExternalStore:Gi,useId:_c,unstable_isNewReconciler:!1};function ph(_,x){try{var L="",N=x;do L+=cc(N),N=N.return;while(N);var Z=L}catch(ee){Z=`
Error generating stack: `+ee.message+`
`+ee.stack}return{value:_,source:x,stack:Z}}function Iu(_,x){try{console.error(x.value)}catch(L){setTimeout(function(){throw L})}}var vc=typeof WeakMap=="function"?WeakMap:Map;function Pu(_,x,L){L=Cs(-1,L),L.tag=3,L.payload={element:null};var N=x.value;return L.callback=function(){vr||(vr=!0,gr=N),Iu(_,x)},L}function Lu(_,x,L){L=Cs(-1,L),L.tag=3;var N=_.type.getDerivedStateFromError;if(typeof N=="function"){var Z=x.value;L.payload=function(){return N(Z)},L.callback=function(){Iu(_,x)}}var ee=_.stateNode;return ee!==null&&typeof ee.componentDidCatch=="function"&&(L.callback=function(){Iu(_,x),typeof N!="function"&&(ji===null?ji=new Set([this]):ji.add(this));var Pe=x.stack;this.componentDidCatch(x.value,{componentStack:Pe!==null?Pe:""})}),L}function Ru(_,x,L){var N=_.pingCache;if(N===null){N=_.pingCache=new vc;var Z=new Set;N.set(x,Z)}else Z=N.get(x),Z===void 0&&(Z=new Set,N.set(x,Z));Z.has(L)||(Z.add(L),_=Tc.bind(null,_,x,L),x.then(_,_))}function Qc(_){do{var x;if((x=_.tag===13)&&(x=_.memoizedState,x=x!==null?x.dehydrated!==null:!0),x)return _;_=_.return}while(_!==null);return null}function bc(_,x,L,N,Z){return(_.mode&1)===0?(_===x?_.flags|=65536:(_.flags|=128,L.flags|=131072,L.flags&=-52805,L.tag===1&&(L.alternate===null?L.tag=17:(x=Cs(-1,1),x.tag=2,Go(L,x))),L.lanes|=1),_):(_.flags|=65536,_.lanes=Z,_)}function Ro(_){_.flags|=4}function Du(_,x){if(_!==null&&_.child===x.child)return!0;if((x.flags&16)!==0)return!1;for(_=x.child;_!==null;){if((_.flags&12854)!==0||(_.subtreeFlags&12854)!==0)return!1;_=_.sibling}return!0}var wc,Vl,eu,va;if(mn)wc=function(_,x){for(var L=x.child;L!==null;){if(L.tag===5||L.tag===6)xt(_,L.stateNode);else if(L.tag!==4&&L.child!==null){L.child.return=L,L=L.child;continue}if(L===x)break;for(;L.sibling===null;){if(L.return===null||L.return===x)return;L=L.return}L.sibling.return=L.return,L=L.sibling}},Vl=function(){},eu=function(_,x,L,N,Z){if(_=_.memoizedProps,_!==N){var ee=x.stateNode,Pe=yn(io.current);L=ln(ee,L,_,N,Z,Pe),(x.updateQueue=L)&&Ro(x)}},va=function(_,x,L,N){L!==N&&Ro(x)};else if(qt){wc=function(_,x,L,N){for(var Z=x.child;Z!==null;){if(Z.tag===5){var ee=Z.stateNode;L&&N&&(ee=pt(ee,Z.type,Z.memoizedProps,Z)),xt(_,ee)}else if(Z.tag===6)ee=Z.stateNode,L&&N&&(ee=Zt(ee,Z.memoizedProps,Z)),xt(_,ee);else if(Z.tag!==4){if(Z.tag===22&&Z.memoizedState!==null)ee=Z.child,ee!==null&&(ee.return=Z),wc(_,Z,!0,!0);else if(Z.child!==null){Z.child.return=Z,Z=Z.child;continue}}if(Z===x)break;for(;Z.sibling===null;){if(Z.return===null||Z.return===x)return;Z=Z.return}Z.sibling.return=Z.return,Z=Z.sibling}};var mh=function(_,x,L,N){for(var Z=x.child;Z!==null;){if(Z.tag===5){var ee=Z.stateNode;L&&N&&(ee=pt(ee,Z.type,Z.memoizedProps,Z)),rt(_,ee)}else if(Z.tag===6)ee=Z.stateNode,L&&N&&(ee=Zt(ee,Z.memoizedProps,Z)),rt(_,ee);else if(Z.tag!==4){if(Z.tag===22&&Z.memoizedState!==null)ee=Z.child,ee!==null&&(ee.return=Z),mh(_,Z,!0,!0);else if(Z.child!==null){Z.child.return=Z,Z=Z.child;continue}}if(Z===x)break;for(;Z.sibling===null;){if(Z.return===null||Z.return===x)return;Z=Z.return}Z.sibling.return=Z.return,Z=Z.sibling}};Vl=function(_,x){var L=x.stateNode;if(!Du(_,x)){_=L.containerInfo;var N=je(_);mh(N,x,!1,!1),L.pendingChildren=N,Ro(x),st(_,N)}},eu=function(_,x,L,N,Z){var ee=_.stateNode,Pe=_.memoizedProps;if((_=Du(_,x))&&Pe===N)x.stateNode=ee;else{var at=x.stateNode,Ut=yn(io.current),Cn=null;Pe!==N&&(Cn=ln(at,L,Pe,N,Z,Ut)),_&&Cn===null?x.stateNode=ee:(ee=De(ee,Cn,L,Pe,N,x,_,at),Pt(ee,L,N,Z,Ut)&&Ro(x),x.stateNode=ee,_?Ro(x):wc(ee,x,!1,!1))}},va=function(_,x,L,N){L!==N?(_=yn(At.current),L=yn(io.current),x.stateNode=Mt(N,_,L,x),Ro(x)):x.stateNode=_.stateNode}}else Vl=function(){},eu=function(){},va=function(){};function Sc(_,x){if(!Sr)switch(_.tailMode){case"hidden":x=_.tail;for(var L=null;x!==null;)x.alternate!==null&&(L=x),x=x.sibling;L===null?_.tail=null:L.sibling=null;break;case"collapsed":L=_.tail;for(var N=null;L!==null;)L.alternate!==null&&(N=L),L=L.sibling;N===null?x||_.tail===null?_.tail=null:_.tail.sibling=null:N.sibling=null}}function so(_){var x=_.alternate!==null&&_.alternate.child===_.child,L=0,N=0;if(x)for(var Z=_.child;Z!==null;)L|=Z.lanes|Z.childLanes,N|=Z.subtreeFlags&14680064,N|=Z.flags&14680064,Z.return=_,Z=Z.sibling;else for(Z=_.child;Z!==null;)L|=Z.lanes|Z.childLanes,N|=Z.subtreeFlags,N|=Z.flags,Z.return=_,Z=Z.sibling;return _.subtreeFlags|=N,_.childLanes=L,x}function Ad(_,x,L){var N=x.pendingProps;switch(fc(x),x.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return so(x),null;case 1:return As(x.type)&&Uo(),so(x),null;case 3:return N=x.stateNode,fr(),ct(Os),ct(nr),Vr(),N.pendingContext&&(N.context=N.pendingContext,N.pendingContext=null),(_===null||_.child===null)&&(yo(x)?Ro(x):_===null||_.memoizedState.isDehydrated&&(x.flags&256)===0||(x.flags|=1024,Vs!==null&&(zd(Vs),Vs=null))),Vl(_,x),so(x),null;case 5:Pr(x),L=yn(At.current);var Z=x.type;if(_!==null&&x.stateNode!=null)eu(_,x,Z,N,L),_.ref!==x.ref&&(x.flags|=512,x.flags|=2097152);else{if(!N){if(x.stateNode===null)throw Error(m(166));return so(x),null}if(_=yn(io.current),yo(x)){if(!Dt)throw Error(m(175));_=Yn(x.stateNode,x.type,x.memoizedProps,L,_,x,!Na),x.updateQueue=_,_!==null&&Ro(x)}else{var ee=Et(Z,N,L,_,x);wc(ee,x,!1,!1),x.stateNode=ee,Pt(ee,Z,N,L,_)&&Ro(x)}x.ref!==null&&(x.flags|=512,x.flags|=2097152)}return so(x),null;case 6:if(_&&x.stateNode!=null)va(_,x,_.memoizedProps,N);else{if(typeof N!="string"&&x.stateNode===null)throw Error(m(166));if(_=yn(At.current),L=yn(io.current),yo(x)){if(!Dt)throw Error(m(176));if(_=x.stateNode,N=x.memoizedProps,(L=bi(_,N,x,!Na))&&(Z=to,Z!==null))switch(ee=(Z.mode&1)!==0,Z.tag){case 3:Xs(Z.stateNode.containerInfo,_,N,ee);break;case 5:$s(Z.type,Z.memoizedProps,Z.stateNode,_,N,ee)}L&&Ro(x)}else x.stateNode=Mt(N,_,L,x)}return so(x),null;case 13:if(ct(Ti),N=x.memoizedState,Sr&&Us!==null&&(x.mode&1)!==0&&(x.flags&128)===0){for(_=Us;_;)_=lt(_);return Wo(),x.flags|=98560,x}if(N!==null&&N.dehydrated!==null){if(N=yo(x),_===null){if(!N)throw Error(m(318));if(!Dt)throw Error(m(344));if(_=x.memoizedState,_=_!==null?_.dehydrated:null,!_)throw Error(m(317));ui(_,x)}else Wo(),(x.flags&128)===0&&(x.memoizedState=null),x.flags|=4;return so(x),null}return Vs!==null&&(zd(Vs),Vs=null),(x.flags&128)!==0?(x.lanes=L,x):(N=N!==null,L=!1,_===null?yo(x):L=_.memoizedState!==null,N&&!L&&(x.child.flags|=8192,(x.mode&1)!==0&&(_===null||(Ti.current&1)!==0?si===0&&(si=3):kd())),x.updateQueue!==null&&(x.flags|=4),so(x),null);case 4:return fr(),Vl(_,x),_===null&&wn(x.stateNode.containerInfo),so(x),null;case 10:return Ol(x.type._context),so(x),null;case 17:return As(x.type)&&Uo(),so(x),null;case 19:if(ct(Ti),Z=x.memoizedState,Z===null)return so(x),null;if(N=(x.flags&128)!==0,ee=Z.rendering,ee===null)if(N)Sc(Z,!1);else{if(si!==0||_!==null&&(_.flags&128)!==0)for(_=x.child;_!==null;){if(ee=Gs(_),ee!==null){for(x.flags|=128,Sc(Z,!1),_=ee.updateQueue,_!==null&&(x.updateQueue=_,x.flags|=4),x.subtreeFlags=0,_=L,N=x.child;N!==null;)L=N,Z=_,L.flags&=14680066,ee=L.alternate,ee===null?(L.childLanes=0,L.lanes=Z,L.child=null,L.subtreeFlags=0,L.memoizedProps=null,L.memoizedState=null,L.updateQueue=null,L.dependencies=null,L.stateNode=null):(L.childLanes=ee.childLanes,L.lanes=ee.lanes,L.child=ee.child,L.subtreeFlags=0,L.deletions=null,L.memoizedProps=ee.memoizedProps,L.memoizedState=ee.memoizedState,L.updateQueue=ee.updateQueue,L.type=ee.type,Z=ee.dependencies,L.dependencies=Z===null?null:{lanes:Z.lanes,firstContext:Z.firstContext}),N=N.sibling;return Ri(Ti,Ti.current&1|2),x.child}_=_.sibling}Z.tail!==null&&wi()>ko&&(x.flags|=128,N=!0,Sc(Z,!1),x.lanes=4194304)}else{if(!N)if(_=Gs(ee),_!==null){if(x.flags|=128,N=!0,_=_.updateQueue,_!==null&&(x.updateQueue=_,x.flags|=4),Sc(Z,!0),Z.tail===null&&Z.tailMode==="hidden"&&!ee.alternate&&!Sr)return so(x),null}else 2*wi()-Z.renderingStartTime>ko&&L!==1073741824&&(x.flags|=128,N=!0,Sc(Z,!1),x.lanes=4194304);Z.isBackwards?(ee.sibling=x.child,x.child=ee):(_=Z.last,_!==null?_.sibling=ee:x.child=ee,Z.last=ee)}return Z.tail!==null?(x=Z.tail,Z.rendering=x,Z.tail=x.sibling,Z.renderingStartTime=wi(),x.sibling=null,_=Ti.current,Ri(Ti,N?_&1|2:_&1),x):(so(x),null);case 22:case 23:return wh(),N=x.memoizedState!==null,_!==null&&_.memoizedState!==null!==N&&(x.flags|=8192),N&&(x.mode&1)!==0?(Vn&1073741824)!==0&&(so(x),mn&&x.subtreeFlags&6&&(x.flags|=8192)):so(x),null;case 24:return null;case 25:return null}throw Error(m(156,x.tag))}var gh=i.ReactCurrentOwner,Do=!1;function oo(_,x,L,N){x.child=_===null?Ga(x,null,L,N):Va(x,_.child,L,N)}function js(_,x,L,N,Z){L=L.render;var ee=x.ref;return ka(x,Z),N=ir(_,x,L,N,ee,Z),L=gs(),_!==null&&!Do?(x.updateQueue=_.updateQueue,x.flags&=-2053,_.lanes&=~Z,qa(_,x,Z)):(Sr&&L&&rl(x),x.flags|=1,oo(_,x,N,Z),x.child)}function Cd(_,x,L,N,Z){if(_===null){var ee=L.type;return typeof ee=="function"&&!Sa(ee)&&ee.defaultProps===void 0&&L.compare===null&&L.defaultProps===void 0?(x.tag=15,x.type=ee,_h(_,x,ee,N,Z)):(_=jr(L.type,null,N,x,x.mode,Z),_.ref=x.ref,_.return=x,x.child=_)}if(ee=_.child,(_.lanes&Z)===0){var Pe=ee.memoizedProps;if(L=L.compare,L=L!==null?L:Ks,L(Pe,N)&&_.ref===x.ref)return qa(_,x,Z)}return x.flags|=1,_=Cc(ee,N),_.ref=x.ref,_.return=x,x.child=_}function _h(_,x,L,N,Z){if(_!==null&&Ks(_.memoizedProps,N)&&_.ref===x.ref)if(Do=!1,(_.lanes&Z)!==0)(_.flags&131072)!==0&&(Do=!0);else return x.lanes=_.lanes,qa(_,x,Z);return zo(_,x,L,N,Z)}function Id(_,x,L){var N=x.pendingProps,Z=N.children,ee=_!==null?_.memoizedState:null;if(N.mode==="hidden")if((x.mode&1)===0)x.memoizedState={baseLanes:0,cachePool:null},Ri(Ai,Vn),Vn|=L;else if((L&1073741824)!==0)x.memoizedState={baseLanes:0,cachePool:null},N=ee!==null?ee.baseLanes:L,Ri(Ai,Vn),Vn|=N;else return _=ee!==null?ee.baseLanes|L:L,x.lanes=x.childLanes=1073741824,x.memoizedState={baseLanes:_,cachePool:null},x.updateQueue=null,Ri(Ai,Vn),Vn|=_,null;else ee!==null?(N=ee.baseLanes|L,x.memoizedState=null):N=L,Ri(Ai,Vn),Vn|=N;return oo(_,x,Z,L),x.child}function Pd(_,x){var L=x.ref;(_===null&&L!==null||_!==null&&_.ref!==L)&&(x.flags|=512,x.flags|=2097152)}function zo(_,x,L,N,Z){var ee=As(L)?Ts:nr.current;return ee=Ra(x,ee),ka(x,Z),L=ir(_,x,L,N,ee,Z),N=gs(),_!==null&&!Do?(x.updateQueue=_.updateQueue,x.flags&=-2053,_.lanes&=~Z,qa(_,x,Z)):(Sr&&N&&rl(x),x.flags|=1,oo(_,x,L,Z),x.child)}function yh(_,x,L,N,Z){if(As(L)){var ee=!0;Mi(x)}else ee=!1;if(ka(x,Z),x.stateNode===null)_!==null&&(_.alternate=null,x.alternate=null,x.flags|=2),qc(x,L,N),Bl(x,L,N,Z),N=!0;else if(_===null){var Pe=x.stateNode,at=x.memoizedProps;Pe.props=at;var Ut=Pe.context,Cn=L.contextType;typeof Cn=="object"&&Cn!==null?Cn=Ns(Cn):(Cn=As(L)?Ts:nr.current,Cn=Ra(x,Cn));var Qn=L.getDerivedStateFromProps,Fi=typeof Qn=="function"||typeof Pe.getSnapshotBeforeUpdate=="function";Fi||typeof Pe.UNSAFE_componentWillReceiveProps!="function"&&typeof Pe.componentWillReceiveProps!="function"||(at!==N||Ut!==Cn)&&yl(x,Pe,N,Cn),Bi=!1;var _i=x.memoizedState;Pe.state=_i,jo(x,N,Pe,Z),Ut=x.memoizedState,at!==N||_i!==Ut||Os.current||Bi?(typeof Qn=="function"&&(go(x,L,Qn,N),Ut=x.memoizedState),(at=Bi||ma(x,L,at,N,_i,Ut,Cn))?(Fi||typeof Pe.UNSAFE_componentWillMount!="function"&&typeof Pe.componentWillMount!="function"||(typeof Pe.componentWillMount=="function"&&Pe.componentWillMount(),typeof Pe.UNSAFE_componentWillMount=="function"&&Pe.UNSAFE_componentWillMount()),typeof Pe.componentDidMount=="function"&&(x.flags|=4194308)):(typeof Pe.componentDidMount=="function"&&(x.flags|=4194308),x.memoizedProps=N,x.memoizedState=Ut),Pe.props=N,Pe.state=Ut,Pe.context=Cn,N=at):(typeof Pe.componentDidMount=="function"&&(x.flags|=4194308),N=!1)}else{Pe=x.stateNode,hc(_,x),at=x.memoizedProps,Cn=x.type===x.elementType?at:as(x.type,at),Pe.props=Cn,Fi=x.pendingProps,_i=Pe.context,Ut=L.contextType,typeof Ut=="object"&&Ut!==null?Ut=Ns(Ut):(Ut=As(L)?Ts:nr.current,Ut=Ra(x,Ut));var Ki=L.getDerivedStateFromProps;(Qn=typeof Ki=="function"||typeof Pe.getSnapshotBeforeUpdate=="function")||typeof Pe.UNSAFE_componentWillReceiveProps!="function"&&typeof Pe.componentWillReceiveProps!="function"||(at!==Fi||_i!==Ut)&&yl(x,Pe,N,Ut),Bi=!1,_i=x.memoizedState,Pe.state=_i,jo(x,N,Pe,Z);var fi=x.memoizedState;at!==Fi||_i!==fi||Os.current||Bi?(typeof Ki=="function"&&(go(x,L,Ki,N),fi=x.memoizedState),(Cn=Bi||ma(x,L,Cn,N,_i,fi,Ut)||!1)?(Qn||typeof Pe.UNSAFE_componentWillUpdate!="function"&&typeof Pe.componentWillUpdate!="function"||(typeof Pe.componentWillUpdate=="function"&&Pe.componentWillUpdate(N,fi,Ut),typeof Pe.UNSAFE_componentWillUpdate=="function"&&Pe.UNSAFE_componentWillUpdate(N,fi,Ut)),typeof Pe.componentDidUpdate=="function"&&(x.flags|=4),typeof Pe.getSnapshotBeforeUpdate=="function"&&(x.flags|=1024)):(typeof Pe.componentDidUpdate!="function"||at===_.memoizedProps&&_i===_.memoizedState||(x.flags|=4),typeof Pe.getSnapshotBeforeUpdate!="function"||at===_.memoizedProps&&_i===_.memoizedState||(x.flags|=1024),x.memoizedProps=N,x.memoizedState=fi),Pe.props=N,Pe.state=fi,Pe.context=Ut,N=Cn):(typeof Pe.componentDidUpdate!="function"||at===_.memoizedProps&&_i===_.memoizedState||(x.flags|=4),typeof Pe.getSnapshotBeforeUpdate!="function"||at===_.memoizedProps&&_i===_.memoizedState||(x.flags|=1024),N=!1)}return xh(_,x,L,N,ee,Z)}function xh(_,x,L,N,Z,ee){Pd(_,x);var Pe=(x.flags&128)!==0;if(!N&&!Pe)return Z&&Ys(x,L,!1),qa(_,x,ee);N=x.stateNode,gh.current=x;var at=Pe&&typeof L.getDerivedStateFromError!="function"?null:N.render();return x.flags|=1,_!==null&&Pe?(x.child=Va(x,_.child,null,ee),x.child=Va(x,null,at,ee)):oo(_,x,at,ee),x.memoizedState=N.state,Z&&Ys(x,L,!0),x.child}function sa(_){var x=_.stateNode;x.pendingContext?En(_,x.pendingContext,x.pendingContext!==x.context):x.context&&En(_,x.context,!1),ni(_,x.containerInfo)}function ba(_,x,L,N,Z){return Wo(),Nl(Z),x.flags|=256,oo(_,x,L,N),x.child}var Wa={dehydrated:null,treeContext:null,retryLane:0};function Gl(_){return{baseLanes:_,cachePool:null}}function kn(_,x,L){var N=x.pendingProps,Z=Ti.current,ee=!1,Pe=(x.flags&128)!==0,at;if((at=Pe)||(at=_!==null&&_.memoizedState===null?!1:(Z&2)!==0),at?(ee=!0,x.flags&=-129):(_===null||_.memoizedState!==null)&&(Z|=1),Ri(Ti,Z&1),_===null)return no(x),_=x.memoizedState,_!==null&&(_=_.dehydrated,_!==null)?((x.mode&1)===0?x.lanes=1:ve(_)?x.lanes=8:x.lanes=1073741824,null):(Z=N.children,_=N.fallback,ee?(N=x.mode,ee=x.child,Z={mode:"hidden",children:Z},(N&1)===0&&ee!==null?(ee.childLanes=0,ee.pendingProps=Z):ee=al(Z,N,0,null),_=Zn(_,N,L,null),ee.return=x,_.return=x,ee.sibling=_,x.child=ee,x.child.memoizedState=Gl(L),x.memoizedState=Wa,_):tu(x,Z));if(Z=_.memoizedState,Z!==null){if(at=Z.dehydrated,at!==null){if(Pe)return x.flags&256?(x.flags&=-257,Ha(_,x,L,Error(m(422)))):x.memoizedState!==null?(x.child=_.child,x.flags|=128,null):(ee=N.fallback,Z=x.mode,N=al({mode:"visible",children:N.children},Z,0,null),ee=Zn(ee,Z,L,null),ee.flags|=2,N.return=x,ee.return=x,N.sibling=ee,x.child=N,(x.mode&1)!==0&&Va(x,_.child,null,L),x.child.memoizedState=Gl(L),x.memoizedState=Wa,ee);if((x.mode&1)===0)x=Ha(_,x,L,null);else if(ve(at))x=Ha(_,x,L,Error(m(419)));else if(N=(L&_.childLanes)!==0,Do||N){if(N=zn,N!==null){switch(L&-L){case 4:ee=2;break;case 16:ee=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:ee=32;break;case 536870912:ee=268435456;break;default:ee=0}N=(ee&(N.suspendedLanes|L))!==0?0:ee,N!==0&&N!==Z.retryLane&&(Z.retryLane=N,Ls(_,N,-1))}kd(),x=Ha(_,x,L,Error(m(421)))}else ci(at)?(x.flags|=128,x.child=_.child,x=ny.bind(null,_),Qe(at,x),x=null):(L=Z.treeContext,Dt&&(Us=$n(at),to=x,Sr=!0,Vs=null,Na=!1,L!==null&&(gi[Or++]=eo,gi[Or++]=fs,gi[Or++]=Qs,eo=L.id,fs=L.overflow,Qs=x)),x=tu(x,x.pendingProps.children),x.flags|=4096);return x}return ee?(N=jl(_,x,N.children,N.fallback,L),ee=x.child,Z=_.child.memoizedState,ee.memoizedState=Z===null?Gl(L):{baseLanes:Z.baseLanes|L,cachePool:null},ee.childLanes=_.childLanes&~L,x.memoizedState=Wa,N):(L=zu(_,x,N.children,L),x.memoizedState=null,L)}return ee?(N=jl(_,x,N.children,N.fallback,L),ee=x.child,Z=_.child.memoizedState,ee.memoizedState=Z===null?Gl(L):{baseLanes:Z.baseLanes|L,cachePool:null},ee.childLanes=_.childLanes&~L,x.memoizedState=Wa,N):(L=zu(_,x,N.children,L),x.memoizedState=null,L)}function tu(_,x){return x=al({mode:"visible",children:x},_.mode,0,null),x.return=_,_.child=x}function zu(_,x,L,N){var Z=_.child;return _=Z.sibling,L=Cc(Z,{mode:"visible",children:L}),(x.mode&1)===0&&(L.lanes=N),L.return=x,L.sibling=null,_!==null&&(N=x.deletions,N===null?(x.deletions=[_],x.flags|=16):N.push(_)),x.child=L}function jl(_,x,L,N,Z){var ee=x.mode;_=_.child;var Pe=_.sibling,at={mode:"hidden",children:L};return(ee&1)===0&&x.child!==_?(L=x.child,L.childLanes=0,L.pendingProps=at,x.deletions=null):(L=Cc(_,at),L.subtreeFlags=_.subtreeFlags&14680064),Pe!==null?N=Cc(Pe,N):(N=Zn(N,ee,Z,null),N.flags|=2),N.return=x,L.return=x,L.sibling=N,x.child=L,N}function Ha(_,x,L,N){return N!==null&&Nl(N),Va(x,_.child,null,L),_=tu(x,x.pendingProps.children),_.flags|=2,x.memoizedState=null,_}function An(_,x,L){_.lanes|=x;var N=_.alternate;N!==null&&(N.lanes|=x),nl(_.return,x,L)}function nu(_,x,L,N,Z){var ee=_.memoizedState;ee===null?_.memoizedState={isBackwards:x,rendering:null,renderingStartTime:0,last:N,tail:L,tailMode:Z}:(ee.isBackwards=x,ee.rendering=null,ee.renderingStartTime=0,ee.last=N,ee.tail=L,ee.tailMode=Z)}function Ld(_,x,L){var N=x.pendingProps,Z=N.revealOrder,ee=N.tail;if(oo(_,x,N.children,L),N=Ti.current,(N&2)!==0)N=N&1|2,x.flags|=128;else{if(_!==null&&(_.flags&128)!==0)e:for(_=x.child;_!==null;){if(_.tag===13)_.memoizedState!==null&&An(_,L,x);else if(_.tag===19)An(_,L,x);else if(_.child!==null){_.child.return=_,_=_.child;continue}if(_===x)break e;for(;_.sibling===null;){if(_.return===null||_.return===x)break e;_=_.return}_.sibling.return=_.return,_=_.sibling}N&=1}if(Ri(Ti,N),(x.mode&1)===0)x.memoizedState=null;else switch(Z){case"forwards":for(L=x.child,Z=null;L!==null;)_=L.alternate,_!==null&&Gs(_)===null&&(Z=L),L=L.sibling;L=Z,L===null?(Z=x.child,x.child=null):(Z=L.sibling,L.sibling=null),nu(x,!1,Z,L,ee);break;case"backwards":for(L=null,Z=x.child,x.child=null;Z!==null;){if(_=Z.alternate,_!==null&&Gs(_)===null){x.child=Z;break}_=Z.sibling,Z.sibling=L,L=Z,Z=_}nu(x,!0,L,null,ee);break;case"together":nu(x,!1,null,null,void 0);break;default:x.memoizedState=null}return x.child}function qa(_,x,L){if(_!==null&&(x.dependencies=_.dependencies),$i|=x.lanes,(L&x.childLanes)===0)return null;if(_!==null&&x.child!==_.child)throw Error(m(153));if(x.child!==null){for(_=x.child,L=Cc(_,_.pendingProps),x.child=L,L.return=x;_.sibling!==null;)_=_.sibling,L=L.sibling=Cc(_,_.pendingProps),L.return=x;L.sibling=null}return x.child}function vh(_,x,L){switch(x.tag){case 3:sa(x),Wo();break;case 5:Wi(x);break;case 1:As(x.type)&&Mi(x);break;case 4:ni(x,x.stateNode.containerInfo);break;case 10:Bs(x,x.type._context,x.memoizedProps.value);break;case 13:var N=x.memoizedState;if(N!==null)return N.dehydrated!==null?(Ri(Ti,Ti.current&1),x.flags|=128,null):(L&x.child.childLanes)!==0?kn(_,x,L):(Ri(Ti,Ti.current&1),_=qa(_,x,L),_!==null?_.sibling:null);Ri(Ti,Ti.current&1);break;case 19:if(N=(L&x.childLanes)!==0,(_.flags&128)!==0){if(N)return Ld(_,x,L);x.flags|=128}var Z=x.memoizedState;if(Z!==null&&(Z.rendering=null,Z.tail=null,Z.lastEffect=null),Ri(Ti,Ti.current),N)break;return null;case 22:case 23:return x.lanes=0,Id(_,x,L)}return qa(_,x,L)}function Rd(_,x){switch(fc(x),x.tag){case 1:return As(x.type)&&Uo(),_=x.flags,_&65536?(x.flags=_&-65537|128,x):null;case 3:return fr(),ct(Os),ct(nr),Vr(),_=x.flags,(_&65536)!==0&&(_&128)===0?(x.flags=_&-65537|128,x):null;case 5:return Pr(x),null;case 13:if(ct(Ti),_=x.memoizedState,_!==null&&_.dehydrated!==null){if(x.alternate===null)throw Error(m(340));Wo()}return _=x.flags,_&65536?(x.flags=_&-65537|128,x):null;case 19:return ct(Ti),null;case 4:return fr(),null;case 10:return Ol(x.type._context),null;case 22:case 23:return wh(),null;case 24:return null;default:return null}}var iu=!1,Wl=!1,cp=typeof WeakSet=="function"?WeakSet:Set,Bn=null;function Mc(_,x){var L=_.ref;if(L!==null)if(typeof L=="function")try{L(null)}catch(N){ys(_,x,N)}else L.current=null}function ru(_,x,L){try{L()}catch(N){ys(_,x,N)}}var Hl=!1;function p(_,x){for(it(_.containerInfo),Bn=x;Bn!==null;)if(_=Bn,x=_.child,(_.subtreeFlags&1028)!==0&&x!==null)x.return=_,Bn=x;else for(;Bn!==null;){_=Bn;try{var L=_.alternate;if((_.flags&1024)!==0)switch(_.tag){case 0:case 11:case 15:break;case 1:if(L!==null){var N=L.memoizedProps,Z=L.memoizedState,ee=_.stateNode,Pe=ee.getSnapshotBeforeUpdate(_.elementType===_.type?N:as(_.type,N),Z);ee.__reactInternalSnapshotBeforeUpdate=Pe}break;case 3:mn&&ye(_.stateNode.containerInfo);break;case 5:case 6:case 4:case 17:break;default:throw Error(m(163))}}catch(at){ys(_,_.return,at)}if(x=_.sibling,x!==null){x.return=_.return,Bn=x;break}Bn=_.return}return L=Hl,Hl=!1,L}function o(_,x,L){var N=x.updateQueue;if(N=N!==null?N.lastEffect:null,N!==null){var Z=N=N.next;do{if((Z.tag&_)===_){var ee=Z.destroy;Z.destroy=void 0,ee!==void 0&&ru(x,L,ee)}Z=Z.next}while(Z!==N)}}function u(_,x){if(x=x.updateQueue,x=x!==null?x.lastEffect:null,x!==null){var L=x=x.next;do{if((L.tag&_)===_){var N=L.create;L.destroy=N()}L=L.next}while(L!==x)}}function y(_){var x=_.ref;if(x!==null){var L=_.stateNode;switch(_.tag){case 5:_=ft(L);break;default:_=L}typeof x=="function"?x(_):x.current=_}}function b(_,x,L){if(To&&typeof To.onCommitFiberUnmount=="function")try{To.onCommitFiberUnmount(ha,x)}catch{}switch(x.tag){case 0:case 11:case 14:case 15:if(_=x.updateQueue,_!==null&&(_=_.lastEffect,_!==null)){var N=_=_.next;do{var Z=N,ee=Z.destroy;Z=Z.tag,ee!==void 0&&((Z&2)!==0||(Z&4)!==0)&&ru(x,L,ee),N=N.next}while(N!==_)}break;case 1:if(Mc(x,L),_=x.stateNode,typeof _.componentWillUnmount=="function")try{_.props=x.memoizedProps,_.state=x.memoizedState,_.componentWillUnmount()}catch(Pe){ys(x,L,Pe)}break;case 5:Mc(x,L);break;case 4:mn?he(_,x,L):qt&&qt&&(x=x.stateNode.containerInfo,L=je(x),He(x,L))}}function M(_,x,L){for(var N=x;;)if(b(_,N,L),N.child===null||mn&&N.tag===4){if(N===x)break;for(;N.sibling===null;){if(N.return===null||N.return===x)return;N=N.return}N.sibling.return=N.return,N=N.sibling}else N.child.return=N,N=N.child}function R(_){var x=_.alternate;x!==null&&(_.alternate=null,R(x)),_.child=null,_.deletions=null,_.sibling=null,_.tag===5&&(x=_.stateNode,x!==null&&rn(x)),_.stateNode=null,_.return=null,_.dependencies=null,_.memoizedProps=null,_.memoizedState=null,_.pendingProps=null,_.stateNode=null,_.updateQueue=null}function z(_){return _.tag===5||_.tag===3||_.tag===4}function V(_){e:for(;;){for(;_.sibling===null;){if(_.return===null||z(_.return))return null;_=_.return}for(_.sibling.return=_.return,_=_.sibling;_.tag!==5&&_.tag!==6&&_.tag!==18;){if(_.flags&2||_.child===null||_.tag===4)continue e;_.child.return=_,_=_.child}if(!(_.flags&2))return _.stateNode}}function X(_){if(mn){e:{for(var x=_.return;x!==null;){if(z(x))break e;x=x.return}throw Error(m(160))}var L=x;switch(L.tag){case 5:x=L.stateNode,L.flags&32&&(bt(x),L.flags&=-33),L=V(_),Q(_,L,x);break;case 3:case 4:x=L.stateNode.containerInfo,L=V(_),q(_,L,x);break;default:throw Error(m(161))}}}function q(_,x,L){var N=_.tag;if(N===5||N===6)_=_.stateNode,x?Tn(L,_,x):kt(L,_);else if(N!==4&&(_=_.child,_!==null))for(q(_,x,L),_=_.sibling;_!==null;)q(_,x,L),_=_.sibling}function Q(_,x,L){var N=_.tag;if(N===5||N===6)_=_.stateNode,x?Ze(L,_,x):ri(L,_);else if(N!==4&&(_=_.child,_!==null))for(Q(_,x,L),_=_.sibling;_!==null;)Q(_,x,L),_=_.sibling}function he(_,x,L){for(var N=x,Z=!1,ee,Pe;;){if(!Z){Z=N.return;e:for(;;){if(Z===null)throw Error(m(160));switch(ee=Z.stateNode,Z.tag){case 5:Pe=!1;break e;case 3:ee=ee.containerInfo,Pe=!0;break e;case 4:ee=ee.containerInfo,Pe=!0;break e}Z=Z.return}Z=!0}if(N.tag===5||N.tag===6)M(_,N,L),Pe?We(ee,N.stateNode):bn(ee,N.stateNode);else if(N.tag===18)Pe?ki(ee,N.stateNode):Cr(ee,N.stateNode);else if(N.tag===4){if(N.child!==null){ee=N.stateNode.containerInfo,Pe=!0,N.child.return=N,N=N.child;continue}}else if(b(_,N,L),N.child!==null){N.child.return=N,N=N.child;continue}if(N===x)break;for(;N.sibling===null;){if(N.return===null||N.return===x)return;N=N.return,N.tag===4&&(Z=!1)}N.sibling.return=N.return,N=N.sibling}}function me(_,x){if(mn){switch(x.tag){case 0:case 11:case 14:case 15:o(3,x,x.return),u(3,x),o(5,x,x.return);return;case 1:return;case 5:var L=x.stateNode;if(L!=null){var N=x.memoizedProps;_=_!==null?_.memoizedProps:N;var Z=x.type,ee=x.updateQueue;x.updateQueue=null,ee!==null&&Fn(L,ee,Z,_,N,x)}return;case 6:if(x.stateNode===null)throw Error(m(162));L=x.memoizedProps,Hn(x.stateNode,_!==null?_.memoizedProps:L,L);return;case 3:Dt&&_!==null&&_.memoizedState.isDehydrated&&Ni(x.stateNode.containerInfo);return;case 12:return;case 13:ge(x);return;case 19:ge(x);return;case 17:return}throw Error(m(163))}switch(x.tag){case 0:case 11:case 14:case 15:o(3,x,x.return),u(3,x),o(5,x,x.return);return;case 12:return;case 13:ge(x);return;case 19:ge(x);return;case 3:Dt&&_!==null&&_.memoizedState.isDehydrated&&Ni(x.stateNode.containerInfo);break;case 22:case 23:return}e:if(qt){switch(x.tag){case 1:case 5:case 6:break e;case 3:case 4:x=x.stateNode,He(x.containerInfo,x.pendingChildren);break e}throw Error(m(163))}}function ge(_){var x=_.updateQueue;if(x!==null){_.updateQueue=null;var L=_.stateNode;L===null&&(L=_.stateNode=new cp),x.forEach(function(N){var Z=iy.bind(null,_,N);L.has(N)||(L.add(N),N.then(Z,Z))})}}function _e(_,x){for(Bn=x;Bn!==null;){x=Bn;var L=x.deletions;if(L!==null)for(var N=0;N<L.length;N++){var Z=L[N];try{var ee=_;mn?he(ee,Z,x):M(ee,Z,x);var Pe=Z.alternate;Pe!==null&&(Pe.return=null),Z.return=null}catch(Jn){ys(Z,x,Jn)}}if(L=x.child,(x.subtreeFlags&12854)!==0&&L!==null)L.return=x,Bn=L;else for(;Bn!==null;){x=Bn;try{var at=x.flags;if(at&32&&mn&&bt(x.stateNode),at&512){var Ut=x.alternate;if(Ut!==null){var Cn=Ut.ref;Cn!==null&&(typeof Cn=="function"?Cn(null):Cn.current=null)}}if(at&8192)switch(x.tag){case 13:if(x.memoizedState!==null){var Qn=x.alternate;(Qn===null||Qn.memoizedState===null)&&(us=wi())}break;case 22:var Fi=x.memoizedState!==null,_i=x.alternate,Ki=_i!==null&&_i.memoizedState!==null;if(L=x,mn){e:if(N=L,Z=Fi,ee=null,mn)for(var fi=N;;){if(fi.tag===5){if(ee===null){ee=fi;var br=fi.stateNode;Z?un(br):te(fi.stateNode,fi.memoizedProps)}}else if(fi.tag===6){if(ee===null){var ns=fi.stateNode;Z?ue(ns):se(ns,fi.memoizedProps)}}else if((fi.tag!==22&&fi.tag!==23||fi.memoizedState===null||fi===N)&&fi.child!==null){fi.child.return=fi,fi=fi.child;continue}if(fi===N)break;for(;fi.sibling===null;){if(fi.return===null||fi.return===N)break e;ee===fi&&(ee=null),fi=fi.return}ee===fi&&(ee=null),fi.sibling.return=fi.return,fi=fi.sibling}}if(Fi&&!Ki&&(L.mode&1)!==0){Bn=L;for(var wt=L.child;wt!==null;){for(L=Bn=wt;Bn!==null;){N=Bn;var Ke=N.child;switch(N.tag){case 0:case 11:case 14:case 15:o(4,N,N.return);break;case 1:Mc(N,N.return);var Vt=N.stateNode;if(typeof Vt.componentWillUnmount=="function"){var Un=N.return;try{Vt.props=N.memoizedProps,Vt.state=N.memoizedState,Vt.componentWillUnmount()}catch(Jn){ys(N,Un,Jn)}}break;case 5:Mc(N,N.return);break;case 22:if(N.memoizedState!==null){Ee(L);continue}}Ke!==null?(Ke.return=N,Bn=Ke):Ee(L)}wt=wt.sibling}}}switch(at&4102){case 2:X(x),x.flags&=-3;break;case 6:X(x),x.flags&=-3,me(x.alternate,x);break;case 4096:x.flags&=-4097;break;case 4100:x.flags&=-4097,me(x.alternate,x);break;case 4:me(x.alternate,x)}}catch(Jn){ys(x,x.return,Jn)}if(L=x.sibling,L!==null){L.return=x.return,Bn=L;break}Bn=x.return}}}function be(_,x,L){Bn=_,ie(_)}function ie(_,x,L){for(var N=(_.mode&1)!==0;Bn!==null;){var Z=Bn,ee=Z.child;if(Z.tag===22&&N){var Pe=Z.memoizedState!==null||iu;if(!Pe){var at=Z.alternate,Ut=at!==null&&at.memoizedState!==null||Wl;at=iu;var Cn=Wl;if(iu=Pe,(Wl=Ut)&&!Cn)for(Bn=Z;Bn!==null;)Pe=Bn,Ut=Pe.child,Pe.tag===22&&Pe.memoizedState!==null?Te(Z):Ut!==null?(Ut.return=Pe,Bn=Ut):Te(Z);for(;ee!==null;)Bn=ee,ie(ee),ee=ee.sibling;Bn=Z,iu=at,Wl=Cn}pe(_)}else(Z.subtreeFlags&8772)!==0&&ee!==null?(ee.return=Z,Bn=ee):pe(_)}}function pe(_){for(;Bn!==null;){var x=Bn;if((x.flags&8772)!==0){var L=x.alternate;try{if((x.flags&8772)!==0)switch(x.tag){case 0:case 11:case 15:Wl||u(5,x);break;case 1:var N=x.stateNode;if(x.flags&4&&!Wl)if(L===null)N.componentDidMount();else{var Z=x.elementType===x.type?L.memoizedProps:as(x.type,L.memoizedProps);N.componentDidUpdate(Z,L.memoizedState,N.__reactInternalSnapshotBeforeUpdate)}var ee=x.updateQueue;ee!==null&&fa(x,ee,N);break;case 3:var Pe=x.updateQueue;if(Pe!==null){if(L=null,x.child!==null)switch(x.child.tag){case 5:L=ft(x.child.stateNode);break;case 1:L=x.child.stateNode}fa(x,Pe,L)}break;case 5:var at=x.stateNode;L===null&&x.flags&4&&On(at,x.type,x.memoizedProps,x);break;case 6:break;case 4:break;case 12:break;case 13:if(Dt&&x.memoizedState===null){var Ut=x.alternate;if(Ut!==null){var Cn=Ut.memoizedState;if(Cn!==null){var Qn=Cn.dehydrated;Qn!==null&&Qi(Qn)}}}break;case 19:case 17:case 21:case 22:case 23:break;default:throw Error(m(163))}Wl||x.flags&512&&y(x)}catch(Fi){ys(x,x.return,Fi)}}if(x===_){Bn=null;break}if(L=x.sibling,L!==null){L.return=x.return,Bn=L;break}Bn=x.return}}function Ee(_){for(;Bn!==null;){var x=Bn;if(x===_){Bn=null;break}var L=x.sibling;if(L!==null){L.return=x.return,Bn=L;break}Bn=x.return}}function Te(_){for(;Bn!==null;){var x=Bn;try{switch(x.tag){case 0:case 11:case 15:var L=x.return;try{u(4,x)}catch(Ut){ys(x,L,Ut)}break;case 1:var N=x.stateNode;if(typeof N.componentDidMount=="function"){var Z=x.return;try{N.componentDidMount()}catch(Ut){ys(x,Z,Ut)}}var ee=x.return;try{y(x)}catch(Ut){ys(x,ee,Ut)}break;case 5:var Pe=x.return;try{y(x)}catch(Ut){ys(x,Pe,Ut)}}}catch(Ut){ys(x,x.return,Ut)}if(x===_){Bn=null;break}var at=x.sibling;if(at!==null){at.return=x.return,Bn=at;break}Bn=x.return}}var Ue=0,Ge=1,Ve=2,et=3,$e=4;if(typeof Symbol=="function"&&Symbol.for){var ht=Symbol.for;Ue=ht("selector.component"),Ge=ht("selector.has_pseudo_class"),Ve=ht("selector.role"),et=ht("selector.test_id"),$e=ht("selector.text")}function Jt(_){var x=gn(_);if(x!=null){if(typeof x.memoizedProps["data-testname"]!="string")throw Error(m(364));return x}if(_=ti(_),_===null)throw Error(m(362));return _.stateNode.current}function ut(_,x){switch(x.$$typeof){case Ue:if(_.type===x.value)return!0;break;case Ge:e:{x=x.value,_=[_,0];for(var L=0;L<_.length;){var N=_[L++],Z=_[L++],ee=x[Z];if(N.tag!==5||!Tt(N)){for(;ee!=null&&ut(N,ee);)Z++,ee=x[Z];if(Z===x.length){x=!0;break e}else for(N=N.child;N!==null;)_.push(N,Z),N=N.sibling}}x=!1}return x;case Ve:if(_.tag===5&&hn(_.stateNode,x.value))return!0;break;case $e:if((_.tag===5||_.tag===6)&&(_=xe(_),_!==null&&0<=_.indexOf(x.value)))return!0;break;case et:if(_.tag===5&&(_=_.memoizedProps["data-testname"],typeof _=="string"&&_.toLowerCase()===x.value.toLowerCase()))return!0;break;default:throw Error(m(365))}return!1}function Bt(_){switch(_.$$typeof){case Ue:return"<"+(Ae(_.value)||"Unknown")+">";case Ge:return":has("+(Bt(_)||"")+")";case Ve:return'[role="'+_.value+'"]';case $e:return'"'+_.value+'"';case et:return'[data-testname="'+_.value+'"]';default:throw Error(m(365))}}function yt(_,x){var L=[];_=[_,0];for(var N=0;N<_.length;){var Z=_[N++],ee=_[N++],Pe=x[ee];if(Z.tag!==5||!Tt(Z)){for(;Pe!=null&&ut(Z,Pe);)ee++,Pe=x[ee];if(ee===x.length)L.push(Z);else for(Z=Z.child;Z!==null;)_.push(Z,ee),Z=Z.sibling}}return L}function Xt(_,x){if(!li)throw Error(m(363));_=Jt(_),_=yt(_,x),x=[],_=Array.from(_);for(var L=0;L<_.length;){var N=_[L++];if(N.tag===5)Tt(N)||x.push(N.stateNode);else for(N=N.child;N!==null;)_.push(N),N=N.sibling}return x}var gt=Math.ceil,Ot=i.ReactCurrentDispatcher,Qt=i.ReactCurrentOwner,Lt=i.ReactCurrentBatchConfig,Ct=0,zn=null,qn=null,vn=0,Vn=0,Ai=Zi(0),si=0,Gn=null,$i=0,hr=0,mr=0,ar=null,xr=null,us=0,ko=1/0;function bo(){ko=wi()+500}var vr=!1,gr=null,ji=null,Gr=!1,es=null,yr=0,Ps=0,Ec=null,Za=-1,El=0;function Xr(){return(Ct&6)!==0?wi():Za!==-1?Za:Za=wi()}function wo(_){return(_.mode&1)===0?1:(Ct&2)!==0&&vn!==0?vn&-vn:_l.transition!==null?(El===0&&(_=ae,ae<<=1,(ae&4194240)===0&&(ae=64),El=_),El):(_=di,_!==0?_:Yt())}function Ls(_,x,L){if(50<Ps)throw Ps=0,Ec=null,Error(m(185));var N=ql(_,x);return N===null?null:(Pn(N,x,L),((Ct&2)===0||N!==zn)&&(N===zn&&((Ct&2)===0&&(hr|=x),si===4&&Tl(N,vn)),Rs(N,L),x===1&&Ct===0&&(_.mode&1)===0&&(bo(),Js&&Co())),N)}function ql(_,x){_.lanes|=x;var L=_.alternate;for(L!==null&&(L.lanes|=x),L=_,_=_.return;_!==null;)_.childLanes|=x,L=_.alternate,L!==null&&(L.childLanes|=x),L=_,_=_.return;return L.tag===3?L.stateNode:null}function Rs(_,x){var L=_.callbackNode;en(_,x);var N=qe(_,_===zn?vn:0);if(N===0)L!==null&&zt(L),_.callbackNode=null,_.callbackPriority=0;else if(x=N&-N,_.callbackPriority!==x){if(L!=null&&zt(L),x===1)_.tag===0?dh(bh.bind(null,_)):gl(bh.bind(null,_)),dn?Mn(function(){Ct===0&&Co()}):Ji(or,Co),L=null;else{switch(vi(N)){case 1:L=or;break;case 4:L=lc;break;case 16:L=tl;break;case 536870912:L=Si;break;default:L=tl}L=Lm(L,ku.bind(null,_))}_.callbackPriority=x,_.callbackNode=L}}function ku(_,x){if(Za=-1,El=0,(Ct&6)!==0)throw Error(m(327));var L=_.callbackNode;if($o()&&_.callbackNode!==L)return null;var N=qe(_,_===zn?vn:0);if(N===0)return null;if((N&30)!==0||(N&_.expiredLanes)!==0||x)x=Mh(_,N);else{x=N;var Z=Ct;Ct|=2;var ee=Sh();(zn!==_||vn!==x)&&(bo(),Al(_,x));do try{ty();break}catch(at){Cl(_,at)}while(1);da(),Ot.current=ee,Ct=Z,qn!==null?x=0:(zn=null,vn=0,x=si)}if(x!==0){if(x===2&&(Z=cn(_),Z!==0&&(N=Z,x=Dd(_,Z))),x===1)throw L=Gn,Al(_,0),Tl(_,N),Rs(_,wi()),L;if(x===6)Tl(_,N);else{if(Z=_.current.alternate,(N&30)===0&&!Q_(Z)&&(x=Mh(_,N),x===2&&(ee=cn(_),ee!==0&&(N=ee,x=Dd(_,ee))),x===1))throw L=Gn,Al(_,0),Tl(_,N),Rs(_,wi()),L;switch(_.finishedWork=Z,_.finishedLanes=N,x){case 0:case 1:throw Error(m(345));case 2:ol(_,xr);break;case 3:if(Tl(_,N),(N&130023424)===N&&(x=us+500-wi(),10<x)){if(qe(_,0)!==0)break;if(Z=_.suspendedLanes,(Z&N)!==N){Xr(),_.pingedLanes|=_.suspendedLanes&Z;break}_.timeoutHandle=ei(ol.bind(null,_,xr),x);break}ol(_,xr);break;case 4:if(Tl(_,N),(N&4194240)===N)break;for(x=_.eventTimes,Z=-1;0<N;){var Pe=31-Hr(N);ee=1<<Pe,Pe=x[Pe],Pe>Z&&(Z=Pe),N&=~ee}if(N=Z,N=wi()-N,N=(120>N?120:480>N?480:1080>N?1080:1920>N?1920:3e3>N?3e3:4320>N?4320:1960*gt(N/1960))-N,10<N){_.timeoutHandle=ei(ol.bind(null,_,xr),N);break}ol(_,xr);break;case 5:ol(_,xr);break;default:throw Error(m(329))}}}return Rs(_,wi()),_.callbackNode===L?ku.bind(null,_):null}function Dd(_,x){var L=ar;return _.current.memoizedState.isDehydrated&&(Al(_,x).flags|=256),_=Mh(_,x),_!==2&&(x=xr,xr=L,x!==null&&zd(x)),_}function zd(_){xr===null?xr=_:xr.push.apply(xr,_)}function Q_(_){for(var x=_;;){if(x.flags&16384){var L=x.updateQueue;if(L!==null&&(L=L.stores,L!==null))for(var N=0;N<L.length;N++){var Z=L[N],ee=Z.getSnapshot;Z=Z.value;try{if(!mo(ee(),Z))return!1}catch{return!1}}}if(L=x.child,x.subtreeFlags&16384&&L!==null)L.return=x,x=L;else{if(x===_)break;for(;x.sibling===null;){if(x.return===null||x.return===_)return!0;x=x.return}x.sibling.return=x.return,x=x.sibling}}return!0}function Tl(_,x){for(x&=~mr,x&=~hr,_.suspendedLanes|=x,_.pingedLanes&=~x,_=_.expirationTimes;0<x;){var L=31-Hr(x),N=1<<L;_[L]=-1,x&=~N}}function bh(_){if((Ct&6)!==0)throw Error(m(327));$o();var x=qe(_,0);if((x&1)===0)return Rs(_,wi()),null;var L=Mh(_,x);if(_.tag!==0&&L===2){var N=cn(_);N!==0&&(x=N,L=Dd(_,N))}if(L===1)throw L=Gn,Al(_,0),Tl(_,x),Rs(_,wi()),L;if(L===6)throw Error(m(345));return _.finishedWork=_.current.alternate,_.finishedLanes=x,ol(_,xr),Rs(_,wi()),null}function up(_){es!==null&&es.tag===0&&(Ct&6)===0&&$o();var x=Ct;Ct|=1;var L=Lt.transition,N=di;try{if(Lt.transition=null,di=1,_)return _()}finally{di=N,Lt.transition=L,Ct=x,(Ct&6)===0&&Co()}}function wh(){Vn=Ai.current,ct(Ai)}function Al(_,x){_.finishedWork=null,_.finishedLanes=0;var L=_.timeoutHandle;if(L!==Wn&&(_.timeoutHandle=Wn,oi(L)),qn!==null)for(L=qn.return;L!==null;){var N=L;switch(fc(N),N.tag){case 1:N=N.type.childContextTypes,N!=null&&Uo();break;case 3:fr(),ct(Os),ct(nr),Vr();break;case 5:Pr(N);break;case 4:fr();break;case 13:ct(Ti);break;case 19:ct(Ti);break;case 10:Ol(N.type._context);break;case 22:case 23:wh()}L=L.return}if(zn=_,qn=_=Cc(_.current,null),vn=Vn=x,si=0,Gn=null,mr=hr=$i=0,xr=ar=null,ls!==null){for(x=0;x<ls.length;x++)if(L=ls[x],N=L.interleaved,N!==null){L.interleaved=null;var Z=N.next,ee=L.pending;if(ee!==null){var Pe=ee.next;ee.next=Z,N.next=Pe}L.pending=N}ls=null}return _}function Cl(_,x){do{var L=qn;try{if(da(),cs.current=Kc,ta){for(var N=pr.memoizedState;N!==null;){var Z=N.queue;Z!==null&&(Z.pending=null),N=N.next}ta=!1}if(Kr=0,Zr=qr=pr=null,Lo=!1,Ho=0,Qt.current=null,L===null||L.return===null){si=1,Gn=x,qn=null;break}e:{var ee=_,Pe=L.return,at=L,Ut=x;if(x=vn,at.flags|=32768,Ut!==null&&typeof Ut=="object"&&typeof Ut.then=="function"){var Cn=Ut,Qn=at,Fi=Qn.tag;if((Qn.mode&1)===0&&(Fi===0||Fi===11||Fi===15)){var _i=Qn.alternate;_i?(Qn.updateQueue=_i.updateQueue,Qn.memoizedState=_i.memoizedState,Qn.lanes=_i.lanes):(Qn.updateQueue=null,Qn.memoizedState=null)}var Ki=Qc(Pe);if(Ki!==null){Ki.flags&=-257,bc(Ki,Pe,at,ee,x),Ki.mode&1&&Ru(ee,Cn,x),x=Ki,Ut=Cn;var fi=x.updateQueue;if(fi===null){var br=new Set;br.add(Ut),x.updateQueue=br}else fi.add(Ut);break e}else{if((x&1)===0){Ru(ee,Cn,x),kd();break e}Ut=Error(m(426))}}else if(Sr&&at.mode&1){var ns=Qc(Pe);if(ns!==null){(ns.flags&65536)===0&&(ns.flags|=256),bc(ns,Pe,at,ee,x),Nl(Ut);break e}}ee=Ut,si!==4&&(si=2),ar===null?ar=[ee]:ar.push(ee),Ut=ph(Ut,at),at=Pe;do{switch(at.tag){case 3:at.flags|=65536,x&=-x,at.lanes|=x;var wt=Pu(at,Ut,x);dc(at,wt);break e;case 1:ee=Ut;var Ke=at.type,Vt=at.stateNode;if((at.flags&128)===0&&(typeof Ke.getDerivedStateFromError=="function"||Vt!==null&&typeof Vt.componentDidCatch=="function"&&(ji===null||!ji.has(Vt)))){at.flags|=65536,x&=-x,at.lanes|=x;var Un=Lu(at,ee,x);dc(at,Un);break e}}at=at.return}while(at!==null)}Od(L)}catch(Jn){x=Jn,qn===L&&L!==null&&(qn=L=L.return);continue}break}while(1)}function Sh(){var _=Ot.current;return Ot.current=Kc,_===null?Kc:_}function kd(){(si===0||si===3||si===2)&&(si=4),zn===null||($i&268435455)===0&&(hr&268435455)===0||Tl(zn,vn)}function Mh(_,x){var L=Ct;Ct|=2;var N=Sh();zn===_&&vn===x||Al(_,x);do try{ey();break}catch(Z){Cl(_,Z)}while(1);if(da(),Ct=L,Ot.current=N,qn!==null)throw Error(m(261));return zn=null,vn=0,si}function ey(){for(;qn!==null;)Im(qn)}function ty(){for(;qn!==null&&!Xn();)Im(qn)}function Im(_){var x=Pm(_.alternate,_,Vn);_.memoizedProps=_.pendingProps,x===null?Od(_):qn=x,Qt.current=null}function Od(_){var x=_;do{var L=x.alternate;if(_=x.return,(x.flags&32768)===0){if(L=Ad(L,x,Vn),L!==null){qn=L;return}}else{if(L=Rd(L,x),L!==null){L.flags&=32767,qn=L;return}if(_!==null)_.flags|=32768,_.subtreeFlags=0,_.deletions=null;else{si=6,qn=null;return}}if(x=x.sibling,x!==null){qn=x;return}qn=x=_}while(x!==null);si===0&&(si=5)}function ol(_,x){var L=di,N=Lt.transition;try{Lt.transition=null,di=1,Ou(_,x,L)}finally{Lt.transition=N,di=L}return null}function Ou(_,x,L){do $o();while(es!==null);if((Ct&6)!==0)throw Error(m(327));var N=_.finishedWork,Z=_.finishedLanes;if(N===null)return null;if(_.finishedWork=null,_.finishedLanes=0,N===_.current)throw Error(m(177));_.callbackNode=null,_.callbackPriority=0;var ee=N.lanes|N.childLanes;if(xn(_,ee),_===zn&&(qn=zn=null,vn=0),(N.subtreeFlags&2064)===0&&(N.flags&2064)===0||Gr||(Gr=!0,Lm(tl,function(){return $o(),null})),ee=(N.flags&15990)!==0,(N.subtreeFlags&15990)!==0||ee){ee=Lt.transition,Lt.transition=null;var Pe=di;di=1;var at=Ct;Ct|=4,Qt.current=null,p(_,N),_e(_,N),tt(_.containerInfo),_.current=N,be(N),ur(),Ct=at,di=Pe,Lt.transition=ee}else _.current=N;if(Gr&&(Gr=!1,es=_,yr=Z),ee=_.pendingLanes,ee===0&&(ji=null),Fs(N.stateNode),Rs(_,wi()),x!==null)for(L=_.onRecoverableError,N=0;N<x.length;N++)L(x[N]);if(vr)throw vr=!1,_=gr,gr=null,_;return(yr&1)!==0&&_.tag!==0&&$o(),ee=_.pendingLanes,(ee&1)!==0?_===Ec?Ps++:(Ps=0,Ec=_):Ps=0,Co(),null}function $o(){if(es!==null){var _=vi(yr),x=Lt.transition,L=di;try{if(Lt.transition=null,di=16>_?16:_,es===null)var N=!1;else{if(_=es,es=null,yr=0,(Ct&6)!==0)throw Error(m(331));var Z=Ct;for(Ct|=4,Bn=_.current;Bn!==null;){var ee=Bn,Pe=ee.child;if((Bn.flags&16)!==0){var at=ee.deletions;if(at!==null){for(var Ut=0;Ut<at.length;Ut++){var Cn=at[Ut];for(Bn=Cn;Bn!==null;){var Qn=Bn;switch(Qn.tag){case 0:case 11:case 15:o(8,Qn,ee)}var Fi=Qn.child;if(Fi!==null)Fi.return=Qn,Bn=Fi;else for(;Bn!==null;){Qn=Bn;var _i=Qn.sibling,Ki=Qn.return;if(R(Qn),Qn===Cn){Bn=null;break}if(_i!==null){_i.return=Ki,Bn=_i;break}Bn=Ki}}}var fi=ee.alternate;if(fi!==null){var br=fi.child;if(br!==null){fi.child=null;do{var ns=br.sibling;br.sibling=null,br=ns}while(br!==null)}}Bn=ee}}if((ee.subtreeFlags&2064)!==0&&Pe!==null)Pe.return=ee,Bn=Pe;else e:for(;Bn!==null;){if(ee=Bn,(ee.flags&2048)!==0)switch(ee.tag){case 0:case 11:case 15:o(9,ee,ee.return)}var wt=ee.sibling;if(wt!==null){wt.return=ee.return,Bn=wt;break e}Bn=ee.return}}var Ke=_.current;for(Bn=Ke;Bn!==null;){Pe=Bn;var Vt=Pe.child;if((Pe.subtreeFlags&2064)!==0&&Vt!==null)Vt.return=Pe,Bn=Vt;else e:for(Pe=Ke;Bn!==null;){if(at=Bn,(at.flags&2048)!==0)try{switch(at.tag){case 0:case 11:case 15:u(9,at)}}catch(Jn){ys(at,at.return,Jn)}if(at===Pe){Bn=null;break e}var Un=at.sibling;if(Un!==null){Un.return=at.return,Bn=Un;break e}Bn=at.return}}if(Ct=Z,Co(),To&&typeof To.onPostCommitFiberRoot=="function")try{To.onPostCommitFiberRoot(ha,_)}catch{}N=!0}return N}finally{di=L,Lt.transition=x}}return!1}function Xa(_,x,L){x=ph(L,x),x=Pu(_,x,1),Go(_,x),x=Xr(),_=ql(_,1),_!==null&&(Pn(_,1,x),Rs(_,x))}function ys(_,x,L){if(_.tag===3)Xa(_,_,L);else for(;x!==null;){if(x.tag===3){Xa(x,_,L);break}else if(x.tag===1){var N=x.stateNode;if(typeof x.type.getDerivedStateFromError=="function"||typeof N.componentDidCatch=="function"&&(ji===null||!ji.has(N))){_=ph(L,_),_=Lu(x,_,1),Go(x,_),_=Xr(),x=ql(x,1),x!==null&&(Pn(x,1,_),Rs(x,_));break}}x=x.return}}function Tc(_,x,L){var N=_.pingCache;N!==null&&N.delete(x),x=Xr(),_.pingedLanes|=_.suspendedLanes&L,zn===_&&(vn&L)===L&&(si===4||si===3&&(vn&130023424)===vn&&500>wi()-us?Al(_,0):mr|=L),Rs(_,x)}function Ac(_,x){x===0&&((_.mode&1)===0?x=1:(x=Ce,Ce<<=1,(Ce&130023424)===0&&(Ce=4194304)));var L=Xr();_=ql(_,x),_!==null&&(Pn(_,x,L),Rs(_,L))}function ny(_){var x=_.memoizedState,L=0;x!==null&&(L=x.retryLane),Ac(_,L)}function iy(_,x){var L=0;switch(_.tag){case 13:var N=_.stateNode,Z=_.memoizedState;Z!==null&&(L=Z.retryLane);break;case 19:N=_.stateNode;break;default:throw Error(m(314))}N!==null&&N.delete(x),Ac(_,L)}var Pm;Pm=function(_,x,L){if(_!==null)if(_.memoizedProps!==x.pendingProps||Os.current)Do=!0;else{if((_.lanes&L)===0&&(x.flags&128)===0)return Do=!1,vh(_,x,L);Do=(_.flags&131072)!==0}else Do=!1,Sr&&(x.flags&1048576)!==0&&il(x,Ba,x.index);switch(x.lanes=0,x.tag){case 2:var N=x.type;_!==null&&(_.alternate=null,x.alternate=null,x.flags|=2),_=x.pendingProps;var Z=Ra(x,nr.current);ka(x,L),Z=ir(null,x,N,_,Z,L);var ee=gs();return x.flags|=1,typeof Z=="object"&&Z!==null&&typeof Z.render=="function"&&Z.$$typeof===void 0?(x.tag=1,x.memoizedState=null,x.updateQueue=null,As(N)?(ee=!0,Mi(x)):ee=!1,x.memoizedState=Z.state!==null&&Z.state!==void 0?Z.state:null,uc(x),Z.updater=Po,x.stateNode=Z,Z._reactInternals=x,Bl(x,N,_,L),x=xh(null,x,N,!0,ee,L)):(x.tag=0,Sr&&ee&&rl(x),oo(null,x,Z,L),x=x.child),x;case 16:N=x.elementType;e:{switch(_!==null&&(_.alternate=null,x.alternate=null,x.flags|=2),_=x.pendingProps,Z=N._init,N=Z(N._payload),x.type=N,Z=x.tag=ry(N),_=as(N,_),Z){case 0:x=zo(null,x,N,_,L);break e;case 1:x=yh(null,x,N,_,L);break e;case 11:x=js(null,x,N,_,L);break e;case 14:x=Cd(null,x,N,as(N.type,_),L);break e}throw Error(m(306,N,""))}return x;case 0:return N=x.type,Z=x.pendingProps,Z=x.elementType===N?Z:as(N,Z),zo(_,x,N,Z,L);case 1:return N=x.type,Z=x.pendingProps,Z=x.elementType===N?Z:as(N,Z),yh(_,x,N,Z,L);case 3:e:{if(sa(x),_===null)throw Error(m(387));N=x.pendingProps,ee=x.memoizedState,Z=ee.element,hc(_,x),jo(x,N,null,L);var Pe=x.memoizedState;if(N=Pe.element,Dt&&ee.isDehydrated)if(ee={element:N,isDehydrated:!1,cache:Pe.cache,transitions:Pe.transitions},x.updateQueue.baseState=ee,x.memoizedState=ee,x.flags&256){Z=Error(m(423)),x=ba(_,x,N,L,Z);break e}else if(N!==Z){Z=Error(m(424)),x=ba(_,x,N,L,Z);break e}else for(Dt&&(Us=Gt(x.stateNode.containerInfo),to=x,Sr=!0,Vs=null,Na=!1),L=Ga(x,null,N,L),x.child=L;L;)L.flags=L.flags&-3|4096,L=L.sibling;else{if(Wo(),N===Z){x=qa(_,x,L);break e}oo(_,x,N,L)}x=x.child}return x;case 5:return Wi(x),_===null&&no(x),N=x.type,Z=x.pendingProps,ee=_!==null?_.memoizedProps:null,Pe=Z.children,pn(N,Z)?Pe=null:ee!==null&&pn(N,ee)&&(x.flags|=32),Pd(_,x),oo(_,x,Pe,L),x.child;case 6:return _===null&&no(x),null;case 13:return kn(_,x,L);case 4:return ni(x,x.stateNode.containerInfo),N=x.pendingProps,_===null?x.child=Va(x,null,N,L):oo(_,x,N,L),x.child;case 11:return N=x.type,Z=x.pendingProps,Z=x.elementType===N?Z:as(N,Z),js(_,x,N,Z,L);case 7:return oo(_,x,x.pendingProps,L),x.child;case 8:return oo(_,x,x.pendingProps.children,L),x.child;case 12:return oo(_,x,x.pendingProps.children,L),x.child;case 10:e:{if(N=x.type._context,Z=x.pendingProps,ee=x.memoizedProps,Pe=Z.value,Bs(x,N,Pe),ee!==null)if(mo(ee.value,Pe)){if(ee.children===Z.children&&!Os.current){x=qa(_,x,L);break e}}else for(ee=x.child,ee!==null&&(ee.return=x);ee!==null;){var at=ee.dependencies;if(at!==null){Pe=ee.child;for(var Ut=at.firstContext;Ut!==null;){if(Ut.context===N){if(ee.tag===1){Ut=Cs(-1,L&-L),Ut.tag=2;var Cn=ee.updateQueue;if(Cn!==null){Cn=Cn.shared;var Qn=Cn.pending;Qn===null?Ut.next=Ut:(Ut.next=Qn.next,Qn.next=Ut),Cn.pending=Ut}}ee.lanes|=L,Ut=ee.alternate,Ut!==null&&(Ut.lanes|=L),nl(ee.return,L,x),at.lanes|=L;break}Ut=Ut.next}}else if(ee.tag===10)Pe=ee.type===x.type?null:ee.child;else if(ee.tag===18){if(Pe=ee.return,Pe===null)throw Error(m(341));Pe.lanes|=L,at=Pe.alternate,at!==null&&(at.lanes|=L),nl(Pe,L,x),Pe=ee.sibling}else Pe=ee.child;if(Pe!==null)Pe.return=ee;else for(Pe=ee;Pe!==null;){if(Pe===x){Pe=null;break}if(ee=Pe.sibling,ee!==null){ee.return=Pe.return,Pe=ee;break}Pe=Pe.return}ee=Pe}oo(_,x,Z.children,L),x=x.child}return x;case 9:return Z=x.type,N=x.pendingProps.children,ka(x,L),Z=Ns(Z),N=N(Z),x.flags|=1,oo(_,x,N,L),x.child;case 14:return N=x.type,Z=as(N,x.pendingProps),Z=as(N.type,Z),Cd(_,x,N,Z,L);case 15:return _h(_,x,x.type,x.pendingProps,L);case 17:return N=x.type,Z=x.pendingProps,Z=x.elementType===N?Z:as(N,Z),_!==null&&(_.alternate=null,x.alternate=null,x.flags|=2),x.tag=1,As(N)?(_=!0,Mi(x)):_=!1,ka(x,L),qc(x,N,Z),Bl(x,N,Z,L),xh(null,x,N,!0,_,L);case 19:return Ld(_,x,L);case 22:return Id(_,x,L)}throw Error(m(156,x.tag))};function Lm(_,x){return Ji(_,x)}function Rm(_,x,L,N){this.tag=_,this.key=L,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=x,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=N,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function wa(_,x,L,N){return new Rm(_,x,L,N)}function Sa(_){return _=_.prototype,!(!_||!_.isReactComponent)}function ry(_){if(typeof _=="function")return Sa(_)?1:0;if(_!=null){if(_=_.$$typeof,_===B)return 11;if(_===Y)return 14}return 2}function Cc(_,x){var L=_.alternate;return L===null?(L=wa(_.tag,x,_.key,_.mode),L.elementType=_.elementType,L.type=_.type,L.stateNode=_.stateNode,L.alternate=_,_.alternate=L):(L.pendingProps=x,L.type=_.type,L.flags=0,L.subtreeFlags=0,L.deletions=null),L.flags=_.flags&14680064,L.childLanes=_.childLanes,L.lanes=_.lanes,L.child=_.child,L.memoizedProps=_.memoizedProps,L.memoizedState=_.memoizedState,L.updateQueue=_.updateQueue,x=_.dependencies,L.dependencies=x===null?null:{lanes:x.lanes,firstContext:x.firstContext},L.sibling=_.sibling,L.index=_.index,L.ref=_.ref,L}function jr(_,x,L,N,Z,ee){var Pe=2;if(N=_,typeof _=="function")Sa(_)&&(Pe=1);else if(typeof _=="string")Pe=5;else e:switch(_){case C:return Zn(L.children,Z,ee,x);case T:Pe=8,Z|=8;break;case I:return _=wa(12,L,x,Z|2),_.elementType=I,_.lanes=ee,_;case F:return _=wa(13,L,x,Z),_.elementType=F,_.lanes=ee,_;case H:return _=wa(19,L,x,Z),_.elementType=H,_.lanes=ee,_;case ne:return al(L,Z,ee,x);default:if(typeof _=="object"&&_!==null)switch(_.$$typeof){case k:Pe=10;break e;case O:Pe=9;break e;case B:Pe=11;break e;case Y:Pe=14;break e;case K:Pe=16,N=null;break e}throw Error(m(130,_==null?_:typeof _,""))}return x=wa(Pe,L,x,Z),x.elementType=_,x.type=N,x.lanes=ee,x}function Zn(_,x,L,N){return _=wa(7,_,N,x),_.lanes=L,_}function al(_,x,L,N){return _=wa(22,_,N,x),_.elementType=ne,_.lanes=L,_.stateNode={},_}function Fu(_,x,L){return _=wa(6,_,null,x),_.lanes=L,_}function Oo(_,x,L){return x=wa(4,_.children!==null?_.children:[],_.key,x),x.lanes=L,x.stateNode={containerInfo:_.containerInfo,pendingChildren:null,implementation:_.implementation},x}function Dm(_,x,L,N,Z){this.tag=x,this.containerInfo=_,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=Wn,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Ln(0),this.expirationTimes=Ln(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ln(0),this.identifierPrefix=N,this.onRecoverableError=Z,Dt&&(this.mutableSourceEagerHydrationData=null)}function hp(_,x,L,N,Z,ee,Pe,at,Ut){return _=new Dm(_,x,L,at,Ut),x===1?(x=1,ee===!0&&(x|=8)):x=0,ee=wa(3,null,null,x),_.current=ee,ee.stateNode=_,ee.memoizedState={element:N,isDehydrated:L,cache:null,transitions:null},uc(ee),_}function $a(_){if(!_)return Ci;_=_._reactInternals;e:{if(ce(_)!==_||_.tag!==1)throw Error(m(170));var x=_;do{switch(x.tag){case 3:x=x.stateNode.context;break e;case 1:if(As(x.type)){x=x.stateNode.__reactInternalMemoizedMergedChildContext;break e}}x=x.return}while(x!==null);throw Error(m(171))}if(_.tag===1){var L=_.type;if(As(L))return Oi(_,L,x)}return x}function Fd(_){var x=_._reactInternals;if(x===void 0)throw typeof _.render=="function"?Error(m(188)):(_=Object.keys(_).join(","),Error(m(268,_)));return _=Xe(x),_===null?null:_.stateNode}function Ic(_,x){if(_=_.memoizedState,_!==null&&_.dehydrated!==null){var L=_.retryLane;_.retryLane=L!==0&&L<x?L:x}}function su(_,x){Ic(_,x),(_=_.alternate)&&Ic(_,x)}function ou(_){return _=Xe(_),_===null?null:_.stateNode}function dp(){return null}return n.attemptContinuousHydration=function(_){if(_.tag===13){var x=Xr();Ls(_,134217728,x),su(_,134217728)}},n.attemptHydrationAtCurrentPriority=function(_){if(_.tag===13){var x=Xr(),L=wo(_);Ls(_,L,x),su(_,L)}},n.attemptSynchronousHydration=function(_){switch(_.tag){case 3:var x=_.stateNode;if(x.current.memoizedState.isDehydrated){var L=Oe(x.pendingLanes);L!==0&&(mi(x,L|1),Rs(x,wi()),(Ct&6)===0&&(bo(),Co()))}break;case 13:var N=Xr();up(function(){return Ls(_,1,N)}),su(_,1)}},n.batchedUpdates=function(_,x){var L=Ct;Ct|=1;try{return _(x)}finally{Ct=L,Ct===0&&(bo(),Js&&Co())}},n.createComponentSelector=function(_){return{$$typeof:Ue,value:_}},n.createContainer=function(_,x,L,N,Z,ee,Pe){return hp(_,x,!1,null,L,N,Z,ee,Pe)},n.createHasPseudoClassSelector=function(_){return{$$typeof:Ge,value:_}},n.createHydrationContainer=function(_,x,L,N,Z,ee,Pe,at,Ut){return _=hp(L,N,!0,_,Z,ee,Pe,at,Ut),_.context=$a(null),L=_.current,N=Xr(),Z=wo(L),ee=Cs(N,Z),ee.callback=x!=null?x:null,Go(L,ee),_.current.lanes=Z,Pn(_,Z,N),Rs(_,N),_},n.createPortal=function(_,x,L){var N=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:E,key:N==null?null:""+N,children:_,containerInfo:x,implementation:L}},n.createRoleSelector=function(_){return{$$typeof:Ve,value:_}},n.createTestNameSelector=function(_){return{$$typeof:et,value:_}},n.createTextSelector=function(_){return{$$typeof:$e,value:_}},n.deferredUpdates=function(_){var x=di,L=Lt.transition;try{return Lt.transition=null,di=16,_()}finally{di=x,Lt.transition=L}},n.discreteUpdates=function(_,x,L,N,Z){var ee=di,Pe=Lt.transition;try{return Lt.transition=null,di=1,_(x,L,N,Z)}finally{di=ee,Lt.transition=Pe,Ct===0&&bo()}},n.findAllNodes=Xt,n.findBoundingRects=function(_,x){if(!li)throw Error(m(363));x=Xt(_,x),_=[];for(var L=0;L<x.length;L++)_.push(Ie(x[L]));for(x=_.length-1;0<x;x--){L=_[x];for(var N=L.x,Z=N+L.width,ee=L.y,Pe=ee+L.height,at=x-1;0<=at;at--)if(x!==at){var Ut=_[at],Cn=Ut.x,Qn=Cn+Ut.width,Fi=Ut.y,_i=Fi+Ut.height;if(N>=Cn&&ee>=Fi&&Z<=Qn&&Pe<=_i){_.splice(x,1);break}else if(N!==Cn||L.width!==Ut.width||_i<ee||Fi>Pe){if(!(ee!==Fi||L.height!==Ut.height||Qn<N||Cn>Z)){Cn>N&&(Ut.width+=Cn-N,Ut.x=N),Qn<Z&&(Ut.width=Z-Cn),_.splice(x,1);break}}else{Fi>ee&&(Ut.height+=Fi-ee,Ut.y=ee),_i<Pe&&(Ut.height=Pe-Fi),_.splice(x,1);break}}}return _},n.findHostInstance=Fd,n.findHostInstanceWithNoPortals=function(_){return _=ke(_),_=_!==null?Je(_):null,_===null?null:_.stateNode},n.findHostInstanceWithWarning=function(_){return Fd(_)},n.flushControlled=function(_){var x=Ct;Ct|=1;var L=Lt.transition,N=di;try{Lt.transition=null,di=1,_()}finally{di=N,Lt.transition=L,Ct=x,Ct===0&&(bo(),Co())}},n.flushPassiveEffects=$o,n.flushSync=up,n.focusWithin=function(_,x){if(!li)throw Error(m(363));for(_=Jt(_),x=yt(_,x),x=Array.from(x),_=0;_<x.length;){var L=x[_++];if(!Tt(L)){if(L.tag===5&&_n(L.stateNode))return!0;for(L=L.child;L!==null;)x.push(L),L=L.sibling}}return!1},n.getCurrentUpdatePriority=function(){return di},n.getFindAllNodesFailureDescription=function(_,x){if(!li)throw Error(m(363));var L=0,N=[];_=[Jt(_),0];for(var Z=0;Z<_.length;){var ee=_[Z++],Pe=_[Z++],at=x[Pe];if((ee.tag!==5||!Tt(ee))&&(ut(ee,at)&&(N.push(Bt(at)),Pe++,Pe>L&&(L=Pe)),Pe<x.length))for(ee=ee.child;ee!==null;)_.push(ee,Pe),ee=ee.sibling}if(L<x.length){for(_=[];L<x.length;L++)_.push(Bt(x[L]));return`findAllNodes was able to match part of the selector:
  `+(N.join(" > ")+`

No matching component was found for:
  `)+_.join(" > ")}return null},n.getPublicRootInstance=function(_){if(_=_.current,!_.child)return null;switch(_.child.tag){case 5:return ft(_.child.stateNode);default:return _.child.stateNode}},n.injectIntoDevTools=function(_){if(_={bundleType:_.bundleType,version:_.version,rendererPackageName:_.rendererPackageName,rendererConfig:_.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:i.ReactCurrentDispatcher,findHostInstanceByFiber:ou,findFiberByHostInstance:_.findFiberByHostInstance||dp,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.0.0-fc46dba67-20220329"},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u")_=!1;else{var x=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(x.isDisabled||!x.supportsFiber)_=!0;else{try{ha=x.inject(_),To=x}catch{}_=!!x.checkDCE}}return _},n.isAlreadyRendering=function(){return!1},n.observeVisibleRects=function(_,x,L,N){if(!li)throw Error(m(363));_=Xt(_,x);var Z=Sn(_,L,N).disconnect;return{disconnect:function(){Z()}}},n.registerMutableSourceForHydration=function(_,x){var L=x._getVersion;L=L(x._source),_.mutableSourceEagerHydrationData==null?_.mutableSourceEagerHydrationData=[x,L]:_.mutableSourceEagerHydrationData.push(x,L)},n.runWithPriority=function(_,x){var L=di;try{return di=_,x()}finally{di=L}},n.shouldError=function(){return null},n.shouldSuspend=function(){return!1},n.updateContainer=function(_,x,L,N){var Z=x.current,ee=Xr(),Pe=wo(Z);return L=$a(L),x.context===null?x.context=L:x.pendingContext=L,x=Cs(ee,Pe),x.payload={element:_},N=N===void 0?null:N,N!==null&&(x.callback=N),Go(Z,x),_=Ls(Z,Pe,ee),_!==null&&Fl(_,Z,Pe),Pe},n};(function(d){d.exports=FF})(r2);const BF=Qx(r2.exports),NF=d=>typeof d=="object"&&typeof d.then=="function",Qh=[];function o2(d,e,n=(a,c)=>a===c){if(d===e)return!0;if(!d||!e)return!1;const a=d.length;if(e.length!==a)return!1;for(let c=0;c<a;c++)if(!n(d[c],e[c]))return!1;return!0}function a2(d,e=null,n=!1,a={}){e===null&&(e=[d]);for(const f of Qh)if(o2(e,f.keys,f.equal)){if(n)return;if(Object.prototype.hasOwnProperty.call(f,"error"))throw f.error;if(Object.prototype.hasOwnProperty.call(f,"response"))return a.lifespan&&a.lifespan>0&&(f.timeout&&clearTimeout(f.timeout),f.timeout=setTimeout(f.remove,a.lifespan)),f.response;if(!n)throw f.promise}const c={keys:e,equal:a.equal,remove:()=>{const f=Qh.indexOf(c);f!==-1&&Qh.splice(f,1)},promise:(NF(d)?d:d(...e)).then(f=>{c.response=f,a.lifespan&&a.lifespan>0&&(c.timeout=setTimeout(c.remove,a.lifespan))}).catch(f=>c.error=f)};if(Qh.push(c),!n)throw c.promise}const UF=(d,e,n)=>a2(d,e,!1,n),VF=(d,e,n)=>void a2(d,e,!0,n),GF=d=>{if(d===void 0||d.length===0)Qh.splice(0,Qh.length);else{const e=Qh.find(n=>o2(d,n.keys,n.equal));e&&e.remove()}},jv={},jF=d=>void Object.assign(jv,d);function WF(d,e){function n(C,{args:T=[],attach:I,...k},O){let B=`${C[0].toUpperCase()}${C.slice(1)}`,F;if(C==="primitive"){if(k.object===void 0)throw new Error("R3F: Primitives without 'object' are invalid!");const H=k.object;F=Af(H,{type:C,root:O,attach:I,primitive:!0})}else{const H=jv[B];if(!H)throw new Error(`R3F: ${B} is not part of the THREE namespace! Did you forget to extend? See: https://docs.pmnd.rs/react-three-fiber/api/objects#using-3rd-party-objects-declaratively`);if(!Array.isArray(T))throw new Error("R3F: The args prop must be an array!");F=Af(new H(...T),{type:C,root:O,attach:I,memoizedProps:{args:T}})}return F.__r3f.attach===void 0&&(F instanceof qi?F.__r3f.attach="geometry":F instanceof fo&&(F.__r3f.attach="material")),B!=="inject"&&Z0(F,k),F}function a(C,T){let I=!1;if(T){var k,O;(k=T.__r3f)!=null&&k.attach?q0(C,T,T.__r3f.attach):T.isObject3D&&C.isObject3D&&(C.add(T),I=!0),I||(O=C.__r3f)==null||O.objects.push(T),T.__r3f||Af(T,{}),T.__r3f.parent=C,Hx(T),Cf(T)}}function c(C,T,I){let k=!1;if(T){var O,B;if((O=T.__r3f)!=null&&O.attach)q0(C,T,T.__r3f.attach);else if(T.isObject3D&&C.isObject3D){T.parent=C,T.dispatchEvent({type:"added"});const F=C.children.filter(Y=>Y!==T),H=F.indexOf(I);C.children=[...F.slice(0,H),T,...F.slice(H)],k=!0}k||(B=C.__r3f)==null||B.objects.push(T),T.__r3f||Af(T,{}),T.__r3f.parent=C,Hx(T),Cf(T)}}function f(C,T,I=!1){C&&[...C].forEach(k=>m(T,k,I))}function m(C,T,I){if(T){var k,O,B;if(T.__r3f&&(T.__r3f.parent=null),(k=C.__r3f)!=null&&k.objects&&(C.__r3f.objects=C.__r3f.objects.filter(ne=>ne!==T)),(O=T.__r3f)!=null&&O.attach)YS(C,T,T.__r3f.attach);else if(T.isObject3D&&C.isObject3D){var F;C.remove(T),(F=T.__r3f)!=null&&F.root&&QF(T.__r3f.root,T)}const Y=(B=T.__r3f)==null?void 0:B.primitive,K=I===void 0?T.dispose!==null&&!Y:I;if(!Y){var H;f((H=T.__r3f)==null?void 0:H.objects,T,K),f(T.children,T,K)}delete T.__r3f,K&&T.dispose&&T.type!=="Scene"&&S_.exports.unstable_scheduleCallback(S_.exports.unstable_IdlePriority,()=>{try{T.dispose()}catch{}}),Cf(C)}}function i(C,T,I,k){var O;const B=(O=C.__r3f)==null?void 0:O.parent;if(!B)return;const F=n(T,I,C.__r3f.root);if(C.children){for(const H of C.children)H.__r3f&&a(F,H);C.children=C.children.filter(H=>!H.__r3f)}C.__r3f.objects.forEach(H=>a(F,H)),C.__r3f.objects=[],C.__r3f.autoRemovedBeforeAppend||m(B,C),F.parent&&(F.__r3f.autoRemovedBeforeAppend=!0),a(B,F),F.raycast&&F.__r3f.eventCount&&F.__r3f.root.getState().internal.interaction.push(F),[k,k.alternate].forEach(H=>{H!==null&&(H.stateNode=F,H.ref&&(typeof H.ref=="function"?H.ref(F):H.ref.current=F))})}const w=()=>console.warn("Text is not allowed in the R3F tree! This could be stray whitespace or characters.");return{reconciler:BF({createInstance:n,removeChild:m,appendChild:a,appendInitialChild:a,insertBefore:c,supportsMutation:!0,isPrimaryRenderer:!1,supportsPersistence:!1,supportsHydration:!1,noTimeout:-1,appendChildToContainer:(C,T)=>{if(!T)return;const I=C.getState().scene;!I.__r3f||(I.__r3f.root=C,a(I,T))},removeChildFromContainer:(C,T)=>{!T||m(C.getState().scene,T)},insertInContainerBefore:(C,T,I)=>{if(!T||!I)return;const k=C.getState().scene;!k.__r3f||c(k,T,I)},getRootHostContext:()=>null,getChildHostContext:C=>C,finalizeInitialChildren(C){var T;const I=(T=C==null?void 0:C.__r3f)!=null?T:{};return Boolean(I.handlers)},prepareUpdate(C,T,I,k){var O;if(((O=C==null?void 0:C.__r3f)!=null?O:{}).primitive&&k.object&&k.object!==C)return[!0];{const{args:F=[],children:H,...Y}=k,{args:K=[],children:ne,...le}=I;if(!Array.isArray(F))throw new Error("R3F: the args prop must be an array!");if(F.some((Ae,oe)=>Ae!==K[oe]))return[!0];const fe=p2(C,Y,le,!0);return fe.changes.length?[!1,fe]:null}},commitUpdate(C,[T,I],k,O,B,F){T?i(C,k,B,F):Z0(C,I)},commitMount(C,T,I,k){var O;const B=(O=C.__r3f)!=null?O:{};C.raycast&&B.handlers&&B.eventCount&&C.__r3f.root.getState().internal.interaction.push(C)},getPublicInstance:C=>C,prepareForCommit:()=>null,preparePortalMount:C=>Af(C.getState().scene),resetAfterCommit:()=>{},shouldSetTextContent:()=>!1,clearContainer:()=>!1,hideInstance(C){var T;const{attach:I,parent:k}=(T=C.__r3f)!=null?T:{};I&&k&&YS(k,C,I),C.isObject3D&&(C.visible=!1),Cf(C)},unhideInstance(C,T){var I;const{attach:k,parent:O}=(I=C.__r3f)!=null?I:{};k&&O&&q0(O,C,k),(C.isObject3D&&T.visible==null||T.visible)&&(C.visible=!0),Cf(C)},createTextInstance:w,hideTextInstance:w,unhideTextInstance:w,getCurrentEventPriority:()=>e?e():Kh.exports.DefaultEventPriority,beforeActiveInstanceBlur:()=>{},afterActiveInstanceBlur:()=>{},detachDeletedInstance:()=>{},now:typeof performance<"u"&&ss.fun(performance.now)?performance.now:ss.fun(Date.now)?Date.now:()=>0,scheduleTimeout:ss.fun(setTimeout)?setTimeout:void 0,cancelTimeout:ss.fun(clearTimeout)?clearTimeout:void 0}),applyProps:Z0}}var qS,ZS;const H0=d=>"colorSpace"in d||"outputColorSpace"in d,l2=()=>{var d;return(d=jv.ColorManagement)!=null?d:null},c2=d=>d&&d.isOrthographicCamera,HF=d=>d&&d.hasOwnProperty("current"),Cm=typeof window<"u"&&((qS=window.document)!=null&&qS.createElement||((ZS=window.navigator)==null?void 0:ZS.product)==="ReactNative")?Ye.exports.useLayoutEffect:Ye.exports.useEffect;function u2(d){const e=Ye.exports.useRef(d);return Cm(()=>void(e.current=d),[d]),e}function qF({set:d}){return Cm(()=>(d(new Promise(()=>null)),()=>d(!1)),[d]),null}class h2 extends Ye.exports.Component{constructor(...e){super(...e),this.state={error:!1}}componentDidCatch(e){this.props.set(e)}render(){return this.state.error?null:this.props.children}}h2.getDerivedStateFromError=()=>({error:!0});const d2="__default",XS=new Map,ZF=d=>d&&!!d.memoized&&!!d.changes;function f2(d){var e;const n=typeof window<"u"?(e=window.devicePixelRatio)!=null?e:2:1;return Array.isArray(d)?Math.min(Math.max(d[0],n),d[1]):d}const $p=d=>{var e;return(e=d.__r3f)==null?void 0:e.root.getState()},ss={obj:d=>d===Object(d)&&!ss.arr(d)&&typeof d!="function",fun:d=>typeof d=="function",str:d=>typeof d=="string",num:d=>typeof d=="number",boo:d=>typeof d=="boolean",und:d=>d===void 0,arr:d=>Array.isArray(d),equ(d,e,{arrays:n="shallow",objects:a="reference",strict:c=!0}={}){if(typeof d!=typeof e||!!d!=!!e)return!1;if(ss.str(d)||ss.num(d))return d===e;const f=ss.obj(d);if(f&&a==="reference")return d===e;const m=ss.arr(d);if(m&&n==="reference")return d===e;if((m||f)&&d===e)return!0;let i;for(i in d)if(!(i in e))return!1;if(f&&n==="shallow"&&a==="shallow"){for(i in c?e:d)if(!ss.equ(d[i],e[i],{strict:c,objects:"reference"}))return!1}else for(i in c?e:d)if(d[i]!==e[i])return!1;if(ss.und(i)){if(m&&d.length===0&&e.length===0||f&&Object.keys(d).length===0&&Object.keys(e).length===0)return!0;if(d!==e)return!1}return!0}};function XF(d){const e={nodes:{},materials:{}};return d&&d.traverse(n=>{n.name&&(e.nodes[n.name]=n),n.material&&!e.materials[n.material.name]&&(e.materials[n.material.name]=n.material)}),e}function $F(d){d.dispose&&d.type!=="Scene"&&d.dispose();for(const e in d)e.dispose==null||e.dispose(),delete d[e]}function Af(d,e){const n=d;return n.__r3f={type:"",root:null,previousAttach:null,memoizedProps:{},eventCount:0,handlers:{},objects:[],parent:null,...e},d}function Wx(d,e){let n=d;if(e.includes("-")){const a=e.split("-"),c=a.pop();return n=a.reduce((f,m)=>f[m],d),{target:n,key:c}}else return{target:n,key:e}}const $S=/-\d+$/;function q0(d,e,n){if(ss.str(n)){if($S.test(n)){const f=n.replace($S,""),{target:m,key:i}=Wx(d,f);Array.isArray(m[i])||(m[i]=[])}const{target:a,key:c}=Wx(d,n);e.__r3f.previousAttach=a[c],a[c]=e}else e.__r3f.previousAttach=n(d,e)}function YS(d,e,n){var a,c;if(ss.str(n)){const{target:f,key:m}=Wx(d,n),i=e.__r3f.previousAttach;i===void 0?delete f[m]:f[m]=i}else(a=e.__r3f)==null||a.previousAttach==null||a.previousAttach(d,e);(c=e.__r3f)==null||delete c.previousAttach}function p2(d,{children:e,key:n,ref:a,...c},{children:f,key:m,ref:i,...w}={},E=!1){var C;const T=(C=d==null?void 0:d.__r3f)!=null?C:{},I=Object.entries(c),k=[];if(E){const B=Object.keys(w);for(let F=0;F<B.length;F++)c.hasOwnProperty(B[F])||I.unshift([B[F],d2+"remove"])}I.forEach(([B,F])=>{var H;if((H=d.__r3f)!=null&&H.primitive&&B==="object"||ss.equ(F,w[B]))return;if(/^on(Pointer|Click|DoubleClick|ContextMenu|Wheel)/.test(B))return k.push([B,F,!0,[]]);let Y=[];B.includes("-")&&(Y=B.split("-")),k.push([B,F,!1,Y]);for(const K in c){const ne=c[K];K.startsWith(`${B}-`)&&k.push([K,ne,!1,K.split("-")])}});const O={...c};return T.memoizedProps&&T.memoizedProps.args&&(O.args=T.memoizedProps.args),T.memoizedProps&&T.memoizedProps.attach&&(O.attach=T.memoizedProps.attach),{memoized:O,changes:k}}const YF=typeof process<"u"&&!1;function Z0(d,e){var n,a,c;const f=(n=d.__r3f)!=null?n:{},m=f.root,i=(a=m==null||m.getState==null?void 0:m.getState())!=null?a:{},{memoized:w,changes:E}=ZF(e)?e:p2(d,e),C=f.eventCount;d.__r3f&&(d.__r3f.memoizedProps=w);for(let I=0;I<E.length;I++){let[k,O,B,F]=E[I];if(H0(d)){const ne="srgb",le="srgb-linear";k==="encoding"?(k="colorSpace",O=O===3001?ne:le):k==="outputEncoding"&&(k="outputColorSpace",O=O===3001?ne:le)}let H=d,Y=H[k];if(F.length&&(Y=F.reduce((K,ne)=>K[ne],d),!(Y&&Y.set))){const[K,...ne]=F.reverse();H=ne.reverse().reduce((le,fe)=>le[fe],d),k=K}if(O===d2+"remove")if(H.constructor){let K=XS.get(H.constructor);K||(K=new H.constructor,XS.set(H.constructor,K)),O=K[k]}else O=0;if(B)O?f.handlers[k]=O:delete f.handlers[k],f.eventCount=Object.keys(f.handlers).length;else if(Y&&Y.set&&(Y.copy||Y instanceof rd)){if(Array.isArray(O))Y.fromArray?Y.fromArray(O):Y.set(...O);else if(Y.copy&&O&&O.constructor&&(YF?Y.constructor.name===O.constructor.name:Y.constructor===O.constructor))Y.copy(O);else if(O!==void 0){const K=Y instanceof Kn;!K&&Y.setScalar?Y.setScalar(O):Y instanceof rd&&O instanceof rd?Y.mask=O.mask:Y.set(O),!l2()&&!i.linear&&K&&Y.convertSRGBToLinear()}}else if(H[k]=O,H[k]instanceof ho&&H[k].format===Qa&&H[k].type===wu){const K=H[k];H0(K)&&H0(i.gl)?K.colorSpace=i.gl.outputColorSpace:K.encoding=i.gl.outputEncoding}Cf(d)}if(f.parent&&i.internal&&d.raycast&&C!==f.eventCount){const I=i.internal.interaction.indexOf(d);I>-1&&i.internal.interaction.splice(I,1),f.eventCount&&i.internal.interaction.push(d)}return!(E.length===1&&E[0][0]==="onUpdate")&&E.length&&(c=d.__r3f)!=null&&c.parent&&Hx(d),d}function Cf(d){var e,n;const a=(e=d.__r3f)==null||(n=e.root)==null||n.getState==null?void 0:n.getState();a&&a.internal.frames===0&&a.invalidate()}function Hx(d){d.onUpdate==null||d.onUpdate(d)}function JF(d,e){d.manual||(c2(d)?(d.left=e.width/-2,d.right=e.width/2,d.top=e.height/2,d.bottom=e.height/-2):d.aspect=e.width/e.height,d.updateProjectionMatrix(),d.updateMatrixWorld())}function n_(d){return(d.eventObject||d.object).uuid+"/"+d.index+d.instanceId}function KF(){var d;const e=typeof self<"u"&&self||typeof window<"u"&&window;if(!e)return Kh.exports.DefaultEventPriority;switch((d=e.event)==null?void 0:d.type){case"click":case"contextmenu":case"dblclick":case"pointercancel":case"pointerdown":case"pointerup":return Kh.exports.DiscreteEventPriority;case"pointermove":case"pointerout":case"pointerover":case"pointerenter":case"pointerleave":case"wheel":return Kh.exports.ContinuousEventPriority;default:return Kh.exports.DefaultEventPriority}}function m2(d,e,n,a){const c=n.get(e);c&&(n.delete(e),n.size===0&&(d.delete(a),c.target.releasePointerCapture(a)))}function QF(d,e){const{internal:n}=d.getState();n.interaction=n.interaction.filter(a=>a!==e),n.initialHits=n.initialHits.filter(a=>a!==e),n.hovered.forEach((a,c)=>{(a.eventObject===e||a.object===e)&&n.hovered.delete(c)}),n.capturedMap.forEach((a,c)=>{m2(n.capturedMap,e,a,c)})}function eB(d){function e(w){const{internal:E}=d.getState(),C=w.offsetX-E.initialClick[0],T=w.offsetY-E.initialClick[1];return Math.round(Math.sqrt(C*C+T*T))}function n(w){return w.filter(E=>["Move","Over","Enter","Out","Leave"].some(C=>{var T;return(T=E.__r3f)==null?void 0:T.handlers["onPointer"+C]}))}function a(w,E){const C=d.getState(),T=new Set,I=[],k=E?E(C.internal.interaction):C.internal.interaction;for(let H=0;H<k.length;H++){const Y=$p(k[H]);Y&&(Y.raycaster.camera=void 0)}C.previousRoot||C.events.compute==null||C.events.compute(w,C);function O(H){const Y=$p(H);if(!Y||!Y.events.enabled||Y.raycaster.camera===null)return[];if(Y.raycaster.camera===void 0){var K;Y.events.compute==null||Y.events.compute(w,Y,(K=Y.previousRoot)==null?void 0:K.getState()),Y.raycaster.camera===void 0&&(Y.raycaster.camera=null)}return Y.raycaster.camera?Y.raycaster.intersectObject(H,!0):[]}let B=k.flatMap(O).sort((H,Y)=>{const K=$p(H.object),ne=$p(Y.object);return!K||!ne?H.distance-Y.distance:ne.events.priority-K.events.priority||H.distance-Y.distance}).filter(H=>{const Y=n_(H);return T.has(Y)?!1:(T.add(Y),!0)});C.events.filter&&(B=C.events.filter(B,C));for(const H of B){let Y=H.object;for(;Y;){var F;(F=Y.__r3f)!=null&&F.eventCount&&I.push({...H,eventObject:Y}),Y=Y.parent}}if("pointerId"in w&&C.internal.capturedMap.has(w.pointerId))for(let H of C.internal.capturedMap.get(w.pointerId).values())T.has(n_(H.intersection))||I.push(H.intersection);return I}function c(w,E,C,T){const I=d.getState();if(w.length){const k={stopped:!1};for(const O of w){const B=$p(O.object)||I,{raycaster:F,pointer:H,camera:Y,internal:K}=B,ne=new Me(H.x,H.y,0).unproject(Y),le=Re=>{var ke,Xe;return(ke=(Xe=K.capturedMap.get(Re))==null?void 0:Xe.has(O.eventObject))!=null?ke:!1},fe=Re=>{const ke={intersection:O,target:E.target};K.capturedMap.has(Re)?K.capturedMap.get(Re).set(O.eventObject,ke):K.capturedMap.set(Re,new Map([[O.eventObject,ke]])),E.target.setPointerCapture(Re)},Ae=Re=>{const ke=K.capturedMap.get(Re);ke&&m2(K.capturedMap,O.eventObject,ke,Re)};let oe={};for(let Re in E){let ke=E[Re];typeof ke!="function"&&(oe[Re]=ke)}let ce={...O,...oe,pointer:H,intersections:w,stopped:k.stopped,delta:C,unprojectedPoint:ne,ray:F.ray,camera:Y,stopPropagation(){const Re="pointerId"in E&&K.capturedMap.get(E.pointerId);if((!Re||Re.has(O.eventObject))&&(ce.stopped=k.stopped=!0,K.hovered.size&&Array.from(K.hovered.values()).find(ke=>ke.eventObject===O.eventObject))){const ke=w.slice(0,w.indexOf(O));f([...ke,O])}},target:{hasPointerCapture:le,setPointerCapture:fe,releasePointerCapture:Ae},currentTarget:{hasPointerCapture:le,setPointerCapture:fe,releasePointerCapture:Ae},nativeEvent:E};if(T(ce),k.stopped===!0)break}}return w}function f(w){const{internal:E}=d.getState();for(const C of E.hovered.values())if(!w.length||!w.find(T=>T.object===C.object&&T.index===C.index&&T.instanceId===C.instanceId)){const I=C.eventObject.__r3f,k=I==null?void 0:I.handlers;if(E.hovered.delete(n_(C)),I!=null&&I.eventCount){const O={...C,intersections:w};k.onPointerOut==null||k.onPointerOut(O),k.onPointerLeave==null||k.onPointerLeave(O)}}}function m(w,E){for(let C=0;C<E.length;C++){const T=E[C].__r3f;T==null||T.handlers.onPointerMissed==null||T.handlers.onPointerMissed(w)}}function i(w){switch(w){case"onPointerLeave":case"onPointerCancel":return()=>f([]);case"onLostPointerCapture":return E=>{const{internal:C}=d.getState();"pointerId"in E&&C.capturedMap.has(E.pointerId)&&requestAnimationFrame(()=>{C.capturedMap.has(E.pointerId)&&(C.capturedMap.delete(E.pointerId),f([]))})}}return function(C){const{onPointerMissed:T,internal:I}=d.getState();I.lastEvent.current=C;const k=w==="onPointerMove",O=w==="onClick"||w==="onContextMenu"||w==="onDoubleClick",F=a(C,k?n:void 0),H=O?e(C):0;w==="onPointerDown"&&(I.initialClick=[C.offsetX,C.offsetY],I.initialHits=F.map(K=>K.eventObject)),O&&!F.length&&H<=2&&(m(C,I.interaction),T&&T(C)),k&&f(F);function Y(K){const ne=K.eventObject,le=ne.__r3f,fe=le==null?void 0:le.handlers;if(!!(le!=null&&le.eventCount))if(k){if(fe.onPointerOver||fe.onPointerEnter||fe.onPointerOut||fe.onPointerLeave){const Ae=n_(K),oe=I.hovered.get(Ae);oe?oe.stopped&&K.stopPropagation():(I.hovered.set(Ae,K),fe.onPointerOver==null||fe.onPointerOver(K),fe.onPointerEnter==null||fe.onPointerEnter(K))}fe.onPointerMove==null||fe.onPointerMove(K)}else{const Ae=fe[w];Ae?(!O||I.initialHits.includes(ne))&&(m(C,I.interaction.filter(oe=>!I.initialHits.includes(oe))),Ae(K)):O&&I.initialHits.includes(ne)&&m(C,I.interaction.filter(oe=>!I.initialHits.includes(oe)))}}c(F,C,H,Y)}}return{handlePointer:i}}const g2=d=>!!(d!=null&&d.render),_2=Ye.exports.createContext(null),tB=(d,e)=>{const n=OF((i,w)=>{const E=new Me,C=new Me,T=new Me;function I(H=w().camera,Y=C,K=w().size){const{width:ne,height:le,top:fe,left:Ae}=K,oe=ne/le;Y instanceof Me?T.copy(Y):T.set(...Y);const ce=H.getWorldPosition(E).distanceTo(T);if(c2(H))return{width:ne/H.zoom,height:le/H.zoom,top:fe,left:Ae,factor:1,distance:ce,aspect:oe};{const Re=H.fov*Math.PI/180,ke=2*Math.tan(Re/2)*ce,Xe=ke*(ne/le);return{width:Xe,height:ke,top:fe,left:Ae,factor:ne/Xe,distance:ce,aspect:oe}}}let k;const O=H=>i(Y=>({performance:{...Y.performance,current:H}})),B=new tn;return{set:i,get:w,gl:null,camera:null,raycaster:null,events:{priority:1,enabled:!0,connected:!1},xr:null,scene:null,invalidate:(H=1)=>d(w(),H),advance:(H,Y)=>e(H,Y,w()),legacy:!1,linear:!1,flat:!1,controls:null,clock:new Bv,pointer:B,mouse:B,frameloop:"always",onPointerMissed:void 0,performance:{current:1,min:.5,max:1,debounce:200,regress:()=>{const H=w();k&&clearTimeout(k),H.performance.current!==H.performance.min&&O(H.performance.min),k=setTimeout(()=>O(w().performance.max),H.performance.debounce)}},size:{width:0,height:0,top:0,left:0,updateStyle:!1},viewport:{initialDpr:0,dpr:0,width:0,height:0,top:0,left:0,aspect:0,distance:0,factor:0,getCurrentViewport:I},setEvents:H=>i(Y=>({...Y,events:{...Y.events,...H}})),setSize:(H,Y,K,ne,le)=>{const fe=w().camera,Ae={width:H,height:Y,top:ne||0,left:le||0,updateStyle:K};i(oe=>({size:Ae,viewport:{...oe.viewport,...I(fe,C,Ae)}}))},setDpr:H=>i(Y=>{const K=f2(H);return{viewport:{...Y.viewport,dpr:K,initialDpr:Y.viewport.initialDpr||K}}}),setFrameloop:(H="always")=>{const Y=w().clock;Y.stop(),Y.elapsedTime=0,H!=="never"&&(Y.start(),Y.elapsedTime=0),i(()=>({frameloop:H}))},previousRoot:void 0,internal:{active:!1,priority:0,frames:0,lastEvent:Ye.exports.createRef(),interaction:[],hovered:new Map,subscribers:[],initialClick:[0,0],initialHits:[],capturedMap:new Map,subscribe:(H,Y,K)=>{const ne=w().internal;return ne.priority=ne.priority+(Y>0?1:0),ne.subscribers.push({ref:H,priority:Y,store:K}),ne.subscribers=ne.subscribers.sort((le,fe)=>le.priority-fe.priority),()=>{const le=w().internal;le!=null&&le.subscribers&&(le.priority=le.priority-(Y>0?1:0),le.subscribers=le.subscribers.filter(fe=>fe.ref!==H))}}}}}),a=n.getState();let c=a.size,f=a.viewport.dpr,m=a.camera;return n.subscribe(()=>{const{camera:i,size:w,viewport:E,gl:C,set:T}=n.getState();if(w!==c||E.dpr!==f){var I;c=w,f=E.dpr,JF(i,w),C.setPixelRatio(E.dpr);const k=(I=w.updateStyle)!=null?I:typeof HTMLCanvasElement<"u"&&C.domElement instanceof HTMLCanvasElement;C.setSize(w.width,w.height,k)}i!==m&&(m=i,T(k=>({viewport:{...k.viewport,...k.viewport.getCurrentViewport(i)}})))}),n.subscribe(i=>d(i)),n};let i_,nB=new Set,iB=new Set,rB=new Set;function X0(d,e){if(!!d.size)for(const{callback:n}of d.values())n(e)}function Yp(d,e){switch(d){case"before":return X0(nB,e);case"after":return X0(iB,e);case"tail":return X0(rB,e)}}let $0,Y0;function J0(d,e,n){let a=e.clock.getDelta();for(e.frameloop==="never"&&typeof d=="number"&&(a=d-e.clock.elapsedTime,e.clock.oldTime=e.clock.elapsedTime,e.clock.elapsedTime=d),$0=e.internal.subscribers,i_=0;i_<$0.length;i_++)Y0=$0[i_],Y0.ref.current(Y0.store.getState(),a,n);return!e.internal.priority&&e.gl.render&&e.gl.render(e.scene,e.camera),e.internal.frames=Math.max(0,e.internal.frames-1),e.frameloop==="always"?1:e.internal.frames}function sB(d){let e=!1,n,a,c;function f(w){a=requestAnimationFrame(f),e=!0,n=0,Yp("before",w);for(const C of d.values()){var E;c=C.store.getState(),c.internal.active&&(c.frameloop==="always"||c.internal.frames>0)&&!((E=c.gl.xr)!=null&&E.isPresenting)&&(n+=J0(w,c))}if(Yp("after",w),n===0)return Yp("tail",w),e=!1,cancelAnimationFrame(a)}function m(w,E=1){var C;if(!w)return d.forEach(T=>m(T.store.getState()),E);(C=w.gl.xr)!=null&&C.isPresenting||!w.internal.active||w.frameloop==="never"||(w.internal.frames=Math.min(60,w.internal.frames+E),e||(e=!0,requestAnimationFrame(f)))}function i(w,E=!0,C,T){if(E&&Yp("before",w),C)J0(w,C,T);else for(const I of d.values())J0(w,I.store.getState());E&&Yp("after",w)}return{loop:f,invalidate:m,advance:i}}function y2(){const d=Ye.exports.useContext(_2);if(!d)throw new Error("R3F: Hooks can only be used within the Canvas component!");return d}function Bc(d=n=>n,e){return y2()(d,e)}function oB(d,e=0){const n=y2(),a=n.getState().internal.subscribe,c=u2(d);return Cm(()=>a(c,e,n),[e,a,n]),null}const JS=new WeakMap;function x2(d,e){return function(n,...a){let c=JS.get(n);return c||(c=new n,JS.set(n,c)),d&&d(c),Promise.all(a.map(f=>new Promise((m,i)=>c.load(f,w=>{w.scene&&Object.assign(w,XF(w.scene)),m(w)},e,w=>i(new Error(`Could not load ${f}: ${w==null?void 0:w.message}`)))))).finally(()=>c.dispose==null?void 0:c.dispose())}}function Wv(d,e,n,a){const c=Array.isArray(e)?e:[e],f=UF(x2(n,a),[d,...c],{equal:ss.equ});return Array.isArray(e)?f:f[0]}Wv.preload=function(d,e,n){const a=Array.isArray(e)?e:[e];return VF(x2(n),[d,...a])};Wv.clear=function(d,e){const n=Array.isArray(e)?e:[e];return GF([d,...n])};const Jf=new Map,{invalidate:KS,advance:QS}=sB(Jf),{reconciler:M_,applyProps:Mf}=WF(Jf,KF),Ef={objects:"shallow",strict:!1},aB=(d,e)=>{const n=typeof d=="function"?d(e):d;return g2(n)?n:new wv({powerPreference:"high-performance",canvas:e,antialias:!0,alpha:!0,...d})};function lB(d,e){if(e)return e;if(typeof HTMLCanvasElement<"u"&&d instanceof HTMLCanvasElement&&d.parentElement){const{width:n,height:a,top:c,left:f}=d.parentElement.getBoundingClientRect();return{width:n,height:a,top:c,left:f}}else if(typeof OffscreenCanvas<"u"&&d instanceof OffscreenCanvas)return{width:d.width,height:d.height,top:0,left:0};return{width:0,height:0,top:0,left:0}}function cB(d){const e=Jf.get(d),n=e==null?void 0:e.fiber,a=e==null?void 0:e.store;e&&console.warn("R3F.createRoot should only be called once!");const c=typeof reportError=="function"?reportError:console.error,f=a||tB(KS,QS),m=n||M_.createContainer(f,Kh.exports.ConcurrentRoot,null,!1,null,"",c,null);e||Jf.set(d,{fiber:m,store:f});let i,w=!1,E;return{configure(C={}){let{gl:T,size:I,scene:k,events:O,onCreated:B,shadows:F=!1,linear:H=!1,flat:Y=!1,legacy:K=!1,orthographic:ne=!1,frameloop:le="always",dpr:fe=[1,2],performance:Ae,raycaster:oe,camera:ce,onPointerMissed:Re}=C,ke=f.getState(),Xe=ke.gl;ke.gl||ke.set({gl:Xe=aB(T,d)});let St=ke.raycaster;St||ke.set({raycaster:St=new e2});const{params:Je,...It}=oe||{};if(ss.equ(It,St,Ef)||Mf(St,{...It}),ss.equ(Je,St.params,Ef)||Mf(St,{params:{...St.params,...Je}}),!ke.camera||ke.camera===E&&!ss.equ(E,ce,Ef)){E=ce;const xt=ce instanceof Em,Pt=xt?ce:ne?new vu(0,0,0,0,.1,1e3):new ks(75,0,.1,1e3);xt||(Pt.position.z=5,ce&&Mf(Pt,ce),!ke.camera&&!(ce!=null&&ce.rotation)&&Pt.lookAt(0,0,0)),ke.set({camera:Pt})}if(!ke.scene){let xt;k instanceof b_?xt=k:(xt=new b_,k&&Mf(xt,k)),ke.set({scene:Af(xt)})}if(!ke.xr){var ft;const xt=(pn,Mt)=>{const ei=f.getState();ei.frameloop!=="never"&&QS(pn,!0,ei,Mt)},Pt=()=>{const pn=f.getState();pn.gl.xr.enabled=pn.gl.xr.isPresenting,pn.gl.xr.setAnimationLoop(pn.gl.xr.isPresenting?xt:null),pn.gl.xr.isPresenting||KS(pn)},ln={connect(){const pn=f.getState().gl;pn.xr.addEventListener("sessionstart",Pt),pn.xr.addEventListener("sessionend",Pt)},disconnect(){const pn=f.getState().gl;pn.xr.removeEventListener("sessionstart",Pt),pn.xr.removeEventListener("sessionend",Pt)}};typeof((ft=Xe.xr)==null?void 0:ft.addEventListener)=="function"&&ln.connect(),ke.set({xr:ln})}if(Xe.shadowMap){const xt=Xe.shadowMap.enabled,Pt=Xe.shadowMap.type;if(Xe.shadowMap.enabled=!!F,ss.boo(F))Xe.shadowMap.type=Kp;else if(ss.str(F)){var Nt;const ln={basic:eE,percentage:O_,soft:Kp,variance:Xh};Xe.shadowMap.type=(Nt=ln[F])!=null?Nt:Kp}else ss.obj(F)&&Object.assign(Xe.shadowMap,F);(xt!==Xe.shadowMap.enabled||Pt!==Xe.shadowMap.type)&&(Xe.shadowMap.needsUpdate=!0)}const Fe=l2();Fe&&("enabled"in Fe?Fe.enabled=!K:"legacyMode"in Fe&&(Fe.legacyMode=K)),Mf(Xe,{outputEncoding:H?3e3:3001,toneMapping:Y?sc:hv}),ke.legacy!==K&&ke.set(()=>({legacy:K})),ke.linear!==H&&ke.set(()=>({linear:H})),ke.flat!==Y&&ke.set(()=>({flat:Y})),T&&!ss.fun(T)&&!g2(T)&&!ss.equ(T,Xe,Ef)&&Mf(Xe,T),O&&!ke.events.handlers&&ke.set({events:O(f)});const Et=lB(d,I);return ss.equ(Et,ke.size,Ef)||ke.setSize(Et.width,Et.height,Et.updateStyle,Et.top,Et.left),fe&&ke.viewport.dpr!==f2(fe)&&ke.setDpr(fe),ke.frameloop!==le&&ke.setFrameloop(le),ke.onPointerMissed||ke.set({onPointerMissed:Re}),Ae&&!ss.equ(Ae,ke.performance,Ef)&&ke.set(xt=>({performance:{...xt.performance,...Ae}})),i=B,w=!0,this},render(C){return w||this.configure(),M_.updateContainer(Ye.exports.createElement(uB,{store:f,children:C,onCreated:i,rootElement:d}),m,null,()=>{}),f},unmount(){v2(d)}}}function uB({store:d,children:e,onCreated:n,rootElement:a}){return Cm(()=>{const c=d.getState();c.set(f=>({internal:{...f.internal,active:!0}})),n&&n(c),d.getState().events.connected||c.events.connect==null||c.events.connect(a)},[]),Ye.exports.createElement(_2.Provider,{value:d},e)}function v2(d,e){const n=Jf.get(d),a=n==null?void 0:n.fiber;if(a){const c=n==null?void 0:n.store.getState();c&&(c.internal.active=!1),M_.updateContainer(null,a,null,()=>{c&&setTimeout(()=>{try{var f,m,i,w;c.events.disconnect==null||c.events.disconnect(),(f=c.gl)==null||(m=f.renderLists)==null||m.dispose==null||m.dispose(),(i=c.gl)==null||i.forceContextLoss==null||i.forceContextLoss(),(w=c.gl)!=null&&w.xr&&c.xr.disconnect(),$F(c),Jf.delete(d),e&&e(d)}catch{}},500)})}}M_.injectIntoDevTools({bundleType:0,rendererPackageName:"@react-three/fiber",version:Ye.exports.version});var hB=Object.defineProperty,dB=Object.defineProperties,fB=Object.getOwnPropertyDescriptors,eM=Object.getOwnPropertySymbols,pB=Object.prototype.hasOwnProperty,mB=Object.prototype.propertyIsEnumerable,tM=(d,e,n)=>e in d?hB(d,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):d[e]=n,nM=(d,e)=>{for(var n in e||(e={}))pB.call(e,n)&&tM(d,n,e[n]);if(eM)for(var n of eM(e))mB.call(e,n)&&tM(d,n,e[n]);return d},gB=(d,e)=>dB(d,fB(e));function b2(d,e,n){if(!d)return;if(n(d)===!0)return d;let a=e?d.return:d.child;for(;a;){const c=b2(a,e,n);if(c)return c;a=e?null:a.sibling}}function w2(d){try{return Object.defineProperties(d,{_currentRenderer:{get(){return null},set(){}},_currentRenderer2:{get(){return null},set(){}}})}catch{return d}}const Hv=w2(Ye.exports.createContext(null));class S2 extends Ye.exports.Component{render(){return Ye.exports.createElement(Hv.Provider,{value:this._reactInternals},this.props.children)}}const{ReactCurrentOwner:iM,ReactCurrentDispatcher:rM}=Ye.exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function _B(){const d=Ye.exports.useContext(Hv);if(d===null)throw new Error("its-fine: useFiber must be called within a <FiberProvider />!");const e=Ye.exports.useId();return Ye.exports.useMemo(()=>{for(const a of[iM==null?void 0:iM.current,d,d==null?void 0:d.alternate]){if(!a)continue;const c=b2(a,!1,f=>{let m=f.memoizedState;for(;m;){if(m.memoizedState===e)return!0;m=m.next}});if(c)return c}},[d,e])}function yB(){var d,e;const n=_B(),[a]=Ye.exports.useState(()=>new Map);a.clear();let c=n;for(;c;){const f=(d=c.type)==null?void 0:d._context;f&&f!==Hv&&!a.has(f)&&a.set(f,(e=rM==null?void 0:rM.current)==null?void 0:e.readContext(w2(f))),c=c.return}return a}function xB(){const d=yB();return Ye.exports.useMemo(()=>Array.from(d.keys()).reduce((e,n)=>a=>Ye.exports.createElement(e,null,Ye.exports.createElement(n.Provider,gB(nM({},a),{value:d.get(n)}))),e=>Ye.exports.createElement(S2,nM({},e))),[d])}const K0={onClick:["click",!1],onContextMenu:["contextmenu",!1],onDoubleClick:["dblclick",!1],onWheel:["wheel",!0],onPointerDown:["pointerdown",!0],onPointerUp:["pointerup",!0],onPointerLeave:["pointerleave",!0],onPointerMove:["pointermove",!0],onPointerCancel:["pointercancel",!0],onLostPointerCapture:["lostpointercapture",!0]};function vB(d){const{handlePointer:e}=eB(d);return{priority:1,enabled:!0,compute(n,a,c){a.pointer.set(n.offsetX/a.size.width*2-1,-(n.offsetY/a.size.height)*2+1),a.raycaster.setFromCamera(a.pointer,a.camera)},connected:void 0,handlers:Object.keys(K0).reduce((n,a)=>({...n,[a]:e(a)}),{}),update:()=>{var n;const{events:a,internal:c}=d.getState();(n=c.lastEvent)!=null&&n.current&&a.handlers&&a.handlers.onPointerMove(c.lastEvent.current)},connect:n=>{var a;const{set:c,events:f}=d.getState();f.disconnect==null||f.disconnect(),c(m=>({events:{...m.events,connected:n}})),Object.entries((a=f.handlers)!=null?a:[]).forEach(([m,i])=>{const[w,E]=K0[m];n.addEventListener(w,i,{passive:E})})},disconnect:()=>{const{set:n,events:a}=d.getState();if(a.connected){var c;Object.entries((c=a.handlers)!=null?c:[]).forEach(([f,m])=>{if(a&&a.connected instanceof HTMLElement){const[i]=K0[f];a.connected.removeEventListener(i,m)}}),n(f=>({events:{...f.events,connected:void 0}}))}}}}const bB=Ye.exports.forwardRef(function({children:e,fallback:n,resize:a,style:c,gl:f,events:m=vB,eventSource:i,eventPrefix:w,shadows:E,linear:C,flat:T,legacy:I,orthographic:k,frameloop:O,dpr:B,performance:F,raycaster:H,camera:Y,scene:K,onPointerMissed:ne,onCreated:le,...fe},Ae){Ye.exports.useMemo(()=>jF(DF),[]);const oe=xB(),[ce,Re]=MI({scroll:!0,debounce:{scroll:50,resize:0},...a}),ke=Ye.exports.useRef(null),Xe=Ye.exports.useRef(null);Ye.exports.useImperativeHandle(Ae,()=>ke.current);const St=u2(ne),[Je,It]=Ye.exports.useState(!1),[ft,Nt]=Ye.exports.useState(!1);if(Je)throw Je;if(ft)throw ft;const Fe=Ye.exports.useRef(null);Cm(()=>{const tt=ke.current;Re.width>0&&Re.height>0&&tt&&(Fe.current||(Fe.current=cB(tt)),Fe.current.configure({gl:f,events:m,shadows:E,linear:C,flat:T,legacy:I,orthographic:k,frameloop:O,dpr:B,performance:F,raycaster:H,camera:Y,scene:K,size:Re,onPointerMissed:(...Et)=>St.current==null?void 0:St.current(...Et),onCreated:Et=>{Et.events.connect==null||Et.events.connect(i?HF(i)?i.current:i:Xe.current),w&&Et.setEvents({compute:(xt,Pt)=>{const ln=xt[w+"X"],pn=xt[w+"Y"];Pt.pointer.set(ln/Pt.size.width*2-1,-(pn/Pt.size.height)*2+1),Pt.raycaster.setFromCamera(Pt.pointer,Pt.camera)}}),le==null||le(Et)}}),Fe.current.render(Ye.exports.createElement(oe,null,Ye.exports.createElement(h2,{set:Nt},Ye.exports.createElement(Ye.exports.Suspense,{fallback:Ye.exports.createElement(qF,{set:It})},e)))))}),Ye.exports.useEffect(()=>{const tt=ke.current;if(tt)return()=>v2(tt)},[]);const it=i?"none":"auto";return Ye.exports.createElement("div",ev({ref:Xe,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",pointerEvents:it,...c}},fe),Ye.exports.createElement("div",{ref:ce,style:{width:"100%",height:"100%"}},Ye.exports.createElement("canvas",{ref:ke,style:{display:"block"}},n)))}),wB=Ye.exports.forwardRef(function(e,n){return Ye.exports.createElement(S2,null,Ye.exports.createElement(bB,ev({},e,{ref:n})))}),SB=d=>d*(Math.PI/180),Q0=d=>d.map(SB),MB=d=>{let e=0,n=0;for(let a=0;a<d.count;a++){const c=d.getX(a);e=Math.min(c,e),n=Math.max(c,n)}return{min:e,max:n}};var EB=Object.defineProperty,TB=(d,e,n)=>e in d?EB(d,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):d[e]=n,Ui=(d,e,n)=>(TB(d,typeof e!="symbol"?e+"":e,n),n);const r_=new np,sM=new _u,AB=Math.cos(70*(Math.PI/180)),oM=(d,e)=>(d%e+e)%e;class CB extends Mu{constructor(e,n){super(),Ui(this,"object"),Ui(this,"domElement"),Ui(this,"enabled",!0),Ui(this,"target",new Me),Ui(this,"minDistance",0),Ui(this,"maxDistance",1/0),Ui(this,"minZoom",0),Ui(this,"maxZoom",1/0),Ui(this,"minPolarAngle",0),Ui(this,"maxPolarAngle",Math.PI),Ui(this,"minAzimuthAngle",-1/0),Ui(this,"maxAzimuthAngle",1/0),Ui(this,"enableDamping",!1),Ui(this,"dampingFactor",.05),Ui(this,"enableZoom",!0),Ui(this,"zoomSpeed",1),Ui(this,"enableRotate",!0),Ui(this,"rotateSpeed",1),Ui(this,"enablePan",!0),Ui(this,"panSpeed",1),Ui(this,"screenSpacePanning",!0),Ui(this,"keyPanSpeed",7),Ui(this,"zoomToCursor",!1),Ui(this,"autoRotate",!1),Ui(this,"autoRotateSpeed",2),Ui(this,"reverseOrbit",!1),Ui(this,"reverseHorizontalOrbit",!1),Ui(this,"reverseVerticalOrbit",!1),Ui(this,"keys",{LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"}),Ui(this,"mouseButtons",{LEFT:jh.ROTATE,MIDDLE:jh.DOLLY,RIGHT:jh.PAN}),Ui(this,"touches",{ONE:Wh.ROTATE,TWO:Wh.DOLLY_PAN}),Ui(this,"target0"),Ui(this,"position0"),Ui(this,"zoom0"),Ui(this,"_domElementKeyEvents",null),Ui(this,"getPolarAngle"),Ui(this,"getAzimuthalAngle"),Ui(this,"setPolarAngle"),Ui(this,"setAzimuthalAngle"),Ui(this,"getDistance"),Ui(this,"listenToKeyEvents"),Ui(this,"stopListenToKeyEvents"),Ui(this,"saveState"),Ui(this,"reset"),Ui(this,"update"),Ui(this,"connect"),Ui(this,"dispose"),this.object=e,this.domElement=n,this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=()=>C.phi,this.getAzimuthalAngle=()=>C.theta,this.setPolarAngle=We=>{let bt=oM(We,2*Math.PI),un=C.phi;un<0&&(un+=2*Math.PI),bt<0&&(bt+=2*Math.PI);let ue=Math.abs(bt-un);2*Math.PI-ue<ue&&(bt<un?bt+=2*Math.PI:un+=2*Math.PI),T.phi=bt-un,a.update()},this.setAzimuthalAngle=We=>{let bt=oM(We,2*Math.PI),un=C.theta;un<0&&(un+=2*Math.PI),bt<0&&(bt+=2*Math.PI);let ue=Math.abs(bt-un);2*Math.PI-ue<ue&&(bt<un?bt+=2*Math.PI:un+=2*Math.PI),T.theta=bt-un,a.update()},this.getDistance=()=>a.object.position.distanceTo(a.target),this.listenToKeyEvents=We=>{We.addEventListener("keydown",ri),this._domElementKeyEvents=We},this.stopListenToKeyEvents=()=>{this._domElementKeyEvents.removeEventListener("keydown",ri),this._domElementKeyEvents=null},this.saveState=()=>{a.target0.copy(a.target),a.position0.copy(a.object.position),a.zoom0=a.object.zoom},this.reset=()=>{a.target.copy(a.target0),a.object.position.copy(a.position0),a.object.zoom=a.zoom0,a.object.updateProjectionMatrix(),a.dispatchEvent(c),a.update(),w=i.NONE},this.update=(()=>{const We=new Me,bt=new Me(0,1,0),un=new Ko().setFromUnitVectors(e.up,bt),ue=un.clone().invert(),te=new Me,se=new Ko,ye=2*Math.PI;return function(){const je=a.object.position;un.setFromUnitVectors(e.up,bt),ue.copy(un).invert(),We.copy(je).sub(a.target),We.applyQuaternion(un),C.setFromVector3(We),a.autoRotate&&w===i.NONE&&Je(Xe()),a.enableDamping?(C.theta+=T.theta*a.dampingFactor,C.phi+=T.phi*a.dampingFactor):(C.theta+=T.theta,C.phi+=T.phi);let rt=a.minAzimuthAngle,st=a.maxAzimuthAngle;isFinite(rt)&&isFinite(st)&&(rt<-Math.PI?rt+=ye:rt>Math.PI&&(rt-=ye),st<-Math.PI?st+=ye:st>Math.PI&&(st-=ye),rt<=st?C.theta=Math.max(rt,Math.min(st,C.theta)):C.theta=C.theta>(rt+st)/2?Math.max(rt,C.theta):Math.min(st,C.theta)),C.phi=Math.max(a.minPolarAngle,Math.min(a.maxPolarAngle,C.phi)),C.makeSafe(),a.enableDamping===!0?a.target.addScaledVector(k,a.dampingFactor):a.target.add(k),a.zoomToCursor&&ce||a.object.isOrthographicCamera?C.radius=xt(C.radius):C.radius=xt(C.radius*I),We.setFromSpherical(C),We.applyQuaternion(ue),je.copy(a.target).add(We),a.object.lookAt(a.target),a.enableDamping===!0?(T.theta*=1-a.dampingFactor,T.phi*=1-a.dampingFactor,k.multiplyScalar(1-a.dampingFactor)):(T.set(0,0,0),k.set(0,0,0));let He=!1;if(a.zoomToCursor&&ce){let pt=null;if(a.object instanceof ks&&a.object.isPerspectiveCamera){const Zt=We.length();pt=xt(Zt*I);const on=Zt-pt;a.object.position.addScaledVector(Ae,on),a.object.updateMatrixWorld()}else if(a.object.isOrthographicCamera){const Zt=new Me(oe.x,oe.y,0);Zt.unproject(a.object),a.object.zoom=Math.max(a.minZoom,Math.min(a.maxZoom,a.object.zoom/I)),a.object.updateProjectionMatrix(),He=!0;const on=new Me(oe.x,oe.y,0);on.unproject(a.object),a.object.position.sub(on).add(Zt),a.object.updateMatrixWorld(),pt=We.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),a.zoomToCursor=!1;pt!==null&&(a.screenSpacePanning?a.target.set(0,0,-1).transformDirection(a.object.matrix).multiplyScalar(pt).add(a.object.position):(r_.origin.copy(a.object.position),r_.direction.set(0,0,-1).transformDirection(a.object.matrix),Math.abs(a.object.up.dot(r_.direction))<AB?e.lookAt(a.target):(sM.setFromNormalAndCoplanarPoint(a.object.up,a.target),r_.intersectPlane(sM,a.target))))}else a.object instanceof vu&&a.object.isOrthographicCamera&&(a.object.zoom=Math.max(a.minZoom,Math.min(a.maxZoom,a.object.zoom/I)),a.object.updateProjectionMatrix(),He=!0);return I=1,ce=!1,He||te.distanceToSquared(a.object.position)>E||8*(1-se.dot(a.object.quaternion))>E?(a.dispatchEvent(c),te.copy(a.object.position),se.copy(a.object.quaternion),He=!1,!0):!1}})(),this.connect=We=>{We===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),a.domElement=We,a.domElement.style.touchAction="none",a.domElement.addEventListener("contextmenu",On),a.domElement.addEventListener("pointerdown",ti),a.domElement.addEventListener("pointercancel",Tt),a.domElement.addEventListener("wheel",Sn)},this.dispose=()=>{var We,bt,un,ue,te,se;(We=a.domElement)==null||We.removeEventListener("contextmenu",On),(bt=a.domElement)==null||bt.removeEventListener("pointerdown",ti),(un=a.domElement)==null||un.removeEventListener("pointercancel",Tt),(ue=a.domElement)==null||ue.removeEventListener("wheel",Sn),(te=a.domElement)==null||te.ownerDocument.removeEventListener("pointermove",Ie),(se=a.domElement)==null||se.ownerDocument.removeEventListener("pointerup",xe),a._domElementKeyEvents!==null&&a._domElementKeyEvents.removeEventListener("keydown",ri)};const a=this,c={type:"change"},f={type:"start"},m={type:"end"},i={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let w=i.NONE;const E=1e-6,C=new jx,T=new jx;let I=1;const k=new Me,O=new tn,B=new tn,F=new tn,H=new tn,Y=new tn,K=new tn,ne=new tn,le=new tn,fe=new tn,Ae=new Me,oe=new tn;let ce=!1;const Re=[],ke={};function Xe(){return 2*Math.PI/60/60*a.autoRotateSpeed}function St(){return Math.pow(.95,a.zoomSpeed)}function Je(We){a.reverseOrbit||a.reverseHorizontalOrbit?T.theta+=We:T.theta-=We}function It(We){a.reverseOrbit||a.reverseVerticalOrbit?T.phi+=We:T.phi-=We}const ft=(()=>{const We=new Me;return function(un,ue){We.setFromMatrixColumn(ue,0),We.multiplyScalar(-un),k.add(We)}})(),Nt=(()=>{const We=new Me;return function(un,ue){a.screenSpacePanning===!0?We.setFromMatrixColumn(ue,1):(We.setFromMatrixColumn(ue,0),We.crossVectors(a.object.up,We)),We.multiplyScalar(un),k.add(We)}})(),Fe=(()=>{const We=new Me;return function(un,ue){const te=a.domElement;if(te&&a.object instanceof ks&&a.object.isPerspectiveCamera){const se=a.object.position;We.copy(se).sub(a.target);let ye=We.length();ye*=Math.tan(a.object.fov/2*Math.PI/180),ft(2*un*ye/te.clientHeight,a.object.matrix),Nt(2*ue*ye/te.clientHeight,a.object.matrix)}else te&&a.object instanceof vu&&a.object.isOrthographicCamera?(ft(un*(a.object.right-a.object.left)/a.object.zoom/te.clientWidth,a.object.matrix),Nt(ue*(a.object.top-a.object.bottom)/a.object.zoom/te.clientHeight,a.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),a.enablePan=!1)}})();function it(We){a.object instanceof ks&&a.object.isPerspectiveCamera||a.object instanceof vu&&a.object.isOrthographicCamera?I/=We:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),a.enableZoom=!1)}function tt(We){a.object instanceof ks&&a.object.isPerspectiveCamera||a.object instanceof vu&&a.object.isOrthographicCamera?I*=We:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),a.enableZoom=!1)}function Et(We){if(!a.zoomToCursor||!a.domElement)return;ce=!0;const bt=a.domElement.getBoundingClientRect(),un=We.clientX-bt.left,ue=We.clientY-bt.top,te=bt.width,se=bt.height;oe.x=un/te*2-1,oe.y=-(ue/se)*2+1,Ae.set(oe.x,oe.y,1).unproject(a.object).sub(a.object.position).normalize()}function xt(We){return Math.max(a.minDistance,Math.min(a.maxDistance,We))}function Pt(We){O.set(We.clientX,We.clientY)}function ln(We){Et(We),ne.set(We.clientX,We.clientY)}function pn(We){H.set(We.clientX,We.clientY)}function Mt(We){B.set(We.clientX,We.clientY),F.subVectors(B,O).multiplyScalar(a.rotateSpeed);const bt=a.domElement;bt&&(Je(2*Math.PI*F.x/bt.clientHeight),It(2*Math.PI*F.y/bt.clientHeight)),O.copy(B),a.update()}function ei(We){le.set(We.clientX,We.clientY),fe.subVectors(le,ne),fe.y>0?it(St()):fe.y<0&&tt(St()),ne.copy(le),a.update()}function oi(We){Y.set(We.clientX,We.clientY),K.subVectors(Y,H).multiplyScalar(a.panSpeed),Fe(K.x,K.y),H.copy(Y),a.update()}function Wn(We){Et(We),We.deltaY<0?tt(St()):We.deltaY>0&&it(St()),a.update()}function jt(We){let bt=!1;switch(We.code){case a.keys.UP:Fe(0,a.keyPanSpeed),bt=!0;break;case a.keys.BOTTOM:Fe(0,-a.keyPanSpeed),bt=!0;break;case a.keys.LEFT:Fe(a.keyPanSpeed,0),bt=!0;break;case a.keys.RIGHT:Fe(-a.keyPanSpeed,0),bt=!0;break}bt&&(We.preventDefault(),a.update())}function mn(){if(Re.length==1)O.set(Re[0].pageX,Re[0].pageY);else{const We=.5*(Re[0].pageX+Re[1].pageX),bt=.5*(Re[0].pageY+Re[1].pageY);O.set(We,bt)}}function qt(){if(Re.length==1)H.set(Re[0].pageX,Re[0].pageY);else{const We=.5*(Re[0].pageX+Re[1].pageX),bt=.5*(Re[0].pageY+Re[1].pageY);H.set(We,bt)}}function Dt(){const We=Re[0].pageX-Re[1].pageX,bt=Re[0].pageY-Re[1].pageY,un=Math.sqrt(We*We+bt*bt);ne.set(0,un)}function gn(){a.enableZoom&&Dt(),a.enablePan&&qt()}function wn(){a.enableZoom&&Dt(),a.enableRotate&&mn()}function Yt(We){if(Re.length==1)B.set(We.pageX,We.pageY);else{const un=bn(We),ue=.5*(We.pageX+un.x),te=.5*(We.pageY+un.y);B.set(ue,te)}F.subVectors(B,O).multiplyScalar(a.rotateSpeed);const bt=a.domElement;bt&&(Je(2*Math.PI*F.x/bt.clientHeight),It(2*Math.PI*F.y/bt.clientHeight)),O.copy(B)}function rn(We){if(Re.length==1)Y.set(We.pageX,We.pageY);else{const bt=bn(We),un=.5*(We.pageX+bt.x),ue=.5*(We.pageY+bt.y);Y.set(un,ue)}K.subVectors(Y,H).multiplyScalar(a.panSpeed),Fe(K.x,K.y),H.copy(Y)}function dn(We){const bt=bn(We),un=We.pageX-bt.x,ue=We.pageY-bt.y,te=Math.sqrt(un*un+ue*ue);le.set(0,te),fe.set(0,Math.pow(le.y/ne.y,a.zoomSpeed)),it(fe.y),ne.copy(le)}function Mn(We){a.enableZoom&&dn(We),a.enablePan&&rn(We)}function li(We){a.enableZoom&&dn(We),a.enableRotate&&Yt(We)}function ti(We){var bt,un;a.enabled!==!1&&(Re.length===0&&((bt=a.domElement)==null||bt.ownerDocument.addEventListener("pointermove",Ie),(un=a.domElement)==null||un.ownerDocument.addEventListener("pointerup",xe)),Fn(We),We.pointerType==="touch"?kt(We):hn(We))}function Ie(We){a.enabled!==!1&&(We.pointerType==="touch"?Hn(We):_n(We))}function xe(We){var bt,un,ue;Ze(We),Re.length===0&&((bt=a.domElement)==null||bt.releasePointerCapture(We.pointerId),(un=a.domElement)==null||un.ownerDocument.removeEventListener("pointermove",Ie),(ue=a.domElement)==null||ue.ownerDocument.removeEventListener("pointerup",xe)),a.dispatchEvent(m),w=i.NONE}function Tt(We){Ze(We)}function hn(We){let bt;switch(We.button){case 0:bt=a.mouseButtons.LEFT;break;case 1:bt=a.mouseButtons.MIDDLE;break;case 2:bt=a.mouseButtons.RIGHT;break;default:bt=-1}switch(bt){case jh.DOLLY:if(a.enableZoom===!1)return;ln(We),w=i.DOLLY;break;case jh.ROTATE:if(We.ctrlKey||We.metaKey||We.shiftKey){if(a.enablePan===!1)return;pn(We),w=i.PAN}else{if(a.enableRotate===!1)return;Pt(We),w=i.ROTATE}break;case jh.PAN:if(We.ctrlKey||We.metaKey||We.shiftKey){if(a.enableRotate===!1)return;Pt(We),w=i.ROTATE}else{if(a.enablePan===!1)return;pn(We),w=i.PAN}break;default:w=i.NONE}w!==i.NONE&&a.dispatchEvent(f)}function _n(We){if(a.enabled!==!1)switch(w){case i.ROTATE:if(a.enableRotate===!1)return;Mt(We);break;case i.DOLLY:if(a.enableZoom===!1)return;ei(We);break;case i.PAN:if(a.enablePan===!1)return;oi(We);break}}function Sn(We){a.enabled===!1||a.enableZoom===!1||w!==i.NONE&&w!==i.ROTATE||(We.preventDefault(),a.dispatchEvent(f),Wn(We),a.dispatchEvent(m))}function ri(We){a.enabled===!1||a.enablePan===!1||jt(We)}function kt(We){switch(Tn(We),Re.length){case 1:switch(a.touches.ONE){case Wh.ROTATE:if(a.enableRotate===!1)return;mn(),w=i.TOUCH_ROTATE;break;case Wh.PAN:if(a.enablePan===!1)return;qt(),w=i.TOUCH_PAN;break;default:w=i.NONE}break;case 2:switch(a.touches.TWO){case Wh.DOLLY_PAN:if(a.enableZoom===!1&&a.enablePan===!1)return;gn(),w=i.TOUCH_DOLLY_PAN;break;case Wh.DOLLY_ROTATE:if(a.enableZoom===!1&&a.enableRotate===!1)return;wn(),w=i.TOUCH_DOLLY_ROTATE;break;default:w=i.NONE}break;default:w=i.NONE}w!==i.NONE&&a.dispatchEvent(f)}function Hn(We){switch(Tn(We),w){case i.TOUCH_ROTATE:if(a.enableRotate===!1)return;Yt(We),a.update();break;case i.TOUCH_PAN:if(a.enablePan===!1)return;rn(We),a.update();break;case i.TOUCH_DOLLY_PAN:if(a.enableZoom===!1&&a.enablePan===!1)return;Mn(We),a.update();break;case i.TOUCH_DOLLY_ROTATE:if(a.enableZoom===!1&&a.enableRotate===!1)return;li(We),a.update();break;default:w=i.NONE}}function On(We){a.enabled!==!1&&We.preventDefault()}function Fn(We){Re.push(We)}function Ze(We){delete ke[We.pointerId];for(let bt=0;bt<Re.length;bt++)if(Re[bt].pointerId==We.pointerId){Re.splice(bt,1);return}}function Tn(We){let bt=ke[We.pointerId];bt===void 0&&(bt=new tn,ke[We.pointerId]=bt),bt.set(We.pageX,We.pageY)}function bn(We){const bt=We.pointerId===Re[0].pointerId?Re[1]:Re[0];return ke[bt.pointerId]}n!==void 0&&this.connect(n),this.update()}}const IB=Ye.exports.forwardRef(({makeDefault:d,camera:e,regress:n,domElement:a,enableDamping:c=!0,keyEvents:f=!1,onChange:m,onStart:i,onEnd:w,...E},C)=>{const T=Bc(fe=>fe.invalidate),I=Bc(fe=>fe.camera),k=Bc(fe=>fe.gl),O=Bc(fe=>fe.events),B=Bc(fe=>fe.setEvents),F=Bc(fe=>fe.set),H=Bc(fe=>fe.get),Y=Bc(fe=>fe.performance),K=e||I,ne=a||O.connected||k.domElement,le=Ye.exports.useMemo(()=>new CB(K),[K]);return oB(()=>{le.enabled&&le.update()},-1),Ye.exports.useEffect(()=>(f&&le.connect(f===!0?ne:f),le.connect(ne),()=>void le.dispose()),[f,ne,n,le,T]),Ye.exports.useEffect(()=>{const fe=ce=>{T(),n&&Y.regress(),m&&m(ce)},Ae=ce=>{i&&i(ce)},oe=ce=>{w&&w(ce)};return le.addEventListener("change",fe),le.addEventListener("start",Ae),le.addEventListener("end",oe),()=>{le.removeEventListener("start",Ae),le.removeEventListener("end",oe),le.removeEventListener("change",fe)}},[m,i,w,le,T,B]),Ye.exports.useEffect(()=>{if(d){const fe=H().controls;return F({controls:le}),()=>F({controls:fe})}},[d,le]),Ye.exports.createElement("primitive",ev({ref:C,object:le,enableDamping:c},E))}),M2="fiftyone-camera-position",PB=new Me(0,0,0),LB=({cameraRef:d,controlsRef:e,settings:n,isGridOn:a,bounds:c})=>{const f=Bc(O=>O.camera),m=Ye.exports.useMemo(()=>new Me(...n.defaultUp).normalize(),[n]),i=Ye.exports.useMemo(()=>{const O=Math.acos(m.dot(new Me(0,1,0))),B=new Me().crossVectors(new Me(0,1,0),m).normalize();return new Ko().setFromAxisAngle(B,O)},[m]);Ye.exports.useEffect(()=>{d.current=f;const O=()=>{window==null||window.localStorage.setItem(M2,JSON.stringify(f.position.toArray()))},B=e.current;return B==null||B.addEventListener("change",O),()=>{B==null||B.removeEventListener("change",O)}},[f,d,e]);const w=Ye.exports.useMemo(()=>m.equals(new Me(0,0,1)),[m]),E=Ye.exports.useMemo(()=>m.equals(new Me(0,1,0)),[m]),C=Ye.exports.useMemo(()=>m.equals(new Me(1,0,0)),[m]),T=Ye.exports.useMemo(()=>C||E||w,[C,E,w]),I=Ye.exports.useMemo(()=>{var B,F,H,Y,K,ne,le,fe,Ae,oe,ce,Re;let O;if(C)O=Math.max(((B=c==null?void 0:c.max)==null?void 0:B.y)-((F=c==null?void 0:c.min)==null?void 0:F.y),((H=c==null?void 0:c.max)==null?void 0:H.z)-((Y=c==null?void 0:c.min)==null?void 0:Y.z));else if(E)O=Math.max(((K=c==null?void 0:c.max)==null?void 0:K.x)-((ne=c==null?void 0:c.min)==null?void 0:ne.x),((le=c==null?void 0:c.max)==null?void 0:le.z)-((fe=c==null?void 0:c.min)==null?void 0:fe.z));else if(w)O=Math.max(((Ae=c==null?void 0:c.max)==null?void 0:Ae.x)-((oe=c==null?void 0:c.min)==null?void 0:oe.x),((ce=c==null?void 0:c.max)==null?void 0:ce.y)-((Re=c==null?void 0:c.min)==null?void 0:Re.y));else return 100;return isNaN(O)?100:Math.ceil(O*1.1)},[c,C,E,w]),k=Ye.exports.useMemo(()=>{const O=Math.ceil(I/10);return O===1?5:O},[I]);return React.createElement(React.Fragment,null,React.createElement(IB,{ref:e,makeDefault:!0,autoRotateSpeed:2.5,zoomSpeed:.5}),React.createElement("axesHelper",null),!T&&React.createElement("arrowHelper",{args:[m,PB]}),a&&React.createElement("gridHelper",{args:[I,k],quaternion:i}))};var qv={},RB=L_.exports;Object.defineProperty(qv,"__esModule",{value:!0});var E2=qv.default=void 0,DB=RB(I_()),zB=P_(),kB=(0,DB.default)((0,zB.jsx)("path",{d:"M12 3c-4.97 0-9 4.03-9 9s4.03 9 9 9c.83 0 1.5-.67 1.5-1.5 0-.39-.15-.74-.39-1.01-.23-.26-.38-.61-.38-.99 0-.83.67-1.5 1.5-1.5H16c2.76 0 5-2.24 5-5 0-4.42-4.03-8-9-8zm-5.5 9c-.83 0-1.5-.67-1.5-1.5S5.67 9 6.5 9 8 9.67 8 10.5 7.33 12 6.5 12zm3-4C8.67 8 8 7.33 8 6.5S8.67 5 9.5 5s1.5.67 1.5 1.5S10.33 8 9.5 8zm5 0c-.83 0-1.5-.67-1.5-1.5S13.67 5 14.5 5s1.5.67 1.5 1.5S15.33 8 14.5 8zm3 4c-.83 0-1.5-.67-1.5-1.5S16.67 9 17.5 9s1.5.67 1.5 1.5-.67 1.5-1.5 1.5z"}),"ColorLens");E2=qv.default=kB;const Md=Qo.div`
  display: flex;
  align-content: center;
  text-align: center;
  cursor: pointer;
  color: var(--fo-palette-text-secondary);
  -webkit-transition: 0.2s ease-in-out;
  -moz-transition: 0.2s ease-in-out;
  -o-transition: 0.2s ease-in-out;
  transition: 0.2s ease-in-out;

  &:hover {
    transform: translate(0, -1px);
  }
`,OB=Qo.div`
  position: absolute;
  bottom: 0;
  left: 0;
  opacity: 1;
  z-index: 20;
  justify-items: center;
  align-items: center;
  display: flex;

  color: #eee;

  -webkit-transition: opacity 0.5s;
  -moz-transition: opacity 0.5s;
  -o-transition: opacity 0.5s;
  -ms-transition: opacity 0.5s;
  transition: opacity 0.5s;
  width: 100%;

  opacity: 0.95;
  height: 37px;
  background-color: var(--fo-palette-background-level3);
  border: 1px solid var(--fo-palette-primary-plainBorder);
  border-left: 0;
  padding: 0 1rem;
`,FB=Qo.div`
  position: relative;
  display: flex;
  flex-grow: 1;
  justify-content: end;
  row-gap: 0.5rem;
  column-gap: 0.75rem;
  align-items: center;
  height: 2.3rem;
`,BB=Qo.div`
  width: 20rem;
  position: absolute;
  bottom: 2.5rem;
  background-color: var(--fo-palette-background-level2);
  border: 1px solid var(--fo-palette-primary-plainBorder);
  box-shadow: 0 8px 15px 0 var(--fo-palette-neutral-softBg);
  border-radius: 3px;
  color: var(--fo-palette-text-secondary);
  overflow: hidden;
`,NB=Qo.div`
  padding: 0 0.25rem;
`,aM=Qo.div`
  height: 100%;
  width: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
`,UB=Qo.div`
  line-height: 1rem;
  padding: 3px 6px;
  background-color: var(--fo-palette-text-secondary);
  color: var(--fo-palette-text-invert);
  border-radius: 1rem;
  border: none;
  font-weight: bold;
  display: flex;
  justify-content: space-between;
  opacity: 1;
`,lM="shadeBy",cM="setPointSize",ex="setPcds",VB="json",GB="help",T2="intensity",Zv="height",A2="rgb",Xv="custom",jB="none",WB=[{label:"Height",value:Zv},{label:"Intensity",value:T2},{label:"RGB",value:A2},{label:"Custom",value:Xv},{label:"None",value:jB}],C2=Su({key:"shadeBy",default:Zv,effects:[ep("shadeBy")]}),I2=Su({key:"customColorMap",default:null,effects:[ep("customColorMap",{useJsonSerialization:!0})]}),zf=Su({key:"openAction",default:null}),P2=Su({key:"pointSize",default:"2",effects:[ep("pointSize")]});Su({key:"pointSizeRange",default:[.1,2]});const L2=Su({key:"isPointSizeAttenuated",default:!1,effects:[ep("isPointSizeAttenuated",{valueClass:"boolean"})]}),R2=Su({key:"isGridOn",default:!0,effects:[ep("isGridOn",{valueClass:"boolean"})]}),$v=d=>{const{children:e}=d;return React.createElement(BB,null,React.createElement(NB,null,e))},HB=()=>{const[d,e]=Ca(zf);return React.createElement(React.Fragment,null,React.createElement(Md,{title:"Shade By"},React.createElement(E2,{sx:{fontSize:24},color:"inherit",onClick:n=>{const a=lM;return e(d===a?null:a),n.stopPropagation(),n.preventDefault(),!1}})),d===lM&&React.createElement(qB,null))},qB=()=>{const[d,e]=Ca(C2),n=Ye.exports.useCallback(a=>()=>{d!==a&&e(a)},[d,e]);return React.createElement($v,null,React.createElement(tv,null,"Shade by"),d===Xv&&React.createElement(XB,null),React.createElement(EI,{active:d,options:WB.map(({label:a,value:c})=>({text:c,title:`Shade by ${a}`,onClick:n(c)}))}))},uM=Qo.div`
  margin-top: 0.5em;
  margin-right: 0.5em;
  display: flex;
  margin: 0.5em auto;
`,hM=Qo.div`
  width: 100%;
  min-height: 2rem;
  margin: 0.5em 0.5em 0.25em 0.5em;
  background-color: ${d=>d.backgroundColor};
`,ZB=Qo.div`
  display: flex;
  align-items: center;
  margin-left: 0.25em;
`,XB=()=>{const d=TI({from:{opacity:0},to:{opacity:1},config:{duration:400}}),e=yi(nv),n=yi(AI),[a,c]=Ca(I2),[f,m]=Ye.exports.useState(!1),[i,w]=Ye.exports.useState(""),E=Ye.exports.useCallback(C=>({hex:T})=>{c(I=>({...I,[C]:T}))},[c]);if(!n||(e==null?void 0:e.length)<2){const C=(e==null?void 0:e.length)>0?n:"default";return React.createElement(dw.div,{style:{display:"flex",...d}},React.createElement(hM,{backgroundColor:a[C],onClick:()=>m(T=>!T)}),f&&React.createElement(uM,null,React.createElement(fw,{color:a[C],onChange:E(C),disableAlpha:!0})))}return React.createElement(dw.div,{style:{display:"flex",flexDirection:"column",justifyItems:"center",...d}},(i==null?void 0:i.length)>0&&React.createElement(uM,null,React.createElement(fw,{color:a[i],onChange:E(i),disableAlpha:!0})),e.map(C=>React.createElement(ZB,{key:C},React.createElement("span",null,C," "),React.createElement(hM,{backgroundColor:a[C],onClick:()=>{w(T=>T===C?"":C)}}))))},$B="_pointSizeSliderThumb_h0ptu_1",YB="_pointSizeTextField_h0ptu_9",JB="_pointSizeSlider_h0ptu_1",KB="_pointSizeContainer_h0ptu_31",QB="_pointSizeBaseContainer_h0ptu_38",e4="_pointSizeAttenuationLabel_h0ptu_42",Gh={pointSizeSliderThumb:$B,pointSizeTextField:YB,pointSizeSlider:JB,pointSizeContainer:KB,pointSizeBaseContainer:QB,pointSizeAttenuationLabel:e4},t4=new RegExp("^([0-9]+([.][0-9]*)?|[.][0-9]+)$"),n4=()=>{const d=gd(),[e,n]=Ca(P2),[a,c]=Ca(L2),f=Ye.exports.useMemo(()=>Number(e),[e]),[m,i]=Ye.exports.useState(f/10),[w,E]=Ye.exports.useState(()=>f===0?2:f*2),[C,T]=Ye.exports.useState(!1),I=Ye.exports.useMemo(()=>f===0?.01:f/10,[m,w]),k=Ye.exports.useCallback((F,H)=>{n(String(H)),T(!1)},[n]),O=Ye.exports.useCallback(F=>{if(!t4.test(F.target.value)){T(!0);return}T(!1);const H=F.target.value;n(H),i(Number(H)/10),parseInt(H)===0?E(2):E(Number(H)*2)},[n,T]),B=Ye.exports.useCallback(F=>{c(F.target.checked)},[c]);return React.createElement($v,null,React.createElement(tv,null,"Set point size"),React.createElement("div",{className:Gh.pointSizeBaseContainer},React.createElement(CI,{control:React.createElement(II,{checked:a,size:"small",disableFocusRipple:!0,onChange:B}),classes:{label:Gh.pointSizeAttenuationLabel},label:"Point Size Attenuation"}),React.createElement("div",{className:Gh.pointSizeContainer},React.createElement(PI,{className:Gh.pointSizeSlider,sx:{color:d.primary.main},classes:{thumb:Gh.pointSizeSliderThumb,dragging:Gh.pointSizeSliderThumb},value:f,min:m,step:I,max:w,onChange:k,valueLabelDisplay:"auto",valueLabelFormat:F=>`${F.toFixed(2)}`}),React.createElement("input",{className:Gh.pointSizeTextField,value:C?"":e,onChange:O}))))},i4=()=>{const[d,e]=Ca(zf),n=Ye.exports.useCallback(a=>{const c=cM;return e(f=>f===c?null:c),a.stopPropagation(),a.preventDefault(),!1},[e]);return React.createElement(React.Fragment,null,React.createElement(Md,{title:"Set Point Size"},React.createElement(rv,{sx:{fontSize:24},color:"inherit",onClick:n})),d===cM&&React.createElement(n4,null))},r4=()=>{const{gl:d,scene:e,camera:n}=Bc();return GM(()=>new Promise(a=>{d.render(e,n),a(d.domElement)})),null},dM=d=>{const{onChangeView:e,view:n,label:a,hint:c}=d;return React.createElement(Md,{onClick:()=>e(n)},React.createElement(UB,{title:c},a))},s4=()=>{const d=yi(nv),e=yi(jM),[n,a]=Ca(zf),c=Ye.exports.useMemo(()=>!d||d.length===0?"":d.length===1?`Showing ${d[0]}`:d.length===2?`Showing ${d.join(" and ")}`:d.length===e.length?"Showing all point clouds":`Showing ${d.length} point clouds`,[d,e]),f=Ye.exports.useCallback(()=>{a(n===ex?null:ex)},[a,n]);return!d||d.length===0?null:React.createElement(React.Fragment,null,React.createElement(Md,{"data-cy":"looker3d-select-slices",title:"Select point clouds"},React.createElement("div",{onClick:f},c)),n===ex&&React.createElement(o4,null))},o4=()=>{const[d,e]=Ca(nv),n=Object.keys(yi(LI)),a=Ye.exports.useRef(null),[c,f]=Ye.exports.useState(!1);return RI(a,()=>c&&f(!1)),n.length===0?null:React.createElement($v,null,React.createElement(tv,null,"Select point clouds"),React.createElement("div",{"data-cy":"looker3d-slice-checkboxes"},n.map(m=>React.createElement(DI,{name:m,key:m,value:d.includes(m),muted:d.includes(m)&&d.length===1,setValue:i=>{e(i?[...d,m]:d.filter(w=>w!==m))}}))))},a4=[{shortcut:"Wheel",title:"Zoom",detail:"Zoom in and out"},{shortcut:"Drag",title:"Rotate",detail:"Rotate the camera"},{shortcut:"Shift + drag",title:"Translate",detail:"Translate the camera"},{shortcut:"T",title:"Top-down",detail:"Reset camera to top-down view"},{shortcut:"E",title:"Ego-view",detail:"Reset the camera to ego view"},{shortcut:"C",title:"Controls",detail:"Toggle controls"},{shortcut:"?",title:"Display help",detail:"Display this help window"},{shortcut:"ESC",title:"Escape ",detail:"Escape the current context"}],l4=d=>{const{helpPanel:e}=d;return React.createElement(React.Fragment,null,React.createElement(Md,null,React.createElement(zI,{sx:{fontSize:24},color:"inherit",onClick:n=>(e.toggle(a4),n.stopPropagation(),n.preventDefault(),!1),"data-for-panel":GB})))},c4=d=>{const{sample:e,jsonPanel:n}=d;return React.createElement(React.Fragment,null,React.createElement(Md,null,React.createElement(kI,{sx:{fontSize:24},color:"inherit",onClick:a=>(n.toggle(e),a.stopPropagation(),a.preventDefault(),!1),"data-for-panel":VB})))};var Yv={},u4=L_.exports;Object.defineProperty(Yv,"__esModule",{value:!0});var D2=Yv.default=void 0,h4=u4(I_()),d4=P_(),f4=(0,h4.default)((0,d4.jsx)("path",{d:"M20 2H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zM8 20H4v-4h4v4zm0-6H4v-4h4v4zm0-6H4V4h4v4zm6 12h-4v-4h4v4zm0-6h-4v-4h4v4zm0-6h-4V4h4v4zm6 12h-4v-4h4v4zm0-6h-4v-4h4v4zm0-6h-4V4h4v4z"}),"GridOn");D2=Yv.default=f4;const p4=()=>{const[d,e]=Ca(R2),{primary:n}=gd();return React.createElement(Md,{title:"Toggle Grid"},React.createElement(D2,{sx:{fontSize:24},style:{color:d?n.main:"inherit"},onClick:a=>{e(c=>!c),a.stopPropagation(),a.preventDefault()}}))},fM="keydown",tx=(d,e,n=[])=>{const a=OI(f=>()=>e(f),n),c=Ye.exports.useCallback(f=>{!(f.target.tagName.toLowerCase()==="input")&&f.code===d&&a()},[a,d]);Ye.exports.useEffect(()=>(window.addEventListener(fM,c),()=>{window.removeEventListener(fM,c)}),[c])},m4=()=>{const d=Ye.exports.useRef(()=>!0),e=FI(BI(!0));return e.state==="hasValue"&&(d.current=e.contents),d.current},g4=({itemRotation:d,dimensions:e,opacity:n,rotation:a,location:c,selected:f,onClick:m,tooltip:i,label:w,color:E,useLegacyCoordinates:C})=>{const T=fn.useMemo(()=>e&&new Vc(...e),[e]);if(!c||!e)return null;const[I,k,O]=c,B=C?new Me(I,k-.5*e[1],O):new Me(I,k,O),F=new Me(...d),Y=new Me(...a).add(F).toArray();return fn.createElement(fn.Fragment,null,fn.createElement("mesh",{position:B,rotation:Y},fn.createElement("lineSegments",null,fn.createElement("edgesGeometry",{args:[T],attach:"geometry"}),fn.createElement("lineBasicMaterial",{attach:"material",linewidth:8,color:f?"orange":E}))),fn.createElement("mesh",{onClick:m,...i.getMeshProps(w),position:B,rotation:Y},fn.createElement("boxGeometry",{args:e}),fn.createElement("meshBasicMaterial",{transparent:!0,opacity:n*.5,color:f?"orange":E})))},_4=({rotation:d,points:e,color:n,opacity:a,onClick:c,tooltip:f,label:m})=>{const i=fn.useMemo(()=>{const E=new qi().setFromPoints(e.map(C=>new Me(...C)));return E.rotateX(d[0]),E.rotateY(d[1]),E.rotateZ(d[2]),E},[e,d]),w=fn.useMemo(()=>f.getMeshProps(m),[f,m]);return fn.createElement("line",{onClick:c,...w,opacity:a},fn.createElement("primitive",{object:i,attach:"geometry",rotation:d}),fn.createElement("lineBasicMaterial",{attach:"material",color:n}))},y4=["Detection","Polyline"],x4=["Detections","Polylines"],z2=(d,e,n,a=[],c,f=[])=>{let m=[];const i=Array.isArray(e)?null:Object.keys(e),w=Array.isArray(e)?e:Object.values(e);for(let E=0;E<w.length;E++){const C=w[E],T=i?i[E]:"";if(!C)continue;const I=[...a,T].filter(O=>!!O).join("."),k=NI([I,...f].join("."),c);y4.includes(k)?m.push({...C,sampleId:d,path:I,selected:C._id in n,_cls:k}):x4.includes(k)&&C[a0[k]]&&(m=[...m,...z2(d,C[a0[k]],n,[...a,T],c,[a0[k]])])}return m},v4=(d,e,n=[],a)=>{var f;const c=[];for(const[m,i]of Object.entries(d)){if(!((f=i==null?void 0:i.sample)!=null&&f._id))return;c.push(z2(i.sample._id,i.sample,e,n,a))}return c.flat()},b4=({opacity:d,filled:e,closed:n,rotation:a,points3d:c,color:f,selected:m,onClick:i,tooltip:w,label:E})=>{if(e)return null;const C=c.map(T=>React.createElement(_4,{key:`polyline-${E}-${c[0][0]}`,rotation:a,points:T,opacity:d,color:m?"orange":f,onClick:i,tooltip:w,label:E}));return React.createElement("group",null,C)};class w4 extends el{constructor(e){super(e),this.littleEndian=!0}load(e,n,a,c){const f=this,m=new Wc(f.manager);m.setPath(f.path),m.setResponseType("arraybuffer"),m.setRequestHeader(f.requestHeader),m.setWithCredentials(f.withCredentials),m.load(e,function(i){try{n(f.parse(i))}catch(w){c?c(w):console.error(w),f.manager.itemError(e)}},a,c)}parse(e){function n(T,I){const k=T.length,O=new Uint8Array(I);let B=0,F=0,H,Y,K;do if(H=T[B++],H<1<<5){if(H++,F+H>I)throw new Error("Output buffer is not large enough");if(B+H>k)throw new Error("Invalid compressed data");do O[F++]=T[B++];while(--H)}else{if(Y=H>>5,K=F-((H&31)<<8)-1,B>=k)throw new Error("Invalid compressed data");if(Y===7&&(Y+=T[B++],B>=k))throw new Error("Invalid compressed data");if(K-=T[B++],F+Y+2>I)throw new Error("Output buffer is not large enough");if(K<0)throw new Error("Invalid compressed data");if(K>=F)throw new Error("Invalid compressed data");do O[F++]=O[K++];while(--Y+2)}while(B<k);return O}function a(T){const I={},k=T.search(/[\r\n]DATA\s(\S*)\s/i),O=/[\r\n]DATA\s(\S*)\s/i.exec(T.slice(k-1));if(I.data=O[1],I.headerLen=O[0].length+k,I.str=T.slice(0,I.headerLen),I.str=I.str.replace(/\#.*/gi,""),I.version=/VERSION (.*)/i.exec(I.str),I.fields=/FIELDS (.*)/i.exec(I.str),I.size=/SIZE (.*)/i.exec(I.str),I.type=/TYPE (.*)/i.exec(I.str),I.count=/COUNT (.*)/i.exec(I.str),I.width=/WIDTH (.*)/i.exec(I.str),I.height=/HEIGHT (.*)/i.exec(I.str),I.viewpoint=/VIEWPOINT (.*)/i.exec(I.str),I.points=/POINTS (.*)/i.exec(I.str),I.version!==null&&(I.version=parseFloat(I.version[1])),I.fields=I.fields!==null?I.fields[1].split(" "):[],I.type!==null&&(I.type=I.type[1].split(" ")),I.width!==null&&(I.width=parseInt(I.width[1])),I.height!==null&&(I.height=parseInt(I.height[1])),I.viewpoint!==null&&(I.viewpoint=I.viewpoint[1]),I.points!==null&&(I.points=parseInt(I.points[1],10)),I.points===null&&(I.points=I.width*I.height),I.size!==null&&(I.size=I.size[1].split(" ").map(function(F){return parseInt(F,10)})),I.count!==null)I.count=I.count[1].split(" ").map(function(F){return parseInt(F,10)});else{I.count=[];for(let F=0,H=I.fields.length;F<H;F++)I.count.push(1)}I.offset={};let B=0;for(let F=0,H=I.fields.length;F<H;F++)I.data==="ascii"?I.offset[I.fields[F]]=F:(I.offset[I.fields[F]]=B,B+=I.size[F]*I.count[F]);return I.rowSize=B,I}const c=w_.decodeText(new Uint8Array(e)),f=a(c),m=[],i=[],w=[];if(f.data==="ascii"){const T=f.offset,k=c.slice(f.headerLen).split(`
`);for(let O=0,B=k.length;O<B;O++){if(k[O]==="")continue;const F=k[O].split(" ");if(T.x!==void 0&&(m.push(parseFloat(F[T.x])),m.push(parseFloat(F[T.y])),m.push(parseFloat(F[T.z]))),T.rgb!==void 0){const H=f.fields.findIndex(oe=>oe==="rgb"),Y=f.type[H],K=parseFloat(F[T.rgb]);let ne=K;if(Y==="F"){const oe=new Float32Array(1);oe[0]=K,ne=new Int32Array(oe.buffer)[0]}const le=ne>>16&255,fe=ne>>8&255,Ae=ne>>0&255;w.push(le/255,fe/255,Ae/255)}T.normal_x!==void 0&&(i.push(parseFloat(F[T.normal_x])),i.push(parseFloat(F[T.normal_y])),i.push(parseFloat(F[T.normal_z])))}}if(f.data==="binary_compressed"){const T=new Uint32Array(e.slice(f.headerLen,f.headerLen+8)),I=T[0],k=T[1],O=n(new Uint8Array(e,f.headerLen+8,I),k),B=new DataView(O.buffer),F=f.offset;for(let H=0;H<f.points;H++)F.x!==void 0&&(m.push(B.getFloat32(f.points*F.x+f.size[0]*H,this.littleEndian)),m.push(B.getFloat32(f.points*F.y+f.size[1]*H,this.littleEndian)),m.push(B.getFloat32(f.points*F.z+f.size[2]*H,this.littleEndian))),F.rgb!==void 0&&(w.push(B.getUint8(f.points*F.rgb+f.size[3]*H+2)/255),w.push(B.getUint8(f.points*F.rgb+f.size[3]*H+1)/255),w.push(B.getUint8(f.points*F.rgb+f.size[3]*H+0)/255)),F.normal_x!==void 0&&(i.push(B.getFloat32(f.points*F.normal_x+f.size[4]*H,this.littleEndian)),i.push(B.getFloat32(f.points*F.normal_y+f.size[5]*H,this.littleEndian)),i.push(B.getFloat32(f.points*F.normal_z+f.size[6]*H,this.littleEndian)))}if(f.data==="binary"){const T=new DataView(e,f.headerLen),I=f.offset;for(let k=0,O=0;k<f.points;k++,O+=f.rowSize)I.x!==void 0&&(m.push(T.getFloat32(O+I.x,this.littleEndian)),m.push(T.getFloat32(O+I.y,this.littleEndian)),m.push(T.getFloat32(O+I.z,this.littleEndian))),I.rgb!==void 0&&(w.push(T.getUint8(O+I.rgb+2)/255),w.push(T.getUint8(O+I.rgb+1)/255),w.push(T.getUint8(O+I.rgb+0)/255)),I.normal_x!==void 0&&(i.push(T.getFloat32(O+I.normal_x,this.littleEndian)),i.push(T.getFloat32(O+I.normal_y,this.littleEndian)),i.push(T.getFloat32(O+I.normal_z,this.littleEndian)))}const E=new qi;m.length>0&&E.setAttribute("position",new hi(m,3)),i.length>0&&E.setAttribute("normal",new hi(i,3)),w.length>0&&E.setAttribute("color",new hi(w,3)),E.computeBoundingSphere();const C=new q_({size:.005});return w.length>0?C.vertexColors=!0:C.color.setHex(Math.random()*16777215),new Ev(E,C)}}const k2=d=>{const e=Ye.exports.useCallback(n=>{const c=document.createElement("canvas");c.width=512,c.height=512;const f=c.getContext("2d");f.rect(0,0,512,512);const m=f.createLinearGradient(0,0,0,512);for(const i of n)m.addColorStop(...i);return f.fillStyle=m,f.fill(),c},[]);return fn.useMemo(()=>new yT(e(d)),[d,e])},pM={vertexShader:`
  // this uniform is used to pass the point size to the vertex shader from JS
  uniform float pointSize;

  // this uniform is used to indicate whether the point size should be attenuated based on distance from camera
  uniform bool isPointSizeAttenuated;

  // these attributes are injected into the vertex shader based on geometry
  attribute vec3 color;

  // this attribute is used to pass the color to the fragment shader
  varying vec3 vColor;

  void main() {
    // assign color to the varying variable so that it can be used in fragment shader
    vColor = color;

    // do a model-view transform to get the position of the point in camera space
    vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );

    // (1.0 / length(mvPosition.xyz)) is used to scale the point size based on distance from camera
    gl_PointSize = pointSize * (isPointSizeAttenuated ? (1.0 / length(mvPosition.xyz)) : 1.0);

    // do a projection transform to get the position of the point in clip space
    gl_Position = projectionMatrix * mvPosition;
  }

  `,fragmentShader:`
  varying vec3 vColor;

  void main() {
    gl_FragColor = vec4(vColor, 1.0);
  } 
  `},mM={vertexShader:`
  uniform float maxZ;
  uniform float minZ;
  uniform float pointSize;
  uniform bool isPointSizeAttenuated;

  varying vec2 vUv;
  varying float hValue;

  float remap ( float minval, float maxval, float curval ) {
    return ( curval - minval ) / ( maxval - minval );
  }

  void main() {
    vUv = uv;
    vec3 pos = position;
    hValue = remap(minZ, maxZ, pos.z);

    vec4 mvPosition = modelViewMatrix * vec4(pos, 1.0);

    gl_PointSize = pointSize * (isPointSizeAttenuated ? (1.0 / length(mvPosition.xyz)) : 1.0);
    gl_Position = projectionMatrix * mvPosition;
  }`,fragmentShader:`
  uniform sampler2D gradientMap;
  varying float hValue;

  void main() {
    float v = clamp(hValue, 0., 1.);
    vec3 col = texture2D(gradientMap, vec2(0, v)).rgb;
    gl_FragColor = vec4(col, 1.);
  }`},gM={vertexShader:`
  uniform float max;
  uniform float min;
  uniform float pointSize;
  uniform bool isPointSizeAttenuated;

  varying vec2 vUv;
  varying float hValue;
  attribute vec3 color;

  float remap ( float minval, float maxval, float curval ) {
    return ( curval - minval ) / ( maxval - minval );
  }

  void main() {
    vUv = uv;
    vec3 pos = position;
    hValue = remap(min, max, color.r);

    vec4 mvPosition = modelViewMatrix * vec4(pos, 1.0);

    gl_PointSize = pointSize * (isPointSizeAttenuated ? (1.0 / length(mvPosition.xyz)) : 1.0);
    gl_Position = projectionMatrix * mvPosition;
  }
`,fragmentShader:`
  uniform sampler2D gradientMap;
  varying float hValue;

  void main() {
    float v = clamp(hValue, 0., 1.);
    vec3 col = texture2D(gradientMap, vec2(0, v)).rgb;
    gl_FragColor = vec4(col, 1.);
  }
`},_M={vertexShader:`
  uniform float pointSize;
  uniform bool isPointSizeAttenuated;
  uniform vec3 color;

  // vColor will be assigned to color for frgament shader
  varying vec3 vColor;

  void main() {
    vColor = color;

    vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
    gl_PointSize = pointSize * (isPointSizeAttenuated ? (1.0 / length(mvPosition.xyz)) : 1.0);    gl_Position = projectionMatrix * mvPosition;
    gl_Position = projectionMatrix * mvPosition;
  }
`,fragmentShader:`
  varying vec3 vColor;

  void main() {
    gl_FragColor = vec4(vColor, 1.0);
  }
`},S4=({gradients:d,min:e,max:n,pointSize:a,isPointSizeAttenuated:c})=>{const f=k2(d);return fn.createElement("shaderMaterial",{uniforms:{minZ:{value:e},maxZ:{value:n},gradientMap:{value:f},pointSize:{value:a},isPointSizeAttenuated:{value:c}},vertexShader:mM.vertexShader,fragmentShader:mM.fragmentShader})},M4=({gradients:d,min:e,max:n,pointSize:a,isPointSizeAttenuated:c})=>{const f=k2(d);return fn.createElement("shaderMaterial",{uniforms:{min:{value:e},max:{value:n},gradientMap:{value:f},pointSize:{value:a},isPointSizeAttenuated:{value:c}},vertexShader:gM.vertexShader,fragmentShader:gM.fragmentShader})},E4=({pointSize:d,isPointSizeAttenuated:e})=>fn.createElement("shaderMaterial",{scale:{value:1},uniforms:{pointSize:{value:d},isPointSizeAttenuated:{value:e}},vertexShader:pM.vertexShader,fragmentShader:pM.fragmentShader}),T4=({pointSize:d,isPointSizeAttenuated:e,color:n})=>{const a=Ye.exports.useMemo(()=>{const c=new Kn(n);return[c.r,c.g,c.b]},[n]);return fn.createElement("shaderMaterial",{scale:{value:1},uniforms:{pointSize:{value:d},isPointSizeAttenuated:{value:e},color:{value:a}},vertexShader:_M.vertexShader,fragmentShader:_M.fragmentShader})},yM=[[0,"rgb(165,0,38)"],[.111,"rgb(215,48,39)"],[.222,"rgb(244,109,67)"],[.333,"rgb(253,174,97)"],[.444,"rgb(254,224,144)"],[.555,"rgb(224,243,248)"],[.666,"rgb(171,217,233)"],[.777,"rgb(116,173,209)"],[.888,"rgb(69,117,180)"],[1,"rgb(49,54,149)"]],A4=({defaultShadingColor:d,isPointSizeAttenuated:e,minZ:n,shadeBy:a,customColor:c,pointSize:f,src:m,rotation:i,onLoad:w})=>{const E=Wv(w4,m),[C,T]=Ye.exports.useState({min:0,max:1}),I=E.geometry,k=Ye.exports.useMemo(()=>(I.computeBoundingBox(),I.boundingBox),[I]);Ye.exports.useEffect(()=>{if(!k)return;w(k);const B=I.getAttribute("color");B&&T(MB(B))},[k,I,E,w]),n==null&&(n=k.min.z);const O=Ye.exports.useMemo(()=>{const B=Number(f);switch(a){case Zv:return React.createElement(S4,{gradients:yM,min:n,max:k.max.z,pointSize:B,isPointSizeAttenuated:e});case T2:return React.createElement(M4,{...C,gradients:yM,pointSize:B,isPointSizeAttenuated:e});case A2:return React.createElement(E4,{pointSize:B,isPointSizeAttenuated:e});case Xv:return React.createElement(T4,{pointSize:B,isPointSizeAttenuated:e,color:c});default:return React.createElement("pointsMaterial",{color:d,size:e?B/1e3:B/2,sizeAttenuation:e})}},[C,a,n,f,k,d,e,c]);return React.createElement("primitive",{key:`${f}-${a}-${e}-${c}`,scale:1,object:E,rotation:i},O)},C4=!0,xM="#00ff00",vM="sample3d-canvas-wrapper",I4=()=>{const d=WM("3d",P4),e=yi(pw),n=yi(bm),a=m4(),c=UI(),f=fn.useRef(),m=fn.useRef(),i=yi(ox),w=i==null?void 0:i.fields,E=i.opacity,C=yi(kM),[T,I]=fn.useState(),{coloring:k,selectedLabelTags:O,customizeColorSetting:B,labelTagColors:F}=yi(VI({withFilter:!0,modal:C4})),H=yi(jM),Y=yi(GI(!0)),K=yi(jI);Ye.exports.useEffect(()=>{kr.DefaultUp=new Me(...d.defaultUp).normalize()},[d]),Ye.exports.useLayoutEffect(()=>{var dn;const rn=document.getElementById(vM);rn&&((dn=rn.querySelector("canvas"))==null||dn.setAttribute("sample-loaded","true"))},[]);const ne=Ye.exports.useCallback(rn=>{c({detail:{id:rn._id,field:rn.path,sampleId:rn.sampleId}})},[c]),le=yi(C2),[fe,Ae]=Ca(I2),oe=yi(P2),ce=yi(L2),Re=yi(WI),ke=Ye.exports.useMemo(()=>{var ti,Ie,xe;if(!T)return[1,1,20];const rn=Math.max((ti=T.max)==null?void 0:ti.x,(Ie=T.max)==null?void 0:Ie.y,(xe=T.max)==null?void 0:xe.z),dn=new Me(...d.defaultUp).normalize(),Mn=isNaN(rn)?20:rn*2,li=dn.multiplyScalar(Mn);return[li.x,li.y,li.z]},[T,d]),Xe=Ye.exports.useMemo(()=>{const rn=window==null?void 0:window.localStorage.getItem(M2);return(rn==null?void 0:rn.length)>0?JSON.parse(rn):d.defaultCameraPosition?[d.defaultCameraPosition.x,d.defaultCameraPosition.y,d.defaultCameraPosition.z]:ke},[ke,d]),St=Ye.exports.useCallback(rn=>{const dn=f.current,Mn=m.current;if(dn&&Mn){Mn.target;const li=dn.position.clone(),ti=Mn.target.clone();switch(Mn.target.set(0,0,0),rn){case"top":dn.position.set(ke[0],ke[1],ke[2]);break;case"pov":dn.position.set(0,-10,1);break}return dn.updateProjectionMatrix(),!(ti.equals(Mn.target)&&li.distanceTo(dn.position)<1)}},[ke]),Je=HI(),It=qI(),ft=pg.get(d,"pointCloud.rotation",[0,0,0]),Nt=pg.get(d,"pointCloud.minZ",null),Fe=Ye.exports.useMemo(()=>Q0(ft),[ft]),[it,tt]=Ye.exports.useMemo(()=>[Q0(pg.get(d,"overlay.rotation",[0,0,0])),Q0(pg.get(d,"overlay.itemRotation",[0,0,0]))],[d]),[Et,xt]=Ye.exports.useState(!1),Pt=$x(zf),ln=Ye.exports.useRef(null),pn=Ye.exports.useCallback(()=>{ei.current||(ln.current&&clearTimeout(ln.current),xt(!1),Pt(null))},[Pt]),Mt=Ye.exports.useCallback(()=>(!Et&&xt(!0),ln.current&&clearTimeout(ln.current),ln.current=setTimeout(pn,3e3),()=>{ln.current&&clearTimeout(ln.current)}),[pn,Et]),ei=Ye.exports.useRef(!1),oi=ZI();tx("KeyT",()=>St("top")),tx("KeyE",()=>St("pov")),tx("Escape",({get:rn,set:dn})=>{const Mn=rn(mw);if(rn(zf)){dn(zf,null);return}for(const xe of["help","json"])if(Mn[xe].isOpen){dn(mw,{...Mn,[xe]:{...Mn[xe],isOpen:!1}});return}const li=rn(eP);if(li&&!Object.values(K).find(xe=>xe.sample._id===li._id))return;const Ie=rn(tP);if(Ie&&Ie.length>0){dn(pw,{});return}dn(nP,{}),dn(iP,null)},[K,Je,It,e,Et]),Ye.exports.useEffect(()=>{var dn;const rn=(dn=f.current)==null?void 0:dn.position;!rn||rn.x===Xe[0]&&rn.y===Xe[1]&&rn.z===Xe[2]||f.current.position.set(Xe[0],Xe[1],Xe[2])},[Xe]),Ye.exports.useEffect(()=>{if(Re)Ae(rn=>rn&&Object.hasOwn(rn,"default")?rn:{...rn!=null?rn:{},default:xM});else{const rn={};for(const dn of H)rn[dn]=xM;Ae(dn=>({...rn,...dn!=null?dn:{}}))}},[Re,H,Ae]);const Wn=Ye.exports.useMemo(()=>n.groupMediaTypes.filter(rn=>rn.mediaType==="point_cloud").length>1,[n]),jt=gd(),mn=yi(R2),qt=Ye.exports.useMemo(()=>Object.entries(K).map(([rn,dn])=>{var Ie;let Mn;if(Array.isArray(dn.urls)){const xe=dn.urls.find(Tt=>Tt.field===Y);if(xe)Mn=xe.url;else return null}else Mn=dn.urls[Y];if(!Mn)return null;const li=XI(Mn),ti=(Ie=fe&&fe[Re?"default":rn])!=null?Ie:"#00ff00";return fn.createElement(A4,{key:rn,minZ:Nt,shadeBy:le,customColor:ti,pointSize:oe,src:li,rotation:Fe,onLoad:xe=>{T||I(xe)},defaultShadingColor:jt.text.primary,isPointSizeAttenuated:ce})}).filter(rn=>rn!==null),[K,Y,le,oe,Fe,Nt,jt,ce,T,fe,Re]),Dt=yi($I({space:YI.SPACE.SAMPLE})),gn=Ye.exports.useMemo(()=>v4(K,e,[],Dt).map(rn=>{const dn=JI(O,rn.tags),Mn=KI({coloring:k,path:rn.path,label:rn,isTagged:dn,labelTagColors:F,customizeColorSetting:B,embeddedDocType:rn._cls});return{...rn,color:Mn,id:rn._id}}).filter(rn=>a(rn.path,rn)),[k,C,a,K,e,w,i,Dt]),[wn,Yt]=Ye.exports.useMemo(()=>{var Mn,li;const rn=[],dn=[];for(const ti of gn)ti._cls==="Detection"?rn.push(fn.createElement(g4,{key:`cuboid-${(Mn=ti.id)!=null?Mn:ti._id}-${ti.sampleId}`,rotation:it,itemRotation:tt,opacity:E,...ti,onClick:()=>ne(ti),label:ti,tooltip:oi,useLegacyCoordinates:d.useLegacyCoordinates})):ti._cls==="Polyline"&&ti.points3d&&dn.push(fn.createElement(b4,{key:`polyline-${(li=ti._id)!=null?li:ti.id}-${ti.sampleId}`,rotation:it,opacity:E,...ti,label:ti,onClick:()=>ne(ti),tooltip:oi}));return[rn,dn]},[gn,tt,E,it,ne,oi,d]);return qt.length===0?fn.createElement(aM,{style:{padding:"2em"}},fn.createElement(QI,null,'No point-cloud samples detected for media field "',Y,'"')):fn.createElement(O2,null,fn.createElement(aM,{onMouseOver:Mt,onMouseMove:Mt,"data-cy":"looker3d"},fn.createElement(wB,{id:vM,onClick:()=>Pt(null)},fn.createElement(r4,null),fn.createElement(LB,{controlsRef:m,cameraRef:f,settings:d,isGridOn:mn,bounds:T}),fn.createElement("mesh",{rotation:it},wn),Yt,qt),(ei.current||Et)&&fn.createElement(OB,{"data-cy":"looker3d-action-bar",onMouseEnter:()=>ei.current=!0,onMouseLeave:()=>ei.current=!1},Wn&&fn.createElement(s4,null),fn.createElement(FB,null,fn.createElement(p4,null),fn.createElement(i4,null),fn.createElement(HB,null),fn.createElement(dM,{onChangeView:St,view:"top",label:"T",hint:"Top View"}),fn.createElement(dM,{onChangeView:St,view:"pov",label:"E",hint:"Ego View"}),fn.createElement(c4,{jsonPanel:Je,sample:K}),fn.createElement(l4,{helpPanel:It})))))};class O2 extends fn.Component{constructor(){super(...arguments);rf(this,"state",{error:null,hasError:!1})}componentDidCatch(n){this.setState({error:n})}render(){return this.state.hasError?fn.createElement(eh,{dataCy:"looker3d"},fn.createElement("div",{"data-cy":"looker-error-info"},this.state.error instanceof Error?this.state.error.message:this.state.error)):this.props.children}}rf(O2,"getDerivedStateFromError",n=>({hasError:!0,error:n}));const P4={useLegacyCoordinates:!1,defaultUp:[0,0,1]};typeof window<"u"&&Jx({name:"Looker3d",component:I4,type:Kx.Visualizer,activator:({dataset:d})=>{var e;return(e=d.mediaType)!=null?e:d.groupMediaTypes.find(n=>n.mediaType==="point_cloud")!==void 0}});const L4="_container_1wrzk_1";var F2={exports:{}};(function(d,e){(function(n,a){d.exports=a()})(Tf,function(){var n=function(D,W){var ae={drag:[],click:[],mousemove:[],mousedown:[],mouseup:[],mouseout:[],keydown:[],keyup:[],touchstart:[],touchmove:[],touchend:[],tap:[]},Ce={on:function(qe,nt,en){if(ae[qe]===void 0)throw new Error("Invalid event type: "+qe);ae[qe].push({selector:nt,fn:en})},render:function(qe){W.store.featureChanged(qe)}},Oe=function(qe,nt){for(var en=ae[qe],cn=en.length;cn--;){var Ln=en[cn];if(Ln.selector(nt)){Ln.fn.call(Ce,nt)||W.store.render(),W.ui.updateMapClasses();break}}};return D.start.call(Ce),{render:D.render,stop:function(){D.stop&&D.stop()},trash:function(){D.trash&&(D.trash(),W.store.render())},combineFeatures:function(){D.combineFeatures&&D.combineFeatures()},uncombineFeatures:function(){D.uncombineFeatures&&D.uncombineFeatures()},drag:function(qe){Oe("drag",qe)},click:function(qe){Oe("click",qe)},mousemove:function(qe){Oe("mousemove",qe)},mousedown:function(qe){Oe("mousedown",qe)},mouseup:function(qe){Oe("mouseup",qe)},mouseout:function(qe){Oe("mouseout",qe)},keydown:function(qe){Oe("keydown",qe)},keyup:function(qe){Oe("keyup",qe)},touchstart:function(qe){Oe("touchstart",qe)},touchmove:function(qe){Oe("touchmove",qe)},touchend:function(qe){Oe("touchend",qe)},tap:function(qe){Oe("tap",qe)}}};function a(D){return D&&D.__esModule&&Object.prototype.hasOwnProperty.call(D,"default")?D.default:D}function c(D){if(D.__esModule)return D;var W=D.default;if(typeof W=="function"){var ae=function Ce(){if(this instanceof Ce){var Oe=[null];Oe.push.apply(Oe,arguments);var qe=Function.bind.apply(W,Oe);return new qe}return W.apply(this,arguments)};ae.prototype=W.prototype}else ae={};return Object.defineProperty(ae,"__esModule",{value:!0}),Object.keys(D).forEach(function(Ce){var Oe=Object.getOwnPropertyDescriptor(D,Ce);Object.defineProperty(ae,Ce,Oe.get?Oe:{enumerable:!0,get:function(){return D[Ce]}})}),ae}var f={},m={RADIUS:6378137,FLATTENING:1/298.257223563,POLAR_RADIUS:63567523142e-4},i=m;function w(D){var W=0;if(D&&D.length>0){W+=Math.abs(E(D[0]));for(var ae=1;ae<D.length;ae++)W-=Math.abs(E(D[ae]))}return W}function E(D){var W,ae,Ce,Oe,qe,nt,en=0,cn=D.length;if(cn>2){for(nt=0;nt<cn;nt++)nt===cn-2?(Ce=cn-2,Oe=cn-1,qe=0):nt===cn-1?(Ce=cn-1,Oe=0,qe=1):(Ce=nt,Oe=nt+1,qe=nt+2),W=D[Ce],ae=D[Oe],en+=(C(D[qe][0])-C(W[0]))*Math.sin(C(ae[1]));en=en*i.RADIUS*i.RADIUS/2}return en}function C(D){return D*Math.PI/180}f.geometry=function D(W){var ae,Ce=0;switch(W.type){case"Polygon":return w(W.coordinates);case"MultiPolygon":for(ae=0;ae<W.coordinates.length;ae++)Ce+=w(W.coordinates[ae]);return Ce;case"Point":case"MultiPoint":case"LineString":case"MultiLineString":return 0;case"GeometryCollection":for(ae=0;ae<W.geometries.length;ae++)Ce+=D(W.geometries[ae]);return Ce}},f.ring=E;var T={CONTROL_BASE:"mapboxgl-ctrl",CONTROL_PREFIX:"mapboxgl-ctrl-",CONTROL_BUTTON:"mapbox-gl-draw_ctrl-draw-btn",CONTROL_BUTTON_LINE:"mapbox-gl-draw_line",CONTROL_BUTTON_POLYGON:"mapbox-gl-draw_polygon",CONTROL_BUTTON_POINT:"mapbox-gl-draw_point",CONTROL_BUTTON_TRASH:"mapbox-gl-draw_trash",CONTROL_BUTTON_COMBINE_FEATURES:"mapbox-gl-draw_combine",CONTROL_BUTTON_UNCOMBINE_FEATURES:"mapbox-gl-draw_uncombine",CONTROL_GROUP:"mapboxgl-ctrl-group",ATTRIBUTION:"mapboxgl-ctrl-attrib",ACTIVE_BUTTON:"active",BOX_SELECT:"mapbox-gl-draw_boxselect"},I={HOT:"mapbox-gl-draw-hot",COLD:"mapbox-gl-draw-cold"},k={ADD:"add",MOVE:"move",DRAG:"drag",POINTER:"pointer",NONE:"none"},O={POLYGON:"polygon",LINE:"line_string",POINT:"point"},B={FEATURE:"Feature",POLYGON:"Polygon",LINE_STRING:"LineString",POINT:"Point",FEATURE_COLLECTION:"FeatureCollection",MULTI_PREFIX:"Multi",MULTI_POINT:"MultiPoint",MULTI_LINE_STRING:"MultiLineString",MULTI_POLYGON:"MultiPolygon"},F={DRAW_LINE_STRING:"draw_line_string",DRAW_POLYGON:"draw_polygon",DRAW_POINT:"draw_point",SIMPLE_SELECT:"simple_select",DIRECT_SELECT:"direct_select",STATIC:"static"},H={CREATE:"draw.create",DELETE:"draw.delete",UPDATE:"draw.update",SELECTION_CHANGE:"draw.selectionchange",MODE_CHANGE:"draw.modechange",ACTIONABLE:"draw.actionable",RENDER:"draw.render",COMBINE_FEATURES:"draw.combine",UNCOMBINE_FEATURES:"draw.uncombine"},Y={MOVE:"move",CHANGE_COORDINATES:"change_coordinates"},K={FEATURE:"feature",MIDPOINT:"midpoint",VERTEX:"vertex"},ne={ACTIVE:"true",INACTIVE:"false"},le=["scrollZoom","boxZoom","dragRotate","dragPan","keyboard","doubleClickZoom","touchZoomRotate"],fe=-85,Ae=Object.freeze({__proto__:null,classes:T,sources:I,cursors:k,types:O,geojsonTypes:B,modes:F,events:H,updateActions:Y,meta:K,activeStates:ne,interactions:le,LAT_MIN:-90,LAT_RENDERED_MIN:fe,LAT_MAX:90,LAT_RENDERED_MAX:85,LNG_MIN:-270,LNG_MAX:270}),oe={Point:0,LineString:1,MultiLineString:1,Polygon:2};function ce(D,W){var ae=oe[D.geometry.type]-oe[W.geometry.type];return ae===0&&D.geometry.type===B.POLYGON?D.area-W.area:ae}function Re(D){return D.map(function(W){return W.geometry.type===B.POLYGON&&(W.area=f.geometry({type:B.FEATURE,property:{},geometry:W.geometry})),W}).sort(ce).map(function(W){return delete W.area,W})}function ke(D,W){return W===void 0&&(W=0),[[D.point.x-W,D.point.y-W],[D.point.x+W,D.point.y+W]]}function Xe(D){if(this._items={},this._nums={},this._length=D?D.length:0,D)for(var W=0,ae=D.length;W<ae;W++)this.add(D[W]),D[W]!==void 0&&(typeof D[W]=="string"?this._items[D[W]]=W:this._nums[D[W]]=W)}Xe.prototype.add=function(D){return this.has(D)||(this._length++,typeof D=="string"?this._items[D]=this._length:this._nums[D]=this._length),this},Xe.prototype.delete=function(D){return this.has(D)===!1||(this._length--,delete this._items[D],delete this._nums[D]),this},Xe.prototype.has=function(D){return(typeof D=="string"||typeof D=="number")&&(this._items[D]!==void 0||this._nums[D]!==void 0)},Xe.prototype.values=function(){var D=this,W=[];return Object.keys(this._items).forEach(function(ae){W.push({k:ae,v:D._items[ae]})}),Object.keys(this._nums).forEach(function(ae){W.push({k:JSON.parse(ae),v:D._nums[ae]})}),W.sort(function(ae,Ce){return ae.v-Ce.v}).map(function(ae){return ae.k})},Xe.prototype.clear=function(){return this._length=0,this._items={},this._nums={},this};var St=[K.FEATURE,K.MIDPOINT,K.VERTEX],Je={click:function(D,W,ae){return It(D,W,ae,ae.options.clickBuffer)},touch:function(D,W,ae){return It(D,W,ae,ae.options.touchBuffer)}};function It(D,W,ae,Ce){if(ae.map===null)return[];var Oe=D?ke(D,Ce):W,qe={};ae.options.styles&&(qe.layers=ae.options.styles.map(function(Ln){return Ln.id}).filter(function(Ln){return ae.map.getLayer(Ln)!=null}));var nt=ae.map.queryRenderedFeatures(Oe,qe).filter(function(Ln){return St.indexOf(Ln.properties.meta)!==-1}),en=new Xe,cn=[];return nt.forEach(function(Ln){var Pn=Ln.properties.id;en.has(Pn)||(en.add(Pn),cn.push(Ln))}),Re(cn)}function ft(D,W){var ae=Je.click(D,null,W),Ce={mouse:k.NONE};return ae[0]&&(Ce.mouse=ae[0].properties.active===ne.ACTIVE?k.MOVE:k.POINTER,Ce.feature=ae[0].properties.meta),W.events.currentModeName().indexOf("draw")!==-1&&(Ce.mouse=k.ADD),W.ui.queueMapClasses(Ce),W.ui.updateMapClasses(),ae[0]}function Nt(D,W){var ae=D.x-W.x,Ce=D.y-W.y;return Math.sqrt(ae*ae+Ce*Ce)}function Fe(D,W,ae){ae===void 0&&(ae={});var Ce=ae.fineTolerance!=null?ae.fineTolerance:4,Oe=ae.grossTolerance!=null?ae.grossTolerance:12,qe=ae.interval!=null?ae.interval:500;D.point=D.point||W.point,D.time=D.time||W.time;var nt=Nt(D.point,W.point);return nt<Ce||nt<Oe&&W.time-D.time<qe}function it(D,W,ae){ae===void 0&&(ae={});var Ce=ae.tolerance!=null?ae.tolerance:25,Oe=ae.interval!=null?ae.interval:250;return D.point=D.point||W.point,D.time=D.time||W.time,Nt(D.point,W.point)<Ce&&W.time-D.time<Oe}var tt={exports:{}},Et=tt.exports=function(D,W){if(W||(W=16),D===void 0&&(D=128),D<=0)return"0";for(var ae=Math.log(Math.pow(2,D))/Math.log(W),Ce=2;ae===1/0;Ce*=2)ae=Math.log(Math.pow(2,D/Ce))/Math.log(W)*Ce;var Oe=ae-Math.floor(ae),qe="";for(Ce=0;Ce<Math.floor(ae);Ce++)qe=Math.floor(Math.random()*W).toString(W)+qe;if(Oe){var nt=Math.pow(W,Oe);qe=Math.floor(Math.random()*nt).toString(W)+qe}var en=parseInt(qe,W);return en!==1/0&&en>=Math.pow(2,D)?Et(D,W):qe};Et.rack=function(D,W,ae){var Ce=function(qe){var nt=0;do{if(nt++>10){if(!ae)throw new Error("too many ID collisions, use more bits");D+=ae}var en=Et(D,W)}while(Object.hasOwnProperty.call(Oe,en));return Oe[en]=qe,en},Oe=Ce.hats={};return Ce.get=function(qe){return Ce.hats[qe]},Ce.set=function(qe,nt){return Ce.hats[qe]=nt,Ce},Ce.bits=D||128,Ce.base=W||16,Ce};var xt=a(tt.exports),Pt=function(D,W){this.ctx=D,this.properties=W.properties||{},this.coordinates=W.geometry.coordinates,this.id=W.id||xt(),this.type=W.geometry.type};Pt.prototype.changed=function(){this.ctx.store.featureChanged(this.id)},Pt.prototype.incomingCoords=function(D){this.setCoordinates(D)},Pt.prototype.setCoordinates=function(D){this.coordinates=D,this.changed()},Pt.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.coordinates))},Pt.prototype.setProperty=function(D,W){this.properties[D]=W},Pt.prototype.toGeoJSON=function(){return JSON.parse(JSON.stringify({id:this.id,type:B.FEATURE,properties:this.properties,geometry:{coordinates:this.getCoordinates(),type:this.type}}))},Pt.prototype.internal=function(D){var W={id:this.id,meta:K.FEATURE,"meta:type":this.type,active:ne.INACTIVE,mode:D};if(this.ctx.options.userProperties)for(var ae in this.properties)W["user_"+ae]=this.properties[ae];return{type:B.FEATURE,properties:W,geometry:{coordinates:this.getCoordinates(),type:this.type}}};var ln=function(D,W){Pt.call(this,D,W)};(ln.prototype=Object.create(Pt.prototype)).isValid=function(){return typeof this.coordinates[0]=="number"&&typeof this.coordinates[1]=="number"},ln.prototype.updateCoordinate=function(D,W,ae){this.coordinates=arguments.length===3?[W,ae]:[D,W],this.changed()},ln.prototype.getCoordinate=function(){return this.getCoordinates()};var pn=function(D,W){Pt.call(this,D,W)};(pn.prototype=Object.create(Pt.prototype)).isValid=function(){return this.coordinates.length>1},pn.prototype.addCoordinate=function(D,W,ae){this.changed();var Ce=parseInt(D,10);this.coordinates.splice(Ce,0,[W,ae])},pn.prototype.getCoordinate=function(D){var W=parseInt(D,10);return JSON.parse(JSON.stringify(this.coordinates[W]))},pn.prototype.removeCoordinate=function(D){this.changed(),this.coordinates.splice(parseInt(D,10),1)},pn.prototype.updateCoordinate=function(D,W,ae){var Ce=parseInt(D,10);this.coordinates[Ce]=[W,ae],this.changed()};var Mt=function(D,W){Pt.call(this,D,W),this.coordinates=this.coordinates.map(function(ae){return ae.slice(0,-1)})};(Mt.prototype=Object.create(Pt.prototype)).isValid=function(){return this.coordinates.length!==0&&this.coordinates.every(function(D){return D.length>2})},Mt.prototype.incomingCoords=function(D){this.coordinates=D.map(function(W){return W.slice(0,-1)}),this.changed()},Mt.prototype.setCoordinates=function(D){this.coordinates=D,this.changed()},Mt.prototype.addCoordinate=function(D,W,ae){this.changed();var Ce=D.split(".").map(function(Oe){return parseInt(Oe,10)});this.coordinates[Ce[0]].splice(Ce[1],0,[W,ae])},Mt.prototype.removeCoordinate=function(D){this.changed();var W=D.split(".").map(function(Ce){return parseInt(Ce,10)}),ae=this.coordinates[W[0]];ae&&(ae.splice(W[1],1),ae.length<3&&this.coordinates.splice(W[0],1))},Mt.prototype.getCoordinate=function(D){var W=D.split(".").map(function(Ce){return parseInt(Ce,10)}),ae=this.coordinates[W[0]];return JSON.parse(JSON.stringify(ae[W[1]]))},Mt.prototype.getCoordinates=function(){return this.coordinates.map(function(D){return D.concat([D[0]])})},Mt.prototype.updateCoordinate=function(D,W,ae){this.changed();var Ce=D.split("."),Oe=parseInt(Ce[0],10),qe=parseInt(Ce[1],10);this.coordinates[Oe]===void 0&&(this.coordinates[Oe]=[]),this.coordinates[Oe][qe]=[W,ae]};var ei={MultiPoint:ln,MultiLineString:pn,MultiPolygon:Mt},oi=function(D,W,ae,Ce,Oe){var qe=ae.split("."),nt=parseInt(qe[0],10),en=qe[1]?qe.slice(1).join("."):null;return D[nt][W](en,Ce,Oe)},Wn=function(D,W){if(Pt.call(this,D,W),delete this.coordinates,this.model=ei[W.geometry.type],this.model===void 0)throw new TypeError(W.geometry.type+" is not a valid type");this.features=this._coordinatesToFeatures(W.geometry.coordinates)};function jt(D){this.map=D.map,this.drawConfig=JSON.parse(JSON.stringify(D.options||{})),this._ctx=D}(Wn.prototype=Object.create(Pt.prototype))._coordinatesToFeatures=function(D){var W=this,ae=this.model.bind(this);return D.map(function(Ce){return new ae(W.ctx,{id:xt(),type:B.FEATURE,properties:{},geometry:{coordinates:Ce,type:W.type.replace("Multi","")}})})},Wn.prototype.isValid=function(){return this.features.every(function(D){return D.isValid()})},Wn.prototype.setCoordinates=function(D){this.features=this._coordinatesToFeatures(D),this.changed()},Wn.prototype.getCoordinate=function(D){return oi(this.features,"getCoordinate",D)},Wn.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.features.map(function(D){return D.type===B.POLYGON?D.getCoordinates():D.coordinates})))},Wn.prototype.updateCoordinate=function(D,W,ae){oi(this.features,"updateCoordinate",D,W,ae),this.changed()},Wn.prototype.addCoordinate=function(D,W,ae){oi(this.features,"addCoordinate",D,W,ae),this.changed()},Wn.prototype.removeCoordinate=function(D){oi(this.features,"removeCoordinate",D),this.changed()},Wn.prototype.getFeatures=function(){return this.features},jt.prototype.setSelected=function(D){return this._ctx.store.setSelected(D)},jt.prototype.setSelectedCoordinates=function(D){var W=this;this._ctx.store.setSelectedCoordinates(D),D.reduce(function(ae,Ce){return ae[Ce.feature_id]===void 0&&(ae[Ce.feature_id]=!0,W._ctx.store.get(Ce.feature_id).changed()),ae},{})},jt.prototype.getSelected=function(){return this._ctx.store.getSelected()},jt.prototype.getSelectedIds=function(){return this._ctx.store.getSelectedIds()},jt.prototype.isSelected=function(D){return this._ctx.store.isSelected(D)},jt.prototype.getFeature=function(D){return this._ctx.store.get(D)},jt.prototype.select=function(D){return this._ctx.store.select(D)},jt.prototype.deselect=function(D){return this._ctx.store.deselect(D)},jt.prototype.deleteFeature=function(D,W){return W===void 0&&(W={}),this._ctx.store.delete(D,W)},jt.prototype.addFeature=function(D){return this._ctx.store.add(D)},jt.prototype.clearSelectedFeatures=function(){return this._ctx.store.clearSelected()},jt.prototype.clearSelectedCoordinates=function(){return this._ctx.store.clearSelectedCoordinates()},jt.prototype.setActionableState=function(D){D===void 0&&(D={});var W={trash:D.trash||!1,combineFeatures:D.combineFeatures||!1,uncombineFeatures:D.uncombineFeatures||!1};return this._ctx.events.actionable(W)},jt.prototype.changeMode=function(D,W,ae){return W===void 0&&(W={}),ae===void 0&&(ae={}),this._ctx.events.changeMode(D,W,ae)},jt.prototype.updateUIClasses=function(D){return this._ctx.ui.queueMapClasses(D)},jt.prototype.activateUIButton=function(D){return this._ctx.ui.setActiveButton(D)},jt.prototype.featuresAt=function(D,W,ae){if(ae===void 0&&(ae="click"),ae!=="click"&&ae!=="touch")throw new Error("invalid buffer type");return Je[ae](D,W,this._ctx)},jt.prototype.newFeature=function(D){var W=D.geometry.type;return W===B.POINT?new ln(this._ctx,D):W===B.LINE_STRING?new pn(this._ctx,D):W===B.POLYGON?new Mt(this._ctx,D):new Wn(this._ctx,D)},jt.prototype.isInstanceOf=function(D,W){if(D===B.POINT)return W instanceof ln;if(D===B.LINE_STRING)return W instanceof pn;if(D===B.POLYGON)return W instanceof Mt;if(D==="MultiFeature")return W instanceof Wn;throw new Error("Unknown feature class: "+D)},jt.prototype.doRender=function(D){return this._ctx.store.featureChanged(D)},jt.prototype.onSetup=function(){},jt.prototype.onDrag=function(){},jt.prototype.onClick=function(){},jt.prototype.onMouseMove=function(){},jt.prototype.onMouseDown=function(){},jt.prototype.onMouseUp=function(){},jt.prototype.onMouseOut=function(){},jt.prototype.onKeyUp=function(){},jt.prototype.onKeyDown=function(){},jt.prototype.onTouchStart=function(){},jt.prototype.onTouchMove=function(){},jt.prototype.onTouchEnd=function(){},jt.prototype.onTap=function(){},jt.prototype.onStop=function(){},jt.prototype.onTrash=function(){},jt.prototype.onCombineFeature=function(){},jt.prototype.onUncombineFeature=function(){},jt.prototype.toDisplayFeatures=function(){throw new Error("You must overwrite toDisplayFeatures")};var mn={drag:"onDrag",click:"onClick",mousemove:"onMouseMove",mousedown:"onMouseDown",mouseup:"onMouseUp",mouseout:"onMouseOut",keyup:"onKeyUp",keydown:"onKeyDown",touchstart:"onTouchStart",touchmove:"onTouchMove",touchend:"onTouchEnd",tap:"onTap"},qt=Object.keys(mn);function Dt(D){var W=Object.keys(D);return function(ae,Ce){Ce===void 0&&(Ce={});var Oe={},qe=W.reduce(function(nt,en){return nt[en]=D[en],nt},new jt(ae));return{start:function(){var nt=this;Oe=qe.onSetup(Ce),qt.forEach(function(en){var cn,Ln=mn[en],Pn=function(){return!1};D[Ln]&&(Pn=function(){return!0}),nt.on(en,Pn,(cn=Ln,function(xn){return qe[cn](Oe,xn)}))})},stop:function(){qe.onStop(Oe)},trash:function(){qe.onTrash(Oe)},combineFeatures:function(){qe.onCombineFeatures(Oe)},uncombineFeatures:function(){qe.onUncombineFeatures(Oe)},render:function(nt,en){qe.toDisplayFeatures(Oe,nt,en)}}}}function gn(D){return[].concat(D).filter(function(W){return W!==void 0})}function wn(){var D=this;if(!(D.ctx.map&&D.ctx.map.getSource(I.HOT)!==void 0))return cn();var W=D.ctx.events.currentModeName();D.ctx.ui.queueMapClasses({mode:W});var ae=[],Ce=[];D.isDirty?Ce=D.getAllIds():(ae=D.getChangedIds().filter(function(Ln){return D.get(Ln)!==void 0}),Ce=D.sources.hot.filter(function(Ln){return Ln.properties.id&&ae.indexOf(Ln.properties.id)===-1&&D.get(Ln.properties.id)!==void 0}).map(function(Ln){return Ln.properties.id})),D.sources.hot=[];var Oe=D.sources.cold.length;D.sources.cold=D.isDirty?[]:D.sources.cold.filter(function(Ln){var Pn=Ln.properties.id||Ln.properties.parent;return ae.indexOf(Pn)===-1});var qe=Oe!==D.sources.cold.length||Ce.length>0;function nt(Ln,Pn){var xn=D.get(Ln).internal(W);D.ctx.events.currentModeRender(xn,function(mi){D.sources[Pn].push(mi)})}if(ae.forEach(function(Ln){return nt(Ln,"hot")}),Ce.forEach(function(Ln){return nt(Ln,"cold")}),qe&&D.ctx.map.getSource(I.COLD).setData({type:B.FEATURE_COLLECTION,features:D.sources.cold}),D.ctx.map.getSource(I.HOT).setData({type:B.FEATURE_COLLECTION,features:D.sources.hot}),D._emitSelectionChange&&(D.ctx.map.fire(H.SELECTION_CHANGE,{features:D.getSelected().map(function(Ln){return Ln.toGeoJSON()}),points:D.getSelectedCoordinates().map(function(Ln){return{type:B.FEATURE,properties:{},geometry:{type:B.POINT,coordinates:Ln.coordinates}}})}),D._emitSelectionChange=!1),D._deletedFeaturesToEmit.length){var en=D._deletedFeaturesToEmit.map(function(Ln){return Ln.toGeoJSON()});D._deletedFeaturesToEmit=[],D.ctx.map.fire(H.DELETE,{features:en})}function cn(){D.isDirty=!1,D.clearChangedIds()}cn(),D.ctx.map.fire(H.RENDER,{})}function Yt(D){var W,ae=this;this._features={},this._featureIds=new Xe,this._selectedFeatureIds=new Xe,this._selectedCoordinates=[],this._changedFeatureIds=new Xe,this._deletedFeaturesToEmit=[],this._emitSelectionChange=!1,this._mapInitialConfig={},this.ctx=D,this.sources={hot:[],cold:[]},this.render=function(){W||(W=requestAnimationFrame(function(){W=null,wn.call(ae)}))},this.isDirty=!1}function rn(D,W){var ae=D._selectedCoordinates.filter(function(Ce){return D._selectedFeatureIds.has(Ce.feature_id)});D._selectedCoordinates.length===ae.length||W.silent||(D._emitSelectionChange=!0),D._selectedCoordinates=ae}Yt.prototype.createRenderBatch=function(){var D=this,W=this.render,ae=0;return this.render=function(){ae++},function(){D.render=W,ae>0&&D.render()}},Yt.prototype.setDirty=function(){return this.isDirty=!0,this},Yt.prototype.featureChanged=function(D){return this._changedFeatureIds.add(D),this},Yt.prototype.getChangedIds=function(){return this._changedFeatureIds.values()},Yt.prototype.clearChangedIds=function(){return this._changedFeatureIds.clear(),this},Yt.prototype.getAllIds=function(){return this._featureIds.values()},Yt.prototype.add=function(D){return this.featureChanged(D.id),this._features[D.id]=D,this._featureIds.add(D.id),this},Yt.prototype.delete=function(D,W){var ae=this;return W===void 0&&(W={}),gn(D).forEach(function(Ce){ae._featureIds.has(Ce)&&(ae._featureIds.delete(Ce),ae._selectedFeatureIds.delete(Ce),W.silent||ae._deletedFeaturesToEmit.indexOf(ae._features[Ce])===-1&&ae._deletedFeaturesToEmit.push(ae._features[Ce]),delete ae._features[Ce],ae.isDirty=!0)}),rn(this,W),this},Yt.prototype.get=function(D){return this._features[D]},Yt.prototype.getAll=function(){var D=this;return Object.keys(this._features).map(function(W){return D._features[W]})},Yt.prototype.select=function(D,W){var ae=this;return W===void 0&&(W={}),gn(D).forEach(function(Ce){ae._selectedFeatureIds.has(Ce)||(ae._selectedFeatureIds.add(Ce),ae._changedFeatureIds.add(Ce),W.silent||(ae._emitSelectionChange=!0))}),this},Yt.prototype.deselect=function(D,W){var ae=this;return W===void 0&&(W={}),gn(D).forEach(function(Ce){ae._selectedFeatureIds.has(Ce)&&(ae._selectedFeatureIds.delete(Ce),ae._changedFeatureIds.add(Ce),W.silent||(ae._emitSelectionChange=!0))}),rn(this,W),this},Yt.prototype.clearSelected=function(D){return D===void 0&&(D={}),this.deselect(this._selectedFeatureIds.values(),{silent:D.silent}),this},Yt.prototype.setSelected=function(D,W){var ae=this;return W===void 0&&(W={}),D=gn(D),this.deselect(this._selectedFeatureIds.values().filter(function(Ce){return D.indexOf(Ce)===-1}),{silent:W.silent}),this.select(D.filter(function(Ce){return!ae._selectedFeatureIds.has(Ce)}),{silent:W.silent}),this},Yt.prototype.setSelectedCoordinates=function(D){return this._selectedCoordinates=D,this._emitSelectionChange=!0,this},Yt.prototype.clearSelectedCoordinates=function(){return this._selectedCoordinates=[],this._emitSelectionChange=!0,this},Yt.prototype.getSelectedIds=function(){return this._selectedFeatureIds.values()},Yt.prototype.getSelected=function(){var D=this;return this._selectedFeatureIds.values().map(function(W){return D.get(W)})},Yt.prototype.getSelectedCoordinates=function(){var D=this;return this._selectedCoordinates.map(function(W){return{coordinates:D.get(W.feature_id).getCoordinate(W.coord_path)}})},Yt.prototype.isSelected=function(D){return this._selectedFeatureIds.has(D)},Yt.prototype.setFeatureProperty=function(D,W,ae){this.get(D).setProperty(W,ae),this.featureChanged(D)},Yt.prototype.storeMapConfig=function(){var D=this;le.forEach(function(W){D.ctx.map[W]&&(D._mapInitialConfig[W]=D.ctx.map[W].isEnabled())})},Yt.prototype.restoreMapConfig=function(){var D=this;Object.keys(this._mapInitialConfig).forEach(function(W){D._mapInitialConfig[W]?D.ctx.map[W].enable():D.ctx.map[W].disable()})},Yt.prototype.getInitialConfigValue=function(D){return this._mapInitialConfig[D]===void 0||this._mapInitialConfig[D]};var dn=function(){for(var D=arguments,W={},ae=0;ae<arguments.length;ae++){var Ce=D[ae];for(var Oe in Ce)Mn.call(Ce,Oe)&&(W[Oe]=Ce[Oe])}return W},Mn=Object.prototype.hasOwnProperty,li=a(dn),ti=["mode","feature","mouse"];function Ie(D){var W=null,ae=null,Ce={onRemove:function(){return D.map.off("load",Ce.connect),clearInterval(ae),Ce.removeLayers(),D.store.restoreMapConfig(),D.ui.removeButtons(),D.events.removeEventListeners(),D.ui.clearMapClasses(),D.boxZoomInitial&&D.map.boxZoom.enable(),D.map=null,D.container=null,D.store=null,W&&W.parentNode&&W.parentNode.removeChild(W),W=null,this},connect:function(){D.map.off("load",Ce.connect),clearInterval(ae),Ce.addLayers(),D.store.storeMapConfig(),D.events.addEventListeners()},onAdd:function(Oe){var qe=Oe.fire;return Oe.fire=function(nt,en){var cn=arguments;return qe.length===1&&arguments.length!==1&&(cn=[li({},{type:nt},en)]),qe.apply(Oe,cn)},D.map=Oe,D.events=function(nt){var en=Object.keys(nt.options.modes).reduce(function(zt,Xn){return zt[Xn]=Dt(nt.options.modes[Xn]),zt},{}),cn={},Ln={},Pn={},xn=null,mi=null;Pn.drag=function(zt,Xn){Xn({point:zt.point,time:new Date().getTime()})?(nt.ui.queueMapClasses({mouse:k.DRAG}),mi.drag(zt)):zt.originalEvent.stopPropagation()},Pn.mousedrag=function(zt){Pn.drag(zt,function(Xn){return!Fe(cn,Xn)})},Pn.touchdrag=function(zt){Pn.drag(zt,function(Xn){return!it(Ln,Xn)})},Pn.mousemove=function(zt){if((zt.originalEvent.buttons!==void 0?zt.originalEvent.buttons:zt.originalEvent.which)===1)return Pn.mousedrag(zt);var Xn=ft(zt,nt);zt.featureTarget=Xn,mi.mousemove(zt)},Pn.mousedown=function(zt){cn={time:new Date().getTime(),point:zt.point};var Xn=ft(zt,nt);zt.featureTarget=Xn,mi.mousedown(zt)},Pn.mouseup=function(zt){var Xn=ft(zt,nt);zt.featureTarget=Xn,Fe(cn,{point:zt.point,time:new Date().getTime()})?mi.click(zt):mi.mouseup(zt)},Pn.mouseout=function(zt){mi.mouseout(zt)},Pn.touchstart=function(zt){if(nt.options.touchEnabled){Ln={time:new Date().getTime(),point:zt.point};var Xn=Je.touch(zt,null,nt)[0];zt.featureTarget=Xn,mi.touchstart(zt)}},Pn.touchmove=function(zt){if(nt.options.touchEnabled)return mi.touchmove(zt),Pn.touchdrag(zt)},Pn.touchend=function(zt){if(zt.originalEvent.preventDefault(),nt.options.touchEnabled){var Xn=Je.touch(zt,null,nt)[0];zt.featureTarget=Xn,it(Ln,{time:new Date().getTime(),point:zt.point})?mi.tap(zt):mi.touchend(zt)}};var di=function(zt){return!(zt===8||zt===46||zt>=48&&zt<=57)};function vi(zt,Xn,ur){ur===void 0&&(ur={}),mi.stop();var wi=en[zt];if(wi===void 0)throw new Error(zt+" is not valid");xn=zt;var or=wi(nt,Xn);mi=n(or,nt),ur.silent||nt.map.fire(H.MODE_CHANGE,{mode:zt}),nt.store.setDirty(),nt.store.render()}Pn.keydown=function(zt){(zt.srcElement||zt.target).classList.contains("mapboxgl-canvas")&&(zt.keyCode!==8&&zt.keyCode!==46||!nt.options.controls.trash?di(zt.keyCode)?mi.keydown(zt):zt.keyCode===49&&nt.options.controls.point?vi(F.DRAW_POINT):zt.keyCode===50&&nt.options.controls.line_string?vi(F.DRAW_LINE_STRING):zt.keyCode===51&&nt.options.controls.polygon&&vi(F.DRAW_POLYGON):(zt.preventDefault(),mi.trash()))},Pn.keyup=function(zt){di(zt.keyCode)&&mi.keyup(zt)},Pn.zoomend=function(){nt.store.changeZoom()},Pn.data=function(zt){if(zt.dataType==="style"){var Xn=nt.setup,ur=nt.map,wi=nt.options,or=nt.store;wi.styles.some(function(lc){return ur.getLayer(lc.id)})||(Xn.addLayers(),or.setDirty(),or.render())}};var Ji={trash:!1,combineFeatures:!1,uncombineFeatures:!1};return{start:function(){xn=nt.options.defaultMode,mi=n(en[xn](nt),nt)},changeMode:vi,actionable:function(zt){var Xn=!1;Object.keys(zt).forEach(function(ur){if(Ji[ur]===void 0)throw new Error("Invalid action type");Ji[ur]!==zt[ur]&&(Xn=!0),Ji[ur]=zt[ur]}),Xn&&nt.map.fire(H.ACTIONABLE,{actions:Ji})},currentModeName:function(){return xn},currentModeRender:function(zt,Xn){return mi.render(zt,Xn)},fire:function(zt,Xn){Pn[zt]&&Pn[zt](Xn)},addEventListeners:function(){nt.map.on("mousemove",Pn.mousemove),nt.map.on("mousedown",Pn.mousedown),nt.map.on("mouseup",Pn.mouseup),nt.map.on("data",Pn.data),nt.map.on("touchmove",Pn.touchmove),nt.map.on("touchstart",Pn.touchstart),nt.map.on("touchend",Pn.touchend),nt.container.addEventListener("mouseout",Pn.mouseout),nt.options.keybindings&&(nt.container.addEventListener("keydown",Pn.keydown),nt.container.addEventListener("keyup",Pn.keyup))},removeEventListeners:function(){nt.map.off("mousemove",Pn.mousemove),nt.map.off("mousedown",Pn.mousedown),nt.map.off("mouseup",Pn.mouseup),nt.map.off("data",Pn.data),nt.map.off("touchmove",Pn.touchmove),nt.map.off("touchstart",Pn.touchstart),nt.map.off("touchend",Pn.touchend),nt.container.removeEventListener("mouseout",Pn.mouseout),nt.options.keybindings&&(nt.container.removeEventListener("keydown",Pn.keydown),nt.container.removeEventListener("keyup",Pn.keyup))},trash:function(zt){mi.trash(zt)},combineFeatures:function(){mi.combineFeatures()},uncombineFeatures:function(){mi.uncombineFeatures()},getMode:function(){return xn}}}(D),D.ui=function(nt){var en={},cn=null,Ln={mode:null,feature:null,mouse:null},Pn={mode:null,feature:null,mouse:null};function xn(zt){Pn=li(Pn,zt)}function mi(){var zt,Xn;if(nt.container){var ur=[],wi=[];ti.forEach(function(or){Pn[or]!==Ln[or]&&(ur.push(or+"-"+Ln[or]),Pn[or]!==null&&wi.push(or+"-"+Pn[or]))}),ur.length>0&&(zt=nt.container.classList).remove.apply(zt,ur),wi.length>0&&(Xn=nt.container.classList).add.apply(Xn,wi),Ln=li(Ln,Pn)}}function di(zt,Xn){Xn===void 0&&(Xn={});var ur=document.createElement("button");return ur.className=T.CONTROL_BUTTON+" "+Xn.className,ur.setAttribute("title",Xn.title),Xn.container.appendChild(ur),ur.addEventListener("click",function(wi){if(wi.preventDefault(),wi.stopPropagation(),wi.target===cn)return vi(),void Xn.onDeactivate();Ji(zt),Xn.onActivate()},!0),ur}function vi(){cn&&(cn.classList.remove(T.ACTIVE_BUTTON),cn=null)}function Ji(zt){vi();var Xn=en[zt];Xn&&Xn&&zt!=="trash"&&(Xn.classList.add(T.ACTIVE_BUTTON),cn=Xn)}return{setActiveButton:Ji,queueMapClasses:xn,updateMapClasses:mi,clearMapClasses:function(){xn({mode:null,feature:null,mouse:null}),mi()},addButtons:function(){var zt=nt.options.controls,Xn=document.createElement("div");return Xn.className=T.CONTROL_GROUP+" "+T.CONTROL_BASE,zt&&(zt[O.LINE]&&(en[O.LINE]=di(O.LINE,{container:Xn,className:T.CONTROL_BUTTON_LINE,title:"LineString tool "+(nt.options.keybindings?"(l)":""),onActivate:function(){return nt.events.changeMode(F.DRAW_LINE_STRING)},onDeactivate:function(){return nt.events.trash()}})),zt[O.POLYGON]&&(en[O.POLYGON]=di(O.POLYGON,{container:Xn,className:T.CONTROL_BUTTON_POLYGON,title:"Polygon tool "+(nt.options.keybindings?"(p)":""),onActivate:function(){return nt.events.changeMode(F.DRAW_POLYGON)},onDeactivate:function(){return nt.events.trash()}})),zt[O.POINT]&&(en[O.POINT]=di(O.POINT,{container:Xn,className:T.CONTROL_BUTTON_POINT,title:"Marker tool "+(nt.options.keybindings?"(m)":""),onActivate:function(){return nt.events.changeMode(F.DRAW_POINT)},onDeactivate:function(){return nt.events.trash()}})),zt.trash&&(en.trash=di("trash",{container:Xn,className:T.CONTROL_BUTTON_TRASH,title:"Delete",onActivate:function(){nt.events.trash()}})),zt.combine_features&&(en.combine_features=di("combineFeatures",{container:Xn,className:T.CONTROL_BUTTON_COMBINE_FEATURES,title:"Combine",onActivate:function(){nt.events.combineFeatures()}})),zt.uncombine_features&&(en.uncombine_features=di("uncombineFeatures",{container:Xn,className:T.CONTROL_BUTTON_UNCOMBINE_FEATURES,title:"Uncombine",onActivate:function(){nt.events.uncombineFeatures()}}))),Xn},removeButtons:function(){Object.keys(en).forEach(function(zt){var Xn=en[zt];Xn.parentNode&&Xn.parentNode.removeChild(Xn),delete en[zt]})}}}(D),D.container=Oe.getContainer(),D.store=new Yt(D),W=D.ui.addButtons(),D.options.boxSelect&&(D.boxZoomInitial=Oe.boxZoom.isEnabled(),Oe.boxZoom.disable(),Oe.dragPan.disable(),Oe.dragPan.enable()),Oe.loaded()?Ce.connect():(Oe.on("load",Ce.connect),ae=setInterval(function(){Oe.loaded()&&Ce.connect()},16)),D.events.start(),W},addLayers:function(){D.map.addSource(I.COLD,{data:{type:B.FEATURE_COLLECTION,features:[]},type:"geojson"}),D.map.addSource(I.HOT,{data:{type:B.FEATURE_COLLECTION,features:[]},type:"geojson"}),D.options.styles.forEach(function(Oe){D.map.addLayer(Oe)}),D.store.setDirty(!0),D.store.render()},removeLayers:function(){D.options.styles.forEach(function(Oe){D.map.getLayer(Oe.id)&&D.map.removeLayer(Oe.id)}),D.map.getSource(I.COLD)&&D.map.removeSource(I.COLD),D.map.getSource(I.HOT)&&D.map.removeSource(I.HOT)}};return D.setup=Ce,Ce}var xe=[{id:"gl-draw-polygon-fill-inactive",type:"fill",filter:["all",["==","active","false"],["==","$type","Polygon"],["!=","mode","static"]],paint:{"fill-color":"#3bb2d0","fill-outline-color":"#3bb2d0","fill-opacity":.1}},{id:"gl-draw-polygon-fill-active",type:"fill",filter:["all",["==","active","true"],["==","$type","Polygon"]],paint:{"fill-color":"#fbb03b","fill-outline-color":"#fbb03b","fill-opacity":.1}},{id:"gl-draw-polygon-midpoint",type:"circle",filter:["all",["==","$type","Point"],["==","meta","midpoint"]],paint:{"circle-radius":3,"circle-color":"#fbb03b"}},{id:"gl-draw-polygon-stroke-inactive",type:"line",filter:["all",["==","active","false"],["==","$type","Polygon"],["!=","mode","static"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#3bb2d0","line-width":2}},{id:"gl-draw-polygon-stroke-active",type:"line",filter:["all",["==","active","true"],["==","$type","Polygon"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#fbb03b","line-dasharray":[.2,2],"line-width":2}},{id:"gl-draw-line-inactive",type:"line",filter:["all",["==","active","false"],["==","$type","LineString"],["!=","mode","static"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#3bb2d0","line-width":2}},{id:"gl-draw-line-active",type:"line",filter:["all",["==","$type","LineString"],["==","active","true"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#fbb03b","line-dasharray":[.2,2],"line-width":2}},{id:"gl-draw-polygon-and-line-vertex-stroke-inactive",type:"circle",filter:["all",["==","meta","vertex"],["==","$type","Point"],["!=","mode","static"]],paint:{"circle-radius":5,"circle-color":"#fff"}},{id:"gl-draw-polygon-and-line-vertex-inactive",type:"circle",filter:["all",["==","meta","vertex"],["==","$type","Point"],["!=","mode","static"]],paint:{"circle-radius":3,"circle-color":"#fbb03b"}},{id:"gl-draw-point-point-stroke-inactive",type:"circle",filter:["all",["==","active","false"],["==","$type","Point"],["==","meta","feature"],["!=","mode","static"]],paint:{"circle-radius":5,"circle-opacity":1,"circle-color":"#fff"}},{id:"gl-draw-point-inactive",type:"circle",filter:["all",["==","active","false"],["==","$type","Point"],["==","meta","feature"],["!=","mode","static"]],paint:{"circle-radius":3,"circle-color":"#3bb2d0"}},{id:"gl-draw-point-stroke-active",type:"circle",filter:["all",["==","$type","Point"],["==","active","true"],["!=","meta","midpoint"]],paint:{"circle-radius":7,"circle-color":"#fff"}},{id:"gl-draw-point-active",type:"circle",filter:["all",["==","$type","Point"],["!=","meta","midpoint"],["==","active","true"]],paint:{"circle-radius":5,"circle-color":"#fbb03b"}},{id:"gl-draw-polygon-fill-static",type:"fill",filter:["all",["==","mode","static"],["==","$type","Polygon"]],paint:{"fill-color":"#404040","fill-outline-color":"#404040","fill-opacity":.1}},{id:"gl-draw-polygon-stroke-static",type:"line",filter:["all",["==","mode","static"],["==","$type","Polygon"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#404040","line-width":2}},{id:"gl-draw-line-static",type:"line",filter:["all",["==","mode","static"],["==","$type","LineString"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#404040","line-width":2}},{id:"gl-draw-point-static",type:"circle",filter:["all",["==","mode","static"],["==","$type","Point"]],paint:{"circle-radius":5,"circle-color":"#404040"}}];function Tt(D){return function(W){var ae=W.featureTarget;return!!ae&&!!ae.properties&&ae.properties.meta===D}}function hn(D){return!!D.originalEvent&&!!D.originalEvent.shiftKey&&D.originalEvent.button===0}function _n(D){return!!D.featureTarget&&!!D.featureTarget.properties&&D.featureTarget.properties.active===ne.ACTIVE&&D.featureTarget.properties.meta===K.FEATURE}function Sn(D){return!!D.featureTarget&&!!D.featureTarget.properties&&D.featureTarget.properties.active===ne.INACTIVE&&D.featureTarget.properties.meta===K.FEATURE}function ri(D){return D.featureTarget===void 0}function kt(D){return!!D.featureTarget&&!!D.featureTarget.properties&&D.featureTarget.properties.meta===K.FEATURE}function Hn(D){var W=D.featureTarget;return!!W&&!!W.properties&&W.properties.meta===K.VERTEX}function On(D){return!!D.originalEvent&&D.originalEvent.shiftKey===!0}function Fn(D){return D.keyCode===27}function Ze(D){return D.keyCode===13}var Tn=Object.freeze({__proto__:null,isOfMetaType:Tt,isShiftMousedown:hn,isActiveFeature:_n,isInactiveFeature:Sn,noTarget:ri,isFeature:kt,isVertex:Hn,isShiftDown:On,isEscapeKey:Fn,isEnterKey:Ze,isTrue:function(){return!0}}),bn=We;function We(D,W){this.x=D,this.y=W}We.prototype={clone:function(){return new We(this.x,this.y)},add:function(D){return this.clone()._add(D)},sub:function(D){return this.clone()._sub(D)},multByPoint:function(D){return this.clone()._multByPoint(D)},divByPoint:function(D){return this.clone()._divByPoint(D)},mult:function(D){return this.clone()._mult(D)},div:function(D){return this.clone()._div(D)},rotate:function(D){return this.clone()._rotate(D)},rotateAround:function(D,W){return this.clone()._rotateAround(D,W)},matMult:function(D){return this.clone()._matMult(D)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(D){return this.x===D.x&&this.y===D.y},dist:function(D){return Math.sqrt(this.distSqr(D))},distSqr:function(D){var W=D.x-this.x,ae=D.y-this.y;return W*W+ae*ae},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(D){return Math.atan2(this.y-D.y,this.x-D.x)},angleWith:function(D){return this.angleWithSep(D.x,D.y)},angleWithSep:function(D,W){return Math.atan2(this.x*W-this.y*D,this.x*D+this.y*W)},_matMult:function(D){var W=D[0]*this.x+D[1]*this.y,ae=D[2]*this.x+D[3]*this.y;return this.x=W,this.y=ae,this},_add:function(D){return this.x+=D.x,this.y+=D.y,this},_sub:function(D){return this.x-=D.x,this.y-=D.y,this},_mult:function(D){return this.x*=D,this.y*=D,this},_div:function(D){return this.x/=D,this.y/=D,this},_multByPoint:function(D){return this.x*=D.x,this.y*=D.y,this},_divByPoint:function(D){return this.x/=D.x,this.y/=D.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var D=this.y;return this.y=this.x,this.x=-D,this},_rotate:function(D){var W=Math.cos(D),ae=Math.sin(D),Ce=W*this.x-ae*this.y,Oe=ae*this.x+W*this.y;return this.x=Ce,this.y=Oe,this},_rotateAround:function(D,W){var ae=Math.cos(D),Ce=Math.sin(D),Oe=W.x+ae*(this.x-W.x)-Ce*(this.y-W.y),qe=W.y+Ce*(this.x-W.x)+ae*(this.y-W.y);return this.x=Oe,this.y=qe,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},We.convert=function(D){return D instanceof We?D:Array.isArray(D)?new We(D[0],D[1]):D};var bt=a(bn);function un(D,W){var ae=W.getBoundingClientRect();return new bt(D.clientX-ae.left-(W.clientLeft||0),D.clientY-ae.top-(W.clientTop||0))}function ue(D,W,ae,Ce){return{type:B.FEATURE,properties:{meta:K.VERTEX,parent:D,coord_path:ae,active:Ce?ne.ACTIVE:ne.INACTIVE},geometry:{type:B.POINT,coordinates:W}}}function te(D,W,ae){var Ce=W.geometry.coordinates,Oe=ae.geometry.coordinates;if(Ce[1]>85||Ce[1]<fe||Oe[1]>85||Oe[1]<fe)return null;var qe={lng:(Ce[0]+Oe[0])/2,lat:(Ce[1]+Oe[1])/2};return{type:B.FEATURE,properties:{meta:K.MIDPOINT,parent:D,lng:qe.lng,lat:qe.lat,coord_path:ae.properties.coord_path},geometry:{type:B.POINT,coordinates:[qe.lng,qe.lat]}}}function se(D,W,ae){W===void 0&&(W={}),ae===void 0&&(ae=null);var Ce,Oe=D.geometry,qe=Oe.type,nt=Oe.coordinates,en=D.properties&&D.properties.id,cn=[];function Ln(xn,mi){var di="",vi=null;xn.forEach(function(Ji,zt){var Xn=mi!=null?mi+"."+zt:String(zt),ur=ue(en,Ji,Xn,Pn(Xn));if(W.midpoints&&vi){var wi=te(en,vi,ur);wi&&cn.push(wi)}vi=ur;var or=JSON.stringify(Ji);di!==or&&cn.push(ur),zt===0&&(di=or)})}function Pn(xn){return!!W.selectedPaths&&W.selectedPaths.indexOf(xn)!==-1}return qe===B.POINT?cn.push(ue(en,nt,ae,Pn(ae))):qe===B.POLYGON?nt.forEach(function(xn,mi){Ln(xn,ae!==null?ae+"."+mi:String(mi))}):qe===B.LINE_STRING?Ln(nt,ae):qe.indexOf(B.MULTI_PREFIX)===0&&(Ce=qe.replace(B.MULTI_PREFIX,""),nt.forEach(function(xn,mi){var di={type:B.FEATURE,properties:D.properties,geometry:{type:Ce,coordinates:xn}};cn=cn.concat(se(di,W,mi))})),cn}var ye={enable:function(D){setTimeout(function(){D.map&&D.map.doubleClickZoom&&D._ctx&&D._ctx.store&&D._ctx.store.getInitialConfigValue&&D._ctx.store.getInitialConfigValue("doubleClickZoom")&&D.map.doubleClickZoom.enable()},0)},disable:function(D){setTimeout(function(){D.map&&D.map.doubleClickZoom&&D.map.doubleClickZoom.disable()},0)}},De={exports:{}},je=function(D){if(!D||!D.type)return null;var W=rt[D.type];if(!W)return null;if(W==="geometry")return{type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:D}]};if(W==="feature")return{type:"FeatureCollection",features:[D]};if(W==="featurecollection")return D},rt={Point:"geometry",MultiPoint:"geometry",LineString:"geometry",MultiLineString:"geometry",Polygon:"geometry",MultiPolygon:"geometry",GeometryCollection:"geometry",Feature:"feature",FeatureCollection:"featurecollection"},st=a(je),He=Object.freeze({__proto__:null,default:function D(W){switch(W&&W.type||null){case"FeatureCollection":return W.features=W.features.reduce(function(ae,Ce){return ae.concat(D(Ce))},[]),W;case"Feature":return W.geometry?D(W.geometry).map(function(ae){var Ce={type:"Feature",properties:JSON.parse(JSON.stringify(W.properties)),geometry:ae};return W.id!==void 0&&(Ce.id=W.id),Ce}):[W];case"MultiPoint":return W.coordinates.map(function(ae){return{type:"Point",coordinates:ae}});case"MultiPolygon":return W.coordinates.map(function(ae){return{type:"Polygon",coordinates:ae}});case"MultiLineString":return W.coordinates.map(function(ae){return{type:"LineString",coordinates:ae}});case"GeometryCollection":return W.geometries.map(D).reduce(function(ae,Ce){return ae.concat(Ce)},[]);case"Point":case"Polygon":case"LineString":return[W]}}}),pt=je,Zt=c(He),on=function(D){return function W(ae){return Array.isArray(ae)&&ae.length&&typeof ae[0]=="number"?[ae]:ae.reduce(function(Ce,Oe){return Array.isArray(Oe)&&Array.isArray(Oe[0])?Ce.concat(W(Oe)):(Ce.push(Oe),Ce)},[])}(D)};Zt instanceof Function||(Zt=Zt.default);var Kt={exports:{}},xi=Kt.exports=function(D){return new ci(D)};function ci(D){this.value=D}function ve(D,W,ae){var Ce=[],Oe=[],qe=!0;return function nt(en){var cn=ae?Qe(en):en,Ln={},Pn=!0,xn={node:cn,node_:en,path:[].concat(Ce),parent:Oe[Oe.length-1],parents:Oe,key:Ce.slice(-1)[0],isRoot:Ce.length===0,level:Ce.length,circular:null,update:function(vi,Ji){xn.isRoot||(xn.parent.node[xn.key]=vi),xn.node=vi,Ji&&(Pn=!1)},delete:function(vi){delete xn.parent.node[xn.key],vi&&(Pn=!1)},remove:function(vi){Gt(xn.parent.node)?xn.parent.node.splice(xn.key,1):delete xn.parent.node[xn.key],vi&&(Pn=!1)},keys:null,before:function(vi){Ln.before=vi},after:function(vi){Ln.after=vi},pre:function(vi){Ln.pre=vi},post:function(vi){Ln.post=vi},stop:function(){qe=!1},block:function(){Pn=!1}};if(!qe)return xn;function mi(){if(typeof xn.node=="object"&&xn.node!==null){xn.keys&&xn.node_===xn.node||(xn.keys=lt(xn.node)),xn.isLeaf=xn.keys.length==0;for(var vi=0;vi<Oe.length;vi++)if(Oe[vi].node_===en){xn.circular=Oe[vi];break}}else xn.isLeaf=!0,xn.keys=null;xn.notLeaf=!xn.isLeaf,xn.notRoot=!xn.isRoot}mi();var di=W.call(xn,xn.node);return di!==void 0&&xn.update&&xn.update(di),Ln.before&&Ln.before.call(xn,xn.node),Pn&&(typeof xn.node!="object"||xn.node===null||xn.circular||(Oe.push(xn),mi(),$n(xn.keys,function(vi,Ji){Ce.push(vi),Ln.pre&&Ln.pre.call(xn,xn.node[vi],vi);var zt=nt(xn.node[vi]);ae&&Yn.call(xn.node,vi)&&(xn.node[vi]=zt.node),zt.isLast=Ji==xn.keys.length-1,zt.isFirst=Ji==0,Ln.post&&Ln.post.call(xn,zt),Ce.pop()}),Oe.pop()),Ln.after&&Ln.after.call(xn,xn.node)),xn}(D).node}function Qe(D){if(typeof D=="object"&&D!==null){var W;if(Gt(D))W=[];else if(mt(D)==="[object Date]")W=new Date(D.getTime?D.getTime():D);else if(function(Oe){return mt(Oe)==="[object RegExp]"}(D))W=new RegExp(D);else if(function(Oe){return mt(Oe)==="[object Error]"}(D))W={message:D.message};else if(function(Oe){return mt(Oe)==="[object Boolean]"}(D))W=new Boolean(D);else if(function(Oe){return mt(Oe)==="[object Number]"}(D))W=new Number(D);else if(function(Oe){return mt(Oe)==="[object String]"}(D))W=new String(D);else if(Object.create&&Object.getPrototypeOf)W=Object.create(Object.getPrototypeOf(D));else if(D.constructor===Object)W={};else{var ae=D.constructor&&D.constructor.prototype||D.__proto__||{},Ce=function(){};Ce.prototype=ae,W=new Ce}return $n(lt(D),function(Oe){W[Oe]=D[Oe]}),W}return D}ci.prototype.get=function(D){for(var W=this.value,ae=0;ae<D.length;ae++){var Ce=D[ae];if(!W||!Yn.call(W,Ce)){W=void 0;break}W=W[Ce]}return W},ci.prototype.has=function(D){for(var W=this.value,ae=0;ae<D.length;ae++){var Ce=D[ae];if(!W||!Yn.call(W,Ce))return!1;W=W[Ce]}return!0},ci.prototype.set=function(D,W){for(var ae=this.value,Ce=0;Ce<D.length-1;Ce++){var Oe=D[Ce];Yn.call(ae,Oe)||(ae[Oe]={}),ae=ae[Oe]}return ae[D[Ce]]=W,W},ci.prototype.map=function(D){return ve(this.value,D,!0)},ci.prototype.forEach=function(D){return this.value=ve(this.value,D,!1),this.value},ci.prototype.reduce=function(D,W){var ae=arguments.length===1,Ce=ae?this.value:W;return this.forEach(function(Oe){this.isRoot&&ae||(Ce=D.call(this,Ce,Oe))}),Ce},ci.prototype.paths=function(){var D=[];return this.forEach(function(W){D.push(this.path)}),D},ci.prototype.nodes=function(){var D=[];return this.forEach(function(W){D.push(this.node)}),D},ci.prototype.clone=function(){var D=[],W=[];return function ae(Ce){for(var Oe=0;Oe<D.length;Oe++)if(D[Oe]===Ce)return W[Oe];if(typeof Ce=="object"&&Ce!==null){var qe=Qe(Ce);return D.push(Ce),W.push(qe),$n(lt(Ce),function(nt){qe[nt]=ae(Ce[nt])}),D.pop(),W.pop(),qe}return Ce}(this.value)};var lt=Object.keys||function(D){var W=[];for(var ae in D)W.push(ae);return W};function mt(D){return Object.prototype.toString.call(D)}var Gt=Array.isArray||function(D){return Object.prototype.toString.call(D)==="[object Array]"},$n=function(D,W){if(D.forEach)return D.forEach(W);for(var ae=0;ae<D.length;ae++)W(D[ae],ae,D)};$n(lt(ci.prototype),function(D){xi[D]=function(W){var ae=[].slice.call(arguments,1),Ce=new ci(W);return Ce[D].apply(Ce,ae)}});var Yn=Object.hasOwnProperty||function(D,W){return W in D},bi=Kt.exports,ui=ai;function ai(D){if(!(this instanceof ai))return new ai(D);this._bbox=D||[1/0,1/0,-1/0,-1/0],this._valid=!!D}ai.prototype.include=function(D){return this._valid=!0,this._bbox[0]=Math.min(this._bbox[0],D[0]),this._bbox[1]=Math.min(this._bbox[1],D[1]),this._bbox[2]=Math.max(this._bbox[2],D[0]),this._bbox[3]=Math.max(this._bbox[3],D[1]),this},ai.prototype.equals=function(D){var W;return W=D instanceof ai?D.bbox():D,this._bbox[0]==W[0]&&this._bbox[1]==W[1]&&this._bbox[2]==W[2]&&this._bbox[3]==W[3]},ai.prototype.center=function(D){return this._valid?[(this._bbox[0]+this._bbox[2])/2,(this._bbox[1]+this._bbox[3])/2]:null},ai.prototype.union=function(D){var W;return this._valid=!0,W=D instanceof ai?D.bbox():D,this._bbox[0]=Math.min(this._bbox[0],W[0]),this._bbox[1]=Math.min(this._bbox[1],W[1]),this._bbox[2]=Math.max(this._bbox[2],W[2]),this._bbox[3]=Math.max(this._bbox[3],W[3]),this},ai.prototype.bbox=function(){return this._valid?this._bbox:null},ai.prototype.contains=function(D){if(!D)return this._fastContains();if(!this._valid)return null;var W=D[0],ae=D[1];return this._bbox[0]<=W&&this._bbox[1]<=ae&&this._bbox[2]>=W&&this._bbox[3]>=ae},ai.prototype.intersect=function(D){return this._valid?(W=D instanceof ai?D.bbox():D,!(this._bbox[0]>W[2]||this._bbox[2]<W[0]||this._bbox[3]<W[1]||this._bbox[1]>W[3])):null;var W},ai.prototype._fastContains=function(){if(!this._valid)return new Function("return null;");var D="return "+this._bbox[0]+"<= ll[0] &&"+this._bbox[1]+"<= ll[1] &&"+this._bbox[2]+">= ll[0] &&"+this._bbox[3]+">= ll[1]";return new Function("ll",D)},ai.prototype.polygon=function(){return this._valid?{type:"Polygon",coordinates:[[[this._bbox[0],this._bbox[1]],[this._bbox[2],this._bbox[1]],[this._bbox[2],this._bbox[3]],[this._bbox[0],this._bbox[3]],[this._bbox[0],this._bbox[1]]]]}:null};var Ni=function(D){if(!D)return[];var W=Zt(pt(D)),ae=[];return W.features.forEach(function(Ce){Ce.geometry&&(ae=ae.concat(on(Ce.geometry.coordinates)))}),ae},Qi=bi,Cr=ui,ki={features:["FeatureCollection"],coordinates:["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon"],geometry:["Feature"],geometries:["GeometryCollection"]},ea=Object.keys(ki);function Xs(D){for(var W=Cr(),ae=Ni(D),Ce=0;Ce<ae.length;Ce++)W.include(ae[Ce]);return W}De.exports=function(D){return Xs(D).bbox()},De.exports.polygon=function(D){return Xs(D).polygon()},De.exports.bboxify=function(D){return Qi(D).map(function(W){W&&ea.some(function(ae){return!!W[ae]&&ki[ae].indexOf(W.type)!==-1})&&(W.bbox=Xs(W).bbox(),this.update(W))})};var $s=a(De.exports),Vi=-90;function Ur(D,W){var ae=Vi,Ce=90,Oe=Vi,qe=90,nt=270,en=-270;D.forEach(function(Ln){var Pn=$s(Ln),xn=Pn[1],mi=Pn[3],di=Pn[0],vi=Pn[2];xn>ae&&(ae=xn),mi<Ce&&(Ce=mi),mi>Oe&&(Oe=mi),xn<qe&&(qe=xn),di<nt&&(nt=di),vi>en&&(en=vi)});var cn=W;return ae+cn.lat>85&&(cn.lat=85-ae),Oe+cn.lat>90&&(cn.lat=90-Oe),Ce+cn.lat<-85&&(cn.lat=-85-Ce),qe+cn.lat<Vi&&(cn.lat=Vi-qe),nt+cn.lng<=-270&&(cn.lng+=360*Math.ceil(Math.abs(cn.lng)/360)),en+cn.lng>=270&&(cn.lng-=360*Math.ceil(Math.abs(cn.lng)/360)),cn}function er(D,W){var ae=Ur(D.map(function(Ce){return Ce.toGeoJSON()}),W);D.forEach(function(Ce){var Oe,qe=Ce.getCoordinates(),nt=function(cn){var Ln={lng:cn[0]+ae.lng,lat:cn[1]+ae.lat};return[Ln.lng,Ln.lat]},en=function(cn){return cn.map(function(Ln){return nt(Ln)})};Ce.type===B.POINT?Oe=nt(qe):Ce.type===B.LINE_STRING||Ce.type===B.MULTI_POINT?Oe=qe.map(nt):Ce.type===B.POLYGON||Ce.type===B.MULTI_LINE_STRING?Oe=qe.map(en):Ce.type===B.MULTI_POLYGON&&(Oe=qe.map(function(cn){return cn.map(function(Ln){return en(Ln)})})),Ce.incomingCoords(Oe)})}var tr={onSetup:function(D){var W=this,ae={dragMoveLocation:null,boxSelectStartLocation:null,boxSelectElement:void 0,boxSelecting:!1,canBoxSelect:!1,dragMoving:!1,canDragMove:!1,initiallySelectedFeatureIds:D.featureIds||[]};return this.setSelected(ae.initiallySelectedFeatureIds.filter(function(Ce){return W.getFeature(Ce)!==void 0})),this.fireActionable(),this.setActionableState({combineFeatures:!0,uncombineFeatures:!0,trash:!0}),ae},fireUpdate:function(){this.map.fire(H.UPDATE,{action:Y.MOVE,features:this.getSelected().map(function(D){return D.toGeoJSON()})})},fireActionable:function(){var D=this,W=this.getSelected(),ae=W.filter(function(en){return D.isInstanceOf("MultiFeature",en)}),Ce=!1;if(W.length>1){Ce=!0;var Oe=W[0].type.replace("Multi","");W.forEach(function(en){en.type.replace("Multi","")!==Oe&&(Ce=!1)})}var qe=ae.length>0,nt=W.length>0;this.setActionableState({combineFeatures:Ce,uncombineFeatures:qe,trash:nt})},getUniqueIds:function(D){return D.length?D.map(function(W){return W.properties.id}).filter(function(W){return W!==void 0}).reduce(function(W,ae){return W.add(ae),W},new Xe).values():[]},stopExtendedInteractions:function(D){D.boxSelectElement&&(D.boxSelectElement.parentNode&&D.boxSelectElement.parentNode.removeChild(D.boxSelectElement),D.boxSelectElement=null),this.map.dragPan.enable(),D.boxSelecting=!1,D.canBoxSelect=!1,D.dragMoving=!1,D.canDragMove=!1},onStop:function(){ye.enable(this)},onMouseMove:function(D,W){return kt(W)&&D.dragMoving&&this.fireUpdate(),this.stopExtendedInteractions(D),!0},onMouseOut:function(D){return!D.dragMoving||this.fireUpdate()}};tr.onTap=tr.onClick=function(D,W){return ri(W)?this.clickAnywhere(D,W):Tt(K.VERTEX)(W)?this.clickOnVertex(D,W):kt(W)?this.clickOnFeature(D,W):void 0},tr.clickAnywhere=function(D){var W=this,ae=this.getSelectedIds();ae.length&&(this.clearSelectedFeatures(),ae.forEach(function(Ce){return W.doRender(Ce)})),ye.enable(this),this.stopExtendedInteractions(D)},tr.clickOnVertex=function(D,W){this.changeMode(F.DIRECT_SELECT,{featureId:W.featureTarget.properties.parent,coordPath:W.featureTarget.properties.coord_path,startPos:W.lngLat}),this.updateUIClasses({mouse:k.MOVE})},tr.startOnActiveFeature=function(D,W){this.stopExtendedInteractions(D),this.map.dragPan.disable(),this.doRender(W.featureTarget.properties.id),D.canDragMove=!0,D.dragMoveLocation=W.lngLat},tr.clickOnFeature=function(D,W){var ae=this;ye.disable(this),this.stopExtendedInteractions(D);var Ce=On(W),Oe=this.getSelectedIds(),qe=W.featureTarget.properties.id,nt=this.isSelected(qe);if(!Ce&&nt&&this.getFeature(qe).type!==B.POINT)return this.changeMode(F.DIRECT_SELECT,{featureId:qe});nt&&Ce?(this.deselect(qe),this.updateUIClasses({mouse:k.POINTER}),Oe.length===1&&ye.enable(this)):!nt&&Ce?(this.select(qe),this.updateUIClasses({mouse:k.MOVE})):nt||Ce||(Oe.forEach(function(en){return ae.doRender(en)}),this.setSelected(qe),this.updateUIClasses({mouse:k.MOVE})),this.doRender(qe)},tr.onMouseDown=function(D,W){return _n(W)?this.startOnActiveFeature(D,W):this.drawConfig.boxSelect&&hn(W)?this.startBoxSelect(D,W):void 0},tr.startBoxSelect=function(D,W){this.stopExtendedInteractions(D),this.map.dragPan.disable(),D.boxSelectStartLocation=un(W.originalEvent,this.map.getContainer()),D.canBoxSelect=!0},tr.onTouchStart=function(D,W){if(_n(W))return this.startOnActiveFeature(D,W)},tr.onDrag=function(D,W){return D.canDragMove?this.dragMove(D,W):this.drawConfig.boxSelect&&D.canBoxSelect?this.whileBoxSelect(D,W):void 0},tr.whileBoxSelect=function(D,W){D.boxSelecting=!0,this.updateUIClasses({mouse:k.ADD}),D.boxSelectElement||(D.boxSelectElement=document.createElement("div"),D.boxSelectElement.classList.add(T.BOX_SELECT),this.map.getContainer().appendChild(D.boxSelectElement));var ae=un(W.originalEvent,this.map.getContainer()),Ce=Math.min(D.boxSelectStartLocation.x,ae.x),Oe=Math.max(D.boxSelectStartLocation.x,ae.x),qe=Math.min(D.boxSelectStartLocation.y,ae.y),nt=Math.max(D.boxSelectStartLocation.y,ae.y),en="translate("+Ce+"px, "+qe+"px)";D.boxSelectElement.style.transform=en,D.boxSelectElement.style.WebkitTransform=en,D.boxSelectElement.style.width=Oe-Ce+"px",D.boxSelectElement.style.height=nt-qe+"px"},tr.dragMove=function(D,W){D.dragMoving=!0,W.originalEvent.stopPropagation();var ae={lng:W.lngLat.lng-D.dragMoveLocation.lng,lat:W.lngLat.lat-D.dragMoveLocation.lat};er(this.getSelected(),ae),D.dragMoveLocation=W.lngLat},tr.onTouchEnd=tr.onMouseUp=function(D,W){var ae=this;if(D.dragMoving)this.fireUpdate();else if(D.boxSelecting){var Ce=[D.boxSelectStartLocation,un(W.originalEvent,this.map.getContainer())],Oe=this.featuresAt(null,Ce,"click"),qe=this.getUniqueIds(Oe).filter(function(nt){return!ae.isSelected(nt)});qe.length&&(this.select(qe),qe.forEach(function(nt){return ae.doRender(nt)}),this.updateUIClasses({mouse:k.MOVE}))}this.stopExtendedInteractions(D)},tr.toDisplayFeatures=function(D,W,ae){W.properties.active=this.isSelected(W.properties.id)?ne.ACTIVE:ne.INACTIVE,ae(W),this.fireActionable(),W.properties.active===ne.ACTIVE&&W.geometry.type!==B.POINT&&se(W).forEach(ae)},tr.onTrash=function(){this.deleteFeature(this.getSelectedIds()),this.fireActionable()},tr.onCombineFeatures=function(){var D=this.getSelected();if(!(D.length===0||D.length<2)){for(var W=[],ae=[],Ce=D[0].type.replace("Multi",""),Oe=0;Oe<D.length;Oe++){var qe=D[Oe];if(qe.type.replace("Multi","")!==Ce)return;qe.type.includes("Multi")?qe.getCoordinates().forEach(function(en){W.push(en)}):W.push(qe.getCoordinates()),ae.push(qe.toGeoJSON())}if(ae.length>1){var nt=this.newFeature({type:B.FEATURE,properties:ae[0].properties,geometry:{type:"Multi"+Ce,coordinates:W}});this.addFeature(nt),this.deleteFeature(this.getSelectedIds(),{silent:!0}),this.setSelected([nt.id]),this.map.fire(H.COMBINE_FEATURES,{createdFeatures:[nt.toGeoJSON()],deletedFeatures:ae})}this.fireActionable()}},tr.onUncombineFeatures=function(){var D=this,W=this.getSelected();if(W.length!==0){for(var ae=[],Ce=[],Oe=function(nt){var en=W[nt];D.isInstanceOf("MultiFeature",en)&&(en.getFeatures().forEach(function(cn){D.addFeature(cn),cn.properties=en.properties,ae.push(cn.toGeoJSON()),D.select([cn.id])}),D.deleteFeature(en.id,{silent:!0}),Ce.push(en.toGeoJSON()))},qe=0;qe<W.length;qe++)Oe(qe);ae.length>1&&this.map.fire(H.UNCOMBINE_FEATURES,{createdFeatures:ae,deletedFeatures:Ce}),this.fireActionable()}};var po=Tt(K.VERTEX),Es=Tt(K.MIDPOINT),Ir={fireUpdate:function(){this.map.fire(H.UPDATE,{action:Y.CHANGE_COORDINATES,features:this.getSelected().map(function(D){return D.toGeoJSON()})})},fireActionable:function(D){this.setActionableState({combineFeatures:!1,uncombineFeatures:!1,trash:D.selectedCoordPaths.length>0})},startDragging:function(D,W){this.map.dragPan.disable(),D.canDragMove=!0,D.dragMoveLocation=W.lngLat},stopDragging:function(D){this.map.dragPan.enable(),D.dragMoving=!1,D.canDragMove=!1,D.dragMoveLocation=null},onVertex:function(D,W){this.startDragging(D,W);var ae=W.featureTarget.properties,Ce=D.selectedCoordPaths.indexOf(ae.coord_path);On(W)||Ce!==-1?On(W)&&Ce===-1&&D.selectedCoordPaths.push(ae.coord_path):D.selectedCoordPaths=[ae.coord_path];var Oe=this.pathsToCoordinates(D.featureId,D.selectedCoordPaths);this.setSelectedCoordinates(Oe)},onMidpoint:function(D,W){this.startDragging(D,W);var ae=W.featureTarget.properties;D.feature.addCoordinate(ae.coord_path,ae.lng,ae.lat),this.fireUpdate(),D.selectedCoordPaths=[ae.coord_path]},pathsToCoordinates:function(D,W){return W.map(function(ae){return{feature_id:D,coord_path:ae}})},onFeature:function(D,W){D.selectedCoordPaths.length===0?this.startDragging(D,W):this.stopDragging(D)},dragFeature:function(D,W,ae){er(this.getSelected(),ae),D.dragMoveLocation=W.lngLat},dragVertex:function(D,W,ae){for(var Ce=D.selectedCoordPaths.map(function(en){return D.feature.getCoordinate(en)}),Oe=Ur(Ce.map(function(en){return{type:B.FEATURE,properties:{},geometry:{type:B.POINT,coordinates:en}}}),ae),qe=0;qe<Ce.length;qe++){var nt=Ce[qe];D.feature.updateCoordinate(D.selectedCoordPaths[qe],nt[0]+Oe.lng,nt[1]+Oe.lat)}},clickNoTarget:function(){this.changeMode(F.SIMPLE_SELECT)},clickInactive:function(){this.changeMode(F.SIMPLE_SELECT)},clickActiveFeature:function(D){D.selectedCoordPaths=[],this.clearSelectedCoordinates(),D.feature.changed()},onSetup:function(D){var W=D.featureId,ae=this.getFeature(W);if(!ae)throw new Error("You must provide a featureId to enter direct_select mode");if(ae.type===B.POINT)throw new TypeError("direct_select mode doesn't handle point features");var Ce={featureId:W,feature:ae,dragMoveLocation:D.startPos||null,dragMoving:!1,canDragMove:!1,selectedCoordPaths:D.coordPath?[D.coordPath]:[]};return this.setSelectedCoordinates(this.pathsToCoordinates(W,Ce.selectedCoordPaths)),this.setSelected(W),ye.disable(this),this.setActionableState({trash:!0}),Ce},onStop:function(){ye.enable(this),this.clearSelectedCoordinates()},toDisplayFeatures:function(D,W,ae){D.featureId===W.properties.id?(W.properties.active=ne.ACTIVE,ae(W),se(W,{map:this.map,midpoints:!0,selectedPaths:D.selectedCoordPaths}).forEach(ae)):(W.properties.active=ne.INACTIVE,ae(W)),this.fireActionable(D)},onTrash:function(D){D.selectedCoordPaths.sort(function(W,ae){return ae.localeCompare(W,"en",{numeric:!0})}).forEach(function(W){return D.feature.removeCoordinate(W)}),this.fireUpdate(),D.selectedCoordPaths=[],this.clearSelectedCoordinates(),this.fireActionable(D),D.feature.isValid()===!1&&(this.deleteFeature([D.featureId]),this.changeMode(F.SIMPLE_SELECT,{}))},onMouseMove:function(D,W){var ae=_n(W),Ce=po(W),Oe=Es(W),qe=D.selectedCoordPaths.length===0;return ae&&qe||Ce&&!qe?this.updateUIClasses({mouse:k.MOVE}):this.updateUIClasses({mouse:k.NONE}),(Ce||ae||Oe)&&D.dragMoving&&this.fireUpdate(),this.stopDragging(D),!0},onMouseOut:function(D){return D.dragMoving&&this.fireUpdate(),!0}};Ir.onTouchStart=Ir.onMouseDown=function(D,W){return po(W)?this.onVertex(D,W):_n(W)?this.onFeature(D,W):Es(W)?this.onMidpoint(D,W):void 0},Ir.onDrag=function(D,W){if(D.canDragMove===!0){D.dragMoving=!0,W.originalEvent.stopPropagation();var ae={lng:W.lngLat.lng-D.dragMoveLocation.lng,lat:W.lngLat.lat-D.dragMoveLocation.lat};D.selectedCoordPaths.length>0?this.dragVertex(D,W,ae):this.dragFeature(D,W,ae),D.dragMoveLocation=W.lngLat}},Ir.onClick=function(D,W){return ri(W)?this.clickNoTarget(D,W):_n(W)?this.clickActiveFeature(D,W):Sn(W)?this.clickInactive(D,W):void this.stopDragging(D)},Ir.onTap=function(D,W){return ri(W)?this.clickNoTarget(D,W):_n(W)?this.clickActiveFeature(D,W):Sn(W)?this.clickInactive(D,W):void 0},Ir.onTouchEnd=Ir.onMouseUp=function(D){D.dragMoving&&this.fireUpdate(),this.stopDragging(D)};var Zi={};function ct(D,W){return!!D.lngLat&&D.lngLat.lng===W[0]&&D.lngLat.lat===W[1]}Zi.onSetup=function(){var D=this.newFeature({type:B.FEATURE,properties:{},geometry:{type:B.POINT,coordinates:[]}});return this.addFeature(D),this.clearSelectedFeatures(),this.updateUIClasses({mouse:k.ADD}),this.activateUIButton(O.POINT),this.setActionableState({trash:!0}),{point:D}},Zi.stopDrawingAndRemove=function(D){this.deleteFeature([D.point.id],{silent:!0}),this.changeMode(F.SIMPLE_SELECT)},Zi.onTap=Zi.onClick=function(D,W){this.updateUIClasses({mouse:k.MOVE}),D.point.updateCoordinate("",W.lngLat.lng,W.lngLat.lat),this.map.fire(H.CREATE,{features:[D.point.toGeoJSON()]}),this.changeMode(F.SIMPLE_SELECT,{featureIds:[D.point.id]})},Zi.onStop=function(D){this.activateUIButton(),D.point.getCoordinate().length||this.deleteFeature([D.point.id],{silent:!0})},Zi.toDisplayFeatures=function(D,W,ae){var Ce=W.properties.id===D.point.id;if(W.properties.active=Ce?ne.ACTIVE:ne.INACTIVE,!Ce)return ae(W)},Zi.onTrash=Zi.stopDrawingAndRemove,Zi.onKeyUp=function(D,W){if(Fn(W)||Ze(W))return this.stopDrawingAndRemove(D,W)};var Ri={onSetup:function(){var D=this.newFeature({type:B.FEATURE,properties:{},geometry:{type:B.POLYGON,coordinates:[[]]}});return this.addFeature(D),this.clearSelectedFeatures(),ye.disable(this),this.updateUIClasses({mouse:k.ADD}),this.activateUIButton(O.POLYGON),this.setActionableState({trash:!0}),{polygon:D,currentVertexPosition:0}},clickAnywhere:function(D,W){if(D.currentVertexPosition>0&&ct(W,D.polygon.coordinates[0][D.currentVertexPosition-1]))return this.changeMode(F.SIMPLE_SELECT,{featureIds:[D.polygon.id]});this.updateUIClasses({mouse:k.ADD}),D.polygon.updateCoordinate("0."+D.currentVertexPosition,W.lngLat.lng,W.lngLat.lat),D.currentVertexPosition++,D.polygon.updateCoordinate("0."+D.currentVertexPosition,W.lngLat.lng,W.lngLat.lat)},clickOnVertex:function(D){return this.changeMode(F.SIMPLE_SELECT,{featureIds:[D.polygon.id]})},onMouseMove:function(D,W){D.polygon.updateCoordinate("0."+D.currentVertexPosition,W.lngLat.lng,W.lngLat.lat),Hn(W)&&this.updateUIClasses({mouse:k.POINTER})}};Ri.onTap=Ri.onClick=function(D,W){return Hn(W)?this.clickOnVertex(D,W):this.clickAnywhere(D,W)},Ri.onKeyUp=function(D,W){Fn(W)?(this.deleteFeature([D.polygon.id],{silent:!0}),this.changeMode(F.SIMPLE_SELECT)):Ze(W)&&this.changeMode(F.SIMPLE_SELECT,{featureIds:[D.polygon.id]})},Ri.onStop=function(D){this.updateUIClasses({mouse:k.NONE}),ye.enable(this),this.activateUIButton(),this.getFeature(D.polygon.id)!==void 0&&(D.polygon.removeCoordinate("0."+D.currentVertexPosition),D.polygon.isValid()?this.map.fire(H.CREATE,{features:[D.polygon.toGeoJSON()]}):(this.deleteFeature([D.polygon.id],{silent:!0}),this.changeMode(F.SIMPLE_SELECT,{},{silent:!0})))},Ri.toDisplayFeatures=function(D,W,ae){var Ce=W.properties.id===D.polygon.id;if(W.properties.active=Ce?ne.ACTIVE:ne.INACTIVE,!Ce)return ae(W);if(W.geometry.coordinates.length!==0){var Oe=W.geometry.coordinates[0].length;if(!(Oe<3)){if(W.properties.meta=K.FEATURE,ae(ue(D.polygon.id,W.geometry.coordinates[0][0],"0.0",!1)),Oe>3){var qe=W.geometry.coordinates[0].length-3;ae(ue(D.polygon.id,W.geometry.coordinates[0][qe],"0."+qe,!1))}if(Oe<=4){var nt=[[W.geometry.coordinates[0][0][0],W.geometry.coordinates[0][0][1]],[W.geometry.coordinates[0][1][0],W.geometry.coordinates[0][1][1]]];if(ae({type:B.FEATURE,properties:W.properties,geometry:{coordinates:nt,type:B.LINE_STRING}}),Oe===3)return}return ae(W)}}},Ri.onTrash=function(D){this.deleteFeature([D.polygon.id],{silent:!0}),this.changeMode(F.SIMPLE_SELECT)};var Ci={onSetup:function(D){var W,ae,Ce=(D=D||{}).featureId,Oe="forward";if(Ce){if(!(W=this.getFeature(Ce)))throw new Error("Could not find a feature with the provided featureId");var qe=D.from;if(qe&&qe.type==="Feature"&&qe.geometry&&qe.geometry.type==="Point"&&(qe=qe.geometry),qe&&qe.type==="Point"&&qe.coordinates&&qe.coordinates.length===2&&(qe=qe.coordinates),!qe||!Array.isArray(qe))throw new Error("Please use the `from` property to indicate which point to continue the line from");var nt=W.coordinates.length-1;if(W.coordinates[nt][0]===qe[0]&&W.coordinates[nt][1]===qe[1])ae=nt+1,W.addCoordinate.apply(W,[ae].concat(W.coordinates[nt]));else{if(W.coordinates[0][0]!==qe[0]||W.coordinates[0][1]!==qe[1])throw new Error("`from` should match the point at either the start or the end of the provided LineString");Oe="backwards",ae=0,W.addCoordinate.apply(W,[ae].concat(W.coordinates[0]))}}else W=this.newFeature({type:B.FEATURE,properties:{},geometry:{type:B.LINE_STRING,coordinates:[]}}),ae=0,this.addFeature(W);return this.clearSelectedFeatures(),ye.disable(this),this.updateUIClasses({mouse:k.ADD}),this.activateUIButton(O.LINE),this.setActionableState({trash:!0}),{line:W,currentVertexPosition:ae,direction:Oe}},clickAnywhere:function(D,W){if(D.currentVertexPosition>0&&ct(W,D.line.coordinates[D.currentVertexPosition-1])||D.direction==="backwards"&&ct(W,D.line.coordinates[D.currentVertexPosition+1]))return this.changeMode(F.SIMPLE_SELECT,{featureIds:[D.line.id]});this.updateUIClasses({mouse:k.ADD}),D.line.updateCoordinate(D.currentVertexPosition,W.lngLat.lng,W.lngLat.lat),D.direction==="forward"?(D.currentVertexPosition++,D.line.updateCoordinate(D.currentVertexPosition,W.lngLat.lng,W.lngLat.lat)):D.line.addCoordinate(0,W.lngLat.lng,W.lngLat.lat)},clickOnVertex:function(D){return this.changeMode(F.SIMPLE_SELECT,{featureIds:[D.line.id]})},onMouseMove:function(D,W){D.line.updateCoordinate(D.currentVertexPosition,W.lngLat.lng,W.lngLat.lat),Hn(W)&&this.updateUIClasses({mouse:k.POINTER})}};Ci.onTap=Ci.onClick=function(D,W){if(Hn(W))return this.clickOnVertex(D,W);this.clickAnywhere(D,W)},Ci.onKeyUp=function(D,W){Ze(W)?this.changeMode(F.SIMPLE_SELECT,{featureIds:[D.line.id]}):Fn(W)&&(this.deleteFeature([D.line.id],{silent:!0}),this.changeMode(F.SIMPLE_SELECT))},Ci.onStop=function(D){ye.enable(this),this.activateUIButton(),this.getFeature(D.line.id)!==void 0&&(D.line.removeCoordinate(""+D.currentVertexPosition),D.line.isValid()?this.map.fire(H.CREATE,{features:[D.line.toGeoJSON()]}):(this.deleteFeature([D.line.id],{silent:!0}),this.changeMode(F.SIMPLE_SELECT,{},{silent:!0})))},Ci.onTrash=function(D){this.deleteFeature([D.line.id],{silent:!0}),this.changeMode(F.SIMPLE_SELECT)},Ci.toDisplayFeatures=function(D,W,ae){var Ce=W.properties.id===D.line.id;if(W.properties.active=Ce?ne.ACTIVE:ne.INACTIVE,!Ce)return ae(W);W.geometry.coordinates.length<2||(W.properties.meta=K.FEATURE,ae(ue(D.line.id,W.geometry.coordinates[D.direction==="forward"?W.geometry.coordinates.length-2:1],""+(D.direction==="forward"?W.geometry.coordinates.length-2:1),!1)),ae(W))};var nr={simple_select:tr,direct_select:Ir,draw_point:Zi,draw_polygon:Ri,draw_line_string:Ci},Os={defaultMode:F.SIMPLE_SELECT,keybindings:!0,touchEnabled:!0,clickBuffer:2,touchBuffer:25,boxSelect:!0,displayControlsDefault:!0,styles:xe,modes:nr,controls:{},userProperties:!1},Ts={point:!0,line_string:!0,polygon:!0,trash:!0,combine_features:!0,uncombine_features:!0},Ra={point:!1,line_string:!1,polygon:!1,trash:!1,combine_features:!1,uncombine_features:!1};function As(D,W){return D.map(function(ae){return ae.source?ae:li(ae,{id:ae.id+"."+W,source:W==="hot"?I.HOT:I.COLD})})}var Uo={exports:{}};(function(D,W){var ae="__lodash_hash_undefined__",Ce=9007199254740991,Oe="[object Arguments]",qe="[object Array]",nt="[object Boolean]",en="[object Date]",cn="[object Error]",Ln="[object Function]",Pn="[object Map]",xn="[object Number]",mi="[object Object]",di="[object Promise]",vi="[object RegExp]",Ji="[object Set]",zt="[object String]",Xn="[object Symbol]",ur="[object WeakMap]",wi="[object ArrayBuffer]",or="[object DataView]",lc=/^\[object .+?Constructor\]$/,tl=/^(?:0|[1-9]\d*)$/,Si={};Si["[object Float32Array]"]=Si["[object Float64Array]"]=Si["[object Int8Array]"]=Si["[object Int16Array]"]=Si["[object Int32Array]"]=Si["[object Uint8Array]"]=Si["[object Uint8ClampedArray]"]=Si["[object Uint16Array]"]=Si["[object Uint32Array]"]=!0,Si[Oe]=Si[qe]=Si[wi]=Si[nt]=Si[or]=Si[en]=Si[cn]=Si[Ln]=Si[Pn]=Si[xn]=Si[mi]=Si[vi]=Si[Ji]=Si[zt]=Si[ur]=!1;var ha=typeof Tf=="object"&&Tf&&Tf.Object===Object&&Tf,To=typeof self=="object"&&self&&self.Object===Object&&self,Fs=ha||To||Function("return this")(),os=W&&!W.nodeType&&W,mo=os&&D&&!D.nodeType&&D,Ao=mo&&mo.exports===os,Js=Ao&&ha.process,Vo=function(){try{return Js&&Js.binding&&Js.binding("util")}catch{}}(),gl=Vo&&Vo.isTypedArray;function dh(ot,At){for(var yn=-1,ni=ot==null?0:ot.length;++yn<ni;)if(At(ot[yn],yn,ot))return!0;return!1}function Co(ot){var At=-1,yn=Array(ot.size);return ot.forEach(function(ni,fr){yn[++At]=[fr,ni]}),yn}function _l(ot){var At=-1,yn=Array(ot.size);return ot.forEach(function(ni){yn[++At]=ni}),yn}var Ks,cc,as,Io=Array.prototype,Da=Function.prototype,ds=Object.prototype,za=Fs["__core-js_shared__"],da=Da.toString,Bs=ds.hasOwnProperty,Ol=(Ks=/[^.]+$/.exec(za&&za.keys&&za.keys.IE_PROTO||""))?"Symbol(src)_1."+Ks:"",nl=ds.toString,ka=RegExp("^"+da.call(Bs).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ns=Ao?Fs.Buffer:void 0,ls=Fs.Symbol,Bi=Fs.Uint8Array,uc=ds.propertyIsEnumerable,hc=Io.splice,Cs=ls?ls.toStringTag:void 0,Go=Object.getOwnPropertySymbols,Fl=Ns?Ns.isBuffer:void 0,dc=(cc=Object.keys,as=Object,function(ot){return cc(as(ot))}),jo=Ua(Fs,"DataView"),fa=Ua(Fs,"Map"),pa=Ua(Fs,"Promise"),go=Ua(Fs,"Set"),Po=Ua(Fs,"WeakMap"),ma=Ua(Object,"create"),qc=yo(jo),yl=yo(fa),Bl=yo(pa),Oa=yo(go),ga=yo(Po),Fa=ls?ls.prototype:void 0,Ba=Fa?Fa.valueOf:void 0;function gi(ot){var At=-1,yn=ot==null?0:ot.length;for(this.clear();++At<yn;){var ni=ot[At];this.set(ni[0],ni[1])}}function Or(ot){var At=-1,yn=ot==null?0:ot.length;for(this.clear();++At<yn;){var ni=ot[At];this.set(ni[0],ni[1])}}function Qs(ot){var At=-1,yn=ot==null?0:ot.length;for(this.clear();++At<yn;){var ni=ot[At];this.set(ni[0],ni[1])}}function eo(ot){var At=-1,yn=ot==null?0:ot.length;for(this.__data__=new Qs;++At<yn;)this.add(ot[At])}function fs(ot){var At=this.__data__=new Or(ot);this.size=At.size}function _o(ot,At){var yn=ps(ot),ni=!yn&&Nl(ot),fr=!yn&&!ni&&_a(ot),Wi=!yn&&!ni&&!fr&&bl(ot),Pr=yn||ni||fr||Wi,Ti=Pr?function(Vr,cs){for(var Jr=-1,Kr=Array(Vr);++Jr<Vr;)Kr[Jr]=cs(Jr);return Kr}(ot.length,String):[],Gs=Ti.length;for(var Fr in ot)!At&&!Bs.call(ot,Fr)||Pr&&(Fr=="length"||fr&&(Fr=="offset"||Fr=="parent")||Wi&&(Fr=="buffer"||Fr=="byteLength"||Fr=="byteOffset")||sl(Fr,Gs))||Ti.push(Fr);return Ti}function il(ot,At){for(var yn=ot.length;yn--;)if(Wo(ot[yn][0],At))return yn;return-1}function rl(ot){return ot==null?ot===void 0?"[object Undefined]":"[object Null]":Cs&&Cs in Object(ot)?function(At){var yn=Bs.call(At,Cs),ni=At[Cs];try{At[Cs]=void 0;var fr=!0}catch{}var Wi=nl.call(At);return fr&&(yn?At[Cs]=ni:delete At[Cs]),Wi}(ot):function(At){return nl.call(At)}(ot)}function fc(ot){return Ga(ot)&&rl(ot)==Oe}function to(ot,At,yn,ni,fr){return ot===At||(ot==null||At==null||!Ga(ot)&&!Ga(At)?ot!=ot&&At!=At:function(Wi,Pr,Ti,Gs,Fr,Vr){var cs=ps(Wi),Jr=ps(Pr),Kr=cs?qe:no(Wi),pr=Jr?qe:no(Pr),qr=(Kr=Kr==Oe?mi:Kr)==mi,Zr=(pr=pr==Oe?mi:pr)==mi,ta=Kr==pr;if(ta&&_a(Wi)){if(!_a(Pr))return!1;cs=!0,qr=!1}if(ta&&!qr)return Vr||(Vr=new fs),cs||bl(Wi)?Na(Wi,Pr,Ti,Gs,Fr,Vr):function(Xi,ir,gs,Qr,xo,Br,_s){switch(gs){case or:if(Xi.byteLength!=ir.byteLength||Xi.byteOffset!=ir.byteOffset)return!1;Xi=Xi.buffer,ir=ir.buffer;case wi:return!(Xi.byteLength!=ir.byteLength||!Br(new Bi(Xi),new Bi(ir)));case nt:case en:case xn:return Wo(+Xi,+ir);case cn:return Xi.name==ir.name&&Xi.message==ir.message;case vi:case zt:return Xi==ir+"";case Pn:var ro=Co;case Ji:var ya=1&Qr;if(ro||(ro=_l),Xi.size!=ir.size&&!ya)return!1;var Gi=_s.get(Xi);if(Gi)return Gi==ir;Qr|=2,_s.set(Xi,ir);var qo=Na(ro(Xi),ro(ir),Qr,xo,Br,_s);return _s.delete(Xi),qo;case Xn:if(Ba)return Ba.call(Xi)==Ba.call(ir)}return!1}(Wi,Pr,Kr,Ti,Gs,Fr,Vr);if(!(1&Ti)){var Lo=qr&&Bs.call(Wi,"__wrapped__"),Ho=Zr&&Bs.call(Pr,"__wrapped__");if(Lo||Ho){var Eu=Lo?Wi.value():Wi,ms=Ho?Pr.value():Pr;return Vr||(Vr=new fs),Fr(Eu,ms,Ti,Gs,Vr)}}return ta?(Vr||(Vr=new fs),function(Xi,ir,gs,Qr,xo,Br){var _s=1&gs,ro=Vs(Xi),ya=ro.length,Gi=Vs(ir).length;if(ya!=Gi&&!_s)return!1;for(var qo=ya;qo--;){var xa=ro[qo];if(!(_s?xa in ir:Bs.call(ir,xa)))return!1}var wl=Br.get(Xi);if(wl&&Br.get(ir))return wl==ir;var na=!0;Br.set(Xi,ir),Br.set(ir,Xi);for(var Sl=_s;++qo<ya;){var Zo=Xi[xa=ro[qo]],vo=ir[xa];if(Qr)var Ml=_s?Qr(vo,Zo,xa,ir,Xi,Br):Qr(Zo,vo,xa,Xi,ir,Br);if(!(Ml===void 0?Zo===vo||xo(Zo,vo,gs,Qr,Br):Ml)){na=!1;break}Sl||(Sl=xa=="constructor")}if(na&&!Sl){var ia=Xi.constructor,Xo=ir.constructor;ia==Xo||!("constructor"in Xi)||!("constructor"in ir)||typeof ia=="function"&&ia instanceof ia&&typeof Xo=="function"&&Xo instanceof Xo||(na=!1)}return Br.delete(Xi),Br.delete(ir),na}(Wi,Pr,Ti,Gs,Fr,Vr)):!1}(ot,At,yn,ni,to,fr))}function Us(ot){return!(!Va(ot)||function(At){return!!Ol&&Ol in At}(ot))&&(Ul(ot)?ka:lc).test(yo(ot))}function Sr(ot){if(yn=(At=ot)&&At.constructor,ni=typeof yn=="function"&&yn.prototype||ds,At!==ni)return dc(ot);var At,yn,ni,fr=[];for(var Wi in Object(ot))Bs.call(ot,Wi)&&Wi!="constructor"&&fr.push(Wi);return fr}function Na(ot,At,yn,ni,fr,Wi){var Pr=1&yn,Ti=ot.length,Gs=At.length;if(Ti!=Gs&&!(Pr&&Gs>Ti))return!1;var Fr=Wi.get(ot);if(Fr&&Wi.get(At))return Fr==At;var Vr=-1,cs=!0,Jr=2&yn?new eo:void 0;for(Wi.set(ot,At),Wi.set(At,ot);++Vr<Ti;){var Kr=ot[Vr],pr=At[Vr];if(ni)var qr=Pr?ni(pr,Kr,Vr,At,ot,Wi):ni(Kr,pr,Vr,ot,At,Wi);if(qr!==void 0){if(qr)continue;cs=!1;break}if(Jr){if(!dh(At,function(Zr,ta){if(Lo=ta,!Jr.has(Lo)&&(Kr===Zr||fr(Kr,Zr,yn,ni,Wi)))return Jr.push(ta);var Lo})){cs=!1;break}}else if(Kr!==pr&&!fr(Kr,pr,yn,ni,Wi)){cs=!1;break}}return Wi.delete(ot),Wi.delete(At),cs}function Vs(ot){return function(At,yn,ni){var fr=yn(At);return ps(At)?fr:function(Wi,Pr){for(var Ti=-1,Gs=Pr.length,Fr=Wi.length;++Ti<Gs;)Wi[Fr+Ti]=Pr[Ti];return Wi}(fr,ni(At))}(ot,io,Zc)}function xl(ot,At){var yn,ni,fr=ot.__data__;return((ni=typeof(yn=At))=="string"||ni=="number"||ni=="symbol"||ni=="boolean"?yn!=="__proto__":yn===null)?fr[typeof At=="string"?"string":"hash"]:fr.map}function Ua(ot,At){var yn=function(ni,fr){return ni==null?void 0:ni[fr]}(ot,At);return Us(yn)?yn:void 0}gi.prototype.clear=function(){this.__data__=ma?ma(null):{},this.size=0},gi.prototype.delete=function(ot){var At=this.has(ot)&&delete this.__data__[ot];return this.size-=At?1:0,At},gi.prototype.get=function(ot){var At=this.__data__;if(ma){var yn=At[ot];return yn===ae?void 0:yn}return Bs.call(At,ot)?At[ot]:void 0},gi.prototype.has=function(ot){var At=this.__data__;return ma?At[ot]!==void 0:Bs.call(At,ot)},gi.prototype.set=function(ot,At){var yn=this.__data__;return this.size+=this.has(ot)?0:1,yn[ot]=ma&&At===void 0?ae:At,this},Or.prototype.clear=function(){this.__data__=[],this.size=0},Or.prototype.delete=function(ot){var At=this.__data__,yn=il(At,ot);return!(yn<0)&&(yn==At.length-1?At.pop():hc.call(At,yn,1),--this.size,!0)},Or.prototype.get=function(ot){var At=this.__data__,yn=il(At,ot);return yn<0?void 0:At[yn][1]},Or.prototype.has=function(ot){return il(this.__data__,ot)>-1},Or.prototype.set=function(ot,At){var yn=this.__data__,ni=il(yn,ot);return ni<0?(++this.size,yn.push([ot,At])):yn[ni][1]=At,this},Qs.prototype.clear=function(){this.size=0,this.__data__={hash:new gi,map:new(fa||Or),string:new gi}},Qs.prototype.delete=function(ot){var At=xl(this,ot).delete(ot);return this.size-=At?1:0,At},Qs.prototype.get=function(ot){return xl(this,ot).get(ot)},Qs.prototype.has=function(ot){return xl(this,ot).has(ot)},Qs.prototype.set=function(ot,At){var yn=xl(this,ot),ni=yn.size;return yn.set(ot,At),this.size+=yn.size==ni?0:1,this},eo.prototype.add=eo.prototype.push=function(ot){return this.__data__.set(ot,ae),this},eo.prototype.has=function(ot){return this.__data__.has(ot)},fs.prototype.clear=function(){this.__data__=new Or,this.size=0},fs.prototype.delete=function(ot){var At=this.__data__,yn=At.delete(ot);return this.size=At.size,yn},fs.prototype.get=function(ot){return this.__data__.get(ot)},fs.prototype.has=function(ot){return this.__data__.has(ot)},fs.prototype.set=function(ot,At){var yn=this.__data__;if(yn instanceof Or){var ni=yn.__data__;if(!fa||ni.length<199)return ni.push([ot,At]),this.size=++yn.size,this;yn=this.__data__=new Qs(ni)}return yn.set(ot,At),this.size=yn.size,this};var Zc=Go?function(ot){return ot==null?[]:(ot=Object(ot),function(At,yn){for(var ni=-1,fr=At==null?0:At.length,Wi=0,Pr=[];++ni<fr;){var Ti=At[ni];yn(Ti,ni,At)&&(Pr[Wi++]=Ti)}return Pr}(Go(ot),function(At){return uc.call(ot,At)}))}:function(){return[]},no=rl;function sl(ot,At){return!!(At=At==null?Ce:At)&&(typeof ot=="number"||tl.test(ot))&&ot>-1&&ot%1==0&&ot<At}function yo(ot){if(ot!=null){try{return da.call(ot)}catch{}try{return ot+""}catch{}}return""}function Wo(ot,At){return ot===At||ot!=ot&&At!=At}(jo&&no(new jo(new ArrayBuffer(1)))!=or||fa&&no(new fa)!=Pn||pa&&no(pa.resolve())!=di||go&&no(new go)!=Ji||Po&&no(new Po)!=ur)&&(no=function(ot){var At=rl(ot),yn=At==mi?ot.constructor:void 0,ni=yn?yo(yn):"";if(ni)switch(ni){case qc:return or;case yl:return Pn;case Bl:return di;case Oa:return Ji;case ga:return ur}return At});var Nl=fc(function(){return arguments}())?fc:function(ot){return Ga(ot)&&Bs.call(ot,"callee")&&!uc.call(ot,"callee")},ps=Array.isArray,_a=Fl||function(){return!1};function Ul(ot){if(!Va(ot))return!1;var At=rl(ot);return At==Ln||At=="[object GeneratorFunction]"||At=="[object AsyncFunction]"||At=="[object Proxy]"}function vl(ot){return typeof ot=="number"&&ot>-1&&ot%1==0&&ot<=Ce}function Va(ot){var At=typeof ot;return ot!=null&&(At=="object"||At=="function")}function Ga(ot){return ot!=null&&typeof ot=="object"}var bl=gl?function(ot){return function(At){return ot(At)}}(gl):function(ot){return Ga(ot)&&vl(ot.length)&&!!Si[rl(ot)]};function io(ot){return(At=ot)!=null&&vl(At.length)&&!Ul(At)?_o(ot):Sr(ot);var At}D.exports=function(ot,At){return to(ot,At)}})(Uo,Uo.exports);var En=a(Uo.exports);function Oi(D,W){return D.length===W.length&&JSON.stringify(D.map(function(ae){return ae}).sort())===JSON.stringify(W.map(function(ae){return ae}).sort())}var Mi={Polygon:Mt,LineString:pn,Point:ln,MultiPolygon:Wn,MultiLineString:Wn,MultiPoint:Wn},Ys=Object.freeze({__proto__:null,CommonSelectors:Tn,constrainFeatureMovement:Ur,createMidPoint:te,createSupplementaryPoints:se,createVertex:ue,doubleClickZoom:ye,euclideanDistance:Nt,featuresAt:Je,getFeatureAtAndSetCursors:ft,isClick:Fe,isEventAtCoordinates:ct,isTap:it,mapEventToBoundingBox:ke,ModeHandler:n,moveFeatures:er,sortFeatures:Re,stringSetsAreEqual:Oi,StringSet:Xe,theme:xe,toDenseArray:gn}),Hr=function(D,W){var ae={options:D=function(Oe){Oe===void 0&&(Oe={});var qe=li(Oe);return Oe.controls||(qe.controls={}),Oe.displayControlsDefault===!1?qe.controls=li(Ra,Oe.controls):qe.controls=li(Ts,Oe.controls),(qe=li(Os,qe)).styles=As(qe.styles,"cold").concat(As(qe.styles,"hot")),qe}(D)};W=function(Oe,qe){return qe.modes=F,qe.getFeatureIdsAt=function(nt){return Je.click({point:nt},null,Oe).map(function(en){return en.properties.id})},qe.getSelectedIds=function(){return Oe.store.getSelectedIds()},qe.getSelected=function(){return{type:B.FEATURE_COLLECTION,features:Oe.store.getSelectedIds().map(function(nt){return Oe.store.get(nt)}).map(function(nt){return nt.toGeoJSON()})}},qe.getSelectedPoints=function(){return{type:B.FEATURE_COLLECTION,features:Oe.store.getSelectedCoordinates().map(function(nt){return{type:B.FEATURE,properties:{},geometry:{type:B.POINT,coordinates:nt.coordinates}}})}},qe.set=function(nt){if(nt.type===void 0||nt.type!==B.FEATURE_COLLECTION||!Array.isArray(nt.features))throw new Error("Invalid FeatureCollection");var en=Oe.store.createRenderBatch(),cn=Oe.store.getAllIds().slice(),Ln=qe.add(nt),Pn=new Xe(Ln);return(cn=cn.filter(function(xn){return!Pn.has(xn)})).length&&qe.delete(cn),en(),Ln},qe.add=function(nt){var en=JSON.parse(JSON.stringify(st(nt))).features.map(function(cn){if(cn.id=cn.id||xt(),cn.geometry===null)throw new Error("Invalid geometry: null");if(Oe.store.get(cn.id)===void 0||Oe.store.get(cn.id).type!==cn.geometry.type){var Ln=Mi[cn.geometry.type];if(Ln===void 0)throw new Error("Invalid geometry type: "+cn.geometry.type+".");var Pn=new Ln(Oe,cn);Oe.store.add(Pn)}else{var xn=Oe.store.get(cn.id);xn.properties=cn.properties,En(xn.properties,cn.properties)||Oe.store.featureChanged(xn.id),En(xn.getCoordinates(),cn.geometry.coordinates)||xn.incomingCoords(cn.geometry.coordinates)}return cn.id});return Oe.store.render(),en},qe.get=function(nt){var en=Oe.store.get(nt);if(en)return en.toGeoJSON()},qe.getAll=function(){return{type:B.FEATURE_COLLECTION,features:Oe.store.getAll().map(function(nt){return nt.toGeoJSON()})}},qe.delete=function(nt){return Oe.store.delete(nt,{silent:!0}),qe.getMode()!==F.DIRECT_SELECT||Oe.store.getSelectedIds().length?Oe.store.render():Oe.events.changeMode(F.SIMPLE_SELECT,void 0,{silent:!0}),qe},qe.deleteAll=function(){return Oe.store.delete(Oe.store.getAllIds(),{silent:!0}),qe.getMode()===F.DIRECT_SELECT?Oe.events.changeMode(F.SIMPLE_SELECT,void 0,{silent:!0}):Oe.store.render(),qe},qe.changeMode=function(nt,en){return en===void 0&&(en={}),nt===F.SIMPLE_SELECT&&qe.getMode()===F.SIMPLE_SELECT?(Oi(en.featureIds||[],Oe.store.getSelectedIds())||(Oe.store.setSelected(en.featureIds,{silent:!0}),Oe.store.render()),qe):(nt===F.DIRECT_SELECT&&qe.getMode()===F.DIRECT_SELECT&&en.featureId===Oe.store.getSelectedIds()[0]||Oe.events.changeMode(nt,en,{silent:!0}),qe)},qe.getMode=function(){return Oe.events.getMode()},qe.trash=function(){return Oe.events.trash({silent:!0}),qe},qe.combineFeatures=function(){return Oe.events.combineFeatures({silent:!0}),qe},qe.uncombineFeatures=function(){return Oe.events.uncombineFeatures({silent:!0}),qe},qe.setFeatureProperty=function(nt,en,cn){return Oe.store.setFeatureProperty(nt,en,cn),qe},qe}(ae,W),ae.api=W;var Ce=Ie(ae);return W.onAdd=Ce.onAdd,W.onRemove=Ce.onRemove,W.types=O,W.options=D,W};function Ei(D){Hr(D,this)}return Ei.modes=nr,Ei.constants=Ae,Ei.lib=Ys,Ei})})(F2);const R4=Qx(F2.exports);function B2(d,e,n){if(d!==null)for(var a,c,f,m,i,w,E,C=0,T=0,I,k=d.type,O=k==="FeatureCollection",B=k==="Feature",F=O?d.features.length:1,H=0;H<F;H++){E=O?d.features[H].geometry:B?d.geometry:d,I=E?E.type==="GeometryCollection":!1,i=I?E.geometries.length:1;for(var Y=0;Y<i;Y++){var K=0,ne=0;if(m=I?E.geometries[Y]:E,m!==null){w=m.coordinates;var le=m.type;switch(C=n&&(le==="Polygon"||le==="MultiPolygon")?1:0,le){case null:break;case"Point":if(e(w,T,H,K,ne)===!1)return!1;T++,K++;break;case"LineString":case"MultiPoint":for(a=0;a<w.length;a++){if(e(w[a],T,H,K,ne)===!1)return!1;T++,le==="MultiPoint"&&K++}le==="LineString"&&K++;break;case"Polygon":case"MultiLineString":for(a=0;a<w.length;a++){for(c=0;c<w[a].length-C;c++){if(e(w[a][c],T,H,K,ne)===!1)return!1;T++}le==="MultiLineString"&&K++,le==="Polygon"&&ne++}le==="Polygon"&&K++;break;case"MultiPolygon":for(a=0;a<w.length;a++){for(ne=0,c=0;c<w[a].length;c++){for(f=0;f<w[a][c].length-C;f++){if(e(w[a][c][f],T,H,K,ne)===!1)return!1;T++}ne++}K++}break;case"GeometryCollection":for(a=0;a<m.geometries.length;a++)if(B2(m.geometries[a],e,n)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function Kf(d){var e=[1/0,1/0,-1/0,-1/0];return B2(d,function(n){e[0]>n[0]&&(e[0]=n[0]),e[1]>n[1]&&(e[1]=n[1]),e[2]<n[0]&&(e[2]=n[0]),e[3]<n[1]&&(e[3]=n[1])}),e}Kf.default=Kf;function N2(d){if(!d)throw new Error("coord is required");if(!Array.isArray(d)){if(d.type==="Feature"&&d.geometry!==null&&d.geometry.type==="Point")return d.geometry.coordinates;if(d.type==="Point")return d.coordinates}if(Array.isArray(d)&&d.length>=2&&!Array.isArray(d[0])&&!Array.isArray(d[1]))return d;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function D4(d){if(Array.isArray(d))return d;if(d.type==="Feature"){if(d.geometry!==null)return d.geometry.coordinates}else if(d.coordinates)return d.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function E_(d){return d.type==="Feature"?d.geometry:d}function J_(d,e,n){if(n===void 0&&(n={}),!d)throw new Error("point is required");if(!e)throw new Error("polygon is required");var a=N2(d),c=E_(e),f=c.type,m=e.bbox,i=c.coordinates;if(m&&z4(a,m)===!1)return!1;f==="Polygon"&&(i=[i]);for(var w=!1,E=0;E<i.length&&!w;E++)if(bM(a,i[E][0],n.ignoreBoundary)){for(var C=!1,T=1;T<i[E].length&&!C;)bM(a,i[E][T],!n.ignoreBoundary)&&(C=!0),T++;C||(w=!0)}return w}function bM(d,e,n){var a=!1;e[0][0]===e[e.length-1][0]&&e[0][1]===e[e.length-1][1]&&(e=e.slice(0,e.length-1));for(var c=0,f=e.length-1;c<e.length;f=c++){var m=e[c][0],i=e[c][1],w=e[f][0],E=e[f][1],C=d[1]*(m-w)+i*(w-d[0])+E*(d[0]-m)===0&&(m-d[0])*(w-d[0])<=0&&(i-d[1])*(E-d[1])<=0;if(C)return!n;var T=i>d[1]!=E>d[1]&&d[0]<(w-m)*(d[1]-i)/(E-i)+m;T&&(a=!a)}return a}function z4(d,e){return e[0]<=d[0]&&e[1]<=d[1]&&e[2]>=d[0]&&e[3]>=d[1]}function xm(d,e,n){n===void 0&&(n={});for(var a=N2(d),c=D4(e),f=0;f<c.length-1;f++){var m=!1;if(n.ignoreEndVertices&&(f===0&&(m="start"),f===c.length-2&&(m="end"),f===0&&f+1===c.length-1&&(m="both")),k4(c[f],c[f+1],a,m,typeof n.epsilon>"u"?null:n.epsilon))return!0}return!1}function k4(d,e,n,a,c){var f=n[0],m=n[1],i=d[0],w=d[1],E=e[0],C=e[1],T=n[0]-i,I=n[1]-w,k=E-i,O=C-w,B=T*O-I*k;if(c!==null){if(Math.abs(B)>c)return!1}else if(B!==0)return!1;if(a){if(a==="start")return Math.abs(k)>=Math.abs(O)?k>0?i<f&&f<=E:E<=f&&f<i:O>0?w<m&&m<=C:C<=m&&m<w;if(a==="end")return Math.abs(k)>=Math.abs(O)?k>0?i<=f&&f<E:E<f&&f<=i:O>0?w<=m&&m<C:C<m&&m<=w;if(a==="both")return Math.abs(k)>=Math.abs(O)?k>0?i<f&&f<E:E<f&&f<i:O>0?w<m&&m<C:C<m&&m<w}else return Math.abs(k)>=Math.abs(O)?k>0?i<=f&&f<=E:E<=f&&f<=i:O>0?w<=m&&m<=C:C<=m&&m<=w;return!1}function O4(d,e){var n=E_(d),a=E_(e),c=n.type,f=a.type,m=n.coordinates,i=a.coordinates;switch(c){case"Point":switch(f){case"Point":return Jv(m,i);default:throw new Error("feature2 "+f+" geometry not supported")}case"MultiPoint":switch(f){case"Point":return F4(n,a);case"MultiPoint":return B4(n,a);default:throw new Error("feature2 "+f+" geometry not supported")}case"LineString":switch(f){case"Point":return xm(a,n,{ignoreEndVertices:!0});case"LineString":return V4(n,a);case"MultiPoint":return N4(n,a);default:throw new Error("feature2 "+f+" geometry not supported")}case"Polygon":switch(f){case"Point":return J_(a,n,{ignoreBoundary:!0});case"LineString":return G4(n,a);case"Polygon":return j4(n,a);case"MultiPoint":return U4(n,a);default:throw new Error("feature2 "+f+" geometry not supported")}default:throw new Error("feature1 "+c+" geometry not supported")}}function F4(d,e){var n,a=!1;for(n=0;n<d.coordinates.length;n++)if(Jv(d.coordinates[n],e.coordinates)){a=!0;break}return a}function B4(d,e){for(var n=0,a=e.coordinates;n<a.length;n++){for(var c=a[n],f=!1,m=0,i=d.coordinates;m<i.length;m++){var w=i[m];if(Jv(c,w)){f=!0;break}}if(!f)return!1}return!0}function N4(d,e){for(var n=!1,a=0,c=e.coordinates;a<c.length;a++){var f=c[a];if(xm(f,d,{ignoreEndVertices:!0})&&(n=!0),!xm(f,d))return!1}return!!n}function U4(d,e){for(var n=0,a=e.coordinates;n<a.length;n++){var c=a[n];if(!J_(c,d,{ignoreBoundary:!0}))return!1}return!0}function V4(d,e){for(var n=!1,a=0,c=e.coordinates;a<c.length;a++){var f=c[a];if(xm({type:"Point",coordinates:f},d,{ignoreEndVertices:!0})&&(n=!0),!xm({type:"Point",coordinates:f},d,{ignoreEndVertices:!1}))return!1}return n}function G4(d,e){var n=!1,a=0,c=Kf(d),f=Kf(e);if(!U2(c,f))return!1;for(a;a<e.coordinates.length-1;a++){var m=W4(e.coordinates[a],e.coordinates[a+1]);if(J_({type:"Point",coordinates:m},d,{ignoreBoundary:!0})){n=!0;break}}return n}function j4(d,e){if(d.type==="Feature"&&d.geometry===null||e.type==="Feature"&&e.geometry===null)return!1;var n=Kf(d),a=Kf(e);if(!U2(n,a))return!1;for(var c=E_(e).coordinates,f=0,m=c;f<m.length;f++)for(var i=m[f],w=0,E=i;w<E.length;w++){var C=E[w];if(!J_(C,d))return!1}return!0}function U2(d,e){return!(d[0]>e[0]||d[2]<e[2]||d[1]>e[1]||d[3]<e[3])}function Jv(d,e){return d[0]===e[0]&&d[1]===e[1]}function W4(d,e){return[(d[0]+e[0])/2,(d[1]+e[1])/2]}var K_={exports:{}};(function(d,e){(function(n,a){d.exports=a()})(Tf,function(){var n,a,c;function f(i,w){if(!n)n=w;else if(!a)a=w;else{var E="self.onerror = function() { console.error('An error occurred while parsing the WebWorker bundle. This is most likely due to improper transpilation by Babel; please see https://docs.mapbox.com/mapbox-gl-js/guides/install/#transpiling'); }; var sharedChunk = {}; ("+n+")(sharedChunk); ("+a+")(sharedChunk); self.onerror = null;",C={};n(C),c=w(C),typeof window<"u"&&window&&window.URL&&window.URL.createObjectURL&&(c.workerUrl=window.URL.createObjectURL(new Blob([E],{type:"text/javascript"})))}}f(["exports"],function(i){var w=typeof self<"u"?self:{},E="2.15.0";let C;const T={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){if(C==null){const r=/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i;try{C={}.API_URL_REGEX!=null?new RegExp({}.API_URL_REGEX):r}catch{C=r}}return C},get API_TILEJSON_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/v[0-9]*\/.*\.json.*$)/i},get API_SPRITE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*\/sprite.*\..*$)/i},get API_FONTS_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/fonts\/v[0-9]*\/)(.*\.pbf.*$)/i},get API_STYLE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*$)/i},get API_CDN_URL_REGEX(){return/^((https?:)?\/\/)?api\.mapbox\.c(n|om)(\/mapbox-gl-js\/)(.*$)/i},get EVENTS_URL(){if(!T.API_URL)return null;try{const r=new URL(T.API_URL);return r.hostname==="api.mapbox.cn"?"https://events.mapbox.cn/events/v2":r.hostname==="api.mapbox.com"?"https://events.mapbox.com/events/v2":null}catch{return null}},SESSION_PATH:"/map-sessions/v1",FEEDBACK_URL:"https://apps.mapbox.com/feedback",TILE_URL_VERSION:"v4",RASTER_URL_PREFIX:"raster/v1",REQUIRE_ACCESS_TOKEN:!0,ACCESS_TOKEN:null,MAX_PARALLEL_IMAGE_REQUESTS:16},I={supported:!1,testSupport:function(r){!B&&O&&(F?H(r):k=r)}};let k,O,B=!1,F=!1;function H(r){const t=r.createTexture();r.bindTexture(r.TEXTURE_2D,t);try{if(r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,O),r.isContextLost())return;I.supported=!0}catch{}r.deleteTexture(t),B=!0}w.document&&(O=w.document.createElement("img"),O.onload=function(){k&&H(k),k=null,F=!0},O.onerror=function(){B=!0,k=null},O.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const Y="01";function K(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var ne=le;function le(r,t,s,l){this.cx=3*r,this.bx=3*(s-r)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(l-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=r,this.p1y=t,this.p2x=s,this.p2y=l}le.prototype={sampleCurveX:function(r){return((this.ax*r+this.bx)*r+this.cx)*r},sampleCurveY:function(r){return((this.ay*r+this.by)*r+this.cy)*r},sampleCurveDerivativeX:function(r){return(3*this.ax*r+2*this.bx)*r+this.cx},solveCurveX:function(r,t){if(t===void 0&&(t=1e-6),r<0)return 0;if(r>1)return 1;for(var s=r,l=0;l<8;l++){var h=this.sampleCurveX(s)-r;if(Math.abs(h)<t)return s;var g=this.sampleCurveDerivativeX(s);if(Math.abs(g)<1e-6)break;s-=h/g}var v=0,S=1;for(s=r,l=0;l<20&&(h=this.sampleCurveX(s),!(Math.abs(h-r)<t));l++)r>h?v=s:S=s,s=.5*(S-v)+v;return s},solve:function(r,t){return this.sampleCurveY(this.solveCurveX(r,t))}};var fe=K(ne),Ae=oe;function oe(r,t){this.x=r,this.y=t}oe.prototype={clone:function(){return new oe(this.x,this.y)},add:function(r){return this.clone()._add(r)},sub:function(r){return this.clone()._sub(r)},multByPoint:function(r){return this.clone()._multByPoint(r)},divByPoint:function(r){return this.clone()._divByPoint(r)},mult:function(r){return this.clone()._mult(r)},div:function(r){return this.clone()._div(r)},rotate:function(r){return this.clone()._rotate(r)},rotateAround:function(r,t){return this.clone()._rotateAround(r,t)},matMult:function(r){return this.clone()._matMult(r)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(r){return this.x===r.x&&this.y===r.y},dist:function(r){return Math.sqrt(this.distSqr(r))},distSqr:function(r){var t=r.x-this.x,s=r.y-this.y;return t*t+s*s},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(r){return Math.atan2(this.y-r.y,this.x-r.x)},angleWith:function(r){return this.angleWithSep(r.x,r.y)},angleWithSep:function(r,t){return Math.atan2(this.x*t-this.y*r,this.x*r+this.y*t)},_matMult:function(r){var t=r[2]*this.x+r[3]*this.y;return this.x=r[0]*this.x+r[1]*this.y,this.y=t,this},_add:function(r){return this.x+=r.x,this.y+=r.y,this},_sub:function(r){return this.x-=r.x,this.y-=r.y,this},_mult:function(r){return this.x*=r,this.y*=r,this},_div:function(r){return this.x/=r,this.y/=r,this},_multByPoint:function(r){return this.x*=r.x,this.y*=r.y,this},_divByPoint:function(r){return this.x/=r.x,this.y/=r.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var r=this.y;return this.y=this.x,this.x=-r,this},_rotate:function(r){var t=Math.cos(r),s=Math.sin(r),l=s*this.x+t*this.y;return this.x=t*this.x-s*this.y,this.y=l,this},_rotateAround:function(r,t){var s=Math.cos(r),l=Math.sin(r),h=t.y+l*(this.x-t.x)+s*(this.y-t.y);return this.x=t.x+s*(this.x-t.x)-l*(this.y-t.y),this.y=h,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},oe.convert=function(r){return r instanceof oe?r:Array.isArray(r)?new oe(r[0],r[1]):r};var ce=K(Ae);const Re=Math.PI/180,ke=180/Math.PI;function Xe(r){return r*Re}function St(r){return r*ke}const Je=[[0,0],[1,0],[1,1],[0,1]];function It(r){if(r<=0)return 0;if(r>=1)return 1;const t=r*r,s=t*r;return 4*(r<.5?s:3*(r-t)+s-.75)}function ft(r,t,s,l){const h=new fe(r,t,s,l);return function(g){return h.solve(g)}}const Nt=ft(.25,.1,.25,1);function Fe(r,t,s){return Math.min(s,Math.max(t,r))}function it(r,t,s){return(s=Fe((s-r)/(t-r),0,1))*s*(3-2*s)}function tt(r,t,s){const l=s-t,h=((r-t)%l+l)%l+t;return h===t?s:h}function Et(r,t,s){if(!r.length)return s(null,[]);let l=r.length;const h=new Array(r.length);let g=null;r.forEach((v,S)=>{t(v,(A,P)=>{A&&(g=A),h[S]=P,--l==0&&s(g,h)})})}function xt(r){const t=[];for(const s in r)t.push(r[s]);return t}function Pt(r,...t){for(const s of t)for(const l in s)r[l]=s[l];return r}let ln=1;function pn(){return ln++}function Mt(){return function r(t){return t?(t^Math.random()*(16>>t/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,r)}()}function ei(r){return r<=1?1:Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function oi(r){return!!r&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(r)}function Wn(r,t){r.forEach(s=>{t[s]&&(t[s]=t[s].bind(t))})}function jt(r,t){return r.indexOf(t,r.length-t.length)!==-1}function mn(r,t,s){const l={};for(const h in r)l[h]=t.call(s||this,r[h],h,r);return l}function qt(r,t,s){const l={};for(const h in r)t.call(s||this,r[h],h,r)&&(l[h]=r[h]);return l}function Dt(r){return Array.isArray(r)?r.map(Dt):typeof r=="object"&&r?mn(r,Dt):r}const gn={};function wn(r){gn[r]||(typeof console<"u"&&console.warn(r),gn[r]=!0)}function Yt(r,t,s){return(s.y-r.y)*(t.x-r.x)>(t.y-r.y)*(s.x-r.x)}function rn(r){let t=0;for(let s,l,h=0,g=r.length,v=g-1;h<g;v=h++)s=r[h],l=r[v],t+=(l.x-s.x)*(s.y+l.y);return t}function dn(){return typeof WorkerGlobalScope<"u"&&typeof self<"u"&&self instanceof WorkerGlobalScope}function Mn(r){const t={};if(r.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(s,l,h,g)=>{const v=h||g;return t[l]=!v||v.toLowerCase(),""}),t["max-age"]){const s=parseInt(t["max-age"],10);isNaN(s)?delete t["max-age"]:t["max-age"]=s}return t}let li=null;function ti(r){if(li==null){const t=r.navigator?r.navigator.userAgent:null;li=!!r.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return li}function Ie(r){try{const t=w[r];return t.setItem("_mapbox_test_",1),t.removeItem("_mapbox_test_"),!0}catch{return!1}}function xe(r,t){return[r[4*t],r[4*t+1],r[4*t+2],r[4*t+3]]}const Tt="mapbox-tiles";let hn=500,_n=50,Sn,ri;function kt(){try{return w.caches}catch{}}function Hn(){kt()&&!Sn&&(Sn=w.caches.open(Tt))}function On(r){const t=r.indexOf("?");if(t<0)return r;const s=function(h){const g=h.indexOf("?");return g>0?h.slice(g+1).split("&"):[]}(r),l=s.filter(h=>{const g=h.split("=");return g[0]==="language"||g[0]==="worldview"});return l.length?`${r.slice(0,t)}?${l.join("&")}`:r.slice(0,t)}let Fn=1/0;const Ze={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};typeof Object.freeze=="function"&&Object.freeze(Ze);class Tn extends Error{constructor(t,s,l){s===401&&rt(l)&&(t+=": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes"),super(t),this.status=s,this.url=l}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const bn=dn()?()=>self.worker&&self.worker.referrer:()=>(w.location.protocol==="blob:"?w.parent:w).location.href,We=function(r,t){if(!(/^file:/.test(s=r.url)||/^file:/.test(bn())&&!/^\w+:/.test(s))){if(w.fetch&&w.Request&&w.AbortController&&w.Request.prototype.hasOwnProperty("signal"))return function(l,h){const g=new w.AbortController,v=new w.Request(l.url,{method:l.method||"GET",body:l.body,credentials:l.credentials,headers:l.headers,referrer:bn(),referrerPolicy:l.referrerPolicy,signal:g.signal});let S=!1,A=!1;const P=(U=v.url).indexOf("sku=")>0&&rt(U);var U;l.type==="json"&&v.headers.set("Accept","application/json");const G=($,J,re)=>{if(A)return;if($&&$.message!=="SecurityError"&&wn($.toString()),J&&re)return j(J);const de=Date.now();w.fetch(v).then(we=>{if(we.ok){const ze=P?we.clone():null;return j(we,ze,de)}return h(new Tn(we.statusText,we.status,l.url))}).catch(we=>{we.name!=="AbortError"&&h(new Error(`${we.message} ${l.url}`))})},j=($,J,re)=>{(l.type==="arrayBuffer"?$.arrayBuffer():l.type==="json"?$.json():$.text()).then(de=>{A||(J&&re&&function(we,ze,Se){if(Hn(),!Sn)return;const Le={status:ze.status,statusText:ze.statusText,headers:new w.Headers};ze.headers.forEach((_t,dt)=>Le.headers.set(dt,_t));const Ne=Mn(ze.headers.get("Cache-Control")||"");if(Ne["no-store"])return;Ne["max-age"]&&Le.headers.set("Expires",new Date(Se+1e3*Ne["max-age"]).toUTCString());const Be=Le.headers.get("Expires");Be&&(new Date(Be).getTime()-Se<42e4||function(_t,dt){if(ri===void 0)try{new Response(new ReadableStream),ri=!0}catch{ri=!1}ri?dt(_t.body):_t.blob().then(dt)}(ze,_t=>{const dt=new w.Response(_t,Le);Hn(),Sn&&Sn.then(Ft=>Ft.put(On(we.url),dt)).catch(Ft=>wn(Ft.message))}))}(v,J,re),S=!0,h(null,de,$.headers.get("Cache-Control"),$.headers.get("Expires")))}).catch(de=>{A||h(new Error(de.message))})};return P?function($,J){if(Hn(),!Sn)return J(null);const re=On($.url);Sn.then(de=>{de.match(re).then(we=>{const ze=function(Se){if(!Se)return!1;const Le=new Date(Se.headers.get("Expires")||0),Ne=Mn(Se.headers.get("Cache-Control")||"");return Le>Date.now()&&!Ne["no-cache"]}(we);de.delete(re),ze&&de.put(re,we.clone()),J(null,we,ze)}).catch(J)}).catch(J)}(v,G):G(null,null),{cancel:()=>{A=!0,S||g.abort()}}}(r,t);if(dn()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",r,t,void 0,!0)}var s;return function(l,h){const g=new w.XMLHttpRequest;g.open(l.method||"GET",l.url,!0),l.type==="arrayBuffer"&&(g.responseType="arraybuffer");for(const v in l.headers)g.setRequestHeader(v,l.headers[v]);return l.type==="json"&&(g.responseType="text",g.setRequestHeader("Accept","application/json")),g.withCredentials=l.credentials==="include",g.onerror=()=>{h(new Error(g.statusText))},g.onload=()=>{if((g.status>=200&&g.status<300||g.status===0)&&g.response!==null){let v=g.response;if(l.type==="json")try{v=JSON.parse(g.response)}catch(S){return h(S)}h(null,v,g.getResponseHeader("Cache-Control"),g.getResponseHeader("Expires"))}else h(new Tn(g.statusText,g.status,l.url))},g.send(l.body),{cancel:()=>g.abort()}}(r,t)},bt=function(r,t){return We(Pt(r,{type:"arrayBuffer"}),t)};function un(r){const t=w.document.createElement("a");return t.href=r,t.protocol===w.document.location.protocol&&t.host===w.document.location.host}const ue="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let te,se;te=[],se=0;const ye=function(r,t){if(I.supported&&(r.headers||(r.headers={}),r.headers.accept="image/webp,*/*"),se>=T.MAX_PARALLEL_IMAGE_REQUESTS){const g={requestParameters:r,callback:t,cancelled:!1,cancel(){this.cancelled=!0}};return te.push(g),g}se++;let s=!1;const l=()=>{if(!s)for(s=!0,se--;te.length&&se<T.MAX_PARALLEL_IMAGE_REQUESTS;){const g=te.shift(),{requestParameters:v,callback:S,cancelled:A}=g;A||(g.cancel=ye(v,S).cancel)}},h=bt(r,(g,v,S,A)=>{l(),g?t(g):v&&(w.createImageBitmap?function(P,U){const G=new w.Blob([new Uint8Array(P)],{type:"image/png"});w.createImageBitmap(G).then(j=>{U(null,j)}).catch(j=>{U(new Error(`Could not load image because of ${j.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(v,(P,U)=>t(P,U,S,A)):function(P,U){const G=new w.Image,j=w.URL;G.onload=()=>{U(null,G),j.revokeObjectURL(G.src),G.onload=null,w.requestAnimationFrame(()=>{G.src=ue})},G.onerror=()=>U(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const $=new w.Blob([new Uint8Array(P)],{type:"image/png"});G.src=P.byteLength?j.createObjectURL($):ue}(v,(P,U)=>t(P,U,S,A)))});return{cancel:()=>{h.cancel(),l()}}},De="NO_ACCESS_TOKEN";function je(r){return r.indexOf("mapbox:")===0}function rt(r){return T.API_URL_REGEX.test(r)}function st(r){return T.API_CDN_URL_REGEX.test(r)}function He(r){return T.API_STYLE_REGEX.test(r)&&!pt(r)}function pt(r){return T.API_SPRITE_REGEX.test(r)}const Zt=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function on(r){const t=r.match(Zt);if(!t)throw new Error("Unable to parse URL object");return{protocol:t[1],authority:t[2],path:t[3]||"/",params:t[4]?t[4].split("&"):[]}}function Kt(r){const t=r.params.length?`?${r.params.join("&")}`:"";return`${r.protocol}://${r.authority}${r.path}${t}`}const xi="mapbox.eventData";function ci(r){if(!r)return null;const t=r.split(".");if(!t||t.length!==3)return null;try{return JSON.parse(decodeURIComponent(w.atob(t[1]).split("").map(s=>"%"+("00"+s.charCodeAt(0).toString(16)).slice(-2)).join("")))}catch{return null}}class ve{constructor(t){this.type=t,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(t){const s=ci(T.ACCESS_TOKEN);let l="";return l=s&&s.u?w.btoa(encodeURIComponent(s.u).replace(/%([0-9A-F]{2})/g,(h,g)=>String.fromCharCode(Number("0x"+g)))):T.ACCESS_TOKEN||"",t?`${xi}.${t}:${l}`:`${xi}:${l}`}fetchEventData(){const t=Ie("localStorage"),s=this.getStorageKey(),l=this.getStorageKey("uuid");if(t)try{const h=w.localStorage.getItem(s);h&&(this.eventData=JSON.parse(h));const g=w.localStorage.getItem(l);g&&(this.anonId=g)}catch{wn("Unable to read from LocalStorage")}}saveEventData(){const t=Ie("localStorage"),s=this.getStorageKey(),l=this.getStorageKey("uuid");if(t)try{w.localStorage.setItem(l,this.anonId),Object.keys(this.eventData).length>=1&&w.localStorage.setItem(s,JSON.stringify(this.eventData))}catch{wn("Unable to write to LocalStorage")}}processRequests(t){}postEvent(t,s,l,h){if(!T.EVENTS_URL)return;const g=on(T.EVENTS_URL);g.params.push(`access_token=${h||T.ACCESS_TOKEN||""}`);const v={event:this.type,created:new Date(t).toISOString()},S=s?Pt(v,s):v,A={url:Kt(g),headers:{"Content-Type":"text/plain"},body:JSON.stringify([S])};this.pendingRequest=function(P,U){return We(Pt(P,{method:"POST"}),U)}(A,P=>{this.pendingRequest=null,l(P),this.saveEventData(),this.processRequests(h)})}queueRequest(t,s){this.queue.push(t),this.processRequests(s)}}const Qe=new class extends ve{constructor(r){super("appUserTurnstile"),this._customAccessToken=r}postTurnstileEvent(r,t){T.EVENTS_URL&&T.ACCESS_TOKEN&&Array.isArray(r)&&r.some(s=>je(s)||rt(s))&&this.queueRequest(Date.now(),t)}processRequests(r){if(this.pendingRequest||this.queue.length===0)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const t=ci(T.ACCESS_TOKEN),s=t?t.u:T.ACCESS_TOKEN;let l=s!==this.eventData.tokenU;oi(this.anonId)||(this.anonId=Mt(),l=!0);const h=this.queue.shift();if(this.eventData.lastSuccess){const g=new Date(this.eventData.lastSuccess),v=new Date(h),S=(h-this.eventData.lastSuccess)/864e5;l=l||S>=1||S<-1||g.getDate()!==v.getDate()}else l=!0;l?this.postEvent(h,{sdkIdentifier:"mapbox-gl-js",sdkVersion:E,skuId:Y,"enabled.telemetry":!1,userId:this.anonId},g=>{g||(this.eventData.lastSuccess=h,this.eventData.tokenU=s)},r):this.processRequests()}},lt=Qe.postTurnstileEvent.bind(Qe),mt=new class extends ve{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(r,t,s,l){this.skuToken=t,this.errorCb=l,T.EVENTS_URL&&(s||T.ACCESS_TOKEN?this.queueRequest({id:r,timestamp:Date.now()},s):this.errorCb(new Error(De)))}processRequests(r){if(this.pendingRequest||this.queue.length===0)return;const{id:t,timestamp:s}=this.queue.shift();t&&this.success[t]||(this.anonId||this.fetchEventData(),oi(this.anonId)||(this.anonId=Mt()),this.postEvent(s,{sdkIdentifier:"mapbox-gl-js",sdkVersion:E,skuId:Y,skuToken:this.skuToken,userId:this.anonId},l=>{l?this.errorCb(l):t&&(this.success[t]=!0)},r))}},Gt=mt.postMapLoadEvent.bind(mt),$n=new class extends ve{constructor(){super("gljs.performance")}postPerformanceEvent(r,t){T.EVENTS_URL&&(r||T.ACCESS_TOKEN)&&this.queueRequest({timestamp:Date.now(),performanceData:t},r)}processRequests(r){if(this.pendingRequest||this.queue.length===0)return;const{timestamp:t,performanceData:s}=this.queue.shift(),l=function(h){const g=w.performance.getEntriesByType("resource"),v=w.performance.getEntriesByType("mark"),S=function(j){const $={};if(j){for(const J in j)if(J!=="other")for(const re of j[J]){const de=`${J}ResolveRangeMin`,we=`${J}ResolveRangeMax`,ze=`${J}RequestCount`,Se=`${J}RequestCachedCount`;$[de]=Math.min($[de]||1/0,re.startTime),$[we]=Math.max($[we]||-1/0,re.responseEnd);const Le=Ne=>{$[Ne]===void 0&&($[Ne]=0),++$[Ne]};re.transferSize!==void 0&&re.transferSize===0&&Le(Se),Le(ze)}}return $}(function(j,$){const J={};if(j)for(const re of j){const de=$(re);J[de]===void 0&&(J[de]=[]),J[de].push(re)}return J}(g,Cr)),A=w.devicePixelRatio,P=w.navigator.connection||w.navigator.mozConnection||w.navigator.webkitConnection,U={counters:[],metadata:[],attributes:[]},G=(j,$,J)=>{J!=null&&j.push({name:$,value:J.toString()})};for(const j in S)G(U.counters,j,S[j]);if(h.interactionRange[0]!==1/0&&h.interactionRange[1]!==-1/0&&(G(U.counters,"interactionRangeMin",h.interactionRange[0]),G(U.counters,"interactionRangeMax",h.interactionRange[1])),v)for(const j of Object.keys(Ni)){const $=Ni[j],J=v.find(re=>re.name===$);J&&G(U.counters,$,J.startTime)}return G(U.counters,"visibilityHidden",h.visibilityHidden),G(U.attributes,"style",function(j){if(j)for(const $ of j){const J=$.name.split("?")[0];if(He(J)){const re=J.split("/").slice(-2);if(re.length===2)return`mapbox://styles/${re[0]}/${re[1]}`}}}(g)),G(U.attributes,"terrainEnabled",h.terrainEnabled?"true":"false"),G(U.attributes,"fogEnabled",h.fogEnabled?"true":"false"),G(U.attributes,"projection",h.projection),G(U.attributes,"zoom",h.zoom),G(U.metadata,"devicePixelRatio",A),G(U.metadata,"connectionEffectiveType",P?P.effectiveType:void 0),G(U.metadata,"navigatorUserAgent",w.navigator.userAgent),G(U.metadata,"screenWidth",w.screen.width),G(U.metadata,"screenHeight",w.screen.height),G(U.metadata,"windowWidth",w.innerWidth),G(U.metadata,"windowHeight",w.innerHeight),G(U.metadata,"mapWidth",h.width/A),G(U.metadata,"mapHeight",h.height/A),G(U.metadata,"webglRenderer",h.renderer),G(U.metadata,"webglVendor",h.vendor),G(U.metadata,"sdkVersion",E),G(U.metadata,"sdkIdentifier","mapbox-gl-js"),U}(s);for(const h of l.metadata);for(const h of l.counters);for(const h of l.attributes);this.postEvent(t,l,()=>{},r)}},Yn=$n.postPerformanceEvent.bind($n),bi=new class extends ve{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(r,t,s,l){if(!T.API_URL||!T.SESSION_PATH)return;const h=on(T.API_URL+T.SESSION_PATH);h.params.push(`sku=${t||""}`),h.params.push(`access_token=${l||T.ACCESS_TOKEN||""}`);const g={url:Kt(h),headers:{"Content-Type":"text/plain"}};this.pendingRequest=function(v,S){return We(Pt(v,{method:"GET"}),S)}(g,v=>{this.pendingRequest=null,s(v),this.saveEventData(),this.processRequests(l)})}getSessionAPI(r,t,s,l){this.skuToken=t,this.errorCb=l,T.SESSION_PATH&&T.API_URL&&(s||T.ACCESS_TOKEN?this.queueRequest({id:r,timestamp:Date.now()},s):this.errorCb(new Error(De)))}processRequests(r){if(this.pendingRequest||this.queue.length===0)return;const{id:t,timestamp:s}=this.queue.shift();t&&this.success[t]||this.getSession(s,this.skuToken,l=>{l?this.errorCb(l):t&&(this.success[t]=!0)},r)}},ui=bi.getSessionAPI.bind(bi),ai=new Set,Ni={create:"create",load:"load",fullLoad:"fullLoad"},Qi={mark(r){w.performance.mark(r)},measure(r,t,s){w.performance.measure(r,t,s)}};function Cr(r){const t=r.name.split("?")[0];return st(t)&&t.includes("mapbox-gl.js")?"javascript":st(t)&&t.includes("mapbox-gl.css")?"css":function(s){return T.API_FONTS_REGEX.test(s)}(t)?"fontRange":pt(t)?"sprite":He(t)?"style":function(s){return T.API_TILEJSON_REGEX.test(s)}(t)?"tilejson":"other"}const ki=w.performance;function ea(r){const t=r?r.url.toString():void 0;return ki.getEntriesByName(t)}let Xs,$s,Vi,Ur;const er={now:()=>Vi!==void 0?Vi:w.performance.now(),setNow(r){Vi=r},restoreNow(){Vi=void 0},frame(r){const t=w.requestAnimationFrame(r);return{cancel:()=>w.cancelAnimationFrame(t)}},getImageData(r,t=0){const{width:s,height:l}=r;Ur||(Ur=w.document.createElement("canvas"));const h=Ur.getContext("2d",{willReadFrequently:!0});if(!h)throw new Error("failed to create canvas 2d context");return(s>Ur.width||l>Ur.height)&&(Ur.width=s,Ur.height=l),h.clearRect(-t,-t,s+2*t,l+2*t),h.drawImage(r,0,0,s,l),h.getImageData(-t,-t,s+2*t,l+2*t)},resolveURL:r=>(Xs||(Xs=w.document.createElement("a")),Xs.href=r,Xs.href),get devicePixelRatio(){return w.devicePixelRatio},get prefersReducedMotion(){return!!w.matchMedia&&($s==null&&($s=w.matchMedia("(prefers-reduced-motion: reduce)")),$s.matches)}};function tr(r,t,s){s[r]&&s[r].indexOf(t)!==-1||(s[r]=s[r]||[],s[r].push(t))}function po(r,t,s){if(s&&s[r]){const l=s[r].indexOf(t);l!==-1&&s[r].splice(l,1)}}class Es{constructor(t,s={}){Pt(this,s),this.type=t}}class Ir extends Es{constructor(t,s={}){super("error",Pt({error:t},s))}}class Zi{on(t,s){return this._listeners=this._listeners||{},tr(t,s,this._listeners),this}off(t,s){return po(t,s,this._listeners),po(t,s,this._oneTimeListeners),this}once(t,s){return s?(this._oneTimeListeners=this._oneTimeListeners||{},tr(t,s,this._oneTimeListeners),this):new Promise(l=>this.once(t,l))}fire(t,s){typeof t=="string"&&(t=new Es(t,s||{}));const l=t.type;if(this.listens(l)){t.target=this;const h=this._listeners&&this._listeners[l]?this._listeners[l].slice():[];for(const S of h)S.call(this,t);const g=this._oneTimeListeners&&this._oneTimeListeners[l]?this._oneTimeListeners[l].slice():[];for(const S of g)po(l,S,this._oneTimeListeners),S.call(this,t);const v=this._eventedParent;v&&(Pt(t,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),v.fire(t))}else t instanceof Ir&&console.error(t.error);return this}listens(t){return!!(this._listeners&&this._listeners[t]&&this._listeners[t].length>0||this._oneTimeListeners&&this._oneTimeListeners[t]&&this._oneTimeListeners[t].length>0||this._eventedParent&&this._eventedParent.listens(t))}setEventedParent(t,s){return this._eventedParent=t,this._eventedParentData=s,this}}var ct=JSON.parse('{"$version":8,"$root":{"version":{"required":true,"type":"enum","values":[8]},"name":{"type":"string"},"metadata":{"type":"*"},"center":{"type":"array","value":"number"},"zoom":{"type":"number"},"bearing":{"type":"number","default":0,"period":360,"units":"degrees"},"pitch":{"type":"number","default":0,"units":"degrees"},"light":{"type":"light"},"terrain":{"type":"terrain"},"fog":{"type":"fog"},"sources":{"required":true,"type":"sources"},"sprite":{"type":"string"},"glyphs":{"type":"string"},"transition":{"type":"transition"},"projection":{"type":"projection"},"layers":{"required":true,"type":"array","value":"layer"}},"sources":{"*":{"type":"source"}},"source":["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],"source_vector":{"type":{"required":true,"type":"enum","values":{"vector":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"attribution":{"type":"string"},"promoteId":{"type":"promoteId"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster":{"type":{"required":true,"type":"enum","values":{"raster":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"attribution":{"type":"string"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_dem":{"type":{"required":true,"type":"enum","values":{"raster-dem":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"attribution":{"type":"string"},"encoding":{"type":"enum","values":{"terrarium":{},"mapbox":{}},"default":"mapbox"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_geojson":{"type":{"required":true,"type":"enum","values":{"geojson":{}}},"data":{"type":"*"},"maxzoom":{"type":"number","default":18},"attribution":{"type":"string"},"buffer":{"type":"number","default":128,"maximum":512,"minimum":0},"filter":{"type":"*"},"tolerance":{"type":"number","default":0.375},"cluster":{"type":"boolean","default":false},"clusterRadius":{"type":"number","default":50,"minimum":0},"clusterMaxZoom":{"type":"number"},"clusterMinPoints":{"type":"number"},"clusterProperties":{"type":"*"},"lineMetrics":{"type":"boolean","default":false},"generateId":{"type":"boolean","default":false},"promoteId":{"type":"promoteId"}},"source_video":{"type":{"required":true,"type":"enum","values":{"video":{}}},"urls":{"required":true,"type":"array","value":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"source_image":{"type":{"required":true,"type":"enum","values":{"image":{}}},"url":{"required":true,"type":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"layer":{"id":{"type":"string","required":true},"type":{"type":"enum","values":{"fill":{},"line":{},"symbol":{},"circle":{},"heatmap":{},"fill-extrusion":{},"raster":{},"hillshade":{},"background":{},"sky":{}},"required":true},"metadata":{"type":"*"},"source":{"type":"string"},"source-layer":{"type":"string"},"minzoom":{"type":"number","minimum":0,"maximum":24},"maxzoom":{"type":"number","minimum":0,"maximum":24},"filter":{"type":"filter"},"layout":{"type":"layout"},"paint":{"type":"paint"}},"layout":["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background","layout_sky"],"layout_background":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_sky":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill":{"fill-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_circle":{"circle-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_heatmap":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill-extrusion":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"},"fill-extrusion-edge-radius":{"type":"number","private":true,"default":0,"minimum":0,"maximum":1,"property-type":"constant"}},"layout_line":{"line-cap":{"type":"enum","values":{"butt":{},"round":{},"square":{}},"default":"butt","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-join":{"type":"enum","values":{"bevel":{},"round":{},"miter":{}},"default":"miter","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{"type":"number","default":2,"requires":[{"line-join":"miter"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-round-limit":{"type":"number","default":1.05,"requires":[{"line-join":"round"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_symbol":{"symbol-placement":{"type":"enum","values":{"point":{},"line":{},"line-center":{}},"default":"point","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-spacing":{"type":"number","default":250,"minimum":1,"units":"pixels","requires":[{"symbol-placement":"line"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{"type":"boolean","default":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{"type":"enum","values":{"auto":{},"viewport-y":{},"source":{}},"default":"auto","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-optional":{"type":"boolean","default":false,"requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-size":{"type":"number","default":1,"minimum":0,"units":"factor of the original icon size","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{"type":"enum","values":{"none":{},"width":{},"height":{},"both":{}},"default":"none","requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{"type":"array","value":"number","length":4,"default":[0,0,0,0],"units":"pixels","requires":["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-image":{"type":"resolvedImage","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-keep-upright":{"type":"boolean","default":false,"requires":["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-offset":{"type":"array","value":"number","length":2,"default":[0,0],"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-field":{"type":"formatted","default":"","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-font":{"type":"array","value":"string","default":["Open Sans Regular","Arial Unicode MS Regular"],"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size":{"type":"number","default":16,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{"type":"number","default":10,"minimum":0,"units":"ems","requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{"type":"number","default":1.2,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-letter-spacing":{"type":"number","default":0,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-justify":{"type":"enum","values":{"auto":{},"left":{},"center":{},"right":{}},"default":"center","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{"type":"number","units":"ems","default":0,"requires":["text-field"],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["zoom","feature"]}},"text-variable-anchor":{"type":"array","value":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["text-field",{"!":"text-variable-anchor"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{"type":"number","default":45,"units":"degrees","requires":["text-field",{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-writing-mode":{"type":"array","value":"enum","values":{"horizontal":{},"vertical":{}},"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-keep-upright":{"type":"boolean","default":true,"requires":["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-transform":{"type":"enum","values":{"none":{},"uppercase":{},"lowercase":{}},"default":"none","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-offset":{"type":"array","value":"number","units":"ems","length":2,"default":[0,0],"requires":["text-field",{"!":"text-radial-offset"}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-optional":{"type":"boolean","default":false,"requires":["text-field","icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_raster":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_hillshade":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"filter":{"type":"array","value":"*"},"filter_symbol":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature","pitch","distance-from-center"]}},"filter_fill":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_line":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_circle":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_fill-extrusion":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_heatmap":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_operator":{"type":"enum","values":{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},"in":{},"!in":{},"all":{},"any":{},"none":{},"has":{},"!has":{},"within":{}}},"geometry_type":{"type":"enum","values":{"Point":{},"LineString":{},"Polygon":{}}},"function":{"expression":{"type":"expression"},"stops":{"type":"array","value":"function_stop"},"base":{"type":"number","default":1,"minimum":0},"property":{"type":"string","default":"$zoom"},"type":{"type":"enum","values":{"identity":{},"exponential":{},"interval":{},"categorical":{}},"default":"exponential"},"colorSpace":{"type":"enum","values":{"rgb":{},"lab":{},"hcl":{}},"default":"rgb"},"default":{"type":"*","required":false}},"function_stop":{"type":"array","minimum":0,"maximum":24,"value":["number","color"],"length":2},"expression":{"type":"array","value":"*","minimum":1},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"high-color":{"type":"color","property-type":"data-constant","default":"#245cdf","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"space-color":{"type":"color","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"horizon-blend":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,0.2,7,0.1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"star-intensity":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],5,0.35,6,0],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":{},"viewport":{}},"property-type":"data-constant","transition":false,"expression":{"interpolated":false,"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"intensity":{"type":"number","property-type":"data-constant","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"projection":{"name":{"type":"enum","values":{"albers":{},"equalEarth":{},"equirectangular":{},"lambertConformalConic":{},"mercator":{},"naturalEarth":{},"winkelTripel":{},"globe":{}},"default":"mercator","required":true},"center":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-180,-90],"maximum":[180,90],"transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]},"parallels":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-90,-90],"maximum":[90,90],"transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]}},"terrain":{"source":{"type":"string","required":true},"exaggeration":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true,"requires":["source"]}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background","paint_sky"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","transition":true,"requires":[{"!":"fill-pattern"},{"fill-antialias":true}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-pattern":{"type":"resolvedImage","transition":false,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-extrusion-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-extrusion-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{"type":"resolvedImage","transition":false,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"requires":["fill-extrusion-height"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-ambient-occlusion-intensity":{"property-type":"data-constant","type":"number","private":true,"default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-radius":{"property-type":"data-constant","type":"number","private":true,"default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true,"requires":["fill-extrusion-edge-radius"]},"fill-extrusion-rounded-roof":{"type":"boolean","default":true,"requires":["fill-extrusion-edge-radius"],"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"line-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["line-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"transition":false,"units":"line widths","requires":[{"!":"line-pattern"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-pattern":{"type":"resolvedImage","transition":false,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-gradient":{"type":"color","transition":false,"requires":[{"!":"line-pattern"},{"source":"geojson","has":{"lineMetrics":true}}],"expression":{"interpolated":true,"parameters":["line-progress"]},"property-type":"color-ramp"},"line-trim-offset":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1],"transition":false,"requires":[{"source":"geojson","has":{"lineMetrics":true}}],"property-type":"constant"}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["circle-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"transition":false,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"heatmap-color":{"type":"color","default":["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",0.1,"royalblue",0.3,"cyan",0.5,"lime",0.7,"yellow",1,"red"],"transition":false,"expression":{"interpolated":true,"parameters":["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["icon-image","icon-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","transition":true,"overridable":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["text-field","text-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"units":"degrees","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-resampling":{"type":"enum","values":{"linear":{},"nearest":{}},"default":"linear","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"transition":false,"units":"milliseconds","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"transition":false,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_background":{"background-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"background-pattern"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-pattern":{"type":"resolvedImage","transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":{},"atmosphere":{}},"default":"atmosphere","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"requires":[{"sky-type":"atmosphere"}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun-intensity":{"type":"number","requires":[{"sky-type":"atmosphere"}],"default":10,"minimum":0,"maximum":100,"transition":false,"property-type":"data-constant"},"sky-gradient-center":{"type":"array","requires":[{"sky-type":"gradient"}],"value":"number","default":[0,0],"length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient-radius":{"type":"number","requires":[{"sky-type":"gradient"}],"default":90,"minimum":0,"maximum":180,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"transition":false,"requires":[{"sky-type":"gradient"}],"expression":{"interpolated":true,"parameters":["sky-radial-progress"]},"property-type":"color-ramp"},"sky-atmosphere-halo-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-atmosphere-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"transition":{"duration":{"type":"number","default":300,"minimum":0,"units":"milliseconds"},"delay":{"type":"number","default":0,"minimum":0,"units":"milliseconds"}},"property-type":{"data-driven":{"type":"property-type"},"color-ramp":{"type":"property-type"},"data-constant":{"type":"property-type"},"constant":{"type":"property-type"}},"promoteId":{"*":{"type":"string"}}}');function Ri(r,...t){for(const s of t)for(const l in s)r[l]=s[l];return r}function Ci(r){return r instanceof Number||r instanceof String||r instanceof Boolean?r.valueOf():r}function nr(r){if(Array.isArray(r))return r.map(nr);if(r instanceof Object&&!(r instanceof Number||r instanceof String||r instanceof Boolean)){const t={};for(const s in r)t[s]=nr(r[s]);return t}return Ci(r)}class Os extends Error{constructor(t,s){super(s),this.message=s,this.key=t}}var Ts=Os;class Ra{constructor(t,s=[]){this.parent=t,this.bindings={};for(const[l,h]of s)this.bindings[l]=h}concat(t){return new Ra(this,t)}get(t){if(this.bindings[t])return this.bindings[t];if(this.parent)return this.parent.get(t);throw new Error(`${t} not found in scope.`)}has(t){return!!this.bindings[t]||!!this.parent&&this.parent.has(t)}}var As=Ra;const Uo={kind:"null"},En={kind:"number"},Oi={kind:"string"},Mi={kind:"boolean"},Ys={kind:"color"},Hr={kind:"object"},Ei={kind:"value"},D={kind:"collator"},W={kind:"formatted"},ae={kind:"resolvedImage"};function Ce(r,t){return{kind:"array",itemType:r,N:t}}function Oe(r){if(r.kind==="array"){const t=Oe(r.itemType);return typeof r.N=="number"?`array<${t}, ${r.N}>`:r.itemType.kind==="value"?"array":`array<${t}>`}return r.kind}const qe=[Uo,En,Oi,Mi,Ys,W,Hr,Ce(Ei),ae];function nt(r,t){if(t.kind==="error")return null;if(r.kind==="array"){if(t.kind==="array"&&(t.N===0&&t.itemType.kind==="value"||!nt(r.itemType,t.itemType))&&(typeof r.N!="number"||r.N===t.N))return null}else{if(r.kind===t.kind)return null;if(r.kind==="value"){for(const s of qe)if(!nt(s,t))return null}}return`Expected ${Oe(r)} but found ${Oe(t)} instead.`}function en(r,t){return t.some(s=>s.kind===r.kind)}function cn(r,t){return t.some(s=>s==="null"?r===null:s==="array"?Array.isArray(r):s==="object"?r&&!Array.isArray(r)&&typeof r=="object":s===typeof r)}var Ln,Pn={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function xn(r){return(r=Math.round(r))<0?0:r>255?255:r}function mi(r){return xn(r[r.length-1]==="%"?parseFloat(r)/100*255:parseInt(r))}function di(r){return(t=r[r.length-1]==="%"?parseFloat(r)/100:parseFloat(r))<0?0:t>1?1:t;var t}function vi(r,t,s){return s<0?s+=1:s>1&&(s-=1),6*s<1?r+(t-r)*s*6:2*s<1?t:3*s<2?r+(t-r)*(2/3-s)*6:r}try{Ln={}.parseCSSColor=function(r){var t,s=r.replace(/ /g,"").toLowerCase();if(s in Pn)return Pn[s].slice();if(s[0]==="#")return s.length===4?(t=parseInt(s.substr(1),16))>=0&&t<=4095?[(3840&t)>>4|(3840&t)>>8,240&t|(240&t)>>4,15&t|(15&t)<<4,1]:null:s.length===7&&(t=parseInt(s.substr(1),16))>=0&&t<=16777215?[(16711680&t)>>16,(65280&t)>>8,255&t,1]:null;var l=s.indexOf("("),h=s.indexOf(")");if(l!==-1&&h+1===s.length){var g=s.substr(0,l),v=s.substr(l+1,h-(l+1)).split(","),S=1;switch(g){case"rgba":if(v.length!==4)return null;S=di(v.pop());case"rgb":return v.length!==3?null:[mi(v[0]),mi(v[1]),mi(v[2]),S];case"hsla":if(v.length!==4)return null;S=di(v.pop());case"hsl":if(v.length!==3)return null;var A=(parseFloat(v[0])%360+360)%360/360,P=di(v[1]),U=di(v[2]),G=U<=.5?U*(P+1):U+P-U*P,j=2*U-G;return[xn(255*vi(j,G,A+1/3)),xn(255*vi(j,G,A)),xn(255*vi(j,G,A-1/3)),S];default:return null}}return null}}catch{}class Ji{constructor(t,s,l,h=1){this.r=t,this.g=s,this.b=l,this.a=h}static parse(t){if(!t)return;if(t instanceof Ji)return t;if(typeof t!="string")return;const s=Ln(t);return s?new Ji(s[0]/255*s[3],s[1]/255*s[3],s[2]/255*s[3],s[3]):void 0}toString(){const[t,s,l,h]=this.toArray();return`rgba(${Math.round(t)},${Math.round(s)},${Math.round(l)},${h})`}toArray(){const{r:t,g:s,b:l,a:h}=this;return h===0?[0,0,0,0]:[255*t/h,255*s/h,255*l/h,h]}toArray01(){const{r:t,g:s,b:l,a:h}=this;return h===0?[0,0,0,0]:[t/h,s/h,l/h,h]}toArray01PremultipliedAlpha(){const{r:t,g:s,b:l,a:h}=this;return[t,s,l,h]}}Ji.black=new Ji(0,0,0,1),Ji.white=new Ji(1,1,1,1),Ji.transparent=new Ji(0,0,0,0),Ji.red=new Ji(1,0,0,1),Ji.blue=new Ji(0,0,1,1);var zt=Ji;class Xn{constructor(t,s,l){this.sensitivity=t?s?"variant":"case":s?"accent":"base",this.locale=l,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(t,s){return this.collator.compare(t,s)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class ur{constructor(t,s,l,h,g){this.text=t.normalize?t.normalize():t,this.image=s,this.scale=l,this.fontStack=h,this.textColor=g}}class wi{constructor(t){this.sections=t}static fromString(t){return new wi([new ur(t,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(t=>t.text.length!==0||t.image&&t.image.name.length!==0)}static factory(t){return t instanceof wi?t:wi.fromString(t)}toString(){return this.sections.length===0?"":this.sections.map(t=>t.text).join("")}serialize(){const t=["format"];for(const s of this.sections){if(s.image){t.push(["image",s.image.name]);continue}t.push(s.text);const l={};s.fontStack&&(l["text-font"]=["literal",s.fontStack.split(",")]),s.scale&&(l["font-scale"]=s.scale),s.textColor&&(l["text-color"]=["rgba"].concat(s.textColor.toArray())),t.push(l)}return t}}class or{constructor(t){this.name=t.name,this.available=t.available}toString(){return this.name}static fromString(t){return t?new or({name:t,available:!1}):null}serialize(){return["image",this.name]}}function lc(r,t,s,l){return typeof r=="number"&&r>=0&&r<=255&&typeof t=="number"&&t>=0&&t<=255&&typeof s=="number"&&s>=0&&s<=255?l===void 0||typeof l=="number"&&l>=0&&l<=1?null:`Invalid rgba value [${[r,t,s,l].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof l=="number"?[r,t,s,l]:[r,t,s]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function tl(r){if(r===null||typeof r=="string"||typeof r=="boolean"||typeof r=="number"||r instanceof zt||r instanceof Xn||r instanceof wi||r instanceof or)return!0;if(Array.isArray(r)){for(const t of r)if(!tl(t))return!1;return!0}if(typeof r=="object"){for(const t in r)if(!tl(r[t]))return!1;return!0}return!1}function Si(r){if(r===null)return Uo;if(typeof r=="string")return Oi;if(typeof r=="boolean")return Mi;if(typeof r=="number")return En;if(r instanceof zt)return Ys;if(r instanceof Xn)return D;if(r instanceof wi)return W;if(r instanceof or)return ae;if(Array.isArray(r)){const t=r.length;let s;for(const l of r){const h=Si(l);if(s){if(s===h)continue;s=Ei;break}s=h}return Ce(s||Ei,t)}return Hr}function ha(r){const t=typeof r;return r===null?"":t==="string"||t==="number"||t==="boolean"?String(r):r instanceof zt||r instanceof wi||r instanceof or?r.toString():JSON.stringify(r)}class To{constructor(t,s){this.type=t,this.value=s}static parse(t,s){if(t.length!==2)return s.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!tl(t[1]))return s.error("invalid value");const l=t[1];let h=Si(l);const g=s.expectedType;return h.kind!=="array"||h.N!==0||!g||g.kind!=="array"||typeof g.N=="number"&&g.N!==0||(h=g),new To(h,l)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return this.type.kind==="array"||this.type.kind==="object"?["literal",this.value]:this.value instanceof zt?["rgba"].concat(this.value.toArray()):this.value instanceof wi?this.value.serialize():this.value}}var Fs=To,os=class{constructor(r){this.name="ExpressionEvaluationError",this.message=r}toJSON(){return this.message}};const mo={string:Oi,number:En,boolean:Mi,object:Hr};class Ao{constructor(t,s){this.type=t,this.args=s}static parse(t,s){if(t.length<2)return s.error("Expected at least one argument.");let l,h=1;const g=t[0];if(g==="array"){let S,A;if(t.length>2){const P=t[1];if(typeof P!="string"||!(P in mo)||P==="object")return s.error('The item type argument of "array" must be one of string, number, boolean',1);S=mo[P],h++}else S=Ei;if(t.length>3){if(t[2]!==null&&(typeof t[2]!="number"||t[2]<0||t[2]!==Math.floor(t[2])))return s.error('The length argument to "array" must be a positive integer literal',2);A=t[2],h++}l=Ce(S,A)}else l=mo[g];const v=[];for(;h<t.length;h++){const S=s.parse(t[h],h,Ei);if(!S)return null;v.push(S)}return new Ao(l,v)}evaluate(t){for(let s=0;s<this.args.length;s++){const l=this.args[s].evaluate(t);if(!nt(this.type,Si(l)))return l;if(s===this.args.length-1)throw new os(`Expected value to be of type ${Oe(this.type)}, but found ${Oe(Si(l))} instead.`)}return null}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}serialize(){const t=this.type,s=[t.kind];if(t.kind==="array"){const l=t.itemType;if(l.kind==="string"||l.kind==="number"||l.kind==="boolean"){s.push(l.kind);const h=t.N;(typeof h=="number"||this.args.length>1)&&s.push(h)}}return s.concat(this.args.map(l=>l.serialize()))}}var Js=Ao;class Vo{constructor(t){this.type=W,this.sections=t}static parse(t,s){if(t.length<2)return s.error("Expected at least one argument.");const l=t[1];if(!Array.isArray(l)&&typeof l=="object")return s.error("First argument must be an image or text section.");const h=[];let g=!1;for(let v=1;v<=t.length-1;++v){const S=t[v];if(g&&typeof S=="object"&&!Array.isArray(S)){g=!1;let A=null;if(S["font-scale"]&&(A=s.parse(S["font-scale"],1,En),!A))return null;let P=null;if(S["text-font"]&&(P=s.parse(S["text-font"],1,Ce(Oi)),!P))return null;let U=null;if(S["text-color"]&&(U=s.parse(S["text-color"],1,Ys),!U))return null;const G=h[h.length-1];G.scale=A,G.font=P,G.textColor=U}else{const A=s.parse(t[v],1,Ei);if(!A)return null;const P=A.type.kind;if(P!=="string"&&P!=="value"&&P!=="null"&&P!=="resolvedImage")return s.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");g=!0,h.push({content:A,scale:null,font:null,textColor:null})}}return new Vo(h)}evaluate(t){return new wi(this.sections.map(s=>{const l=s.content.evaluate(t);return Si(l)===ae?new ur("",l,null,null,null):new ur(ha(l),null,s.scale?s.scale.evaluate(t):null,s.font?s.font.evaluate(t).join(","):null,s.textColor?s.textColor.evaluate(t):null)}))}eachChild(t){for(const s of this.sections)t(s.content),s.scale&&t(s.scale),s.font&&t(s.font),s.textColor&&t(s.textColor)}outputDefined(){return!1}serialize(){const t=["format"];for(const s of this.sections){t.push(s.content.serialize());const l={};s.scale&&(l["font-scale"]=s.scale.serialize()),s.font&&(l["text-font"]=s.font.serialize()),s.textColor&&(l["text-color"]=s.textColor.serialize()),t.push(l)}return t}}class gl{constructor(t){this.type=ae,this.input=t}static parse(t,s){if(t.length!==2)return s.error("Expected two arguments.");const l=s.parse(t[1],1,Oi);return l?new gl(l):s.error("No image name provided.")}evaluate(t){const s=this.input.evaluate(t),l=or.fromString(s);return l&&t.availableImages&&(l.available=t.availableImages.indexOf(s)>-1),l}eachChild(t){t(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const dh={"to-boolean":Mi,"to-color":Ys,"to-number":En,"to-string":Oi};class Co{constructor(t,s){this.type=t,this.args=s}static parse(t,s){if(t.length<2)return s.error("Expected at least one argument.");const l=t[0];if((l==="to-boolean"||l==="to-string")&&t.length!==2)return s.error("Expected one argument.");const h=dh[l],g=[];for(let v=1;v<t.length;v++){const S=s.parse(t[v],v,Ei);if(!S)return null;g.push(S)}return new Co(h,g)}evaluate(t){if(this.type.kind==="boolean")return Boolean(this.args[0].evaluate(t));if(this.type.kind==="color"){let s,l;for(const h of this.args){if(s=h.evaluate(t),l=null,s instanceof zt)return s;if(typeof s=="string"){const g=t.parseColor(s);if(g)return g}else if(Array.isArray(s)&&(l=s.length<3||s.length>4?`Invalid rbga value ${JSON.stringify(s)}: expected an array containing either three or four numeric values.`:lc(s[0],s[1],s[2],s[3]),!l))return new zt(s[0]/255,s[1]/255,s[2]/255,s[3])}throw new os(l||`Could not parse color from value '${typeof s=="string"?s:String(JSON.stringify(s))}'`)}if(this.type.kind==="number"){let s=null;for(const l of this.args){if(s=l.evaluate(t),s===null)return 0;const h=Number(s);if(!isNaN(h))return h}throw new os(`Could not convert ${JSON.stringify(s)} to number.`)}return this.type.kind==="formatted"?wi.fromString(ha(this.args[0].evaluate(t))):this.type.kind==="resolvedImage"?or.fromString(ha(this.args[0].evaluate(t))):ha(this.args[0].evaluate(t))}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}serialize(){if(this.type.kind==="formatted")return new Vo([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if(this.type.kind==="resolvedImage")return new gl(this.args[0]).serialize();const t=[`to-${this.type.kind}`];return this.eachChild(s=>{t.push(s.serialize())}),t}}var _l=Co;const Ks=["Unknown","Point","LineString","Polygon"];var cc=class{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null}id(){return this.feature&&this.feature.id!==void 0?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?Ks[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const r=this.featureDistanceData.center,t=this.featureDistanceData.scale,{x:s,y:l}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(s*t-r[0])+this.featureDistanceData.bearing[1]*(l*t-r[1])}return 0}parseColor(r){let t=this._parseColorCache[r];return t||(t=this._parseColorCache[r]=zt.parse(r)),t}};class as{constructor(t,s,l,h){this.name=t,this.type=s,this._evaluate=l,this.args=h}evaluate(t){return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map(t=>t.serialize()))}static parse(t,s){const l=t[0],h=as.definitions[l];if(!h)return s.error(`Unknown expression "${l}". If you wanted a literal array, use ["literal", [...]].`,0);const g=Array.isArray(h)?h[0]:h.type,v=Array.isArray(h)?[[h[1],h[2]]]:h.overloads,S=v.filter(([P])=>!Array.isArray(P)||P.length===t.length-1);let A=null;for(const[P,U]of S){A=new Bl(s.registry,s.path,null,s.scope);const G=[];let j=!1;for(let $=1;$<t.length;$++){const J=t[$],re=Array.isArray(P)?P[$-1]:P.type,de=A.parse(J,1+G.length,re);if(!de){j=!0;break}G.push(de)}if(!j)if(Array.isArray(P)&&P.length!==G.length)A.error(`Expected ${P.length} arguments, but found ${G.length} instead.`);else{for(let $=0;$<G.length;$++){const J=Array.isArray(P)?P[$]:P.type,re=G[$];A.concat($+1).checkSubtype(J,re.type)}if(A.errors.length===0)return new as(l,g,U,G)}}if(S.length===1)s.errors.push(...A.errors);else{const P=(S.length?S:v).map(([G])=>{return j=G,Array.isArray(j)?`(${j.map(Oe).join(", ")})`:`(${Oe(j.type)}...)`;var j}).join(" | "),U=[];for(let G=1;G<t.length;G++){const j=s.parse(t[G],1+U.length);if(!j)return null;U.push(Oe(j.type))}s.error(`Expected arguments of type ${P}, but found (${U.join(", ")}) instead.`)}return null}static register(t,s){as.definitions=s;for(const l in s)t[l]=as}}var Io=as;class Da{constructor(t,s,l){this.type=D,this.locale=l,this.caseSensitive=t,this.diacriticSensitive=s}static parse(t,s){if(t.length!==2)return s.error("Expected one argument.");const l=t[1];if(typeof l!="object"||Array.isArray(l))return s.error("Collator options argument must be an object.");const h=s.parse(l["case-sensitive"]!==void 0&&l["case-sensitive"],1,Mi);if(!h)return null;const g=s.parse(l["diacritic-sensitive"]!==void 0&&l["diacritic-sensitive"],1,Mi);if(!g)return null;let v=null;return l.locale&&(v=s.parse(l.locale,1,Oi),!v)?null:new Da(h,g,v)}evaluate(t){return new Xn(this.caseSensitive.evaluate(t),this.diacriticSensitive.evaluate(t),this.locale?this.locale.evaluate(t):null)}eachChild(t){t(this.caseSensitive),t(this.diacriticSensitive),this.locale&&t(this.locale)}outputDefined(){return!1}serialize(){const t={};return t["case-sensitive"]=this.caseSensitive.serialize(),t["diacritic-sensitive"]=this.diacriticSensitive.serialize(),this.locale&&(t.locale=this.locale.serialize()),["collator",t]}}const ds=8192;function za(r,t){r[0]=Math.min(r[0],t[0]),r[1]=Math.min(r[1],t[1]),r[2]=Math.max(r[2],t[0]),r[3]=Math.max(r[3],t[1])}function da(r,t){return!(r[0]<=t[0]||r[2]>=t[2]||r[1]<=t[1]||r[3]>=t[3])}function Bs(r,t){const s=(180+r[0])/360,l=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+r[1]*Math.PI/360)))/360,h=Math.pow(2,t.z);return[Math.round(s*h*ds),Math.round(l*h*ds)]}function Ol(r,t,s){const l=r[0]-t[0],h=r[1]-t[1],g=r[0]-s[0],v=r[1]-s[1];return l*v-g*h==0&&l*g<=0&&h*v<=0}function nl(r,t){let s=!1;for(let v=0,S=t.length;v<S;v++){const A=t[v];for(let P=0,U=A.length;P<U-1;P++){if(Ol(r,A[P],A[P+1]))return!1;(h=A[P])[1]>(l=r)[1]!=(g=A[P+1])[1]>l[1]&&l[0]<(g[0]-h[0])*(l[1]-h[1])/(g[1]-h[1])+h[0]&&(s=!s)}}var l,h,g;return s}function ka(r,t){for(let s=0;s<t.length;s++)if(nl(r,t[s]))return!0;return!1}function Ns(r,t,s,l){const h=l[0]-s[0],g=l[1]-s[1],v=(r[0]-s[0])*g-h*(r[1]-s[1]),S=(t[0]-s[0])*g-h*(t[1]-s[1]);return v>0&&S<0||v<0&&S>0}function ls(r,t,s){for(const P of s)for(let U=0;U<P.length-1;++U)if((S=[(v=P[U+1])[0]-(g=P[U])[0],v[1]-g[1]])[0]*(A=[(h=t)[0]-(l=r)[0],h[1]-l[1]])[1]-S[1]*A[0]!=0&&Ns(l,h,g,v)&&Ns(g,v,l,h))return!0;var l,h,g,v,S,A;return!1}function Bi(r,t){for(let s=0;s<r.length;++s)if(!nl(r[s],t))return!1;for(let s=0;s<r.length-1;++s)if(ls(r[s],r[s+1],t))return!1;return!0}function uc(r,t){for(let s=0;s<t.length;s++)if(Bi(r,t[s]))return!0;return!1}function hc(r,t,s){const l=[];for(let h=0;h<r.length;h++){const g=[];for(let v=0;v<r[h].length;v++){const S=Bs(r[h][v],s);za(t,S),g.push(S)}l.push(g)}return l}function Cs(r,t,s){const l=[];for(let h=0;h<r.length;h++){const g=hc(r[h],t,s);l.push(g)}return l}function Go(r,t,s,l){if(r[0]<s[0]||r[0]>s[2]){const h=.5*l;let g=r[0]-s[0]>h?-l:s[0]-r[0]>h?l:0;g===0&&(g=r[0]-s[2]>h?-l:s[2]-r[0]>h?l:0),r[0]+=g}za(t,r)}function Fl(r,t,s,l){const h=Math.pow(2,l.z)*ds,g=[l.x*ds,l.y*ds],v=[];if(!r)return v;for(const S of r)for(const A of S){const P=[A.x+g[0],A.y+g[1]];Go(P,t,s,h),v.push(P)}return v}function dc(r,t,s,l){const h=Math.pow(2,l.z)*ds,g=[l.x*ds,l.y*ds],v=[];if(!r)return v;for(const A of r){const P=[];for(const U of A){const G=[U.x+g[0],U.y+g[1]];za(t,G),P.push(G)}v.push(P)}if(t[2]-t[0]<=h/2){(S=t)[0]=S[1]=1/0,S[2]=S[3]=-1/0;for(const A of v)for(const P of A)Go(P,t,s,h)}var S;return v}class jo{constructor(t,s){this.type=Mi,this.geojson=t,this.geometries=s}static parse(t,s){if(t.length!==2)return s.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(tl(t[1])){const l=t[1];if(l.type==="FeatureCollection")for(let h=0;h<l.features.length;++h){const g=l.features[h].geometry.type;if(g==="Polygon"||g==="MultiPolygon")return new jo(l,l.features[h].geometry)}else if(l.type==="Feature"){const h=l.geometry.type;if(h==="Polygon"||h==="MultiPolygon")return new jo(l,l.geometry)}else if(l.type==="Polygon"||l.type==="MultiPolygon")return new jo(l,l)}return s.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(t.geometry()!=null&&t.canonicalID()!=null){if(t.geometryType()==="Point")return function(s,l){const h=[1/0,1/0,-1/0,-1/0],g=[1/0,1/0,-1/0,-1/0],v=s.canonicalID();if(!v)return!1;if(l.type==="Polygon"){const S=hc(l.coordinates,g,v),A=Fl(s.geometry(),h,g,v);if(!da(h,g))return!1;for(const P of A)if(!nl(P,S))return!1}if(l.type==="MultiPolygon"){const S=Cs(l.coordinates,g,v),A=Fl(s.geometry(),h,g,v);if(!da(h,g))return!1;for(const P of A)if(!ka(P,S))return!1}return!0}(t,this.geometries);if(t.geometryType()==="LineString")return function(s,l){const h=[1/0,1/0,-1/0,-1/0],g=[1/0,1/0,-1/0,-1/0],v=s.canonicalID();if(!v)return!1;if(l.type==="Polygon"){const S=hc(l.coordinates,g,v),A=dc(s.geometry(),h,g,v);if(!da(h,g))return!1;for(const P of A)if(!Bi(P,S))return!1}if(l.type==="MultiPolygon"){const S=Cs(l.coordinates,g,v),A=dc(s.geometry(),h,g,v);if(!da(h,g))return!1;for(const P of A)if(!uc(P,S))return!1}return!0}(t,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}serialize(){return["within",this.geojson]}}var fa=jo;function pa(r){if(r instanceof Io&&(r.name==="get"&&r.args.length===1||r.name==="feature-state"||r.name==="has"&&r.args.length===1||r.name==="properties"||r.name==="geometry-type"||r.name==="id"||/^filter-/.test(r.name))||r instanceof fa)return!1;let t=!0;return r.eachChild(s=>{t&&!pa(s)&&(t=!1)}),t}function go(r){if(r instanceof Io&&r.name==="feature-state")return!1;let t=!0;return r.eachChild(s=>{t&&!go(s)&&(t=!1)}),t}function Po(r,t){if(r instanceof Io&&t.indexOf(r.name)>=0)return!1;let s=!0;return r.eachChild(l=>{s&&!Po(l,t)&&(s=!1)}),s}class ma{constructor(t,s){this.type=s.type,this.name=t,this.boundExpression=s}static parse(t,s){if(t.length!==2||typeof t[1]!="string")return s.error("'var' expression requires exactly one string literal argument.");const l=t[1];return s.scope.has(l)?new ma(l,s.scope.get(l)):s.error(`Unknown variable "${l}". Make sure "${l}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}var qc=ma;class yl{constructor(t,s=[],l,h=new As,g=[]){this.registry=t,this.path=s,this.key=s.map(v=>`[${v}]`).join(""),this.scope=h,this.errors=g,this.expectedType=l}parse(t,s,l,h,g={}){return s?this.concat(s,l,h)._parse(t,g):this._parse(t,g)}_parse(t,s){function l(h,g,v){return v==="assert"?new Js(g,[h]):v==="coerce"?new _l(g,[h]):h}if(t!==null&&typeof t!="string"&&typeof t!="boolean"&&typeof t!="number"||(t=["literal",t]),Array.isArray(t)){if(t.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const h=t[0];if(typeof h!="string")return this.error(`Expression name must be a string, but found ${typeof h} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const g=this.registry[h];if(g){let v=g.parse(t,this);if(!v)return null;if(this.expectedType){const S=this.expectedType,A=v.type;if(S.kind!=="string"&&S.kind!=="number"&&S.kind!=="boolean"&&S.kind!=="object"&&S.kind!=="array"||A.kind!=="value")if(S.kind!=="color"&&S.kind!=="formatted"&&S.kind!=="resolvedImage"||A.kind!=="value"&&A.kind!=="string"){if(this.checkSubtype(S,A))return null}else v=l(v,S,s.typeAnnotation||"coerce");else v=l(v,S,s.typeAnnotation||"assert")}if(!(v instanceof Fs)&&v.type.kind!=="resolvedImage"&&Oa(v)){const S=new cc;try{v=new Fs(v.type,v.evaluate(S))}catch(A){return this.error(A.message),null}}return v}return this.error(`Unknown expression "${h}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(t===void 0?"'undefined' value invalid. Use null instead.":typeof t=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,s,l){const h=typeof t=="number"?this.path.concat(t):this.path,g=l?this.scope.concat(l):this.scope;return new yl(this.registry,h,s||null,g,this.errors)}error(t,...s){const l=`${this.key}${s.map(h=>`[${h}]`).join("")}`;this.errors.push(new Ts(l,t))}checkSubtype(t,s){const l=nt(t,s);return l&&this.error(l),l}}var Bl=yl;function Oa(r){if(r instanceof qc)return Oa(r.boundExpression);if(r instanceof Io&&r.name==="error"||r instanceof Da||r instanceof fa)return!1;const t=r instanceof _l||r instanceof Js;let s=!0;return r.eachChild(l=>{s=t?s&&Oa(l):s&&l instanceof Fs}),!!s&&pa(r)&&Po(r,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center"])}function ga(r,t){const s=r.length-1;let l,h,g=0,v=s,S=0;for(;g<=v;)if(S=Math.floor((g+v)/2),l=r[S],h=r[S+1],l<=t){if(S===s||t<h)return S;g=S+1}else{if(!(l>t))throw new os("Input is not a number.");v=S-1}return 0}class Fa{constructor(t,s,l){this.type=t,this.input=s,this.labels=[],this.outputs=[];for(const[h,g]of l)this.labels.push(h),this.outputs.push(g)}static parse(t,s){if(t.length-1<4)return s.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return s.error("Expected an even number of arguments.");const l=s.parse(t[1],1,En);if(!l)return null;const h=[];let g=null;s.expectedType&&s.expectedType.kind!=="value"&&(g=s.expectedType);for(let v=1;v<t.length;v+=2){const S=v===1?-1/0:t[v],A=t[v+1],P=v,U=v+1;if(typeof S!="number")return s.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',P);if(h.length&&h[h.length-1][0]>=S)return s.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',P);const G=s.parse(A,U,g);if(!G)return null;g=g||G.type,h.push([S,G])}return new Fa(g,l,h)}evaluate(t){const s=this.labels,l=this.outputs;if(s.length===1)return l[0].evaluate(t);const h=this.input.evaluate(t);if(h<=s[0])return l[0].evaluate(t);const g=s.length;return h>=s[g-1]?l[g-1].evaluate(t):l[ga(s,h)].evaluate(t)}eachChild(t){t(this.input);for(const s of this.outputs)t(s)}outputDefined(){return this.outputs.every(t=>t.outputDefined())}serialize(){const t=["step",this.input.serialize()];for(let s=0;s<this.labels.length;s++)s>0&&t.push(this.labels[s]),t.push(this.outputs[s].serialize());return t}}var Ba=Fa;function gi(r,t,s){return r*(1-s)+t*s}var Or=Object.freeze({__proto__:null,array:function(r,t,s){return r.map((l,h)=>gi(l,t[h],s))},color:function(r,t,s){return new zt(gi(r.r,t.r,s),gi(r.g,t.g,s),gi(r.b,t.b,s),gi(r.a,t.a,s))},number:gi});const Qs=.95047,eo=1.08883,fs=4/29,_o=6/29,il=3*_o*_o,rl=_o*_o*_o,fc=Math.PI/180,to=180/Math.PI;function Us(r){return r>rl?Math.pow(r,1/3):r/il+fs}function Sr(r){return r>_o?r*r*r:il*(r-fs)}function Na(r){return 255*(r<=.0031308?12.92*r:1.055*Math.pow(r,1/2.4)-.055)}function Vs(r){return(r/=255)<=.04045?r/12.92:Math.pow((r+.055)/1.055,2.4)}function xl(r){const t=Vs(r.r),s=Vs(r.g),l=Vs(r.b),h=Us((.4124564*t+.3575761*s+.1804375*l)/Qs),g=Us((.2126729*t+.7151522*s+.072175*l)/1);return{l:116*g-16,a:500*(h-g),b:200*(g-Us((.0193339*t+.119192*s+.9503041*l)/eo)),alpha:r.a}}function Ua(r){let t=(r.l+16)/116,s=isNaN(r.a)?t:t+r.a/500,l=isNaN(r.b)?t:t-r.b/200;return t=1*Sr(t),s=Qs*Sr(s),l=eo*Sr(l),new zt(Na(3.2404542*s-1.5371385*t-.4985314*l),Na(-.969266*s+1.8760108*t+.041556*l),Na(.0556434*s-.2040259*t+1.0572252*l),r.alpha)}function Zc(r,t,s){const l=t-r;return r+s*(l>180||l<-180?l-360*Math.round(l/360):l)}const no={forward:xl,reverse:Ua,interpolate:function(r,t,s){return{l:gi(r.l,t.l,s),a:gi(r.a,t.a,s),b:gi(r.b,t.b,s),alpha:gi(r.alpha,t.alpha,s)}}},sl={forward:function(r){const{l:t,a:s,b:l}=xl(r),h=Math.atan2(l,s)*to;return{h:h<0?h+360:h,c:Math.sqrt(s*s+l*l),l:t,alpha:r.a}},reverse:function(r){const t=r.h*fc,s=r.c;return Ua({l:r.l,a:Math.cos(t)*s,b:Math.sin(t)*s,alpha:r.alpha})},interpolate:function(r,t,s){return{h:Zc(r.h,t.h,s),c:gi(r.c,t.c,s),l:gi(r.l,t.l,s),alpha:gi(r.alpha,t.alpha,s)}}};var yo=Object.freeze({__proto__:null,hcl:sl,lab:no});class Wo{constructor(t,s,l,h,g){this.type=t,this.operator=s,this.interpolation=l,this.input=h,this.labels=[],this.outputs=[];for(const[v,S]of g)this.labels.push(v),this.outputs.push(S)}static interpolationFactor(t,s,l,h){let g=0;if(t.name==="exponential")g=Nl(s,t.base,l,h);else if(t.name==="linear")g=Nl(s,1,l,h);else if(t.name==="cubic-bezier"){const v=t.controlPoints;g=new fe(v[0],v[1],v[2],v[3]).solve(Nl(s,1,l,h))}return g}static parse(t,s){let[l,h,g,...v]=t;if(!Array.isArray(h)||h.length===0)return s.error("Expected an interpolation type expression.",1);if(h[0]==="linear")h={name:"linear"};else if(h[0]==="exponential"){const P=h[1];if(typeof P!="number")return s.error("Exponential interpolation requires a numeric base.",1,1);h={name:"exponential",base:P}}else{if(h[0]!=="cubic-bezier")return s.error(`Unknown interpolation type ${String(h[0])}`,1,0);{const P=h.slice(1);if(P.length!==4||P.some(U=>typeof U!="number"||U<0||U>1))return s.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);h={name:"cubic-bezier",controlPoints:P}}}if(t.length-1<4)return s.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return s.error("Expected an even number of arguments.");if(g=s.parse(g,2,En),!g)return null;const S=[];let A=null;l==="interpolate-hcl"||l==="interpolate-lab"?A=Ys:s.expectedType&&s.expectedType.kind!=="value"&&(A=s.expectedType);for(let P=0;P<v.length;P+=2){const U=v[P],G=v[P+1],j=P+3,$=P+4;if(typeof U!="number")return s.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',j);if(S.length&&S[S.length-1][0]>=U)return s.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',j);const J=s.parse(G,$,A);if(!J)return null;A=A||J.type,S.push([U,J])}return A.kind==="number"||A.kind==="color"||A.kind==="array"&&A.itemType.kind==="number"&&typeof A.N=="number"?new Wo(A,l,h,g,S):s.error(`Type ${Oe(A)} is not interpolatable.`)}evaluate(t){const s=this.labels,l=this.outputs;if(s.length===1)return l[0].evaluate(t);const h=this.input.evaluate(t);if(h<=s[0])return l[0].evaluate(t);const g=s.length;if(h>=s[g-1])return l[g-1].evaluate(t);const v=ga(s,h),S=Wo.interpolationFactor(this.interpolation,h,s[v],s[v+1]),A=l[v].evaluate(t),P=l[v+1].evaluate(t);return this.operator==="interpolate"?Or[this.type.kind.toLowerCase()](A,P,S):this.operator==="interpolate-hcl"?sl.reverse(sl.interpolate(sl.forward(A),sl.forward(P),S)):no.reverse(no.interpolate(no.forward(A),no.forward(P),S))}eachChild(t){t(this.input);for(const s of this.outputs)t(s)}outputDefined(){return this.outputs.every(t=>t.outputDefined())}serialize(){let t;t=this.interpolation.name==="linear"?["linear"]:this.interpolation.name==="exponential"?this.interpolation.base===1?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const s=[this.operator,t,this.input.serialize()];for(let l=0;l<this.labels.length;l++)s.push(this.labels[l],this.outputs[l].serialize());return s}}function Nl(r,t,s,l){const h=l-s,g=r-s;return h===0?0:t===1?g/h:(Math.pow(t,g)-1)/(Math.pow(t,h)-1)}var ps=Wo;class _a{constructor(t,s){this.type=t,this.args=s}static parse(t,s){if(t.length<2)return s.error("Expectected at least one argument.");let l=null;const h=s.expectedType;h&&h.kind!=="value"&&(l=h);const g=[];for(const S of t.slice(1)){const A=s.parse(S,1+g.length,l,void 0,{typeAnnotation:"omit"});if(!A)return null;l=l||A.type,g.push(A)}const v=h&&g.some(S=>nt(h,S.type));return new _a(v?Ei:l,g)}evaluate(t){let s,l=null,h=0;for(const g of this.args){if(h++,l=g.evaluate(t),l&&l instanceof or&&!l.available&&(s||(s=l),l=null,h===this.args.length))return s;if(l!==null)break}return l}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}serialize(){const t=["coalesce"];return this.eachChild(s=>{t.push(s.serialize())}),t}}var Ul=_a;class vl{constructor(t,s){this.type=s.type,this.bindings=[].concat(t),this.result=s}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const s of this.bindings)t(s[1]);t(this.result)}static parse(t,s){if(t.length<4)return s.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);const l=[];for(let g=1;g<t.length-1;g+=2){const v=t[g];if(typeof v!="string")return s.error(`Expected string, but found ${typeof v} instead.`,g);if(/[^a-zA-Z0-9_]/.test(v))return s.error("Variable names must contain only alphanumeric characters or '_'.",g);const S=s.parse(t[g+1],g+1);if(!S)return null;l.push([v,S])}const h=s.parse(t[t.length-1],t.length-1,s.expectedType,l);return h?new vl(l,h):null}outputDefined(){return this.result.outputDefined()}serialize(){const t=["let"];for(const[s,l]of this.bindings)t.push(s,l.serialize());return t.push(this.result.serialize()),t}}var Va=vl;class Ga{constructor(t,s,l){this.type=t,this.index=s,this.input=l}static parse(t,s){if(t.length!==3)return s.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const l=s.parse(t[1],1,En),h=s.parse(t[2],2,Ce(s.expectedType||Ei));return l&&h?new Ga(h.type.itemType,l,h):null}evaluate(t){const s=this.index.evaluate(t),l=this.input.evaluate(t);if(s<0)throw new os(`Array index out of bounds: ${s} < 0.`);if(s>=l.length)throw new os(`Array index out of bounds: ${s} > ${l.length-1}.`);if(s!==Math.floor(s))throw new os(`Array index must be an integer, but found ${s} instead.`);return l[s]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}var bl=Ga;class io{constructor(t,s){this.type=Mi,this.needle=t,this.haystack=s}static parse(t,s){if(t.length!==3)return s.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const l=s.parse(t[1],1,Ei),h=s.parse(t[2],2,Ei);return l&&h?en(l.type,[Mi,Oi,En,Uo,Ei])?new io(l,h):s.error(`Expected first argument to be of type boolean, string, number or null, but found ${Oe(l.type)} instead`):null}evaluate(t){const s=this.needle.evaluate(t),l=this.haystack.evaluate(t);if(l==null)return!1;if(!cn(s,["boolean","string","number","null"]))throw new os(`Expected first argument to be of type boolean, string, number or null, but found ${Oe(Si(s))} instead.`);if(!cn(l,["string","array"]))throw new os(`Expected second argument to be of type array or string, but found ${Oe(Si(l))} instead.`);return l.indexOf(s)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}var ot=io;class At{constructor(t,s,l){this.type=En,this.needle=t,this.haystack=s,this.fromIndex=l}static parse(t,s){if(t.length<=2||t.length>=5)return s.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const l=s.parse(t[1],1,Ei),h=s.parse(t[2],2,Ei);if(!l||!h)return null;if(!en(l.type,[Mi,Oi,En,Uo,Ei]))return s.error(`Expected first argument to be of type boolean, string, number or null, but found ${Oe(l.type)} instead`);if(t.length===4){const g=s.parse(t[3],3,En);return g?new At(l,h,g):null}return new At(l,h)}evaluate(t){const s=this.needle.evaluate(t),l=this.haystack.evaluate(t);if(!cn(s,["boolean","string","number","null"]))throw new os(`Expected first argument to be of type boolean, string, number or null, but found ${Oe(Si(s))} instead.`);if(!cn(l,["string","array"]))throw new os(`Expected second argument to be of type array or string, but found ${Oe(Si(l))} instead.`);if(this.fromIndex){const h=this.fromIndex.evaluate(t);return l.indexOf(s,h)}return l.indexOf(s)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}serialize(){if(this.fromIndex!=null&&this.fromIndex!==void 0){const t=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),t]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}var yn=At;class ni{constructor(t,s,l,h,g,v){this.inputType=t,this.type=s,this.input=l,this.cases=h,this.outputs=g,this.otherwise=v}static parse(t,s){if(t.length<5)return s.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return s.error("Expected an even number of arguments.");let l,h;s.expectedType&&s.expectedType.kind!=="value"&&(h=s.expectedType);const g={},v=[];for(let P=2;P<t.length-1;P+=2){let U=t[P];const G=t[P+1];Array.isArray(U)||(U=[U]);const j=s.concat(P);if(U.length===0)return j.error("Expected at least one branch label.");for(const J of U){if(typeof J!="number"&&typeof J!="string")return j.error("Branch labels must be numbers or strings.");if(typeof J=="number"&&Math.abs(J)>Number.MAX_SAFE_INTEGER)return j.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof J=="number"&&Math.floor(J)!==J)return j.error("Numeric branch labels must be integer values.");if(l){if(j.checkSubtype(l,Si(J)))return null}else l=Si(J);if(g[String(J)]!==void 0)return j.error("Branch labels must be unique.");g[String(J)]=v.length}const $=s.parse(G,P,h);if(!$)return null;h=h||$.type,v.push($)}const S=s.parse(t[1],1,Ei);if(!S)return null;const A=s.parse(t[t.length-1],t.length-1,h);return A?S.type.kind!=="value"&&s.concat(1).checkSubtype(l,S.type)?null:new ni(l,h,S,g,v,A):null}evaluate(t){const s=this.input.evaluate(t);return(Si(s)===this.inputType&&this.outputs[this.cases[s]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)}outputDefined(){return this.outputs.every(t=>t.outputDefined())&&this.otherwise.outputDefined()}serialize(){const t=["match",this.input.serialize()],s=Object.keys(this.cases).sort(),l=[],h={};for(const v of s){const S=h[this.cases[v]];S===void 0?(h[this.cases[v]]=l.length,l.push([this.cases[v],[v]])):l[S][1].push(v)}const g=v=>this.inputType.kind==="number"?Number(v):v;for(const[v,S]of l)t.push(S.length===1?g(S[0]):S.map(g)),t.push(this.outputs[v].serialize());return t.push(this.otherwise.serialize()),t}}var fr=ni;class Wi{constructor(t,s,l){this.type=t,this.branches=s,this.otherwise=l}static parse(t,s){if(t.length<4)return s.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return s.error("Expected an odd number of arguments.");let l;s.expectedType&&s.expectedType.kind!=="value"&&(l=s.expectedType);const h=[];for(let v=1;v<t.length-1;v+=2){const S=s.parse(t[v],v,Mi);if(!S)return null;const A=s.parse(t[v+1],v+1,l);if(!A)return null;h.push([S,A]),l=l||A.type}const g=s.parse(t[t.length-1],t.length-1,l);return g?new Wi(l,h,g):null}evaluate(t){for(const[s,l]of this.branches)if(s.evaluate(t))return l.evaluate(t);return this.otherwise.evaluate(t)}eachChild(t){for(const[s,l]of this.branches)t(s),t(l);t(this.otherwise)}outputDefined(){return this.branches.every(([t,s])=>s.outputDefined())&&this.otherwise.outputDefined()}serialize(){const t=["case"];return this.eachChild(s=>{t.push(s.serialize())}),t}}var Pr=Wi;class Ti{constructor(t,s,l,h){this.type=t,this.input=s,this.beginIndex=l,this.endIndex=h}static parse(t,s){if(t.length<=2||t.length>=5)return s.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const l=s.parse(t[1],1,Ei),h=s.parse(t[2],2,En);if(!l||!h)return null;if(!en(l.type,[Ce(Ei),Oi,Ei]))return s.error(`Expected first argument to be of type array or string, but found ${Oe(l.type)} instead`);if(t.length===4){const g=s.parse(t[3],3,En);return g?new Ti(l.type,l,h,g):null}return new Ti(l.type,l,h)}evaluate(t){const s=this.input.evaluate(t),l=this.beginIndex.evaluate(t);if(!cn(s,["string","array"]))throw new os(`Expected first argument to be of type array or string, but found ${Oe(Si(s))} instead.`);if(this.endIndex){const h=this.endIndex.evaluate(t);return s.slice(l,h)}return s.slice(l)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}serialize(){if(this.endIndex!=null&&this.endIndex!==void 0){const t=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),t]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}var Gs=Ti;function Fr(r,t){return r==="=="||r==="!="?t.kind==="boolean"||t.kind==="string"||t.kind==="number"||t.kind==="null"||t.kind==="value":t.kind==="string"||t.kind==="number"||t.kind==="value"}function Vr(r,t,s,l){return l.compare(t,s)===0}function cs(r,t,s){const l=r!=="=="&&r!=="!=";return class V2{constructor(g,v,S){this.type=Mi,this.lhs=g,this.rhs=v,this.collator=S,this.hasUntypedArgument=g.type.kind==="value"||v.type.kind==="value"}static parse(g,v){if(g.length!==3&&g.length!==4)return v.error("Expected two or three arguments.");const S=g[0];let A=v.parse(g[1],1,Ei);if(!A)return null;if(!Fr(S,A.type))return v.concat(1).error(`"${S}" comparisons are not supported for type '${Oe(A.type)}'.`);let P=v.parse(g[2],2,Ei);if(!P)return null;if(!Fr(S,P.type))return v.concat(2).error(`"${S}" comparisons are not supported for type '${Oe(P.type)}'.`);if(A.type.kind!==P.type.kind&&A.type.kind!=="value"&&P.type.kind!=="value")return v.error(`Cannot compare types '${Oe(A.type)}' and '${Oe(P.type)}'.`);l&&(A.type.kind==="value"&&P.type.kind!=="value"?A=new Js(P.type,[A]):A.type.kind!=="value"&&P.type.kind==="value"&&(P=new Js(A.type,[P])));let U=null;if(g.length===4){if(A.type.kind!=="string"&&P.type.kind!=="string"&&A.type.kind!=="value"&&P.type.kind!=="value")return v.error("Cannot use collator to compare non-string types.");if(U=v.parse(g[3],3,D),!U)return null}return new V2(A,P,U)}evaluate(g){const v=this.lhs.evaluate(g),S=this.rhs.evaluate(g);if(l&&this.hasUntypedArgument){const A=Si(v),P=Si(S);if(A.kind!==P.kind||A.kind!=="string"&&A.kind!=="number")throw new os(`Expected arguments for "${r}" to be (string, string) or (number, number), but found (${A.kind}, ${P.kind}) instead.`)}if(this.collator&&!l&&this.hasUntypedArgument){const A=Si(v),P=Si(S);if(A.kind!=="string"||P.kind!=="string")return t(g,v,S)}return this.collator?s(g,v,S,this.collator.evaluate(g)):t(g,v,S)}eachChild(g){g(this.lhs),g(this.rhs),this.collator&&g(this.collator)}outputDefined(){return!0}serialize(){const g=[r];return this.eachChild(v=>{g.push(v.serialize())}),g}}}const Jr=cs("==",function(r,t,s){return t===s},Vr),Kr=cs("!=",function(r,t,s){return t!==s},function(r,t,s,l){return!Vr(0,t,s,l)}),pr=cs("<",function(r,t,s){return t<s},function(r,t,s,l){return l.compare(t,s)<0}),qr=cs(">",function(r,t,s){return t>s},function(r,t,s,l){return l.compare(t,s)>0}),Zr=cs("<=",function(r,t,s){return t<=s},function(r,t,s,l){return l.compare(t,s)<=0}),ta=cs(">=",function(r,t,s){return t>=s},function(r,t,s,l){return l.compare(t,s)>=0});class Lo{constructor(t,s,l,h,g,v){this.type=Oi,this.number=t,this.locale=s,this.currency=l,this.unit=h,this.minFractionDigits=g,this.maxFractionDigits=v}static parse(t,s){if(t.length!==3)return s.error("Expected two arguments.");const l=s.parse(t[1],1,En);if(!l)return null;const h=t[2];if(typeof h!="object"||Array.isArray(h))return s.error("NumberFormat options argument must be an object.");let g=null;if(h.locale&&(g=s.parse(h.locale,1,Oi),!g))return null;let v=null;if(h.currency&&(v=s.parse(h.currency,1,Oi),!v))return null;let S=null;if(h.unit&&(S=s.parse(h.unit,1,Oi),!S))return null;let A=null;if(h["min-fraction-digits"]&&(A=s.parse(h["min-fraction-digits"],1,En),!A))return null;let P=null;return h["max-fraction-digits"]&&(P=s.parse(h["max-fraction-digits"],1,En),!P)?null:new Lo(l,g,v,S,A,P)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(t):void 0,unit:this.unit?this.unit.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.unit&&t(this.unit),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const t={};return this.locale&&(t.locale=this.locale.serialize()),this.currency&&(t.currency=this.currency.serialize()),this.unit&&(t.unit=this.unit.serialize()),this.minFractionDigits&&(t["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(t["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),t]}}class Ho{constructor(t){this.type=En,this.input=t}static parse(t,s){if(t.length!==2)return s.error(`Expected 1 argument, but found ${t.length-1} instead.`);const l=s.parse(t[1],1);return l?l.type.kind!=="array"&&l.type.kind!=="string"&&l.type.kind!=="value"?s.error(`Expected argument of type string or array, but found ${Oe(l.type)} instead.`):new Ho(l):null}evaluate(t){const s=this.input.evaluate(t);if(typeof s=="string"||Array.isArray(s))return s.length;throw new os(`Expected value to be of type string or array, but found ${Oe(Si(s))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}serialize(){const t=["length"];return this.eachChild(s=>{t.push(s.serialize())}),t}}const Eu={"==":Jr,"!=":Kr,">":qr,"<":pr,">=":ta,"<=":Zr,array:Js,at:bl,boolean:Js,case:Pr,coalesce:Ul,collator:Da,format:Vo,image:gl,in:ot,"index-of":yn,interpolate:ps,"interpolate-hcl":ps,"interpolate-lab":ps,length:Ho,let:Va,literal:Fs,match:fr,number:Js,"number-format":Lo,object:Js,slice:Gs,step:Ba,string:Js,"to-boolean":_l,"to-color":_l,"to-number":_l,"to-string":_l,var:qc,within:fa};function ms(r,[t,s,l,h]){t=t.evaluate(r),s=s.evaluate(r),l=l.evaluate(r);const g=h?h.evaluate(r):1,v=lc(t,s,l,g);if(v)throw new os(v);return new zt(t/255*g,s/255*g,l/255*g,g)}function Xi(r,t){return r in t}function ir(r,t){const s=t[r];return s===void 0?null:s}function gs(r){return{type:r}}Io.register(Eu,{error:[{kind:"error"},[Oi],(r,[t])=>{throw new os(t.evaluate(r))}],typeof:[Oi,[Ei],(r,[t])=>Oe(Si(t.evaluate(r)))],"to-rgba":[Ce(En,4),[Ys],(r,[t])=>t.evaluate(r).toArray()],rgb:[Ys,[En,En,En],ms],rgba:[Ys,[En,En,En,En],ms],has:{type:Mi,overloads:[[[Oi],(r,[t])=>Xi(t.evaluate(r),r.properties())],[[Oi,Hr],(r,[t,s])=>Xi(t.evaluate(r),s.evaluate(r))]]},get:{type:Ei,overloads:[[[Oi],(r,[t])=>ir(t.evaluate(r),r.properties())],[[Oi,Hr],(r,[t,s])=>ir(t.evaluate(r),s.evaluate(r))]]},"feature-state":[Ei,[Oi],(r,[t])=>ir(t.evaluate(r),r.featureState||{})],properties:[Hr,[],r=>r.properties()],"geometry-type":[Oi,[],r=>r.geometryType()],id:[Ei,[],r=>r.id()],zoom:[En,[],r=>r.globals.zoom],pitch:[En,[],r=>r.globals.pitch||0],"distance-from-center":[En,[],r=>r.distanceFromCenter()],"heatmap-density":[En,[],r=>r.globals.heatmapDensity||0],"line-progress":[En,[],r=>r.globals.lineProgress||0],"sky-radial-progress":[En,[],r=>r.globals.skyRadialProgress||0],accumulated:[Ei,[],r=>r.globals.accumulated===void 0?null:r.globals.accumulated],"+":[En,gs(En),(r,t)=>{let s=0;for(const l of t)s+=l.evaluate(r);return s}],"*":[En,gs(En),(r,t)=>{let s=1;for(const l of t)s*=l.evaluate(r);return s}],"-":{type:En,overloads:[[[En,En],(r,[t,s])=>t.evaluate(r)-s.evaluate(r)],[[En],(r,[t])=>-t.evaluate(r)]]},"/":[En,[En,En],(r,[t,s])=>t.evaluate(r)/s.evaluate(r)],"%":[En,[En,En],(r,[t,s])=>t.evaluate(r)%s.evaluate(r)],ln2:[En,[],()=>Math.LN2],pi:[En,[],()=>Math.PI],e:[En,[],()=>Math.E],"^":[En,[En,En],(r,[t,s])=>Math.pow(t.evaluate(r),s.evaluate(r))],sqrt:[En,[En],(r,[t])=>Math.sqrt(t.evaluate(r))],log10:[En,[En],(r,[t])=>Math.log(t.evaluate(r))/Math.LN10],ln:[En,[En],(r,[t])=>Math.log(t.evaluate(r))],log2:[En,[En],(r,[t])=>Math.log(t.evaluate(r))/Math.LN2],sin:[En,[En],(r,[t])=>Math.sin(t.evaluate(r))],cos:[En,[En],(r,[t])=>Math.cos(t.evaluate(r))],tan:[En,[En],(r,[t])=>Math.tan(t.evaluate(r))],asin:[En,[En],(r,[t])=>Math.asin(t.evaluate(r))],acos:[En,[En],(r,[t])=>Math.acos(t.evaluate(r))],atan:[En,[En],(r,[t])=>Math.atan(t.evaluate(r))],min:[En,gs(En),(r,t)=>Math.min(...t.map(s=>s.evaluate(r)))],max:[En,gs(En),(r,t)=>Math.max(...t.map(s=>s.evaluate(r)))],abs:[En,[En],(r,[t])=>Math.abs(t.evaluate(r))],round:[En,[En],(r,[t])=>{const s=t.evaluate(r);return s<0?-Math.round(-s):Math.round(s)}],floor:[En,[En],(r,[t])=>Math.floor(t.evaluate(r))],ceil:[En,[En],(r,[t])=>Math.ceil(t.evaluate(r))],"filter-==":[Mi,[Oi,Ei],(r,[t,s])=>r.properties()[t.value]===s.value],"filter-id-==":[Mi,[Ei],(r,[t])=>r.id()===t.value],"filter-type-==":[Mi,[Oi],(r,[t])=>r.geometryType()===t.value],"filter-<":[Mi,[Oi,Ei],(r,[t,s])=>{const l=r.properties()[t.value],h=s.value;return typeof l==typeof h&&l<h}],"filter-id-<":[Mi,[Ei],(r,[t])=>{const s=r.id(),l=t.value;return typeof s==typeof l&&s<l}],"filter->":[Mi,[Oi,Ei],(r,[t,s])=>{const l=r.properties()[t.value],h=s.value;return typeof l==typeof h&&l>h}],"filter-id->":[Mi,[Ei],(r,[t])=>{const s=r.id(),l=t.value;return typeof s==typeof l&&s>l}],"filter-<=":[Mi,[Oi,Ei],(r,[t,s])=>{const l=r.properties()[t.value],h=s.value;return typeof l==typeof h&&l<=h}],"filter-id-<=":[Mi,[Ei],(r,[t])=>{const s=r.id(),l=t.value;return typeof s==typeof l&&s<=l}],"filter->=":[Mi,[Oi,Ei],(r,[t,s])=>{const l=r.properties()[t.value],h=s.value;return typeof l==typeof h&&l>=h}],"filter-id->=":[Mi,[Ei],(r,[t])=>{const s=r.id(),l=t.value;return typeof s==typeof l&&s>=l}],"filter-has":[Mi,[Ei],(r,[t])=>t.value in r.properties()],"filter-has-id":[Mi,[],r=>r.id()!==null&&r.id()!==void 0],"filter-type-in":[Mi,[Ce(Oi)],(r,[t])=>t.value.indexOf(r.geometryType())>=0],"filter-id-in":[Mi,[Ce(Ei)],(r,[t])=>t.value.indexOf(r.id())>=0],"filter-in-small":[Mi,[Oi,Ce(Ei)],(r,[t,s])=>s.value.indexOf(r.properties()[t.value])>=0],"filter-in-large":[Mi,[Oi,Ce(Ei)],(r,[t,s])=>function(l,h,g,v){for(;g<=v;){const S=g+v>>1;if(h[S]===l)return!0;h[S]>l?v=S-1:g=S+1}return!1}(r.properties()[t.value],s.value,0,s.value.length-1)],all:{type:Mi,overloads:[[[Mi,Mi],(r,[t,s])=>t.evaluate(r)&&s.evaluate(r)],[gs(Mi),(r,t)=>{for(const s of t)if(!s.evaluate(r))return!1;return!0}]]},any:{type:Mi,overloads:[[[Mi,Mi],(r,[t,s])=>t.evaluate(r)||s.evaluate(r)],[gs(Mi),(r,t)=>{for(const s of t)if(s.evaluate(r))return!0;return!1}]]},"!":[Mi,[Mi],(r,[t])=>!t.evaluate(r)],"is-supported-script":[Mi,[Oi],(r,[t])=>{const s=r.globals&&r.globals.isSupportedScript;return!s||s(t.evaluate(r))}],upcase:[Oi,[Oi],(r,[t])=>t.evaluate(r).toUpperCase()],downcase:[Oi,[Oi],(r,[t])=>t.evaluate(r).toLowerCase()],concat:[Oi,gs(Ei),(r,t)=>t.map(s=>ha(s.evaluate(r))).join("")],"resolved-locale":[Oi,[D],(r,[t])=>t.evaluate(r).resolvedLocale()]});var Qr=Eu;function xo(r){return{result:"success",value:r}}function Br(r){return{result:"error",value:r}}function _s(r){return r["property-type"]==="data-driven"}function ro(r){return!!r.expression&&r.expression.parameters.indexOf("zoom")>-1}function ya(r){return!!r.expression&&r.expression.interpolated}function Gi(r){return r instanceof Number?"number":r instanceof String?"string":r instanceof Boolean?"boolean":Array.isArray(r)?"array":r===null?"null":typeof r}function qo(r){return typeof r=="object"&&r!==null&&!Array.isArray(r)}function xa(r){return r}function wl(r,t){const s=t.type==="color",l=r.stops&&typeof r.stops[0][0]=="object",h=l||!(l||r.property!==void 0),g=r.type||(ya(t)?"exponential":"interval");if(s&&((r=Ri({},r)).stops&&(r.stops=r.stops.map(P=>[P[0],zt.parse(P[1])])),r.default=zt.parse(r.default?r.default:t.default)),r.colorSpace&&r.colorSpace!=="rgb"&&!yo[r.colorSpace])throw new Error(`Unknown color space: ${r.colorSpace}`);let v,S,A;if(g==="exponential")v=vo;else if(g==="interval")v=Zo;else if(g==="categorical"){v=Sl,S=Object.create(null);for(const P of r.stops)S[P[0]]=P[1];A=typeof r.stops[0][0]}else{if(g!=="identity")throw new Error(`Unknown function type "${g}"`);v=Ml}if(l){const P={},U=[];for(let $=0;$<r.stops.length;$++){const J=r.stops[$],re=J[0].zoom;P[re]===void 0&&(P[re]={zoom:re,type:r.type,property:r.property,default:r.default,stops:[]},U.push(re)),P[re].stops.push([J[0].value,J[1]])}const G=[];for(const $ of U)G.push([P[$].zoom,wl(P[$],t)]);const j={name:"linear"};return{kind:"composite",interpolationType:j,interpolationFactor:ps.interpolationFactor.bind(void 0,j),zoomStops:G.map($=>$[0]),evaluate:({zoom:$},J)=>vo({stops:G,base:r.base},t,$).evaluate($,J)}}if(h){const P=g==="exponential"?{name:"exponential",base:r.base!==void 0?r.base:1}:null;return{kind:"camera",interpolationType:P,interpolationFactor:ps.interpolationFactor.bind(void 0,P),zoomStops:r.stops.map(U=>U[0]),evaluate:({zoom:U})=>v(r,t,U,S,A)}}return{kind:"source",evaluate(P,U){const G=U&&U.properties?U.properties[r.property]:void 0;return G===void 0?na(r.default,t.default):v(r,t,G,S,A)}}}function na(r,t,s){return r!==void 0?r:t!==void 0?t:s!==void 0?s:void 0}function Sl(r,t,s,l,h){return na(typeof s===h?l[s]:void 0,r.default,t.default)}function Zo(r,t,s){if(Gi(s)!=="number")return na(r.default,t.default);const l=r.stops.length;if(l===1||s<=r.stops[0][0])return r.stops[0][1];if(s>=r.stops[l-1][0])return r.stops[l-1][1];const h=ga(r.stops.map(g=>g[0]),s);return r.stops[h][1]}function vo(r,t,s){const l=r.base!==void 0?r.base:1;if(Gi(s)!=="number")return na(r.default,t.default);const h=r.stops.length;if(h===1||s<=r.stops[0][0])return r.stops[0][1];if(s>=r.stops[h-1][0])return r.stops[h-1][1];const g=ga(r.stops.map(U=>U[0]),s),v=function(U,G,j,$){const J=$-j,re=U-j;return J===0?0:G===1?re/J:(Math.pow(G,re)-1)/(Math.pow(G,J)-1)}(s,l,r.stops[g][0],r.stops[g+1][0]),S=r.stops[g][1],A=r.stops[g+1][1];let P=Or[t.type]||xa;if(r.colorSpace&&r.colorSpace!=="rgb"){const U=yo[r.colorSpace];P=(G,j)=>U.reverse(U.interpolate(U.forward(G),U.forward(j),v))}return typeof S.evaluate=="function"?{evaluate(...U){const G=S.evaluate.apply(void 0,U),j=A.evaluate.apply(void 0,U);if(G!==void 0&&j!==void 0)return P(G,j,v)}}:P(S,A,v)}function Ml(r,t,s){return t.type==="color"?s=zt.parse(s):t.type==="formatted"?s=wi.fromString(s.toString()):t.type==="resolvedImage"?s=or.fromString(s.toString()):Gi(s)===t.type||t.type==="enum"&&t.values[s]||(s=void 0),na(s,r.default,t.default)}class ia{constructor(t,s){this.expression=t,this._warningHistory={},this._evaluator=new cc,this._defaultValue=s?function(l){return l.type==="color"&&(qo(l.default)||Array.isArray(l.default))?new zt(0,0,0,0):l.type==="color"?zt.parse(l.default)||null:l.default===void 0?null:l.default}(s):null,this._enumValues=s&&s.type==="enum"?s.values:null}evaluateWithoutErrorHandling(t,s,l,h,g,v,S,A){return this._evaluator.globals=t,this._evaluator.feature=s,this._evaluator.featureState=l,this._evaluator.canonical=h||null,this._evaluator.availableImages=g||null,this._evaluator.formattedSection=v,this._evaluator.featureTileCoord=S||null,this._evaluator.featureDistanceData=A||null,this.expression.evaluate(this._evaluator)}evaluate(t,s,l,h,g,v,S,A){this._evaluator.globals=t,this._evaluator.feature=s||null,this._evaluator.featureState=l||null,this._evaluator.canonical=h||null,this._evaluator.availableImages=g||null,this._evaluator.formattedSection=v||null,this._evaluator.featureTileCoord=S||null,this._evaluator.featureDistanceData=A||null;try{const P=this.expression.evaluate(this._evaluator);if(P==null||typeof P=="number"&&P!=P)return this._defaultValue;if(this._enumValues&&!(P in this._enumValues))throw new os(`Expected value to be one of ${Object.keys(this._enumValues).map(U=>JSON.stringify(U)).join(", ")}, but found ${JSON.stringify(P)} instead.`);return P}catch(P){return this._warningHistory[P.message]||(this._warningHistory[P.message]=!0,typeof console<"u"&&console.warn(P.message)),this._defaultValue}}}function Xo(r){return Array.isArray(r)&&r.length>0&&typeof r[0]=="string"&&r[0]in Qr}function ja(r,t){const s=new Bl(Qr,[],t?function(h){const g={color:Ys,string:Oi,number:En,enum:Oi,boolean:Mi,formatted:W,resolvedImage:ae};return h.type==="array"?Ce(g[h.value]||Ei,h.length):g[h.type]}(t):void 0),l=s.parse(r,void 0,void 0,void 0,t&&t.type==="string"?{typeAnnotation:"coerce"}:void 0);return l?xo(new ia(l,t)):Br(s.errors)}class Tu{constructor(t,s){this.kind=t,this._styleExpression=s,this.isStateDependent=t!=="constant"&&!go(s.expression)}evaluateWithoutErrorHandling(t,s,l,h,g,v){return this._styleExpression.evaluateWithoutErrorHandling(t,s,l,h,g,v)}evaluate(t,s,l,h,g,v){return this._styleExpression.evaluate(t,s,l,h,g,v)}}class pc{constructor(t,s,l,h){this.kind=t,this.zoomStops=l,this._styleExpression=s,this.isStateDependent=t!=="camera"&&!go(s.expression),this.interpolationType=h}evaluateWithoutErrorHandling(t,s,l,h,g,v){return this._styleExpression.evaluateWithoutErrorHandling(t,s,l,h,g,v)}evaluate(t,s,l,h,g,v){return this._styleExpression.evaluate(t,s,l,h,g,v)}interpolationFactor(t,s,l){return this.interpolationType?ps.interpolationFactor(this.interpolationType,t,s,l):0}}function mc(r,t){if((r=ja(r,t)).result==="error")return r;const s=r.value.expression,l=pa(s);if(!l&&!_s(t))return Br([new Ts("","data expressions not supported")]);const h=Po(s,["zoom","pitch","distance-from-center"]);if(!h&&!ro(t))return Br([new Ts("","zoom expressions not supported")]);const g=gc(s);return g||h?g instanceof Ts?Br([g]):g instanceof ps&&!ya(t)?Br([new Ts("",'"interpolate" expressions cannot be used with this property')]):xo(g?new pc(l?"camera":"composite",r.value,g.labels,g instanceof ps?g.interpolation:void 0):new Tu(l?"constant":"source",r.value)):Br([new Ts("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class Xc{constructor(t,s){this._parameters=t,this._specification=s,Ri(this,wl(this._parameters,this._specification))}static deserialize(t){return new Xc(t._parameters,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification}}}function gc(r){let t=null;if(r instanceof Va)t=gc(r.result);else if(r instanceof Ul){for(const s of r.args)if(t=gc(s),t)break}else(r instanceof Ba||r instanceof ps)&&r.input instanceof Io&&r.input.name==="zoom"&&(t=r);return t instanceof Ts||r.eachChild(s=>{const l=gc(s);l instanceof Ts?t=l:!t&&l?t=new Ts("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):t&&l&&t!==l&&(t=new Ts("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),t}class Dn{constructor(t,s,l,h){this.message=(t?`${t}: `:"")+l,h&&(this.identifier=h),s!=null&&s.__line__&&(this.line=s.__line__)}}function ra(r){const t=r.key,s=r.value,l=r.valueSpec||{},h=r.objectElementValidators||{},g=r.style,v=r.styleSpec;let S=[];const A=Gi(s);if(A!=="object")return[new Dn(t,s,`object expected, ${A} found`)];for(const P in s){const U=P.split(".")[0];let G;h[U]?G=h[U]:l[U]?G=js:h["*"]?G=h["*"]:l["*"]&&(G=js),G?S=S.concat(G({key:(t&&`${t}.`)+P,value:s[P],valueSpec:l[U]||l["*"],style:g,styleSpec:v,object:s,objectKey:P},s)):S.push(new Dn(t,s[P],`unknown property "${P}"`))}for(const P in l)h[P]||l[P].required&&l[P].default===void 0&&s[P]===void 0&&S.push(new Dn(t,s,`missing required property "${P}"`));return S}function Td(r){const t=r.value,s=r.valueSpec,l=r.style,h=r.styleSpec,g=r.key,v=r.arrayElementValidator||js;if(Gi(t)!=="array")return[new Dn(g,t,`array expected, ${Gi(t)} found`)];if(s.length&&t.length!==s.length)return[new Dn(g,t,`array length ${s.length} expected, length ${t.length} found`)];if(s["min-length"]&&t.length<s["min-length"])return[new Dn(g,t,`array length at least ${s["min-length"]} expected, length ${t.length} found`)];let S={type:s.value,values:s.values,minimum:s.minimum,maximum:s.maximum,function:void 0};h.$version<7&&(S.function=s.function),Gi(s.value)==="object"&&(S=s.value);let A=[];for(let P=0;P<t.length;P++)A=A.concat(v({array:t,arrayIndex:P,value:t[P],valueSpec:S,style:l,styleSpec:h,key:`${g}[${P}]`}));return A}function _c(r){const t=r.key,s=r.value,l=r.valueSpec;let h=Gi(s);if(h==="number"&&s!=s&&(h="NaN"),h!=="number")return[new Dn(t,s,`number expected, ${h} found`)];if("minimum"in l){let g=l.minimum;if(Gi(l.minimum)==="array"&&(g=l.minimum[r.arrayIndex]),s<g)return[new Dn(t,s,`${s} is less than the minimum value ${g}`)]}if("maximum"in l){let g=l.maximum;if(Gi(l.maximum)==="array"&&(g=l.maximum[r.arrayIndex]),s>g)return[new Dn(t,s,`${s} is greater than the maximum value ${g}`)]}return[]}function $c(r){const t=r.valueSpec,s=Ci(r.value.type);let l,h,g,v={};const S=s!=="categorical"&&r.value.property===void 0,A=!S,P=Gi(r.value.stops)==="array"&&Gi(r.value.stops[0])==="array"&&Gi(r.value.stops[0][0])==="object",U=ra({key:r.key,value:r.value,valueSpec:r.styleSpec.function,style:r.style,styleSpec:r.styleSpec,objectElementValidators:{stops:function($){if(s==="identity")return[new Dn($.key,$.value,'identity function may not have a "stops" property')];let J=[];const re=$.value;return J=J.concat(Td({key:$.key,value:re,valueSpec:$.valueSpec,style:$.style,styleSpec:$.styleSpec,arrayElementValidator:G})),Gi(re)==="array"&&re.length===0&&J.push(new Dn($.key,re,"array must have at least one stop")),J},default:function($){return js({key:$.key,value:$.value,valueSpec:t,style:$.style,styleSpec:$.styleSpec})}}});return s==="identity"&&S&&U.push(new Dn(r.key,r.value,'missing required property "property"')),s==="identity"||r.value.stops||U.push(new Dn(r.key,r.value,'missing required property "stops"')),s==="exponential"&&r.valueSpec.expression&&!ya(r.valueSpec)&&U.push(new Dn(r.key,r.value,"exponential functions not supported")),r.styleSpec.$version>=8&&(A&&!_s(r.valueSpec)?U.push(new Dn(r.key,r.value,"property functions not supported")):S&&!ro(r.valueSpec)&&U.push(new Dn(r.key,r.value,"zoom functions not supported"))),s!=="categorical"&&!P||r.value.property!==void 0||U.push(new Dn(r.key,r.value,'"property" property is required')),U;function G($){let J=[];const re=$.value,de=$.key;if(Gi(re)!=="array")return[new Dn(de,re,`array expected, ${Gi(re)} found`)];if(re.length!==2)return[new Dn(de,re,`array length 2 expected, length ${re.length} found`)];if(P){if(Gi(re[0])!=="object")return[new Dn(de,re,`object expected, ${Gi(re[0])} found`)];if(re[0].zoom===void 0)return[new Dn(de,re,"object stop key must have zoom")];if(re[0].value===void 0)return[new Dn(de,re,"object stop key must have value")];const we=Ci(re[0].zoom);if(typeof we!="number")return[new Dn(de,re[0].zoom,"stop zoom values must be numbers")];if(g&&g>we)return[new Dn(de,re[0].zoom,"stop zoom values must appear in ascending order")];we!==g&&(g=we,h=void 0,v={}),J=J.concat(ra({key:`${de}[0]`,value:re[0],valueSpec:{zoom:{}},style:$.style,styleSpec:$.styleSpec,objectElementValidators:{zoom:_c,value:j}}))}else J=J.concat(j({key:`${de}[0]`,value:re[0],valueSpec:{},style:$.style,styleSpec:$.styleSpec},re));return Xo(nr(re[1]))?J.concat([new Dn(`${de}[1]`,re[1],"expressions are not allowed in function stops.")]):J.concat(js({key:`${de}[1]`,value:re[1],valueSpec:t,style:$.style,styleSpec:$.styleSpec}))}function j($,J){const re=Gi($.value),de=Ci($.value),we=$.value!==null?$.value:J;if(l){if(re!==l)return[new Dn($.key,we,`${re} stop domain type must match previous stop domain type ${l}`)]}else l=re;if(re!=="number"&&re!=="string"&&re!=="boolean"&&typeof de!="number"&&typeof de!="string"&&typeof de!="boolean")return[new Dn($.key,we,"stop domain value must be a number, string, or boolean")];if(re!=="number"&&s!=="categorical"){let ze=`number expected, ${re} found`;return _s(t)&&s===void 0&&(ze+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Dn($.key,we,ze)]}return s!=="categorical"||re!=="number"||typeof de=="number"&&isFinite(de)&&Math.floor(de)===de?s!=="categorical"&&re==="number"&&typeof de=="number"&&typeof h=="number"&&h!==void 0&&de<h?[new Dn($.key,we,"stop domain values must appear in ascending order")]:(h=de,s==="categorical"&&de in v?[new Dn($.key,we,"stop domain values must be unique")]:(v[de]=!0,[])):[new Dn($.key,we,`integer expected, found ${String(de)}`)]}}function Is(r){const t=(r.expressionContext==="property"?mc:ja)(nr(r.value),r.valueSpec);if(t.result==="error")return t.value.map(l=>new Dn(`${r.key}${l.key}`,r.value,l.message));const s=t.value.expression||t.value._styleExpression.expression;if(r.expressionContext==="property"&&r.propertyKey==="text-font"&&!s.outputDefined())return[new Dn(r.key,r.value,`Invalid data expression for "${r.propertyKey}". Output values must be contained as literals within the expression.`)];if(r.expressionContext==="property"&&r.propertyType==="layout"&&!go(s))return[new Dn(r.key,r.value,'"feature-state" data expressions are not supported with layout properties.')];if(r.expressionContext==="filter")return yc(s,r);if(r.expressionContext&&r.expressionContext.indexOf("cluster")===0){if(!Po(s,["zoom","feature-state"]))return[new Dn(r.key,r.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(r.expressionContext==="cluster-initial"&&!pa(s))return[new Dn(r.key,r.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function yc(r,t){const s=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(t.valueSpec&&t.valueSpec.expression)for(const h of t.valueSpec.expression.parameters)s.delete(h);if(s.size===0)return[];const l=[];return r instanceof Io&&s.has(r.name)?[new Dn(t.key,t.value,`["${r.name}"] expression is not supported in a filter for a ${t.object.type} layer with id: ${t.object.id}`)]:(r.eachChild(h=>{l.push(...yc(h,t))}),l)}function Yc(r){const t=r.key,s=r.value,l=r.valueSpec,h=[];return Array.isArray(l.values)?l.values.indexOf(Ci(s))===-1&&h.push(new Dn(t,s,`expected one of [${l.values.join(", ")}], ${JSON.stringify(s)} found`)):Object.keys(l.values).indexOf(Ci(s))===-1&&h.push(new Dn(t,s,`expected one of [${Object.keys(l.values).join(", ")}], ${JSON.stringify(s)} found`)),h}function Au(r){if(r===!0||r===!1)return!0;if(!Array.isArray(r)||r.length===0)return!1;switch(r[0]){case"has":return r.length>=2&&r[1]!=="$id"&&r[1]!=="$type";case"in":return r.length>=3&&(typeof r[1]!="string"||Array.isArray(r[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return r.length!==3||Array.isArray(r[1])||Array.isArray(r[2]);case"any":case"all":for(const t of r.slice(1))if(!Au(t)&&typeof t!="boolean")return!1;return!0;default:return!0}}function Jc(r,t="fill"){if(r==null)return{filter:()=>!0,needGeometry:!1,needFeature:!1};Au(r)||(r=vc(r));const s=r;let l=!0;try{l=function(P){if(!xc(P))return P;let U=nr(P);return Cu(U),U=Kc(U),U}(s)}catch{console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.
This is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md
and paste the contents of this message in the report.
Thank you!
Filter Expression:
${JSON.stringify(s,null,2)}
        `)}const h=ct[`filter_${t}`],g=ja(l,h);let v=null;if(g.result==="error")throw new Error(g.value.map(P=>`${P.key}: ${P.message}`).join(", "));v=(P,U,G)=>g.value.evaluate(P,U,{},G);let S=null,A=null;if(l!==s){const P=ja(s,h);if(P.result==="error")throw new Error(P.value.map(U=>`${U.key}: ${U.message}`).join(", "));S=(U,G,j,$,J)=>P.value.evaluate(U,G,{},j,void 0,void 0,$,J),A=!pa(P.value.expression)}return{filter:v,dynamicFilter:S||void 0,needGeometry:Iu(l),needFeature:!!A}}function Kc(r){if(!Array.isArray(r))return r;const t=function(s){if(fh.has(s[0])){for(let l=1;l<s.length;l++)if(xc(s[l]))return!0}return s}(r);return t===!0?t:t.map(s=>Kc(s))}function Cu(r){let t=!1;const s=[];if(r[0]==="case"){for(let l=1;l<r.length-1;l+=2)t=t||xc(r[l]),s.push(r[l+1]);s.push(r[r.length-1])}else if(r[0]==="match"){t=t||xc(r[1]);for(let l=2;l<r.length-1;l+=2)s.push(r[l+1]);s.push(r[r.length-1])}else if(r[0]==="step"){t=t||xc(r[1]);for(let l=1;l<r.length-1;l+=2)s.push(r[l+1])}t&&(r.length=0,r.push("any",...s));for(let l=1;l<r.length;l++)Cu(r[l])}function xc(r){if(!Array.isArray(r))return!1;if((t=r[0])==="pitch"||t==="distance-from-center")return!0;var t;for(let s=1;s<r.length;s++)if(xc(r[s]))return!0;return!1}const fh=new Set(["in","==","!=",">",">=","<","<=","to-boolean"]);function ph(r,t){return r<t?-1:r>t?1:0}function Iu(r){if(!Array.isArray(r))return!1;if(r[0]==="within")return!0;for(let t=1;t<r.length;t++)if(Iu(r[t]))return!0;return!1}function vc(r){if(!r)return!0;const t=r[0];return r.length<=1?t!=="any":t==="=="?Pu(r[1],r[2],"=="):t==="!="?Qc(Pu(r[1],r[2],"==")):t==="<"||t===">"||t==="<="||t===">="?Pu(r[1],r[2],t):t==="any"?(s=r.slice(1),["any"].concat(s.map(vc))):t==="all"?["all"].concat(r.slice(1).map(vc)):t==="none"?["all"].concat(r.slice(1).map(vc).map(Qc)):t==="in"?Lu(r[1],r.slice(2)):t==="!in"?Qc(Lu(r[1],r.slice(2))):t==="has"?Ru(r[1]):t==="!has"?Qc(Ru(r[1])):t!=="within"||r;var s}function Pu(r,t,s){switch(r){case"$type":return[`filter-type-${s}`,t];case"$id":return[`filter-id-${s}`,t];default:return[`filter-${s}`,r,t]}}function Lu(r,t){if(t.length===0)return!1;switch(r){case"$type":return["filter-type-in",["literal",t]];case"$id":return["filter-id-in",["literal",t]];default:return t.length>200&&!t.some(s=>typeof s!=typeof t[0])?["filter-in-large",r,["literal",t.sort(ph)]]:["filter-in-small",r,["literal",t]]}}function Ru(r){switch(r){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",r]}}function Qc(r){return["!",r]}function bc(r){return Au(nr(r.value))?Is(Ri({},r,{expressionContext:"filter",valueSpec:r.styleSpec[`filter_${r.layerType||"fill"}`]})):Ro(r)}function Ro(r){const t=r.value,s=r.key;if(Gi(t)!=="array")return[new Dn(s,t,`array expected, ${Gi(t)} found`)];const l=r.styleSpec;let h,g=[];if(t.length<1)return[new Dn(s,t,"filter array must have at least 1 element")];switch(g=g.concat(Yc({key:`${s}[0]`,value:t[0],valueSpec:l.filter_operator,style:r.style,styleSpec:r.styleSpec})),Ci(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&Ci(t[1])==="$type"&&g.push(new Dn(s,t,`"$type" cannot be use with operator "${t[0]}"`));case"==":case"!=":t.length!==3&&g.push(new Dn(s,t,`filter array for operator "${t[0]}" must have 3 elements`));case"in":case"!in":t.length>=2&&(h=Gi(t[1]),h!=="string"&&g.push(new Dn(`${s}[1]`,t[1],`string expected, ${h} found`)));for(let v=2;v<t.length;v++)h=Gi(t[v]),Ci(t[1])==="$type"?g=g.concat(Yc({key:`${s}[${v}]`,value:t[v],valueSpec:l.geometry_type,style:r.style,styleSpec:r.styleSpec})):h!=="string"&&h!=="number"&&h!=="boolean"&&g.push(new Dn(`${s}[${v}]`,t[v],`string, number, or boolean expected, ${h} found`));break;case"any":case"all":case"none":for(let v=1;v<t.length;v++)g=g.concat(Ro({key:`${s}[${v}]`,value:t[v],style:r.style,styleSpec:r.styleSpec}));break;case"has":case"!has":h=Gi(t[1]),t.length!==2?g.push(new Dn(s,t,`filter array for "${t[0]}" operator must have 2 elements`)):h!=="string"&&g.push(new Dn(`${s}[1]`,t[1],`string expected, ${h} found`));break;case"within":h=Gi(t[1]),t.length!==2?g.push(new Dn(s,t,`filter array for "${t[0]}" operator must have 2 elements`)):h!=="object"&&g.push(new Dn(`${s}[1]`,t[1],`object expected, ${h} found`))}return g}function Du(r,t){const s=r.key,l=r.style,h=r.styleSpec,g=r.value,v=r.objectKey,S=h[`${t}_${r.layerType}`];if(!S)return[];const A=v.match(/^(.*)-transition$/);if(t==="paint"&&A&&S[A[1]]&&S[A[1]].transition)return js({key:s,value:g,valueSpec:h.transition,style:l,styleSpec:h});const P=r.valueSpec||S[v];if(!P)return[new Dn(s,g,`unknown property "${v}"`)];let U;if(Gi(g)==="string"&&_s(P)&&!P.tokens&&(U=/^{([^}]+)}$/.exec(g))){const j=`\`{ "type": "identity", "property": ${U?JSON.stringify(U[1]):'"_"'} }\``;return[new Dn(s,g,`"${v}" does not support interpolation syntax
Use an identity property function instead: ${j}.`)]}const G=[];return r.layerType==="symbol"&&(v==="text-field"&&l&&!l.glyphs&&G.push(new Dn(s,g,'use of "text-field" requires a style "glyphs" property')),v==="text-font"&&qo(nr(g))&&Ci(g.type)==="identity"&&G.push(new Dn(s,g,'"text-font" does not support identity functions'))),G.concat(js({key:r.key,value:g,valueSpec:P,style:l,styleSpec:h,expressionContext:"property",propertyType:t,propertyKey:v}))}function wc(r){return Du(r,"paint")}function Vl(r){return Du(r,"layout")}function eu(r){let t=[];const s=r.value,l=r.key,h=r.style,g=r.styleSpec;s.type||s.ref||t.push(new Dn(l,s,'either "type" or "ref" is required'));let v=Ci(s.type);const S=Ci(s.ref);if(s.id){const A=Ci(s.id);for(let P=0;P<r.arrayIndex;P++){const U=h.layers[P];Ci(U.id)===A&&t.push(new Dn(l,s.id,`duplicate layer id "${s.id}", previously used at line ${U.id.__line__}`))}}if("ref"in s){let A;["type","source","source-layer","filter","layout"].forEach(P=>{P in s&&t.push(new Dn(l,s[P],`"${P}" is prohibited for ref layers`))}),h.layers.forEach(P=>{Ci(P.id)===S&&(A=P)}),A?A.ref?t.push(new Dn(l,s.ref,"ref cannot reference another ref layer")):v=Ci(A.type):typeof S=="string"&&t.push(new Dn(l,s.ref,`ref layer "${S}" not found`))}else if(v!=="background"&&v!=="sky")if(s.source){const A=h.sources&&h.sources[s.source],P=A&&Ci(A.type);A?P==="vector"&&v==="raster"?t.push(new Dn(l,s.source,`layer "${s.id}" requires a raster source`)):P==="raster"&&v!=="raster"?t.push(new Dn(l,s.source,`layer "${s.id}" requires a vector source`)):P!=="vector"||s["source-layer"]?P==="raster-dem"&&v!=="hillshade"?t.push(new Dn(l,s.source,"raster-dem source can only be used with layer type 'hillshade'.")):v!=="line"||!s.paint||!s.paint["line-gradient"]&&!s.paint["line-trim-offset"]||P==="geojson"&&A.lineMetrics||t.push(new Dn(l,s,`layer "${s.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new Dn(l,s,`layer "${s.id}" must specify a "source-layer"`)):t.push(new Dn(l,s.source,`source "${s.source}" not found`))}else t.push(new Dn(l,s,'missing required property "source"'));return t=t.concat(ra({key:l,value:s,valueSpec:g.layer,style:r.style,styleSpec:r.styleSpec,objectElementValidators:{"*":()=>[],type:()=>js({key:`${l}.type`,value:s.type,valueSpec:g.layer.type,style:r.style,styleSpec:r.styleSpec,object:s,objectKey:"type"}),filter:A=>bc(Ri({layerType:v},A)),layout:A=>ra({layer:s,key:A.key,value:A.value,valueSpec:{},style:A.style,styleSpec:A.styleSpec,objectElementValidators:{"*":P=>Vl(Ri({layerType:v},P))}}),paint:A=>ra({layer:s,key:A.key,value:A.value,valueSpec:{},style:A.style,styleSpec:A.styleSpec,objectElementValidators:{"*":P=>wc(Ri({layerType:v},P))}})}})),t}function va(r){const t=r.value,s=r.key,l=Gi(t);return l!=="string"?[new Dn(s,t,`string expected, ${l} found`)]:[]}const mh={promoteId:function({key:r,value:t}){if(Gi(t)==="string")return va({key:r,value:t});{const s=[];for(const l in t)s.push(...va({key:`${r}.${l}`,value:t[l]}));return s}}};function Sc(r){const t=r.value,s=r.key,l=r.styleSpec,h=r.style;if(!t.type)return[new Dn(s,t,'"type" is required')];const g=Ci(t.type);let v;switch(g){case"vector":case"raster":case"raster-dem":return v=ra({key:s,value:t,valueSpec:l[`source_${g.replace("-","_")}`],style:r.style,styleSpec:l,objectElementValidators:mh}),v;case"geojson":if(v=ra({key:s,value:t,valueSpec:l.source_geojson,style:h,styleSpec:l,objectElementValidators:mh}),t.cluster)for(const S in t.clusterProperties){const[A,P]=t.clusterProperties[S],U=typeof A=="string"?[A,["accumulated"],["get",S]]:A;v.push(...Is({key:`${s}.${S}.map`,value:P,expressionContext:"cluster-map"})),v.push(...Is({key:`${s}.${S}.reduce`,value:U,expressionContext:"cluster-reduce"}))}return v;case"video":return ra({key:s,value:t,valueSpec:l.source_video,style:h,styleSpec:l});case"image":return ra({key:s,value:t,valueSpec:l.source_image,style:h,styleSpec:l});case"canvas":return[new Dn(s,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Yc({key:`${s}.type`,value:t.type,valueSpec:{values:so(l)},style:h,styleSpec:l})}}function so(r){return r.source.reduce((t,s)=>{const l=r[s];return l.type.type==="enum"&&(t=t.concat(Object.keys(l.type.values))),t},[])}function Ad(r){const t=r.value,s=r.styleSpec,l=s.light,h=r.style;let g=[];const v=Gi(t);if(t===void 0)return g;if(v!=="object")return g=g.concat([new Dn("light",t,`object expected, ${v} found`)]),g;for(const S in t){const A=S.match(/^(.*)-transition$/);g=g.concat(A&&l[A[1]]&&l[A[1]].transition?js({key:S,value:t[S],valueSpec:s.transition,style:h,styleSpec:s}):l[S]?js({key:S,value:t[S],valueSpec:l[S],style:h,styleSpec:s}):[new Dn(S,t[S],`unknown property "${S}"`)])}return g}function gh(r){const t=r.value,s=r.key,l=r.style,h=r.styleSpec,g=h.terrain;let v=[];const S=Gi(t);if(t===void 0)return v;if(S!=="object")return v=v.concat([new Dn("terrain",t,`object expected, ${S} found`)]),v;for(const A in t){const P=A.match(/^(.*)-transition$/);v=v.concat(P&&g[P[1]]&&g[P[1]].transition?js({key:A,value:t[A],valueSpec:h.transition,style:l,styleSpec:h}):g[A]?js({key:A,value:t[A],valueSpec:g[A],style:l,styleSpec:h}):[new Dn(A,t[A],`unknown property "${A}"`)])}if(t.source){const A=l.sources&&l.sources[t.source],P=A&&Ci(A.type);A?P!=="raster-dem"&&v.push(new Dn(s,t.source,`terrain cannot be used with a source of type ${String(P)}, it only be used with a "raster-dem" source type`)):v.push(new Dn(s,t.source,`source "${t.source}" not found`))}else v.push(new Dn(s,t,'terrain is missing required property "source"'));return v}function Do(r){const t=r.value,s=r.style,l=r.styleSpec,h=l.fog;let g=[];const v=Gi(t);if(t===void 0)return g;if(v!=="object")return g=g.concat([new Dn("fog",t,`object expected, ${v} found`)]),g;for(const S in t){const A=S.match(/^(.*)-transition$/);g=g.concat(A&&h[A[1]]&&h[A[1]].transition?js({key:S,value:t[S],valueSpec:l.transition,style:s,styleSpec:l}):h[S]?js({key:S,value:t[S],valueSpec:h[S],style:s,styleSpec:l}):[new Dn(S,t[S],`unknown property "${S}"`)])}return g}const oo={"*":()=>[],array:Td,boolean:function(r){const t=r.value,s=r.key,l=Gi(t);return l!=="boolean"?[new Dn(s,t,`boolean expected, ${l} found`)]:[]},number:_c,color:function(r){const t=r.key,s=r.value,l=Gi(s);return l!=="string"?[new Dn(t,s,`color expected, ${l} found`)]:Ln(s)===null?[new Dn(t,s,`color expected, "${s}" found`)]:[]},enum:Yc,filter:bc,function:$c,layer:eu,object:ra,source:Sc,light:Ad,terrain:gh,fog:Do,string:va,formatted:function(r){return va(r).length===0?[]:Is(r)},resolvedImage:function(r){return va(r).length===0?[]:Is(r)},projection:function(r){const t=r.value,s=r.styleSpec,l=s.projection,h=r.style;let g=[];const v=Gi(t);if(v==="object")for(const S in t)g=g.concat(js({key:S,value:t[S],valueSpec:l[S],style:h,styleSpec:s}));else v!=="string"&&(g=g.concat([new Dn("projection",t,`object or string expected, ${v} found`)]));return g}};function js(r){const t=r.value,s=r.valueSpec,l=r.styleSpec;return s.expression&&qo(Ci(t))?$c(r):s.expression&&Xo(nr(t))?Is(r):s.type&&oo[s.type]?oo[s.type](r):ra(Ri({},r,{valueSpec:s.type?l[s.type]:s}))}function Cd(r){const t=r.value,s=r.key,l=va(r);return l.length||(t.indexOf("{fontstack}")===-1&&l.push(new Dn(s,t,'"glyphs" url must include a "{fontstack}" token')),t.indexOf("{range}")===-1&&l.push(new Dn(s,t,'"glyphs" url must include a "{range}" token'))),l}function _h(r,t=ct){return zo(js({key:"",value:r,valueSpec:t.$root,styleSpec:t,style:r,objectElementValidators:{glyphs:Cd,"*":()=>[]}}))}const Id=r=>zo(wc(r)),Pd=r=>zo(Vl(r));function zo(r){return r.slice().sort((t,s)=>t.line&&s.line?t.line-s.line:0)}function yh(r,t){let s=!1;if(t&&t.length)for(const l of t)r.fire(new Ir(new Error(l.message))),s=!0;return s}var xh=ba,sa=3;function ba(r,t,s){var l=this.cells=[];if(r instanceof ArrayBuffer){this.arrayBuffer=r;var h=new Int32Array(this.arrayBuffer);r=h[0],this.d=(t=h[1])+2*(s=h[2]);for(var g=0;g<this.d*this.d;g++){var v=h[sa+g],S=h[sa+g+1];l.push(v===S?null:h.subarray(v,S))}var A=h[sa+l.length+1];this.keys=h.subarray(h[sa+l.length],A),this.bboxes=h.subarray(A),this.insert=this._insertReadonly}else{this.d=t+2*s;for(var P=0;P<this.d*this.d;P++)l.push([]);this.keys=[],this.bboxes=[]}this.n=t,this.extent=r,this.padding=s,this.scale=t/r,this.uid=0;var U=s/t*r;this.min=-U,this.max=r+U}ba.prototype.insert=function(r,t,s,l,h){this._forEachCell(t,s,l,h,this._insertCell,this.uid++),this.keys.push(r),this.bboxes.push(t),this.bboxes.push(s),this.bboxes.push(l),this.bboxes.push(h)},ba.prototype._insertReadonly=function(){throw"Cannot insert into a GridIndex created from an ArrayBuffer."},ba.prototype._insertCell=function(r,t,s,l,h,g){this.cells[h].push(g)},ba.prototype.query=function(r,t,s,l,h){var g=this.min,v=this.max;if(r<=g&&t<=g&&v<=s&&v<=l&&!h)return Array.prototype.slice.call(this.keys);var S=[];return this._forEachCell(r,t,s,l,this._queryCell,S,{},h),S},ba.prototype._queryCell=function(r,t,s,l,h,g,v,S){var A=this.cells[h];if(A!==null)for(var P=this.keys,U=this.bboxes,G=0;G<A.length;G++){var j=A[G];if(v[j]===void 0){var $=4*j;(S?S(U[$+0],U[$+1],U[$+2],U[$+3]):r<=U[$+2]&&t<=U[$+3]&&s>=U[$+0]&&l>=U[$+1])?(v[j]=!0,g.push(P[j])):v[j]=!1}}},ba.prototype._forEachCell=function(r,t,s,l,h,g,v,S){for(var A=this._convertToCellCoord(r),P=this._convertToCellCoord(t),U=this._convertToCellCoord(s),G=this._convertToCellCoord(l),j=A;j<=U;j++)for(var $=P;$<=G;$++){var J=this.d*$+j;if((!S||S(this._convertFromCellCoord(j),this._convertFromCellCoord($),this._convertFromCellCoord(j+1),this._convertFromCellCoord($+1)))&&h.call(this,r,t,s,l,J,g,v,S))return}},ba.prototype._convertFromCellCoord=function(r){return(r-this.padding)/this.scale},ba.prototype._convertToCellCoord=function(r){return Math.max(0,Math.min(this.d-1,Math.floor(r*this.scale)+this.padding))},ba.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var r=this.cells,t=sa+this.cells.length+1+1,s=0,l=0;l<this.cells.length;l++)s+=this.cells[l].length;var h=new Int32Array(t+s+this.keys.length+this.bboxes.length);h[0]=this.extent,h[1]=this.n,h[2]=this.padding;for(var g=t,v=0;v<r.length;v++){var S=r[v];h[sa+v]=g,h.set(S,g),g+=S.length}return h[sa+r.length]=g,h.set(this.keys,g),h[sa+r.length+1]=g+=this.keys.length,h.set(this.bboxes,g),g+=this.bboxes.length,h.buffer};var Wa=K(xh);const Gl={};function kn(r,t,s={}){Object.defineProperty(r,"_classRegistryKey",{value:t,writeable:!1}),Gl[t]={klass:r,omit:s.omit||[]}}kn(Object,"Object"),Wa.serialize=function(r,t){const s=r.toArrayBuffer();return t&&t.push(s),{buffer:s}},Wa.deserialize=function(r){return new Wa(r.buffer)},Object.defineProperty(Wa,"name",{value:"Grid"}),kn(Wa,"Grid"),kn(zt,"Color"),kn(Error,"Error"),kn(Tn,"AJAXError"),kn(or,"ResolvedImage"),kn(Xc,"StylePropertyFunction"),kn(ia,"StyleExpression",{omit:["_evaluator"]}),kn(pc,"ZoomDependentExpression"),kn(Tu,"ZoomConstantExpression"),kn(Io,"CompoundExpression",{omit:["_evaluate"]});for(const r in Qr)Gl[Qr[r]._classRegistryKey]||kn(Qr[r],`Expression${r}`);function tu(r){return r&&typeof ArrayBuffer<"u"&&(r instanceof ArrayBuffer||r.constructor&&r.constructor.name==="ArrayBuffer")}function zu(r){return w.ImageBitmap&&r instanceof w.ImageBitmap}function jl(r,t){if(r==null||typeof r=="boolean"||typeof r=="number"||typeof r=="string"||r instanceof Boolean||r instanceof Number||r instanceof String||r instanceof Date||r instanceof RegExp)return r;if(tu(r)||zu(r))return t&&t.push(r),r;if(ArrayBuffer.isView(r)){const s=r;return t&&t.push(s.buffer),s}if(r instanceof w.ImageData)return t&&t.push(r.data.buffer),r;if(Array.isArray(r)){const s=[];for(const l of r)s.push(jl(l,t));return s}if(typeof r=="object"){const s=r.constructor,l=s._classRegistryKey;if(!l)throw new Error(`can't serialize object of unregistered class ${l}`);const h=s.serialize?s.serialize(r,t):{};if(!s.serialize){for(const g in r)r.hasOwnProperty(g)&&(Gl[l].omit.indexOf(g)>=0||(h[g]=jl(r[g],t)));r instanceof Error&&(h.message=r.message)}if(h.$name)throw new Error("$name property is reserved for worker serialization logic.");return l!=="Object"&&(h.$name=l),h}throw new Error("can't serialize object of type "+typeof r)}function Ha(r){if(r==null||typeof r=="boolean"||typeof r=="number"||typeof r=="string"||r instanceof Boolean||r instanceof Number||r instanceof String||r instanceof Date||r instanceof RegExp||tu(r)||zu(r)||ArrayBuffer.isView(r)||r instanceof w.ImageData)return r;if(Array.isArray(r))return r.map(Ha);if(typeof r=="object"){const t=r.$name||"Object",{klass:s}=Gl[t];if(!s)throw new Error(`can't deserialize unregistered class ${t}`);if(s.deserialize)return s.deserialize(r);const l=Object.create(s.prototype);for(const h of Object.keys(r))h!=="$name"&&(l[h]=Ha(r[h]));return l}throw new Error("can't deserialize object of type "+typeof r)}const An={"Latin-1 Supplement":r=>r>=128&&r<=255,Arabic:r=>r>=1536&&r<=1791,"Arabic Supplement":r=>r>=1872&&r<=1919,"Arabic Extended-A":r=>r>=2208&&r<=2303,"Hangul Jamo":r=>r>=4352&&r<=4607,"Unified Canadian Aboriginal Syllabics":r=>r>=5120&&r<=5759,Khmer:r=>r>=6016&&r<=6143,"Unified Canadian Aboriginal Syllabics Extended":r=>r>=6320&&r<=6399,"General Punctuation":r=>r>=8192&&r<=8303,"Letterlike Symbols":r=>r>=8448&&r<=8527,"Number Forms":r=>r>=8528&&r<=8591,"Miscellaneous Technical":r=>r>=8960&&r<=9215,"Control Pictures":r=>r>=9216&&r<=9279,"Optical Character Recognition":r=>r>=9280&&r<=9311,"Enclosed Alphanumerics":r=>r>=9312&&r<=9471,"Geometric Shapes":r=>r>=9632&&r<=9727,"Miscellaneous Symbols":r=>r>=9728&&r<=9983,"Miscellaneous Symbols and Arrows":r=>r>=11008&&r<=11263,"CJK Radicals Supplement":r=>r>=11904&&r<=12031,"Kangxi Radicals":r=>r>=12032&&r<=12255,"Ideographic Description Characters":r=>r>=12272&&r<=12287,"CJK Symbols and Punctuation":r=>r>=12288&&r<=12351,Hiragana:r=>r>=12352&&r<=12447,Katakana:r=>r>=12448&&r<=12543,Bopomofo:r=>r>=12544&&r<=12591,"Hangul Compatibility Jamo":r=>r>=12592&&r<=12687,Kanbun:r=>r>=12688&&r<=12703,"Bopomofo Extended":r=>r>=12704&&r<=12735,"CJK Strokes":r=>r>=12736&&r<=12783,"Katakana Phonetic Extensions":r=>r>=12784&&r<=12799,"Enclosed CJK Letters and Months":r=>r>=12800&&r<=13055,"CJK Compatibility":r=>r>=13056&&r<=13311,"CJK Unified Ideographs Extension A":r=>r>=13312&&r<=19903,"Yijing Hexagram Symbols":r=>r>=19904&&r<=19967,"CJK Unified Ideographs":r=>r>=19968&&r<=40959,"Yi Syllables":r=>r>=40960&&r<=42127,"Yi Radicals":r=>r>=42128&&r<=42191,"Hangul Jamo Extended-A":r=>r>=43360&&r<=43391,"Hangul Syllables":r=>r>=44032&&r<=55215,"Hangul Jamo Extended-B":r=>r>=55216&&r<=55295,"Private Use Area":r=>r>=57344&&r<=63743,"CJK Compatibility Ideographs":r=>r>=63744&&r<=64255,"Arabic Presentation Forms-A":r=>r>=64336&&r<=65023,"Vertical Forms":r=>r>=65040&&r<=65055,"CJK Compatibility Forms":r=>r>=65072&&r<=65103,"Small Form Variants":r=>r>=65104&&r<=65135,"Arabic Presentation Forms-B":r=>r>=65136&&r<=65279,"Halfwidth and Fullwidth Forms":r=>r>=65280&&r<=65519};function nu(r){for(const t of r)if(vh(t.charCodeAt(0)))return!0;return!1}function Ld(r){for(const t of r)if(!qa(t.charCodeAt(0)))return!1;return!0}function qa(r){return!(An.Arabic(r)||An["Arabic Supplement"](r)||An["Arabic Extended-A"](r)||An["Arabic Presentation Forms-A"](r)||An["Arabic Presentation Forms-B"](r))}function vh(r){return!(r!==746&&r!==747&&(r<4352||!(An["Bopomofo Extended"](r)||An.Bopomofo(r)||An["CJK Compatibility Forms"](r)&&!(r>=65097&&r<=65103)||An["CJK Compatibility Ideographs"](r)||An["CJK Compatibility"](r)||An["CJK Radicals Supplement"](r)||An["CJK Strokes"](r)||!(!An["CJK Symbols and Punctuation"](r)||r>=12296&&r<=12305||r>=12308&&r<=12319||r===12336)||An["CJK Unified Ideographs Extension A"](r)||An["CJK Unified Ideographs"](r)||An["Enclosed CJK Letters and Months"](r)||An["Hangul Compatibility Jamo"](r)||An["Hangul Jamo Extended-A"](r)||An["Hangul Jamo Extended-B"](r)||An["Hangul Jamo"](r)||An["Hangul Syllables"](r)||An.Hiragana(r)||An["Ideographic Description Characters"](r)||An.Kanbun(r)||An["Kangxi Radicals"](r)||An["Katakana Phonetic Extensions"](r)||An.Katakana(r)&&r!==12540||!(!An["Halfwidth and Fullwidth Forms"](r)||r===65288||r===65289||r===65293||r>=65306&&r<=65310||r===65339||r===65341||r===65343||r>=65371&&r<=65503||r===65507||r>=65512&&r<=65519)||!(!An["Small Form Variants"](r)||r>=65112&&r<=65118||r>=65123&&r<=65126)||An["Unified Canadian Aboriginal Syllabics"](r)||An["Unified Canadian Aboriginal Syllabics Extended"](r)||An["Vertical Forms"](r)||An["Yijing Hexagram Symbols"](r)||An["Yi Syllables"](r)||An["Yi Radicals"](r))))}function Rd(r){return!(vh(r)||function(t){return!!(An["Latin-1 Supplement"](t)&&(t===167||t===169||t===174||t===177||t===188||t===189||t===190||t===215||t===247)||An["General Punctuation"](t)&&(t===8214||t===8224||t===8225||t===8240||t===8241||t===8251||t===8252||t===8258||t===8263||t===8264||t===8265||t===8273)||An["Letterlike Symbols"](t)||An["Number Forms"](t)||An["Miscellaneous Technical"](t)&&(t>=8960&&t<=8967||t>=8972&&t<=8991||t>=8996&&t<=9e3||t===9003||t>=9085&&t<=9114||t>=9150&&t<=9165||t===9167||t>=9169&&t<=9179||t>=9186&&t<=9215)||An["Control Pictures"](t)&&t!==9251||An["Optical Character Recognition"](t)||An["Enclosed Alphanumerics"](t)||An["Geometric Shapes"](t)||An["Miscellaneous Symbols"](t)&&!(t>=9754&&t<=9759)||An["Miscellaneous Symbols and Arrows"](t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||An["CJK Symbols and Punctuation"](t)||An.Katakana(t)||An["Private Use Area"](t)||An["CJK Compatibility Forms"](t)||An["Small Form Variants"](t)||An["Halfwidth and Fullwidth Forms"](t)||t===8734||t===8756||t===8757||t>=9984&&t<=10087||t>=10102&&t<=10131||t===65532||t===65533)}(r))}function iu(r){return r>=1424&&r<=2303||An["Arabic Presentation Forms-A"](r)||An["Arabic Presentation Forms-B"](r)}function Wl(r,t){return!(!t&&iu(r)||r>=2304&&r<=3583||r>=3840&&r<=4255||An.Khmer(r))}function cp(r){for(const t of r)if(iu(t.charCodeAt(0)))return!0;return!1}const Bn="deferred",Mc="loading",ru="loaded";let Hl=null,p="unavailable",o=null;const u=function(r){r&&typeof r=="string"&&r.indexOf("NetworkError")>-1&&(p="error"),Hl&&Hl(r)};function y(){b.fire(new Es("pluginStateChange",{pluginStatus:p,pluginURL:o}))}const b=new Zi,M=function(){return p},R=function(){if(p!==Bn||!o)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");p=Mc,y(),o&&bt({url:o},r=>{r?u(r):(p=ru,y())})},z={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>p===ru||z.applyArabicShaping!=null,isLoading:()=>p===Mc,setState(r){p=r.pluginStatus,o=r.pluginURL},isParsed:()=>z.applyArabicShaping!=null&&z.processBidirectionalText!=null&&z.processStyledBidirectionalText!=null,getPluginURL:()=>o};class V{constructor(t,s){this.zoom=t,s?(this.now=s.now,this.fadeDuration=s.fadeDuration,this.transition=s.transition,this.pitch=s.pitch):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0)}isSupportedScript(t){return function(s,l){for(const h of s)if(!Wl(h.charCodeAt(0),l))return!1;return!0}(t,z.isLoaded())}}class X{constructor(t,s){this.property=t,this.value=s,this.expression=function(l,h){if(qo(l))return new Xc(l,h);if(Xo(l)){const g=mc(l,h);if(g.result==="error")throw new Error(g.value.map(v=>`${v.key}: ${v.message}`).join(", "));return g.value}{let g=l;return typeof l=="string"&&h.type==="color"&&(g=zt.parse(l)),{kind:"constant",evaluate:()=>g}}}(s===void 0?t.specification.default:s,t.specification)}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(t,s,l){return this.property.possiblyEvaluate(this,t,s,l)}}class q{constructor(t){this.property=t,this.value=new X(t,void 0)}transitioned(t,s){return new he(this.property,this.value,s,Pt({},t.transition,this.transition),t.now)}untransitioned(){return new he(this.property,this.value,null,{},0)}}class Q{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitionablePropertyValues)}getValue(t){return Dt(this._values[t].value.value)}setValue(t,s){this._values.hasOwnProperty(t)||(this._values[t]=new q(this._values[t].property)),this._values[t].value=new X(this._values[t].property,s===null?void 0:Dt(s))}getTransition(t){return Dt(this._values[t].transition)}setTransition(t,s){this._values.hasOwnProperty(t)||(this._values[t]=new q(this._values[t].property)),this._values[t].transition=Dt(s)||void 0}serialize(){const t={};for(const s of Object.keys(this._values)){const l=this.getValue(s);l!==void 0&&(t[s]=l);const h=this.getTransition(s);h!==void 0&&(t[`${s}-transition`]=h)}return t}transitioned(t,s){const l=new me(this._properties);for(const h of Object.keys(this._values))l._values[h]=this._values[h].transitioned(t,s._values[h]);return l}untransitioned(){const t=new me(this._properties);for(const s of Object.keys(this._values))t._values[s]=this._values[s].untransitioned();return t}}class he{constructor(t,s,l,h,g){const v=h.delay||0,S=h.duration||0;g=g||0,this.property=t,this.value=s,this.begin=g+v,this.end=this.begin+S,t.specification.transition&&(h.delay||h.duration)&&(this.prior=l)}possiblyEvaluate(t,s,l){const h=t.now||0,g=this.value.possiblyEvaluate(t,s,l),v=this.prior;if(v){if(h>this.end)return this.prior=null,g;if(this.value.isDataDriven())return this.prior=null,g;if(h<this.begin)return v.possiblyEvaluate(t,s,l);{const S=(h-this.begin)/(this.end-this.begin);return this.property.interpolate(v.possiblyEvaluate(t,s,l),g,It(S))}}return g}}class me{constructor(t){this._properties=t,this._values=Object.create(t.defaultTransitioningPropertyValues)}possiblyEvaluate(t,s,l){const h=new be(this._properties);for(const g of Object.keys(this._values))h._values[g]=this._values[g].possiblyEvaluate(t,s,l);return h}hasTransition(){for(const t of Object.keys(this._values))if(this._values[t].prior)return!0;return!1}}class ge{constructor(t){this._properties=t,this._values=Object.create(t.defaultPropertyValues)}getValue(t){return Dt(this._values[t].value)}setValue(t,s){this._values[t]=new X(this._values[t].property,s===null?void 0:Dt(s))}serialize(){const t={};for(const s of Object.keys(this._values)){const l=this.getValue(s);l!==void 0&&(t[s]=l)}return t}possiblyEvaluate(t,s,l){const h=new be(this._properties);for(const g of Object.keys(this._values))h._values[g]=this._values[g].possiblyEvaluate(t,s,l);return h}}class _e{constructor(t,s,l){this.property=t,this.value=s,this.parameters=l}isConstant(){return this.value.kind==="constant"}constantOr(t){return this.value.kind==="constant"?this.value.value:t}evaluate(t,s,l,h){return this.property.evaluate(this.value,this.parameters,t,s,l,h)}}class be{constructor(t){this._properties=t,this._values=Object.create(t.defaultPossiblyEvaluatedValues)}get(t){return this._values[t]}}class ie{constructor(t){this.specification=t}possiblyEvaluate(t,s){return t.expression.evaluate(s)}interpolate(t,s,l){const h=Or[this.specification.type];return h?h(t,s,l):t}}class pe{constructor(t,s){this.specification=t,this.overrides=s}possiblyEvaluate(t,s,l,h){return new _e(this,t.expression.kind==="constant"||t.expression.kind==="camera"?{kind:"constant",value:t.expression.evaluate(s,null,{},l,h)}:t.expression,s)}interpolate(t,s,l){if(t.value.kind!=="constant"||s.value.kind!=="constant")return t;if(t.value.value===void 0||s.value.value===void 0)return new _e(this,{kind:"constant",value:void 0},t.parameters);const h=Or[this.specification.type];return h?new _e(this,{kind:"constant",value:h(t.value.value,s.value.value,l)},t.parameters):t}evaluate(t,s,l,h,g,v){return t.kind==="constant"?t.value:t.evaluate(s,l,h,g,v)}}class Ee{constructor(t){this.specification=t}possiblyEvaluate(t,s,l,h){return!!t.expression.evaluate(s,null,{},l,h)}interpolate(){return!1}}class Te{constructor(t){this.properties=t,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];const s=new V(0,{});for(const l in t){const h=t[l];h.specification.overridable&&this.overridableProperties.push(l);const g=this.defaultPropertyValues[l]=new X(h,void 0),v=this.defaultTransitionablePropertyValues[l]=new q(h);this.defaultTransitioningPropertyValues[l]=v.untransitioned(),this.defaultPossiblyEvaluatedValues[l]=g.possiblyEvaluate(s)}}}function Ue(r,t){return 256*(r=Fe(Math.floor(r),0,255))+Fe(Math.floor(t),0,255)}kn(pe,"DataDrivenProperty"),kn(ie,"DataConstantProperty"),kn(Ee,"ColorRampProperty");const Ge={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Ve{constructor(t,s){this._structArray=t,this._pos1=s*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class et{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(t,s){return t._trim(),s&&(t.isTransferred=!0,s.push(t.arrayBuffer)),{length:t.length,arrayBuffer:t.arrayBuffer}}static deserialize(t){const s=Object.create(this.prototype);return s.arrayBuffer=t.arrayBuffer,s.length=t.length,s.capacity=t.arrayBuffer.byteLength/s.bytesPerElement,s._refreshViews(),s}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(t){this.reserve(t),this.length=t}reserve(t){if(t>this.capacity){this.capacity=Math.max(t,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const s=this.uint8;this._refreshViews(),s&&this.uint8.set(s)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null}}function $e(r,t=1){let s=0,l=0;return{members:r.map(h=>{const g=Ge[h.type].BYTES_PER_ELEMENT,v=s=ht(s,Math.max(t,g)),S=h.components||1;return l=Math.max(l,g),s+=g*S,{name:h.name,type:h.type,components:S,offset:v}}),size:ht(s,Math.max(l,t)),alignment:t}}function ht(r,t){return Math.ceil(r/t)*t}class Jt extends et{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,s){const l=this.length;return this.resize(l+1),this.emplace(l,t,s)}emplace(t,s,l){const h=2*t;return this.int16[h+0]=s,this.int16[h+1]=l,t}}Jt.prototype.bytesPerElement=4,kn(Jt,"StructArrayLayout2i4");class ut extends et{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,s,l){const h=this.length;return this.resize(h+1),this.emplace(h,t,s,l)}emplace(t,s,l,h){const g=3*t;return this.int16[g+0]=s,this.int16[g+1]=l,this.int16[g+2]=h,t}}ut.prototype.bytesPerElement=6,kn(ut,"StructArrayLayout3i6");class Bt extends et{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,s,l,h){const g=this.length;return this.resize(g+1),this.emplace(g,t,s,l,h)}emplace(t,s,l,h,g){const v=4*t;return this.int16[v+0]=s,this.int16[v+1]=l,this.int16[v+2]=h,this.int16[v+3]=g,t}}Bt.prototype.bytesPerElement=8,kn(Bt,"StructArrayLayout4i8");class yt extends et{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,s,l,h,g,v,S){const A=this.length;return this.resize(A+1),this.emplace(A,t,s,l,h,g,v,S)}emplace(t,s,l,h,g,v,S,A){const P=6*t,U=12*t,G=3*t;return this.int16[P+0]=s,this.int16[P+1]=l,this.uint8[U+4]=h,this.uint8[U+5]=g,this.uint8[U+6]=v,this.uint8[U+7]=S,this.float32[G+2]=A,t}}yt.prototype.bytesPerElement=12,kn(yt,"StructArrayLayout2i4ub1f12");class Xt extends et{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,s,l,h){const g=this.length;return this.resize(g+1),this.emplace(g,t,s,l,h)}emplace(t,s,l,h,g){const v=4*t;return this.float32[v+0]=s,this.float32[v+1]=l,this.float32[v+2]=h,this.float32[v+3]=g,t}}Xt.prototype.bytesPerElement=16,kn(Xt,"StructArrayLayout4f16");class gt extends et{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,s,l,h,g){const v=this.length;return this.resize(v+1),this.emplace(v,t,s,l,h,g)}emplace(t,s,l,h,g,v){const S=6*t,A=3*t;return this.uint16[S+0]=s,this.uint16[S+1]=l,this.uint16[S+2]=h,this.uint16[S+3]=g,this.float32[A+2]=v,t}}gt.prototype.bytesPerElement=12,kn(gt,"StructArrayLayout4ui1f12");class Ot extends et{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,s,l,h){const g=this.length;return this.resize(g+1),this.emplace(g,t,s,l,h)}emplace(t,s,l,h,g){const v=4*t;return this.uint16[v+0]=s,this.uint16[v+1]=l,this.uint16[v+2]=h,this.uint16[v+3]=g,t}}Ot.prototype.bytesPerElement=8,kn(Ot,"StructArrayLayout4ui8");class Qt extends et{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,s,l,h,g,v){const S=this.length;return this.resize(S+1),this.emplace(S,t,s,l,h,g,v)}emplace(t,s,l,h,g,v,S){const A=6*t;return this.int16[A+0]=s,this.int16[A+1]=l,this.int16[A+2]=h,this.int16[A+3]=g,this.int16[A+4]=v,this.int16[A+5]=S,t}}Qt.prototype.bytesPerElement=12,kn(Qt,"StructArrayLayout6i12");class Lt extends et{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,s,l,h,g,v,S,A,P,U,G,j){const $=this.length;return this.resize($+1),this.emplace($,t,s,l,h,g,v,S,A,P,U,G,j)}emplace(t,s,l,h,g,v,S,A,P,U,G,j,$){const J=12*t;return this.int16[J+0]=s,this.int16[J+1]=l,this.int16[J+2]=h,this.int16[J+3]=g,this.uint16[J+4]=v,this.uint16[J+5]=S,this.uint16[J+6]=A,this.uint16[J+7]=P,this.int16[J+8]=U,this.int16[J+9]=G,this.int16[J+10]=j,this.int16[J+11]=$,t}}Lt.prototype.bytesPerElement=24,kn(Lt,"StructArrayLayout4i4ui4i24");class Ct extends et{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,s,l,h,g,v){const S=this.length;return this.resize(S+1),this.emplace(S,t,s,l,h,g,v)}emplace(t,s,l,h,g,v,S){const A=10*t,P=5*t;return this.int16[A+0]=s,this.int16[A+1]=l,this.int16[A+2]=h,this.float32[P+2]=g,this.float32[P+3]=v,this.float32[P+4]=S,t}}Ct.prototype.bytesPerElement=20,kn(Ct,"StructArrayLayout3i3f20");class zn extends et{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t){const s=this.length;return this.resize(s+1),this.emplace(s,t)}emplace(t,s){return this.uint32[1*t+0]=s,t}}zn.prototype.bytesPerElement=4,kn(zn,"StructArrayLayout1ul4");class qn extends et{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,s,l,h,g,v,S,A,P,U,G,j,$){const J=this.length;return this.resize(J+1),this.emplace(J,t,s,l,h,g,v,S,A,P,U,G,j,$)}emplace(t,s,l,h,g,v,S,A,P,U,G,j,$,J){const re=20*t,de=10*t;return this.int16[re+0]=s,this.int16[re+1]=l,this.int16[re+2]=h,this.int16[re+3]=g,this.int16[re+4]=v,this.float32[de+3]=S,this.float32[de+4]=A,this.float32[de+5]=P,this.float32[de+6]=U,this.int16[re+14]=G,this.uint32[de+8]=j,this.uint16[re+18]=$,this.uint16[re+19]=J,t}}qn.prototype.bytesPerElement=40,kn(qn,"StructArrayLayout5i4f1i1ul2ui40");class vn extends et{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,s,l,h,g,v,S){const A=this.length;return this.resize(A+1),this.emplace(A,t,s,l,h,g,v,S)}emplace(t,s,l,h,g,v,S,A){const P=8*t;return this.int16[P+0]=s,this.int16[P+1]=l,this.int16[P+2]=h,this.int16[P+4]=g,this.int16[P+5]=v,this.int16[P+6]=S,this.int16[P+7]=A,t}}vn.prototype.bytesPerElement=16,kn(vn,"StructArrayLayout3i2i2i16");class Vn extends et{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(t,s,l,h,g){const v=this.length;return this.resize(v+1),this.emplace(v,t,s,l,h,g)}emplace(t,s,l,h,g,v){const S=4*t,A=8*t;return this.float32[S+0]=s,this.float32[S+1]=l,this.float32[S+2]=h,this.int16[A+6]=g,this.int16[A+7]=v,t}}Vn.prototype.bytesPerElement=16,kn(Vn,"StructArrayLayout2f1f2i16");class Ai extends et{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,s,l,h){const g=this.length;return this.resize(g+1),this.emplace(g,t,s,l,h)}emplace(t,s,l,h,g){const v=12*t,S=3*t;return this.uint8[v+0]=s,this.uint8[v+1]=l,this.float32[S+1]=h,this.float32[S+2]=g,t}}Ai.prototype.bytesPerElement=12,kn(Ai,"StructArrayLayout2ub2f12");class si extends et{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,s,l){const h=this.length;return this.resize(h+1),this.emplace(h,t,s,l)}emplace(t,s,l,h){const g=3*t;return this.float32[g+0]=s,this.float32[g+1]=l,this.float32[g+2]=h,t}}si.prototype.bytesPerElement=12,kn(si,"StructArrayLayout3f12");class Gn extends et{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,s,l){const h=this.length;return this.resize(h+1),this.emplace(h,t,s,l)}emplace(t,s,l,h){const g=3*t;return this.uint16[g+0]=s,this.uint16[g+1]=l,this.uint16[g+2]=h,t}}Gn.prototype.bytesPerElement=6,kn(Gn,"StructArrayLayout3ui6");class $i extends et{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t,s,l,h,g,v,S,A,P,U,G,j,$,J,re,de,we,ze,Se,Le,Ne){const Be=this.length;return this.resize(Be+1),this.emplace(Be,t,s,l,h,g,v,S,A,P,U,G,j,$,J,re,de,we,ze,Se,Le,Ne)}emplace(t,s,l,h,g,v,S,A,P,U,G,j,$,J,re,de,we,ze,Se,Le,Ne,Be){const _t=30*t,dt=15*t,Ft=60*t;return this.int16[_t+0]=s,this.int16[_t+1]=l,this.int16[_t+2]=h,this.float32[dt+2]=g,this.float32[dt+3]=v,this.uint16[_t+8]=S,this.uint16[_t+9]=A,this.uint32[dt+5]=P,this.uint32[dt+6]=U,this.uint32[dt+7]=G,this.uint16[_t+16]=j,this.uint16[_t+17]=$,this.uint16[_t+18]=J,this.float32[dt+10]=re,this.float32[dt+11]=de,this.uint8[Ft+48]=we,this.uint8[Ft+49]=ze,this.uint8[Ft+50]=Se,this.uint32[dt+13]=Le,this.int16[_t+28]=Ne,this.uint8[Ft+58]=Be,t}}$i.prototype.bytesPerElement=60,kn($i,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class hr extends et{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(t,s,l,h,g,v,S,A,P,U,G,j,$,J,re,de,we,ze,Se,Le,Ne,Be,_t,dt,Ft,nn,vt,Wt,Ht,$t){const sn=this.length;return this.resize(sn+1),this.emplace(sn,t,s,l,h,g,v,S,A,P,U,G,j,$,J,re,de,we,ze,Se,Le,Ne,Be,_t,dt,Ft,nn,vt,Wt,Ht,$t)}emplace(t,s,l,h,g,v,S,A,P,U,G,j,$,J,re,de,we,ze,Se,Le,Ne,Be,_t,dt,Ft,nn,vt,Wt,Ht,$t,sn){const Rt=38*t,In=19*t;return this.int16[Rt+0]=s,this.int16[Rt+1]=l,this.int16[Rt+2]=h,this.float32[In+2]=g,this.float32[In+3]=v,this.int16[Rt+8]=S,this.int16[Rt+9]=A,this.int16[Rt+10]=P,this.int16[Rt+11]=U,this.int16[Rt+12]=G,this.int16[Rt+13]=j,this.uint16[Rt+14]=$,this.uint16[Rt+15]=J,this.uint16[Rt+16]=re,this.uint16[Rt+17]=de,this.uint16[Rt+18]=we,this.uint16[Rt+19]=ze,this.uint16[Rt+20]=Se,this.uint16[Rt+21]=Le,this.uint16[Rt+22]=Ne,this.uint16[Rt+23]=Be,this.uint16[Rt+24]=_t,this.uint16[Rt+25]=dt,this.uint16[Rt+26]=Ft,this.uint16[Rt+27]=nn,this.uint16[Rt+28]=vt,this.uint32[In+15]=Wt,this.float32[In+16]=Ht,this.float32[In+17]=$t,this.float32[In+18]=sn,t}}hr.prototype.bytesPerElement=76,kn(hr,"StructArrayLayout3i2f6i15ui1ul3f76");class mr extends et{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t){const s=this.length;return this.resize(s+1),this.emplace(s,t)}emplace(t,s){return this.float32[1*t+0]=s,t}}mr.prototype.bytesPerElement=4,kn(mr,"StructArrayLayout1f4");class ar extends et{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,s,l,h,g){const v=this.length;return this.resize(v+1),this.emplace(v,t,s,l,h,g)}emplace(t,s,l,h,g,v){const S=5*t;return this.float32[S+0]=s,this.float32[S+1]=l,this.float32[S+2]=h,this.float32[S+3]=g,this.float32[S+4]=v,t}}ar.prototype.bytesPerElement=20,kn(ar,"StructArrayLayout5f20");class xr extends et{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,s,l,h){const g=this.length;return this.resize(g+1),this.emplace(g,t,s,l,h)}emplace(t,s,l,h,g){const v=6*t;return this.uint32[3*t+0]=s,this.uint16[v+2]=l,this.uint16[v+3]=h,this.uint16[v+4]=g,t}}xr.prototype.bytesPerElement=12,kn(xr,"StructArrayLayout1ul3ui12");class us extends et{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t,s){const l=this.length;return this.resize(l+1),this.emplace(l,t,s)}emplace(t,s,l){const h=2*t;return this.uint16[h+0]=s,this.uint16[h+1]=l,t}}us.prototype.bytesPerElement=4,kn(us,"StructArrayLayout2ui4");class ko extends et{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(t){const s=this.length;return this.resize(s+1),this.emplace(s,t)}emplace(t,s){return this.uint16[1*t+0]=s,t}}ko.prototype.bytesPerElement=2,kn(ko,"StructArrayLayout1ui2");class bo extends et{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(t,s){const l=this.length;return this.resize(l+1),this.emplace(l,t,s)}emplace(t,s,l){const h=2*t;return this.float32[h+0]=s,this.float32[h+1]=l,t}}bo.prototype.bytesPerElement=8,kn(bo,"StructArrayLayout2f8");class vr extends Ve{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.int16[this._pos2+3]}get tileAnchorY(){return this._structArray.int16[this._pos2+4]}get x1(){return this._structArray.float32[this._pos4+3]}get y1(){return this._structArray.float32[this._pos4+4]}get x2(){return this._structArray.float32[this._pos4+5]}get y2(){return this._structArray.float32[this._pos4+6]}get padding(){return this._structArray.int16[this._pos2+14]}get featureIndex(){return this._structArray.uint32[this._pos4+8]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+18]}get bucketIndex(){return this._structArray.uint16[this._pos2+19]}}vr.prototype.size=40;class gr extends qn{get(t){return new vr(this,t)}}kn(gr,"CollisionBoxArray");class ji extends Ve{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+8]}get numGlyphs(){return this._structArray.uint16[this._pos2+9]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+5]}get lineStartIndex(){return this._structArray.uint32[this._pos4+6]}get lineLength(){return this._structArray.uint32[this._pos4+7]}get segment(){return this._structArray.uint16[this._pos2+16]}get lowerSize(){return this._structArray.uint16[this._pos2+17]}get upperSize(){return this._structArray.uint16[this._pos2+18]}get lineOffsetX(){return this._structArray.float32[this._pos4+10]}get lineOffsetY(){return this._structArray.float32[this._pos4+11]}get writingMode(){return this._structArray.uint8[this._pos1+48]}get placedOrientation(){return this._structArray.uint8[this._pos1+49]}set placedOrientation(t){this._structArray.uint8[this._pos1+49]=t}get hidden(){return this._structArray.uint8[this._pos1+50]}set hidden(t){this._structArray.uint8[this._pos1+50]=t}get crossTileID(){return this._structArray.uint32[this._pos4+13]}set crossTileID(t){this._structArray.uint32[this._pos4+13]=t}get associatedIconIndex(){return this._structArray.int16[this._pos2+28]}get flipState(){return this._structArray.uint8[this._pos1+58]}set flipState(t){this._structArray.uint8[this._pos1+58]=t}}ji.prototype.size=60;class Gr extends $i{get(t){return new ji(this,t)}}kn(Gr,"PlacedSymbolArray");class es extends Ve{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+11]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+13]}get key(){return this._structArray.uint16[this._pos2+14]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+17]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+19]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+21]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+22]}get featureIndex(){return this._structArray.uint16[this._pos2+23]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+25]}get numIconVertices(){return this._structArray.uint16[this._pos2+26]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+27]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+28]}get crossTileID(){return this._structArray.uint32[this._pos4+15]}set crossTileID(t){this._structArray.uint32[this._pos4+15]=t}get textOffset0(){return this._structArray.float32[this._pos4+16]}get textOffset1(){return this._structArray.float32[this._pos4+17]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+18]}}es.prototype.size=76;class yr extends hr{get(t){return new es(this,t)}}kn(yr,"SymbolInstanceArray");class Ps extends mr{getoffsetX(t){return this.float32[1*t+0]}}kn(Ps,"GlyphOffsetArray");class Ec extends Jt{getx(t){return this.int16[2*t+0]}gety(t){return this.int16[2*t+1]}}kn(Ec,"SymbolLineVertexArray");class Za extends Ve{get featureIndex(){return this._structArray.uint32[this._pos4+0]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+2]}get bucketIndex(){return this._structArray.uint16[this._pos2+3]}get layoutVertexArrayOffset(){return this._structArray.uint16[this._pos2+4]}}Za.prototype.size=12;class El extends xr{get(t){return new Za(this,t)}}kn(El,"FeatureIndexArray");class Xr extends us{geta_centroid_pos0(t){return this.uint16[2*t+0]}geta_centroid_pos1(t){return this.uint16[2*t+1]}}kn(Xr,"FillExtrusionCentroidArray");const wo=$e([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),Ls=$e([{name:"a_dash",components:4,type:"Uint16"}]);var ql={exports:{}},Rs={exports:{}};Rs.exports=function(r,t){var s,l,h,g,v,S,A,P;for(l=r.length-(s=3&r.length),h=t,v=3432918353,S=461845907,P=0;P<l;)A=255&r.charCodeAt(P)|(255&r.charCodeAt(++P))<<8|(255&r.charCodeAt(++P))<<16|(255&r.charCodeAt(++P))<<24,++P,h=27492+(65535&(g=5*(65535&(h=(h^=A=(65535&(A=(A=(65535&A)*v+(((A>>>16)*v&65535)<<16)&4294967295)<<15|A>>>17))*S+(((A>>>16)*S&65535)<<16)&4294967295)<<13|h>>>19))+((5*(h>>>16)&65535)<<16)&4294967295))+((58964+(g>>>16)&65535)<<16);switch(A=0,s){case 3:A^=(255&r.charCodeAt(P+2))<<16;case 2:A^=(255&r.charCodeAt(P+1))<<8;case 1:h^=A=(65535&(A=(A=(65535&(A^=255&r.charCodeAt(P)))*v+(((A>>>16)*v&65535)<<16)&4294967295)<<15|A>>>17))*S+(((A>>>16)*S&65535)<<16)&4294967295}return h^=r.length,h=2246822507*(65535&(h^=h>>>16))+((2246822507*(h>>>16)&65535)<<16)&4294967295,h=3266489909*(65535&(h^=h>>>13))+((3266489909*(h>>>16)&65535)<<16)&4294967295,(h^=h>>>16)>>>0};var ku=Rs.exports,Dd={exports:{}};Dd.exports=function(r,t){for(var s,l=r.length,h=t^l,g=0;l>=4;)s=1540483477*(65535&(s=255&r.charCodeAt(g)|(255&r.charCodeAt(++g))<<8|(255&r.charCodeAt(++g))<<16|(255&r.charCodeAt(++g))<<24))+((1540483477*(s>>>16)&65535)<<16),h=1540483477*(65535&h)+((1540483477*(h>>>16)&65535)<<16)^(s=1540483477*(65535&(s^=s>>>24))+((1540483477*(s>>>16)&65535)<<16)),l-=4,++g;switch(l){case 3:h^=(255&r.charCodeAt(g+2))<<16;case 2:h^=(255&r.charCodeAt(g+1))<<8;case 1:h=1540483477*(65535&(h^=255&r.charCodeAt(g)))+((1540483477*(h>>>16)&65535)<<16)}return h=1540483477*(65535&(h^=h>>>13))+((1540483477*(h>>>16)&65535)<<16),(h^=h>>>15)>>>0};var zd=ku,Q_=Dd.exports;ql.exports=zd,ql.exports.murmur3=zd,ql.exports.murmur2=Q_;var Tl=K(ql.exports);class bh{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(t,s,l,h){this.ids.push(up(t)),this.positions.push(s,l,h)}getPositions(t){const s=up(t);let l=0,h=this.ids.length-1;for(;l<h;){const v=l+h>>1;this.ids[v]>=s?h=v:l=v+1}const g=[];for(;this.ids[l]===s;)g.push({index:this.positions[3*l],start:this.positions[3*l+1],end:this.positions[3*l+2]}),l++;return g}static serialize(t,s){const l=new Float64Array(t.ids),h=new Uint32Array(t.positions);return wh(l,h,0,l.length-1),s&&s.push(l.buffer,h.buffer),{ids:l,positions:h}}static deserialize(t){const s=new bh;return s.ids=t.ids,s.positions=t.positions,s.indexed=!0,s}}function up(r){const t=+r;return!isNaN(t)&&Number.MIN_SAFE_INTEGER<=t&&t<=Number.MAX_SAFE_INTEGER?t:Tl(String(r))}function wh(r,t,s,l){for(;s<l;){const h=r[s+l>>1];let g=s-1,v=l+1;for(;;){do g++;while(r[g]<h);do v--;while(r[v]>h);if(g>=v)break;Al(r,g,v),Al(t,3*g,3*v),Al(t,3*g+1,3*v+1),Al(t,3*g+2,3*v+2)}v-s<l-v?(wh(r,t,s,v),s=v+1):(wh(r,t,v+1,l),l=v)}}function Al(r,t,s){const l=r[t];r[t]=r[s],r[s]=l}kn(bh,"FeaturePositionMap");class Cl{constructor(t){this.gl=t.gl,this.initialized=!1}fetchUniformLocation(t,s){return this.location||this.initialized||(this.location=this.gl.getUniformLocation(t,s),this.initialized=!0),!!this.location}}class Sh extends Cl{constructor(t){super(t),this.current=0}set(t,s,l){this.fetchUniformLocation(t,s)&&this.current!==l&&(this.current=l,this.gl.uniform1f(this.location,l))}}class kd extends Cl{constructor(t){super(t),this.current=[0,0,0,0]}set(t,s,l){this.fetchUniformLocation(t,s)&&(l[0]===this.current[0]&&l[1]===this.current[1]&&l[2]===this.current[2]&&l[3]===this.current[3]||(this.current=l,this.gl.uniform4f(this.location,l[0],l[1],l[2],l[3])))}}class Mh extends Cl{constructor(t){super(t),this.current=zt.transparent}set(t,s,l){this.fetchUniformLocation(t,s)&&(l.r===this.current.r&&l.g===this.current.g&&l.b===this.current.b&&l.a===this.current.a||(this.current=l,this.gl.uniform4f(this.location,l.r,l.g,l.b,l.a)))}}const ey=new Float32Array(16),ty=new Float32Array(9),Im=new Float32Array(4);function Od(r){return[Ue(255*r.r,255*r.g),Ue(255*r.b,255*r.a)]}class ol{constructor(t,s,l){this.value=t,this.uniformNames=s.map(h=>`u_${h}`),this.type=l}setUniform(t,s,l,h,g){s.set(t,g,h.constantOr(this.value))}getBinding(t,s){return this.type==="color"?new Mh(t):new Sh(t)}}class Ou{constructor(t,s){this.uniformNames=s.map(l=>`u_${l}`),this.pattern=null,this.pixelRatio=1}setConstantPatternPositions(t){this.pixelRatio=t.pixelRatio||1,this.pattern=t.tl.concat(t.br)}setUniform(t,s,l,h,g){const v=g==="u_pattern"||g==="u_dash"?this.pattern:g==="u_pixel_ratio"?this.pixelRatio:null;v&&s.set(t,g,v)}getBinding(t,s){return s==="u_pattern"||s==="u_dash"?new kd(t):new Sh(t)}}class $o{constructor(t,s,l,h){this.expression=t,this.type=l,this.maxValue=0,this.paintVertexAttributes=s.map(g=>({name:`a_${g}`,type:"Float32",components:l==="color"?2:1,offset:0})),this.paintVertexArray=new h}populatePaintArray(t,s,l,h,g,v){const S=this.paintVertexArray.length,A=this.expression.evaluate(new V(0),s,{},g,h,v);this.paintVertexArray.resize(t),this._setPaintValue(S,t,A)}updatePaintArray(t,s,l,h,g){const v=this.expression.evaluate({zoom:0},l,h,void 0,g);this._setPaintValue(t,s,v)}_setPaintValue(t,s,l){if(this.type==="color"){const h=Od(l);for(let g=t;g<s;g++)this.paintVertexArray.emplace(g,h[0],h[1])}else{for(let h=t;h<s;h++)this.paintVertexArray.emplace(h,l);this.maxValue=Math.max(this.maxValue,Math.abs(l))}}upload(t){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class Xa{constructor(t,s,l,h,g,v){this.expression=t,this.uniformNames=s.map(S=>`u_${S}_t`),this.type=l,this.useIntegerZoom=h,this.zoom=g,this.maxValue=0,this.paintVertexAttributes=s.map(S=>({name:`a_${S}`,type:"Float32",components:l==="color"?4:2,offset:0})),this.paintVertexArray=new v}populatePaintArray(t,s,l,h,g,v){const S=this.expression.evaluate(new V(this.zoom),s,{},g,h,v),A=this.expression.evaluate(new V(this.zoom+1),s,{},g,h,v),P=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValue(P,t,S,A)}updatePaintArray(t,s,l,h,g){const v=this.expression.evaluate({zoom:this.zoom},l,h,void 0,g),S=this.expression.evaluate({zoom:this.zoom+1},l,h,void 0,g);this._setPaintValue(t,s,v,S)}_setPaintValue(t,s,l,h){if(this.type==="color"){const g=Od(l),v=Od(h);for(let S=t;S<s;S++)this.paintVertexArray.emplace(S,g[0],g[1],v[0],v[1])}else{for(let g=t;g<s;g++)this.paintVertexArray.emplace(g,l,h);this.maxValue=Math.max(this.maxValue,Math.abs(l),Math.abs(h))}}upload(t){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer&&this.paintVertexBuffer.buffer?this.paintVertexBuffer.updateData(this.paintVertexArray):this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}setUniform(t,s,l,h,g){const v=this.useIntegerZoom?Math.floor(l.zoom):l.zoom,S=Fe(this.expression.interpolationFactor(v,this.zoom,this.zoom+1),0,1);s.set(t,g,S)}getBinding(t,s){return new Sh(t)}}class ys{constructor(t,s,l,h,g){this.expression=t,this.layerId=g,this.paintVertexAttributes=(l==="array"?Ls:wo).members;for(let v=0;v<s.length;++v);this.paintVertexArray=new h}populatePaintArray(t,s,l){const h=this.paintVertexArray.length;this.paintVertexArray.resize(t),this._setPaintValues(h,t,s.patterns&&s.patterns[this.layerId],l)}updatePaintArray(t,s,l,h,g,v){this._setPaintValues(t,s,l.patterns&&l.patterns[this.layerId],v)}_setPaintValues(t,s,l,h){if(!h||!l)return;const g=h[l];if(!g)return;const{tl:v,br:S,pixelRatio:A}=g;for(let P=t;P<s;P++)this.paintVertexArray.emplace(P,v[0],v[1],S[0],S[1],A)}upload(t){this.paintVertexArray&&this.paintVertexArray.arrayBuffer&&(this.paintVertexBuffer=t.createVertexBuffer(this.paintVertexArray,this.paintVertexAttributes,this.expression.isStateDependent))}destroy(){this.paintVertexBuffer&&this.paintVertexBuffer.destroy()}}class Tc{constructor(t,s,l=()=>!0){this.binders={},this._buffers=[];const h=[];for(const g in t.paint._values){if(!l(g))continue;const v=t.paint.get(g);if(!(v instanceof _e&&_s(v.property.specification)))continue;const S=iy(g,t.type),A=v.value,P=v.property.specification.type,U=!!v.property.useIntegerZoom,G=g==="line-dasharray"||g.endsWith("pattern"),j=g==="line-dasharray"&&t.layout.get("line-cap").value.kind!=="constant";if(A.kind!=="constant"||j)if(A.kind==="source"||j||G){const $=Rm(g,P,"source");this.binders[g]=G?new ys(A,S,P,$,t.id):new $o(A,S,P,$),h.push(`/a_${g}`)}else{const $=Rm(g,P,"composite");this.binders[g]=new Xa(A,S,P,U,s,$),h.push(`/z_${g}`)}else this.binders[g]=G?new Ou(A.value,S):new ol(A.value,S,P),h.push(`/u_${g}`)}this.cacheKey=h.sort().join("")}getMaxValue(t){const s=this.binders[t];return s instanceof $o||s instanceof Xa?s.maxValue:0}populatePaintArrays(t,s,l,h,g,v){for(const S in this.binders){const A=this.binders[S];(A instanceof $o||A instanceof Xa||A instanceof ys)&&A.populatePaintArray(t,s,l,h,g,v)}}setConstantPatternPositions(t){for(const s in this.binders){const l=this.binders[s];l instanceof Ou&&l.setConstantPatternPositions(t)}}updatePaintArrays(t,s,l,h,g,v){let S=!1;for(const A in t){const P=s.getPositions(A);for(const U of P){const G=l.feature(U.index);for(const j in this.binders){const $=this.binders[j];if(($ instanceof $o||$ instanceof Xa||$ instanceof ys)&&$.expression.isStateDependent===!0){const J=h.paint.get(j);$.expression=J.value,$.updatePaintArray(U.start,U.end,G,t[A],g,v),S=!0}}}}return S}defines(){const t=[];for(const s in this.binders){const l=this.binders[s];(l instanceof ol||l instanceof Ou)&&t.push(...l.uniformNames.map(h=>`#define HAS_UNIFORM_${h}`))}return t}getBinderAttributes(){const t=[];for(const s in this.binders){const l=this.binders[s];if(l instanceof $o||l instanceof Xa||l instanceof ys)for(let h=0;h<l.paintVertexAttributes.length;h++)t.push(l.paintVertexAttributes[h].name)}return t}getBinderUniforms(){const t=[];for(const s in this.binders){const l=this.binders[s];if(l instanceof ol||l instanceof Ou||l instanceof Xa)for(const h of l.uniformNames)t.push(h)}return t}getPaintVertexBuffers(){return this._buffers}getUniforms(t){const s=[];for(const l in this.binders){const h=this.binders[l];if(h instanceof ol||h instanceof Ou||h instanceof Xa)for(const g of h.uniformNames)s.push({name:g,property:l,binding:h.getBinding(t,g)})}return s}setUniforms(t,s,l,h,g){for(const{name:v,property:S,binding:A}of l)this.binders[S].setUniform(t,A,g,h.get(S),v)}updatePaintBuffers(){this._buffers=[];for(const t in this.binders){const s=this.binders[t];(s instanceof $o||s instanceof Xa||s instanceof ys)&&s.paintVertexBuffer&&this._buffers.push(s.paintVertexBuffer)}}upload(t){for(const s in this.binders){const l=this.binders[s];(l instanceof $o||l instanceof Xa||l instanceof ys)&&l.upload(t)}this.updatePaintBuffers()}destroy(){for(const t in this.binders){const s=this.binders[t];(s instanceof $o||s instanceof Xa||s instanceof ys)&&s.destroy()}}}class Ac{constructor(t,s,l=()=>!0){this.programConfigurations={};for(const h of t)this.programConfigurations[h.id]=new Tc(h,s,l);this.needsUpload=!1,this._featureMap=new bh,this._bufferOffset=0}populatePaintArrays(t,s,l,h,g,v,S){for(const A in this.programConfigurations)this.programConfigurations[A].populatePaintArrays(t,s,h,g,v,S);s.id!==void 0&&this._featureMap.add(s.id,l,this._bufferOffset,t),this._bufferOffset=t,this.needsUpload=!0}updatePaintArrays(t,s,l,h,g){for(const v of l)this.needsUpload=this.programConfigurations[v.id].updatePaintArrays(t,this._featureMap,s,v,h,g)||this.needsUpload}get(t){return this.programConfigurations[t]}upload(t){if(this.needsUpload){for(const s in this.programConfigurations)this.programConfigurations[s].upload(t);this.needsUpload=!1}}destroy(){for(const t in this.programConfigurations)this.programConfigurations[t].destroy()}}const ny={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern","pixel_ratio"],"fill-pattern":["pattern","pixel_ratio"],"fill-extrusion-pattern":["pattern","pixel_ratio"],"line-dasharray":["dash"]};function iy(r,t){return ny[r]||[r.replace(`${t}-`,"").replace(/-/g,"_")]}const Pm={"line-pattern":{source:gt,composite:gt},"fill-pattern":{source:gt,composite:gt},"fill-extrusion-pattern":{source:gt,composite:gt},"line-dasharray":{source:Ot,composite:Ot}},Lm={color:{source:bo,composite:Xt},number:{source:mr,composite:bo}};function Rm(r,t,s){const l=Pm[r];return l&&l[s]||Lm[t][s]}kn(ol,"ConstantBinder"),kn(Ou,"PatternConstantBinder"),kn($o,"SourceExpressionBinder"),kn(ys,"PatternCompositeBinder"),kn(Xa,"CompositeExpressionBinder"),kn(Tc,"ProgramConfiguration",{omit:["_buffers"]}),kn(Ac,"ProgramConfigurationSet");const wa="-transition";class Sa extends Zi{constructor(t,s){if(super(),this.id=t.id,this.type=t.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,t.type!=="custom"&&(this.metadata=t.metadata,this.minzoom=t.minzoom,this.maxzoom=t.maxzoom,t.type!=="background"&&t.type!=="sky"&&(this.source=t.source,this.sourceLayer=t["source-layer"],this.filter=t.filter),s.layout&&(this._unevaluatedLayout=new ge(s.layout)),s.paint)){this._transitionablePaint=new Q(s.paint);for(const l in t.paint)this.setPaintProperty(l,t.paint[l],{validate:!1});for(const l in t.layout)this.setLayoutProperty(l,t.layout[l],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new be(s.paint)}}getLayoutProperty(t){return t==="visibility"?this.visibility:this._unevaluatedLayout.getValue(t)}setLayoutProperty(t,s,l={}){s!=null&&this._validate(Pd,`layers.${this.id}.layout.${t}`,t,s,l)||(t!=="visibility"?this._unevaluatedLayout.setValue(t,s):this.visibility=s)}getPaintProperty(t){return jt(t,wa)?this._transitionablePaint.getTransition(t.slice(0,-11)):this._transitionablePaint.getValue(t)}setPaintProperty(t,s,l={}){if(s!=null&&this._validate(Id,`layers.${this.id}.paint.${t}`,t,s,l))return!1;if(jt(t,wa))return this._transitionablePaint.setTransition(t.slice(0,-11),s||void 0),!1;{const h=this._transitionablePaint._values[t],g=h.value.isDataDriven(),v=h.value;this._transitionablePaint.setValue(t,s),this._handleSpecialPaintPropertyUpdate(t);const S=this._transitionablePaint._values[t].value,A=S.isDataDriven(),P=jt(t,"pattern")||t==="line-dasharray";return A||g||P||this._handleOverridablePaintPropertyUpdate(t,v,S)}}_handleSpecialPaintPropertyUpdate(t){}getProgramIds(){return null}getProgramConfiguration(t){return null}_handleOverridablePaintPropertyUpdate(t,s,l){return!1}isHidden(t){return!!(this.minzoom&&t<this.minzoom)||!!(this.maxzoom&&t>=this.maxzoom)||this.visibility==="none"}updateTransitions(t){this._transitioningPaint=this._transitionablePaint.transitioned(t,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(t,s){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(t,void 0,s)),this.paint=this._transitioningPaint.possiblyEvaluate(t,void 0,s)}serialize(){const t={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(t.layout=t.layout||{},t.layout.visibility=this.visibility),qt(t,(s,l)=>!(s===void 0||l==="layout"&&!Object.keys(s).length||l==="paint"&&!Object.keys(s).length))}_validate(t,s,l,h,g={}){return(!g||g.validate!==!1)&&yh(this,t.call(_h,{key:s,layerType:this.type,objectKey:l,value:h,styleSpec:ct,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const t in this.paint._values){const s=this.paint.get(t);if(s instanceof _e&&_s(s.property.specification)&&(s.value.kind==="source"||s.value.kind==="composite")&&s.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=Jc(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const ry=$e([{name:"a_pos",components:2,type:"Int16"}],4),Cc=$e([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class jr{constructor(t=[]){this.segments=t}prepareSegment(t,s,l,h){let g=this.segments[this.segments.length-1];return t>jr.MAX_VERTEX_ARRAY_LENGTH&&wn(`Max vertices per segment is ${jr.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${t}`),(!g||g.vertexLength+t>jr.MAX_VERTEX_ARRAY_LENGTH||g.sortKey!==h)&&(g={vertexOffset:s.length,primitiveOffset:l.length,vertexLength:0,primitiveLength:0},h!==void 0&&(g.sortKey=h),this.segments.push(g)),g}get(){return this.segments}destroy(){for(const t of this.segments)for(const s in t.vaos)t.vaos[s].destroy()}static simpleSegment(t,s,l,h){return new jr([{vertexOffset:t,primitiveOffset:s,vertexLength:l,primitiveLength:h,vaos:{},sortKey:0}])}}jr.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,kn(jr,"SegmentVector");var Zn=8192;class al{constructor(t,s){t&&(s?this.setSouthWest(t).setNorthEast(s):t.length===4?this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]]):this.setSouthWest(t[0]).setNorthEast(t[1]))}setNorthEast(t){return this._ne=t instanceof Mr?new Mr(t.lng,t.lat):Mr.convert(t),this}setSouthWest(t){return this._sw=t instanceof Mr?new Mr(t.lng,t.lat):Mr.convert(t),this}extend(t){const s=this._sw,l=this._ne;let h,g;if(t instanceof Mr)h=t,g=t;else{if(!(t instanceof al))return Array.isArray(t)?t.length===4||t.every(Array.isArray)?this.extend(al.convert(t)):this.extend(Mr.convert(t)):typeof t=="object"&&t!==null&&t.hasOwnProperty("lat")&&(t.hasOwnProperty("lon")||t.hasOwnProperty("lng"))?this.extend(Mr.convert(t)):this;if(h=t._sw,g=t._ne,!h||!g)return this}return s||l?(s.lng=Math.min(h.lng,s.lng),s.lat=Math.min(h.lat,s.lat),l.lng=Math.max(g.lng,l.lng),l.lat=Math.max(g.lat,l.lat)):(this._sw=new Mr(h.lng,h.lat),this._ne=new Mr(g.lng,g.lat)),this}getCenter(){return new Mr((this._sw.lng+this._ne.lng)/2,(this._sw.lat+this._ne.lat)/2)}getSouthWest(){return this._sw}getNorthEast(){return this._ne}getNorthWest(){return new Mr(this.getWest(),this.getNorth())}getSouthEast(){return new Mr(this.getEast(),this.getSouth())}getWest(){return this._sw.lng}getSouth(){return this._sw.lat}getEast(){return this._ne.lng}getNorth(){return this._ne.lat}toArray(){return[this._sw.toArray(),this._ne.toArray()]}toString(){return`LngLatBounds(${this._sw.toString()}, ${this._ne.toString()})`}isEmpty(){return!(this._sw&&this._ne)}contains(t){const{lng:s,lat:l}=Mr.convert(t);let h=this._sw.lng<=s&&s<=this._ne.lng;return this._sw.lng>this._ne.lng&&(h=this._sw.lng>=s&&s>=this._ne.lng),this._sw.lat<=l&&l<=this._ne.lat&&h}static convert(t){return!t||t instanceof al?t:new al(t)}}var Fu=1e-6,Oo=typeof Float32Array<"u"?Float32Array:Array;function Dm(){var r=new Oo(9);return Oo!=Float32Array&&(r[1]=0,r[2]=0,r[3]=0,r[5]=0,r[6]=0,r[7]=0),r[0]=1,r[4]=1,r[8]=1,r}function hp(r,t,s){var l=t[0],h=t[1],g=t[2],v=t[3],S=t[4],A=t[5],P=t[6],U=t[7],G=t[8],j=s[0],$=s[1],J=s[2],re=s[3],de=s[4],we=s[5],ze=s[6],Se=s[7],Le=s[8];return r[0]=j*l+$*v+J*P,r[1]=j*h+$*S+J*U,r[2]=j*g+$*A+J*G,r[3]=re*l+de*v+we*P,r[4]=re*h+de*S+we*U,r[5]=re*g+de*A+we*G,r[6]=ze*l+Se*v+Le*P,r[7]=ze*h+Se*S+Le*U,r[8]=ze*g+Se*A+Le*G,r}function $a(r){return r[0]=1,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=1,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=1,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r}function Fd(r,t){var s=t[0],l=t[1],h=t[2],g=t[3],v=t[4],S=t[5],A=t[6],P=t[7],U=t[8],G=t[9],j=t[10],$=t[11],J=t[12],re=t[13],de=t[14],we=t[15],ze=s*S-l*v,Se=s*A-h*v,Le=s*P-g*v,Ne=l*A-h*S,Be=l*P-g*S,_t=h*P-g*A,dt=U*re-G*J,Ft=U*de-j*J,nn=U*we-$*J,vt=G*de-j*re,Wt=G*we-$*re,Ht=j*we-$*de,$t=ze*Ht-Se*Wt+Le*vt+Ne*nn-Be*Ft+_t*dt;return $t?(r[0]=(S*Ht-A*Wt+P*vt)*($t=1/$t),r[1]=(h*Wt-l*Ht-g*vt)*$t,r[2]=(re*_t-de*Be+we*Ne)*$t,r[3]=(j*Be-G*_t-$*Ne)*$t,r[4]=(A*nn-v*Ht-P*Ft)*$t,r[5]=(s*Ht-h*nn+g*Ft)*$t,r[6]=(de*Le-J*_t-we*Se)*$t,r[7]=(U*_t-j*Le+$*Se)*$t,r[8]=(v*Wt-S*nn+P*dt)*$t,r[9]=(l*nn-s*Wt-g*dt)*$t,r[10]=(J*Be-re*Le+we*ze)*$t,r[11]=(G*Le-U*Be-$*ze)*$t,r[12]=(S*Ft-v*vt-A*dt)*$t,r[13]=(s*vt-l*Ft+h*dt)*$t,r[14]=(re*Se-J*Ne-de*ze)*$t,r[15]=(U*Ne-G*Se+j*ze)*$t,r):null}function Ic(r,t,s){var l=t[0],h=t[1],g=t[2],v=t[3],S=t[4],A=t[5],P=t[6],U=t[7],G=t[8],j=t[9],$=t[10],J=t[11],re=t[12],de=t[13],we=t[14],ze=t[15],Se=s[0],Le=s[1],Ne=s[2],Be=s[3];return r[0]=Se*l+Le*S+Ne*G+Be*re,r[1]=Se*h+Le*A+Ne*j+Be*de,r[2]=Se*g+Le*P+Ne*$+Be*we,r[3]=Se*v+Le*U+Ne*J+Be*ze,r[4]=(Se=s[4])*l+(Le=s[5])*S+(Ne=s[6])*G+(Be=s[7])*re,r[5]=Se*h+Le*A+Ne*j+Be*de,r[6]=Se*g+Le*P+Ne*$+Be*we,r[7]=Se*v+Le*U+Ne*J+Be*ze,r[8]=(Se=s[8])*l+(Le=s[9])*S+(Ne=s[10])*G+(Be=s[11])*re,r[9]=Se*h+Le*A+Ne*j+Be*de,r[10]=Se*g+Le*P+Ne*$+Be*we,r[11]=Se*v+Le*U+Ne*J+Be*ze,r[12]=(Se=s[12])*l+(Le=s[13])*S+(Ne=s[14])*G+(Be=s[15])*re,r[13]=Se*h+Le*A+Ne*j+Be*de,r[14]=Se*g+Le*P+Ne*$+Be*we,r[15]=Se*v+Le*U+Ne*J+Be*ze,r}function su(r,t,s){var l,h,g,v,S,A,P,U,G,j,$,J,re=s[0],de=s[1],we=s[2];return t===r?(r[12]=t[0]*re+t[4]*de+t[8]*we+t[12],r[13]=t[1]*re+t[5]*de+t[9]*we+t[13],r[14]=t[2]*re+t[6]*de+t[10]*we+t[14],r[15]=t[3]*re+t[7]*de+t[11]*we+t[15]):(h=t[1],g=t[2],v=t[3],S=t[4],A=t[5],P=t[6],U=t[7],G=t[8],j=t[9],$=t[10],J=t[11],r[0]=l=t[0],r[1]=h,r[2]=g,r[3]=v,r[4]=S,r[5]=A,r[6]=P,r[7]=U,r[8]=G,r[9]=j,r[10]=$,r[11]=J,r[12]=l*re+S*de+G*we+t[12],r[13]=h*re+A*de+j*we+t[13],r[14]=g*re+P*de+$*we+t[14],r[15]=v*re+U*de+J*we+t[15]),r}function ou(r,t,s){var l=s[0],h=s[1],g=s[2];return r[0]=t[0]*l,r[1]=t[1]*l,r[2]=t[2]*l,r[3]=t[3]*l,r[4]=t[4]*h,r[5]=t[5]*h,r[6]=t[6]*h,r[7]=t[7]*h,r[8]=t[8]*g,r[9]=t[9]*g,r[10]=t[10]*g,r[11]=t[11]*g,r[12]=t[12],r[13]=t[13],r[14]=t[14],r[15]=t[15],r}function dp(r,t,s){var l=Math.sin(s),h=Math.cos(s),g=t[4],v=t[5],S=t[6],A=t[7],P=t[8],U=t[9],G=t[10],j=t[11];return t!==r&&(r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[3],r[12]=t[12],r[13]=t[13],r[14]=t[14],r[15]=t[15]),r[4]=g*h+P*l,r[5]=v*h+U*l,r[6]=S*h+G*l,r[7]=A*h+j*l,r[8]=P*h-g*l,r[9]=U*h-v*l,r[10]=G*h-S*l,r[11]=j*h-A*l,r}function _(r,t,s){var l=Math.sin(s),h=Math.cos(s),g=t[0],v=t[1],S=t[2],A=t[3],P=t[8],U=t[9],G=t[10],j=t[11];return t!==r&&(r[4]=t[4],r[5]=t[5],r[6]=t[6],r[7]=t[7],r[12]=t[12],r[13]=t[13],r[14]=t[14],r[15]=t[15]),r[0]=g*h-P*l,r[1]=v*h-U*l,r[2]=S*h-G*l,r[3]=A*h-j*l,r[8]=g*l+P*h,r[9]=v*l+U*h,r[10]=S*l+G*h,r[11]=A*l+j*h,r}function x(r,t){return r[0]=t[0],r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=t[1],r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=t[2],r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r}function L(r,t,s){var l,h,g,v=s[0],S=s[1],A=s[2],P=Math.hypot(v,S,A);return P<Fu?null:(v*=P=1/P,S*=P,A*=P,l=Math.sin(t),h=Math.cos(t),r[0]=v*v*(g=1-h)+h,r[1]=S*v*g+A*l,r[2]=A*v*g-S*l,r[3]=0,r[4]=v*S*g-A*l,r[5]=S*S*g+h,r[6]=A*S*g+v*l,r[7]=0,r[8]=v*A*g+S*l,r[9]=S*A*g-v*l,r[10]=A*A*g+h,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r)}Math.hypot||(Math.hypot=function(){for(var r=0,t=arguments.length;t--;)r+=arguments[t]*arguments[t];return Math.sqrt(r)});var N=Ic;function Z(){var r=new Oo(3);return Oo!=Float32Array&&(r[0]=0,r[1]=0,r[2]=0),r}function ee(r){var t=new Oo(3);return t[0]=r[0],t[1]=r[1],t[2]=r[2],t}function Pe(r){return Math.hypot(r[0],r[1],r[2])}function at(r,t,s){var l=new Oo(3);return l[0]=r,l[1]=t,l[2]=s,l}function Ut(r,t,s){return r[0]=t[0]+s[0],r[1]=t[1]+s[1],r[2]=t[2]+s[2],r}function Cn(r,t,s){return r[0]=t[0]-s[0],r[1]=t[1]-s[1],r[2]=t[2]-s[2],r}function Qn(r,t,s){return r[0]=t[0]*s[0],r[1]=t[1]*s[1],r[2]=t[2]*s[2],r}function Fi(r,t,s){return r[0]=Math.min(t[0],s[0]),r[1]=Math.min(t[1],s[1]),r[2]=Math.min(t[2],s[2]),r}function _i(r,t,s){return r[0]=Math.max(t[0],s[0]),r[1]=Math.max(t[1],s[1]),r[2]=Math.max(t[2],s[2]),r}function Ki(r,t,s){return r[0]=t[0]*s,r[1]=t[1]*s,r[2]=t[2]*s,r}function fi(r,t,s,l){return r[0]=t[0]+s[0]*l,r[1]=t[1]+s[1]*l,r[2]=t[2]+s[2]*l,r}function br(r,t){var s=t[0],l=t[1],h=t[2],g=s*s+l*l+h*h;return g>0&&(g=1/Math.sqrt(g)),r[0]=t[0]*g,r[1]=t[1]*g,r[2]=t[2]*g,r}function ns(r,t){return r[0]*t[0]+r[1]*t[1]+r[2]*t[2]}function wt(r,t,s){var l=t[0],h=t[1],g=t[2],v=s[0],S=s[1],A=s[2];return r[0]=h*A-g*S,r[1]=g*v-l*A,r[2]=l*S-h*v,r}function Ke(r,t,s){var l=t[0],h=t[1],g=t[2],v=s[3]*l+s[7]*h+s[11]*g+s[15];return r[0]=(s[0]*l+s[4]*h+s[8]*g+s[12])/(v=v||1),r[1]=(s[1]*l+s[5]*h+s[9]*g+s[13])/v,r[2]=(s[2]*l+s[6]*h+s[10]*g+s[14])/v,r}function Vt(r,t,s){var l=s[0],h=s[1],g=s[2],v=t[0],S=t[1],A=t[2],P=h*A-g*S,U=g*v-l*A,G=l*S-h*v,j=h*G-g*U,$=g*P-l*G,J=l*U-h*P,re=2*s[3];return U*=re,G*=re,$*=2,J*=2,r[0]=v+(P*=re)+(j*=2),r[1]=S+U+$,r[2]=A+G+J,r}var Un,Jn=Cn,Yi=Qn,Hi=Pe;function _r(r,t,s){return r[0]=t[0]*s,r[1]=t[1]*s,r[2]=t[2]*s,r[3]=t[3]*s,r}function Ws(r,t){var s=t[0],l=t[1],h=t[2],g=t[3],v=s*s+l*l+h*h+g*g;return v>0&&(v=1/Math.sqrt(v)),r[0]=s*v,r[1]=l*v,r[2]=h*v,r[3]=g*v,r}function rr(r,t,s){var l=t[0],h=t[1],g=t[2],v=t[3];return r[0]=s[0]*l+s[4]*h+s[8]*g+s[12]*v,r[1]=s[1]*l+s[5]*h+s[9]*g+s[13]*v,r[2]=s[2]*l+s[6]*h+s[10]*g+s[14]*v,r[3]=s[3]*l+s[7]*h+s[11]*g+s[15]*v,r}function Zl(){var r=new Oo(4);return Oo!=Float32Array&&(r[0]=0,r[1]=0,r[2]=0),r[3]=1,r}function zm(r){return r[0]=0,r[1]=0,r[2]=0,r[3]=1,r}function e1(r,t,s){s*=.5;var l=t[0],h=t[1],g=t[2],v=t[3],S=Math.sin(s),A=Math.cos(s);return r[0]=l*A+v*S,r[1]=h*A+g*S,r[2]=g*A-h*S,r[3]=v*A-l*S,r}function t1(r,t,s){s*=.5;var l=t[0],h=t[1],g=t[2],v=t[3],S=Math.sin(s),A=Math.cos(s);return r[0]=l*A-g*S,r[1]=h*A+v*S,r[2]=g*A+l*S,r[3]=v*A-h*S,r}Z(),Un=new Oo(4),Oo!=Float32Array&&(Un[0]=0,Un[1]=0,Un[2]=0,Un[3]=0);var Y2=Ws;Z(),at(1,0,0),at(0,1,0),Zl(),Zl(),Dm();const J2=$e([{type:"Float32",name:"a_globe_pos",components:3},{type:"Float32",name:"a_uv",components:2}]),{members:n1}=J2,i1=$e([{name:"a_pos_3",components:3,type:"Int16"}]);var fp=$e([{name:"a_pos",type:"Int16",components:2}]);class sy{constructor(t,s){this.pos=t,this.dir=s}intersectsPlane(t,s,l){const h=ns(s,this.dir);if(Math.abs(h)<1e-6)return!1;const g=((t[0]-this.pos[0])*s[0]+(t[1]-this.pos[1])*s[1]+(t[2]-this.pos[2])*s[2])/h;return l[0]=this.pos[0]+this.dir[0]*g,l[1]=this.pos[1]+this.dir[1]*g,l[2]=this.pos[2]+this.dir[2]*g,!0}closestPointOnSphere(t,s,l){if(function($,J){var re=$[0],de=$[1],we=$[2],ze=J[0],Se=J[1],Le=J[2];return Math.abs(re-ze)<=Fu*Math.max(1,Math.abs(re),Math.abs(ze))&&Math.abs(de-Se)<=Fu*Math.max(1,Math.abs(de),Math.abs(Se))&&Math.abs(we-Le)<=Fu*Math.max(1,Math.abs(we),Math.abs(Le))}(this.pos,t)||s===0)return l[0]=l[1]=l[2]=0,!1;const[h,g,v]=this.dir,S=this.pos[0]-t[0],A=this.pos[1]-t[1],P=this.pos[2]-t[2],U=h*h+g*g+v*v,G=2*(S*h+A*g+P*v),j=G*G-4*U*(S*S+A*A+P*P-s*s);if(j<0){const $=Math.max(-G/2,0),J=S+h*$,re=A+g*$,de=P+v*$,we=Math.hypot(J,re,de);return l[0]=J*s/we,l[1]=re*s/we,l[2]=de*s/we,!1}{const $=(-G-Math.sqrt(j))/(2*U);if($<0){const J=Math.hypot(S,A,P);return l[0]=S*s/J,l[1]=A*s/J,l[2]=P*s/J,!1}return l[0]=S+h*$,l[1]=A+g*$,l[2]=P+v*$,!0}}}class oy{constructor(t,s,l,h,g){this.TL=t,this.TR=s,this.BR=l,this.BL=h,this.horizon=g}static fromInvProjectionMatrix(t,s,l){const h=[-1,1,1],g=[1,1,1],v=[1,-1,1],S=[-1,-1,1],A=Ke(h,h,t),P=Ke(g,g,t),U=Ke(v,v,t),G=Ke(S,S,t);return new oy(A,P,U,G,s/l)}}class ay{constructor(t,s){this.points=t,this.planes=s}static fromInvProjectionMatrix(t,s,l,h){const g=Math.pow(2,l),v=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map(A=>{const P=rr([],A,t),U=1/P[3]/s*g;return function(G,j,$){return G[0]=j[0]*$[0],G[1]=j[1]*$[1],G[2]=j[2]*$[2],G[3]=j[3]*$[3],G}(P,P,[U,U,h?1/P[3]:U,U])}),S=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(A=>{const P=br([],wt([],Jn([],v[A[0]],v[A[1]]),Jn([],v[A[2]],v[A[1]]))),U=-ns(P,v[A[1]]);return P.concat(U)});return new ay(v,S)}}class oa{static fromPoints(t){const s=[1/0,1/0,1/0],l=[-1/0,-1/0,-1/0];for(const h of t)Fi(s,s,h),_i(l,l,h);return new oa(s,l)}static applyTransform(t,s){const l=t.getCorners();for(let h=0;h<l.length;++h)Ke(l[h],l[h],s);return oa.fromPoints(l)}constructor(t,s){this.min=t,this.max=s,this.center=Ki([],Ut([],this.min,this.max),.5)}quadrant(t){const s=[t%2==0,t<2],l=ee(this.min),h=ee(this.max);for(let g=0;g<s.length;g++)l[g]=s[g]?this.min[g]:this.center[g],h[g]=s[g]?this.center[g]:this.max[g];return h[2]=this.max[2],new oa(l,h)}distanceX(t){return Math.max(Math.min(this.max[0],t[0]),this.min[0])-t[0]}distanceY(t){return Math.max(Math.min(this.max[1],t[1]),this.min[1])-t[1]}distanceZ(t){return Math.max(Math.min(this.max[2],t[2]),this.min[2])-t[2]}getCorners(){const t=this.min,s=this.max;return[[t[0],t[1],t[2]],[s[0],t[1],t[2]],[s[0],s[1],t[2]],[t[0],s[1],t[2]],[t[0],t[1],s[2]],[s[0],t[1],s[2]],[s[0],s[1],s[2]],[t[0],s[1],s[2]]]}intersects(t){const s=this.getCorners();let l=!0;for(let h=0;h<t.planes.length;h++){const g=t.planes[h];let v=0;for(let S=0;S<s.length;S++)v+=ns(g,s[S])+g[3]>=0;if(v===0)return 0;v!==s.length&&(l=!1)}if(l)return 2;for(let h=0;h<3;h++){let g=Number.MAX_VALUE,v=-Number.MAX_VALUE;for(let S=0;S<t.points.length;S++){const A=t.points[S][h]-this.min[h];g=Math.min(g,A),v=Math.max(v,A)}if(v<0||g>this.max[h]-this.min[h])return 0}return 1}}const ly=5,r1=6,Pc=Zn/Math.PI/2,K2=16383,Eh=64,pp=[Eh,32,16],Il=-Pc,Pl=Pc,Q2=[new oa([Il,Il,Il],[Pl,Pl,Pl]),new oa([Il,Il,Il],[0,0,Pl]),new oa([0,Il,Il],[Pl,0,Pl]),new oa([Il,0,Il],[0,Pl,Pl]),new oa([0,0,Il],[Pl,Pl,Pl])];function km(r){return r*Pc/_p}function s1(r,t,s,l=!0){const h=Ki([],r._camera.position,r.worldSize),g=[t,s,1,1];rr(g,g,r.pixelMatrixInverse),_r(g,g,1/g[3]);const v=br([],Jn([],g,h)),S=r.globeMatrix,A=[S[12],S[13],S[14]],P=Jn([],A,h),U=Pe(P),G=br([],P),j=r.worldSize/(2*Math.PI),$=ns(G,v),J=Math.asin(j/U);if(J<Math.acos($)){if(!l)return null;const nn=[],vt=[];Ki(nn,v,U/$),br(vt,Jn(vt,nn,P)),br(v,Ut(v,P,Ki(v,vt,Math.tan(J)*U)))}const re=[];new sy(h,v).closestPointOnSphere(A,j,re);const de=br([],xe(S,0)),we=br([],xe(S,1)),ze=br([],xe(S,2)),Se=ns(de,re),Le=ns(we,re),Ne=ns(ze,re),Be=St(Math.asin(-Le/j));let _t=St(Math.atan2(Se,Ne));_t=r.center.lng+function(nn,vt){const Wt=(vt-nn+180)%360-180;return Wt<-180?Wt+360:Wt}(r.center.lng,_t);const dt=Rc(_t),Ft=Fe(Dc(Be),0,1);return new Vd(dt,Ft)}class eA{constructor(t,s,l){this.a=Jn([],t,l),this.b=Jn([],s,l),this.center=l;const h=br([],this.a),g=br([],this.b);this.angle=Math.acos(ns(h,g))}}function cy(r,t){if(r.angle===0)return null;let s;return s=r.a[t]===0?1/r.angle*.5*Math.PI:1/r.angle*Math.atan(r.b[t]/r.a[t]/Math.sin(r.angle)-1/Math.tan(r.angle)),s<0||s>1?null:function(l,h,g,v){const S=Math.sin(g);return l*(Math.sin((1-v)*g)/S)+h*(Math.sin(v*g)/S)}(r.a[t],r.b[t],r.angle,Fe(s,0,1))+r.center[t]}function Lc(r){if(r.z<=1)return Q2[r.z+2*r.y+r.x];const t=uy(Om(r));return oa.fromPoints(t)}function Th(r,t,s){return Ki(r,r,1-s),fi(r,r,t,s)}function o1(r,t){const s=Ud(t.zoom);if(s===0)return Lc(r);const l=Om(r),h=uy(l),g=Rc(l.getWest())*t.worldSize,v=Rc(l.getEast())*t.worldSize,S=Dc(l.getNorth())*t.worldSize,A=Dc(l.getSouth())*t.worldSize,P=[g,S,0],U=[v,S,0],G=[g,A,0],j=[v,A,0],$=Fd([],t.globeMatrix);return Ke(P,P,$),Ke(U,U,$),Ke(G,G,$),Ke(j,j,$),h[0]=Th(h[0],G,s),h[1]=Th(h[1],j,s),h[2]=Th(h[2],U,s),h[3]=Th(h[3],P,s),oa.fromPoints(h)}function a1(r,t,s){for(const l of r)Ke(l,l,t),Ki(l,l,s)}function tA(r,t,s){const l=t/r.worldSize,h=r.globeMatrix;if(s.z<=1){const dt=Lc(s).getCorners();return a1(dt,h,l),oa.fromPoints(dt)}const g=Om(s),v=uy(g);a1(v,h,l);const S=Number.MAX_VALUE,A=[-S,-S,-S],P=[S,S,S];if(g.contains(r.center)){for(const nn of v)Fi(P,P,nn),_i(A,A,nn);A[2]=0;const dt=r.point,Ft=[dt.x*l,dt.y*l,0];return Fi(P,P,Ft),_i(A,A,Ft),new oa(P,A)}const U=[h[12]*l,h[13]*l,h[14]*l],G=g.getCenter(),j=Fe(r.center.lat,-Bo,Bo),$=Fe(G.lat,-Bo,Bo),J=Rc(r.center.lng),re=Dc(j);let de=J-Rc(G.lng);const we=re-Dc($);de>.5?de-=1:de<-.5&&(de+=1);let ze=0;Math.abs(de)>Math.abs(we)?ze=de>=0?1:3:(ze=we>=0?0:2,fi(U,U,[h[4]*l,h[5]*l,h[6]*l],-Math.sin(Xe(we>=0?g.getSouth():g.getNorth()))*Pc));const Se=v[ze],Le=v[(ze+1)%4],Ne=new eA(Se,Le,U),Be=[cy(Ne,0)||Se[0],cy(Ne,1)||Se[1],cy(Ne,2)||Se[2]],_t=Ud(r.zoom);if(_t>0){const dt=function({x:nn,y:vt,z:Wt},Ht,$t,sn,Rt){const In=1/(1<<Wt);let Nn=nn*In,Rn=Nn+In,Ii=vt*In,an=Ii+In,ii=0;const Pi=(Nn+Rn)/2-sn;return Pi>.5?ii=-1:Pi<-.5&&(ii=1),Nn=((Nn+ii)*Ht-(sn*=Ht))*$t+sn,Rn=((Rn+ii)*Ht-sn)*$t+sn,Ii=(Ii*Ht-(Rt*=Ht))*$t+Rt,an=(an*Ht-Rt)*$t+Rt,[[Nn,an,0],[Rn,an,0],[Rn,Ii,0],[Nn,Ii,0]]}(s,t,r._pixelsPerMercatorPixel,J,re);for(let nn=0;nn<v.length;nn++)Th(v[nn],dt[nn],_t);const Ft=Ut([],dt[ze],dt[(ze+1)%4]);Ki(Ft,Ft,.5),Th(Be,Ft,_t)}for(const dt of v)Fi(P,P,dt),_i(A,A,dt);return P[2]=Math.min(Se[2],Le[2]),Fi(P,P,Be),_i(A,A,Be),new oa(P,A)}function Om({x:r,y:t,z:s}){const l=1/(1<<s),h=new Mr(ll(r*l),Fo((t+1)*l)),g=new Mr(ll((r+1)*l),Fo(t*l));return new al(h,g)}function uy(r){const t=Xe(r.getNorth()),s=Xe(r.getSouth()),l=Math.cos(t),h=Math.cos(s),g=Math.sin(t),v=Math.sin(s),S=r.getWest(),A=r.getEast();return[Bd(h,v,S),Bd(h,v,A),Bd(l,g,A),Bd(l,g,S)]}function Bd(r,t,s,l=Pc){return s=Xe(s),[r*Math.sin(s)*l,-t*l,r*Math.cos(s)*l]}function Nd(r,t,s){return Bd(Math.cos(Xe(r)),Math.sin(Xe(r)),t,s)}function mp(r,t,s,l){const h=1<<s.z,g=(r/Zn+s.x)/h;return Nd(Fo((t/Zn+s.y)/h),ll(g),l)}function Fm({min:r,max:t}){return K2/Math.max(t[0]-r[0],t[1]-r[1],t[2]-r[2])}const l1=new Float64Array(16);function gp(r){const t=Fm(r),s=x(l1,[t,t,t]);return su(s,s,((l=[])[0]=-(h=r.min)[0],l[1]=-h[1],l[2]=-h[2],l));var l,h}function hy(r){const t=(l=r.min,(s=l1)[0]=1,s[1]=0,s[2]=0,s[3]=0,s[4]=0,s[5]=1,s[6]=0,s[7]=0,s[8]=0,s[9]=0,s[10]=1,s[11]=0,s[12]=l[0],s[13]=l[1],s[14]=l[2],s[15]=1,s);var s,l;const h=1/Fm(r);return ou(t,t,[h,h,h])}function c1(r,t,s,l,h){const g=function(A){const P=Zn/(2*Math.PI);return A/(2*Math.PI)/P}(s),v=[r,t,-s/(2*Math.PI)],S=$a(new Float64Array(16));return su(S,S,v),ou(S,S,[g,g,g]),dp(S,S,Xe(-h)),_(S,S,Xe(-l)),S}function Ud(r){return it(ly,r1,r)}function u1(r,t){const s=Nd(t.lat,t.lng),l=function(J){const re=Nd(J._center.lat,J._center.lng);let de=wt([],at(0,1,0),re);const we=L([],-J.angle,re);de=Ke(de,de,we),L(we,-J._pitch,de);const ze=br([],re);return Ki(ze,ze,km(J.cameraToCenterDistance/J.pixelsPerMeter)),Ke(ze,ze,we),Ut([],re,ze)}(r);return v=(h=Cn([],l,s))[0],S=h[1],A=h[2],P=(g=s)[0],U=g[1],G=g[2],$=(j=Math.sqrt(v*v+S*S+A*A)*Math.sqrt(P*P+U*U+G*G))&&ns(h,g)/j,Math.acos(Math.min(Math.max($,-1),1));var h,g,v,S,A,P,U,G,j,$}function dy(r,t){return u1(r,t)>Math.PI/2*1.01}const h1=Xe(85),nA=Math.cos(h1),iA=Math.sin(h1),_p=63710088e-1,d1=2*Math.PI*_p;class Bu{constructor(t,s){if(isNaN(t)||isNaN(s))throw new Error(`Invalid LngLat object: (${t}, ${s})`);if(this.lng=+t,this.lat=+s,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Bu(tt(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(t){const s=Math.PI/180,l=this.lat*s,h=t.lat*s,g=Math.sin(l)*Math.sin(h)+Math.cos(l)*Math.cos(h)*Math.cos((t.lng-this.lng)*s);return _p*Math.acos(Math.min(g,1))}toBounds(t=0){const s=360*t/40075017,l=s/Math.cos(Math.PI/180*this.lat);return new al(new Bu(this.lng-l,this.lat-s),new Bu(this.lng+l,this.lat+s))}toEcef(t){const s=km(t);return Nd(this.lat,this.lng,Pc+s)}static convert(t){if(t instanceof Bu)return t;if(Array.isArray(t)&&(t.length===2||t.length===3))return new Bu(Number(t[0]),Number(t[1]));if(!Array.isArray(t)&&typeof t=="object"&&t!==null)return new Bu(Number("lng"in t?t.lng:t.lon),Number(t.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: <lng>, lat: <lat>}, an object {lon: <lng>, lat: <lat>}, or an array of [<lng>, <lat>]")}}var Mr=Bu;function fy(r){return d1*Math.cos(r*Math.PI/180)}function Rc(r){return(180+r)/360}function Dc(r){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+r*Math.PI/360)))/360}function Xl(r,t){return r/fy(t)}function ll(r){return 360*r-180}function Fo(r){return 360/Math.PI*Math.atan(Math.exp((180-360*r)*Math.PI/180))-90}function f1(r,t){return r*fy(Fo(t))}const Bo=85.051129;function p1(r){return 1/Math.cos(r*Math.PI/180)}class Vd{constructor(t,s,l=0){this.x=+t,this.y=+s,this.z=+l}static fromLngLat(t,s=0){const l=Mr.convert(t);return new Vd(Rc(l.lng),Dc(l.lat),Xl(s,l.lat))}toLngLat(){return new Mr(ll(this.x),Fo(this.y))}toAltitude(){return f1(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/d1*p1(Fo(this.y))}}function py(r,t,s,l,h,g,v,S,A){const P=(t+l)/2,U=(s+h)/2,G=new ce(P,U);S(G),function(j,$,J,re,de,we){const ze=J-de,Se=re-we;return Math.abs((re-$)*ze-(J-j)*Se)/Math.hypot(ze,Se)}(G.x,G.y,g.x,g.y,v.x,v.y)>=A?(py(r,t,s,P,U,g,G,S,A),py(r,P,U,l,h,G,v,S,A)):r.push(v)}function m1(r,t,s){let l=r[0],h=l.x,g=l.y;t(l);const v=[l];for(let S=1;S<r.length;S++){const A=r[S],{x:P,y:U}=A;t(A),py(v,h,g,P,U,l,A,t,s),h=P,g=U,l=A}return v}function my(r,t,s,l){if(l(t,s)){const h=t.add(s)._mult(.5);my(r,t,h,l),my(r,h,s,l)}else r.push(s)}function rA(r,t){let s=r[0];const l=[s];for(let h=1;h<r.length;h++){const g=r[h];my(l,s,g,t),s=g}return l}const gy=Math.pow(2,14)-1,g1=-gy-1;function sA(r,t){const s=Math.round(r.x*t),l=Math.round(r.y*t);return r.x=Fe(s,g1,gy),r.y=Fe(l,g1,gy),(s<r.x||s>r.x+1||l<r.y||l>r.y+1)&&wn("Geometry exceeds allowed extent, reduce your vector tile buffer size"),r}function au(r,t,s){const l=r.loadGeometry(),h=r.extent,g=Zn/h;if(t&&s&&s.projection.isReprojectedInTileSpace){const v=1<<t.z,{scale:S,x:A,y:P,projection:U}=s,G=j=>{const $=ll((t.x+j.x/h)/v),J=Fo((t.y+j.y/h)/v),re=U.project($,J);j.x=(re.x*S-A)*h,j.y=(re.y*S-P)*h};for(let j=0;j<l.length;j++)if(r.type!==1)l[j]=m1(l[j],G,1);else{const $=[];for(const J of l[j])J.x<0||J.x>=h||J.y<0||J.y>=h||(G(J),$.push(J));l[j]=$}}for(const v of l)for(const S of v)sA(S,g);return l}function Ah(r,t){return{type:r.type,id:r.id,properties:r.properties,geometry:t?au(r):[]}}function Bm(r,t,s,l,h){r.emplaceBack(2*t+(l+1)/2,2*s+(h+1)/2)}function Nm(r,t,s){r.emplaceBack(t.x,t.y,t.z,s[0]*16384,s[1]*16384,s[2]*16384)}class _y{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(s=>s.id),this.index=t.index,this.hasPattern=!1,this.projection=t.projection,this.layoutVertexArray=new Jt,this.indexArray=new Gn,this.segments=new jr,this.programConfigurations=new Ac(t.layers,t.zoom),this.stateDependentLayerIds=this.layers.filter(s=>s.isStateDependent()).map(s=>s.id)}populate(t,s,l,h){const g=this.layers[0],v=[];let S=null;g.type==="circle"&&(S=g.layout.get("circle-sort-key"));for(const{feature:P,id:U,index:G,sourceLayerIndex:j}of t){const $=this.layers[0]._featureFilter.needGeometry,J=Ah(P,$);if(!this.layers[0]._featureFilter.filter(new V(this.zoom),J,l))continue;const re=S?S.evaluate(J,{},l):void 0,de={id:U,properties:P.properties,type:P.type,sourceLayerIndex:j,index:G,geometry:$?J.geometry:au(P,l,h),patterns:{},sortKey:re};v.push(de)}S&&v.sort((P,U)=>P.sortKey-U.sortKey);let A=null;h.projection.name==="globe"&&(this.globeExtVertexArray=new Qt,A=h.projection);for(const P of v){const{geometry:U,index:G,sourceLayerIndex:j}=P,$=t[G].feature;this.addFeature(P,U,G,s.availableImages,l,A),s.featureIndex.insert($,U,G,j,this.index)}}update(t,s,l,h){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,s,this.stateDependentLayers,l,h)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,ry.members),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,Cc.members))),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}addFeature(t,s,l,h,g,v){for(const S of s)for(const A of S){const P=A.x,U=A.y;if(P<0||P>=Zn||U<0||U>=Zn)continue;if(v){const $=v.projectTilePoint(P,U,g),J=v.upVector(g,P,U),re=this.globeExtVertexArray;Nm(re,$,J),Nm(re,$,J),Nm(re,$,J),Nm(re,$,J)}const G=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,t.sortKey),j=G.vertexLength;Bm(this.layoutVertexArray,P,U,-1,-1),Bm(this.layoutVertexArray,P,U,1,-1),Bm(this.layoutVertexArray,P,U,1,1),Bm(this.layoutVertexArray,P,U,-1,1),this.indexArray.emplaceBack(j,j+1,j+2),this.indexArray.emplaceBack(j,j+2,j+3),G.vertexLength+=4,G.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,l,{},h,g)}}function _1(r,t){for(let s=0;s<r.length;s++)if(Ch(t,r[s]))return!0;for(let s=0;s<t.length;s++)if(Ch(r,t[s]))return!0;return!!yy(r,t)}function oA(r,t,s){return!!Ch(r,t)||!!xy(t,r,s)}function y1(r,t){if(r.length===1)return v1(t,r[0]);for(let s=0;s<t.length;s++){const l=t[s];for(let h=0;h<l.length;h++)if(Ch(r,l[h]))return!0}for(let s=0;s<r.length;s++)if(v1(t,r[s]))return!0;for(let s=0;s<t.length;s++)if(yy(r,t[s]))return!0;return!1}function aA(r,t,s){if(r.length>1){if(yy(r,t))return!0;for(let l=0;l<t.length;l++)if(xy(t[l],r,s))return!0}for(let l=0;l<r.length;l++)if(xy(r[l],t,s))return!0;return!1}function yy(r,t){if(r.length===0||t.length===0)return!1;for(let s=0;s<r.length-1;s++){const l=r[s],h=r[s+1];for(let g=0;g<t.length-1;g++)if(lA(l,h,t[g],t[g+1]))return!0}return!1}function lA(r,t,s,l){return Yt(r,s,l)!==Yt(t,s,l)&&Yt(r,t,s)!==Yt(r,t,l)}function xy(r,t,s){const l=s*s;if(t.length===1)return r.distSqr(t[0])<l;for(let h=1;h<t.length;h++)if(x1(r,t[h-1],t[h])<l)return!0;return!1}function x1(r,t,s){const l=t.distSqr(s);if(l===0)return r.distSqr(t);const h=((r.x-t.x)*(s.x-t.x)+(r.y-t.y)*(s.y-t.y))/l;return r.distSqr(h<0?t:h>1?s:s.sub(t)._mult(h)._add(t))}function v1(r,t){let s,l,h,g=!1;for(let v=0;v<r.length;v++){s=r[v];for(let S=0,A=s.length-1;S<s.length;A=S++)l=s[S],h=s[A],l.y>t.y!=h.y>t.y&&t.x<(h.x-l.x)*(t.y-l.y)/(h.y-l.y)+l.x&&(g=!g)}return g}function Ch(r,t){let s=!1;for(let l=0,h=r.length-1;l<r.length;h=l++){const g=r[l],v=r[h];g.y>t.y!=v.y>t.y&&t.x<(v.x-g.x)*(t.y-g.y)/(v.y-g.y)+g.x&&(s=!s)}return s}function b1(r,t,s,l,h){for(const v of r)if(t<=v.x&&s<=v.y&&l>=v.x&&h>=v.y)return!0;const g=[new ce(t,s),new ce(t,h),new ce(l,h),new ce(l,s)];if(r.length>2){for(const v of g)if(Ch(r,v))return!0}for(let v=0;v<r.length-1;v++)if(cA(r[v],r[v+1],g))return!0;return!1}function cA(r,t,s){const l=s[0],h=s[2];if(r.x<l.x&&t.x<l.x||r.x>h.x&&t.x>h.x||r.y<l.y&&t.y<l.y||r.y>h.y&&t.y>h.y)return!1;const g=Yt(r,t,s[0]);return g!==Yt(r,t,s[1])||g!==Yt(r,t,s[2])||g!==Yt(r,t,s[3])}function Gd(r,t,s){const l=t.paint.get(r).value;return l.kind==="constant"?l.value:s.programConfigurations.get(t.id).getMaxValue(r)}function Um(r){return Math.sqrt(r[0]*r[0]+r[1]*r[1])}function w1(r,t,s,l,h){if(!t[0]&&!t[1])return r;const g=ce.convert(t)._mult(h);s==="viewport"&&g._rotate(-l);const v=[];for(let S=0;S<r.length;S++)v.push(r[S].sub(g));return v}function S1(r,t,s,l){const h=ce.convert(r)._mult(l);return t==="viewport"&&h._rotate(-s),h}kn(_y,"CircleBucket",{omit:["layers"]});const uA=new Te({"circle-sort-key":new pe(ct.layout_circle["circle-sort-key"])});var hA={paint:new Te({"circle-radius":new pe(ct.paint_circle["circle-radius"]),"circle-color":new pe(ct.paint_circle["circle-color"]),"circle-blur":new pe(ct.paint_circle["circle-blur"]),"circle-opacity":new pe(ct.paint_circle["circle-opacity"]),"circle-translate":new ie(ct.paint_circle["circle-translate"]),"circle-translate-anchor":new ie(ct.paint_circle["circle-translate-anchor"]),"circle-pitch-scale":new ie(ct.paint_circle["circle-pitch-scale"]),"circle-pitch-alignment":new ie(ct.paint_circle["circle-pitch-alignment"]),"circle-stroke-width":new pe(ct.paint_circle["circle-stroke-width"]),"circle-stroke-color":new pe(ct.paint_circle["circle-stroke-color"]),"circle-stroke-opacity":new pe(ct.paint_circle["circle-stroke-opacity"])}),layout:uA};function M1(r,t,s,l,h,g,v,S,A){if(g&&r.queryGeometry.isAboveHorizon)return!1;g&&(A*=r.pixelToTileUnitsFactor);const P=r.tileID.canonical,U=s.projection.upVectorScale(P,s.center.lat,s.worldSize).metersToTile;for(const G of t)for(const j of G){const $=j.add(S),J=h&&s.elevation?s.elevation.exaggeration()*h.getElevationAt($.x,$.y,!0):0,re=s.projection.projectTilePoint($.x,$.y,P);if(J>0){const Se=s.projection.upVector(P,$.x,$.y);re.x+=Se[0]*U*J,re.y+=Se[1]*U*J,re.z+=Se[2]*U*J}const de=g?$:dA(re.x,re.y,re.z,l),we=g?r.tilespaceRays.map(Se=>pA(Se,J)):r.queryGeometry.screenGeometry,ze=rr([],[re.x,re.y,re.z,1],l);if(!v&&g?A*=ze[3]/s.cameraToCenterDistance:v&&!g&&(A*=s.cameraToCenterDistance/ze[3]),g){const Se=Fo((j.y/Zn+P.y)/(1<<P.z));A/=s.projection.pixelsPerMeter(Se,1)/Xl(1,Se)}if(oA(we,de,A))return!0}return!1}function dA(r,t,s,l){const h=rr([],[r,t,s,1],l);return new ce(h[0]/h[3],h[1]/h[3])}const E1=at(0,0,0),fA=at(0,0,1);function pA(r,t){const s=Z();return E1[2]=t,r.intersectsPlane(E1,fA,s),new ce(s[0],s[1])}class T1 extends _y{}function A1(r,{width:t,height:s},l,h){if(h){if(h instanceof Uint8ClampedArray)h=new Uint8Array(h.buffer);else if(h.length!==t*s*l)throw new RangeError("mismatched image size")}else h=new Uint8Array(t*s*l);return r.width=t,r.height=s,r.data=h,r}function C1(r,t,s){const{width:l,height:h}=t;l===r.width&&h===r.height||(vy(r,t,{x:0,y:0},{x:0,y:0},{width:Math.min(r.width,l),height:Math.min(r.height,h)},s),r.width=l,r.height=h,r.data=t.data)}function vy(r,t,s,l,h,g){if(h.width===0||h.height===0)return t;if(h.width>r.width||h.height>r.height||s.x>r.width-h.width||s.y>r.height-h.height)throw new RangeError("out of range source coordinates for image copy");if(h.width>t.width||h.height>t.height||l.x>t.width-h.width||l.y>t.height-h.height)throw new RangeError("out of range destination coordinates for image copy");const v=r.data,S=t.data;for(let A=0;A<h.height;A++){const P=((s.y+A)*r.width+s.x)*g,U=((l.y+A)*t.width+l.x)*g;for(let G=0;G<h.width*g;G++)S[U+G]=v[P+G]}return t}kn(T1,"HeatmapBucket",{omit:["layers"]});class lu{constructor(t,s){A1(this,t,1,s)}resize(t){C1(this,new lu(t),1)}clone(){return new lu({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,s,l,h,g){vy(t,s,l,h,g,1)}}class Ya{constructor(t,s){A1(this,t,4,s)}resize(t){C1(this,new Ya(t),4)}replace(t,s){s?this.data.set(t):this.data=t instanceof Uint8ClampedArray?new Uint8Array(t.buffer):t}clone(){return new Ya({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,s,l,h,g){vy(t,s,l,h,g,4)}}kn(lu,"AlphaImage"),kn(Ya,"RGBAImage");var mA={paint:new Te({"heatmap-radius":new pe(ct.paint_heatmap["heatmap-radius"]),"heatmap-weight":new pe(ct.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new ie(ct.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Ee(ct.paint_heatmap["heatmap-color"]),"heatmap-opacity":new ie(ct.paint_heatmap["heatmap-opacity"])})};function by(r){const t={},s=r.resolution||256,l=r.clips?r.clips.length:1,h=r.image||new Ya({width:s,height:l}),g=(v,S,A)=>{t[r.evaluationKey]=A;const P=r.expression.evaluate(t);h.data[v+S+0]=Math.floor(255*P.r/P.a),h.data[v+S+1]=Math.floor(255*P.g/P.a),h.data[v+S+2]=Math.floor(255*P.b/P.a),h.data[v+S+3]=Math.floor(255*P.a)};if(r.clips)for(let v=0,S=0;v<l;++v,S+=4*s)for(let A=0,P=0;A<s;A++,P+=4){const U=A/(s-1),{start:G,end:j}=r.clips[v];g(S,P,G*(1-U)+j*U)}else for(let v=0,S=0;v<s;v++,S+=4)g(0,S,v/(s-1));return h}var gA={paint:new Te({"hillshade-illumination-direction":new ie(ct.paint_hillshade["hillshade-illumination-direction"]),"hillshade-illumination-anchor":new ie(ct.paint_hillshade["hillshade-illumination-anchor"]),"hillshade-exaggeration":new ie(ct.paint_hillshade["hillshade-exaggeration"]),"hillshade-shadow-color":new ie(ct.paint_hillshade["hillshade-shadow-color"]),"hillshade-highlight-color":new ie(ct.paint_hillshade["hillshade-highlight-color"]),"hillshade-accent-color":new ie(ct.paint_hillshade["hillshade-accent-color"])})};const _A=$e([{name:"a_pos",components:2,type:"Int16"}],4),{members:yA}=_A;var wy={exports:{}};function Vm(r,t,s){s=s||2;var l,h,g,v,S,A,P,U=t&&t.length,G=U?t[0]*s:r.length,j=I1(r,0,G,s,!0),$=[];if(!j||j.next===j.prev)return $;if(U&&(j=function(re,de,we,ze){var Se,Le,Ne,Be=[];for(Se=0,Le=de.length;Se<Le;Se++)(Ne=I1(re,de[Se]*ze,Se<Le-1?de[Se+1]*ze:re.length,ze,!1))===Ne.next&&(Ne.steiner=!0),Be.push(TA(Ne));for(Be.sort(SA),Se=0;Se<Be.length;Se++)we=MA(Be[Se],we);return we}(r,t,j,s)),r.length>80*s){l=g=r[0],h=v=r[1];for(var J=s;J<G;J+=s)(S=r[J])<l&&(l=S),(A=r[J+1])<h&&(h=A),S>g&&(g=S),A>v&&(v=A);P=(P=Math.max(g-l,v-h))!==0?32767/P:0}return yp(j,$,s,l,h,P,0),$}function I1(r,t,s,l,h){var g,v;if(h===Ey(r,t,s,l)>0)for(g=t;g<s;g+=l)v=R1(g,r[g],r[g+1],v);else for(g=s-l;g>=t;g-=l)v=R1(g,r[g],r[g+1],v);return v&&Gm(v,v.next)&&(vp(v),v=v.next),v}function Ih(r,t){if(!r)return r;t||(t=r);var s,l=r;do if(s=!1,l.steiner||!Gm(l,l.next)&&xs(l.prev,l,l.next)!==0)l=l.next;else{if(vp(l),(l=t=l.prev)===l.next)break;s=!0}while(s||l!==t);return t}function yp(r,t,s,l,h,g,v){if(r){!v&&g&&function(U,G,j,$){var J=U;do J.z===0&&(J.z=Sy(J.x,J.y,G,j,$)),J.prevZ=J.prev,J.nextZ=J.next,J=J.next;while(J!==U);J.prevZ.nextZ=null,J.prevZ=null,function(re){var de,we,ze,Se,Le,Ne,Be,_t,dt=1;do{for(we=re,re=null,Le=null,Ne=0;we;){for(Ne++,ze=we,Be=0,de=0;de<dt&&(Be++,ze=ze.nextZ);de++);for(_t=dt;Be>0||_t>0&&ze;)Be!==0&&(_t===0||!ze||we.z<=ze.z)?(Se=we,we=we.nextZ,Be--):(Se=ze,ze=ze.nextZ,_t--),Le?Le.nextZ=Se:re=Se,Se.prevZ=Le,Le=Se;we=ze}Le.nextZ=null,dt*=2}while(Ne>1)}(J)}(r,l,h,g);for(var S,A,P=r;r.prev!==r.next;)if(S=r.prev,A=r.next,g?vA(r,l,h,g):xA(r))t.push(S.i/s|0),t.push(r.i/s|0),t.push(A.i/s|0),vp(r),r=A.next,P=A.next;else if((r=A)===P){v?v===1?yp(r=bA(Ih(r),t,s),t,s,l,h,g,2):v===2&&wA(r,t,s,l,h,g):yp(Ih(r),t,s,l,h,g,1);break}}}function xA(r){var t=r.prev,s=r,l=r.next;if(xs(t,s,l)>=0)return!1;for(var h=t.x,g=s.x,v=l.x,S=t.y,A=s.y,P=l.y,U=h<g?h<v?h:v:g<v?g:v,G=S<A?S<P?S:P:A<P?A:P,j=h>g?h>v?h:v:g>v?g:v,$=S>A?S>P?S:P:A>P?A:P,J=l.next;J!==t;){if(J.x>=U&&J.x<=j&&J.y>=G&&J.y<=$&&jd(h,S,g,A,v,P,J.x,J.y)&&xs(J.prev,J,J.next)>=0)return!1;J=J.next}return!0}function vA(r,t,s,l){var h=r.prev,g=r,v=r.next;if(xs(h,g,v)>=0)return!1;for(var S=h.x,A=g.x,P=v.x,U=h.y,G=g.y,j=v.y,$=S<A?S<P?S:P:A<P?A:P,J=U<G?U<j?U:j:G<j?G:j,re=S>A?S>P?S:P:A>P?A:P,de=U>G?U>j?U:j:G>j?G:j,we=Sy($,J,t,s,l),ze=Sy(re,de,t,s,l),Se=r.prevZ,Le=r.nextZ;Se&&Se.z>=we&&Le&&Le.z<=ze;){if(Se.x>=$&&Se.x<=re&&Se.y>=J&&Se.y<=de&&Se!==h&&Se!==v&&jd(S,U,A,G,P,j,Se.x,Se.y)&&xs(Se.prev,Se,Se.next)>=0||(Se=Se.prevZ,Le.x>=$&&Le.x<=re&&Le.y>=J&&Le.y<=de&&Le!==h&&Le!==v&&jd(S,U,A,G,P,j,Le.x,Le.y)&&xs(Le.prev,Le,Le.next)>=0))return!1;Le=Le.nextZ}for(;Se&&Se.z>=we;){if(Se.x>=$&&Se.x<=re&&Se.y>=J&&Se.y<=de&&Se!==h&&Se!==v&&jd(S,U,A,G,P,j,Se.x,Se.y)&&xs(Se.prev,Se,Se.next)>=0)return!1;Se=Se.prevZ}for(;Le&&Le.z<=ze;){if(Le.x>=$&&Le.x<=re&&Le.y>=J&&Le.y<=de&&Le!==h&&Le!==v&&jd(S,U,A,G,P,j,Le.x,Le.y)&&xs(Le.prev,Le,Le.next)>=0)return!1;Le=Le.nextZ}return!0}function bA(r,t,s){var l=r;do{var h=l.prev,g=l.next.next;!Gm(h,g)&&P1(h,l,l.next,g)&&xp(h,g)&&xp(g,h)&&(t.push(h.i/s|0),t.push(l.i/s|0),t.push(g.i/s|0),vp(l),vp(l.next),l=r=g),l=l.next}while(l!==r);return Ih(l)}function wA(r,t,s,l,h,g){var v=r;do{for(var S=v.next.next;S!==v.prev;){if(v.i!==S.i&&AA(v,S)){var A=L1(v,S);return v=Ih(v,v.next),A=Ih(A,A.next),yp(v,t,s,l,h,g,0),void yp(A,t,s,l,h,g,0)}S=S.next}v=v.next}while(v!==r)}function SA(r,t){return r.x-t.x}function MA(r,t){var s=function(h,g){var v,S=g,A=h.x,P=h.y,U=-1/0;do{if(P<=S.y&&P>=S.next.y&&S.next.y!==S.y){var G=S.x+(P-S.y)*(S.next.x-S.x)/(S.next.y-S.y);if(G<=A&&G>U&&(U=G,v=S.x<S.next.x?S:S.next,G===A))return v}S=S.next}while(S!==g);if(!v)return null;var j,$=v,J=v.x,re=v.y,de=1/0;S=v;do A>=S.x&&S.x>=J&&A!==S.x&&jd(P<re?A:U,P,J,re,P<re?U:A,P,S.x,S.y)&&(j=Math.abs(P-S.y)/(A-S.x),xp(S,h)&&(j<de||j===de&&(S.x>v.x||S.x===v.x&&EA(v,S)))&&(v=S,de=j)),S=S.next;while(S!==$);return v}(r,t);if(!s)return t;var l=L1(s,r);return Ih(l,l.next),Ih(s,s.next)}function EA(r,t){return xs(r.prev,r,t.prev)<0&&xs(t.next,r,r.next)<0}function Sy(r,t,s,l,h){return(r=1431655765&((r=858993459&((r=252645135&((r=16711935&((r=(r-s)*h|0)|r<<8))|r<<4))|r<<2))|r<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-l)*h|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function TA(r){var t=r,s=r;do(t.x<s.x||t.x===s.x&&t.y<s.y)&&(s=t),t=t.next;while(t!==r);return s}function jd(r,t,s,l,h,g,v,S){return(h-v)*(t-S)>=(r-v)*(g-S)&&(r-v)*(l-S)>=(s-v)*(t-S)&&(s-v)*(g-S)>=(h-v)*(l-S)}function AA(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!function(s,l){var h=s;do{if(h.i!==s.i&&h.next.i!==s.i&&h.i!==l.i&&h.next.i!==l.i&&P1(h,h.next,s,l))return!0;h=h.next}while(h!==s);return!1}(r,t)&&(xp(r,t)&&xp(t,r)&&function(s,l){var h=s,g=!1,v=(s.x+l.x)/2,S=(s.y+l.y)/2;do h.y>S!=h.next.y>S&&h.next.y!==h.y&&v<(h.next.x-h.x)*(S-h.y)/(h.next.y-h.y)+h.x&&(g=!g),h=h.next;while(h!==s);return g}(r,t)&&(xs(r.prev,r,t.prev)||xs(r,t.prev,t))||Gm(r,t)&&xs(r.prev,r,r.next)>0&&xs(t.prev,t,t.next)>0)}function xs(r,t,s){return(t.y-r.y)*(s.x-t.x)-(t.x-r.x)*(s.y-t.y)}function Gm(r,t){return r.x===t.x&&r.y===t.y}function P1(r,t,s,l){var h=Wm(xs(r,t,s)),g=Wm(xs(r,t,l)),v=Wm(xs(s,l,r)),S=Wm(xs(s,l,t));return h!==g&&v!==S||!(h!==0||!jm(r,s,t))||!(g!==0||!jm(r,l,t))||!(v!==0||!jm(s,r,l))||!(S!==0||!jm(s,t,l))}function jm(r,t,s){return t.x<=Math.max(r.x,s.x)&&t.x>=Math.min(r.x,s.x)&&t.y<=Math.max(r.y,s.y)&&t.y>=Math.min(r.y,s.y)}function Wm(r){return r>0?1:r<0?-1:0}function xp(r,t){return xs(r.prev,r,r.next)<0?xs(r,t,r.next)>=0&&xs(r,r.prev,t)>=0:xs(r,t,r.prev)<0||xs(r,r.next,t)<0}function L1(r,t){var s=new My(r.i,r.x,r.y),l=new My(t.i,t.x,t.y),h=r.next,g=t.prev;return r.next=t,t.prev=r,s.next=h,h.prev=s,l.next=s,s.prev=l,g.next=l,l.prev=g,l}function R1(r,t,s,l){var h=new My(r,t,s);return l?(h.next=l.next,h.prev=l,l.next.prev=h,l.next=h):(h.prev=h,h.next=h),h}function vp(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function My(r,t,s){this.i=r,this.x=t,this.y=s,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Ey(r,t,s,l){for(var h=0,g=t,v=s-l;g<s;g+=l)h+=(r[v]-r[g])*(r[g+1]+r[v+1]),v=g;return h}wy.exports=Vm,wy.exports.default=Vm,Vm.deviation=function(r,t,s,l){var h=t&&t.length,g=Math.abs(Ey(r,0,h?t[0]*s:r.length,s));if(h)for(var v=0,S=t.length;v<S;v++)g-=Math.abs(Ey(r,t[v]*s,v<S-1?t[v+1]*s:r.length,s));var A=0;for(v=0;v<l.length;v+=3){var P=l[v]*s,U=l[v+1]*s,G=l[v+2]*s;A+=Math.abs((r[P]-r[G])*(r[U+1]-r[P+1])-(r[P]-r[U])*(r[G+1]-r[P+1]))}return g===0&&A===0?0:Math.abs((A-g)/g)},Vm.flatten=function(r){for(var t=r[0][0].length,s={vertices:[],holes:[],dimensions:t},l=0,h=0;h<r.length;h++){for(var g=0;g<r[h].length;g++)for(var v=0;v<t;v++)s.vertices.push(r[h][g][v]);h>0&&s.holes.push(l+=r[h-1].length)}return s};var Ty=K(wy.exports);function CA(r,t,s,l,h){D1(r,t,s||0,l||r.length-1,h||IA)}function D1(r,t,s,l,h){for(;l>s;){if(l-s>600){var g=l-s+1,v=t-s+1,S=Math.log(g),A=.5*Math.exp(2*S/3),P=.5*Math.sqrt(S*A*(g-A)/g)*(v-g/2<0?-1:1);D1(r,t,Math.max(s,Math.floor(t-v*A/g+P)),Math.min(l,Math.floor(t+(g-v)*A/g+P)),h)}var U=r[t],G=s,j=l;for(bp(r,s,t),h(r[l],U)>0&&bp(r,s,l);G<j;){for(bp(r,G,j),G++,j--;h(r[G],U)<0;)G++;for(;h(r[j],U)>0;)j--}h(r[s],U)===0?bp(r,s,j):bp(r,++j,l),j<=t&&(s=j+1),t<=j&&(l=j-1)}}function bp(r,t,s){var l=r[t];r[t]=r[s],r[s]=l}function IA(r,t){return r<t?-1:r>t?1:0}function Ay(r,t){const s=r.length;if(s<=1)return[r];const l=[];let h,g;for(let v=0;v<s;v++){const S=rn(r[v]);S!==0&&(r[v].area=Math.abs(S),g===void 0&&(g=S<0),g===S<0?(h&&l.push(h),h=[r[v]]):h.push(r[v]))}if(h&&l.push(h),t>1)for(let v=0;v<l.length;v++)l[v].length<=t||(CA(l[v],t,1,l[v].length-1,PA),l[v]=l[v].slice(0,t));return l}function PA(r,t){return t.area-r.area}function Cy(r,t,s){const l=s.patternDependencies;let h=!1;for(const g of t){const v=g.paint.get(`${r}-pattern`);v.isConstant()||(h=!0);const S=v.constantOr(null);S&&(h=!0,l[S]=!0)}return h}function Iy(r,t,s,l,h){const g=h.patternDependencies;for(const v of t){const S=v.paint.get(`${r}-pattern`).value;if(S.kind!=="constant"){let A=S.evaluate({zoom:l},s,{},h.availableImages);A=A&&A.name?A.name:A,g[A]=!0,s.patterns[v.id]=A}}return s}class Hm{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(s=>s.id),this.index=t.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Jt,this.indexArray=new Gn,this.indexArray2=new us,this.programConfigurations=new Ac(t.layers,t.zoom),this.segments=new jr,this.segments2=new jr,this.stateDependentLayerIds=this.layers.filter(s=>s.isStateDependent()).map(s=>s.id),this.projection=t.projection}populate(t,s,l,h){this.hasPattern=Cy("fill",this.layers,s);const g=this.layers[0].layout.get("fill-sort-key"),v=[];for(const{feature:S,id:A,index:P,sourceLayerIndex:U}of t){const G=this.layers[0]._featureFilter.needGeometry,j=Ah(S,G);if(!this.layers[0]._featureFilter.filter(new V(this.zoom),j,l))continue;const $=g?g.evaluate(j,{},l,s.availableImages):void 0,J={id:A,properties:S.properties,type:S.type,sourceLayerIndex:U,index:P,geometry:G?j.geometry:au(S,l,h),patterns:{},sortKey:$};v.push(J)}g&&v.sort((S,A)=>S.sortKey-A.sortKey);for(const S of v){const{geometry:A,index:P,sourceLayerIndex:U}=S;if(this.hasPattern){const G=Iy("fill",this.layers,S,this.zoom,s);this.patternFeatures.push(G)}else this.addFeature(S,A,P,l,{},s.availableImages);s.featureIndex.insert(t[P].feature,A,P,U,this.index)}}update(t,s,l,h){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,s,this.stateDependentLayers,l,h)}addFeatures(t,s,l,h,g){for(const v of this.patternFeatures)this.addFeature(v,v.geometry,v.index,s,l,h)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,yA),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.indexBuffer2=t.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(t,s,l,h,g,v=[]){for(const S of Ay(s,500)){let A=0;for(const J of S)A+=J.length;const P=this.segments.prepareSegment(A,this.layoutVertexArray,this.indexArray),U=P.vertexLength,G=[],j=[];for(const J of S){if(J.length===0)continue;J!==S[0]&&j.push(G.length/2);const re=this.segments2.prepareSegment(J.length,this.layoutVertexArray,this.indexArray2),de=re.vertexLength;this.layoutVertexArray.emplaceBack(J[0].x,J[0].y),this.indexArray2.emplaceBack(de+J.length-1,de),G.push(J[0].x),G.push(J[0].y);for(let we=1;we<J.length;we++)this.layoutVertexArray.emplaceBack(J[we].x,J[we].y),this.indexArray2.emplaceBack(de+we-1,de+we),G.push(J[we].x),G.push(J[we].y);re.vertexLength+=J.length,re.primitiveLength+=J.length}const $=Ty(G,j);for(let J=0;J<$.length;J+=3)this.indexArray.emplaceBack(U+$[J],U+$[J+1],U+$[J+2]);P.vertexLength+=A,P.primitiveLength+=$.length/3}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,l,g,v,h)}}kn(Hm,"FillBucket",{omit:["layers","patternFeatures"]});const LA=new Te({"fill-sort-key":new pe(ct.layout_fill["fill-sort-key"])});var RA={paint:new Te({"fill-antialias":new ie(ct.paint_fill["fill-antialias"]),"fill-opacity":new pe(ct.paint_fill["fill-opacity"]),"fill-color":new pe(ct.paint_fill["fill-color"]),"fill-outline-color":new pe(ct.paint_fill["fill-outline-color"]),"fill-translate":new ie(ct.paint_fill["fill-translate"]),"fill-translate-anchor":new ie(ct.paint_fill["fill-translate-anchor"]),"fill-pattern":new pe(ct.paint_fill["fill-pattern"])}),layout:LA};const DA=$e([{name:"a_pos_normal_ed",components:4,type:"Int16"}]),zA=$e([{name:"a_centroid_pos",components:2,type:"Uint16"}]),kA=$e([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]),{members:OA}=DA;var qm={},FA=Ae,z1=Wd;function Wd(r,t,s,l,h){this.properties={},this.extent=s,this.type=0,this._pbf=r,this._geometry=-1,this._keys=l,this._values=h,r.readFields(BA,this,t)}function BA(r,t,s){r==1?t.id=s.readVarint():r==2?function(l,h){for(var g=l.readVarint()+l.pos;l.pos<g;){var v=h._keys[l.readVarint()],S=h._values[l.readVarint()];h.properties[v]=S}}(s,t):r==3?t.type=s.readVarint():r==4&&(t._geometry=s.pos)}function NA(r){for(var t,s,l=0,h=0,g=r.length,v=g-1;h<g;v=h++)l+=((s=r[v]).x-(t=r[h]).x)*(t.y+s.y);return l}Wd.types=["Unknown","Point","LineString","Polygon"],Wd.prototype.loadGeometry=function(){var r=this._pbf;r.pos=this._geometry;for(var t,s=r.readVarint()+r.pos,l=1,h=0,g=0,v=0,S=[];r.pos<s;){if(h<=0){var A=r.readVarint();l=7&A,h=A>>3}if(h--,l===1||l===2)g+=r.readSVarint(),v+=r.readSVarint(),l===1&&(t&&S.push(t),t=[]),t.push(new FA(g,v));else{if(l!==7)throw new Error("unknown command "+l);t&&t.push(t[0].clone())}}return t&&S.push(t),S},Wd.prototype.bbox=function(){var r=this._pbf;r.pos=this._geometry;for(var t=r.readVarint()+r.pos,s=1,l=0,h=0,g=0,v=1/0,S=-1/0,A=1/0,P=-1/0;r.pos<t;){if(l<=0){var U=r.readVarint();s=7&U,l=U>>3}if(l--,s===1||s===2)(h+=r.readSVarint())<v&&(v=h),h>S&&(S=h),(g+=r.readSVarint())<A&&(A=g),g>P&&(P=g);else if(s!==7)throw new Error("unknown command "+s)}return[v,A,S,P]},Wd.prototype.toGeoJSON=function(r,t,s){var l,h,g=this.extent*Math.pow(2,s),v=this.extent*r,S=this.extent*t,A=this.loadGeometry(),P=Wd.types[this.type];function U($){for(var J=0;J<$.length;J++){var re=$[J];$[J]=[360*(re.x+v)/g-180,360/Math.PI*Math.atan(Math.exp((180-360*(re.y+S)/g)*Math.PI/180))-90]}}switch(this.type){case 1:var G=[];for(l=0;l<A.length;l++)G[l]=A[l][0];U(A=G);break;case 2:for(l=0;l<A.length;l++)U(A[l]);break;case 3:for(A=function($){var J=$.length;if(J<=1)return[$];for(var re,de,we=[],ze=0;ze<J;ze++){var Se=NA($[ze]);Se!==0&&(de===void 0&&(de=Se<0),de===Se<0?(re&&we.push(re),re=[$[ze]]):re.push($[ze]))}return re&&we.push(re),we}(A),l=0;l<A.length;l++)for(h=0;h<A[l].length;h++)U(A[l][h])}A.length===1?A=A[0]:P="Multi"+P;var j={type:"Feature",geometry:{type:P,coordinates:A},properties:this.properties};return"id"in this&&(j.id=this.id),j};var UA=z1,k1=O1;function O1(r,t){this.version=1,this.name=null,this.extent=4096,this.length=0,this._pbf=r,this._keys=[],this._values=[],this._features=[],r.readFields(VA,this,t),this.length=this._features.length}function VA(r,t,s){r===15?t.version=s.readVarint():r===1?t.name=s.readString():r===5?t.extent=s.readVarint():r===2?t._features.push(s.pos):r===3?t._keys.push(s.readString()):r===4&&t._values.push(function(l){for(var h=null,g=l.readVarint()+l.pos;l.pos<g;){var v=l.readVarint()>>3;h=v===1?l.readString():v===2?l.readFloat():v===3?l.readDouble():v===4?l.readVarint64():v===5?l.readVarint():v===6?l.readSVarint():v===7?l.readBoolean():null}return h}(s))}O1.prototype.feature=function(r){if(r<0||r>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[r];var t=this._pbf.readVarint()+this._pbf.pos;return new UA(this._pbf,t,this.extent,this._keys,this._values)};var GA=k1;function jA(r,t,s){if(r===3){var l=new GA(s,s.readVarint()+s.pos);l.length&&(t[l.name]=l)}}var Py=qm.VectorTile=function(r,t){this.layers=r.readFields(jA,{},t)},Zm=qm.VectorTileFeature=z1;function Xm(r,t,s,l){const h=[],g=l===0?(v,S,A,P,U,G)=>{v.push(new ce(G,A+(G-S)/(P-S)*(U-A)))}:(v,S,A,P,U,G)=>{v.push(new ce(S+(G-A)/(U-A)*(P-S),G))};for(const v of r){const S=[];for(const A of v){if(A.length<=2)continue;const P=[];for(let j=0;j<A.length-1;j++){const $=A[j].x,J=A[j].y,re=A[j+1].x,de=A[j+1].y,we=l===0?$:J,ze=l===0?re:de;we<t?ze>t&&g(P,$,J,re,de,t):we>s?ze<s&&g(P,$,J,re,de,s):P.push(A[j]),ze<t&&we>=t&&g(P,$,J,re,de,t),ze>s&&we<=s&&g(P,$,J,re,de,s)}let U=A[A.length-1];const G=l===0?U.x:U.y;G>=t&&G<=s&&P.push(U),P.length&&(U=P[P.length-1],P[0].x===U.x&&P[0].y===U.y||P.push(P[0]),S.push(P))}S.length&&h.push(S)}return h}qm.VectorTileLayer=k1;const WA=Zm.types,HA=Math.pow(2,13);function wp(r,t,s,l,h,g,v,S){r.emplaceBack((t<<1)+v,(s<<1)+g,(Math.floor(l*HA)<<1)+h,Math.round(S))}function Sp(r,t,s){r.emplaceBack(t.x,t.y,t.z,s[0]*16384,s[1]*16384,s[2]*16384)}class F1{constructor(){this.acc=new ce(0,0),this.polyCount=[]}startRing(t){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new ce(t.x,t.y),this.max=new ce(t.x,t.y))}append(t,s){this.currentPolyCount.edges++,this.acc._add(t);const l=this.min,h=this.max;t.x<l.x?l.x=t.x:t.x>h.x&&(h.x=t.x),t.y<l.y?l.y=t.y:t.y>h.y&&(h.y=t.y),((t.x===0||t.x===Zn)&&t.x===s.x)!=((t.y===0||t.y===Zn)&&t.y===s.y)&&this.processBorderOverlap(t,s),s.x<0!=t.x<0&&this.addBorderIntersection(0,gi(s.y,t.y,(0-s.x)/(t.x-s.x))),s.x>Zn!=t.x>Zn&&this.addBorderIntersection(1,gi(s.y,t.y,(Zn-s.x)/(t.x-s.x))),s.y<0!=t.y<0&&this.addBorderIntersection(2,gi(s.x,t.x,(0-s.y)/(t.y-s.y))),s.y>Zn!=t.y>Zn&&this.addBorderIntersection(3,gi(s.x,t.x,(Zn-s.y)/(t.y-s.y)))}addBorderIntersection(t,s){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const l=this.borders[t];s<l[0]&&(l[0]=s),s>l[1]&&(l[1]=s)}processBorderOverlap(t,s){if(t.x===s.x){if(t.y===s.y)return;const l=t.x===0?0:1;this.addBorderIntersection(l,s.y),this.addBorderIntersection(l,t.y)}else{const l=t.y===0?2:3;this.addBorderIntersection(l,s.x),this.addBorderIntersection(l,t.x)}}centroid(){const t=this.polyCount.reduce((s,l)=>s+l.edges,0);return t!==0?this.acc.div(t)._round():new ce(0,0)}span(){return new ce(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce((t,s)=>t+ +(s[0]!==Number.MAX_VALUE),0)}}class Mp{constructor(t){this.zoom=t.zoom,this.canonical=t.canonical,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(s=>s.id),this.index=t.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=t.projection,this.layoutVertexArray=new Bt,this.centroidVertexArray=new Xr,this.indexArray=new Gn,this.programConfigurations=new Ac(t.layers,t.zoom),this.segments=new jr,this.stateDependentLayerIds=this.layers.filter(s=>s.isStateDependent()).map(s=>s.id),this.enableTerrain=t.enableTerrain}populate(t,s,l,h){this.features=[],this.hasPattern=Cy("fill-extrusion",this.layers,s),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=function(g){const v=Math.exp(Math.PI*(1-g.y/(1<<g.z)*2));return 80150034*v/(v*v+1)/Zn/(1<<g.z)}(l),this.edgeRadius=this.layers[0].layout.get("fill-extrusion-edge-radius")/this.tileToMeter;for(const{feature:g,id:v,index:S,sourceLayerIndex:A}of t){const P=this.layers[0]._featureFilter.needGeometry,U=Ah(g,P);if(!this.layers[0]._featureFilter.filter(new V(this.zoom),U,l))continue;const G={id:v,sourceLayerIndex:A,index:S,geometry:P?U.geometry:au(g,l,h),properties:g.properties,type:g.type,patterns:{}},j=this.layoutVertexArray.length;this.hasPattern?this.features.push(Iy("fill-extrusion",this.layers,G,this.zoom,s)):this.addFeature(G,G.geometry,S,l,{},s.availableImages,h),s.featureIndex.insert(g,G.geometry,S,A,this.index,j)}this.sortBorders()}addFeatures(t,s,l,h,g){for(const v of this.features){const{geometry:S}=v;this.addFeature(v,S,v.index,s,l,h,g)}this.sortBorders()}update(t,s,l,h){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,s,this.stateDependentLayers,l,h)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,OA),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=t.createVertexBuffer(this.layoutVertexExtArray,kA.members,!0))),this.programConfigurations.upload(t),this.uploaded=!0}uploadCentroid(t){this.centroidVertexArray.length!==0&&(this.centroidVertexBuffer?this.needsCentroidUpdate&&this.centroidVertexBuffer.updateData(this.centroidVertexArray):this.centroidVertexBuffer=t.createVertexBuffer(this.centroidVertexArray,zA.members,!0),this.needsCentroidUpdate=!1)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.centroidVertexBuffer&&this.centroidVertexBuffer.destroy(),this.layoutVertexExtBuffer&&this.layoutVertexExtBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(t,s,l,h,g,v,S){const A=[new ce(0,0),new ce(Zn,Zn)],P=S.projection,U=P.name==="globe",G=this.enableTerrain&&!U?new F1:null,j=WA[t.type]==="Polygon";U&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new Qt);const $=Ay(s,500);for(let we=$.length-1;we>=0;we--){const ze=$[we];(ze.length===0||(J=ze[0]).every(Se=>Se.x<=0)||J.every(Se=>Se.x>=Zn)||J.every(Se=>Se.y<=0)||J.every(Se=>Se.y>=Zn))&&$.splice(we,1)}var J;let re;if(U)re=W1($,A,h);else{re=[];for(const we of $)re.push({polygon:we,bounds:A})}const de=j?this.edgeRadius:0;for(const{polygon:we,bounds:ze}of re){let Se=0,Le=0;for(const Be of we)j&&!Be[0].equals(Be[Be.length-1])&&Be.push(Be[0]),Le+=j?Be.length-1:Be.length;const Ne=this.segments.prepareSegment((j?5:4)*Le,this.layoutVertexArray,this.indexArray);if(j){const Be=[],_t=[];Se=Ne.vertexLength;for(const Ft of we){let nn,vt;Ft.length&&Ft!==we[0]&&_t.push(Be.length/2),nn=Ft[1].sub(Ft[0])._perp()._unit();for(let Wt=1;Wt<Ft.length;Wt++){const Ht=Ft[Wt],$t=Ft[Wt===Ft.length-1?1:Wt+1];let{x:sn,y:Rt}=Ht;if(de){vt=$t.sub(Ht)._perp()._unit();const In=nn.add(vt)._unit(),Nn=de*Math.min(4,1/(nn.x*In.x+nn.y*In.y));sn+=Nn*In.x,Rt+=Nn*In.y,nn=vt}wp(this.layoutVertexArray,sn,Rt,0,0,1,1,0),Ne.vertexLength++,Be.push(Ht.x,Ht.y),U&&Sp(this.layoutVertexExtArray,P.projectTilePoint(sn,Rt,h),P.upVector(h,sn,Rt))}}const dt=Ty(Be,_t);for(let Ft=0;Ft<dt.length;Ft+=3)this.indexArray.emplaceBack(Se+dt[Ft],Se+dt[Ft+2],Se+dt[Ft+1]),Ne.primitiveLength++}for(const Be of we){G&&Be.length&&G.startRing(Be[0]);let _t,dt,Ft,nn=Be.length>4&&V1(Be[Be.length-2],Be[0],Be[1]),vt=de?qA(Be[Be.length-2],Be[0],Be[1],de):0;dt=Be[1].sub(Be[0])._perp()._unit();let Wt=!0;for(let Ht=1,$t=0;Ht<Be.length;Ht++){let sn=Be[Ht-1],Rt=Be[Ht];const In=Be[Ht===Be.length-1?1:Ht+1];if(G&&j&&G.currentPolyCount.top++,U1(Rt,sn,ze)){de&&(dt=In.sub(Rt)._perp()._unit(),Wt=!Wt);continue}G&&G.append(Rt,sn);const Nn=Rt.sub(sn)._perp(),Rn=Nn.x/(Math.abs(Nn.x)+Math.abs(Nn.y)),Ii=Nn.y>0?1:0,an=sn.dist(Rt);if($t+an>32768&&($t=0),de){Ft=In.sub(Rt)._perp()._unit();let Li=N1(sn,Rt,In,B1(dt,Ft),de);isNaN(Li)&&(Li=0);const pi=Rt.sub(sn)._unit();sn=sn.add(pi.mult(vt))._round(),Rt=Rt.add(pi.mult(-Li))._round(),vt=Li,dt=Ft}const ii=Ne.vertexLength,Pi=Be.length>4&&V1(sn,Rt,In);let lr=G1($t,nn,Wt);if(wp(this.layoutVertexArray,sn.x,sn.y,Rn,Ii,0,0,lr),wp(this.layoutVertexArray,sn.x,sn.y,Rn,Ii,0,1,lr),$t+=an,lr=G1($t,Pi,!Wt),nn=Pi,wp(this.layoutVertexArray,Rt.x,Rt.y,Rn,Ii,0,0,lr),wp(this.layoutVertexArray,Rt.x,Rt.y,Rn,Ii,0,1,lr),Ne.vertexLength+=4,this.indexArray.emplaceBack(ii+0,ii+1,ii+2),this.indexArray.emplaceBack(ii+1,ii+3,ii+2),Ne.primitiveLength+=2,de){const Li=Se+(Ht===1?Be.length-2:Ht-2),pi=Ht===1?Se:Li+1;if(this.indexArray.emplaceBack(ii+1,Li,ii+3),this.indexArray.emplaceBack(Li,pi,ii+3),Ne.primitiveLength+=2,_t===void 0&&(_t=ii),!U1(In,Be[Ht],ze)){const Nr=Ht===Be.length-1?_t:Ne.vertexLength;this.indexArray.emplaceBack(ii+2,ii+3,Nr),this.indexArray.emplaceBack(ii+3,Nr+1,Nr),this.indexArray.emplaceBack(ii+3,pi,Nr+1),Ne.primitiveLength+=3}Wt=!Wt}if(U){const Li=this.layoutVertexExtArray,pi=P.projectTilePoint(sn.x,sn.y,h),Nr=P.projectTilePoint(Rt.x,Rt.y,h),Di=P.upVector(h,sn.x,sn.y),zi=P.upVector(h,Rt.x,Rt.y);Sp(Li,pi,Di),Sp(Li,pi,Di),Sp(Li,Nr,zi),Sp(Li,Nr,zi)}}j&&(Se+=Be.length-1)}}if(G&&G.polyCount.length>0){if(G.borders){G.vertexArrayOffset=this.centroidVertexArray.length;const we=G.borders,ze=this.featuresOnBorder.push(G)-1;for(let Se=0;Se<4;Se++)we[Se][0]!==Number.MAX_VALUE&&this.borders[Se].push(ze)}this.encodeCentroid(G.borders?void 0:G.centroid(),G)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,l,g,v,h)}sortBorders(){for(let t=0;t<4;t++)this.borders[t].sort((s,l)=>this.featuresOnBorder[s].borders[t][0]-this.featuresOnBorder[l].borders[t][0])}encodeCentroid(t,s,l=!0){let h,g;if(t)if(t.y!==0){const S=s.span()._mult(this.tileToMeter);h=(Math.max(t.x,1)<<3)+Math.min(7,Math.round(S.x/10)),g=(Math.max(t.y,1)<<3)+Math.min(7,Math.round(S.y/10))}else h=Math.ceil(7*(t.x+450)),g=0;else h=0,g=+l;let v=l?this.centroidVertexArray.length:s.vertexArrayOffset;for(const S of s.polyCount){l&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*S.edges+S.top);for(let A=0;A<S.top;A++)this.centroidVertexArray.emplace(v++,h,g);for(let A=0;A<2*S.edges;A++)this.centroidVertexArray.emplace(v++,0,g),this.centroidVertexArray.emplace(v++,h,g)}}}function B1(r,t){const s=r.add(t)._unit();return r.x*s.x+r.y*s.y}function qA(r,t,s,l){const h=t.sub(r)._perp()._unit(),g=s.sub(t)._perp()._unit();return N1(r,t,s,B1(h,g),l)}function N1(r,t,s,l,h){const g=Math.sqrt(1-l*l);return Math.min(r.dist(t)/3,t.dist(s)/3,h*g/l)}function U1(r,t,s){return r.x<s[0].x&&t.x<s[0].x||r.x>s[1].x&&t.x>s[1].x||r.y<s[0].y&&t.y<s[0].y||r.y>s[1].y&&t.y>s[1].y}function V1(r,t,s){if(r.x<0||r.x>=Zn||t.x<0||t.x>=Zn||s.x<0||s.x>=Zn)return!1;const l=s.sub(t),h=l.perp(),g=r.sub(t);return(l.x*g.x+l.y*g.y)/Math.sqrt((l.x*l.x+l.y*l.y)*(g.x*g.x+g.y*g.y))>-.866&&h.x*g.x+h.y*g.y<0}function G1(r,t,s){const l=t?2|r:-3&r;return s?1|l:-2&l}function j1(){const r=Math.PI/32,t=Math.tan(r),s=_p;return s*Math.sqrt(1+2*t*t)-s}function W1(r,t,s){const l=1<<s.z,h=ll(s.x/l),g=ll((s.x+1)/l),v=Fo(s.y/l),S=Fo((s.y+1)/l);return function(A,P,U,G,j=0,$){const J=[];if(!A.length||!U||!G)return J;const re=(Be,_t)=>{for(const dt of Be)J.push({polygon:dt,bounds:_t})},de=Math.ceil(Math.log2(U)),we=Math.ceil(Math.log2(G)),ze=de-we,Se=[];for(let Be=0;Be<Math.abs(ze);Be++)Se.push(ze>0?0:1);for(let Be=0;Be<Math.min(de,we);Be++)Se.push(0),Se.push(1);let Le=A;if(Le=Xm(Le,P[0].y-j,P[1].y+j,1),Le=Xm(Le,P[0].x-j,P[1].x+j,0),!Le.length)return J;const Ne=[];for(Se.length?Ne.push({polygons:Le,bounds:P,depth:0}):re(Le,P);Ne.length;){const Be=Ne.pop(),_t=Be.depth,dt=Se[_t],Ft=Be.bounds[0],nn=Be.bounds[1],vt=dt===0?Ft.x:Ft.y,Wt=dt===0?nn.x:nn.y,Ht=$?$(dt,vt,Wt):.5*(vt+Wt),$t=Xm(Be.polygons,vt-j,Ht+j,dt),sn=Xm(Be.polygons,Ht-j,Wt+j,dt);if($t.length){const Rt=[Ft,new ce(dt===0?Ht:nn.x,dt===1?Ht:nn.y)];Se.length>_t+1?Ne.push({polygons:$t,bounds:Rt,depth:_t+1}):re($t,Rt)}if(sn.length){const Rt=[new ce(dt===0?Ht:Ft.x,dt===1?Ht:Ft.y),nn];Se.length>_t+1?Ne.push({polygons:sn,bounds:Rt,depth:_t+1}):re(sn,Rt)}}return J}(r,t,Math.ceil((g-h)/11.25),Math.ceil((v-S)/11.25),1,(A,P,U)=>{if(A===0)return .5*(P+U);{const G=Fo((s.y+P/Zn)/l);return(Dc(.5*(Fo((s.y+U/Zn)/l)+G))*l-s.y)*Zn}})}kn(Mp,"FillExtrusionBucket",{omit:["layers","features"]}),kn(F1,"PartMetadata");const ZA=new Te({"fill-extrusion-edge-radius":new ie(ct["layout_fill-extrusion"]["fill-extrusion-edge-radius"])});var XA={paint:new Te({"fill-extrusion-opacity":new ie(ct["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new pe(ct["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new ie(ct["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new ie(ct["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new pe(ct["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new pe(ct["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new pe(ct["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new ie(ct["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"]),"fill-extrusion-ambient-occlusion-intensity":new ie(ct["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-intensity"]),"fill-extrusion-ambient-occlusion-radius":new ie(ct["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-radius"]),"fill-extrusion-rounded-roof":new ie(ct["paint_fill-extrusion"]["fill-extrusion-rounded-roof"])}),layout:ZA};function H1(r,t,s){var l=2*Math.PI*6378137/256/Math.pow(2,s);return[r*l-2*Math.PI*6378137/2,t*l-2*Math.PI*6378137/2]}class $m{constructor(t,s,l){this.z=t,this.x=s,this.y=l,this.key=Ep(0,t,t,s,l)}equals(t){return this.z===t.z&&this.x===t.x&&this.y===t.y}url(t,s){const l=function(g,v,S){var A=H1(256*g,256*(v=Math.pow(2,S)-v-1),S),P=H1(256*(g+1),256*(v+1),S);return A[0]+","+A[1]+","+P[0]+","+P[1]}(this.x,this.y,this.z),h=function(g,v,S){let A,P="";for(let U=g;U>0;U--)A=1<<U-1,P+=(v&A?1:0)+(S&A?2:0);return P}(this.z,this.x,this.y);return t[(this.x+this.y)%t.length].replace("{prefix}",(this.x%16).toString(16)+(this.y%16).toString(16)).replace(/{z}/g,String(this.z)).replace(/{x}/g,String(this.x)).replace(/{y}/g,String(s==="tms"?Math.pow(2,this.z)-this.y-1:this.y)).replace("{quadkey}",h).replace("{bbox-epsg-3857}",l)}toString(){return`${this.z}/${this.x}/${this.y}`}}class q1{constructor(t,s){this.wrap=t,this.canonical=s,this.key=Ep(t,s.z,s.z,s.x,s.y)}}class aa{constructor(t,s,l,h,g){this.overscaledZ=t,this.wrap=s,this.canonical=new $m(l,+h,+g),this.key=s===0&&t===l?this.canonical.key:Ep(s,t,l,h,g)}equals(t){return this.overscaledZ===t.overscaledZ&&this.wrap===t.wrap&&this.canonical.equals(t.canonical)}scaledTo(t){const s=this.canonical.z-t;return t>this.canonical.z?new aa(t,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new aa(t,this.wrap,t,this.canonical.x>>s,this.canonical.y>>s)}calculateScaledKey(t,s=!0){if(this.overscaledZ===t&&s)return this.key;if(t>this.canonical.z)return Ep(this.wrap*+s,t,this.canonical.z,this.canonical.x,this.canonical.y);{const l=this.canonical.z-t;return Ep(this.wrap*+s,t,t,this.canonical.x>>l,this.canonical.y>>l)}}isChildOf(t){if(t.wrap!==this.wrap)return!1;const s=this.canonical.z-t.canonical.z;return t.overscaledZ===0||t.overscaledZ<this.overscaledZ&&t.canonical.x===this.canonical.x>>s&&t.canonical.y===this.canonical.y>>s}children(t){if(this.overscaledZ>=t)return[new aa(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const s=this.canonical.z+1,l=2*this.canonical.x,h=2*this.canonical.y;return[new aa(s,this.wrap,s,l,h),new aa(s,this.wrap,s,l+1,h),new aa(s,this.wrap,s,l,h+1),new aa(s,this.wrap,s,l+1,h+1)]}isLessThan(t){return this.wrap<t.wrap||!(this.wrap>t.wrap)&&(this.overscaledZ<t.overscaledZ||!(this.overscaledZ>t.overscaledZ)&&(this.canonical.x<t.canonical.x||!(this.canonical.x>t.canonical.x)&&this.canonical.y<t.canonical.y))}wrapped(){return new aa(this.overscaledZ,0,this.canonical.z,this.canonical.x,this.canonical.y)}unwrapTo(t){return new aa(this.overscaledZ,t,this.canonical.z,this.canonical.x,this.canonical.y)}overscaleFactor(){return Math.pow(2,this.overscaledZ-this.canonical.z)}toUnwrapped(){return new q1(this.wrap,this.canonical)}toString(){return`${this.overscaledZ}/${this.canonical.x}/${this.canonical.y}`}}function Ep(r,t,s,l,h){const g=1<<Math.min(s,22);let v=g*(h%g)+l%g;return r&&s<22&&(v+=g*g*((r<0?-2*r-1:2*r)%(1<<2*(22-s)))),16*(32*v+s)+(t-s)}kn($m,"CanonicalTileID"),kn(aa,"OverscaledTileID",{omit:["projMatrix"]});class Hd extends ce{constructor(t,s,l){super(t,s),this.z=l}}function Tp(r,t){return r.x*t.x+r.y*t.y}function Z1(r,t){if(r.length===1){let s=0;const l=t[s++];let h;for(;!h||l.equals(h);)if(h=t[s++],!h)return 1/0;for(;s<t.length;s++){const g=t[s],v=r[0],S=h.sub(l),A=g.sub(l),P=v.sub(l),U=Tp(S,S),G=Tp(S,A),j=Tp(A,A),$=Tp(P,S),J=Tp(P,A),re=U*j-G*G,de=(j*$-G*J)/re,we=(U*J-G*$)/re,ze=l.z*(1-de-we)+h.z*de+g.z*we;if(isFinite(ze))return ze}return 1/0}{let s=1/0;for(const l of t)s=Math.min(s,l.z);return s}}function X1(r,t,s,l,h,g,v,S){const A=v*h.getElevationAt(r,t,!0,!0),P=g[0]!==0,U=P?g[1]===0?v*(g[0]/7-450):v*function(G,j,$){const J=Math.floor(j[0]/8),re=Math.floor(j[1]/8),de=10*(j[0]-8*J),we=10*(j[1]-8*re),ze=G.getElevationAt(J,re,!0,!0),Se=G.getMeterToDEM($),Le=Math.floor(.5*(de*Se-1)),Ne=Math.floor(.5*(we*Se-1)),Be=G.tileCoordToPixel(J,re),_t=2*Le+1,dt=2*Ne+1,Ft=function(sn,Rt,In,Nn,Rn){return[sn.getElevationAtPixel(Rt,In,!0),sn.getElevationAtPixel(Rt+Rn,In,!0),sn.getElevationAtPixel(Rt,In+Rn,!0),sn.getElevationAtPixel(Rt+Nn,In+Rn,!0)]}(G,Be.x-Le,Be.y-Ne,_t,dt),nn=Math.abs(Ft[0]-Ft[1]),vt=Math.abs(Ft[2]-Ft[3]),Wt=Math.abs(Ft[0]-Ft[2])+Math.abs(Ft[1]-Ft[3]),Ht=Math.min(.25,.5*Se*(nn+vt)/_t),$t=Math.min(.25,.5*Se*Wt/dt);return ze+Math.max(Ht*de,$t*we)}(h,g,S):A;return{base:A+(s===0)?-1:s,top:P?Math.max(U+l,A+s+2):A+l}}const $A=$e([{name:"a_pos_normal",components:2,type:"Int16"},{name:"a_data",components:4,type:"Uint8"},{name:"a_linesofar",components:1,type:"Float32"}],4),{members:YA}=$A,JA=$e([{name:"a_packed",components:4,type:"Float32"}]),{members:KA}=JA,QA=Zm.types,eC=Math.cos(Math.PI/180*37.5);class Ym{constructor(t){this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(s=>s.id),this.index=t.index,this.projection=t.projection,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(s=>{this.gradients[s.id]={}}),this.layoutVertexArray=new yt,this.layoutVertexArray2=new Xt,this.indexArray=new Gn,this.programConfigurations=new Ac(t.layers,t.zoom),this.segments=new jr,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(s=>s.isStateDependent()).map(s=>s.id)}populate(t,s,l,h){this.hasPattern=Cy("line",this.layers,s);const g=this.layers[0].layout.get("line-sort-key"),v=[];for(const{feature:U,id:G,index:j,sourceLayerIndex:$}of t){const J=this.layers[0]._featureFilter.needGeometry,re=Ah(U,J);if(!this.layers[0]._featureFilter.filter(new V(this.zoom),re,l))continue;const de=g?g.evaluate(re,{},l):void 0,we={id:G,properties:U.properties,type:U.type,sourceLayerIndex:$,index:j,geometry:J?re.geometry:au(U,l,h),patterns:{},sortKey:de};v.push(we)}g&&v.sort((U,G)=>U.sortKey-G.sortKey);const{lineAtlas:S,featureIndex:A}=s,P=this.addConstantDashes(S);for(const U of v){const{geometry:G,index:j,sourceLayerIndex:$}=U;if(P&&this.addFeatureDashes(U,S),this.hasPattern){const J=Iy("line",this.layers,U,this.zoom,s);this.patternFeatures.push(J)}else this.addFeature(U,G,j,l,S.positions,s.availableImages);A.insert(t[j].feature,G,j,$,this.index)}}addConstantDashes(t){let s=!1;for(const l of this.layers){const h=l.paint.get("line-dasharray").value,g=l.layout.get("line-cap").value;if(h.kind!=="constant"||g.kind!=="constant")s=!0;else{const v=g.value,S=h.value;if(!S)continue;t.addDash(S,v)}}return s}addFeatureDashes(t,s){const l=this.zoom;for(const h of this.layers){const g=h.paint.get("line-dasharray").value,v=h.layout.get("line-cap").value;if(g.kind==="constant"&&v.kind==="constant")continue;let S,A;if(g.kind==="constant"){if(S=g.value,!S)continue}else S=g.evaluate({zoom:l},t);A=v.kind==="constant"?v.value:v.evaluate({zoom:l},t),s.addDash(S,A),t.patterns[h.id]=s.getKey(S,A)}}update(t,s,l,h){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(t,s,this.stateDependentLayers,l,h)}addFeatures(t,s,l,h,g){for(const v of this.patternFeatures)this.addFeature(v,v.geometry,v.index,s,l,h)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(t){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=t.createVertexBuffer(this.layoutVertexArray2,KA)),this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,YA),this.indexBuffer=t.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(t),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(t){if(t.properties&&t.properties.hasOwnProperty("mapbox_clip_start")&&t.properties.hasOwnProperty("mapbox_clip_end"))return{start:+t.properties.mapbox_clip_start,end:+t.properties.mapbox_clip_end}}addFeature(t,s,l,h,g,v){const S=this.layers[0].layout,A=S.get("line-join").evaluate(t,{}),P=S.get("line-cap").evaluate(t,{}),U=S.get("line-miter-limit"),G=S.get("line-round-limit");this.lineClips=this.lineFeatureClips(t);for(const j of s)this.addLine(j,t,A,P,U,G);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,t,l,g,v,h)}addLine(t,s,l,h,g,v){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let we=0;we<t.length-1;we++)this.totalDistance+=t[we].dist(t[we+1]);this.updateScaledDistance(),this.maxLineLength=Math.max(this.maxLineLength,this.totalDistance)}const S=QA[s.type]==="Polygon";let A=t.length;for(;A>=2&&t[A-1].equals(t[A-2]);)A--;let P=0;for(;P<A-1&&t[P].equals(t[P+1]);)P++;if(A<(S?3:2))return;l==="bevel"&&(g=1.05);const U=this.overscaling<=16?15*Zn/(512*this.overscaling):0,G=this.segments.prepareSegment(10*A,this.layoutVertexArray,this.indexArray);let j,$,J,re,de;this.e1=this.e2=-1,S&&(j=t[A-2],de=t[P].sub(j)._unit()._perp());for(let we=P;we<A;we++){if(J=we===A-1?S?t[P+1]:void 0:t[we+1],J&&t[we].equals(J))continue;de&&(re=de),j&&($=j),j=t[we],de=J?J.sub(j)._unit()._perp():re,re=re||de;let ze=re.add(de);ze.x===0&&ze.y===0||ze._unit();const Se=re.x*de.x+re.y*de.y,Le=ze.x*de.x+ze.y*de.y,Ne=Le!==0?1/Le:1/0,Be=2*Math.sqrt(2-2*Le),_t=Le<eC&&$&&J,dt=re.x*de.y-re.y*de.x>0;if(_t&&we>P){const vt=j.dist($);if(vt>2*U){const Wt=j.sub(j.sub($)._mult(U/vt)._round());this.updateDistance($,Wt),this.addCurrentVertex(Wt,re,0,0,G),$=Wt}}const Ft=$&&J;let nn=Ft?l:S?"butt":h;if(Ft&&nn==="round"&&(Ne<v?nn="miter":Ne<=2&&(nn="fakeround")),nn==="miter"&&Ne>g&&(nn="bevel"),nn==="bevel"&&(Ne>2&&(nn="flipbevel"),Ne<g&&(nn="miter")),$&&this.updateDistance($,j),nn==="miter")ze._mult(Ne),this.addCurrentVertex(j,ze,0,0,G);else if(nn==="flipbevel"){if(Ne>100)ze=de.mult(-1);else{const vt=Ne*re.add(de).mag()/re.sub(de).mag();ze._perp()._mult(vt*(dt?-1:1))}this.addCurrentVertex(j,ze,0,0,G),this.addCurrentVertex(j,ze.mult(-1),0,0,G)}else if(nn==="bevel"||nn==="fakeround"){const vt=-Math.sqrt(Ne*Ne-1),Wt=dt?vt:0,Ht=dt?0:vt;if($&&this.addCurrentVertex(j,re,Wt,Ht,G),nn==="fakeround"){const $t=Math.round(180*Be/Math.PI/20);for(let sn=1;sn<$t;sn++){let Rt=sn/$t;if(Rt!==.5){const Nn=Rt-.5;Rt+=Rt*Nn*(Rt-1)*((1.0904+Se*(Se*(3.55645-1.43519*Se)-3.2452))*Nn*Nn+(.848013+Se*(.215638*Se-1.06021)))}const In=de.sub(re)._mult(Rt)._add(re)._unit()._mult(dt?-1:1);this.addHalfVertex(j,In.x,In.y,!1,dt,0,G)}}J&&this.addCurrentVertex(j,de,-Wt,-Ht,G)}else if(nn==="butt")this.addCurrentVertex(j,ze,0,0,G);else if(nn==="square"){const vt=$?1:-1;$||this.addCurrentVertex(j,ze,vt,vt,G),this.addCurrentVertex(j,ze,0,0,G),$&&this.addCurrentVertex(j,ze,vt,vt,G)}else nn==="round"&&($&&(this.addCurrentVertex(j,re,0,0,G),this.addCurrentVertex(j,re,1,1,G,!0)),J&&(this.addCurrentVertex(j,de,-1,-1,G,!0),this.addCurrentVertex(j,de,0,0,G)));if(_t&&we<A-1){const vt=j.dist(J);if(vt>2*U){const Wt=j.add(J.sub(j)._mult(U/vt)._round());this.updateDistance(j,Wt),this.addCurrentVertex(Wt,de,0,0,G),j=Wt}}}}addCurrentVertex(t,s,l,h,g,v=!1){const S=s.y*h-s.x,A=-s.y-s.x*h;this.addHalfVertex(t,s.x+s.y*l,s.y-s.x*l,v,!1,l,g),this.addHalfVertex(t,S,A,v,!0,-h,g)}addHalfVertex({x:t,y:s},l,h,g,v,S,A){this.layoutVertexArray.emplaceBack((t<<1)+(g?1:0),(s<<1)+(v?1:0),Math.round(63*l)+128,Math.round(63*h)+128,1+(S===0?0:S<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineClips.start,this.lineClips.end);const P=A.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,P),A.primitiveLength++),v?this.e2=P:this.e1=P}updateScaledDistance(){if(this.lineClips){const t=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=t*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(t,s){this.distance+=t.dist(s),this.updateScaledDistance()}}kn(Ym,"LineBucket",{omit:["layers","patternFeatures"]});const tC=new Te({"line-cap":new pe(ct.layout_line["line-cap"]),"line-join":new pe(ct.layout_line["line-join"]),"line-miter-limit":new ie(ct.layout_line["line-miter-limit"]),"line-round-limit":new ie(ct.layout_line["line-round-limit"]),"line-sort-key":new pe(ct.layout_line["line-sort-key"])});var $1={paint:new Te({"line-opacity":new pe(ct.paint_line["line-opacity"]),"line-color":new pe(ct.paint_line["line-color"]),"line-translate":new ie(ct.paint_line["line-translate"]),"line-translate-anchor":new ie(ct.paint_line["line-translate-anchor"]),"line-width":new pe(ct.paint_line["line-width"]),"line-gap-width":new pe(ct.paint_line["line-gap-width"]),"line-offset":new pe(ct.paint_line["line-offset"]),"line-blur":new pe(ct.paint_line["line-blur"]),"line-dasharray":new pe(ct.paint_line["line-dasharray"]),"line-pattern":new pe(ct.paint_line["line-pattern"]),"line-gradient":new Ee(ct.paint_line["line-gradient"]),"line-trim-offset":new ie(ct.paint_line["line-trim-offset"])}),layout:tC};const Y1=new class extends pe{possiblyEvaluate(r,t){return t=new V(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,transition:t.transition}),super.possiblyEvaluate(r,t)}evaluate(r,t,s,l){return t=Pt({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(r,t,s,l)}}($1.paint.properties["line-width"].specification);function J1(r,t){return t>0?t+2*r:r}Y1.useIntegerZoom=!0;const nC=$e([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),iC=$e([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),rC=$e([{name:"a_projected_pos",components:4,type:"Float32"}],4);$e([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const sC=$e([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),oC=$e([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);$e([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Int16",name:"tileAnchorX"},{type:"Int16",name:"tileAnchorY"},{type:"Float32",name:"x1"},{type:"Float32",name:"y1"},{type:"Float32",name:"x2"},{type:"Float32",name:"y2"},{type:"Int16",name:"padding"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const K1=$e([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),aC=$e([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);$e([{name:"triangle",components:3,type:"Uint16"}]),$e([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"},{type:"Uint8",name:"flipState"}]),$e([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"}]),$e([{type:"Float32",name:"offsetX"}]),$e([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var So=24;const $l=128;function Ly(r,t){const{expression:s}=t;if(s.kind==="constant")return{kind:"constant",layoutSize:s.evaluate(new V(r+1))};if(s.kind==="source")return{kind:"source"};{const{zoomStops:l,interpolationType:h}=s;let g=0;for(;g<l.length&&l[g]<=r;)g++;g=Math.max(0,g-1);let v=g;for(;v<l.length&&l[v]<r+1;)v++;v=Math.min(l.length-1,v);const S=l[g],A=l[v];return s.kind==="composite"?{kind:"composite",minZoom:S,maxZoom:A,interpolationType:h}:{kind:"camera",minZoom:S,maxZoom:A,minSize:s.evaluate(new V(S)),maxSize:s.evaluate(new V(A)),interpolationType:h}}}function Jm(r,{uSize:t,uSizeT:s},{lowerSize:l,upperSize:h}){return r.kind==="source"?l/$l:r.kind==="composite"?gi(l/$l,h/$l,s):t}function qd(r,t){let s=0,l=0;if(r.kind==="constant")l=r.layoutSize;else if(r.kind!=="source"){const{interpolationType:h,minZoom:g,maxZoom:v}=r,S=h?Fe(ps.interpolationFactor(h,t,g,v),0,1):0;r.kind==="camera"?l=gi(r.minSize,r.maxSize,S):s=S}return{uSizeT:s,uSize:l}}var lC=Object.freeze({__proto__:null,SIZE_PACK_FACTOR:$l,evaluateSizeForFeature:Jm,evaluateSizeForZoom:qd,getSizeData:Ly});function cC(r,t,s){return r.sections.forEach(l=>{l.text=function(h,g,v){const S=g.layout.get("text-transform").evaluate(v,{});return S==="uppercase"?h=h.toLocaleUpperCase():S==="lowercase"&&(h=h.toLocaleLowerCase()),z.applyArabicShaping&&(h=z.applyArabicShaping(h)),h}(l.text,t,s)}),r}const Ap={"!":"\uFE15","#":"\uFF03",$:"\uFF04","%":"\uFF05","&":"\uFF06","(":"\uFE35",")":"\uFE36","*":"\uFF0A","+":"\uFF0B",",":"\uFE10","-":"\uFE32",".":"\u30FB","/":"\uFF0F",":":"\uFE13",";":"\uFE14","<":"\uFE3F","=":"\uFF1D",">":"\uFE40","?":"\uFE16","@":"\uFF20","[":"\uFE47","\\":"\uFF3C","]":"\uFE48","^":"\uFF3E",_:"\uFE33","`":"\uFF40","{":"\uFE37","|":"\u2015","}":"\uFE38","~":"\uFF5E","\xA2":"\uFFE0","\xA3":"\uFFE1","\xA5":"\uFFE5","\xA6":"\uFFE4","\xAC":"\uFFE2","\xAF":"\uFFE3","\u2013":"\uFE32","\u2014":"\uFE31","\u2018":"\uFE43","\u2019":"\uFE44","\u201C":"\uFE41","\u201D":"\uFE42","\u2026":"\uFE19","\u2027":"\u30FB","\u20A9":"\uFFE6","\u3001":"\uFE11","\u3002":"\uFE12","\u3008":"\uFE3F","\u3009":"\uFE40","\u300A":"\uFE3D","\u300B":"\uFE3E","\u300C":"\uFE41","\u300D":"\uFE42","\u300E":"\uFE43","\u300F":"\uFE44","\u3010":"\uFE3B","\u3011":"\uFE3C","\u3014":"\uFE39","\u3015":"\uFE3A","\u3016":"\uFE17","\u3017":"\uFE18","\uFF01":"\uFE15","\uFF08":"\uFE35","\uFF09":"\uFE36","\uFF0C":"\uFE10","\uFF0D":"\uFE32","\uFF0E":"\u30FB","\uFF1A":"\uFE13","\uFF1B":"\uFE14","\uFF1C":"\uFE3F","\uFF1E":"\uFE40","\uFF1F":"\uFE16","\uFF3B":"\uFE47","\uFF3D":"\uFE48","\uFF3F":"\uFE33","\uFF5B":"\uFE37","\uFF5C":"\u2015","\uFF5D":"\uFE38","\uFF5F":"\uFE35","\uFF60":"\uFE36","\uFF61":"\uFE12","\uFF62":"\uFE41","\uFF63":"\uFE42","\u2190":"\u2191","\u2192":"\u2193"};function uC(r){return r==="\uFE36"||r==="\uFE48"||r==="\uFE38"||r==="\uFE44"||r==="\uFE42"||r==="\uFE3E"||r==="\uFE3C"||r==="\uFE3A"||r==="\uFE18"||r==="\uFE40"||r==="\uFE10"||r==="\uFE13"||r==="\uFE14"||r==="\uFF40"||r==="\uFFE3"||r==="\uFE11"||r==="\uFE12"}function hC(r){return r==="\uFE35"||r==="\uFE47"||r==="\uFE37"||r==="\uFE43"||r==="\uFE41"||r==="\uFE3D"||r==="\uFE3B"||r==="\uFE39"||r==="\uFE17"||r==="\uFE3F"}var Q1=Lr,eb=function(r,t,s,l,h){var g,v,S=8*h-l-1,A=(1<<S)-1,P=A>>1,U=-7,G=s?h-1:0,j=s?-1:1,$=r[t+G];for(G+=j,g=$&(1<<-U)-1,$>>=-U,U+=S;U>0;g=256*g+r[t+G],G+=j,U-=8);for(v=g&(1<<-U)-1,g>>=-U,U+=l;U>0;v=256*v+r[t+G],G+=j,U-=8);if(g===0)g=1-P;else{if(g===A)return v?NaN:1/0*($?-1:1);v+=Math.pow(2,l),g-=P}return($?-1:1)*v*Math.pow(2,g-l)},tb=function(r,t,s,l,h,g){var v,S,A,P=8*g-h-1,U=(1<<P)-1,G=U>>1,j=h===23?Math.pow(2,-24)-Math.pow(2,-77):0,$=l?0:g-1,J=l?1:-1,re=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(S=isNaN(t)?1:0,v=U):(v=Math.floor(Math.log(t)/Math.LN2),t*(A=Math.pow(2,-v))<1&&(v--,A*=2),(t+=v+G>=1?j/A:j*Math.pow(2,1-G))*A>=2&&(v++,A/=2),v+G>=U?(S=0,v=U):v+G>=1?(S=(t*A-1)*Math.pow(2,h),v+=G):(S=t*Math.pow(2,G-1)*Math.pow(2,h),v=0));h>=8;r[s+$]=255&S,$+=J,S/=256,h-=8);for(v=v<<h|S,P+=h;P>0;r[s+$]=255&v,$+=J,v/=256,P-=8);r[s+$-J]|=128*re};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */function Lr(r){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(r)?r:new Uint8Array(r||0),this.pos=0,this.type=0,this.length=this.buf.length}Lr.Varint=0,Lr.Fixed64=1,Lr.Bytes=2,Lr.Fixed32=5;var Ry=4294967296,nb=1/Ry,ib=typeof TextDecoder>"u"?null:new TextDecoder("utf8");function cu(r){return r.type===Lr.Bytes?r.readVarint()+r.pos:r.pos+1}function Zd(r,t,s){return s?4294967296*t+(r>>>0):4294967296*(t>>>0)+(r>>>0)}function rb(r,t,s){var l=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));s.realloc(l);for(var h=s.pos-1;h>=r;h--)s.buf[h+l]=s.buf[h]}function dC(r,t){for(var s=0;s<r.length;s++)t.writeVarint(r[s])}function fC(r,t){for(var s=0;s<r.length;s++)t.writeSVarint(r[s])}function pC(r,t){for(var s=0;s<r.length;s++)t.writeFloat(r[s])}function mC(r,t){for(var s=0;s<r.length;s++)t.writeDouble(r[s])}function gC(r,t){for(var s=0;s<r.length;s++)t.writeBoolean(r[s])}function _C(r,t){for(var s=0;s<r.length;s++)t.writeFixed32(r[s])}function yC(r,t){for(var s=0;s<r.length;s++)t.writeSFixed32(r[s])}function xC(r,t){for(var s=0;s<r.length;s++)t.writeFixed64(r[s])}function vC(r,t){for(var s=0;s<r.length;s++)t.writeSFixed64(r[s])}function Km(r,t){return(r[t]|r[t+1]<<8|r[t+2]<<16)+16777216*r[t+3]}function Xd(r,t,s){r[s]=t,r[s+1]=t>>>8,r[s+2]=t>>>16,r[s+3]=t>>>24}function sb(r,t){return(r[t]|r[t+1]<<8|r[t+2]<<16)+(r[t+3]<<24)}Lr.prototype={destroy:function(){this.buf=null},readFields:function(r,t,s){for(s=s||this.length;this.pos<s;){var l=this.readVarint(),h=l>>3,g=this.pos;this.type=7&l,r(h,t,this),this.pos===g&&this.skip(l)}return t},readMessage:function(r,t){return this.readFields(r,t,this.readVarint()+this.pos)},readFixed32:function(){var r=Km(this.buf,this.pos);return this.pos+=4,r},readSFixed32:function(){var r=sb(this.buf,this.pos);return this.pos+=4,r},readFixed64:function(){var r=Km(this.buf,this.pos)+Km(this.buf,this.pos+4)*Ry;return this.pos+=8,r},readSFixed64:function(){var r=Km(this.buf,this.pos)+sb(this.buf,this.pos+4)*Ry;return this.pos+=8,r},readFloat:function(){var r=eb(this.buf,this.pos,!0,23,4);return this.pos+=4,r},readDouble:function(){var r=eb(this.buf,this.pos,!0,52,8);return this.pos+=8,r},readVarint:function(r){var t,s,l=this.buf;return t=127&(s=l[this.pos++]),s<128?t:(t|=(127&(s=l[this.pos++]))<<7,s<128?t:(t|=(127&(s=l[this.pos++]))<<14,s<128?t:(t|=(127&(s=l[this.pos++]))<<21,s<128?t:function(h,g,v){var S,A,P=v.buf;if(S=(112&(A=P[v.pos++]))>>4,A<128||(S|=(127&(A=P[v.pos++]))<<3,A<128)||(S|=(127&(A=P[v.pos++]))<<10,A<128)||(S|=(127&(A=P[v.pos++]))<<17,A<128)||(S|=(127&(A=P[v.pos++]))<<24,A<128)||(S|=(1&(A=P[v.pos++]))<<31,A<128))return Zd(h,S,g);throw new Error("Expected varint not more than 10 bytes")}(t|=(15&(s=l[this.pos]))<<28,r,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var r=this.readVarint();return r%2==1?(r+1)/-2:r/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var r=this.readVarint()+this.pos,t=this.pos;return this.pos=r,r-t>=12&&ib?function(s,l,h){return ib.decode(s.subarray(l,h))}(this.buf,t,r):function(s,l,h){for(var g="",v=l;v<h;){var S,A,P,U=s[v],G=null,j=U>239?4:U>223?3:U>191?2:1;if(v+j>h)break;j===1?U<128&&(G=U):j===2?(192&(S=s[v+1]))==128&&(G=(31&U)<<6|63&S)<=127&&(G=null):j===3?(A=s[v+2],(192&(S=s[v+1]))==128&&(192&A)==128&&((G=(15&U)<<12|(63&S)<<6|63&A)<=2047||G>=55296&&G<=57343)&&(G=null)):j===4&&(A=s[v+2],P=s[v+3],(192&(S=s[v+1]))==128&&(192&A)==128&&(192&P)==128&&((G=(15&U)<<18|(63&S)<<12|(63&A)<<6|63&P)<=65535||G>=1114112)&&(G=null)),G===null?(G=65533,j=1):G>65535&&(G-=65536,g+=String.fromCharCode(G>>>10&1023|55296),G=56320|1023&G),g+=String.fromCharCode(G),v+=j}return g}(this.buf,t,r)},readBytes:function(){var r=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,r);return this.pos=r,t},readPackedVarint:function(r,t){if(this.type!==Lr.Bytes)return r.push(this.readVarint(t));var s=cu(this);for(r=r||[];this.pos<s;)r.push(this.readVarint(t));return r},readPackedSVarint:function(r){if(this.type!==Lr.Bytes)return r.push(this.readSVarint());var t=cu(this);for(r=r||[];this.pos<t;)r.push(this.readSVarint());return r},readPackedBoolean:function(r){if(this.type!==Lr.Bytes)return r.push(this.readBoolean());var t=cu(this);for(r=r||[];this.pos<t;)r.push(this.readBoolean());return r},readPackedFloat:function(r){if(this.type!==Lr.Bytes)return r.push(this.readFloat());var t=cu(this);for(r=r||[];this.pos<t;)r.push(this.readFloat());return r},readPackedDouble:function(r){if(this.type!==Lr.Bytes)return r.push(this.readDouble());var t=cu(this);for(r=r||[];this.pos<t;)r.push(this.readDouble());return r},readPackedFixed32:function(r){if(this.type!==Lr.Bytes)return r.push(this.readFixed32());var t=cu(this);for(r=r||[];this.pos<t;)r.push(this.readFixed32());return r},readPackedSFixed32:function(r){if(this.type!==Lr.Bytes)return r.push(this.readSFixed32());var t=cu(this);for(r=r||[];this.pos<t;)r.push(this.readSFixed32());return r},readPackedFixed64:function(r){if(this.type!==Lr.Bytes)return r.push(this.readFixed64());var t=cu(this);for(r=r||[];this.pos<t;)r.push(this.readFixed64());return r},readPackedSFixed64:function(r){if(this.type!==Lr.Bytes)return r.push(this.readSFixed64());var t=cu(this);for(r=r||[];this.pos<t;)r.push(this.readSFixed64());return r},skip:function(r){var t=7&r;if(t===Lr.Varint)for(;this.buf[this.pos++]>127;);else if(t===Lr.Bytes)this.pos=this.readVarint()+this.pos;else if(t===Lr.Fixed32)this.pos+=4;else{if(t!==Lr.Fixed64)throw new Error("Unimplemented type: "+t);this.pos+=8}},writeTag:function(r,t){this.writeVarint(r<<3|t)},realloc:function(r){for(var t=this.length||16;t<this.pos+r;)t*=2;if(t!==this.length){var s=new Uint8Array(t);s.set(this.buf),this.buf=s,this.length=t}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(r){this.realloc(4),Xd(this.buf,r,this.pos),this.pos+=4},writeSFixed32:function(r){this.realloc(4),Xd(this.buf,r,this.pos),this.pos+=4},writeFixed64:function(r){this.realloc(8),Xd(this.buf,-1&r,this.pos),Xd(this.buf,Math.floor(r*nb),this.pos+4),this.pos+=8},writeSFixed64:function(r){this.realloc(8),Xd(this.buf,-1&r,this.pos),Xd(this.buf,Math.floor(r*nb),this.pos+4),this.pos+=8},writeVarint:function(r){(r=+r||0)>268435455||r<0?function(t,s){var l,h;if(t>=0?(l=t%4294967296|0,h=t/4294967296|0):(h=~(-t/4294967296),4294967295^(l=~(-t%4294967296))?l=l+1|0:(l=0,h=h+1|0)),t>=18446744073709552e3||t<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");s.realloc(10),function(g,v,S){S.buf[S.pos++]=127&g|128,g>>>=7,S.buf[S.pos++]=127&g|128,g>>>=7,S.buf[S.pos++]=127&g|128,g>>>=7,S.buf[S.pos++]=127&g|128,S.buf[S.pos]=127&(g>>>=7)}(l,0,s),function(g,v){var S=(7&g)<<4;v.buf[v.pos++]|=S|((g>>>=3)?128:0),g&&(v.buf[v.pos++]=127&g|((g>>>=7)?128:0),g&&(v.buf[v.pos++]=127&g|((g>>>=7)?128:0),g&&(v.buf[v.pos++]=127&g|((g>>>=7)?128:0),g&&(v.buf[v.pos++]=127&g|((g>>>=7)?128:0),g&&(v.buf[v.pos++]=127&g)))))}(h,s)}(r,this):(this.realloc(4),this.buf[this.pos++]=127&r|(r>127?128:0),r<=127||(this.buf[this.pos++]=127&(r>>>=7)|(r>127?128:0),r<=127||(this.buf[this.pos++]=127&(r>>>=7)|(r>127?128:0),r<=127||(this.buf[this.pos++]=r>>>7&127))))},writeSVarint:function(r){this.writeVarint(r<0?2*-r-1:2*r)},writeBoolean:function(r){this.writeVarint(Boolean(r))},writeString:function(r){r=String(r),this.realloc(4*r.length),this.pos++;var t=this.pos;this.pos=function(l,h,g){for(var v,S,A=0;A<h.length;A++){if((v=h.charCodeAt(A))>55295&&v<57344){if(!S){v>56319||A+1===h.length?(l[g++]=239,l[g++]=191,l[g++]=189):S=v;continue}if(v<56320){l[g++]=239,l[g++]=191,l[g++]=189,S=v;continue}v=S-55296<<10|v-56320|65536,S=null}else S&&(l[g++]=239,l[g++]=191,l[g++]=189,S=null);v<128?l[g++]=v:(v<2048?l[g++]=v>>6|192:(v<65536?l[g++]=v>>12|224:(l[g++]=v>>18|240,l[g++]=v>>12&63|128),l[g++]=v>>6&63|128),l[g++]=63&v|128)}return g}(this.buf,r,this.pos);var s=this.pos-t;s>=128&&rb(t,s,this),this.pos=t-1,this.writeVarint(s),this.pos+=s},writeFloat:function(r){this.realloc(4),tb(this.buf,r,this.pos,!0,23,4),this.pos+=4},writeDouble:function(r){this.realloc(8),tb(this.buf,r,this.pos,!0,52,8),this.pos+=8},writeBytes:function(r){var t=r.length;this.writeVarint(t),this.realloc(t);for(var s=0;s<t;s++)this.buf[this.pos++]=r[s]},writeRawMessage:function(r,t){this.pos++;var s=this.pos;r(t,this);var l=this.pos-s;l>=128&&rb(s,l,this),this.pos=s-1,this.writeVarint(l),this.pos+=l},writeMessage:function(r,t,s){this.writeTag(r,Lr.Bytes),this.writeRawMessage(t,s)},writePackedVarint:function(r,t){t.length&&this.writeMessage(r,dC,t)},writePackedSVarint:function(r,t){t.length&&this.writeMessage(r,fC,t)},writePackedBoolean:function(r,t){t.length&&this.writeMessage(r,gC,t)},writePackedFloat:function(r,t){t.length&&this.writeMessage(r,pC,t)},writePackedDouble:function(r,t){t.length&&this.writeMessage(r,mC,t)},writePackedFixed32:function(r,t){t.length&&this.writeMessage(r,_C,t)},writePackedSFixed32:function(r,t){t.length&&this.writeMessage(r,yC,t)},writePackedFixed64:function(r,t){t.length&&this.writeMessage(r,xC,t)},writePackedSFixed64:function(r,t){t.length&&this.writeMessage(r,vC,t)},writeBytesField:function(r,t){this.writeTag(r,Lr.Bytes),this.writeBytes(t)},writeFixed32Field:function(r,t){this.writeTag(r,Lr.Fixed32),this.writeFixed32(t)},writeSFixed32Field:function(r,t){this.writeTag(r,Lr.Fixed32),this.writeSFixed32(t)},writeFixed64Field:function(r,t){this.writeTag(r,Lr.Fixed64),this.writeFixed64(t)},writeSFixed64Field:function(r,t){this.writeTag(r,Lr.Fixed64),this.writeSFixed64(t)},writeVarintField:function(r,t){this.writeTag(r,Lr.Varint),this.writeVarint(t)},writeSVarintField:function(r,t){this.writeTag(r,Lr.Varint),this.writeSVarint(t)},writeStringField:function(r,t){this.writeTag(r,Lr.Bytes),this.writeString(t)},writeFloatField:function(r,t){this.writeTag(r,Lr.Fixed32),this.writeFloat(t)},writeDoubleField:function(r,t){this.writeTag(r,Lr.Fixed64),this.writeDouble(t)},writeBooleanField:function(r,t){this.writeVarintField(r,Boolean(t))}};var Qm=K(Q1);const Dy=3;function bC(r,t,s){t.glyphs=[],r===1&&s.readMessage(wC,t)}function wC(r,t,s){if(r===3){const{id:l,bitmap:h,width:g,height:v,left:S,top:A,advance:P}=s.readMessage(SC,{});t.glyphs.push({id:l,bitmap:new lu({width:g+2*Dy,height:v+2*Dy},h),metrics:{width:g,height:v,left:S,top:A,advance:P}})}else r===4?t.ascender=s.readSVarint():r===5&&(t.descender=s.readSVarint())}function SC(r,t,s){r===1?t.id=s.readVarint():r===2?t.bitmap=s.readBytes():r===3?t.width=s.readVarint():r===4?t.height=s.readVarint():r===5?t.left=s.readSVarint():r===6?t.top=s.readSVarint():r===7&&(t.advance=s.readVarint())}const ob=Dy;function zy(r){let t=0,s=0;for(const v of r)t+=v.w*v.h,s=Math.max(s,v.w);r.sort((v,S)=>S.h-v.h);const l=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),s),h:1/0}];let h=0,g=0;for(const v of r)for(let S=l.length-1;S>=0;S--){const A=l[S];if(!(v.w>A.w||v.h>A.h)){if(v.x=A.x,v.y=A.y,g=Math.max(g,v.y+v.h),h=Math.max(h,v.x+v.w),v.w===A.w&&v.h===A.h){const P=l.pop();S<l.length&&(l[S]=P)}else v.h===A.h?(A.x+=v.w,A.w-=v.w):v.w===A.w?(A.y+=v.h,A.h-=v.h):(l.push({x:A.x+v.w,y:A.y,w:A.w-v.w,h:v.h}),A.y+=v.h,A.h-=v.h);break}}return{w:h,h:g,fill:t/(h*g)||0}}const Ma=1;class ky{constructor(t,{pixelRatio:s,version:l,stretchX:h,stretchY:g,content:v}){this.paddedRect=t,this.pixelRatio=s,this.stretchX=h,this.stretchY=g,this.content=v,this.version=l}get tl(){return[this.paddedRect.x+Ma,this.paddedRect.y+Ma]}get br(){return[this.paddedRect.x+this.paddedRect.w-Ma,this.paddedRect.y+this.paddedRect.h-Ma]}get displaySize(){return[(this.paddedRect.w-2*Ma)/this.pixelRatio,(this.paddedRect.h-2*Ma)/this.pixelRatio]}}class ab{constructor(t,s){const l={},h={};this.haveRenderCallbacks=[];const g=[];this.addImages(t,l,g),this.addImages(s,h,g);const{w:v,h:S}=zy(g),A=new Ya({width:v||1,height:S||1});for(const P in t){const U=t[P],G=l[P].paddedRect;Ya.copy(U.data,A,{x:0,y:0},{x:G.x+Ma,y:G.y+Ma},U.data)}for(const P in s){const U=s[P],G=h[P].paddedRect,j=G.x+Ma,$=G.y+Ma,J=U.data.width,re=U.data.height;Ya.copy(U.data,A,{x:0,y:0},{x:j,y:$},U.data),Ya.copy(U.data,A,{x:0,y:re-1},{x:j,y:$-1},{width:J,height:1}),Ya.copy(U.data,A,{x:0,y:0},{x:j,y:$+re},{width:J,height:1}),Ya.copy(U.data,A,{x:J-1,y:0},{x:j-1,y:$},{width:1,height:re}),Ya.copy(U.data,A,{x:0,y:0},{x:j+J,y:$},{width:1,height:re})}this.image=A,this.iconPositions=l,this.patternPositions=h}addImages(t,s,l){for(const h in t){const g=t[h],v={x:0,y:0,w:g.data.width+2*Ma,h:g.data.height+2*Ma};l.push(v),s[h]=new ky(v,g),g.hasRenderCallback&&this.haveRenderCallbacks.push(h)}}patchUpdatedImages(t,s){this.haveRenderCallbacks=this.haveRenderCallbacks.filter(l=>t.hasImage(l)),t.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const l in t.updatedImages)this.patchUpdatedImage(this.iconPositions[l],t.getImage(l),s),this.patchUpdatedImage(this.patternPositions[l],t.getImage(l),s)}patchUpdatedImage(t,s,l){if(!t||!s||t.version===s.version)return;t.version=s.version;const[h,g]=t.tl;l.update(s.data,void 0,{x:h,y:g})}}kn(ky,"ImagePosition"),kn(ab,"ImageAtlas");const cl={horizontal:1,vertical:2,horizontalOnly:3},lb=-17;class Cp{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(t,s){const l=new Cp;return l.scale=t||1,l.fontStack=s,l}static forImage(t){const s=new Cp;return s.imageName=t,s}}class $d{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(t,s){const l=new $d;for(let h=0;h<t.sections.length;h++){const g=t.sections[h];g.image?l.addImageSection(g):l.addTextSection(g,s)}return l}length(){return this.text.length}getSection(t){return this.sections[this.sectionIndex[t]]}getSections(){return this.sections}getSectionIndex(t){return this.sectionIndex[t]}getCharCode(t){return this.text.charCodeAt(t)}verticalizePunctuation(t){this.text=function(s,l){let h="";for(let g=0;g<s.length;g++){const v=s.charCodeAt(g+1)||null,S=s.charCodeAt(g-1)||null;h+=!l&&(v&&Rd(v)&&!Ap[s[g+1]]||S&&Rd(S)&&!Ap[s[g-1]])||!Ap[s[g]]?s[g]:Ap[s[g]]}return h}(this.text,t)}trim(){let t=0;for(let l=0;l<this.text.length&&eg[this.text.charCodeAt(l)];l++)t++;let s=this.text.length;for(let l=this.text.length-1;l>=0&&l>=t&&eg[this.text.charCodeAt(l)];l--)s--;this.text=this.text.substring(t,s),this.sectionIndex=this.sectionIndex.slice(t,s)}substring(t,s){const l=new $d;return l.text=this.text.substring(t,s),l.sectionIndex=this.sectionIndex.slice(t,s),l.sections=this.sections,l}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((t,s)=>Math.max(t,this.sections[s].scale),0)}addTextSection(t,s){this.text+=t.text,this.sections.push(Cp.forText(t.scale,t.fontStack||s));const l=this.sections.length-1;for(let h=0;h<t.text.length;++h)this.sectionIndex.push(l)}addImageSection(t){const s=t.image?t.image.name:"";if(s.length===0)return void wn("Can't add FormattedSection with an empty image.");const l=this.getNextImageSectionCharCode();l?(this.text+=String.fromCharCode(l),this.sections.push(Cp.forImage(s)),this.sectionIndex.push(this.sections.length-1)):wn("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Oy(r,t,s,l,h,g,v,S,A,P,U,G,j,$,J){const re=$d.fromFeature(r,h);G===cl.vertical&&re.verticalizePunctuation(j);let de=[];const we=function(Be,_t,dt,Ft,nn,vt){if(!Be)return[];const Wt=[],Ht=function(In,Nn,Rn,Ii,an,ii){let Pi=0;for(let lr=0;lr<In.length();lr++){const Li=In.getSection(lr);Pi+=cb(In.getCharCode(lr),Li,Ii,an,Nn,ii)}return Pi/Math.max(1,Math.ceil(Pi/Rn))}(Be,_t,dt,Ft,nn,vt),$t=Be.text.indexOf("\u200B")>=0;let sn=0;for(let In=0;In<Be.length();In++){const Nn=Be.getSection(In),Rn=Be.getCharCode(In);if(eg[Rn]||(sn+=cb(Rn,Nn,Ft,nn,_t,vt)),In<Be.length()-1){const Ii=!((Rt=Rn)<11904||!(An["Bopomofo Extended"](Rt)||An.Bopomofo(Rt)||An["CJK Compatibility Forms"](Rt)||An["CJK Compatibility Ideographs"](Rt)||An["CJK Compatibility"](Rt)||An["CJK Radicals Supplement"](Rt)||An["CJK Strokes"](Rt)||An["CJK Symbols and Punctuation"](Rt)||An["CJK Unified Ideographs Extension A"](Rt)||An["CJK Unified Ideographs"](Rt)||An["Enclosed CJK Letters and Months"](Rt)||An["Halfwidth and Fullwidth Forms"](Rt)||An.Hiragana(Rt)||An["Ideographic Description Characters"](Rt)||An["Kangxi Radicals"](Rt)||An["Katakana Phonetic Extensions"](Rt)||An.Katakana(Rt)||An["Vertical Forms"](Rt)||An["Yi Radicals"](Rt)||An["Yi Syllables"](Rt)));(MC[Rn]||Ii||Nn.imageName)&&Wt.push(hb(In+1,sn,Ht,Wt,EC(Rn,Be.getCharCode(In+1),Ii&&$t),!1))}}var Rt;return db(hb(Be.length(),sn,Ht,Wt,0,!0))}(re,P,g,t,l,$),{processBidirectionalText:ze,processStyledBidirectionalText:Se}=z;if(ze&&re.sections.length===1){const Be=ze(re.toString(),we);for(const _t of Be){const dt=new $d;dt.text=_t,dt.sections=re.sections;for(let Ft=0;Ft<_t.length;Ft++)dt.sectionIndex.push(0);de.push(dt)}}else if(Se){const Be=Se(re.text,re.sectionIndex,we);for(const _t of Be){const dt=new $d;dt.text=_t[0],dt.sectionIndex=_t[1],dt.sections=re.sections,de.push(dt)}}else de=function(Be,_t){const dt=[],Ft=Be.text;let nn=0;for(const vt of _t)dt.push(Be.substring(nn,vt)),nn=vt;return nn<Ft.length&&dt.push(Be.substring(nn,Ft.length)),dt}(re,we);const Le=[],Ne={positionedLines:Le,text:re.toString(),top:U[1],bottom:U[1],left:U[0],right:U[0],writingMode:G,iconsInText:!1,verticalizable:!1,hasBaseline:!1};return function(Be,_t,dt,Ft,nn,vt,Wt,Ht,$t,sn,Rt,In){let Nn=0,Rn=0,Ii=0;const an=Ht==="right"?1:Ht==="left"?0:.5;let ii=!1;for(const Di of nn){const zi=Di.getSections();for(const Er of zi){if(Er.imageName)continue;const Rr=_t[Er.fontStack];if(Rr&&(ii=Rr.ascender!==void 0&&Rr.descender!==void 0,!ii))break}if(!ii)break}let Pi=0;for(const Di of nn){Di.trim();const zi=Di.getMaxScale(),Er=(zi-1)*So,Rr={positionedGlyphs:[],lineOffset:0};Be.positionedLines[Pi]=Rr;const Dr=Rr.positionedGlyphs;let Tr=0;if(!Di.length()){Rn+=vt,++Pi;continue}let $r=0,is=0;for(let Ar=0;Ar<Di.length();Ar++){const Ds=Di.getSection(Ar),bs=Di.getSectionIndex(Ar),ts=Di.getCharCode(Ar);let dr=Ds.scale,ws=null,zr=null,la=null,Ss=So,Mo=0;const ao=!($t===cl.horizontal||!Rt&&!vh(ts)||Rt&&(eg[ts]||(lr=ts,An.Arabic(lr)||An["Arabic Supplement"](lr)||An["Arabic Extended-A"](lr)||An["Arabic Presentation Forms-A"](lr)||An["Arabic Presentation Forms-B"](lr))));if(Ds.imageName){const ca=Ft[Ds.imageName];if(!ca)continue;la=Ds.imageName,Be.iconsInText=Be.iconsInText||!0,zr=ca.paddedRect;const lo=ca.displaySize;dr=dr*So/In,ws={width:lo[0],height:lo[1],left:Ma,top:-ob,advance:ao?lo[1]:lo[0],localGlyph:!1},Mo=ii?-ws.height*dr:lb+zi*So-lo[1]*dr,Ss=ws.advance;const Kl=(ao?lo[0]:lo[1])*dr-So*zi;Kl>0&&Kl>Tr&&(Tr=Kl)}else{const ca=dt[Ds.fontStack];if(!ca)continue;ca[ts]&&(zr=ca[ts]);const lo=_t[Ds.fontStack];if(!lo)continue;const Kl=lo.glyphs[ts];if(!Kl)continue;if(ws=Kl.metrics,Ss=ts!==8203?So:0,ii){const nf=lo.ascender!==void 0?Math.abs(lo.ascender):0,Bp=lo.descender!==void 0?Math.abs(lo.descender):0,Np=(nf+Bp)*dr;$r<Np&&($r=Np,is=(nf-Bp)/2*dr),Mo=-nf*dr}else Mo=lb+(zi-dr)*So}ao?(Be.verticalizable=!0,Dr.push({glyph:ts,imageName:la,x:Nn,y:Rn+Mo,vertical:ao,scale:dr,localGlyph:ws.localGlyph,fontStack:Ds.fontStack,sectionIndex:bs,metrics:ws,rect:zr}),Nn+=Ss*dr+sn):(Dr.push({glyph:ts,imageName:la,x:Nn,y:Rn+Mo,vertical:ao,scale:dr,localGlyph:ws.localGlyph,fontStack:Ds.fontStack,sectionIndex:bs,metrics:ws,rect:zr}),Nn+=ws.advance*dr+sn)}Dr.length!==0&&(Ii=Math.max(Nn-sn,Ii),ii?fb(Dr,an,Tr,is,vt*zi/2):fb(Dr,an,Tr,0,vt/2)),Nn=0;const vs=vt*zi+Tr;Rr.lineOffset=Math.max(Tr,Er),Rn+=vs,++Pi}var lr;const Li=Rn,{horizontalAlign:pi,verticalAlign:Nr}=Fy(Wt);(function(Di,zi,Er,Rr,Dr,Tr){const $r=(zi-Er)*Dr,is=-Tr*Rr;for(const vs of Di)for(const Ar of vs.positionedGlyphs)Ar.x+=$r,Ar.y+=is})(Be.positionedLines,an,pi,Nr,Ii,Li),Be.top+=-Nr*Li,Be.bottom=Be.top+Li,Be.left+=-pi*Ii,Be.right=Be.left+Ii,Be.hasBaseline=ii}(Ne,t,s,l,de,v,S,A,G,P,j,J),!function(Be){for(const _t of Be)if(_t.positionedGlyphs.length!==0)return!1;return!0}(Le)&&Ne}const eg={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},MC={10:!0,32:!0,38:!0,40:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0};function cb(r,t,s,l,h,g){if(t.imageName){const v=l[t.imageName];return v?v.displaySize[0]*t.scale*So/g+h:0}{const v=s[t.fontStack],S=v&&v.glyphs[r];return S?S.metrics.advance*t.scale+h:0}}function ub(r,t,s,l){const h=Math.pow(r-t,2);return l?r<t?h/2:2*h:h+Math.abs(s)*s}function EC(r,t,s){let l=0;return r===10&&(l-=1e4),s&&(l+=150),r!==40&&r!==65288||(l+=50),t!==41&&t!==65289||(l+=50),l}function hb(r,t,s,l,h,g){let v=null,S=ub(t,s,h,g);for(const A of l){const P=ub(t-A.x,s,h,g)+A.badness;P<=S&&(v=A,S=P)}return{index:r,x:t,priorBreak:v,badness:S}}function db(r){return r?db(r.priorBreak).concat(r.index):[]}function Fy(r){let t=.5,s=.5;switch(r){case"right":case"top-right":case"bottom-right":t=1;break;case"left":case"top-left":case"bottom-left":t=0}switch(r){case"bottom":case"bottom-right":case"bottom-left":s=1;break;case"top":case"top-right":case"top-left":s=0}return{horizontalAlign:t,verticalAlign:s}}function fb(r,t,s,l,h){if(!(t||s||l||h))return;const g=r.length-1,v=r[g],S=(v.x+v.metrics.advance*v.scale)*t;for(let A=0;A<=g;A++)r[A].x-=S,r[A].y+=s+l+h}function TC(r,t,s){const{horizontalAlign:l,verticalAlign:h}=Fy(s),g=t[0]-r.displaySize[0]*l,v=t[1]-r.displaySize[1]*h;return{image:r,top:v,bottom:v+r.displaySize[1],left:g,right:g+r.displaySize[0]}}function pb(r,t,s,l,h,g){const v=r.image;let S;if(v.content){const de=v.content,we=v.pixelRatio||1;S=[de[0]/we,de[1]/we,v.displaySize[0]-de[2]/we,v.displaySize[1]-de[3]/we]}const A=t.left*g,P=t.right*g;let U,G,j,$;s==="width"||s==="both"?($=h[0]+A-l[3],G=h[0]+P+l[1]):($=h[0]+(A+P-v.displaySize[0])/2,G=$+v.displaySize[0]);const J=t.top*g,re=t.bottom*g;return s==="height"||s==="both"?(U=h[1]+J-l[0],j=h[1]+re+l[2]):(U=h[1]+(J+re-v.displaySize[1])/2,j=U+v.displaySize[1]),{image:v,top:U,right:G,bottom:j,left:$,collisionPadding:S}}class uu extends ce{constructor(t,s,l,h,g){super(t,s),this.angle=h,this.z=l,g!==void 0&&(this.segment=g)}clone(){return new uu(this.x,this.y,this.z,this.angle,this.segment)}}function mb(r,t,s,l,h){if(t.segment===void 0)return!0;let g=t,v=t.segment+1,S=0;for(;S>-s/2;){if(v--,v<0)return!1;S-=r[v].dist(g),g=r[v]}S+=r[v].dist(r[v+1]),v++;const A=[];let P=0;for(;S<s/2;){const U=r[v],G=r[v+1];if(!G)return!1;let j=r[v-1].angleTo(U)-U.angleTo(G);for(j=Math.abs((j+3*Math.PI)%(2*Math.PI)-Math.PI),A.push({distance:S,angleDelta:j}),P+=j;S-A[0].distance>l;)P-=A.shift().angleDelta;if(P>h)return!1;v++,S+=U.dist(G)}return!0}function gb(r){let t=0;for(let s=0;s<r.length-1;s++)t+=r[s].dist(r[s+1]);return t}function _b(r,t,s){return r?.6*t*s:0}function yb(r,t){return Math.max(r?r.right-r.left:0,t?t.right-t.left:0)}function AC(r,t,s,l,h,g){const v=_b(s,h,g),S=yb(s,l)*g;let A=0;const P=gb(r)/2;for(let U=0;U<r.length-1;U++){const G=r[U],j=r[U+1],$=G.dist(j);if(A+$>P){const J=(P-A)/$,re=gi(G.x,j.x,J),de=gi(G.y,j.y,J),we=new uu(re,de,0,j.angleTo(G),U);return!v||mb(r,we,S,v,t)?we:void 0}A+=$}}function CC(r,t,s,l,h,g,v,S,A){const P=_b(l,g,v),U=yb(l,h),G=U*v,j=r[0].x===0||r[0].x===A||r[0].y===0||r[0].y===A;return t-G<t/4&&(t=G+t/4),xb(r,j?t/2*S%t:(U/2+2*g)*v*S%t,t,P,s,G,j,!1,A)}function xb(r,t,s,l,h,g,v,S,A){const P=g/2,U=gb(r);let G=0,j=t-s,$=[];for(let J=0;J<r.length-1;J++){const re=r[J],de=r[J+1],we=re.dist(de),ze=de.angleTo(re);for(;j+s<G+we;){j+=s;const Se=(j-G)/we,Le=gi(re.x,de.x,Se),Ne=gi(re.y,de.y,Se);if(Le>=0&&Le<A&&Ne>=0&&Ne<A&&j-P>=0&&j+P<=U){const Be=new uu(Le,Ne,0,ze,J);Be._round(),l&&!mb(r,Be,g,l,h)||$.push(Be)}}G+=we}return S||$.length||v||($=xb(r,G/2,s,l,h,g,v,!0,A)),$}function vb(r,t,s,l,h){const g=[];for(let v=0;v<r.length;v++){const S=r[v];let A;for(let P=0;P<S.length-1;P++){let U=S[P],G=S[P+1];U.x<t&&G.x<t||(U.x<t?U=new ce(t,U.y+(t-U.x)/(G.x-U.x)*(G.y-U.y))._round():G.x<t&&(G=new ce(t,U.y+(t-U.x)/(G.x-U.x)*(G.y-U.y))._round()),U.y<s&&G.y<s||(U.y<s?U=new ce(U.x+(s-U.y)/(G.y-U.y)*(G.x-U.x),s)._round():G.y<s&&(G=new ce(U.x+(s-U.y)/(G.y-U.y)*(G.x-U.x),s)._round()),U.x>=l&&G.x>=l||(U.x>=l?U=new ce(l,U.y+(l-U.x)/(G.x-U.x)*(G.y-U.y))._round():G.x>=l&&(G=new ce(l,U.y+(l-U.x)/(G.x-U.x)*(G.y-U.y))._round()),U.y>=h&&G.y>=h||(U.y>=h?U=new ce(U.x+(h-U.y)/(G.y-U.y)*(G.x-U.x),h)._round():G.y>=h&&(G=new ce(U.x+(h-U.y)/(G.y-U.y)*(G.x-U.x),h)._round()),A&&U.equals(A[A.length-1])||(A=[U],g.push(A)),A.push(G)))))}}return g}kn(uu,"Anchor");const Ip=1e20;function bb(r,t,s,l,h,g,v,S,A){for(let P=t;P<t+l;P++)wb(r,s*g+P,g,h,v,S,A);for(let P=s;P<s+h;P++)wb(r,P*g+t,1,l,v,S,A)}function wb(r,t,s,l,h,g,v){g[0]=0,v[0]=-Ip,v[1]=Ip,h[0]=r[t];for(let S=1,A=0,P=0;S<l;S++){h[S]=r[t+S*s];const U=S*S;do{const G=g[A];P=(h[S]-h[G]+U-G*G)/(S-G)/2}while(P<=v[A]&&--A>-1);A++,g[A]=S,v[A]=P,v[A+1]=Ip}for(let S=0,A=0;S<l;S++){for(;v[A+1]<S;)A++;const P=g[A],U=S-P;r[t+S*s]=h[P]+U*U}}const Yl=2,By={none:0,ideographs:1,all:2};class Yd{constructor(t,s,l){this.requestManager=t,this.localGlyphMode=s,this.localFontFamily=l,this.entries={},this.localGlyphs={200:{},400:{},500:{},900:{}}}setURL(t){this.url=t}getGlyphs(t,s){const l=[];for(const h in t)for(const g of t[h])l.push({stack:h,id:g});Et(l,({stack:h,id:g},v)=>{let S=this.entries[h];S||(S=this.entries[h]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let A=S.glyphs[g];if(A!==void 0)return void v(null,{stack:h,id:g,glyph:A});if(A=this._tinySDF(S,h,g),A)return S.glyphs[g]=A,void v(null,{stack:h,id:g,glyph:A});const P=Math.floor(g/256);if(256*P>65535)return void v(new Error("glyphs > 65535 not supported"));if(S.ranges[P])return void v(null,{stack:h,id:g,glyph:A});let U=S.requests[P];U||(U=S.requests[P]=[],Yd.loadGlyphRange(h,P,this.url,this.requestManager,(G,j)=>{if(j){S.ascender=j.ascender,S.descender=j.descender;for(const $ in j.glyphs)this._doesCharSupportLocalGlyph(+$)||(S.glyphs[+$]=j.glyphs[+$]);S.ranges[P]=!0}for(const $ of U)$(G,j);delete S.requests[P]})),U.push((G,j)=>{G?v(G):j&&v(null,{stack:h,id:g,glyph:j.glyphs[g]||null})})},(h,g)=>{if(h)s(h);else if(g){const v={};for(const{stack:S,id:A,glyph:P}of g)v[S]===void 0&&(v[S]={}),v[S].glyphs===void 0&&(v[S].glyphs={}),v[S].glyphs[A]=P&&{id:P.id,bitmap:P.bitmap.clone(),metrics:P.metrics},v[S].ascender=this.entries[S].ascender,v[S].descender=this.entries[S].descender;s(null,v)}})}_doesCharSupportLocalGlyph(t){return this.localGlyphMode!==By.none&&(this.localGlyphMode===By.all?!!this.localFontFamily:!!this.localFontFamily&&(An["CJK Unified Ideographs"](t)||An["Hangul Syllables"](t)||An.Hiragana(t)||An.Katakana(t)||An["CJK Symbols and Punctuation"](t)))}_tinySDF(t,s,l){const h=this.localFontFamily;if(!h||!this._doesCharSupportLocalGlyph(l))return;let g=t.tinySDF;if(!g){let re="400";/bold/i.test(s)?re="900":/medium/i.test(s)?re="500":/light/i.test(s)&&(re="200"),g=t.tinySDF=new Yd.TinySDF({fontFamily:h,fontWeight:re,fontSize:24*Yl,buffer:3*Yl,radius:8*Yl}),g.fontWeight=re}if(this.localGlyphs[g.fontWeight][l])return this.localGlyphs[g.fontWeight][l];const v=String.fromCharCode(l),{data:S,width:A,height:P,glyphWidth:U,glyphHeight:G,glyphLeft:j,glyphTop:$,glyphAdvance:J}=g.draw(v);return this.localGlyphs[g.fontWeight][l]={id:l,bitmap:new lu({width:A,height:P},S),metrics:{width:U/Yl,height:G/Yl,left:j/Yl,top:$/Yl-27,advance:J/Yl,localGlyph:!0}}}}Yd.loadGlyphRange=function(r,t,s,l,h){const g=256*t,v=g+255,S=l.transformRequest(l.normalizeGlyphsURL(s).replace("{fontstack}",r).replace("{range}",`${g}-${v}`),Ze.Glyphs);bt(S,(A,P)=>{if(A)h(A);else if(P){const U={},G=function(j){return new Qm(j).readFields(bC,{})}(P);for(const j of G.glyphs)U[j.id]=j;h(null,{glyphs:U,ascender:G.ascender,descender:G.descender})}})},Yd.TinySDF=class{constructor({fontSize:r=24,buffer:t=3,radius:s=8,cutoff:l=.25,fontFamily:h="sans-serif",fontWeight:g="normal",fontStyle:v="normal"}={}){this.buffer=t,this.cutoff=l,this.radius=s;const S=this.size=r+4*t,A=this._createCanvas(S),P=this.ctx=A.getContext("2d",{willReadFrequently:!0});P.font=`${v} ${g} ${r}px ${h}`,P.textBaseline="alphabetic",P.textAlign="left",P.fillStyle="black",this.gridOuter=new Float64Array(S*S),this.gridInner=new Float64Array(S*S),this.f=new Float64Array(S),this.z=new Float64Array(S+1),this.v=new Uint16Array(S)}_createCanvas(r){const t=document.createElement("canvas");return t.width=t.height=r,t}draw(r){const{width:t,actualBoundingBoxAscent:s,actualBoundingBoxDescent:l,actualBoundingBoxLeft:h,actualBoundingBoxRight:g}=this.ctx.measureText(r),v=Math.ceil(s),S=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(g-h))),A=Math.min(this.size-this.buffer,v+Math.ceil(l)),P=S+2*this.buffer,U=A+2*this.buffer,G=Math.max(P*U,0),j=new Uint8ClampedArray(G),$={data:j,width:P,height:U,glyphWidth:S,glyphHeight:A,glyphTop:v,glyphLeft:0,glyphAdvance:t};if(S===0||A===0)return $;const{ctx:J,buffer:re,gridInner:de,gridOuter:we}=this;J.clearRect(re,re,S,A),J.fillText(r,re,re+v);const ze=J.getImageData(re,re,S,A);we.fill(Ip,0,G),de.fill(0,0,G);for(let Se=0;Se<A;Se++)for(let Le=0;Le<S;Le++){const Ne=ze.data[4*(Se*S+Le)+3]/255;if(Ne===0)continue;const Be=(Se+re)*P+Le+re;if(Ne===1)we[Be]=0,de[Be]=Ip;else{const _t=.5-Ne;we[Be]=_t>0?_t*_t:0,de[Be]=_t<0?_t*_t:0}}bb(we,0,0,P,U,P,this.f,this.v,this.z),bb(de,re,re,S,A,P,this.f,this.v,this.z);for(let Se=0;Se<G;Se++){const Le=Math.sqrt(we[Se])-Math.sqrt(de[Se]);j[Se]=Math.round(255-255*(Le/this.radius+this.cutoff))}return $}};const Jd=Ma;function Sb(r,t,s,l){const h=[],g=r.image,v=g.pixelRatio,S=g.paddedRect.w-2*Jd,A=g.paddedRect.h-2*Jd,P=r.right-r.left,U=r.bottom-r.top,G=g.stretchX||[[0,S]],j=g.stretchY||[[0,A]],$=(vt,Wt)=>vt+Wt[1]-Wt[0],J=G.reduce($,0),re=j.reduce($,0),de=S-J,we=A-re;let ze=0,Se=J,Le=0,Ne=re,Be=0,_t=de,dt=0,Ft=we;if(g.content&&l){const vt=g.content;ze=tg(G,0,vt[0]),Le=tg(j,0,vt[1]),Se=tg(G,vt[0],vt[2]),Ne=tg(j,vt[1],vt[3]),Be=vt[0]-ze,dt=vt[1]-Le,_t=vt[2]-vt[0]-Se,Ft=vt[3]-vt[1]-Ne}const nn=(vt,Wt,Ht,$t)=>{const sn=ng(vt.stretch-ze,Se,P,r.left),Rt=ig(vt.fixed-Be,_t,vt.stretch,J),In=ng(Wt.stretch-Le,Ne,U,r.top),Nn=ig(Wt.fixed-dt,Ft,Wt.stretch,re),Rn=ng(Ht.stretch-ze,Se,P,r.left),Ii=ig(Ht.fixed-Be,_t,Ht.stretch,J),an=ng($t.stretch-Le,Ne,U,r.top),ii=ig($t.fixed-dt,Ft,$t.stretch,re),Pi=new ce(sn,In),lr=new ce(Rn,In),Li=new ce(Rn,an),pi=new ce(sn,an),Nr=new ce(Rt/v,Nn/v),Di=new ce(Ii/v,ii/v),zi=t*Math.PI/180;if(zi){const Dr=Math.sin(zi),Tr=Math.cos(zi),$r=[Tr,-Dr,Dr,Tr];Pi._matMult($r),lr._matMult($r),pi._matMult($r),Li._matMult($r)}const Er=vt.stretch+vt.fixed,Rr=Wt.stretch+Wt.fixed;return{tl:Pi,tr:lr,bl:pi,br:Li,tex:{x:g.paddedRect.x+Jd+Er,y:g.paddedRect.y+Jd+Rr,w:Ht.stretch+Ht.fixed-Er,h:$t.stretch+$t.fixed-Rr},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:Nr,pixelOffsetBR:Di,minFontScaleX:_t/v/P,minFontScaleY:Ft/v/U,isSDF:s}};if(l&&(g.stretchX||g.stretchY)){const vt=Mb(G,de,J),Wt=Mb(j,we,re);for(let Ht=0;Ht<vt.length-1;Ht++){const $t=vt[Ht],sn=vt[Ht+1];for(let Rt=0;Rt<Wt.length-1;Rt++)h.push(nn($t,Wt[Rt],sn,Wt[Rt+1]))}}else h.push(nn({fixed:0,stretch:-1},{fixed:0,stretch:-1},{fixed:0,stretch:S+1},{fixed:0,stretch:A+1}));return h}function tg(r,t,s){let l=0;for(const h of r)l+=Math.max(t,Math.min(s,h[1]))-Math.max(t,Math.min(s,h[0]));return l}function Mb(r,t,s){const l=[{fixed:-Jd,stretch:0}];for(const[h,g]of r){const v=l[l.length-1];l.push({fixed:h-v.stretch,stretch:v.stretch}),l.push({fixed:h-v.stretch,stretch:v.stretch+(g-h)})}return l.push({fixed:t+Jd,stretch:s}),l}function ng(r,t,s,l){return r/t*s+l}function ig(r,t,s,l){return r-t*s/l}function IC(r,t,s,l){const h=t+r.positionedLines[l].lineOffset;return l===0?s+h/2:s+(h+(t+r.positionedLines[l-1].lineOffset))/2}class PC{constructor(t=[],s=LC){if(this.data=t,this.length=this.data.length,this.compare=s,this.length>0)for(let l=(this.length>>1)-1;l>=0;l--)this._down(l)}push(t){this.data.push(t),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const t=this.data[0],s=this.data.pop();return this.length--,this.length>0&&(this.data[0]=s,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:s,compare:l}=this,h=s[t];for(;t>0;){const g=t-1>>1,v=s[g];if(l(h,v)>=0)break;s[t]=v,t=g}s[t]=h}_down(t){const{data:s,compare:l}=this,h=this.length>>1,g=s[t];for(;t<h;){let v=1+(t<<1),S=s[v];const A=v+1;if(A<this.length&&l(s[A],S)<0&&(v=A,S=s[A]),l(S,g)>=0)break;s[t]=S,t=v}s[t]=g}}function LC(r,t){return r<t?-1:r>t?1:0}function RC(r,t=1,s=!1){let l=1/0,h=1/0,g=-1/0,v=-1/0;const S=r[0];for(let $=0;$<S.length;$++){const J=S[$];(!$||J.x<l)&&(l=J.x),(!$||J.y<h)&&(h=J.y),(!$||J.x>g)&&(g=J.x),(!$||J.y>v)&&(v=J.y)}const A=Math.min(g-l,v-h);let P=A/2;const U=new PC([],DC);if(A===0)return new ce(l,h);for(let $=l;$<g;$+=A)for(let J=h;J<v;J+=A)U.push(new Kd($+P,J+P,P,r));let G=function($){let J=0,re=0,de=0;const we=$[0];for(let ze=0,Se=we.length,Le=Se-1;ze<Se;Le=ze++){const Ne=we[ze],Be=we[Le],_t=Ne.x*Be.y-Be.x*Ne.y;re+=(Ne.x+Be.x)*_t,de+=(Ne.y+Be.y)*_t,J+=3*_t}return new Kd(re/J,de/J,0,$)}(r),j=U.length;for(;U.length;){const $=U.pop();($.d>G.d||!G.d)&&(G=$,s&&console.log("found best %d after %d probes",Math.round(1e4*$.d)/1e4,j)),$.max-G.d<=t||(P=$.h/2,U.push(new Kd($.p.x-P,$.p.y-P,P,r)),U.push(new Kd($.p.x+P,$.p.y-P,P,r)),U.push(new Kd($.p.x-P,$.p.y+P,P,r)),U.push(new Kd($.p.x+P,$.p.y+P,P,r)),j+=4)}return s&&(console.log(`num probes: ${j}`),console.log(`best distance: ${G.d}`)),G.p}function DC(r,t){return t.max-r.max}class Kd{constructor(t,s,l,h){this.p=new ce(t,s),this.h=l,this.d=function(g,v){let S=!1,A=1/0;for(let P=0;P<v.length;P++){const U=v[P];for(let G=0,j=U.length,$=j-1;G<j;$=G++){const J=U[G],re=U[$];J.y>g.y!=re.y>g.y&&g.x<(re.x-J.x)*(g.y-J.y)/(re.y-J.y)+J.x&&(S=!S),A=Math.min(A,x1(g,J,re))}}return(S?1:-1)*Math.sqrt(A)}(this.p,h),this.max=this.d+this.h*Math.SQRT2}}const Qd=7,Ny=Number.POSITIVE_INFINITY,zC=Math.sqrt(2);function Eb(r,[t,s]){let l=0,h=0;if(s===Ny){t<0&&(t=0);const g=t/zC;switch(r){case"top-right":case"top-left":h=g-Qd;break;case"bottom-right":case"bottom-left":h=-g+Qd;break;case"bottom":h=-t+Qd;break;case"top":h=t-Qd}switch(r){case"top-right":case"bottom-right":l=-g;break;case"top-left":case"bottom-left":l=g;break;case"left":l=t;break;case"right":l=-t}}else{switch(t=Math.abs(t),s=Math.abs(s),r){case"top-right":case"top-left":case"top":h=s-Qd;break;case"bottom-right":case"bottom-left":case"bottom":h=-s+Qd}switch(r){case"top-right":case"bottom-right":case"right":l=-t;break;case"top-left":case"bottom-left":case"left":l=t}}return[l,h]}function kC(r,t,s,l,h,g,v,S,A,P){r.createArrays(),r.tilePixelRatio=Zn/(512*r.overscaling),r.compareText={},r.iconsNeedLinear=!1;const U=r.layers[0].layout,G=r.layers[0]._unevaluatedLayout._values,j={};if(r.textSizeData.kind==="composite"){const{minZoom:re,maxZoom:de}=r.textSizeData;j.compositeTextSizes=[G["text-size"].possiblyEvaluate(new V(re),S),G["text-size"].possiblyEvaluate(new V(de),S)]}if(r.iconSizeData.kind==="composite"){const{minZoom:re,maxZoom:de}=r.iconSizeData;j.compositeIconSizes=[G["icon-size"].possiblyEvaluate(new V(re),S),G["icon-size"].possiblyEvaluate(new V(de),S)]}j.layoutTextSize=G["text-size"].possiblyEvaluate(new V(A+1),S),j.layoutIconSize=G["icon-size"].possiblyEvaluate(new V(A+1),S),j.textMaxSize=G["text-size"].possiblyEvaluate(new V(18),S);const $=U.get("text-rotation-alignment")==="map"&&U.get("symbol-placement")!=="point",J=U.get("text-size");for(const re of r.features){const de=U.get("text-font").evaluate(re,{},S).join(","),we=J.evaluate(re,{},S),ze=j.layoutTextSize.evaluate(re,{},S),Se=(j.layoutIconSize.evaluate(re,{},S),{horizontal:{},vertical:void 0}),Le=re.text;let Ne,Be=[0,0];if(Le){const Ft=Le.toString(),nn=U.get("text-letter-spacing").evaluate(re,{},S)*So,vt=U.get("text-line-height").evaluate(re,{},S)*So,Wt=Ld(Ft)?nn:0,Ht=U.get("text-anchor").evaluate(re,{},S),$t=U.get("text-variable-anchor");if(!$t){const Rn=U.get("text-radial-offset").evaluate(re,{},S);Be=Rn?Eb(Ht,[Rn*So,Ny]):U.get("text-offset").evaluate(re,{},S).map(Ii=>Ii*So)}let sn=$?"center":U.get("text-justify").evaluate(re,{},S);const Rt=U.get("symbol-placement")==="point",In=Rt?U.get("text-max-width").evaluate(re,{},S)*So:1/0,Nn=Rn=>{r.allowVerticalPlacement&&nu(Ft)&&(Se.vertical=Oy(Le,t,s,h,de,In,vt,Ht,Rn,Wt,Be,cl.vertical,!0,ze,we))};if(!$&&$t){const Rn=sn==="auto"?$t.map(an=>Uy(an)):[sn];let Ii=!1;for(let an=0;an<Rn.length;an++){const ii=Rn[an];if(!Se.horizontal[ii])if(Ii)Se.horizontal[ii]=Se.horizontal[0];else{const Pi=Oy(Le,t,s,h,de,In,vt,"center",ii,Wt,Be,cl.horizontal,!1,ze,we);Pi&&(Se.horizontal[ii]=Pi,Ii=Pi.positionedLines.length===1)}}Nn("left")}else{if(sn==="auto"&&(sn=Uy(Ht)),Rt||U.get("text-writing-mode").indexOf("horizontal")>=0||!nu(Ft)){const Rn=Oy(Le,t,s,h,de,In,vt,Ht,sn,Wt,Be,cl.horizontal,!1,ze,we);Rn&&(Se.horizontal[sn]=Rn)}Nn(Rt?"left":sn)}}let _t=!1;if(re.icon&&re.icon.name){const Ft=l[re.icon.name];Ft&&(Ne=TC(h[re.icon.name],U.get("icon-offset").evaluate(re,{},S),U.get("icon-anchor").evaluate(re,{},S)),_t=Ft.sdf,r.sdfIcons===void 0?r.sdfIcons=Ft.sdf:r.sdfIcons!==Ft.sdf&&wn("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(Ft.pixelRatio!==r.pixelRatio||U.get("icon-rotate").constantOr(1)!==0)&&(r.iconsNeedLinear=!0))}const dt=Ab(Se.horizontal)||Se.vertical;r.iconsInText||(r.iconsInText=!!dt&&dt.iconsInText),(dt||Ne)&&OC(r,re,Se,Ne,l,j,ze,0,Be,_t,v,S,P)}g&&r.generateCollisionDebugBuffers(A,r.collisionBoxArray)}function Uy(r){switch(r){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function OC(r,t,s,l,h,g,v,S,A,P,U,G,j){let $=g.textMaxSize.evaluate(t,{},G);$===void 0&&($=v);const J=r.layers[0].layout,re=J.get("icon-offset").evaluate(t,{},G),de=Ab(s.horizontal)||s.vertical,we=j.name==="globe",ze=So,Se=v/ze,Le=r.tilePixelRatio*$/ze,Ne=(Ht=r.overscaling,r.zoom>18&&Ht>2&&(Ht>>=1),Math.max(Zn/(512*Ht),1)*J.get("symbol-spacing")),Be=J.get("text-padding")*r.tilePixelRatio,_t=J.get("icon-padding")*r.tilePixelRatio,dt=Xe(J.get("text-max-angle")),Ft=J.get("text-rotation-alignment")==="map"&&J.get("symbol-placement")!=="point",nn=J.get("icon-rotation-alignment")==="map"&&J.get("symbol-placement")!=="point",vt=J.get("symbol-placement"),Wt=Ne/2;var Ht;const $t=J.get("icon-text-fit");let sn;l&&$t!=="none"&&(r.allowVerticalPlacement&&s.vertical&&(sn=pb(l,s.vertical,$t,J.get("icon-text-fit-padding"),re,Se)),de&&(l=pb(l,de,$t,J.get("icon-text-fit-padding"),re,Se)));const Rt=(In,Nn,Rn)=>{if(Nn.x<0||Nn.x>=Zn||Nn.y<0||Nn.y>=Zn)return;let Ii=null;if(we){const{x:an,y:ii,z:Pi}=j.projectTilePoint(Nn.x,Nn.y,Rn);Ii={anchor:new uu(an,ii,Pi,0,void 0),up:j.upVector(Rn,Nn.x,Nn.y)}}(function(an,ii,Pi,lr,Li,pi,Nr,Di,zi,Er,Rr,Dr,Tr,$r,is,vs,Ar,Ds,bs,ts,dr,ws,zr,la,Ss){const Mo=an.addToLineVertexArray(ii,lr);let ao,ca,lo,Kl,nf,Bp,Np,ow=0,aw=0,lw=0,cw=0,t0=-1,n0=-1;const Fc={};let uw=Tl("");const Rh=Pi?Pi.anchor:ii;let i0=0,r0=0;if(zi._unevaluatedLayout.getValue("text-radial-offset")===void 0?[i0,r0]=zi.layout.get("text-offset").evaluate(dr,{},Ss).map(Ja=>Ja*So):(i0=zi.layout.get("text-radial-offset").evaluate(dr,{},Ss)*So,r0=Ny),an.allowVerticalPlacement&&Li.vertical){const Ja=Li.vertical;if(is)Bp=Vy(Ja),Di&&(Np=Vy(Di));else{const Ka=zi.layout.get("text-rotate").evaluate(dr,{},Ss)+90;lo=rg(Er,Rh,ii,Rr,Dr,Tr,Ja,$r,Ka,vs),Di&&(Kl=rg(Er,Rh,ii,Rr,Dr,Tr,Di,Ds,Ka))}}if(pi){const Ja=zi.layout.get("icon-rotate").evaluate(dr,{},Ss),Ka=zi.layout.get("icon-text-fit")!=="none",Up=Sb(pi,Ja,zr,Ka),o0=Di?Sb(Di,Ja,zr,Ka):void 0;ca=rg(Er,Rh,ii,Rr,Dr,Tr,pi,Ds,Ja),ow=4*Up.length;const hw=an.iconSizeData;let Dh=null;hw.kind==="source"?(Dh=[$l*zi.layout.get("icon-size").evaluate(dr,{},Ss)],Dh[0]>Nu&&wn(`${an.layerIds[0]}: Value for "icon-size" is >= ${Pp}. Reduce your "icon-size".`)):hw.kind==="composite"&&(Dh=[$l*ws.compositeIconSizes[0].evaluate(dr,{},Ss),$l*ws.compositeIconSizes[1].evaluate(dr,{},Ss)],(Dh[0]>Nu||Dh[1]>Nu)&&wn(`${an.layerIds[0]}: Value for "icon-size" is >= ${Pp}. Reduce your "icon-size".`)),an.addSymbols(an.icon,Up,Dh,ts,bs,dr,!1,Pi,ii,Mo.lineStartIndex,Mo.lineLength,-1,la,Ss),t0=an.icon.placedSymbolArray.length-1,o0&&(aw=4*o0.length,an.addSymbols(an.icon,o0,Dh,ts,bs,dr,cl.vertical,Pi,ii,Mo.lineStartIndex,Mo.lineLength,-1,la,Ss),n0=an.icon.placedSymbolArray.length-1)}for(const Ja in Li.horizontal){const Ka=Li.horizontal[Ja];ao||(uw=Tl(Ka.text),is?nf=Vy(Ka):ao=rg(Er,Rh,ii,Rr,Dr,Tr,Ka,$r,zi.layout.get("text-rotate").evaluate(dr,{},Ss),vs));const Up=Ka.positionedLines.length===1;if(lw+=Tb(an,Pi,ii,Ka,Nr,zi,is,dr,vs,Mo,Li.vertical?cl.horizontal:cl.horizontalOnly,Up?Object.keys(Li.horizontal):[Ja],Fc,t0,ws,la,Ss),Up)break}Li.vertical&&(cw+=Tb(an,Pi,ii,Li.vertical,Nr,zi,is,dr,vs,Mo,cl.vertical,["vertical"],Fc,n0,ws,la,Ss));let Hu=-1;const s0=(Ja,Ka)=>Ja?Math.max(Ja,Ka):Ka;Hu=s0(nf,Hu),Hu=s0(Bp,Hu),Hu=s0(Np,Hu);const uI=Hu>-1?1:0;an.glyphOffsetArray.length>=Vu.MAX_GLYPHS&&wn("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),dr.sortKey!==void 0&&an.addToSortKeyRanges(an.symbolInstances.length,dr.sortKey),an.symbolInstances.emplaceBack(Rh.x,Rh.y,Rh.z,ii.x,ii.y,Fc.right>=0?Fc.right:-1,Fc.center>=0?Fc.center:-1,Fc.left>=0?Fc.left:-1,Fc.vertical>=0?Fc.vertical:-1,t0,n0,uw,ao!==void 0?ao:an.collisionBoxArray.length,ao!==void 0?ao+1:an.collisionBoxArray.length,lo!==void 0?lo:an.collisionBoxArray.length,lo!==void 0?lo+1:an.collisionBoxArray.length,ca!==void 0?ca:an.collisionBoxArray.length,ca!==void 0?ca+1:an.collisionBoxArray.length,Kl||an.collisionBoxArray.length,Kl?Kl+1:an.collisionBoxArray.length,Rr,lw,cw,ow,aw,uI,0,i0,r0,Hu)})(r,Nn,Ii,In,s,l,h,sn,r.layers[0],r.collisionBoxArray,t.index,t.sourceLayerIndex,r.index,Be,Ft,A,0,_t,nn,re,t,g,P,U,G)};if(vt==="line")for(const In of vb(t.geometry,0,0,Zn,Zn)){const Nn=CC(In,Ne,dt,s.vertical||de,l,ze,Le,r.overscaling,Zn);for(const Rn of Nn)de&&FC(r,de.text,Wt,Rn)||Rt(In,Rn,G)}else if(vt==="line-center"){for(const In of t.geometry)if(In.length>1){const Nn=AC(In,dt,s.vertical||de,l,ze,Le);Nn&&Rt(In,Nn,G)}}else if(t.type==="Polygon")for(const In of Ay(t.geometry,0)){const Nn=RC(In,16);Rt(In[0],new uu(Nn.x,Nn.y,0,0,void 0),G)}else if(t.type==="LineString")for(const In of t.geometry)Rt(In,new uu(In[0].x,In[0].y,0,0,void 0),G);else if(t.type==="Point")for(const In of t.geometry)for(const Nn of In)Rt([Nn],new uu(Nn.x,Nn.y,0,0,void 0),G)}const Pp=255,Nu=Pp*$l;function Tb(r,t,s,l,h,g,v,S,A,P,U,G,j,$,J,re,de){const we=function(Le,Ne,Be,_t,dt,Ft,nn,vt){const Wt=[];if(Ne.positionedLines.length===0)return Wt;const Ht=_t.layout.get("text-rotate").evaluate(Ft,{})*Math.PI/180,$t=function(Rn){const Ii=Rn[0],an=Rn[1],ii=Ii*an;return ii>0?[Ii,-an]:ii<0?[-Ii,an]:Ii===0?[an,Ii]:[an,-Ii]}(Be);let sn=Math.abs(Ne.top-Ne.bottom);for(const Rn of Ne.positionedLines)sn-=Rn.lineOffset;const Rt=Ne.positionedLines.length,In=sn/Rt;let Nn=Ne.top-Be[1];for(let Rn=0;Rn<Rt;++Rn){const Ii=Ne.positionedLines[Rn];Nn=IC(Ne,In,Nn,Rn);for(const an of Ii.positionedGlyphs){if(!an.rect)continue;const ii=an.rect||{};let Pi=ob+1,lr=!0,Li=1,pi=0;if(an.imageName){const zr=nn[an.imageName];if(!zr)continue;if(zr.sdf){wn("SDF images are not supported in formatted text and will be ignored.");continue}lr=!1,Li=zr.pixelRatio,Pi=Ma/Li}const Nr=(dt||vt)&&an.vertical,Di=an.metrics.advance*an.scale/2,zi=an.metrics,Er=an.rect;if(Er===null)continue;vt&&Ne.verticalizable&&(pi=an.imageName?Di-an.metrics.width*an.scale/2:0);const Rr=dt?[an.x+Di,an.y]:[0,0];let Dr=[0,0],Tr=[0,0],$r=!1;dt||(Nr?(Tr=[an.x+Di+$t[0],an.y+$t[1]-pi],$r=!0):Dr=[an.x+Di+Be[0],an.y+Be[1]-pi]);const is=Er.w*an.scale/(Li*(an.localGlyph?Yl:1)),vs=Er.h*an.scale/(Li*(an.localGlyph?Yl:1));let Ar,Ds,bs,ts;if(Nr){const zr=an.y-Nn,la=new ce(-Di,Di-zr),Ss=-Math.PI/2,Mo=new ce(...Tr);Ar=new ce(-Di+Dr[0],Dr[1]),Ar._rotateAround(Ss,la)._add(Mo),Ar.x+=-zr+Di,Ar.y-=(zi.left-Pi)*an.scale;const ao=an.imageName?zi.advance*an.scale:So*an.scale,ca=String.fromCharCode(an.glyph);uC(ca)?Ar.x+=(1-Pi)*an.scale:hC(ca)?Ar.x+=ao-zi.height*an.scale+(-Pi-1)*an.scale:Ar.x+=an.imageName||zi.width+2*Pi===Er.w&&zi.height+2*Pi===Er.h?(ao-vs)/2:(ao-(zi.height+2*Pi)*an.scale)/2,Ds=new ce(Ar.x,Ar.y-is),bs=new ce(Ar.x+vs,Ar.y),ts=new ce(Ar.x+vs,Ar.y-is)}else{const zr=(zi.left-Pi)*an.scale-Di+Dr[0],la=(-zi.top-Pi)*an.scale+Dr[1],Ss=zr+is,Mo=la+vs;Ar=new ce(zr,la),Ds=new ce(Ss,la),bs=new ce(zr,Mo),ts=new ce(Ss,Mo)}if(Ht){let zr;zr=dt?new ce(0,0):$r?new ce($t[0],$t[1]):new ce(Be[0],Be[1]),Ar._rotateAround(Ht,zr),Ds._rotateAround(Ht,zr),bs._rotateAround(Ht,zr),ts._rotateAround(Ht,zr)}const dr=new ce(0,0),ws=new ce(0,0);Wt.push({tl:Ar,tr:Ds,bl:bs,br:ts,tex:ii,writingMode:Ne.writingMode,glyphOffset:Rr,sectionIndex:an.sectionIndex,isSDF:lr,pixelOffsetTL:dr,pixelOffsetBR:ws,minFontScaleX:0,minFontScaleY:0})}}return Wt}(0,l,A,g,v,S,h,r.allowVerticalPlacement),ze=r.textSizeData;let Se=null;ze.kind==="source"?(Se=[$l*g.layout.get("text-size").evaluate(S,{},de)],Se[0]>Nu&&wn(`${r.layerIds[0]}: Value for "text-size" is >= ${Pp}. Reduce your "text-size".`)):ze.kind==="composite"&&(Se=[$l*J.compositeTextSizes[0].evaluate(S,{},de),$l*J.compositeTextSizes[1].evaluate(S,{},de)],(Se[0]>Nu||Se[1]>Nu)&&wn(`${r.layerIds[0]}: Value for "text-size" is >= ${Pp}. Reduce your "text-size".`)),r.addSymbols(r.text,we,Se,A,v,S,U,t,s,P.lineStartIndex,P.lineLength,$,re,de);for(const Le of G)j[Le]=r.text.placedSymbolArray.length-1;return 4*we.length}function Ab(r){for(const t in r)return r[t];return null}function rg(r,t,s,l,h,g,v,S,A,P){let U=v.top,G=v.bottom,j=v.left,$=v.right;const J=v.collisionPadding;if(J&&(j-=J[0],U-=J[1],$+=J[2],G+=J[3]),A){const re=new ce(j,U),de=new ce($,U),we=new ce(j,G),ze=new ce($,G),Se=Xe(A);let Le=new ce(0,0);P&&(Le=new ce(P[0],P[1])),re._rotateAround(Se,Le),de._rotateAround(Se,Le),we._rotateAround(Se,Le),ze._rotateAround(Se,Le),j=Math.min(re.x,de.x,we.x,ze.x),$=Math.max(re.x,de.x,we.x,ze.x),U=Math.min(re.y,de.y,we.y,ze.y),G=Math.max(re.y,de.y,we.y,ze.y)}return r.emplaceBack(t.x,t.y,t.z,s.x,s.y,j,U,$,G,S,l,h,g),r.length-1}function Vy(r){r.collisionPadding&&(r.top-=r.collisionPadding[1],r.bottom+=r.collisionPadding[3]);const t=r.bottom-r.top;return t>0?Math.max(10,t):null}function FC(r,t,s,l){const h=r.compareText;if(t in h){const g=h[t];for(let v=g.length-1;v>=0;v--)if(l.dist(g[v])<s)return!0}else h[t]=[];return h[t].push(l),!1}function Cb(r,t){const s=r.fovAboveCenter,l=r.elevation?r.elevation.getMinElevationBelowMSL()*t:0,h=(r._camera.position[2]*r.worldSize-l)/Math.cos(r._pitch),g=Math.sin(s)*h/Math.sin(Math.max(Math.PI/2-r._pitch-s,.01)),v=Math.sin(r._pitch)*g+h;return Math.min(1.01*v,h*(1/r._horizonShift))}function Ph(r,t){if(!t.isReprojectedInTileSpace)return{scale:1<<r.z,x:r.x,y:r.y,x2:r.x+1,y2:r.y+1,projection:t};const s=Math.pow(2,-r.z),l=r.x*s,h=(r.x+1)*s,g=r.y*s,v=(r.y+1)*s,S=ll(l),A=ll(h),P=Fo(g),U=Fo(v),G=t.project(S,P),j=t.project(A,P),$=t.project(A,U),J=t.project(S,U);let re=Math.min(G.x,j.x,$.x,J.x),de=Math.min(G.y,j.y,$.y,J.y),we=Math.max(G.x,j.x,$.x,J.x),ze=Math.max(G.y,j.y,$.y,J.y);const Se=s/16;function Le(Be,_t,dt,Ft,nn,vt){const Wt=(dt+nn)/2,Ht=(Ft+vt)/2,$t=t.project(ll(Wt),Fo(Ht)),sn=Math.max(0,re-$t.x,de-$t.y,$t.x-we,$t.y-ze);re=Math.min(re,$t.x),we=Math.max(we,$t.x),de=Math.min(de,$t.y),ze=Math.max(ze,$t.y),sn>Se&&(Le(Be,$t,dt,Ft,Wt,Ht),Le($t,_t,Wt,Ht,nn,vt))}Le(G,j,l,g,h,g),Le(j,$,h,g,h,v),Le($,J,h,v,l,v),Le(J,G,l,v,l,g),re-=Se,de-=Se,we+=Se,ze+=Se;const Ne=1/Math.max(we-re,ze-de);return{scale:Ne,x:re*Ne,y:de*Ne,x2:we*Ne,y2:ze*Ne,projection:t}}const BC=$a(new Float32Array(16));class Uu{constructor(t){this.spec=t,this.name=t.name,this.wrap=!1,this.requiresDraping=!1,this.supportsWorldCopies=!1,this.supportsTerrain=!1,this.supportsFog=!1,this.supportsFreeCamera=!1,this.zAxisUnit="meters",this.isReprojectedInTileSpace=!0,this.unsupportedLayers=["custom"],this.center=[0,0],this.range=[3.5,7]}project(t,s){return{x:0,y:0,z:0}}unproject(t,s){return new Mr(0,0)}projectTilePoint(t,s,l){return{x:t,y:s,z:0}}locationPoint(t,s,l=!0){return t._coordinatePoint(t.locationCoordinate(s),l)}pixelsPerMeter(t,s){return Xl(1,t)*s}pixelSpaceConversion(t,s,l){return 1}farthestPixelDistance(t){return Cb(t,t.pixelsPerMeter)}pointCoordinate(t,s,l,h){const g=t.horizonLineFromTop(!1),v=new ce(s,Math.max(g,l));return t.rayIntersectionCoordinate(t.pointRayIntersection(v,h))}pointCoordinate3D(t,s,l){const h=new ce(s,l);if(t.elevation)return t.elevation.pointCoordinate(h);{const g=this.pointCoordinate(t,h.x,h.y,0);return[g.x,g.y,g.z]}}isPointAboveHorizon(t,s){if(t.elevation)return!this.pointCoordinate3D(t,s.x,s.y);const l=t.horizonLineFromTop();return s.y<l}createInversionMatrix(t,s){return BC}createTileMatrix(t,s,l){let h,g,v;const S=l.canonical,A=$a(new Float64Array(16));if(this.isReprojectedInTileSpace){const P=Ph(S,this);h=1,g=P.x+l.wrap*P.scale,v=P.y,ou(A,A,[h/P.scale,h/P.scale,t.pixelsPerMeter/s])}else h=s/t.zoomScale(S.z),g=(S.x+Math.pow(2,S.z)*l.wrap)*h,v=S.y*h;return su(A,A,[g,v,0]),ou(A,A,[h/Zn,h/Zn,1]),A}upVector(t,s,l){return[0,0,1]}upVectorScale(t,s,l){return{metersToTile:1}}}class NC extends Uu{constructor(t){super(t),this.range=[4,7],this.center=t.center||[-96,37.5];const[s,l]=this.parallels=t.parallels||[29.5,45.5],h=Math.sin(Xe(s));this.n=(h+Math.sin(Xe(l)))/2,this.c=1+h*(2*this.n-h),this.r0=Math.sqrt(this.c)/this.n}project(t,s){const{n:l,c:h,r0:g}=this,v=Xe(t-this.center[0]),S=Xe(s),A=Math.sqrt(h-2*l*Math.sin(S))/l;return{x:A*Math.sin(v*l),y:A*Math.cos(v*l)-g,z:0}}unproject(t,s){const{n:l,c:h,r0:g}=this,v=g+s;let S=Math.atan2(t,Math.abs(v))*Math.sign(v);v*l<0&&(S-=Math.PI*Math.sign(t)*Math.sign(v));const A=Xe(this.center[0])*l;S=tt(S,-Math.PI-A,Math.PI-A);const P=Fe(St(S/l)+this.center[0],-180,180),U=Math.asin(Fe((h-(t*t+v*v)*l*l)/(2*l),-1,1)),G=Fe(St(U),-Bo,Bo);return new Mr(P,G)}}const Lp=1.340264,Rp=-.081106,Dp=893e-6,zp=.003796,sg=Math.sqrt(3)/2;class UC extends Uu{project(t,s){s=s/180*Math.PI,t=t/180*Math.PI;const l=Math.asin(sg*Math.sin(s)),h=l*l,g=h*h*h;return{x:.5*(t*Math.cos(l)/(sg*(Lp+3*Rp*h+g*(7*Dp+9*zp*h)))/Math.PI+.5),y:1-.5*(l*(Lp+Rp*h+g*(Dp+zp*h))/Math.PI+1),z:0}}unproject(t,s){t=(2*t-.5)*Math.PI;let l=s=(2*(1-s)-1)*Math.PI,h=l*l,g=h*h*h;for(let U,G,j,$=0;$<12&&(G=l*(Lp+Rp*h+g*(Dp+zp*h))-s,j=Lp+3*Rp*h+g*(7*Dp+9*zp*h),U=G/j,l=Fe(l-U,-Math.PI/3,Math.PI/3),h=l*l,g=h*h*h,!(Math.abs(U)<1e-12));++$);const v=sg*t*(Lp+3*Rp*h+g*(7*Dp+9*zp*h))/Math.cos(l),S=Math.asin(Math.sin(l)/sg),A=Fe(180*v/Math.PI,-180,180),P=Fe(180*S/Math.PI,-Bo,Bo);return new Mr(A,P)}}class VC extends Uu{constructor(t){super(t),this.wrap=!0,this.supportsWorldCopies=!0}project(t,s){return{x:.5+t/360,y:.5-s/360,z:0}}unproject(t,s){const l=360*(t-.5),h=Fe(360*(.5-s),-Bo,Bo);return new Mr(l,h)}}const ef=Math.PI/2;function og(r){return Math.tan((ef+r)/2)}class GC extends Uu{constructor(t){super(t),this.center=t.center||[0,30];const[s,l]=this.parallels=t.parallels||[30,30];let h=Xe(s),g=Xe(l);this.southernCenter=h+g<0,this.southernCenter&&(h=-h,g=-g);const v=Math.cos(h),S=og(h);this.n=h===g?Math.sin(h):Math.log(v/Math.cos(g))/Math.log(og(g)/S),this.f=v*Math.pow(og(h),this.n)/this.n}project(t,s){s=Xe(s),this.southernCenter&&(s=-s),t=Xe(t-this.center[0]);const l=1e-6,{n:h,f:g}=this;g>0?s<-ef+l&&(s=-ef+l):s>ef-l&&(s=ef-l);const v=g/Math.pow(og(s),h);let S=v*Math.sin(h*t),A=g-v*Math.cos(h*t);return S=.5*(S/Math.PI+.5),A=.5*(A/Math.PI+.5),{x:S,y:this.southernCenter?A:1-A,z:0}}unproject(t,s){t=(2*t-.5)*Math.PI,this.southernCenter&&(s=1-s),s=(2*(1-s)-.5)*Math.PI;const{n:l,f:h}=this,g=h-s,v=Math.sign(g),S=Math.sign(l)*Math.sqrt(t*t+g*g);let A=Math.atan2(t,Math.abs(g))*v;g*l<0&&(A-=Math.PI*Math.sign(t)*v);const P=Fe(St(A/l)+this.center[0],-180,180),U=Fe(St(2*Math.atan(Math.pow(h/S,1/l))-ef),-Bo,Bo);return new Mr(P,this.southernCenter?-U:U)}}class Ib extends Uu{constructor(t){super(t),this.wrap=!0,this.supportsWorldCopies=!0,this.supportsTerrain=!0,this.supportsFog=!0,this.supportsFreeCamera=!0,this.isReprojectedInTileSpace=!1,this.unsupportedLayers=[],this.range=null}project(t,s){return{x:Rc(t),y:Dc(s),z:0}}unproject(t,s){const l=ll(t),h=Fo(s);return new Mr(l,h)}}const Pb=Xe(Bo);class jC extends Uu{project(t,s){const l=(s=Xe(s))*s,h=l*l;return{x:.5*((t=Xe(t))*(.8707-.131979*l+h*(h*(.003971*l-.001529*h)-.013791))/Math.PI+.5),y:1-.5*(s*(1.007226+l*(.015085+h*(.028874*l-.044475-.005916*h)))/Math.PI+1),z:0}}unproject(t,s){t=(2*t-.5)*Math.PI;let l=s=(2*(1-s)-1)*Math.PI,h=25,g=0,v=l*l;do{v=l*l;const P=v*v;g=(l*(1.007226+v*(.015085+P*(.028874*v-.044475-.005916*P)))-s)/(1.007226+v*(.045255+P*(.259866*v-.311325-.005916*11*P))),l=Fe(l-g,-Pb,Pb)}while(Math.abs(g)>1e-6&&--h>0);v=l*l;const S=Fe(St(t/(.8707+v*(v*(v*v*v*(.003971-.001529*v)-.013791)-.131979))),-180,180),A=St(l);return new Mr(S,A)}}const Lb=Xe(Bo);class WC extends Uu{project(t,s){s=Xe(s),t=Xe(t);const l=Math.cos(s),h=2/Math.PI,g=Math.acos(l*Math.cos(t/2)),v=Math.sin(g)/g,S=.5*(t*h+2*l*Math.sin(t/2)/v)||0,A=.5*(s+Math.sin(s)/v)||0;return{x:.5*(S/Math.PI+.5),y:1-.5*(A/Math.PI+1),z:0}}unproject(t,s){let l=t=(2*t-.5)*Math.PI,h=s=(2*(1-s)-1)*Math.PI,g=25;const v=1e-6;let S=0,A=0;do{const P=Math.cos(h),U=Math.sin(h),G=2*U*P,j=U*U,$=P*P,J=Math.cos(l/2),re=Math.sin(l/2),de=2*J*re,we=re*re,ze=1-$*J*J,Se=ze?1/ze:0,Le=ze?Math.acos(P*J)*Math.sqrt(1/ze):0,Ne=.5*(2*Le*P*re+2*l/Math.PI)-t,Be=.5*(Le*U+h)-s,_t=.5*Se*($*we+Le*P*J*j)+1/Math.PI,dt=Se*(de*G/4-Le*U*re),Ft=.125*Se*(G*re-Le*U*$*de),nn=.5*Se*(j*J+Le*we*P)+.5,vt=dt*Ft-nn*_t;S=(Be*dt-Ne*nn)/vt,A=(Ne*Ft-Be*_t)/vt,l=Fe(l-S,-Math.PI,Math.PI),h=Fe(h-A,-Lb,Lb)}while((Math.abs(S)>v||Math.abs(A)>v)&&--g>0);return new Mr(St(l),St(h))}}class Rb extends Uu{constructor(t){super(t),this.center=t.center||[0,0],this.parallels=t.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Xe(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(t,s){const{scale:l,cosPhi:h}=this;return{x:Xe(t)*h*l+.5,y:-Math.sin(Xe(s))/h*l+.5,z:0}}unproject(t,s){const{scale:l,cosPhi:h}=this,g=-(s-.5)/l,v=Fe(St((t-.5)/l)/h,-180,180),S=Math.asin(Fe(g*h,-1,1)),A=Fe(St(S),-Bo,Bo);return new Mr(v,A)}}class HC extends Ib{constructor(t){super(t),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug"],this.range=[3,5]}projectTilePoint(t,s,l){const h=mp(t,s,l);return Ke(h,h,gp(Lc(l))),{x:h[0],y:h[1],z:h[2]}}locationPoint(t,s){const l=Nd(s.lat,s.lng),h=br([],l),g=t.elevation?t.elevation.getAtPointOrZero(t.locationCoordinate(s),t._centerAltitude):t._centerAltitude;fi(l,l,h,Xl(1,0)*Zn*g);const v=$a(new Float64Array(16));return Ic(v,t.pixelMatrix,t.globeMatrix),Ke(l,l,v),new ce(l[0],l[1])}pixelsPerMeter(t,s){return Xl(1,0)*s}pixelSpaceConversion(t,s,l){const h=Xl(1,t)*s,g=gi(Xl(1,45)*s,h,l);return this.pixelsPerMeter(t,s)/g}createTileMatrix(t,s,l){const h=hy(Lc(l.canonical));return Ic(new Float64Array(16),t.globeMatrix,h)}createInversionMatrix(t,s){const{center:l}=t,h=gp(Lc(s));return _(h,h,Xe(l.lng)),dp(h,h,Xe(l.lat)),ou(h,h,[t._pixelsPerMercatorPixel,t._pixelsPerMercatorPixel,1]),Float32Array.from(h)}pointCoordinate(t,s,l,h){return s1(t,s,l,!0)||new Vd(0,0)}pointCoordinate3D(t,s,l){const h=this.pointCoordinate(t,s,l,0);return[h.x,h.y,h.z]}isPointAboveHorizon(t,s){return!s1(t,s.x,s.y,!1)}farthestPixelDistance(t){const s=function(h,g){const v=h.cameraToCenterDistance,S=h._centerAltitude*g,A=h._camera,P=h._camera.forward(),U=Ut([],Ki([],P,-v),[0,0,S]),G=h.worldSize/(2*Math.PI),j=[0,0,-G],$=h.width/h.height,J=Math.tan(h.fovAboveCenter),re=Ki([],A.up(),J),de=Ki([],A.right(),J*$),we=br([],Ut([],Ut([],P,re),de)),ze=[];let Se;if(new sy(U,we).closestPointOnSphere(j,G,ze)){const Le=Ut([],ze,j),Ne=Jn([],Le,U);Se=Math.cos(h.fovAboveCenter)*Pe(Ne)}else{const Le=Jn([],U,j),Ne=Jn([],j,U);br(Ne,Ne);const Be=Pe(Le)-G;Se=Math.sqrt(Be*(Be+2*G));const _t=Math.acos(Se/(G+Be))-Math.acos(ns(P,Ne));Se*=Math.cos(_t)}return 1.01*Se}(t,this.pixelsPerMeter(t.center.lat,t.worldSize)),l=Ud(t.zoom);if(l>0){const h=Cb(t,Xl(1,t.center.lat)*t.worldSize),g=t.worldSize/(2*Math.PI),v=Math.max(t.width,t.height)/t.worldSize*Math.PI;return gi(s,h+g*(1-Math.cos(v)),Math.pow(l,10))}return s}upVector(t,s,l){return mp(s,l,t,1)}upVectorScale(t){return{metersToTile:km(Fm(Lc(t)))}}}function Db(r){const t=r.parallels,s=!!t&&Math.abs(t[0]+t[1])<.01;switch(r.name){case"mercator":return new Ib(r);case"equirectangular":return new VC(r);case"naturalEarth":return new jC(r);case"equalEarth":return new UC(r);case"winkelTripel":return new WC(r);case"albers":return s?new Rb(r):new NC(r);case"lambertConformalConic":return s?new Rb(r):new GC(r);case"globe":return new HC(r)}throw new Error(`Invalid projection name: ${r.name}`)}const qC=Zm.types,ZC=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function ag(r,t,s,l,h,g,v,S,A,P,U,G,j){const $=S?Math.min(Nu,Math.round(S[0])):0,J=S?Math.min(Nu,Math.round(S[1])):0;r.emplaceBack(t,s,Math.round(32*l),Math.round(32*h),g,v,($<<1)+(A?1:0),J,16*P,16*U,256*G,256*j)}function lg(r,t,s,l,h,g,v){r.emplaceBack(t,s,l,h,g,v)}function cg(r,t,s,l,h){r.emplaceBack(t,s,l,h),r.emplaceBack(t,s,l,h),r.emplaceBack(t,s,l,h),r.emplaceBack(t,s,l,h)}function XC(r){for(const t of r.sections)if(cp(t.text))return!0;return!1}class Gy{constructor(t){this.layoutVertexArray=new Lt,this.indexArray=new Gn,this.programConfigurations=t,this.segments=new jr,this.dynamicLayoutVertexArray=new Xt,this.opacityVertexArray=new zn,this.placedSymbolArray=new Gr,this.globeExtVertexArray=new Ct}isEmpty(){return this.layoutVertexArray.length===0&&this.indexArray.length===0&&this.dynamicLayoutVertexArray.length===0&&this.opacityVertexArray.length===0}upload(t,s,l,h){this.isEmpty()||(l&&(this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,nC.members),this.indexBuffer=t.createIndexBuffer(this.indexArray,s),this.dynamicLayoutVertexBuffer=t.createVertexBuffer(this.dynamicLayoutVertexArray,rC.members,!0),this.opacityVertexBuffer=t.createVertexBuffer(this.opacityVertexArray,ZC,!0),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=t.createVertexBuffer(this.globeExtVertexArray,iC.members,!0)),this.opacityVertexBuffer.itemSize=1),(l||h)&&this.programConfigurations.upload(t))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}}kn(Gy,"SymbolBuffers");class jy{constructor(t,s,l){this.layoutVertexArray=new t,this.layoutAttributes=s,this.indexArray=new l,this.segments=new jr,this.collisionVertexArray=new Ai,this.collisionVertexArrayExt=new si}upload(t){this.layoutVertexBuffer=t.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=t.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=t.createVertexBuffer(this.collisionVertexArray,sC.members,!0),this.collisionVertexBufferExt=t.createVertexBuffer(this.collisionVertexArrayExt,oC.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}kn(jy,"CollisionBuffers");class Vu{constructor(t){this.collisionBoxArray=t.collisionBoxArray,this.zoom=t.zoom,this.overscaling=t.overscaling,this.layers=t.layers,this.layerIds=this.layers.map(v=>v.id),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=$a([]),this.placementViewportMatrix=$a([]);const s=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Ly(this.zoom,s["text-size"]),this.iconSizeData=Ly(this.zoom,s["icon-size"]);const l=this.layers[0].layout,h=l.get("symbol-sort-key"),g=l.get("symbol-z-order");this.canOverlap=l.get("text-allow-overlap")||l.get("icon-allow-overlap")||l.get("text-ignore-placement")||l.get("icon-ignore-placement"),this.sortFeaturesByKey=g!=="viewport-y"&&h.constantOr(1)!==void 0,this.sortFeaturesByY=(g==="viewport-y"||g==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=l.get("text-writing-mode").map(v=>cl[v]),this.stateDependentLayerIds=this.layers.filter(v=>v.isStateDependent()).map(v=>v.id),this.sourceID=t.sourceID,this.projection=t.projection}createArrays(){this.text=new Gy(new Ac(this.layers,this.zoom,t=>/^text/.test(t))),this.icon=new Gy(new Ac(this.layers,this.zoom,t=>/^icon/.test(t))),this.glyphOffsetArray=new Ps,this.lineVertexArray=new Ec,this.symbolInstances=new yr}calculateGlyphDependencies(t,s,l,h,g){for(let v=0;v<t.length;v++)if(s[t.charCodeAt(v)]=!0,h&&g){const S=Ap[t.charAt(v)];S&&(s[S.charCodeAt(0)]=!0)}}populate(t,s,l,h){const g=this.layers[0],v=g.layout,S=this.projection.name==="globe",A=v.get("text-font"),P=v.get("text-field"),U=v.get("icon-image"),G=(P.value.kind!=="constant"||P.value.value instanceof wi&&!P.value.value.isEmpty()||P.value.value.toString().length>0)&&(A.value.kind!=="constant"||A.value.value.length>0),j=U.value.kind!=="constant"||!!U.value.value||Object.keys(U.parameters).length>0,$=v.get("symbol-sort-key");if(this.features=[],!G&&!j)return;const J=s.iconDependencies,re=s.glyphDependencies,de=s.availableImages,we=new V(this.zoom);for(const{feature:ze,id:Se,index:Le,sourceLayerIndex:Ne}of t){const Be=g._featureFilter.needGeometry,_t=Ah(ze,Be);if(!g._featureFilter.filter(we,_t,l))continue;if(Be||(_t.geometry=au(ze,l,h)),S&&ze.type!==1&&l.z<=5){const vt=_t.geometry,Wt=.98078528056,Ht=($t,sn)=>ns(mp($t.x,$t.y,l,1),mp(sn.x,sn.y,l,1))<Wt;for(let $t=0;$t<vt.length;$t++)vt[$t]=rA(vt[$t],Ht)}let dt,Ft;if(G){const vt=g.getValueAndResolveTokens("text-field",_t,l,de),Wt=wi.factory(vt);XC(Wt)&&(this.hasRTLText=!0),(!this.hasRTLText||M()==="unavailable"||this.hasRTLText&&z.isParsed())&&(dt=cC(Wt,g,_t))}if(j){const vt=g.getValueAndResolveTokens("icon-image",_t,l,de);Ft=vt instanceof or?vt:or.fromString(vt)}if(!dt&&!Ft)continue;const nn=this.sortFeaturesByKey?$.evaluate(_t,{},l):void 0;if(this.features.push({id:Se,text:dt,icon:Ft,index:Le,sourceLayerIndex:Ne,geometry:_t.geometry,properties:ze.properties,type:qC[ze.type],sortKey:nn}),Ft&&(J[Ft.name]=!0),dt){const vt=A.evaluate(_t,{},l).join(","),Wt=v.get("text-rotation-alignment")==="map"&&v.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(cl.vertical)>=0;for(const Ht of dt.sections)if(Ht.image)J[Ht.image.name]=!0;else{const $t=nu(dt.toString()),sn=Ht.fontStack||vt,Rt=re[sn]=re[sn]||{};this.calculateGlyphDependencies(Ht.text,Rt,Wt,this.allowVerticalPlacement,$t)}}}v.get("symbol-placement")==="line"&&(this.features=function(ze){const Se={},Le={},Ne=[];let Be=0;function _t(vt){Ne.push(ze[vt]),Be++}function dt(vt,Wt,Ht){const $t=Le[vt];return delete Le[vt],Le[Wt]=$t,Ne[$t].geometry[0].pop(),Ne[$t].geometry[0]=Ne[$t].geometry[0].concat(Ht[0]),$t}function Ft(vt,Wt,Ht){const $t=Se[Wt];return delete Se[Wt],Se[vt]=$t,Ne[$t].geometry[0].shift(),Ne[$t].geometry[0]=Ht[0].concat(Ne[$t].geometry[0]),$t}function nn(vt,Wt,Ht){const $t=Ht?Wt[0][Wt[0].length-1]:Wt[0][0];return`${vt}:${$t.x}:${$t.y}`}for(let vt=0;vt<ze.length;vt++){const Wt=ze[vt],Ht=Wt.geometry,$t=Wt.text?Wt.text.toString():null;if(!$t){_t(vt);continue}const sn=nn($t,Ht),Rt=nn($t,Ht,!0);if(sn in Le&&Rt in Se&&Le[sn]!==Se[Rt]){const In=Ft(sn,Rt,Ht),Nn=dt(sn,Rt,Ne[In].geometry);delete Se[sn],delete Le[Rt],Le[nn($t,Ne[Nn].geometry,!0)]=Nn,Ne[In].geometry=null}else sn in Le?dt(sn,Rt,Ht):Rt in Se?Ft(sn,Rt,Ht):(_t(vt),Se[sn]=Be-1,Le[Rt]=Be-1)}return Ne.filter(vt=>vt.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((ze,Se)=>ze.sortKey-Se.sortKey)}update(t,s,l,h){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(t,s,this.layers,l,h),this.icon.programConfigurations.updatePaintArrays(t,s,this.layers,l,h))}isEmpty(){return this.symbolInstances.length===0&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(t){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(t),this.iconCollisionBox.upload(t)),this.text.upload(t,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(t,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=Db(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(t,s){const l=this.lineVertexArray.length;if(t.segment!==void 0)for(const{x:h,y:g}of s)this.lineVertexArray.emplaceBack(h,g);return{lineStartIndex:l,lineLength:this.lineVertexArray.length-l}}addSymbols(t,s,l,h,g,v,S,A,P,U,G,j,$,J){const re=t.indexArray,de=t.layoutVertexArray,we=t.globeExtVertexArray,ze=t.segments.prepareSegment(4*s.length,de,re,this.canOverlap?v.sortKey:void 0),Se=this.glyphOffsetArray.length,Le=ze.vertexLength,Ne=this.allowVerticalPlacement&&S===cl.vertical?Math.PI/2:0,Be=v.text&&v.text.sections;for(let dt=0;dt<s.length;dt++){const{tl:Ft,tr:nn,bl:vt,br:Wt,tex:Ht,pixelOffsetTL:$t,pixelOffsetBR:sn,minFontScaleX:Rt,minFontScaleY:In,glyphOffset:Nn,isSDF:Rn,sectionIndex:Ii}=s[dt],an=ze.vertexLength,ii=Nn[1];if(ag(de,P.x,P.y,Ft.x,ii+Ft.y,Ht.x,Ht.y,l,Rn,$t.x,$t.y,Rt,In),ag(de,P.x,P.y,nn.x,ii+nn.y,Ht.x+Ht.w,Ht.y,l,Rn,sn.x,$t.y,Rt,In),ag(de,P.x,P.y,vt.x,ii+vt.y,Ht.x,Ht.y+Ht.h,l,Rn,$t.x,sn.y,Rt,In),ag(de,P.x,P.y,Wt.x,ii+Wt.y,Ht.x+Ht.w,Ht.y+Ht.h,l,Rn,sn.x,sn.y,Rt,In),A){const{x:Pi,y:lr,z:Li}=A.anchor,[pi,Nr,Di]=A.up;lg(we,Pi,lr,Li,pi,Nr,Di),lg(we,Pi,lr,Li,pi,Nr,Di),lg(we,Pi,lr,Li,pi,Nr,Di),lg(we,Pi,lr,Li,pi,Nr,Di),cg(t.dynamicLayoutVertexArray,Pi,lr,Li,Ne)}else cg(t.dynamicLayoutVertexArray,P.x,P.y,P.z,Ne);re.emplaceBack(an,an+1,an+2),re.emplaceBack(an+1,an+2,an+3),ze.vertexLength+=4,ze.primitiveLength+=2,this.glyphOffsetArray.emplaceBack(Nn[0]),dt!==s.length-1&&Ii===s[dt+1].sectionIndex||t.programConfigurations.populatePaintArrays(de.length,v,v.index,{},$,J,Be&&Be[Ii])}const _t=A?A.anchor:P;t.placedSymbolArray.emplaceBack(_t.x,_t.y,_t.z,P.x,P.y,Se,this.glyphOffsetArray.length-Se,Le,U,G,P.segment,l?l[0]:0,l?l[1]:0,h[0],h[1],S,0,!1,0,j,0)}_commitLayoutVertex(t,s,l,h,g,v,S){t.emplaceBack(s,l,h,g,v,Math.round(S.x),Math.round(S.y))}_addCollisionDebugVertices(t,s,l,h,g,v,S){const A=l.segments.prepareSegment(4,l.layoutVertexArray,l.indexArray),P=A.vertexLength,U=S.tileAnchorX,G=S.tileAnchorY;for(let $=0;$<4;$++)l.collisionVertexArray.emplaceBack(0,0,0,0);l.collisionVertexArrayExt.emplaceBack(s,-t.padding,-t.padding),l.collisionVertexArrayExt.emplaceBack(s,t.padding,-t.padding),l.collisionVertexArrayExt.emplaceBack(s,t.padding,t.padding),l.collisionVertexArrayExt.emplaceBack(s,-t.padding,t.padding),this._commitLayoutVertex(l.layoutVertexArray,h,g,v,U,G,new ce(t.x1,t.y1)),this._commitLayoutVertex(l.layoutVertexArray,h,g,v,U,G,new ce(t.x2,t.y1)),this._commitLayoutVertex(l.layoutVertexArray,h,g,v,U,G,new ce(t.x2,t.y2)),this._commitLayoutVertex(l.layoutVertexArray,h,g,v,U,G,new ce(t.x1,t.y2)),A.vertexLength+=4;const j=l.indexArray;j.emplaceBack(P,P+1),j.emplaceBack(P+1,P+2),j.emplaceBack(P+2,P+3),j.emplaceBack(P+3,P),A.primitiveLength+=4}_addTextDebugCollisionBoxes(t,s,l,h,g,v){for(let S=h;S<g;S++){const A=l.get(S),P=this.getSymbolInstanceTextSize(t,v,s,S);this._addCollisionDebugVertices(A,P,this.textCollisionBox,A.projectedAnchorX,A.projectedAnchorY,A.projectedAnchorZ,v)}}_addIconDebugCollisionBoxes(t,s,l,h,g,v){for(let S=h;S<g;S++){const A=l.get(S),P=this.getSymbolInstanceIconSize(t,s,v.placedIconSymbolIndex);this._addCollisionDebugVertices(A,P,this.iconCollisionBox,A.projectedAnchorX,A.projectedAnchorY,A.projectedAnchorZ,v)}}generateCollisionDebugBuffers(t,s){this.hasDebugData()&&this.destroyDebugData(),this.textCollisionBox=new jy(vn,K1.members,us),this.iconCollisionBox=new jy(vn,K1.members,us);const l=qd(this.iconSizeData,t),h=qd(this.textSizeData,t);for(let g=0;g<this.symbolInstances.length;g++){const v=this.symbolInstances.get(g);this._addTextDebugCollisionBoxes(h,t,s,v.textBoxStartIndex,v.textBoxEndIndex,v),this._addTextDebugCollisionBoxes(h,t,s,v.verticalTextBoxStartIndex,v.verticalTextBoxEndIndex,v),this._addIconDebugCollisionBoxes(l,t,s,v.iconBoxStartIndex,v.iconBoxEndIndex,v),this._addIconDebugCollisionBoxes(l,t,s,v.verticalIconBoxStartIndex,v.verticalIconBoxEndIndex,v)}}getSymbolInstanceTextSize(t,s,l,h){const g=this.text.placedSymbolArray.get(s.rightJustifiedTextSymbolIndex>=0?s.rightJustifiedTextSymbolIndex:s.centerJustifiedTextSymbolIndex>=0?s.centerJustifiedTextSymbolIndex:s.leftJustifiedTextSymbolIndex>=0?s.leftJustifiedTextSymbolIndex:s.verticalPlacedTextSymbolIndex>=0?s.verticalPlacedTextSymbolIndex:h),v=Jm(this.textSizeData,t,g)/So;return this.tilePixelRatio*v}getSymbolInstanceIconSize(t,s,l){const h=this.icon.placedSymbolArray.get(l),g=Jm(this.iconSizeData,t,h);return this.tilePixelRatio*g}_commitDebugCollisionVertexUpdate(t,s,l){t.emplaceBack(s,-l,-l),t.emplaceBack(s,l,-l),t.emplaceBack(s,l,l),t.emplaceBack(s,-l,l)}_updateTextDebugCollisionBoxes(t,s,l,h,g,v){for(let S=h;S<g;S++){const A=l.get(S),P=this.getSymbolInstanceTextSize(t,v,s,S);this._commitDebugCollisionVertexUpdate(this.textCollisionBox.collisionVertexArrayExt,P,A.padding)}}_updateIconDebugCollisionBoxes(t,s,l,h,g,v){for(let S=h;S<g;S++){const A=l.get(S),P=this.getSymbolInstanceIconSize(t,s,v);this._commitDebugCollisionVertexUpdate(this.iconCollisionBox.collisionVertexArrayExt,P,A.padding)}}updateCollisionDebugBuffers(t,s){if(!this.hasDebugData())return;this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexArrayExt.clear(),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexArrayExt.clear();const l=qd(this.iconSizeData,t),h=qd(this.textSizeData,t);for(let g=0;g<this.symbolInstances.length;g++){const v=this.symbolInstances.get(g);this._updateTextDebugCollisionBoxes(h,t,s,v.textBoxStartIndex,v.textBoxEndIndex,v),this._updateTextDebugCollisionBoxes(h,t,s,v.verticalTextBoxStartIndex,v.verticalTextBoxEndIndex,v),this._updateIconDebugCollisionBoxes(l,t,s,v.iconBoxStartIndex,v.iconBoxEndIndex,v.placedIconSymbolIndex),this._updateIconDebugCollisionBoxes(l,t,s,v.verticalIconBoxStartIndex,v.verticalIconBoxEndIndex,v.placedIconSymbolIndex)}this.hasTextCollisionBoxData()&&this.textCollisionBox.collisionVertexBufferExt&&this.textCollisionBox.collisionVertexBufferExt.updateData(this.textCollisionBox.collisionVertexArrayExt),this.hasIconCollisionBoxData()&&this.iconCollisionBox.collisionVertexBufferExt&&this.iconCollisionBox.collisionVertexBufferExt.updateData(this.iconCollisionBox.collisionVertexArrayExt)}_deserializeCollisionBoxesForSymbol(t,s,l,h,g,v,S,A,P){const U={};if(s<l){const{x1:G,y1:j,x2:$,y2:J,padding:re,projectedAnchorX:de,projectedAnchorY:we,projectedAnchorZ:ze,tileAnchorX:Se,tileAnchorY:Le,featureIndex:Ne}=t.get(s);U.textBox={x1:G,y1:j,x2:$,y2:J,padding:re,projectedAnchorX:de,projectedAnchorY:we,projectedAnchorZ:ze,tileAnchorX:Se,tileAnchorY:Le},U.textFeatureIndex=Ne}if(h<g){const{x1:G,y1:j,x2:$,y2:J,padding:re,projectedAnchorX:de,projectedAnchorY:we,projectedAnchorZ:ze,tileAnchorX:Se,tileAnchorY:Le,featureIndex:Ne}=t.get(h);U.verticalTextBox={x1:G,y1:j,x2:$,y2:J,padding:re,projectedAnchorX:de,projectedAnchorY:we,projectedAnchorZ:ze,tileAnchorX:Se,tileAnchorY:Le},U.verticalTextFeatureIndex=Ne}if(v<S){const{x1:G,y1:j,x2:$,y2:J,padding:re,projectedAnchorX:de,projectedAnchorY:we,projectedAnchorZ:ze,tileAnchorX:Se,tileAnchorY:Le,featureIndex:Ne}=t.get(v);U.iconBox={x1:G,y1:j,x2:$,y2:J,padding:re,projectedAnchorX:de,projectedAnchorY:we,projectedAnchorZ:ze,tileAnchorX:Se,tileAnchorY:Le},U.iconFeatureIndex=Ne}if(A<P){const{x1:G,y1:j,x2:$,y2:J,padding:re,projectedAnchorX:de,projectedAnchorY:we,projectedAnchorZ:ze,tileAnchorX:Se,tileAnchorY:Le,featureIndex:Ne}=t.get(A);U.verticalIconBox={x1:G,y1:j,x2:$,y2:J,padding:re,projectedAnchorX:de,projectedAnchorY:we,projectedAnchorZ:ze,tileAnchorX:Se,tileAnchorY:Le},U.verticalIconFeatureIndex=Ne}return U}deserializeCollisionBoxes(t){this.collisionArrays=[];for(let s=0;s<this.symbolInstances.length;s++){const l=this.symbolInstances.get(s);this.collisionArrays.push(this._deserializeCollisionBoxesForSymbol(t,l.textBoxStartIndex,l.textBoxEndIndex,l.verticalTextBoxStartIndex,l.verticalTextBoxEndIndex,l.iconBoxStartIndex,l.iconBoxEndIndex,l.verticalIconBoxStartIndex,l.verticalIconBoxEndIndex))}}hasTextData(){return this.text.segments.get().length>0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(t,s){const l=t.placedSymbolArray.get(s),h=l.vertexStartIndex+4*l.numGlyphs;for(let g=l.vertexStartIndex;g<h;g+=4)t.indexArray.emplaceBack(g,g+1,g+2),t.indexArray.emplaceBack(g+1,g+2,g+3)}getSortedSymbolIndexes(t){if(this.sortedAngle===t&&this.symbolInstanceIndexes!==void 0)return this.symbolInstanceIndexes;const s=Math.sin(t),l=Math.cos(t),h=[],g=[],v=[];for(let S=0;S<this.symbolInstances.length;++S){v.push(S);const A=this.symbolInstances.get(S);h.push(0|Math.round(s*A.tileAnchorX+l*A.tileAnchorY)),g.push(A.featureIndex)}return v.sort((S,A)=>h[S]-h[A]||g[A]-g[S]),v}addToSortKeyRanges(t,s){const l=this.sortKeyRanges[this.sortKeyRanges.length-1];l&&l.sortKey===s?l.symbolInstanceEnd=t+1:this.sortKeyRanges.push({sortKey:s,symbolInstanceStart:t,symbolInstanceEnd:t+1})}sortFeatures(t){if(this.sortFeaturesByY&&this.sortedAngle!==t&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(t),this.sortedAngle=t,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const s of this.symbolInstanceIndexes){const l=this.symbolInstances.get(s);this.featureSortOrder.push(l.featureIndex);const{rightJustifiedTextSymbolIndex:h,centerJustifiedTextSymbolIndex:g,leftJustifiedTextSymbolIndex:v,verticalPlacedTextSymbolIndex:S,placedIconSymbolIndex:A,verticalPlacedIconSymbolIndex:P}=l;h>=0&&this.addIndicesForPlacedSymbol(this.text,h),g>=0&&g!==h&&this.addIndicesForPlacedSymbol(this.text,g),v>=0&&v!==g&&v!==h&&this.addIndicesForPlacedSymbol(this.text,v),S>=0&&this.addIndicesForPlacedSymbol(this.text,S),A>=0&&this.addIndicesForPlacedSymbol(this.icon,A),P>=0&&this.addIndicesForPlacedSymbol(this.icon,P)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}kn(Vu,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Vu.MAX_GLYPHS=65535,Vu.addDynamicAttributes=cg;const $C=new Te({"symbol-placement":new ie(ct.layout_symbol["symbol-placement"]),"symbol-spacing":new ie(ct.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new ie(ct.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new pe(ct.layout_symbol["symbol-sort-key"]),"symbol-z-order":new ie(ct.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new ie(ct.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new ie(ct.layout_symbol["icon-ignore-placement"]),"icon-optional":new ie(ct.layout_symbol["icon-optional"]),"icon-rotation-alignment":new ie(ct.layout_symbol["icon-rotation-alignment"]),"icon-size":new pe(ct.layout_symbol["icon-size"]),"icon-text-fit":new ie(ct.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new ie(ct.layout_symbol["icon-text-fit-padding"]),"icon-image":new pe(ct.layout_symbol["icon-image"]),"icon-rotate":new pe(ct.layout_symbol["icon-rotate"]),"icon-padding":new ie(ct.layout_symbol["icon-padding"]),"icon-keep-upright":new ie(ct.layout_symbol["icon-keep-upright"]),"icon-offset":new pe(ct.layout_symbol["icon-offset"]),"icon-anchor":new pe(ct.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new ie(ct.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new ie(ct.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new ie(ct.layout_symbol["text-rotation-alignment"]),"text-field":new pe(ct.layout_symbol["text-field"]),"text-font":new pe(ct.layout_symbol["text-font"]),"text-size":new pe(ct.layout_symbol["text-size"]),"text-max-width":new pe(ct.layout_symbol["text-max-width"]),"text-line-height":new pe(ct.layout_symbol["text-line-height"]),"text-letter-spacing":new pe(ct.layout_symbol["text-letter-spacing"]),"text-justify":new pe(ct.layout_symbol["text-justify"]),"text-radial-offset":new pe(ct.layout_symbol["text-radial-offset"]),"text-variable-anchor":new ie(ct.layout_symbol["text-variable-anchor"]),"text-anchor":new pe(ct.layout_symbol["text-anchor"]),"text-max-angle":new ie(ct.layout_symbol["text-max-angle"]),"text-writing-mode":new ie(ct.layout_symbol["text-writing-mode"]),"text-rotate":new pe(ct.layout_symbol["text-rotate"]),"text-padding":new ie(ct.layout_symbol["text-padding"]),"text-keep-upright":new ie(ct.layout_symbol["text-keep-upright"]),"text-transform":new pe(ct.layout_symbol["text-transform"]),"text-offset":new pe(ct.layout_symbol["text-offset"]),"text-allow-overlap":new ie(ct.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new ie(ct.layout_symbol["text-ignore-placement"]),"text-optional":new ie(ct.layout_symbol["text-optional"])});var Wy={paint:new Te({"icon-opacity":new pe(ct.paint_symbol["icon-opacity"]),"icon-color":new pe(ct.paint_symbol["icon-color"]),"icon-halo-color":new pe(ct.paint_symbol["icon-halo-color"]),"icon-halo-width":new pe(ct.paint_symbol["icon-halo-width"]),"icon-halo-blur":new pe(ct.paint_symbol["icon-halo-blur"]),"icon-translate":new ie(ct.paint_symbol["icon-translate"]),"icon-translate-anchor":new ie(ct.paint_symbol["icon-translate-anchor"]),"text-opacity":new pe(ct.paint_symbol["text-opacity"]),"text-color":new pe(ct.paint_symbol["text-color"],{runtimeType:Ys,getOverride:r=>r.textColor,hasOverride:r=>!!r.textColor}),"text-halo-color":new pe(ct.paint_symbol["text-halo-color"]),"text-halo-width":new pe(ct.paint_symbol["text-halo-width"]),"text-halo-blur":new pe(ct.paint_symbol["text-halo-blur"]),"text-translate":new ie(ct.paint_symbol["text-translate"]),"text-translate-anchor":new ie(ct.paint_symbol["text-translate-anchor"])}),layout:$C};class zb{constructor(t){this.type=t.property.overrides?t.property.overrides.runtimeType:Uo,this.defaultValue=t}evaluate(t){if(t.formattedSection){const s=this.defaultValue.property.overrides;if(s&&s.hasOverride(t.formattedSection))return s.getOverride(t.formattedSection)}return t.feature&&t.featureState?this.defaultValue.evaluate(t.feature,t.featureState):this.defaultValue.property.specification.default}eachChild(t){this.defaultValue.isConstant()||t(this.defaultValue.value._styleExpression.expression)}outputDefined(){return!1}serialize(){return null}}kn(zb,"FormatSectionOverride",{omit:["defaultValue"]});class ug extends Sa{constructor(t){super(t,Wy)}recalculate(t,s){super.recalculate(t,s),this.layout.get("icon-rotation-alignment")==="auto"&&(this.layout._values["icon-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-rotation-alignment")==="auto"&&(this.layout._values["text-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-pitch-alignment")==="auto"&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),this.layout.get("icon-pitch-alignment")==="auto"&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const l=this.layout.get("text-writing-mode");if(l){const h=[];for(const g of l)h.indexOf(g)<0&&h.push(g);this.layout._values["text-writing-mode"]=h}else this.layout._values["text-writing-mode"]=this.layout.get("symbol-placement")==="point"?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(t,s,l,h){const g=this.layout.get(t).evaluate(s,{},l,h),v=this._unevaluatedLayout._values[t];return v.isDataDriven()||Xo(v.value)||!g?g:function(S,A){return A.replace(/{([^{}]+)}/g,(P,U)=>U in S?String(S[U]):"")}(s.properties,g)}createBucket(t){return new Vu(t)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const t of Wy.paint.overridableProperties){if(!ug.hasPaintOverride(this.layout,t))continue;const s=this.paint.get(t),l=new zb(s),h=new ia(l,s.property.specification);let g=null;g=s.value.kind==="constant"||s.value.kind==="source"?new Tu("source",h):new pc("composite",h,s.value.zoomStops,s.value._interpolationType),this.paint._values[t]=new _e(s.property,g,s.parameters)}}_handleOverridablePaintPropertyUpdate(t,s,l){return!(!this.layout||s.isDataDriven()||l.isDataDriven())&&ug.hasPaintOverride(this.layout,t)}static hasPaintOverride(t,s){const l=t.get("text-field"),h=Wy.paint.properties[s];let g=!1;const v=S=>{for(const A of S)if(h.overrides&&h.overrides.hasOverride(A))return void(g=!0)};if(l.value.kind==="constant"&&l.value.value instanceof wi)v(l.value.value.sections);else if(l.value.kind==="source"){const S=P=>{g||(P instanceof Fs&&Si(P.value)===W?v(P.value.sections):P instanceof Vo?v(P.sections):P.eachChild(S))},A=l.value;A._styleExpression&&S(A._styleExpression.expression)}return g}getProgramConfiguration(t){return new Tc(this,t)}}var YC={paint:new Te({"background-color":new ie(ct.paint_background["background-color"]),"background-pattern":new ie(ct.paint_background["background-pattern"]),"background-opacity":new ie(ct.paint_background["background-opacity"])})},JC={paint:new Te({"raster-opacity":new ie(ct.paint_raster["raster-opacity"]),"raster-hue-rotate":new ie(ct.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new ie(ct.paint_raster["raster-brightness-min"]),"raster-brightness-max":new ie(ct.paint_raster["raster-brightness-max"]),"raster-saturation":new ie(ct.paint_raster["raster-saturation"]),"raster-contrast":new ie(ct.paint_raster["raster-contrast"]),"raster-resampling":new ie(ct.paint_raster["raster-resampling"]),"raster-fade-duration":new ie(ct.paint_raster["raster-fade-duration"])})};class KC extends Sa{constructor(t){super(t,{}),this.implementation=t}is3D(){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}isLayerDraped(){return this.implementation.renderToTile!==void 0}shouldRedrape(){return!!this.implementation.shouldRerenderTiles&&this.implementation.shouldRerenderTiles()}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){}onAdd(t){this.implementation.onAdd&&this.implementation.onAdd(t,t.painter.context.gl)}onRemove(t){this.implementation.onRemove&&this.implementation.onRemove(t,t.painter.context.gl)}}var QC={paint:new Te({"sky-type":new ie(ct.paint_sky["sky-type"]),"sky-atmosphere-sun":new ie(ct.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new ie(ct.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new ie(ct.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new ie(ct.paint_sky["sky-gradient-radius"]),"sky-gradient":new Ee(ct.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new ie(ct.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new ie(ct.paint_sky["sky-atmosphere-color"]),"sky-opacity":new ie(ct.paint_sky["sky-opacity"])})};function Hy(r,t,s){const l=[0,0,1],h=zm([]);return t1(h,h,s?-Xe(r)+Math.PI:Xe(r)),e1(h,h,-Xe(t)),Vt(l,l,h),br(l,l)}const eI={circle:class extends Sa{constructor(r){super(r,hA)}createBucket(r){return new _y(r)}queryRadius(r){const t=r;return Gd("circle-radius",this,t)+Gd("circle-stroke-width",this,t)+Um(this.paint.get("circle-translate"))}queryIntersectsFeature(r,t,s,l,h,g,v,S){const A=S1(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),g.angle,r.pixelToTileUnitsFactor),P=this.paint.get("circle-radius").evaluate(t,s)+this.paint.get("circle-stroke-width").evaluate(t,s);return M1(r,l,g,v,S,this.paint.get("circle-pitch-alignment")==="map",this.paint.get("circle-pitch-scale")==="map",A,P)}getProgramIds(){return["circle"]}getProgramConfiguration(r){return new Tc(this,r)}},heatmap:class extends Sa{createBucket(r){return new T1(r)}constructor(r){super(r,mA),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(r){r==="heatmap-color"&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=by({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null)}queryRadius(r){return Gd("heatmap-radius",this,r)}queryIntersectsFeature(r,t,s,l,h,g,v,S){const A=this.paint.get("heatmap-radius").evaluate(t,s);return M1(r,l,g,v,S,!0,!0,new ce(0,0),A)}hasOffscreenPass(){return this.paint.get("heatmap-opacity")!==0&&this.visibility!=="none"}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(r){return new Tc(this,r)}},hillshade:class extends Sa{constructor(r){super(r,gA)}hasOffscreenPass(){return this.paint.get("hillshade-exaggeration")!==0&&this.visibility!=="none"}getProgramIds(){return["hillshade","hillshadePrepare"]}},fill:class extends Sa{constructor(r){super(r,RA)}getProgramIds(){const r=this.paint.get("fill-pattern"),t=r&&r.constantOr(1),s=[t?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&s.push(t&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),s}getProgramConfiguration(r){return new Tc(this,r)}recalculate(r,t){super.recalculate(r,t);const s=this.paint._values["fill-outline-color"];s.value.kind==="constant"&&s.value.value===void 0&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(r){return new Hm(r)}queryRadius(){return Um(this.paint.get("fill-translate"))}queryIntersectsFeature(r,t,s,l,h,g){return!r.queryGeometry.isAboveHorizon&&y1(w1(r.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),g.angle,r.pixelToTileUnitsFactor),l)}isTileClipped(){return!0}},"fill-extrusion":class extends Sa{constructor(r){super(r,XA)}createBucket(r){return new Mp(r)}queryRadius(){return Um(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}getProgramConfiguration(r){return new Tc(this,r)}queryIntersectsFeature(r,t,s,l,h,g,v,S,A){const P=S1(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),g.angle,r.pixelToTileUnitsFactor),U=this.paint.get("fill-extrusion-height").evaluate(t,s),G=this.paint.get("fill-extrusion-base").evaluate(t,s),j=[0,0],$=S&&g.elevation,J=g.elevation?g.elevation.exaggeration():1,re=r.tile.getBucket(this);if($&&re instanceof Mp){const Le=re.centroidVertexArray,Ne=A+1;Ne<Le.length&&(j[0]=Le.geta_centroid_pos0(Ne),j[1]=Le.geta_centroid_pos1(Ne))}if(j[0]===0&&j[1]===1)return!1;g.projection.name==="globe"&&(l=W1([l],[new ce(0,0),new ce(Zn,Zn)],r.tileID.canonical).map(Le=>Le.polygon).flat());const de=$?S:null,[we,ze]=function(Le,Ne,Be,_t,dt,Ft,nn,vt,Wt,Ht,$t){return Le.projection.name==="globe"?function(sn,Rt,In,Nn,Rn,Ii,an,ii,Pi,lr,Li){const pi=[],Nr=[],Di=sn.projection.upVectorScale(Li,sn.center.lat,sn.worldSize).metersToTile,zi=[0,0,0,1],Er=[0,0,0,1],Rr=(Tr,$r,is,vs)=>{Tr[0]=$r,Tr[1]=is,Tr[2]=vs,Tr[3]=1},Dr=j1();In>0&&(In+=Dr),Nn+=Dr;for(const Tr of Rt){const $r=[],is=[];for(const vs of Tr){const Ar=vs.x+Rn.x,Ds=vs.y+Rn.y,bs=sn.projection.projectTilePoint(Ar,Ds,Li),ts=sn.projection.upVector(Li,vs.x,vs.y);let dr=In,ws=Nn;if(an){const zr=X1(Ar,Ds,In,Nn,an,ii,Pi,lr);dr+=zr.base,ws+=zr.top}In!==0?Rr(zi,bs.x+ts[0]*Di*dr,bs.y+ts[1]*Di*dr,bs.z+ts[2]*Di*dr):Rr(zi,bs.x,bs.y,bs.z),Rr(Er,bs.x+ts[0]*Di*ws,bs.y+ts[1]*Di*ws,bs.z+ts[2]*Di*ws),Ke(zi,zi,Ii),Ke(Er,Er,Ii),$r.push(new Hd(zi[0],zi[1],zi[2])),is.push(new Hd(Er[0],Er[1],Er[2]))}pi.push($r),Nr.push(is)}return[pi,Nr]}(Le,Ne,Be,_t,dt,Ft,nn,vt,Wt,Ht,$t):nn?function(sn,Rt,In,Nn,Rn,Ii,an,ii,Pi){const lr=[],Li=[],pi=[0,0,0,1];for(const Nr of sn){const Di=[],zi=[];for(const Er of Nr){const Rr=Er.x+Nn.x,Dr=Er.y+Nn.y,Tr=X1(Rr,Dr,Rt,In,Ii,an,ii,Pi);pi[0]=Rr,pi[1]=Dr,pi[2]=Tr.base,pi[3]=1,rr(pi,pi,Rn),pi[3]=Math.max(pi[3],1e-5);const $r=new Hd(pi[0]/pi[3],pi[1]/pi[3],pi[2]/pi[3]);pi[0]=Rr,pi[1]=Dr,pi[2]=Tr.top,pi[3]=1,rr(pi,pi,Rn),pi[3]=Math.max(pi[3],1e-5);const is=new Hd(pi[0]/pi[3],pi[1]/pi[3],pi[2]/pi[3]);Di.push($r),zi.push(is)}lr.push(Di),Li.push(zi)}return[lr,Li]}(Ne,Be,_t,dt,Ft,nn,vt,Wt,Ht):function(sn,Rt,In,Nn,Rn){const Ii=[],an=[],ii=Rn[8]*Rt,Pi=Rn[9]*Rt,lr=Rn[10]*Rt,Li=Rn[11]*Rt,pi=Rn[8]*In,Nr=Rn[9]*In,Di=Rn[10]*In,zi=Rn[11]*In;for(const Er of sn){const Rr=[],Dr=[];for(const Tr of Er){const $r=Tr.x+Nn.x,is=Tr.y+Nn.y,vs=Rn[0]*$r+Rn[4]*is+Rn[12],Ar=Rn[1]*$r+Rn[5]*is+Rn[13],Ds=Rn[2]*$r+Rn[6]*is+Rn[14],bs=Rn[3]*$r+Rn[7]*is+Rn[15],ts=vs+ii,dr=Ar+Pi,ws=Ds+lr,zr=Math.max(bs+Li,1e-5),la=vs+pi,Ss=Ar+Nr,Mo=Ds+Di,ao=Math.max(bs+zi,1e-5);Rr.push(new Hd(ts/zr,dr/zr,ws/zr)),Dr.push(new Hd(la/ao,Ss/ao,Mo/ao))}Ii.push(Rr),an.push(Dr)}return[Ii,an]}(Ne,Be,_t,dt,Ft)}(g,l,G,U,P,v,de,j,J,g.center.lat,r.tileID.canonical),Se=r.queryGeometry;return function(Le,Ne,Be){let _t=1/0;y1(Be,Ne)&&(_t=Z1(Be,Ne[0]));for(let dt=0;dt<Ne.length;dt++){const Ft=Ne[dt],nn=Le[dt];for(let vt=0;vt<Ft.length-1;vt++){const Wt=Ft[vt],Ht=[Wt,Ft[vt+1],nn[vt+1],nn[vt],Wt];_1(Be,Ht)&&(_t=Math.min(_t,Z1(Be,Ht)))}}return _t!==1/0&&_t}(we,ze,Se.isPointQuery()?Se.screenBounds:Se.screenGeometry)}},line:class extends Sa{constructor(r){super(r,$1),this.gradientVersion=0}_handleSpecialPaintPropertyUpdate(r){if(r==="line-gradient"){const t=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=t._styleExpression&&t._styleExpression.expression instanceof Ba,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}widthExpression(){return this._transitionablePaint._values["line-width"].value.expression}recalculate(r,t){super.recalculate(r,t),this.paint._values["line-floorwidth"]=Y1.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,r)}createBucket(r){return new Ym(r)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getProgramConfiguration(r){return new Tc(this,r)}queryRadius(r){const t=r,s=J1(Gd("line-width",this,t),Gd("line-gap-width",this,t)),l=Gd("line-offset",this,t);return s/2+Math.abs(l)+Um(this.paint.get("line-translate"))}queryIntersectsFeature(r,t,s,l,h,g){if(r.queryGeometry.isAboveHorizon)return!1;const v=w1(r.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),g.angle,r.pixelToTileUnitsFactor),S=r.pixelToTileUnitsFactor/2*J1(this.paint.get("line-width").evaluate(t,s),this.paint.get("line-gap-width").evaluate(t,s)),A=this.paint.get("line-offset").evaluate(t,s);return A&&(l=function(P,U){const G=[],j=new ce(0,0);for(let $=0;$<P.length;$++){const J=P[$],re=[];for(let de=0;de<J.length;de++){const we=J[de],ze=J[de+1],Se=de===0?j:we.sub(J[de-1])._unit()._perp(),Le=de===J.length-1?j:ze.sub(we)._unit()._perp(),Ne=Se._add(Le)._unit();Ne._mult(1/(Ne.x*Le.x+Ne.y*Le.y)),re.push(Ne._mult(U)._add(we))}G.push(re)}return G}(l,A*r.pixelToTileUnitsFactor)),function(P,U,G){for(let j=0;j<U.length;j++){const $=U[j];if(P.length>=3){for(let J=0;J<$.length;J++)if(Ch(P,$[J]))return!0}if(aA(P,$,G))return!0}return!1}(v,l,S)}isTileClipped(){return!0}},symbol:ug,background:class extends Sa{constructor(r){super(r,YC)}getProgramIds(){return[this.paint.get("background-pattern")?"backgroundPattern":"background"]}},raster:class extends Sa{constructor(r){super(r,JC)}getProgramIds(){return["raster"]}},sky:class extends Sa{constructor(r){super(r,QC),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(r){r==="sky-gradient"?this._updateColorRamp():r!=="sky-atmosphere-sun"&&r!=="sky-atmosphere-halo-color"&&r!=="sky-atmosphere-color"&&r!=="sky-atmosphere-sun-intensity"||(this._skyboxInvalidated=!0)}_updateColorRamp(){this.colorRamp=by({expression:this._transitionablePaint._values["sky-gradient"].value.expression,evaluationKey:"skyRadialProgress"}),this.colorRampTexture&&(this.colorRampTexture.destroy(),this.colorRampTexture=null)}needsSkyboxCapture(r){if(this._skyboxInvalidated||!this.skyboxTexture||!this.skyboxGeometry)return!0;if(!this.paint.get("sky-atmosphere-sun")){const t=r.style.light.properties.get("position");return this._lightPosition.azimuthal!==t.azimuthal||this._lightPosition.polar!==t.polar}return!1}getCenter(r,t){if(this.paint.get("sky-type")==="atmosphere"){const l=this.paint.get("sky-atmosphere-sun"),h=!l,g=r.style.light,v=g.properties.get("position");return h&&g.properties.get("anchor")==="viewport"&&wn("The sun direction is attached to a light with viewport anchor, lighting may behave unexpectedly."),h?Hy(v.azimuthal,90-v.polar,t):Hy(l[0],90-l[1],t)}const s=this.paint.get("sky-gradient-center");return Hy(s[0],90-s[1],t)}is3D(){return!1}isSky(){return!0}markSkyboxValid(r){this._skyboxInvalidated=!1,this._lightPosition=r.style.light.properties.get("position")}hasOffscreenPass(){return!0}getProgramIds(){const r=this.paint.get("sky-type");return r==="atmosphere"?["skyboxCapture","skybox"]:r==="gradient"?["skyboxGradient"]:null}}};class kp{constructor(t,s,l,h){this.context=t,this.format=l,this.texture=t.gl.createTexture(),this.update(s,h)}update(t,s,l){const{width:h,height:g}=t,{context:v}=this,{gl:S}=v,{HTMLImageElement:A,HTMLCanvasElement:P,HTMLVideoElement:U,ImageData:G,ImageBitmap:j}=w;if(S.bindTexture(S.TEXTURE_2D,this.texture),v.pixelStoreUnpackFlipY.set(!1),v.pixelStoreUnpack.set(1),v.pixelStoreUnpackPremultiplyAlpha.set(this.format===S.RGBA&&(!s||s.premultiply!==!1)),l||this.size&&this.size[0]===h&&this.size[1]===g){const{x:$,y:J}=l||{x:0,y:0};t instanceof A||t instanceof P||t instanceof U||t instanceof G||j&&t instanceof j?S.texSubImage2D(S.TEXTURE_2D,0,$,J,S.RGBA,S.UNSIGNED_BYTE,t):S.texSubImage2D(S.TEXTURE_2D,0,$,J,h,g,S.RGBA,S.UNSIGNED_BYTE,t.data)}else this.size=[h,g],t instanceof A||t instanceof P||t instanceof U||t instanceof G||j&&t instanceof j?S.texImage2D(S.TEXTURE_2D,0,this.format,this.format,S.UNSIGNED_BYTE,t):S.texImage2D(S.TEXTURE_2D,0,this.format,h,g,0,this.format,S.UNSIGNED_BYTE,t.data);this.useMipmap=Boolean(s&&s.useMipmap&&this.isSizePowerOfTwo()),this.useMipmap&&S.generateMipmap(S.TEXTURE_2D)}bind(t,s){const{context:l}=this,{gl:h}=l;h.bindTexture(h.TEXTURE_2D,this.texture),t!==this.filter&&(h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MAG_FILTER,t),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MIN_FILTER,this.useMipmap?t===h.NEAREST?h.NEAREST_MIPMAP_NEAREST:h.LINEAR_MIPMAP_NEAREST:t),this.filter=t),s!==this.wrap&&(h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_S,s),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_T,s),this.wrap=s)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}class tI{constructor(t){this._callback=t,this._triggered=!1,typeof MessageChannel<"u"&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._callback()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._callback()},0))}remove(){this._channel=void 0,this._callback=()=>{}}}class nI{constructor(){this.tasks={},this.taskQueue=[],Wn(["process"],this),this.invoker=new tI(this.process),this.nextId=0}add(t,s){const l=this.nextId++,h=function({type:g,isSymbolTile:v,zoom:S}){return S=S||0,g==="message"?0:g!=="maybePrepare"||v?g!=="parseTile"||v?g==="parseTile"&&v?300-S:g==="maybePrepare"&&v?400-S:500:200-S:100-S}(s);if(h===0){dn();try{t()}finally{}return{cancel:()=>{}}}return this.tasks[l]={fn:t,metadata:s,priority:h,id:l},this.taskQueue.push(l),this.invoker.trigger(),{cancel:()=>{delete this.tasks[l]}}}process(){dn();try{if(this.taskQueue=this.taskQueue.filter(l=>!!this.tasks[l]),!this.taskQueue.length)return;const t=this.pick();if(t===null)return;const s=this.tasks[t];if(delete this.tasks[t],this.taskQueue.length&&this.invoker.trigger(),!s)return;s.fn()}finally{}}pick(){let t=null,s=1/0;for(let h=0;h<this.taskQueue.length;h++){const g=this.tasks[this.taskQueue[h]];g.priority<s&&(s=g.priority,t=h)}if(t===null)return null;const l=this.taskQueue[t];return this.taskQueue.splice(t,1),l}remove(){this.invoker.remove()}}class kb{constructor(t){this._stringToNumber={},this._numberToString=[];for(let s=0;s<t.length;s++){const l=t[s];this._stringToNumber[l]=s,this._numberToString[s]=l}}encode(t){return this._stringToNumber[t]}decode(t){return this._numberToString[t]}}const iI=["tile","layer","source","sourceLayer","state"];class Ob{constructor(t,s,l,h,g){this.type="Feature",this._vectorTileFeature=t,this._z=s,this._x=l,this._y=h,this.properties=t.properties,this.id=g}get geometry(){return this._geometry===void 0&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._x,this._y,this._z).geometry),this._geometry}set geometry(t){this._geometry=t}toJSON(){const t={type:"Feature",state:void 0,geometry:this.geometry,properties:this.properties};this.id!==void 0&&(t.id=this.id);for(const s of iI)this[s]!==void 0&&(t[s]=this[s]);return t}}const Ll=32,zc=33,Gu=new Uint16Array(8184);for(let r=0;r<2046;r++){let t=r+2,s=0,l=0,h=0,g=0,v=0,S=0;for(1&t?h=g=v=Ll:s=l=S=Ll;(t>>=1)>1;){const P=s+h>>1,U=l+g>>1;1&t?(h=s,g=l,s=v,l=S):(s=h,l=g,h=v,g=S),v=P,S=U}const A=4*r;Gu[A+0]=s,Gu[A+1]=l,Gu[A+2]=h,Gu[A+3]=g}const kc=new Uint16Array(2178),ju=new Uint8Array(1089),hg=new Uint16Array(1089);function Fb(r){return r===0?-.03125:r===32?.03125:0}var Bb=$e([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const Nb={type:2,extent:Zn,loadGeometry:()=>[[new ce(0,0),new ce(Zn+1,0),new ce(Zn+1,Zn+1),new ce(0,Zn+1),new ce(0,0)]]};class qy{constructor(t,s,l,h,g){this.tileID=t,this.uid=pn(),this.uses=0,this.tileSize=s,this.tileZoom=l,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=g,this.expiredRequestCount=0,this.state="loading",h&&h.transform&&(this.projection=h.transform.projection)}registerFadeDuration(t){const s=t+this.timeAdded;s<er.now()||this.fadeEndTime&&s<this.fadeEndTime||(this.fadeEndTime=s)}wasRequested(){return this.state==="errored"||this.state==="loaded"||this.state==="reloading"}get tileTransform(){return this._tileTransform||(this._tileTransform=Ph(this.tileID.canonical,this.projection)),this._tileTransform}loadVectorData(t,s,l){if(this.unloadVectorData(),this.state="loaded",t){t.featureIndex&&(this.latestFeatureIndex=t.featureIndex,t.rawTileData?(this.latestRawTileData=t.rawTileData,this.latestFeatureIndex.rawTileData=t.rawTileData):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData)),this.collisionBoxArray=t.collisionBoxArray,this.buckets=function(h,g){const v={};if(!g)return v;for(const S of h){const A=S.layerIds.map(P=>g.getLayer(P)).filter(Boolean);if(A.length!==0){S.layers=A,S.stateDependentLayerIds&&(S.stateDependentLayers=S.stateDependentLayerIds.map(P=>A.filter(U=>U.id===P)[0]));for(const P of A)v[P.id]=S}}return v}(t.buckets,s.style),this.hasSymbolBuckets=!1;for(const h in this.buckets){const g=this.buckets[h];if(g instanceof Vu){if(this.hasSymbolBuckets=!0,!l)break;g.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const h in this.buckets){const g=this.buckets[h];if(g instanceof Vu&&g.hasRTLText){this.hasRTLText=!0,z.isLoading()||z.isLoaded()||M()!=="deferred"||R();break}}this.queryPadding=0;for(const h in this.buckets){const g=this.buckets[h];this.queryPadding=Math.max(this.queryPadding,s.style.getLayer(h).queryRadius(g))}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage),t.lineAtlas&&(this.lineAtlas=t.lineAtlas)}else this.collisionBoxArray=new gr}unloadVectorData(){if(this.hasData()){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(t){return this.buckets[t.id]}upload(t){for(const l in this.buckets){const h=this.buckets[l];h.uploadPending()&&h.upload(t)}const s=t.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new kp(t,this.imageAtlas.image,s.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new kp(t,this.glyphAtlasImage,s.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new kp(t,this.lineAtlas.image,s.ALPHA),this.lineAtlas.uploaded=!0)}prepare(t){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture)}queryRenderedFeatures(t,s,l,h,g,v,S,A){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:h,pixelPosMatrix:S,transform:v,params:g,tileTransform:this.tileTransform},t,s,l):{}}querySourceFeatures(t,s){const l=this.latestFeatureIndex;if(!l||!l.rawTileData)return;const h=l.loadVTLayers(),g=s?s.sourceLayer:"",v=h._geojsonTileLayer||h[g];if(!v)return;const S=Jc(s&&s.filter),{z:A,x:P,y:U}=this.tileID.canonical,G={z:A,x:P,y:U};for(let j=0;j<v.length;j++){const $=v.feature(j);if(S.needGeometry){const de=Ah($,!0);if(!S.filter(new V(this.tileID.overscaledZ),de,this.tileID.canonical))continue}else if(!S.filter(new V(this.tileID.overscaledZ),$))continue;const J=l.getId($,g),re=new Ob($,A,P,U,J);re.tile=G,t.push(re)}}hasData(){return this.state==="loaded"||this.state==="reloading"||this.state==="expired"}patternsLoaded(){return!!this.imageAtlas&&!!Object.keys(this.imageAtlas.patternPositions).length}setExpiryData(t){const s=this.expirationTime;if(t.cacheControl){const l=Mn(t.cacheControl);l["max-age"]&&(this.expirationTime=Date.now()+1e3*l["max-age"])}else t.expires&&(this.expirationTime=new Date(t.expires).getTime());if(this.expirationTime){const l=Date.now();let h=!1;if(this.expirationTime>l)h=!1;else if(s)if(this.expirationTime<s)h=!0;else{const g=this.expirationTime-s;g?this.expirationTime=l+Math.max(g,3e4):h=!0}else h=!0;h?(this.expiredRequestCount++,this.state="expired"):this.expiredRequestCount=0}}getExpiryTimeout(){if(this.expirationTime)return this.expiredRequestCount?1e3*(1<<Math.min(this.expiredRequestCount-1,31)):Math.min(this.expirationTime-new Date().getTime(),Math.pow(2,31)-1)}setFeatureState(t,s){if(!this.latestFeatureIndex||!this.latestFeatureIndex.rawTileData||Object.keys(t).length===0||!s)return;const l=this.latestFeatureIndex.loadVTLayers(),h=s.style.listImages();for(const g in this.buckets){if(!s.style.hasLayer(g))continue;const v=this.buckets[g],S=v.layers[0].sourceLayer||"_geojsonTileLayer",A=l[S],P=t[S];if(!A||!P||Object.keys(P).length===0)continue;if(v.update(P,A,h,this.imageAtlas&&this.imageAtlas.patternPositions||{}),v instanceof Ym||v instanceof Hm){const G=s.style._getSourceCache(v.layers[0].source);s._terrain&&s._terrain.enabled&&G&&v.programConfigurations.needsUpload&&s._terrain._clearRenderCacheForTile(G.id,this.tileID)}const U=s&&s.style&&s.style.getLayer(g);U&&(this.queryPadding=Math.max(this.queryPadding,U.queryRadius(v)))}}holdingForFade(){return this.symbolFadeHoldUntil!==void 0}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil<er.now()}clearFadeHold(){this.symbolFadeHoldUntil=void 0}setHoldDuration(t){this.symbolFadeHoldUntil=er.now()+t}setTexture(t,s){const l=s.context,h=l.gl;this.texture=this.texture||s.getTileTexture(t.width),this.texture?this.texture.update(t,{useMipmap:!0}):(this.texture=new kp(l,t,h.RGBA,{useMipmap:!0}),this.texture.bind(h.LINEAR,h.CLAMP_TO_EDGE))}setDependencies(t,s){const l={};for(const h of s)l[h]=!0;this.dependencies[t]=l}hasDependency(t,s){for(const l of t){const h=this.dependencies[l];if(h){for(const g of s)if(h[g])return!0}}return!1}clearQueryDebugViz(){}_makeDebugTileBoundsBuffers(t,s){if(!s||s.name==="mercator"||this._tileDebugBuffer)return;const l=au(Nb,this.tileID.canonical,this.tileTransform)[0],h=new Jt,g=new ko;for(let v=0;v<l.length;v++){const{x:S,y:A}=l[v];h.emplaceBack(S,A),g.emplaceBack(v)}g.emplaceBack(0),this._tileDebugIndexBuffer=t.createIndexBuffer(g),this._tileDebugBuffer=t.createVertexBuffer(h,fp.members),this._tileDebugSegments=jr.simpleSegment(0,0,h.length,g.length)}_makeTileBoundsBuffers(t,s){if(this._tileBoundsBuffer||!s||s.name==="mercator")return;const l=au(Nb,this.tileID.canonical,this.tileTransform)[0];let h,g;if(this.isRaster){const v=function(S,A){const P=Ph(S,A),U=Math.pow(2,S.z);for(let de=0;de<zc;de++)for(let we=0;we<zc;we++){const ze=ll((S.x+(we+Fb(we))/Ll)/U),Se=Fo((S.y+(de+Fb(de))/Ll)/U),Le=A.project(ze,Se),Ne=de*zc+we;kc[2*Ne+0]=Math.round((Le.x*P.scale-P.x)*Zn),kc[2*Ne+1]=Math.round((Le.y*P.scale-P.y)*Zn)}ju.fill(0),hg.fill(0);for(let de=2045;de>=0;de--){const we=4*de,ze=Gu[we+0],Se=Gu[we+1],Le=Gu[we+2],Ne=Gu[we+3],Be=ze+Le>>1,_t=Se+Ne>>1,dt=Be+_t-Se,Ft=_t+ze-Be,nn=Se*zc+ze,vt=Ne*zc+Le,Wt=_t*zc+Be,Ht=Math.hypot((kc[2*nn+0]+kc[2*vt+0])/2-kc[2*Wt+0],(kc[2*nn+1]+kc[2*vt+1])/2-kc[2*Wt+1])>=16;ju[Wt]=ju[Wt]||(Ht?1:0),de<1022&&(ju[Wt]=ju[Wt]||ju[(Se+Ft>>1)*zc+(ze+dt>>1)]||ju[(Ne+Ft>>1)*zc+(Le+dt>>1)])}const G=new Bt,j=new Gn;let $=0;function J(de,we){const ze=we*zc+de;return hg[ze]===0&&(G.emplaceBack(kc[2*ze+0],kc[2*ze+1],de*Zn/Ll,we*Zn/Ll),hg[ze]=++$),hg[ze]-1}function re(de,we,ze,Se,Le,Ne){const Be=de+ze>>1,_t=we+Se>>1;if(Math.abs(de-Le)+Math.abs(we-Ne)>1&&ju[_t*zc+Be])re(Le,Ne,de,we,Be,_t),re(ze,Se,Le,Ne,Be,_t);else{const dt=J(de,we),Ft=J(ze,Se),nn=J(Le,Ne);j.emplaceBack(dt,Ft,nn)}}return re(0,0,Ll,Ll,Ll,0),re(Ll,Ll,0,0,0,Ll),{vertices:G,indices:j}}(this.tileID.canonical,s);h=v.vertices,g=v.indices}else{h=new Bt,g=new Gn;for(const{x:S,y:A}of l)h.emplaceBack(S,A,0,0);const v=Ty(h.int16,void 0,4);for(let S=0;S<v.length;S+=3)g.emplaceBack(v[S],v[S+1],v[S+2])}this._tileBoundsBuffer=t.createVertexBuffer(h,Bb.members),this._tileBoundsIndexBuffer=t.createIndexBuffer(g),this._tileBoundsSegments=jr.simpleSegment(0,0,h.length,g.length)}_makeGlobeTileDebugBuffers(t,s){const l=s.projection;if(!l||l.name!=="globe"||s.freezeTileCoverage)return;const h=this.tileID.canonical,g=gp(o1(h,s)),v=Ud(s.zoom);let S;v>0&&(S=Fd(new Float64Array(16),s.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(t,h,s,g,S,v),this._makeGlobeTileDebugTextBuffer(t,h,s,g,S,v)}_globePoint(t,s,l,h,g,v,S){let A=mp(t,s,l);if(v){const P=1<<l.z,U=Rc(h.center.lng),G=Dc(h.center.lat),j=(l.x+.5)/P-U;let $=0;j>.5?$=-1:j<-.5&&($=1);let J=(t/Zn+l.x)/P+$,re=(s/Zn+l.y)/P;J=(J-U)*h._pixelsPerMercatorPixel+U,re=(re-G)*h._pixelsPerMercatorPixel+G;const de=[J*h.worldSize,re*h.worldSize,0];Ke(de,de,v),A=Th(A,de,S)}return Ke(A,A,g)}_makeGlobeTileDebugBorderBuffer(t,s,l,h,g,v){const S=new Jt,A=new ko,P=new ut,U=(j,$,J,re,de)=>{const we=(J-j)/(de-1),ze=(re-$)/(de-1),Se=S.length;for(let Le=0;Le<de;Le++){const Ne=j+Le*we,Be=$+Le*ze;S.emplaceBack(Ne,Be);const _t=this._globePoint(Ne,Be,s,l,h,g,v);P.emplaceBack(_t[0],_t[1],_t[2]),A.emplaceBack(Se+Le)}},G=Zn;U(0,0,G,0,16),U(G,0,G,G,16),U(G,G,0,G,16),U(0,G,0,0,16),this._tileDebugIndexBuffer=t.createIndexBuffer(A),this._tileDebugBuffer=t.createVertexBuffer(S,fp.members),this._globeTileDebugBorderBuffer=t.createVertexBuffer(P,i1.members),this._tileDebugSegments=jr.simpleSegment(0,0,S.length,A.length)}_makeGlobeTileDebugTextBuffer(t,s,l,h,g,v){const S=Zn/4,A=new Jt,P=new Gn,U=new ut,G=25;P.reserve(32),A.reserve(G),U.reserve(G);const j=($,J)=>G*$+J;for(let $=0;$<G;$++){const J=$*S;for(let re=0;re<G;re++){const de=re*S;A.emplaceBack(de,J);const we=this._globePoint(de,J,s,l,h,g,v);U.emplaceBack(we[0],we[1],we[2])}}for(let $=0;$<4;$++)for(let J=0;J<4;J++){const re=j($,J),de=j($,J+1),we=j($+1,J),ze=j($+1,J+1);P.emplaceBack(re,de,we),P.emplaceBack(we,de,ze)}this._tileDebugTextIndexBuffer=t.createIndexBuffer(P),this._tileDebugTextBuffer=t.createVertexBuffer(A,fp.members),this._globeTileDebugTextBuffer=t.createVertexBuffer(U,i1.members),this._tileDebugTextSegments=jr.simpleSegment(0,0,G,32)}}class rI{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,s,l){const h=String(s);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][h]=this.stateChanges[t][h]||{},Pt(this.stateChanges[t][h],l),this.deletedStates[t]===null){this.deletedStates[t]={};for(const g in this.state[t])g!==h&&(this.deletedStates[t][g]=null)}else if(this.deletedStates[t]&&this.deletedStates[t][h]===null){this.deletedStates[t][h]={};for(const g in this.state[t][h])l[g]||(this.deletedStates[t][h][g]=null)}else for(const g in l)this.deletedStates[t]&&this.deletedStates[t][h]&&this.deletedStates[t][h][g]===null&&delete this.deletedStates[t][h][g]}removeFeatureState(t,s,l){if(this.deletedStates[t]===null)return;const h=String(s);if(this.deletedStates[t]=this.deletedStates[t]||{},l&&s!==void 0)this.deletedStates[t][h]!==null&&(this.deletedStates[t][h]=this.deletedStates[t][h]||{},this.deletedStates[t][h][l]=null);else if(s!==void 0)if(this.stateChanges[t]&&this.stateChanges[t][h])for(l in this.deletedStates[t][h]={},this.stateChanges[t][h])this.deletedStates[t][h][l]=null;else this.deletedStates[t][h]=null;else this.deletedStates[t]=null}getState(t,s){const l=String(s),h=Pt({},(this.state[t]||{})[l],(this.stateChanges[t]||{})[l]);if(this.deletedStates[t]===null)return{};if(this.deletedStates[t]){const g=this.deletedStates[t][s];if(g===null)return{};for(const v in g)delete h[v]}return h}initializeTileState(t,s){t.setFeatureState(this.state,s)}coalesceChanges(t,s){const l={};for(const h in this.stateChanges){this.state[h]=this.state[h]||{};const g={};for(const v in this.stateChanges[h])this.state[h][v]||(this.state[h][v]={}),Pt(this.state[h][v],this.stateChanges[h][v]),g[v]=this.state[h][v];l[h]=g}for(const h in this.deletedStates){this.state[h]=this.state[h]||{};const g={};if(this.deletedStates[h]===null)for(const v in this.state[h])g[v]={},this.state[h][v]={};else for(const v in this.deletedStates[h]){if(this.deletedStates[h][v]===null)this.state[h][v]={};else if(this.state[h][v])for(const S of Object.keys(this.deletedStates[h][v]))delete this.state[h][v][S];g[v]=this.state[h][v]}l[h]=l[h]||{},Pt(l[h],g)}if(this.stateChanges={},this.deletedStates={},Object.keys(l).length!==0)for(const h in t)t[h].setFeatureState(l,s)}}class Ub{constructor(t){this.size=t,this.minimums=[],this.maximums=[],this.leaves=[]}getElevation(t,s){const l=this.toIdx(t,s);return{min:this.minimums[l],max:this.maximums[l]}}isLeaf(t,s){return this.leaves[this.toIdx(t,s)]}toIdx(t,s){return s*this.size+t}}function Vb(r,t,s,l){let h=0,g=Number.MAX_VALUE;for(let v=0;v<3;v++)if(Math.abs(l[v])<1e-15){if(s[v]<r[v]||s[v]>t[v])return null}else{const S=1/l[v];let A=(r[v]-s[v])*S,P=(t[v]-s[v])*S;if(A>P){const U=A;A=P,P=U}if(A>h&&(h=A),P<g&&(g=P),h>g)return null}return h}function Gb(r,t,s,l,h,g,v,S,A,P,U){const G=l-r,j=h-t,$=g-s,J=v-r,re=S-t,de=A-s,we=U[1]*de-U[2]*re,ze=U[2]*J-U[0]*de,Se=U[0]*re-U[1]*J,Le=G*we+j*ze+$*Se;if(Math.abs(Le)<1e-15)return null;const Ne=1/Le,Be=P[0]-r,_t=P[1]-t,dt=P[2]-s,Ft=(Be*we+_t*ze+dt*Se)*Ne;if(Ft<0||Ft>1)return null;const nn=_t*$-dt*j,vt=dt*G-Be*$,Wt=Be*j-_t*G,Ht=(U[0]*nn+U[1]*vt+U[2]*Wt)*Ne;return Ht<0||Ft+Ht>1?null:(J*nn+re*vt+de*Wt)*Ne}function jb(r,t,s){return(r-t)/(s-t)}function Wb(r,t,s,l,h,g,v,S,A){const P=1<<s,U=g-l,G=v-h,j=(r+1)/P*U+l,$=(t+0)/P*G+h,J=(t+1)/P*G+h;S[0]=(r+0)/P*U+l,S[1]=$,A[0]=j,A[1]=J}class Hb{constructor(t){if(this.maximums=[],this.minimums=[],this.leaves=[],this.childOffsets=[],this.nodeCount=0,this.dem=t,this._siblingOffset=[[0,0],[1,0],[0,1],[1,1]],!this.dem)return;const s=function(g){const v=Math.ceil(Math.log2(g.dim/8)),S=[];let A=Math.ceil(Math.pow(2,v));const P=1/A,U=($,J,re,de,we)=>{const ze=de?1:0,Se=($+1)*re-ze,Le=J*re,Ne=(J+1)*re-ze;we[0]=$*re,we[1]=Le,we[2]=Se,we[3]=Ne};let G=new Ub(A);const j=[];for(let $=0;$<A*A;$++){U($%A,Math.floor($/A),P,!1,j);const J=Wu(j[0],j[1],g),re=Wu(j[2],j[1],g),de=Wu(j[2],j[3],g),we=Wu(j[0],j[3],g);G.minimums.push(Math.min(J,re,de,we)),G.maximums.push(Math.max(J,re,de,we)),G.leaves.push(1)}for(S.push(G),A/=2;A>=1;A/=2){const $=S[S.length-1];G=new Ub(A);for(let J=0;J<A*A;J++){U(J%A,Math.floor(J/A),2,!0,j);const re=$.getElevation(j[0],j[1]),de=$.getElevation(j[2],j[1]),we=$.getElevation(j[2],j[3]),ze=$.getElevation(j[0],j[3]),Se=$.isLeaf(j[0],j[1]),Le=$.isLeaf(j[2],j[1]),Ne=$.isLeaf(j[2],j[3]),Be=$.isLeaf(j[0],j[3]),_t=Math.min(re.min,de.min,we.min,ze.min),dt=Math.max(re.max,de.max,we.max,ze.max),Ft=Se&&Le&&Ne&&Be;G.maximums.push(dt),G.minimums.push(_t),G.leaves.push(dt-_t<=5&&Ft?1:0)}S.push(G)}return S}(this.dem),l=s.length-1,h=s[l];this._addNode(h.minimums[0],h.maximums[0],h.leaves[0]),this._construct(s,0,0,l,0)}raycastRoot(t,s,l,h,g,v,S=1){return Vb([t,s,-100],[l,h,this.maximums[0]*S],g,v)}raycast(t,s,l,h,g,v,S=1){if(!this.nodeCount)return null;const A=this.raycastRoot(t,s,l,h,g,v,S);if(A==null)return null;const P=[],U=[],G=[],j=[],$=[{idx:0,t:A,nodex:0,nodey:0,depth:0}];for(;$.length>0;){const{idx:J,t:re,nodex:de,nodey:we,depth:ze}=$.pop();if(this.leaves[J]){Wb(de,we,ze,t,s,l,h,G,j);const Le=1<<ze,Ne=(de+0)/Le,Be=(de+1)/Le,_t=(we+0)/Le,dt=(we+1)/Le,Ft=Wu(Ne,_t,this.dem)*S,nn=Wu(Be,_t,this.dem)*S,vt=Wu(Be,dt,this.dem)*S,Wt=Wu(Ne,dt,this.dem)*S,Ht=Gb(G[0],G[1],Ft,j[0],G[1],nn,j[0],j[1],vt,g,v),$t=Gb(j[0],j[1],vt,G[0],j[1],Wt,G[0],G[1],Ft,g,v),sn=Math.min(Ht!==null?Ht:Number.MAX_VALUE,$t!==null?$t:Number.MAX_VALUE);if(sn!==Number.MAX_VALUE)return sn;{const Rt=fi([],g,v,re);if(qb(Ft,nn,Wt,vt,jb(Rt[0],G[0],j[0]),jb(Rt[1],G[1],j[1]))>=Rt[2])return re}continue}let Se=0;for(let Le=0;Le<this._siblingOffset.length;Le++){Wb((de<<1)+this._siblingOffset[Le][0],(we<<1)+this._siblingOffset[Le][1],ze+1,t,s,l,h,G,j),G[2]=-100,j[2]=this.maximums[this.childOffsets[J]+Le]*S;const Ne=Vb(G,j,g,v);if(Ne!=null){const Be=Ne;P[Le]=Be;let _t=!1;for(let dt=0;dt<Se&&!_t;dt++)Be>=P[U[dt]]&&(U.splice(dt,0,Le),_t=!0);_t||(U[Se]=Le),Se++}}for(let Le=0;Le<Se;Le++){const Ne=U[Le];$.push({idx:this.childOffsets[J]+Ne,t:P[Ne],nodex:(de<<1)+this._siblingOffset[Ne][0],nodey:(we<<1)+this._siblingOffset[Ne][1],depth:ze+1})}}return null}_addNode(t,s,l){return this.minimums.push(t),this.maximums.push(s),this.leaves.push(l),this.childOffsets.push(0),this.nodeCount++}_construct(t,s,l,h,g){if(t[h].isLeaf(s,l)===1)return;this.childOffsets[g]||(this.childOffsets[g]=this.nodeCount);const v=h-1,S=t[v];let A=0,P=0;for(let U=0;U<this._siblingOffset.length;U++){const G=2*s+this._siblingOffset[U][0],j=2*l+this._siblingOffset[U][1],$=S.getElevation(G,j),J=S.isLeaf(G,j),re=this._addNode($.min,$.max,J);J&&(A|=1<<U),P||(P=re)}for(let U=0;U<this._siblingOffset.length;U++)A&1<<U||this._construct(t,2*s+this._siblingOffset[U][0],2*l+this._siblingOffset[U][1],v,P+U)}}function qb(r,t,s,l,h,g){return gi(gi(r,s,g),gi(t,l,g),h)}function Wu(r,t,s){const l=s.dim,h=Fe(r*l-.5,0,l-1),g=Fe(t*l-.5,0,l-1),v=Math.floor(h),S=Math.floor(g),A=Math.min(v+1,l-1),P=Math.min(S+1,l-1);return qb(s.get(v,S),s.get(A,S),s.get(v,P),s.get(A,P),h-v,g-S)}const Zb={mapbox:[6553.6,25.6,.1,1e4],terrarium:[256,1,1/256,32768]};function sI(r,t,s){return(256*r*256+256*t+s)/10-1e4}function oI(r,t,s){return 256*r+t+s/256-32768}class dg{get tree(){return this._tree||this._buildQuadTree(),this._tree}constructor(t,s,l,h=!1,g=!1){if(this.uid=t,s.height!==s.width)throw new RangeError("DEM tiles must be square");if(l&&l!=="mapbox"&&l!=="terrarium")return wn(`"${l}" is not a valid encoding type. Valid types include "mapbox" and "terrarium".`);this.stride=s.height;const v=this.dim=s.height-2,S=new Uint32Array(s.data.buffer);if(this.pixels=new Uint8Array(s.data.buffer),this.encoding=l||"mapbox",this.borderReady=h,!h){for(let A=0;A<v;A++)S[this._idx(-1,A)]=S[this._idx(0,A)],S[this._idx(v,A)]=S[this._idx(v-1,A)],S[this._idx(A,-1)]=S[this._idx(A,0)],S[this._idx(A,v)]=S[this._idx(A,v-1)];S[this._idx(-1,-1)]=S[this._idx(0,0)],S[this._idx(v,-1)]=S[this._idx(v-1,0)],S[this._idx(-1,v)]=S[this._idx(0,v-1)],S[this._idx(v,v)]=S[this._idx(v-1,v-1)],g&&this._buildQuadTree()}}_buildQuadTree(){this._tree=new Hb(this)}get(t,s,l=!1){l&&(t=Fe(t,-1,this.dim),s=Fe(s,-1,this.dim));const h=4*this._idx(t,s);return(this.encoding==="terrarium"?oI:sI)(this.pixels[h],this.pixels[h+1],this.pixels[h+2])}static getUnpackVector(t){return Zb[t]}get unpackVector(){return Zb[this.encoding]}_idx(t,s){if(t<-1||t>=this.dim+1||s<-1||s>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(s+1)*this.stride+(t+1)}static pack(t,s){const l=[0,0,0,0],h=dg.getUnpackVector(s);let g=Math.floor((t+h[3])/h[2]);return l[2]=g%256,g=Math.floor(g/256),l[1]=g%256,g=Math.floor(g/256),l[0]=g,l}getPixels(){return new Ya({width:this.stride,height:this.stride},this.pixels)}backfillBorder(t,s,l){if(this.dim!==t.dim)throw new Error("dem dimension mismatch");let h=s*this.dim,g=s*this.dim+this.dim,v=l*this.dim,S=l*this.dim+this.dim;switch(s){case-1:h=g-1;break;case 1:g=h+1}switch(l){case-1:v=S-1;break;case 1:S=v+1}const A=-s*this.dim,P=-l*this.dim;for(let U=v;U<S;U++)for(let G=h;G<g;G++){const j=4*this._idx(G,U),$=4*this._idx(G+A,U+P);this.pixels[j+0]=t.pixels[$+0],this.pixels[j+1]=t.pixels[$+1],this.pixels[j+2]=t.pixels[$+2],this.pixels[j+3]=t.pixels[$+3]}}onDeserialize(){this._tree&&(this._tree.dem=this)}}kn(dg,"DEMData"),kn(Hb,"DemMinMaxQuadTree",{omit:["dem"]});class aI{constructor(t,s){this.max=t,this.onRemove=s,this.reset()}reset(){for(const t in this.data)for(const s of this.data[t])s.timeout&&clearTimeout(s.timeout),this.onRemove(s.value);return this.data={},this.order=[],this}add(t,s,l){const h=t.wrapped().key;this.data[h]===void 0&&(this.data[h]=[]);const g={value:s,timeout:void 0};if(l!==void 0&&(g.timeout=setTimeout(()=>{this.remove(t,g)},l)),this.data[h].push(g),this.order.push(h),this.order.length>this.max){const v=this._getAndRemoveByKey(this.order[0]);v&&this.onRemove(v)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const s=this.data[t].shift();return s.timeout&&clearTimeout(s.timeout),this.data[t].length===0&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),s.value}getByKey(t){const s=this.data[t];return s?s[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,s){if(!this.has(t))return this;const l=t.wrapped().key,h=s===void 0?0:this.data[l].indexOf(s),g=this.data[l][h];return this.data[l].splice(h,1),g.timeout&&clearTimeout(g.timeout),this.data[l].length===0&&delete this.data[l],this.onRemove(g.value),this.order.splice(this.order.indexOf(l),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const s=this._getAndRemoveByKey(this.order[0]);s&&this.onRemove(s)}return this}filter(t){const s=[];for(const l in this.data)for(const h of this.data[l])t(h.value)||s.push(h);for(const l of s)this.remove(l.value.tileID,l)}}class tf{constructor(t,s,l){this.func=t,this.mask=s,this.range=l}}tf.ReadOnly=!1,tf.ReadWrite=!0,tf.disabled=new tf(519,tf.ReadOnly,[0,1]);const Zy=7680;class Xy{constructor(t,s,l,h,g,v){this.test=t,this.ref=s,this.mask=l,this.fail=h,this.depthFail=g,this.pass=v}}Xy.disabled=new Xy({func:519,mask:0},0,0,Zy,Zy,Zy);class Oc{constructor(t,s,l){this.blendFunction=t,this.blendColor=s,this.mask=l}}Oc.Replace=[1,0],Oc.disabled=new Oc(Oc.Replace,zt.transparent,[!1,!1,!1,!1]),Oc.unblended=new Oc(Oc.Replace,zt.transparent,[!0,!0,!0,!0]),Oc.alphaBlended=new Oc([1,771],zt.transparent,[!0,!0,!0,!0]);const $y=1029,Yy=2305;class Jl{constructor(t,s,l){this.enable=t,this.mode=s,this.frontFace=l}}Jl.disabled=new Jl(!1,$y,Yy),Jl.backCCW=new Jl(!0,$y,Yy),Jl.backCW=new Jl(!0,$y,2304),Jl.frontCW=new Jl(!0,1028,2304),Jl.frontCCW=new Jl(!0,1028,Yy);class Lh extends Zi{constructor(t,s,l){super(),this.id=t,this._onlySymbols=l,s.on("data",h=>{h.dataType==="source"&&h.sourceDataType==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&h.dataType==="source"&&h.sourceDataType==="content"&&(this.reload(),this.transform&&this.update(this.transform))}),s.on("error",()=>{this._sourceErrored=!0}),this._source=s,this._tiles={},this._cache=new aI(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=s.minTileCacheSize,this._maxTileCacheSize=s.maxTileCacheSize,this._loadedParentTiles={},this._coveredTiles={},this._state=new rI,this._isRaster=this._source.type==="raster"||this._source.type==="raster-dem"||this._source.type==="custom"&&this._source._dataType==="raster"}onAdd(t){this.map=t,this._minTileCacheSize=this._minTileCacheSize===void 0&&t?t._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=this._maxTileCacheSize===void 0&&t?t._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;for(const t in this._tiles){const s=this._tiles[t];if(s.state!=="loaded"&&s.state!=="errored")return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(t,s){return t.isSymbolTile=this._onlySymbols,this._source.loadTile(t,s)}_unloadTile(t){if(this._source.unloadTile)return this._source.unloadTile(t,()=>{})}_abortTile(t){if(this._source.abortTile)return this._source.abortTile(t,()=>{})}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const s in this._tiles){const l=this._tiles[s];l.upload(t),l.prepare(this.map.style.imageManager)}}getIds(){return xt(this._tiles).map(t=>t.tileID).sort(Xb).map(t=>t.key)}getRenderableIds(t){const s=[];for(const l in this._tiles)this._isIdRenderable(+l,t)&&s.push(this._tiles[l]);return t?s.sort((l,h)=>{const g=l.tileID,v=h.tileID,S=new ce(g.canonical.x,g.canonical.y)._rotate(this.transform.angle),A=new ce(v.canonical.x,v.canonical.y)._rotate(this.transform.angle);return g.overscaledZ-v.overscaledZ||A.y-S.y||A.x-S.x}).map(l=>l.tileID.key):s.map(l=>l.tileID).sort(Xb).map(l=>l.key)}hasRenderableParent(t){const s=this.findLoadedParent(t,0);return!!s&&this._isIdRenderable(s.tileID.key)}_isIdRenderable(t,s){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(s||!this._tiles[t].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)this._tiles[t].state!=="errored"&&this._reloadTile(+t,"reloading")}}_reloadTile(t,s){const l=this._tiles[t];l&&(l.state!=="loading"&&(l.state=s),this._loadTile(l,this._tileLoaded.bind(this,l,t,s)))}_tileLoaded(t,s,l,h){if(h)if(t.state="errored",h.status!==404)this._source.fire(new Ir(h,{tile:t}));else if(this._source.type==="raster-dem"&&this.usedForTerrain&&this.map.painter.terrain){const g=this.map.painter.terrain;this.update(this.transform,g.getScaledDemTileSize(),!0),g.resetTileLookupCache(this.id)}else this.update(this.transform);else t.timeAdded=er.now(),l==="expired"&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(s,t),this._source.type==="raster-dem"&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),this._source.fire(new Es("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id}))}_backfillDEM(t){const s=this.getRenderableIds();for(let h=0;h<s.length;h++){const g=s[h];if(t.neighboringTiles&&t.neighboringTiles[g]){const v=this.getTileByID(g);l(t,v),l(v,t)}}function l(h,g){if(!h.dem||h.dem.borderReady)return;h.needsHillshadePrepare=!0,h.needsDEMTextureUpload=!0;let v=g.tileID.canonical.x-h.tileID.canonical.x;const S=g.tileID.canonical.y-h.tileID.canonical.y,A=Math.pow(2,h.tileID.canonical.z),P=g.tileID.key;v===0&&S===0||Math.abs(S)>1||(Math.abs(v)>1&&(Math.abs(v+A)===1?v+=A:Math.abs(v-A)===1&&(v-=A)),g.dem&&h.dem&&(h.dem.backfillBorder(g.dem,v,S),h.neighboringTiles&&h.neighboringTiles[P]&&(h.neighboringTiles[P].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,s,l,h){for(const g in this._tiles){let v=this._tiles[g];if(h[g]||!v.hasData()||v.tileID.overscaledZ<=s||v.tileID.overscaledZ>l)continue;let S=v.tileID;for(;v&&v.tileID.overscaledZ>s+1;){const P=v.tileID.scaledTo(v.tileID.overscaledZ-1);v=this._tiles[P.key],v&&v.hasData()&&(S=P)}let A=S;for(;A.overscaledZ>s;)if(A=A.scaledTo(A.overscaledZ-1),t[A.key]){h[S.key]=S;break}}}findLoadedParent(t,s){if(t.key in this._loadedParentTiles){const l=this._loadedParentTiles[t.key];return l&&l.tileID.overscaledZ>=s?l:null}for(let l=t.overscaledZ-1;l>=s;l--){const h=t.scaledTo(l),g=this._getLoadedTile(h);if(g)return g}}_getLoadedTile(t){const s=this._tiles[t.key];return s&&s.hasData()?s:this._cache.getByKey(this._source.reparseOverscaled?t.wrapped().key:t.canonical.key)}updateCacheSize(t,s){s=s||this._source.tileSize;const l=Math.ceil(t.width/s)+1,h=Math.ceil(t.height/s)+1,g=Math.floor(l*h*5),v=typeof this._minTileCacheSize=="number"?Math.max(this._minTileCacheSize,g):g,S=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,v):v;this._cache.setMaxSize(S)}handleWrapJump(t){const s=Math.round((t-(this._prevLng===void 0?t:this._prevLng))/360);if(this._prevLng=t,s){const l={};for(const h in this._tiles){const g=this._tiles[h];g.tileID=g.tileID.unwrapTo(g.tileID.wrap+s),l[g.tileID.key]=g}this._tiles=l;for(const h in this._timers)clearTimeout(this._timers[h]),delete this._timers[h];for(const h in this._tiles)this._setTileReloadTimer(+h,this._tiles[h])}}update(t,s,l){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage||this.usedForTerrain&&!l)return;let h;this.updateCacheSize(t,s),this.transform.projection.name!=="globe"&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?h=t.getVisibleUnwrappedCoordinates(this._source.tileID).map(S=>new aa(S.canonical.z,S.wrap,S.canonical.z,S.canonical.x,S.canonical.y)):(h=t.coveringTiles({tileSize:s||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!l,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(h=h.filter(S=>this._source.hasTile(S)))):h=[];const g=this._updateRetainedTiles(h);if($b(this._source.type)&&h.length!==0){const S={},A={},P=Object.keys(g);for(const G of P){const j=g[G],$=this._tiles[G];if(!$||$.fadeEndTime&&$.fadeEndTime<=er.now())continue;const J=this.findLoadedParent(j,Math.max(j.overscaledZ-Lh.maxOverzooming,this._source.minzoom));J&&(this._addTile(J.tileID),S[J.tileID.key]=J.tileID),A[G]=j}const U=h[h.length-1].overscaledZ;for(const G in this._tiles){const j=this._tiles[G];if(g[G]||!j.hasData())continue;let $=j.tileID;for(;$.overscaledZ>U;){$=$.scaledTo($.overscaledZ-1);const J=this._tiles[$.key];if(J&&J.hasData()&&A[$.key]){g[G]=j.tileID;break}}}for(const G in S)g[G]||(this._coveredTiles[G]=!0,g[G]=S[G])}for(const S in g)this._tiles[S].clearFadeHold();const v=function(S,A){const P=[];for(const U in S)U in A||P.push(U);return P}(this._tiles,g);for(const S of v){const A=this._tiles[S];A.hasSymbolBuckets&&!A.holdingForFade()?A.setHoldDuration(this.map._fadeDuration):A.hasSymbolBuckets&&!A.symbolFadeFinished()||this._removeTile(+S)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(+t)}_updateRetainedTiles(t){const s={};if(t.length===0)return s;const l={},h=t.reduce((P,U)=>Math.min(P,U.overscaledZ),1/0),g=t[0].overscaledZ,v=Math.max(g-Lh.maxOverzooming,this._source.minzoom),S=Math.max(g+Lh.maxUnderzooming,this._source.minzoom),A={};for(const P of t){const U=this._addTile(P);s[P.key]=P,U.hasData()||h<this._source.maxzoom&&(A[P.key]=P)}this._retainLoadedChildren(A,h,S,s);for(const P of t){let U=this._tiles[P.key];if(U.hasData())continue;if(P.canonical.z>=this._source.maxzoom){const j=P.children(this._source.maxzoom)[0],$=this.getTile(j);if($&&$.hasData()){s[j.key]=j;continue}}else{const j=P.children(this._source.maxzoom);if(s[j[0].key]&&s[j[1].key]&&s[j[2].key]&&s[j[3].key])continue}let G=U.wasRequested();for(let j=P.overscaledZ-1;j>=v;--j){const $=P.scaledTo(j);if(l[$.key]||(l[$.key]=!0,U=this.getTile($),!U&&G&&(U=this._addTile($)),U&&(s[$.key]=$,G=U.wasRequested(),U.hasData())))break}}return s}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const s=[];let l,h=this._tiles[t].tileID;for(;h.overscaledZ>0;){if(h.key in this._loadedParentTiles){l=this._loadedParentTiles[h.key];break}s.push(h.key);const g=h.scaledTo(h.overscaledZ-1);if(l=this._getLoadedTile(g),l)break;h=g}for(const g of s)this._loadedParentTiles[g]=l}}_addTile(t){let s=this._tiles[t.key];if(s)return s;s=this._cache.getAndRemove(t),s&&(this._setTileReloadTimer(t.key,s),s.tileID=t,this._state.initializeTileState(s,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,s)));const l=Boolean(s);if(!l){const h=this.map?this.map.painter:null;s=new qy(t,this._source.tileSize*t.overscaleFactor(),this.transform.tileZoom,h,this._isRaster),this._loadTile(s,this._tileLoaded.bind(this,s,t.key,s.state))}return s?(s.uses++,this._tiles[t.key]=s,l||this._source.fire(new Es("dataloading",{tile:s,coord:s.tileID,dataType:"source"})),s):null}_setTileReloadTimer(t,s){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const l=s.getExpiryTimeout();l&&(this._timers[t]=setTimeout(()=>{this._reloadTile(t,"expired"),delete this._timers[t]},l))}_removeTile(t){const s=this._tiles[t];s&&(s.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),s.uses>0||(s.hasData()&&s.state!=="reloading"?this._cache.add(s.tileID,s,s.getExpiryTimeout()):(s.aborted=!0,this._abortTile(s),this._unloadTile(s))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(+t);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(t,s,l){const h=[],g=this.transform;if(!g)return h;const v=g.projection.name==="globe",S=Rc(g.center.lng);for(const A in this._tiles){const P=this._tiles[A];if(l&&P.clearQueryDebugViz(),P.holdingForFade())continue;let U;if(v){const G=P.tileID.canonical;if(G.z===0){const j=[Math.abs(Fe(S,...Op(G,-1))-S),Math.abs(Fe(S,...Op(G,1))-S)];U=[0,2*j.indexOf(Math.min(...j))-1]}else{const j=[Math.abs(Fe(S,...Op(G,-1))-S),Math.abs(Fe(S,...Op(G,0))-S),Math.abs(Fe(S,...Op(G,1))-S)];U=[j.indexOf(Math.min(...j))-1]}}else U=[0];for(const G of U){const j=t.containsTile(P,g,s,G);j&&h.push(j)}}return h}getVisibleCoordinates(t){const s=this.getRenderableIds(t).map(l=>this._tiles[l].tileID);for(const l of s)l.projMatrix=this.transform.calculateProjMatrix(l.toUnwrapped());return s}hasTransition(){if(this._source.hasTransition())return!0;if($b(this._source.type))for(const t in this._tiles){const s=this._tiles[t];if(s.fadeEndTime!==void 0&&s.fadeEndTime>=er.now())return!0}return!1}setFeatureState(t,s,l){this._state.updateState(t=t||"_geojsonTileLayer",s,l)}removeFeatureState(t,s,l){this._state.removeFeatureState(t=t||"_geojsonTileLayer",s,l)}getFeatureState(t,s){return this._state.getState(t=t||"_geojsonTileLayer",s)}setDependencies(t,s,l){const h=this._tiles[t];h&&h.setDependencies(s,l)}reloadTilesForDependencies(t,s){for(const l in this._tiles)this._tiles[l].hasDependency(t,s)&&this._reloadTile(+l,"reloading");this._cache.filter(l=>!l.hasDependency(t,s))}_preloadTiles(t,s){if(!this._sourceLoaded){const S=()=>{this._sourceLoaded&&(this._source.off("data",S),this._preloadTiles(t,s))};return void this._source.on("data",S)}const l=new Map,h=Array.isArray(t)?t:[t],g=this.map.painter.terrain,v=this.usedForTerrain&&g?g.getScaledDemTileSize():this._source.tileSize;for(const S of h){const A=S.coveringTiles({tileSize:v,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const P of A)l.set(P.key,P);this.usedForTerrain&&S.updateElevation(!1)}Et(Array.from(l.values()),(S,A)=>{const P=new qy(S,this._source.tileSize*S.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(P,U=>{this._source.type==="raster-dem"&&P.dem&&this._backfillDEM(P),A(U,P)})},s)}}function Xb(r,t){const s=Math.abs(2*r.wrap)-+(r.wrap<0),l=Math.abs(2*t.wrap)-+(t.wrap<0);return r.overscaledZ-t.overscaledZ||l-s||t.canonical.y-r.canonical.y||t.canonical.x-r.canonical.x}function $b(r){return r==="raster"||r==="image"||r==="video"||r==="custom"}function Op(r,t){const s=1<<r.z;return[r.x/s+t,(r.x+1)/s+t]}Lh.maxOverzooming=10,Lh.maxUnderzooming=3;class fg{constructor(t,s,l){this._demTile=t,this._dem=this._demTile.dem,this._scale=s,this._offset=l}static create(t,s,l){const h=l||t.findDEMTileFor(s);if(!h||!h.dem)return;const g=h.dem,v=h.tileID,S=1<<s.canonical.z-v.canonical.z;return new fg(h,h.tileSize/Zn/S,[(s.canonical.x/S-v.canonical.x)*g.dim,(s.canonical.y/S-v.canonical.y)*g.dim])}tileCoordToPixel(t,s){const l=s*this._scale+this._offset[1],h=Math.floor(t*this._scale+this._offset[0]),g=Math.floor(l);return new ce(h,g)}getElevationAt(t,s,l,h){const g=t*this._scale+this._offset[0],v=s*this._scale+this._offset[1],S=Math.floor(g),A=Math.floor(v),P=this._dem;return h=!!h,l?gi(gi(P.get(S,A,h),P.get(S,A+1,h),v-A),gi(P.get(S+1,A,h),P.get(S+1,A+1,h),v-A),g-S):P.get(S,A,h)}getElevationAtPixel(t,s,l){return this._dem.get(t,s,!!l)}getMeterToDEM(t){return(1<<this._demTile.tileID.canonical.z)*Xl(1,t)*this._dem.stride}}class Yb{constructor(t,s){this.tileID=t,this.x=t.canonical.x,this.y=t.canonical.y,this.z=t.canonical.z,this.grid=new Wa(Zn,16,0),this.featureIndexArray=new El,this.promoteId=s}insert(t,s,l,h,g,v=0){const S=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(l,h,g,v);const A=this.grid;for(let P=0;P<s.length;P++){const U=s[P],G=[1/0,1/0,-1/0,-1/0];for(let j=0;j<U.length;j++){const $=U[j];G[0]=Math.min(G[0],$.x),G[1]=Math.min(G[1],$.y),G[2]=Math.max(G[2],$.x),G[3]=Math.max(G[3],$.y)}G[0]<Zn&&G[1]<Zn&&G[2]>=0&&G[3]>=0&&A.insert(S,G[0],G[1],G[2],G[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new Py(new Qm(this.rawTileData)).layers,this.sourceLayerCoder=new kb(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const t in this.vtLayers)this.vtFeatures[t]=[]}return this.vtLayers}query(t,s,l,h){this.loadVTLayers();const g=t.params||{},v=Jc(g.filter),S=t.tileResult,A=t.transform,P=S.bufferedTilespaceBounds,U=this.grid.query(P.min.x,P.min.y,P.max.x,P.max.y,(J,re,de,we)=>b1(S.bufferedTilespaceGeometry,J,re,de,we));U.sort(lI);let G=null;A.elevation&&U.length>0&&(G=fg.create(A.elevation,this.tileID));const j={};let $;for(let J=0;J<U.length;J++){const re=U[J];if(re===$)continue;$=re;const de=this.featureIndexArray.get(re);let we=null;this.loadMatchingFeature(j,de,v,g.layers,g.availableImages,s,l,h,(ze,Se,Le,Ne=0)=>(we||(we=au(ze,this.tileID.canonical,t.tileTransform)),Se.queryIntersectsFeature(S,ze,Le,we,this.z,t.transform,t.pixelPosMatrix,G,Ne)))}return j}loadMatchingFeature(t,s,l,h,g,v,S,A,P){const{featureIndex:U,bucketIndex:G,sourceLayerIndex:j,layoutVertexArrayOffset:$}=s,J=this.bucketLayerIDs[G];if(h&&!function(ze,Se){for(let Le=0;Le<ze.length;Le++)if(Se.indexOf(ze[Le])>=0)return!0;return!1}(h,J))return;const re=this.sourceLayerCoder.decode(j),de=this.vtLayers[re].feature(U);if(l.needGeometry){const ze=Ah(de,!0);if(!l.filter(new V(this.tileID.overscaledZ),ze,this.tileID.canonical))return}else if(!l.filter(new V(this.tileID.overscaledZ),de))return;const we=this.getId(de,re);for(let ze=0;ze<J.length;ze++){const Se=J[ze];if(h&&h.indexOf(Se)<0)continue;const Le=v[Se];if(!Le)continue;let Ne={};we!==void 0&&A&&(Ne=A.getState(Le.sourceLayer||"_geojsonTileLayer",we));const Be=Pt({},S[Se]);Be.paint=Jb(Be.paint,Le.paint,de,Ne,g),Be.layout=Jb(Be.layout,Le.layout,de,Ne,g);const _t=!P||P(de,Le,Ne,$);if(!_t)continue;const dt=new Ob(de,this.z,this.x,this.y,we);dt.layer=Be;let Ft=t[Se];Ft===void 0&&(Ft=t[Se]=[]),Ft.push({featureIndex:U,feature:dt,intersectionZ:_t})}}lookupSymbolFeatures(t,s,l,h,g,v,S,A){const P={};this.loadVTLayers();const U=Jc(g);for(const G of t)this.loadMatchingFeature(P,{bucketIndex:l,sourceLayerIndex:h,featureIndex:G,layoutVertexArrayOffset:0},U,v,S,A,s);return P}loadFeature(t){const{featureIndex:s,sourceLayerIndex:l}=t;this.loadVTLayers();const h=this.sourceLayerCoder.decode(l),g=this.vtFeatures[h];if(g[s])return g[s];const v=this.vtLayers[h].feature(s);return g[s]=v,v}hasLayer(t){for(const s of this.bucketLayerIDs)for(const l of s)if(t===l)return!0;return!1}getId(t,s){let l=t.id;if(this.promoteId){const h=typeof this.promoteId=="string"?this.promoteId:this.promoteId[s];h!=null&&(l=t.properties[h]),typeof l=="boolean"&&(l=Number(l))}return l}}function Jb(r,t,s,l,h){return mn(r,(g,v)=>{const S=t instanceof be?t.get(v):null;return S&&S.evaluate?S.evaluate(s,l,h):S})}function lI(r,t){return t-r}kn(Yb,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});class Kb{constructor(t,s){this.width=t,this.height=s,this.nextRow=0,this.image=new lu({width:t,height:s}),this.positions={},this.uploaded=!1}getDash(t,s){const l=this.getKey(t,s);return this.positions[l]}trim(){const t=this.width,s=this.height=ei(this.nextRow);this.image.resize({width:t,height:s})}getKey(t,s){return t.join(",")+s}getDashRanges(t,s,l){const h=[];let g=t.length%2==1?-t[t.length-1]*l:0,v=t[0]*l,S=!0;h.push({left:g,right:v,isDash:S,zeroLength:t[0]===0});let A=t[0];for(let P=1;P<t.length;P++){S=!S;const U=t[P];g=A*l,A+=U,v=A*l,h.push({left:g,right:v,isDash:S,zeroLength:U===0})}return h}addRoundDash(t,s,l){const h=s/2;for(let g=-l;g<=l;g++){const v=this.width*(this.nextRow+l+g);let S=0,A=t[S];for(let P=0;P<this.width;P++){P/A.right>1&&(A=t[++S]);const U=Math.abs(P-A.left),G=Math.abs(P-A.right),j=Math.min(U,G);let $;const J=g/l*(h+1);if(A.isDash){const re=h-Math.abs(J);$=Math.sqrt(j*j+re*re)}else $=h-Math.sqrt(j*j+J*J);this.image.data[v+P]=Math.max(0,Math.min(255,$+128))}}}addRegularDash(t,s){for(let A=t.length-1;A>=0;--A){const P=t[A],U=t[A+1];P.zeroLength?t.splice(A,1):U&&U.isDash===P.isDash&&(U.left=P.left,t.splice(A,1))}const l=t[0],h=t[t.length-1];l.isDash===h.isDash&&(l.left=h.left-this.width,h.right=l.right+this.width);const g=this.width*this.nextRow;let v=0,S=t[v];for(let A=0;A<this.width;A++){A/S.right>1&&(S=t[++v]);const P=Math.abs(A-S.left),U=Math.abs(A-S.right),G=Math.min(P,U);this.image.data[g+A]=Math.max(0,Math.min(255,(S.isDash?G:-G)+s+128))}}addDash(t,s){const l=this.getKey(t,s);if(this.positions[l])return this.positions[l];const h=s==="round",g=h?7:0,v=2*g+1;if(this.nextRow+v>this.height)return wn("LineAtlas out of space"),null;t.length===0&&t.push(1);let S=0;for(let U=0;U<t.length;U++)t[U]<0&&(wn("Negative value is found in line dasharray, replacing values with 0"),t[U]=0),S+=t[U];if(S!==0){const U=this.width/S,G=this.getDashRanges(t,this.width,U);h?this.addRoundDash(G,U,g):this.addRegularDash(G,s==="square"?.5*U:0)}const A=this.nextRow+g;this.nextRow+=v;const P={tl:[A,g],br:[S,0]};return this.positions[l]=P,P}}kn(Kb,"LineAtlas");const Qb=1*Yl;class ew{constructor(t){const s={},l=[];for(const S in t){const A=t[S],P=s[S]={};for(const U in A.glyphs){const G=A.glyphs[+U];if(!G||G.bitmap.width===0||G.bitmap.height===0)continue;const j=G.metrics.localGlyph?Qb:1,$={x:0,y:0,w:G.bitmap.width+2*j,h:G.bitmap.height+2*j};l.push($),P[U]=$}}const{w:h,h:g}=zy(l),v=new lu({width:h||1,height:g||1});for(const S in t){const A=t[S];for(const P in A.glyphs){const U=A.glyphs[+P];if(!U||U.bitmap.width===0||U.bitmap.height===0)continue;const G=s[S][P],j=U.metrics.localGlyph?Qb:1;lu.copy(U.bitmap,v,{x:0,y:0},{x:G.x+j,y:G.y+j},U.bitmap)}}this.image=v,this.positions=s}}kn(ew,"GlyphAtlas");class cI{constructor(t){this.tileID=new aa(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.tileZoom=t.tileZoom,this.uid=t.uid,this.zoom=t.zoom,this.canonical=t.tileID.canonical,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=t.showCollisionBoxes,this.collectResourceTiming=!!t.collectResourceTiming,this.returnDependencies=!!t.returnDependencies,this.promoteId=t.promoteId,this.enableTerrain=!!t.enableTerrain,this.isSymbolTile=t.isSymbolTile,this.tileTransform=Ph(t.tileID.canonical,t.projection),this.projection=t.projection}parse(t,s,l,h,g){this.status="parsing",this.data=t,this.collisionBoxArray=new gr;const v=new kb(Object.keys(t.layers).sort()),S=new Yb(this.tileID,this.promoteId);S.bucketLayerIDs=[];const A={},P=new Kb(256,256),U={featureIndex:S,iconDependencies:{},patternDependencies:{},glyphDependencies:{},lineAtlas:P,availableImages:l},G=s.familiesBySource[this.source];for(const Ne in G){const Be=t.layers[Ne];if(!Be)continue;let _t=!1,dt=!1;for(const vt of G[Ne])vt[0].type==="symbol"?_t=!0:dt=!0;if(this.isSymbolTile===!0&&!_t||this.isSymbolTile===!1&&!dt)continue;Be.version===1&&wn(`Vector tile source "${this.source}" layer "${Ne}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const Ft=v.encode(Ne),nn=[];for(let vt=0;vt<Be.length;vt++){const Wt=Be.feature(vt),Ht=S.getId(Wt,Ne);nn.push({feature:Wt,id:Ht,index:vt,sourceLayerIndex:Ft})}for(const vt of G[Ne]){const Wt=vt[0];this.isSymbolTile!==void 0&&Wt.type==="symbol"!==this.isSymbolTile||Wt.minzoom&&this.zoom<Math.floor(Wt.minzoom)||Wt.maxzoom&&this.zoom>=Wt.maxzoom||Wt.visibility!=="none"&&(Jy(vt,this.zoom,l),(A[Wt.id]=Wt.createBucket({index:S.bucketLayerIDs.length,layers:vt,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:Ft,sourceID:this.source,enableTerrain:this.enableTerrain,projection:this.projection.spec,availableImages:l})).populate(nn,U,this.tileID.canonical,this.tileTransform),S.bucketLayerIDs.push(vt.map(Ht=>Ht.id)))}}let j,$,J,re;P.trim();const de={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},we=()=>{if(j)return g(j);if($&&J&&re){const Ne=new ew($),Be=new ab(J,re);for(const _t in A){const dt=A[_t];dt instanceof Vu?(Jy(dt.layers,this.zoom,l),kC(dt,$,Ne.positions,J,Be.iconPositions,this.showCollisionBoxes,l,this.tileID.canonical,this.tileZoom,this.projection)):dt.hasPattern&&(dt instanceof Ym||dt instanceof Hm||dt instanceof Mp)&&(Jy(dt.layers,this.zoom,l),dt.addFeatures(U,this.tileID.canonical,Be.patternPositions,l,this.tileTransform))}this.status="done",g(null,{buckets:xt(A).filter(_t=>!_t.isEmpty()),featureIndex:S,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:Ne.image,lineAtlas:P,imageAtlas:Be,glyphMap:this.returnDependencies?$:null,iconMap:this.returnDependencies?J:null,glyphPositions:this.returnDependencies?Ne.positions:null})}},ze=mn(U.glyphDependencies,Ne=>Object.keys(Ne).map(Number));Object.keys(ze).length?h.send("getGlyphs",{uid:this.uid,stacks:ze},(Ne,Be)=>{j||(j=Ne,$=Be,we())},void 0,!1,de):$={};const Se=Object.keys(U.iconDependencies);Se.length?h.send("getImages",{icons:Se,source:this.source,tileID:this.tileID,type:"icons"},(Ne,Be)=>{j||(j=Ne,J=Be,we())},void 0,!1,de):J={};const Le=Object.keys(U.patternDependencies);Le.length?h.send("getImages",{icons:Le,source:this.source,tileID:this.tileID,type:"patterns"},(Ne,Be)=>{j||(j=Ne,re=Be,we())},void 0,!1,de):re={},we()}}function Jy(r,t,s){const l=new V(t);for(const h of r)h.recalculate(l,s)}class tw{constructor(t){this.entries={},this.scheduler=t}request(t,s,l,h){const g=this.entries[t]=this.entries[t]||{callbacks:[]};if(g.result){const[v,S]=g.result;return this.scheduler?this.scheduler.add(()=>{h(v,S)},s):h(v,S),()=>{}}return g.callbacks.push(h),g.cancel||(g.cancel=l((v,S)=>{g.result=[v,S];for(const A of g.callbacks)this.scheduler?this.scheduler.add(()=>{A(v,S)},s):A(v,S);setTimeout(()=>delete this.entries[t],3e3)})),()=>{g.result||(g.callbacks=g.callbacks.filter(v=>v!==h),g.callbacks.length||(g.cancel(),delete this.entries[t]))}}}function nw(r,t,s){const l=JSON.stringify(r.request);return r.data&&(this.deduped.entries[l]={result:[null,r.data]}),this.deduped.request(l,{type:"parseTile",isSymbolTile:r.isSymbolTile,zoom:r.tileZoom},h=>{const g=bt(r.request,(v,S,A,P)=>{v?h(v):S&&h(null,{vectorTile:s?void 0:new Py(new Qm(S)),rawData:S,cacheControl:A,expires:P})});return()=>{g.cancel(),h()}},t)}const iw=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class Ky{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[s,l]=new Uint8Array(t,0,2);if(s!==219)throw new Error("Data does not appear to be in a KDBush format.");const h=l>>4;if(h!==1)throw new Error(`Got v${h} data when expected v1.`);const g=iw[15&l];if(!g)throw new Error("Unrecognized array type.");const[v]=new Uint16Array(t,2,1),[S]=new Uint32Array(t,4,1);return new Ky(S,v,g,t)}constructor(t,s=64,l=Float64Array,h){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+s,2),65535),this.ArrayType=l,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;const g=iw.indexOf(this.ArrayType),v=2*t*this.ArrayType.BYTES_PER_ELEMENT,S=t*this.IndexArrayType.BYTES_PER_ELEMENT,A=(8-S%8)%8;if(g<0)throw new Error(`Unexpected typed array class: ${l}.`);h&&h instanceof ArrayBuffer?(this.data=h,this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+S+A,2*t),this._pos=2*t,this._finished=!0):(this.data=new ArrayBuffer(8+v+S+A),this.ids=new this.IndexArrayType(this.data,8,t),this.coords=new this.ArrayType(this.data,8+S+A,2*t),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+g]),new Uint16Array(this.data,2,1)[0]=s,new Uint32Array(this.data,4,1)[0]=t)}add(t,s){const l=this._pos>>1;return this.ids[l]=l,this.coords[this._pos++]=t,this.coords[this._pos++]=s,l}finish(){const t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return Qy(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,s,l,h){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:g,coords:v,nodeSize:S}=this,A=[0,g.length-1,0],P=[];for(;A.length;){const U=A.pop()||0,G=A.pop()||0,j=A.pop()||0;if(G-j<=S){for(let de=j;de<=G;de++){const we=v[2*de],ze=v[2*de+1];we>=t&&we<=l&&ze>=s&&ze<=h&&P.push(g[de])}continue}const $=j+G>>1,J=v[2*$],re=v[2*$+1];J>=t&&J<=l&&re>=s&&re<=h&&P.push(g[$]),(U===0?t<=J:s<=re)&&(A.push(j),A.push($-1),A.push(1-U)),(U===0?l>=J:h>=re)&&(A.push($+1),A.push(G),A.push(1-U))}return P}within(t,s,l){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:h,coords:g,nodeSize:v}=this,S=[0,h.length-1,0],A=[],P=l*l;for(;S.length;){const U=S.pop()||0,G=S.pop()||0,j=S.pop()||0;if(G-j<=v){for(let de=j;de<=G;de++)sw(g[2*de],g[2*de+1],t,s)<=P&&A.push(h[de]);continue}const $=j+G>>1,J=g[2*$],re=g[2*$+1];sw(J,re,t,s)<=P&&A.push(h[$]),(U===0?t-l<=J:s-l<=re)&&(S.push(j),S.push($-1),S.push(1-U)),(U===0?t+l>=J:s+l>=re)&&(S.push($+1),S.push(G),S.push(1-U))}return A}}function Qy(r,t,s,l,h,g){if(h-l<=s)return;const v=l+h>>1;rw(r,t,v,l,h,g),Qy(r,t,s,l,v-1,1-g),Qy(r,t,s,v+1,h,1-g)}function rw(r,t,s,l,h,g){for(;h>l;){if(h-l>600){const P=h-l+1,U=s-l+1,G=Math.log(P),j=.5*Math.exp(2*G/3),$=.5*Math.sqrt(G*j*(P-j)/P)*(U-P/2<0?-1:1);rw(r,t,s,Math.max(l,Math.floor(s-U*j/P+$)),Math.min(h,Math.floor(s+(P-U)*j/P+$)),g)}const v=t[2*s+g];let S=l,A=h;for(Fp(r,t,l,s),t[2*h+g]>v&&Fp(r,t,l,h);S<A;){for(Fp(r,t,S,A),S++,A--;t[2*S+g]<v;)S++;for(;t[2*A+g]>v;)A--}t[2*l+g]===v?Fp(r,t,l,A):(A++,Fp(r,t,A,h)),A<=s&&(l=A+1),s<=A&&(h=A-1)}}function Fp(r,t,s,l){e0(r,s,l),e0(t,2*s,2*l),e0(t,2*s+1,2*l+1)}function e0(r,t,s){const l=r[t];r[t]=r[s],r[s]=l}function sw(r,t,s,l){const h=r-s,g=t-l;return h*h+g*g}i.ARRAY_TYPE=Oo,i.AUTH_ERR_MSG=De,i.Aabb=oa,i.Actor=class{constructor(r,t,s){this.target=r,this.parent=t,this.mapId=s,this.callbacks={},this.cancelCallbacks={},Wn(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=dn()?r:w,this.scheduler=new nI}send(r,t,s,l,h=!1,g){const v=Math.round(1e18*Math.random()).toString(36).substring(0,10);s&&(s.metadata=g,this.callbacks[v]=s);const S=ti(this.globalScope)?void 0:[];return this.target.postMessage({id:v,type:r,hasCallback:!!s,targetMapId:l,mustQueue:h,sourceMapId:this.mapId,data:jl(t,S)},S),{cancel:()=>{s&&delete this.callbacks[v],this.target.postMessage({id:v,type:"<cancel>",targetMapId:l,sourceMapId:this.mapId})}}}receive(r){const t=r.data,s=t.id;if(s&&(!t.targetMapId||this.mapId===t.targetMapId))if(t.type==="<cancel>"){const l=this.cancelCallbacks[s];delete this.cancelCallbacks[s],l&&l.cancel()}else if(t.mustQueue||dn()){const l=this.callbacks[s];this.cancelCallbacks[s]=this.scheduler.add(()=>this.processTask(s,t),l&&l.metadata||{type:"message"})}else this.processTask(s,t)}processTask(r,t){if(t.type==="<response>"){const s=this.callbacks[r];delete this.callbacks[r],s&&(t.error?s(Ha(t.error)):s(null,Ha(t.data)))}else{const s=ti(this.globalScope)?void 0:[],l=t.hasCallback?(g,v)=>{delete this.cancelCallbacks[r],this.target.postMessage({id:r,type:"<response>",sourceMapId:this.mapId,error:g?jl(g):null,data:jl(v,s)},s)}:g=>{},h=Ha(t.data);if(this.parent[t.type])this.parent[t.type](t.sourceMapId,h,l);else if(this.parent.getWorkerSource){const g=t.type.split(".");this.parent.getWorkerSource(t.sourceMapId,g[0],h.source)[g[1]](h,l)}else l(new Error(`Could not find function ${t.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},i.CanonicalTileID=$m,i.Color=zt,i.ColorMode=Oc,i.CullFaceMode=Jl,i.DEMData=dg,i.DataConstantProperty=ie,i.DedupedRequest=tw,i.DepthMode=tf,i.EXTENT=Zn,i.Elevation=class{isDataAvailableAtPoint(r){const t=this._source();if(this.isUsingMockSource()||!t||r.y<0||r.y>1)return!1;const s=t.getSource().maxzoom,l=1<<s,h=Math.floor(r.x),g=Math.floor((r.x-h)*l),v=Math.floor(r.y*l),S=this.findDEMTileFor(new aa(s,h,s,g,v));return!(!S||!S.dem)}getAtPointOrZero(r,t=0){return this.getAtPoint(r,t)||0}getAtPoint(r,t,s=!0){if(this.isUsingMockSource())return null;t==null&&(t=null);const l=this._source();if(!l||r.y<0||r.y>1)return t;const h=l.getSource().maxzoom,g=1<<h,v=Math.floor(r.x),S=r.x-v,A=new aa(h,v,h,Math.floor(S*g),Math.floor(r.y*g)),P=this.findDEMTileFor(A);if(!P||!P.dem)return t;const U=P.dem,G=1<<P.tileID.canonical.z,j=(S*G-P.tileID.canonical.x)*U.dim,$=(r.y*G-P.tileID.canonical.y)*U.dim,J=Math.floor(j),re=Math.floor($);return(s?this.exaggeration():1)*gi(gi(U.get(J,re),U.get(J,re+1),$-re),gi(U.get(J+1,re),U.get(J+1,re+1),$-re),j-J)}getAtTileOffset(r,t,s){const l=1<<r.canonical.z;return this.getAtPointOrZero(new Vd(r.wrap+(r.canonical.x+t/Zn)/l,(r.canonical.y+s/Zn)/l))}getAtTileOffsetFunc(r,t,s,l){return h=>{const g=this.getAtTileOffset(r,h.x,h.y),v=l.upVector(r.canonical,h.x,h.y);return Ki(v,v,g*l.upVectorScale(r.canonical,t,s).metersToTile),v}}getForTilePoints(r,t,s,l){if(this.isUsingMockSource())return!1;const h=fg.create(this,r,l);return!!h&&(t.forEach(g=>{g[2]=this.exaggeration()*h.getElevationAt(g[0],g[1],s)}),!0)}getMinMaxForTile(r){if(this.isUsingMockSource())return null;const t=this.findDEMTileFor(r);if(!t||!t.dem)return null;const s=t.dem.tree,l=t.tileID,h=1<<r.canonical.z-l.canonical.z;let g=r.canonical.x/h-l.canonical.x,v=r.canonical.y/h-l.canonical.y,S=0;for(let A=0;A<r.canonical.z-l.canonical.z&&!s.leaves[S];A++){g*=2,v*=2;const P=2*Math.floor(v)+Math.floor(g);S=s.childOffsets[S]+P,g%=1,v%=1}return{min:this.exaggeration()*s.minimums[S],max:this.exaggeration()*s.maximums[S]}}getMinElevationBelowMSL(){throw new Error("Pure virtual method called.")}raycast(r,t,s){throw new Error("Pure virtual method called.")}pointCoordinate(r){throw new Error("Pure virtual method called.")}_source(){throw new Error("Pure virtual method called.")}isUsingMockSource(){throw new Error("Pure virtual method called.")}exaggeration(){throw new Error("Pure virtual method called.")}findDEMTileFor(r){throw new Error("Pure virtual method called.")}get visibleDemTiles(){throw new Error("Getter must be implemented in subclass.")}},i.ErrorEvent=Ir,i.EvaluationParameters=V,i.Event=Es,i.Evented=Zi,i.FillExtrusionBucket=Mp,i.Frustum=ay,i.FrustumCorners=oy,i.GLOBE_RADIUS=Pc,i.GLOBE_SCALE_MATCH_LATITUDE=45,i.GLOBE_ZOOM_THRESHOLD_MAX=r1,i.GLOBE_ZOOM_THRESHOLD_MIN=ly,i.GlobeSharedBuffers=class{constructor(r){this._createGrid(r),this._createPoles(r)}destroy(){this._poleIndexBuffer.destroy(),this._gridBuffer.destroy(),this._gridIndexBuffer.destroy(),this._poleNorthVertexBuffer.destroy(),this._poleSouthVertexBuffer.destroy();for(const r of this._poleSegments)r.destroy();for(const r of this._gridSegments)r.withSkirts.destroy(),r.withoutSkirts.destroy();if(this._wireframeIndexBuffer){this._wireframeIndexBuffer.destroy();for(const r of this._wireframeSegments)r.destroy()}}_fillGridMeshWithLods(r,t){const s=new Jt,l=new Gn,h=[],g=r+1+2,v=t[0]+1,S=t[0]+1+(1+t.length),A=(P,U,G)=>{let j=P===g-1?P-2:P===0?P:P-1;return j+=G?24575:0,[j,U]};for(let P=0;P<g;++P)s.emplaceBack(...A(P,0,!0));for(let P=0;P<v;++P)for(let U=0;U<g;++U)s.emplaceBack(...A(U,P,(U===0||U===g-1)&&!0));for(let P=0;P<t.length;++P){const U=t[P];for(let G=0;G<g;++G)s.emplaceBack(...A(G,U,!0))}for(let P=0;P<t.length;++P){const U=l.length,G=t[P]+1+2,j=new Gn;for(let re=0;re<G-1;re++){const de=re===G-2,we=de?g*(S-t.length+P-re):g;for(let ze=0;ze<g-1;ze++){const Se=re*g+ze;re===0||de||ze===0||ze===g-2?(j.emplaceBack(Se+1,Se,Se+we),j.emplaceBack(Se+we,Se+we+1,Se+1)):(l.emplaceBack(Se+1,Se,Se+we),l.emplaceBack(Se+we,Se+we+1,Se+1))}}const $=jr.simpleSegment(0,U,s.length,l.length-U);for(let re=0;re<j.uint16.length;re+=3)l.emplaceBack(j.uint16[re],j.uint16[re+1],j.uint16[re+2]);const J=jr.simpleSegment(0,U,s.length,l.length-U);h.push({withoutSkirts:$,withSkirts:J})}return{vertices:s,indices:l,segments:h}}_createGrid(r){const t=this._fillGridMeshWithLods(Eh,pp);this._gridSegments=t.segments,this._gridBuffer=r.createVertexBuffer(t.vertices,fp.members),this._gridIndexBuffer=r.createIndexBuffer(t.indices,!0)}_createPoles(r){const t=new Gn;for(let h=0;h<=Eh;h++)t.emplaceBack(0,h+1,h+2);this._poleIndexBuffer=r.createIndexBuffer(t,!0);const s=new ar,l=new ar;this._poleSegments=[];for(let h=0,g=0;h<ly;h++){const v=360/(1<<h);s.emplaceBack(0,-Pc,0,.5,0),l.emplaceBack(0,-Pc,0,.5,1);for(let S=0;S<=Eh;S++){const A=S/Eh,P=gi(0,v,A),[U,G,j]=Bd(nA,iA,P,Pc);s.emplaceBack(U,G,j,A,0),l.emplaceBack(U,G,j,A,1)}this._poleSegments.push(jr.simpleSegment(g,0,66,64)),g+=66}this._poleNorthVertexBuffer=r.createVertexBuffer(s,n1,!1),this._poleSouthVertexBuffer=r.createVertexBuffer(l,n1,!1)}getGridBuffers(r,t){return[this._gridBuffer,this._gridIndexBuffer,t?this._gridSegments[r].withSkirts:this._gridSegments[r].withoutSkirts]}getPoleBuffers(r){return[this._poleNorthVertexBuffer,this._poleSouthVertexBuffer,this._poleIndexBuffer,this._poleSegments[r]]}getWirefameBuffers(r,t){if(!this._wireframeSegments){const s=new us,l=Eh,h=l+1+2,g=1;this._wireframeSegments=[];for(let v=0,S=0;v<pp.length;v++){const A=pp[v];for(let U=g;U<A+g;U++)for(let G=g;G<l+g;G++){const j=U*h+G;s.emplaceBack(j,j+1),s.emplaceBack(j,j+h),s.emplaceBack(j,j+h+1)}const P=A*l*3;this._wireframeSegments.push(jr.simpleSegment(0,S,(A+1)*h,P)),S+=P}this._wireframeIndexBuffer=r.createIndexBuffer(s)}return[this._gridBuffer,this._wireframeIndexBuffer,this._wireframeSegments[t]]}},i.GlyphManager=Yd,i.ImagePosition=ky,i.KDBush=Ky,i.LivePerformanceUtils=Qi,i.LngLat=Mr,i.LngLatBounds=al,i.LocalGlyphMode=By,i.MAX_MERCATOR_LATITUDE=Bo,i.MercatorCoordinate=Vd,i.ONE_EM=So,i.OverscaledTileID=aa,i.PerformanceMarkers=Ni,i.Point=ce,i.Properties=Te,i.RGBAImage=Ya,i.Ray=sy,i.RequestManager=class{constructor(r,t,s){this._transformRequestFn=r,this._customAccessToken=t,this._silenceAuthErrors=!!s,this._createSkuToken()}_createSkuToken(){const r=function(){let t="";for(let s=0;s<10;s++)t+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return{token:["1",Y,t].join(""),tokenExpiresAt:Date.now()+432e5}}();this._skuToken=r.token,this._skuTokenExpiresAt=r.tokenExpiresAt}_isSkuTokenExpired(){return Date.now()>this._skuTokenExpiresAt}transformRequest(r,t){return this._transformRequestFn&&this._transformRequestFn(r,t)||{url:r}}normalizeStyleURL(r,t){if(!je(r))return r;const s=on(r);return s.path=`/styles/v1${s.path}`,this._makeAPIURL(s,this._customAccessToken||t)}normalizeGlyphsURL(r,t){if(!je(r))return r;const s=on(r);return s.path=`/fonts/v1${s.path}`,this._makeAPIURL(s,this._customAccessToken||t)}normalizeSourceURL(r,t,s,l){if(!je(r))return r;const h=on(r);return h.path=`/v4/${h.authority}.json`,h.params.push("secure"),s&&h.params.push(`language=${s}`),l&&h.params.push(`worldview=${l}`),this._makeAPIURL(h,this._customAccessToken||t)}normalizeSpriteURL(r,t,s,l){const h=on(r);return je(r)?(h.path=`/styles/v1${h.path}/sprite${t}${s}`,this._makeAPIURL(h,this._customAccessToken||l)):(h.path+=`${t}${s}`,Kt(h))}normalizeTileURL(r,t,s){if(this._isSkuTokenExpired()&&this._createSkuToken(),r&&!je(r))return r;const l=on(r);l.path=l.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${t||s&&l.authority!=="raster"&&s===512?"@2x":""}${I.supported?".webp":"$1"}`),l.authority==="raster"?l.path=`/${T.RASTER_URL_PREFIX}${l.path}`:(l.path=l.path.replace(/^.+\/v4\//,"/"),l.path=`/${T.TILE_URL_VERSION}${l.path}`);const h=this._customAccessToken||function(g){for(const v of g){const S=v.match(/^access_token=(.*)$/);if(S)return S[1]}return null}(l.params)||T.ACCESS_TOKEN;return T.REQUIRE_ACCESS_TOKEN&&h&&this._skuToken&&l.params.push(`sku=${this._skuToken}`),this._makeAPIURL(l,h)}canonicalizeTileURL(r,t){const s=on(r);if(!s.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!s.path.match(/\.[\w]+$/))return r;let l="mapbox://";s.path.match(/^\/raster\/v1\//)?l+=`raster/${s.path.replace(`/${T.RASTER_URL_PREFIX}/`,"")}`:l+=`tiles/${s.path.replace(`/${T.TILE_URL_VERSION}/`,"")}`;let h=s.params;return t&&(h=h.filter(g=>!g.match(/^access_token=/))),h.length&&(l+=`?${h.join("&")}`),l}canonicalizeTileset(r,t){const s=!!t&&je(t),l=[];for(const h of r.tiles||[])rt(h)?l.push(this.canonicalizeTileURL(h,s)):l.push(h);return l}_makeAPIURL(r,t){const s="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",l=on(T.API_URL);if(r.protocol=l.protocol,r.authority=l.authority,r.protocol==="http"){const h=r.params.indexOf("secure");h>=0&&r.params.splice(h,1)}if(l.path!=="/"&&(r.path=`${l.path}${r.path}`),!T.REQUIRE_ACCESS_TOKEN)return Kt(r);if(t=t||T.ACCESS_TOKEN,!this._silenceAuthErrors){if(!t)throw new Error(`An API access token is required to use Mapbox GL. ${s}`);if(t[0]==="s")throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${s}`)}return r.params=r.params.filter(h=>h.indexOf("access_token")===-1),r.params.push(`access_token=${t||""}`),Kt(r)}},i.ResourceType=Ze,i.SegmentVector=jr,i.SourceCache=Lh,i.StencilMode=Xy,i.StructArrayLayout1ui2=ko,i.StructArrayLayout2f1f2i16=Vn,i.StructArrayLayout2i4=Jt,i.StructArrayLayout2ui4=us,i.StructArrayLayout3f12=si,i.StructArrayLayout3ui6=Gn,i.StructArrayLayout4i8=Bt,i.StructArrayLayout5f20=ar,i.Texture=kp,i.Tile=qy,i.Transitionable=Q,i.Uniform1f=Sh,i.Uniform1i=class extends Cl{constructor(r){super(r),this.current=0}set(r,t,s){this.fetchUniformLocation(r,t)&&this.current!==s&&(this.current=s,this.gl.uniform1i(this.location,s))}},i.Uniform2f=class extends Cl{constructor(r){super(r),this.current=[0,0]}set(r,t,s){this.fetchUniformLocation(r,t)&&(s[0]===this.current[0]&&s[1]===this.current[1]||(this.current=s,this.gl.uniform2f(this.location,s[0],s[1])))}},i.Uniform3f=class extends Cl{constructor(r){super(r),this.current=[0,0,0]}set(r,t,s){this.fetchUniformLocation(r,t)&&(s[0]===this.current[0]&&s[1]===this.current[1]&&s[2]===this.current[2]||(this.current=s,this.gl.uniform3f(this.location,s[0],s[1],s[2])))}},i.Uniform4f=kd,i.UniformColor=Mh,i.UniformMatrix2f=class extends Cl{constructor(r){super(r),this.current=Im}set(r,t,s){if(this.fetchUniformLocation(r,t)){for(let l=0;l<4;l++)if(s[l]!==this.current[l]){this.current=s,this.gl.uniformMatrix2fv(this.location,!1,s);break}}}},i.UniformMatrix3f=class extends Cl{constructor(r){super(r),this.current=ty}set(r,t,s){if(this.fetchUniformLocation(r,t)){for(let l=0;l<9;l++)if(s[l]!==this.current[l]){this.current=s,this.gl.uniformMatrix3fv(this.location,!1,s);break}}}},i.UniformMatrix4f=class extends Cl{constructor(r){super(r),this.current=ey}set(r,t,s){if(this.fetchUniformLocation(r,t)){if(s[12]!==this.current[12]||s[0]!==this.current[0])return this.current=s,void this.gl.uniformMatrix4fv(this.location,!1,s);for(let l=1;l<16;l++)if(s[l]!==this.current[l]){this.current=s,this.gl.uniformMatrix4fv(this.location,!1,s);break}}}},i.UnwrappedTileID=q1,i.ValidationError=Dn,i.VectorTileFeature=Zm,i.VectorTileWorkerSource=class extends Zi{constructor(r,t,s,l,h){super(),this.actor=r,this.layerIndex=t,this.availableImages=s,this.loadVectorData=h||nw,this.loading={},this.loaded={},this.deduped=new tw(r.scheduler),this.isSpriteLoaded=l,this.scheduler=r.scheduler}loadTile(r,t){const s=r.uid,l=r&&r.request,h=l&&l.collectResourceTiming,g=this.loading[s]=new cI(r);g.abort=this.loadVectorData(r,(v,S)=>{const A=!this.loading[s];if(delete this.loading[s],A||v||!S)return g.status="done",A||(this.loaded[s]=g),t(v);const P=S.rawData,U={};S.expires&&(U.expires=S.expires),S.cacheControl&&(U.cacheControl=S.cacheControl),g.vectorTile=S.vectorTile||new Py(new Qm(P));const G=()=>{g.parse(g.vectorTile,this.layerIndex,this.availableImages,this.actor,(j,$)=>{if(j||!$)return t(j);const J={};if(h){const re=ea(l);re.length>0&&(J.resourceTiming=JSON.parse(JSON.stringify(re)))}t(null,Pt({rawTileData:P.slice(0)},$,U,J))})};this.isSpriteLoaded?G():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(G,{type:"parseTile",isSymbolTile:r.isSymbolTile,zoom:r.tileZoom}):G()}),this.loaded=this.loaded||{},this.loaded[s]=g})}reloadTile(r,t){const s=this.loaded,l=r.uid,h=this;if(s&&s[l]){const g=s[l];g.showCollisionBoxes=r.showCollisionBoxes,g.enableTerrain=!!r.enableTerrain,g.projection=r.projection,g.tileTransform=Ph(r.tileID.canonical,r.projection);const v=(S,A)=>{const P=g.reloadCallback;P&&(delete g.reloadCallback,g.parse(g.vectorTile,h.layerIndex,this.availableImages,h.actor,P)),t(S,A)};g.status==="parsing"?g.reloadCallback=v:g.status==="done"&&(g.vectorTile?g.parse(g.vectorTile,this.layerIndex,this.availableImages,this.actor,v):v())}}abortTile(r,t){const s=r.uid,l=this.loading[s];l&&(l.abort&&l.abort(),delete this.loading[s]),t()}removeTile(r,t){const s=this.loaded,l=r.uid;s&&s[l]&&delete s[l],t()}},i.WritingMode=cl,i.ZoomDependentExpression=pc,i.add=Ut,i.addDynamicAttributes=cg,i.adjoint=function(r,t){var s=t[0],l=t[1],h=t[2],g=t[3],v=t[4],S=t[5],A=t[6],P=t[7],U=t[8];return r[0]=v*U-S*P,r[1]=h*P-l*U,r[2]=l*S-h*v,r[3]=S*A-g*U,r[4]=s*U-h*A,r[5]=h*g-s*S,r[6]=g*P-v*A,r[7]=l*A-s*P,r[8]=s*v-l*g,r},i.asyncAll=Et,i.bezier=ft,i.bindAll=Wn,i.boundsAttributes=Bb,i.bufferConvexPolygon=function(r,t){const s=[];for(let l=0;l<r.length;l++){const h=tt(l-1,-1,r.length-1),g=tt(l+1,-1,r.length-1),v=r[l],S=r[g],A=r[h].sub(v).unit(),P=S.sub(v).unit(),U=P.angleWithSep(A.x,A.y),G=A.add(P).unit().mult(-1*t/Math.sin(U/2));s.push(v.add(G))}return s},i.cacheEntryPossiblyAdded=function(r){Fn++,Fn>_n&&(r.getActor().send("enforceCacheSizeLimit",hn),Fn=0)},i.calculateGlobeLabelMatrix=function(r,t){const{x:s,y:l}=r.point,h=c1(s,l,r.worldSize/r._pixelsPerMercatorPixel,0,0);return Ic(h,h,hy(Lc(t)))},i.calculateGlobeMatrix=function(r){const{x:t,y:s}=r.point,{lng:l,lat:h}=r._center;return c1(t,s,r.worldSize,l,h)},i.calculateGlobeMercatorMatrix=function(r){const t=r.pixelsPerMeter,s=t/Xl(1,r.center.lat),l=$a(new Float64Array(16));return su(l,l,[r.point.x,r.point.y,0]),ou(l,l,[s,s,t]),Float32Array.from(l)},i.circumferenceAtLatitude=fy,i.clamp=Fe,i.clearTileCache=function(r){if(!kt())return;const t=w.caches.delete(Tt);r&&t.catch(r).then(()=>r())},i.clipLine=vb,i.clone=function(r){var t=new Oo(16);return t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[8]=r[8],t[9]=r[9],t[10]=r[10],t[11]=r[11],t[12]=r[12],t[13]=r[13],t[14]=r[14],t[15]=r[15],t},i.clone$1=Dt,i.collisionCircleLayout=aC,i.config=T,i.conjugate=function(r,t){return r[0]=-t[0],r[1]=-t[1],r[2]=-t[2],r[3]=t[3],r},i.create=function(){var r=new Oo(16);return Oo!=Float32Array&&(r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[11]=0,r[12]=0,r[13]=0,r[14]=0),r[0]=1,r[5]=1,r[10]=1,r[15]=1,r},i.create$1=Dm,i.createExpression=ja,i.createLayout=$e,i.createStyleLayer=function(r){return r.type==="custom"?new KC(r):new eI[r.type](r)},i.cross=wt,i.degToRad=Xe,i.distance=function(r,t){return Math.hypot(t[0]-r[0],t[1]-r[1],t[2]-r[2])},i.div=function(r,t,s){return r[0]=t[0]/s[0],r[1]=t[1]/s[1],r[2]=t[2]/s[2],r},i.dot=ns,i.earthRadius=_p,i.ease=Nt,i.easeCubicInOut=It,i.ecefToLatLng=function([r,t,s]){const l=Math.hypot(r,t,s),h=Math.atan2(r,s),g=.5*Math.PI-Math.acos(-t/l);return new Mr(St(h),St(g))},i.emitValidationErrors=yh,i.endsWith=jt,i.enforceCacheSizeLimit=function(r){Hn(),Sn&&Sn.then(t=>{t.keys().then(s=>{for(let l=0;l<s.length-r;l++)t.delete(s[l])})})},i.evaluateSizeForFeature=Jm,i.evaluateSizeForZoom=qd,i.evaluateVariableOffset=Eb,i.evented=b,i.exactEquals=function(r,t){return r[0]===t[0]&&r[1]===t[1]&&r[2]===t[2]&&r[3]===t[3]},i.exactEquals$1=function(r,t){return r[0]===t[0]&&r[1]===t[1]&&r[2]===t[2]},i.exported=er,i.exported$1=I,i.extend=Pt,i.extend$1=Ri,i.fillExtrusionHeightLift=j1,i.filterObject=qt,i.fromMat4=function(r,t){return r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[4],r[4]=t[5],r[5]=t[6],r[6]=t[8],r[7]=t[9],r[8]=t[10],r},i.fromQuat=function(r,t){var s=t[0],l=t[1],h=t[2],g=t[3],v=s+s,S=l+l,A=h+h,P=s*v,U=l*v,G=l*S,j=h*v,$=h*S,J=h*A,re=g*v,de=g*S,we=g*A;return r[0]=1-G-J,r[1]=U+we,r[2]=j-de,r[3]=0,r[4]=U-we,r[5]=1-P-J,r[6]=$+re,r[7]=0,r[8]=j+de,r[9]=$-re,r[10]=1-P-G,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r},i.fromRotation=function(r,t){var s=Math.sin(t),l=Math.cos(t);return r[0]=l,r[1]=s,r[2]=0,r[3]=-s,r[4]=l,r[5]=0,r[6]=0,r[7]=0,r[8]=1,r},i.fromScaling=x,i.furthestTileCorner=function(r){const t=Math.round((r+45+360)%360/90)%4;return Je[t]},i.getAABBPointSquareDist=function(r,t,s){let l=0;for(let h=0;h<2;++h){const g=s?s[h]:0;r[h]>g&&(l+=(r[h]-g)*(r[h]-g)),t[h]<g&&(l+=(g-t[h])*(g-t[h]))}return l},i.getAnchorAlignment=Fy,i.getAnchorJustification=Uy,i.getBounds=function(r){let t=1/0,s=1/0,l=-1/0,h=-1/0;for(const g of r)t=Math.min(t,g.x),s=Math.min(s,g.y),l=Math.max(l,g.x),h=Math.max(h,g.y);return{min:new ce(t,s),max:new ce(l,h)}},i.getColumn=xe,i.getDefaultExportFromCjs=K,i.getGridMatrix=function(r,t,s,l){const h=t.getNorth(),g=t.getSouth(),v=t.getWest(),S=t.getEast(),A=1<<r.z,P=S-v,U=h-g,G=P/Eh,j=-U/pp[s],$=[0,G,0,j,0,0,h,v,0];if(r.z>0){const J=180/l;hp($,$,[J/P+1,0,0,0,J/U+1,0,-.5*J/G,.5*J/j,1])}return $[2]=A,$[5]=r.x,$[8]=r.y,$},i.getImage=ye,i.getJSON=function(r,t){return We(Pt(r,{type:"json"}),t)},i.getLatitudinalLod=function(r){const t=Bo-5;r=Fe(r,-t,t)/t*90;const s=Math.pow(Math.abs(Math.sin(Xe(r))),3);return Math.round(s*(pp.length-1))},i.getMapSessionAPI=ui,i.getPerformanceMeasurement=ea,i.getProjection=Db,i.getRTLTextPluginStatus=M,i.getReferrer=bn,i.getTilePoint=function(r,{x:t,y:s},l=0){return new ce(((t-l)*r.scale-r.x)*Zn,(s*r.scale-r.y)*Zn)},i.getTileVec3=function(r,t,s=0){return at(((t.x-s)*r.scale-r.x)*Zn,(t.y*r.scale-r.y)*Zn,f1(t.z,t.y))},i.getVideo=function(r,t){const s=w.document.createElement("video");s.muted=!0,s.onloadstart=function(){t(null,s)};for(let l=0;l<r.length;l++){const h=w.document.createElement("source");un(r[l])||(s.crossOrigin="Anonymous"),h.src=r[l],s.appendChild(h)}return{cancel:()=>{}}},i.globeCenterToScreenPoint=function(r){const t=[0,0,0],s=$a(new Float64Array(16));return Ic(s,r.pixelMatrix,r.globeMatrix),Ke(t,t,s),new ce(t[0],t[1])},i.globeDenormalizeECEF=hy,i.globeECEFOrigin=function(r,t){const s=[0,0,0];return Ke(s,s,gp(Lc(t.canonical))),Ke(s,s,r),s},i.globeMetersToEcef=km,i.globeNormalizeECEF=gp,i.globePixelsToTileUnits=function(r,t){return Zn/(512*Math.pow(2,r))*Fm(Lc(t))},i.globePoleMatrixForTile=function(r,t,s){const l=$a(new Float64Array(16)),h=(t/(1<<r)-.5)*Math.PI*2;return _(l,s.globeMatrix,h),Float32Array.from(l)},i.globeTileBounds=Lc,i.globeTiltAtLngLat=u1,i.globeToMercatorTransition=Ud,i.globeUseCustomAntiAliasing=function(r,t,s){const l=Ud(s.zoom),h=r.style.map._antialias,g=!!t.extStandardDerivatives,v=t.extStandardDerivativesForceOff||r.terrain&&r.terrain.exaggeration()>0;return l===0&&!h&&!v&&g},i.identity=$a,i.identity$1=zm,i.invert=Fd,i.isFullscreen=function(){return!!w.document.fullscreenElement||!!w.document.webkitFullscreenElement},i.isLngLatBehindGlobe=dy,i.isMapAuthenticated=function(r){return ai.has(r)},i.isMapboxURL=je,i.isSafariWithAntialiasingBug=function(r){const t=r.navigator?r.navigator.userAgent:null;return!!ti(r)&&t&&(t.match("Version/15.4")||t.match("Version/15.5")||t.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},i.latFromMercatorY=Fo,i.latLngToECEF=Nd,i.len=Hi,i.length=Pe,i.length$1=function(r){return Math.hypot(r[0],r[1],r[2],r[3])},i.lngFromMercatorX=ll,i.loadVectorTile=nw,i.makeRequest=We,i.mapValue=function(r,t,s,l,h){return Fe((r-t)/(s-t)*(h-l)+l,l,h)},i.mercatorScale=p1,i.mercatorXfromLng=Rc,i.mercatorYfromLat=Dc,i.mercatorZfromAltitude=Xl,i.mul=N,i.mul$1=Yi,i.multiply=Ic,i.multiply$1=hp,i.multiply$2=Qn,i.nextPowerOfTwo=ei,i.normalize=br,i.normalize$1=Y2,i.normalize$2=Ws,i.number=gi,i.ortho=function(r,t,s,l,h,g,v){var S=1/(t-s),A=1/(l-h),P=1/(g-v);return r[0]=-2*S,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=-2*A,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=2*P,r[11]=0,r[12]=(t+s)*S,r[13]=(h+l)*A,r[14]=(v+g)*P,r[15]=1,r},i.pbf=Q1,i.perspective=function(r,t,s,l,h){var g,v=1/Math.tan(t/2);return r[0]=v/s,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=v,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[11]=-1,r[12]=0,r[13]=0,r[15]=0,h!=null&&h!==1/0?(r[10]=(h+l)*(g=1/(l-h)),r[14]=2*h*l*g):(r[10]=-1,r[14]=-2*l),r},i.pick=function(r,t){const s={};for(let l=0;l<t.length;l++){const h=t[l];h in r&&(s[h]=r[h])}return s},i.plugin=z,i.pointGeometry=Ae,i.polesInViewport=function(r){const t=$a(new Float64Array(16));Ic(t,r.pixelMatrix,r.globeMatrix);const s=[0,Il,0],l=[0,Pl,0];return Ke(s,s,t),Ke(l,l,t),[s[0]>0&&s[0]<=r.width&&s[1]>0&&s[1]<=r.height&&!dy(r,new Mr(r.center.lat,90)),l[0]>0&&l[0]<=r.width&&l[1]>0&&l[1]<=r.height&&!dy(r,new Mr(r.center.lat,-90))]},i.polygonContainsPoint=Ch,i.polygonIntersectsBox=b1,i.polygonIntersectsPolygon=_1,i.polygonizeBounds=function(r,t,s=0,l=!0){const h=new ce(s,s),g=r.sub(h),v=t.add(h),S=[g,new ce(v.x,g.y),v,new ce(g.x,v.y)];return l&&S.push(g.clone()),S},i.posAttributes=fp,i.postMapLoadEvent=Gt,i.postPerformanceEvent=Yn,i.postTurnstileEvent=lt,i.potpack=zy,i.prevPowerOfTwo=function(r){return r<=1?1:Math.pow(2,Math.floor(Math.log(r)/Math.LN2))},i.radToDeg=St,i.refProperties=["type","source","source-layer","minzoom","maxzoom","filter","layout"],i.registerForPluginStateChange=function(r){return r({pluginStatus:p,pluginURL:o}),b.on("pluginStateChange",r),r},i.removeAuthState=function(r){ai.delete(r)},i.renderColorRamp=by,i.resample=m1,i.rotateX=dp,i.rotateX$1=e1,i.rotateY=_,i.rotateY$1=t1,i.rotateZ=function(r,t,s){var l=Math.sin(s),h=Math.cos(s),g=t[0],v=t[1],S=t[2],A=t[3],P=t[4],U=t[5],G=t[6],j=t[7];return t!==r&&(r[8]=t[8],r[9]=t[9],r[10]=t[10],r[11]=t[11],r[12]=t[12],r[13]=t[13],r[14]=t[14],r[15]=t[15]),r[0]=g*h+P*l,r[1]=v*h+U*l,r[2]=S*h+G*l,r[3]=A*h+j*l,r[4]=P*h-g*l,r[5]=U*h-v*l,r[6]=G*h-S*l,r[7]=j*h-A*l,r},i.rotateZ$1=function(r,t,s){s*=.5;var l=t[0],h=t[1],g=t[2],v=t[3],S=Math.sin(s),A=Math.cos(s);return r[0]=l*A+h*S,r[1]=h*A-l*S,r[2]=g*A+v*S,r[3]=v*A-g*S,r},i.scale=ou,i.scale$1=_r,i.scale$2=Ki,i.scaleAndAdd=fi,i.set=function(r,t,s,l){return r[0]=t,r[1]=s,r[2]=l,r},i.setCacheLimits=function(r,t){hn=r,_n=t},i.setColumn=function(r,t,s){r[4*t+0]=s[0],r[4*t+1]=s[1],r[4*t+2]=s[2],r[4*t+3]=s[3]},i.setRTLTextPlugin=function(r,t,s=!1){if(p===Bn||p===Mc||p===ru)throw new Error("setRTLTextPlugin cannot be called multiple times.");o=er.resolveURL(r),p=Bn,Hl=t,y(),s||R()},i.smoothstep=it,i.spec=ct,i.squaredLength=function(r){var t=r[0],s=r[1],l=r[2];return t*t+s*s+l*l},i.storeAuthState=function(r,t){t?ai.add(r):ai.delete(r)},i.sub=Jn,i.subtract=Cn,i.symbolSize=lC,i.tileAABB=function(r,t,s,l,h,g,v,S,A){if(A.name==="globe")return tA(r,t,new $m(s,l,h));const P=Ph({z:s,x:l,y:h},A);return new oa([(g+P.x/P.scale)*t,t*(P.y/P.scale),v],[(g+P.x2/P.scale)*t,t*(P.y2/P.scale),S])},i.tileCornersToBounds=Om,i.tileTransform=Ph,i.transformMat3=function(r,t,s){var l=t[0],h=t[1],g=t[2];return r[0]=l*s[0]+h*s[3]+g*s[6],r[1]=l*s[1]+h*s[4]+g*s[7],r[2]=l*s[2]+h*s[5]+g*s[8],r},i.transformMat4=Ke,i.transformMat4$1=rr,i.transformQuat=Vt,i.transitionTileAABBinECEF=o1,i.translate=su,i.transpose=function(r,t){if(r===t){var s=t[1],l=t[2],h=t[5];r[1]=t[3],r[2]=t[6],r[3]=s,r[5]=t[7],r[6]=l,r[7]=h}else r[0]=t[0],r[1]=t[3],r[2]=t[6],r[3]=t[1],r[4]=t[4],r[5]=t[7],r[6]=t[2],r[7]=t[5],r[8]=t[8];return r},i.triggerPluginCompletionEvent=u,i.uniqueId=pn,i.updateGlobeVertexNormal=function(r,t,s,l,h){const g=5*t+2;r.float32[g+0]=s,r.float32[g+1]=l,r.float32[g+2]=h},i.validateCustomStyleLayer=function(r){const t=[],s=r.id;return s===void 0&&t.push({message:`layers.${s}: missing required property "id"`}),r.render===void 0&&t.push({message:`layers.${s}: missing required method "render"`}),r.renderingMode&&r.renderingMode!=="2d"&&r.renderingMode!=="3d"&&t.push({message:`layers.${s}: property "renderingMode" must be either "2d" or "3d"`}),t},i.validateFilter=r=>zo(bc(r)),i.validateFog=r=>zo(Do(r)),i.validateLayer=r=>zo(eu(r)),i.validateLight=r=>zo(Ad(r)),i.validateSource=r=>zo(Sc(r)),i.validateStyle=_h,i.validateTerrain=r=>zo(gh(r)),i.values=xt,i.vectorTile=qm,i.version=E,i.warnOnce=wn,i.window=w,i.wrap=tt}),f(["./shared"],function(i){function w(ue){if(typeof ue=="number"||typeof ue=="boolean"||typeof ue=="string"||ue==null)return JSON.stringify(ue);if(Array.isArray(ue)){let se="[";for(const ye of ue)se+=`${w(ye)},`;return`${se}]`}let te="{";for(const se of Object.keys(ue).sort())te+=`${se}:${w(ue[se])},`;return`${te}}`}function E(ue){let te="";for(const se of i.refProperties)te+=`/${w(ue[se])}`;return te}class C{constructor(te){this.keyCache={},te&&this.replace(te)}replace(te){this._layerConfigs={},this._layers={},this.update(te,[])}update(te,se){for(const De of te)this._layerConfigs[De.id]=De,(this._layers[De.id]=i.createStyleLayer(De)).compileFilter(),this.keyCache[De.id]&&delete this.keyCache[De.id];for(const De of se)delete this.keyCache[De],delete this._layerConfigs[De],delete this._layers[De];this.familiesBySource={};const ye=function(De,je){const rt={};for(let He=0;He<De.length;He++){const pt=je&&je[De[He].id]||E(De[He]);je&&(je[De[He].id]=pt);let Zt=rt[pt];Zt||(Zt=rt[pt]=[]),Zt.push(De[He])}const st=[];for(const He in rt)st.push(rt[He]);return st}(i.values(this._layerConfigs),this.keyCache);for(const De of ye){const je=De.map(on=>this._layers[on.id]),rt=je[0];if(rt.visibility==="none")continue;const st=rt.source||"";let He=this.familiesBySource[st];He||(He=this.familiesBySource[st]={});const pt=rt.sourceLayer||"_geojsonTileLayer";let Zt=He[pt];Zt||(Zt=He[pt]=[]),Zt.push(je)}}}class T{loadTile(te,se){const{uid:ye,encoding:De,rawImageData:je,padding:rt,buildQuadTree:st}=te,He=i.window.ImageBitmap&&je instanceof i.window.ImageBitmap?this.getImageData(je,rt):je;se(null,new i.DEMData(ye,He,De,rt<1,st))}getImageData(te,se){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(te.width,te.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=te.width,this.offscreenCanvas.height=te.height,this.offscreenCanvasContext.drawImage(te,0,0,te.width,te.height);const ye=this.offscreenCanvasContext.getImageData(-se,-se,te.width+2*se,te.height+2*se);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),ye}}function I(ue,te){if(ue.length!==0){k(ue[0],te);for(var se=1;se<ue.length;se++)k(ue[se],!te)}}function k(ue,te){for(var se=0,ye=0,De=0,je=ue.length,rt=je-1;De<je;rt=De++){var st=(ue[De][0]-ue[rt][0])*(ue[rt][1]+ue[De][1]),He=se+st;ye+=Math.abs(se)>=Math.abs(st)?se-He+st:st-He+se,se=He}se+ye>=0!=!!te&&ue.reverse()}var O=i.getDefaultExportFromCjs(function ue(te,se){var ye,De=te&&te.type;if(De==="FeatureCollection")for(ye=0;ye<te.features.length;ye++)ue(te.features[ye],se);else if(De==="GeometryCollection")for(ye=0;ye<te.geometries.length;ye++)ue(te.geometries[ye],se);else if(De==="Feature")ue(te.geometry,se);else if(De==="Polygon")I(te.coordinates,se);else if(De==="MultiPolygon")for(ye=0;ye<te.coordinates.length;ye++)I(te.coordinates[ye],se);return te});const B=i.VectorTileFeature.prototype.toGeoJSON;var F={exports:{}},H=i.pointGeometry,Y=i.vectorTile.VectorTileFeature,K=ne;function ne(ue,te){this.options=te||{},this.features=ue,this.length=ue.length}function le(ue,te){this.id=typeof ue.id=="number"?ue.id:void 0,this.type=ue.type,this.rawGeometry=ue.type===1?[ue.geometry]:ue.geometry,this.properties=ue.tags,this.extent=te||4096}ne.prototype.feature=function(ue){return new le(this.features[ue],this.options.extent)},le.prototype.loadGeometry=function(){var ue=this.rawGeometry;this.geometry=[];for(var te=0;te<ue.length;te++){for(var se=ue[te],ye=[],De=0;De<se.length;De++)ye.push(new H(se[De][0],se[De][1]));this.geometry.push(ye)}return this.geometry},le.prototype.bbox=function(){this.geometry||this.loadGeometry();for(var ue=this.geometry,te=1/0,se=-1/0,ye=1/0,De=-1/0,je=0;je<ue.length;je++)for(var rt=ue[je],st=0;st<rt.length;st++){var He=rt[st];te=Math.min(te,He.x),se=Math.max(se,He.x),ye=Math.min(ye,He.y),De=Math.max(De,He.y)}return[te,ye,se,De]},le.prototype.toGeoJSON=Y.prototype.toGeoJSON;var fe=i.pbf,Ae=K;function oe(ue){var te=new fe;return function(se,ye){for(var De in se.layers)ye.writeMessage(3,ce,se.layers[De])}(ue,te),te.finish()}function ce(ue,te){var se;te.writeVarintField(15,ue.version||1),te.writeStringField(1,ue.name||""),te.writeVarintField(5,ue.extent||4096);var ye={keys:[],values:[],keycache:{},valuecache:{}};for(se=0;se<ue.length;se++)ye.feature=ue.feature(se),te.writeMessage(2,Re,ye);var De=ye.keys;for(se=0;se<De.length;se++)te.writeStringField(3,De[se]);var je=ye.values;for(se=0;se<je.length;se++)te.writeMessage(4,It,je[se])}function Re(ue,te){var se=ue.feature;se.id!==void 0&&te.writeVarintField(1,se.id),te.writeMessage(2,ke,ue),te.writeVarintField(3,se.type),te.writeMessage(4,Je,se)}function ke(ue,te){var se=ue.feature,ye=ue.keys,De=ue.values,je=ue.keycache,rt=ue.valuecache;for(var st in se.properties){var He=se.properties[st],pt=je[st];if(He!==null){pt===void 0&&(ye.push(st),je[st]=pt=ye.length-1),te.writeVarint(pt);var Zt=typeof He;Zt!=="string"&&Zt!=="boolean"&&Zt!=="number"&&(He=JSON.stringify(He));var on=Zt+":"+He,Kt=rt[on];Kt===void 0&&(De.push(He),rt[on]=Kt=De.length-1),te.writeVarint(Kt)}}}function Xe(ue,te){return(te<<3)+(7&ue)}function St(ue){return ue<<1^ue>>31}function Je(ue,te){for(var se=ue.loadGeometry(),ye=ue.type,De=0,je=0,rt=se.length,st=0;st<rt;st++){var He=se[st],pt=1;ye===1&&(pt=He.length),te.writeVarint(Xe(1,pt));for(var Zt=ye===3?He.length-1:He.length,on=0;on<Zt;on++){on===1&&ye!==1&&te.writeVarint(Xe(2,Zt-1));var Kt=He[on].x-De,xi=He[on].y-je;te.writeVarint(St(Kt)),te.writeVarint(St(xi)),De+=Kt,je+=xi}ye===3&&te.writeVarint(Xe(7,1))}}function It(ue,te){var se=typeof ue;se==="string"?te.writeStringField(1,ue):se==="boolean"?te.writeBooleanField(7,ue):se==="number"&&(ue%1!=0?te.writeDoubleField(3,ue):ue<0?te.writeSVarintField(6,ue):te.writeVarintField(5,ue))}F.exports=oe,F.exports.fromVectorTileJs=oe,F.exports.fromGeojsonVt=function(ue,te){te=te||{};var se={};for(var ye in ue)se[ye]=new Ae(ue[ye].features,te),se[ye].name=ye,se[ye].version=te.version,se[ye].extent=te.extent;return oe({layers:se})},F.exports.GeoJSONWrapper=Ae;var ft=i.getDefaultExportFromCjs(F.exports);const Nt={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:ue=>ue},Fe=Math.fround||(it=new Float32Array(1),ue=>(it[0]=+ue,it[0]));var it;const tt=3,Et=5,xt=6;class Pt{constructor(te){this.options=Object.assign(Object.create(Nt),te),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(te){const{log:se,minZoom:ye,maxZoom:De}=this.options;se&&console.time("total time");const je=`prepare ${te.length} points`;se&&console.time(je),this.points=te;const rt=[];for(let He=0;He<te.length;He++){const pt=te[He];if(!pt.geometry)continue;const[Zt,on]=pt.geometry.coordinates,Kt=Fe(Mt(Zt)),xi=Fe(ei(on));rt.push(Kt,xi,1/0,He,-1,1),this.options.reduce&&rt.push(0)}let st=this.trees[De+1]=this._createTree(rt);se&&console.timeEnd(je);for(let He=De;He>=ye;He--){const pt=+Date.now();st=this.trees[He]=this._createTree(this._cluster(st,He)),se&&console.log("z%d: %d clusters in %dms",He,st.numItems,+Date.now()-pt)}return se&&console.timeEnd("total time"),this}getClusters(te,se){let ye=((te[0]+180)%360+360)%360-180;const De=Math.max(-90,Math.min(90,te[1]));let je=te[2]===180?180:((te[2]+180)%360+360)%360-180;const rt=Math.max(-90,Math.min(90,te[3]));if(te[2]-te[0]>=360)ye=-180,je=180;else if(ye>je){const on=this.getClusters([ye,De,180,rt],se),Kt=this.getClusters([-180,De,je,rt],se);return on.concat(Kt)}const st=this.trees[this._limitZoom(se)],He=st.range(Mt(ye),ei(rt),Mt(je),ei(De)),pt=st.data,Zt=[];for(const on of He){const Kt=this.stride*on;Zt.push(pt[Kt+Et]>1?ln(pt,Kt,this.clusterProps):this.points[pt[Kt+tt]])}return Zt}getChildren(te){const se=this._getOriginId(te),ye=this._getOriginZoom(te),De="No cluster with the specified id.",je=this.trees[ye];if(!je)throw new Error(De);const rt=je.data;if(se*this.stride>=rt.length)throw new Error(De);const st=this.options.radius/(this.options.extent*Math.pow(2,ye-1)),He=je.within(rt[se*this.stride],rt[se*this.stride+1],st),pt=[];for(const Zt of He){const on=Zt*this.stride;rt[on+4]===te&&pt.push(rt[on+Et]>1?ln(rt,on,this.clusterProps):this.points[rt[on+tt]])}if(pt.length===0)throw new Error(De);return pt}getLeaves(te,se,ye){const De=[];return this._appendLeaves(De,te,se=se||10,ye=ye||0,0),De}getTile(te,se,ye){const De=this.trees[this._limitZoom(te)],je=Math.pow(2,te),{extent:rt,radius:st}=this.options,He=st/rt,pt=(ye-He)/je,Zt=(ye+1+He)/je,on={features:[]};return this._addTileFeatures(De.range((se-He)/je,pt,(se+1+He)/je,Zt),De.data,se,ye,je,on),se===0&&this._addTileFeatures(De.range(1-He/je,pt,1,Zt),De.data,je,ye,je,on),se===je-1&&this._addTileFeatures(De.range(0,pt,He/je,Zt),De.data,-1,ye,je,on),on.features.length?on:null}getClusterExpansionZoom(te){let se=this._getOriginZoom(te)-1;for(;se<=this.options.maxZoom;){const ye=this.getChildren(te);if(se++,ye.length!==1)break;te=ye[0].properties.cluster_id}return se}_appendLeaves(te,se,ye,De,je){const rt=this.getChildren(se);for(const st of rt){const He=st.properties;if(He&&He.cluster?je+He.point_count<=De?je+=He.point_count:je=this._appendLeaves(te,He.cluster_id,ye,De,je):je<De?je++:te.push(st),te.length===ye)break}return je}_createTree(te){const se=new i.KDBush(te.length/this.stride|0,this.options.nodeSize,Float32Array);for(let ye=0;ye<te.length;ye+=this.stride)se.add(te[ye],te[ye+1]);return se.finish(),se.data=te,se}_addTileFeatures(te,se,ye,De,je,rt){for(const st of te){const He=st*this.stride,pt=se[He+Et]>1;let Zt,on,Kt;if(pt)Zt=pn(se,He,this.clusterProps),on=se[He],Kt=se[He+1];else{const ve=this.points[se[He+tt]];Zt=ve.properties;const[Qe,lt]=ve.geometry.coordinates;on=Mt(Qe),Kt=ei(lt)}const xi={type:1,geometry:[[Math.round(this.options.extent*(on*je-ye)),Math.round(this.options.extent*(Kt*je-De))]],tags:Zt};let ci;ci=pt||this.options.generateId?se[He+tt]:this.points[se[He+tt]].id,ci!==void 0&&(xi.id=ci),rt.features.push(xi)}}_limitZoom(te){return Math.max(this.options.minZoom,Math.min(Math.floor(+te),this.options.maxZoom+1))}_cluster(te,se){const{radius:ye,extent:De,reduce:je,minPoints:rt}=this.options,st=ye/(De*Math.pow(2,se)),He=te.data,pt=[],Zt=this.stride;for(let on=0;on<He.length;on+=Zt){if(He[on+2]<=se)continue;He[on+2]=se;const Kt=He[on],xi=He[on+1],ci=te.within(He[on],He[on+1],st),ve=He[on+Et];let Qe=ve;for(const lt of ci){const mt=lt*Zt;He[mt+2]>se&&(Qe+=He[mt+Et])}if(Qe>ve&&Qe>=rt){let lt,mt=Kt*ve,Gt=xi*ve,$n=-1;const Yn=((on/Zt|0)<<5)+(se+1)+this.points.length;for(const bi of ci){const ui=bi*Zt;if(He[ui+2]<=se)continue;He[ui+2]=se;const ai=He[ui+Et];mt+=He[ui]*ai,Gt+=He[ui+1]*ai,He[ui+4]=Yn,je&&(lt||(lt=this._map(He,on,!0),$n=this.clusterProps.length,this.clusterProps.push(lt)),je(lt,this._map(He,ui)))}He[on+4]=Yn,pt.push(mt/Qe,Gt/Qe,1/0,Yn,-1,Qe),je&&pt.push($n)}else{for(let lt=0;lt<Zt;lt++)pt.push(He[on+lt]);if(Qe>1)for(const lt of ci){const mt=lt*Zt;if(!(He[mt+2]<=se)){He[mt+2]=se;for(let Gt=0;Gt<Zt;Gt++)pt.push(He[mt+Gt])}}}}return pt}_getOriginId(te){return te-this.points.length>>5}_getOriginZoom(te){return(te-this.points.length)%32}_map(te,se,ye){if(te[se+Et]>1){const rt=this.clusterProps[te[se+xt]];return ye?Object.assign({},rt):rt}const De=this.points[te[se+tt]].properties,je=this.options.map(De);return ye&&je===De?Object.assign({},je):je}}function ln(ue,te,se){return{type:"Feature",id:ue[te+tt],properties:pn(ue,te,se),geometry:{type:"Point",coordinates:[(ye=ue[te],360*(ye-.5)),oi(ue[te+1])]}};var ye}function pn(ue,te,se){const ye=ue[te+Et],De=ye>=1e4?`${Math.round(ye/1e3)}k`:ye>=1e3?Math.round(ye/100)/10+"k":ye,je=ue[te+xt],rt=je===-1?{}:Object.assign({},se[je]);return Object.assign(rt,{cluster:!0,cluster_id:ue[te+tt],point_count:ye,point_count_abbreviated:De})}function Mt(ue){return ue/360+.5}function ei(ue){const te=Math.sin(ue*Math.PI/180),se=.5-.25*Math.log((1+te)/(1-te))/Math.PI;return se<0?0:se>1?1:se}function oi(ue){const te=(180-360*ue)*Math.PI/180;return 360*Math.atan(Math.exp(te))/Math.PI-90}function Wn(ue,te,se,ye){for(var De,je=ye,rt=se-te>>1,st=se-te,He=ue[te],pt=ue[te+1],Zt=ue[se],on=ue[se+1],Kt=te+3;Kt<se;Kt+=3){var xi=jt(ue[Kt],ue[Kt+1],He,pt,Zt,on);if(xi>je)De=Kt,je=xi;else if(xi===je){var ci=Math.abs(Kt-rt);ci<st&&(De=Kt,st=ci)}}je>ye&&(De-te>3&&Wn(ue,te,De,ye),ue[De+2]=je,se-De>3&&Wn(ue,De,se,ye))}function jt(ue,te,se,ye,De,je){var rt=De-se,st=je-ye;if(rt!==0||st!==0){var He=((ue-se)*rt+(te-ye)*st)/(rt*rt+st*st);He>1?(se=De,ye=je):He>0&&(se+=rt*He,ye+=st*He)}return(rt=ue-se)*rt+(st=te-ye)*st}function mn(ue,te,se,ye){var De={id:ue===void 0?null:ue,type:te,geometry:se,tags:ye,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(je){var rt=je.geometry,st=je.type;if(st==="Point"||st==="MultiPoint"||st==="LineString")qt(je,rt);else if(st==="Polygon"||st==="MultiLineString")for(var He=0;He<rt.length;He++)qt(je,rt[He]);else if(st==="MultiPolygon")for(He=0;He<rt.length;He++)for(var pt=0;pt<rt[He].length;pt++)qt(je,rt[He][pt])}(De),De}function qt(ue,te){for(var se=0;se<te.length;se+=3)ue.minX=Math.min(ue.minX,te[se]),ue.minY=Math.min(ue.minY,te[se+1]),ue.maxX=Math.max(ue.maxX,te[se]),ue.maxY=Math.max(ue.maxY,te[se+1])}function Dt(ue,te,se,ye){if(te.geometry){var De=te.geometry.coordinates,je=te.geometry.type,rt=Math.pow(se.tolerance/((1<<se.maxZoom)*se.extent),2),st=[],He=te.id;if(se.promoteId?He=te.properties[se.promoteId]:se.generateId&&(He=ye||0),je==="Point")gn(De,st);else if(je==="MultiPoint")for(var pt=0;pt<De.length;pt++)gn(De[pt],st);else if(je==="LineString")wn(De,st,rt,!1);else if(je==="MultiLineString"){if(se.lineMetrics){for(pt=0;pt<De.length;pt++)wn(De[pt],st=[],rt,!1),ue.push(mn(He,"LineString",st,te.properties));return}Yt(De,st,rt,!1)}else if(je==="Polygon")Yt(De,st,rt,!0);else{if(je!=="MultiPolygon"){if(je==="GeometryCollection"){for(pt=0;pt<te.geometry.geometries.length;pt++)Dt(ue,{id:He,geometry:te.geometry.geometries[pt],properties:te.properties},se,ye);return}throw new Error("Input data is not a valid GeoJSON object.")}for(pt=0;pt<De.length;pt++){var Zt=[];Yt(De[pt],Zt,rt,!0),st.push(Zt)}}ue.push(mn(He,je,st,te.properties))}}function gn(ue,te){te.push(rn(ue[0])),te.push(dn(ue[1])),te.push(0)}function wn(ue,te,se,ye){for(var De,je,rt=0,st=0;st<ue.length;st++){var He=rn(ue[st][0]),pt=dn(ue[st][1]);te.push(He),te.push(pt),te.push(0),st>0&&(rt+=ye?(De*pt-He*je)/2:Math.sqrt(Math.pow(He-De,2)+Math.pow(pt-je,2))),De=He,je=pt}var Zt=te.length-3;te[2]=1,Wn(te,0,Zt,se),te[Zt+2]=1,te.size=Math.abs(rt),te.start=0,te.end=te.size}function Yt(ue,te,se,ye){for(var De=0;De<ue.length;De++){var je=[];wn(ue[De],je,se,ye),te.push(je)}}function rn(ue){return ue/360+.5}function dn(ue){var te=Math.sin(ue*Math.PI/180),se=.5-.25*Math.log((1+te)/(1-te))/Math.PI;return se<0?0:se>1?1:se}function Mn(ue,te,se,ye,De,je,rt,st){if(ye/=te,je>=(se/=te)&&rt<ye)return ue;if(rt<se||je>=ye)return null;for(var He=[],pt=0;pt<ue.length;pt++){var Zt=ue[pt],on=Zt.geometry,Kt=Zt.type,xi=De===0?Zt.minX:Zt.minY,ci=De===0?Zt.maxX:Zt.maxY;if(xi>=se&&ci<ye)He.push(Zt);else if(!(ci<se||xi>=ye)){var ve=[];if(Kt==="Point"||Kt==="MultiPoint")li(on,ve,se,ye,De);else if(Kt==="LineString")ti(on,ve,se,ye,De,!1,st.lineMetrics);else if(Kt==="MultiLineString")xe(on,ve,se,ye,De,!1);else if(Kt==="Polygon")xe(on,ve,se,ye,De,!0);else if(Kt==="MultiPolygon")for(var Qe=0;Qe<on.length;Qe++){var lt=[];xe(on[Qe],lt,se,ye,De,!0),lt.length&&ve.push(lt)}if(ve.length){if(st.lineMetrics&&Kt==="LineString"){for(Qe=0;Qe<ve.length;Qe++)He.push(mn(Zt.id,Kt,ve[Qe],Zt.tags));continue}Kt!=="LineString"&&Kt!=="MultiLineString"||(ve.length===1?(Kt="LineString",ve=ve[0]):Kt="MultiLineString"),Kt!=="Point"&&Kt!=="MultiPoint"||(Kt=ve.length===3?"Point":"MultiPoint"),He.push(mn(Zt.id,Kt,ve,Zt.tags))}}}return He.length?He:null}function li(ue,te,se,ye,De){for(var je=0;je<ue.length;je+=3){var rt=ue[je+De];rt>=se&&rt<=ye&&(te.push(ue[je]),te.push(ue[je+1]),te.push(ue[je+2]))}}function ti(ue,te,se,ye,De,je,rt){for(var st,He,pt=Ie(ue),Zt=De===0?hn:_n,on=ue.start,Kt=0;Kt<ue.length-3;Kt+=3){var xi=ue[Kt],ci=ue[Kt+1],ve=ue[Kt+2],Qe=ue[Kt+3],lt=ue[Kt+4],mt=De===0?xi:ci,Gt=De===0?Qe:lt,$n=!1;rt&&(st=Math.sqrt(Math.pow(xi-Qe,2)+Math.pow(ci-lt,2))),mt<se?Gt>se&&(He=Zt(pt,xi,ci,Qe,lt,se),rt&&(pt.start=on+st*He)):mt>ye?Gt<ye&&(He=Zt(pt,xi,ci,Qe,lt,ye),rt&&(pt.start=on+st*He)):Tt(pt,xi,ci,ve),Gt<se&&mt>=se&&(He=Zt(pt,xi,ci,Qe,lt,se),$n=!0),Gt>ye&&mt<=ye&&(He=Zt(pt,xi,ci,Qe,lt,ye),$n=!0),!je&&$n&&(rt&&(pt.end=on+st*He),te.push(pt),pt=Ie(ue)),rt&&(on+=st)}var Yn=ue.length-3;xi=ue[Yn],ci=ue[Yn+1],ve=ue[Yn+2],(mt=De===0?xi:ci)>=se&&mt<=ye&&Tt(pt,xi,ci,ve),Yn=pt.length-3,je&&Yn>=3&&(pt[Yn]!==pt[0]||pt[Yn+1]!==pt[1])&&Tt(pt,pt[0],pt[1],pt[2]),pt.length&&te.push(pt)}function Ie(ue){var te=[];return te.size=ue.size,te.start=ue.start,te.end=ue.end,te}function xe(ue,te,se,ye,De,je){for(var rt=0;rt<ue.length;rt++)ti(ue[rt],te,se,ye,De,je,!1)}function Tt(ue,te,se,ye){ue.push(te),ue.push(se),ue.push(ye)}function hn(ue,te,se,ye,De,je){var rt=(je-te)/(ye-te);return ue.push(je),ue.push(se+(De-se)*rt),ue.push(1),rt}function _n(ue,te,se,ye,De,je){var rt=(je-se)/(De-se);return ue.push(te+(ye-te)*rt),ue.push(je),ue.push(1),rt}function Sn(ue,te){for(var se=[],ye=0;ye<ue.length;ye++){var De,je=ue[ye],rt=je.type;if(rt==="Point"||rt==="MultiPoint"||rt==="LineString")De=ri(je.geometry,te);else if(rt==="MultiLineString"||rt==="Polygon"){De=[];for(var st=0;st<je.geometry.length;st++)De.push(ri(je.geometry[st],te))}else if(rt==="MultiPolygon")for(De=[],st=0;st<je.geometry.length;st++){for(var He=[],pt=0;pt<je.geometry[st].length;pt++)He.push(ri(je.geometry[st][pt],te));De.push(He)}se.push(mn(je.id,rt,De,je.tags))}return se}function ri(ue,te){var se=[];se.size=ue.size,ue.start!==void 0&&(se.start=ue.start,se.end=ue.end);for(var ye=0;ye<ue.length;ye+=3)se.push(ue[ye]+te,ue[ye+1],ue[ye+2]);return se}function kt(ue,te){if(ue.transformed)return ue;var se,ye,De,je=1<<ue.z,rt=ue.x,st=ue.y;for(se=0;se<ue.features.length;se++){var He=ue.features[se],pt=He.geometry,Zt=He.type;if(He.geometry=[],Zt===1)for(ye=0;ye<pt.length;ye+=2)He.geometry.push(Hn(pt[ye],pt[ye+1],te,je,rt,st));else for(ye=0;ye<pt.length;ye++){var on=[];for(De=0;De<pt[ye].length;De+=2)on.push(Hn(pt[ye][De],pt[ye][De+1],te,je,rt,st));He.geometry.push(on)}}return ue.transformed=!0,ue}function Hn(ue,te,se,ye,De,je){return[Math.round(se*(ue*ye-De)),Math.round(se*(te*ye-je))]}function On(ue,te,se,ye,De){for(var je=te===De.maxZoom?0:De.tolerance/((1<<te)*De.extent),rt={features:[],numPoints:0,numSimplified:0,numFeatures:0,source:null,x:se,y:ye,z:te,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0},st=0;st<ue.length;st++){rt.numFeatures++,Fn(rt,ue[st],je,De);var He=ue[st].minX,pt=ue[st].minY,Zt=ue[st].maxX,on=ue[st].maxY;He<rt.minX&&(rt.minX=He),pt<rt.minY&&(rt.minY=pt),Zt>rt.maxX&&(rt.maxX=Zt),on>rt.maxY&&(rt.maxY=on)}return rt}function Fn(ue,te,se,ye){var De=te.geometry,je=te.type,rt=[];if(je==="Point"||je==="MultiPoint")for(var st=0;st<De.length;st+=3)rt.push(De[st]),rt.push(De[st+1]),ue.numPoints++,ue.numSimplified++;else if(je==="LineString")Ze(rt,De,ue,se,!1,!1);else if(je==="MultiLineString"||je==="Polygon")for(st=0;st<De.length;st++)Ze(rt,De[st],ue,se,je==="Polygon",st===0);else if(je==="MultiPolygon")for(var He=0;He<De.length;He++){var pt=De[He];for(st=0;st<pt.length;st++)Ze(rt,pt[st],ue,se,!0,st===0)}if(rt.length){var Zt=te.tags||null;if(je==="LineString"&&ye.lineMetrics){for(var on in Zt={},te.tags)Zt[on]=te.tags[on];Zt.mapbox_clip_start=De.start/De.size,Zt.mapbox_clip_end=De.end/De.size}var Kt={geometry:rt,type:je==="Polygon"||je==="MultiPolygon"?3:je==="LineString"||je==="MultiLineString"?2:1,tags:Zt};te.id!==null&&(Kt.id=te.id),ue.features.push(Kt)}}function Ze(ue,te,se,ye,De,je){var rt=ye*ye;if(ye>0&&te.size<(De?rt:ye))se.numPoints+=te.length/3;else{for(var st=[],He=0;He<te.length;He+=3)(ye===0||te[He+2]>rt)&&(se.numSimplified++,st.push(te[He]),st.push(te[He+1])),se.numPoints++;De&&function(pt,Zt){for(var on=0,Kt=0,xi=pt.length,ci=xi-2;Kt<xi;ci=Kt,Kt+=2)on+=(pt[Kt]-pt[ci])*(pt[Kt+1]+pt[ci+1]);if(on>0===Zt)for(Kt=0,xi=pt.length;Kt<xi/2;Kt+=2){var ve=pt[Kt],Qe=pt[Kt+1];pt[Kt]=pt[xi-2-Kt],pt[Kt+1]=pt[xi-1-Kt],pt[xi-2-Kt]=ve,pt[xi-1-Kt]=Qe}}(st,je),ue.push(st)}}function Tn(ue,te){var se=(te=this.options=function(De,je){for(var rt in je)De[rt]=je[rt];return De}(Object.create(this.options),te)).debug;if(se&&console.time("preprocess data"),te.maxZoom<0||te.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(te.promoteId&&te.generateId)throw new Error("promoteId and generateId cannot be used together.");var ye=function(De,je){var rt=[];if(De.type==="FeatureCollection")for(var st=0;st<De.features.length;st++)Dt(rt,De.features[st],je,st);else Dt(rt,De.type==="Feature"?De:{geometry:De},je);return rt}(ue,te);this.tiles={},this.tileCoords=[],se&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",te.indexMaxZoom,te.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),ye=function(De,je){var rt=je.buffer/je.extent,st=De,He=Mn(De,1,-1-rt,rt,0,-1,2,je),pt=Mn(De,1,1-rt,2+rt,0,-1,2,je);return(He||pt)&&(st=Mn(De,1,-rt,1+rt,0,-1,2,je)||[],He&&(st=Sn(He,1).concat(st)),pt&&(st=st.concat(Sn(pt,-1)))),st}(ye,te),ye.length&&this.splitTile(ye,0,0,0),se&&(ye.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}function bn(ue,te,se){return 32*((1<<ue)*se+te)+ue}function We(ue,te){const se=ue.tileID.canonical;if(!this._geoJSONIndex)return te(null,null);const ye=this._geoJSONIndex.getTile(se.z,se.x,se.y);if(!ye)return te(null,null);const De=new class{constructor(rt){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=i.EXTENT,this.length=rt.length,this._features=rt}feature(rt){return new class{constructor(st){this._feature=st,this.extent=i.EXTENT,this.type=st.type,this.properties=st.tags,"id"in st&&!isNaN(st.id)&&(this.id=parseInt(st.id,10))}loadGeometry(){if(this._feature.type===1){const st=[];for(const He of this._feature.geometry)st.push([new i.Point(He[0],He[1])]);return st}{const st=[];for(const He of this._feature.geometry){const pt=[];for(const Zt of He)pt.push(new i.Point(Zt[0],Zt[1]));st.push(pt)}return st}}toGeoJSON(st,He,pt){return B.call(this,st,He,pt)}}(this._features[rt])}}(ye.features);let je=ft(De);je.byteOffset===0&&je.byteLength===je.buffer.byteLength||(je=new Uint8Array(je)),te(null,{vectorTile:De,rawData:je.buffer})}Tn.prototype.options={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,debug:0},Tn.prototype.splitTile=function(ue,te,se,ye,De,je,rt){for(var st=[ue,te,se,ye],He=this.options,pt=He.debug;st.length;){ye=st.pop(),se=st.pop(),te=st.pop(),ue=st.pop();var Zt=1<<te,on=bn(te,se,ye),Kt=this.tiles[on];if(!Kt&&(pt>1&&console.time("creation"),Kt=this.tiles[on]=On(ue,te,se,ye,He),this.tileCoords.push({z:te,x:se,y:ye}),pt)){pt>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",te,se,ye,Kt.numFeatures,Kt.numPoints,Kt.numSimplified),console.timeEnd("creation"));var xi="z"+te;this.stats[xi]=(this.stats[xi]||0)+1,this.total++}if(Kt.source=ue,De){if(te===He.maxZoom||te===De)continue;var ci=1<<De-te;if(se!==Math.floor(je/ci)||ye!==Math.floor(rt/ci))continue}else if(te===He.indexMaxZoom||Kt.numPoints<=He.indexMaxPoints)continue;if(Kt.source=null,ue.length!==0){pt>1&&console.time("clipping");var ve,Qe,lt,mt,Gt,$n,Yn=.5*He.buffer/He.extent,bi=.5-Yn,ui=.5+Yn,ai=1+Yn;ve=Qe=lt=mt=null,Gt=Mn(ue,Zt,se-Yn,se+ui,0,Kt.minX,Kt.maxX,He),$n=Mn(ue,Zt,se+bi,se+ai,0,Kt.minX,Kt.maxX,He),ue=null,Gt&&(ve=Mn(Gt,Zt,ye-Yn,ye+ui,1,Kt.minY,Kt.maxY,He),Qe=Mn(Gt,Zt,ye+bi,ye+ai,1,Kt.minY,Kt.maxY,He),Gt=null),$n&&(lt=Mn($n,Zt,ye-Yn,ye+ui,1,Kt.minY,Kt.maxY,He),mt=Mn($n,Zt,ye+bi,ye+ai,1,Kt.minY,Kt.maxY,He),$n=null),pt>1&&console.timeEnd("clipping"),st.push(ve||[],te+1,2*se,2*ye),st.push(Qe||[],te+1,2*se,2*ye+1),st.push(lt||[],te+1,2*se+1,2*ye),st.push(mt||[],te+1,2*se+1,2*ye+1)}}},Tn.prototype.getTile=function(ue,te,se){var ye=this.options,De=ye.extent,je=ye.debug;if(ue<0||ue>24)return null;var rt=1<<ue,st=bn(ue,te=(te%rt+rt)%rt,se);if(this.tiles[st])return kt(this.tiles[st],De);je>1&&console.log("drilling down to z%d-%d-%d",ue,te,se);for(var He,pt=ue,Zt=te,on=se;!He&&pt>0;)pt--,Zt=Math.floor(Zt/2),on=Math.floor(on/2),He=this.tiles[bn(pt,Zt,on)];return He&&He.source?(je>1&&console.log("found parent tile z%d-%d-%d",pt,Zt,on),je>1&&console.time("drilling down"),this.splitTile(He.source,pt,Zt,on,ue,te,se),je>1&&console.timeEnd("drilling down"),this.tiles[st]?kt(this.tiles[st],De):null):null};class bt extends i.VectorTileWorkerSource{constructor(te,se,ye,De,je){super(te,se,ye,De,We),je&&(this.loadGeoJSON=je)}loadData(te,se){const ye=te&&te.request,De=ye&&ye.collectResourceTiming;this.loadGeoJSON(te,(je,rt)=>{if(je||!rt)return se(je);if(typeof rt!="object")return se(new Error(`Input data given to '${te.source}' is not a valid GeoJSON object.`));{O(rt,!0);try{if(te.filter){const He=i.createExpression(te.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(He.result==="error")throw new Error(He.value.map(Zt=>`${Zt.key}: ${Zt.message}`).join(", "));rt={type:"FeatureCollection",features:rt.features.filter(Zt=>He.value.evaluate({zoom:0},Zt))}}this._geoJSONIndex=te.cluster?new Pt(function({superclusterOptions:He,clusterProperties:pt}){if(!pt||!He)return He;const Zt={},on={},Kt={accumulated:null,zoom:0},xi={properties:null},ci=Object.keys(pt);for(const ve of ci){const[Qe,lt]=pt[ve],mt=i.createExpression(lt),Gt=i.createExpression(typeof Qe=="string"?[Qe,["accumulated"],["get",ve]]:Qe);Zt[ve]=mt.value,on[ve]=Gt.value}return He.map=ve=>{xi.properties=ve;const Qe={};for(const lt of ci)Qe[lt]=Zt[lt].evaluate(Kt,xi);return Qe},He.reduce=(ve,Qe)=>{xi.properties=Qe;for(const lt of ci)Kt.accumulated=ve[lt],ve[lt]=on[lt].evaluate(Kt,xi)},He}(te)).load(rt.features):function(He,pt){return new Tn(He,pt)}(rt,te.geojsonVtOptions)}catch(He){return se(He)}this.loaded={};const st={};if(De){const He=i.getPerformanceMeasurement(ye);He&&(st.resourceTiming={},st.resourceTiming[te.source]=JSON.parse(JSON.stringify(He)))}se(null,st)}})}reloadTile(te,se){const ye=this.loaded;return ye&&ye[te.uid]?super.reloadTile(te,se):this.loadTile(te,se)}loadGeoJSON(te,se){if(te.request)i.getJSON(te.request,se);else{if(typeof te.data!="string")return se(new Error(`Input data given to '${te.source}' is not a valid GeoJSON object.`));try{return se(null,JSON.parse(te.data))}catch{return se(new Error(`Input data given to '${te.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(te,se){try{se(null,this._geoJSONIndex.getClusterExpansionZoom(te.clusterId))}catch(ye){se(ye)}}getClusterChildren(te,se){try{se(null,this._geoJSONIndex.getChildren(te.clusterId))}catch(ye){se(ye)}}getClusterLeaves(te,se){try{se(null,this._geoJSONIndex.getLeaves(te.clusterId,te.limit,te.offset))}catch(ye){se(ye)}}}class un{constructor(te){this.self=te,this.actor=new i.Actor(te,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=i.getProjection({name:"mercator"}),this.workerSourceTypes={vector:i.VectorTileWorkerSource,geojson:bt},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(se,ye)=>{if(this.workerSourceTypes[se])throw new Error(`Worker source with name "${se}" already registered.`);this.workerSourceTypes[se]=ye},this.self.registerRTLTextPlugin=se=>{if(i.plugin.isParsed())throw new Error("RTL text plugin already registered.");i.plugin.applyArabicShaping=se.applyArabicShaping,i.plugin.processBidirectionalText=se.processBidirectionalText,i.plugin.processStyledBidirectionalText=se.processStyledBidirectionalText}}clearCaches(te,se,ye){delete this.layerIndexes[te],delete this.availableImages[te],delete this.workerSources[te],delete this.demWorkerSources[te],ye()}checkIfReady(te,se,ye){ye()}setReferrer(te,se){this.referrer=se}spriteLoaded(te,se){this.isSpriteLoaded[te]=se;for(const ye in this.workerSources[te]){const De=this.workerSources[te][ye];for(const je in De)De[je]instanceof i.VectorTileWorkerSource&&(De[je].isSpriteLoaded=se,De[je].fire(new i.Event("isSpriteLoaded")))}}setImages(te,se,ye){this.availableImages[te]=se;for(const De in this.workerSources[te]){const je=this.workerSources[te][De];for(const rt in je)je[rt].availableImages=se}ye()}enableTerrain(te,se,ye){this.terrain=se,ye()}setProjection(te,se){this.projections[te]=i.getProjection(se)}setLayers(te,se,ye){this.getLayerIndex(te).replace(se),ye()}updateLayers(te,se,ye){this.getLayerIndex(te).update(se.layers,se.removedIds),ye()}loadTile(te,se,ye){const De=this.enableTerrain?i.extend({enableTerrain:this.terrain},se):se;De.projection=this.projections[te]||this.defaultProjection,this.getWorkerSource(te,se.type,se.source).loadTile(De,ye)}loadDEMTile(te,se,ye){const De=this.enableTerrain?i.extend({buildQuadTree:this.terrain},se):se;this.getDEMWorkerSource(te,se.source).loadTile(De,ye)}reloadTile(te,se,ye){const De=this.enableTerrain?i.extend({enableTerrain:this.terrain},se):se;De.projection=this.projections[te]||this.defaultProjection,this.getWorkerSource(te,se.type,se.source).reloadTile(De,ye)}abortTile(te,se,ye){this.getWorkerSource(te,se.type,se.source).abortTile(se,ye)}removeTile(te,se,ye){this.getWorkerSource(te,se.type,se.source).removeTile(se,ye)}removeSource(te,se,ye){if(!this.workerSources[te]||!this.workerSources[te][se.type]||!this.workerSources[te][se.type][se.source])return;const De=this.workerSources[te][se.type][se.source];delete this.workerSources[te][se.type][se.source],De.removeSource!==void 0?De.removeSource(se,ye):ye()}loadWorkerSource(te,se,ye){try{this.self.importScripts(se.url),ye()}catch(De){ye(De.toString())}}syncRTLPluginState(te,se,ye){try{i.plugin.setState(se);const De=i.plugin.getPluginURL();if(i.plugin.isLoaded()&&!i.plugin.isParsed()&&De!=null){this.self.importScripts(De);const je=i.plugin.isParsed();ye(je?void 0:new Error(`RTL Text Plugin failed to import scripts from ${De}`),je)}}catch(De){ye(De.toString())}}getAvailableImages(te){let se=this.availableImages[te];return se||(se=[]),se}getLayerIndex(te){let se=this.layerIndexes[te];return se||(se=this.layerIndexes[te]=new C),se}getWorkerSource(te,se,ye){if(this.workerSources[te]||(this.workerSources[te]={}),this.workerSources[te][se]||(this.workerSources[te][se]={}),!this.workerSources[te][se][ye]){const De={send:(je,rt,st,He,pt,Zt)=>{this.actor.send(je,rt,st,te,pt,Zt)},scheduler:this.actor.scheduler};this.workerSources[te][se][ye]=new this.workerSourceTypes[se](De,this.getLayerIndex(te),this.getAvailableImages(te),this.isSpriteLoaded[te])}return this.workerSources[te][se][ye]}getDEMWorkerSource(te,se){return this.demWorkerSources[te]||(this.demWorkerSources[te]={}),this.demWorkerSources[te][se]||(this.demWorkerSources[te][se]=new T),this.demWorkerSources[te][se]}enforceCacheSizeLimit(te,se){i.enforceCacheSizeLimit(se)}getWorkerPerformanceMetrics(te,se,ye){ye(void 0,void 0)}}return typeof WorkerGlobalScope<"u"&&typeof self<"u"&&self instanceof WorkerGlobalScope&&(self.worker=new un(self)),un}),f(["./shared"],function(i){function w(p,o){if(Array.isArray(p)){if(!Array.isArray(o)||p.length!==o.length)return!1;for(let u=0;u<p.length;u++)if(!w(p[u],o[u]))return!1;return!0}if(typeof p=="object"&&p!==null&&o!==null){if(typeof o!="object"||Object.keys(p).length!==Object.keys(o).length)return!1;for(const u in p)if(!w(p[u],o[u]))return!1;return!0}return p===o}var E=C;function C(p){return!function(o){return typeof window>"u"||typeof document>"u"?"not a browser":Array.prototype&&Array.prototype.every&&Array.prototype.filter&&Array.prototype.forEach&&Array.prototype.indexOf&&Array.prototype.lastIndexOf&&Array.prototype.map&&Array.prototype.some&&Array.prototype.reduce&&Array.prototype.reduceRight&&Array.isArray?Function.prototype&&Function.prototype.bind?Object.keys&&Object.create&&Object.getPrototypeOf&&Object.getOwnPropertyNames&&Object.isSealed&&Object.isFrozen&&Object.isExtensible&&Object.getOwnPropertyDescriptor&&Object.defineProperty&&Object.defineProperties&&Object.seal&&Object.freeze&&Object.preventExtensions?"JSON"in window&&"parse"in JSON&&"stringify"in JSON?function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var y,b,M=new Blob([""],{type:"text/javascript"}),R=URL.createObjectURL(M);try{b=new Worker(R),y=!0}catch{y=!1}return b&&b.terminate(),URL.revokeObjectURL(R),y}()?"Uint8ClampedArray"in window?ArrayBuffer.isView?function(){var y=document.createElement("canvas");y.width=y.height=1;var b=y.getContext("2d");if(!b)return!1;var M=b.getImageData(0,0,1,1);return M&&M.width===y.width}()?(T[u=o&&o.failIfMajorPerformanceCaveat]===void 0&&(T[u]=function(y){var b,M=function(R){var z=document.createElement("canvas"),V=Object.create(C.webGLContextAttributes);return V.failIfMajorPerformanceCaveat=R,z.getContext("webgl",V)||z.getContext("experimental-webgl",V)}(y);if(!M)return!1;try{b=M.createShader(M.VERTEX_SHADER)}catch{return!1}return!(!b||M.isContextLost())&&(M.shaderSource(b,"void main() {}"),M.compileShader(b),M.getShaderParameter(b,M.COMPILE_STATUS)===!0)}(u)),T[u]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL support"):"insufficient Canvas/getImageData support":"insufficient ArrayBuffer support":"insufficient Uint8ClampedArray support":"insufficient worker support":"insufficient JSON support":"insufficient Object support":"insufficient Function support":"insufficent Array support";var u}(p)}var T={};function I(p,o,u){const y=i.window.document.createElement(p);return o!==void 0&&(y.className=o),u&&u.appendChild(y),y}function k(p,o,u){const y=i.window.document.createElementNS("http://www.w3.org/2000/svg",p);for(const b of Object.keys(o))y.setAttributeNS(null,b,o[b]);return u&&u.appendChild(y),y}C.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0};const O=i.window.document&&i.window.document.documentElement.style,B=O&&O.userSelect!==void 0?"userSelect":"WebkitUserSelect";let F;function H(){O&&B&&(F=O[B],O[B]="none")}function Y(){O&&B&&(O[B]=F)}function K(p){p.preventDefault(),p.stopPropagation(),i.window.removeEventListener("click",K,!0)}function ne(){i.window.addEventListener("click",K,!0),i.window.setTimeout(()=>{i.window.removeEventListener("click",K,!0)},0)}function le(p,o){const u=p.getBoundingClientRect();return oe(p,u,o)}function fe(p,o){const u=p.getBoundingClientRect(),y=[];for(let b=0;b<o.length;b++)y.push(oe(p,u,o[b]));return y}function Ae(p){return i.window.InstallTrigger!==void 0&&p.button===2&&p.ctrlKey&&i.window.navigator.platform.toUpperCase().indexOf("MAC")>=0?0:p.button}function oe(p,o,u){const y=p.offsetWidth===o.width?1:p.offsetWidth/o.width;return new i.Point((u.clientX-o.left)*y,(u.clientY-o.top)*y)}function ce(p,o){var u=o[0],y=o[1],b=o[2],M=o[3],R=u*M-b*y;return R?(p[0]=M*(R=1/R),p[1]=-y*R,p[2]=-b*R,p[3]=u*R,p):null}function Re(p){const{userImage:o}=p;return!!(o&&o.render&&o.render())&&(p.data.replace(new Uint8Array(o.data.buffer)),!0)}class ke extends i.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new i.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(o){if(this.loaded!==o&&(this.loaded=o,o)){for(const{ids:u,callback:y}of this.requestors)this._notify(u,y);this.requestors=[]}}hasImage(o){return!!this.getImage(o)}getImage(o){return this.images[o]}addImage(o,u){this._validate(o,u)&&(this.images[o]=u)}_validate(o,u){let y=!0;return this._validateStretch(u.stretchX,u.data&&u.data.width)||(this.fire(new i.ErrorEvent(new Error(`Image "${o}" has invalid "stretchX" value`))),y=!1),this._validateStretch(u.stretchY,u.data&&u.data.height)||(this.fire(new i.ErrorEvent(new Error(`Image "${o}" has invalid "stretchY" value`))),y=!1),this._validateContent(u.content,u)||(this.fire(new i.ErrorEvent(new Error(`Image "${o}" has invalid "content" value`))),y=!1),y}_validateStretch(o,u){if(!o)return!0;let y=0;for(const b of o){if(b[0]<y||b[1]<b[0]||u<b[1])return!1;y=b[1]}return!0}_validateContent(o,u){return!(o&&(o.length!==4||o[0]<0||u.data.width<o[0]||o[1]<0||u.data.height<o[1]||o[2]<0||u.data.width<o[2]||o[3]<0||u.data.height<o[3]||o[2]<o[0]||o[3]<o[1]))}updateImage(o,u){u.version=this.images[o].version+1,this.images[o]=u,this.updatedImages[o]=!0}removeImage(o){const u=this.images[o];delete this.images[o],delete this.patterns[o],u.userImage&&u.userImage.onRemove&&u.userImage.onRemove()}listImages(){return Object.keys(this.images)}getImages(o,u){let y=!0;if(!this.isLoaded())for(const b of o)this.images[b]||(y=!1);this.isLoaded()||y?this._notify(o,u):this.requestors.push({ids:o,callback:u})}_notify(o,u){const y={};for(const b of o){this.images[b]||this.fire(new i.Event("styleimagemissing",{id:b}));const M=this.images[b];M?y[b]={data:M.data.clone(),pixelRatio:M.pixelRatio,sdf:M.sdf,version:M.version,stretchX:M.stretchX,stretchY:M.stretchY,content:M.content,hasRenderCallback:Boolean(M.userImage&&M.userImage.render)}:i.warnOnce(`Image "${b}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`)}u(null,y)}getPixelSize(){const{width:o,height:u}=this.atlasImage;return{width:o,height:u}}getPattern(o){const u=this.patterns[o],y=this.getImage(o);if(!y)return null;if(u&&u.position.version===y.version)return u.position;if(u)u.position.version=y.version;else{const b={w:y.data.width+2,h:y.data.height+2,x:0,y:0},M=new i.ImagePosition(b,y);this.patterns[o]={bin:b,position:M}}return this._updatePatternAtlas(),this.patterns[o].position}bind(o){const u=o.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new i.Texture(o,this.atlasImage,u.RGBA),this.atlasTexture&&this.atlasTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE)}_updatePatternAtlas(){const o=[];for(const M in this.patterns)o.push(this.patterns[M].bin);const{w:u,h:y}=i.potpack(o),b=this.atlasImage;b.resize({width:u||1,height:y||1});for(const M in this.patterns){const{bin:R}=this.patterns[M],z=R.x+1,V=R.y+1,X=this.images[M].data,q=X.width,Q=X.height;i.RGBAImage.copy(X,b,{x:0,y:0},{x:z,y:V},{width:q,height:Q}),i.RGBAImage.copy(X,b,{x:0,y:Q-1},{x:z,y:V-1},{width:q,height:1}),i.RGBAImage.copy(X,b,{x:0,y:0},{x:z,y:V+Q},{width:q,height:1}),i.RGBAImage.copy(X,b,{x:q-1,y:0},{x:z-1,y:V},{width:1,height:Q}),i.RGBAImage.copy(X,b,{x:0,y:0},{x:z+q,y:V},{width:1,height:Q})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(o){for(const u of o){if(this.callbackDispatchedThisFrame[u])continue;this.callbackDispatchedThisFrame[u]=!0;const y=this.images[u];Re(y)&&this.updateImage(u,y)}}}const Xe=new i.Properties({anchor:new i.DataConstantProperty(i.spec.light.anchor),position:new class{constructor(){this.specification=i.spec.light.position}possiblyEvaluate(p,o){return function([u,y,b]){const M=i.degToRad(y+90),R=i.degToRad(b);return{x:u*Math.cos(M)*Math.sin(R),y:u*Math.sin(M)*Math.sin(R),z:u*Math.cos(R),azimuthal:y,polar:b}}(p.expression.evaluate(o))}interpolate(p,o,u){return{x:i.number(p.x,o.x,u),y:i.number(p.y,o.y,u),z:i.number(p.z,o.z,u),azimuthal:i.number(p.azimuthal,o.azimuthal,u),polar:i.number(p.polar,o.polar,u)}}},color:new i.DataConstantProperty(i.spec.light.color),intensity:new i.DataConstantProperty(i.spec.light.intensity)});class St extends i.Evented{constructor(o){super(),this._transitionable=new i.Transitionable(Xe),this.setLight(o),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(o,u={}){if(!this._validate(i.validateLight,o,u))for(const y in o){const b=o[y];i.endsWith(y,"-transition")?this._transitionable.setTransition(y.slice(0,-11),b):this._transitionable.setValue(y,b)}}updateTransitions(o){this._transitioning=this._transitionable.transitioned(o,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(o){this.properties=this._transitioning.possiblyEvaluate(o)}_validate(o,u,y){return(!y||y.validate!==!1)&&i.emitValidationErrors(this,o.call(i.validateStyle,i.extend({value:u,style:{glyphs:!0,sprite:!0},styleSpec:i.spec})))}}const Je=new i.Properties({source:new i.DataConstantProperty(i.spec.terrain.source),exaggeration:new i.DataConstantProperty(i.spec.terrain.exaggeration)});let It=class extends i.Evented{constructor(p,o){super(),this._transitionable=new i.Transitionable(Je),this.set(p),this._transitioning=this._transitionable.untransitioned(),this.drapeRenderMode=o}get(){return this._transitionable.serialize()}set(p){for(const o in p){const u=p[o];i.endsWith(o,"-transition")?this._transitionable.setTransition(o.slice(0,-11),u):this._transitionable.setValue(o,u)}}updateTransitions(p){this._transitioning=this._transitionable.transitioned(p,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(p){this.properties=this._transitioning.possiblyEvaluate(p)}};function ft(p,o,u,y){const b=i.smoothstep(45,65,u),[M,R]=Nt(p,y),z=i.length(o);let V=1-Math.min(1,Math.exp((z-M)/(R-M)*-6));return V*=V*V,V=Math.min(1,1.00747*V),V*b*p.alpha}function Nt(p,o){const u=.5/Math.tan(.5*o);return[p.range[0]+u,p.range[1]+u]}const Fe=new i.Properties({range:new i.DataConstantProperty(i.spec.fog.range),color:new i.DataConstantProperty(i.spec.fog.color),"high-color":new i.DataConstantProperty(i.spec.fog["high-color"]),"space-color":new i.DataConstantProperty(i.spec.fog["space-color"]),"horizon-blend":new i.DataConstantProperty(i.spec.fog["horizon-blend"]),"star-intensity":new i.DataConstantProperty(i.spec.fog["star-intensity"])});class it extends i.Evented{constructor(o,u){super(),this._transitionable=new i.Transitionable(Fe),this.set(o),this._transitioning=this._transitionable.untransitioned(),this._transform=u}get state(){const o=this._transform,u=o.projection.name==="globe",y=i.globeToMercatorTransition(o.zoom),b=this.properties.get("range"),M=[.5,3];return{range:u?[i.number(M[0],b[0],y),i.number(M[1],b[1],y)]:b,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(o,u={}){if(!this._validate(i.validateFog,o,u)){for(const y of Object.keys(i.spec.fog))o&&o[y]===void 0&&(o[y]=i.spec.fog[y].default);for(const y in o){const b=o[y];i.endsWith(y,"-transition")?this._transitionable.setTransition(y.slice(0,-11),b):this._transitionable.setValue(y,b)}}}getOpacity(o){if(!this._transform.projection.supportsFog)return 0;const u=this.properties&&this.properties.get("color")||1;return(this._transform.projection.name==="globe"?1:i.smoothstep(45,65,o))*u.a}getOpacityAtLatLng(o,u){return this._transform.projection.supportsFog?function(y,b,M){const R=i.MercatorCoordinate.fromLngLat(b),z=M.elevation?M.elevation.getAtPointOrZero(R):0,V=[R.x,R.y,z];return i.transformMat4(V,V,M.mercatorFogMatrix),ft(y,V,M.pitch,M._fov)}(this.state,o,u):0}getFovAdjustedRange(o){return this._transform.projection.supportsFog?Nt(this.state,o):[0,1]}updateTransitions(o){this._transitioning=this._transitionable.transitioned(o,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()}recalculate(o){this.properties=this._transitioning.possiblyEvaluate(o)}_validate(o,u,y){return(!y||y.validate!==!1)&&i.emitValidationErrors(this,o.call(i.validateStyle,i.extend({value:u,style:{glyphs:!0,sprite:!0},styleSpec:i.spec})))}}class tt{constructor(o,u){this.workerPool=o,this.actors=[],this.currentActor=0,this.id=i.uniqueId();const y=this.workerPool.acquire(this.id);for(let b=0;b<y.length;b++){const M=new tt.Actor(y[b],u,this.id);M.name=`Worker ${b}`,this.actors.push(M)}this.ready=!1,this.broadcast("checkIfReady",null,()=>{this.ready=!0})}broadcast(o,u,y){i.asyncAll(this.actors,(b,M)=>{b.send(o,u,M)},y=y||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(o=>{o.remove()}),this.actors=[],this.workerPool.release(this.id)}}function Et(p,o,u){return o*(i.EXTENT/(p.tileSize*Math.pow(2,u-p.tileID.overscaledZ)))}tt.Actor=i.Actor;class xt{constructor(o,u,y,b){this.screenBounds=o,this.cameraPoint=u,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=y,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,b)}static createFromScreenPoints(o,u){let y,b;if(o instanceof i.Point||typeof o[0]=="number"){const M=i.Point.convert(o);y=[M],b=u.isPointAboveHorizon(M)}else{const M=i.Point.convert(o[0]),R=i.Point.convert(o[1]);y=[M,R],b=i.polygonizeBounds(M,R).every(z=>u.isPointAboveHorizon(z))}return new xt(y,u.getCameraPoint(),b,u)}isPointQuery(){return this.screenBounds.length===1}bufferedScreenGeometry(o){return i.polygonizeBounds(this.screenBounds[0],this.screenBounds.length===1?this.screenBounds[0]:this.screenBounds[1],o)}bufferedCameraGeometry(o){const u=this.screenBounds[0],y=this.screenBounds.length===1?this.screenBounds[0].add(new i.Point(1,1)):this.screenBounds[1],b=i.polygonizeBounds(u,y,0,!1);return this.cameraPoint.y>y.y&&(this.cameraPoint.x>u.x&&this.cameraPoint.x<y.x?b.splice(3,0,this.cameraPoint):this.cameraPoint.x>=y.x?b[2]=this.cameraPoint:this.cameraPoint.x<=u.x&&(b[3]=this.cameraPoint)),i.bufferConvexPolygon(b,o)}bufferedCameraGeometryGlobe(o){const u=this.screenBounds[0],y=this.screenBounds.length===1?this.screenBounds[0].add(new i.Point(1,1)):this.screenBounds[1],b=i.polygonizeBounds(u,y,o),M=this.cameraPoint.clone();switch(3*((M.y>u.y)+(M.y>y.y))+((M.x>u.x)+(M.x>y.x))){case 0:b[0]=M,b[4]=M.clone();break;case 1:b.splice(1,0,M);break;case 2:b[1]=M;break;case 3:b.splice(4,0,M);break;case 5:b.splice(2,0,M);break;case 6:b[3]=M;break;case 7:b.splice(3,0,M);break;case 8:b[2]=M}return b}containsTile(o,u,y,b=0){const M=o.queryPadding/u._pixelsPerMercatorPixel+1,R=y?this._bufferedCameraMercator(M,u):this._bufferedScreenMercator(M,u);let z=o.tileID.wrap+(R.unwrapped?b:0);const V=R.polygon.map(be=>i.getTilePoint(o.tileTransform,be,z));if(!i.polygonIntersectsBox(V,0,0,i.EXTENT,i.EXTENT))return;z=o.tileID.wrap+(this.screenGeometryMercator.unwrapped?b:0);const X=this.screenGeometryMercator.polygon.map(be=>i.getTileVec3(o.tileTransform,be,z)),q=X.map(be=>new i.Point(be[0],be[1])),Q=u.getFreeCameraOptions().position||new i.MercatorCoordinate(0,0,0),he=i.getTileVec3(o.tileTransform,Q,z),me=X.map(be=>{const ie=i.sub(be,be,he);return i.normalize(ie,ie),new i.Ray(he,ie)}),ge=Et(o,1,u.zoom)*u._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:q,tilespaceRays:me,bufferedTilespaceGeometry:V,bufferedTilespaceBounds:(_e=i.getBounds(V),_e.min.x=i.clamp(_e.min.x,0,i.EXTENT),_e.min.y=i.clamp(_e.min.y,0,i.EXTENT),_e.max.x=i.clamp(_e.max.x,0,i.EXTENT),_e.max.y=i.clamp(_e.max.y,0,i.EXTENT),_e),tile:o,tileID:o.tileID,pixelToTileUnitsFactor:ge};var _e}_bufferedScreenMercator(o,u){const y=pn(o);if(this._screenRaycastCache[y])return this._screenRaycastCache[y];{let b;return b=u.projection.name==="globe"?this._projectAndResample(this.bufferedScreenGeometry(o),u):{polygon:this.bufferedScreenGeometry(o).map(M=>u.pointCoordinate3D(M)),unwrapped:!0},this._screenRaycastCache[y]=b,b}}_bufferedCameraMercator(o,u){const y=pn(o);if(this._cameraRaycastCache[y])return this._cameraRaycastCache[y];{let b;return b=u.projection.name==="globe"?this._projectAndResample(this.bufferedCameraGeometryGlobe(o),u):{polygon:this.bufferedCameraGeometry(o).map(M=>u.pointCoordinate3D(M)),unwrapped:!0},this._cameraRaycastCache[y]=b,b}}_projectAndResample(o,u){const y=function(M,R){const z=i.multiply([],R.pixelMatrix,R.globeMatrix),V=[0,-i.GLOBE_RADIUS,0,1],X=[0,i.GLOBE_RADIUS,0,1],q=[0,0,0,1];i.transformMat4$1(V,V,z),i.transformMat4$1(X,X,z),i.transformMat4$1(q,q,z);const Q=new i.Point(V[0]/V[3],V[1]/V[3]),he=new i.Point(X[0]/X[3],X[1]/X[3]),me=i.polygonContainsPoint(M,Q)&&V[3]<q[3],ge=i.polygonContainsPoint(M,he)&&X[3]<q[3];if(!me&&!ge)return null;const _e=function(Ve,et,$e){for(let ht=1;ht<Ve.length;ht++){const Jt=ln(et.pointCoordinate3D(Ve[ht-1]).x),ut=ln(et.pointCoordinate3D(Ve[ht]).x);if($e<0){if(Jt<ut)return{idx:ht,t:-Jt/(ut-1-Jt)}}else if(ut<Jt)return{idx:ht,t:(1-Jt)/(ut+1-Jt)}}return null}(M,R,me?-1:1);if(!_e)return null;const{idx:be,t:ie}=_e;let pe=be>1?Pt(M.slice(0,be),R):[],Ee=be<M.length?Pt(M.slice(be),R):[];pe=pe.map(Ve=>new i.Point(ln(Ve.x),Ve.y)),Ee=Ee.map(Ve=>new i.Point(ln(Ve.x),Ve.y));const Te=[...pe];Te.length===0&&Te.push(Ee[Ee.length-1]);const Ue=i.number(Te[Te.length-1].y,(Ee.length===0?pe[0]:Ee[0]).y,ie);let Ge;return Ge=me?[new i.Point(0,Ue),new i.Point(0,0),new i.Point(1,0),new i.Point(1,Ue)]:[new i.Point(1,Ue),new i.Point(1,1),new i.Point(0,1),new i.Point(0,Ue)],Te.push(...Ge),Ee.length===0?Te.push(pe[0]):Te.push(...Ee),{polygon:Te.map(Ve=>new i.MercatorCoordinate(Ve.x,Ve.y)),unwrapped:!1}}(o,u);if(y)return y;const b=function(M,R){let z=!1,V=-1/0,X=0;for(let Q=0;Q<M.length-1;Q++)M[Q].x>V&&(V=M[Q].x,X=Q);for(let Q=0;Q<M.length-1;Q++){const he=(X+Q)%(M.length-1),me=M[he],ge=M[he+1];Math.abs(me.x-ge.x)>.5&&(me.x<ge.x?(me.x+=1,he===0&&(M[M.length-1].x+=1)):(ge.x+=1,he+1===M.length-1&&(M[0].x+=1)),z=!0)}const q=i.mercatorXfromLng(R.center.lng);return z&&q<Math.abs(q-1)&&M.forEach(Q=>{Q.x-=1}),{polygon:M,unwrapped:z}}(Pt(o,u).map(M=>new i.Point(ln(M.x),M.y)),u);return{polygon:b.polygon.map(M=>new i.MercatorCoordinate(M.x,M.y)),unwrapped:b.unwrapped}}}function Pt(p,o){return i.resample(p,u=>{const y=o.pointCoordinate3D(u);u.x=y.x,u.y=y.y},1/256)}function ln(p){return p<0?1+p%1:p%1}function pn(p){return 100*p|0}function Mt(p,o,u,y,b){const M=function(R,z){if(R)return b(R);if(z){p.url&&z.tiles&&p.tiles&&delete p.tiles;const V=i.pick(i.extend(z,p),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);z.vector_layers&&(V.vectorLayers=z.vector_layers,V.vectorLayerIds=V.vectorLayers.map(X=>X.id)),V.tiles=o.canonicalizeTileset(V,p.url),b(null,V)}};return p.url?i.getJSON(o.transformRequest(o.normalizeSourceURL(p.url,null,u,y),i.ResourceType.Source),M):i.exported.frame(()=>M(null,p))}class ei{constructor(o,u,y){this.bounds=i.LngLatBounds.convert(this.validateBounds(o)),this.minzoom=u||0,this.maxzoom=y||24}validateBounds(o){return Array.isArray(o)&&o.length===4?[Math.max(-180,o[0]),Math.max(-90,o[1]),Math.min(180,o[2]),Math.min(90,o[3])]:[-180,-90,180,90]}contains(o){const u=Math.pow(2,o.z),y=Math.floor(i.mercatorXfromLng(this.bounds.getWest())*u),b=Math.floor(i.mercatorYfromLat(this.bounds.getNorth())*u),M=Math.ceil(i.mercatorXfromLng(this.bounds.getEast())*u),R=Math.ceil(i.mercatorYfromLat(this.bounds.getSouth())*u);return o.x>=y&&o.x<M&&o.y>=b&&o.y<R}}class oi{constructor(o,u,y){this.context=o;const b=o.gl;this.buffer=b.createBuffer(),this.dynamicDraw=Boolean(y),this.context.unbindVAO(),o.bindElementBuffer.set(this.buffer),b.bufferData(b.ELEMENT_ARRAY_BUFFER,u.arrayBuffer,this.dynamicDraw?b.DYNAMIC_DRAW:b.STATIC_DRAW),this.dynamicDraw||u.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(o){const u=this.context.gl;this.context.unbindVAO(),this.bind(),u.bufferSubData(u.ELEMENT_ARRAY_BUFFER,0,o.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const Wn={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class jt{constructor(o,u,y,b){this.length=u.length,this.attributes=y,this.itemSize=u.bytesPerElement,this.dynamicDraw=b,this.context=o;const M=o.gl;this.buffer=M.createBuffer(),o.bindVertexBuffer.set(this.buffer),M.bufferData(M.ARRAY_BUFFER,u.arrayBuffer,this.dynamicDraw?M.DYNAMIC_DRAW:M.STATIC_DRAW),this.dynamicDraw||u.destroy()}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(o){const u=this.context.gl;this.bind(),u.bufferSubData(u.ARRAY_BUFFER,0,o.arrayBuffer)}enableAttributes(o,u){for(let y=0;y<this.attributes.length;y++){const b=u.attributes[this.attributes[y].name];b!==void 0&&o.enableVertexAttribArray(b)}}setVertexAttribPointers(o,u,y){for(let b=0;b<this.attributes.length;b++){const M=this.attributes[b],R=u.attributes[M.name];R!==void 0&&o.vertexAttribPointer(R,M.components,o[Wn[M.type]],!1,this.itemSize,M.offset+this.itemSize*(y||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class mn{constructor(o){this.gl=o.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(o){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class qt extends mn{getDefault(){return i.Color.transparent}set(o){const u=this.current;(o.r!==u.r||o.g!==u.g||o.b!==u.b||o.a!==u.a||this.dirty)&&(this.gl.clearColor(o.r,o.g,o.b,o.a),this.current=o,this.dirty=!1)}}class Dt extends mn{getDefault(){return 1}set(o){(o!==this.current||this.dirty)&&(this.gl.clearDepth(o),this.current=o,this.dirty=!1)}}class gn extends mn{getDefault(){return 0}set(o){(o!==this.current||this.dirty)&&(this.gl.clearStencil(o),this.current=o,this.dirty=!1)}}class wn extends mn{getDefault(){return[!0,!0,!0,!0]}set(o){const u=this.current;(o[0]!==u[0]||o[1]!==u[1]||o[2]!==u[2]||o[3]!==u[3]||this.dirty)&&(this.gl.colorMask(o[0],o[1],o[2],o[3]),this.current=o,this.dirty=!1)}}class Yt extends mn{getDefault(){return!0}set(o){(o!==this.current||this.dirty)&&(this.gl.depthMask(o),this.current=o,this.dirty=!1)}}class rn extends mn{getDefault(){return 255}set(o){(o!==this.current||this.dirty)&&(this.gl.stencilMask(o),this.current=o,this.dirty=!1)}}class dn extends mn{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(o){const u=this.current;(o.func!==u.func||o.ref!==u.ref||o.mask!==u.mask||this.dirty)&&(this.gl.stencilFunc(o.func,o.ref,o.mask),this.current=o,this.dirty=!1)}}class Mn extends mn{getDefault(){const o=this.gl;return[o.KEEP,o.KEEP,o.KEEP]}set(o){const u=this.current;(o[0]!==u[0]||o[1]!==u[1]||o[2]!==u[2]||this.dirty)&&(this.gl.stencilOp(o[0],o[1],o[2]),this.current=o,this.dirty=!1)}}class li extends mn{getDefault(){return!1}set(o){if(o===this.current&&!this.dirty)return;const u=this.gl;o?u.enable(u.STENCIL_TEST):u.disable(u.STENCIL_TEST),this.current=o,this.dirty=!1}}class ti extends mn{getDefault(){return[0,1]}set(o){const u=this.current;(o[0]!==u[0]||o[1]!==u[1]||this.dirty)&&(this.gl.depthRange(o[0],o[1]),this.current=o,this.dirty=!1)}}class Ie extends mn{getDefault(){return!1}set(o){if(o===this.current&&!this.dirty)return;const u=this.gl;o?u.enable(u.DEPTH_TEST):u.disable(u.DEPTH_TEST),this.current=o,this.dirty=!1}}class xe extends mn{getDefault(){return this.gl.LESS}set(o){(o!==this.current||this.dirty)&&(this.gl.depthFunc(o),this.current=o,this.dirty=!1)}}class Tt extends mn{getDefault(){return!1}set(o){if(o===this.current&&!this.dirty)return;const u=this.gl;o?u.enable(u.BLEND):u.disable(u.BLEND),this.current=o,this.dirty=!1}}class hn extends mn{getDefault(){const o=this.gl;return[o.ONE,o.ZERO]}set(o){const u=this.current;(o[0]!==u[0]||o[1]!==u[1]||this.dirty)&&(this.gl.blendFunc(o[0],o[1]),this.current=o,this.dirty=!1)}}class _n extends mn{getDefault(){return i.Color.transparent}set(o){const u=this.current;(o.r!==u.r||o.g!==u.g||o.b!==u.b||o.a!==u.a||this.dirty)&&(this.gl.blendColor(o.r,o.g,o.b,o.a),this.current=o,this.dirty=!1)}}class Sn extends mn{getDefault(){return this.gl.FUNC_ADD}set(o){(o!==this.current||this.dirty)&&(this.gl.blendEquation(o),this.current=o,this.dirty=!1)}}class ri extends mn{getDefault(){return!1}set(o){if(o===this.current&&!this.dirty)return;const u=this.gl;o?u.enable(u.CULL_FACE):u.disable(u.CULL_FACE),this.current=o,this.dirty=!1}}class kt extends mn{getDefault(){return this.gl.BACK}set(o){(o!==this.current||this.dirty)&&(this.gl.cullFace(o),this.current=o,this.dirty=!1)}}class Hn extends mn{getDefault(){return this.gl.CCW}set(o){(o!==this.current||this.dirty)&&(this.gl.frontFace(o),this.current=o,this.dirty=!1)}}let On,Fn=class extends mn{getDefault(){return null}set(p){(p!==this.current||this.dirty)&&(this.gl.useProgram(p),this.current=p,this.dirty=!1)}};class Ze extends mn{getDefault(){return this.gl.TEXTURE0}set(o){(o!==this.current||this.dirty)&&(this.gl.activeTexture(o),this.current=o,this.dirty=!1)}}class Tn extends mn{getDefault(){const o=this.gl;return[0,0,o.drawingBufferWidth,o.drawingBufferHeight]}set(o){const u=this.current;(o[0]!==u[0]||o[1]!==u[1]||o[2]!==u[2]||o[3]!==u[3]||this.dirty)&&(this.gl.viewport(o[0],o[1],o[2],o[3]),this.current=o,this.dirty=!1)}}class bn extends mn{getDefault(){return null}set(o){if(o===this.current&&!this.dirty)return;const u=this.gl;u.bindFramebuffer(u.FRAMEBUFFER,o),this.current=o,this.dirty=!1}}class We extends mn{getDefault(){return null}set(o){if(o===this.current&&!this.dirty)return;const u=this.gl;u.bindRenderbuffer(u.RENDERBUFFER,o),this.current=o,this.dirty=!1}}class bt extends mn{getDefault(){return null}set(o){if(o===this.current&&!this.dirty)return;const u=this.gl;u.bindTexture(u.TEXTURE_2D,o),this.current=o,this.dirty=!1}}class un extends mn{getDefault(){return null}set(o){if(o===this.current&&!this.dirty)return;const u=this.gl;u.bindBuffer(u.ARRAY_BUFFER,o),this.current=o,this.dirty=!1}}class ue extends mn{getDefault(){return null}set(o){const u=this.gl;u.bindBuffer(u.ELEMENT_ARRAY_BUFFER,o),this.current=o,this.dirty=!1}}class te extends mn{constructor(o){super(o),this.vao=o.extVertexArrayObject}getDefault(){return null}set(o){this.vao&&(o!==this.current||this.dirty)&&(this.vao.bindVertexArrayOES(o),this.current=o,this.dirty=!1)}}class se extends mn{getDefault(){return 4}set(o){if(o===this.current&&!this.dirty)return;const u=this.gl;u.pixelStorei(u.UNPACK_ALIGNMENT,o),this.current=o,this.dirty=!1}}class ye extends mn{getDefault(){return!1}set(o){if(o===this.current&&!this.dirty)return;const u=this.gl;u.pixelStorei(u.UNPACK_PREMULTIPLY_ALPHA_WEBGL,o),this.current=o,this.dirty=!1}}class De extends mn{getDefault(){return!1}set(o){if(o===this.current&&!this.dirty)return;const u=this.gl;u.pixelStorei(u.UNPACK_FLIP_Y_WEBGL,o),this.current=o,this.dirty=!1}}class je extends mn{constructor(o,u){super(o),this.context=o,this.parent=u}getDefault(){return null}}class rt extends je{setDirty(){this.dirty=!0}set(o){if(o===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const u=this.gl;u.framebufferTexture2D(u.FRAMEBUFFER,u.COLOR_ATTACHMENT0,u.TEXTURE_2D,o,0),this.current=o,this.dirty=!1}}class st extends je{attachment(){return this.gl.DEPTH_ATTACHMENT}set(o){if(o===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const u=this.gl;u.framebufferRenderbuffer(u.FRAMEBUFFER,this.attachment(),u.RENDERBUFFER,o),this.current=o,this.dirty=!1}}class He extends st{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}class pt{constructor(o,u,y,b){this.context=o,this.width=u,this.height=y;const M=this.framebuffer=o.gl.createFramebuffer();this.colorAttachment=new rt(o,M),b&&(this.depthAttachment=new st(o,M))}destroy(){const o=this.context.gl,u=this.colorAttachment.get();if(u&&o.deleteTexture(u),this.depthAttachment){const y=this.depthAttachment.get();y&&o.deleteRenderbuffer(y)}o.deleteFramebuffer(this.framebuffer)}}class Zt{constructor(o,u=!1){if(this.gl=o,this.isWebGL2=u,this.extVertexArrayObject=this.gl.getExtension("OES_vertex_array_object"),u){const y=o;this.extVertexArrayObject={createVertexArrayOES:y.createVertexArray.bind(o),deleteVertexArrayOES:y.deleteVertexArray.bind(o),bindVertexArrayOES:y.bindVertexArray.bind(o)}}this.clearColor=new qt(this),this.clearDepth=new Dt(this),this.clearStencil=new gn(this),this.colorMask=new wn(this),this.depthMask=new Yt(this),this.stencilMask=new rn(this),this.stencilFunc=new dn(this),this.stencilOp=new Mn(this),this.stencilTest=new li(this),this.depthRange=new ti(this),this.depthTest=new Ie(this),this.depthFunc=new xe(this),this.blend=new Tt(this),this.blendFunc=new hn(this),this.blendColor=new _n(this),this.blendEquation=new Sn(this),this.cullFace=new ri(this),this.cullFaceSide=new kt(this),this.frontFace=new Hn(this),this.program=new Fn(this),this.activeTexture=new Ze(this),this.viewport=new Tn(this),this.bindFramebuffer=new bn(this),this.bindRenderbuffer=new We(this),this.bindTexture=new bt(this),this.bindVertexBuffer=new un(this),this.bindElementBuffer=new ue(this),this.bindVertexArrayOES=this.extVertexArrayObject&&new te(this),this.pixelStoreUnpack=new se(this),this.pixelStoreUnpackPremultiplyAlpha=new ye(this),this.pixelStoreUnpackFlipY=new De(this),this.extTextureFilterAnisotropic=o.getExtension("EXT_texture_filter_anisotropic")||o.getExtension("MOZ_EXT_texture_filter_anisotropic")||o.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=o.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.extTextureFilterAnisotropicForceOff=!1,this.extStandardDerivativesForceOff=!1,this.extDebugRendererInfo=o.getExtension("WEBGL_debug_renderer_info"),this.extDebugRendererInfo&&(this.renderer=o.getParameter(this.extDebugRendererInfo.UNMASKED_RENDERER_WEBGL),this.vendor=o.getParameter(this.extDebugRendererInfo.UNMASKED_VENDOR_WEBGL)),u||(this.extTextureHalfFloat=o.getExtension("OES_texture_half_float")),(u||this.extTextureHalfFloat&&o.getExtension("OES_texture_half_float_linear"))&&(this.extRenderToTextureHalfFloat=o.getExtension("EXT_color_buffer_half_float")),this.extStandardDerivatives=u||o.getExtension("OES_standard_derivatives"),this.extTimerQuery=o.getExtension("EXT_disjoint_timer_query"),this.maxTextureSize=o.getParameter(o.MAX_TEXTURE_SIZE)}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.extVertexArrayObject&&(this.bindVertexArrayOES.dirty=!0),this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(o,u){return new oi(this,o,u)}createVertexBuffer(o,u,y){return new jt(this,o,u,y)}createRenderbuffer(o,u,y){const b=this.gl,M=b.createRenderbuffer();return this.bindRenderbuffer.set(M),b.renderbufferStorage(b.RENDERBUFFER,o,u,y),this.bindRenderbuffer.set(null),M}createFramebuffer(o,u,y){return new pt(this,o,u,y)}clear({color:o,depth:u,stencil:y}){const b=this.gl;let M=0;o&&(M|=b.COLOR_BUFFER_BIT,this.clearColor.set(o),this.colorMask.set([!0,!0,!0,!0])),u!==void 0&&(M|=b.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(u),this.depthMask.set(!0)),y!==void 0&&(M|=b.STENCIL_BUFFER_BIT,this.clearStencil.set(y),this.stencilMask.set(255)),b.clear(M)}setCullFace(o){o.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(o.mode),this.frontFace.set(o.frontFace))}setDepthMode(o){o.func!==this.gl.ALWAYS||o.mask?(this.depthTest.set(!0),this.depthFunc.set(o.func),this.depthMask.set(o.mask),this.depthRange.set(o.range)):this.depthTest.set(!1)}setStencilMode(o){o.test.func!==this.gl.ALWAYS||o.mask?(this.stencilTest.set(!0),this.stencilMask.set(o.mask),this.stencilOp.set([o.fail,o.depthFail,o.pass]),this.stencilFunc.set({func:o.test.func,ref:o.ref,mask:o.test.mask})):this.stencilTest.set(!1)}setColorMode(o){w(o.blendFunction,i.ColorMode.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(o.blendFunction),this.blendColor.set(o.blendColor)),this.colorMask.set(o.mask)}unbindVAO(){this.extVertexArrayObject&&this.bindVertexArrayOES.set(null)}}class on extends i.Evented{constructor(o,u,y,b){if(super(),this.id=o,this.dispatcher=y,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,i.extend(this,i.pick(u,["url","scheme","tileSize","promoteId"])),this._options=i.extend({type:"vector"},u),this._collectResourceTiming=u.collectResourceTiming,this.tileSize!==512)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(b),this._tileWorkers={},this._deduped=new i.DedupedRequest}load(o){this._loaded=!1,this.fire(new i.Event("dataloading",{dataType:"source"}));const u=Array.isArray(this.map._language)?this.map._language.join():this.map._language,y=this.map._worldview;this._tileJSONRequest=Mt(this._options,this.map._requestManager,u,y,(b,M)=>{this._tileJSONRequest=null,this._loaded=!0,b?(u&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${u}`),y&&y.length!==2&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${y}`),this.fire(new i.ErrorEvent(b))):M&&(i.extend(this,M),M.bounds&&(this.tileBounds=new ei(M.bounds,this.minzoom,this.maxzoom)),i.postTurnstileEvent(M.tiles,this.map._requestManager._customAccessToken),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"}))),o&&o(b)})}loaded(){return this._loaded}hasTile(o){return!this.tileBounds||this.tileBounds.contains(o.canonical)}onAdd(o){this.map=o,this.load()}reload(){this.cancelTileJSONRequest(),this.load(()=>this.map.style._clearSource(this.id))}setTiles(o){return this._options.tiles=o,this.reload(),this}setUrl(o){return this.url=o,this._options.url=o,this.reload(),this}onRemove(){this.cancelTileJSONRequest()}serialize(){return i.extend({},this._options)}loadTile(o,u){const y=this.map._requestManager.normalizeTileURL(o.tileID.canonical.url(this.tiles,this.scheme)),b={request:this.map._requestManager.transformRequest(y,i.ResourceType.Tile),data:void 0,uid:o.uid,tileID:o.tileID,tileZoom:o.tileZoom,zoom:o.tileID.overscaledZ,tileSize:this.tileSize*o.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:i.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:o.isSymbolTile};if(b.request.collectResourceTiming=this._collectResourceTiming,o.actor&&o.state!=="expired")o.state==="loading"?o.reloadCallback=u:o.request=o.actor.send("reloadTile",b,M.bind(this));else if(o.actor=this._tileWorkers[y]=this._tileWorkers[y]||this.dispatcher.getActor(),this.dispatcher.ready)o.request=o.actor.send("loadTile",b,M.bind(this),void 0,!0);else{const R=i.loadVectorTile.call({deduped:this._deduped},b,(z,V)=>{z||!V?M.call(this,z):(b.data={cacheControl:V.cacheControl,expires:V.expires,rawData:V.rawData.slice(0)},o.actor&&o.actor.send("loadTile",b,M.bind(this),void 0,!0))},!0);o.request={cancel:R}}function M(R,z){return delete o.request,o.aborted?u(null):R&&R.status!==404?u(R):(z&&z.resourceTiming&&(o.resourceTiming=z.resourceTiming),this.map._refreshExpiredTiles&&z&&o.setExpiryData(z),o.loadVectorData(z,this.map.painter),i.cacheEntryPossiblyAdded(this.dispatcher),u(null),void(o.reloadCallback&&(this.loadTile(o,o.reloadCallback),o.reloadCallback=null)))}}abortTile(o){o.request&&(o.request.cancel(),delete o.request),o.actor&&o.actor.send("abortTile",{uid:o.uid,type:this.type,source:this.id})}unloadTile(o){o.unloadVectorData(),o.actor&&o.actor.send("removeTile",{uid:o.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}class Kt extends i.Evented{constructor(o,u,y,b){super(),this.id=o,this.dispatcher=y,this.setEventedParent(b),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=i.extend({type:"raster"},u),i.extend(this,i.pick(u,["url","scheme","tileSize"]))}load(o){this._loaded=!1,this.fire(new i.Event("dataloading",{dataType:"source"})),this._tileJSONRequest=Mt(this._options,this.map._requestManager,null,null,(u,y)=>{this._tileJSONRequest=null,this._loaded=!0,u?this.fire(new i.ErrorEvent(u)):y&&(i.extend(this,y),y.bounds&&(this.tileBounds=new ei(y.bounds,this.minzoom,this.maxzoom)),i.postTurnstileEvent(y.tiles),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"}))),o&&o(u)})}loaded(){return this._loaded}onAdd(o){this.map=o,this.load()}reload(){this.cancelTileJSONRequest(),this.load(()=>this.map.style._clearSource(this.id))}setTiles(o){return this._options.tiles=o,this.reload(),this}setUrl(o){return this.url=o,this._options.url=o,this.reload(),this}onRemove(){this.cancelTileJSONRequest()}serialize(){return i.extend({},this._options)}hasTile(o){return!this.tileBounds||this.tileBounds.contains(o.canonical)}loadTile(o,u){const y=i.exported.devicePixelRatio>=2,b=this.map._requestManager.normalizeTileURL(o.tileID.canonical.url(this.tiles,this.scheme),y,this.tileSize);o.request=i.getImage(this.map._requestManager.transformRequest(b,i.ResourceType.Tile),(M,R,z,V)=>(delete o.request,o.aborted?(o.state="unloaded",u(null)):M?(o.state="errored",u(M)):R?(this.map._refreshExpiredTiles&&o.setExpiryData({cacheControl:z,expires:V}),o.setTexture(R,this.map.painter),o.state="loaded",i.cacheEntryPossiblyAdded(this.dispatcher),void u(null)):u(null)))}static loadTileData(o,u,y){o.setTexture(u,y)}static unloadTileData(o,u){o.texture&&u.saveTileTexture(o.texture)}abortTile(o,u){o.request&&(o.request.cancel(),delete o.request),u()}unloadTile(o,u){o.texture&&this.map.painter.saveTileTexture(o.texture),u()}hasTransition(){return!1}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}}function xi(p,o,u,y,b,M,R,z){const V=[p,u,b,o,y,M,1,1,1],X=[R,z,1],q=i.adjoint([],V),[Q,he,me]=i.transformMat3(X,X,i.transpose(q,q));return i.multiply$1(V,[Q,0,0,0,he,0,0,0,me],V)}class ci extends i.Evented{constructor(o,u,y,b){super(),this.id=o,this.dispatcher=y,this.coordinates=u.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(b),this.options=u,this._dirty=!1}load(o,u){this._loaded=u||!1,this.fire(new i.Event("dataloading",{dataType:"source"})),this.url=this.options.url,this._imageRequest=i.getImage(this.map._requestManager.transformRequest(this.url,i.ResourceType.Image),(y,b)=>{if(this._imageRequest=null,this._loaded=!0,y)this.fire(new i.ErrorEvent(y));else if(b){const{HTMLImageElement:M}=i.window;this.image=b instanceof M?i.exported.getImageData(b):b,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,o&&(this.coordinates=o),this._finishLoading()}})}loaded(){return this._loaded}updateImage(o){return this.image&&o.url?(this._imageRequest&&o.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=o.url,this.load(o.coordinates,this._loaded),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(o){this.map=o,this.load()}onRemove(){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),this.texture&&this.texture.destroy()}setCoordinates(o){this.coordinates=o,this._boundsArray=void 0;const u=o.map(i.MercatorCoordinate.fromLngLat);return this.tileID=function(y){let b=1/0,M=1/0,R=-1/0,z=-1/0;for(const Q of y)b=Math.min(b,Q.x),M=Math.min(M,Q.y),R=Math.max(R,Q.x),z=Math.max(z,Q.y);const V=Math.max(R-b,z-M),X=Math.max(0,Math.floor(-Math.log(V)/Math.LN2)),q=Math.pow(2,X);return new i.CanonicalTileID(X,Math.floor((b+R)/2*q),Math.floor((M+z)/2*q))}(u),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0}_prepareData(o){for(const V in this.tiles){const X=this.tiles[V];X.state!=="loaded"&&(X.state="loaded",X.texture=this.texture)}if(this._boundsArray)return;const u=i.tileTransform(this.tileID,this.map.transform.projection),[y,b,M,R]=this.coordinates.map(V=>{const X=u.projection.project(V[0],V[1]);return i.getTilePoint(u,X)._round()});this.perspectiveTransform=function(V,X,q,Q,he,me,ge,_e,be,ie){const pe=xi(0,0,V,0,0,X,V,X),Ee=xi(q,Q,he,me,ge,_e,be,ie);return i.multiply$1(Ee,i.adjoint(pe,pe),Ee),[Ee[6]/Ee[8]*V/i.EXTENT,Ee[7]/Ee[8]*X/i.EXTENT]}(this.width,this.height,y.x,y.y,b.x,b.y,R.x,R.y,M.x,M.y);const z=this._boundsArray=new i.StructArrayLayout4i8;z.emplaceBack(y.x,y.y,0,0),z.emplaceBack(b.x,b.y,i.EXTENT,0),z.emplaceBack(R.x,R.y,0,i.EXTENT),z.emplaceBack(M.x,M.y,i.EXTENT,i.EXTENT),this.boundsBuffer&&this.boundsBuffer.destroy(),this.boundsBuffer=o.createVertexBuffer(z,i.boundsAttributes.members),this.boundsSegments=i.SegmentVector.simpleSegment(0,0,4,2)}prepare(){if(Object.keys(this.tiles).length===0||!this.image)return;const o=this.map.painter.context,u=o.gl;this._dirty&&(this.texture?this.texture.update(this.image):(this.texture=new i.Texture(o,this.image,u.RGBA),this.texture.bind(u.LINEAR,u.CLAMP_TO_EDGE)),this._dirty=!1),this._prepareData(o)}loadTile(o,u){this.tileID&&this.tileID.equals(o.tileID.canonical)?(this.tiles[String(o.tileID.wrap)]=o,o.buckets={},u(null)):(o.state="errored",u(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const ve={vector:on,raster:Kt,"raster-dem":class extends Kt{constructor(p,o,u,y){super(p,o,u,y),this.type="raster-dem",this.maxzoom=22,this._options=i.extend({type:"raster-dem"},o),this.encoding=o.encoding||"mapbox"}loadTile(p,o){const u=this.map._requestManager.normalizeTileURL(p.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function y(b,M){b&&(p.state="errored",o(b)),M&&(p.dem=M,p.dem.onDeserialize(),p.needsHillshadePrepare=!0,p.needsDEMTextureUpload=!0,p.state="loaded",o(null))}p.request=i.getImage(this.map._requestManager.transformRequest(u,i.ResourceType.Tile),function(b,M,R,z){if(delete p.request,p.aborted)p.state="unloaded",o(null);else if(b)p.state="errored",o(b);else if(M){this.map._refreshExpiredTiles&&p.setExpiryData({cacheControl:R,expires:z});const V=i.window.ImageBitmap&&M instanceof i.window.ImageBitmap&&(On==null&&(On=i.window.OffscreenCanvas&&new i.window.OffscreenCanvas(1,1).getContext("2d")&&typeof i.window.createImageBitmap=="function"),On),X=1-(M.width-i.prevPowerOfTwo(M.width))/2;X<1||p.neighboringTiles||(p.neighboringTiles=this._getNeighboringTiles(p.tileID));const q=V?M:i.exported.getImageData(M,X),Q={uid:p.uid,coord:p.tileID,source:this.id,rawImageData:q,encoding:this.encoding,padding:X};p.actor&&p.state!=="expired"||(p.actor=this.dispatcher.getActor(),p.actor.send("loadDEMTile",Q,y.bind(this),void 0,!0))}}.bind(this))}_getNeighboringTiles(p){const o=p.canonical,u=Math.pow(2,o.z),y=(o.x-1+u)%u,b=o.x===0?p.wrap-1:p.wrap,M=(o.x+1+u)%u,R=o.x+1===u?p.wrap+1:p.wrap,z={};return z[new i.OverscaledTileID(p.overscaledZ,b,o.z,y,o.y).key]={backfilled:!1},z[new i.OverscaledTileID(p.overscaledZ,R,o.z,M,o.y).key]={backfilled:!1},o.y>0&&(z[new i.OverscaledTileID(p.overscaledZ,b,o.z,y,o.y-1).key]={backfilled:!1},z[new i.OverscaledTileID(p.overscaledZ,p.wrap,o.z,o.x,o.y-1).key]={backfilled:!1},z[new i.OverscaledTileID(p.overscaledZ,R,o.z,M,o.y-1).key]={backfilled:!1}),o.y+1<u&&(z[new i.OverscaledTileID(p.overscaledZ,b,o.z,y,o.y+1).key]={backfilled:!1},z[new i.OverscaledTileID(p.overscaledZ,p.wrap,o.z,o.x,o.y+1).key]={backfilled:!1},z[new i.OverscaledTileID(p.overscaledZ,R,o.z,M,o.y+1).key]={backfilled:!1}),z}unloadTile(p){p.demTexture&&this.map.painter.saveTileTexture(p.demTexture),p.fbo&&(p.fbo.destroy(),delete p.fbo),p.dem&&delete p.dem,delete p.neighboringTiles,p.state="unloaded"}},geojson:class extends i.Evented{constructor(p,o,u,y){super(),this.id=p,this.type="geojson",this.minzoom=0,this.maxzoom=18,this.tileSize=512,this.isTileClipped=!0,this.reparseOverscaled=!0,this._loaded=!1,this.actor=u.getActor(),this.setEventedParent(y),this._data=o.data,this._options=i.extend({},o),this._collectResourceTiming=o.collectResourceTiming,o.maxzoom!==void 0&&(this.maxzoom=o.maxzoom),o.type&&(this.type=o.type),o.attribution&&(this.attribution=o.attribution),this.promoteId=o.promoteId;const b=i.EXTENT/this.tileSize;this.workerOptions=i.extend({source:this.id,cluster:o.cluster||!1,geojsonVtOptions:{buffer:(o.buffer!==void 0?o.buffer:128)*b,tolerance:(o.tolerance!==void 0?o.tolerance:.375)*b,extent:i.EXTENT,maxZoom:this.maxzoom,lineMetrics:o.lineMetrics||!1,generateId:o.generateId||!1},superclusterOptions:{maxZoom:o.clusterMaxZoom!==void 0?o.clusterMaxZoom:this.maxzoom-1,minPoints:Math.max(2,o.clusterMinPoints||2),extent:i.EXTENT,radius:(o.clusterRadius!==void 0?o.clusterRadius:50)*b,log:!1,generateId:o.generateId||!1},clusterProperties:o.clusterProperties,filter:o.filter},o.workerOptions)}onAdd(p){this.map=p,this.setData(this._data)}setData(p){return this._data=p,this._updateWorkerData(),this}getClusterExpansionZoom(p,o){return this.actor.send("geojson.getClusterExpansionZoom",{clusterId:p,source:this.id},o),this}getClusterChildren(p,o){return this.actor.send("geojson.getClusterChildren",{clusterId:p,source:this.id},o),this}getClusterLeaves(p,o,u,y){return this.actor.send("geojson.getClusterLeaves",{source:this.id,clusterId:p,limit:o,offset:u},y),this}_updateWorkerData(){if(this._pendingLoad)return void(this._coalesce=!0);this.fire(new i.Event("dataloading",{dataType:"source"})),this._loaded=!1;const p=i.extend({},this.workerOptions),o=this._data;typeof o=="string"?(p.request=this.map._requestManager.transformRequest(i.exported.resolveURL(o),i.ResourceType.Source),p.request.collectResourceTiming=this._collectResourceTiming):p.data=JSON.stringify(o),this._pendingLoad=this.actor.send(`${this.type}.loadData`,p,(u,y)=>{if(this._loaded=!0,this._pendingLoad=null,u)this.fire(new i.ErrorEvent(u));else{const b={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&y&&y.resourceTiming&&y.resourceTiming[this.id]&&(b.resourceTiming=y.resourceTiming[this.id]),this.fire(new i.Event("data",b)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)})}loaded(){return this._loaded}loadTile(p,o){const u=p.actor?"reloadTile":"loadTile";p.actor=this.actor,p.request=this.actor.send(u,{type:this.type,uid:p.uid,tileID:p.tileID,tileZoom:p.tileZoom,zoom:p.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:i.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},(y,b)=>(delete p.request,p.unloadVectorData(),p.aborted?o(null):y?o(y):(p.loadVectorData(b,this.map.painter,u==="reloadTile"),o(null))),void 0,u==="loadTile")}abortTile(p){p.request&&(p.request.cancel(),delete p.request),p.aborted=!0}unloadTile(p){p.unloadVectorData(),this.actor.send("removeTile",{uid:p.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return i.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends ci{constructor(p,o,u,y){super(p,o,u,y),this.roundZoom=!0,this.type="video",this.options=o}load(){this._loaded=!1;const p=this.options;this.urls=[];for(const o of p.urls)this.urls.push(this.map._requestManager.transformRequest(o,i.ResourceType.Source).url);i.getVideo(this.urls,(o,u)=>{this._loaded=!0,o?this.fire(new i.ErrorEvent(o)):u&&(this.video=u,this.video.loop=!0,this.video.setAttribute("playsinline",""),this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading())})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(p){if(this.video){const o=this.video.seekable;p<o.start(0)||p>o.end(0)?this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${this.id}`,null,`Playback for this video can be set only between the ${o.start(0)} and ${o.end(0)}-second mark.`))):this.video.currentTime=p}}getVideo(){return this.video}onAdd(p){this.map||(this.map=p,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;const p=this.map.painter.context,o=p.gl;this.texture?this.video.paused||(this.texture.bind(o.LINEAR,o.CLAMP_TO_EDGE),o.texSubImage2D(o.TEXTURE_2D,0,0,0,o.RGBA,o.UNSIGNED_BYTE,this.video)):(this.texture=new i.Texture(p,this.video,o.RGBA),this.texture.bind(o.LINEAR,o.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(p)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:ci,canvas:class extends ci{constructor(p,o,u,y){super(p,o,u,y),o.coordinates?Array.isArray(o.coordinates)&&o.coordinates.length===4&&!o.coordinates.some(b=>!Array.isArray(b)||b.length!==2||b.some(M=>typeof M!="number"))||this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${p}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${p}`,null,'missing required property "coordinates"'))),o.animate&&typeof o.animate!="boolean"&&this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${p}`,null,'optional "animate" property must be a boolean value'))),o.canvas?typeof o.canvas=="string"||o.canvas instanceof i.window.HTMLCanvasElement||this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${p}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new i.ErrorEvent(new i.ValidationError(`sources.${p}`,null,'missing required property "canvas"'))),this.options=o,this.animate=o.animate===void 0||o.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof i.window.HTMLCanvasElement?this.options.canvas:i.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new i.ErrorEvent(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}getCanvas(){return this.canvas}onAdd(p){this.map=p,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let p=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,p=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,p=!0),this._hasInvalidDimensions()||Object.keys(this.tiles).length===0)return;const o=this.map.painter.context;this.texture?(p||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new i.Texture(o,this.canvas,o.gl.RGBA,{premultiply:!0}),this._prepareData(o)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const p of[this.canvas.width,this.canvas.height])if(isNaN(p)||p<=0)return!0;return!1}},custom:class extends i.Evented{constructor(p,o,u,y){super(),this.id=p,this.type="custom",this._dataType="raster",this._dispatcher=u,this._implementation=o,this.setEventedParent(y),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new i.ErrorEvent(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new i.ErrorEvent(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new ei(this._implementation.bounds,this.minzoom,this.maxzoom)),o.update=this._update.bind(this),o.clearTiles=this._clearTiles.bind(this),o.coveringTiles=this._coveringTiles.bind(this),i.extend(this,i.pick(o,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return i.pick(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new i.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(p){this._map=p,this._loaded=!1,this.fire(new i.Event("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(p),this.load()}onRemove(p){this._implementation.onRemove&&this._implementation.onRemove(p)}hasTile(p){if(this._implementation.hasTile){const{x:o,y:u,z:y}=p.canonical;return this._implementation.hasTile({x:o,y:u,z:y})}return!this.tileBounds||this.tileBounds.contains(p.canonical)}loadTile(p,o){const{x:u,y,z:b}=p.tileID.canonical,M=new i.window.AbortController;p.request=Promise.resolve(this._implementation.loadTile({x:u,y,z:b},{signal:M.signal})).then(function(R){return delete p.request,p.aborted?(p.state="unloaded",o(null)):R===void 0?(p.state="errored",o(null)):R===null?(this.loadTileData(p,{width:this.tileSize,height:this.tileSize,data:null}),p.state="loaded",o(null)):function(z){return z instanceof i.window.ImageData||z instanceof i.window.HTMLCanvasElement||z instanceof i.window.ImageBitmap||z instanceof i.window.HTMLImageElement}(R)?(this.loadTileData(p,R),p.state="loaded",void o(null)):(p.state="errored",o(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}.bind(this)).catch(R=>{R.code!==20&&(p.state="errored",o(R))}),p.request.cancel=()=>M.abort()}loadTileData(p,o){Kt.loadTileData(p,o,this._map.painter)}unloadTileData(p){Kt.unloadTileData(p,this._map.painter)}unloadTile(p,o){if(this.unloadTileData(p),this._implementation.unloadTile){const{x:u,y,z:b}=p.tileID.canonical;this._implementation.unloadTile({x:u,y,z:b})}o()}abortTile(p,o){p.request&&p.request.cancel&&(p.request.cancel(),delete p.request),o()}hasTransition(){return!1}_coveringTiles(){return this._map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map(p=>({x:p.canonical.x,y:p.canonical.y,z:p.canonical.z}))}_clearTiles(){this._map.style._clearSource(this.id)}_update(){this.fire(new i.Event("data",{dataType:"source",sourceDataType:"content"}))}}},Qe=function(p,o,u,y){const b=new ve[o.type](p,o,u,y);if(b.id!==p)throw new Error(`Expected Source id to be ${p} instead of ${b.id}`);return i.bindAll(["load","abort","unload","serialize","prepare"],b),b};function lt(p,o){const u=i.identity([]);return i.scale(u,u,[.5*p.width,.5*-p.height,1]),i.translate(u,u,[1,-1,0]),i.multiply(u,u,p.calculateProjMatrix(o.toUnwrapped())),Float32Array.from(u)}function mt(p,o,u,y,b,M,R,z=!1){const V=p.tilesIn(y,R,z);V.sort($n);const X=[];for(const Q of V)X.push({wrappedTileID:Q.tile.tileID.wrapped().key,queryResults:Q.tile.queryRenderedFeatures(o,u,p._state,Q,b,M,lt(p.transform,Q.tile.tileID),z)});const q=function(Q){const he={},me={};for(const ge of Q){const _e=ge.queryResults,be=ge.wrappedTileID,ie=me[be]=me[be]||{};for(const pe in _e){const Ee=_e[pe],Te=ie[pe]=ie[pe]||{},Ue=he[pe]=he[pe]||[];for(const Ge of Ee)Te[Ge.featureIndex]||(Te[Ge.featureIndex]=!0,Ue.push(Ge))}}return he}(X);for(const Q in q)q[Q].forEach(he=>{const me=he.feature,ge=me.layer;ge&&ge.type!=="background"&&ge.type!=="sky"&&(me.source=ge.source,ge["source-layer"]&&(me.sourceLayer=ge["source-layer"]),me.state=me.id!==void 0?p.getFeatureState(ge["source-layer"],me.id):{})});return q}function Gt(p,o){const u=p.getRenderableIds().map(M=>p.getTileByID(M)),y=[],b={};for(let M=0;M<u.length;M++){const R=u[M],z=R.tileID.canonical.key;b[z]||(b[z]=!0,R.querySourceFeatures(y,o))}return y}function $n(p,o){const u=p.tileID,y=o.tileID;return u.overscaledZ-y.overscaledZ||u.canonical.y-y.canonical.y||u.wrap-y.wrap||u.canonical.x-y.canonical.x}function Yn(){return Hl.workerClass!=null?new Hl.workerClass:new i.window.Worker(Hl.workerUrl)}const bi="mapboxgl_preloaded_worker_pool";class ui{constructor(){this.active={}}acquire(o){if(!this.workers)for(this.workers=[];this.workers.length<ui.workerCount;)this.workers.push(new Yn);return this.active[o]=!0,this.workers.slice()}release(o){delete this.active[o],this.numActive()===0&&(this.workers.forEach(u=>{u.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[bi]}numActive(){return Object.keys(this.active).length}}let ai;function Ni(){return ai||(ai=new ui),ai}function Qi(p,o){const u={};for(const y in p)y!=="ref"&&(u[y]=p[y]);return i.refProperties.forEach(y=>{y in o&&(u[y]=o[y])}),u}function Cr(p){p=p.slice();const o=Object.create(null);for(let u=0;u<p.length;u++)o[p[u].id]=p[u];for(let u=0;u<p.length;u++)"ref"in p[u]&&(p[u]=Qi(p[u],o[p[u].ref]));return p}ui.workerCount=2;const ki={setStyle:"setStyle",addLayer:"addLayer",removeLayer:"removeLayer",setPaintProperty:"setPaintProperty",setLayoutProperty:"setLayoutProperty",setFilter:"setFilter",addSource:"addSource",removeSource:"removeSource",setGeoJSONSourceData:"setGeoJSONSourceData",setLayerZoomRange:"setLayerZoomRange",setLayerProperty:"setLayerProperty",setCenter:"setCenter",setZoom:"setZoom",setBearing:"setBearing",setPitch:"setPitch",setSprite:"setSprite",setGlyphs:"setGlyphs",setTransition:"setTransition",setLight:"setLight",setTerrain:"setTerrain",setFog:"setFog",setProjection:"setProjection"};function ea(p,o,u){u.push({command:ki.addSource,args:[p,o[p]]})}function Xs(p,o,u){o.push({command:ki.removeSource,args:[p]}),u[p]=!0}function $s(p,o,u,y){Xs(p,u,y),ea(p,o,u)}function Vi(p,o,u){let y;for(y in p[u])if(p[u].hasOwnProperty(y)&&y!=="data"&&!w(p[u][y],o[u][y]))return!1;for(y in o[u])if(o[u].hasOwnProperty(y)&&y!=="data"&&!w(p[u][y],o[u][y]))return!1;return!0}function Ur(p,o,u,y,b,M){let R;for(R in o=o||{},p=p||{})p.hasOwnProperty(R)&&(w(p[R],o[R])||u.push({command:M,args:[y,R,o[R],b]}));for(R in o)o.hasOwnProperty(R)&&!p.hasOwnProperty(R)&&(w(p[R],o[R])||u.push({command:M,args:[y,R,o[R],b]}))}function er(p){return p.id}function tr(p,o){return p[o.id]=o,p}class po{constructor(o,u){this.reset(o,u)}reset(o,u){this.points=o||[],this._distances=[0];for(let y=1;y<this.points.length;y++)this._distances[y]=this._distances[y-1]+this.points[y].dist(this.points[y-1]);this.length=this._distances[this._distances.length-1],this.padding=Math.min(u||0,.5*this.length),this.paddedLength=this.length-2*this.padding}lerp(o){if(this.points.length===1)return this.points[0];o=i.clamp(o,0,1);let u=1,y=this._distances[u];const b=o*this.paddedLength+this.padding;for(;y<b&&u<this._distances.length;)y=this._distances[++u];const M=u-1,R=this._distances[M],z=y-R,V=z>0?(b-R)/z:0;return this.points[M].mult(1-V).add(this.points[u].mult(V))}}class Es{constructor(o,u,y){const b=this.boxCells=[],M=this.circleCells=[];this.xCellCount=Math.ceil(o/y),this.yCellCount=Math.ceil(u/y);for(let R=0;R<this.xCellCount*this.yCellCount;R++)b.push([]),M.push([]);this.circleKeys=[],this.boxKeys=[],this.bboxes=[],this.circles=[],this.width=o,this.height=u,this.xScale=this.xCellCount/o,this.yScale=this.yCellCount/u,this.boxUid=0,this.circleUid=0}keysLength(){return this.boxKeys.length+this.circleKeys.length}insert(o,u,y,b,M){this._forEachCell(u,y,b,M,this._insertBoxCell,this.boxUid++),this.boxKeys.push(o),this.bboxes.push(u),this.bboxes.push(y),this.bboxes.push(b),this.bboxes.push(M)}insertCircle(o,u,y,b){this._forEachCell(u-b,y-b,u+b,y+b,this._insertCircleCell,this.circleUid++),this.circleKeys.push(o),this.circles.push(u),this.circles.push(y),this.circles.push(b)}_insertBoxCell(o,u,y,b,M,R){this.boxCells[M].push(R)}_insertCircleCell(o,u,y,b,M,R){this.circleCells[M].push(R)}_query(o,u,y,b,M,R){if(y<0||o>this.width||b<0||u>this.height)return!M&&[];const z=[];if(o<=0&&u<=0&&this.width<=y&&this.height<=b){if(M)return!0;for(let V=0;V<this.boxKeys.length;V++)z.push({key:this.boxKeys[V],x1:this.bboxes[4*V],y1:this.bboxes[4*V+1],x2:this.bboxes[4*V+2],y2:this.bboxes[4*V+3]});for(let V=0;V<this.circleKeys.length;V++){const X=this.circles[3*V],q=this.circles[3*V+1],Q=this.circles[3*V+2];z.push({key:this.circleKeys[V],x1:X-Q,y1:q-Q,x2:X+Q,y2:q+Q})}return R?z.filter(R):z}return this._forEachCell(o,u,y,b,this._queryCell,z,{hitTest:M,seenUids:{box:{},circle:{}}},R),M?z.length>0:z}_queryCircle(o,u,y,b,M){const R=o-y,z=o+y,V=u-y,X=u+y;if(z<0||R>this.width||X<0||V>this.height)return!b&&[];const q=[];return this._forEachCell(R,V,z,X,this._queryCellCircle,q,{hitTest:b,circle:{x:o,y:u,radius:y},seenUids:{box:{},circle:{}}},M),b?q.length>0:q}query(o,u,y,b,M){return this._query(o,u,y,b,!1,M)}hitTest(o,u,y,b,M){return this._query(o,u,y,b,!0,M)}hitTestCircle(o,u,y,b){return this._queryCircle(o,u,y,!0,b)}_queryCell(o,u,y,b,M,R,z,V){const X=z.seenUids,q=this.boxCells[M];if(q!==null){const he=this.bboxes;for(const me of q)if(!X.box[me]){X.box[me]=!0;const ge=4*me;if(o<=he[ge+2]&&u<=he[ge+3]&&y>=he[ge+0]&&b>=he[ge+1]&&(!V||V(this.boxKeys[me]))){if(z.hitTest)return R.push(!0),!0;R.push({key:this.boxKeys[me],x1:he[ge],y1:he[ge+1],x2:he[ge+2],y2:he[ge+3]})}}}const Q=this.circleCells[M];if(Q!==null){const he=this.circles;for(const me of Q)if(!X.circle[me]){X.circle[me]=!0;const ge=3*me;if(this._circleAndRectCollide(he[ge],he[ge+1],he[ge+2],o,u,y,b)&&(!V||V(this.circleKeys[me]))){if(z.hitTest)return R.push(!0),!0;{const _e=he[ge],be=he[ge+1],ie=he[ge+2];R.push({key:this.circleKeys[me],x1:_e-ie,y1:be-ie,x2:_e+ie,y2:be+ie})}}}}}_queryCellCircle(o,u,y,b,M,R,z,V){const X=z.circle,q=z.seenUids,Q=this.boxCells[M];if(Q!==null){const me=this.bboxes;for(const ge of Q)if(!q.box[ge]){q.box[ge]=!0;const _e=4*ge;if(this._circleAndRectCollide(X.x,X.y,X.radius,me[_e+0],me[_e+1],me[_e+2],me[_e+3])&&(!V||V(this.boxKeys[ge])))return R.push(!0),!0}}const he=this.circleCells[M];if(he!==null){const me=this.circles;for(const ge of he)if(!q.circle[ge]){q.circle[ge]=!0;const _e=3*ge;if(this._circlesCollide(me[_e],me[_e+1],me[_e+2],X.x,X.y,X.radius)&&(!V||V(this.circleKeys[ge])))return R.push(!0),!0}}}_forEachCell(o,u,y,b,M,R,z,V){const X=this._convertToXCellCoord(o),q=this._convertToYCellCoord(u),Q=this._convertToXCellCoord(y),he=this._convertToYCellCoord(b);for(let me=X;me<=Q;me++)for(let ge=q;ge<=he;ge++)if(M.call(this,o,u,y,b,this.xCellCount*ge+me,R,z,V))return}_convertToXCellCoord(o){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(o*this.xScale)))}_convertToYCellCoord(o){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(o*this.yScale)))}_circlesCollide(o,u,y,b,M,R){const z=b-o,V=M-u,X=y+R;return X*X>z*z+V*V}_circleAndRectCollide(o,u,y,b,M,R,z){const V=(R-b)/2,X=Math.abs(o-(b+V));if(X>V+y)return!1;const q=(z-M)/2,Q=Math.abs(u-(M+q));if(Q>q+y)return!1;if(X<=V||Q<=q)return!0;const he=X-V,me=Q-q;return he*he+me*me<=y*y}}const Ir={unknown:0,flipRequired:1,flipNotRequired:2},Zi=Math.tan(85*Math.PI/180);function ct(p,o,u,y,b,M,R){const z=i.create();if(u)if(M.name==="globe"){const V=i.calculateGlobeLabelMatrix(b,o);i.multiply(z,z,V)}else{const V=ce([],R);z[0]=V[0],z[1]=V[1],z[4]=V[2],z[5]=V[3],y||i.rotateZ(z,z,b.angle)}else i.multiply(z,b.labelPlaneMatrix,p);return z}function Ri(p,o,u,y,b,M,R){const z=ct(p,o,u,y,b,M,R);return M.name==="globe"&&u||(z[2]=z[6]=z[10]=z[14]=0),z}function Ci(p,o,u,y,b,M,R){if(u){if(M.name==="globe"){const z=ct(p,o,u,y,b,M,R);return i.invert(z,z),i.multiply(z,p,z),z}{const z=i.clone(p),V=i.identity([]);return V[0]=R[0],V[1]=R[1],V[4]=R[2],V[5]=R[3],i.multiply(z,z,V),y||i.rotateZ(z,z,-b.angle),z}}return b.glCoordMatrix}function nr(p,o,u,y){const b=[p,o,u,1];u?i.transformMat4$1(b,b,y):Ei(b,b,y);const M=b[3];return b[0]/=M,b[1]/=M,b[2]/=M,b}function Os(p,o){return Math.min(.5+p/o*.5,1.5)}function Ts(p,o){const u=p[0]/p[3],y=p[1]/p[3];return u>=-o[0]&&u<=o[0]&&y>=-o[1]&&y<=o[1]}function Ra(p,o,u,y,b,M,R,z,V,X){const q=u.transform,Q=y?p.textSizeData:p.iconSizeData,he=i.evaluateSizeForZoom(Q,u.transform.zoom),me=q.projection.name==="globe",ge=[256/u.width*2+1,256/u.height*2+1],_e=y?p.text.dynamicLayoutVertexArray:p.icon.dynamicLayoutVertexArray;_e.clear();let be=null;me&&(be=y?p.text.globeExtVertexArray:p.icon.globeExtVertexArray);const ie=p.lineVertexArray,pe=y?p.text.placedSymbolArray:p.icon.placedSymbolArray,Ee=u.transform.width/u.transform.height;let Te,Ue=!1;for(let Ge=0;Ge<pe.length;Ge++){const Ve=pe.get(Ge),{numGlyphs:et,writingMode:$e}=Ve;if($e!==i.WritingMode.vertical||Ue||Te===i.WritingMode.horizontal||(Ue=!0),Te=$e,(Ve.hidden||$e===i.WritingMode.vertical)&&!Ue){Hr(et,_e);continue}Ue=!1;const ht=new i.Point(Ve.tileAnchorX,Ve.tileAnchorY);let{x:Jt,y:ut,z:Bt}=q.projection.projectTilePoint(ht.x,ht.y,X.canonical);if(V){const[qn,vn,Vn]=V(ht);Jt+=qn,ut+=vn,Bt+=Vn}const yt=[Jt,ut,Bt,1];if(i.transformMat4$1(yt,yt,o),!Ts(yt,ge)){Hr(et,_e);continue}const Xt=Os(u.transform.cameraToCenterDistance,yt[3]),gt=i.evaluateSizeForFeature(Q,he,Ve),Ot=R?gt/Xt:gt*Xt,Qt=nr(Jt,ut,Bt,b);if(Qt[3]<=0){Hr(et,_e);continue}let Lt={};const Ct=R?null:V,zn=En(Ve,Ot,!1,z,o,b,M,p.glyphOffsetArray,ie,_e,be,Qt,ht,Lt,Ee,Ct,q.projection,X,R);Ue=zn.useVertical,Ct&&zn.needsFlipping&&(Lt={}),(zn.notEnoughRoom||Ue||zn.needsFlipping&&En(Ve,Ot,!0,z,o,b,M,p.glyphOffsetArray,ie,_e,be,Qt,ht,Lt,Ee,Ct,q.projection,X,R).notEnoughRoom)&&Hr(et,_e)}y?(p.text.dynamicLayoutVertexBuffer.updateData(_e),be&&p.text.globeExtVertexBuffer.updateData(be)):(p.icon.dynamicLayoutVertexBuffer.updateData(_e),be&&p.icon.globeExtVertexBuffer.updateData(be))}function As(p,o,u,y,b,M,R,z,V,X,q,Q,he,me,ge,_e){const{lineStartIndex:be,glyphStartIndex:ie,segment:pe}=z,Ee=ie+z.numGlyphs,Te=be+z.lineLength,Ue=o.getoffsetX(ie),Ge=o.getoffsetX(Ee-1),Ve=Ys(p*Ue,u,y,b,M,R,pe,be,Te,V,X,q,Q,he,!0,me,ge,_e);if(!Ve)return null;const et=Ys(p*Ge,u,y,b,M,R,pe,be,Te,V,X,q,Q,he,!0,me,ge,_e);return et?{first:Ve,last:et}:null}function Uo(p,o,u,y){return p===i.WritingMode.horizontal&&Math.abs(y)>Math.abs(u)?{useVertical:!0}:p===i.WritingMode.vertical?y>0?{needsFlipping:!0}:null:o!==Ir.unknown&&function(b,M){return b===0||Math.abs(M/b)>Zi}(u,y)?o===Ir.flipRequired?{needsFlipping:!0}:null:u<0?{needsFlipping:!0}:null}function En(p,o,u,y,b,M,R,z,V,X,q,Q,he,me,ge,_e,be,ie,pe){const Ee=o/24,Te=p.lineOffsetX*Ee,Ue=p.lineOffsetY*Ee,{lineStartIndex:Ge,glyphStartIndex:Ve,numGlyphs:et,segment:$e,writingMode:ht,flipState:Jt}=p,ut=Ge+p.lineLength,Bt=yt=>{if(q){const[Qt,Lt,Ct]=yt.up,zn=X.length;i.updateGlobeVertexNormal(q,zn+0,Qt,Lt,Ct),i.updateGlobeVertexNormal(q,zn+1,Qt,Lt,Ct),i.updateGlobeVertexNormal(q,zn+2,Qt,Lt,Ct),i.updateGlobeVertexNormal(q,zn+3,Qt,Lt,Ct)}const[Xt,gt,Ot]=yt.point;i.addDynamicAttributes(X,Xt,gt,Ot,yt.angle)};if(et>1){const yt=As(Ee,z,Te,Ue,u,Q,he,p,V,M,me,_e,!1,be,ie,pe);if(!yt)return{notEnoughRoom:!0};if(y&&!u){let[Xt,gt,Ot]=yt.first.point,[Qt,Lt,Ct]=yt.last.point;[Xt,gt]=nr(Xt,gt,Ot,R),[Qt,Lt]=nr(Qt,Lt,Ct,R);const zn=Uo(ht,Jt,(Qt-Xt)*ge,Lt-gt);if(p.flipState=zn&&zn.needsFlipping?Ir.flipRequired:Ir.flipNotRequired,zn)return zn}Bt(yt.first);for(let Xt=Ve+1;Xt<Ve+et-1;Xt++){const gt=Ys(Ee*z.getoffsetX(Xt),Te,Ue,u,Q,he,$e,Ge,ut,V,M,me,_e,!1,!1,be,ie,pe);if(!gt)return X.length-=4*(Xt-Ve),{notEnoughRoom:!0};Bt(gt)}Bt(yt.last)}else{if(y&&!u){const Xt=nr(he.x,he.y,0,b),gt=Ge+$e+1,Ot=new i.Point(V.getx(gt),V.gety(gt)),Qt=nr(Ot.x,Ot.y,0,b),Lt=Qt[3]>0?Qt:Mi(he,Ot,Xt,1,b,void 0,be,ie.canonical),Ct=Uo(ht,Jt,(Lt[0]-Xt[0])*ge,Lt[1]-Xt[1]);if(p.flipState=Ct&&Ct.needsFlipping?Ir.flipRequired:Ir.flipNotRequired,Ct)return Ct}const yt=Ys(Ee*z.getoffsetX(Ve),Te,Ue,u,Q,he,$e,Ge,ut,V,M,me,_e,!1,!1,be,ie,pe);if(!yt)return{notEnoughRoom:!0};Bt(yt)}return{}}function Oi(p,o,u,y,b){const{x:M,y:R,z}=y.projectTilePoint(p.x,p.y,o);if(!b)return nr(M,R,z,u);const[V,X,q]=b(p);return nr(M+V,R+X,z+q,u)}function Mi(p,o,u,y,b,M,R,z){const V=Oi(p.sub(o)._unit()._add(p),z,b,R,M);return i.sub(V,u,V),i.normalize(V,V),i.scaleAndAdd(V,u,V,y)}function Ys(p,o,u,y,b,M,R,z,V,X,q,Q,he,me,ge,_e,be,ie){const pe=y?p-o:p+o;let Ee=pe>0?1:-1,Te=0;y&&(Ee*=-1,Te=Math.PI),Ee<0&&(Te+=Math.PI);let Ue=z+R+(Ee>0?0:1)|0,Ge=b,Ve=b,et=0,$e=0;const ht=Math.abs(pe),Jt=[],ut=[];let Bt=M,yt=Bt;const Xt=()=>Mi(yt,Bt,Ve,ht-et+1,q,he,_e,be.canonical);for(;et+$e<=ht;){if(Ue+=Ee,Ue<z||Ue>=V)return null;if(Ve=Ge,yt=Bt,Jt.push(Ve),me&&ut.push(yt),Bt=new i.Point(X.getx(Ue),X.gety(Ue)),Ge=Q[Ue],!Ge){const Vn=Oi(Bt,be.canonical,q,_e,he);Ge=Vn[3]>0?Q[Ue]=Vn:Xt()}et+=$e,$e=i.distance(Ve,Ge)}ge&&he&&(Q[Ue]&&(Ge=Xt(),$e=i.distance(Ve,Ge)),Q[Ue]=Ge);const gt=(ht-et)/$e,Ot=Bt.sub(yt)._mult(gt)._add(yt),Qt=i.sub([],Ge,Ve),Lt=i.scaleAndAdd([],Ve,Qt,gt);let Ct=[0,0,1],zn=Qt[0],qn=Qt[1];if(ie&&(Ct=_e.upVector(be.canonical,Ot.x,Ot.y),Ct[0]!==0||Ct[1]!==0||Ct[2]!==1)){const Vn=[Ct[2],0,-Ct[0]],Ai=i.cross([],Ct,Vn);i.normalize(Vn,Vn),i.normalize(Ai,Ai),zn=i.dot(Qt,Vn),qn=i.dot(Qt,Ai)}if(u){const Vn=i.cross([],Ct,Qt);i.normalize(Vn,Vn),i.scaleAndAdd(Lt,Lt,Vn,u*Ee)}const vn=Te+Math.atan2(qn,zn);return Jt.push(Lt),me&&ut.push(Ot),{point:Lt,angle:vn,path:Jt,tilePath:ut,up:Ct}}function Hr(p,o){const u=o.length,y=u+4*p;o.resize(y),o.float32.fill(-1/0,4*u,4*y)}function Ei(p,o,u){const y=o[0],b=o[1];return p[0]=u[0]*y+u[4]*b+u[12],p[1]=u[1]*y+u[5]*b+u[13],p[3]=u[3]*y+u[7]*b+u[15],p}const D=100;class W{constructor(o,u,y=new Es(o.width+200,o.height+200,25),b=new Es(o.width+200,o.height+200,25)){this.transform=o,this.grid=y,this.ignoredGrid=b,this.pitchfactor=Math.cos(o._pitch)*o.cameraToCenterDistance,this.screenRightBoundary=o.width+D,this.screenBottomBoundary=o.height+D,this.gridRightBoundary=o.width+200,this.gridBottomBoundary=o.height+200,this.fogState=u}placeCollisionBox(o,u,y,b,M,R,z,V){let X=y.projectedAnchorX,q=y.projectedAnchorY,Q=y.projectedAnchorZ;const he=y.elevation,me=y.tileID,ge=o.getProjection();if(he&&me){const[Ge,Ve,et]=ge.upVector(me.canonical,y.tileAnchorX,y.tileAnchorY),$e=ge.upVectorScale(me.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;X+=Ge*he*$e,q+=Ve*he*$e,Q+=et*he*$e}const _e=this.projectAndGetPerspectiveRatio(z,X,q,Q,y.tileID,ge.name==="globe"||!!he||this.transform.pitch>0,ge),be=R*_e.perspectiveRatio,ie=(y.x1*u+b.x-y.padding)*be+_e.point.x,pe=(y.y1*u+b.y-y.padding)*be+_e.point.y,Ee=(y.x2*u+b.x+y.padding)*be+_e.point.x,Te=(y.y2*u+b.y+y.padding)*be+_e.point.y,Ue=_e.perspectiveRatio<=.55||_e.occluded;return!this.isInsideGrid(ie,pe,Ee,Te)||!M&&this.grid.hitTest(ie,pe,Ee,Te,V)||Ue?{box:[],offscreen:!1,occluded:_e.occluded}:{box:[ie,pe,Ee,Te],offscreen:this.isOffscreen(ie,pe,Ee,Te),occluded:!1}}placeCollisionCircles(o,u,y,b,M,R,z,V,X,q,Q,he,me,ge,_e){const be=[],ie=this.transform.elevation,pe=o.getProjection(),Ee=ie?ie.getAtTileOffsetFunc(_e,this.transform.center.lat,this.transform.worldSize,pe):null,Te=new i.Point(y.tileAnchorX,y.tileAnchorY);let{x:Ue,y:Ge,z:Ve}=pe.projectTilePoint(Te.x,Te.y,_e.canonical);if(Ee){const[Ot,Qt,Lt]=Ee(Te);Ue+=Ot,Ge+=Qt,Ve+=Lt}const et=pe.name==="globe",$e=this.projectAndGetPerspectiveRatio(z,Ue,Ge,Ve,_e,et||!!ie||this.transform.pitch>0,pe),{perspectiveRatio:ht}=$e,Jt=(Q?R/ht:R*ht)/i.ONE_EM,ut=nr(Ue,Ge,Ve,V),Bt=$e.signedDistanceFromCamera>0?As(Jt,M,y.lineOffsetX*Jt,y.lineOffsetY*Jt,!1,ut,Te,y,b,V,{},ie&&!Q?Ee:null,Q&&!!ie,pe,_e,Q):null;let yt=!1,Xt=!1,gt=!0;if(Bt&&!$e.occluded){const Ot=.5*me*ht+ge,Qt=new i.Point(-100,-100),Lt=new i.Point(this.screenRightBoundary,this.screenBottomBoundary),Ct=new po,{first:zn,last:qn}=Bt,vn=zn.path.length;let Vn=[];for(let Gn=vn-1;Gn>=1;Gn--)Vn.push(zn.path[Gn]);for(let Gn=1;Gn<qn.path.length;Gn++)Vn.push(qn.path[Gn]);const Ai=2.5*Ot;X&&(Vn=Vn.map(([Gn,$i,hr],mr)=>(Ee&&!et&&(hr=Ee(mr<vn-1?zn.tilePath[vn-1-mr]:qn.tilePath[mr-vn+2])[2]),nr(Gn,$i,hr,X))),Vn.some(Gn=>Gn[3]<=0)&&(Vn=[]));let si=[];if(Vn.length>0){let Gn=1/0,$i=-1/0,hr=1/0,mr=-1/0;for(const ar of Vn)Gn=Math.min(Gn,ar[0]),hr=Math.min(hr,ar[1]),$i=Math.max($i,ar[0]),mr=Math.max(mr,ar[1]);$i>=Qt.x&&Gn<=Lt.x&&mr>=Qt.y&&hr<=Lt.y&&(si=[Vn.map(ar=>new i.Point(ar[0],ar[1]))],(Gn<Qt.x||$i>Lt.x||hr<Qt.y||mr>Lt.y)&&(si=i.clipLine(si,Qt.x,Qt.y,Lt.x,Lt.y)))}for(const Gn of si){Ct.reset(Gn,.25*Ot);let $i=0;$i=Ct.length<=.5*Ot?1:Math.ceil(Ct.paddedLength/Ai)+1;for(let hr=0;hr<$i;hr++){const mr=hr/Math.max($i-1,1),ar=Ct.lerp(mr),xr=ar.x+D,us=ar.y+D;be.push(xr,us,Ot,0);const ko=xr-Ot,bo=us-Ot,vr=xr+Ot,gr=us+Ot;if(gt=gt&&this.isOffscreen(ko,bo,vr,gr),Xt=Xt||this.isInsideGrid(ko,bo,vr,gr),!u&&this.grid.hitTestCircle(xr,us,Ot,he)&&(yt=!0,!q))return{circles:[],offscreen:!1,collisionDetected:yt,occluded:!1}}}}return{circles:!q&&yt||!Xt?[]:be,offscreen:gt,collisionDetected:yt,occluded:$e.occluded}}queryRenderedSymbols(o){if(o.length===0||this.grid.keysLength()===0&&this.ignoredGrid.keysLength()===0)return{};const u=[];let y=1/0,b=1/0,M=-1/0,R=-1/0;for(const q of o){const Q=new i.Point(q.x+D,q.y+D);y=Math.min(y,Q.x),b=Math.min(b,Q.y),M=Math.max(M,Q.x),R=Math.max(R,Q.y),u.push(Q)}const z=this.grid.query(y,b,M,R).concat(this.ignoredGrid.query(y,b,M,R)),V={},X={};for(const q of z){const Q=q.key;if(V[Q.bucketInstanceId]===void 0&&(V[Q.bucketInstanceId]={}),V[Q.bucketInstanceId][Q.featureIndex])continue;const he=[new i.Point(q.x1,q.y1),new i.Point(q.x2,q.y1),new i.Point(q.x2,q.y2),new i.Point(q.x1,q.y2)];i.polygonIntersectsPolygon(u,he)&&(V[Q.bucketInstanceId][Q.featureIndex]=!0,X[Q.bucketInstanceId]===void 0&&(X[Q.bucketInstanceId]=[]),X[Q.bucketInstanceId].push(Q.featureIndex))}return X}insertCollisionBox(o,u,y,b,M){(u?this.ignoredGrid:this.grid).insert({bucketInstanceId:y,featureIndex:b,collisionGroupID:M},o[0],o[1],o[2],o[3])}insertCollisionCircles(o,u,y,b,M){const R=u?this.ignoredGrid:this.grid,z={bucketInstanceId:y,featureIndex:b,collisionGroupID:M};for(let V=0;V<o.length;V+=4)R.insertCircle(z,o[V],o[V+1],o[V+2])}projectAndGetPerspectiveRatio(o,u,y,b,M,R,z){const V=[u,y,b,1];let X=!1;b||this.transform.pitch>0?(i.transformMat4$1(V,V,o),this.fogState&&M&&z.name!=="globe"&&(X=function(he,me,ge,_e,be,ie){const pe=ie.calculateFogTileMatrix(be),Ee=[me,ge,_e];return i.transformMat4(Ee,Ee,pe),ft(he,Ee,ie.pitch,ie._fov)}(this.fogState,u,y,b,M.toUnwrapped(),this.transform)>.9)):Ei(V,V,o);const q=V[3];return{point:new i.Point((V[0]/q+1)/2*this.transform.width+D,(-V[1]/q+1)/2*this.transform.height+D),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(z)/q*.5,1.5),signedDistanceFromCamera:q,occluded:R&&V[2]>q||X}}isOffscreen(o,u,y,b){return y<D||o>=this.screenRightBoundary||b<D||u>this.screenBottomBoundary}isInsideGrid(o,u,y,b){return y>=0&&o<this.gridRightBoundary&&b>=0&&u<this.gridBottomBoundary}getViewportMatrix(){const o=i.identity([]);return i.translate(o,o,[-100,-100,0]),o}}function ae(p,o,u){const y=o.createTileMatrix(p,p.worldSize,u.toUnwrapped());return i.multiply(new Float32Array(16),p.projMatrix,y)}function Ce(p,o,u){if(o.projection.name===u.projection.name)return p.projMatrix;const y=u.clone();return y.setProjection(o.projection),ae(y,o.getProjection(),p)}function Oe(p,o,u){return o.name===u.projection.name?p.projMatrix:ae(u,o,p)}class qe{constructor(o,u,y,b){this.opacity=o?Math.max(0,Math.min(1,o.opacity+(o.placed?u:-u))):b&&y?1:0,this.placed=y}isHidden(){return this.opacity===0&&!this.placed}}class nt{constructor(o,u,y,b,M,R=!1){this.text=new qe(o?o.text:null,u,y,M),this.icon=new qe(o?o.icon:null,u,b,M),this.clipped=R}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class en{constructor(o,u,y,b=!1){this.text=o,this.icon=u,this.skipFade=y,this.clipped=b}}class cn{constructor(){this.invProjMatrix=i.create(),this.viewportMatrix=i.create(),this.circles=[]}}class Ln{constructor(o,u,y,b,M){this.bucketInstanceId=o,this.featureIndex=u,this.sourceLayerIndex=y,this.bucketIndex=b,this.tileID=M}}class Pn{constructor(o){this.crossSourceCollisions=o,this.maxGroupID=0,this.collisionGroups={}}get(o){if(this.crossSourceCollisions)return{ID:0,predicate:null};if(!this.collisionGroups[o]){const u=++this.maxGroupID;this.collisionGroups[o]={ID:u,predicate:y=>y.collisionGroupID===u}}return this.collisionGroups[o]}}function xn(p,o,u,y,b){const{horizontalAlign:M,verticalAlign:R}=i.getAnchorAlignment(p),z=-(M-.5)*o,V=-(R-.5)*u,X=i.evaluateVariableOffset(p,y);return new i.Point(z+X[0]*b,V+X[1]*b)}function mi(p,o,u,y,b){const M=new i.Point(p,o);return u&&M._rotate(y?b:-b),M}class di{constructor(o,u,y,b,M){this.transform=o.clone(),this.projection=o.projection.name,this.collisionIndex=new W(this.transform,M),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=u,this.retainedQueryData={},this.collisionGroups=new Pn(y),this.collisionCircleArrays={},this.prevPlacement=b,b&&(b.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(o,u,y,b){const M=y.getBucket(u),R=y.latestFeatureIndex;if(!M||!R||u.id!==M.layerIds[0])return;const z=M.layers[0].layout,V=y.collisionBoxArray,X=Math.pow(2,this.transform.zoom-y.tileID.overscaledZ),q=y.tileSize/i.EXTENT,Q=y.tileID.toUnwrapped();this.transform.setProjection(M.projection);const he=(me=y.tileID,ge=M.getProjection(),_e=this.transform,ge.name===this.projection?_e.calculateProjMatrix(me.toUnwrapped()):ae(_e,ge,me));var me,ge,_e;const be=z.get("text-pitch-alignment")==="map",ie=z.get("text-rotation-alignment")==="map";u.compileFilter();const pe=u.dynamicFilter(),Ee=u.dynamicFilterNeedsFeature(),Te=this.transform.calculatePixelsToTileUnitsMatrix(y),Ue=Ri(he,y.tileID.canonical,be,ie,this.transform,M.getProjection(),Te);let Ge=null;if(be){const $e=Ci(he,y.tileID.canonical,be,ie,this.transform,M.getProjection(),Te);Ge=i.multiply([],this.transform.labelPlaneMatrix,$e)}let Ve=null;pe&&y.latestFeatureIndex&&(Ve={unwrappedTileID:Q,dynamicFilter:pe,dynamicFilterNeedsFeature:Ee,featureIndex:y.latestFeatureIndex}),this.retainedQueryData[M.bucketInstanceId]=new Ln(M.bucketInstanceId,R,M.sourceLayerIndex,M.index,y.tileID);const et={bucket:M,layout:z,posMatrix:he,textLabelPlaneMatrix:Ue,labelToScreenMatrix:Ge,clippingData:Ve,scale:X,textPixelRatio:q,holdingForFade:y.holdingForFade(),collisionBoxArray:V,partiallyEvaluatedTextSize:i.evaluateSizeForZoom(M.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:i.evaluateSizeForZoom(M.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(M.sourceID)};if(b)for(const $e of M.sortKeyRanges){const{sortKey:ht,symbolInstanceStart:Jt,symbolInstanceEnd:ut}=$e;o.push({sortKey:ht,symbolInstanceStart:Jt,symbolInstanceEnd:ut,parameters:et})}else o.push({symbolInstanceStart:0,symbolInstanceEnd:M.symbolInstances.length,parameters:et})}attemptAnchorPlacement(o,u,y,b,M,R,z,V,X,q,Q,he,me,ge,_e,be,ie,pe){const{textOffset0:Ee,textOffset1:Te,crossTileID:Ue}=he,Ge=[Ee,Te],Ve=xn(o,y,b,Ge,M),et=this.collisionIndex.placeCollisionBox(ge,M,u,mi(Ve.x,Ve.y,R,z,this.transform.angle),Q,V,X,q.predicate);if(be){const $e=ge.getSymbolInstanceIconSize(pe,this.transform.zoom,he.placedIconSymbolIndex);if(this.collisionIndex.placeCollisionBox(ge,$e,be,mi(Ve.x,Ve.y,R,z,this.transform.angle),Q,V,X,q.predicate).box.length===0)return}if(et.box.length>0){let $e;return this.prevPlacement&&this.prevPlacement.variableOffsets[Ue]&&this.prevPlacement.placements[Ue]&&this.prevPlacement.placements[Ue].text&&($e=this.prevPlacement.variableOffsets[Ue].anchor),this.variableOffsets[Ue]={textOffset:Ge,width:y,height:b,anchor:o,textScale:M,prevAnchor:$e},this.markUsedJustification(ge,o,he,_e),ge.allowVerticalPlacement&&(this.markUsedOrientation(ge,_e,he),this.placedOrientations[Ue]=_e),{shift:Ve,placedGlyphBoxes:et}}}placeLayerBucketPart(o,u,y,b){const{bucket:M,layout:R,posMatrix:z,textLabelPlaneMatrix:V,labelToScreenMatrix:X,clippingData:q,textPixelRatio:Q,holdingForFade:he,collisionBoxArray:me,partiallyEvaluatedTextSize:ge,partiallyEvaluatedIconSize:_e,collisionGroup:be}=o.parameters,ie=R.get("text-optional"),pe=R.get("icon-optional"),Ee=R.get("text-allow-overlap"),Te=R.get("icon-allow-overlap"),Ue=R.get("text-rotation-alignment")==="map",Ge=R.get("text-pitch-alignment")==="map",Ve=R.get("icon-text-fit")!=="none",et=R.get("symbol-z-order")==="viewport-y";this.transform.setProjection(M.projection);let $e=Ee&&(Te||!M.hasIconData()||pe),ht=Te&&(Ee||!M.hasTextData()||ie);!M.collisionArrays&&me&&M.deserializeCollisionBoxes(me),y&&b&&M.updateCollisionDebugBuffers(this.transform.zoom,me);const Jt=(ut,Bt,yt)=>{const{crossTileID:Xt,numVerticalGlyphVertices:gt}=ut;if(q){const vr={zoom:this.transform.zoom,pitch:this.transform.pitch};let gr=null;if(q.dynamicFilterNeedsFeature){const ji=this.retainedQueryData[M.bucketInstanceId];gr=q.featureIndex.loadFeature({featureIndex:ut.featureIndex,bucketIndex:ji.bucketIndex,sourceLayerIndex:ji.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,q.dynamicFilter)(vr,gr,this.retainedQueryData[M.bucketInstanceId].tileID.canonical,new i.Point(ut.tileAnchorX,ut.tileAnchorY),this.transform.calculateDistanceTileData(q.unwrappedTileID)))return this.placements[Xt]=new en(!1,!1,!1,!0),void u.add(Xt)}if(u.has(Xt))return;if(he)return void(this.placements[Xt]=new en(!1,!1,!1));let Ot=!1,Qt=!1,Lt=!0,Ct=!1,zn=!1,qn=null,vn={box:null,offscreen:null,occluded:null},Vn={box:null,offscreen:null,occluded:null},Ai=null,si=null,Gn=null,$i=0,hr=0,mr=0;yt.textFeatureIndex?$i=yt.textFeatureIndex:ut.useRuntimeCollisionCircles&&($i=ut.featureIndex),yt.verticalTextFeatureIndex&&(hr=yt.verticalTextFeatureIndex);const ar=vr=>{vr.tileID=this.retainedQueryData[M.bucketInstanceId].tileID;const gr=this.transform.elevation;(gr||vr.elevation)&&(vr.elevation=gr?gr.getAtTileOffset(vr.tileID,vr.tileAnchorX,vr.tileAnchorY):0)},xr=yt.textBox;if(xr){ar(xr);const vr=ji=>{let Gr=i.WritingMode.horizontal;if(M.allowVerticalPlacement&&!ji&&this.prevPlacement){const es=this.prevPlacement.placedOrientations[Xt];es&&(this.placedOrientations[Xt]=es,Gr=es,this.markUsedOrientation(M,Gr,ut))}return Gr},gr=(ji,Gr)=>{if(M.allowVerticalPlacement&&gt>0&&yt.verticalTextBox){for(const es of M.writingModes)if(es===i.WritingMode.vertical?(vn=Gr(),Vn=vn):vn=ji(),vn&&vn.box&&vn.box.length)break}else vn=ji()};if(R.get("text-variable-anchor")){let ji=R.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[Xt]){const yr=this.prevPlacement.variableOffsets[Xt];ji.indexOf(yr.anchor)>0&&(ji=ji.filter(Ps=>Ps!==yr.anchor),ji.unshift(yr.anchor))}const Gr=(yr,Ps,Ec)=>{const Za=M.getSymbolInstanceTextSize(ge,ut,this.transform.zoom,Bt),El=(yr.x2-yr.x1)*Za+2*yr.padding,Xr=(yr.y2-yr.y1)*Za+2*yr.padding,wo=Ve&&!Te?Ps:null;wo&&ar(wo);let Ls={box:[],offscreen:!1,occluded:!1};const ql=Ee?2*ji.length:ji.length;for(let Rs=0;Rs<ql;++Rs){const ku=this.attemptAnchorPlacement(ji[Rs%ji.length],yr,El,Xr,Za,Ue,Ge,Q,z,be,Rs>=ji.length,ut,Bt,M,Ec,wo,ge,_e);if(ku&&(Ls=ku.placedGlyphBoxes,Ls&&Ls.box&&Ls.box.length)){Ot=!0,qn=ku.shift;break}}return Ls};gr(()=>Gr(xr,yt.iconBox,i.WritingMode.horizontal),()=>{const yr=yt.verticalTextBox;return yr&&ar(yr),M.allowVerticalPlacement&&!(vn&&vn.box&&vn.box.length)&&gt>0&&yr?Gr(yr,yt.verticalIconBox,i.WritingMode.vertical):{box:null,offscreen:null,occluded:null}}),vn&&(Ot=vn.box,Lt=vn.offscreen,Ct=vn.occluded);const es=vr(!(!vn||!vn.box));if(!Ot&&this.prevPlacement){const yr=this.prevPlacement.variableOffsets[Xt];yr&&(this.variableOffsets[Xt]=yr,this.markUsedJustification(M,yr.anchor,ut,es))}}else{const ji=(Gr,es)=>{const yr=M.getSymbolInstanceTextSize(ge,ut,this.transform.zoom,Bt),Ps=this.collisionIndex.placeCollisionBox(M,yr,Gr,new i.Point(0,0),Ee,Q,z,be.predicate);return Ps&&Ps.box&&Ps.box.length&&(this.markUsedOrientation(M,es,ut),this.placedOrientations[Xt]=es),Ps};gr(()=>ji(xr,i.WritingMode.horizontal),()=>{const Gr=yt.verticalTextBox;return M.allowVerticalPlacement&&gt>0&&Gr?(ar(Gr),ji(Gr,i.WritingMode.vertical)):{box:null,offscreen:null,occluded:null}}),vr(!!(vn&&vn.box&&vn.box.length))}}if(Ai=vn,Ot=Ai&&Ai.box&&Ai.box.length>0,Lt=Ai&&Ai.offscreen,Ct=Ai&&Ai.occluded,ut.useRuntimeCollisionCircles){const vr=M.text.placedSymbolArray.get(ut.centerJustifiedTextSymbolIndex>=0?ut.centerJustifiedTextSymbolIndex:ut.verticalPlacedTextSymbolIndex),gr=i.evaluateSizeForFeature(M.textSizeData,ge,vr),ji=R.get("text-padding");si=this.collisionIndex.placeCollisionCircles(M,Ee,vr,M.lineVertexArray,M.glyphOffsetArray,gr,z,V,X,y,Ge,be.predicate,ut.collisionCircleDiameter*gr/i.ONE_EM,ji,this.retainedQueryData[M.bucketInstanceId].tileID),Ot=Ee||si.circles.length>0&&!si.collisionDetected,Lt=Lt&&si.offscreen,Ct=si.occluded}if(yt.iconFeatureIndex&&(mr=yt.iconFeatureIndex),yt.iconBox){const vr=gr=>{ar(gr);const ji=Ve&&qn?mi(qn.x,qn.y,Ue,Ge,this.transform.angle):new i.Point(0,0),Gr=M.getSymbolInstanceIconSize(_e,this.transform.zoom,ut.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(M,Gr,gr,ji,Te,Q,z,be.predicate)};Vn&&Vn.box&&Vn.box.length&&yt.verticalIconBox?(Gn=vr(yt.verticalIconBox),Qt=Gn.box.length>0):(Gn=vr(yt.iconBox),Qt=Gn.box.length>0),Lt=Lt&&Gn.offscreen,zn=Gn.occluded}const us=ie||ut.numHorizontalGlyphVertices===0&&gt===0,ko=pe||ut.numIconVertices===0;if(us||ko?ko?us||(Qt=Qt&&Ot):Ot=Qt&&Ot:Qt=Ot=Qt&&Ot,Ot&&Ai&&Ai.box&&this.collisionIndex.insertCollisionBox(Ai.box,R.get("text-ignore-placement"),M.bucketInstanceId,Vn&&Vn.box&&hr?hr:$i,be.ID),Qt&&Gn&&this.collisionIndex.insertCollisionBox(Gn.box,R.get("icon-ignore-placement"),M.bucketInstanceId,mr,be.ID),si&&(Ot&&this.collisionIndex.insertCollisionCircles(si.circles,R.get("text-ignore-placement"),M.bucketInstanceId,$i,be.ID),y)){const vr=M.bucketInstanceId;let gr=this.collisionCircleArrays[vr];gr===void 0&&(gr=this.collisionCircleArrays[vr]=new cn);for(let ji=0;ji<si.circles.length;ji+=4)gr.circles.push(si.circles[ji+0]),gr.circles.push(si.circles[ji+1]),gr.circles.push(si.circles[ji+2]),gr.circles.push(si.collisionDetected?1:0)}const bo=M.projection.name!=="globe";$e=$e&&(bo||!Ct),ht=ht&&(bo||!zn),this.placements[Xt]=new en(Ot||$e,Qt||ht,Lt||M.justReloaded),u.add(Xt)};if(et){const ut=M.getSortedSymbolIndexes(this.transform.angle);for(let Bt=ut.length-1;Bt>=0;--Bt){const yt=ut[Bt];Jt(M.symbolInstances.get(yt),yt,M.collisionArrays[yt])}}else for(let ut=o.symbolInstanceStart;ut<o.symbolInstanceEnd;ut++)Jt(M.symbolInstances.get(ut),ut,M.collisionArrays[ut]);if(y&&M.bucketInstanceId in this.collisionCircleArrays){const ut=this.collisionCircleArrays[M.bucketInstanceId];i.invert(ut.invProjMatrix,z),ut.viewportMatrix=this.collisionIndex.getViewportMatrix()}M.justReloaded=!1}markUsedJustification(o,u,y,b){const{leftJustifiedTextSymbolIndex:M,centerJustifiedTextSymbolIndex:R,rightJustifiedTextSymbolIndex:z,verticalPlacedTextSymbolIndex:V,crossTileID:X}=y,q=i.getAnchorJustification(u),Q=b===i.WritingMode.vertical?V:q==="left"?M:q==="center"?R:q==="right"?z:-1;M>=0&&(o.text.placedSymbolArray.get(M).crossTileID=Q>=0&&M!==Q?0:X),R>=0&&(o.text.placedSymbolArray.get(R).crossTileID=Q>=0&&R!==Q?0:X),z>=0&&(o.text.placedSymbolArray.get(z).crossTileID=Q>=0&&z!==Q?0:X),V>=0&&(o.text.placedSymbolArray.get(V).crossTileID=Q>=0&&V!==Q?0:X)}markUsedOrientation(o,u,y){const b=u===i.WritingMode.horizontal||u===i.WritingMode.horizontalOnly?u:0,M=u===i.WritingMode.vertical?u:0,{leftJustifiedTextSymbolIndex:R,centerJustifiedTextSymbolIndex:z,rightJustifiedTextSymbolIndex:V,verticalPlacedTextSymbolIndex:X}=y,q=o.text.placedSymbolArray;R>=0&&(q.get(R).placedOrientation=b),z>=0&&(q.get(z).placedOrientation=b),V>=0&&(q.get(V).placedOrientation=b),X>=0&&(q.get(X).placedOrientation=M)}commit(o){this.commitTime=o,this.zoomAtLastRecencyCheck=this.transform.zoom;const u=this.prevPlacement;let y=!1;this.prevZoomAdjustment=u?u.zoomAdjustment(this.transform.zoom):0;const b=u?u.symbolFadeChange(o):1,M=u?u.opacities:{},R=u?u.variableOffsets:{},z=u?u.placedOrientations:{};for(const V in this.placements){const X=this.placements[V],q=M[V];q?(this.opacities[V]=new nt(q,b,X.text,X.icon,null,X.clipped),y=y||X.text!==q.text.placed||X.icon!==q.icon.placed):(this.opacities[V]=new nt(null,b,X.text,X.icon,X.skipFade,X.clipped),y=y||X.text||X.icon)}for(const V in M){const X=M[V];if(!this.opacities[V]){const q=new nt(X,b,!1,!1);q.isHidden()||(this.opacities[V]=q,y=y||X.text.placed||X.icon.placed)}}for(const V in R)this.variableOffsets[V]||!this.opacities[V]||this.opacities[V].isHidden()||(this.variableOffsets[V]=R[V]);for(const V in z)this.placedOrientations[V]||!this.opacities[V]||this.opacities[V].isHidden()||(this.placedOrientations[V]=z[V]);y?this.lastPlacementChangeTime=o:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=u?u.lastPlacementChangeTime:o)}updateLayerOpacities(o,u){const y=new Set;for(const b of u){const M=b.getBucket(o);M&&b.latestFeatureIndex&&o.id===M.layerIds[0]&&this.updateBucketOpacities(M,y,b.collisionBoxArray)}}updateBucketOpacities(o,u,y){o.hasTextData()&&o.text.opacityVertexArray.clear(),o.hasIconData()&&o.icon.opacityVertexArray.clear(),o.hasIconCollisionBoxData()&&o.iconCollisionBox.collisionVertexArray.clear(),o.hasTextCollisionBoxData()&&o.textCollisionBox.collisionVertexArray.clear();const b=o.layers[0].layout,M=!!o.layers[0].dynamicFilter(),R=new nt(null,0,!1,!1,!0),z=b.get("text-allow-overlap"),V=b.get("icon-allow-overlap"),X=b.get("text-variable-anchor"),q=b.get("text-rotation-alignment")==="map",Q=b.get("text-pitch-alignment")==="map",he=b.get("icon-text-fit")!=="none",me=new nt(null,0,z&&(V||!o.hasIconData()||b.get("icon-optional")),V&&(z||!o.hasTextData()||b.get("text-optional")),!0);!o.collisionArrays&&y&&(o.hasIconCollisionBoxData()||o.hasTextCollisionBoxData())&&o.deserializeCollisionBoxes(y);const ge=(be,ie,pe)=>{for(let Ee=0;Ee<ie/4;Ee++)be.opacityVertexArray.emplaceBack(pe)};let _e=0;for(let be=0;be<o.symbolInstances.length;be++){const ie=o.symbolInstances.get(be),{numHorizontalGlyphVertices:pe,numVerticalGlyphVertices:Ee,crossTileID:Te,numIconVertices:Ue}=ie,Ge=u.has(Te);let Ve=this.opacities[Te];Ge?Ve=R:Ve||(Ve=me,this.opacities[Te]=Ve),u.add(Te);const et=pe>0||Ee>0,$e=Ue>0,ht=this.placedOrientations[Te],Jt=ht===i.WritingMode.vertical,ut=ht===i.WritingMode.horizontal||ht===i.WritingMode.horizontalOnly;if(!et&&!$e||Ve.isHidden()||_e++,et){const Bt=tl(Ve.text);ge(o.text,pe,Jt?Si:Bt),ge(o.text,Ee,ut?Si:Bt);const yt=Ve.text.isHidden(),{leftJustifiedTextSymbolIndex:Xt,centerJustifiedTextSymbolIndex:gt,rightJustifiedTextSymbolIndex:Ot,verticalPlacedTextSymbolIndex:Qt}=ie,Lt=o.text.placedSymbolArray,Ct=yt||Jt?1:0;Xt>=0&&(Lt.get(Xt).hidden=Ct),gt>=0&&(Lt.get(gt).hidden=Ct),Ot>=0&&(Lt.get(Ot).hidden=Ct),Qt>=0&&(Lt.get(Qt).hidden=yt||ut?1:0);const zn=this.variableOffsets[Te];zn&&this.markUsedJustification(o,zn.anchor,ie,ht);const qn=this.placedOrientations[Te];qn&&(this.markUsedJustification(o,"left",ie,qn),this.markUsedOrientation(o,qn,ie))}if($e){const Bt=tl(Ve.icon),{placedIconSymbolIndex:yt,verticalPlacedIconSymbolIndex:Xt}=ie,gt=o.icon.placedSymbolArray,Ot=Ve.icon.isHidden()?1:0;yt>=0&&(ge(o.icon,Ue,Jt?Si:Bt),gt.get(yt).hidden=Ot),Xt>=0&&(ge(o.icon,ie.numVerticalIconVertices,ut?Si:Bt),gt.get(Xt).hidden=Ot)}if(o.hasIconCollisionBoxData()||o.hasTextCollisionBoxData()){const Bt=o.collisionArrays[be];if(Bt){let yt=new i.Point(0,0),Xt=!0;if(Bt.textBox||Bt.verticalTextBox){if(X){const Ot=this.variableOffsets[Te];Ot?(yt=xn(Ot.anchor,Ot.width,Ot.height,Ot.textOffset,Ot.textScale),q&&yt._rotate(Q?this.transform.angle:-this.transform.angle)):Xt=!1}M&&(Xt=!Ve.clipped),Bt.textBox&&vi(o.textCollisionBox.collisionVertexArray,Ve.text.placed,!Xt||Jt,yt.x,yt.y),Bt.verticalTextBox&&vi(o.textCollisionBox.collisionVertexArray,Ve.text.placed,!Xt||ut,yt.x,yt.y)}const gt=Xt&&Boolean(!ut&&Bt.verticalIconBox);Bt.iconBox&&vi(o.iconCollisionBox.collisionVertexArray,Ve.icon.placed,gt,he?yt.x:0,he?yt.y:0),Bt.verticalIconBox&&vi(o.iconCollisionBox.collisionVertexArray,Ve.icon.placed,!gt,he?yt.x:0,he?yt.y:0)}}}if(o.fullyClipped=_e===0,o.sortFeatures(this.transform.angle),this.retainedQueryData[o.bucketInstanceId]&&(this.retainedQueryData[o.bucketInstanceId].featureSortOrder=o.featureSortOrder),o.hasTextData()&&o.text.opacityVertexBuffer&&o.text.opacityVertexBuffer.updateData(o.text.opacityVertexArray),o.hasIconData()&&o.icon.opacityVertexBuffer&&o.icon.opacityVertexBuffer.updateData(o.icon.opacityVertexArray),o.hasIconCollisionBoxData()&&o.iconCollisionBox.collisionVertexBuffer&&o.iconCollisionBox.collisionVertexBuffer.updateData(o.iconCollisionBox.collisionVertexArray),o.hasTextCollisionBoxData()&&o.textCollisionBox.collisionVertexBuffer&&o.textCollisionBox.collisionVertexBuffer.updateData(o.textCollisionBox.collisionVertexArray),o.bucketInstanceId in this.collisionCircleArrays){const be=this.collisionCircleArrays[o.bucketInstanceId];o.placementInvProjMatrix=be.invProjMatrix,o.placementViewportMatrix=be.viewportMatrix,o.collisionCircleArray=be.circles,delete this.collisionCircleArrays[o.bucketInstanceId]}}symbolFadeChange(o){return this.fadeDuration===0?1:(o-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(o){return Math.max(0,(this.transform.zoom-o)/1.5)}hasTransitions(o){return this.stale||o-this.lastPlacementChangeTime<this.fadeDuration}stillRecent(o,u){const y=this.zoomAtLastRecencyCheck===u?1-this.zoomAdjustment(u):1;return this.zoomAtLastRecencyCheck=u,this.commitTime+this.fadeDuration*y>o}setStale(){this.stale=!0}}function vi(p,o,u,y,b){p.emplaceBack(o?1:0,u?1:0,y||0,b||0),p.emplaceBack(o?1:0,u?1:0,y||0,b||0),p.emplaceBack(o?1:0,u?1:0,y||0,b||0),p.emplaceBack(o?1:0,u?1:0,y||0,b||0)}const Ji=Math.pow(2,25),zt=Math.pow(2,24),Xn=Math.pow(2,17),ur=Math.pow(2,16),wi=Math.pow(2,9),or=Math.pow(2,8),lc=Math.pow(2,1);function tl(p){if(p.opacity===0&&!p.placed)return 0;if(p.opacity===1&&p.placed)return 4294967295;const o=p.placed?1:0,u=Math.floor(127*p.opacity);return u*Ji+o*zt+u*Xn+o*ur+u*wi+o*or+u*lc+o}const Si=0;class ha{constructor(o){this._sortAcrossTiles=o.layout.get("symbol-z-order")!=="viewport-y"&&o.layout.get("symbol-sort-key").constantOr(1)!==void 0,this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs=new Set,this._bucketParts=[]}continuePlacement(o,u,y,b,M){const R=this._bucketParts;for(;this._currentTileIndex<o.length;)if(u.getBucketParts(R,b,o[this._currentTileIndex],this._sortAcrossTiles),this._currentTileIndex++,M())return!0;for(this._sortAcrossTiles&&(this._sortAcrossTiles=!1,R.sort((z,V)=>z.sortKey-V.sortKey));this._currentPartIndex<R.length;){const z=R[this._currentPartIndex];if(u.placeLayerBucketPart(z,this._seenCrossTileIDs,y,z.symbolInstanceStart===0),this._currentPartIndex++,M())return!0}return!1}}class To{constructor(o,u,y,b,M,R,z,V){this.placement=new di(o,M,R,z,V),this._currentPlacementIndex=u.length-1,this._forceFullPlacement=y,this._showCollisionBoxes=b,this._done=!1}isDone(){return this._done}continuePlacement(o,u,y){const b=i.exported.now(),M=()=>{const R=i.exported.now()-b;return!this._forceFullPlacement&&R>2};for(;this._currentPlacementIndex>=0;){const R=u[o[this._currentPlacementIndex]],z=this.placement.collisionIndex.transform.zoom;if(R.type==="symbol"&&(!R.minzoom||R.minzoom<=z)&&(!R.maxzoom||R.maxzoom>z)){if(this._inProgressLayer||(this._inProgressLayer=new ha(R)),this._inProgressLayer.continuePlacement(y[R.source],this.placement,this._showCollisionBoxes,R,M))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(o){return this.placement.commit(o),this.placement}}const Fs=512/i.EXTENT/2;class os{constructor(o,u,y){this.tileID=o,this.bucketInstanceId=y,this.index=new i.KDBush(u.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const b=o.canonical.x*i.EXTENT,M=o.canonical.y*i.EXTENT;for(let R=0;R<u.length;R++){const{key:z,crossTileID:V,tileAnchorX:X,tileAnchorY:q}=u.get(R),Q=Math.floor((b+X)*Fs),he=Math.floor((M+q)*Fs);this.index.add(Q,he),this.keys.push(z),this.crossTileIDs.push(V)}this.index.finish()}findMatches(o,u,y){const b=this.tileID.canonical.z<u.canonical.z?1:Math.pow(2,this.tileID.canonical.z-u.canonical.z),M=Fs/Math.pow(2,u.canonical.z-this.tileID.canonical.z),R=u.canonical.x*i.EXTENT,z=u.canonical.y*i.EXTENT;for(let V=0;V<o.length;V++){const X=o.get(V);if(X.crossTileID)continue;const{key:q,tileAnchorX:Q,tileAnchorY:he}=X,me=Math.floor((R+Q)*M),ge=Math.floor((z+he)*M),_e=this.index.range(me-b,ge-b,me+b,ge+b);for(const be of _e){const ie=this.crossTileIDs[be];if(this.keys[be]===q&&!y.has(ie)){y.add(ie),X.crossTileID=ie;break}}}}}class mo{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class Ao{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(o){const u=Math.round((o-this.lng)/360);if(u!==0)for(const y in this.indexes){const b=this.indexes[y],M={};for(const R in b){const z=b[R];z.tileID=z.tileID.unwrapTo(z.tileID.wrap+u),M[z.tileID.key]=z}this.indexes[y]=M}this.lng=o}addBucket(o,u,y){if(this.indexes[o.overscaledZ]&&this.indexes[o.overscaledZ][o.key]){if(this.indexes[o.overscaledZ][o.key].bucketInstanceId===u.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(o.overscaledZ,this.indexes[o.overscaledZ][o.key])}for(let M=0;M<u.symbolInstances.length;M++)u.symbolInstances.get(M).crossTileID=0;this.usedCrossTileIDs[o.overscaledZ]||(this.usedCrossTileIDs[o.overscaledZ]=new Set);const b=this.usedCrossTileIDs[o.overscaledZ];for(const M in this.indexes){const R=this.indexes[M];if(Number(M)>o.overscaledZ)for(const z in R){const V=R[z];V.tileID.isChildOf(o)&&V.findMatches(u.symbolInstances,o,b)}else{const z=R[o.scaledTo(Number(M)).key];z&&z.findMatches(u.symbolInstances,o,b)}}for(let M=0;M<u.symbolInstances.length;M++){const R=u.symbolInstances.get(M);R.crossTileID||(R.crossTileID=y.generate(),b.add(R.crossTileID))}return this.indexes[o.overscaledZ]===void 0&&(this.indexes[o.overscaledZ]={}),this.indexes[o.overscaledZ][o.key]=new os(o,u.symbolInstances,u.bucketInstanceId),!0}removeBucketCrossTileIDs(o,u){for(const y of u.crossTileIDs)this.usedCrossTileIDs[o].delete(y)}removeStaleBuckets(o){let u=!1;for(const y in this.indexes){const b=this.indexes[y];for(const M in b)o[b[M].bucketInstanceId]||(this.removeBucketCrossTileIDs(y,b[M]),delete b[M],u=!0)}return u}}class Js{constructor(){this.layerIndexes={},this.crossTileIDs=new mo,this.maxBucketInstanceId=0,this.bucketsInCurrentPlacement={}}addLayer(o,u,y,b){let M=this.layerIndexes[o.id];M===void 0&&(M=this.layerIndexes[o.id]=new Ao);let R=!1;const z={};b.name!=="globe"&&M.handleWrapJump(y);for(const V of u){const X=V.getBucket(o);X&&o.id===X.layerIds[0]&&(X.bucketInstanceId||(X.bucketInstanceId=++this.maxBucketInstanceId),M.addBucket(V.tileID,X,this.crossTileIDs)&&(R=!0),z[X.bucketInstanceId]=!0)}return M.removeStaleBuckets(z)&&(R=!0),R}pruneUnusedLayers(o){const u={};o.forEach(y=>{u[y]=!0});for(const y in this.layerIndexes)u[y]||delete this.layerIndexes[y]}}const Vo=(p,o)=>i.emitValidationErrors(p,o&&o.filter(u=>u.identifier!=="source.canvas")),gl=i.pick(ki,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),dh=i.pick(ki,["setCenter","setZoom","setBearing","setPitch"]),Co={version:8,layers:[],sources:{}},_l={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class Ks extends i.Evented{constructor(o,u={}){super(),this.map=o,this.dispatcher=new tt(Ni(),this),this.imageManager=new ke,this.imageManager.setEventedParent(this),this.glyphManager=new i.GlyphManager(o._requestManager,u.localFontFamily?i.LocalGlyphMode.all:u.localIdeographFontFamily?i.LocalGlyphMode.ideographs:i.LocalGlyphMode.none,u.localFontFamily||u.localIdeographFontFamily),this.crossTileSymbolIndex=new Js,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",i.getReferrer());const y=this;this._rtlTextPluginCallback=Ks.registerForPluginStateChange(b=>{y.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:b.pluginStatus,pluginURL:b.pluginURL},(M,R)=>{if(i.triggerPluginCompletionEvent(M),R&&R.every(z=>z))for(const z in y._sourceCaches){const V=y._sourceCaches[z],X=V.getSource().type;X!=="vector"&&X!=="geojson"||V.reload()}})}),this.on("data",b=>{if(b.dataType!=="source"||b.sourceDataType!=="metadata")return;const M=this.getSource(b.sourceId);if(M&&M.vectorLayerIds)for(const R in this._layers){const z=this._layers[R];z.source===M.id&&this._validateLayer(z)}})}loadURL(o,u={}){this.fire(new i.Event("dataloading",{dataType:"style"}));const y=typeof u.validate=="boolean"?u.validate:!i.isMapboxURL(o);o=this.map._requestManager.normalizeStyleURL(o,u.accessToken);const b=this.map._requestManager.transformRequest(o,i.ResourceType.Style);this._request=i.getJSON(b,(M,R)=>{this._request=null,M?this.fire(new i.ErrorEvent(M)):R&&this._load(R,y)})}loadJSON(o,u={}){this.fire(new i.Event("dataloading",{dataType:"style"})),this._request=i.exported.frame(()=>{this._request=null,this._load(o,u.validate!==!1)})}loadEmpty(){this.fire(new i.Event("dataloading",{dataType:"style"})),this._load(Co,!1)}_updateLayerCount(o,u){const y=u?1:-1;o.is3D()&&(this._num3DLayers+=y),o.type==="circle"&&(this._numCircleLayers+=y),o.type==="symbol"&&(this._numSymbolLayers+=y)}_load(o,u){if(u&&Vo(this,i.validateStyle(o)))return;this._loaded=!0,this.stylesheet=i.clone$1(o),this._updateMapProjection();for(const b in o.sources)this.addSource(b,o.sources[b],{validate:!1});this._changed=!1,o.sprite?this._loadSprite(o.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(o.glyphs);const y=Cr(this.stylesheet.layers);this._order=y.map(b=>b.id),this._layers={},this._serializedLayers={};for(const b of y){const M=i.createStyleLayer(b);M.setEventedParent(this,{layer:{id:M.id}}),this._layers[M.id]=M,this._serializedLayers[M.id]=M.serialize(),this._updateLayerCount(M,!0)}this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new St(this.stylesheet.light),this.stylesheet.terrain&&!this.terrainSetForDrapingOnly()&&this._createTerrain(this.stylesheet.terrain,1),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this._updateDrapeFirstLayers(),this.fire(new i.Event("data",{dataType:"style"})),this.fire(new i.Event("style.load"))}terrainSetForDrapingOnly(){return!!this.terrain&&this.terrain.drapeRenderMode===0}setProjection(o){o?this.stylesheet.projection=o:delete this.stylesheet.projection,this._updateMapProjection()}applyProjectionUpdate(){this._loaded&&(this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),this.map.transform.projection.requiresDraping?this.getTerrain()||this.stylesheet.terrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null))}_updateMapProjection(){this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.stylesheet.projection)}_loadSprite(o){this._spriteRequest=function(u,y,b){let M,R,z;const V=i.exported.devicePixelRatio>1?"@2x":"";let X=i.getJSON(y.transformRequest(y.normalizeSpriteURL(u,V,".json"),i.ResourceType.SpriteJSON),(he,me)=>{X=null,z||(z=he,M=me,Q())}),q=i.getImage(y.transformRequest(y.normalizeSpriteURL(u,V,".png"),i.ResourceType.SpriteImage),(he,me)=>{q=null,z||(z=he,R=me,Q())});function Q(){if(z)b(z);else if(M&&R){const he=i.exported.getImageData(R),me={};for(const ge in M){const{width:_e,height:be,x:ie,y:pe,sdf:Ee,pixelRatio:Te,stretchX:Ue,stretchY:Ge,content:Ve}=M[ge],et=new i.RGBAImage({width:_e,height:be});i.RGBAImage.copy(he,et,{x:ie,y:pe},{x:0,y:0},{width:_e,height:be}),me[ge]={data:et,pixelRatio:Te,sdf:Ee,stretchX:Ue,stretchY:Ge,content:Ve}}b(null,me)}}return{cancel(){X&&(X.cancel(),X=null),q&&(q.cancel(),q=null)}}}(o,this.map._requestManager,(u,y)=>{if(this._spriteRequest=null,u)this.fire(new i.ErrorEvent(u));else if(y)for(const b in y)this.imageManager.addImage(b,y[b]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new i.Event("data",{dataType:"style"}))})}_validateLayer(o){const u=this.getSource(o.source);if(!u)return;const y=o.sourceLayer;y&&(u.type==="geojson"||u.vectorLayerIds&&u.vectorLayerIds.indexOf(y)===-1)&&this.fire(new i.ErrorEvent(new Error(`Source layer "${y}" does not exist on source "${u.id}" as specified by style layer "${o.id}"`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const o in this._sourceCaches)if(!this._sourceCaches[o].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(o){const u=[];for(const y of o){const b=this._layers[y];b.type!=="custom"&&u.push(b.serialize())}return u}hasTransitions(){if(this.light&&this.light.hasTransition()||this.fog&&this.fog.hasTransition())return!0;for(const o in this._sourceCaches)if(this._sourceCaches[o].hasTransition())return!0;for(const o in this._layers)if(this._layers[o].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(o){return!!this.terrain&&(typeof o.isLayerDraped=="function"?o.isLayerDraped():_l[o.type])}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}update(o){if(!this._loaded)return;const u=this._changed;if(this._changed){const b=Object.keys(this._updatedLayers),M=Object.keys(this._removedLayers);(b.length||M.length)&&this._updateWorkerLayers(b,M);for(const R in this._updatedSources){const z=this._updatedSources[R];z==="reload"?this._reloadSource(R):z==="clear"&&this._clearSource(R)}this._updateTilesForChangedImages();for(const R in this._updatedPaintProps)this._layers[R].updateTransitions(o);this.light.updateTransitions(o),this.fog&&this.fog.updateTransitions(o),this._resetUpdates()}const y={};for(const b in this._sourceCaches){const M=this._sourceCaches[b];y[b]=M.used,M.used=!1}for(const b of this._order){const M=this._layers[b];if(M.recalculate(o,this._availableImages),!M.isHidden(o.zoom)){const z=this._getLayerSourceCache(M);z&&(z.used=!0)}const R=this.map.painter;if(R){const z=M.getProgramIds();if(!z)continue;const V=M.getProgramConfiguration(o.zoom);for(const X of z)R.useProgram(X,V)}}for(const b in y){const M=this._sourceCaches[b];y[b]!==M.used&&M.getSource().fire(new i.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:M.getSource().id}))}this.light.recalculate(o),this.terrain&&this.terrain.recalculate(o),this.fog&&this.fog.recalculate(o),this.z=o.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),u&&this.fire(new i.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const o=Object.keys(this._changedImages);if(o.length){for(const u in this._sourceCaches)this._sourceCaches[u].reloadTilesForDependencies(["icons","patterns"],o);this._changedImages={}}}_updateWorkerLayers(o,u){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(o),removedIds:u})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(o){if(this._checkLoaded(),Vo(this,i.validateStyle(o)))return!1;(o=i.clone$1(o)).layers=Cr(o.layers);const u=function(b,M){if(!b)return[{command:ki.setStyle,args:[M]}];let R=[];try{if(!w(b.version,M.version))return[{command:ki.setStyle,args:[M]}];w(b.center,M.center)||R.push({command:ki.setCenter,args:[M.center]}),w(b.zoom,M.zoom)||R.push({command:ki.setZoom,args:[M.zoom]}),w(b.bearing,M.bearing)||R.push({command:ki.setBearing,args:[M.bearing]}),w(b.pitch,M.pitch)||R.push({command:ki.setPitch,args:[M.pitch]}),w(b.sprite,M.sprite)||R.push({command:ki.setSprite,args:[M.sprite]}),w(b.glyphs,M.glyphs)||R.push({command:ki.setGlyphs,args:[M.glyphs]}),w(b.transition,M.transition)||R.push({command:ki.setTransition,args:[M.transition]}),w(b.light,M.light)||R.push({command:ki.setLight,args:[M.light]}),w(b.fog,M.fog)||R.push({command:ki.setFog,args:[M.fog]}),w(b.projection,M.projection)||R.push({command:ki.setProjection,args:[M.projection]});const z={},V=[];(function(Q,he,me,ge){let _e;for(_e in he=he||{},Q=Q||{})Q.hasOwnProperty(_e)&&(he.hasOwnProperty(_e)||Xs(_e,me,ge));for(_e in he){if(!he.hasOwnProperty(_e))continue;const be=he[_e];Q.hasOwnProperty(_e)?w(Q[_e],be)||(Q[_e].type==="geojson"&&be.type==="geojson"&&Vi(Q,he,_e)?me.push({command:ki.setGeoJSONSourceData,args:[_e,be.data]}):$s(_e,he,me,ge)):ea(_e,he,me)}})(b.sources,M.sources,V,z);const X=[];b.layers&&b.layers.forEach(Q=>{Q.source&&z[Q.source]?R.push({command:ki.removeLayer,args:[Q.id]}):X.push(Q)});let q=b.terrain;q&&z[q.source]&&(R.push({command:ki.setTerrain,args:[void 0]}),q=void 0),R=R.concat(V),w(q,M.terrain)||R.push({command:ki.setTerrain,args:[M.terrain]}),function(Q,he,me){he=he||[];const ge=(Q=Q||[]).map(er),_e=he.map(er),be=Q.reduce(tr,{}),ie=he.reduce(tr,{}),pe=ge.slice(),Ee=Object.create(null);let Te,Ue,Ge,Ve,et,$e,ht;for(Te=0,Ue=0;Te<ge.length;Te++)Ge=ge[Te],ie.hasOwnProperty(Ge)?Ue++:(me.push({command:ki.removeLayer,args:[Ge]}),pe.splice(pe.indexOf(Ge,Ue),1));for(Te=0,Ue=0;Te<_e.length;Te++)Ge=_e[_e.length-1-Te],pe[pe.length-1-Te]!==Ge&&(be.hasOwnProperty(Ge)?(me.push({command:ki.removeLayer,args:[Ge]}),pe.splice(pe.lastIndexOf(Ge,pe.length-Ue),1)):Ue++,$e=pe[pe.length-Te],me.push({command:ki.addLayer,args:[ie[Ge],$e]}),pe.splice(pe.length-Te,0,Ge),Ee[Ge]=!0);for(Te=0;Te<_e.length;Te++)if(Ge=_e[Te],Ve=be[Ge],et=ie[Ge],!Ee[Ge]&&!w(Ve,et))if(w(Ve.source,et.source)&&w(Ve["source-layer"],et["source-layer"])&&w(Ve.type,et.type)){for(ht in Ur(Ve.layout,et.layout,me,Ge,null,ki.setLayoutProperty),Ur(Ve.paint,et.paint,me,Ge,null,ki.setPaintProperty),w(Ve.filter,et.filter)||me.push({command:ki.setFilter,args:[Ge,et.filter]}),w(Ve.minzoom,et.minzoom)&&w(Ve.maxzoom,et.maxzoom)||me.push({command:ki.setLayerZoomRange,args:[Ge,et.minzoom,et.maxzoom]}),Ve)Ve.hasOwnProperty(ht)&&ht!=="layout"&&ht!=="paint"&&ht!=="filter"&&ht!=="metadata"&&ht!=="minzoom"&&ht!=="maxzoom"&&(ht.indexOf("paint.")===0?Ur(Ve[ht],et[ht],me,Ge,ht.slice(6),ki.setPaintProperty):w(Ve[ht],et[ht])||me.push({command:ki.setLayerProperty,args:[Ge,ht,et[ht]]}));for(ht in et)et.hasOwnProperty(ht)&&!Ve.hasOwnProperty(ht)&&ht!=="layout"&&ht!=="paint"&&ht!=="filter"&&ht!=="metadata"&&ht!=="minzoom"&&ht!=="maxzoom"&&(ht.indexOf("paint.")===0?Ur(Ve[ht],et[ht],me,Ge,ht.slice(6),ki.setPaintProperty):w(Ve[ht],et[ht])||me.push({command:ki.setLayerProperty,args:[Ge,ht,et[ht]]}))}else me.push({command:ki.removeLayer,args:[Ge]}),$e=pe[pe.lastIndexOf(Ge)+1],me.push({command:ki.addLayer,args:[et,$e]})}(X,M.layers,R)}catch(z){console.warn("Unable to compute style diff:",z),R=[{command:ki.setStyle,args:[M]}]}return R}(this.serialize(),o).filter(b=>!(b.command in dh));if(u.length===0)return!1;const y=u.filter(b=>!(b.command in gl));if(y.length>0)throw new Error(`Unimplemented: ${y.map(b=>b.command).join(", ")}.`);return u.forEach(b=>{b.command!=="setTransition"&&b.command!=="setProjection"&&this[b.command].apply(this,b.args)}),this.stylesheet=o,this._updateMapProjection(),!0}addImage(o,u){return this.getImage(o)?this.fire(new i.ErrorEvent(new Error("An image with this name already exists."))):(this.imageManager.addImage(o,u),this._afterImageUpdated(o),this)}updateImage(o,u){this.imageManager.updateImage(o,u)}getImage(o){return this.imageManager.getImage(o)}removeImage(o){return this.getImage(o)?(this.imageManager.removeImage(o),this._afterImageUpdated(o),this):this.fire(new i.ErrorEvent(new Error("No image with this name exists.")))}_afterImageUpdated(o){this._availableImages=this.imageManager.listImages(),this._changedImages[o]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new i.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(o,u,y={}){if(this._checkLoaded(),this.getSource(o)!==void 0)throw new Error("There is already a source with this ID");if(!u.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(u).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(u.type)>=0&&this._validate(i.validateSource,`sources.${o}`,u,null,y))return;this.map&&this.map._collectResourceTiming&&(u.collectResourceTiming=!0);const b=Qe(o,u,this.dispatcher,this);b.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(o),source:b.serialize(),sourceId:o}));const M=R=>{const z=(R?"symbol:":"other:")+o,V=this._sourceCaches[z]=new i.SourceCache(z,b,R);(R?this._symbolSourceCaches:this._otherSourceCaches)[o]=V,V.style=this,V.onAdd(this.map)};M(!1),u.type!=="vector"&&u.type!=="geojson"||M(!0),b.onAdd&&b.onAdd(this.map),this._changed=!0}removeSource(o){this._checkLoaded();const u=this.getSource(o);if(!u)throw new Error("There is no source with this ID");for(const b in this._layers)if(this._layers[b].source===o)return this.fire(new i.ErrorEvent(new Error(`Source "${o}" cannot be removed while layer "${b}" is using it.`)));if(this.terrain&&this.terrain.get().source===o)return this.fire(new i.ErrorEvent(new Error(`Source "${o}" cannot be removed while terrain is using it.`)));const y=this._getSourceCaches(o);for(const b of y)delete this._sourceCaches[b.id],delete this._updatedSources[b.id],b.fire(new i.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:b.getSource().id})),b.setEventedParent(null),b.clearTiles();return delete this._otherSourceCaches[o],delete this._symbolSourceCaches[o],u.setEventedParent(null),u.onRemove&&u.onRemove(this.map),this._changed=!0,this}setGeoJSONSourceData(o,u){this._checkLoaded(),this.getSource(o).setData(u),this._changed=!0}getSource(o){const u=this._getSourceCache(o);return u&&u.getSource()}_getSources(){const o=[];for(const u in this._otherSourceCaches){const y=this._getSourceCache(u);y&&o.push(y.getSource())}return o}addLayer(o,u,y={}){this._checkLoaded();const b=o.id;if(this.getLayer(b))return void this.fire(new i.ErrorEvent(new Error(`Layer with id "${b}" already exists on this map`)));let M;if(o.type==="custom"){if(Vo(this,i.validateCustomStyleLayer(o)))return;M=i.createStyleLayer(o)}else{if(typeof o.source=="object"&&(this.addSource(b,o.source),o=i.clone$1(o),o=i.extend(o,{source:b})),this._validate(i.validateLayer,`layers.${b}`,o,{arrayIndex:-1},y))return;M=i.createStyleLayer(o),this._validateLayer(M),M.setEventedParent(this,{layer:{id:b}}),this._serializedLayers[M.id]=M.serialize(),this._updateLayerCount(M,!0)}const R=u?this._order.indexOf(u):this._order.length;if(u&&R===-1)return void this.fire(new i.ErrorEvent(new Error(`Layer with id "${u}" does not exist on this map.`)));this._order.splice(R,0,b),this._layerOrderChanged=!0,this._layers[b]=M;const z=this._getLayerSourceCache(M);if(this._removedLayers[b]&&M.source&&z&&M.type!=="custom"){const V=this._removedLayers[b];delete this._removedLayers[b],V.type!==M.type?this._updatedSources[M.source]="clear":(this._updatedSources[M.source]="reload",z.pause())}this._updateLayer(M),M.onAdd&&M.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(o,u){if(this._checkLoaded(),this._changed=!0,!this._layers[o])return void this.fire(new i.ErrorEvent(new Error(`The layer '${o}' does not exist in the map's style and cannot be moved.`)));if(o===u)return;const y=this._order.indexOf(o);this._order.splice(y,1);const b=u?this._order.indexOf(u):this._order.length;u&&b===-1?this.fire(new i.ErrorEvent(new Error(`Layer with id "${u}" does not exist on this map.`))):(this._order.splice(b,0,o),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(o){this._checkLoaded();const u=this._layers[o];if(!u)return void this.fire(new i.ErrorEvent(new Error(`The layer '${o}' does not exist in the map's style and cannot be removed.`)));u.setEventedParent(null),this._updateLayerCount(u,!1);const y=this._order.indexOf(o);this._order.splice(y,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[o]=u,delete this._layers[o],delete this._serializedLayers[o],delete this._updatedLayers[o],delete this._updatedPaintProps[o],u.onRemove&&u.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(o){return this._layers[o]}hasLayer(o){return o in this._layers}hasLayerType(o){for(const u in this._layers)if(this._layers[u].type===o)return!0;return!1}setLayerZoomRange(o,u,y){this._checkLoaded();const b=this.getLayer(o);b?b.minzoom===u&&b.maxzoom===y||(u!=null&&(b.minzoom=u),y!=null&&(b.maxzoom=y),this._updateLayer(b)):this.fire(new i.ErrorEvent(new Error(`The layer '${o}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(o,u,y={}){this._checkLoaded();const b=this.getLayer(o);if(b){if(!w(b.filter,u))return u==null?(b.filter=void 0,void this._updateLayer(b)):void(this._validate(i.validateFilter,`layers.${b.id}.filter`,u,{layerType:b.type},y)||(b.filter=i.clone$1(u),this._updateLayer(b)))}else this.fire(new i.ErrorEvent(new Error(`The layer '${o}' does not exist in the map's style and cannot be filtered.`)))}getFilter(o){const u=this.getLayer(o);return u&&i.clone$1(u.filter)}setLayoutProperty(o,u,y,b={}){this._checkLoaded();const M=this.getLayer(o);M?w(M.getLayoutProperty(u),y)||(M.setLayoutProperty(u,y,b),this._updateLayer(M)):this.fire(new i.ErrorEvent(new Error(`The layer '${o}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(o,u){const y=this.getLayer(o);if(y)return y.getLayoutProperty(u);this.fire(new i.ErrorEvent(new Error(`The layer '${o}' does not exist in the map's style.`)))}setPaintProperty(o,u,y,b={}){this._checkLoaded();const M=this.getLayer(o);M?w(M.getPaintProperty(u),y)||(M.setPaintProperty(u,y,b)&&this._updateLayer(M),this._changed=!0,this._updatedPaintProps[o]=!0):this.fire(new i.ErrorEvent(new Error(`The layer '${o}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(o,u){const y=this.getLayer(o);return y&&y.getPaintProperty(u)}setFeatureState(o,u){this._checkLoaded();const y=o.source,b=o.sourceLayer,M=this.getSource(y);if(!M)return void this.fire(new i.ErrorEvent(new Error(`The source '${y}' does not exist in the map's style.`)));const R=M.type;if(R==="geojson"&&b)return void this.fire(new i.ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if(R==="vector"&&!b)return void this.fire(new i.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));o.id===void 0&&this.fire(new i.ErrorEvent(new Error("The feature id parameter must be provided.")));const z=this._getSourceCaches(y);for(const V of z)V.setFeatureState(b,o.id,u)}removeFeatureState(o,u){this._checkLoaded();const y=o.source,b=this.getSource(y);if(!b)return void this.fire(new i.ErrorEvent(new Error(`The source '${y}' does not exist in the map's style.`)));const M=b.type,R=M==="vector"?o.sourceLayer:void 0;if(M==="vector"&&!R)return void this.fire(new i.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));if(u&&typeof o.id!="string"&&typeof o.id!="number")return void this.fire(new i.ErrorEvent(new Error("A feature id is required to remove its specific state property.")));const z=this._getSourceCaches(y);for(const V of z)V.removeFeatureState(R,o.id,u)}getFeatureState(o){this._checkLoaded();const u=o.source,y=o.sourceLayer,b=this.getSource(u);if(b){if(b.type!=="vector"||y)return o.id===void 0&&this.fire(new i.ErrorEvent(new Error("The feature id parameter must be provided."))),this._getSourceCaches(u)[0].getFeatureState(y,o.id);this.fire(new i.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new i.ErrorEvent(new Error(`The source '${u}' does not exist in the map's style.`)))}getTransition(){return i.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const o={};for(const u in this._sourceCaches){const y=this._sourceCaches[u].getSource();o[y.id]||(o[y.id]=y.serialize())}return i.filterObject({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,terrain:this.getTerrain()||void 0,fog:this.stylesheet.fog,center:this.stylesheet.center,zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,projection:this.stylesheet.projection,sources:o,layers:this._serializeLayers(this._order)},u=>u!==void 0)}_updateLayer(o){this._updatedLayers[o.id]=!0;const u=this._getLayerSourceCache(o);o.source&&!this._updatedSources[o.source]&&u&&u.getSource().type!=="raster"&&(this._updatedSources[o.source]="reload",u.pause()),this._changed=!0,o.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(o){const u=R=>this._layers[R].type==="fill-extrusion",y={},b=[];for(let R=this._order.length-1;R>=0;R--){const z=this._order[R];if(u(z)){y[z]=R;for(const V of o){const X=V[z];if(X)for(const q of X)b.push(q)}}}b.sort((R,z)=>z.intersectionZ-R.intersectionZ);const M=[];for(let R=this._order.length-1;R>=0;R--){const z=this._order[R];if(u(z))for(let V=b.length-1;V>=0;V--){const X=b[V].feature;if(y[X.layer.id]<R)break;M.push(X),b.pop()}else for(const V of o){const X=V[z];if(X)for(const q of X)M.push(q.feature)}}return M}queryRenderedFeatures(o,u,y){u&&u.filter&&this._validate(i.validateFilter,"queryRenderedFeatures.filter",u.filter,null,u);const b={};if(u&&u.layers){if(!Array.isArray(u.layers))return this.fire(new i.ErrorEvent(new Error("parameters.layers must be an Array."))),[];for(const V of u.layers){const X=this._layers[V];if(!X)return this.fire(new i.ErrorEvent(new Error(`The layer '${V}' does not exist in the map's style and cannot be queried for features.`))),[];b[X.source]=!0}}const M=[];u.availableImages=this._availableImages;const R=u&&u.layers?u.layers.some(V=>{const X=this.getLayer(V);return X&&X.is3D()}):this.has3DLayers(),z=xt.createFromScreenPoints(o,y);for(const V in this._sourceCaches){const X=this._sourceCaches[V].getSource().id;u.layers&&!b[X]||M.push(mt(this._sourceCaches[V],this._layers,this._serializedLayers,z,u,y,R,!!this.map._showQueryGeometry))}return this.placement&&M.push(function(V,X,q,Q,he,me,ge){const _e={},be=me.queryRenderedSymbols(Q),ie=[];for(const pe of Object.keys(be).map(Number))ie.push(ge[pe]);ie.sort($n);for(const pe of ie){const Ee=pe.featureIndex.lookupSymbolFeatures(be[pe.bucketInstanceId],X,pe.bucketIndex,pe.sourceLayerIndex,he.filter,he.layers,he.availableImages,V);for(const Te in Ee){const Ue=_e[Te]=_e[Te]||[],Ge=Ee[Te];Ge.sort((Ve,et)=>{const $e=pe.featureSortOrder;if($e){const ht=$e.indexOf(Ve.featureIndex);return $e.indexOf(et.featureIndex)-ht}return et.featureIndex-Ve.featureIndex});for(const Ve of Ge)Ue.push(Ve)}}for(const pe in _e)_e[pe].forEach(Ee=>{const Te=Ee.feature,Ue=q(V[pe]);if(!Ue)return;const Ge=Ue.getFeatureState(Te.layer["source-layer"],Te.id);Te.source=Te.layer.source,Te.layer["source-layer"]&&(Te.sourceLayer=Te.layer["source-layer"]),Te.state=Ge});return _e}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),z.screenGeometry,u,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(M)}querySourceFeatures(o,u){u&&u.filter&&this._validate(i.validateFilter,"querySourceFeatures.filter",u.filter,null,u);const y=this._getSourceCaches(o);let b=[];for(const M of y)b=b.concat(Gt(M,u));return b}addSourceType(o,u,y){return Ks.getSourceType(o)?y(new Error(`A source type called "${o}" already exists.`)):(Ks.setSourceType(o,u),u.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:o,url:u.workerSourceURL},y):y(null,null))}getLight(){return this.light.getLight()}setLight(o,u={}){this._checkLoaded();const y=this.light.getLight();let b=!1;for(const R in o)if(!w(o[R],y[R])){b=!0;break}if(!b)return;const M=this._setTransitionParameters({duration:300,delay:0});this.light.setLight(o,u),this.light.updateTransitions(M)}getTerrain(){return this.terrain&&this.terrain.drapeRenderMode===1?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}setTerrain(o,u=1){if(this._checkLoaded(),!o)return delete this.terrain,delete this.stylesheet.terrain,this.dispatcher.broadcast("enableTerrain",!1),this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);let y=o;if(u===1){if(typeof y.source=="object"){const b="terrain-dem-src";this.addSource(b,y.source),y=i.clone$1(y),y=i.extend(y,{source:b})}if(this._validate(i.validateTerrain,"terrain",y))return}if(!this.terrain||this.terrain&&u!==this.terrain.drapeRenderMode){if(!y)return;this._createTerrain(y,u)}else{const b=this.terrain,M=b.get();for(const R of Object.keys(i.spec.terrain))!y.hasOwnProperty(R)&&i.spec.terrain[R].default&&(y[R]=i.spec.terrain[R].default);for(const R in y)if(!w(y[R],M[R])){b.set(y),this.stylesheet.terrain=y;const z=this._setTransitionParameters({duration:0});b.updateTransitions(z);break}}this._updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(o){const u=this.fog=new it(o,this.map.transform);this.stylesheet.fog=o;const y=this._setTransitionParameters({duration:0});u.updateTransitions(y)}_updateMarkersOpacity(){this.map._markers.length!==0&&this.map._requestDomTask(()=>{for(const o of this.map._markers)o._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(o){if(this._checkLoaded(),!o)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const u=this.fog,y=u.get();Object.keys(o).length===0&&u.set(o);for(const b in o)if(!w(o[b],y[b])){u.set(o),this.stylesheet.fog=o;const M=this._setTransitionParameters({duration:0});u.updateTransitions(M);break}}else this._createFog(o);this._markersNeedUpdate=!0}_setTransitionParameters(o){return{now:i.exported.now(),transition:i.extend(o,this.stylesheet.transition)}}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const o=this._order.filter(y=>this.isLayerDraped(this._layers[y])),u=this._order.filter(y=>!this.isLayerDraped(this._layers[y]));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...o),this._drapedFirstOrder.push(...u)}_createTerrain(o,u){const y=this.terrain=new It(o,u);this.stylesheet.terrain=o,this.dispatcher.broadcast("enableTerrain",!this.terrainSetForDrapingOnly()),this._force3DLayerUpdate();const b=this._setTransitionParameters({duration:0});y.updateTransitions(b)}_force3DLayerUpdate(){for(const o in this._layers){const u=this._layers[o];u.type==="fill-extrusion"&&this._updateLayer(u)}}_forceSymbolLayerUpdate(){for(const o in this._layers){const u=this._layers[o];u.type==="symbol"&&this._updateLayer(u)}}_validate(o,u,y,b,M={}){return(!M||M.validate!==!1)&&Vo(this,o.call(i.validateStyle,i.extend({key:u,style:this.serialize(),value:y,styleSpec:i.spec},b)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),i.evented.off("pluginStateChange",this._rtlTextPluginCallback);for(const o in this._layers)this._layers[o].setEventedParent(null);for(const o in this._sourceCaches)this._sourceCaches[o].clearTiles(),this._sourceCaches[o].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(o){const u=this._getSourceCaches(o);for(const y of u)y.clearTiles()}_reloadSource(o){const u=this._getSourceCaches(o);for(const y of u)y.resume(),y.reload()}_reloadSources(){for(const o of this._getSources())o.reload&&o.reload()}_updateSources(o){for(const u in this._sourceCaches)this._sourceCaches[u].update(o)}_generateCollisionBoxes(){for(const o in this._sourceCaches){const u=this._sourceCaches[o];u.resume(),u.reload()}}_updatePlacement(o,u,y,b,M=!1){let R=!1,z=!1;const V={};for(const X of this._order){const q=this._layers[X];if(q.type!=="symbol")continue;if(!V[q.source]){const he=this._getLayerSourceCache(q);if(!he)continue;V[q.source]=he.getRenderableIds(!0).map(me=>he.getTileByID(me)).sort((me,ge)=>ge.tileID.overscaledZ-me.tileID.overscaledZ||(me.tileID.isLessThan(ge.tileID)?-1:1))}const Q=this.crossTileSymbolIndex.addLayer(q,V[q.source],o.center.lng,o.projection);R=R||Q}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),M=M||this._layerOrderChanged||y===0,this._layerOrderChanged&&this.fire(new i.Event("neworder")),(M||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(i.exported.now(),o.zoom))&&(this.pauseablePlacement=new To(o,this._order,M,u,y,b,this.placement,this.fog&&o.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,V),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(i.exported.now()),z=!0),R&&this.pauseablePlacement.placement.setStale()),z||R)for(const X of this._order){const q=this._layers[X];q.type==="symbol"&&this.placement.updateLayerOpacities(q,V[q.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(i.exported.now())}_releaseSymbolFadeTiles(){for(const o in this._sourceCaches)this._sourceCaches[o].releaseSymbolFadeTiles()}getImages(o,u,y){this.imageManager.getImages(u.icons,y),this._updateTilesForChangedImages();const b=M=>{M&&M.setDependencies(u.tileID.key,u.type,u.icons)};b(this._otherSourceCaches[u.source]),b(this._symbolSourceCaches[u.source])}getGlyphs(o,u,y){this.glyphManager.getGlyphs(u.stacks,y)}getResource(o,u,y){return i.makeRequest(u,y)}_getSourceCache(o){return this._otherSourceCaches[o]}_getLayerSourceCache(o){return o.type==="symbol"?this._symbolSourceCaches[o.source]:this._otherSourceCaches[o.source]}_getSourceCaches(o){const u=[];return this._otherSourceCaches[o]&&u.push(this._otherSourceCaches[o]),this._symbolSourceCaches[o]&&u.push(this._symbolSourceCaches[o]),u}_isSourceCacheLoaded(o){const u=this._getSourceCaches(o);return u.length===0?(this.fire(new i.ErrorEvent(new Error(`There is no source with ID '${o}'`))),!1):u.every(y=>y.loaded())}has3DLayers(){return this._num3DLayers>0}hasSymbolLayers(){return this._numSymbolLayers>0}hasCircleLayers(){return this._numCircleLayers>0}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}destroy(){this._clearWorkerCaches(),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}Ks.getSourceType=function(p){return ve[p]},Ks.setSourceType=function(p,o){ve[p]=o},Ks.registerForPluginStateChange=i.registerForPluginStateChange;var cc=`
#define EPSILON 0.0000001
#define PI 3.141592653589793
#define EXTENT 8192.0
#define HALF_PI PI/2.0
#define QUARTER_PI PI/4.0
#define RAD_TO_DEG 180.0/PI
#define DEG_TO_RAD PI/180.0
#define GLOBE_RADIUS EXTENT/PI/2.0`,as="attribute highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;varying highp vec3 v_uv;void main() {const mat3 half_neg_pi_around_x=mat3(1.0,0.0, 0.0,0.0,0.0,-1.0,0.0,1.0, 0.0);v_uv=half_neg_pi_around_x*a_pos_3f;vec4 pos=u_matrix*vec4(a_pos_3f,1.0);gl_Position=pos.xyww;}",Io=`
#define ELEVATION_SCALE 7.0
#define ELEVATION_OFFSET 450.0
#ifdef PROJECTION_GLOBE_VIEW
uniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;vec3 elevationVector(vec2 pos) {vec2 uv=pos/EXTENT;vec3 up=normalize(mix(
mix(u_tile_tl_up,u_tile_tr_up,uv.xxx),mix(u_tile_bl_up,u_tile_br_up,uv.xxx),uv.yyy));return up*u_tile_up_scale;}
#else
vec3 elevationVector(vec2 pos) { return vec3(0,0,1); }
#endif
const float skirtOffset=24575.0;vec3 decomposeToPosAndSkirt(vec2 posWithComposedSkirt)
{float skirt=float(posWithComposedSkirt.x >=skirtOffset);vec2 pos=posWithComposedSkirt-vec2(skirt*skirtOffset,0.0);return vec3(pos,skirt);}
#ifdef TERRAIN
#ifdef TERRAIN_DEM_FLOAT_FORMAT
uniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;
#else
uniform sampler2D u_dem;uniform sampler2D u_dem_prev;
#endif
uniform vec4 u_dem_unpack;uniform vec2 u_dem_tl;uniform vec2 u_dem_tl_prev;uniform float u_dem_scale;uniform float u_dem_scale_prev;uniform float u_dem_size;uniform float u_dem_lerp;uniform float u_exaggeration;uniform float u_meter_to_dem;uniform mat4 u_label_plane_matrix_inv;uniform sampler2D u_depth;uniform vec2 u_depth_size_inv;vec4 tileUvToDemSample(vec2 uv,float dem_size,float dem_scale,vec2 dem_tl) {vec2 pos=dem_size*(uv*dem_scale+dem_tl)+1.0;vec2 f=fract(pos);return vec4((pos-f+0.5)/(dem_size+2.0),f);}float decodeElevation(vec4 v) {return dot(vec4(v.xyz*255.0,-1.0),u_dem_unpack);}float currentElevation(vec2 apos) {
#ifdef TERRAIN_DEM_FLOAT_FORMAT
vec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale+u_dem_tl)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem,pos).a;
#else
float dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale,u_dem_tl);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem,pos));
#ifdef TERRAIN_DEM_NEAREST_FILTER
return u_exaggeration*tl;
#endif
float tr=decodeElevation(texture2D(u_dem,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);
#endif
}float prevElevation(vec2 apos) {
#ifdef TERRAIN_DEM_FLOAT_FORMAT
vec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale_prev+u_dem_tl_prev)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem_prev,pos).a;
#else
float dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale_prev,u_dem_tl_prev);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem_prev,pos));float tr=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem_prev,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);
#endif
}
#ifdef TERRAIN_VERTEX_MORPHING
float elevation(vec2 apos) {
#ifdef ZERO_EXAGGERATION
return 0.0;
#endif
float nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}
#else
float elevation(vec2 apos) {
#ifdef ZERO_EXAGGERATION
return 0.0;
#endif
return currentElevation(apos);}
#endif
highp float unpack_depth(highp vec4 rgba_depth)
{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}bool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;float depth=unpack_depth(texture2D(u_depth,(coord.xy+1.0)*0.5));return coord.z > depth+0.0005;}float occlusionFade(vec4 frag) {vec3 coord=frag.xyz/frag.w;vec3 df=vec3(5.0*u_depth_size_inv,0.0);vec2 uv=0.5*coord.xy+0.5;vec4 depth=vec4(
unpack_depth(texture2D(u_depth,uv-df.xz)),unpack_depth(texture2D(u_depth,uv+df.xz)),unpack_depth(texture2D(u_depth,uv-df.zy)),unpack_depth(texture2D(u_depth,uv+df.zy))
);return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z-0.001)-depth),0.0,1.0));}vec4 fourSample(vec2 pos,vec2 off) {
#ifdef TERRAIN_DEM_FLOAT_FORMAT
float tl=texture2D(u_dem,pos).a;float tr=texture2D(u_dem,pos+vec2(off.x,0.0)).a;float bl=texture2D(u_dem,pos+vec2(0.0,off.y)).a;float br=texture2D(u_dem,pos+off).a;
#else
vec4 demtl=vec4(texture2D(u_dem,pos).xyz*255.0,-1.0);float tl=dot(demtl,u_dem_unpack);vec4 demtr=vec4(texture2D(u_dem,pos+vec2(off.x,0.0)).xyz*255.0,-1.0);float tr=dot(demtr,u_dem_unpack);vec4 dembl=vec4(texture2D(u_dem,pos+vec2(0.0,off.y)).xyz*255.0,-1.0);float bl=dot(dembl,u_dem_unpack);vec4 dembr=vec4(texture2D(u_dem,pos+off).xyz*255.0,-1.0);float br=dot(dembr,u_dem_unpack);
#endif
return vec4(tl,tr,bl,br);}float flatElevation(vec2 pack) {vec2 apos=floor(pack/8.0);vec2 span=10.0*(pack-apos*8.0);vec2 uvTex=(apos-vec2(1.0,1.0))/8190.0;float size=u_dem_size+2.0;float dd=1.0/size;vec2 pos=u_dem_size*(uvTex*u_dem_scale+u_dem_tl)+1.0;vec2 f=fract(pos);pos=(pos-f+0.5)*dd;vec4 h=fourSample(pos,vec2(dd));float z=mix(mix(h.x,h.y,f.x),mix(h.z,h.w,f.x),f.y);vec2 w=floor(0.5*(span*u_meter_to_dem-1.0));vec2 d=dd*w;h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);}
#else
float elevation(vec2 pos) { return 0.0; }bool isOccluded(vec4 frag) { return false; }float occlusionFade(vec4 frag) { return 1.0; }
#endif`,Da=`#ifdef FOG
uniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump mat4 u_fog_matrix;varying vec3 v_fog_pos;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}vec3 fog_position(vec3 pos) {return (u_fog_matrix*vec4(pos,1.0)).xyz;}vec3 fog_position(vec2 pos) {return fog_position(vec3(pos,0.0));}float fog(vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));return opacity*fog_horizon_blending(pos/depth);}
#endif`,ds=`#ifdef FOG
uniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump float u_fog_temporal_offset;varying vec3 v_fog_pos;uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform highp vec2 u_viewport;uniform float u_globe_transition;uniform int u_is_globe;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}float globe_glow_progress() {highp vec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix(
mix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float sdf=length(closest_point-u_globe_pos)/u_globe_radius;return sdf+PI*0.5;}float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos) {float depth=length(pos);float opacity;if (u_is_globe==1) {float glow_progress=globe_glow_progress();float t=mix(glow_progress,depth,u_globe_transition);opacity=fog_opacity(fog_range(t));} else {opacity=fog_opacity(fog_range(depth));opacity*=fog_horizon_blending(pos/depth);}return mix(color,u_fog_color.rgb,opacity);}vec4 fog_apply_from_vert(vec4 color,float fog_opac) {float alpha=EPSILON+color.a;color.rgb=mix(color.rgb/alpha,u_fog_color.rgb,fog_opac)*alpha;return color;}vec3 fog_apply_sky_gradient(vec3 camera_ray,vec3 sky_color) {float horizon_blend=fog_horizon_blending(normalize(camera_ray));return mix(sky_color,u_fog_color.rgb,horizon_blend);}vec4 fog_apply_premultiplied(vec4 color,vec3 pos) {float alpha=EPSILON+color.a;color.rgb=fog_apply(color.rgb/alpha,pos)*alpha;return color;}vec3 fog_dither(vec3 color) {vec2 dither_seed=gl_FragCoord.xy+u_fog_temporal_offset;return dither(color,dither_seed);}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}
#endif`;let za={},da={};const Bs=[];ls(cc,Bs),ls(Io,Bs),ls(Da,Bs),ls(ds,Bs),za=Bi("",Io),da=Bi(ds,Da);const Ol=Bi(`
#if __VERSION__ >=300
#define varying in
#define gl_FragColor glFragColor
#define texture2D texture
#define textureCube texture
out vec4 glFragColor;
#endif
highp vec3 hash(highp vec2 p) {highp vec3 p3=fract(p.xyx*vec3(443.8975,397.2973,491.1871));p3+=dot(p3,p3.yxz+19.19);return fract((p3.xxy+p3.yzz)*p3.zyx);}vec3 dither(vec3 color,highp vec2 seed) {vec3 rnd=hash(seed)+hash(seed+0.59374)-0.5;return color+rnd/255.0;}highp float unpack_depth(highp vec4 rgba_depth)
{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}highp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}`,`
#if __VERSION__ >=300
#define attribute in
#define varying out
#define texture2D texture
#endif
float wrap(float n,float min,float max) {float d=max-min;float w=mod(mod(n-min,d)+d,d)+min;return (w==min) ? max : w;}
#ifdef PROJECTION_GLOBE_VIEW
vec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) {
#ifndef PROJECTED_POS_ON_VIEWPORT
float tiles=tile_id.z;vec2 mercator=(tile_anchor/EXTENT+tile_id.xy)/tiles;mercator-=mercator_center;mercator.x=wrap(mercator.x,-0.5,0.5);vec4 mercator_tile=vec4(mercator.xy*EXTENT,EXTENT/(2.0*PI),1.0);mercator_tile=matrix*mercator_tile;return mercator_tile.xyz;
#else
return vec3(0.0);
#endif
}vec3 mix_globe_mercator(vec3 globe,vec3 mercator,float t) {return mix(globe,mercator,t);}mat3 globe_mercator_surface_vectors(vec3 pos_normal,vec3 up_dir,float zoom_transition) {vec3 normal=zoom_transition==0.0 ? pos_normal : normalize(mix(pos_normal,up_dir,zoom_transition));vec3 xAxis=normalize(vec3(normal.z,0.0,-normal.x));vec3 yAxis=normalize(cross(normal,xAxis));return mat3(xAxis,yAxis,normal);}
#endif
vec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(
unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0
);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}const vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);//Normalized device coordinate that is not rendered.`),nl=cc,ka=`
#ifdef GL_ES
precision mediump float;
#else

#if !defined(lowp)
#define lowp
#endif

#if !defined(mediump)
#define mediump
#endif

#if !defined(highp)
#define highp
#endif

#endif`;var Ns={background:Bi(`uniform vec4 u_color;uniform float u_opacity;
#ifdef LIGHTING_3D_MODE
varying vec4 v_color;
#endif
void main() {vec4 out_color;
#ifdef LIGHTING_3D_MODE
out_color=v_color;
#else
out_color=u_color;
#endif
#ifdef FOG
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
#endif
gl_FragColor=out_color*u_opacity;
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`attribute vec2 a_pos;uniform mat4 u_matrix;
#ifdef LIGHTING_3D_MODE
uniform vec4 u_color;varying vec4 v_color;
#endif
void main() {gl_Position=u_matrix*vec4(a_pos,0,1);
#ifdef LIGHTING_3D_MODE
v_color=apply_lighting(u_color);
#endif
#ifdef FOG
v_fog_pos=fog_position(a_pos);
#endif
}`),backgroundPattern:Bi(`uniform vec2 u_pattern_tl;uniform vec2 u_pattern_br;uniform vec2 u_texsize;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos;void main() {vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(u_pattern_tl/u_texsize,u_pattern_br/u_texsize,imagecoord);vec4 out_color=texture2D(u_image,pos);
#ifdef LIGHTING_3D_MODE
out_color=apply_lighting(out_color);
#endif
#ifdef FOG
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
#endif
gl_FragColor=out_color*u_opacity;
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`uniform mat4 u_matrix;uniform vec2 u_pattern_size;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_pattern_size,u_tile_units_to_pixels,a_pos);
#ifdef FOG
v_fog_pos=fog_position(a_pos);
#endif
}`),circle:Bi(`varying vec3 v_data;varying float v_visibility;
#pragma mapbox: define highp vec4 color
#pragma mapbox: define mediump float radius
#pragma mapbox: define lowp float blur
#pragma mapbox: define lowp float opacity
#pragma mapbox: define highp vec4 stroke_color
#pragma mapbox: define mediump float stroke_width
#pragma mapbox: define lowp float stroke_opacity
void main() {
#pragma mapbox: initialize highp vec4 color
#pragma mapbox: initialize mediump float radius
#pragma mapbox: initialize lowp float blur
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize highp vec4 stroke_color
#pragma mapbox: initialize mediump float stroke_width
#pragma mapbox: initialize lowp float stroke_opacity
vec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(
antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width)
);vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t);
#ifdef LIGHTING_3D_MODE
out_color=apply_lighting(out_color);
#endif
#ifdef FOG
out_color=fog_apply_premultiplied(out_color,v_fog_pos);
#endif
gl_FragColor=out_color*(v_visibility*opacity_t);
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`#define NUM_VISIBILITY_RINGS 2
#define INV_SQRT2 0.70710678
#define ELEVATION_BIAS 0.0001
#define NUM_SAMPLES_PER_RING 16
uniform mat4 u_matrix;uniform mat2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;
#ifdef PROJECTION_GLOBE_VIEW
attribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;
#endif
varying vec3 v_data;varying float v_visibility;
#pragma mapbox: define highp vec4 color
#pragma mapbox: define mediump float radius
#pragma mapbox: define lowp float blur
#pragma mapbox: define lowp float opacity
#pragma mapbox: define highp vec4 stroke_color
#pragma mapbox: define mediump float stroke_width
#pragma mapbox: define lowp float stroke_opacity
vec2 calc_offset(vec2 extrusion,float radius,float stroke_width, float view_scale) {return extrusion*(radius+stroke_width)*u_extrude_scale*view_scale;}float cantilevered_elevation(vec2 pos,float radius,float stroke_width,float view_scale) {vec2 c1=pos+calc_offset(vec2(-1,-1),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1,-1),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1,1),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1,1),radius,stroke_width,view_scale);float h1=elevation(c1)+ELEVATION_BIAS;float h2=elevation(c2)+ELEVATION_BIAS;float h3=elevation(c3)+ELEVATION_BIAS;float h4=elevation(c4)+ELEVATION_BIAS;return max(h4,max(h3,max(h1,h2)));}float circle_elevation(vec2 pos) {
#if defined(TERRAIN)
return elevation(pos)+ELEVATION_BIAS;
#else
return 0.0;
#endif
}vec4 project_vertex(vec2 extrusion,vec4 world_center,vec4 projected_center,float radius,float stroke_width, float view_scale,mat3 surface_vectors) {vec2 sample_offset=calc_offset(extrusion,radius,stroke_width,view_scale);
#ifdef PITCH_WITH_MAP
#ifdef PROJECTION_GLOBE_VIEW
return u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) );
#else
return u_matrix*( world_center+vec4(sample_offset,0,0) );
#endif
#else
return projected_center+vec4(sample_offset,0,0);
#endif
}float get_sample_step() {
#ifdef PITCH_WITH_MAP
return 2.0*PI/float(NUM_SAMPLES_PER_RING);
#else
return PI/float(NUM_SAMPLES_PER_RING);
#endif
}void main(void) {
#pragma mapbox: initialize highp vec4 color
#pragma mapbox: initialize mediump float radius
#pragma mapbox: initialize lowp float blur
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize highp vec4 stroke_color
#pragma mapbox: initialize mediump float stroke_width
#pragma mapbox: initialize lowp float stroke_opacity
vec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);vec4 world_center;mat3 surface_vectors;
#ifdef PROJECTION_GLOBE_VIEW
vec3 pos_normal_3=a_pos_normal_3/16384.0;surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(circle_center)*circle_elevation(circle_center);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*circle_elevation(circle_center);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,circle_center,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);world_center=vec4(pos,1);
#else 
surface_vectors=mat3(1.0);float height=circle_elevation(circle_center);world_center=vec4(circle_center,height,1);
#endif
vec4 projected_center=u_matrix*world_center;float view_scale=0.0;
#ifdef PITCH_WITH_MAP
#ifdef SCALE_WITH_MAP
view_scale=1.0;
#else
view_scale=projected_center.w/u_camera_to_center_distance;
#endif
#else
#ifdef SCALE_WITH_MAP
view_scale=u_camera_to_center_distance;
#else
view_scale=projected_center.w;
#endif
#endif
gl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0;
#ifdef TERRAIN
float step=get_sample_step();vec4 occlusion_world_center;vec4 occlusion_projected_center;
#ifdef PITCH_WITH_MAP
float cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);occlusion_world_center=vec4(circle_center,cantilevered_height,1);occlusion_projected_center=u_matrix*occlusion_world_center;
#else
occlusion_world_center=world_center;occlusion_projected_center=projected_center;
#endif
for(int ring=0; ring < NUM_VISIBILITY_RINGS; ring++) {float scale=(float(ring)+1.0)/float(NUM_VISIBILITY_RINGS);for(int i=0; i < NUM_SAMPLES_PER_RING; i++) {vec2 extrusion=vec2(cos(step*float(i)),-sin(step*float(i)))*scale;vec4 frag_pos=project_vertex(extrusion,occlusion_world_center,occlusion_projected_center,radius,stroke_width,view_scale,surface_vectors);visibility+=float(!isOccluded(frag_pos));}}visibility/=float(NUM_VISIBILITY_RINGS)*float(NUM_SAMPLES_PER_RING);
#else
visibility=1.0;
#endif
#ifdef PROJECTION_GLOBE_VIEW
visibility=1.0;
#endif
v_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);
#ifdef FOG
v_fog_pos=fog_position(world_center.xyz);
#endif
}`),clippingMask:Bi("void main() {gl_FragColor=vec4(1.0);}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:Bi(`uniform highp float u_intensity;varying vec2 v_extrude;
#pragma mapbox: define highp float weight
#define GAUSS_COEF 0.3989422804014327
void main() {
#pragma mapbox: initialize highp float weight
float d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);gl_FragColor=vec4(val,1.0,1.0,1.0);
#ifdef FOG
if (u_is_globe==0) {gl_FragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);}
#endif
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;
#ifdef PROJECTION_GLOBE_VIEW
attribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;
#endif
varying vec2 v_extrude;
#pragma mapbox: define highp float weight
#pragma mapbox: define mediump float radius
const highp float ZERO=1.0/255.0/16.0;
#define GAUSS_COEF 0.3989422804014327
void main(void) {
#pragma mapbox: initialize highp float weight
#pragma mapbox: initialize mediump float radius
vec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 tilePos=floor(a_pos*0.5);vec3 pos;
#ifdef PROJECTION_GLOBE_VIEW
vec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(tilePos)*elevation(tilePos);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*elevation(tilePos);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,tilePos,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);
#else
pos=vec3(tilePos+extrude,elevation(tilePos));
#endif
gl_Position=u_matrix*vec4(pos,1);
#ifdef FOG
v_fog_pos=fog_position(pos);
#endif
}`),heatmapTexture:Bi(`uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;varying vec2 v_pos;void main() {float t=texture2D(u_image,v_pos).r;vec4 color=texture2D(u_color_ramp,vec2(t,0.5));gl_FragColor=color*u_opacity;
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(0.0);
#endif
}`,"attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=a_pos*0.5+0.5;}"),collisionBox:Bi("varying float v_placed;varying float v_notUsed;void main() {vec4 red =vec4(1.0,0.0,0.0,1.0);vec4 blue=vec4(0.0,0.0,1.0,0.5);gl_FragColor =mix(red,blue,step(0.5,v_placed))*0.5;gl_FragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}",`attribute vec3 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;attribute vec2 a_shift;attribute float a_size_scale;attribute vec2 a_padding;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;varying float v_placed;varying float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_pos+elevationVector(a_anchor_pos)*elevation(a_anchor_pos),1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(
0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,1.5);gl_Position=projectedPoint;gl_Position.xy+=(a_extrude*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}`),collisionCircle:Bi("varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);gl_FragColor=color*alpha*opacity_t;}",`attribute vec2 a_pos_2f;attribute float a_radius;attribute vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd  =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz  /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos_2f;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(
mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(
0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}`),debug:Bi("uniform highp vec4 u_color;uniform sampler2D u_overlay;varying vec2 v_uv;void main() {vec4 overlay_color=texture2D(u_overlay,v_uv);gl_FragColor=mix(u_color,overlay_color,overlay_color.a);}",`attribute vec2 a_pos;
#ifdef PROJECTION_GLOBE_VIEW
attribute vec3 a_pos_3;
#endif
varying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {float h=elevation(a_pos);v_uv=a_pos/8192.0;
#ifdef PROJECTION_GLOBE_VIEW
gl_Position=u_matrix*vec4(a_pos_3+elevationVector(a_pos)*h,1);
#else
gl_Position=u_matrix*vec4(a_pos*u_overlay_scale,h,1);
#endif
}`),fill:Bi(`#pragma mapbox: define highp vec4 color
#pragma mapbox: define lowp float opacity
void main() {
#pragma mapbox: initialize highp vec4 color
#pragma mapbox: initialize lowp float opacity
vec4 out_color=color;
#ifdef LIGHTING_3D_MODE
out_color=apply_lighting(out_color);
#endif
#ifdef FOG
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
#endif
gl_FragColor=out_color*opacity;
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`attribute vec2 a_pos;uniform mat4 u_matrix;
#pragma mapbox: define highp vec4 color
#pragma mapbox: define lowp float opacity
void main() {
#pragma mapbox: initialize highp vec4 color
#pragma mapbox: initialize lowp float opacity
gl_Position=u_matrix*vec4(a_pos,0,1);
#ifdef FOG
v_fog_pos=fog_position(a_pos);
#endif
}`),fillOutline:Bi(`varying vec2 v_pos;
#pragma mapbox: define highp vec4 outline_color
#pragma mapbox: define lowp float opacity
void main() {
#pragma mapbox: initialize highp vec4 outline_color
#pragma mapbox: initialize lowp float opacity
float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color;
#ifdef LIGHTING_3D_MODE
out_color=apply_lighting(out_color);
#endif
#ifdef FOG
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
#endif
gl_FragColor=out_color*(alpha*opacity);
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos;
#pragma mapbox: define highp vec4 outline_color
#pragma mapbox: define lowp float opacity
void main() {
#pragma mapbox: initialize highp vec4 outline_color
#pragma mapbox: initialize lowp float opacity
gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;
#ifdef FOG
v_fog_pos=fog_position(a_pos);
#endif
}`),fillOutlinePattern:Bi(`uniform vec2 u_texsize;uniform sampler2D u_image;varying vec2 v_pos;varying vec2 v_pos_world;
#pragma mapbox: define lowp float opacity
#pragma mapbox: define lowp vec4 pattern
void main() {
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize mediump vec4 pattern
vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);float dist=length(v_pos_world-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=texture2D(u_image,pos);
#ifdef LIGHTING_3D_MODE
out_color=apply_lighting(out_color);
#endif
#ifdef FOG
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
#endif
gl_FragColor=out_color*(alpha*opacity);
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos;varying vec2 v_pos_world;
#pragma mapbox: define lowp float opacity
#pragma mapbox: define lowp vec4 pattern
#pragma mapbox: define lowp float pixel_ratio
void main() {
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize mediump vec4 pattern
#pragma mapbox: initialize lowp float pixel_ratio
vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);v_pos_world=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;
#ifdef FOG
v_fog_pos=fog_position(a_pos);
#endif
}`),fillPattern:Bi(`uniform vec2 u_texsize;uniform sampler2D u_image;varying vec2 v_pos;
#pragma mapbox: define lowp float opacity
#pragma mapbox: define lowp vec4 pattern
void main() {
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize mediump vec4 pattern
vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);vec4 out_color=texture2D(u_image,pos);
#ifdef LIGHTING_3D_MODE
out_color=apply_lighting(out_color);
#endif
#ifdef FOG
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
#endif
gl_FragColor=out_color*opacity;
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos;
#pragma mapbox: define lowp float opacity
#pragma mapbox: define lowp vec4 pattern
#pragma mapbox: define lowp float pixel_ratio
void main() {
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize mediump vec4 pattern
#pragma mapbox: initialize lowp float pixel_ratio
vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);
#ifdef FOG
v_fog_pos=fog_position(a_pos);
#endif
}`),fillExtrusion:Bi(`varying vec4 v_color;
#ifdef RENDER_SHADOWS
varying highp vec4 v_pos_light_view_0;varying highp vec4 v_pos_light_view_1;varying float v_depth;
#endif
#ifdef FAUX_AO
uniform lowp vec2 u_ao;varying vec3 v_ao;
#endif
#ifdef ZERO_ROOF_RADIUS
varying vec4 v_roof_color;
#endif
#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS)
varying highp vec3 v_normal;
#endif
void main() {
#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS)
vec3 normal=v_normal;
#endif
float z;vec4 color;
#ifdef ZERO_ROOF_RADIUS
z=float(normal.z > 0.00001);color=mix(v_color,v_roof_color,z);
#else
color=v_color;
#endif
#ifdef FAUX_AO
float intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;
#ifdef ZERO_ROOF_RADIUS
concave*=(1.0-z);
#endif
float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);color.rgb=color.rgb*shade;
#endif
#ifdef RENDER_SHADOWS
#ifdef ZERO_ROOF_RADIUS
normal=mix(normal,vec3(0.0,0.0,1.0),z);
#endif
color.xyz=shadowed_color_normal(color.xyz,normalize(normal),v_pos_light_view_0,v_pos_light_view_1,v_depth);
#endif
#ifdef FOG
color=fog_dither(fog_apply_premultiplied(color,v_fog_pos));
#endif
gl_FragColor=color;
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_edge_radius;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;
#ifdef PROJECTION_GLOBE_VIEW
attribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;
#endif
varying vec4 v_color;
#ifdef RENDER_SHADOWS
uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;varying highp vec4 v_pos_light_view_0;varying highp vec4 v_pos_light_view_1;varying float v_depth;
#endif
#ifdef ZERO_ROOF_RADIUS
varying vec4 v_roof_color;
#endif
#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS)
varying highp vec3 v_normal;
#endif
#ifdef FAUX_AO
uniform lowp vec2 u_ao;varying vec3 v_ao;
#endif
#pragma mapbox: define highp float base
#pragma mapbox: define highp float height
#pragma mapbox: define highp vec4 color
void main() {
#pragma mapbox: initialize highp float base
#pragma mapbox: initialize highp float height
#pragma mapbox: initialize highp vec4 color
vec4 pos_nx=floor(a_pos_normal_ed*0.5);vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));
#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS)
v_normal=normal;
#endif
base=max(0.0,base);height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);
#if defined(HAS_CENTROID) || defined(TERRAIN)
centroid_pos=a_centroid_pos;
#endif
float ele=0.0;float h=0.0;float c_ele;vec3 pos;
#ifdef TERRAIN
bool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);pos=vec3(pos_nx.xy,h);
#else
h=t > 0.0 ? height : base;pos=vec3(pos_nx.xy,h);
#endif
#ifdef PROJECTION_GLOBE_VIEW
float lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*h);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);
#endif
float hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);
#ifdef RENDER_SHADOWS
v_pos_light_view_0=u_light_matrix_0*vec4(pos,1);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1);v_depth=gl_Position.w;
#endif
float NdotL=0.0;float colorvalue=0.0;
#ifdef LIGHTING_3D_MODE
NdotL=calculate_NdotL(normal);
#else
colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),NdotL);
#endif
if (normal.y !=0.0) {float r=0.84;
#ifndef LIGHTING_3D_MODE
r=mix(0.7,0.98,1.0-u_lightintensity);
#endif
NdotL*=(
(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}v_color=vec4(0.0,0.0,0.0,1.0);
#ifdef FAUX_AO
float concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;
#ifdef TERRAIN
top_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);
#endif
v_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);
#ifdef PROJECTION_GLOBE_VIEW
top_height+=u_height_lift;
#endif
gl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;
#endif
#ifdef LIGHTING_3D_MODE
v_color=apply_lighting(color,NdotL);
#else
v_color.rgb+=clamp(color.rgb*NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));
#endif
v_color*=u_opacity;
#ifdef ZERO_ROOF_RADIUS
v_roof_color=vec4(0.0,0.0,0.0,1.0);
#ifdef LIGHTING_3D_MODE
v_roof_color=apply_lighting(color,calculate_NdotL(vec3(0.0,0.0,1.0)));
#else
float roofNdotL=clamp(u_lightpos.z,0.0,1.0);roofNdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),roofNdotL);v_roof_color.rgb+=clamp(color.rgb*roofNdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));
#endif
v_roof_color*=u_opacity;
#endif
#ifdef FOG
v_fog_pos=fog_position(pos);
#endif
}`),fillExtrusionPattern:Bi(`uniform vec2 u_texsize;uniform sampler2D u_image;
#ifdef FAUX_AO
uniform lowp vec2 u_ao;varying vec3 v_ao;
#endif
#ifdef LIGHTING_3D_MODE
varying float v_NdotL;
#endif
varying vec2 v_pos;varying vec4 v_lighting;uniform lowp float u_opacity;
#pragma mapbox: define lowp float base
#pragma mapbox: define lowp float height
#pragma mapbox: define lowp vec4 pattern
#pragma mapbox: define lowp float pixel_ratio
void main() {
#pragma mapbox: initialize lowp float base
#pragma mapbox: initialize lowp float height
#pragma mapbox: initialize mediump vec4 pattern
#pragma mapbox: initialize lowp float pixel_ratio
vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);vec4 out_color=texture2D(u_image,pos);
#ifdef LIGHTING_3D_MODE
out_color=apply_lighting(out_color,v_NdotL)*u_opacity;
#else
out_color=out_color*v_lighting;
#endif
#ifdef FAUX_AO
float intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);out_color.rgb=out_color.rgb*shade;
#endif
#ifdef FOG
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
#endif
gl_FragColor=out_color;
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform float u_tile_units_to_pixels;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;
#ifdef PROJECTION_GLOBE_VIEW
attribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;
#endif
varying vec2 v_pos;varying vec4 v_lighting;
#ifdef FAUX_AO
uniform lowp vec2 u_ao;varying vec3 v_ao;
#endif
#ifdef LIGHTING_3D_MODE
varying float v_NdotL;
#endif
#pragma mapbox: define lowp float base
#pragma mapbox: define lowp float height
#pragma mapbox: define lowp vec4 pattern
#pragma mapbox: define lowp float pixel_ratio
void main() {
#pragma mapbox: initialize lowp float base
#pragma mapbox: initialize lowp float height
#pragma mapbox: initialize mediump vec4 pattern
#pragma mapbox: initialize lowp float pixel_ratio
vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec4 pos_nx=floor(a_pos_normal_ed*0.5);mediump vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;mediump vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=a_pos_normal_ed.w;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);
#if defined(HAS_CENTROID) || defined(TERRAIN)
centroid_pos=a_centroid_pos;
#endif
float ele=0.0;float h=z;vec3 p;float c_ele;
#ifdef TERRAIN
bool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);p=vec3(pos_nx.xy,h);
#else
p=vec3(pos_nx.xy,z);
#endif
#ifdef PROJECTION_GLOBE_VIEW
float lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(p.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,p.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*p.z;p=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);
#endif
float hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(p,1),AWAY,hidden);vec2 pos=normal.z==1.0
? pos_nx.xy
: vec2(edgedistance,z*u_height_factor);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float NdotL=0.0;
#ifdef LIGHTING_3D_MODE
NdotL=calculate_NdotL(normal);
#else
NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),NdotL);
#endif
if (normal.y !=0.0) {float r=0.84;
#ifndef LIGHTING_3D_MODE
r=mix(0.7,0.98,1.0-u_lightintensity);
#endif
NdotL*=(
(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}
#ifdef FAUX_AO
float concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;
#ifdef TERRAIN
top_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);
#endif
v_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);
#ifdef PROJECTION_GLOBE_VIEW
top_height+=u_height_lift;
#endif
gl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;
#endif
#ifdef LIGHTING_3D_MODE
v_NdotL=NdotL;
#else
v_lighting.rgb+=clamp(NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;
#endif 
#ifdef FOG
v_fog_pos=fog_position(p);
#endif
}`),hillshadePrepare:Bi(`#ifdef GL_ES
precision highp float;
#endif
uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord) {
#ifdef TERRAIN_DEM_FLOAT_FORMAT
return texture2D(u_image,coord).a/4.0;
#else
vec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;
#endif
}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y));float b=getElevation(v_pos+vec2(0,-epsilon.y));float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y));float d=getElevation(v_pos+vec2(-epsilon.x,0));float e=getElevation(v_pos+vec2(epsilon.x,0));float f=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float g=getElevation(v_pos+vec2(0,epsilon.y));float h=getElevation(v_pos+vec2(epsilon.x,epsilon.y));float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2(
(c+e+e+h)-(a+d+d+f),(f+g+g+h)-(a+b+b+c)
)/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(
deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,"uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:Bi(`uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;void main() {vec4 pixel=texture2D(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color;
#ifdef LIGHTING_3D_MODE
gl_FragColor=apply_lighting(gl_FragColor);
#endif
#ifdef FOG
gl_FragColor=fog_dither(fog_apply_premultiplied(gl_FragColor,v_fog_pos));
#endif
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;
#ifdef FOG
v_fog_pos=fog_position(a_pos);
#endif
}`),line:Bi(`uniform lowp float u_device_pixel_ratio;uniform float u_alpha_discard_threshold;uniform highp vec2 u_trim_offset;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;varying highp vec4 v_uv;
#ifdef RENDER_LINE_DASH
uniform sampler2D u_dash_image;varying vec2 v_tex;
#endif
#ifdef RENDER_LINE_GRADIENT
uniform sampler2D u_gradient_image;
#endif
uniform float u_border_width;uniform vec4 u_border_color;float luminance(vec3 c) {return (c.r+c.r+c.b+c.g+c.g+c.g)*0.1667;}
#pragma mapbox: define highp vec4 color
#pragma mapbox: define lowp float floorwidth
#pragma mapbox: define lowp vec4 dash
#pragma mapbox: define lowp float blur
#pragma mapbox: define lowp float opacity
float linearstep(float edge0,float edge1,float x) {return  clamp((x-edge0)/(edge1-edge0),0.0,1.0);}void main() {
#pragma mapbox: initialize highp vec4 color
#pragma mapbox: initialize lowp float floorwidth
#pragma mapbox: initialize lowp vec4 dash
#pragma mapbox: initialize lowp float blur
#pragma mapbox: initialize lowp float opacity
float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);
#ifdef RENDER_LINE_DASH
float sdfdist=texture2D(u_dash_image,v_tex).a;float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/dash.z;alpha*=linearstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);
#endif
highp vec4 out_color;
#ifdef RENDER_LINE_GRADIENT
out_color=texture2D(u_gradient_image,v_uv.xy);
#else
out_color=color;
#endif
float trimmed=1.0;
#ifdef RENDER_LINE_TRIM_OFFSET
highp float start=v_uv[2];highp float end=v_uv[3];highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=(start+(v_uv.x)*(end-start));if (trim_end > trim_start) {if (line_progress <=trim_end && line_progress >=trim_start) {out_color=vec4(0,0,0,0);trimmed=0.0;}}
#endif
#ifdef LIGHTING_3D_MODE
out_color=apply_lighting(out_color);
#endif
#ifdef FOG
out_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));
#endif
#ifdef RENDER_LINE_ALPHA_DISCARD
if (alpha < u_alpha_discard_threshold) {discard;}
#endif
#ifdef RENDER_LINE_BORDER
float edgeBlur=(u_border_width+1.0/u_device_pixel_ratio);float alpha2=clamp(min(dist-(v_width2.t-edgeBlur),v_width2.s-dist)/edgeBlur,0.0,1.0);if (alpha2 < 1.) {float smoothAlpha=smoothstep(0.6,1.0,alpha2);
#ifdef RENDER_LINE_BORDER_AUTO
float Y=(out_color.a > 0.01) ? luminance(out_color.rgb/out_color.a) : 1.;float adjustment=(Y > 0.) ? 0.5/Y : 0.45;if (out_color.a > 0.25 && Y < 0.25) {vec3 borderColor=(Y > 0.) ? out_color.rgb : vec3(1,1,1)*out_color.a;out_color.rgb=out_color.rgb+borderColor*(adjustment*(1.0-smoothAlpha));} else {out_color.rgb*=(0.6 +0.4*smoothAlpha);}
#else
out_color.rgb=mix(u_border_color.rgb*u_border_color.a*trimmed,out_color.rgb,smoothAlpha);
#endif
}
#endif
gl_FragColor=out_color*(alpha*opacity);
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`
#define EXTRUDE_SCALE 0.015873016
attribute vec2 a_pos_normal;attribute vec4 a_data;
#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)
attribute highp vec4 a_packed;
#endif
#ifdef RENDER_LINE_DASH
attribute float a_linesofar;
#endif
uniform mat4 u_matrix;uniform mat2 u_pixels_to_tile_units;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp vec4 v_uv;
#ifdef RENDER_LINE_DASH
uniform vec2 u_texsize;uniform float u_tile_units_to_pixels;varying vec2 v_tex;
#endif
#ifdef RENDER_LINE_GRADIENT
uniform float u_image_height;
#endif
#pragma mapbox: define highp vec4 color
#pragma mapbox: define lowp float floorwidth
#pragma mapbox: define lowp vec4 dash
#pragma mapbox: define lowp float blur
#pragma mapbox: define lowp float opacity
#pragma mapbox: define mediump float gapwidth
#pragma mapbox: define lowp float offset
#pragma mapbox: define mediump float width
void main() {
#pragma mapbox: initialize highp vec4 color
#pragma mapbox: initialize lowp float floorwidth
#pragma mapbox: initialize lowp vec4 dash
#pragma mapbox: initialize lowp float blur
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize mediump float gapwidth
#pragma mapbox: initialize lowp float offset
#pragma mapbox: initialize mediump float width
float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*EXTRUDE_SCALE;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*EXTRUDE_SCALE*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;
#ifndef RENDER_TO_TEXTURE
float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
#else
v_gamma_scale=1.0;
#endif
#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)
float a_uv_x=a_packed[0];float a_split_index=a_packed[1];highp float a_clip_start=a_packed[2];highp float a_clip_end=a_packed[3];
#ifdef RENDER_LINE_GRADIENT
highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec4(a_uv_x,a_split_index*texel_height-half_texel_height,a_clip_start,a_clip_end);
#else
v_uv=vec4(a_uv_x,0.0,a_clip_start,a_clip_end);
#endif
#endif
#ifdef RENDER_LINE_DASH
float scale=dash.z==0.0 ? 0.0 : u_tile_units_to_pixels/dash.z;float height=dash.y;v_tex=vec2(a_linesofar*scale/floorwidth,(-normal.y*height+dash.x+0.5)/u_texsize.y);
#endif
v_width2=vec2(outset,inset);
#ifdef FOG
v_fog_pos=fog_position(pos);
#endif
}`),linePattern:Bi(`uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_tile_units_to_pixels;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;
#pragma mapbox: define lowp vec4 pattern
#pragma mapbox: define lowp float pixel_ratio
#pragma mapbox: define lowp float blur
#pragma mapbox: define lowp float opacity
void main() {
#pragma mapbox: initialize mediump vec4 pattern
#pragma mapbox: initialize lowp float pixel_ratio
#pragma mapbox: initialize lowp float blur
#pragma mapbox: initialize lowp float opacity
vec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;vec2 pattern_size=vec2(display_size.x/u_tile_units_to_pixels,display_size.y);float aspect=display_size.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x=mod(v_linesofar/pattern_size.x*aspect,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(x,y));vec4 color=texture2D(u_image,pos);
#ifdef LIGHTING_3D_MODE
color=apply_lighting(color);
#endif
#ifdef FOG
color=fog_dither(fog_apply_premultiplied(color,v_fog_pos));
#endif
gl_FragColor=color*(alpha*opacity);
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`
#define scale 0.015873016
attribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_linesofar;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;
#pragma mapbox: define lowp float blur
#pragma mapbox: define lowp float opacity
#pragma mapbox: define lowp float offset
#pragma mapbox: define mediump float gapwidth
#pragma mapbox: define mediump float width
#pragma mapbox: define lowp float floorwidth
#pragma mapbox: define lowp vec4 pattern
#pragma mapbox: define lowp float pixel_ratio
void main() {
#pragma mapbox: initialize lowp float blur
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize lowp float offset
#pragma mapbox: initialize mediump float gapwidth
#pragma mapbox: initialize mediump float width
#pragma mapbox: initialize lowp float floorwidth
#pragma mapbox: initialize mediump vec4 pattern
#pragma mapbox: initialize lowp float pixel_ratio
float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;
#ifndef RENDER_TO_TEXTURE
float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;
#else
v_gamma_scale=1.0;
#endif
v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;
#ifdef FOG
v_fog_pos=fog_position(pos);
#endif
}`),raster:Bi(`uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;varying vec2 v_pos0;varying vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(
dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);vec3 out_color=mix(u_high_vec,u_low_vec,rgb);
#ifdef LIGHTING_3D_MODE
out_color=apply_lighting(out_color);
#endif
#ifdef FOG
out_color=fog_dither(fog_apply(out_color,v_fog_pos));
#endif
gl_FragColor=vec4(out_color*color.a,color.a);
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform vec2 u_perspective_transform;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {float w=1.0+dot(a_texture_pos,u_perspective_transform);gl_Position=u_matrix*vec4(a_pos*w,0,w);v_pos0=a_texture_pos/8192.0;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;
#ifdef FOG
v_fog_pos=fog_position(a_pos);
#endif
}`),symbolIcon:Bi(`uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;
#pragma mapbox: define lowp float opacity
void main() {
#pragma mapbox: initialize lowp float opacity
lowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_projected_pos;attribute float a_fade_opacity;
#ifdef PROJECTION_GLOBE_VIEW
attribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;
#endif
uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform vec3 u_up_vector;
#ifdef PROJECTION_GLOBE_VIEW
uniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;
#endif
varying vec2 v_tex;varying float v_fade_opacity;
#pragma mapbox: define lowp float opacity
void main() {
#pragma mapbox: initialize lowp float opacity
vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_min_font_scale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;
#ifdef PROJECTION_GLOBE_VIEW
mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;
#else
world_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;
#endif
vec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?
camera_to_anchor_distance/u_camera_to_center_distance :
u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(
0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjected_point;
#ifdef PROJECTION_GLOBE_VIEW
vec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetProjected_point=u_matrix*vec4(a_globe_anchor+displacement,1);
#else
offsetProjected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);
#endif
vec2 a=projected_point.xy/projected_point.w;vec2 b=offsetProjected_point.xy/offsetProjected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;
#ifdef PROJECTION_GLOBE_VIEW
vec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);
#else
projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);
#endif
highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*max(a_min_font_scale,font_scale)+a_pxoffset/16.0);
#ifdef TERRAIN
#ifdef PITCH_WITH_MAP_TERRAIN
vec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);
#endif
#endif
float occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;
#ifdef PROJECTION_GLOBE_VIEW
vec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));
#else
gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));
#endif
float projection_transition_fade=1.0;
#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)
projection_transition_fade=1.0-step(EPSILON,u_zoom_transition);
#endif
v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;v_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change))*projection_transition_fade;}`),symbolSDF:Bi(`#define SDF_PX 8.0
uniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1;
#pragma mapbox: define highp vec4 fill_color
#pragma mapbox: define highp vec4 halo_color
#pragma mapbox: define lowp float opacity
#pragma mapbox: define lowp float halo_width
#pragma mapbox: define lowp float halo_blur
void main() {
#pragma mapbox: initialize highp vec4 fill_color
#pragma mapbox: initialize highp vec4 halo_color
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize lowp float halo_width
#pragma mapbox: initialize lowp float halo_blur
float EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_projected_pos;attribute float a_fade_opacity;
#ifdef PROJECTION_GLOBE_VIEW
attribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;
#endif
uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector;
#ifdef PROJECTION_GLOBE_VIEW
uniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;
#endif
varying vec2 v_data0;varying vec3 v_data1;
#pragma mapbox: define highp vec4 fill_color
#pragma mapbox: define highp vec4 halo_color
#pragma mapbox: define lowp float opacity
#pragma mapbox: define lowp float halo_width
#pragma mapbox: define lowp float halo_blur
void main() {
#pragma mapbox: initialize highp vec4 fill_color
#pragma mapbox: initialize highp vec4 halo_color
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize lowp float halo_width
#pragma mapbox: initialize lowp float halo_blur
vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;
#ifdef PROJECTION_GLOBE_VIEW
mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;
#else
world_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;
#endif
vec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?
camera_to_anchor_distance/u_camera_to_center_distance :
u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(
0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetprojected_point;
#ifdef PROJECTION_GLOBE_VIEW
vec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetprojected_point=u_matrix*vec4(a_globe_anchor+displacement,1);
#else
offsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);
#endif
vec2 a=projected_point.xy/projected_point.w;vec2 b=offsetprojected_point.xy/offsetprojected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;
#ifdef PROJECTION_GLOBE_VIEW
vec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);
#else
projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);
#endif
highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset);
#ifdef TERRAIN
#ifdef PITCH_WITH_MAP_TERRAIN
vec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);
#endif
#endif
float occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;
#ifdef PROJECTION_GLOBE_VIEW
vec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));
#else
gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));
#endif
float gamma_scale=gl_Position.w;float projection_transition_fade=1.0;
#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)
projection_transition_fade=1.0-step(EPSILON,u_zoom_transition);
#endif
vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade);}`),symbolTextAndIcon:Bi(`#define SDF_PX 8.0
#define SDF 1.0
#define ICON 0.0
uniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1;
#pragma mapbox: define highp vec4 fill_color
#pragma mapbox: define highp vec4 halo_color
#pragma mapbox: define lowp float opacity
#pragma mapbox: define lowp float halo_width
#pragma mapbox: define lowp float halo_blur
void main() {
#pragma mapbox: initialize highp vec4 fill_color
#pragma mapbox: initialize highp vec4 halo_color
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize lowp float halo_width
#pragma mapbox: initialize lowp float halo_blur
float fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha;
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
return;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_projected_pos;attribute float a_fade_opacity;
#ifdef PROJECTION_GLOBE_VIEW
attribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;
#endif
uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector;uniform vec2 u_texsize_icon;
#ifdef PROJECTION_GLOBE_VIEW
uniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;
#endif
varying vec4 v_data0;varying vec4 v_data1;
#pragma mapbox: define highp vec4 fill_color
#pragma mapbox: define highp vec4 halo_color
#pragma mapbox: define lowp float opacity
#pragma mapbox: define lowp float halo_width
#pragma mapbox: define lowp float halo_blur
void main() {
#pragma mapbox: initialize highp vec4 fill_color
#pragma mapbox: initialize highp vec4 halo_color
#pragma mapbox: initialize lowp float opacity
#pragma mapbox: initialize lowp float halo_width
#pragma mapbox: initialize lowp float halo_blur
vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;
#ifdef PROJECTION_GLOBE_VIEW
mercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;
#else
world_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;
#endif
vec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?
camera_to_anchor_distance/u_camera_to_center_distance :
u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(
0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offset_projected_point=u_matrix*vec4(a_pos+vec2(1,0),0,1);vec2 a=projected_point.xy/projected_point.w;vec2 b=offset_projected_point.xy/offset_projected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;
#ifdef PROJECTION_GLOBE_VIEW
vec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);
#else
projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);
#endif
highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*font_scale);
#ifdef TERRAIN
#ifdef PITCH_WITH_MAP_TERRAIN
vec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);
#endif
#endif
float occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;
#ifdef PROJECTION_GLOBE_VIEW
vec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));
#else
gl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));
#endif
float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));float projection_transition_fade=1.0;
#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)
projection_transition_fade=1.0-step(EPSILON,u_zoom_transition);
#endif
v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade,is_sdf);}`),terrainRaster:Bi(`uniform sampler2D u_image0;varying vec2 v_pos0;
#ifdef FOG
varying float v_fog_opacity;
#endif
#ifdef RENDER_SHADOWS
varying vec4 v_pos_light_view_0;varying vec4 v_pos_light_view_1;varying float v_depth;
#endif
void main() {vec4 color=texture2D(u_image0,v_pos0);
#ifdef RENDER_SHADOWS
color.xyz=shadowed_color(color.xyz,v_pos_light_view_0,v_pos_light_view_1,v_depth);
#endif
#ifdef FOG
#ifdef ZERO_EXAGGERATION
color=fog_dither(fog_apply_premultiplied(color,v_fog_pos));
#else
color=fog_dither(fog_apply_from_vert(color,v_fog_opacity));
#endif
#endif
gl_FragColor=color;
#ifdef TERRAIN_WIREFRAME
gl_FragColor=vec4(1.0,0.0,0.0,0.8);
#endif
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`uniform mat4 u_matrix;uniform float u_skirt_height;attribute vec2 a_pos;varying vec2 v_pos0;
#ifdef FOG
varying float v_fog_opacity;
#endif
#ifdef RENDER_SHADOWS
uniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;varying vec4 v_pos_light_view_0;varying vec4 v_pos_light_view_1;varying float v_depth;
#endif
const float wireframeOffset=0.00015;void main() {vec3 decomposedPosAndSkirt=decomposeToPosAndSkirt(a_pos);float skirt=decomposedPosAndSkirt.z;vec2 decodedPos=decomposedPosAndSkirt.xy;float elevation=elevation(decodedPos)-skirt*u_skirt_height;
#ifdef TERRAIN_WIREFRAME
elevation+=wireframeOffset;
#endif
v_pos0=decodedPos/8192.0;gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);
#ifdef FOG
#ifdef ZERO_EXAGGERATION
v_fog_pos=fog_position(decodedPos);
#else
v_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));
#endif
#endif
#ifdef RENDER_SHADOWS
vec3 pos=vec3(decodedPos,elevation);v_pos_light_view_0=u_light_matrix_0*vec4(pos,1.);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1.);v_depth=gl_Position.w;
#endif
}`),terrainDepth:Bi(`#ifdef GL_ES
precision highp float;
#endif
varying float v_depth;void main() {gl_FragColor=pack_depth(v_depth);}`,"uniform mat4 u_matrix;attribute vec2 a_pos;varying float v_depth;void main() {float elevation=elevation(a_pos);gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}"),skybox:Bi(`
varying lowp vec3 v_uv;uniform lowp samplerCube u_cubemap;uniform lowp float u_opacity;uniform highp float u_temporal_offset;uniform highp vec3 u_sun_direction;float sun_disk(highp vec3 ray_direction,highp vec3 sun_direction) {highp float cos_angle=dot(normalize(ray_direction),sun_direction);const highp float cos_sun_angular_diameter=0.99996192306;const highp float smoothstep_delta=1e-5;return smoothstep(
cos_sun_angular_diameter-smoothstep_delta,cos_sun_angular_diameter+smoothstep_delta,cos_angle);}float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec3 uv=v_uv;const float y_bias=0.015;uv.y+=y_bias;uv.y=pow(abs(uv.y),1.0/5.0);uv.y=map(uv.y,0.0,1.0,-1.0,1.0);vec3 sky_color=textureCube(u_cubemap,uv).rgb;
#ifdef FOG
sky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color);
#endif
sky_color.rgb=dither(sky_color.rgb,gl_FragCoord.xy+u_temporal_offset);sky_color+=0.1*sun_disk(v_uv,u_sun_direction);gl_FragColor=vec4(sky_color*u_opacity,u_opacity);
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,as),skyboxGradient:Bi(`varying highp vec3 v_uv;uniform lowp sampler2D u_color_ramp;uniform highp vec3 u_center_direction;uniform lowp float u_radius;uniform lowp float u_opacity;uniform highp float u_temporal_offset;void main() {float progress=acos(dot(normalize(v_uv),u_center_direction))/u_radius;vec4 color=texture2D(u_color_ramp,vec2(progress,0.5));
#ifdef FOG
color.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a;
#endif
color*=u_opacity;color.rgb=dither(color.rgb,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=color;
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,as),skyboxCapture:Bi(`
varying highp vec3 v_position;uniform highp float u_sun_intensity;uniform highp float u_luminance;uniform lowp vec3 u_sun_direction;uniform highp vec4 u_color_tint_r;uniform highp vec4 u_color_tint_m;
#ifdef GL_ES
precision highp float;
#endif
#define BETA_R                  vec3(5.5e-6,13.0e-6,22.4e-6)
#define BETA_M                  vec3(21e-6,21e-6,21e-6)
#define MIE_G                   0.76
#define DENSITY_HEIGHT_SCALE_R  8000.0
#define DENSITY_HEIGHT_SCALE_M  1200.0
#define PLANET_RADIUS           6360e3
#define ATMOSPHERE_RADIUS       6420e3
#define SAMPLE_STEPS            10
#define DENSITY_STEPS           4
float ray_sphere_exit(vec3 orig,vec3 dir,float radius) {float a=dot(dir,dir);float b=2.0*dot(dir,orig);float c=dot(orig,orig)-radius*radius;float d=sqrt(b*b-4.0*a*c);return (-b+d)/(2.0*a);}vec3 extinction(vec2 density) {return exp(-vec3(BETA_R*u_color_tint_r.a*density.x+BETA_M*u_color_tint_m.a*density.y));}vec2 local_density(vec3 point) {float height=max(length(point)-PLANET_RADIUS,0.0);float exp_r=exp(-height/DENSITY_HEIGHT_SCALE_R);float exp_m=exp(-height/DENSITY_HEIGHT_SCALE_M);return vec2(exp_r,exp_m);}float phase_ray(float cos_angle) {return (3.0/(16.0*PI))*(1.0+cos_angle*cos_angle);}float phase_mie(float cos_angle) {return (3.0/(8.0*PI))*((1.0-MIE_G*MIE_G)*(1.0+cos_angle*cos_angle))/((2.0+MIE_G*MIE_G)*pow(1.0+MIE_G*MIE_G-2.0*MIE_G*cos_angle,1.5));}vec2 density_to_atmosphere(vec3 point,vec3 light_dir) {float ray_len=ray_sphere_exit(point,light_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(DENSITY_STEPS);vec2 density_point_to_atmosphere=vec2(0.0);for (int i=0; i < DENSITY_STEPS;++i) {vec3 point_on_ray=point+light_dir*((float(i)+0.5)*step_len);density_point_to_atmosphere+=local_density(point_on_ray)*step_len;;}return density_point_to_atmosphere;}vec3 atmosphere(vec3 ray_dir,vec3 sun_direction,float sun_intensity) {vec2 density_orig_to_point=vec2(0.0);vec3 scatter_r=vec3(0.0);vec3 scatter_m=vec3(0.0);vec3 origin=vec3(0.0,PLANET_RADIUS,0.0);float ray_len=ray_sphere_exit(origin,ray_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(SAMPLE_STEPS);for (int i=0; i < SAMPLE_STEPS;++i) {vec3 point_on_ray=origin+ray_dir*((float(i)+0.5)*step_len);vec2 density=local_density(point_on_ray)*step_len;density_orig_to_point+=density;vec2 density_point_to_atmosphere=density_to_atmosphere(point_on_ray,sun_direction);vec2 density_orig_to_atmosphere=density_orig_to_point+density_point_to_atmosphere;vec3 extinction=extinction(density_orig_to_atmosphere);scatter_r+=density.x*extinction;scatter_m+=density.y*extinction;}float cos_angle=dot(ray_dir,sun_direction);float phase_r=phase_ray(cos_angle);float phase_m=phase_mie(cos_angle);vec3 beta_r=BETA_R*u_color_tint_r.rgb*u_color_tint_r.a;vec3 beta_m=BETA_M*u_color_tint_m.rgb*u_color_tint_m.a;return (scatter_r*phase_r*beta_r+scatter_m*phase_m*beta_m)*sun_intensity;}const float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;vec3 uncharted2_tonemap(vec3 x) {return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;}void main() {vec3 ray_direction=v_position;ray_direction.y=pow(ray_direction.y,5.0);const float y_bias=0.015;ray_direction.y+=y_bias;vec3 color=atmosphere(normalize(ray_direction),u_sun_direction,u_sun_intensity);float white_scale=1.0748724675633854;color=uncharted2_tonemap((log2(2.0/pow(u_luminance,4.0)))*color)*white_scale;gl_FragColor=vec4(color,1.0);}`,"attribute highp vec3 a_pos_3f;uniform mat3 u_matrix_3f;varying highp vec3 v_position;float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec4 pos=vec4(u_matrix_3f*a_pos_3f,1.0);v_position=pos.xyz;v_position.y*=-1.0;v_position.y=map(v_position.y,-1.0,1.0,0.0,1.0);gl_Position=vec4(a_pos_3f.xy,0.0,1.0);}"),globeRaster:Bi(`uniform sampler2D u_image0;varying vec2 v_pos0;
#ifndef FOG
uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform vec2 u_viewport;
#endif
void main() {vec4 color;
#ifdef CUSTOM_ANTIALIASING
vec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix(
mix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);vec3 dir=normalize(ray_dir);vec3 closest_point=dot(u_globe_pos,dir)*dir;float norm_dist_from_center=1.0-length(closest_point-u_globe_pos)/u_globe_radius;const float antialias_pixel=2.0;float antialias_factor=antialias_pixel*fwidth(norm_dist_from_center);float antialias=smoothstep(0.0,antialias_factor,norm_dist_from_center);vec4 raster=texture2D(u_image0,v_pos0);color=vec4(raster.rgb*antialias,raster.a*antialias);
#else
color=texture2D(u_image0,v_pos0);
#endif
#ifdef FOG
color=fog_dither(fog_apply_premultiplied(color,v_fog_pos));
#endif
gl_FragColor=color;
#ifdef TERRAIN_WIREFRAME
gl_FragColor=vec4(1.0,0.0,0.0,0.8);
#endif
#ifdef OVERDRAW_INSPECTOR
gl_FragColor=vec4(1.0);
#endif
}`,`uniform mat4 u_proj_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;uniform mat3 u_grid_matrix;uniform float u_skirt_height;
#ifdef GLOBE_POLES
attribute vec3 a_globe_pos;attribute vec2 a_uv;
#else
attribute vec2 a_pos;
#endif
varying vec2 v_pos0;const float wireframeOffset=1e3;float mercatorXfromLng(float lng) {return (180.0+lng)/360.0;}float mercatorYfromLat(float lat) {return (180.0-(RAD_TO_DEG*log(tan(QUARTER_PI+lat/2.0*DEG_TO_RAD))))/360.0;}vec3 latLngToECEF(vec2 latLng) {latLng=DEG_TO_RAD*latLng;float cosLat=cos(latLng[0]);float sinLat=sin(latLng[0]);float cosLng=cos(latLng[1]);float sinLng=sin(latLng[1]);float sx=cosLat*sinLng*GLOBE_RADIUS;float sy=-sinLat*GLOBE_RADIUS;float sz=cosLat*cosLng*GLOBE_RADIUS;return vec3(sx,sy,sz);}void main() {
#ifdef GLOBE_POLES
vec3 globe_pos=a_globe_pos;vec2 uv=a_uv;
#else
float tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];vec3 decomposed_pos_and_skirt=decomposeToPosAndSkirt(a_pos);vec3 latLng=u_grid_matrix*vec3(decomposed_pos_and_skirt.xy,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=mercatorY*tiles-idy;float mercatorX=mercatorXfromLng(latLng[1]);float uvX=mercatorX*tiles-idx;vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);vec2 uv=vec2(uvX,uvY);
#endif
v_pos0=uv;vec2 tile_pos=uv*EXTENT;vec3 globe_derived_up_vector=normalize(globe_pos)*u_tile_up_scale;
#ifdef GLOBE_POLES
vec3 up_vector=globe_derived_up_vector;
#else
vec3 up_vector=elevationVector(tile_pos);
#endif
float height=elevation(tile_pos);
#ifdef TERRAIN_WIREFRAME
height+=wireframeOffset;
#endif
globe_pos+=up_vector*height;
#ifndef GLOBE_POLES
globe_pos-=globe_derived_up_vector*u_skirt_height*decomposed_pos_and_skirt.z;
#endif
#ifdef GLOBE_POLES
vec4 interpolated_pos=u_globe_matrix*vec4(globe_pos,1.0);
#else
vec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {merc_world_pos=vec4(merc_pos,height-u_skirt_height*decomposed_pos_and_skirt.z,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0);
#endif
gl_Position=u_proj_matrix*interpolated_pos;
#ifdef FOG
v_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);
#endif
}`),globeAtmosphere:Bi(`uniform float u_transition;uniform highp float u_fadeout_range;uniform highp float u_temporal_offset;uniform vec3 u_start_color;uniform vec4 u_color;uniform vec4 u_space_color;uniform vec4 u_high_color;uniform float u_star_intensity;uniform float u_star_size;uniform float u_star_density;uniform float u_horizon_angle;uniform mat4 u_rotation_matrix;varying highp vec3 v_ray_dir;varying highp vec3 v_horizon_dir;highp float random(highp vec3 p) {p=fract(p*vec3(23.2342,97.1231,91.2342));p+=dot(p.zxy,p.yxz+123.1234);return fract(p.x*p.y);}float stars(vec3 p,float scale,vec2 offset) {vec2 uv_scale=(u_viewport/u_star_size)*scale;vec3 position=vec3(p.xy*uv_scale+offset*u_viewport,p.z);vec3 q=fract(position)-0.5;vec3 id=floor(position);float random_visibility=step(random(id),u_star_density);float circle=smoothstep(0.5+u_star_intensity,0.5,length(q));return circle*random_visibility;}void main() {highp vec3 dir=normalize(v_ray_dir);float globe_pos_dot_dir;
#ifdef PROJECTION_GLOBE_VIEW
globe_pos_dot_dir=dot(u_globe_pos,dir);highp vec3 closest_point_forward=abs(globe_pos_dot_dir)*dir;float norm_dist_from_center=length(closest_point_forward-u_globe_pos)/u_globe_radius;if (norm_dist_from_center < 0.98) {discard;return;}
#endif
highp vec3 horizon_dir=normalize(v_horizon_dir);float horizon_angle_mercator=dir.y < horizon_dir.y ?
0.0 : max(acos(dot(dir,horizon_dir)),0.0);float horizon_angle;
#ifdef PROJECTION_GLOBE_VIEW
highp vec3 closest_point=globe_pos_dot_dir*dir;float closest_point_to_center=length(closest_point-u_globe_pos);float theta=asin(clamp(closest_point_to_center/length(u_globe_pos),-1.0,1.0));horizon_angle=globe_pos_dot_dir < 0.0 ?
PI-theta-u_horizon_angle : theta-u_horizon_angle;float angle_t=pow(u_transition,10.0);horizon_angle=mix(horizon_angle,horizon_angle_mercator,angle_t);
#else
horizon_angle=horizon_angle_mercator;
#endif
horizon_angle/=PI;float t=exp(-horizon_angle/u_fadeout_range);float alpha_0=u_color.a;float alpha_1=u_high_color.a;float alpha_2=u_space_color.a;vec3 color_stop_0=u_color.rgb;vec3 color_stop_1=u_high_color.rgb;vec3 color_stop_2=u_space_color.rgb;vec3 c0=mix(color_stop_2,color_stop_1,alpha_1);vec3 c1=mix(c0,color_stop_0,alpha_0);vec3 c2=mix(c0,c1,t);vec3 c =mix(color_stop_2,c2,t);float a0=mix(alpha_2,1.0,alpha_1);float a1=mix(a0,1.0,alpha_0);float a2=mix(a0,a1,t);float a =mix(alpha_2,a2,t);vec2 uv=gl_FragCoord.xy/u_viewport-0.5;float aspect_ratio=u_viewport.x/u_viewport.y;vec4 uv_dir=vec4(normalize(vec3(uv.x*aspect_ratio,uv.y,1.0)),1.0);uv_dir=u_rotation_matrix*uv_dir;vec3 n=abs(uv_dir.xyz);vec2 uv_remap=(n.x > n.y && n.x > n.z) ? uv_dir.yz/uv_dir.x:
(n.y > n.x && n.y > n.z) ? uv_dir.zx/uv_dir.y:
uv_dir.xy/uv_dir.z;uv_remap.x/=aspect_ratio;vec3 D=vec3(uv_remap,1.0);highp float star_field=0.0;if (u_star_intensity > 0.0) {star_field+=stars(D,1.2,vec2(0.0,0.0));star_field+=stars(D,1.0,vec2(1.0,0.0));star_field+=stars(D,0.8,vec2(0.0,1.0));star_field+=stars(D,0.6,vec2(1.0,1.0));star_field*=(1.0-pow(t,0.25+(1.0-u_high_color.a)*0.75));c+=star_field*alpha_2;}c=dither(c,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=vec4(c,a);}`,`attribute vec3 a_pos;attribute vec2 a_uv;uniform vec3 u_frustum_tl;uniform vec3 u_frustum_tr;uniform vec3 u_frustum_br;uniform vec3 u_frustum_bl;uniform float u_horizon;varying highp vec3 v_ray_dir;varying highp vec3 v_horizon_dir;void main() {v_ray_dir=mix(
mix(u_frustum_tl,u_frustum_tr,a_uv.x),mix(u_frustum_bl,u_frustum_br,a_uv.x),a_uv.y);v_horizon_dir=mix(
mix(u_frustum_tl,u_frustum_bl,u_horizon),mix(u_frustum_tr,u_frustum_br,u_horizon),a_uv.x);gl_Position=vec4(a_pos,1.0);}`)};function ls(p,o){const u=p.replace(/\s*\/\/[^\n]*\n/g,`
`).split(`
`);for(let y of u)if(y=y.trim(),y[0]==="#"&&y.includes("if")&&!y.includes("endif")){y=y.replace("#","").replace(/ifdef|ifndef|elif|if/g,"").replace(/!|defined|\(|\)|\|\||&&/g,"").replace(/\s+/g," ").trim();const b=y.split(" ");for(const M of b)o.includes(M)||o.push(M)}}function Bi(p,o){const u=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,y=o.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),b={},M=[...Bs];return ls(p,M),ls(o,M),{fragmentSource:p=p.replace(u,(R,z,V,X,q)=>(b[q]=!0,z==="define"?`
#ifndef HAS_UNIFORM_u_${q}
varying ${V} ${X} ${q};
#else
uniform ${V} ${X} u_${q};
#endif
`:`
#ifdef HAS_UNIFORM_u_${q}
    ${V} ${X} ${q} = u_${q};
#endif
`)),vertexSource:o=o.replace(u,(R,z,V,X,q)=>{const Q=X==="float"?"vec2":"vec4",he=q.match(/color/)?"color":Q;return b[q]?z==="define"?`
#ifndef HAS_UNIFORM_u_${q}
uniform lowp float u_${q}_t;
attribute ${V} ${Q} a_${q};
varying ${V} ${X} ${q};
#else
uniform ${V} ${X} u_${q};
#endif
`:he==="vec4"?`
#ifndef HAS_UNIFORM_u_${q}
    ${q} = a_${q};
#else
    ${V} ${X} ${q} = u_${q};
#endif
`:`
#ifndef HAS_UNIFORM_u_${q}
    ${q} = unpack_mix_${he}(a_${q}, u_${q}_t);
#else
    ${V} ${X} ${q} = u_${q};
#endif
`:z==="define"?`
#ifndef HAS_UNIFORM_u_${q}
uniform lowp float u_${q}_t;
attribute ${V} ${Q} a_${q};
#else
uniform ${V} ${X} u_${q};
#endif
`:he==="vec4"?`
#ifndef HAS_UNIFORM_u_${q}
    ${V} ${X} ${q} = a_${q};
#else
    ${V} ${X} ${q} = u_${q};
#endif
`:`
#ifndef HAS_UNIFORM_u_${q}
    ${V} ${X} ${q} = unpack_mix_${he}(a_${q}, u_${q}_t);
#else
    ${V} ${X} ${q} = u_${q};
#endif
`}),staticAttributes:y,usedDefines:M}}class uc{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(o,u,y,b,M,R,z){this.context=o;let V=this.boundPaintVertexBuffers.length!==b.length;for(let q=0;!V&&q<b.length;q++)this.boundPaintVertexBuffers[q]!==b[q]&&(V=!0);let X=this.boundDynamicVertexBuffers.length!==z.length;for(let q=0;!X&&q<z.length;q++)this.boundDynamicVertexBuffers[q]!==z[q]&&(X=!0);if(!o.extVertexArrayObject||!this.vao||this.boundProgram!==u||this.boundLayoutVertexBuffer!==y||V||X||this.boundIndexBuffer!==M||this.boundVertexOffset!==R)this.freshBind(u,y,b,M,R,z);else{o.bindVertexArrayOES.set(this.vao);for(const q of z)q&&q.bind();M&&M.dynamicDraw&&M.bind()}}freshBind(o,u,y,b,M,R){let z;const V=o.numAttributes,X=this.context,q=X.gl;if(X.extVertexArrayObject)this.vao&&this.destroy(),this.vao=X.extVertexArrayObject.createVertexArrayOES(),X.bindVertexArrayOES.set(this.vao),z=0,this.boundProgram=o,this.boundLayoutVertexBuffer=u,this.boundPaintVertexBuffers=y,this.boundIndexBuffer=b,this.boundVertexOffset=M,this.boundDynamicVertexBuffers=R;else{z=X.currentNumAttributes||0;for(let Q=V;Q<z;Q++)q.disableVertexAttribArray(Q)}u.enableAttributes(q,o),u.bind(),u.setVertexAttribPointers(q,o,M);for(const Q of y)Q.enableAttributes(q,o),Q.bind(),Q.setVertexAttribPointers(q,o,M);for(const Q of R)Q&&(Q.enableAttributes(q,o),Q.bind(),Q.setVertexAttribPointers(q,o,M));b&&b.bind(),X.currentNumAttributes=V}destroy(){this.vao&&(this.context.extVertexArrayObject.deleteVertexArrayOES(this.vao),this.vao=null)}}function hc(p,o){const u=Math.pow(2,o.canonical.z),y=o.canonical.y;return[new i.MercatorCoordinate(0,y/u).toLngLat().lat,new i.MercatorCoordinate(0,(y+1)/u).toLngLat().lat]}function Cs(p,o,u,y,b,M,R){const z=p.context,V=z.gl,X=u.fbo;if(!X)return;p.prepareDrawTile();const q=p.useProgram("hillshade");z.activeTexture.set(V.TEXTURE0),V.bindTexture(V.TEXTURE_2D,X.colorAttachment.get());const Q=((_e,be,ie,pe)=>{const Ee=ie.paint.get("hillshade-shadow-color"),Te=ie.paint.get("hillshade-highlight-color"),Ue=ie.paint.get("hillshade-accent-color");let Ge=ie.paint.get("hillshade-illumination-direction")*(Math.PI/180);ie.paint.get("hillshade-illumination-anchor")==="viewport"&&(Ge-=_e.transform.angle);const Ve=!_e.options.moving;return{u_matrix:pe||_e.transform.calculateProjMatrix(be.tileID.toUnwrapped(),Ve),u_image:0,u_latrange:hc(0,be.tileID),u_light:[ie.paint.get("hillshade-exaggeration"),Ge],u_shadow:Ee,u_highlight:Te,u_accent:Ue}})(p,u,y,p.terrain?o.projMatrix:null);p.prepareDrawProgram(z,q,o.toUnwrapped());const{tileBoundsBuffer:he,tileBoundsIndexBuffer:me,tileBoundsSegments:ge}=p.getTileBoundsBuffers(u);q.draw(z,V.TRIANGLES,b,M,R,i.CullFaceMode.disabled,Q,y.id,he,me,ge)}function Go(p,o,u){if(!o.needsDEMTextureUpload)return;const y=p.context,b=y.gl;y.pixelStoreUnpackPremultiplyAlpha.set(!1),o.demTexture=o.demTexture||p.getTileTexture(u.stride);const M=u.getPixels();o.demTexture?o.demTexture.update(M,{premultiply:!1}):o.demTexture=new i.Texture(y,M,b.RGBA,{premultiply:!1}),o.needsDEMTextureUpload=!1}function Fl(p,o,u,y,b,M){const R=p.context,z=R.gl;if(!o.dem)return;const V=o.dem;if(R.activeTexture.set(z.TEXTURE1),Go(p,o,V),!o.demTexture)return;o.demTexture.bind(z.NEAREST,z.CLAMP_TO_EDGE);const X=V.dim;R.activeTexture.set(z.TEXTURE0);let q=o.fbo;if(!q){const ge=new i.Texture(R,{width:X,height:X,data:null},z.RGBA);ge.bind(z.LINEAR,z.CLAMP_TO_EDGE),q=o.fbo=R.createFramebuffer(X,X,!0),q.colorAttachment.set(ge.texture)}R.bindFramebuffer.set(q.framebuffer),R.viewport.set([0,0,X,X]);const{tileBoundsBuffer:Q,tileBoundsIndexBuffer:he,tileBoundsSegments:me}=p.getMercatorTileBoundsBuffers();p.useProgram("hillshadePrepare").draw(R,z.TRIANGLES,y,b,M,i.CullFaceMode.disabled,((ge,_e)=>{const be=_e.stride,ie=i.create();return i.ortho(ie,0,i.EXTENT,-i.EXTENT,0,0,1),i.translate(ie,ie,[0,-i.EXTENT,0]),{u_matrix:ie,u_image:1,u_dimension:[be,be],u_zoom:ge.overscaledZ,u_unpack:_e.unpackVector}})(o.tileID,V),u.id,Q,he,me),o.needsHillshadePrepare=!1}const dc=p=>({u_matrix:new i.UniformMatrix4f(p),u_image0:new i.Uniform1i(p),u_skirt_height:new i.Uniform1f(p)}),jo=(p,o)=>({u_matrix:p,u_image0:0,u_skirt_height:o}),fa=(p,o,u,y,b,M,R,z,V,X,q,Q,he,me,ge)=>({u_proj_matrix:Float32Array.from(p),u_globe_matrix:o,u_normalize_matrix:Float32Array.from(y),u_merc_matrix:u,u_zoom_transition:b,u_merc_center:M,u_image0:0,u_frustum_tl:R,u_frustum_tr:z,u_frustum_br:V,u_frustum_bl:X,u_globe_pos:q,u_globe_radius:Q,u_viewport:he,u_grid_matrix:ge?Float32Array.from(ge):new Float32Array(9),u_skirt_height:me});function pa(p,o){return p!=null&&o!=null&&!(!p.hasData()||!o.hasData())&&p.demTexture!=null&&o.demTexture!=null&&p.tileID.key!==o.tileID.key}const go=new class{constructor(){this.operations={}}newMorphing(p,o,u,y,b){if(p in this.operations){const M=this.operations[p];M.to.tileID.key!==u.tileID.key&&(M.queued=u)}else this.operations[p]={startTime:y,phase:0,duration:b,from:o,to:u,queued:null}}getMorphValuesForProxy(p){if(!(p in this.operations))return null;const o=this.operations[p];return{from:o.from,to:o.to,phase:o.phase}}update(p){for(const o in this.operations){const u=this.operations[o];for(u.phase=(p-u.startTime)/u.duration;u.phase>=1||!this._validOp(u);)if(!this._nextOp(u,p)){delete this.operations[o];break}}}_nextOp(p,o){return!!p.queued&&(p.from=p.to,p.to=p.queued,p.queued=null,p.phase=0,p.startTime=o,!0)}_validOp(p){return p.from.hasData()&&p.to.hasData()}},Po={0:null,1:"TERRAIN_VERTEX_MORPHING",2:"TERRAIN_WIREFRAME"};function ma(p){return 6*Math.pow(1.5,22-p)}function qc(p,o){const u=1<<p.z;return!o&&(p.x===0||p.x===u-1)||p.y===0||p.y===u-1}const yl=p=>({u_matrix:p});function Bl(p,o,u,y,b){if(b>0){const M=i.exported.now(),R=(M-p.timeAdded)/b,z=o?(M-o.timeAdded)/b:-1,V=u.getSource(),X=y.coveringZoomLevel({tileSize:V.tileSize,roundZoom:V.roundZoom}),q=!o||Math.abs(o.tileID.overscaledZ-X)>Math.abs(p.tileID.overscaledZ-X),Q=q&&p.refreshedUponExpiration?1:i.clamp(q?R:1-z,0,1);return p.refreshedUponExpiration&&R>=1&&(p.refreshedUponExpiration=!1),o?{opacity:1,mix:1-Q}:{opacity:Q,mix:0}}return{opacity:1,mix:0}}class Oa extends i.SourceCache{constructor(o){const u={type:"raster-dem",maxzoom:o.transform.maxZoom},y=new tt(Ni(),null),b=Qe("mock-dem",u,y,o.style);super("mock-dem",b,!1),b.setEventedParent(this),this._sourceLoaded=!0}_loadTile(o,u){o.state="loaded",u(null)}}class ga extends i.SourceCache{constructor(o){const u=Qe("proxy",{type:"geojson",maxzoom:o.transform.maxZoom},new tt(Ni(),null),o.style);super("proxy",u,!1),u.setEventedParent(this),this.map=this.getSource().map=o,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(o,u,y){if(o.freezeTileCoverage)return;this.transform=o;const b=o.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((M,R)=>{if(M[R.key]="",!this._tiles[R.key]){const z=new i.Tile(R,this._source.tileSize*R.overscaleFactor(),o.tileZoom);z.state="loaded",this._tiles[R.key]=z}return M},{});for(const M in this._tiles)M in b||(this.freeFBO(M),this._tiles[M].unloadVectorData(),delete this._tiles[M])}freeFBO(o){const u=this.proxyCachedFBO[o];if(u!==void 0){const y=Object.values(u);this.renderCachePool.push(...y),delete this.proxyCachedFBO[o]}}deallocRenderCache(){this.renderCache.forEach(o=>o.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class Fa extends i.OverscaledTileID{constructor(o,u,y){super(o.overscaledZ,o.wrap,o.canonical.z,o.canonical.x,o.canonical.y),this.proxyTileKey=u,this.projMatrix=y}}class Ba extends i.Elevation{constructor(o,u){super(),this.painter=o,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[y,b,M]=function(V){const X=new i.StructArrayLayout2i4,q=new i.StructArrayLayout3ui6,Q=131;X.reserve(17161),q.reserve(33800);const he=i.EXTENT/128,me=i.EXTENT+he/2,ge=me+he;for(let be=-he;be<ge;be+=he)for(let ie=-he;ie<ge;ie+=he){const pe=ie<0||ie>me||be<0||be>me?24575:0,Ee=i.clamp(Math.round(ie),0,i.EXTENT),Te=i.clamp(Math.round(be),0,i.EXTENT);X.emplaceBack(Ee+pe,Te)}const _e=(be,ie)=>{const pe=ie*Q+be;q.emplaceBack(pe+1,pe,pe+Q),q.emplaceBack(pe+Q,pe+Q+1,pe+1)};for(let be=1;be<129;be++)for(let ie=1;ie<129;ie++)_e(ie,be);return[0,129].forEach(be=>{for(let ie=0;ie<130;ie++)_e(ie,be),_e(be,ie)}),[X,q,32768]}(),R=o.context;this.gridBuffer=R.createVertexBuffer(y,i.posAttributes.members),this.gridIndexBuffer=R.createIndexBuffer(b),this.gridSegments=i.SegmentVector.simpleSegment(0,0,y.length,b.length),this.gridNoSkirtSegments=i.SegmentVector.simpleSegment(0,0,y.length,M),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new ga(u.map),this.orthoMatrix=i.create(),i.ortho(this.orthoMatrix,this.painter.transform.projection.name==="globe"?.015:0,i.EXTENT,0,i.EXTENT,0,1);const z=R.gl;this._overlapStencilMode=new i.StencilMode({func:z.GEQUAL,mask:255},0,255,z.KEEP,z.KEEP,z.REPLACE),this._previousZoom=o.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=u,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new Oa(u.map)}set style(o){o.on("data",this._onStyleDataEvent.bind(this)),o.on("neworder",this._checkRenderCacheEfficiency.bind(this)),this._style=o,this._checkRenderCacheEfficiency(),this._style.map.on("moveend",()=>{this._clearLineLayersFromRenderCache()})}update(o,u,y){if(o&&o.terrain){this._style!==o&&(this.style=o),this.enabled=!0;const b=o.terrain.properties;this.sourceCache=o.terrain.drapeRenderMode===0?this._mockSourceCache:o._getSourceCache(b.get("source")),this._exaggeration=b.get("exaggeration");const M=()=>{this.sourceCache.used&&i.warnOnce(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source.
This leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const R=this.getScaledDemTileSize();this.sourceCache.update(u,R,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,M(),this._initializing=!0),M(),u.updateElevation(!0,y),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(u),this._emptyDEMTextureDirty=!0}else this._disable()}resetTileLookupCache(o){this._findCoveringTileCache[o]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_checkRenderCacheEfficiency(){const o=this.renderCacheEfficiency(this._style);this._style.map._optimizeForTerrain||o.efficiency!==100&&i.warnOnce(`Terrain render cache efficiency is not optimal (${o.efficiency}%) and performance
                may be affected negatively, consider placing all background, fill and line layers before layer
                with id '${o.firstUndrapedLayer}' or create a map using optimizeForTerrain: true option.`)}_onStyleDataEvent(o){o.coord&&o.dataType==="source"?this._clearRenderCacheForTile(o.sourceCacheId,o.coord):o.dataType==="style"&&(this._invalidateRenderCache=!0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const o in this._style._sourceCaches)this._style._sourceCaches[o].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach(o=>o.fb.destroy()),this.pool=[],this._depthFBO&&(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0)}_source(){return this.enabled?this.sourceCache:null}isUsingMockSource(){return this.sourceCache===this._mockSourceCache}exaggeration(){return this._exaggeration}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const o=2*this.proxySourceCache.getSource().tileSize;return[o,o]}set useVertexMorphing(o){this._useVertexMorphing=o}updateTileBinding(o){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const u=this.proxySourceCache,y=this.painter.transform;this._initializing&&(this._initializing=y._centerAltitude===0&&this.getAtPointOrZero(i.MercatorCoordinate.fromLngLat(y.center),-1)===-1,this._emptyDEMTextureDirty=!this._initializing);const b=this.proxyCoords=u.getIds().map(V=>{const X=u.getTileByID(V).tileID;return X.projMatrix=y.calculateProjMatrix(X.toUnwrapped()),X});(function(V,X){const q=X.transform.pointCoordinate(X.transform.getCameraPoint()),Q=new i.Point(q.x,q.y);V.sort((he,me)=>{if(me.overscaledZ-he.overscaledZ)return me.overscaledZ-he.overscaledZ;const ge=new i.Point(he.canonical.x+(1<<he.canonical.z)*he.wrap,he.canonical.y),_e=new i.Point(me.canonical.x+(1<<me.canonical.z)*me.wrap,me.canonical.y),be=Q.mult(1<<he.canonical.z);return be.x-=.5,be.y-=.5,be.distSqr(ge)-be.distSqr(_e)})})(b,this.painter),this._previousZoom=y.zoom;const M=this.proxyToSource||{};this.proxyToSource={},b.forEach(V=>{this.proxyToSource[V.key]={}}),this.terrainTileForTile={};const R=this._style._sourceCaches;for(const V in R){const X=R[V];if(!X.used||(X!==this.sourceCache&&this.resetTileLookupCache(X.id),this._setupProxiedCoordsForOrtho(X,o[V],M),X.usedForTerrain))continue;const q=o[V];X.getSource().reparseOverscaled&&this._assignTerrainTiles(q)}this.proxiedCoords[u.id]=b.map(V=>new Fa(V,V.key,this.orthoMatrix)),this._assignTerrainTiles(b),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(M),this.renderingToTexture=!1,this._updateTimestamp=i.exported.now();const z={};this._visibleDemTiles=[];for(const V of this.proxyCoords){const X=this.terrainTileForTile[V.key];if(!X)continue;const q=X.tileID.key;q in z||(this._visibleDemTiles.push(X),z[q]=q)}}_assignTerrainTiles(o){this._initializing||o.forEach(u=>{if(this.terrainTileForTile[u.key])return;const y=this._findTileCoveringTileID(u,this.sourceCache);y&&(this.terrainTileForTile[u.key]=y)})}_prepareDEMTextures(){const o=this.painter.context,u=o.gl;for(const y in this.terrainTileForTile){const b=this.terrainTileForTile[y],M=b.dem;!M||b.demTexture&&!b.needsDEMTextureUpload||(o.activeTexture.set(u.TEXTURE1),Go(this.painter,b,M))}}_prepareDemTileUniforms(o,u,y,b){if(!u||u.demTexture==null)return!1;const M=o.tileID.canonical,R=Math.pow(2,u.tileID.canonical.z-M.z),z=b||"";return y[`u_dem_tl${z}`]=[M.x*R%1,M.y*R%1],y[`u_dem_scale${z}`]=R,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const o=this.painter.context,u=o.gl;if(!this._emptyDepthBufferTexture){const y=new i.RGBAImage({width:1,height:1},Uint8Array.of(255,255,255,255));this._emptyDepthBufferTexture=new i.Texture(o,y,u.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let o=0;const u=this._visibleDemTiles.reduce((y,b)=>{if(!b.dem)return y;const M=b.dem.tree.minimums[0];return M>0&&o++,y+M},0);return o?u/o:0}_updateEmptyDEMTexture(){const o=this.painter.context,u=o.gl;o.activeTexture.set(u.TEXTURE2);const y=this._getLoadedAreaMinimum(),b=new i.RGBAImage({width:1,height:1},new Uint8Array(i.DEMData.pack(y,this.sourceCache.getSource().encoding)));this._emptyDEMTextureDirty=!1;let M=this._emptyDEMTexture;return M?M.update(b,{premultiply:!1}):M=this._emptyDEMTexture=new i.Texture(o,b,u.RGBA,{premultiply:!1}),M}setupElevationDraw(o,u,y){const b=this.painter.context,M=b.gl,R=(z=this.sourceCache.getSource().encoding,{u_dem:2,u_dem_prev:4,u_dem_unpack:i.DEMData.getUnpackVector(z),u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_exaggeration:0});var z;R.u_dem_size=this.sourceCache.getSource().tileSize,R.u_exaggeration=this.exaggeration();let V=null,X=null,q=1;if(y&&y.morphing&&this._useVertexMorphing){const Q=y.morphing.srcDemTile,he=y.morphing.dstDemTile;q=y.morphing.phase,Q&&he&&(this._prepareDemTileUniforms(o,Q,R,"_prev")&&(X=Q),this._prepareDemTileUniforms(o,he,R)&&(V=he))}if(X&&V?(b.activeTexture.set(M.TEXTURE2),V.demTexture.bind(M.NEAREST,M.CLAMP_TO_EDGE,M.NEAREST),b.activeTexture.set(M.TEXTURE4),X.demTexture.bind(M.NEAREST,M.CLAMP_TO_EDGE,M.NEAREST),R.u_dem_lerp=q):(V=this.terrainTileForTile[o.tileID.key],b.activeTexture.set(M.TEXTURE2),(this._prepareDemTileUniforms(o,V,R)?V.demTexture:this.emptyDEMTexture).bind(M.NEAREST,M.CLAMP_TO_EDGE)),b.activeTexture.set(M.TEXTURE3),y&&y.useDepthForOcclusion?(this._depthTexture&&this._depthTexture.bind(M.NEAREST,M.CLAMP_TO_EDGE),this._depthFBO&&(R.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height])):(this.emptyDepthBufferTexture.bind(M.NEAREST,M.CLAMP_TO_EDGE),R.u_depth_size_inv=[1,1]),y&&y.useMeterToDem&&V){const Q=(1<<V.tileID.canonical.z)*i.mercatorZfromAltitude(1,this.painter.transform.center.lat)*this.sourceCache.getSource().tileSize;R.u_meter_to_dem=Q}if(y&&y.labelPlaneMatrixInv&&(R.u_label_plane_matrix_inv=y.labelPlaneMatrixInv),u.setTerrainUniformValues(b,R),this.painter.transform.projection.name==="globe"){const Q=this.globeUniformValues(this.painter.transform,o.tileID.canonical,y&&y.useDenormalizedUpVectorScale);u.setGlobeUniformValues(b,Q)}}globeUniformValues(o,u,y){const b=o.projection;return{u_tile_tl_up:b.upVector(u,0,0),u_tile_tr_up:b.upVector(u,i.EXTENT,0),u_tile_br_up:b.upVector(u,i.EXTENT,i.EXTENT),u_tile_bl_up:b.upVector(u,0,i.EXTENT),u_tile_up_scale:y?i.globeMetersToEcef(1):b.upVectorScale(u,o.center.lat,o.worldSize).metersToTile}}renderToBackBuffer(o){const u=this.painter,y=this.painter.context;o.length!==0&&(y.bindFramebuffer.set(null),y.viewport.set([0,0,u.width,u.height]),u.gpuTimingDeferredRenderStart(),this.renderingToTexture=!1,function(b,M,R,z,V){if(b.transform.projection.name==="globe")(function(X,q,Q,he,me){const ge=X.context,_e=ge.gl;let be,ie;const pe=X.options.showTerrainWireframe?2:0,Ee=X.transform,Te=i.globeUseCustomAntiAliasing(X,ge,Ee),Ue=(Xt,gt)=>{if(ie===Xt)return;const Ot=[Po[Xt],"PROJECTION_GLOBE_VIEW"];Te&&Ot.push("CUSTOM_ANTIALIASING"),gt&&Ot.push(Po[pe]),be=X.useProgram("globeRaster",null,Ot),ie=Xt},Ge=X.colorModeForRenderPass(),Ve=new i.DepthMode(_e.LEQUAL,i.DepthMode.ReadWrite,X.depthRangeFor3D);go.update(me);const et=i.calculateGlobeMercatorMatrix(Ee),$e=[i.mercatorXfromLng(Ee.center.lng),i.mercatorYfromLat(Ee.center.lat)],ht=pe?[!1,!0]:[!1],Jt=X.globeSharedBuffers,ut=[Ee.width*i.exported.devicePixelRatio,Ee.height*i.exported.devicePixelRatio],Bt=Float32Array.from(Ee.globeMatrix),yt={useDenormalizedUpVectorScale:!0};if(ht.forEach(Xt=>{const gt=X.transform,Ot=ma(gt.zoom)*q.exaggeration();ie=-1;const Qt=Xt?_e.LINES:_e.TRIANGLES;for(const Lt of he){const Ct=Q.getTile(Lt),zn=i.StencilMode.disabled,qn=q.prevTerrainTileForTile[Lt.key],vn=q.terrainTileForTile[Lt.key];pa(qn,vn)&&go.newMorphing(Lt.key,qn,vn,me,250),ge.activeTexture.set(_e.TEXTURE0),Ct.texture.bind(_e.LINEAR,_e.CLAMP_TO_EDGE);const Vn=go.getMorphValuesForProxy(Lt.key),Ai=Vn?1:0;Vn&&i.extend$1(yt,{morphing:{srcDemTile:Vn.from,dstDemTile:Vn.to,phase:i.easeCubicInOut(Vn.phase)}});const si=i.tileCornersToBounds(Lt.canonical),Gn=i.getLatitudinalLod(si.getCenter().lat),$i=i.getGridMatrix(Lt.canonical,si,Gn,gt.worldSize/gt._pixelsPerMercatorPixel),hr=i.globeNormalizeECEF(i.globeTileBounds(Lt.canonical)),mr=fa(gt.projMatrix,Bt,et,hr,i.globeToMercatorTransition(gt.zoom),$e,gt.frustumCorners.TL,gt.frustumCorners.TR,gt.frustumCorners.BR,gt.frustumCorners.BL,gt.globeCenterInViewSpace,gt.globeRadius,ut,Ot,$i);if(Ue(Ai,Xt),q.setupElevationDraw(Ct,be,yt),X.prepareDrawProgram(ge,be,Lt.toUnwrapped()),Jt){const[ar,xr,us]=Xt?Jt.getWirefameBuffers(X.context,Gn):Jt.getGridBuffers(Gn,Ot!==0);be.draw(ge,Qt,Ve,zn,Ge,i.CullFaceMode.backCCW,mr,"globe_raster",ar,xr,us)}}}),Jt){const Xt=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];Te&&Xt.push("CUSTOM_ANTIALIASING"),be=X.useProgram("globeRaster",null,Xt);for(const gt of he){const{x:Ot,y:Qt,z:Lt}=gt.canonical,Ct=Qt===0,zn=Qt===(1<<Lt)-1,[qn,vn,Vn,Ai]=Jt.getPoleBuffers(Lt);if(Ai&&(Ct||zn)){const si=Q.getTile(gt);ge.activeTexture.set(_e.TEXTURE0),si.texture.bind(_e.LINEAR,_e.CLAMP_TO_EDGE);let Gn=i.globePoleMatrixForTile(Lt,Ot,Ee);const $i=i.globeNormalizeECEF(i.globeTileBounds(gt.canonical)),hr=(mr,ar)=>mr.draw(ge,_e.TRIANGLES,Ve,i.StencilMode.disabled,Ge,i.CullFaceMode.disabled,fa(Ee.projMatrix,Gn,Gn,$i,0,$e,Ee.frustumCorners.TL,Ee.frustumCorners.TR,Ee.frustumCorners.BR,Ee.frustumCorners.BL,Ee.globeCenterInViewSpace,Ee.globeRadius,ut,0),"globe_pole_raster",ar,Vn,Ai);q.setupElevationDraw(si,be,yt),X.prepareDrawProgram(ge,be,gt.toUnwrapped()),Ct&&hr(be,qn),zn&&(Gn=i.scale(i.create(),Gn,[1,-1,1]),hr(be,vn))}}}})(b,M,R,z,V);else{const X=b.context,q=X.gl;let Q,he;const me=b.options.showTerrainWireframe?2:0,ge=(Ee,Te)=>{if(he===Ee)return;const Ue=[Po[Ee]];Te&&Ue.push(Po[me]),Q=b.useProgram("terrainRaster",null,Ue),he=Ee},_e=b.colorModeForRenderPass(),be=new i.DepthMode(q.LEQUAL,i.DepthMode.ReadWrite,b.depthRangeFor3D);go.update(V);const ie=b.transform,pe=ma(ie.zoom)*M.exaggeration();(me?[!1,!0]:[!1]).forEach(Ee=>{he=-1;const Te=Ee?q.LINES:q.TRIANGLES,[Ue,Ge]=Ee?M.getWirefameBuffer():[M.gridIndexBuffer,M.gridSegments];for(const Ve of z){const et=R.getTile(Ve),$e=i.StencilMode.disabled,ht=M.prevTerrainTileForTile[Ve.key],Jt=M.terrainTileForTile[Ve.key];pa(ht,Jt)&&go.newMorphing(Ve.key,ht,Jt,V,250),X.activeTexture.set(q.TEXTURE0),et.texture.bind(q.LINEAR,q.CLAMP_TO_EDGE,q.LINEAR_MIPMAP_NEAREST);const ut=go.getMorphValuesForProxy(Ve.key),Bt=ut?1:0;let yt;ut&&(yt={morphing:{srcDemTile:ut.from,dstDemTile:ut.to,phase:i.easeCubicInOut(ut.phase)}});const Xt=jo(Ve.projMatrix,qc(Ve.canonical,ie.renderWorldCopies)?pe/10:pe);ge(Bt,Ee),M.setupElevationDraw(et,Q,yt),b.prepareDrawProgram(X,Q,Ve.toUnwrapped()),Q.draw(X,Te,be,$e,_e,i.CullFaceMode.backCCW,Xt,"terrain_raster",M.gridBuffer,Ue,Ge)}})}}(u,this,this.proxySourceCache,o,this._updateTimestamp),this.renderingToTexture=!0,u.gpuTimingDeferredRenderEnd(),o.splice(0,o.length))}renderBatch(o){if(this._drapedRenderBatches.length===0)return o+1;this.renderingToTexture=!0;const u=this.painter,y=this.painter.context,b=this.proxySourceCache,M=this.proxiedCoords[b.id],R=this._drapedRenderBatches.shift(),z=[],V=u.style.order;let X=0;for(const q of M){const Q=b.getTileByID(q.proxyTileKey),he=b.proxyCachedFBO[q.key]?b.proxyCachedFBO[q.key][o]:void 0,me=he!==void 0?b.renderCache[he]:this.pool[X++],ge=he!==void 0;if(Q.texture=me.tex,ge&&!me.dirty){z.push(Q.tileID);continue}let _e;y.bindFramebuffer.set(me.fb.framebuffer),this.renderedToTile=!1,me.dirty&&(y.clear({color:i.Color.transparent,stencil:0}),me.dirty=!1);for(let be=R.start;be<=R.end;++be){const ie=u.style._layers[V[be]];if(ie.isHidden(u.transform.zoom))continue;const pe=u.style._getLayerSourceCache(ie),Ee=pe?this.proxyToSource[q.key][pe.id]:[q];if(!Ee)continue;const Te=Ee;y.viewport.set([0,0,me.fb.width,me.fb.height]),_e!==(pe?pe.id:null)&&(this._setupStencil(me,Ee,ie,pe),_e=pe?pe.id:null),u.renderLayer(u,pe,ie,Te)}this.renderedToTile?(me.dirty=!0,z.push(Q.tileID)):ge||--X,X===5&&(X=0,this.renderToBackBuffer(z))}return this.renderToBackBuffer(z),this.renderingToTexture=!1,y.bindFramebuffer.set(null),y.viewport.set([0,0,u.width,u.height]),R.end+1}postRender(){}renderCacheEfficiency(o){const u=o.order.length;if(u===0)return{efficiency:100};let y,b=0,M=0,R=!1;for(let z=0;z<u;++z){const V=o._layers[o.order[z]];this._style.isLayerDraped(V)?(R&&++b,++M):R||(R=!0,y=V.id)}return M===0?{efficiency:100}:{efficiency:100*(1-b/M),firstUndrapedLayer:y}}getMinElevationBelowMSL(){let o=0;return this._visibleDemTiles.filter(u=>u.dem).forEach(u=>{o=Math.min(o,u.dem.tree.minimums[0])}),o===0?o:(o-30)*this._exaggeration}raycast(o,u,y){if(!this._visibleDemTiles)return null;const b=this._visibleDemTiles.filter(M=>M.dem).map(M=>{const R=M.tileID,z=1<<R.overscaledZ,{x:V,y:X}=R.canonical,q=V/z,Q=(V+1)/z,he=X/z,me=(X+1)/z;return{minx:q,miny:he,maxx:Q,maxy:me,t:M.dem.tree.raycastRoot(q,he,Q,me,o,u,y),tile:M}});b.sort((M,R)=>(M.t!==null?M.t:Number.MAX_VALUE)-(R.t!==null?R.t:Number.MAX_VALUE));for(const M of b){if(M.t==null)return null;const R=M.tile.dem.tree.raycast(M.minx,M.miny,M.maxx,M.maxy,o,u,y);if(R!=null)return R}return null}_createFBO(){const o=this.painter.context,u=o.gl,y=this.drapeBufferSize;o.activeTexture.set(u.TEXTURE0);const b=new i.Texture(o,{width:y[0],height:y[1],data:null},u.RGBA);b.bind(u.LINEAR,u.CLAMP_TO_EDGE);const M=o.createFramebuffer(y[0],y[1],!1);return M.colorAttachment.set(b.texture),M.depthAttachment=new He(o,M.framebuffer),this._sharedDepthStencil===void 0?(this._sharedDepthStencil=o.createRenderbuffer(o.gl.DEPTH_STENCIL,y[0],y[1]),this._stencilRef=0,M.depthAttachment.set(this._sharedDepthStencil),o.clear({stencil:0})):M.depthAttachment.set(this._sharedDepthStencil),o.extTextureFilterAnisotropic&&!o.extTextureFilterAnisotropicForceOff&&u.texParameterf(u.TEXTURE_2D,o.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,o.extTextureFilterAnisotropicMax),{fb:M,tex:b,dirty:!1}}_initFBOPool(){for(;this.pool.length<Math.min(5,this.proxyCoords.length);)this.pool.push(this._createFBO())}_shouldDisableRenderCache(){if(this._style.light&&this._style.light.hasTransition())return!0;for(const o in this._style._sourceCaches)if(this._style._sourceCaches[o].hasTransition())return!0;return this._style.order.some(o=>{const u=this._style._layers[o],y=u.isHidden(this.painter.transform.zoom);return u.type==="custom"?!y&&u.shouldRedrape():!y&&u.hasTransition()})}_clearLineLayersFromRenderCache(){let o=!1;for(const y of this._style._getSources())if(y instanceof on){o=!0;break}if(!o)return;const u={};for(let y=0;y<this._style.order.length;++y){const b=this._style._layers[this._style.order[y]],M=this._style._getLayerSourceCache(b);if(M&&!u[M.id]&&!b.isHidden(this.painter.transform.zoom)&&b.type==="line"&&b.widthExpression()instanceof i.ZoomDependentExpression){u[M.id]=!0;for(const R of this.proxyCoords){const z=this.proxyToSource[R.key][M.id];if(z)for(const V of z)this._clearRenderCacheForTile(M.id,V)}}}}_clearRasterLayersFromRenderCache(){let o=!1;for(const y in this._style._sourceCaches)if(this._style._sourceCaches[y]._source instanceof Kt){o=!0;break}if(!o)return;const u={};for(let y=0;y<this._style.order.length;++y){const b=this._style._layers[this._style.order[y]],M=this._style._getLayerSourceCache(b);if(!M||u[M.id]||b.isHidden(this.painter.transform.zoom)||b.type!=="raster")continue;const R=b.paint.get("raster-fade-duration");for(const z of this.proxyCoords){const V=this.proxyToSource[z.key][M.id];if(V)for(const X of V){const q=Bl(M.getTile(X),M.findLoadedParent(X,0),M,this.painter.transform,R);(q.opacity!==1||q.mix!==0)&&this._clearRenderCacheForTile(M.id,X)}}}}_setupDrapedRenderBatches(){const o=this._style.order,u=o.length;if(u===0)return;const y=[];let b,M=0,R=this._style._layers[o[M]];for(;!this._style.isLayerDraped(R)&&R.isHidden(this.painter.transform.zoom)&&++M<u;)R=this._style._layers[o[M]];for(;M<u;++M){const z=this._style._layers[o[M]];z.isHidden(this.painter.transform.zoom)||(this._style.isLayerDraped(z)?b===void 0&&(b=M):b!==void 0&&(y.push({start:b,end:M-1}),b=void 0))}b!==void 0&&y.push({start:b,end:M-1}),this._drapedRenderBatches=y}_setupRenderCache(o){const u=this.proxySourceCache;if(this._shouldDisableRenderCache()||this._invalidateRenderCache){if(this._invalidateRenderCache=!1,u.renderCache.length>u.renderCachePool.length){const R=Object.values(u.proxyCachedFBO);u.proxyCachedFBO={};for(let z=0;z<R.length;++z){const V=Object.values(R[z]);u.renderCachePool.push(...V)}}return}this._clearRasterLayersFromRenderCache();const y=this.proxyCoords,b=this._tilesDirty;for(let R=y.length-1;R>=0;R--){const z=y[R];if(u.getTileByID(z.key),u.proxyCachedFBO[z.key]!==void 0){const V=o[z.key],X=this.proxyToSource[z.key];let q=0;for(const Q in X){const he=X[Q],me=V[Q];if(!me||me.length!==he.length||he.some((ge,_e)=>ge!==me[_e]||b[Q]&&b[Q].hasOwnProperty(ge.key))){q=-1;break}++q}for(const Q in u.proxyCachedFBO[z.key])u.renderCache[u.proxyCachedFBO[z.key][Q]].dirty=q<0||q!==Object.values(V).length}}const M=[...this._drapedRenderBatches];M.sort((R,z)=>z.end-z.start-(R.end-R.start));for(const R of M)for(const z of y){if(u.proxyCachedFBO[z.key])continue;let V=u.renderCachePool.pop();V===void 0&&u.renderCache.length<50&&(V=u.renderCache.length,u.renderCache.push(this._createFBO())),V!==void 0&&(u.proxyCachedFBO[z.key]={},u.proxyCachedFBO[z.key][R.start]=V,u.renderCache[V].dirty=!0)}this._tilesDirty={}}_setupStencil(o,u,y,b){if(!b||!this._sourceTilesOverlap[b.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const M=this.painter.context,R=M.gl;if(u.length<=1)return void(this._overlapStencilType=!1);let z;if(y.isTileClipped())z=u.length,this._overlapStencilMode.test={func:R.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(u[0].overscaledZ>u[u.length-1].overscaledZ))return void(this._overlapStencilType=!1);z=1,this._overlapStencilMode.test={func:R.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+z>255&&(M.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=z,this._overlapStencilMode.ref=this._stencilRef,y.isTileClipped()&&this._renderTileClippingMasks(u,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return this._overlapStencilType==="Clip"||this._overlapStencilType==="Mask"}stencilModeForRTTOverlap(o){return this.renderingToTexture&&this._overlapStencilType?(this._overlapStencilType==="Clip"&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[o.key]),this._overlapStencilMode):i.StencilMode.disabled}_renderTileClippingMasks(o,u){const y=this.painter,b=this.painter.context,M=b.gl;y._tileClippingMaskIDs={},b.setColorMode(i.ColorMode.disabled),b.setDepthMode(i.DepthMode.disabled);const R=y.useProgram("clippingMask");for(const z of o){const V=y._tileClippingMaskIDs[z.key]=--u;R.draw(b,M.TRIANGLES,i.DepthMode.disabled,new i.StencilMode({func:M.ALWAYS,mask:0},V,255,M.KEEP,M.KEEP,M.REPLACE),i.ColorMode.disabled,i.CullFaceMode.disabled,yl(z.projMatrix),"$clipping",y.tileExtentBuffer,y.quadTriangleIndexBuffer,y.tileExtentSegments)}}pointCoordinate(o){const u=this.painter.transform;if(o.x<0||o.x>u.width||o.y<0||o.y>u.height)return null;const y=[o.x,o.y,1,1];i.transformMat4$1(y,y,u.pixelMatrixInverse),i.scale$1(y,y,1/y[3]),y[0]/=u.worldSize,y[1]/=u.worldSize;const b=u._camera.position,M=i.mercatorZfromAltitude(1,u.center.lat),R=[b[0],b[1],b[2]/M,0],z=i.subtract([],y.slice(0,3),R);i.normalize(z,z);const V=this.raycast(R,z,this._exaggeration);return V!==null&&V?(i.scaleAndAdd(R,R,z,V),R[3]=R[2],R[2]*=M,R):null}drawDepth(){const o=this.painter,u=o.context,y=this.proxySourceCache,b=Math.ceil(o.width),M=Math.ceil(o.height);if(!this._depthFBO||this._depthFBO.width===b&&this._depthFBO.height===M||(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0),!this._depthFBO){const R=u.gl,z=u.createFramebuffer(b,M,!0);u.activeTexture.set(R.TEXTURE0);const V=new i.Texture(u,{width:b,height:M,data:null},R.RGBA);V.bind(R.NEAREST,R.CLAMP_TO_EDGE),z.colorAttachment.set(V.texture);const X=u.createRenderbuffer(u.gl.DEPTH_COMPONENT16,b,M);z.depthAttachment.set(X),this._depthFBO=z,this._depthTexture=V}u.bindFramebuffer.set(this._depthFBO.framebuffer),u.viewport.set([0,0,b,M]),function(R,z,V,X){if(R.transform.projection.name==="globe")return;const q=R.context,Q=q.gl;q.clear({depth:1});const he=R.useProgram("terrainDepth"),me=new i.DepthMode(Q.LESS,i.DepthMode.ReadWrite,R.depthRangeFor3D);for(const ge of X){const _e=V.getTile(ge),be=jo(ge.projMatrix,0);z.setupElevationDraw(_e,he),he.draw(q,Q.TRIANGLES,me,i.StencilMode.disabled,i.ColorMode.unblended,i.CullFaceMode.backCCW,be,"terrain_depth",z.gridBuffer,z.gridIndexBuffer,z.gridNoSkirtSegments)}}(o,this,y,this.proxyCoords)}_setupProxiedCoordsForOrtho(o,u,y){if(o.getSource()instanceof ci)return this._setupProxiedCoordsForImageSource(o,u,y);this._findCoveringTileCache[o.id]=this._findCoveringTileCache[o.id]||{};const b=this.proxiedCoords[o.id]=[],M=this.proxyCoords;for(let z=0;z<M.length;z++){const V=M[z],X=this._findTileCoveringTileID(V,o);if(X){const q=this._createProxiedId(V,X,y[V.key]&&y[V.key][o.id]);b.push(q),this.proxyToSource[V.key][o.id]=[q]}}let R=!1;for(let z=0;z<u.length;z++){const V=o.getTile(u[z]);if(!V||!V.hasData())continue;const X=this._findTileCoveringTileID(V.tileID,this.proxySourceCache);if(X&&X.tileID.canonical.z!==V.tileID.canonical.z){const q=this.proxyToSource[X.tileID.key][o.id],Q=this._createProxiedId(X.tileID,V,y[X.tileID.key]&&y[X.tileID.key][o.id]);q?q.splice(q.length-1,0,Q):this.proxyToSource[X.tileID.key][o.id]=[Q],b.push(Q),R=!0}}this._sourceTilesOverlap[o.id]=R}_setupProxiedCoordsForImageSource(o,u,y){if(!o.getSource().loaded())return;const b=this.proxiedCoords[o.id]=[],M=this.proxyCoords,R=o.getSource(),z=new i.Point(R.tileID.x,R.tileID.y)._div(1<<R.tileID.z),V=R.coordinates.map(i.MercatorCoordinate.fromLngLat).reduce((q,Q)=>(q.min.x=Math.min(q.min.x,Q.x-z.x),q.min.y=Math.min(q.min.y,Q.y-z.y),q.max.x=Math.max(q.max.x,Q.x-z.x),q.max.y=Math.max(q.max.y,Q.y-z.y),q),{min:new i.Point(Number.MAX_VALUE,Number.MAX_VALUE),max:new i.Point(-Number.MAX_VALUE,-Number.MAX_VALUE)}),X=(q,Q)=>{const he=q.wrap+q.canonical.x/(1<<q.canonical.z),me=q.canonical.y/(1<<q.canonical.z),ge=i.EXTENT/(1<<q.canonical.z),_e=Q.wrap+Q.canonical.x/(1<<Q.canonical.z),be=Q.canonical.y/(1<<Q.canonical.z);return he+ge<_e+V.min.x||he>_e+V.max.x||me+ge<be+V.min.y||me>be+V.max.y};for(let q=0;q<M.length;q++){const Q=M[q];for(let he=0;he<u.length;he++){const me=o.getTile(u[he]);if(!me||!me.hasData()||X(Q,me.tileID))continue;const ge=this._createProxiedId(Q,me,y[Q.key]&&y[Q.key][o.id]),_e=this.proxyToSource[Q.key][o.id];_e?_e.push(ge):this.proxyToSource[Q.key][o.id]=[ge],b.push(ge)}}}_createProxiedId(o,u,y){let b=this.orthoMatrix;if(y){const M=y.find(R=>R.key===u.tileID.key);if(M)return M}if(u.tileID.key!==o.key){const M=o.canonical.z-u.tileID.canonical.z;let R,z,V;b=i.create();const X=u.tileID.wrap-o.wrap<<o.overscaledZ;M>0?(R=i.EXTENT>>M,z=R*((u.tileID.canonical.x<<M)-o.canonical.x+X),V=R*((u.tileID.canonical.y<<M)-o.canonical.y)):(R=i.EXTENT<<-M,z=i.EXTENT*(u.tileID.canonical.x-(o.canonical.x+X<<-M)),V=i.EXTENT*(u.tileID.canonical.y-(o.canonical.y<<-M))),i.ortho(b,0,R,0,R,0,1),i.translate(b,b,[z,V,0])}return new Fa(u.tileID,o.key,b)}_findTileCoveringTileID(o,u){let y=u.getTile(o);if(y&&y.hasData())return y;const b=this._findCoveringTileCache[u.id],M=b[o.key];if(y=M?u.getTileByID(M):null,y&&y.hasData()||M===null)return y;let R=y?y.tileID:o,z=R.overscaledZ;const V=u.getSource().minzoom,X=[];if(!M){const Q=u.getSource().maxzoom;if(o.canonical.z>=Q){const he=o.canonical.z-Q;u.getSource().reparseOverscaled?(z=Math.max(o.canonical.z+2,u.transform.tileZoom),R=new i.OverscaledTileID(z,o.wrap,Q,o.canonical.x>>he,o.canonical.y>>he)):he!==0&&(z=Q,R=new i.OverscaledTileID(z,o.wrap,Q,o.canonical.x>>he,o.canonical.y>>he))}R.key!==o.key&&(X.push(R.key),y=u.getTile(R))}const q=Q=>{X.forEach(he=>{b[he]=Q}),X.length=0};for(z-=1;z>=V&&(!y||!y.hasData());z--){y&&q(y.tileID.key);const Q=R.calculateScaledKey(z);if(y=u.getTileByID(Q),y&&y.hasData())break;const he=b[Q];if(he===null)break;he===void 0?X.push(Q):y=u.getTileByID(he)}return q(y?y.tileID.key:null),y&&y.hasData()?y:null}findDEMTileFor(o){return this.enabled?this._findTileCoveringTileID(o,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(o,u){let y=this._tilesDirty[o];y||(y=this._tilesDirty[o]={}),y[u.key]=!0}getWirefameBuffer(){if(!this.wireframeSegments){const o=function(u){let y=0;const b=new i.StructArrayLayout2ui4,M=131;for(let R=1;R<129;R++){for(let z=1;z<129;z++)y=R*M+z,b.emplaceBack(y,y+1),b.emplaceBack(y,y+M),b.emplaceBack(y+1,y+M),R===128&&b.emplaceBack(y+M,y+M+1);b.emplaceBack(y+1,y+1+M)}return b}();this.wireframeIndexBuffer=this.painter.context.createIndexBuffer(o),this.wireframeSegments=i.SegmentVector.simpleSegment(0,0,this.gridBuffer.length,o.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}}class gi{static cacheKey(o,u,y,b){let M=`${u}${b?b.cacheKey:""}`;for(const R of y)o.usedDefines.includes(R)&&(M+=`/${R}`);return M}constructor(o,u,y,b,M,R){const z=o.gl;this.program=z.createProgram();const V=function(ie){const pe=[];for(let Ee=0;Ee<ie.length;Ee++){if(ie[Ee]===null)continue;const Te=ie[Ee].split(" ");pe.push(Te.pop())}return pe}(y.staticAttributes),X=b?b.getBinderAttributes():[],q=V.concat(X);let Q=b?b.defines():[];Q=Q.concat(R.map(ie=>`#define ${ie}`));const he=o.isWebGL2?`#version 300 es
`:"",me=he+Q.concat(o.extStandardDerivatives&&he.length===0?`#extension GL_OES_standard_derivatives : enable
`.concat(ka):ka,ka,nl,Ol.fragmentSource,da.fragmentSource,y.fragmentSource).join(`
`),ge=he+Q.concat(`
#ifdef GL_ES
precision highp float;
#else

#if !defined(lowp)
#define lowp
#endif

#if !defined(mediump)
#define mediump
#endif

#if !defined(highp)
#define highp
#endif

#endif`,nl,Ol.vertexSource,da.vertexSource,za.vertexSource,y.vertexSource).join(`
`),_e=z.createShader(z.FRAGMENT_SHADER);if(z.isContextLost())return void(this.failedToCreate=!0);z.shaderSource(_e,me),z.compileShader(_e),z.attachShader(this.program,_e);const be=z.createShader(z.VERTEX_SHADER);if(z.isContextLost())this.failedToCreate=!0;else{z.shaderSource(be,ge),z.compileShader(be),z.attachShader(this.program,be),this.attributes={},this.numAttributes=q.length;for(let ie=0;ie<this.numAttributes;ie++)q[ie]&&(z.bindAttribLocation(this.program,ie,q[ie]),this.attributes[q[ie]]=ie);z.linkProgram(this.program),z.deleteShader(be),z.deleteShader(_e),this.fixedUniforms=M(o),this.binderUniforms=b?b.getUniforms(o):[],R.includes("TERRAIN")&&(this.terrainUniforms=(ie=>({u_dem:new i.Uniform1i(ie),u_dem_prev:new i.Uniform1i(ie),u_dem_unpack:new i.Uniform4f(ie),u_dem_tl:new i.Uniform2f(ie),u_dem_scale:new i.Uniform1f(ie),u_dem_tl_prev:new i.Uniform2f(ie),u_dem_scale_prev:new i.Uniform1f(ie),u_dem_size:new i.Uniform1f(ie),u_dem_lerp:new i.Uniform1f(ie),u_exaggeration:new i.Uniform1f(ie),u_depth:new i.Uniform1i(ie),u_depth_size_inv:new i.Uniform2f(ie),u_meter_to_dem:new i.Uniform1f(ie),u_label_plane_matrix_inv:new i.UniformMatrix4f(ie)}))(o)),R.includes("GLOBE")&&(this.globeUniforms=(ie=>({u_tile_tl_up:new i.Uniform3f(ie),u_tile_tr_up:new i.Uniform3f(ie),u_tile_br_up:new i.Uniform3f(ie),u_tile_bl_up:new i.Uniform3f(ie),u_tile_up_scale:new i.Uniform1f(ie)}))(o)),R.includes("FOG")&&(this.fogUniforms=(ie=>({u_fog_matrix:new i.UniformMatrix4f(ie),u_fog_range:new i.Uniform2f(ie),u_fog_color:new i.Uniform4f(ie),u_fog_horizon_blend:new i.Uniform1f(ie),u_fog_temporal_offset:new i.Uniform1f(ie),u_frustum_tl:new i.Uniform3f(ie),u_frustum_tr:new i.Uniform3f(ie),u_frustum_br:new i.Uniform3f(ie),u_frustum_bl:new i.Uniform3f(ie),u_globe_pos:new i.Uniform3f(ie),u_globe_radius:new i.Uniform1f(ie),u_globe_transition:new i.Uniform1f(ie),u_is_globe:new i.Uniform1i(ie),u_viewport:new i.Uniform2f(ie)}))(o))}}setTerrainUniformValues(o,u){if(!this.terrainUniforms)return;const y=this.terrainUniforms;if(!this.failedToCreate){o.program.set(this.program);for(const b in u)y[b]&&y[b].set(this.program,b,u[b])}}setGlobeUniformValues(o,u){if(!this.globeUniforms)return;const y=this.globeUniforms;if(!this.failedToCreate){o.program.set(this.program);for(const b in u)y[b]&&y[b].set(this.program,b,u[b])}}setFogUniformValues(o,u){if(!this.fogUniforms)return;const y=this.fogUniforms;if(!this.failedToCreate){o.program.set(this.program);for(const b in u)y[b].set(this.program,b,u[b])}}draw(o,u,y,b,M,R,z,V,X,q,Q,he,me,ge,_e){const be=o.gl;if(this.failedToCreate)return;o.program.set(this.program),o.setDepthMode(y),o.setStencilMode(b),o.setColorMode(M),o.setCullFace(R);for(const pe of Object.keys(this.fixedUniforms))this.fixedUniforms[pe].set(this.program,pe,z[pe]);ge&&ge.setUniforms(this.program,o,this.binderUniforms,he,{zoom:me});const ie={[be.LINES]:2,[be.TRIANGLES]:3,[be.LINE_STRIP]:1}[u];for(const pe of Q.get()){const Ee=pe.vaos||(pe.vaos={});(Ee[V]||(Ee[V]=new uc)).bind(o,this,X,ge?ge.getPaintVertexBuffers():[],q,pe.vertexOffset,_e||[]),be.drawElements(u,pe.primitiveLength*ie,be.UNSIGNED_SHORT,pe.primitiveOffset*ie*2)}}}function Or(p,o){const u=Math.pow(2,o.tileID.overscaledZ),y=o.tileSize*Math.pow(2,p.transform.tileZoom)/u,b=y*(o.tileID.canonical.x+o.tileID.wrap*u),M=y*o.tileID.canonical.y;return{u_image:0,u_texsize:o.imageAtlasTexture.size,u_tile_units_to_pixels:1/Et(o,1,p.transform.tileZoom),u_pixel_coord_upper:[b>>16,M>>16],u_pixel_coord_lower:[65535&b,65535&M]}}const Qs=i.create(),eo=(p,o,u,y,b,M,R,z,V,X,q)=>{const Q=o.style.light,he=Q.properties.get("position"),me=[he.x,he.y,he.z],ge=i.create$1();Q.properties.get("anchor")==="viewport"&&(i.fromRotation(ge,-o.transform.angle),i.transformMat3(me,me,ge));const _e=Q.properties.get("color"),be=o.transform,ie={u_matrix:p,u_lightpos:me,u_lightintensity:Q.properties.get("intensity"),u_lightcolor:[_e.r,_e.g,_e.b],u_vertical_gradient:+u,u_opacity:y,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Qs,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_ao:b,u_edge_radius:M};return be.projection.name==="globe"&&(ie.u_tile_id=[R.canonical.x,R.canonical.y,1<<R.canonical.z],ie.u_zoom_transition=V,ie.u_inv_rot_matrix=q,ie.u_merc_center=X,ie.u_up_dir=be.projection.upVector(new i.CanonicalTileID(0,0,0),X[0]*i.EXTENT,X[1]*i.EXTENT),ie.u_height_lift=z),ie},fs=(p,o,u,y,b,M,R,z,V,X,q,Q)=>{const he=eo(p,o,u,y,b,M,R,V,X,q,Q),me={u_height_factor:-Math.pow(2,R.overscaledZ)/z.tileSize/8};return i.extend(he,Or(o,z),me)},_o=p=>({u_matrix:p}),il=(p,o,u)=>i.extend(_o(p),Or(o,u)),rl=(p,o)=>({u_matrix:p,u_world:o}),fc=(p,o,u,y)=>i.extend(il(p,o,u),{u_world:y}),to=i.create(),Us=(p,o,u,y,b,M)=>{const R=p.transform,z=R.projection.name==="globe";let V;if(M.paint.get("circle-pitch-alignment")==="map")if(z){const q=i.globePixelsToTileUnits(R.zoom,o.canonical)*R._pixelsPerMercatorPixel;V=Float32Array.from([q,0,0,q])}else V=R.calculatePixelsToTileUnitsMatrix(u);else V=new Float32Array([R.pixelsToGLUnits[0],0,0,R.pixelsToGLUnits[1]]);const X={u_camera_to_center_distance:R.cameraToCenterDistance,u_matrix:p.translatePosMatrix(o.projMatrix,u,M.paint.get("circle-translate"),M.paint.get("circle-translate-anchor")),u_device_pixel_ratio:i.exported.devicePixelRatio,u_extrude_scale:V,u_inv_rot_matrix:to,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(z){X.u_inv_rot_matrix=y,X.u_merc_center=b,X.u_tile_id=[o.canonical.x,o.canonical.y,1<<o.canonical.z],X.u_zoom_transition=i.globeToMercatorTransition(R.zoom);const q=b[0]*i.EXTENT,Q=b[1]*i.EXTENT;X.u_up_dir=R.projection.upVector(new i.CanonicalTileID(0,0,0),q,Q)}return X},Sr=p=>{const o=[];return p.paint.get("circle-pitch-alignment")==="map"&&o.push("PITCH_WITH_MAP"),p.paint.get("circle-pitch-scale")==="map"&&o.push("SCALE_WITH_MAP"),o},Na=(p,o,u,y)=>{const b=i.EXTENT/u.tileSize;return{u_matrix:p,u_camera_to_center_distance:o.getCameraToCenterDistance(y),u_extrude_scale:[o.pixelsToGLUnits[0]/b,o.pixelsToGLUnits[1]/b]}},Vs=(p,o,u=1)=>({u_matrix:p,u_color:o,u_overlay:0,u_overlay_scale:u}),xl=i.create(),Ua=(p,o,u,y,b,M,R)=>{const z=p.transform,V=z.projection.name==="globe",X=V?i.globePixelsToTileUnits(z.zoom,o.canonical)*z._pixelsPerMercatorPixel:Et(u,1,M),q={u_matrix:o.projMatrix,u_extrude_scale:X,u_intensity:R,u_inv_rot_matrix:xl,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(V){q.u_inv_rot_matrix=y,q.u_merc_center=b,q.u_tile_id=[o.canonical.x,o.canonical.y,1<<o.canonical.z],q.u_zoom_transition=i.globeToMercatorTransition(z.zoom);const Q=b[0]*i.EXTENT,he=b[1]*i.EXTENT;q.u_up_dir=z.projection.upVector(new i.CanonicalTileID(0,0,0),Q,he)}return q},Zc=(p,o,u,y,b,M,R)=>{const z=p.transform,V=z.calculatePixelsToTileUnitsMatrix(o);return{u_matrix:yo(p,o,u,y),u_pixels_to_tile_units:V,u_device_pixel_ratio:M,u_units_to_pixels:[1/z.pixelsToGLUnits[0],1/z.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:b,u_texsize:Wo(u)?o.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:sl(o,p.transform),u_alpha_discard_threshold:0,u_trim_offset:R}},no=(p,o,u,y,b)=>{const M=p.transform;return{u_matrix:yo(p,o,u,y),u_texsize:o.imageAtlasTexture.size,u_pixels_to_tile_units:M.calculatePixelsToTileUnitsMatrix(o),u_device_pixel_ratio:b,u_image:0,u_tile_units_to_pixels:sl(o,M),u_units_to_pixels:[1/M.pixelsToGLUnits[0],1/M.pixelsToGLUnits[1]],u_alpha_discard_threshold:0}};function sl(p,o){return 1/Et(p,1,o.tileZoom)}function yo(p,o,u,y){return p.translatePosMatrix(y||o.tileID.projMatrix,o,u.paint.get("line-translate"),u.paint.get("line-translate-anchor"))}function Wo(p){const o=p.paint.get("line-dasharray").value;return o.value||o.kind!=="constant"}const Nl=(p,o,u,y,b,M)=>{return{u_matrix:p,u_tl_parent:o,u_scale_parent:u,u_fade_t:y.mix,u_opacity:y.opacity*b.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:b.paint.get("raster-brightness-min"),u_brightness_high:b.paint.get("raster-brightness-max"),u_saturation_factor:(z=b.paint.get("raster-saturation"),z>0?1-1/(1.001-z):-z),u_contrast_factor:(R=b.paint.get("raster-contrast"),R>0?1/(1-R):1+R),u_spin_weights:ps(b.paint.get("raster-hue-rotate")),u_perspective_transform:M};var R,z};function ps(p){p*=Math.PI/180;const o=Math.sin(p),u=Math.cos(p);return[(2*u+1)/3,(-Math.sqrt(3)*o-u+1)/3,(Math.sqrt(3)*o-u+1)/3]}const _a=i.create(),Ul=(p,o,u,y,b,M,R,z,V,X,q,Q,he,me,ge,_e)=>{const be=b.transform,ie={u_is_size_zoom_constant:+(p==="constant"||p==="source"),u_is_size_feature_constant:+(p==="constant"||p==="camera"),u_size_t:o?o.uSizeT:0,u_size:o?o.uSize:0,u_camera_to_center_distance:be.cameraToCenterDistance,u_rotate_symbol:+u,u_aspect_ratio:be.width/be.height,u_fade_change:b.options.fadeDuration?b.symbolFadeChange:1,u_matrix:M,u_label_plane_matrix:R,u_coord_matrix:z,u_is_text:+V,u_pitch_with_map:+y,u_texsize:X,u_texture:0,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:_a,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:_a,u_up_vector:[0,-1,0]};return _e.name==="globe"&&(ie.u_tile_id=[q.canonical.x,q.canonical.y,1<<q.canonical.z],ie.u_zoom_transition=Q,ie.u_inv_rot_matrix=me,ie.u_merc_center=he,ie.u_camera_forward=be._camera.forward(),ie.u_ecef_origin=i.globeECEFOrigin(be.globeMatrix,q.toUnwrapped()),ie.u_tile_matrix=Float32Array.from(be.globeMatrix),ie.u_up_vector=ge),ie},vl=(p,o,u,y,b,M,R,z,V,X,q,Q,he,me,ge,_e,be)=>i.extend(Ul(p,o,u,y,b,M,R,z,V,X,Q,he,me,ge,_e,be),{u_gamma_scale:y?b.transform.cameraToCenterDistance*Math.cos(b.terrain?0:b.transform._pitch):1,u_device_pixel_ratio:i.exported.devicePixelRatio,u_is_halo:+q}),Va=(p,o,u,y,b,M,R,z,V,X,q,Q,he,me,ge,_e)=>i.extend(vl(p,o,u,y,b,M,R,z,!0,V,!0,q,Q,he,me,ge,_e),{u_texsize_icon:X,u_texture_icon:1}),Ga=(p,o,u)=>({u_matrix:p,u_opacity:o,u_color:u}),bl=(p,o,u,y,b)=>i.extend(function(M,R,z){const V=R.imageManager.getPattern(M.toString()),{width:X,height:q}=R.imageManager.getPixelSize(),Q=Math.pow(2,z.tileID.overscaledZ),he=z.tileSize*Math.pow(2,R.transform.tileZoom)/Q,me=he*(z.tileID.canonical.x+z.tileID.wrap*Q),ge=he*z.tileID.canonical.y;return{u_image:0,u_pattern_tl:V.tl,u_pattern_br:V.br,u_texsize:[X,q],u_pattern_size:V.displaySize,u_tile_units_to_pixels:1/Et(z,1,R.transform.tileZoom),u_pixel_coord_upper:[me>>16,ge>>16],u_pixel_coord_lower:[65535&me,65535&ge]}}(y,u,b),{u_matrix:p,u_opacity:o}),io={fillExtrusion:p=>({u_matrix:new i.UniformMatrix4f(p),u_lightpos:new i.Uniform3f(p),u_lightintensity:new i.Uniform1f(p),u_lightcolor:new i.Uniform3f(p),u_vertical_gradient:new i.Uniform1f(p),u_opacity:new i.Uniform1f(p),u_edge_radius:new i.Uniform1f(p),u_ao:new i.Uniform2f(p),u_tile_id:new i.Uniform3f(p),u_zoom_transition:new i.Uniform1f(p),u_inv_rot_matrix:new i.UniformMatrix4f(p),u_merc_center:new i.Uniform2f(p),u_up_dir:new i.Uniform3f(p),u_height_lift:new i.Uniform1f(p)}),fillExtrusionPattern:p=>({u_matrix:new i.UniformMatrix4f(p),u_lightpos:new i.Uniform3f(p),u_lightintensity:new i.Uniform1f(p),u_lightcolor:new i.Uniform3f(p),u_vertical_gradient:new i.Uniform1f(p),u_height_factor:new i.Uniform1f(p),u_edge_radius:new i.Uniform1f(p),u_ao:new i.Uniform2f(p),u_tile_id:new i.Uniform3f(p),u_zoom_transition:new i.Uniform1f(p),u_inv_rot_matrix:new i.UniformMatrix4f(p),u_merc_center:new i.Uniform2f(p),u_up_dir:new i.Uniform3f(p),u_height_lift:new i.Uniform1f(p),u_image:new i.Uniform1i(p),u_texsize:new i.Uniform2f(p),u_pixel_coord_upper:new i.Uniform2f(p),u_pixel_coord_lower:new i.Uniform2f(p),u_tile_units_to_pixels:new i.Uniform1f(p),u_opacity:new i.Uniform1f(p)}),fill:p=>({u_matrix:new i.UniformMatrix4f(p)}),fillPattern:p=>({u_matrix:new i.UniformMatrix4f(p),u_image:new i.Uniform1i(p),u_texsize:new i.Uniform2f(p),u_pixel_coord_upper:new i.Uniform2f(p),u_pixel_coord_lower:new i.Uniform2f(p),u_tile_units_to_pixels:new i.Uniform1f(p)}),fillOutline:p=>({u_matrix:new i.UniformMatrix4f(p),u_world:new i.Uniform2f(p)}),fillOutlinePattern:p=>({u_matrix:new i.UniformMatrix4f(p),u_world:new i.Uniform2f(p),u_image:new i.Uniform1i(p),u_texsize:new i.Uniform2f(p),u_pixel_coord_upper:new i.Uniform2f(p),u_pixel_coord_lower:new i.Uniform2f(p),u_tile_units_to_pixels:new i.Uniform1f(p)}),circle:p=>({u_camera_to_center_distance:new i.Uniform1f(p),u_extrude_scale:new i.UniformMatrix2f(p),u_device_pixel_ratio:new i.Uniform1f(p),u_matrix:new i.UniformMatrix4f(p),u_inv_rot_matrix:new i.UniformMatrix4f(p),u_merc_center:new i.Uniform2f(p),u_tile_id:new i.Uniform3f(p),u_zoom_transition:new i.Uniform1f(p),u_up_dir:new i.Uniform3f(p)}),collisionBox:p=>({u_matrix:new i.UniformMatrix4f(p),u_camera_to_center_distance:new i.Uniform1f(p),u_extrude_scale:new i.Uniform2f(p)}),collisionCircle:p=>({u_matrix:new i.UniformMatrix4f(p),u_inv_matrix:new i.UniformMatrix4f(p),u_camera_to_center_distance:new i.Uniform1f(p),u_viewport_size:new i.Uniform2f(p)}),debug:p=>({u_color:new i.UniformColor(p),u_matrix:new i.UniformMatrix4f(p),u_overlay:new i.Uniform1i(p),u_overlay_scale:new i.Uniform1f(p)}),clippingMask:p=>({u_matrix:new i.UniformMatrix4f(p)}),heatmap:p=>({u_extrude_scale:new i.Uniform1f(p),u_intensity:new i.Uniform1f(p),u_matrix:new i.UniformMatrix4f(p),u_inv_rot_matrix:new i.UniformMatrix4f(p),u_merc_center:new i.Uniform2f(p),u_tile_id:new i.Uniform3f(p),u_zoom_transition:new i.Uniform1f(p),u_up_dir:new i.Uniform3f(p)}),heatmapTexture:p=>({u_image:new i.Uniform1i(p),u_color_ramp:new i.Uniform1i(p),u_opacity:new i.Uniform1f(p)}),hillshade:p=>({u_matrix:new i.UniformMatrix4f(p),u_image:new i.Uniform1i(p),u_latrange:new i.Uniform2f(p),u_light:new i.Uniform2f(p),u_shadow:new i.UniformColor(p),u_highlight:new i.UniformColor(p),u_accent:new i.UniformColor(p)}),hillshadePrepare:p=>({u_matrix:new i.UniformMatrix4f(p),u_image:new i.Uniform1i(p),u_dimension:new i.Uniform2f(p),u_zoom:new i.Uniform1f(p),u_unpack:new i.Uniform4f(p)}),line:p=>({u_matrix:new i.UniformMatrix4f(p),u_pixels_to_tile_units:new i.UniformMatrix2f(p),u_device_pixel_ratio:new i.Uniform1f(p),u_units_to_pixels:new i.Uniform2f(p),u_dash_image:new i.Uniform1i(p),u_gradient_image:new i.Uniform1i(p),u_image_height:new i.Uniform1f(p),u_texsize:new i.Uniform2f(p),u_tile_units_to_pixels:new i.Uniform1f(p),u_alpha_discard_threshold:new i.Uniform1f(p),u_trim_offset:new i.Uniform2f(p)}),linePattern:p=>({u_matrix:new i.UniformMatrix4f(p),u_texsize:new i.Uniform2f(p),u_pixels_to_tile_units:new i.UniformMatrix2f(p),u_device_pixel_ratio:new i.Uniform1f(p),u_image:new i.Uniform1i(p),u_units_to_pixels:new i.Uniform2f(p),u_tile_units_to_pixels:new i.Uniform1f(p),u_alpha_discard_threshold:new i.Uniform1f(p)}),raster:p=>({u_matrix:new i.UniformMatrix4f(p),u_tl_parent:new i.Uniform2f(p),u_scale_parent:new i.Uniform1f(p),u_fade_t:new i.Uniform1f(p),u_opacity:new i.Uniform1f(p),u_image0:new i.Uniform1i(p),u_image1:new i.Uniform1i(p),u_brightness_low:new i.Uniform1f(p),u_brightness_high:new i.Uniform1f(p),u_saturation_factor:new i.Uniform1f(p),u_contrast_factor:new i.Uniform1f(p),u_spin_weights:new i.Uniform3f(p),u_perspective_transform:new i.Uniform2f(p)}),symbolIcon:p=>({u_is_size_zoom_constant:new i.Uniform1i(p),u_is_size_feature_constant:new i.Uniform1i(p),u_size_t:new i.Uniform1f(p),u_size:new i.Uniform1f(p),u_camera_to_center_distance:new i.Uniform1f(p),u_rotate_symbol:new i.Uniform1i(p),u_aspect_ratio:new i.Uniform1f(p),u_fade_change:new i.Uniform1f(p),u_matrix:new i.UniformMatrix4f(p),u_label_plane_matrix:new i.UniformMatrix4f(p),u_coord_matrix:new i.UniformMatrix4f(p),u_is_text:new i.Uniform1i(p),u_pitch_with_map:new i.Uniform1i(p),u_texsize:new i.Uniform2f(p),u_tile_id:new i.Uniform3f(p),u_zoom_transition:new i.Uniform1f(p),u_inv_rot_matrix:new i.UniformMatrix4f(p),u_merc_center:new i.Uniform2f(p),u_camera_forward:new i.Uniform3f(p),u_tile_matrix:new i.UniformMatrix4f(p),u_up_vector:new i.Uniform3f(p),u_ecef_origin:new i.Uniform3f(p),u_texture:new i.Uniform1i(p)}),symbolSDF:p=>({u_is_size_zoom_constant:new i.Uniform1i(p),u_is_size_feature_constant:new i.Uniform1i(p),u_size_t:new i.Uniform1f(p),u_size:new i.Uniform1f(p),u_camera_to_center_distance:new i.Uniform1f(p),u_rotate_symbol:new i.Uniform1i(p),u_aspect_ratio:new i.Uniform1f(p),u_fade_change:new i.Uniform1f(p),u_matrix:new i.UniformMatrix4f(p),u_label_plane_matrix:new i.UniformMatrix4f(p),u_coord_matrix:new i.UniformMatrix4f(p),u_is_text:new i.Uniform1i(p),u_pitch_with_map:new i.Uniform1i(p),u_texsize:new i.Uniform2f(p),u_texture:new i.Uniform1i(p),u_gamma_scale:new i.Uniform1f(p),u_device_pixel_ratio:new i.Uniform1f(p),u_tile_id:new i.Uniform3f(p),u_zoom_transition:new i.Uniform1f(p),u_inv_rot_matrix:new i.UniformMatrix4f(p),u_merc_center:new i.Uniform2f(p),u_camera_forward:new i.Uniform3f(p),u_tile_matrix:new i.UniformMatrix4f(p),u_up_vector:new i.Uniform3f(p),u_ecef_origin:new i.Uniform3f(p),u_is_halo:new i.Uniform1i(p)}),symbolTextAndIcon:p=>({u_is_size_zoom_constant:new i.Uniform1i(p),u_is_size_feature_constant:new i.Uniform1i(p),u_size_t:new i.Uniform1f(p),u_size:new i.Uniform1f(p),u_camera_to_center_distance:new i.Uniform1f(p),u_rotate_symbol:new i.Uniform1i(p),u_aspect_ratio:new i.Uniform1f(p),u_fade_change:new i.Uniform1f(p),u_matrix:new i.UniformMatrix4f(p),u_label_plane_matrix:new i.UniformMatrix4f(p),u_coord_matrix:new i.UniformMatrix4f(p),u_is_text:new i.Uniform1i(p),u_pitch_with_map:new i.Uniform1i(p),u_texsize:new i.Uniform2f(p),u_texsize_icon:new i.Uniform2f(p),u_texture:new i.Uniform1i(p),u_texture_icon:new i.Uniform1i(p),u_gamma_scale:new i.Uniform1f(p),u_device_pixel_ratio:new i.Uniform1f(p),u_is_halo:new i.Uniform1i(p)}),background:p=>({u_matrix:new i.UniformMatrix4f(p),u_opacity:new i.Uniform1f(p),u_color:new i.UniformColor(p)}),backgroundPattern:p=>({u_matrix:new i.UniformMatrix4f(p),u_opacity:new i.Uniform1f(p),u_image:new i.Uniform1i(p),u_pattern_tl:new i.Uniform2f(p),u_pattern_br:new i.Uniform2f(p),u_texsize:new i.Uniform2f(p),u_pattern_size:new i.Uniform2f(p),u_pixel_coord_upper:new i.Uniform2f(p),u_pixel_coord_lower:new i.Uniform2f(p),u_tile_units_to_pixels:new i.Uniform1f(p)}),terrainRaster:dc,terrainDepth:dc,skybox:p=>({u_matrix:new i.UniformMatrix4f(p),u_sun_direction:new i.Uniform3f(p),u_cubemap:new i.Uniform1i(p),u_opacity:new i.Uniform1f(p),u_temporal_offset:new i.Uniform1f(p)}),skyboxGradient:p=>({u_matrix:new i.UniformMatrix4f(p),u_color_ramp:new i.Uniform1i(p),u_center_direction:new i.Uniform3f(p),u_radius:new i.Uniform1f(p),u_opacity:new i.Uniform1f(p),u_temporal_offset:new i.Uniform1f(p)}),skyboxCapture:p=>({u_matrix_3f:new i.UniformMatrix3f(p),u_sun_direction:new i.Uniform3f(p),u_sun_intensity:new i.Uniform1f(p),u_color_tint_r:new i.Uniform4f(p),u_color_tint_m:new i.Uniform4f(p),u_luminance:new i.Uniform1f(p)}),globeRaster:p=>({u_proj_matrix:new i.UniformMatrix4f(p),u_globe_matrix:new i.UniformMatrix4f(p),u_normalize_matrix:new i.UniformMatrix4f(p),u_merc_matrix:new i.UniformMatrix4f(p),u_zoom_transition:new i.Uniform1f(p),u_merc_center:new i.Uniform2f(p),u_image0:new i.Uniform1i(p),u_grid_matrix:new i.UniformMatrix3f(p),u_skirt_height:new i.Uniform1f(p),u_frustum_tl:new i.Uniform3f(p),u_frustum_tr:new i.Uniform3f(p),u_frustum_br:new i.Uniform3f(p),u_frustum_bl:new i.Uniform3f(p),u_globe_pos:new i.Uniform3f(p),u_globe_radius:new i.Uniform1f(p),u_viewport:new i.Uniform2f(p)}),globeAtmosphere:p=>({u_frustum_tl:new i.Uniform3f(p),u_frustum_tr:new i.Uniform3f(p),u_frustum_br:new i.Uniform3f(p),u_frustum_bl:new i.Uniform3f(p),u_horizon:new i.Uniform1f(p),u_transition:new i.Uniform1f(p),u_fadeout_range:new i.Uniform1f(p),u_color:new i.Uniform4f(p),u_high_color:new i.Uniform4f(p),u_space_color:new i.Uniform4f(p),u_star_intensity:new i.Uniform1f(p),u_star_density:new i.Uniform1f(p),u_star_size:new i.Uniform1f(p),u_temporal_offset:new i.Uniform1f(p),u_horizon_angle:new i.Uniform1f(p),u_rotation_matrix:new i.UniformMatrix4f(p)})};let ot;function At(p,o,u,y,b,M,R){const z=p.context,V=z.gl,X=p.transform,q=p.useProgram("collisionBox"),Q=[];let he=0,me=0;for(let Te=0;Te<y.length;Te++){const Ue=y[Te],Ge=o.getTile(Ue),Ve=Ge.getBucket(u);if(!Ve)continue;const et=Ce(Ue,Ve,X);let $e=et;b[0]===0&&b[1]===0||($e=p.translatePosMatrix(et,Ge,b,M));const ht=R?Ve.textCollisionBox:Ve.iconCollisionBox,Jt=Ve.collisionCircleArray;if(Jt.length>0){const ut=i.create(),Bt=$e;i.mul(ut,Ve.placementInvProjMatrix,X.glCoordMatrix),i.mul(ut,ut,Ve.placementViewportMatrix),Q.push({circleArray:Jt,circleOffset:me,transform:Bt,invTransform:ut,projection:Ve.getProjection()}),he+=Jt.length/4,me=he}ht&&(p.terrain&&p.terrain.setupElevationDraw(Ge,q),q.draw(z,V.LINES,i.DepthMode.disabled,i.StencilMode.disabled,p.colorModeForRenderPass(),i.CullFaceMode.disabled,Na($e,X,Ge,Ve.getProjection()),u.id,ht.layoutVertexBuffer,ht.indexBuffer,ht.segments,null,X.zoom,null,[ht.collisionVertexBuffer,ht.collisionVertexBufferExt]))}if(!R||!Q.length)return;const ge=p.useProgram("collisionCircle"),_e=new i.StructArrayLayout2f1f2i16;_e.resize(4*he),_e._trim();let be=0;for(const Te of Q)for(let Ue=0;Ue<Te.circleArray.length/4;Ue++){const Ge=4*Ue,Ve=Te.circleArray[Ge+0],et=Te.circleArray[Ge+1],$e=Te.circleArray[Ge+2],ht=Te.circleArray[Ge+3];_e.emplace(be++,Ve,et,$e,ht,0),_e.emplace(be++,Ve,et,$e,ht,1),_e.emplace(be++,Ve,et,$e,ht,2),_e.emplace(be++,Ve,et,$e,ht,3)}(!ot||ot.length<2*he)&&(ot=function(Te){const Ue=2*Te,Ge=new i.StructArrayLayout3ui6;Ge.resize(Ue),Ge._trim();for(let Ve=0;Ve<Ue;Ve++){const et=6*Ve;Ge.uint16[et+0]=4*Ve+0,Ge.uint16[et+1]=4*Ve+1,Ge.uint16[et+2]=4*Ve+2,Ge.uint16[et+3]=4*Ve+2,Ge.uint16[et+4]=4*Ve+3,Ge.uint16[et+5]=4*Ve+0}return Ge}(he));const ie=z.createIndexBuffer(ot,!0),pe=z.createVertexBuffer(_e,i.collisionCircleLayout.members,!0);for(const Te of Q){const Ue={u_matrix:Te.transform,u_inv_matrix:Te.invTransform,u_camera_to_center_distance:(Ee=X).getCameraToCenterDistance(Te.projection),u_viewport_size:[Ee.width,Ee.height]};ge.draw(z,V.TRIANGLES,i.DepthMode.disabled,i.StencilMode.disabled,p.colorModeForRenderPass(),i.CullFaceMode.disabled,Ue,u.id,pe,ie,i.SegmentVector.simpleSegment(0,2*Te.circleOffset,Te.circleArray.length,Te.circleArray.length/2),null,X.zoom)}var Ee;pe.destroy(),ie.destroy()}const yn=i.create();function ni({width:p,height:o,anchor:u,textOffset:y,textScale:b},M){const{horizontalAlign:R,verticalAlign:z}=i.getAnchorAlignment(u),V=-(R-.5)*p,X=-(z-.5)*o,q=i.evaluateVariableOffset(u,y);return new i.Point((V/b+q[0])*M,(X/b+q[1])*M)}function fr(p,o,u,y,b,M,R,z,V,X,q){const Q=p.text.placedSymbolArray,he=p.text.dynamicLayoutVertexArray,me=p.icon.dynamicLayoutVertexArray,ge={},_e=p.getProjection(),be=Oe(z,_e,M),ie=M.elevation,pe=_e.upVectorScale(z.canonical,M.center.lat,M.worldSize).metersToTile;he.clear();for(let Ee=0;Ee<Q.length;Ee++){const Te=Q.get(Ee),{tileAnchorX:Ue,tileAnchorY:Ge,numGlyphs:Ve}=Te,et=Te.hidden||!Te.crossTileID||p.allowVerticalPlacement&&!Te.placedOrientation?null:y[Te.crossTileID];if(et){let $e=0,ht=0,Jt=0;if(ie){const Ct=ie?ie.getAtTileOffset(z,Ue,Ge):0,[zn,qn,vn]=_e.upVector(z.canonical,Ue,Ge);$e=Ct*zn*pe,ht=Ct*qn*pe,Jt=Ct*vn*pe}let[ut,Bt,yt,Xt]=nr(Te.projectedAnchorX+$e,Te.projectedAnchorY+ht,Te.projectedAnchorZ+Jt,u?be:R);const gt=Os(M.getCameraToCenterDistance(_e),Xt);let Ot=b.evaluateSizeForFeature(p.textSizeData,X,Te)*gt/i.ONE_EM;u&&(Ot*=p.tilePixelRatio/V);const Qt=ni(et,Ot);u?({x:ut,y:Bt,z:yt}=_e.projectTilePoint(Ue+Qt.x,Ge+Qt.y,z.canonical),[ut,Bt,yt]=nr(ut+$e,Bt+ht,yt+Jt,R)):(o&&Qt._rotate(-M.angle),ut+=Qt.x,Bt+=Qt.y,yt=0);const Lt=p.allowVerticalPlacement&&Te.placedOrientation===i.WritingMode.vertical?Math.PI/2:0;for(let Ct=0;Ct<Ve;Ct++)i.addDynamicAttributes(he,ut,Bt,yt,Lt);q&&Te.associatedIconIndex>=0&&(ge[Te.associatedIconIndex]={x:ut,y:Bt,z:yt,angle:Lt})}else Hr(Ve,he)}if(q){me.clear();const Ee=p.icon.placedSymbolArray;for(let Te=0;Te<Ee.length;Te++){const Ue=Ee.get(Te),{numGlyphs:Ge}=Ue,Ve=ge[Te];if(Ue.hidden||!Ve)Hr(Ge,me);else{const{x:et,y:$e,z:ht,angle:Jt}=Ve;for(let ut=0;ut<Ge;ut++)i.addDynamicAttributes(me,et,$e,ht,Jt)}}p.icon.dynamicLayoutVertexBuffer.updateData(me)}p.text.dynamicLayoutVertexBuffer.updateData(he)}function Wi(p,o,u){return u.iconsInText&&o?"symbolTextAndIcon":p?"symbolSDF":"symbolIcon"}function Pr(p,o,u,y,b,M,R,z,V,X,q,Q){const he=p.context,me=he.gl,ge=p.transform,_e=z==="map",be=V==="map",ie=_e&&u.layout.get("symbol-placement")!=="point",pe=_e&&!be&&!ie,Ee=u.layout.get("symbol-sort-key").constantOr(1)!==void 0;let Te=!1;const Ue=p.depthModeForSublayer(0,i.DepthMode.ReadOnly),Ge=[i.mercatorXfromLng(ge.center.lng),i.mercatorYfromLat(ge.center.lat)],Ve=u.layout.get("text-variable-anchor"),et=ge.projection.name==="globe",$e=[],ht=[0,-1,0];let Jt=ht;!et&&!ge.mercatorFromTransition||_e||(Jt=function(ut){const Bt=ut._camera.getWorldToCamera(ut.worldSize,1),yt=i.multiply([],Bt,ut.globeMatrix);i.invert(yt,yt);const Xt=[0,0,0],gt=[0,1,0,0];return i.transformMat4$1(gt,gt,yt),Xt[0]=gt[0],Xt[1]=gt[1],Xt[2]=gt[2],i.normalize(Xt,Xt),Xt}(ge));for(const ut of y){const Bt=o.getTile(ut),yt=Bt.getBucket(u);if(!yt||yt.projection.name==="mercator"&&et)continue;const Xt=b?yt.text:yt.icon;if(!Xt||yt.fullyClipped||!Xt.segments.get().length)continue;const gt=Xt.programConfigurations.get(u.id),Ot=b||yt.sdfIcons,Qt=b?yt.textSizeData:yt.iconSizeData,Lt=be||ge.pitch!==0,Ct=i.evaluateSizeForZoom(Qt,ge.zoom);let zn,qn,vn,Vn,Ai=[0,0],si=null;if(b)qn=Bt.glyphAtlasTexture,vn=me.LINEAR,zn=Bt.glyphAtlasTexture.size,yt.iconsInText&&(Ai=Bt.imageAtlasTexture.size,si=Bt.imageAtlasTexture,Vn=Lt||p.options.rotating||p.options.zooming||Qt.kind==="composite"||Qt.kind==="camera"?me.LINEAR:me.NEAREST);else{const Xr=u.layout.get("icon-size").constantOr(0)!==1||yt.iconsNeedLinear;qn=Bt.imageAtlasTexture,vn=Ot||p.options.rotating||p.options.zooming||Xr||Lt?me.LINEAR:me.NEAREST,zn=Bt.imageAtlasTexture.size}const Gn=yt.projection.name==="globe",$i=Gn?Jt:ht,hr=Gn?i.globeToMercatorTransition(ge.zoom):0,mr=Oe(ut,yt.getProjection(),ge),ar=ge.calculatePixelsToTileUnitsMatrix(Bt),xr=ct(mr,Bt.tileID.canonical,be,_e,ge,yt.getProjection(),ar),us=p.terrain&&be&&ie?i.invert(i.create(),xr):yn,ko=Ci(mr,Bt.tileID.canonical,be,_e,ge,yt.getProjection(),ar),bo=Ve&&yt.hasTextData(),vr=u.layout.get("icon-text-fit")!=="none"&&bo&&yt.hasIconData();if(ie){const Xr=ge.elevation,wo=Xr?Xr.getAtTileOffsetFunc(ut,ge.center.lat,ge.worldSize,yt.getProjection()):null,Ls=Ri(mr,Bt.tileID.canonical,be,_e,ge,yt.getProjection(),ar);Ra(yt,mr,p,b,Ls,ko,be,X,wo,ut)}const gr=ie||b&&Ve||vr,ji=p.translatePosMatrix(mr,Bt,M,R),Gr=gr?yn:xr,es=p.translatePosMatrix(ko,Bt,M,R,!0),yr=yt.getProjection().createInversionMatrix(ge,ut.canonical),Ps=[];p.terrainRenderModeElevated()&&be&&Ps.push("PITCH_WITH_MAP_TERRAIN"),Gn&&Ps.push("PROJECTION_GLOBE_VIEW"),gr&&Ps.push("PROJECTED_POS_ON_VIEWPORT");const Ec=Ot&&u.paint.get(b?"text-halo-width":"icon-halo-width").constantOr(1)!==0;let Za;Za=Ot?yt.iconsInText?Va(Qt.kind,Ct,pe,be,p,ji,Gr,es,zn,Ai,ut,hr,Ge,yr,$i,yt.getProjection()):vl(Qt.kind,Ct,pe,be,p,ji,Gr,es,b,zn,!0,ut,hr,Ge,yr,$i,yt.getProjection()):Ul(Qt.kind,Ct,pe,be,p,ji,Gr,es,b,zn,ut,hr,Ge,yr,$i,yt.getProjection());const El={program:p.useProgram(Wi(Ot,b,yt),gt,Ps),buffers:Xt,uniformValues:Za,atlasTexture:qn,atlasTextureIcon:si,atlasInterpolation:vn,atlasInterpolationIcon:Vn,isSDF:Ot,hasHalo:Ec,tile:Bt,labelPlaneMatrixInv:us};if(Ee&&yt.canOverlap){Te=!0;const Xr=Xt.segments.get();for(const wo of Xr)$e.push({segments:new i.SegmentVector([wo]),sortKey:wo.sortKey,state:El})}else $e.push({segments:Xt.segments,sortKey:0,state:El})}Te&&$e.sort((ut,Bt)=>ut.sortKey-Bt.sortKey);for(const ut of $e){const Bt=ut.state;if(p.terrain&&p.terrain.setupElevationDraw(Bt.tile,Bt.program,{useDepthForOcclusion:!et,labelPlaneMatrixInv:Bt.labelPlaneMatrixInv}),he.activeTexture.set(me.TEXTURE0),Bt.atlasTexture.bind(Bt.atlasInterpolation,me.CLAMP_TO_EDGE),Bt.atlasTextureIcon&&(he.activeTexture.set(me.TEXTURE1),Bt.atlasTextureIcon&&Bt.atlasTextureIcon.bind(Bt.atlasInterpolationIcon,me.CLAMP_TO_EDGE)),Bt.isSDF){const yt=Bt.uniformValues;Bt.hasHalo&&(yt.u_is_halo=1,Ti(Bt.buffers,ut.segments,u,p,Bt.program,Ue,q,Q,yt)),yt.u_is_halo=0}Ti(Bt.buffers,ut.segments,u,p,Bt.program,Ue,q,Q,Bt.uniformValues)}}function Ti(p,o,u,y,b,M,R,z,V){const X=y.context,q=[p.dynamicLayoutVertexBuffer,p.opacityVertexBuffer,p.globeExtVertexBuffer];b.draw(X,X.gl.TRIANGLES,M,R,z,i.CullFaceMode.disabled,V,u.id,p.layoutVertexBuffer,p.indexBuffer,o,u.paint,y.transform.zoom,p.programConfigurations.get(u.id),q)}function Gs(p,o,u,y,b,M,R){const z=p.context.gl,V=u.paint.get("fill-pattern"),X=V&&V.constantOr(1);let q,Q,he,me,ge;R?(Q=X&&!u.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",q=z.LINES):(Q=X?"fillPattern":"fill",q=z.TRIANGLES);for(const _e of y){const be=o.getTile(_e);if(X&&!be.patternsLoaded())continue;const ie=be.getBucket(u);if(!ie)continue;p.prepareDrawTile();const pe=ie.programConfigurations.get(u.id),Ee=p.useProgram(Q,pe);X&&(p.context.activeTexture.set(z.TEXTURE0),be.imageAtlasTexture.bind(z.LINEAR,z.CLAMP_TO_EDGE),pe.updatePaintBuffers());const Te=V.constantOr(null);if(Te&&be.imageAtlas){const Ge=be.imageAtlas.patternPositions[Te.toString()];Ge&&pe.setConstantPatternPositions(Ge)}const Ue=p.translatePosMatrix(_e.projMatrix,be,u.paint.get("fill-translate"),u.paint.get("fill-translate-anchor"));if(R){me=ie.indexBuffer2,ge=ie.segments2;const Ge=p.terrain&&p.terrain.renderingToTexture?p.terrain.drapeBufferSize:[z.drawingBufferWidth,z.drawingBufferHeight];he=Q==="fillOutlinePattern"&&X?fc(Ue,p,be,Ge):rl(Ue,Ge)}else me=ie.indexBuffer,ge=ie.segments,he=X?il(Ue,p,be):_o(Ue);p.prepareDrawProgram(p.context,Ee,_e.toUnwrapped()),Ee.draw(p.context,q,b,p.stencilModeForClipping(_e),M,i.CullFaceMode.disabled,he,u.id,ie.layoutVertexBuffer,me,ge,u.paint,p.transform.zoom,pe)}}function Fr(p,o,u,y,b,M,R){const z=p.context,V=z.gl,X=p.transform,q=u.paint.get("fill-extrusion-pattern"),Q=q.constantOr(1),he=u.paint.get("fill-extrusion-opacity"),me=[u.paint.get("fill-extrusion-ambient-occlusion-intensity"),u.paint.get("fill-extrusion-ambient-occlusion-radius")],ge=u.layout.get("fill-extrusion-edge-radius"),_e=ge>0&&!u.paint.get("fill-extrusion-rounded-roof"),be=_e?0:ge,ie=X.projection.name==="globe"?i.fillExtrusionHeightLift():0,pe=X.projection.name==="globe",Ee=pe?i.globeToMercatorTransition(X.zoom):0,Te=[i.mercatorXfromLng(X.center.lng),i.mercatorYfromLat(X.center.lat)],Ue=[];pe&&Ue.push("PROJECTION_GLOBE_VIEW"),me[0]>0&&Ue.push("FAUX_AO"),_e&&Ue.push("ZERO_ROOF_RADIUS");for(const Ge of y){const Ve=o.getTile(Ge),et=Ve.getBucket(u);if(!et||et.projection.name!==X.projection.name)continue;const $e=et.programConfigurations.get(u.id),ht=p.useProgram(Q?"fillExtrusionPattern":"fillExtrusion",$e,Ue);if(p.terrain){const Ot=p.terrain;if(p.style.terrainSetForDrapingOnly())Ot.setupElevationDraw(Ve,ht,{useMeterToDem:!0});else{if(!et.enableTerrain)continue;if(Ot.setupElevationDraw(Ve,ht,{useMeterToDem:!0}),Vr(z,o,Ge,et,u,Ot),!et.centroidVertexBuffer){const Qt=ht.attributes.a_centroid_pos;Qt!==void 0&&V.vertexAttrib2f(Qt,0,0)}}}Q&&(p.context.activeTexture.set(V.TEXTURE0),Ve.imageAtlasTexture.bind(V.LINEAR,V.CLAMP_TO_EDGE),$e.updatePaintBuffers());const Jt=q.constantOr(null);if(Jt&&Ve.imageAtlas){const Ot=Ve.imageAtlas.patternPositions[Jt.toString()];Ot&&$e.setConstantPatternPositions(Ot)}const ut=p.translatePosMatrix(Ge.projMatrix,Ve,u.paint.get("fill-extrusion-translate"),u.paint.get("fill-extrusion-translate-anchor")),Bt=X.projection.createInversionMatrix(X,Ge.canonical),yt=u.paint.get("fill-extrusion-vertical-gradient"),Xt=Q?fs(ut,p,yt,he,me,be,Ge,Ve,ie,Ee,Te,Bt):eo(ut,p,yt,he,me,be,Ge,ie,Ee,Te,Bt);p.prepareDrawProgram(z,ht,Ge.toUnwrapped());const gt=[];p.terrain&&gt.push(et.centroidVertexBuffer),pe&&gt.push(et.layoutVertexExtBuffer),ht.draw(z,z.gl.TRIANGLES,b,M,R,i.CullFaceMode.backCCW,Xt,u.id,et.layoutVertexBuffer,et.indexBuffer,et.segments,u.paint,p.transform.zoom,$e,gt)}}function Vr(p,o,u,y,b,M){const R=[ie=>{let pe=ie.canonical.x-1,Ee=ie.wrap;return pe<0&&(pe=(1<<ie.canonical.z)-1,Ee--),new i.OverscaledTileID(ie.overscaledZ,Ee,ie.canonical.z,pe,ie.canonical.y)},ie=>{let pe=ie.canonical.x+1,Ee=ie.wrap;return pe===1<<ie.canonical.z&&(pe=0,Ee++),new i.OverscaledTileID(ie.overscaledZ,Ee,ie.canonical.z,pe,ie.canonical.y)},ie=>new i.OverscaledTileID(ie.overscaledZ,ie.wrap,ie.canonical.z,ie.canonical.x,(ie.canonical.y===0?1<<ie.canonical.z:ie.canonical.y)-1),ie=>new i.OverscaledTileID(ie.overscaledZ,ie.wrap,ie.canonical.z,ie.canonical.x,ie.canonical.y===(1<<ie.canonical.z)-1?0:ie.canonical.y+1)],z=ie=>{const pe=o.getSource().minzoom,Ee=Ue=>{const Ge=o.getTileByID(Ue);if(Ge&&Ge.hasData())return Ge.getBucket(b)},Te=[0,-1,1];for(const Ue of Te){if(ie.overscaledZ+Ue<pe)continue;const Ge=Ee(ie.calculateScaledKey(ie.overscaledZ+Ue));if(Ge)return Ge}},V=[0,0,0],X=(ie,pe)=>(V[0]=Math.min(ie.min.y,pe.min.y),V[1]=Math.max(ie.max.y,pe.max.y),V[2]=i.EXTENT-pe.min.x>ie.max.x?pe.min.x-i.EXTENT:ie.max.x,V),q=(ie,pe)=>(V[0]=Math.min(ie.min.x,pe.min.x),V[1]=Math.max(ie.max.x,pe.max.x),V[2]=i.EXTENT-pe.min.y>ie.max.y?pe.min.y-i.EXTENT:ie.max.y,V),Q=[(ie,pe)=>X(ie,pe),(ie,pe)=>X(pe,ie),(ie,pe)=>q(ie,pe),(ie,pe)=>q(pe,ie)],he=new i.Point(0,0);let me,ge,_e;const be=(ie,pe,Ee,Te,Ue)=>{const Ge=[[Te?Ee:ie,Te?ie:Ee,0],[Te?Ee:pe,Te?pe:Ee,0]],Ve=Ue<0?i.EXTENT+Ue:Ue,et=[Te?Ve:(ie+pe)/2,Te?(ie+pe)/2:Ve,0];return Ee===0&&Ue<0||Ee!==0&&Ue>0?M.getForTilePoints(_e,[et],!0,ge):Ge.push(et),M.getForTilePoints(u,Ge,!0,me),Math.max(Ge[0][2],Ge[1][2],et[2])/M.exaggeration()};for(let ie=0;ie<4;ie++){const pe=(ie<2?1:5)-ie,Ee=y.borders[ie];if(Ee.length===0)continue;const Te=_e=R[ie](u),Ue=z(Te);if(!(Ue&&Ue instanceof i.FillExtrusionBucket&&Ue.enableTerrain)||y.borderDoneWithNeighborZ[ie]===Ue.canonical.z&&Ue.borderDoneWithNeighborZ[pe]===y.canonical.z||(ge=M.findDEMTileFor(Te),!ge||!ge.dem))continue;if(!me){const $e=M.findDEMTileFor(u);if(!$e||!$e.dem)return;me=$e}const Ge=Ue.borders[pe];let Ve=0;const et=Ue.borderDoneWithNeighborZ[pe]!==y.canonical.z;if(y.canonical.z===Ue.canonical.z){for(let $e=0;$e<Ee.length;$e++){const ht=y.featuresOnBorder[Ee[$e]],Jt=ht.borders[ie];let ut;for(;Ve<Ge.length&&(ut=Ue.featuresOnBorder[Ge[Ve]],!(ut.borders[pe][1]>Jt[0]+3));)et&&Ue.encodeCentroid(void 0,ut,!1),Ve++;if(ut&&Ve<Ge.length){const Bt=Ve;let yt=0;for(;!(ut.borders[pe][0]>Jt[1]-3)&&(yt++,++Ve!==Ge.length);)ut=Ue.featuresOnBorder[Ge[Ve]];if(ut=Ue.featuresOnBorder[Ge[Bt]],ht.intersectsCount()>1||ut.intersectsCount()>1||yt!==1){yt!==1&&(Ve=Bt),y.encodeCentroid(void 0,ht,!1),et&&Ue.encodeCentroid(void 0,ut,!1);continue}const Xt=Q[ie](ht,ut),gt=ie%2?i.EXTENT-1:0;he.x=be(Xt[0],Math.min(i.EXTENT-1,Xt[1]),gt,ie<2,Xt[2]),he.y=0,y.encodeCentroid(he,ht,!1),et&&Ue.encodeCentroid(he,ut,!1)}else y.encodeCentroid(void 0,ht,!1)}y.borderDoneWithNeighborZ[ie]=Ue.canonical.z,y.needsCentroidUpdate=!0,et&&(Ue.borderDoneWithNeighborZ[pe]=y.canonical.z,Ue.needsCentroidUpdate=!0)}else{for(const $e of Ee)y.encodeCentroid(void 0,y.featuresOnBorder[$e],!1);if(et){for(const $e of Ge)Ue.encodeCentroid(void 0,Ue.featuresOnBorder[$e],!1);Ue.borderDoneWithNeighborZ[pe]=y.canonical.z,Ue.needsCentroidUpdate=!0}y.borderDoneWithNeighborZ[ie]=Ue.canonical.z,y.needsCentroidUpdate=!0}}(y.needsCentroidUpdate||!y.centroidVertexBuffer&&y.centroidVertexArray.length!==0)&&y.uploadCentroid(p)}const cs=new i.Color(1,0,0,1),Jr=new i.Color(0,1,0,1),Kr=new i.Color(0,0,1,1),pr=new i.Color(1,0,1,1),qr=new i.Color(0,1,1,1);function Zr(p,o,u){const y=p.context,b=p.transform,M=y.gl,R=b.projection.name==="globe",z=R?["PROJECTION_GLOBE_VIEW"]:null;let V=u.projMatrix;if(R&&i.globeToMercatorTransition(b.zoom)>0){const ht=i.transitionTileAABBinECEF(u.canonical,b),Jt=i.globeDenormalizeECEF(ht);V=i.multiply(new Float32Array(16),b.globeMatrix,Jt),i.multiply(V,b.projMatrix,V)}const X=p.useProgram("debug",null,z),q=o.getTileByID(u.key);p.terrain&&p.terrain.setupElevationDraw(q,X);const Q=i.DepthMode.disabled,he=i.StencilMode.disabled,me=p.colorModeForRenderPass(),ge="$debug";y.activeTexture.set(M.TEXTURE0),p.emptyTexture.bind(M.LINEAR,M.CLAMP_TO_EDGE),R?q._makeGlobeTileDebugBuffers(p.context,b):q._makeDebugTileBoundsBuffers(p.context,b.projection);const _e=q._tileDebugBuffer||p.debugBuffer,be=q._tileDebugIndexBuffer||p.debugIndexBuffer,ie=q._tileDebugSegments||p.debugSegments;X.draw(y,M.LINE_STRIP,Q,he,me,i.CullFaceMode.disabled,Vs(V,i.Color.red),ge,_e,be,ie,null,null,null,[q._globeTileDebugBorderBuffer]);const pe=q.latestRawTileData,Ee=Math.floor((pe&&pe.byteLength||0)/1024),Te=o.getTile(u).tileSize,Ue=512/Math.min(Te,512)*(u.overscaledZ/b.zoom)*.5;let Ge=u.canonical.toString();u.overscaledZ!==u.canonical.z&&(Ge+=` => ${u.overscaledZ}`),Ge+=` ${Ee}kb`,function(ht,Jt){ht.initDebugOverlayCanvas();const ut=ht.debugOverlayCanvas,Bt=ht.context.gl,yt=ht.debugOverlayCanvas.getContext("2d");yt.clearRect(0,0,ut.width,ut.height),yt.shadowColor="white",yt.shadowBlur=2,yt.lineWidth=1.5,yt.strokeStyle="white",yt.textBaseline="top",yt.font="bold 36px Open Sans, sans-serif",yt.fillText(Jt,5,5),yt.strokeText(Jt,5,5),ht.debugOverlayTexture.update(ut),ht.debugOverlayTexture.bind(Bt.LINEAR,Bt.CLAMP_TO_EDGE)}(p,Ge);const Ve=q._tileDebugTextBuffer||p.debugBuffer,et=q._tileDebugTextIndexBuffer||p.quadTriangleIndexBuffer,$e=q._tileDebugTextSegments||p.debugSegments;X.draw(y,M.TRIANGLES,Q,he,i.ColorMode.alphaBlended,i.CullFaceMode.disabled,Vs(V,i.Color.transparent,Ue),ge,Ve,et,$e,null,null,null,[q._globeTileDebugTextBuffer])}function ta(p,o,u,y){Ho(p,0,o+u/2,p.transform.width,u,y)}function Lo(p,o,u,y){Ho(p,o-u/2,0,u,p.transform.height,y)}function Ho(p,o,u,y,b,M){const R=p.context,z=R.gl;z.enable(z.SCISSOR_TEST),z.scissor(o*i.exported.devicePixelRatio,u*i.exported.devicePixelRatio,y*i.exported.devicePixelRatio,b*i.exported.devicePixelRatio),R.clear({color:M}),z.disable(z.SCISSOR_TEST)}const Eu=i.createLayout([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:ms}=Eu;function Xi(p,o,u,y){p.emplaceBack(o,u,y)}class ir{constructor(o){this.vertexArray=new i.StructArrayLayout3f12,this.indices=new i.StructArrayLayout3ui6,Xi(this.vertexArray,-1,-1,1),Xi(this.vertexArray,1,-1,1),Xi(this.vertexArray,-1,1,1),Xi(this.vertexArray,1,1,1),Xi(this.vertexArray,-1,-1,-1),Xi(this.vertexArray,1,-1,-1),Xi(this.vertexArray,-1,1,-1),Xi(this.vertexArray,1,1,-1),this.indices.emplaceBack(5,1,3),this.indices.emplaceBack(3,7,5),this.indices.emplaceBack(6,2,0),this.indices.emplaceBack(0,4,6),this.indices.emplaceBack(2,6,7),this.indices.emplaceBack(7,3,2),this.indices.emplaceBack(5,4,0),this.indices.emplaceBack(0,1,5),this.indices.emplaceBack(0,2,3),this.indices.emplaceBack(3,1,0),this.indices.emplaceBack(7,6,4),this.indices.emplaceBack(4,5,7),this.vertexBuffer=o.createVertexBuffer(this.vertexArray,ms),this.indexBuffer=o.createIndexBuffer(this.indices),this.segment=i.SegmentVector.simpleSegment(0,0,36,12)}}function gs(p,o,u,y,b,M){const R=p.gl,z=o.paint.get("sky-atmosphere-color"),V=o.paint.get("sky-atmosphere-halo-color"),X=o.paint.get("sky-atmosphere-sun-intensity"),q=((Q,he,me,ge,_e)=>({u_matrix_3f:Q,u_sun_direction:he,u_sun_intensity:me,u_color_tint_r:[ge.r,ge.g,ge.b,ge.a],u_color_tint_m:[_e.r,_e.g,_e.b,_e.a],u_luminance:5e-5}))(i.fromMat4(i.create$1(),y),b,X,z,V);R.framebufferTexture2D(R.FRAMEBUFFER,R.COLOR_ATTACHMENT0,R.TEXTURE_CUBE_MAP_POSITIVE_X+M,o.skyboxTexture,0),u.draw(p,R.TRIANGLES,i.DepthMode.disabled,i.StencilMode.disabled,i.ColorMode.unblended,i.CullFaceMode.frontCW,q,"skyboxCapture",o.skyboxGeometry.vertexBuffer,o.skyboxGeometry.indexBuffer,o.skyboxGeometry.segment)}const Qr=i.createLayout([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class xo{constructor(o){const u=new i.StructArrayLayout5f20;u.emplaceBack(-1,1,1,0,0),u.emplaceBack(1,1,1,1,0),u.emplaceBack(1,-1,1,1,1),u.emplaceBack(-1,-1,1,0,1);const y=new i.StructArrayLayout3ui6;y.emplaceBack(0,1,2),y.emplaceBack(2,3,0),this.vertexBuffer=o.createVertexBuffer(u,Qr.members),this.indexBuffer=o.createIndexBuffer(y),this.segments=i.SegmentVector.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const Br={symbol:function(p,o,u,y,b){if(p.renderPass!=="translucent")return;const M=i.StencilMode.disabled,R=p.colorModeForRenderPass();u.layout.get("text-variable-anchor")&&function(z,V,X,q,Q,he,me){const ge=V.transform,_e=Q==="map",be=he==="map";for(const ie of z){const pe=q.getTile(ie),Ee=pe.getBucket(X);if(!Ee||!Ee.text||!Ee.text.segments.get().length)continue;const Te=i.evaluateSizeForZoom(Ee.textSizeData,ge.zoom),Ue=Oe(ie,Ee.getProjection(),ge),Ge=ge.calculatePixelsToTileUnitsMatrix(pe),Ve=ct(Ue,pe.tileID.canonical,be,_e,ge,Ee.getProjection(),Ge),et=X.layout.get("icon-text-fit")!=="none"&&Ee.hasIconData();if(Te){const $e=Math.pow(2,ge.zoom-pe.tileID.overscaledZ);fr(Ee,_e,be,me,i.symbolSize,ge,Ve,ie,$e,Te,et)}}}(y,p,u,o,u.layout.get("text-rotation-alignment"),u.layout.get("text-pitch-alignment"),b),u.paint.get("icon-opacity").constantOr(1)!==0&&Pr(p,o,u,y,!1,u.paint.get("icon-translate"),u.paint.get("icon-translate-anchor"),u.layout.get("icon-rotation-alignment"),u.layout.get("icon-pitch-alignment"),u.layout.get("icon-keep-upright"),M,R),u.paint.get("text-opacity").constantOr(1)!==0&&Pr(p,o,u,y,!0,u.paint.get("text-translate"),u.paint.get("text-translate-anchor"),u.layout.get("text-rotation-alignment"),u.layout.get("text-pitch-alignment"),u.layout.get("text-keep-upright"),M,R),o.map.showCollisionBoxes&&(At(p,o,u,y,u.paint.get("text-translate"),u.paint.get("text-translate-anchor"),!0),At(p,o,u,y,u.paint.get("icon-translate"),u.paint.get("icon-translate-anchor"),!1))},circle:function(p,o,u,y){if(p.renderPass!=="translucent")return;const b=u.paint.get("circle-opacity"),M=u.paint.get("circle-stroke-width"),R=u.paint.get("circle-stroke-opacity"),z=u.layout.get("circle-sort-key").constantOr(1)!==void 0;if(b.constantOr(1)===0&&(M.constantOr(1)===0||R.constantOr(1)===0))return;const V=p.context,X=V.gl,q=p.transform,Q=p.depthModeForSublayer(0,i.DepthMode.ReadOnly),he=i.StencilMode.disabled,me=p.colorModeForRenderPass(),ge=q.projection.name==="globe",_e=[i.mercatorXfromLng(q.center.lng),i.mercatorYfromLat(q.center.lat)],be=[];for(let pe=0;pe<y.length;pe++){const Ee=y[pe],Te=o.getTile(Ee),Ue=Te.getBucket(u);if(!Ue||Ue.projection.name!==q.projection.name)continue;const Ge=Ue.programConfigurations.get(u.id),Ve=Sr(u);ge&&Ve.push("PROJECTION_GLOBE_VIEW");const et=p.useProgram("circle",Ge,Ve),$e=Ue.layoutVertexBuffer,ht=Ue.globeExtVertexBuffer,Jt=Ue.indexBuffer,ut=q.projection.createInversionMatrix(q,Ee.canonical),Bt={programConfiguration:Ge,program:et,layoutVertexBuffer:$e,globeExtVertexBuffer:ht,indexBuffer:Jt,uniformValues:Us(p,Ee,Te,ut,_e,u),tile:Te};if(z){const yt=Ue.segments.get();for(const Xt of yt)be.push({segments:new i.SegmentVector([Xt]),sortKey:Xt.sortKey,state:Bt})}else be.push({segments:Ue.segments,sortKey:0,state:Bt})}z&&be.sort((pe,Ee)=>pe.sortKey-Ee.sortKey);const ie={useDepthForOcclusion:!ge};for(const pe of be){const{programConfiguration:Ee,program:Te,layoutVertexBuffer:Ue,globeExtVertexBuffer:Ge,indexBuffer:Ve,uniformValues:et,tile:$e}=pe.state,ht=pe.segments;p.terrain&&p.terrain.setupElevationDraw($e,Te,ie),p.prepareDrawProgram(V,Te,$e.tileID.toUnwrapped()),Te.draw(V,X.TRIANGLES,Q,he,me,i.CullFaceMode.disabled,et,u.id,Ue,Ve,ht,u.paint,q.zoom,Ee,[Ge])}},heatmap:function(p,o,u,y){if(u.paint.get("heatmap-opacity")!==0)if(p.renderPass==="offscreen"){const b=p.context,M=b.gl,R=i.StencilMode.disabled,z=new i.ColorMode([M.ONE,M.ONE],i.Color.transparent,[!0,!0,!0,!0]);(function(me,ge,_e,be){const ie=me.gl,pe=ge.width*be,Ee=ge.height*be;me.activeTexture.set(ie.TEXTURE1),me.viewport.set([0,0,pe,Ee]);let Te=_e.heatmapFbo;if(!Te||Te&&(Te.width!==pe||Te.height!==Ee)){Te&&Te.destroy();const Ue=ie.createTexture();ie.bindTexture(ie.TEXTURE_2D,Ue),ie.texParameteri(ie.TEXTURE_2D,ie.TEXTURE_WRAP_S,ie.CLAMP_TO_EDGE),ie.texParameteri(ie.TEXTURE_2D,ie.TEXTURE_WRAP_T,ie.CLAMP_TO_EDGE),ie.texParameteri(ie.TEXTURE_2D,ie.TEXTURE_MIN_FILTER,ie.LINEAR),ie.texParameteri(ie.TEXTURE_2D,ie.TEXTURE_MAG_FILTER,ie.LINEAR),Te=_e.heatmapFbo=me.createFramebuffer(pe,Ee,!1),function(Ge,Ve,et,$e,ht,Jt){const ut=Ge.gl;ut.texImage2D(ut.TEXTURE_2D,0,Ge.isWebGL2&&Ge.extRenderToTextureHalfFloat?ut.RGBA16F:ut.RGBA,ht,Jt,0,ut.RGBA,Ge.extRenderToTextureHalfFloat?Ge.isWebGL2?ut.HALF_FLOAT:Ge.extTextureHalfFloat.HALF_FLOAT_OES:ut.UNSIGNED_BYTE,null),$e.colorAttachment.set(et)}(me,0,Ue,Te,pe,Ee)}else ie.bindTexture(ie.TEXTURE_2D,Te.colorAttachment.get()),me.bindFramebuffer.set(Te.framebuffer)})(b,p,u,p.transform.projection.name==="globe"?.5:.25),b.clear({color:i.Color.transparent});const V=p.transform,X=V.projection.name==="globe",q=X?["PROJECTION_GLOBE_VIEW"]:null,Q=X?i.CullFaceMode.frontCCW:i.CullFaceMode.disabled,he=[i.mercatorXfromLng(V.center.lng),i.mercatorYfromLat(V.center.lat)];for(let me=0;me<y.length;me++){const ge=y[me];if(o.hasRenderableParent(ge))continue;const _e=o.getTile(ge),be=_e.getBucket(u);if(!be||be.projection.name!==V.projection.name)continue;const ie=be.programConfigurations.get(u.id),pe=p.useProgram("heatmap",ie,q),{zoom:Ee}=p.transform;p.terrain&&p.terrain.setupElevationDraw(_e,pe),p.prepareDrawProgram(b,pe,ge.toUnwrapped());const Te=V.projection.createInversionMatrix(V,ge.canonical);pe.draw(b,M.TRIANGLES,i.DepthMode.disabled,R,z,Q,Ua(p,ge,_e,Te,he,Ee,u.paint.get("heatmap-intensity")),u.id,be.layoutVertexBuffer,be.indexBuffer,be.segments,u.paint,p.transform.zoom,ie,X?[be.globeExtVertexBuffer]:null)}b.viewport.set([0,0,p.width,p.height])}else p.renderPass==="translucent"&&(p.context.setColorMode(p.colorModeForRenderPass()),function(b,M){const R=b.context,z=R.gl,V=M.heatmapFbo;if(!V)return;R.activeTexture.set(z.TEXTURE0),z.bindTexture(z.TEXTURE_2D,V.colorAttachment.get()),R.activeTexture.set(z.TEXTURE1);let X=M.colorRampTexture;X||(X=M.colorRampTexture=new i.Texture(R,M.colorRamp,z.RGBA)),X.bind(z.LINEAR,z.CLAMP_TO_EDGE),b.useProgram("heatmapTexture").draw(R,z.TRIANGLES,i.DepthMode.disabled,i.StencilMode.disabled,b.colorModeForRenderPass(),i.CullFaceMode.disabled,((q,Q,he,me)=>({u_image:0,u_color_ramp:1,u_opacity:Q.paint.get("heatmap-opacity")}))(0,M),M.id,b.viewportBuffer,b.quadTriangleIndexBuffer,b.viewportSegments,M.paint,b.transform.zoom)}(p,u))},line:function(p,o,u,y){if(p.renderPass!=="translucent")return;const b=u.paint.get("line-opacity"),M=u.paint.get("line-width");if(b.constantOr(1)===0||M.constantOr(1)===0)return;const R=p.depthModeForSublayer(0,i.DepthMode.ReadOnly),z=p.colorModeForRenderPass(),V=p.terrain&&p.terrain.renderingToTexture?1:i.exported.devicePixelRatio,X=u.paint.get("line-dasharray"),q=X.constantOr(1),Q=u.layout.get("line-cap"),he=u.paint.get("line-pattern"),me=he.constantOr(1),ge=u.paint.get("line-gradient"),_e=me?"linePattern":"line",be=p.context,ie=be.gl,pe=(Te=>{const Ue=[];Wo(Te)&&Ue.push("RENDER_LINE_DASH"),Te.paint.get("line-gradient")&&Ue.push("RENDER_LINE_GRADIENT");const Ge=Te.paint.get("line-trim-offset");Ge[0]===0&&Ge[1]===0||Ue.push("RENDER_LINE_TRIM_OFFSET");const Ve=Te.paint.get("line-pattern").constantOr(1),et=Te.paint.get("line-opacity").constantOr(1)!==1;return!Ve&&et&&Ue.push("RENDER_LINE_ALPHA_DISCARD"),Ue})(u);let Ee=pe.includes("RENDER_LINE_ALPHA_DISCARD");p.terrain&&p.terrain.clipOrMaskOverlapStencilType()&&(Ee=!1);for(const Te of y){const Ue=o.getTile(Te);if(me&&!Ue.patternsLoaded())continue;const Ge=Ue.getBucket(u);if(!Ge)continue;p.prepareDrawTile();const Ve=Ge.programConfigurations.get(u.id),et=p.useProgram(_e,Ve,pe),$e=he.constantOr(null);if($e&&Ue.imageAtlas){const Ot=Ue.imageAtlas.patternPositions[$e.toString()];Ot&&Ve.setConstantPatternPositions(Ot)}const ht=X.constantOr(null),Jt=Q.constantOr(null);if(!me&&ht&&Jt&&Ue.lineAtlas){const Ot=Ue.lineAtlas.getDash(ht,Jt);Ot&&Ve.setConstantPatternPositions(Ot)}let[ut,Bt]=u.paint.get("line-trim-offset");(Jt==="round"||Jt==="square")&&ut!==Bt&&(ut===0&&(ut-=1),Bt===1&&(Bt+=1));const yt=p.terrain?Te.projMatrix:null,Xt=me?no(p,Ue,u,yt,V):Zc(p,Ue,u,yt,Ge.lineClipsArray.length,V,[ut,Bt]);if(ge){const Ot=Ge.gradients[u.id];let Qt=Ot.texture;if(u.gradientVersion!==Ot.version){let Lt=256;if(u.stepInterpolant){const Ct=o.getSource().maxzoom,zn=Te.canonical.z===Ct?Math.ceil(1<<p.transform.maxZoom-Te.canonical.z):1;Lt=i.clamp(i.nextPowerOfTwo(Ge.maxLineLength/i.EXTENT*1024*zn),256,be.maxTextureSize)}Ot.gradient=i.renderColorRamp({expression:u.gradientExpression(),evaluationKey:"lineProgress",resolution:Lt,image:Ot.gradient||void 0,clips:Ge.lineClipsArray}),Ot.texture?Ot.texture.update(Ot.gradient):Ot.texture=new i.Texture(be,Ot.gradient,ie.RGBA),Ot.version=u.gradientVersion,Qt=Ot.texture}be.activeTexture.set(ie.TEXTURE1),Qt.bind(u.stepInterpolant?ie.NEAREST:ie.LINEAR,ie.CLAMP_TO_EDGE)}q&&(be.activeTexture.set(ie.TEXTURE0),Ue.lineAtlasTexture.bind(ie.LINEAR,ie.REPEAT),Ve.updatePaintBuffers()),me&&(be.activeTexture.set(ie.TEXTURE0),Ue.imageAtlasTexture.bind(ie.LINEAR,ie.CLAMP_TO_EDGE),Ve.updatePaintBuffers()),p.prepareDrawProgram(be,et,Te.toUnwrapped());const gt=Ot=>{et.draw(be,ie.TRIANGLES,R,Ot,z,i.CullFaceMode.disabled,Xt,u.id,Ge.layoutVertexBuffer,Ge.indexBuffer,Ge.segments,u.paint,p.transform.zoom,Ve,[Ge.layoutVertexBuffer2])};if(Ee){const Ot=p.stencilModeForClipping(Te).ref;Ot===0&&p.terrain&&be.clear({stencil:0});const Qt={func:ie.EQUAL,mask:255};Xt.u_alpha_discard_threshold=.8,gt(new i.StencilMode(Qt,Ot,255,ie.KEEP,ie.KEEP,ie.INVERT)),Xt.u_alpha_discard_threshold=0,gt(new i.StencilMode(Qt,Ot,255,ie.KEEP,ie.KEEP,ie.KEEP))}else gt(p.stencilModeForClipping(Te))}Ee&&(p.resetStencilClippingMasks(),p.terrain&&be.clear({stencil:0}))},fill:function(p,o,u,y){const b=u.paint.get("fill-color"),M=u.paint.get("fill-opacity");if(M.constantOr(1)===0)return;const R=p.colorModeForRenderPass(),z=u.paint.get("fill-pattern"),V=p.opaquePassEnabledForLayer()&&!z.constantOr(1)&&b.constantOr(i.Color.transparent).a===1&&M.constantOr(0)===1?"opaque":"translucent";if(p.renderPass===V){const X=p.depthModeForSublayer(1,p.renderPass==="opaque"?i.DepthMode.ReadWrite:i.DepthMode.ReadOnly);Gs(p,o,u,y,X,R,!1)}if(p.renderPass==="translucent"&&u.paint.get("fill-antialias")){const X=p.depthModeForSublayer(u.getPaintProperty("fill-outline-color")?2:0,i.DepthMode.ReadOnly);Gs(p,o,u,y,X,R,!0)}},"fill-extrusion":function(p,o,u,y){const b=u.paint.get("fill-extrusion-opacity");if(b!==0&&p.renderPass==="translucent"){const M=new i.DepthMode(p.context.gl.LEQUAL,i.DepthMode.ReadWrite,p.depthRangeFor3D);if(b!==1||u.paint.get("fill-extrusion-pattern").constantOr(1))Fr(p,o,u,y,M,i.StencilMode.disabled,i.ColorMode.disabled),Fr(p,o,u,y,M,p.stencilModeFor3D(),p.colorModeForRenderPass()),p.resetStencilClippingMasks();else{const R=p.colorModeForRenderPass();Fr(p,o,u,y,M,i.StencilMode.disabled,R)}}},hillshade:function(p,o,u,y){if(p.renderPass!=="offscreen"&&p.renderPass!=="translucent")return;const b=p.context,M=p.depthModeForSublayer(0,i.DepthMode.ReadOnly),R=p.colorModeForRenderPass(),z=p.terrain&&p.terrain.renderingToTexture,[V,X]=p.renderPass!=="translucent"||z?[{},y]:p.stencilConfigForOverlap(y);for(const q of X){const Q=o.getTile(q);if(Q.needsHillshadePrepare&&p.renderPass==="offscreen")Fl(p,Q,u,M,i.StencilMode.disabled,R);else if(p.renderPass==="translucent"){const he=z&&p.terrain?p.terrain.stencilModeForRTTOverlap(q):V[q.overscaledZ];Cs(p,q,Q,u,M,he,R)}}b.viewport.set([0,0,p.width,p.height]),p.resetStencilClippingMasks()},raster:function(p,o,u,y,b,M){if(p.renderPass!=="translucent"||u.paint.get("raster-opacity")===0||!y.length)return;const R=p.context,z=R.gl,V=o.getSource(),X=p.useProgram("raster"),q=p.colorModeForRenderPass(),Q=p.terrain&&p.terrain.renderingToTexture,[he,me]=V instanceof ci||Q?[{},y]:p.stencilConfigForOverlap(y),ge=me[me.length-1].overscaledZ,_e=!p.options.moving;for(const be of me){const ie=Q?i.DepthMode.disabled:p.depthModeForSublayer(be.overscaledZ-ge,u.paint.get("raster-opacity")===1?i.DepthMode.ReadWrite:i.DepthMode.ReadOnly,z.LESS),pe=be.toUnwrapped(),Ee=o.getTile(be);if(Q&&(!Ee||!Ee.hasData()))continue;const Te=Q?be.projMatrix:p.transform.calculateProjMatrix(pe,_e),Ue=p.terrain&&Q?p.terrain.stencilModeForRTTOverlap(be):he[be.overscaledZ],Ge=M?0:u.paint.get("raster-fade-duration");Ee.registerFadeDuration(Ge);const Ve=o.findLoadedParent(be,0),et=Bl(Ee,Ve,o,p.transform,Ge);let $e,ht;p.terrain&&p.terrain.prepareDrawTile();const Jt=u.paint.get("raster-resampling")==="nearest"?z.NEAREST:z.LINEAR;R.activeTexture.set(z.TEXTURE0),Ee.texture.bind(Jt,z.CLAMP_TO_EDGE),R.activeTexture.set(z.TEXTURE1),Ve?(Ve.texture.bind(Jt,z.CLAMP_TO_EDGE),$e=Math.pow(2,Ve.tileID.overscaledZ-Ee.tileID.overscaledZ),ht=[Ee.tileID.canonical.x*$e%1,Ee.tileID.canonical.y*$e%1]):Ee.texture.bind(Jt,z.CLAMP_TO_EDGE),Ee.texture.useMipmap&&R.extTextureFilterAnisotropic&&p.transform.pitch>20&&z.texParameterf(z.TEXTURE_2D,R.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,R.extTextureFilterAnisotropicMax);const ut=Nl(Te,ht||[0,0],$e||1,et,u,V instanceof ci?V.perspectiveTransform:[0,0]);if(p.prepareDrawProgram(R,X,pe),V instanceof ci)V.boundsBuffer&&V.boundsSegments&&X.draw(R,z.TRIANGLES,ie,i.StencilMode.disabled,q,i.CullFaceMode.disabled,ut,u.id,V.boundsBuffer,p.quadTriangleIndexBuffer,V.boundsSegments);else{const{tileBoundsBuffer:Bt,tileBoundsIndexBuffer:yt,tileBoundsSegments:Xt}=p.getTileBoundsBuffers(Ee);X.draw(R,z.TRIANGLES,ie,Ue,q,i.CullFaceMode.disabled,ut,u.id,Bt,yt,Xt)}}p.resetStencilClippingMasks()},background:function(p,o,u,y){const b=u.paint.get("background-color"),M=u.paint.get("background-opacity");if(M===0)return;const R=p.context,z=R.gl,V=p.transform,X=V.tileSize,q=u.paint.get("background-pattern");if(p.isPatternMissing(q))return;const Q=!q&&b.a===1&&M===1&&p.opaquePassEnabledForLayer()?"opaque":"translucent";if(p.renderPass!==Q)return;const he=i.StencilMode.disabled,me=p.depthModeForSublayer(0,Q==="opaque"?i.DepthMode.ReadWrite:i.DepthMode.ReadOnly),ge=p.colorModeForRenderPass(),_e=p.useProgram(q?"backgroundPattern":"background");let be,ie=y;ie||(be=p.getBackgroundTiles(),ie=Object.values(be).map(pe=>pe.tileID)),q&&(R.activeTexture.set(z.TEXTURE0),p.imageManager.bind(p.context));for(const pe of ie){const Ee=pe.toUnwrapped(),Te=y?pe.projMatrix:p.transform.calculateProjMatrix(Ee);p.prepareDrawTile();const Ue=o?o.getTile(pe):be?be[pe.key]:new i.Tile(pe,X,V.zoom,p),Ge=q?bl(Te,M,p,q,{tileID:pe,tileSize:X}):Ga(Te,M,b);p.prepareDrawProgram(R,_e,Ee);const{tileBoundsBuffer:Ve,tileBoundsIndexBuffer:et,tileBoundsSegments:$e}=p.getTileBoundsBuffers(Ue);_e.draw(R,z.TRIANGLES,me,he,ge,i.CullFaceMode.disabled,Ge,u.id,Ve,et,$e)}},sky:function(p,o,u){const y=p.transform,b=y.projection.name==="mercator"||y.projection.name==="globe"?1:i.smoothstep(7,8,y.zoom),M=u.paint.get("sky-opacity")*b;if(M===0)return;const R=p.context,z=u.paint.get("sky-type"),V=new i.DepthMode(R.gl.LEQUAL,i.DepthMode.ReadOnly,[0,1]),X=p.frameCounter/1e3%1;z==="atmosphere"?p.renderPass==="offscreen"?u.needsSkyboxCapture(p)&&(function(q,Q,he,me){const ge=q.context,_e=ge.gl;let be=Q.skyboxFbo;if(!be){be=Q.skyboxFbo=ge.createFramebuffer(32,32,!1),Q.skyboxGeometry=new ir(ge),Q.skyboxTexture=ge.gl.createTexture(),_e.bindTexture(_e.TEXTURE_CUBE_MAP,Q.skyboxTexture),_e.texParameteri(_e.TEXTURE_CUBE_MAP,_e.TEXTURE_WRAP_S,_e.CLAMP_TO_EDGE),_e.texParameteri(_e.TEXTURE_CUBE_MAP,_e.TEXTURE_WRAP_T,_e.CLAMP_TO_EDGE),_e.texParameteri(_e.TEXTURE_CUBE_MAP,_e.TEXTURE_MIN_FILTER,_e.LINEAR),_e.texParameteri(_e.TEXTURE_CUBE_MAP,_e.TEXTURE_MAG_FILTER,_e.LINEAR);for(let Te=0;Te<6;++Te)_e.texImage2D(_e.TEXTURE_CUBE_MAP_POSITIVE_X+Te,0,_e.RGBA,32,32,0,_e.RGBA,_e.UNSIGNED_BYTE,null)}ge.bindFramebuffer.set(be.framebuffer),ge.viewport.set([0,0,32,32]);const ie=Q.getCenter(q,!0),pe=q.useProgram("skyboxCapture"),Ee=new Float64Array(16);i.identity(Ee),i.rotateY(Ee,Ee,.5*-Math.PI),gs(ge,Q,pe,Ee,ie,0),i.identity(Ee),i.rotateY(Ee,Ee,.5*Math.PI),gs(ge,Q,pe,Ee,ie,1),i.identity(Ee),i.rotateX(Ee,Ee,.5*-Math.PI),gs(ge,Q,pe,Ee,ie,2),i.identity(Ee),i.rotateX(Ee,Ee,.5*Math.PI),gs(ge,Q,pe,Ee,ie,3),i.identity(Ee),gs(ge,Q,pe,Ee,ie,4),i.identity(Ee),i.rotateY(Ee,Ee,Math.PI),gs(ge,Q,pe,Ee,ie,5),ge.viewport.set([0,0,q.width,q.height])}(p,u),u.markSkyboxValid(p)):p.renderPass==="sky"&&function(q,Q,he,me,ge){const _e=q.context,be=_e.gl,ie=q.transform,pe=q.useProgram("skybox");_e.activeTexture.set(be.TEXTURE0),be.bindTexture(be.TEXTURE_CUBE_MAP,Q.skyboxTexture);const Ee=((Te,Ue,Ge,Ve,et)=>({u_matrix:Te,u_sun_direction:Ue,u_cubemap:0,u_opacity:Ve,u_temporal_offset:et}))(ie.skyboxMatrix,Q.getCenter(q,!1),0,me,ge);q.prepareDrawProgram(_e,pe),pe.draw(_e,be.TRIANGLES,he,i.StencilMode.disabled,q.colorModeForRenderPass(),i.CullFaceMode.backCW,Ee,"skybox",Q.skyboxGeometry.vertexBuffer,Q.skyboxGeometry.indexBuffer,Q.skyboxGeometry.segment)}(p,u,V,M,X):z==="gradient"&&p.renderPass==="sky"&&function(q,Q,he,me,ge){const _e=q.context,be=_e.gl,ie=q.transform,pe=q.useProgram("skyboxGradient");Q.skyboxGeometry||(Q.skyboxGeometry=new ir(_e)),_e.activeTexture.set(be.TEXTURE0);let Ee=Q.colorRampTexture;Ee||(Ee=Q.colorRampTexture=new i.Texture(_e,Q.colorRamp,be.RGBA)),Ee.bind(be.LINEAR,be.CLAMP_TO_EDGE);const Te=((Ue,Ge,Ve,et,$e)=>({u_matrix:Ue,u_color_ramp:0,u_center_direction:Ge,u_radius:i.degToRad(Ve),u_opacity:et,u_temporal_offset:$e}))(ie.skyboxMatrix,Q.getCenter(q,!1),Q.paint.get("sky-gradient-radius"),me,ge);q.prepareDrawProgram(_e,pe),pe.draw(_e,be.TRIANGLES,he,i.StencilMode.disabled,q.colorModeForRenderPass(),i.CullFaceMode.backCW,Te,"skyboxGradient",Q.skyboxGeometry.vertexBuffer,Q.skyboxGeometry.indexBuffer,Q.skyboxGeometry.segment)}(p,u,V,M,X)},debug:function(p,o,u){for(let y=0;y<u.length;y++)Zr(p,o,u[y])},custom:function(p,o,u,y){const b=p.context,M=u.implementation;if(!p.transform.projection.unsupportedLayers||!p.transform.projection.unsupportedLayers.includes("custom")||p.terrain&&(p.terrain.renderingToTexture||p.renderPass==="offscreen")&&u.isLayerDraped()){if(p.renderPass==="offscreen"){const R=M.prerender;if(R){if(p.setCustomLayerDefaults(),b.setColorMode(p.colorModeForRenderPass()),p.transform.projection.name==="globe"){const z=p.transform.pointMerc;R.call(M,b.gl,p.transform.customLayerMatrix(),p.transform.getProjection(),p.transform.globeToMercatorMatrix(),i.globeToMercatorTransition(p.transform.zoom),[z.x,z.y],p.transform.pixelsPerMeterRatio)}else R.call(M,b.gl,p.transform.customLayerMatrix());b.setDirty(),p.setBaseState()}}else if(p.renderPass==="translucent"){if(p.terrain&&p.terrain.renderingToTexture){const z=M.renderToTile;if(z){const V=y[0].canonical,X=new i.MercatorCoordinate(V.x+y[0].wrap*(1<<V.z),V.y,V.z);b.setDepthMode(i.DepthMode.disabled),b.setStencilMode(i.StencilMode.disabled),b.setColorMode(p.colorModeForRenderPass()),p.setCustomLayerDefaults(),z.call(M,b.gl,X),b.setDirty(),p.setBaseState()}return}p.setCustomLayerDefaults(),b.setColorMode(p.colorModeForRenderPass()),b.setStencilMode(i.StencilMode.disabled);const R=M.renderingMode==="3d"?new i.DepthMode(p.context.gl.LEQUAL,i.DepthMode.ReadWrite,p.depthRangeFor3D):p.depthModeForSublayer(0,i.DepthMode.ReadOnly);if(b.setDepthMode(R),p.transform.projection.name==="globe"){const z=p.transform.pointMerc;M.render(b.gl,p.transform.customLayerMatrix(),p.transform.getProjection(),p.transform.globeToMercatorMatrix(),i.globeToMercatorTransition(p.transform.zoom),[z.x,z.y],p.transform.pixelsPerMeterRatio)}else M.render(b.gl,p.transform.customLayerMatrix());b.setDirty(),p.setBaseState(),b.bindFramebuffer.set(null)}}else i.warnOnce("Custom layers are not yet supported with this projection. Use mercator or globe to enable usage of custom layers.")}};class _s{constructor(o,u,y=!1){this.context=new Zt(o,y),this.transform=u,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.setup(),this.numSublayers=i.SourceCache.maxUnderzooming+i.SourceCache.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.deferredRenderGpuTimeQueries=[],this.gpuTimers={},this.frameCounter=0,this._backgroundTiles={}}updateTerrain(o,u){const y=!!o&&!!o.terrain&&this.transform.projection.supportsTerrain;if(!(y||this._terrain&&this._terrain.enabled))return;this._terrain||(this._terrain=new Ba(this,o));const b=this._terrain;this.transform.elevation=y?b:null,b.update(o,this.transform,u)}_updateFog(o){const u=o.fog;if(!u||this.transform.projection.name==="globe"||u.getOpacity(this.transform.pitch)<1||u.properties.get("horizon-blend")<.03)return void(this.transform.fogCullDistSq=null);const[y,b]=u.getFovAdjustedRange(this.transform._fov);if(y>b)return void(this.transform.fogCullDistSq=null);const M=y+.78*(b-y);this.transform.fogCullDistSq=M*M}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled?this._terrain:null}resize(o,u){if(this.width=o*i.exported.devicePixelRatio,this.height=u*i.exported.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const y of this.style.order)this.style._layers[y].resize()}setup(){const o=this.context,u=new i.StructArrayLayout2i4;u.emplaceBack(0,0),u.emplaceBack(i.EXTENT,0),u.emplaceBack(0,i.EXTENT),u.emplaceBack(i.EXTENT,i.EXTENT),this.tileExtentBuffer=o.createVertexBuffer(u,i.posAttributes.members),this.tileExtentSegments=i.SegmentVector.simpleSegment(0,0,4,2);const y=new i.StructArrayLayout2i4;y.emplaceBack(0,0),y.emplaceBack(i.EXTENT,0),y.emplaceBack(0,i.EXTENT),y.emplaceBack(i.EXTENT,i.EXTENT),this.debugBuffer=o.createVertexBuffer(y,i.posAttributes.members),this.debugSegments=i.SegmentVector.simpleSegment(0,0,4,5);const b=new i.StructArrayLayout2i4;b.emplaceBack(-1,-1),b.emplaceBack(1,-1),b.emplaceBack(-1,1),b.emplaceBack(1,1),this.viewportBuffer=o.createVertexBuffer(b,i.posAttributes.members),this.viewportSegments=i.SegmentVector.simpleSegment(0,0,4,2);const M=new i.StructArrayLayout4i8;M.emplaceBack(0,0,0,0),M.emplaceBack(i.EXTENT,0,i.EXTENT,0),M.emplaceBack(0,i.EXTENT,0,i.EXTENT),M.emplaceBack(i.EXTENT,i.EXTENT,i.EXTENT,i.EXTENT),this.mercatorBoundsBuffer=o.createVertexBuffer(M,i.boundsAttributes.members),this.mercatorBoundsSegments=i.SegmentVector.simpleSegment(0,0,4,2);const R=new i.StructArrayLayout3ui6;R.emplaceBack(0,1,2),R.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=o.createIndexBuffer(R);const z=new i.StructArrayLayout1ui2;for(const X of[0,1,3,2,0])z.emplaceBack(X);this.debugIndexBuffer=o.createIndexBuffer(z),this.emptyTexture=new i.Texture(o,new i.RGBAImage({width:1,height:1},Uint8Array.of(0,0,0,0)),o.gl.RGBA),this.identityMat=i.create();const V=this.context.gl;this.stencilClearMode=new i.StencilMode({func:V.ALWAYS,mask:0},0,255,V.ZERO,V.ZERO,V.ZERO),this.loadTimeStamps.push(i.window.performance.now()),this.atmosphereBuffer=new xo(this.context)}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(o){return o._makeTileBoundsBuffers(this.context,this.transform.projection),o._tileBoundsBuffer?{tileBoundsBuffer:o._tileBoundsBuffer,tileBoundsIndexBuffer:o._tileBoundsIndexBuffer,tileBoundsSegments:o._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const o=this.context,u=o.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.useProgram("clippingMask").draw(o,u.TRIANGLES,i.DepthMode.disabled,this.stencilClearMode,i.ColorMode.disabled,i.CullFaceMode.disabled,yl(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(o,u,y){if(!u||this.currentStencilSource===u.id||!o.isTileClipped()||!y||y.length===0)return;if(this._tileClippingMaskIDs&&!this.terrain){let z=!1;for(const V of y)if(this._tileClippingMaskIDs[V.key]===void 0){z=!0;break}if(!z)return}this.currentStencilSource=u.id;const b=this.context,M=b.gl;this.nextStencilID+y.length>256&&this.clearStencil(),b.setColorMode(i.ColorMode.disabled),b.setDepthMode(i.DepthMode.disabled);const R=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const z of y){const V=u.getTile(z),X=this._tileClippingMaskIDs[z.key]=this.nextStencilID++,{tileBoundsBuffer:q,tileBoundsIndexBuffer:Q,tileBoundsSegments:he}=this.getTileBoundsBuffers(V);R.draw(b,M.TRIANGLES,i.DepthMode.disabled,new i.StencilMode({func:M.ALWAYS,mask:0},X,255,M.KEEP,M.KEEP,M.REPLACE),i.ColorMode.disabled,i.CullFaceMode.disabled,yl(z.projMatrix),"$clipping",q,Q,he)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const o=this.nextStencilID++,u=this.context.gl;return new i.StencilMode({func:u.NOTEQUAL,mask:255},o,255,u.KEEP,u.KEEP,u.REPLACE)}stencilModeForClipping(o){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(o);const u=this.context.gl;return new i.StencilMode({func:u.EQUAL,mask:255},this._tileClippingMaskIDs[o.key],0,u.KEEP,u.KEEP,u.REPLACE)}stencilConfigForOverlap(o){const u=this.context.gl,y=o.sort((R,z)=>z.overscaledZ-R.overscaledZ),b=y[y.length-1].overscaledZ,M=y[0].overscaledZ-b+1;if(M>1){this.currentStencilSource=void 0,this.nextStencilID+M>256&&this.clearStencil();const R={};for(let z=0;z<M;z++)R[z+b]=new i.StencilMode({func:u.GEQUAL,mask:255},z+this.nextStencilID,255,u.KEEP,u.KEEP,u.REPLACE);return this.nextStencilID+=M,[R,y]}return[{[b]:i.StencilMode.disabled},y]}colorModeForRenderPass(){const o=this.context.gl;return this._showOverdrawInspector?new i.ColorMode([o.CONSTANT_COLOR,o.ONE],new i.Color(.125,.125,.125,0),[!0,!0,!0,!0]):this.renderPass==="opaque"?i.ColorMode.unblended:i.ColorMode.alphaBlended}depthModeForSublayer(o,u,y){if(!this.opaquePassEnabledForLayer())return i.DepthMode.disabled;const b=1-((1+this.currentLayer)*this.numSublayers+o)*this.depthEpsilon;return new i.DepthMode(y||this.context.gl.LEQUAL,u,[b,b])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(o,u){this.style=o,this.options=u,this.imageManager=o.imageManager,this.glyphManager=o.glyphManager,this.symbolFadeChange=o.placement.symbolFadeChange(i.exported.now()),this.imageManager.beginFrame();const y=this.style.order,b=this.style._sourceCaches;for(const X in b){const q=b[X];q.used&&q.prepare(this.context)}const M={},R={},z={};for(const X in b){const q=b[X];M[X]=q.getVisibleCoordinates(),R[X]=M[X].slice().reverse(),z[X]=q.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let X=0;X<y.length;X++)if(this.style._layers[y[X]].is3D()){this.opaquePassCutoff=X;break}if(this.terrain&&(this.terrain.updateTileBinding(z),this.opaquePassCutoff=0),this.transform.projection.name!=="globe"||this.globeSharedBuffers||(this.globeSharedBuffers=new i.GlobeSharedBuffers(this.context)),!i.isMapAuthenticated(this.context.gl))return;this.renderPass="offscreen";for(const X of y){const q=this.style._layers[X],Q=o._getLayerSourceCache(q);if(!q.hasOffscreenPass()||q.isHidden(this.transform.zoom))continue;const he=Q?R[Q.id]:void 0;(q.type==="custom"||q.isSky()||he&&he.length)&&this.renderLayer(this,Q,q,he)}this.depthRangeFor3D=[0,1-(o.order.length+2)*this.numSublayers*this.depthEpsilon];const V=this.terrain;if(V&&(this.style.hasSymbolLayers()||this.style.hasCircleLayers())&&V.drawDepth(),this.context.bindFramebuffer.set(null),this.context.viewport.set([0,0,this.width,this.height]),this.context.clear({color:u.showOverdrawInspector?i.Color.black:i.Color.transparent,depth:1}),this.clearStencil(),this._showOverdrawInspector=u.showOverdrawInspector,this.renderPass="opaque",!this.terrain)for(this.currentLayer=y.length-1;this.currentLayer>=0;this.currentLayer--){const X=this.style._layers[y[this.currentLayer]],q=o._getLayerSourceCache(X);if(X.isSky())continue;const Q=q?R[q.id]:void 0;this._renderTileClippingMasks(X,q,Q),this.renderLayer(this,q,X,Q)}if(this.style.fog&&this.transform.projection.supportsFog&&function(X,q){const Q=X.context,he=Q.gl,me=X.transform,ge=new i.DepthMode(he.LEQUAL,i.DepthMode.ReadOnly,[0,1]),_e=X.useProgram("globeAtmosphere",null,me.projection.name==="globe"?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"]),be=i.globeToMercatorTransition(me.zoom),ie=q.properties.get("color").toArray01(),pe=q.properties.get("high-color").toArray01(),Ee=q.properties.get("space-color").toArray01PremultipliedAlpha(),Te=i.identity$1([]);i.rotateY$1(Te,Te,-i.degToRad(me._center.lng)),i.rotateX$1(Te,Te,i.degToRad(me._center.lat)),i.rotateZ$1(Te,Te,me.angle),i.rotateX$1(Te,Te,-me._pitch);const Ue=i.fromQuat(new Float32Array(16),Te),Ge=i.mapValue(q.properties.get("star-intensity"),0,1,0,.25),Ve=5e-4,et=i.mapValue(q.properties.get("horizon-blend"),0,1,Ve,.25),$e=i.globeUseCustomAntiAliasing(X,Q,me)&&et===Ve?me.worldSize/(2*Math.PI*1.025)-1:me.globeRadius,ht=X.frameCounter/1e3%1,Jt=i.length(me.globeCenterInViewSpace),ut=Math.sqrt(Math.pow(Jt,2)-Math.pow($e,2)),Bt=Math.acos(ut/Jt),yt=((gt,Ot,Qt,Lt,Ct,zn,qn,vn,Vn,Ai,si,Gn,$i,hr)=>({u_frustum_tl:gt,u_frustum_tr:Ot,u_frustum_br:Qt,u_frustum_bl:Lt,u_horizon:Ct,u_transition:zn,u_fadeout_range:qn,u_color:vn,u_high_color:Vn,u_space_color:Ai,u_star_intensity:si,u_star_size:5*i.exported.devicePixelRatio,u_star_density:0,u_temporal_offset:Gn,u_horizon_angle:$i,u_rotation_matrix:hr}))(me.frustumCorners.TL,me.frustumCorners.TR,me.frustumCorners.BR,me.frustumCorners.BL,me.frustumCorners.horizon,be,et,ie,pe,Ee,Ge,ht,Bt,Ue);X.prepareDrawProgram(Q,_e);const Xt=X.atmosphereBuffer;Xt&&_e.draw(Q,he.TRIANGLES,ge,i.StencilMode.disabled,i.ColorMode.alphaBlended,i.CullFaceMode.backCW,yt,"skybox",Xt.vertexBuffer,Xt.indexBuffer,Xt.segments)}(this,this.style.fog),this.renderPass="sky",(i.globeToMercatorTransition(this.transform.zoom)>0||this.transform.projection.name!=="globe")&&this.transform.isHorizonVisible())for(this.currentLayer=0;this.currentLayer<y.length;this.currentLayer++){const X=this.style._layers[y[this.currentLayer]],q=o._getLayerSourceCache(X);X.isSky()&&this.renderLayer(this,q,X,q?R[q.id]:void 0)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer<y.length;){const X=this.style._layers[y[this.currentLayer]],q=o._getLayerSourceCache(X);if(X.isSky()){++this.currentLayer;continue}if(this.terrain&&this.style.isLayerDraped(X)){if(X.isHidden(this.transform.zoom)){++this.currentLayer;continue}this.currentLayer=this.terrain.renderBatch(this.currentLayer);continue}const Q=q?(X.type==="symbol"?z:R)[q.id]:void 0;this._renderTileClippingMasks(X,q,q?M[q.id]:void 0),this.renderLayer(this,q,X,Q),++this.currentLayer}if(this.terrain&&this.terrain.postRender(),this.options.showTileBoundaries||this.options.showQueryGeometry||this.options.showTileAABBs){let X=null;i.values(this.style._layers).forEach(q=>{const Q=o._getLayerSourceCache(q);Q&&!q.isHidden(this.transform.zoom)&&(!X||X.getSource().maxzoom<Q.getSource().maxzoom)&&(X=Q)}),X&&this.options.showTileBoundaries&&Br.debug(this,X,X.getVisibleCoordinates())}this.options.showPadding&&function(X){const q=X.transform.padding;ta(X,X.transform.height-(q.top||0),3,cs),ta(X,q.bottom||0,3,Jr),Lo(X,q.left||0,3,Kr),Lo(X,X.transform.width-(q.right||0),3,pr);const Q=X.transform.centerPoint;(function(he,me,ge,_e){Ho(he,me-1,ge-10,2,20,_e),Ho(he,me-10,ge-1,20,2,_e)})(X,Q.x,X.transform.height-Q.y,qr)}(this),this.context.setDefault(),this.frameCounter=(this.frameCounter+1)%Number.MAX_SAFE_INTEGER,this.tileLoaded&&this.options.speedIndexTiming&&(this.loadTimeStamps.push(i.window.performance.now()),this.saveCanvasCopy())}renderLayer(o,u,y,b){y.isHidden(this.transform.zoom)||(y.type==="background"||y.type==="sky"||y.type==="custom"||b&&b.length)&&(this.id=y.id,this.gpuTimingStart(y),(!o.transform.projection.unsupportedLayers||!o.transform.projection.unsupportedLayers.includes(y.type)||o.terrain&&y.type==="custom")&&Br[y.type](o,u,y,b,this.style.placement.variableOffsets,this.options.isInitialLoad),this.gpuTimingEnd())}gpuTimingStart(o){if(!this.options.gpuTiming)return;const u=this.context.extTimerQuery;let y=this.gpuTimers[o.id];y||(y=this.gpuTimers[o.id]={calls:0,cpuTime:0,query:u.createQueryEXT()}),y.calls++,u.beginQueryEXT(u.TIME_ELAPSED_EXT,y.query)}gpuTimingDeferredRenderStart(){if(this.options.gpuTimingDeferredRender){const o=this.context.extTimerQuery,u=o.createQueryEXT();this.deferredRenderGpuTimeQueries.push(u),o.beginQueryEXT(o.TIME_ELAPSED_EXT,u)}}gpuTimingDeferredRenderEnd(){if(!this.options.gpuTimingDeferredRender)return;const o=this.context.extTimerQuery;o.endQueryEXT(o.TIME_ELAPSED_EXT)}gpuTimingEnd(){if(!this.options.gpuTiming)return;const o=this.context.extTimerQuery;o.endQueryEXT(o.TIME_ELAPSED_EXT)}collectGpuTimers(){const o=this.gpuTimers;return this.gpuTimers={},o}collectDeferredRenderGpuQueries(){const o=this.deferredRenderGpuTimeQueries;return this.deferredRenderGpuTimeQueries=[],o}queryGpuTimers(o){const u={};for(const y in o){const b=o[y],M=this.context.extTimerQuery,R=M.getQueryObjectEXT(b.query,M.QUERY_RESULT_EXT)/1e6;M.deleteQueryEXT(b.query),u[y]=R}return u}queryGpuTimeDeferredRender(o){if(!this.options.gpuTimingDeferredRender)return 0;const u=this.context.extTimerQuery;let y=0;for(const b of o)y+=u.getQueryObjectEXT(b,u.QUERY_RESULT_EXT)/1e6,u.deleteQueryEXT(b);return y}translatePosMatrix(o,u,y,b,M){if(!y[0]&&!y[1])return o;const R=M?b==="map"?this.transform.angle:0:b==="viewport"?-this.transform.angle:0;if(R){const X=Math.sin(R),q=Math.cos(R);y=[y[0]*q-y[1]*X,y[0]*X+y[1]*q]}const z=[M?y[0]:Et(u,y[0],this.transform.zoom),M?y[1]:Et(u,y[1],this.transform.zoom),0],V=new Float32Array(16);return i.translate(V,o,z),V}saveTileTexture(o){const u=this._tileTextures[o.size[0]];u?u.push(o):this._tileTextures[o.size[0]]=[o]}getTileTexture(o){const u=this._tileTextures[o];return u&&u.length>0?u.pop():null}isPatternMissing(o){return o===null||o!==void 0&&!this.imageManager.getPattern(o.toString())}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture}currentGlobalDefines(){const o=this.terrain&&this.terrain.renderingToTexture,u=this.terrain&&this.terrain.exaggeration()===0,y=this.style&&this.style.fog,b=[];return this.terrainRenderModeElevated()&&b.push("TERRAIN"),this.transform.projection.name==="globe"&&b.push("GLOBE"),u&&b.push("ZERO_EXAGGERATION"),y&&!o&&y.getOpacity(this.transform.pitch)!==0&&b.push("FOG"),o&&b.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&b.push("OVERDRAW_INSPECTOR"),b}useProgram(o,u,y){this.cache=this.cache||{};const b=y||[],M=this.currentGlobalDefines().concat(b),R=gi.cacheKey(Ns[o],o,M,u);return this.cache[R]||(this.cache[R]=new gi(this.context,o,Ns[o],u,io[o],M)),this.cache[R]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.frontFace.setDefault(),this.context.cullFaceSide.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const o=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(o.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=i.window.document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new i.Texture(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this._terrain&&this._terrain.destroy(),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.atmosphereBuffer&&this.atmosphereBuffer.destroy()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}prepareDrawProgram(o,u,y){if(this.terrain&&this.terrain.renderingToTexture)return;const b=this.style.fog;if(b){const M=b.getOpacity(this.transform.pitch),R=((z,V,X,q,Q,he,me,ge,_e,be,ie)=>{const pe=z.transform,Ee=V.properties.get("color").toArray01();Ee[3]=q;const Te=z.frameCounter/1e3%1;return{u_fog_matrix:X?pe.calculateFogTileMatrix(X):z.identityMat,u_fog_range:V.getFovAdjustedRange(pe._fov),u_fog_color:Ee,u_fog_horizon_blend:V.properties.get("horizon-blend"),u_fog_temporal_offset:Te,u_frustum_tl:Q,u_frustum_tr:he,u_frustum_br:me,u_frustum_bl:ge,u_globe_pos:_e,u_globe_radius:be,u_viewport:ie,u_globe_transition:i.globeToMercatorTransition(pe.zoom),u_is_globe:+(pe.projection.name==="globe")}})(this,b,y,M,this.transform.frustumCorners.TL,this.transform.frustumCorners.TR,this.transform.frustumCorners.BR,this.transform.frustumCorners.BL,this.transform.globeCenterInViewSpace,this.transform.globeRadius,[this.transform.width*i.exported.devicePixelRatio,this.transform.height*i.exported.devicePixelRatio]);u.setFogUniformValues(o,R)}}setTileLoadedFlag(o){this.tileLoaded=o}saveCanvasCopy(){const o=this.canvasCopy();o&&(this.frameCopies.push(o),this.tileLoaded=!1)}canvasCopy(){const o=this.context.gl,u=o.createTexture();return o.bindTexture(o.TEXTURE_2D,u),o.copyTexImage2D(o.TEXTURE_2D,0,o.RGBA,0,0,o.drawingBufferWidth,o.drawingBufferHeight,0),u}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const o=this.style&&this.style.fog;return!!o&&o.getOpacity(this.transform.pitch)!==0}getBackgroundTiles(){const o=this._backgroundTiles,u=this._backgroundTiles={},y=this.transform.coveringTiles({tileSize:512});for(const b of y)u[b.key]=o[b.key]||new i.Tile(b,512,this.transform.tileZoom,this);return u}clearBackgroundTiles(){this._backgroundTiles={}}}class ro{constructor(o=0,u=0,y=0,b=0){if(isNaN(o)||o<0||isNaN(u)||u<0||isNaN(y)||y<0||isNaN(b)||b<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=o,this.bottom=u,this.left=y,this.right=b}interpolate(o,u,y){return u.top!=null&&o.top!=null&&(this.top=i.number(o.top,u.top,y)),u.bottom!=null&&o.bottom!=null&&(this.bottom=i.number(o.bottom,u.bottom,y)),u.left!=null&&o.left!=null&&(this.left=i.number(o.left,u.left,y)),u.right!=null&&o.right!=null&&(this.right=i.number(o.right,u.right,y)),this}getCenter(o,u){const y=i.clamp((this.left+o-this.right)/2,0,o),b=i.clamp((this.top+u-this.bottom)/2,0,u);return new i.Point(y,b)}equals(o){return this.top===o.top&&this.bottom===o.bottom&&this.left===o.left&&this.right===o.right}clone(){return new ro(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function ya(p,o){const u=i.getColumn(p,3);i.fromQuat(p,o),i.setColumn(p,3,u)}function Gi(p,o){const u=i.identity$1([]);return i.rotateZ$1(u,u,-o),i.rotateX$1(u,u,-p),u}function qo(p,o){const u=[p[0],p[1],0],y=[o[0],o[1],0];if(i.length(u)>=1e-15){const R=i.normalize([],u);i.scale$2(y,R,i.dot(y,R)),o[0]=y[0],o[1]=y[1]}const b=i.cross([],o,p);if(i.len(b)<1e-15)return null;const M=Math.atan2(-b[1],b[0]);return Gi(Math.atan2(Math.sqrt(p[0]*p[0]+p[1]*p[1]),-p[2]),M)}class xa{constructor(o,u){this.position=o,this.orientation=u}get position(){return this._position}set position(o){if(o){const u=o instanceof i.MercatorCoordinate?o:new i.MercatorCoordinate(o[0],o[1],o[2]);this._renderWorldCopies&&(u.x=i.wrap(u.x,0,1)),this._position=u}else this._position=null}lookAtPoint(o,u){if(this.orientation=null,!this.position)return;const y=this.position,b=this._elevation?this._elevation.getAtPointOrZero(i.MercatorCoordinate.fromLngLat(o)):0,M=i.MercatorCoordinate.fromLngLat(o,b),R=[M.x-y.x,M.y-y.y,M.z-y.z];u||(u=[0,0,1]),u[2]=Math.abs(u[2]),this.orientation=qo(R,u)}setPitchBearing(o,u){this.orientation=Gi(i.degToRad(o),i.degToRad(-u))}}class wl{constructor(o,u){this._transform=i.identity([]),this.orientation=u,this.position=o}get mercatorPosition(){const o=this.position;return new i.MercatorCoordinate(o[0],o[1],o[2])}get position(){const o=i.getColumn(this._transform,3);return[o[0],o[1],o[2]]}set position(o){var u;o&&i.setColumn(this._transform,3,[(u=o)[0],u[1],u[2],1])}get orientation(){return this._orientation}set orientation(o){this._orientation=o||i.identity$1([]),o&&ya(this._transform,this._orientation)}getPitchBearing(){const o=this.forward(),u=this.right();return{bearing:Math.atan2(-u[1],u[0]),pitch:Math.atan2(Math.sqrt(o[0]*o[0]+o[1]*o[1]),-o[2])}}setPitchBearing(o,u){this._orientation=Gi(o,u),ya(this._transform,this._orientation)}forward(){const o=i.getColumn(this._transform,2);return[-o[0],-o[1],-o[2]]}up(){const o=i.getColumn(this._transform,1);return[-o[0],-o[1],-o[2]]}right(){const o=i.getColumn(this._transform,0);return[o[0],o[1],o[2]]}getCameraToWorld(o,u){const y=new Float64Array(16);return i.invert(y,this.getWorldToCamera(o,u)),y}getWorldToCameraPosition(o,u,y){const b=this.position;i.scale$2(b,b,-o);const M=new Float64Array(16);return i.fromScaling(M,[y,y,y]),i.translate(M,M,b),M[10]*=u,M}getWorldToCamera(o,u){const y=new Float64Array(16),b=new Float64Array(4),M=this.position;return i.conjugate(b,this._orientation),i.scale$2(M,M,-o),i.fromQuat(y,b),i.translate(y,y,M),y[1]*=-1,y[5]*=-1,y[9]*=-1,y[13]*=-1,y[8]*=u,y[9]*=u,y[10]*=u,y[11]*=u,y}getCameraToClipPerspective(o,u,y,b){const M=new Float64Array(16);return i.perspective(M,o,u,y,b),M}getDistanceToElevation(o,u=!1){const y=o===0?0:i.mercatorZfromAltitude(o,u?i.latFromMercatorY(this.position[1]):this.position[1]),b=this.forward();return(y-this.position[2])/b[2]}clone(){return new wl([...this.position],[...this.orientation])}}function na(p,o){const u=Zo(p.projection,p.zoom,p.width,p.height),y=function(M,R,z,V,X){const q=new i.LngLat(z.lng-180*vo,z.lat),Q=new i.LngLat(z.lng+180*vo,z.lat),he=M.project(q.lng,q.lat),me=M.project(Q.lng,Q.lat),ge=-Math.atan2(me.y-he.y,me.x-he.x),_e=i.MercatorCoordinate.fromLngLat(z);_e.y=i.clamp(_e.y,-1+vo,1-vo);const be=_e.toLngLat(),ie=M.project(be.lng,be.lat),pe=i.MercatorCoordinate.fromLngLat(be);pe.x+=vo;const Ee=pe.toLngLat(),Te=M.project(Ee.lng,Ee.lat),Ue=ia(Te.x-ie.x,Te.y-ie.y,ge),Ge=i.MercatorCoordinate.fromLngLat(be);Ge.y+=vo;const Ve=Ge.toLngLat(),et=M.project(Ve.lng,Ve.lat),$e=ia(et.x-ie.x,et.y-ie.y,ge),ht=Math.abs(Ue.x)/Math.abs($e.y),Jt=i.identity([]);i.rotateZ(Jt,Jt,-ge*(1-(X?0:V)));const ut=i.identity([]);return i.scale(ut,ut,[1,1-(1-ht)*V,1]),ut[4]=-$e.x/$e.y*V,i.rotateZ(ut,ut,ge),i.multiply(ut,Jt,ut),ut}(p.projection,0,p.center,u,o),b=Sl(p);return i.scale(y,y,[b,b,1]),y}function Sl(p){const o=p.projection,u=Zo(p.projection,p.zoom,p.width,p.height),y=Ml(o,p.center),b=Ml(o,i.LngLat.convert(o.center));return Math.pow(2,y*u+(1-u)*b)}function Zo(p,o,u,y,b=1/0){const M=p.range;if(!M)return 0;const R=Math.min(b,Math.max(u,y)),z=Math.log(R/1024)/Math.LN2;return i.smoothstep(M[0]+z,M[1]+z,o)}const vo=1/4e4;function Ml(p,o){const u=i.clamp(o.lat,-i.MAX_MERCATOR_LATITUDE,i.MAX_MERCATOR_LATITUDE),y=new i.LngLat(o.lng-180*vo,u),b=new i.LngLat(o.lng+180*vo,u),M=p.project(y.lng,u),R=p.project(b.lng,u),z=i.MercatorCoordinate.fromLngLat(y),V=i.MercatorCoordinate.fromLngLat(b),X=R.x-M.x,q=R.y-M.y,Q=V.x-z.x,he=V.y-z.y,me=Math.sqrt((Q*Q+he*he)/(X*X+q*q));return Math.log(me)/Math.LN2}function ia(p,o,u){const y=Math.cos(u),b=Math.sin(u);return{x:p*y-o*b,y:p*b+o*y}}class Xo{constructor(o,u,y,b,M,R,z){this.tileSize=512,this._renderWorldCopies=M===void 0||M,this._minZoom=o||0,this._maxZoom=u||22,this._minPitch=y==null?0:y,this._maxPitch=b==null?60:b,this.setProjection(R),this.setMaxBounds(z),this.width=0,this.height=0,this._center=new i.LngLat(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._nearZ=0,this._farZ=0,this._unmodified=!0,this._edgeInsets=new ro,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._distanceTileDataCache={},this._camera=new wl,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._pixelsPerMercatorPixel=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._horizonShift=.1}clone(){const o=new Xo(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection());return o._elevation=this._elevation,o._centerAltitude=this._centerAltitude,o._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,o.tileSize=this.tileSize,o.mercatorFromTransition=this.mercatorFromTransition,o.width=this.width,o.height=this.height,o.cameraElevationReference=this.cameraElevationReference,o._center=this._center,o._setZoom(this.zoom),o._seaLevelZoom=this._seaLevelZoom,o.angle=this.angle,o._fov=this._fov,o._pitch=this._pitch,o._nearZ=this._nearZ,o._farZ=this._farZ,o._averageElevation=this._averageElevation,o._unmodified=this._unmodified,o._edgeInsets=this._edgeInsets.clone(),o._camera=this._camera.clone(),o._calcMatrices(),o.freezeTileCoverage=this.freezeTileCoverage,o.frustumCorners=this.frustumCorners,o}get elevation(){return this._elevation}set elevation(o){this._elevation!==o&&(this._elevation=o,this._updateCameraOnTerrain(),this._calcMatrices())}updateElevation(o,u=!1){const y=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(this._seaLevelZoom==null||y)&&this._updateCameraOnTerrain(),(o||y)&&this._constrainCamera(u),this._calcMatrices()}getProjection(){return i.pick(this.projection,["name","center","parallels"])}setProjection(o){this.projectionOptions=o||{name:"mercator"};const u=this.projection?this.getProjection():void 0;this.projection=i.getProjection(this.projectionOptions);const y=!w(u,this.getProjection());return y&&this._calcMatrices(),this.mercatorFromTransition=!1,y}setMercatorFromTransition(){const o=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=i.getProjection({name:"mercator"});const u=o!==this.projection.name;return u&&this._calcMatrices(),u}get minZoom(){return this._minZoom}set minZoom(o){this._minZoom!==o&&(this._minZoom=o,this.zoom=Math.max(this.zoom,o))}get maxZoom(){return this._maxZoom}set maxZoom(o){this._maxZoom!==o&&(this._maxZoom=o,this.zoom=Math.min(this.zoom,o))}get minPitch(){return this._minPitch}set minPitch(o){this._minPitch!==o&&(this._minPitch=o,this.pitch=Math.max(this.pitch,o))}get maxPitch(){return this._maxPitch}set maxPitch(o){this._maxPitch!==o&&(this._maxPitch=o,this.pitch=Math.min(this.pitch,o))}get renderWorldCopies(){return this._renderWorldCopies&&this.projection.supportsWorldCopies===!0}set renderWorldCopies(o){o===void 0?o=!0:o===null&&(o=!1),this._renderWorldCopies=o}get worldSize(){return this.tileSize*this.scale}get cameraWorldSizeForFog(){const o=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(o))}get cameraWorldSize(){const o=Math.max(this._camera.getDistanceToElevation(this._averageElevation,!0),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(o))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return i.mercatorZfromAltitude(this.center.lat,this.cameraWorldSizeForFog)}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new i.Point(this.width,this.height)}get bearing(){return i.wrap(this.rotation,-180,180)}set bearing(o){this.rotation=o}get rotation(){return-this.angle/Math.PI*180}set rotation(o){const u=-o*Math.PI/180;var y;this.angle!==u&&(this._unmodified=!1,this.angle=u,this._calcMatrices(),this.rotationMatrix=(y=new i.ARRAY_TYPE(4),i.ARRAY_TYPE!=Float32Array&&(y[1]=0,y[2]=0),y[0]=1,y[3]=1,y),function(b,M,R){var z=M[0],V=M[1],X=M[2],q=M[3],Q=Math.sin(R),he=Math.cos(R);b[0]=z*he+X*Q,b[1]=V*he+q*Q,b[2]=z*-Q+X*he,b[3]=V*-Q+q*he}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(o){const u=i.clamp(o,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==u&&(this._unmodified=!1,this._pitch=u,this._calcMatrices())}get aspect(){return this.width/this.height}get fov(){return this._fov/Math.PI*180}get fovX(){return this._fov}get fovY(){const o=1/Math.tan(.5*this.fovX);return 2*Math.atan(1/this.aspect/o)}set fov(o){o=Math.max(.01,Math.min(60,o)),this._fov!==o&&(this._unmodified=!1,this._fov=i.degToRad(o),this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(o){this._averageElevation=o,this._calcFogMatrices(),this._distanceTileDataCache={}}get zoom(){return this._zoom}set zoom(o){const u=Math.min(Math.max(o,this.minZoom),this.maxZoom);this._zoom!==u&&(this._unmodified=!1,this._setZoom(u),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices())}_setZoom(o){this._zoom=o,this.scale=this.zoomScale(o),this.tileZoom=Math.floor(o),this.zoomFraction=o-this.tileZoom}_updateCameraOnTerrain(){if(!this._elevation||!this._elevation.isDataAvailableAtPoint(this.locationCoordinate(this.center)))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const o=this._elevation;this._centerAltitude=o.getAtPointOrZero(this.locationCoordinate(this.center)),this._centerAltitudeValidForExaggeration=o.exaggeration(),this._updateSeaLevelZoom()}_updateSeaLevelZoom(){this._centerAltitudeValidForExaggeration!==void 0&&(this._seaLevelZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize))}sampleAverageElevation(){if(!this._elevation)return 0;const o=this._elevation,u=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],y=this.horizonLineFromTop();let b=0,M=0;for(let R=0;R<u.length;R++){const z=new i.Point(u[R][0]*this.width,y+u[R][1]*(this.height-y)),V=o.pointCoordinate(z);if(!V)continue;const X=1/Math.hypot(V[0]-this._camera.position[0],V[1]-this._camera.position[1]);b+=V[3]*X,M+=X}return M===0?NaN:b/M}get center(){return this._center}set center(o){o.lat===this._center.lat&&o.lng===this._center.lng||(this._unmodified=!1,this._center=o,this._terrainEnabled()&&(this.cameraElevationReference==="ground"?this._updateCameraOnTerrain():this._updateZoomFromElevation()),this._constrain(),this._calcMatrices())}_updateZoomFromElevation(){if(this._seaLevelZoom==null||!this._elevation)return;const o=this._seaLevelZoom,u=this._elevation.getAtPointOrZero(this.locationCoordinate(this.center)),y=this.pixelsPerMeter/this.worldSize*u,b=this._mercatorZfromZoom(o),M=this._mercatorZfromZoom(this._maxZoom),R=Math.max(b-y,M);this._setZoom(this._zoomFromMercatorZ(R))}get padding(){return this._edgeInsets.toJSON()}set padding(o){this._edgeInsets.equals(o)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,o,1),this._calcMatrices())}computeZoomRelativeTo(o){const u=this.rayIntersectionCoordinate(this.pointRayIntersection(this.centerPoint,o.toAltitude()));let y;y=o.z<this._camera.position[2]?[u.x,u.y,u.z]:[o.x,o.y,o.z];const b=i.length(i.sub([],this._camera.position,y));return i.clamp(this._zoomFromMercatorZ(b),this._minZoom,this._maxZoom)}setFreeCameraOptions(o){if(!this.height||!o.position&&!o.orientation)return;this._updateCameraState();let u=!1;if(o.orientation&&!i.exactEquals(o.orientation,this._camera.orientation)&&(u=this._setCameraOrientation(o.orientation)),o.position){const y=[o.position.x,o.position.y,o.position.z];i.exactEquals$1(y,this._camera.position)||(this._setCameraPosition(y),u=!0)}u&&(this._updateStateFromCamera(),this.recenterOnTerrain())}getFreeCameraOptions(){this._updateCameraState();const o=this._camera.position,u=new xa;return u.position=new i.MercatorCoordinate(o[0],o[1],o[2]),u.orientation=this._camera.orientation,u._elevation=this.elevation,u._renderWorldCopies=this.renderWorldCopies,u}_setCameraOrientation(o){if(!i.length$1(o))return!1;i.normalize$1(o,o);const u=i.transformQuat([],[0,0,-1],o),y=i.transformQuat([],[0,-1,0],o);if(y[2]<0)return!1;const b=qo(u,y);return!!b&&(this._camera.orientation=b,!0)}_setCameraPosition(o){const u=this.zoomScale(this.minZoom)*this.tileSize,y=this.zoomScale(this.maxZoom)*this.tileSize,b=this.cameraToCenterDistance;o[2]=i.clamp(o[2],b/y,b/u),this._camera.position=o}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}get fovAboveCenter(){return this._fov*(.5+this.centerOffset.y/this.height)}isPaddingEqual(o){return this._edgeInsets.equals(o)}interpolatePadding(o,u,y){this._unmodified=!1,this._edgeInsets.interpolate(o,u,y),this._constrain(),this._calcMatrices()}coveringZoomLevel(o){const u=(o.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/o.tileSize));return Math.max(0,u)}getVisibleUnwrappedCoordinates(o){const u=[new i.UnwrappedTileID(0,o)];if(this.renderWorldCopies){const y=this.pointCoordinate(new i.Point(0,0)),b=this.pointCoordinate(new i.Point(this.width,0)),M=this.pointCoordinate(new i.Point(this.width,this.height)),R=this.pointCoordinate(new i.Point(0,this.height)),z=Math.floor(Math.min(y.x,b.x,M.x,R.x)),V=Math.floor(Math.max(y.x,b.x,M.x,R.x)),X=1;for(let q=z-X;q<=V+X;q++)q!==0&&u.push(new i.UnwrappedTileID(q,o))}return u}coveringTiles(o){let u=this.coveringZoomLevel(o);const y=u,b=this.elevation&&!o.isTerrainDEM,M=this.projection.name==="mercator";if(o.minzoom!==void 0&&u<o.minzoom)return[];o.maxzoom!==void 0&&u>o.maxzoom&&(u=o.maxzoom);const R=this.locationCoordinate(this.center),z=this.center.lat,V=1<<u,X=[V*R.x,V*R.y,0],q=this.projection.name==="globe",Q=!q,he=i.Frustum.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,u,Q),me=q?this._camera.mercatorPosition:this.pointCoordinate(this.getCameraPoint()),ge=V*i.mercatorZfromAltitude(1,this.center.lat),_e=this._camera.position[2]/i.mercatorZfromAltitude(1,this.center.lat),be=[V*me.x,V*me.y,_e*(Q?1:ge)],ie=this.cameraToCenterDistance/o.tileSize*(o.roundZoom?1:.502),pe=this.pitch<=60&&this._edgeInsets.top<=this._edgeInsets.bottom&&!this._elevation&&!this.projection.isReprojectedInTileSpace?u:0,Ee=o.isTerrainDEM&&this._elevation?1e4*this._elevation.exaggeration():this._centerAltitude,Te=o.isTerrainDEM?-Ee:this._elevation?this._elevation.getMinElevationBelowMSL():0,Ue=this.projection.isReprojectedInTileSpace?Sl(this):1,Ge=gt=>{const Qt=new i.MercatorCoordinate(gt.x+25e-6,gt.y,gt.z),Lt=new i.MercatorCoordinate(gt.x,gt.y+25e-6,gt.z),Ct=gt.toLngLat(),zn=Qt.toLngLat(),qn=Lt.toLngLat(),vn=this.locationCoordinate(Ct),Vn=this.locationCoordinate(zn),Ai=this.locationCoordinate(qn),si=Math.hypot(Vn.x-vn.x,Vn.y-vn.y),Gn=Math.hypot(Ai.x-vn.x,Ai.y-vn.y);return Math.sqrt(si*Gn)*Ue/25e-6},Ve=gt=>{const Ot=Ee,Qt=Te;return{aabb:i.tileAABB(this,V,0,0,0,gt,Qt,Ot,this.projection),zoom:0,x:0,y:0,minZ:Qt,maxZ:Ot,wrap:gt,fullyVisible:!1}},et=[];let $e=[];const ht=u,Jt=o.reparseOverscaled?y:u,ut=gt=>gt*gt,Bt=ut((_e-this._centerAltitude)*ge),yt=gt=>{if(!this._elevation||!gt.tileID||!M)return;const Ot=this._elevation.getMinMaxForTile(gt.tileID),Qt=gt.aabb;Ot?(Qt.min[2]=Ot.min,Qt.max[2]=Ot.max,Qt.center[2]=(Qt.min[2]+Qt.max[2])/2):(gt.shouldSplit=Xt(gt),gt.shouldSplit||(Qt.min[2]=Qt.max[2]=Qt.center[2]=this._centerAltitude))},Xt=gt=>{if(gt.zoom<pe)return!0;if(gt.zoom===ht)return!1;if(gt.shouldSplit!=null)return gt.shouldSplit;const Ot=gt.aabb.distanceX(be),Qt=gt.aabb.distanceY(be);let Lt=Bt,Ct=1;if(q){Lt=ut(gt.aabb.distanceZ(be));const vn=Math.pow(2,gt.zoom),Vn=i.latFromMercatorY((gt.y+1)/vn),Ai=i.latFromMercatorY(gt.y/vn),si=Math.min(Math.max(z,Vn),Ai),Gn=i.circumferenceAtLatitude(si)/i.circumferenceAtLatitude(z);if(Ct=si===z?1/Math.max(1,this._mercatorScaleRatio-.3):Math.min(1,Gn/this._mercatorScaleRatio),this.zoom<=i.GLOBE_ZOOM_THRESHOLD_MIN&&gt.zoom===ht-1&&Gn>=.9)return!0}else if(b&&(Lt=ut(gt.aabb.distanceZ(be)*ge)),this.projection.isReprojectedInTileSpace&&y<=5){const vn=Math.pow(2,gt.zoom),Vn=Ge(new i.MercatorCoordinate((gt.x+.5)/vn,(gt.y+.5)/vn));Ct=Vn>.85?1:Vn}const zn=Ot*Ot+Qt*Qt+Lt,qn=ut((1<<ht-gt.zoom)*ie*Ct*((vn,Vn)=>{if(Vn*ut(.707)<vn)return 1;const Ai=Math.sqrt(Vn/vn);return Ai/(1.4144271570014144+(Math.pow(1.1,Ai-1.4144271570014144+1)-1)/(1.1-1)-1)})(Math.max(Lt,Bt),zn));return zn<qn};if(this.renderWorldCopies)for(let gt=1;gt<=3;gt++)et.push(Ve(-gt)),et.push(Ve(gt));for(et.push(Ve(0));et.length>0;){const gt=et.pop(),Ot=gt.x,Qt=gt.y;let Lt=gt.fullyVisible;if(!Lt){const Ct=gt.aabb.intersects(he);if(Ct===0)continue;Lt=Ct===2}if(gt.zoom!==ht&&Xt(gt))for(let Ct=0;Ct<4;Ct++){const zn=(Ot<<1)+Ct%2,qn=(Qt<<1)+(Ct>>1),vn={aabb:M?gt.aabb.quadrant(Ct):i.tileAABB(this,V,gt.zoom+1,zn,qn,gt.wrap,gt.minZ,gt.maxZ,this.projection),zoom:gt.zoom+1,x:zn,y:qn,wrap:gt.wrap,fullyVisible:Lt,tileID:void 0,shouldSplit:void 0,minZ:gt.minZ,maxZ:gt.maxZ};b&&!q&&(vn.tileID=new i.OverscaledTileID(gt.zoom+1===ht?Jt:gt.zoom+1,gt.wrap,gt.zoom+1,zn,qn),yt(vn)),et.push(vn)}else{const Ct=gt.zoom===ht?Jt:gt.zoom;if(o.minzoom&&o.minzoom>Ct)continue;const zn=X[0]-(.5+Ot+(gt.wrap<<gt.zoom))*(1<<u-gt.zoom),qn=X[1]-.5-Qt,vn=gt.tileID?gt.tileID:new i.OverscaledTileID(Ct,gt.wrap,gt.zoom,Ot,Qt);$e.push({tileID:vn,distanceSq:zn*zn+qn*qn})}}if(this.fogCullDistSq){const gt=this.fogCullDistSq,Ot=this.horizonLineFromTop();$e=$e.filter(Qt=>{const Lt=[0,0,0,1],Ct=[i.EXTENT,i.EXTENT,0,1],zn=this.calculateFogTileMatrix(Qt.tileID.toUnwrapped());i.transformMat4$1(Lt,Lt,zn),i.transformMat4$1(Ct,Ct,zn);const qn=i.getAABBPointSquareDist(Lt,Ct);if(qn===0)return!0;let vn=!1;const Vn=this._elevation;if(Vn&&qn>gt&&Ot!==0){const Ai=this.calculateProjMatrix(Qt.tileID.toUnwrapped());let si;o.isTerrainDEM||(si=Vn.getMinMaxForTile(Qt.tileID)),si||(si={min:Te,max:Ee});const Gn=i.furthestTileCorner(this.rotation),$i=[Gn[0]*i.EXTENT,Gn[1]*i.EXTENT,si.max];i.transformMat4($i,$i,Ai),vn=(1-$i[1])*this.height*.5<Ot}return qn<gt||vn})}return $e.sort((gt,Ot)=>gt.distanceSq-Ot.distanceSq).map(gt=>gt.tileID)}resize(o,u){this.width=o,this.height=u,this.pixelsToGLUnits=[2/o,-2/u],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(o){return Math.pow(2,o)}scaleZoom(o){return Math.log(o)/Math.LN2}project(o){const u=i.clamp(o.lat,-i.MAX_MERCATOR_LATITUDE,i.MAX_MERCATOR_LATITUDE),y=this.projection.project(o.lng,u);return new i.Point(y.x*this.worldSize,y.y*this.worldSize)}unproject(o){return this.projection.unproject(o.x/this.worldSize,o.y/this.worldSize)}get point(){return this.project(this.center)}get pointMerc(){return this.point._div(this.worldSize)}get pixelsPerMeterRatio(){return this.pixelsPerMeter/i.mercatorZfromAltitude(1,this.center.lat)/this.worldSize}setLocationAtPoint(o,u){let y,b;const M=this.centerPoint;if(this.projection.name==="globe"){const z=this.worldSize;y=(u.x-M.x)/z,b=(u.y-M.y)/z}else{const z=this.pointCoordinate(u),V=this.pointCoordinate(M);y=z.x-V.x,b=z.y-V.y}const R=this.locationCoordinate(o);this.setLocation(new i.MercatorCoordinate(R.x-y,R.y-b))}setLocation(o){this.center=this.coordinateLocation(o),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(o){return this.projection.locationPoint(this,o)}locationPoint3D(o){return this.projection.locationPoint(this,o,!0)}pointLocation(o){return this.coordinateLocation(this.pointCoordinate(o))}pointLocation3D(o){return this.coordinateLocation(this.pointCoordinate3D(o))}locationCoordinate(o,u){const y=u?i.mercatorZfromAltitude(u,o.lat):void 0,b=this.projection.project(o.lng,o.lat);return new i.MercatorCoordinate(b.x,b.y,y)}coordinateLocation(o){return this.projection.unproject(o.x,o.y)}pointRayIntersection(o,u){const y=u!=null?u:this._centerAltitude,b=[o.x,o.y,0,1],M=[o.x,o.y,1,1];i.transformMat4$1(b,b,this.pixelMatrixInverse),i.transformMat4$1(M,M,this.pixelMatrixInverse);const R=M[3];i.scale$1(b,b,1/b[3]),i.scale$1(M,M,1/R);const z=b[2],V=M[2];return{p0:b,p1:M,t:z===V?0:(y-z)/(V-z)}}screenPointToMercatorRay(o){const u=[o.x,o.y,0,1],y=[o.x,o.y,1,1];return i.transformMat4$1(u,u,this.pixelMatrixInverse),i.transformMat4$1(y,y,this.pixelMatrixInverse),i.scale$1(u,u,1/u[3]),i.scale$1(y,y,1/y[3]),u[2]=i.mercatorZfromAltitude(u[2],this._center.lat)*this.worldSize,y[2]=i.mercatorZfromAltitude(y[2],this._center.lat)*this.worldSize,i.scale$1(u,u,1/this.worldSize),i.scale$1(y,y,1/this.worldSize),new i.Ray([u[0],u[1],u[2]],i.normalize([],i.sub([],y,u)))}rayIntersectionCoordinate(o){const{p0:u,p1:y,t:b}=o,M=i.mercatorZfromAltitude(u[2],this._center.lat),R=i.mercatorZfromAltitude(y[2],this._center.lat);return new i.MercatorCoordinate(i.number(u[0],y[0],b)/this.worldSize,i.number(u[1],y[1],b)/this.worldSize,i.number(M,R,b))}pointCoordinate(o,u=this._centerAltitude){return this.projection.pointCoordinate(this,o.x,o.y,u)}pointCoordinate3D(o){if(!this.elevation)return this.pointCoordinate(o);let u=this.projection.pointCoordinate3D(this,o.x,o.y);if(u)return new i.MercatorCoordinate(u[0],u[1],u[2]);let y=0,b=this.horizonLineFromTop();if(o.y>b)return this.pointCoordinate(o);const M=.02*b,R=o.clone();for(let z=0;z<10&&b-y>M;z++){R.y=i.number(y,b,.66);const V=this.projection.pointCoordinate3D(this,R.x,R.y);V?(b=R.y,u=V):y=R.y}return u?new i.MercatorCoordinate(u[0],u[1],u[2]):this.pointCoordinate(o)}isPointAboveHorizon(o){return this.projection.isPointAboveHorizon(this,o)}isPointOnSurface(o){if(o.y<0||o.y>this.height||o.x<0||o.x>this.width)return!1;if(this.elevation||this.zoom>=i.GLOBE_ZOOM_THRESHOLD_MAX)return!this.isPointAboveHorizon(o);const u=this.pointCoordinate(o);return u.y>=0&&u.y<=1}_coordinatePoint(o,u){const y=u&&this.elevation?this.elevation.getAtPointOrZero(o,this._centerAltitude):this._centerAltitude,b=[o.x*this.worldSize,o.y*this.worldSize,y+o.toAltitude(),1];return i.transformMat4$1(b,b,this.pixelMatrix),b[3]>0?new i.Point(b[0]/b[3],b[1]/b[3]):new i.Point(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){const{top:o,left:u}=this._edgeInsets,y=this.height-this._edgeInsets.bottom,b=this.width-this._edgeInsets.right,M=this.pointLocation3D(new i.Point(u,o)),R=this.pointLocation3D(new i.Point(b,o)),z=this.pointLocation3D(new i.Point(b,y)),V=this.pointLocation3D(new i.Point(u,y));let X=Math.min(M.lng,R.lng,z.lng,V.lng),q=Math.max(M.lng,R.lng,z.lng,V.lng),Q=Math.min(M.lat,R.lat,z.lat,V.lat),he=Math.max(M.lat,R.lat,z.lat,V.lat);const me=Math.pow(2,-this.zoom)/16*270,ge=this.projection.name==="globe"?1:4,_e=(be,ie,pe,Ee,Te)=>{const Ue=(be+pe)/2,Ge=(ie+Ee)/2,Ve=new i.Point(Ue,Ge),{lng:et,lat:$e}=this.pointLocation3D(Ve),ht=Math.max(0,X-et,Q-$e,et-q,$e-he);X=Math.min(X,et),q=Math.max(q,et),Q=Math.min(Q,$e),he=Math.max(he,$e),(Te<ge||ht>me)&&(_e(be,ie,Ue,Ge,Te+1),_e(Ue,Ge,pe,Ee,Te+1))};if(_e(u,o,b,o,1),_e(b,o,b,y,1),_e(b,y,u,y,1),_e(u,y,u,o,1),this.projection.name==="globe"){const[be,ie]=i.polesInViewport(this);be?(he=90,q=180,X=-180):ie&&(Q=-90,q=180,X=-180)}return new i.LngLatBounds(new i.LngLat(X,Q),new i.LngLat(q,he))}_getBoundsRectangular(o,u){const{top:y,left:b}=this._edgeInsets,M=this.height-this._edgeInsets.bottom,R=this.width-this._edgeInsets.right,z=new i.Point(b,y),V=new i.Point(R,y),X=new i.Point(R,M),q=new i.Point(b,M);let Q=this.pointCoordinate(z,o),he=this.pointCoordinate(V,o);const me=this.pointCoordinate(X,u),ge=this.pointCoordinate(q,u),_e=(be,ie)=>(ie.y-be.y)/(ie.x-be.x);return Q.y>1&&he.y>=0?Q=new i.MercatorCoordinate((1-ge.y)/_e(ge,Q)+ge.x,1):Q.y<0&&he.y<=1&&(Q=new i.MercatorCoordinate(-ge.y/_e(ge,Q)+ge.x,0)),he.y>1&&Q.y>=0?he=new i.MercatorCoordinate((1-me.y)/_e(me,he)+me.x,1):he.y<0&&Q.y<=1&&(he=new i.MercatorCoordinate(-me.y/_e(me,he)+me.x,0)),new i.LngLatBounds().extend(this.coordinateLocation(Q)).extend(this.coordinateLocation(he)).extend(this.coordinateLocation(ge)).extend(this.coordinateLocation(me))}_getBoundsRectangularTerrain(){const o=this.elevation;if(!o.visibleDemTiles.length||o.isUsingMockSource())return this._getBoundsRectangular(0,0);const u=o.visibleDemTiles.reduce((y,b)=>{if(b.dem){const M=b.dem.tree;y.min=Math.min(y.min,M.minimums[0]),y.max=Math.max(y.max,M.maximums[0])}return y},{min:Number.MAX_VALUE,max:0});return this._getBoundsRectangular(u.min*o.exaggeration(),u.max*o.exaggeration())}getBounds(){return this.projection.name==="mercator"||this.projection.name==="equirectangular"?this._terrainEnabled()?this._getBoundsRectangularTerrain():this._getBoundsRectangular(0,0):this._getBoundsNonRectangular()}horizonLineFromTop(o=!0){const u=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))+this.centerOffset.y,y=this.height/2-u*(1-this._horizonShift);return o?Math.max(0,y):y}getMaxBounds(){return this.maxBounds}setMaxBounds(o){this.maxBounds=o,this.minLat=-i.MAX_MERCATOR_LATITUDE,this.maxLat=i.MAX_MERCATOR_LATITUDE,this.minLng=-180,this.maxLng=180,o&&(this.minLat=o.getSouth(),this.maxLat=o.getNorth(),this.minLng=o.getWest(),this.maxLng=o.getEast(),this.maxLng<this.minLng&&(this.maxLng+=360)),this.worldMinX=i.mercatorXfromLng(this.minLng)*this.tileSize,this.worldMaxX=i.mercatorXfromLng(this.maxLng)*this.tileSize,this.worldMinY=i.mercatorYfromLat(this.maxLat)*this.tileSize,this.worldMaxY=i.mercatorYfromLat(this.minLat)*this.tileSize,this._constrain()}calculatePosMatrix(o,u){return this.projection.createTileMatrix(this,u,o)}calculateDistanceTileData(o){const u=o.key,y=this._distanceTileDataCache;if(y[u])return y[u];const b=o.canonical,M=1/this.height,R=this.cameraWorldSize,z=R/this.zoomScale(b.z),V=(b.x+Math.pow(2,b.z)*o.wrap)*z,X=b.y*z,q=this.point;q.x*=R/this.worldSize,q.y*=R/this.worldSize;const Q=this.angle,he=Math.sin(-Q),me=-Math.cos(-Q);return y[u]={bearing:[he,me],center:[(q.x-V)*M,(q.y-X)*M],scale:z/i.EXTENT*M},y[u]}calculateFogTileMatrix(o){const u=o.key,y=this._fogTileMatrixCache;if(y[u])return y[u];const b=this.projection.createTileMatrix(this,this.cameraWorldSizeForFog,o);return i.multiply(b,this.worldToFogMatrix,b),y[u]=new Float32Array(b),y[u]}calculateProjMatrix(o,u=!1){const y=o.key,b=u?this._alignedProjMatrixCache:this._projMatrixCache;if(b[y])return b[y];const M=this.calculatePosMatrix(o,this.worldSize);return i.multiply(M,this.projection.isReprojectedInTileSpace?this.mercatorMatrix:u?this.alignedProjMatrix:this.projMatrix,M),b[y]=new Float32Array(M),b[y]}calculatePixelsToTileUnitsMatrix(o){const u=o.tileID.key,y=this._pixelsToTileUnitsCache;if(y[u])return y[u];const b=function(M,R){const{scale:z}=M.tileTransform,V=z*i.EXTENT/(M.tileSize*Math.pow(2,R.zoom-M.tileID.overscaledZ+M.tileID.canonical.z));return X=new Float32Array(4),he=(q=R.inverseAdjustmentMatrix)[1],me=q[2],ge=q[3],be=(Q=[V,V])[1],X[0]=q[0]*(_e=Q[0]),X[1]=he*_e,X[2]=me*be,X[3]=ge*be,X;var X,q,Q,he,me,ge,_e,be}(o,this);return y[u]=b,y[u]}customLayerMatrix(){return this.mercatorMatrix.slice()}globeToMercatorMatrix(){if(this.projection.name==="globe"){const o=1/this.worldSize,u=i.fromScaling([],[o,o,o]);return i.multiply(u,u,this.globeMatrix),u}}recenterOnTerrain(){if(!this._elevation||this.projection.name==="globe")return;const o=this._elevation;this._updateCameraState();const u=i.mercatorZfromAltitude(1,this._center.lat)*this.worldSize,y=this._computeCameraPosition(u),b=this._camera.forward(),M=i.mercatorZfromAltitude(1,this._center.lat);y[2]/=M,b[2]/=M,i.normalize(b,b);const R=o.raycast(y,b,o.exaggeration());if(R){const z=i.scaleAndAdd([],y,b,R),V=new i.MercatorCoordinate(z[0],z[1],i.mercatorZfromAltitude(z[2],i.latFromMercatorY(z[1]))),X=(V.z+i.length([V.x-y[0],V.y-y[1],V.z-y[2]*M]))*this._pixelsPerMercatorPixel;this._seaLevelZoom=this._zoomFromMercatorZ(X),this._centerAltitude=V.toAltitude(),this._center=this.coordinateLocation(V),this._updateZoomFromElevation(),this._constrain(),this._calcMatrices()}}_constrainCamera(o=!1){if(!this._elevation)return;const u=this._elevation,y=i.mercatorZfromAltitude(1,this._center.lat)*this.worldSize,b=this._computeCameraPosition(y),M=u.getAtPointOrZero(new i.MercatorCoordinate(...b)),R=this.pixelsPerMeter/this.worldSize*M,z=this._minimumHeightOverTerrain(),V=b[2]-R;if(V<=z)if(V<0||o){const X=this.locationCoordinate(this._center,this._centerAltitude),q=[b[0],b[1],X.z-b[2]],Q=i.length(q);q[2]-=(z-V)/this._pixelsPerMercatorPixel;const he=i.length(q);if(he===0)return;i.scale$2(q,q,Q/he*this._pixelsPerMercatorPixel),this._camera.position=[b[0],b[1],X.z*this._pixelsPerMercatorPixel-q[2]],this._updateStateFromCamera()}else this._isCameraConstrained=!0}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const o=this.projection.name==="globe"||this.mercatorFromTransition;if(this.projection.isReprojectedInTileSpace||o){const he=this.center;return he.lat=i.clamp(he.lat,this.minLat,this.maxLat),(this.maxBounds||!this.renderWorldCopies&&!o)&&(he.lng=i.clamp(he.lng,this.minLng,this.maxLng)),this.center=he,void(this._constraining=!1)}const u=this._unmodified,{x:y,y:b}=this.point;let M=0,R=y,z=b;const V=this.width/2,X=this.height/2,q=this.worldMinY*this.scale,Q=this.worldMaxY*this.scale;if(b-X<q&&(z=q+X),b+X>Q&&(z=Q-X),Q-q<this.height&&(M=Math.max(M,this.height/(Q-q)),z=(Q+q)/2),this.maxBounds||!this._renderWorldCopies||!this.projection.wrap){const he=this.worldMinX*this.scale,me=this.worldMaxX*this.scale,ge=this.worldSize/2-(he+me)/2;R=(y+ge+this.worldSize)%this.worldSize-ge,R-V<he&&(R=he+V),R+V>me&&(R=me-V),me-he<this.width&&(M=Math.max(M,this.width/(me-he)),R=(me+he)/2)}R===y&&z===b||(this.center=this.unproject(new i.Point(R,z))),M&&(this.zoom+=this.scaleZoom(M)),this._constrainCamera(),this._unmodified=u,this._constraining=!1}_minZoomForBounds(){let o=Math.max(0,this.scaleZoom(this.height/(this.worldMaxY-this.worldMinY)));return this.maxBounds&&(o=Math.max(o,this.scaleZoom(this.width/(this.worldMaxX-this.worldMinX)))),o}_maxCameraBoundsDistance(){return this._mercatorZfromZoom(this._minZoomForBounds())}_calcMatrices(){if(!this.height)return;const o=this.centerOffset,u=this.pixelsPerMeter;this.projection.name==="globe"&&(this._mercatorScaleRatio=i.mercatorZfromAltitude(1,this.center.lat)/i.mercatorZfromAltitude(1,i.GLOBE_SCALE_MATCH_LATITUDE));const y=Zo(this.projection,this.zoom,this.width,this.height,1024);this._pixelsPerMercatorPixel=this.projection.pixelSpaceConversion(this.center.lat,this.worldSize,y),this.cameraToCenterDistance=.5/Math.tan(.5*this._fov)*this.height*this._pixelsPerMercatorPixel,this._updateCameraState(),this._farZ=this.projection.farthestPixelDistance(this),this._nearZ=this.height/50;const b=this.projection.zAxisUnit==="meters"?u:1,M=this._camera.getWorldToCamera(this.worldSize,b),R=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,this._farZ);R[8]=2*-o.x/this.width,R[9]=2*o.y/this.height;let z=i.mul([],R,M);if(this.projection.isReprojectedInTileSpace){const Ge=this.locationCoordinate(this.center),Ve=i.identity([]);i.translate(Ve,Ve,[Ge.x*this.worldSize,Ge.y*this.worldSize,0]),i.multiply(Ve,Ve,na(this)),i.translate(Ve,Ve,[-Ge.x*this.worldSize,-Ge.y*this.worldSize,0]),i.multiply(z,z,Ve),this.inverseAdjustmentMatrix=function(et){const $e=na(et,!0);return ce([],[$e[0],$e[1],$e[4],$e[5]])}(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];this.mercatorMatrix=i.scale([],z,[this.worldSize,this.worldSize,this.worldSize/b,1]),this.projMatrix=z,this.invProjMatrix=i.invert(new Float64Array(16),this.projMatrix);const V=i.invert([],R);this.frustumCorners=i.FrustumCorners.fromInvProjectionMatrix(V,this.horizonLineFromTop(),this.height);const X=new Float32Array(16);i.identity(X),i.scale(X,X,[1,-1,1]),i.rotateX(X,X,this._pitch),i.rotateZ(X,X,this.angle);const q=i.perspective(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ),Q=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;q[8]=2*-o.x/this.width,q[9]=2*(o.y+Q)/this.height,this.skyboxMatrix=i.multiply(X,q,X);const he=this.point,me=he.x,ge=he.y,_e=this.width%2/2,be=this.height%2/2,ie=Math.cos(this.angle),pe=Math.sin(this.angle),Ee=me-Math.round(me)+ie*_e+pe*be,Te=ge-Math.round(ge)+ie*be+pe*_e,Ue=new Float64Array(z);if(i.translate(Ue,Ue,[Ee>.5?Ee-1:Ee,Te>.5?Te-1:Te,0]),this.alignedProjMatrix=Ue,z=i.create(),i.scale(z,z,[this.width/2,-this.height/2,1]),i.translate(z,z,[1,-1,0]),this.labelPlaneMatrix=z,z=i.create(),i.scale(z,z,[1,-1,1]),i.translate(z,z,[-1,-1,0]),i.scale(z,z,[2/this.width,2/this.height,1]),this.glCoordMatrix=z,this.pixelMatrix=i.multiply(new Float64Array(16),this.labelPlaneMatrix,this.projMatrix),this._calcFogMatrices(),this._distanceTileDataCache={},z=i.invert(new Float64Array(16),this.pixelMatrix),!z)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=z,this.projection.name==="globe"||this.mercatorFromTransition){this.globeMatrix=i.calculateGlobeMatrix(this);const Ge=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=i.transformMat4(Ge,Ge,M),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=z;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const o=this.cameraWorldSizeForFog,u=this.cameraPixelsPerMeter,y=this._camera.position,b=1/this.height/this._pixelsPerMercatorPixel,M=[o,o,u];i.scale$2(M,M,b),i.scale$2(y,y,-1),i.multiply$2(y,y,M);const R=i.create();i.translate(R,R,y),i.scale(R,R,M),this.mercatorFogMatrix=R,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(o,u,b)}_computeCameraPosition(o){const u=(o=o||this.pixelsPerMeter)/this.pixelsPerMeter,y=this._camera.forward(),b=this.point,M=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*u-o/this.worldSize*this._centerAltitude;return[b.x/this.worldSize-y[0]*M,b.y/this.worldSize-y[1]*M,o/this.worldSize*this._centerAltitude-y[2]*M]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(o){const u=this._maxCameraBoundsDistance()*Math.cos(this._pitch),y=this._camera.position[2],b=o[2];let M=1;this.projection.wrap&&(this.center=this.center.wrap()),b>0&&(M=Math.min((u-y)/b,1)),this._camera.position=i.scaleAndAdd([],this._camera.position,o,M),this._updateStateFromCamera()}_updateStateFromCamera(){const o=this._camera.position,u=this._camera.forward(),{pitch:y,bearing:b}=this._camera.getPitchBearing(),M=i.mercatorZfromAltitude(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,R=this._mercatorZfromZoom(this._maxZoom)*Math.cos(i.degToRad(this._maxPitch)),z=Math.max((o[2]-M)/Math.cos(y),R),V=this._zoomFromMercatorZ(z);i.scaleAndAdd(o,o,u,z),this._pitch=i.clamp(y,i.degToRad(this.minPitch),i.degToRad(this.maxPitch)),this.angle=i.wrap(b,-Math.PI,Math.PI),this._setZoom(i.clamp(V,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new i.MercatorCoordinate(o[0],o[1],o[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(o){return Math.pow(2,o)*this.tileSize}_mercatorZfromZoom(o){return this.cameraToCenterDistance/this._worldSizeFromZoom(o)}_minimumHeightOverTerrain(){const o=Math.min((this._seaLevelZoom!=null?this._seaLevelZoom:this._zoom)+4,this._maxZoom);return this._mercatorZfromZoom(o)}_zoomFromMercatorZ(o){return this.scaleZoom(this.cameraToCenterDistance/(o*this.tileSize))}zoomFromMercatorZAdjusted(o){let u=0,y=i.GLOBE_ZOOM_THRESHOLD_MAX,b=0,M=1/0;for(;y-u>1e-6&&y>u;){const R=u+.5*(y-u),z=this.tileSize*Math.pow(2,R),V=this.getCameraToCenterDistance(this.projection,R,z),X=this.scaleZoom(V/(o*this.tileSize)),q=Math.abs(R-X);q<M&&(M=q,b=R),R<X?u=R:y=R}return b}_terrainEnabled(){return!(!this._elevation||!this.projection.supportsTerrain&&(i.warnOnce("Terrain is not yet supported with alternate projections. Use mercator or globe to enable terrain."),1))}anyCornerOffEdge(o,u){const y=Math.min(o.x,u.x),b=Math.max(o.x,u.x),M=Math.min(o.y,u.y),R=Math.max(o.y,u.y);if(M<this.horizonLineFromTop(!1))return!0;if(this.projection.name!=="mercator")return!1;const z=[new i.Point(y,M),new i.Point(b,R),new i.Point(y,R),new i.Point(b,M)],V=this.renderWorldCopies?-3:0,X=this.renderWorldCopies?4:1;for(const q of z){const Q=this.pointRayIntersection(q);if(Q.t<0)return!0;const he=this.rayIntersectionCoordinate(Q);if(he.x<V||he.y<0||he.x>X||he.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+i.radToDeg(this.fovAboveCenter)>88||this.anyCornerOffEdge(new i.Point(0,0),new i.Point(this.width,this.height))}zoomDeltaToMovement(o,u){const y=i.length(i.sub([],this._camera.position,o)),b=this._zoomFromMercatorZ(y)+u;return y-this._mercatorZfromZoom(b)}getCameraPoint(){if(this.projection.name==="globe"){const o=function([u,y,b],M){const R=[u,y,b,1];i.transformMat4$1(R,R,M);const z=R[3]=Math.max(R[3],1e-6);return R[0]/=z,R[1]/=z,R[2]/=z,R}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new i.Point(o[0],o[1])}{const o=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new i.Point(0,o))}}getCameraToCenterDistance(o,u=this.zoom,y=this.worldSize){const b=Zo(o,u,this.width,this.height,1024),M=o.pixelSpaceConversion(this.center.lat,y,b);return .5/Math.tan(.5*this._fov)*this.height*M}getWorldToCameraMatrix(){const o=this._camera.getWorldToCamera(this.worldSize,this.projection.zAxisUnit==="meters"?this.pixelsPerMeter:1);return this.projection.name==="globe"&&i.multiply(o,o,this.globeMatrix),o}}function ja(p,o){let u=!1,y=null;const b=()=>{y=null,u&&(p(),y=setTimeout(b,o),u=!1)};return()=>(u=!0,y||b(),y)}class Tu{constructor(o){this._hashName=o&&encodeURIComponent(o),i.bindAll(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=ja(this._updateHashUnthrottled.bind(this),300)}addTo(o){return this._map=o,i.window.addEventListener("hashchange",this._onHashChange,!1),o.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),i.window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(){const o=this._map;if(!o)return"";const u=pc(o);if(this._hashName){const y=this._hashName;let b=!1;const M=i.window.location.hash.slice(1).split("&").map(R=>{const z=R.split("=")[0];return z===y?(b=!0,`${z}=${u}`):R}).filter(R=>R);return b||M.push(`${y}=${u}`),`#${M.join("&")}`}return`#${u}`}_getCurrentHash(){const o=i.window.location.hash.replace("#","");if(this._hashName){let u;return o.split("&").map(y=>y.split("=")).forEach(y=>{y[0]===this._hashName&&(u=y)}),(u&&u[1]||"").split("/")}return o.split("/")}_onHashChange(){const o=this._map;if(!o)return!1;const u=this._getCurrentHash();if(u.length>=3&&!u.some(y=>isNaN(y))){const y=o.dragRotate.isEnabled()&&o.touchZoomRotate.isEnabled()?+(u[3]||0):o.getBearing();return o.jumpTo({center:[+u[2],+u[1]],zoom:+u[0],bearing:y,pitch:+(u[4]||0)}),!0}return!1}_updateHashUnthrottled(){const o=i.window.location.href.replace(/(#.+)?$/,this.getHashString());i.window.history.replaceState(i.window.history.state,null,o)}}function pc(p,o){const u=p.getCenter(),y=Math.round(100*p.getZoom())/100,b=Math.ceil((y*Math.LN2+Math.log(512/360/.5))/Math.LN10),M=Math.pow(10,b),R=Math.round(u.lng*M)/M,z=Math.round(u.lat*M)/M,V=p.getBearing(),X=p.getPitch();let q=o?`/${R}/${z}/${y}`:`${y}/${z}/${R}`;return(V||X)&&(q+="/"+Math.round(10*V)/10),X&&(q+=`/${Math.round(X)}`),q}const mc={linearity:.3,easing:i.bezier(0,0,.3,1)},Xc=i.extend({deceleration:2500,maxSpeed:1400},mc),gc=i.extend({deceleration:20,maxSpeed:1400},mc),Dn=i.extend({deceleration:1e3,maxSpeed:360},mc),ra=i.extend({deceleration:1e3,maxSpeed:90},mc);class Td{constructor(o){this._map=o,this.clear()}clear(){this._inertiaBuffer=[]}record(o){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:i.exported.now(),settings:o})}_drainInertiaBuffer(){const o=this._inertiaBuffer,u=i.exported.now();for(;o.length>0&&u-o[0].time>160;)o.shift()}_onMoveEnd(o){if(this._map._prefersReducedMotion()||(this._drainInertiaBuffer(),this._inertiaBuffer.length<2))return;const u={zoom:0,bearing:0,pitch:0,pan:new i.Point(0,0),pinchAround:void 0,around:void 0};for(const{settings:M}of this._inertiaBuffer)u.zoom+=M.zoomDelta||0,u.bearing+=M.bearingDelta||0,u.pitch+=M.pitchDelta||0,M.panDelta&&u.pan._add(M.panDelta),M.around&&(u.around=M.around),M.pinchAround&&(u.pinchAround=M.pinchAround);const y=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,b={};if(u.pan.mag()){const M=$c(u.pan.mag(),y,i.extend({},Xc,o||{}));b.offset=u.pan.mult(M.amount/u.pan.mag()),b.center=this._map.transform.center,_c(b,M)}if(u.zoom){const M=$c(u.zoom,y,gc);b.zoom=this._map.transform.zoom+M.amount,_c(b,M)}if(u.bearing){const M=$c(u.bearing,y,Dn);b.bearing=this._map.transform.bearing+i.clamp(M.amount,-179,179),_c(b,M)}if(u.pitch){const M=$c(u.pitch,y,ra);b.pitch=this._map.transform.pitch+M.amount,_c(b,M)}if(b.zoom||b.bearing){const M=u.pinchAround===void 0?u.around:u.pinchAround;b.around=M?this._map.unproject(M):this._map.getCenter()}return this.clear(),b.noMoveStart=!0,b}}function _c(p,o){(!p.duration||p.duration<o.duration)&&(p.duration=o.duration,p.easing=o.easing)}function $c(p,o,u){const{maxSpeed:y,linearity:b,deceleration:M}=u,R=i.clamp(p*b/(o/1e3),-y,y),z=Math.abs(R)/(M*b);return{easing:u.easing,duration:1e3*z,amount:R*(z/2)}}class Is extends i.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(o,u,y,b={}){const M=le(u.getCanvasContainer(),y),R=u.unproject(M);super(o,i.extend({point:M,lngLat:R,originalEvent:y},b)),this._defaultPrevented=!1,this.target=u}}class yc extends i.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(o,u,y){const b=o==="touchend"?y.changedTouches:y.touches,M=fe(u.getCanvasContainer(),b),R=M.map(V=>u.unproject(V)),z=M.reduce((V,X,q,Q)=>V.add(X.div(Q.length)),new i.Point(0,0));super(o,{points:M,point:z,lngLats:R,lngLat:u.unproject(z),originalEvent:y}),this._defaultPrevented=!1}}class Yc extends i.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(o,u,y){super(o,{originalEvent:y}),this._defaultPrevented=!1}}class Au{constructor(o,u){this._map=o,this._clickTolerance=u.clickTolerance}reset(){this._mousedownPos=void 0}wheel(o){return this._firePreventable(new Yc(o.type,this._map,o))}mousedown(o,u){return this._mousedownPos=u,this._firePreventable(new Is(o.type,this._map,o))}mouseup(o){this._map.fire(new Is(o.type,this._map,o))}preclick(o){const u=i.extend({},o);u.type="preclick",this._map.fire(new Is(u.type,this._map,u))}click(o,u){this._mousedownPos&&this._mousedownPos.dist(u)>=this._clickTolerance||(this.preclick(o),this._map.fire(new Is(o.type,this._map,o)))}dblclick(o){return this._firePreventable(new Is(o.type,this._map,o))}mouseover(o){this._map.fire(new Is(o.type,this._map,o))}mouseout(o){this._map.fire(new Is(o.type,this._map,o))}touchstart(o){return this._firePreventable(new yc(o.type,this._map,o))}touchmove(o){this._map.fire(new yc(o.type,this._map,o))}touchend(o){this._map.fire(new yc(o.type,this._map,o))}touchcancel(o){this._map.fire(new yc(o.type,this._map,o))}_firePreventable(o){if(this._map.fire(o),o.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Jc{constructor(o){this._map=o}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(o){this._map.fire(new Is(o.type,this._map,o))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Is("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(o){this._delayContextMenu?this._contextMenuEvent=o:this._map.fire(new Is(o.type,this._map,o)),this._map.listens("contextmenu")&&o.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Kc{constructor(o,u){this._map=o,this._el=o.getCanvasContainer(),this._container=o.getContainer(),this._clickTolerance=u.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(o,u){this.isEnabled()&&o.shiftKey&&o.button===0&&(H(),this._startPos=this._lastPos=u,this._active=!0)}mousemoveWindow(o,u){if(!this._active)return;const y=u,b=this._startPos,M=this._lastPos;if(!b||!M||M.equals(y)||!this._box&&y.dist(b)<this._clickTolerance)return;this._lastPos=y,this._box||(this._box=I("div","mapboxgl-boxzoom",this._container),this._container.classList.add("mapboxgl-crosshair"),this._fireEvent("boxzoomstart",o));const R=Math.min(b.x,y.x),z=Math.max(b.x,y.x),V=Math.min(b.y,y.y),X=Math.max(b.y,y.y);this._map._requestDomTask(()=>{this._box&&(this._box.style.transform=`translate(${R}px,${V}px)`,this._box.style.width=z-R+"px",this._box.style.height=X-V+"px")})}mouseupWindow(o,u){if(!this._active)return;const y=this._startPos,b=u;if(y&&o.button===0){if(this.reset(),ne(),y.x!==b.x||y.y!==b.y)return this._map.fire(new i.Event("boxzoomend",{originalEvent:o})),{cameraAnimation:M=>M.fitScreenCoordinates(y,b,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",o)}}keydown(o){this._active&&o.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",o))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),Y(),delete this._startPos,delete this._lastPos}_fireEvent(o,u){return this._map.fire(new i.Event(o,{originalEvent:u}))}}function Cu(p,o){const u={};for(let y=0;y<p.length;y++)u[p[y].identifier]=o[y];return u}class xc{constructor(o){this.reset(),this.numTouches=o.numTouches}reset(){this.centroid=void 0,this.startTime=0,this.touches={},this.aborted=!1}touchstart(o,u,y){(this.centroid||y.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===0&&(this.startTime=o.timeStamp),y.length===this.numTouches&&(this.centroid=function(b){const M=new i.Point(0,0);for(const R of b)M._add(R);return M.div(b.length)}(u),this.touches=Cu(y,u)))}touchmove(o,u,y){if(this.aborted||!this.centroid)return;const b=Cu(y,u);for(const M in this.touches){const R=b[M];(!R||R.dist(this.touches[M])>30)&&(this.aborted=!0)}}touchend(o,u,y){if((!this.centroid||o.timeStamp-this.startTime>500)&&(this.aborted=!0),y.length===0){const b=!this.aborted&&this.centroid;if(this.reset(),b)return b}}}class fh{constructor(o){this.singleTap=new xc(o),this.numTaps=o.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(o,u,y){this.singleTap.touchstart(o,u,y)}touchmove(o,u,y){this.singleTap.touchmove(o,u,y)}touchend(o,u,y){const b=this.singleTap.touchend(o,u,y);if(b){const M=o.timeStamp-this.lastTime<500,R=!this.lastTap||this.lastTap.dist(b)<30;if(M&&R||this.reset(),this.count++,this.lastTime=o.timeStamp,this.lastTap=b,this.count===this.numTaps)return this.reset(),b}}}class ph{constructor(){this._zoomIn=new fh({numTouches:1,numTaps:2}),this._zoomOut=new fh({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(o,u,y){this._zoomIn.touchstart(o,u,y),this._zoomOut.touchstart(o,u,y)}touchmove(o,u,y){this._zoomIn.touchmove(o,u,y),this._zoomOut.touchmove(o,u,y)}touchend(o,u,y){const b=this._zoomIn.touchend(o,u,y),M=this._zoomOut.touchend(o,u,y);return b?(this._active=!0,o.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:R=>R.easeTo({duration:300,zoom:R.getZoom()+1,around:R.unproject(b)},{originalEvent:o})}):M?(this._active=!0,o.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:R=>R.easeTo({duration:300,zoom:R.getZoom()-1,around:R.unproject(M)},{originalEvent:o})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const Iu={0:1,2:2};class vc{constructor(o){this.reset(),this._clickTolerance=o.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(o,u){return!1}_move(o,u){return{}}mousedown(o,u){if(this._lastPoint)return;const y=Ae(o);this._correctButton(o,y)&&(this._lastPoint=u,this._eventButton=y)}mousemoveWindow(o,u){const y=this._lastPoint;if(y){if(o.preventDefault(),this._eventButton!=null&&function(b,M){const R=Iu[M];return b.buttons===void 0||(b.buttons&R)!==R}(o,this._eventButton))this.reset();else if(this._moved||!(u.dist(y)<this._clickTolerance))return this._moved=!0,this._lastPoint=u,this._move(y,u)}}mouseupWindow(o){this._lastPoint&&Ae(o)===this._eventButton&&(this._moved&&ne(),this.reset())}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Pu extends vc{mousedown(o,u){super.mousedown(o,u),this._lastPoint&&(this._active=!0)}_correctButton(o,u){return u===0&&!o.ctrlKey}_move(o,u){return{around:u,panDelta:u.sub(o)}}}class Lu extends vc{_correctButton(o,u){return u===0&&o.ctrlKey||u===2}_move(o,u){const y=.8*(u.x-o.x);if(y)return this._active=!0,{bearingDelta:y}}contextmenu(o){o.preventDefault()}}class Ru extends vc{_correctButton(o,u){return u===0&&o.ctrlKey||u===2}_move(o,u){const y=-.5*(u.y-o.y);if(y)return this._active=!0,{pitchDelta:y}}contextmenu(o){o.preventDefault()}}class Qc{constructor(o,u){this._map=o,this._el=o.getCanvasContainer(),this._minTouches=1,this._clickTolerance=u.clickTolerance||1,this.reset(),i.bindAll(["_addTouchPanBlocker","_showTouchPanBlockerAlert"],this)}reset(){this._active=!1,this._touches={},this._sum=new i.Point(0,0)}touchstart(o,u,y){return this._calculateTransform(o,u,y)}touchmove(o,u,y){if(this._active&&!(y.length<this._minTouches)){if(this._map._cooperativeGestures&&!this._map.isMoving()){if(y.length===1&&!i.isFullscreen())return void this._showTouchPanBlockerAlert();this._alertContainer.style.visibility!=="hidden"&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}return o.cancelable&&o.preventDefault(),this._calculateTransform(o,u,y)}}touchend(o,u,y){this._calculateTransform(o,u,y),this._active&&y.length<this._minTouches&&this.reset()}touchcancel(){this.reset()}_calculateTransform(o,u,y){y.length>0&&(this._active=!0);const b=Cu(y,u),M=new i.Point(0,0),R=new i.Point(0,0);let z=0;for(const X in b){const q=b[X],Q=this._touches[X];Q&&(M._add(q),R._add(q.sub(Q)),z++,b[X]=q)}if(this._touches=b,z<this._minTouches||!R.mag())return;const V=R.div(z);return this._sum._add(V),this._sum.mag()<this._clickTolerance?void 0:{around:M.div(z),panDelta:V}}enable(){this._enabled=!0,this._map._cooperativeGestures&&(this._addTouchPanBlocker(),this._el.classList.add("mapboxgl-touch-pan-blocker-override","mapboxgl-scrollable-page"))}disable(){this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove(),this._el.classList.remove("mapboxgl-touch-pan-blocker-override","mapboxgl-scrollable-page")),this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}_addTouchPanBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=I("div","mapboxgl-touch-pan-blocker",this._map._container),this._alertContainer.textContent=this._map._getUIString("TouchPanBlocker.Message"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_showTouchPanBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-touch-pan-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.setAttribute("role","null")},500)}}class bc{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(o){}_move(o,u,y){return{}}touchstart(o,u,y){this._firstTwoTouches||y.length<2||(this._firstTwoTouches=[y[0].identifier,y[1].identifier],this._start([u[0],u[1]]))}touchmove(o,u,y){const b=this._firstTwoTouches;if(!b)return;o.preventDefault();const[M,R]=b,z=Ro(y,u,M),V=Ro(y,u,R);if(!z||!V)return;const X=this._aroundCenter?null:z.add(V).div(2);return this._move([z,V],X,o)}touchend(o,u,y){if(!this._firstTwoTouches)return;const[b,M]=this._firstTwoTouches,R=Ro(y,u,b),z=Ro(y,u,M);R&&z||(this._active&&ne(),this.reset())}touchcancel(){this.reset()}enable(o){this._enabled=!0,this._aroundCenter=!!o&&o.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function Ro(p,o,u){for(let y=0;y<p.length;y++)if(p[y].identifier===u)return o[y]}function Du(p,o){return Math.log(p/o)/Math.LN2}class wc extends bc{reset(){super.reset(),this._distance=0,this._startDistance=0}_start(o){this._startDistance=this._distance=o[0].dist(o[1])}_move(o,u){const y=this._distance;if(this._distance=o[0].dist(o[1]),this._active||!(Math.abs(Du(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:Du(this._distance,y),pinchAround:u}}}function Vl(p,o){return 180*p.angleWith(o)/Math.PI}class eu extends bc{reset(){super.reset(),this._minDiameter=0,this._startVector=void 0,this._vector=void 0}_start(o){this._startVector=this._vector=o[0].sub(o[1]),this._minDiameter=o[0].dist(o[1])}_move(o,u){const y=this._vector;if(this._vector=o[0].sub(o[1]),y&&(this._active||!this._isBelowThreshold(this._vector)))return this._active=!0,{bearingDelta:Vl(this._vector,y),pinchAround:u}}_isBelowThreshold(o){this._minDiameter=Math.min(this._minDiameter,o.mag());const u=25/(Math.PI*this._minDiameter)*360,y=this._startVector;if(!y)return!1;const b=Vl(o,y);return Math.abs(b)<u}}function va(p){return Math.abs(p.y)>Math.abs(p.x)}class mh extends bc{constructor(o){super(),this._map=o}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(o){this._lastPoints=o,va(o[0].sub(o[1]))&&(this._valid=!1)}_move(o,u,y){const b=this._lastPoints;if(!b)return;const M=o[0].sub(b[0]),R=o[1].sub(b[1]);return this._map._cooperativeGestures&&!i.isFullscreen()&&y.touches.length<3||(this._valid=this.gestureBeginsVertically(M,R,y.timeStamp),!this._valid)?void 0:(this._lastPoints=o,this._active=!0,{pitchDelta:(M.y+R.y)/2*-.5})}gestureBeginsVertically(o,u,y){if(this._valid!==void 0)return this._valid;const b=o.mag()>=2,M=u.mag()>=2;if(!b&&!M)return;if(!b||!M)return this._firstMove==null&&(this._firstMove=y),y-this._firstMove<100&&void 0;const R=o.y>0==u.y>0;return va(o)&&va(u)&&R}}const Sc={panStep:100,bearingStep:15,pitchStep:10};class so{constructor(){const o=Sc;this._panStep=o.panStep,this._bearingStep=o.bearingStep,this._pitchStep=o.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(o){if(o.altKey||o.ctrlKey||o.metaKey)return;let u=0,y=0,b=0,M=0,R=0;switch(o.keyCode){case 61:case 107:case 171:case 187:u=1;break;case 189:case 109:case 173:u=-1;break;case 37:o.shiftKey?y=-1:(o.preventDefault(),M=-1);break;case 39:o.shiftKey?y=1:(o.preventDefault(),M=1);break;case 38:o.shiftKey?b=1:(o.preventDefault(),R=-1);break;case 40:o.shiftKey?b=-1:(o.preventDefault(),R=1);break;default:return}return this._rotationDisabled&&(y=0,b=0),{cameraAnimation:z=>{const V=z.getZoom();z.easeTo({duration:300,easeId:"keyboardHandler",easing:Ad,zoom:u?Math.round(V)+u*(o.shiftKey?2:1):V,bearing:z.getBearing()+y*this._bearingStep,pitch:z.getPitch()+b*this._pitchStep,offset:[-M*this._panStep,-R*this._panStep],center:z.getCenter()},{originalEvent:o})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function Ad(p){return p*(2-p)}const gh=4.000244140625;class Do{constructor(o,u){this._map=o,this._el=o.getCanvasContainer(),this._handler=u,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,i.bindAll(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this)}setZoomRate(o){this._defaultZoomRate=o}setWheelZoomRate(o){this._wheelZoomRate=o}isEnabled(){return!!this._enabled}isActive(){return this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(o){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!o&&o.around==="center",this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(o){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(o.ctrlKey||o.metaKey||this.isZooming()||i.isFullscreen()))return void this._showBlockerAlert();this._alertContainer.style.visibility!=="hidden"&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let u=o.deltaMode===i.window.WheelEvent.DOM_DELTA_LINE?40*o.deltaY:o.deltaY;const y=i.exported.now(),b=y-(this._lastWheelEventTime||0);this._lastWheelEventTime=y,u!==0&&u%gh==0?this._type="wheel":u!==0&&Math.abs(u)<4?this._type="trackpad":b>400?(this._type=null,this._lastValue=u,this._timeout=setTimeout(this._onTimeout,40,o)):this._type||(this._type=Math.abs(b*u)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,u+=this._lastValue)),o.shiftKey&&u&&(u/=4),this._type&&(this._lastWheelEvent=o,this._delta-=u,this._active||this._start(o)),o.preventDefault()}_onTimeout(o){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(o)}_start(o){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const u=le(this._el,o);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:u,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const o=this._map.transform;this._type==="wheel"&&o.projection.wrap&&(o._center.lng>=180||o._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);const u=()=>o._terrainEnabled()&&this._aroundCoord?o.computeZoomRelativeTo(this._aroundCoord):o.zoom;if(this._delta!==0){const V=this._type==="wheel"&&Math.abs(this._delta)>gh?this._wheelZoomRate:this._defaultZoomRate;let X=2/(1+Math.exp(-Math.abs(this._delta*V)));this._delta<0&&X!==0&&(X=1/X);const q=u(),Q=Math.pow(2,q),he=typeof this._targetZoom=="number"?o.zoomScale(this._targetZoom):Q;this._targetZoom=Math.min(o.maxZoom,Math.max(o.minZoom,o.scaleZoom(he*X))),this._type==="wheel"&&(this._startZoom=q,this._easing=this._smoothOutEasing(200)),this._delta=0}const y=typeof this._targetZoom=="number"?this._targetZoom:u(),b=this._startZoom,M=this._easing;let R,z=!1;if(this._type==="wheel"&&b&&M){const V=Math.min((i.exported.now()-this._lastWheelEventTime)/200,1),X=M(V);R=i.number(b,y,X),V<1?this._frameId||(this._frameId=!0):z=!0}else R=y,z=!0;return this._active=!0,z&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!z,zoomDelta:R-u(),around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(o){let u=i.ease;if(this._prevEase){const y=this._prevEase,b=(i.exported.now()-y.start)/y.duration,M=y.easing(b+.01)-y.easing(b),R=.27/Math.sqrt(M*M+1e-4)*.01,z=Math.sqrt(.0729-R*R);u=i.bezier(R,z,.25,1)}return this._prevEase={start:i.exported.now(),duration:o,easing:u},u}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=I("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(i.window.navigator.userAgent)?this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize=`${Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))}px`)}_showBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","null")},200)}}class oo{constructor(o,u){this._clickZoom=o,this._tapZoom=u}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class js{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(o,u){return o.preventDefault(),{cameraAnimation:y=>{y.easeTo({duration:300,zoom:y.getZoom()+(o.shiftKey?-1:1),around:y.unproject(u)},{originalEvent:o})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Cd{constructor(){this._tap=new fh({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(o,u,y){this._swipePoint||(this._tapTime&&o.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?y.length>0&&(this._swipePoint=u[0],this._swipeTouch=y[0].identifier):this._tap.touchstart(o,u,y))}touchmove(o,u,y){if(this._tapTime){if(this._swipePoint){if(y[0].identifier!==this._swipeTouch)return;const b=u[0],M=b.y-this._swipePoint.y;return this._swipePoint=b,o.preventDefault(),this._active=!0,{zoomDelta:M/128}}}else this._tap.touchmove(o,u,y)}touchend(o,u,y){this._tapTime?this._swipePoint&&y.length===0&&this.reset():this._tap.touchend(o,u,y)&&(this._tapTime=o.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class _h{constructor(o,u,y){this._el=o,this._mousePan=u,this._touchPan=y}enable(o){this._inertiaOptions=o||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("mapboxgl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("mapboxgl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Id{constructor(o,u,y){this._pitchWithRotate=o.pitchWithRotate,this._mouseRotate=u,this._mousePitch=y}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class Pd{constructor(o,u,y,b){this._el=o,this._touchZoom=u,this._touchRotate=y,this._tapDragZoom=b,this._rotationDisabled=!1,this._enabled=!0}enable(o){this._touchZoom.enable(o),this._rotationDisabled||this._touchRotate.enable(o),this._tapDragZoom.enable(),this._el.classList.add("mapboxgl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("mapboxgl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}const zo=p=>p.zoom||p.drag||p.pitch||p.rotate;class yh extends i.Event{}class xh{constructor(){this.constants=[1,1,.01],this.radius=0}setup(o,u){const y=i.sub([],u,o);this.radius=i.length(y[2]<0?i.div([],y,this.constants):[y[0],y[1],0])}projectRay(o){i.div(o,o,this.constants),i.normalize(o,o),i.mul$1(o,o,this.constants);const u=i.scale$2([],o,this.radius);if(u[2]>0){const y=i.scale$2([],[0,0,1],i.dot(u,[0,0,1])),b=i.scale$2([],i.normalize([],[u[0],u[1],0]),this.radius),M=i.add([],u,i.scale$2([],i.sub([],i.add([],b,y),u),2));u[0]=M[0],u[1]=M[1]}return u}}function sa(p){return p.panDelta&&p.panDelta.mag()||p.zoomDelta||p.bearingDelta||p.pitchDelta}class ba{constructor(o,u){this._map=o,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Td(o),this._bearingSnap=u.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new xh,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(u),i.bindAll(["handleEvent","handleWindowEvent"],this);const y=this._el;this._listeners=[[y,"touchstart",{passive:!0}],[y,"touchmove",{passive:!1}],[y,"touchend",void 0],[y,"touchcancel",void 0],[y,"mousedown",void 0],[y,"mousemove",void 0],[y,"mouseup",void 0],[i.window.document,"mousemove",{capture:!0}],[i.window.document,"mouseup",void 0],[y,"mouseover",void 0],[y,"mouseout",void 0],[y,"dblclick",void 0],[y,"click",void 0],[y,"keydown",{capture:!1}],[y,"keyup",void 0],[y,"wheel",{passive:!1}],[y,"contextmenu",void 0],[i.window,"blur",void 0]];for(const[b,M,R]of this._listeners)b.addEventListener(M,b===i.window.document?this.handleWindowEvent:this.handleEvent,R)}destroy(){for(const[o,u,y]of this._listeners)o.removeEventListener(u,o===i.window.document?this.handleWindowEvent:this.handleEvent,y)}_addDefaultHandlers(o){const u=this._map,y=u.getCanvasContainer();this._add("mapEvent",new Au(u,o));const b=u.boxZoom=new Kc(u,o);this._add("boxZoom",b);const M=new ph,R=new js;u.doubleClickZoom=new oo(R,M),this._add("tapZoom",M),this._add("clickZoom",R);const z=new Cd;this._add("tapDragZoom",z);const V=u.touchPitch=new mh(u);this._add("touchPitch",V);const X=new Lu(o),q=new Ru(o);u.dragRotate=new Id(o,X,q),this._add("mouseRotate",X,["mousePitch"]),this._add("mousePitch",q,["mouseRotate"]);const Q=new Pu(o),he=new Qc(u,o);u.dragPan=new _h(y,Q,he),this._add("mousePan",Q),this._add("touchPan",he,["touchZoom","touchRotate"]);const me=new eu,ge=new wc;u.touchZoomRotate=new Pd(y,ge,me,z),this._add("touchRotate",me,["touchPan","touchZoom"]),this._add("touchZoom",ge,["touchPan","touchRotate"]),this._add("blockableMapEvent",new Jc(u));const _e=u.scrollZoom=new Do(u,this);this._add("scrollZoom",_e,["mousePan"]);const be=u.keyboard=new so;this._add("keyboard",be);for(const ie of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])o.interactive&&o[ie]&&u[ie].enable(o[ie])}_add(o,u,y){this._handlers.push({handlerName:o,handler:u,allowed:y}),this._handlersById[o]=u}stop(o){if(!this._updatingCamera){for(const{handler:u}of this._handlers)u.reset();this._inertia.clear(),this._fireEvents({},{},o),this._changes=[]}}isActive(){for(const{handler:o}of this._handlers)if(o.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!zo(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(o,u,y){for(const b in o)if(b!==y&&(!u||u.indexOf(b)<0))return!0;return!1}handleWindowEvent(o){this.handleEvent(o,`${o.type}Window`)}_getMapTouches(o){const u=[];for(const y of o)this._el.contains(y.target)&&u.push(y);return u}handleEvent(o,u){this._updatingCamera=!0;const y=o.type==="renderFrame",b=y?void 0:o,M={needsRenderFrame:!1},R={},z={},V=o.touches?this._getMapTouches(o.touches):void 0,X=V?fe(this._el,V):y?void 0:le(this._el,o);for(const{handlerName:he,handler:me,allowed:ge}of this._handlers){if(!me.isEnabled())continue;let _e;this._blockedByActive(z,ge,he)?me.reset():me[u||o.type]&&(_e=me[u||o.type](o,X,V),this.mergeHandlerResult(M,R,_e,he,b),_e&&_e.needsRenderFrame&&this._triggerRenderFrame()),(_e||me.isActive())&&(z[he]=me)}const q={};for(const he in this._previousActiveHandlers)z[he]||(q[he]=b);this._previousActiveHandlers=z,(Object.keys(q).length||sa(M))&&(this._changes.push([M,R,q]),this._triggerRenderFrame()),(Object.keys(z).length||sa(M))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:Q}=M;Q&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],Q(this._map))}mergeHandlerResult(o,u,y,b,M){if(!y)return;i.extend(o,y);const R={handlerName:b,originalEvent:y.originalEvent||M};y.zoomDelta!==void 0&&(u.zoom=R),y.panDelta!==void 0&&(u.drag=R),y.pitchDelta!==void 0&&(u.pitch=R),y.bearingDelta!==void 0&&(u.rotate=R)}_applyChanges(){const o={},u={},y={};for(const[b,M,R]of this._changes)b.panDelta&&(o.panDelta=(o.panDelta||new i.Point(0,0))._add(b.panDelta)),b.zoomDelta&&(o.zoomDelta=(o.zoomDelta||0)+b.zoomDelta),b.bearingDelta&&(o.bearingDelta=(o.bearingDelta||0)+b.bearingDelta),b.pitchDelta&&(o.pitchDelta=(o.pitchDelta||0)+b.pitchDelta),b.around!==void 0&&(o.around=b.around),b.aroundCoord!==void 0&&(o.aroundCoord=b.aroundCoord),b.pinchAround!==void 0&&(o.pinchAround=b.pinchAround),b.noInertia&&(o.noInertia=b.noInertia),i.extend(u,M),i.extend(y,R);this._updateMapTransform(o,u,y),this._changes=[]}_updateMapTransform(o,u,y){const b=this._map,M=b.transform,R=pe=>[pe.x,pe.y,pe.z];if((pe=>{const Ee=this._eventsInProgress.drag;return Ee&&!this._handlersById[Ee.handlerName].isActive()})()&&!sa(o)){const pe=M.zoom;M.cameraElevationReference="sea",M.recenterOnTerrain(),M.cameraElevationReference="ground",pe!==M.zoom&&this._map._update(!0)}if(M._isCameraConstrained&&b._stop(!0),!sa(o))return void this._fireEvents(u,y,!0);let{panDelta:z,zoomDelta:V,bearingDelta:X,pitchDelta:q,around:Q,aroundCoord:he,pinchAround:me}=o;M._isCameraConstrained&&(V>0&&(V=0),M._isCameraConstrained=!1),me!==void 0&&(Q=me),(V||(pe=>u[pe]&&!this._eventsInProgress[pe])("drag"))&&Q&&(this._dragOrigin=R(M.pointCoordinate3D(Q)),this._trackingEllipsoid.setup(M._camera.position,this._dragOrigin)),M.cameraElevationReference="sea",b._stop(!0),Q=Q||b.transform.centerPoint,X&&(M.bearing+=X),q&&(M.pitch+=q),M._updateCameraState();const ge=[0,0,0];if(z)if(M.projection.name==="mercator"){const pe=this._trackingEllipsoid.projectRay(M.screenPointToMercatorRay(Q).dir),Ee=this._trackingEllipsoid.projectRay(M.screenPointToMercatorRay(Q.sub(z)).dir);ge[0]=Ee[0]-pe[0],ge[1]=Ee[1]-pe[1]}else{const pe=M.pointCoordinate(Q);if(M.projection.name==="globe"){z=z.rotate(-M.angle);const Ee=M._pixelsPerMercatorPixel/M.worldSize;ge[0]=-z.x*i.mercatorScale(i.latFromMercatorY(pe.y))*Ee,ge[1]=-z.y*i.mercatorScale(M.center.lat)*Ee}else{const Ee=M.pointCoordinate(Q.sub(z));pe&&Ee&&(ge[0]=Ee.x-pe.x,ge[1]=Ee.y-pe.y)}}const _e=M.zoom,be=[0,0,0];if(V){const pe=R(he||M.pointCoordinate3D(Q)),Ee={dir:i.normalize([],i.sub([],pe,M._camera.position))};if(Ee.dir[2]<0){const Te=M.zoomDeltaToMovement(pe,V);i.scale$2(be,Ee.dir,Te)}}const ie=i.add(ge,ge,be);M._translateCameraConstrained(ie),V&&Math.abs(M.zoom-_e)>1e-4&&M.recenterOnTerrain(),M.cameraElevationReference="ground",this._map._update(),o.noInertia||this._inertia.record(o),this._fireEvents(u,y,!0)}_fireEvents(o,u,y){const b=zo(this._eventsInProgress),M=zo(o),R={};for(const q in o){const{originalEvent:Q}=o[q];this._eventsInProgress[q]||(R[`${q}start`]=Q),this._eventsInProgress[q]=o[q]}!b&&M&&this._fireEvent("movestart",M.originalEvent);for(const q in R)this._fireEvent(q,R[q]);M&&this._fireEvent("move",M.originalEvent);for(const q in o){const{originalEvent:Q}=o[q];this._fireEvent(q,Q)}const z={};let V;for(const q in this._eventsInProgress){const{handlerName:Q,originalEvent:he}=this._eventsInProgress[q];this._handlersById[Q].isActive()||(delete this._eventsInProgress[q],V=u[Q]||he,z[`${q}end`]=V)}for(const q in z)this._fireEvent(q,z[q]);const X=zo(this._eventsInProgress);if(y&&(b||M)&&!X){this._updatingCamera=!0;const q=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),Q=he=>he!==0&&-this._bearingSnap<he&&he<this._bearingSnap;q?(Q(q.bearing||this._map.getBearing())&&(q.bearing=0),this._map.easeTo(q,{originalEvent:V})):(this._map.fire(new i.Event("moveend",{originalEvent:V})),Q(this._map.getBearing())&&this._map.resetNorth()),this._updatingCamera=!1}}_fireEvent(o,u){this._map.fire(new i.Event(o,u?{originalEvent:u}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(o=>{this._frameId=void 0,this.handleEvent(new yh("renderFrame",{timeStamp:o})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}const Wa="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class Gl extends i.Evented{constructor(o,u){super(),this._moving=!1,this._zooming=!1,this.transform=o,this._bearingSnap=u.bearingSnap,this._respectPrefersReducedMotion=u.respectPrefersReducedMotion!==!1,i.bindAll(["_renderFrameCallback"],this)}getCenter(){return new i.LngLat(this.transform.center.lng,this.transform.center.lat)}setCenter(o,u){return this.jumpTo({center:o},u)}panBy(o,u,y){return o=i.Point.convert(o).mult(-1),this.panTo(this.transform.center,i.extend({offset:o},u),y)}panTo(o,u,y){return this.easeTo(i.extend({center:o},u),y)}getZoom(){return this.transform.zoom}setZoom(o,u){return this.jumpTo({zoom:o},u),this}zoomTo(o,u,y){return this.easeTo(i.extend({zoom:o},u),y)}zoomIn(o,u){return this.zoomTo(this.getZoom()+1,o,u),this}zoomOut(o,u){return this.zoomTo(this.getZoom()-1,o,u),this}getBearing(){return this.transform.bearing}setBearing(o,u){return this.jumpTo({bearing:o},u),this}getPadding(){return this.transform.padding}setPadding(o,u){return this.jumpTo({padding:o},u),this}rotateTo(o,u,y){return this.easeTo(i.extend({bearing:o},u),y)}resetNorth(o,u){return this.rotateTo(0,i.extend({duration:1e3},o),u),this}resetNorthPitch(o,u){return this.easeTo(i.extend({bearing:0,pitch:0,duration:1e3},o),u),this}snapToNorth(o,u){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(o,u):this}getPitch(){return this.transform.pitch}setPitch(o,u){return this.jumpTo({pitch:o},u),this}cameraForBounds(o,u){o=i.LngLatBounds.convert(o);const y=u&&u.bearing||0,b=u&&u.pitch||0,M=o.getNorthWest(),R=o.getSouthEast();return this._cameraForBounds(this.transform,M,R,y,b,u)}_extendCameraOptions(o){const u={top:0,bottom:0,right:0,left:0};if(typeof(o=i.extend({padding:u,offset:[0,0],maxZoom:this.transform.maxZoom},o)).padding=="number"){const y=o.padding;o.padding={top:y,bottom:y,right:y,left:y}}return o.padding=i.extend(u,o.padding),o}_minimumAABBFrustumDistance(o,u){const y=u.max[0]-u.min[0],b=u.max[1]-u.min[1];return y/b>o.aspect?y/(2*Math.tan(.5*o.fovX)*o.aspect):b/(2*Math.tan(.5*o.fovY)*o.aspect)}_cameraForBoundsOnGlobe(o,u,y,b,M,R){const z=o.clone(),V=this._extendCameraOptions(R);z.bearing=b,z.pitch=M;const X=i.LngLat.convert(u),q=i.LngLat.convert(y),Q=.5*(X.lat+q.lat),he=.5*(X.lng+q.lng),me=i.latLngToECEF(Q,he),ge=i.normalize([],me),_e=i.normalize([],i.cross([],ge,[0,1,0])),be=i.cross([],_e,ge),ie=[_e[0],_e[1],_e[2],0,be[0],be[1],be[2],0,ge[0],ge[1],ge[2],0,0,0,0,1],pe=[me,i.latLngToECEF(X.lat,X.lng),i.latLngToECEF(q.lat,X.lng),i.latLngToECEF(q.lat,q.lng),i.latLngToECEF(X.lat,q.lng),i.latLngToECEF(Q,X.lng),i.latLngToECEF(Q,q.lng),i.latLngToECEF(X.lat,he),i.latLngToECEF(q.lat,he)];let Ee=i.Aabb.fromPoints(pe.map(Lt=>[i.dot(_e,Lt),i.dot(be,Lt),i.dot(ge,Lt)]));const Te=i.transformMat4([],Ee.center,ie);i.squaredLength(Te)===0&&i.set(Te,0,0,1),i.normalize(Te,Te),i.scale$2(Te,Te,i.GLOBE_RADIUS),z.center=i.ecefToLatLng(Te);const Ue=z.getWorldToCameraMatrix(),Ge=i.invert(new Float64Array(16),Ue);Ee=i.Aabb.applyTransform(Ee,i.multiply([],Ue,ie)),i.transformMat4(Te,Te,Ue);const Ve=.5*(Ee.max[2]-Ee.min[2]),et=this._minimumAABBFrustumDistance(z,Ee),$e=i.scale$2([],[0,0,1],Ve),ht=i.add($e,Te,$e),Jt=et+(z.pitch===0?0:i.distance(Te,ht)),ut=z.globeCenterInViewSpace,Bt=i.sub([],Te,[ut[0],ut[1],ut[2]]);i.normalize(Bt,Bt),i.scale$2(Bt,Bt,Jt);const yt=i.add([],Te,Bt);i.transformMat4(yt,yt,Ge);const Xt=i.earthRadius/i.GLOBE_RADIUS,gt=i.length(yt),Ot=i.mercatorZfromAltitude(Math.max(gt*Xt-i.earthRadius,Number.EPSILON),0),Qt=Math.min(z.zoomFromMercatorZAdjusted(Ot),V.maxZoom);return Qt>.5*(i.GLOBE_ZOOM_THRESHOLD_MIN+i.GLOBE_ZOOM_THRESHOLD_MAX)?(z.setProjection({name:"mercator"}),z.zoom=Qt,this._cameraForBounds(z,u,y,b,M,R)):{center:z.center,zoom:Qt,bearing:b,pitch:M}}queryTerrainElevation(o,u){const y=this.transform.elevation;return y?(u=i.extend({},{exaggerated:!0},u),y.getAtPoint(i.MercatorCoordinate.fromLngLat(o),null,u.exaggerated)):null}_cameraForBounds(o,u,y,b,M,R){if(o.projection.name==="globe")return this._cameraForBoundsOnGlobe(o,u,y,b,M,R);const z=o.clone(),V=this._extendCameraOptions(R),X=z.padding;z.bearing=b,z.pitch=M;const q=i.LngLat.convert(u),Q=i.LngLat.convert(y),he=new i.LngLat(q.lng,Q.lat),me=new i.LngLat(Q.lng,q.lat),ge=z.project(q),_e=z.project(Q),be=this.queryTerrainElevation(q),ie=this.queryTerrainElevation(Q),pe=this.queryTerrainElevation(he),Ee=this.queryTerrainElevation(me),Te=[[ge.x,ge.y,Math.min(be||0,ie||0,pe||0,Ee||0)],[_e.x,_e.y,Math.max(be||0,ie||0,pe||0,Ee||0)]];let Ue=i.Aabb.fromPoints(Te);const Ge=z.getWorldToCameraMatrix(),Ve=i.invert(new Float64Array(16),Ge);Ue=i.Aabb.applyTransform(Ue,Ge);const et=i.sub([],Ue.max,Ue.min),$e=X.left||0,ht=X.right||0,Jt=X.bottom||0,ut=X.top||0,{left:Bt,right:yt,top:Xt,bottom:gt}=V.padding,Ot=.5*($e+ht),Qt=.5*(ut+Jt),Lt=Math.min(z.scaleZoom(z.scale*Math.min((z.width-($e+ht+Bt+yt))/et[0],(z.height-(Jt+ut+gt+Xt))/et[1])),V.maxZoom),Ct=z.scale/z.zoomScale(Lt);Ue=new i.Aabb([Ue.min[0]-(Bt+Ot)*Ct,Ue.min[1]-(gt+Qt)*Ct,Ue.min[2]],[Ue.max[0]+(yt+Ot)*Ct,Ue.max[1]+(Xt+Qt)*Ct,Ue.max[2]]);const zn=.5*et[2],qn=this._minimumAABBFrustumDistance(z,Ue),vn=[0,0,1,0];i.transformMat4$1(vn,vn,Ge),i.normalize$2(vn,vn);const Vn=i.scale$2([],vn,qn+zn),Ai=i.add([],Ue.center,Vn),si=(typeof V.offset.x=="number"&&typeof V.offset.y=="number"?new i.Point(V.offset.x,V.offset.y):i.Point.convert(V.offset)).rotate(-i.degToRad(b));Ue.center[0]-=si.x*Ct,Ue.center[1]+=si.y*Ct,i.transformMat4(Ue.center,Ue.center,Ve),i.transformMat4(Ai,Ai,Ve);const Gn=[Ue.center[0],Ue.center[1],Ai[2]*z.pixelsPerMeter];i.scale$2(Gn,Gn,1/z.worldSize);const $i=i.lngFromMercatorX(Gn[0]),hr=i.latFromMercatorY(Gn[1]),mr=Math.min(z._zoomFromMercatorZ(Gn[2]),V.maxZoom),ar=new i.LngLat($i,hr);return z.mercatorFromTransition&&mr<.5*(i.GLOBE_ZOOM_THRESHOLD_MIN+i.GLOBE_ZOOM_THRESHOLD_MAX)?(z.setProjection({name:"globe"}),z.zoom=mr,this._cameraForBounds(z,u,y,b,M,R)):{center:ar,zoom:mr,bearing:b,pitch:M}}fitBounds(o,u,y){const b=this.cameraForBounds(o,u);return this._fitInternal(b,u,y)}fitScreenCoordinates(o,u,y,b,M){const R=i.Point.convert(o),z=i.Point.convert(u),V=new i.Point(Math.min(R.x,z.x),Math.min(R.y,z.y)),X=new i.Point(Math.max(R.x,z.x),Math.max(R.y,z.y));if(this.transform.projection.name==="mercator"&&this.transform.anyCornerOffEdge(R,z))return this;const q=this.transform.pointLocation3D(V),Q=this.transform.pointLocation3D(X),he=this.transform.pointLocation3D(new i.Point(V.x,X.y)),me=this.transform.pointLocation3D(new i.Point(X.x,V.y)),ge=[Math.min(q.lng,Q.lng,he.lng,me.lng),Math.min(q.lat,Q.lat,he.lat,me.lat)],_e=[Math.max(q.lng,Q.lng,he.lng,me.lng),Math.max(q.lat,Q.lat,he.lat,me.lat)],be=b&&b.pitch?b.pitch:this.getPitch(),ie=this._cameraForBounds(this.transform,ge,_e,y,be,b);return this._fitInternal(ie,b,M)}_fitInternal(o,u,y){return o?(delete(u=i.extend(o,u)).padding,u.linear?this.easeTo(u,y):this.flyTo(u,y)):this}jumpTo(o,u){this.stop();const y=o.preloadOnly?this.transform.clone():this.transform;let b=!1,M=!1,R=!1;return"zoom"in o&&y.zoom!==+o.zoom&&(b=!0,y.zoom=+o.zoom),o.center!==void 0&&(y.center=i.LngLat.convert(o.center)),"bearing"in o&&y.bearing!==+o.bearing&&(M=!0,y.bearing=+o.bearing),"pitch"in o&&y.pitch!==+o.pitch&&(R=!0,y.pitch=+o.pitch),o.padding==null||y.isPaddingEqual(o.padding)||(y.padding=o.padding),o.preloadOnly?(this._preloadTiles(y),this):(this.fire(new i.Event("movestart",u)).fire(new i.Event("move",u)),b&&this.fire(new i.Event("zoomstart",u)).fire(new i.Event("zoom",u)).fire(new i.Event("zoomend",u)),M&&this.fire(new i.Event("rotatestart",u)).fire(new i.Event("rotate",u)).fire(new i.Event("rotateend",u)),R&&this.fire(new i.Event("pitchstart",u)).fire(new i.Event("pitch",u)).fire(new i.Event("pitchend",u)),this.fire(new i.Event("moveend",u)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||i.warnOnce(Wa),this.transform.getFreeCameraOptions()}setFreeCameraOptions(o,u){const y=this.transform;if(!y.projection.supportsFreeCamera)return i.warnOnce(Wa),this;this.stop();const b=y.zoom,M=y.pitch,R=y.bearing;y.setFreeCameraOptions(o);const z=b!==y.zoom,V=M!==y.pitch,X=R!==y.bearing;return this.fire(new i.Event("movestart",u)).fire(new i.Event("move",u)),z&&this.fire(new i.Event("zoomstart",u)).fire(new i.Event("zoom",u)).fire(new i.Event("zoomend",u)),X&&this.fire(new i.Event("rotatestart",u)).fire(new i.Event("rotate",u)).fire(new i.Event("rotateend",u)),V&&this.fire(new i.Event("pitchstart",u)).fire(new i.Event("pitch",u)).fire(new i.Event("pitchend",u)),this.fire(new i.Event("moveend",u)),this}easeTo(o,u){this._stop(!1,o.easeId),((o=i.extend({offset:[0,0],duration:500,easing:i.ease},o)).animate===!1||this._prefersReducedMotion(o))&&(o.duration=0);const y=this.transform,b=this.getZoom(),M=this.getBearing(),R=this.getPitch(),z=this.getPadding(),V="zoom"in o?+o.zoom:b,X="bearing"in o?this._normalizeBearing(o.bearing,M):M,q="pitch"in o?+o.pitch:R,Q="padding"in o?o.padding:y.padding,he=i.Point.convert(o.offset);let me,ge,_e;if(y.projection.name==="globe"){const $e=i.MercatorCoordinate.fromLngLat(y.center),ht=he.rotate(-y.angle);$e.x+=ht.x/y.worldSize,$e.y+=ht.y/y.worldSize;const Jt=$e.toLngLat(),ut=i.LngLat.convert(o.center||Jt);this._normalizeCenter(ut),me=y.centerPoint.add(ht),ge=new i.Point($e.x,$e.y).mult(y.worldSize),_e=new i.Point(i.mercatorXfromLng(ut.lng),i.mercatorYfromLat(ut.lat)).mult(y.worldSize).sub(ge)}else{me=y.centerPoint.add(he);const $e=y.pointLocation(me),ht=i.LngLat.convert(o.center||$e);this._normalizeCenter(ht),ge=y.project($e),_e=y.project(ht).sub(ge)}const be=y.zoomScale(V-b);let ie,pe;o.around&&(ie=i.LngLat.convert(o.around),pe=y.locationPoint(ie));const Ee=this._zooming||V!==b,Te=this._rotating||M!==X,Ue=this._pitching||q!==R,Ge=!y.isPaddingEqual(Q),Ve=$e=>ht=>{if(Ee&&($e.zoom=i.number(b,V,ht)),Te&&($e.bearing=i.number(M,X,ht)),Ue&&($e.pitch=i.number(R,q,ht)),Ge&&($e.interpolatePadding(z,Q,ht),me=$e.centerPoint.add(he)),ie)$e.setLocationAtPoint(ie,pe);else{const Jt=$e.zoomScale($e.zoom-b),ut=V>b?Math.min(2,be):Math.max(.5,be),Bt=Math.pow(ut,1-ht),yt=$e.unproject(ge.add(_e.mult(ht*Bt)).mult(Jt));$e.setLocationAtPoint($e.renderWorldCopies?yt.wrap():yt,me)}return o.preloadOnly||this._fireMoveEvents(u),$e};if(o.preloadOnly){const $e=this._emulate(Ve,o.duration,y);return this._preloadTiles($e),this}const et={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=Ee,this._rotating=Te,this._pitching=Ue,this._padding=Ge,this._easeId=o.easeId,this._prepareEase(u,o.noMoveStart,et),this._ease(Ve(y),$e=>{y.recenterOnTerrain(),this._afterEase(u,$e)},o),this}_prepareEase(o,u,y={}){this._moving=!0,this.transform.cameraElevationReference="sea",u||y.moving||this.fire(new i.Event("movestart",o)),this._zooming&&!y.zooming&&this.fire(new i.Event("zoomstart",o)),this._rotating&&!y.rotating&&this.fire(new i.Event("rotatestart",o)),this._pitching&&!y.pitching&&this.fire(new i.Event("pitchstart",o))}_fireMoveEvents(o){this.fire(new i.Event("move",o)),this._zooming&&this.fire(new i.Event("zoom",o)),this._rotating&&this.fire(new i.Event("rotate",o)),this._pitching&&this.fire(new i.Event("pitch",o))}_afterEase(o,u){if(this._easeId&&u&&this._easeId===u)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const y=this._zooming,b=this._rotating,M=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,y&&this.fire(new i.Event("zoomend",o)),b&&this.fire(new i.Event("rotateend",o)),M&&this.fire(new i.Event("pitchend",o)),this.fire(new i.Event("moveend",o))}flyTo(o,u){if(this._prefersReducedMotion(o)){const Lt=i.pick(o,["center","zoom","bearing","pitch","around"]);return this.jumpTo(Lt,u)}this.stop(),o=i.extend({offset:[0,0],speed:1.2,curve:1.42,easing:i.ease},o);const y=this.transform,b=this.getZoom(),M=this.getBearing(),R=this.getPitch(),z=this.getPadding(),V="zoom"in o?i.clamp(+o.zoom,y.minZoom,y.maxZoom):b,X="bearing"in o?this._normalizeBearing(o.bearing,M):M,q="pitch"in o?+o.pitch:R,Q="padding"in o?o.padding:y.padding,he=y.zoomScale(V-b),me=i.Point.convert(o.offset);let ge=y.centerPoint.add(me);const _e=y.pointLocation(ge),be=i.LngLat.convert(o.center||_e);this._normalizeCenter(be);const ie=y.project(_e),pe=y.project(be).sub(ie);let Ee=o.curve;const Te=Math.max(y.width,y.height),Ue=Te/he,Ge=pe.mag();if("minZoom"in o){const Lt=i.clamp(Math.min(o.minZoom,b,V),y.minZoom,y.maxZoom),Ct=Te/y.zoomScale(Lt-b);Ee=Math.sqrt(Ct/Ge*2)}const Ve=Ee*Ee;function et(Lt){const Ct=(Ue*Ue-Te*Te+(Lt?-1:1)*Ve*Ve*Ge*Ge)/(2*(Lt?Ue:Te)*Ve*Ge);return Math.log(Math.sqrt(Ct*Ct+1)-Ct)}function $e(Lt){return(Math.exp(Lt)-Math.exp(-Lt))/2}function ht(Lt){return(Math.exp(Lt)+Math.exp(-Lt))/2}const Jt=et(0);let ut=function(Lt){return ht(Jt)/ht(Jt+Ee*Lt)},Bt=function(Lt){return Te*((ht(Jt)*($e(Ct=Jt+Ee*Lt)/ht(Ct))-$e(Jt))/Ve)/Ge;var Ct},yt=(et(1)-Jt)/Ee;if(Math.abs(Ge)<1e-6||!isFinite(yt)){if(Math.abs(Te-Ue)<1e-6)return this.easeTo(o,u);const Lt=Ue<Te?-1:1;yt=Math.abs(Math.log(Ue/Te))/Ee,Bt=function(){return 0},ut=function(Ct){return Math.exp(Lt*Ee*Ct)}}o.duration="duration"in o?+o.duration:1e3*yt/("screenSpeed"in o?+o.screenSpeed/Ee:+o.speed),o.maxDuration&&o.duration>o.maxDuration&&(o.duration=0);const Xt=M!==X,gt=q!==R,Ot=!y.isPaddingEqual(Q),Qt=Lt=>Ct=>{const zn=Ct*yt,qn=1/ut(zn);Lt.zoom=Ct===1?V:b+Lt.scaleZoom(qn),Xt&&(Lt.bearing=i.number(M,X,Ct)),gt&&(Lt.pitch=i.number(R,q,Ct)),Ot&&(Lt.interpolatePadding(z,Q,Ct),ge=Lt.centerPoint.add(me));const vn=Ct===1?be:Lt.unproject(ie.add(pe.mult(Bt(zn))).mult(qn));return Lt.setLocationAtPoint(Lt.renderWorldCopies?vn.wrap():vn,ge),Lt._updateCameraOnTerrain(),o.preloadOnly||this._fireMoveEvents(u),Lt};if(o.preloadOnly){const Lt=this._emulate(Qt,o.duration,y);return this._preloadTiles(Lt),this}return this._zooming=!0,this._rotating=Xt,this._pitching=gt,this._padding=Ot,this._prepareEase(u,!1),this._ease(Qt(y),()=>this._afterEase(u),o),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(o,u){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const y=this._onEaseEnd;this._onEaseEnd=void 0,y.call(this,u)}if(!o){const y=this.handlers;y&&y.stop(!1)}return this}_ease(o,u,y){y.animate===!1||y.duration===0?(o(1),u()):(this._easeStart=i.exported.now(),this._easeOptions=y,this._onEaseFrame=o,this._onEaseEnd=u,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const o=Math.min((i.exported.now()-this._easeStart)/this._easeOptions.duration,1),u=this._onEaseFrame;u&&u(this._easeOptions.easing(o)),o<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(o,u){o=i.wrap(o,-180,180);const y=Math.abs(o-u);return Math.abs(o-360-u)<y&&(o-=360),Math.abs(o+360-u)<y&&(o+=360),o}_normalizeCenter(o){const u=this.transform;if(!u.renderWorldCopies||u.maxBounds)return;const y=o.lng-u.center.lng;o.lng+=y>180?-360:y<-180?360:0}_prefersReducedMotion(o){return this._respectPrefersReducedMotion&&i.exported.prefersReducedMotion&&!(o&&o.essential)}_emulate(o,u,y){const b=Math.ceil(15*u/1e3),M=[],R=o(y.clone());for(let z=0;z<=b;z++){const V=R(z/b);M.push(V.clone())}return M}}class kn{constructor(o={}){this.options=o,i.bindAll(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(o){const u=this.options&&this.options.compact;return this._map=o,this._container=I("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=I("button","mapboxgl-ctrl-attrib-button",this._container),I("span","mapboxgl-ctrl-icon",this._compactButton).setAttribute("aria-hidden","true"),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=I("div","mapboxgl-ctrl-attrib-inner",this._container),this._innerContainer.setAttribute("role","list"),u&&this._container.classList.add("mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),u===void 0&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0,this._attribHTML=void 0}_setElementTitle(o,u){const y=this._map._getUIString(`AttributionControl.${u}`);o.setAttribute("aria-label",y),o.removeAttribute("title"),o.firstElementChild&&o.firstElementChild.setAttribute("title",y)}_toggleAttribution(){this._container.classList.contains("mapboxgl-compact-show")?(this._container.classList.remove("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","false")):(this._container.classList.add("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","true"))}_updateEditLink(){let o=this._editLink;o||(o=this._editLink=this._container.querySelector(".mapbox-improve-map"));const u=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||i.config.ACCESS_TOKEN}];if(o){const y=u.reduce((b,M,R)=>(M.value&&(b+=`${M.key}=${M.value}${R<u.length-1?"&":""}`),b),"?");o.href=`${i.config.FEEDBACK_URL}/${y}#${pc(this._map,!0)}`,o.rel="noopener nofollow",this._setElementTitle(o,"MapFeedback")}}_updateData(o){!o||o.sourceDataType!=="metadata"&&o.sourceDataType!=="visibility"&&o.dataType!=="style"||(this._updateAttributions(),this._updateEditLink())}_updateAttributions(){if(!this._map.style)return;let o=[];if(this._map.style.stylesheet){const b=this._map.style.stylesheet;this.styleOwner=b.owner,this.styleId=b.id}const u=this._map.style._sourceCaches;for(const b in u){const M=u[b];if(M.used){const R=M.getSource();R.attribution&&o.indexOf(R.attribution)<0&&o.push(R.attribution)}}o.sort((b,M)=>b.length-M.length),o=o.filter((b,M)=>{for(let R=M+1;R<o.length;R++)if(o[R].indexOf(b)>=0)return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?o=[...this.options.customAttribution,...o]:o.unshift(this.options.customAttribution));const y=o.join(" | ");y!==this._attribHTML&&(this._attribHTML=y,o.length?(this._innerContainer.innerHTML=y,this._container.classList.remove("mapboxgl-attrib-empty")):this._container.classList.add("mapboxgl-attrib-empty"),this._editLink=null)}_updateCompact(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("mapboxgl-compact"):this._container.classList.remove("mapboxgl-compact","mapboxgl-compact-show")}}class tu{constructor(){i.bindAll(["_updateLogo","_updateCompact"],this)}onAdd(o){this._map=o,this._container=I("div","mapboxgl-ctrl");const u=I("a","mapboxgl-ctrl-logo");return u.target="_blank",u.rel="noopener nofollow",u.href="https://www.mapbox.com/",u.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),u.setAttribute("rel","noopener nofollow"),this._container.appendChild(u),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact)}getDefaultPosition(){return"bottom-left"}_updateLogo(o){o&&o.sourceDataType!=="metadata"||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const o=this._map.style._sourceCaches;if(Object.entries(o).length===0)return!0;for(const u in o){const y=o[u].getSource();if(y.hasOwnProperty("mapbox_logo")&&!y.mapbox_logo)return!1}return!0}_updateCompact(){const o=this._container.children;if(o.length){const u=o[0];this._map.getCanvasContainer().offsetWidth<250?u.classList.add("mapboxgl-compact"):u.classList.remove("mapboxgl-compact")}}}class zu{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(o){const u=++this._id;return this._queue.push({callback:o,id:u,cancelled:!1}),u}remove(o){const u=this._currentlyRunning,y=u?this._queue.concat(u):this._queue;for(const b of y)if(b.id===o)return void(b.cancelled=!0)}run(o=0){const u=this._currentlyRunning=this._queue;this._queue=[];for(const y of u)if(!y.cancelled&&(y.callback(o),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}function jl(p,o,u){if(p=new i.LngLat(p.lng,p.lat),o){const y=new i.LngLat(p.lng-360,p.lat),b=new i.LngLat(p.lng+360,p.lat),M=360*Math.ceil(Math.abs(p.lng-u.center.lng)/360),R=u.locationPoint(p).distSqr(o),z=o.x<0||o.y<0||o.x>u.width||o.y>u.height;u.locationPoint(y).distSqr(o)<R&&(z||Math.abs(y.lng-u.center.lng)<M)?p=y:u.locationPoint(b).distSqr(o)<R&&(z||Math.abs(b.lng-u.center.lng)<M)&&(p=b)}for(;Math.abs(p.lng-u.center.lng)>180;){const y=u.locationPoint(p);if(y.x>=0&&y.y>=0&&y.x<=u.width&&y.y<=u.height)break;p.lng>u.center.lng?p.lng-=360:p.lng+=360}return p}const Ha={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};class An extends i.Evented{constructor(o,u){if(super(),(o instanceof i.window.HTMLElement||u)&&(o=i.extend({element:o},u)),i.bindAll(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this),this._anchor=o&&o.anchor||"center",this._color=o&&o.color||"#3FB1CE",this._scale=o&&o.scale||1,this._draggable=o&&o.draggable||!1,this._clickTolerance=o&&o.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=o&&o.rotation||0,this._rotationAlignment=o&&o.rotationAlignment||"auto",this._pitchAlignment=o&&o.pitchAlignment&&o.pitchAlignment||"auto",this._updateMoving=()=>this._update(!0),this._occludedOpacity=o&&o.occludedOpacity||.2,o&&o.element)this._element=o.element,this._offset=i.Point.convert(o&&o.offset||[0,0]);else{this._defaultMarker=!0,this._element=I("div");const b=41,M=27,R=k("svg",{display:"block",height:b*this._scale+"px",width:M*this._scale+"px",viewBox:`0 0 ${M} ${b}`},this._element),z=k("radialGradient",{id:"shadowGradient"},k("defs",{},R));k("stop",{offset:"10%","stop-opacity":.4},z),k("stop",{offset:"100%","stop-opacity":.05},z),k("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},R),k("path",{fill:this._color,d:"M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z"},R),k("path",{opacity:.25,d:"M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z"},R),k("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},R),this._offset=i.Point.convert(o&&o.offset||[0,-14])}this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.classList.add("mapboxgl-marker"),this._element.addEventListener("dragstart",b=>{b.preventDefault()}),this._element.addEventListener("mousedown",b=>{b.preventDefault()});const y=this._element.classList;for(const b in Ha)y.remove(`mapboxgl-marker-anchor-${b}`);y.add(`mapboxgl-marker-anchor-${this._anchor}`),this._popup=null}addTo(o){return o===this._map||(this.remove(),this._map=o,o.getCanvasContainer().appendChild(this._element),o.on("move",this._updateMoving),o.on("moveend",this._update),o.on("remove",this._clearFadeTimer),o._addMarker(this),this.setDraggable(this._draggable),this._update(),o.on("click",this._onMapClick)),this}remove(){const o=this._map;return o&&(o.off("click",this._onMapClick),o.off("move",this._updateMoving),o.off("moveend",this._update),o.off("mousedown",this._addDragHandler),o.off("touchstart",this._addDragHandler),o.off("mouseup",this._onUp),o.off("touchend",this._onUp),o.off("mousemove",this._onMove),o.off("touchmove",this._onMove),o.off("remove",this._clearFadeTimer),o._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(o){return this._lngLat=i.LngLat.convert(o),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(o){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeAttribute("role"),this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),o){if(!("offset"in o.options)){const b=Math.sqrt(Math.pow(13.5,2)/2);o.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[b,-1*(38.1-13.5+b)],"bottom-right":[-b,-1*(38.1-13.5+b)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=o,o._marker=this,this._lngLat&&this._popup.setLngLat(this._lngLat),this._element.setAttribute("role","button"),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress),this._element.setAttribute("aria-expanded","false")}return this}_onKeyPress(o){const u=o.code,y=o.charCode||o.keyCode;u!=="Space"&&u!=="Enter"&&y!==32&&y!==13||this.togglePopup()}_onMapClick(o){const u=o.originalEvent.target,y=this._element;this._popup&&(u===y||y.contains(u))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const o=this._popup;return o?(o.isOpen()?(o.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(o.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const o=this._map,u=this._pos;if(!o||!u)return!1;const y=o.unproject(u),b=o.getFreeCameraOptions();if(!b.position)return!1;const M=b.position.toLngLat();return M.distanceTo(y)<.9*M.distanceTo(this._lngLat)}_evaluateOpacity(){const o=this._map;if(!o)return;const u=this._pos;if(!u||u.x<0||u.x>o.transform.width||u.y<0||u.y>o.transform.height)return void this._clearFadeTimer();const y=o.unproject(u);let b;o._showingGlobe()&&i.isLngLatBehindGlobe(o.transform,this._lngLat)?b=0:(b=1-o._queryFogOpacity(y),o.transform._terrainEnabled()&&o.getTerrain()&&this._behindTerrain()&&(b*=this._occludedOpacity)),this._element.style.opacity=`${b}`,this._element.style.pointerEvents=b>0?"auto":"none",this._popup&&this._popup._setOpacity(b),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){const o=this._pos;if(!o||!this._map)return;const u=this._offset.mult(this._scale);this._element.style.transform=`
            translate(${o.x}px,${o.y}px)
            ${Ha[this._anchor]}
            ${this._calculateXYTransform()} ${this._calculateZTransform()}
            translate(${u.x}px,${u.y}px)
        `}_calculateXYTransform(){const o=this._pos,u=this._map,y=this.getPitchAlignment();if(!u||!o||y!=="map")return"";if(!u._showingGlobe()){const V=u.getPitch();return V?`rotateX(${V}deg)`:""}const b=i.radToDeg(i.globeTiltAtLngLat(u.transform,this._lngLat)),M=o.sub(i.globeCenterToScreenPoint(u.transform)),R=Math.abs(M.x)+Math.abs(M.y);if(R===0)return"";const z=b/R;return`rotateX(${-M.y*z}deg) rotateY(${M.x*z}deg)`}_calculateZTransform(){const o=this._pos,u=this._map;if(!u||!o)return"";let y=0;const b=this.getRotationAlignment();if(b==="map")if(u._showingGlobe()){const M=u.project(new i.LngLat(this._lngLat.lng,this._lngLat.lat+.001)),R=u.project(new i.LngLat(this._lngLat.lng,this._lngLat.lat-.001)).sub(M);y=i.radToDeg(Math.atan2(R.y,R.x))-90}else y=-u.getBearing();else if(b==="horizon"){const M=i.smoothstep(4,6,u.getZoom()),R=i.globeCenterToScreenPoint(u.transform);R.y+=M*u.transform.height;const z=o.sub(R),V=i.radToDeg(Math.atan2(z.y,z.x));y=(V>90?V-270:V+90)*(1-M)}return y+=this._rotation,y?`rotateZ(${y}deg)`:""}_update(o){i.window.cancelAnimationFrame(this._updateFrameId);const u=this._map;u&&(u.transform.renderWorldCopies&&(this._lngLat=jl(this._lngLat,this._pos,u.transform)),this._pos=u.project(this._lngLat),o===!0?this._updateFrameId=i.window.requestAnimationFrame(()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())}):this._pos=this._pos.round(),u._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(u._showingGlobe()||u.getTerrain()||u.getFog())&&!this._fadeTimer&&(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))}))}getOffset(){return this._offset}setOffset(o){return this._offset=i.Point.convert(o),this._update(),this}_onMove(o){const u=this._map;if(!u)return;const y=this._pointerdownPos,b=this._positionDelta;if(y&&b){if(!this._isDragging){const M=this._clickTolerance||u._clickTolerance;if(o.point.dist(y)<M)return;this._isDragging=!0}this._pos=o.point.sub(b),this._lngLat=u.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none",this._state==="pending"&&(this._state="active",this.fire(new i.Event("dragstart"))),this.fire(new i.Event("drag"))}}_onUp(){this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1;const o=this._map;o&&(o.off("mousemove",this._onMove),o.off("touchmove",this._onMove)),this._state==="active"&&this.fire(new i.Event("dragend")),this._state="inactive"}_addDragHandler(o){const u=this._map,y=this._pos;u&&y&&this._element.contains(o.originalEvent.target)&&(o.preventDefault(),this._positionDelta=o.point.sub(y),this._pointerdownPos=o.point,this._state="pending",u.on("mousemove",this._onMove),u.on("touchmove",this._onMove),u.once("mouseup",this._onUp),u.once("touchend",this._onUp))}setDraggable(o){this._draggable=!!o;const u=this._map;return u&&(o?(u.on("mousedown",this._addDragHandler),u.on("touchstart",this._addDragHandler)):(u.off("mousedown",this._addDragHandler),u.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(o){return this._rotation=o||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(o){return this._rotationAlignment=o||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment==="auto"||this._rotationAlignment==="horizon"&&this._map&&!this._map._showingGlobe()?"viewport":this._rotationAlignment}setPitchAlignment(o){return this._pitchAlignment=o||"auto",this._update(),this}getPitchAlignment(){return this._pitchAlignment==="auto"?this.getRotationAlignment():this._pitchAlignment}setOccludedOpacity(o){return this._occludedOpacity=o||.2,this._update(),this}getOccludedOpacity(){return this._occludedOpacity}}const nu={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px"},Ld=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function qa(p=new i.Point(0,0),o="bottom"){if(typeof p=="number"){const u=Math.round(Math.sqrt(.5*Math.pow(p,2)));switch(o){case"top":return new i.Point(0,p);case"top-left":return new i.Point(u,u);case"top-right":return new i.Point(-u,u);case"bottom":return new i.Point(0,-p);case"bottom-left":return new i.Point(u,-u);case"bottom-right":return new i.Point(-u,-u);case"left":return new i.Point(p,0);case"right":return new i.Point(-p,0)}return new i.Point(0,0)}return p instanceof i.Point||Array.isArray(p)?i.Point.convert(p):i.Point.convert(p[o]||[0,0])}class vh{constructor(o){this.jumpTo(o)}getValue(o){if(o<=this._startTime)return this._start;if(o>=this._endTime)return this._end;const u=i.easeCubicInOut((o-this._startTime)/(this._endTime-this._startTime));return this._start*(1-u)+this._end*u}isEasing(o){return o>=this._startTime&&o<=this._endTime}jumpTo(o){this._startTime=-1/0,this._endTime=-1/0,this._start=o,this._end=o}easeTo(o,u,y){this._start=this.getValue(u),this._end=o,this._startTime=u,this._endTime=u+y}}const Rd={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox logo","Map.Title":"Map","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use \u2318 + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"},iu={center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:85,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,performanceMetricsCollection:!0,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,optimizeForTerrain:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,minTileCacheSize:null,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,transformRequest:null,accessToken:null,fadeDuration:300,respectPrefersReducedMotion:!0,crossSourceCollisions:!0},Wl={showCompass:!0,showZoom:!0,visualizePitch:!1};class cp{constructor(o,u,y=!1){this._clickTolerance=10,this.element=u,this.mouseRotate=new Lu({clickTolerance:o.dragRotate._mouseRotate._clickTolerance}),this.map=o,y&&(this.mousePitch=new Ru({clickTolerance:o.dragRotate._mousePitch._clickTolerance})),i.bindAll(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),u.addEventListener("mousedown",this.mousedown),u.addEventListener("touchstart",this.touchstart,{passive:!1}),u.addEventListener("touchmove",this.touchmove),u.addEventListener("touchend",this.touchend),u.addEventListener("touchcancel",this.reset)}down(o,u){this.mouseRotate.mousedown(o,u),this.mousePitch&&this.mousePitch.mousedown(o,u),H()}move(o,u){const y=this.map,b=this.mouseRotate.mousemoveWindow(o,u),M=b&&b.bearingDelta;if(M&&y.setBearing(y.getBearing()+M),this.mousePitch){const R=this.mousePitch.mousemoveWindow(o,u),z=R&&R.pitchDelta;z&&y.setPitch(y.getPitch()+z)}}off(){const o=this.element;o.removeEventListener("mousedown",this.mousedown),o.removeEventListener("touchstart",this.touchstart,{passive:!1}),o.removeEventListener("touchmove",this.touchmove),o.removeEventListener("touchend",this.touchend),o.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){Y(),i.window.removeEventListener("mousemove",this.mousemove),i.window.removeEventListener("mouseup",this.mouseup)}mousedown(o){this.down(i.extend({},o,{ctrlKey:!0,preventDefault:()=>o.preventDefault()}),le(this.element,o)),i.window.addEventListener("mousemove",this.mousemove),i.window.addEventListener("mouseup",this.mouseup)}mousemove(o){this.move(o,le(this.element,o))}mouseup(o){this.mouseRotate.mouseupWindow(o),this.mousePitch&&this.mousePitch.mouseupWindow(o),this.offTemp()}touchstart(o){o.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=fe(this.element,o.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>o.preventDefault()},this._startPos))}touchmove(o){o.targetTouches.length!==1?this.reset():(this._lastPos=fe(this.element,o.targetTouches)[0],this.move({preventDefault:()=>o.preventDefault()},this._lastPos))}touchend(o){o.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),this.reset()}reset(){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp()}}const Bn={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0,showUserHeading:!1},Mc={maxWidth:100,unit:"metric"},ru={kilometer:"km",meter:"m",mile:"mi",foot:"ft","nautical-mile":"nm"},Hl={version:i.version,supported:E,setRTLTextPlugin:i.setRTLTextPlugin,getRTLTextPluginStatus:i.getRTLTextPluginStatus,Map:class extends Gl{constructor(p){if(i.LivePerformanceUtils.mark(i.PerformanceMarkers.create),(p=i.extend({},iu,p)).minZoom!=null&&p.maxZoom!=null&&p.minZoom>p.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(p.minPitch!=null&&p.maxPitch!=null&&p.minPitch>p.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(p.minPitch!=null&&p.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(p.maxPitch!=null&&p.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(p.antialias&&i.isSafariWithAntialiasingBug(i.window)&&(p.antialias=!1,i.warnOnce("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new Xo(p.minZoom,p.maxZoom,p.minPitch,p.maxPitch,p.renderWorldCopies),p),this._interactive=p.interactive,this._minTileCacheSize=p.minTileCacheSize,this._maxTileCacheSize=p.maxTileCacheSize,this._failIfMajorPerformanceCaveat=p.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=p.preserveDrawingBuffer,this._antialias=p.antialias,this._useWebGL2=p.useWebGL2,this._trackResize=p.trackResize,this._bearingSnap=p.bearingSnap,this._refreshExpiredTiles=p.refreshExpiredTiles,this._fadeDuration=p.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=p.crossSourceCollisions,this._collectResourceTiming=p.collectResourceTiming,this._optimizeForTerrain=p.optimizeForTerrain,this._language=this._parseLanguage(p.language),this._worldview=p.worldview,this._renderTaskQueue=new zu,this._domRenderTaskQueue=new zu,this._controls=[],this._markers=[],this._popups=[],this._mapId=i.uniqueId(),this._locale=i.extend({},Rd,p.locale),this._clickTolerance=p.clickTolerance,this._cooperativeGestures=p.cooperativeGestures,this._performanceMetricsCollection=p.performanceMetricsCollection,this._containerWidth=0,this._containerHeight=0,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new vh(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._requestManager=new i.RequestManager(p.transformRequest,p.accessToken,p.testMode),this._silenceAuthErrors=!!p.testMode,typeof p.container=="string"){if(this._container=i.window.document.getElementById(p.container),!this._container)throw new Error(`Container '${p.container}' not found.`)}else{if(!(p.container instanceof i.window.HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=p.container}if(this._container.childNodes.length>0&&i.warnOnce("The map container element should be empty, otherwise the map's interactivity will be negatively impacted. If you want to display a message when WebGL is not supported, use the Mapbox GL Supported plugin instead."),p.maxBounds&&this.setMaxBounds(p.maxBounds),i.bindAll(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),this.painter===void 0)throw new Error("Failed to initialize WebGL.");this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),i.window!==void 0&&(i.window.addEventListener("online",this._onWindowOnline,!1),i.window.addEventListener("resize",this._onWindowResize,!1),i.window.addEventListener("orientationchange",this._onWindowResize,!1),i.window.addEventListener("webkitfullscreenchange",this._onWindowResize,!1),i.window.addEventListener("visibilitychange",this._onVisibilityChange,!1)),this.handlers=new ba(this,p),this._localFontFamily=p.localFontFamily,this._localIdeographFontFamily=p.localIdeographFontFamily,p.style&&this.setStyle(p.style,{localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),p.projection&&this.setProjection(p.projection),this._hash=p.hash&&new Tu(typeof p.hash=="string"&&p.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:p.center,zoom:p.zoom,bearing:p.bearing,pitch:p.pitch}),p.bounds&&(this.resize(),this.fitBounds(p.bounds,i.extend({},p.fitBoundsOptions,{duration:0})))),this.resize(),p.attributionControl&&this.addControl(new kn({customAttribution:p.customAttribution})),this._logoControl=new tu,this.addControl(this._logoControl,p.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",o=>{this._update(o.dataType==="style"),this.fire(new i.Event(`${o.dataType}data`,o))}),this.on("dataloading",o=>{this.fire(new i.Event(`${o.dataType}dataloading`,o))})}_getMapId(){return this._mapId}addControl(p,o){if(o===void 0&&(o=p.getDefaultPosition?p.getDefaultPosition():"top-right"),!p||!p.onAdd)return this.fire(new i.ErrorEvent(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const u=p.onAdd(this);this._controls.push(p);const y=this._controlPositions[o];return o.indexOf("bottom")!==-1?y.insertBefore(u,y.firstChild):y.appendChild(u),this}removeControl(p){if(!p||!p.onRemove)return this.fire(new i.ErrorEvent(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const o=this._controls.indexOf(p);return o>-1&&this._controls.splice(o,1),p.onRemove(this),this}hasControl(p){return this._controls.indexOf(p)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(p){if(this._updateContainerDimensions(),this._containerWidth===this.transform.width&&this._containerHeight===this.transform.height)return this;this._resizeCanvas(this._containerWidth,this._containerHeight),this.transform.resize(this._containerWidth,this._containerHeight),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight));const o=!this._moving;return o&&this.fire(new i.Event("movestart",p)).fire(new i.Event("move",p)),this.fire(new i.Event("resize",p)),o&&this.fire(new i.Event("moveend",p)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(p){return this.transform.setMaxBounds(i.LngLatBounds.convert(p)),this._update()}setMinZoom(p){if((p=p==null?-2:p)>=-2&&p<=this.transform.maxZoom)return this.transform.minZoom=p,this._update(),this.getZoom()<p?this.setZoom(p):this.fire(new i.Event("zoomstart")).fire(new i.Event("zoom")).fire(new i.Event("zoomend")),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(p){if((p=p==null?22:p)>=this.transform.minZoom)return this.transform.maxZoom=p,this._update(),this.getZoom()>p?this.setZoom(p):this.fire(new i.Event("zoomstart")).fire(new i.Event("zoom")).fire(new i.Event("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(p){if((p=p==null?0:p)<0)throw new Error("minPitch must be greater than or equal to 0");if(p>=0&&p<=this.transform.maxPitch)return this.transform.minPitch=p,this._update(),this.getPitch()<p?this.setPitch(p):this.fire(new i.Event("pitchstart")).fire(new i.Event("pitch")).fire(new i.Event("pitchend")),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(p){if((p=p==null?85:p)>85)throw new Error("maxPitch must be less than or equal to 85");if(p>=this.transform.minPitch)return this.transform.maxPitch=p,this._update(),this.getPitch()>p?this.setPitch(p):this.fire(new i.Event("pitchstart")).fire(new i.Event("pitch")).fire(new i.Event("pitchend")),this;throw new Error("maxPitch must be greater than or equal to minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(p){return this.transform.renderWorldCopies=p,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(p){return p==="auto"?i.window.navigator.language:Array.isArray(p)?p.length===0?void 0:p.map(o=>o==="auto"?i.window.navigator.language:o):p}setLanguage(p){const o=this._parseLanguage(p);if(!this.style||o===this._language)return this;this._language=o,this.style._reloadSources();for(const u of this._controls)u._setLanguage&&u._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(p){return this.style&&p!==this._worldview?(this._worldview=p,this.style._reloadSources(),this):this}getProjection(){return this.transform.mercatorFromTransition?{name:"globe",center:[0,0]}:this.transform.getProjection()}_showingGlobe(){return this.transform.projection.name==="globe"}setProjection(p){return this._lazyInitEmptyStyle(),p?typeof p=="string"&&(p={name:p}):p=null,this._useExplicitProjection=!!p,this._prioritizeAndUpdateProjection(p,this.style.stylesheet?this.style.stylesheet.projection:null)}_updateProjectionTransition(){if(this.getProjection().name!=="globe")return;const p=this.transform,o=p.projection.name;let u;o==="globe"&&p.zoom>=i.GLOBE_ZOOM_THRESHOLD_MAX?(p.setMercatorFromTransition(),u=!0):o==="mercator"&&p.zoom<i.GLOBE_ZOOM_THRESHOLD_MAX&&(p.setProjection({name:"globe"}),u=!0),u&&(this.style.applyProjectionUpdate(),this.style._forceSymbolLayerUpdate())}_prioritizeAndUpdateProjection(p,o){return this._updateProjection(p||o||{name:"mercator"})}_updateProjection(p){let o;if(o=p.name==="globe"&&this.transform.zoom>=i.GLOBE_ZOOM_THRESHOLD_MAX?this.transform.setMercatorFromTransition():this.transform.setProjection(p),this.style.applyProjectionUpdate(),o){this.painter.clearBackgroundTiles();for(const u in this.style._sourceCaches)this.style._sourceCaches[u].clearTiles();this._update(!0),this._forceMarkerAndPopupUpdate(!0)}return this}project(p){return this.transform.locationPoint3D(i.LngLat.convert(p))}unproject(p){return this.transform.pointLocation3D(i.Point.convert(p))}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()||!1}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()||!1}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()||!1}_isDragging(){return this.handlers&&this.handlers._isDragging()||!1}_createDelegatedListener(p,o,u){if(p==="mouseenter"||p==="mouseover"){let y=!1;const b=R=>{const z=o.filter(X=>this.getLayer(X)),V=z.length?this.queryRenderedFeatures(R.point,{layers:z}):[];V.length?y||(y=!0,u.call(this,new Is(p,this,R.originalEvent,{features:V}))):y=!1},M=()=>{y=!1};return{layers:new Set(o),listener:u,delegates:{mousemove:b,mouseout:M}}}if(p==="mouseleave"||p==="mouseout"){let y=!1;const b=R=>{const z=o.filter(V=>this.getLayer(V));(z.length?this.queryRenderedFeatures(R.point,{layers:z}):[]).length?y=!0:y&&(y=!1,u.call(this,new Is(p,this,R.originalEvent)))},M=R=>{y&&(y=!1,u.call(this,new Is(p,this,R.originalEvent)))};return{layers:new Set(o),listener:u,delegates:{mousemove:b,mouseout:M}}}{const y=b=>{const M=o.filter(z=>this.getLayer(z)),R=M.length?this.queryRenderedFeatures(b.point,{layers:M}):[];R.length&&(b.features=R,u.call(this,b),delete b.features)};return{layers:new Set(o),listener:u,delegates:{[p]:y}}}}on(p,o,u){if(u===void 0)return super.on(p,o);Array.isArray(o)||(o=[o]);const y=this._createDelegatedListener(p,o,u);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[p]=this._delegatedListeners[p]||[],this._delegatedListeners[p].push(y);for(const b in y.delegates)this.on(b,y.delegates[b]);return this}once(p,o,u){if(u===void 0)return super.once(p,o);Array.isArray(o)||(o=[o]);const y=this._createDelegatedListener(p,o,u);for(const b in y.delegates)this.once(b,y.delegates[b]);return this}off(p,o,u){if(u===void 0)return super.off(p,o);o=new Set(Array.isArray(o)?o:[o]);const y=(M,R)=>{if(M.size!==R.size)return!1;for(const z of M)if(!R.has(z))return!1;return!0},b=this._delegatedListeners?this._delegatedListeners[p]:void 0;return b&&(M=>{for(let R=0;R<M.length;R++){const z=M[R];if(z.listener===u&&y(z.layers,o)){for(const V in z.delegates)this.off(V,z.delegates[V]);return M.splice(R,1),this}}})(b),this}queryRenderedFeatures(p,o){return this.style?(o!==void 0||p===void 0||p instanceof i.Point||Array.isArray(p)||(o=p,p=void 0),this.style.queryRenderedFeatures(p=p||[[0,0],[this.transform.width,this.transform.height]],o=o||{},this.transform)):[]}querySourceFeatures(p,o){return this.style.querySourceFeatures(p,o)}isPointOnSurface(p){const{name:o}=this.transform.projection;return o!=="globe"&&o!=="mercator"&&i.warnOnce(`${o} projection does not support isPointOnSurface, this API may behave unexpectedly.`),this.transform.isPointOnSurface(i.Point.convert(p))}setStyle(p,o){return(o=i.extend({},{localIdeographFontFamily:this._localIdeographFontFamily,localFontFamily:this._localFontFamily},o)).diff!==!1&&o.localIdeographFontFamily===this._localIdeographFontFamily&&o.localFontFamily===this._localFontFamily&&this.style&&p?(this._diffStyle(p,o),this):(this._localIdeographFontFamily=o.localIdeographFontFamily,this._localFontFamily=o.localFontFamily,this._updateStyle(p,o))}_getUIString(p){const o=this._locale[p];if(o==null)throw new Error(`Missing UI string '${p}'`);return o}_updateStyle(p,o){return this.style&&(this.style.setEventedParent(null),this.style._remove(),this.style=void 0),p&&(this.style=new Ks(this,o||{}),this.style.setEventedParent(this,{style:this.style}),typeof p=="string"?this.style.loadURL(p):this.style.loadJSON(p)),this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new Ks(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(p,o){if(typeof p=="string"){const u=this._requestManager.normalizeStyleURL(p),y=this._requestManager.transformRequest(u,i.ResourceType.Style);i.getJSON(y,(b,M)=>{b?this.fire(new i.ErrorEvent(b)):M&&this._updateDiff(M,o)})}else typeof p=="object"&&this._updateDiff(p,o)}_updateDiff(p,o){try{this.style.setState(p)&&this._update(!0)}catch(u){i.warnOnce(`Unable to perform style diff: ${u.message||u.error||u}.  Rebuilding the style from scratch.`),this._updateStyle(p,o)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(i.warnOnce("There is no style added to the map."),!1)}addSource(p,o){return this._lazyInitEmptyStyle(),this.style.addSource(p,o),this._update(!0)}isSourceLoaded(p){return!!this.style&&this.style._isSourceCacheLoaded(p)}areTilesLoaded(){const p=this.style&&this.style._sourceCaches;for(const o in p){const u=p[o]._tiles;for(const y in u){const b=u[y];if(b.state!=="loaded"&&b.state!=="errored")return!1}}return!0}addSourceType(p,o,u){this._lazyInitEmptyStyle(),this.style.addSourceType(p,o,u)}removeSource(p){return this.style.removeSource(p),this._updateTerrain(),this._update(!0)}getSource(p){return this.style.getSource(p)}addImage(p,o,{pixelRatio:u=1,sdf:y=!1,stretchX:b,stretchY:M,content:R}={}){if(this._lazyInitEmptyStyle(),o instanceof i.window.HTMLImageElement||i.window.ImageBitmap&&o instanceof i.window.ImageBitmap){const{width:z,height:V,data:X}=i.exported.getImageData(o);this.style.addImage(p,{data:new i.RGBAImage({width:z,height:V},X),pixelRatio:u,stretchX:b,stretchY:M,content:R,sdf:y,version:0})}else if(o.width===void 0||o.height===void 0)this.fire(new i.ErrorEvent(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));else{const{width:z,height:V}=o,X=o;this.style.addImage(p,{data:new i.RGBAImage({width:z,height:V},new Uint8Array(X.data)),pixelRatio:u,stretchX:b,stretchY:M,content:R,sdf:y,version:0,userImage:X}),X.onAdd&&X.onAdd(this,p)}}updateImage(p,o){const u=this.style.getImage(p);if(!u)return void this.fire(new i.ErrorEvent(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const y=o instanceof i.window.HTMLImageElement||i.window.ImageBitmap&&o instanceof i.window.ImageBitmap?i.exported.getImageData(o):o,{width:b,height:M}=y;b!==void 0&&M!==void 0?b===u.data.width&&M===u.data.height?(u.data.replace(y.data,!(o instanceof i.window.HTMLImageElement||i.window.ImageBitmap&&o instanceof i.window.ImageBitmap)),this.style.updateImage(p,u)):this.fire(new i.ErrorEvent(new Error(`The width and height of the updated image (${b}, ${M})
                must be that same as the previous version of the image
                (${u.data.width}, ${u.data.height})`))):this.fire(new i.ErrorEvent(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")))}hasImage(p){return p?!!this.style.getImage(p):(this.fire(new i.ErrorEvent(new Error("Missing required image id"))),!1)}removeImage(p){this.style.removeImage(p)}loadImage(p,o){i.getImage(this._requestManager.transformRequest(p,i.ResourceType.Image),(u,y)=>{o(u,y instanceof i.window.HTMLImageElement?i.exported.getImageData(y):y)})}listImages(){return this.style.listImages()}addLayer(p,o){return this._lazyInitEmptyStyle(),this.style.addLayer(p,o),this._update(!0)}moveLayer(p,o){return this.style.moveLayer(p,o),this._update(!0)}removeLayer(p){return this.style.removeLayer(p),this._update(!0)}getLayer(p){return this.style.getLayer(p)}setLayerZoomRange(p,o,u){return this.style.setLayerZoomRange(p,o,u),this._update(!0)}setFilter(p,o,u={}){return this.style.setFilter(p,o,u),this._update(!0)}getFilter(p){return this.style.getFilter(p)}setPaintProperty(p,o,u,y={}){return this.style.setPaintProperty(p,o,u,y),this._update(!0)}getPaintProperty(p,o){return this.style.getPaintProperty(p,o)}setLayoutProperty(p,o,u,y={}){return this.style.setLayoutProperty(p,o,u,y),this._update(!0)}getLayoutProperty(p,o){return this.style.getLayoutProperty(p,o)}setLight(p,o={}){return this._lazyInitEmptyStyle(),this.style.setLight(p,o),this._update(!0)}getLight(){return this.style.getLight()}setTerrain(p){return this._lazyInitEmptyStyle(),!p&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(p),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(p){return this._lazyInitEmptyStyle(),this.style.setFog(p),this._update(!0)}getFog(){return this.style?this.style.getFog():null}_queryFogOpacity(p){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(i.LngLat.convert(p),this.transform):0}setFeatureState(p,o){return this.style.setFeatureState(p,o),this._update()}removeFeatureState(p,o){return this.style.removeFeatureState(p,o),this._update()}getFeatureState(p){return this.style.getFeatureState(p)}_updateContainerDimensions(){if(!this._container)return;const p=this._container.getBoundingClientRect().width||400,o=this._container.getBoundingClientRect().height||300;let u,y,b,M=this._container;for(;M&&(!y||!b);){const R=i.window.getComputedStyle(M).transform;R&&R!=="none"&&(u=R.match(/matrix.*\((.+)\)/)[1].split(", "),u[0]&&u[0]!=="0"&&u[0]!=="1"&&(y=u[0]),u[3]&&u[3]!=="0"&&u[3]!=="1"&&(b=u[3])),M=M.parentElement}this._containerWidth=y?Math.abs(p/y):p,this._containerHeight=b?Math.abs(o/b):o}_detectMissingCSS(){i.window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")!=="rgb(250, 128, 114)"&&i.warnOnce("This page appears to be missing CSS declarations for Mapbox GL JS, which may cause the map to display incorrectly. Please ensure your page includes mapbox-gl.css, as described in https://www.mapbox.com/mapbox-gl-js/api/.")}_setupContainer(){const p=this._container;p.classList.add("mapboxgl-map"),(this._missingCSSCanary=I("div","mapboxgl-canary",p)).style.visibility="hidden",this._detectMissingCSS();const o=this._canvasContainer=I("div","mapboxgl-canvas-container",p);this._interactive&&o.classList.add("mapboxgl-interactive"),this._canvas=I("canvas","mapboxgl-canvas",o),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex","0"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const u=this._controlContainer=I("div","mapboxgl-control-container",p),y=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(b=>{y[b]=I("div",`mapboxgl-ctrl-${b}`,u)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(p,o){const u=i.exported.devicePixelRatio||1;this._canvas.width=u*Math.ceil(p),this._canvas.height=u*Math.ceil(o),this._canvas.style.width=`${p}px`,this._canvas.style.height=`${o}px`}_addMarker(p){this._markers.push(p)}_removeMarker(p){const o=this._markers.indexOf(p);o!==-1&&this._markers.splice(o,1)}_addPopup(p){this._popups.push(p)}_removePopup(p){const o=this._popups.indexOf(p);o!==-1&&this._popups.splice(o,1)}_setupPainter(){const p=i.extend({},E.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),o=this._useWebGL2&&this._canvas.getContext("webgl2",p),u=o||this._canvas.getContext("webgl",p)||this._canvas.getContext("experimental-webgl",p);u?(this._useWebGL2&&!o&&i.warnOnce("Failed to create WebGL 2 context. Using WebGL 1."),i.storeAuthState(u,!0),this.painter=new _s(u,this.transform,!!o),this.on("data",y=>{y.dataType==="source"&&this.painter.setTileLoadedFlag(!0)}),i.exported$1.testSupport(u)):this.fire(new i.ErrorEvent(new Error("Failed to initialize WebGL")))}_contextLost(p){p.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new i.Event("webglcontextlost",{originalEvent:p}))}_contextRestored(p){this._setupPainter(),this.resize(),this._update(),this.fire(new i.Event("webglcontextrestored",{originalEvent:p}))}_onMapScroll(p){if(p.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(p){return this.style?(this._styleDirty=this._styleDirty||p,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(p){return this._update(),this._renderTaskQueue.add(p)}_cancelRenderFrame(p){this._renderTaskQueue.remove(p)}_requestDomTask(p){!this.loaded()||this.loaded()&&!this.isMoving()?p():this._domRenderTaskQueue.add(p)}_render(p){let o;const u=this.painter.context.extTimerQuery,y=i.exported.now();if(this.listens("gpu-timing-frame")&&(o=u.createQueryEXT(),u.beginQueryEXT(u.TIME_ELAPSED_EXT,o)),this.painter.context.setDirty(),this.painter.setBaseState(),(this.isMoving()||this.isRotating()||this.isZooming())&&(this._interactionRange[0]=Math.min(this._interactionRange[0],i.window.performance.now()),this._interactionRange[1]=Math.max(this._interactionRange[1],i.window.performance.now())),this._renderTaskQueue.run(p),this._domRenderTaskQueue.run(p),this._removed)return;this._updateProjectionTransition();const b=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const z=this.transform.zoom,V=this.transform.pitch,X=i.exported.now(),q=new i.EvaluationParameters(z,{now:X,fadeDuration:b,pitch:V,transition:this.style.getTransition()});this.style.update(q)}this.style&&this.style.fog&&this.style.fog.hasTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let M=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),M=this._updateAverageElevation(y),this.style._updateSources(this.transform),this._forceMarkerAndPopupUpdate()):M=this._updateAverageElevation(y),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,b,this._crossSourceCollisions),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showTerrainWireframe:this.showTerrainWireframe,showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,showTileAABBs:this.showTileAABBs,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:b,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),gpuTimingDeferredRender:!!this.listens("gpu-timing-deferred-render"),speedIndexTiming:this.speedIndexTiming}),this.fire(new i.Event("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new i.Event("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),o){const z=i.exported.now()-y;u.endQueryEXT(u.TIME_ELAPSED_EXT,o),setTimeout(()=>{const V=u.getQueryObjectEXT(o,u.QUERY_RESULT_EXT)/1e6;u.deleteQueryEXT(o),this.fire(new i.Event("gpu-timing-frame",{cpuTime:z,gpuTime:V})),i.window.performance.mark("frame-gpu",{startTime:y,detail:{gpuTime:V}})},50)}if(this.listens("gpu-timing-layer")){const z=this.painter.collectGpuTimers();setTimeout(()=>{const V=this.painter.queryGpuTimers(z);this.fire(new i.Event("gpu-timing-layer",{layerTimes:V}))},50)}if(this.listens("gpu-timing-deferred-render")){const z=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{const V=this.painter.queryGpuTimeDeferredRender(z);this.fire(new i.Event("gpu-timing-deferred-render",{gpuTime:V}))},50)}const R=this._sourcesDirty||this._styleDirty||this._placementDirty||M;if(R||this._repaint)this.triggerRepaint();else{const z=!this.isMoving()&&this.loaded();if(z&&(M=this._updateAverageElevation(y,!0)),M)this.triggerRepaint();else if(this._triggerFrame(!1),z&&(this.fire(new i.Event("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const V=this._calculateSpeedIndex();this.fire(new i.Event("speedindexcompleted",{speedIndex:V})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||R||(this._fullyLoaded=!0,i.LivePerformanceUtils.mark(i.PerformanceMarkers.fullLoad),this._performanceMetricsCollection&&i.postPerformanceEvent(this._requestManager._customAccessToken,{width:this.painter.width,height:this.painter.height,interactionRange:this._interactionRange,visibilityHidden:this._visibilityHidden,terrainEnabled:!!this.painter.style.getTerrain(),fogEnabled:!!this.painter.style.getFog(),projection:this.getProjection().name,zoom:this.transform.zoom,renderer:this.painter.context.renderer,vendor:this.painter.context.vendor}),this._authenticate())}_forceMarkerAndPopupUpdate(p){for(const o of this._markers)p&&!this.getRenderWorldCopies()&&(o._lngLat=o._lngLat.wrap()),o._update();for(const o of this._popups)!p||this.getRenderWorldCopies()||o._trackPointer||(o._lngLat=o._lngLat.wrap()),o._update()}_updateAverageElevation(p,o=!1){const u=y=>(this.transform.averageElevation=y,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return this.transform.averageElevation!==0&&u(0);if((o||p-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(p)){const y=this.transform.averageElevation;let b=this.transform.sampleAverageElevation(),M=!1;this.transform.elevation&&(M=this.transform.elevation.exaggeration()!==this._averageElevationExaggeration,this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(b)?b=0:this._averageElevationLastSampledAt=p;const R=Math.abs(y-b);if(R>1){if(this._isInitialLoad||M)return this._averageElevation.jumpTo(b),u(b);this._averageElevation.easeTo(b,p,300)}else if(R>1e-4)return this._averageElevation.jumpTo(b),u(b)}return!!this._averageElevation.isEasing(p)&&u(this._averageElevation.getValue(p))}_authenticate(){i.getMapSessionAPI(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,p=>{if(p&&(p.message===i.AUTH_ERR_MSG||p.status===401)){const o=this.painter.context.gl;i.storeAuthState(o,!1),this._logoControl instanceof tu&&this._logoControl._updateLogo(),o&&o.clear(o.DEPTH_BUFFER_BIT|o.COLOR_BUFFER_BIT|o.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new i.ErrorEvent(new Error("A valid Mapbox access token is required to use Mapbox GL JS. To create an account or a new access token, visit https://account.mapbox.com/")))}}),i.postMapLoadEvent(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_updateTerrain(){const p=this._isDragging();this.painter.updateTerrain(this.style,p)}_calculateSpeedIndex(){const p=this.painter.canvasCopy(),o=this.painter.getCanvasCopiesAndTimestamps();o.timeStamps.push(performance.now());const u=this.painter.context.gl,y=u.createFramebuffer();function b(M){u.framebufferTexture2D(u.FRAMEBUFFER,u.COLOR_ATTACHMENT0,u.TEXTURE_2D,M,0);const R=new Uint8Array(u.drawingBufferWidth*u.drawingBufferHeight*4);return u.readPixels(0,0,u.drawingBufferWidth,u.drawingBufferHeight,u.RGBA,u.UNSIGNED_BYTE,R),R}return u.bindFramebuffer(u.FRAMEBUFFER,y),this._canvasPixelComparison(b(p),o.canvasCopies.map(b),o.timeStamps)}_canvasPixelComparison(p,o,u){let y=u[1]-u[0];const b=p.length/4;for(let M=0;M<o.length;M++){const R=o[M];let z=0;for(let V=0;V<R.length;V+=4)R[V]===p[V]&&R[V+1]===p[V+1]&&R[V+2]===p[V+2]&&R[V+3]===p[V+3]&&(z+=1);y+=(u[M+2]-u[M+1])*(1-z/b)}return y}remove(){this._hash&&this._hash.remove();for(const o of this._controls)o.onRemove(this);this._controls=[],this._frame&&(this._frame.cancel(),this._frame=null),this._renderTaskQueue.clear(),this._domRenderTaskQueue.clear(),this.style&&this.style.destroy(),this.painter.destroy(),this.handlers&&this.handlers.destroy(),this.handlers=void 0,this.setStyle(null),i.window!==void 0&&(i.window.removeEventListener("resize",this._onWindowResize,!1),i.window.removeEventListener("orientationchange",this._onWindowResize,!1),i.window.removeEventListener("webkitfullscreenchange",this._onWindowResize,!1),i.window.removeEventListener("online",this._onWindowOnline,!1),i.window.removeEventListener("visibilitychange",this._onVisibilityChange,!1));const p=this.painter.context.gl.getExtension("WEBGL_lose_context");p&&p.loseContext(),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvasContainer.remove(),this._controlContainer.remove(),this._missingCSSCanary.remove(),this._canvas=void 0,this._canvasContainer=void 0,this._controlContainer=void 0,this._missingCSSCanary=void 0,this._container.classList.remove("mapboxgl-map"),this._container.removeEventListener("scroll",this._onMapScroll,!1),i.removeAuthState(this.painter.context.gl),this._removed=!0,this.fire(new i.Event("remove"))}triggerRepaint(){this._triggerFrame(!0)}_triggerFrame(p){this._renderNextFrame=this._renderNextFrame||p,this.style&&!this._frame&&(this._frame=i.exported.frame(o=>{const u=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,u&&this._render(o)}))}_preloadTiles(p){const o=this.style?Object.values(this.style._sourceCaches):[];return i.asyncAll(o,(u,y)=>u._preloadTiles(p,y),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(p){this._trackResize&&this.resize({originalEvent:p})._update()}_onVisibilityChange(){i.window.document.visibilityState==="hidden"&&this._visibilityHidden++}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(p){this._showTileBoundaries!==p&&(this._showTileBoundaries=p,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(p){this._showTerrainWireframe!==p&&(this._showTerrainWireframe=p,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(p){this._speedIndexTiming!==p&&(this._speedIndexTiming=p,this._update())}get showPadding(){return!!this._showPadding}set showPadding(p){this._showPadding!==p&&(this._showPadding=p,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(p){this._showCollisionBoxes!==p&&(this._showCollisionBoxes=p,p?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(p){this._showOverdrawInspector!==p&&(this._showOverdrawInspector=p,this._update())}get repaint(){return!!this._repaint}set repaint(p){this._repaint!==p&&(this._repaint=p,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(p){this._vertices=p,this._update()}get showTileAABBs(){return!!this._showTileAABBs}set showTileAABBs(p){this._showTileAABBs!==p&&(this._showTileAABBs=p,p&&this._update())}_setCacheLimits(p,o){i.setCacheLimits(p,o)}get version(){return i.version}},NavigationControl:class{constructor(p){this.options=i.extend({},Wl,p),this._container=I("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",o=>o.preventDefault()),this.options.showZoom&&(i.bindAll(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",o=>{this._map&&this._map.zoomIn({},{originalEvent:o})}),I("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",o=>{this._map&&this._map.zoomOut({},{originalEvent:o})}),I("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(i.bindAll(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",o=>{const u=this._map;u&&(this.options.visualizePitch?u.resetNorthPitch({},{originalEvent:o}):u.resetNorth({},{originalEvent:o}))}),this._compassIcon=I("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const p=this._map;if(!p)return;const o=p.getZoom(),u=o===p.getMaxZoom(),y=o===p.getMinZoom();this._zoomInButton.disabled=u,this._zoomOutButton.disabled=y,this._zoomInButton.setAttribute("aria-disabled",u.toString()),this._zoomOutButton.setAttribute("aria-disabled",y.toString())}_rotateCompassArrow(){const p=this._map;if(!p)return;const o=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(p.transform.pitch*(Math.PI/180)),.5)}) rotateX(${p.transform.pitch}deg) rotateZ(${p.transform.angle*(180/Math.PI)}deg)`:`rotate(${p.transform.angle*(180/Math.PI)}deg)`;p._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=o)})}onAdd(p){return this._map=p,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),p.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&p.on("pitch",this._rotateCompassArrow),p.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new cp(p,this._compass,this.options.visualizePitch)),this._container}onRemove(){const p=this._map;p&&(this._container.remove(),this.options.showZoom&&p.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&p.off("pitch",this._rotateCompassArrow),p.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(p,o){const u=I("button",p,this._container);return u.type="button",u.addEventListener("click",o),u}_setButtonTitle(p,o){if(!this._map)return;const u=this._map._getUIString(`NavigationControl.${o}`);p.setAttribute("aria-label",u),p.firstElementChild&&p.firstElementChild.setAttribute("title",u)}},GeolocateControl:class extends i.Evented{constructor(p){super(),this.options=i.extend({geolocation:i.window.navigator.geolocation},Bn,p),i.bindAll(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=ja(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(p){return this._map=p,this._container=I("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){this._geolocationWatchID!==void 0&&(this.options.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,this._numberOfWatches=0,this._noTimeout=!1}_checkGeolocationSupport(p){const o=(u=!!this.options.geolocation)=>{this._supportsGeolocation=u,p(u)};this._supportsGeolocation!==void 0?p(this._supportsGeolocation):i.window.navigator.permissions!==void 0?i.window.navigator.permissions.query({name:"geolocation"}).then(u=>o(u.state!=="denied")).catch(()=>o()):o()}_isOutOfMapMaxBounds(p){const o=this._map.getMaxBounds(),u=p.coords;return!!o&&(u.longitude<o.getWest()||u.longitude>o.getEast()||u.latitude<o.getSouth()||u.latitude>o.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting")}}_onSuccess(p){if(this._map){if(this._isOutOfMapMaxBounds(p))return this._setErrorState(),this.fire(new i.Event("outofmaxbounds",p)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=p,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background")}this.options.showUserLocation&&this._watchState!=="OFF"&&this._updateMarker(p),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(p),this.options.showUserLocation&&this._dotElement.classList.remove("mapboxgl-user-location-dot-stale"),this.fire(new i.Event("geolocate",p)),this._finish()}}_updateCamera(p){const o=new i.LngLat(p.coords.longitude,p.coords.latitude),u=p.coords.accuracy,y=this._map.getBearing(),b=i.extend({bearing:y},this.options.fitBoundsOptions);this._map.fitBounds(o.toBounds(u),b,{geolocateSource:!0})}_updateMarker(p){if(p){const o=new i.LngLat(p.coords.longitude,p.coords.latitude);this._accuracyCircleMarker.setLngLat(o).addTo(this._map),this._userLocationDotMarker.setLngLat(o).addTo(this._map),this._accuracy=p.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const p=this._map.transform,o=i.mercatorZfromAltitude(1,p._center.lat)*p.worldSize,u=Math.ceil(2*this._accuracy*o);this._circleElement.style.width=`${u}px`,this._circleElement.style.height=`${u}px`}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_updateMarkerRotation(){this._userLocationDotMarker&&typeof this._heading=="number"?(this._userLocationDotMarker.setRotation(this._heading),this._dotElement.classList.add("mapboxgl-user-location-show-heading")):(this._dotElement.classList.remove("mapboxgl-user-location-show-heading"),this._userLocationDotMarker.setRotation(0))}_onError(p){if(this._map){if(this.options.trackUserLocation)if(p.code===1){this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const o=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",o),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",o),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(p.code===3&&this._noTimeout)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("mapboxgl-user-location-dot-stale"),this.fire(new i.Event("error",p)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(p){if(this._map!==void 0){if(this._container.addEventListener("contextmenu",o=>o.preventDefault()),this._geolocateButton=I("button","mapboxgl-ctrl-geolocate",this._container),I("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",p===!1){i.warnOnce("Geolocation support is not available so the GeolocateControl will be disabled.");const o=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",o),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",o)}else{const o=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",o),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",o)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=I("div","mapboxgl-user-location"),this._dotElement.appendChild(I("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(I("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new An({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=I("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new An({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",o=>{o.geolocateSource||this._watchState!=="ACTIVE_LOCK"||o.originalEvent&&o.originalEvent.type==="resize"||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new i.Event("trackuserlocationend")))})}}_onDeviceOrientation(p){this._userLocationDotMarker&&(p.webkitCompassHeading?this._heading=p.webkitCompassHeading:p.absolute===!0&&(this._heading=-1*p.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return i.warnOnce("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new i.Event("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":this._numberOfWatches--,this._noTimeout=!1,this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this.fire(new i.Event("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new i.Event("trackuserlocationstart"))}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"BACKGROUND":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");break;case"BACKGROUND_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error")}if(this._watchState==="OFF"&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let p;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(p={maximumAge:6e5,timeout:0},this._noTimeout=!0):(p=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,p),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const p=()=>{i.window.addEventListener("ondeviceorientationabsolute"in i.window?"deviceorientationabsolute":"deviceorientation",this._onDeviceOrientation)};i.window.DeviceMotionEvent!==void 0&&typeof i.window.DeviceMotionEvent.requestPermission=="function"?DeviceOrientationEvent.requestPermission().then(o=>{o==="granted"&&p()}).catch(console.error):p()}_clearWatch(){this.options.geolocation.clearWatch(this._geolocationWatchID),i.window.removeEventListener("deviceorientation",this._onDeviceOrientation),i.window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientation),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},AttributionControl:kn,ScaleControl:class{constructor(p){this.options=i.extend({},Mc,p),this._isNumberFormatSupported=function(){try{return new Intl.NumberFormat("en",{style:"unit",unitDisplay:"short",unit:"meter"}),!0}catch{return!1}}(),i.bindAll(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const p=this.options.maxWidth||100,o=this._map,u=o._containerHeight/2,y=o._containerWidth/2-p/2,b=o.unproject([y,u]),M=o.unproject([y+p,u]),R=b.distanceTo(M);if(this.options.unit==="imperial"){const z=3.2808*R;z>5280?this._setScale(p,z/5280,"mile"):this._setScale(p,z,"foot")}else this.options.unit==="nautical"?this._setScale(p,R/1852,"nautical-mile"):R>=1e3?this._setScale(p,R/1e3,"kilometer"):this._setScale(p,R,"meter")}_setScale(p,o,u){this._map._requestDomTask(()=>{const y=function(M){const R=Math.pow(10,`${Math.floor(M)}`.length-1);let z=M/R;return z=z>=10?10:z>=5?5:z>=3?3:z>=2?2:z>=1?1:function(V){const X=Math.pow(10,Math.ceil(-Math.log(V)/Math.LN10));return Math.round(V*X)/X}(z),R*z}(o),b=y/o;this._container.innerHTML=this._isNumberFormatSupported&&u!=="nautical-mile"?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:u}).format(y):`${y}&nbsp;${ru[u]}`,this._container.style.width=p*b+"px"})}onAdd(p){return this._map=p,this._language=p.getLanguage(),this._container=I("div","mapboxgl-ctrl mapboxgl-ctrl-scale",p.getContainer()),this._container.dir="auto",this._map.on("move",this._update),this._update(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._update),this._map=void 0}_setLanguage(p){this._language=p,this._update()}setUnit(p){this.options.unit=p,this._update()}},FullscreenControl:class{constructor(p){this._fullscreen=!1,p&&p.container&&(p.container instanceof i.window.HTMLElement?this._container=p.container:i.warnOnce("Full screen control 'container' must be a DOM element.")),i.bindAll(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in i.window.document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in i.window.document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(p){return this._map=p,this._container||(this._container=this._map.getContainer()),this._controlContainer=I("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",i.warnOnce("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,i.window.document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!i.window.document.fullscreenEnabled&&!i.window.document.webkitFullscreenEnabled)}_setupUI(){const p=this._fullscreenButton=I("button","mapboxgl-ctrl-fullscreen",this._controlContainer);I("span","mapboxgl-ctrl-icon",p).setAttribute("aria-hidden","true"),p.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),i.window.document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const p=this._getTitle();this._fullscreenButton.setAttribute("aria-label",p),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",p)}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(i.window.document.fullscreenElement||i.window.document.webkitFullscreenElement)===this._container!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("mapboxgl-ctrl-shrink"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-fullscreen"),this._updateTitle())}_onClickFullscreen(){this._isFullscreen()?i.window.document.exitFullscreen?i.window.document.exitFullscreen():i.window.document.webkitCancelFullScreen&&i.window.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},Popup:class extends i.Evented{constructor(p){super(),this.options=i.extend(Object.create(nu),p),i.bindAll(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(p&&p.className?p.className.trim().split(/\s+/):[])}addTo(p){return this._map&&this.remove(),this._map=p,this.options.closeOnClick&&p.on("preclick",this._onClose),this.options.closeOnMove&&p.on("move",this._onClose),p.on("remove",this.remove),this._update(),p._addPopup(this),this._focusFirstElement(),this._trackPointer?(p.on("mousemove",this._onMouseEvent),p.on("mouseup",this._onMouseEvent),p._canvasContainer.classList.add("mapboxgl-track-pointer")):p.on("move",this._update),this.fire(new i.Event("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const p=this._map;return p&&(p.off("move",this._update),p.off("move",this._onClose),p.off("preclick",this._onClose),p.off("click",this._onClose),p.off("remove",this.remove),p.off("mousemove",this._onMouseEvent),p.off("mouseup",this._onMouseEvent),p.off("drag",this._onMouseEvent),p._canvasContainer&&p._canvasContainer.classList.remove("mapboxgl-track-pointer"),p._removePopup(this),this._map=void 0),this.fire(new i.Event("close")),this}getLngLat(){return this._lngLat}setLngLat(p){this._lngLat=i.LngLat.convert(p),this._pos=null,this._trackPointer=!1,this._update();const o=this._map;return o&&(o.on("move",this._update),o.off("mousemove",this._onMouseEvent),o._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const p=this._map;return p&&(p.off("move",this._update),p.on("mousemove",this._onMouseEvent),p.on("drag",this._onMouseEvent),p._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(p){return this.setDOMContent(i.window.document.createTextNode(p))}setHTML(p){const o=i.window.document.createDocumentFragment(),u=i.window.document.createElement("body");let y;for(u.innerHTML=p;y=u.firstChild,y;)o.appendChild(y);return this.setDOMContent(o)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(p){return this.options.maxWidth=p,this._update(),this}setDOMContent(p){let o=this._content;if(o)for(;o.hasChildNodes();)o.firstChild&&o.removeChild(o.firstChild);else o=this._content=I("div","mapboxgl-popup-content",this._container||void 0);if(o.appendChild(p),this.options.closeButton){const u=this._closeButton=I("button","mapboxgl-popup-close-button",o);u.type="button",u.setAttribute("aria-label","Close popup"),u.setAttribute("aria-hidden","true"),u.innerHTML="&#215;",u.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(p){return this._classList.add(p),this._updateClassList(),this}removeClassName(p){return this._classList.delete(p),this._updateClassList(),this}setOffset(p){return this.options.offset=p,this._update(),this}toggleClassName(p){let o;return this._classList.delete(p)?o=!1:(this._classList.add(p),o=!0),this._updateClassList(),o}_onMouseEvent(p){this._update(p.point)}_getAnchor(p){if(this.options.anchor)return this.options.anchor;const o=this._map,u=this._container,y=this._pos;if(!o||!u||!y)return"bottom";const b=u.offsetWidth,M=u.offsetHeight,R=y.x<b/2,z=y.x>o.transform.width-b/2;if(y.y+p<M)return R?"top-left":z?"top-right":"top";if(y.y>o.transform.height-M){if(R)return"bottom-left";if(z)return"bottom-right"}return R?"left":z?"right":"bottom"}_updateClassList(){const p=this._container;if(!p)return;const o=[...this._classList];o.push("mapboxgl-popup"),this._anchor&&o.push(`mapboxgl-popup-anchor-${this._anchor}`),this._trackPointer&&o.push("mapboxgl-popup-track-pointer"),p.className=o.join(" ")}_update(p){const o=this._map,u=this._content;if(!o||!this._lngLat&&!this._trackPointer||!u)return;let y=this._container;if(y||(y=this._container=I("div","mapboxgl-popup",o.getContainer()),this._tip=I("div","mapboxgl-popup-tip",y),y.appendChild(u)),this.options.maxWidth&&y.style.maxWidth!==this.options.maxWidth&&(y.style.maxWidth=this.options.maxWidth),o.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=jl(this._lngLat,this._pos,o.transform)),!this._trackPointer||p){const b=this._pos=this._trackPointer&&p?p:o.project(this._lngLat),M=qa(this.options.offset),R=this._anchor=this._getAnchor(M.y),z=qa(this.options.offset,R),V=b.add(z).round();o._requestDomTask(()=>{this._container&&R&&(this._container.style.transform=`${Ha[R]} translate(${V.x}px,${V.y}px)`)})}if(!this._marker&&o._showingGlobe()){const b=i.isLngLatBehindGlobe(o.transform,this._lngLat)?0:1;this._setOpacity(b)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const p=this._container.querySelector(Ld);p&&p.focus()}_onClose(){this.remove()}_setOpacity(p){this._container&&(this._container.style.opacity=`${p}`),this._content&&(this._content.style.pointerEvents=p?"auto":"none")}},Marker:An,Style:Ks,LngLat:i.LngLat,LngLatBounds:i.LngLatBounds,Point:i.Point,MercatorCoordinate:i.MercatorCoordinate,FreeCameraOptions:xa,Evented:i.Evented,config:i.config,prewarm:function(){Ni().acquire(bi)},clearPrewarmedResources:function(){const p=ai;p&&(p.isPreloaded()&&p.numActive()===1?(p.release(bi),ai=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},get accessToken(){return i.config.ACCESS_TOKEN},set accessToken(p){i.config.ACCESS_TOKEN=p},get baseApiUrl(){return i.config.API_URL},set baseApiUrl(p){i.config.API_URL=p},get workerCount(){return ui.workerCount},set workerCount(p){ui.workerCount=p},get maxParallelImageRequests(){return i.config.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(p){i.config.MAX_PARALLEL_IMAGE_REQUESTS=p},clearStorage(p){i.clearTileCache(p)},workerUrl:"",workerClass:null,setNow:i.exported.setNow,restoreNow:i.exported.restoreNow};return Hl});var m=c;return m})})(K_);const G2=Qx(K_.exports),H4=_P({__proto__:null,default:G2},[K_.exports]);const q4=Ye.exports.createContext(null);function Z4(d,e){const n=Array.isArray(d)?d[0]:d?d.x:0,a=Array.isArray(d)?d[1]:d?d.y:0,c=Array.isArray(e)?e[0]:e?e.x:0,f=Array.isArray(e)?e[1]:e?e.y:0;return n===c&&a===f}function dl(d,e){if(d===e)return!0;if(!d||!e)return!1;if(Array.isArray(d)){if(!Array.isArray(e)||d.length!==e.length)return!1;for(let n=0;n<d.length;n++)if(!dl(d[n],e[n]))return!1;return!0}else if(Array.isArray(e))return!1;if(typeof d=="object"&&typeof e=="object"){const n=Object.keys(d),a=Object.keys(e);if(n.length!==a.length)return!1;for(const c of n)if(!e.hasOwnProperty(c)||!dl(d[c],e[c]))return!1;return!0}return!1}function X4(d){const e=d.clone();return e.pixelsToGLUnits=d.pixelsToGLUnits,e}function wM(d,e){if(!d.getProjection)return;const n=d.getProjection(),a=e.getProjection();dl(n,a)||e.setProjection(n)}function SM(d){return{longitude:d.center.lng,latitude:d.center.lat,zoom:d.zoom,pitch:d.pitch,bearing:d.bearing,padding:d.padding}}function MM(d,e){const n=e.viewState||e;let a=!1;if("longitude"in n&&"latitude"in n){const c=d.center;d.center=new c.constructor(n.longitude,n.latitude),a=a||c!==d.center}if("zoom"in n){const c=d.zoom;d.zoom=n.zoom,a=a||c!==d.zoom}if("bearing"in n){const c=d.bearing;d.bearing=n.bearing,a=a||c!==d.bearing}if("pitch"in n){const c=d.pitch;d.pitch=n.pitch,a=a||c!==d.pitch}return n.padding&&!d.isPaddingEqual(n.padding)&&(a=!0,d.padding=n.padding),a}const $4=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function EM(d){if(!d)return null;if(typeof d=="string"||("toJS"in d&&(d=d.toJS()),!d.layers))return d;const e={};for(const a of d.layers)e[a.id]=a;const n=d.layers.map(a=>{let c=null;"interactive"in a&&(c=Object.assign({},a),delete c.interactive);const f=e[a.ref];if(f){c=c||Object.assign({},a),delete c.ref;for(const m of $4)m in f&&(c[m]=f[m])}return c||a});return{...d,layers:n}}const TM={version:8,sources:{},layers:[]},AM={mousedown:"onMouseDown",mouseup:"onMouseUp",mouseover:"onMouseOver",mousemove:"onMouseMove",click:"onClick",dblclick:"onDblClick",mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",mouseout:"onMouseOut",contextmenu:"onContextMenu",touchstart:"onTouchStart",touchend:"onTouchEnd",touchmove:"onTouchMove",touchcancel:"onTouchCancel"},nx={movestart:"onMoveStart",move:"onMove",moveend:"onMoveEnd",dragstart:"onDragStart",drag:"onDrag",dragend:"onDragEnd",zoomstart:"onZoomStart",zoom:"onZoom",zoomend:"onZoomEnd",rotatestart:"onRotateStart",rotate:"onRotate",rotateend:"onRotateEnd",pitchstart:"onPitchStart",pitch:"onPitch",pitchend:"onPitchEnd"},CM={wheel:"onWheel",boxzoomstart:"onBoxZoomStart",boxzoomend:"onBoxZoomEnd",boxzoomcancel:"onBoxZoomCancel",resize:"onResize",load:"onLoad",render:"onRender",idle:"onIdle",remove:"onRemove",data:"onData",styledata:"onStyleData",sourcedata:"onSourceData",error:"onError"},Y4=["minZoom","maxZoom","minPitch","maxPitch","maxBounds","projection","renderWorldCopies"],J4=["scrollZoom","boxZoom","dragRotate","dragPan","keyboard","doubleClickZoom","touchZoomRotate","touchPitch"];class Qf{constructor(e,n,a){this._map=null,this._internalUpdate=!1,this._inRender=!1,this._hoveredFeatures=null,this._deferredEvents={move:!1,zoom:!1,pitch:!1,rotate:!1},this._onEvent=c=>{const f=this.props[CM[c.type]];f?f(c):c.type==="error"&&console.error(c.error)},this._onPointerEvent=c=>{(c.type==="mousemove"||c.type==="mouseout")&&this._updateHover(c);const f=this.props[AM[c.type]];f&&(this.props.interactiveLayerIds&&c.type!=="mouseover"&&c.type!=="mouseout"&&(c.features=this._hoveredFeatures||this._queryRenderedFeatures(c.point)),f(c),delete c.features)},this._onCameraEvent=c=>{if(!this._internalUpdate){const f=this.props[nx[c.type]];f&&f(c)}c.type in this._deferredEvents&&(this._deferredEvents[c.type]=!1)},this._MapClass=e,this.props=n,this._initialize(a)}get map(){return this._map}get transform(){return this._renderTransform}setProps(e){const n=this.props;this.props=e;const a=this._updateSettings(e,n);a&&this._createShadowTransform(this._map);const c=this._updateSize(e),f=this._updateViewState(e,!0);this._updateStyle(e,n),this._updateStyleComponents(e,n),this._updateHandlers(e,n),(a||c||f&&!this._map.isMoving())&&this.redraw()}static reuse(e,n){const a=Qf.savedMaps.pop();if(!a)return null;const c=a.map,f=c.getContainer();for(n.className=f.className;f.childNodes.length>0;)n.appendChild(f.childNodes[0]);c._container=n;const m=c._resizeObserver;m&&(m.disconnect(),m.observe(n)),a.setProps({...e,styleDiffing:!1}),c.resize();const{initialViewState:i}=e;return i&&(i.bounds?c.fitBounds(i.bounds,{...i.fitBoundsOptions,duration:0}):a._updateViewState(i,!1)),c.isStyleLoaded()?c.fire("load"):c.once("styledata",()=>c.fire("load")),c._update(),a}_initialize(e){const{props:n}=this,{mapStyle:a=TM}=n,c={...n,...n.initialViewState,accessToken:n.mapboxAccessToken||K4()||null,container:e,style:EM(a)},f=c.initialViewState||c.viewState||c;if(Object.assign(c,{center:[f.longitude||0,f.latitude||0],zoom:f.zoom||0,pitch:f.pitch||0,bearing:f.bearing||0}),n.gl){const C=HTMLCanvasElement.prototype.getContext;HTMLCanvasElement.prototype.getContext=()=>(HTMLCanvasElement.prototype.getContext=C,n.gl)}const m=new this._MapClass(c);f.padding&&m.setPadding(f.padding),n.cursor&&(m.getCanvas().style.cursor=n.cursor),this._createShadowTransform(m);const i=m._render;m._render=C=>{this._inRender=!0,i.call(m,C),this._inRender=!1};const w=m._renderTaskQueue.run;m._renderTaskQueue.run=C=>{w.call(m._renderTaskQueue,C),this._onBeforeRepaint()},m.on("render",()=>this._onAfterRepaint());const E=m.fire;m.fire=this._fireEvent.bind(this,E),m.on("resize",()=>{this._renderTransform.resize(m.transform.width,m.transform.height)}),m.on("styledata",()=>{this._updateStyleComponents(this.props,{}),wM(m.transform,this._renderTransform)}),m.on("sourcedata",()=>this._updateStyleComponents(this.props,{}));for(const C in AM)m.on(C,this._onPointerEvent);for(const C in nx)m.on(C,this._onCameraEvent);for(const C in CM)m.on(C,this._onEvent);this._map=m}recycle(){const n=this.map.getContainer().querySelector("[mapboxgl-children]");n==null||n.remove(),Qf.savedMaps.push(this)}destroy(){this._map.remove()}redraw(){const e=this._map;!this._inRender&&e.style&&(e._frame&&(e._frame.cancel(),e._frame=null),e._render())}_createShadowTransform(e){const n=X4(e.transform);e.painter.transform=n,this._renderTransform=n}_updateSize(e){const{viewState:n}=e;if(n){const a=this._map;if(n.width!==a.transform.width||n.height!==a.transform.height)return a.resize(),!0}return!1}_updateViewState(e,n){if(this._internalUpdate)return!1;const a=this._map,c=this._renderTransform,{zoom:f,pitch:m,bearing:i}=c,w=a.isMoving();w&&(c.cameraElevationReference="sea");const E=MM(c,{...SM(a.transform),...e});if(w&&(c.cameraElevationReference="ground"),E&&n){const C=this._deferredEvents;C.move=!0,C.zoom||(C.zoom=f!==c.zoom),C.rotate||(C.rotate=i!==c.bearing),C.pitch||(C.pitch=m!==c.pitch)}return w||MM(a.transform,e),E}_updateSettings(e,n){const a=this._map;let c=!1;for(const f of Y4)if(f in e&&!dl(e[f],n[f])){c=!0;const m=a[`set${f[0].toUpperCase()}${f.slice(1)}`];m==null||m.call(a,e[f])}return c}_updateStyle(e,n){if(e.cursor!==n.cursor&&(this._map.getCanvas().style.cursor=e.cursor||""),e.mapStyle!==n.mapStyle){const{mapStyle:a=TM,styleDiffing:c=!0}=e,f={diff:c};return"localIdeographFontFamily"in e&&(f.localIdeographFontFamily=e.localIdeographFontFamily),this._map.setStyle(EM(a),f),!0}return!1}_updateStyleComponents(e,n){const a=this._map;let c=!1;return a.isStyleLoaded()&&("light"in e&&a.setLight&&!dl(e.light,n.light)&&(c=!0,a.setLight(e.light)),"fog"in e&&a.setFog&&!dl(e.fog,n.fog)&&(c=!0,a.setFog(e.fog)),"terrain"in e&&a.setTerrain&&!dl(e.terrain,n.terrain)&&(!e.terrain||a.getSource(e.terrain.source))&&(c=!0,a.setTerrain(e.terrain))),c}_updateHandlers(e,n){var a,c;const f=this._map;let m=!1;for(const i of J4){const w=(a=e[i])!==null&&a!==void 0?a:!0,E=(c=n[i])!==null&&c!==void 0?c:!0;dl(w,E)||(m=!0,w?f[i].enable(w):f[i].disable())}return m}_queryRenderedFeatures(e){const n=this._map,a=n.transform,{interactiveLayerIds:c=[]}=this.props;try{return n.transform=this._renderTransform,n.queryRenderedFeatures(e,{layers:c.filter(n.getLayer.bind(n))})}catch{return[]}finally{n.transform=a}}_updateHover(e){var n;const{props:a}=this;if(a.interactiveLayerIds&&(a.onMouseMove||a.onMouseEnter||a.onMouseLeave)){const f=e.type,m=((n=this._hoveredFeatures)===null||n===void 0?void 0:n.length)>0,i=this._queryRenderedFeatures(e.point),w=i.length>0;!w&&m&&(e.type="mouseleave",this._onPointerEvent(e)),this._hoveredFeatures=i,w&&!m&&(e.type="mouseenter",this._onPointerEvent(e)),e.type=f}else this._hoveredFeatures=null}_fireEvent(e,n,a){const c=this._map,f=c.transform,m=typeof n=="string"?n:n.type;return m==="move"&&this._updateViewState(this.props,!1),m in nx&&(typeof n=="object"&&(n.viewState=SM(f)),this._map.isMoving())?(c.transform=this._renderTransform,e.call(c,n,a),c.transform=f,c):(e.call(c,n,a),c)}_onBeforeRepaint(){const e=this._map;this._internalUpdate=!0;for(const a in this._deferredEvents)this._deferredEvents[a]&&e.fire(a);this._internalUpdate=!1;const n=this._map.transform;e.transform=this._renderTransform,this._onAfterRepaint=()=>{wM(this._renderTransform,n),e.transform=n}}}Qf.savedMaps=[];function K4(){let d=null;if(typeof location<"u"){const e=/access_token=([^&\/]*)/.exec(location.search);d=e&&e[1]}try{d=d||{}.MapboxAccessToken}catch{}try{d=d||{}.REACT_APP_MAPBOX_ACCESS_TOKEN}catch{}return d}const Q4=["setMaxBounds","setMinZoom","setMaxZoom","setMinPitch","setMaxPitch","setRenderWorldCopies","setProjection","setStyle","addSource","removeSource","addLayer","removeLayer","setLayerZoomRange","setFilter","setPaintProperty","setLayoutProperty","setLight","setTerrain","setFog","remove"];function eN(d){if(!d)return null;const e=d.map,n={getMap:()=>e,getCenter:()=>d.transform.center,getZoom:()=>d.transform.zoom,getBearing:()=>d.transform.bearing,getPitch:()=>d.transform.pitch,getPadding:()=>d.transform.padding,getBounds:()=>d.transform.getBounds(),project:a=>{const c=e.transform;e.transform=d.transform;const f=e.project(a);return e.transform=c,f},unproject:a=>{const c=e.transform;e.transform=d.transform;const f=e.unproject(a);return e.transform=c,f},queryTerrainElevation:(a,c)=>{const f=e.transform;e.transform=d.transform;const m=e.queryTerrainElevation(a,c);return e.transform=f,m},queryRenderedFeatures:(a,c)=>{const f=e.transform;e.transform=d.transform;const m=e.queryRenderedFeatures(a,c);return e.transform=f,m}};for(const a of tN(e))!(a in n)&&!Q4.includes(a)&&(n[a]=e[a].bind(e));return n}function tN(d){const e=new Set;let n=d;for(;n;){for(const a of Object.getOwnPropertyNames(n))a[0]!=="_"&&typeof d[a]=="function"&&a!=="fire"&&a!=="setEventedParent"&&e.add(a);n=Object.getPrototypeOf(n)}return Array.from(e)}const nN=typeof document<"u"?Ye.exports.useLayoutEffect:Ye.exports.useEffect,iN=["baseApiUrl","maxParallelImageRequests","workerClass","workerCount","workerUrl"];function rN(d,e){for(const a of iN)a in e&&(d[a]=e[a]);const{RTLTextPlugin:n="https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-rtl-text/v0.2.3/mapbox-gl-rtl-text.js"}=e;n&&d.getRTLTextPluginStatus&&d.getRTLTextPluginStatus()==="unavailable"&&d.setRTLTextPlugin(n,a=>{a&&console.error(a)},!1)}const ap=Ye.exports.createContext(null);function sN(d,e,n){const a=Ye.exports.useContext(q4),[c,f]=Ye.exports.useState(null),m=Ye.exports.useRef(),{current:i}=Ye.exports.useRef({mapLib:null,map:null});Ye.exports.useEffect(()=>{const C=d.mapLib;let T=!0,I;return Promise.resolve(C||n).then(k=>{if(!T)return;if(!k)throw new Error("Invalid mapLib");const O="Map"in k?k:k.default;if(!O.Map)throw new Error("Invalid mapLib");if(rN(O,d),!O.supported||O.supported(d))d.reuseMaps&&(I=Qf.reuse(d,m.current)),I||(I=new Qf(O.Map,d,m.current)),i.map=eN(I),i.mapLib=O,f(I),a==null||a.onMapMount(i.map,d.id);else throw new Error("Map is not supported by this browser")}).catch(k=>{const{onError:O}=d;O?O({type:"error",target:null,originalEvent:null,error:k}):console.error(k)}),()=>{T=!1,I&&(a==null||a.onMapUnmount(d.id),d.reuseMaps?I.recycle():I.destroy())}},[]),nN(()=>{c&&c.setProps(d)}),Ye.exports.useImperativeHandle(e,()=>i.map,[c]);const w=Ye.exports.useMemo(()=>({position:"relative",width:"100%",height:"100%",...d.style}),[d.style]),E={height:"100%"};return Ye.exports.createElement("div",{id:d.id,ref:m,style:w},c&&Ye.exports.createElement(ap.Provider,{value:i},Ye.exports.createElement("div",{"mapboxgl-children":"",style:E},d.children)))}const oN=/box|flex|grid|column|lineHeight|fontWeight|opacity|order|tabSize|zIndex/;function Ed(d,e){if(!d||!e)return;const n=d.style;for(const a in e){const c=e[a];Number.isFinite(c)&&!oN.test(a)?n[a]=`${c}px`:n[a]=c}}function aN(d,e){const{map:n,mapLib:a}=Ye.exports.useContext(ap),c=Ye.exports.useRef({props:d});c.current.props=d;const f=Ye.exports.useMemo(()=>{let B=!1;Ye.exports.Children.forEach(d.children,Y=>{Y&&(B=!0)});const F={...d,element:B?document.createElement("div"):null},H=new a.Marker(F);return H.setLngLat([d.longitude,d.latitude]),H.getElement().addEventListener("click",Y=>{var K,ne;(ne=(K=c.current.props).onClick)===null||ne===void 0||ne.call(K,{type:"click",target:H,originalEvent:Y})}),H.on("dragstart",Y=>{var K,ne;const le=Y;le.lngLat=f.getLngLat(),(ne=(K=c.current.props).onDragStart)===null||ne===void 0||ne.call(K,le)}),H.on("drag",Y=>{var K,ne;const le=Y;le.lngLat=f.getLngLat(),(ne=(K=c.current.props).onDrag)===null||ne===void 0||ne.call(K,le)}),H.on("dragend",Y=>{var K,ne;const le=Y;le.lngLat=f.getLngLat(),(ne=(K=c.current.props).onDragEnd)===null||ne===void 0||ne.call(K,le)}),H},[]);Ye.exports.useEffect(()=>(f.addTo(n.getMap()),()=>{f.remove()}),[]);const{longitude:m,latitude:i,offset:w,style:E,draggable:C=!1,popup:T=null,rotation:I=0,rotationAlignment:k="auto",pitchAlignment:O="auto"}=d;return Ye.exports.useEffect(()=>{Ed(f.getElement(),E)},[E]),Ye.exports.useImperativeHandle(e,()=>f,[]),(f.getLngLat().lng!==m||f.getLngLat().lat!==i)&&f.setLngLat([m,i]),w&&!Z4(f.getOffset(),w)&&f.setOffset(w),f.isDraggable()!==C&&f.setDraggable(C),f.getRotation()!==I&&f.setRotation(I),f.getRotationAlignment()!==k&&f.setRotationAlignment(k),f.getPitchAlignment()!==O&&f.setPitchAlignment(O),f.getPopup()!==T&&f.setPopup(T),HM.exports.createPortal(d.children,f.getElement())}Ye.exports.memo(Ye.exports.forwardRef(aN));function IM(d){return new Set(d?d.trim().split(/\s+/):[])}function lN(d,e){const{map:n,mapLib:a}=Ye.exports.useContext(ap),c=Ye.exports.useMemo(()=>document.createElement("div"),[]),f=Ye.exports.useRef({props:d});f.current.props=d;const m=Ye.exports.useMemo(()=>{const i={...d},w=new a.Popup(i);return w.setLngLat([d.longitude,d.latitude]),w.once("open",E=>{var C,T;(T=(C=f.current.props).onOpen)===null||T===void 0||T.call(C,E)}),w},[]);if(Ye.exports.useEffect(()=>{const i=w=>{var E,C;(C=(E=f.current.props).onClose)===null||C===void 0||C.call(E,w)};return m.on("close",i),m.setDOMContent(c).addTo(n.getMap()),()=>{m.off("close",i),m.isOpen()&&m.remove()}},[]),Ye.exports.useEffect(()=>{Ed(m.getElement(),d.style)},[d.style]),Ye.exports.useImperativeHandle(e,()=>m,[]),m.isOpen()&&((m.getLngLat().lng!==d.longitude||m.getLngLat().lat!==d.latitude)&&m.setLngLat([d.longitude,d.latitude]),d.offset&&!dl(m.options.offset,d.offset)&&m.setOffset(d.offset),(m.options.anchor!==d.anchor||m.options.maxWidth!==d.maxWidth)&&(m.options.anchor=d.anchor,m.setMaxWidth(d.maxWidth)),m.options.className!==d.className)){const i=IM(m.options.className),w=IM(d.className);for(const E of i)w.has(E)||m.removeClassName(E);for(const E of w)i.has(E)||m.addClassName(E);m.options.className=d.className}return HM.exports.createPortal(d.children,c)}Ye.exports.memo(Ye.exports.forwardRef(lN));function lp(d,e,n,a){const c=Ye.exports.useContext(ap),f=Ye.exports.useMemo(()=>d(c),[]);return Ye.exports.useEffect(()=>{const m=a||n||e,i=typeof e=="function"&&typeof n=="function"?e:null,w=typeof n=="function"?n:typeof e=="function"?e:null,{map:E}=c;return E.hasControl(f)||(E.addControl(f,m==null?void 0:m.position),i&&i(c)),()=>{w&&w(c),E.hasControl(f)&&E.removeControl(f)}},[]),f}function cN(d){const e=lp(({mapLib:n})=>new n.AttributionControl(d),{position:d.position});return Ye.exports.useEffect(()=>{Ed(e._container,d.style)},[d.style]),null}Ye.exports.memo(cN);function uN(d){const e=lp(({mapLib:n})=>new n.FullscreenControl({container:d.containerId&&document.getElementById(d.containerId)}),{position:d.position});return Ye.exports.useEffect(()=>{Ed(e._controlContainer,d.style)},[d.style]),null}Ye.exports.memo(uN);function hN(d,e){const n=Ye.exports.useRef({props:d}),a=lp(({mapLib:c})=>{const f=new c.GeolocateControl(d),m=f._setupUI;return f._setupUI=i=>{f._container.hasChildNodes()||m(i)},f.on("geolocate",i=>{var w,E;(E=(w=n.current.props).onGeolocate)===null||E===void 0||E.call(w,i)}),f.on("error",i=>{var w,E;(E=(w=n.current.props).onError)===null||E===void 0||E.call(w,i)}),f.on("outofmaxbounds",i=>{var w,E;(E=(w=n.current.props).onOutOfMaxBounds)===null||E===void 0||E.call(w,i)}),f.on("trackuserlocationstart",i=>{var w,E;(E=(w=n.current.props).onTrackUserLocationStart)===null||E===void 0||E.call(w,i)}),f.on("trackuserlocationend",i=>{var w,E;(E=(w=n.current.props).onTrackUserLocationEnd)===null||E===void 0||E.call(w,i)}),f},{position:d.position});return n.current.props=d,Ye.exports.useImperativeHandle(e,()=>a,[]),Ye.exports.useEffect(()=>{Ed(a._container,d.style)},[d.style]),null}Ye.exports.memo(Ye.exports.forwardRef(hN));function dN(d){const e=lp(({mapLib:n})=>new n.NavigationControl(d),{position:d.position});return Ye.exports.useEffect(()=>{Ed(e._container,d.style)},[d.style]),null}Ye.exports.memo(dN);function fN(d){const e=lp(({mapLib:f})=>new f.ScaleControl(d),{position:d.position}),n=Ye.exports.useRef(d),a=n.current;n.current=d;const{style:c}=d;return d.maxWidth!==void 0&&d.maxWidth!==a.maxWidth&&(e.options.maxWidth=d.maxWidth),d.unit!==void 0&&d.unit!==a.unit&&e.setUnit(d.unit),Ye.exports.useEffect(()=>{Ed(e._container,c)},[c]),null}Ye.exports.memo(fN);function T_(d,e){if(!d)throw new Error(e)}function pN(d,e,n,a){if(T_(n.id===a.id,"layer id changed"),T_(n.type===a.type,"layer type changed"),n.type==="custom"||a.type==="custom")return;const{layout:c={},paint:f={},filter:m,minzoom:i,maxzoom:w,beforeId:E}=n;if(E!==a.beforeId&&d.moveLayer(e,E),c!==a.layout){const C=a.layout||{};for(const T in c)dl(c[T],C[T])||d.setLayoutProperty(e,T,c[T]);for(const T in C)c.hasOwnProperty(T)||d.setLayoutProperty(e,T,void 0)}if(f!==a.paint){const C=a.paint||{};for(const T in f)dl(f[T],C[T])||d.setPaintProperty(e,T,f[T]);for(const T in C)f.hasOwnProperty(T)||d.setPaintProperty(e,T,void 0)}dl(m,a.filter)||d.setFilter(e,m),(i!==a.minzoom||w!==a.maxzoom)&&d.setLayerZoomRange(e,i,w)}function mN(d,e,n){if(d.style&&d.style._loaded&&(!("source"in n)||d.getSource(n.source))){const a={...n,id:e};delete a.beforeId,d.addLayer(a,n.beforeId)}}let gN=0;function _N(d){const e=Ye.exports.useContext(ap).map.getMap(),n=Ye.exports.useRef(d),[,a]=Ye.exports.useState(0),c=Ye.exports.useMemo(()=>d.id||`jsx-layer-${gN++}`,[]);if(Ye.exports.useEffect(()=>{if(e){const m=()=>a(i=>i+1);return e.on("styledata",m),m(),()=>{e.off("styledata",m),e.style&&e.style._loaded&&e.getLayer(c)&&e.removeLayer(c)}}},[e]),e&&e.style&&e.getLayer(c))try{pN(e,c,d,n.current)}catch(m){console.warn(m)}else mN(e,c,d);return n.current=d,null}let yN=0;function xN(d,e,n){if(d.style&&d.style._loaded){const a={...n};return delete a.id,delete a.children,d.addSource(e,a),d.getSource(e)}return null}function vN(d,e,n){T_(e.id===n.id,"source id changed"),T_(e.type===n.type,"source type changed");let a="",c=0;for(const m in e)m!=="children"&&m!=="id"&&!dl(n[m],e[m])&&(a=m,c++);if(!c)return;const f=e.type;if(f==="geojson")d.setData(e.data);else if(f==="image")d.updateImage({url:e.url,coordinates:e.coordinates});else if("setCoordinates"in d&&c===1&&a==="coordinates")d.setCoordinates(e.coordinates);else if("setUrl"in d)switch(a){case"url":d.setUrl(e.url);break;case"tiles":d.setTiles(e.tiles);break}else console.warn(`Unable to update <Source> prop: ${a}`)}function bN(d){const e=Ye.exports.useContext(ap).map.getMap(),n=Ye.exports.useRef(d),[,a]=Ye.exports.useState(0),c=Ye.exports.useMemo(()=>d.id||`jsx-source-${yN++}`,[]);Ye.exports.useEffect(()=>{if(e){const m=()=>setTimeout(()=>a(i=>i+1),0);return e.on("styledata",m),m(),()=>{var i;if(e.off("styledata",m),e.style&&e.style._loaded&&e.getSource(c)){const w=(i=e.getStyle())===null||i===void 0?void 0:i.layers;if(w)for(const E of w)E.source===c&&e.removeLayer(E.id);e.removeSource(c)}}}},[e]);let f=e&&e.style&&e.getSource(c);return f?vN(f,d,n.current):f=xN(e,c,d),n.current=d,f&&Ye.exports.Children.map(d.children,m=>m&&Ye.exports.cloneElement(m,{source:c}))||null}const wN=rP(()=>Promise.resolve().then(()=>H4),void 0,import.meta.url),SN=(()=>Ye.exports.forwardRef(function(e,n){return sN(e,n,wN)}))(),ix=_N,MN=bN;function EN(d,e){var n=Ye.exports.useRef(null),a=Ye.exports.useRef(null);a.current=e;var c=Ye.exports.useRef(null);Ye.exports.useEffect(function(){f()});var f=Ye.exports.useCallback(function(){var m=c.current,i=a.current,w=m||(i?i instanceof Element?i:i.current:null);n.current&&n.current.element===w&&n.current.subscriber===d||(n.current&&n.current.cleanup&&n.current.cleanup(),n.current={element:w,subscriber:d,cleanup:w?d(w):void 0})},[d]);return Ye.exports.useEffect(function(){return function(){n.current&&n.current.cleanup&&(n.current.cleanup(),n.current=null)}},[]),Ye.exports.useCallback(function(m){c.current=m,f()},[f])}function PM(d,e,n){return d[e]?d[e][0]?d[e][0][n]:d[e][n]:e==="contentBoxSize"?d.contentRect[n==="inlineSize"?"width":"height"]:void 0}function TN(d){d===void 0&&(d={});var e=d.onResize,n=Ye.exports.useRef(void 0);n.current=e;var a=d.round||Math.round,c=Ye.exports.useRef(),f=Ye.exports.useState({width:void 0,height:void 0}),m=f[0],i=f[1],w=Ye.exports.useRef(!1);Ye.exports.useEffect(function(){return w.current=!1,function(){w.current=!0}},[]);var E=Ye.exports.useRef({width:void 0,height:void 0}),C=EN(Ye.exports.useCallback(function(T){return(!c.current||c.current.box!==d.box||c.current.round!==a)&&(c.current={box:d.box,round:a,instance:new ResizeObserver(function(I){var k=I[0],O=d.box==="border-box"?"borderBoxSize":d.box==="device-pixel-content-box"?"devicePixelContentBoxSize":"contentBoxSize",B=PM(k,O,"inlineSize"),F=PM(k,O,"blockSize"),H=B?a(B):void 0,Y=F?a(F):void 0;if(E.current.width!==H||E.current.height!==Y){var K={width:H,height:Y};E.current.width=H,E.current.height=Y,n.current?n.current(K):w.current||i(K)}})}),c.current.instance.observe(T,{box:d.box}),function(){c.current&&c.current.instance.unobserve(T)}},[d.box,a]),d.ref);return Ye.exports.useMemo(function(){return{ref:C,width:m.width,height:m.height}},[C,m.width,m.height])}class AN{constructor(){rf(this,"_cls");rf(this,"_nameMap");rf(this,"params")}toJSON(){const e=this._cls,n=[];if(this.params)for(const[a,c]of Object.entries(this.params))a&&n.push([this._getSerializedName(a),c]);return{_cls:e,kwargs:n}}_getSerializedName(e){return this._nameMap.has(e)?this._nameMap.get(e):e}}class LM extends AN{constructor(e=null){super(),this.params=e,this._cls="fiftyone.core.aggregations.Values",this._nameMap=new Map(Object.entries({fieldOrExpr:"field_or_expr",expr:"expr",missingValue:"missing_value",unwind:"unwind"}))}}const CN="/aggregate";function IN({view:d,filters:e,dataset:n,sample_ids:a}={}){const[c,f]=fn.useState(!0),[m,i]=fn.useState(null);return[async(E,C)=>{f(!0);const T=E.map(k=>k.toJSON()),I=await vm()("POST",CN,{filters:e,view:d,dataset:C||n.name,sample_ids:a,aggregations:T});i(I.aggregate),f(!1)},m,c]}const PN=({path:d,dataset:e,filters:n,view:a})=>{const[c,f,m]=IN({dataset:e,filters:n,view:a});return fn.useEffect(()=>{c([new LM({fieldOrExpr:"id"}),new LM({fieldOrExpr:`${d}.point.coordinates`})],e.name)},[e,n,a,d]),{loading:m,samples:fn.useMemo(()=>f?f[0].reduce((i,w,E)=>(f[1][E]&&(i[w]=f[1][E]),i),{}):{},[f])}};function LN({draw:d,onCreate:e}){const n=fn.useRef(e);return n.current=e,lp(({map:a})=>(a.on("draw.create",c=>{n.current(c),d.delete(c.features[0].id)}),d),({map:a})=>{a.off("draw.create",n.current)}),null}const Kv="@fiftyone/map",RN=Object.freeze({clustering:!0,clusterMaxZoom:11,clusters:{paint:{"circle-color":"rgb(244, 113, 6)","circle-opacity":.7,"circle-radius":["step",["get","point_count"],20,10,30,25,40]},textPaint:{"text-color":"white"}},pointPaint:{"circle-color":"rgb(244, 113, 6)","circle-opacity":.7,"circle-radius":4}}),DN=D_({key:"@fiftyone/map/state.defaultActiveField",get:({get:d})=>d(W2)[0]}),j2=Su({key:"@fiftyone/map/state.activeField",default:DN}),W2=D_({key:"@fiftyone/map/state.geoFields",get:({get:d})=>d(sP).filter(e=>e.embeddedDocType==="fiftyone.core.labels.GeoLocation").map(({name:e})=>e).sort()}),zN=D_({key:"hasSelection",get:({get:d})=>d(md).scope===Kv}),H2={Street:"streets-v11",Dark:"dark-v10",Light:"light-v10",Outdoors:"outdoors-v11",Satellite:"satellite-v9"},kN=Object.keys(H2),ON=D_({key:"defaultMapStyle",get:({get:d})=>d(oP)==="dark"?"Dark":"Light"}),q2=Su({key:"@fiftyone/map/state.mapStyle",default:ON,effects:[ep("@fiftyone/map/state.style",{sessionStorage:!0,map:d=>["Dark","Light"].includes(d)?void 0:d})]}),FN="_options_1pz6v_1",rx="_link_1pz6v_16";const BN=(d,e,n,a=!1)=>{const c=Ye.exports.useRef(n);c.current=n,Ye.exports.useEffect(()=>{if(!d)return;const f=m=>c.current(m);return d&&d.addEventListener(e,f,a),()=>{d&&d.removeEventListener(e,f)}},[d,e])},NN=d=>({values:kN.filter(n=>n.includes(d))}),RM=({value:d})=>fn.createElement(fn.Fragment,null,d),UN=({clearSelectionData:d,fitSelectionData:e,fitData:n})=>{const a=gd(),[c,f]=Ca(q2),m=yi(W2),[i,w]=Ca(j2),E=yi(zN),C={background:a.neutral.softBg,borderTopLeftRadius:3,borderTopRightRadius:3,padding:"0.25rem"},T=fn.useCallback(()=>{d(),n()},[d,n]);return BN(window,"keydown",({key:I})=>{switch(I){case"Escape":T();break;case"f":e();break}}),fn.createElement("div",{className:FN},fn.createElement("div",null,fn.createElement(p_,{placeholder:"Map Style",value:c,onSelect:f,useSearch:NN,component:RM,containerStyle:C,overflow:!0}),m.length>1&&fn.createElement(p_,{placeholder:"Field",value:i,onSelect:w,useSearch:()=>({values:m}),component:RM,containerStyle:C,overflow:!0})),fn.createElement("div",null,E&&fn.createElement(s_,{to:T,className:rx,title:"Reset (Esc)"},fn.createElement(qx,null)),fn.createElement(s_,{to:e,className:rx,title:"Fit data (f)"},fn.createElement(qM,null)),fn.createElement(s_,{className:rx,href:"https://docs.voxel51.com/user_guide/app.html#map-panel",title:"Help",to:FM("https://docs.voxel51.com"),target:"_blank"},fn.createElement(BM,null)),fn.createElement(NM,{place:UM.MAP_ACTIONS})))},Z2={animate:!1,padding:30},X2=d=>d.features.reduce((e,{geometry:{coordinates:n}})=>e.extend(n),new K_.exports.LngLatBounds),sx=(d,e)=>{d.fitBounds(X2(e),Z2)},VN=d=>{const e=Object.entries(d);return e.length===0?null:{type:"FeatureCollection",features:e.map(([n,a])=>({type:"Feature",properties:{id:n},geometry:{type:"Point",coordinates:a}}))}},GN=()=>{const d=gd(),e=yi(bm),n=yi(R_),a=yi(Xx);let{loading:c,samples:f}=PN({dataset:e,filters:a,view:n,path:yi(j2)});const m=WM("map",RN),i=yi(q2),[{selection:w},E]=Ca(md),C=Yx(),T=fn.useRef(null),I=fn.useMemo(()=>aP.exports.debounce(()=>{T.current&&T.current.resize()},0,{trailing:!0}),[]),{ref:k}=TN({onResize:I}),O=fn.useMemo(()=>{let Ae=f;if(w){Ae={};for(const oe of w)f[oe]&&(Ae[oe]=f[oe])}return VN(Ae)},[f,w]),B=fn.useMemo(()=>O&&X2(O),[f]),[F]=fn.useState(()=>new R4({displayControlsDefault:!1,defaultMode:"draw_polygon"})),[H,Y]=fn.useState(!1),K=fn.useCallback(()=>{var ke;const Ae=(ke=T.current)==null?void 0:ke.getMap();if(!Ae)return;Ae.on("click","cluster",Xe=>{var ft;Xe.preventDefault();const St=Ae.queryRenderedFeatures(Xe.point,{layers:["cluster"]});F.changeMode("simple_select");const Je=(ft=St[0].properties)==null?void 0:ft.cluster_id;Ae.getSource("points").getClusterExpansionZoom(Je,(Nt,Fe)=>{var tt;if(Nt)return;const it=St[0].geometry;(tt=T.current)==null||tt.easeTo({center:it.coordinates,zoom:Fe})})});const oe=()=>Ae.getCanvas().style.cursor="pointer",ce=()=>Ae.getCanvas().style.cursor="crosshair",Re=()=>Ae.getCanvas().style.cursor="all-scroll";Ae.on("mouseenter","cluster",oe),Ae.on("mouseleave","cluster",ce),Ae.on("mouseenter","point",()=>oe),Ae.on("mouseleave","point",()=>ce),Ae.on("dragstart",Re),Ae.on("dragend",ce)},[]),ne=fn.useMemo(()=>Object.keys(f).length,[f]);fn.useEffect(()=>{T.current&&O&&sx(T.current,O)},[O]),GM(()=>new Promise(Ae=>{T.current.once("render",()=>{Ae(T.current.getCanvas())}),T.current.setBearing(T.current.getBearing())}));const le=OM();return fn.useEffect(()=>{le(C)},[]),m.mapboxAccessToken?(!Object.keys(f).length||!O)&&!c?fn.createElement(eh,null,"No data"):fn.createElement("div",{className:L4,ref:k},c&&!ne?fn.createElement(eh,{style:{opacity:.5}},"Pixelating..."):H?fn.createElement(eh,null,"Something went wrong... is your\xA0",fn.createElement(gw,{style:{color:d.text.primary},href:"https://docs.voxel51.com/user_guide/app.html#map-panel"},"Mapbox token"),"\xA0valid?"):fn.createElement(SN,{ref:T,mapLib:G2,mapStyle:`mapbox://styles/mapbox/${H2[i]}`,initialViewState:{bounds:B,fitBoundsOptions:Z2},onStyleData:()=>{T.current&&(T.current.getCanvas().style.cursor="crosshair")},mapboxAccessToken:m.mapboxAccessToken,onLoad:K,onRender:()=>{F.getMode()!=="draw_polygon"&&F.changeMode("draw_polygon")},onError:({error:Ae})=>{throw Y(!0),Ae}},fn.createElement(MN,{id:"points",type:"geojson",data:O,cluster:m.clustering,clusterMaxZoom:m.clusterMaxZoom},m.clustering&&fn.createElement(ix,{id:"cluster",filter:["has","point_count"],paint:{"circle-color":d.primary.plainColor,"circle-opacity":.7,"circle-radius":["step",["get","point_count"],20,10,30,25,40],...m.clusters.paint},type:"circle"}),m.clustering&&fn.createElement(ix,{id:"cluster-count",filter:["has","point_count"],layout:{"text-field":"{point_count_abbreviated}","text-font":["DIN Offc Pro Medium","Arial Unicode MS Bold"],"text-size":12},paint:m.clusters.textPaint,type:"symbol"}),fn.createElement(ix,{id:"point",filter:["!",["has","point_count"]],paint:m.pointPaint,type:"circle"})),fn.createElement(LN,{draw:F,onCreate:Ae=>{const{features:[oe]}=Ae,ce=new Set;for(let Re=0;Re<O.features.length;Re++)O4(oe,O.features[Re])&&ce.add(O.features[Re].properties.id);!ce.size||E({selection:Array.from(ce),scope:Kv})}})),fn.createElement(UN,{fitData:()=>T.current&&sx(T.current,O),fitSelectionData:()=>T.current&&sx(T.current,O),clearSelectionData:C})):fn.createElement(eh,null,"No Mapbox token provided.\xA0",fn.createElement(gw,{style:{color:d.text.primary},href:"https://docs.voxel51.com/user_guide/app.html#map-panel"},"Learn more"))};var Qv={},jN=L_.exports;Object.defineProperty(Qv,"__esModule",{value:!0});var $2=Qv.default=void 0,WN=jN(I_()),HN=P_(),qN=(0,WN.default)((0,HN.jsx)("path",{d:"m20.5 3-.16.03L15 5.1 9 3 3.36 4.9c-.21.07-.36.25-.36.48V20.5c0 .28.22.5.5.5l.16-.03L9 18.9l6 2.1 5.64-1.9c.21-.07.36-.25.36-.48V3.5c0-.28-.22-.5-.5-.5zM15 19l-6-2.11V5l6 2.11V19z"}),"Map");$2=Qv.default=qN;function ZN(){const{selection:d,scope:e}=yi(md),n=Yx();return e!==Kv?null:React.createElement(VM,{selectionCount:d==null?void 0:d.length.toString(),onClickSelection:n})}Jx({name:"Map",label:"Map",component:GN,type:Kx.Panel,activator:XN,Icon:$2,panelOptions:{TabIndicator:ZN}});function XN({schema:d}){for(const e in d)if(d[e].embeddedDocType==="fiftyone.core.labels.GeoLocation")return!0;return!1}const $N="_page_8fb7q_1",YN="_rest_8fb7q_8",JN="_icons_8fb7q_13",KN={page:$N,rest:YN,icons:JN},QN=fI,r5=({prepared:d})=>{const e=lP.exports.usePreloadedQuery(QN,d),n=Boolean(yi(cP)),c=yi(uP)===0;return Ye.exports.useEffect(()=>{var f;(f=document.getElementById("modal"))==null||f.classList.toggle("modalon",n)},[n]),fn.createElement(fn.Fragment,null,fn.createElement(mP,{fragment:e,hasDataset:!c}),c?fn.createElement(gP,{mode:"ADD_SAMPLE"}):fn.createElement(fn.Fragment,null,fn.createElement("div",{className:KN.page},fn.createElement(hP.Provider,{value:e},fn.createElement(dP,null),fn.createElement(fP,null))),fn.createElement(pP,null)))};export{r5 as default};
