isard 2.1.2 → 2.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/basemap/mvt.d.ts +3 -2
- package/dist/basemap/mvt.js +67 -30
- package/dist/basemap/mvt.js.map +1 -1
- package/dist/basemap.worker.js +2 -2
- package/dist/basemap.worker.js.map +4 -4
- package/dist/isard_grid_bg.wasm +0 -0
- package/dist/isard_webgl2_bg.wasm +0 -0
- package/dist/isard_webgpu_bg.wasm +0 -0
- package/package.json +1 -1
package/dist/basemap.worker.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var ie=(e,t)=>Error(`isard: ${String(e)}: HTTP ${t}`),St=async(e,t)=>{let n=await fetch(e,t);if(!n.ok)throw ie(e,n.status);return n};class le{capacity;evict;entries=new Map;weights=new Map;total=0;constructor(e,t){this.capacity=e;this.evict=t}get size(){return this.entries.size}get(e){let t=this.entries.get(e);if(t!==void 0)this.entries.delete(e),this.entries.set(e,t);return t}has(e){return this.entries.has(e)}set(e,t){this.delete(e),this.entries.set(e,t),this.total+=1,this.trim()}weigh(e,t){if(!this.entries.has(e))return;this.total+=t-(this.weights.get(e)??1),this.weights.set(e,t),this.trim()}delete(e){if(!this.entries.has(e))return!1;return this.total-=this.weights.get(e)??1,this.weights.delete(e),this.entries.delete(e)}trim(){for(let[e,t]of this.entries){if(this.total<=this.capacity||this.entries.size<=1)break;this.delete(e),this.evict?.(t,e)}}values(){return this.entries.values()}clear(){this.entries.clear(),this.weights.clear(),this.total=0}}var kt=[];var vt=(e)=>{kt=e};var oe=(e,t={})=>{let n=String(e),r=kt.filter(([s])=>n.startsWith(s));if(r.length===0)return t;let o=new Headers(t.headers);return r.forEach(([,s])=>{Object.entries(s).forEach(([a,i])=>{o.set(a,i)})}),{...t,headers:o}};var qn=96,$n=(e,t,n,r,o,s)=>{let a=new Uint8ClampedArray(s*s*4),i=s/o,c=o+1;for(let l=0;l<s;l+=1){let u=(l+0.5)/i,d=Math.min(o-1,Math.floor(u)),f=u-d;for(let p=0;p<s;p+=1){let A=(p+0.5)/i,y=Math.min(o-1,Math.floor(A)),w=A-y,m=2*(d*c+y),M=m+2*c,b=(1-w)*(1-f),x=w*(1-f),T=(1-w)*f,E=w*f,_=b*r[m]+x*r[m+2]+T*r[M]+E*r[M+2],g=b*r[m+1]+x*r[m+3]+T*r[M+1]+E*r[M+3],h=_-0.5,S=g-0.5;if(!(h>-1&&S>-1&&h<t&&S<n))continue;let k=Math.floor(h),v=Math.floor(S),R=h-k,W=S-v,B=0,O=0,P=0,I=0;for(let F=0;F<4;F+=1){let C=k+(F&1),V=v+(F>>1);if(C<0||V<0||C>=t||V>=n)continue;let J=4*(V*t+C),z=(F&1?R:1-R)*(F>>1?W:1-W)*e[J+3];B+=z*e[J],O+=z*e[J+1],P+=z*e[J+2],I+=z}if(I<=0)continue;let L=4*(l*s+p);a[L]=B/I,a[L+1]=O/I,a[L+2]=P/I,a[L+3]=I}}return a},Rt=(e=qn)=>{let t=new Map,n=new Set,r=(l)=>{n.delete(l),l.then((u)=>u?.close(),()=>{return})},o=(l)=>{if(t.has(l))n.add(l);else r(l)},s=new le(e,o),a=(l)=>{let u=(t.get(l)??1)-1;if(u>0)t.set(l,u);else if(t.delete(l),n.has(l))r(l)},i=(l)=>{let u=()=>{let f=(async()=>{let p=await fetch(l,oe(l));if(p.status===404||p.status===204||p.status===410)return null;if(!p.ok)throw ie(l,p.status);return createImageBitmap(await p.blob())})();return f.catch(()=>s.delete(l)),s.set(l,f),f},d=s.get(l)??u();return t.set(d,(t.get(d)??0)+1),d};return{draw:async(l,u)=>{let d=l.sources.map((f)=>[f,i(f.url)]);try{let f=await Promise.all(d.map(async([m,M])=>[m,await M]));if(u.throwIfAborted(),!f.some(([,m])=>m))return null;let A=new OffscreenCanvas(l.width,l.height).getContext("2d",{willReadFrequently:!0});if(!A)throw Error("isard: no 2D canvas to reproject the tiles");f.forEach(([m,M])=>{if(M)A.drawImage(M,m.x,m.y,m.w,m.h)});let y=A.getImageData(0,0,l.width,l.height).data,w=$n(y,l.width,l.height,l.mesh,l.n,l.size);return createImageBitmap(new ImageData(w,l.size,l.size),{premultiplyAlpha:"none"})}finally{d.forEach(([,f])=>{a(f)})}},cache:s,close:()=>{[...s.values()].forEach(o),s.clear()}}};var xe=(e,t,n)=>Math.max(t,Math.min(n,e));var Ko=Math.PI/180,Tt=40075016.686,Go=Tt/360;var Et=(e)=>e*360-180,It=(e)=>Math.atan(Math.sinh(Math.PI*(1-2*e)))*180/Math.PI;var rt=(e)=>Tt*Math.cos(Math.atan(Math.sinh(Math.PI*(1-2*e)))),_e=(e,t)=>rt((t+0.5)/2**e)/2**e,G=(e,t,n,r)=>e.replaceAll("{z}",String(t)).replaceAll("{x}",String(n)).replaceAll("{y}",String(r));var fe=256,Yn=(e,t,n=Number.NEGATIVE_INFINITY)=>{let r=e.length>>2,o=new Float32Array(r);if(t==="terrarium")for(let s=0,a=0;s<r;s+=1,a+=4){let i=e[a]*256+e[a+1]+e[a+2]/256-32768;o[s]=i>n?i:n}else for(let s=0,a=0;s<r;s+=1,a+=4){let i=-1e4+(e[a]*65536+e[a+1]*256+e[a+2])*0.1;o[s]=i>n?i:n}return o},Lt=async(e,t,n,r,o)=>{let s=await fetch(e,oe(e,{signal:r}));if(s.status===404||s.status===204||s.status===410)return null;if(!s.ok)throw ie(e,s.status);let a=await createImageBitmap(await s.blob(),{premultiplyAlpha:"none",colorSpaceConversion:"none"});try{o.canvas??=new OffscreenCanvas(fe,fe);let i=o.canvas.getContext("2d",{willReadFrequently:!0});if(!i)throw Error("isard: no 2D context");return i.imageSmoothingEnabled=!1,i.clearRect(0,0,fe,fe),i.drawImage(a,0,0,fe,fe),Yn(i.getImageData(0,0,fe,fe).data,t,n)}finally{a.close()}};var Kn="aliceblue f0f8ff antiquewhite faebd7 aqua 00ffff aquamarine 7fffd4 azure f0ffff beige f5f5dc bisque ffe4c4 black 000000 blanchedalmond ffebcd blue 0000ff blueviolet 8a2be2 brown a52a2a burlywood deb887 cadetblue 5f9ea0 chartreuse 7fff00 chocolate d2691e coral ff7f50 cornflowerblue 6495ed cornsilk fff8dc crimson dc143c cyan 00ffff darkblue 00008b darkcyan 008b8b darkgoldenrod b8860b darkgray a9a9a9 darkgreen 006400 darkgrey a9a9a9 darkkhaki bdb76b darkmagenta 8b008b darkolivegreen 556b2f darkorange ff8c00 darkorchid 9932cc darkred 8b0000 darksalmon e9967a darkseagreen 8fbc8f darkslateblue 483d8b darkslategray 2f4f4f darkslategrey 2f4f4f darkturquoise 00ced1 darkviolet 9400d3 deeppink ff1493 deepskyblue 00bfff dimgray 696969 dimgrey 696969 dodgerblue 1e90ff firebrick b22222 floralwhite fffaf0 forestgreen 228b22 fuchsia ff00ff gainsboro dcdcdc ghostwhite f8f8ff gold ffd700 goldenrod daa520 gray 808080 green 008000 greenyellow adff2f grey 808080 honeydew f0fff0 hotpink ff69b4 indianred cd5c5c indigo 4b0082 ivory fffff0 khaki f0e68c lavender e6e6fa lavenderblush fff0f5 lawngreen 7cfc00 lemonchiffon fffacd lightblue add8e6 lightcoral f08080 lightcyan e0ffff lightgoldenrodyellow fafad2 lightgray d3d3d3 lightgreen 90ee90 lightgrey d3d3d3 lightpink ffb6c1 lightsalmon ffa07a lightseagreen 20b2aa lightskyblue 87cefa lightslategray 778899 lightslategrey 778899 lightsteelblue b0c4de lightyellow ffffe0 lime 00ff00 limegreen 32cd32 linen faf0e6 magenta ff00ff maroon 800000 mediumaquamarine 66cdaa mediumblue 0000cd mediumorchid ba55d3 mediumpurple 9370db mediumseagreen 3cb371 mediumslateblue 7b68ee mediumspringgreen 00fa9a mediumturquoise 48d1cc mediumvioletred c71585 midnightblue 191970 mintcream f5fffa mistyrose ffe4e1 moccasin ffe4b5 navajowhite ffdead navy 000080 oldlace fdf5e6 olive 808000 olivedrab 6b8e23 orange ffa500 orangered ff4500 orchid da70d6 palegoldenrod eee8aa palegreen 98fb98 paleturquoise afeeee palevioletred db7093 papayawhip ffefd5 peachpuff ffdab9 peru cd853f pink ffc0cb plum dda0dd powderblue b0e0e6 purple 800080 rebeccapurple 663399 red ff0000 rosybrown bc8f8f royalblue 4169e1 saddlebrown 8b4513 salmon fa8072 sandybrown f4a460 seagreen 2e8b57 seashell fff5ee sienna a0522d silver c0c0c0 skyblue 87ceeb slateblue 6a5acd slategray 708090 slategrey 708090 snow fffafa springgreen 00ff7f steelblue 4682b4 tan d2b48c teal 008080 thistle d8bfd8 tomato ff6347 turquoise 40e0d0 violet ee82ee wheat f5deb3 white ffffff whitesmoke f5f5f5 yellow ffff00 yellowgreen 9acd32",ot,Gn=(e)=>{if(!ot){let t=Kn.split(" ");ot=new Map(Array.from({length:Math.floor(t.length/2)},(n,r)=>[t[2*r]??"",t[2*r+1]??""]))}return ot.get(e)},ze=(e)=>Number.isFinite(e)?xe(e,0,1):0,Ft=(e)=>{if(!/^[0-9a-f]+$/.test(e)||![3,4,6,8].includes(e.length))return;let t=e.length<=4?[...e].map((r)=>r+r).join(""):e,n=(r)=>Number.parseInt(t.slice(r,r+2),16)/255;return[n(0),n(2),n(4),t.length===8?n(6):1]},Zn=(e)=>{if(e===void 0)return 1;return ze(e.endsWith("%")?Number.parseFloat(e)/100:Number.parseFloat(e))},Xn=(e,t,n)=>{let r=n<0.5?n*(1+t):n+t-n*t,o=2*n-r,s=(a)=>{let i=(a%1+1)%1;if(i<0.16666666666666666)return o+(r-o)*6*i;if(i<0.5)return r;if(i<0.6666666666666666)return o+(r-o)*(0.6666666666666666-i)*6;return o};return[s(e+0.3333333333333333),s(e),s(e-0.3333333333333333)]},Nt=(e)=>{if(typeof e!=="string")return;let t=e.trim().toLowerCase();if(t.startsWith("#"))return Ft(t.slice(1));if(t==="transparent")return[0,0,0,0];let n=Gn(t);if(n)return Ft(n);let r=/^(rgba?|hsla?)\(([^)]*)\)$/.exec(t);if(!r?.[1]||r[2]===void 0)return;let o=r[2].split(/[\s,/]+/).filter(Boolean);if(o.length<3||o.slice(0,3).some((u)=>Number.isNaN(Number.parseFloat(u))))return;let s=Zn(o[3]);if(r[1].startsWith("rgb")){let u=(d)=>ze(d.endsWith("%")?Number.parseFloat(d)/100:Number.parseFloat(d)/255);return[u(o[0]??""),u(o[1]??""),u(o[2]??""),s]}let a=Number.parseFloat(o[0]??"")/360,[i,c,l]=Xn(a,ze(Number.parseFloat(o[1]??"")/100),ze(Number.parseFloat(o[2]??"")/100));return[i,c,l,s]};var be=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e);var Qn=["Unknown","Point","LineString","Polygon"],Z=(e,t)=>({zoom:t,properties:e.properties,type:Qn[e.type]??"Unknown"}),ce=(e)=>Nt(e),Je=([e,t,n,r])=>`rgba(${Math.round(e*255)},${Math.round(t*255)},${Math.round(n*255)},${r})`,Ct=(e,t,n,r=1)=>{let o=n-t;if(o===0)return 0;let s=e-t;return r===1?s/o:(r**s-1)/(r**o-1)},it=(e,t,n)=>{if(typeof e==="number"&&typeof t==="number")return e+(t-e)*n;let r=ce(e),o=ce(t);if(r&&o){let s=(a)=>r[a]+(o[a]-r[a])*n;return Je([s(0),s(1),s(2),s(3)])}if(Array.isArray(e)&&Array.isArray(t))return e.map((s,a)=>it(s,t[a],n));return n<0.5?e:t},Wt=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e)&&Array.isArray(e.stops),er=(e,t)=>{let n=e.property===void 0?t.zoom:t.properties[e.property],r=e.stops,o=e.type??(e.property===void 0||typeof r[0]?.[0]==="number"?"exponential":"categorical");if(o==="identity")return n??e.default;if(o==="categorical")return r.find(([u])=>u===n)?.[1]??e.default;if(typeof n!=="number"||!r.length)return e.default??r[0]?.[1];let s=([u])=>{if(Array.isArray(u))return Number.NaN;return be(u)?Number(u.zoom):Number(u)},a=r[0];if(!a)return e.default;if(n<=s(a))return a[1];let i=r.findIndex((u,d)=>d>0&&Boolean(r[d-1])&&Boolean(u)&&n<s(u)),[c,l]=[r[i-1],r[i]];if(i<0||!c||!l)return r.at(-1)?.[1];if(o==="interval")return c[1];return it(c[1],l[1],Ct(n,s(c),s(l),e.base??1))},st=(e)=>e,Ot={"<":(e,t)=>e<t,"<=":(e,t)=>e<=t,">":(e,t)=>e>t,">=":(e,t)=>e>=t},Bt=(e,t,n)=>{let r=(a)=>typeof a==="object"&&a!==null?String(a):a,[o,s]=[r(t),r(n)];return typeof o==="string"&&typeof s==="string"?Ot[e](o,s):Ot[e](Number(o),Number(s))},He=(e,t)=>{if(t==="$type")return e.type;return typeof t==="string"?e.properties[t]:void 0},tr=new Set(["literal","zoom","get","has","!has","properties","id","geometry-type","concat","format","image","number-format","to-number","to-string","to-boolean","to-color","number","string","boolean","typeof","length","at","upcase","downcase","coalesce","!","all","any","==","!=","<","<=",">",">=","in","case","match","step","interpolate","interpolate-hcl","interpolate-lab","rgb","rgba","+","-","*","/","%","^","min","max","abs","round","floor","ceil","sqrt","ln","log10","log2","pi","e"]),Re=(e)=>Array.isArray(e)&&typeof e[0]==="string"&&tr.has(e[0]),Pt=new Set,ve=(e)=>e===void 0||e===null?"":String(e),ae=(e,t)=>{if(Wt(e))return er(e,t);if(!Array.isArray(e))return e;let[n,...r]=e;if(typeof n!=="string")return e;let o=(i)=>ae(r[i]??null,t),s=(i)=>Number(o(i)),a=()=>r.map((i,c)=>s(c));switch(n){case"literal":return r[0];case"zoom":return t.zoom;case"get":return He(t,o(0));case"has":return He(t,o(0))!==void 0;case"!has":return He(t,o(0))===void 0;case"properties":return t.properties;case"id":return null;case"geometry-type":return t.type;case"concat":return r.map((i,c)=>ve(o(c))).join("");case"format":return r.map((i,c)=>i!==null&&typeof i==="object"&&!Array.isArray(i)?"":ve(o(c))).join("");case"image":return o(0);case"number-format":{let i=be(r[1])?r[1]:{},c=(u)=>{let d=i[u];return typeof d==="number"?d:void 0},l=s(0);if(!Number.isFinite(l))return"";return l.toLocaleString(typeof i.locale==="string"?i.locale:void 0,{minimumFractionDigits:c("min-fraction-digits"),maximumFractionDigits:c("max-fraction-digits")})}case"to-number":{for(let i=0;i<r.length;i+=1){let c=o(i),l=typeof c==="string"&&c.trim()===""?Number.NaN:Number(c);if(c!==null&&c!==void 0&&!Number.isNaN(l))return l}return 0}case"to-string":return ve(o(0));case"to-boolean":{let i=o(0);return!(i===""||i===0||i===!1||i===null||i===void 0||Number.isNaN(i))}case"to-color":case"number":case"string":case"boolean":{let i={"to-color":(c)=>ce(c)!==void 0,number:(c)=>typeof c==="number",string:(c)=>typeof c==="string",boolean:(c)=>typeof c==="boolean"};for(let c=0;c<r.length;c+=1){let l=o(c);if(i[n]?.(l))return l}return r.length?o(r.length-1):null}case"typeof":{let i=o(0);if(i===null||i===void 0)return"null";return Array.isArray(i)?"array":typeof i}case"length":{let i=o(0);return typeof i==="string"||Array.isArray(i)?i.length:0}case"at":{let i=o(1);return Array.isArray(i)?i[s(0)]??null:null}case"upcase":return ve(o(0)).toUpperCase();case"downcase":return ve(o(0)).toLowerCase();case"coalesce":for(let i=0;i<r.length;i+=1){let c=o(i);if(c!==void 0&&c!==null)return c}return null;case"!":return!o(0);case"all":return r.every((i,c)=>Boolean(o(c)));case"any":return r.some((i,c)=>Boolean(o(c)));case"==":return o(0)===o(1);case"!=":return o(0)!==o(1);case"<":case"<=":case">":case">=":return Bt(n,o(0),o(1));case"in":{let i=o(1),c=o(0);if(typeof i==="string")return i.includes(String(c));return Array.isArray(i)&&i.includes(c)}case"case":{let i=r.findIndex((c,l)=>l%2===0&&l+1<r.length&&Boolean(o(l)));return i<0?o(r.length-1):o(i+1)}case"match":{let i=o(0),c=r.findIndex((l,u)=>u%2===1&&u+1<r.length&&(Array.isArray(l)?st(l).includes(i):l===i));return c<0?o(r.length-1):o(c+1)}case"step":{let i=s(0),c=o(1);for(let l=2;l+1<r.length;l+=2)if(i>=Number(r[l]))c=o(l+1);else break;return c}case"interpolate":case"interpolate-hcl":case"interpolate-lab":{let i=r[0],c=s(1),l=Array.isArray(i)&&i[0]==="exponential"?Number(i[1]):1,u=Array.from({length:Math.floor((r.length-2)/2)},(y,w)=>[Number(r[2+2*w]),r[3+2*w]??null]),d=u[0];if(!d)return null;if(c<=d[0])return ae(d[1],t);let f=u.findIndex((y,w)=>w>0&&c<y[0]),[p,A]=[u[f-1],u[f]];if(f<0||!p||!A)return ae(u.at(-1)?.[1]??null,t);return it(ae(p[1],t),ae(A[1],t),Ct(c,p[0],A[0],l))}case"rgb":case"rgba":return Je([s(0)/255,s(1)/255,s(2)/255,r.length>3?s(3):1]);case"+":return a().reduce((i,c)=>i+c,0);case"*":return a().reduce((i,c)=>i*c,1);case"-":return r.length===1?-s(0):s(0)-s(1);case"/":return s(0)/s(1);case"%":return s(0)%s(1);case"^":return s(0)**s(1);case"min":return Math.min(...a());case"max":return Math.max(...a());case"abs":return Math.abs(s(0));case"round":return Math.sign(s(0))*Math.round(Math.abs(s(0)));case"floor":return Math.floor(s(0));case"ceil":return Math.ceil(s(0));case"sqrt":return Math.sqrt(s(0));case"ln":return Math.log(s(0));case"log10":return Math.log10(s(0));case"log2":return Math.log2(s(0));case"pi":return Math.PI;case"e":return Math.E;default:if(!Pt.has(n))Pt.add(n),console.warn(`isard: the style expression "${n}" is not supported`);return null}},nr=new Set(["==","!=","<","<=",">",">="]),je=(e)=>{if(e.type==="line")return"line";if(e.type==="fill-extrusion")return"extrusion";if(e.type==="circle")return"circle";return e.type==="fill"||e.type==="background"?"fill":void 0},rr=(e)=>{let[t,n,...r]=e;if(typeof t!=="string"||typeof n!=="string"||r.some(Array.isArray))return!1;if(nr.has(t))return e.length===3;if(t==="in")return e.length!==3||!Array.isArray(e[2]);return t==="!in"||t==="has"||t==="!has"},or=(e,t)=>{let[n,r,...o]=e,s=He(t,r);switch(n){case"==":return s===o[0];case"!=":return s!==o[0];case"<":case"<=":case">":case">=":return Bt(n,s,o[0]);case"in":return st(o).includes(s);case"!in":return!st(o).includes(s);case"has":return s!==void 0;case"!has":return s===void 0;default:return!0}},Ut=new WeakMap,Dt=(e)=>{if(!Array.isArray(e))return()=>Boolean(e);let t=Ut.get(e);if(t)return t;let r=(()=>{let o=e[0];if(o==="all"||o==="any"||o==="none"){let s=e.slice(1).map(Dt);if(o==="all")return(a)=>s.every((i)=>i(a));if(o==="any")return(a)=>s.some((i)=>i(a));return(a)=>!s.some((i)=>i(a))}if(rr(e))return(s)=>or(e,s);return(s)=>Boolean(ae(e,s))})();return Ut.set(e,r),r},Q=(e,t)=>{if(e===void 0||e===null)return!0;return Dt(e)(t)},at=(e)=>Array.isArray(e)&&(e[0]==="zoom"||e.some(at)),sr=new Set(["get","has","!has","geometry-type","properties","id"]),me=(e)=>{if(e!==void 0&&Wt(e))return e.property!==void 0;if(!Array.isArray(e))return!1;if(sr.has(e[0]))return!0;return e.some((t)=>me(t))},ct=(e,t)=>{if(e===void 0||e===null)return"";if(typeof e==="string")return e.replace(/\{([^}]+)\}/g,(r,o)=>{let s=t.properties[o];return s===void 0?"":String(s)});let n=ae(e,t);if(Array.isArray(n))return n.filter((r)=>typeof r==="string").join("");return n===void 0||n===null?"":String(n)},Vt=(e)=>/Regular|Bold|Italic|Semibold|Light|Medium|Black/.test(e)?e:`${e} Regular`,lt=(e)=>{let t=new Set,n=(i)=>i.filter((c,l)=>l>=3&&l%2===1).map(Number),r=(i)=>{if(!Array.isArray(i))return;let c=(l)=>Array.isArray(l)&&l[0]==="zoom";if((i[0]==="interpolate"||i[0]==="interpolate-hcl"||i[0]==="interpolate-lab")&&c(i[2]))n(i).forEach((l)=>{t.add(l)});else if(i[0]==="step"&&c(i[1]))n(i).forEach((l)=>{t.add(l),t.add(l-0.01)});i.forEach(r)};r(e);let o=[...t].filter(Number.isFinite);if(o.length===0)o.push(0);let[s,a]=[Math.min(...o),Math.max(...o)];return o.push(...Array.from({length:Math.floor(a)-Math.ceil(s)+1},(i,c)=>Math.ceil(s)+c)),[...new Set(o)].sort((i,c)=>i-c).map((i)=>[i,Number(ae(e,{zoom:i,properties:{},type:"Unknown"}))])};class Fe{static __wrap(e){let t=Object.create(Fe.prototype);return t.__wbg_ptr=e,zt.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,zt.unregister(this),e}free(){let e=this.__destroy_into_raw();D.__wbg_gridset_free(e,0)}count(){return D.gridset_count(this.__wbg_ptr)>>>0}meta(e){let t,n;try{let r=D.gridset_meta(this.__wbg_ptr,e);return t=r[0],n=r[1],ft(r[0],r[1])}finally{D.__wbindgen_free(t,n,1)}}values(e){return D.gridset_values(this.__wbg_ptr,e)}}if(Symbol.dispose)Fe.prototype[Symbol.dispose]=Fe.prototype.free;class Ne{static __wrap(e){let t=Object.create(Ne.prototype);return t.__wbg_ptr=e,Ht.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Ht.unregister(this),e}free(){let e=this.__destroy_into_raw();D.__wbg_streetflow_free(e,0)}eastU(){return D.streetflow_eastU(this.__wbg_ptr)}eastV(){return D.streetflow_eastV(this.__wbg_ptr)}northU(){return D.streetflow_northU(this.__wbg_ptr)}northV(){return D.streetflow_northV(this.__wbg_ptr)}}if(Symbol.dispose)Ne.prototype[Symbol.dispose]=Ne.prototype.free;function jt(e){let t=fr(e,D.__wbindgen_malloc),n=he,r=D.readGrids(t,n);if(r[2])throw pr(r[1]);return Fe.__wrap(r[0])}function qt(e,t,n,r,o,s){let a=mr(e,D.__wbindgen_malloc),i=he,c=Jt(t,D.__wbindgen_malloc),l=he,u=Jt(n,D.__wbindgen_malloc),d=he,f=D.streetFlow(a,i,c,l,u,d,r,o,s);return Ne.__wrap(f)}function ir(){return{__proto__:null,"./isard_grid_bg.js":{__proto__:null,__wbg___wbindgen_throw_41e9ee4f547fc59a:function(t,n){throw Error(ft(t,n))},__wbg_new_from_slice_ca6ad97db1f4779a:function(t,n){return new Float32Array(ar(t,n))},__wbindgen_generic_0000000000000001:function(t,n){return ft(t,n)},__wbindgen_init_externref_table:function(){let t=D.__wbindgen_externrefs,n=t.grow(4);t.set(0,void 0),t.set(n+0,void 0),t.set(n+1,null),t.set(n+2,!0),t.set(n+3,!1)}}}}var zt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e)=>D.__wbg_gridset_free(e,1)),Ht=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e)=>D.__wbg_streetflow_free(e,1));function ar(e,t){return e=e>>>0,cr().subarray(e/4,e/4+t)}var Te=null;function cr(){if(Te===null||Te.byteLength===0)Te=new Float32Array(D.memory.buffer);return Te}var Ee=null;function lr(){if(Ee===null||Ee.byteLength===0)Ee=new Float64Array(D.memory.buffer);return Ee}function ft(e,t){return br(e>>>0,t)}var Ie=null;function ur(){if(Ie===null||Ie.byteLength===0)Ie=new Uint32Array(D.memory.buffer);return Ie}var Le=null;function $t(){if(Le===null||Le.byteLength===0)Le=new Uint8Array(D.memory.buffer);return Le}function Jt(e,t){let n=t(e.length*4,4)>>>0;return ur().set(e,n/4),he=e.length,n}function fr(e,t){let n=t(e.length*1,1)>>>0;return $t().set(e,n/1),he=e.length,n}function mr(e,t){let n=t(e.length*8,8)>>>0;return lr().set(e,n/8),he=e.length,n}function pr(e){let t=D.__wbindgen_externrefs.get(e);return D.__externref_table_dealloc(e),t}var qe=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});qe.decode();var dr=2146435072,ut=0;function br(e,t){if(ut+=t,ut>=dr)qe=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),qe.decode(),ut=t;return qe.decode($t().subarray(e,e+t))}var he=0,hr,yr,D;function gr(e,t){return yr=e,D=e.exports,hr=t,Te=null,Ee=null,Ie=null,Le=null,D.__wbindgen_start(),D}async function wr(e,t){if(typeof Response==="function"&&e instanceof Response){if(!e.ok)throw Error(`failed to fetch Wasm: ${e.status} ${e.statusText} fetching '${e.url}'`);if(typeof WebAssembly.instantiateStreaming==="function")try{return await WebAssembly.instantiateStreaming(e,t)}catch(o){if(n(e.type)&&e.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",o);else throw o}let r=await e.arrayBuffer();return await WebAssembly.instantiate(r,t)}else{let r=await WebAssembly.instantiate(e,t);if(r instanceof WebAssembly.Instance)return{instance:r,module:e};else return r}function n(r){switch(r){case"basic":case"cors":case"default":return!0}return!1}}async function Yt(e){if(D!==void 0)return D;if(e!==void 0)if(Object.getPrototypeOf(e)===Object.prototype)({module_or_path:e}=e);else console.warn("using deprecated parameters for the initialization function; pass a single object instead");if(e===void 0)e=new URL("isard_grid_bg.wasm",import.meta.url);let t=ir();if(typeof e==="string"||typeof Request==="function"&&e instanceof Request||typeof URL==="function"&&e instanceof URL)e=fetch(e);let{instance:n,module:r}=await wr(await e,t);return gr(n,r)}var mt={},Kt=async(e)=>{let t=mt.ready??Yt({module_or_path:e});mt.ready=t,await t.catch((n)=>{throw mt.ready=void 0,n})},Gt=async(e,t,n,r,o)=>{await Kt(o);let s=qt(e.points,e.ringStart,e.polygonStart,t,n,r);try{return{eastU:s.eastU(),eastV:s.eastV(),northU:s.northU(),northV:s.northV()}}finally{s.free()}},xr=(e)=>typeof e==="object"&&e!==null&&("name"in e)&&("width"in e)&&("height"in e)&&("bounds"in e)&&Array.isArray(e.bounds),Zt=async(e,t)=>{await Kt(t);let n=jt(e);try{let r=[],o=[];for(let s=0;s<n.count();s++){let a=JSON.parse(n.meta(s));if(!xr(a))throw Error("isard: a grid without its description");r.push(a),o.push(n.values(s))}return{grids:r,values:o}}finally{n.free()}};var ye=6,Xt=4;var Qt=(e)=>e*7919%360,pt=["shelter","bin","postbox","fountain","rack","bench"];class en{type;properties;shapes;first;end;constructor(e,t,n,r,o){this.type=e;this.properties=t;this.shapes=n;this.first=r;this.end=o}get geometry(){let{values:e,ranges:t}=this.shapes,n=[];for(let r=this.first;r<this.end;r+=2)n.push(e.subarray(t[r],t[r+1]));return n}}class dt{buf;end;pos;constructor(e,t=0,n=e.length){this.buf=e;this.end=n;this.pos=t}varint(){let e=0;for(let t=0;t<70;t+=7){let n=this.buf[this.pos++]??0;if(e+=(n&127)*2**t,n<128)break}return e}int64(){let e=0,t=0;for(let n=0;n<10;n+=1){let r=this.buf[this.pos++]??0,o=r&127;if(n<4)e|=o<<7*n;else if(n===4)e|=(o&15)<<28,t|=o>>4;else t|=o<<7*n-32;if(r<128)break}return(t|0)*4294967296+(e>>>0)}sint(){let e=this.varint();return e%2===1?-(e+1)/2:e/2}sub(){let e=this.varint(),t=Math.min(this.pos+e,this.end),n=new dt(this.buf,this.pos,t);return this.pos=t,n}string(){let e=this.varint(),t=Math.min(this.pos+e,this.end),n=_r.decode(this.buf.subarray(this.pos,t));return this.pos=t,n}float(){let e=this.pos+4<=this.end?this.view().getFloat32(this.pos,!0):0;return this.pos+=4,e}double(){let e=this.pos+8<=this.end?this.view().getFloat64(this.pos,!0):0;return this.pos+=8,e}view(){return new DataView(this.buf.buffer,this.buf.byteOffset,this.buf.byteLength)}skip(e){if(e===0)this.varint();else if(e===1)this.pos+=8;else if(e===2)this.pos+=this.varint();else if(e===5)this.pos+=4}get more(){return this.pos<this.end}}var _r=new TextDecoder,Ar=(e)=>{let t="";while(e.more){let n=e.varint();switch(n>>3){case 1:t=e.string();break;case 2:t=e.float();break;case 3:t=e.double();break;case 4:t=e.int64();break;case 5:t=e.varint();break;case 6:t=e.sint();break;case 7:t=e.varint()!==0;break;default:e.skip(n&7)}}return t};class tn{values=new Int32Array(1024);length=0;ranges=[];push(e,t){if(this.length+2>this.values.length){let n=new Int32Array(this.values.length*2);n.set(this.values),this.values=n}this.values[this.length++]=e,this.values[this.length++]=t}shapes(){return{values:this.values.slice(0,this.length),ranges:Uint32Array.from(this.ranges)}}}var Mr=(e,t)=>{let[n,r]=[0,0],o=-1,s=()=>{if(o>=0)t.ranges.push(o,t.length)};while(e.more){let a=e.varint(),i=a&7,c=a>>3;if(i===7){if(o>=0&&t.length>o)t.push(t.values[o]??0,t.values[o+1]??0);continue}for(let l=0;l<c&&e.more;l+=1){if(n+=e.sint(),r+=e.sint(),i===1)s(),o=t.length;if(o>=0)t.push(n,r)}}s()},nn=(e)=>[...e.values()].reduce((t,n)=>t+n.bytes,0),Sr=270,bt=(e,t)=>{let n=new Map,r=new dt(e);while(r.more){let o=r.varint();if(o>>3!==3){r.skip(o&7);continue}let s=r.sub(),a="",i=4096,c=[],l=[],u=[];while(s.more){let w=s.varint();switch(w>>3){case 1:a=s.string();break;case 2:u.push(s.sub());break;case 3:c.push(s.string());break;case 4:l.push(Ar(s.sub()));break;case 5:i=s.varint();break;default:s.skip(w&7)}}if(t&&!t.has(a))continue;let d=[],f=new tn;for(let w of u){let m=1,M={},b=f.ranges.length;while(w.more){let x=w.varint();switch(x>>3){case 2:{let T=w.sub();while(T.more){let E=c[T.varint()],_=l[T.varint()];if(E!==void 0&&_!==void 0)M[E]=_}break}case 3:m=Math.min(3,Math.max(1,w.varint()));break;case 4:Mr(w.sub(),f);break;default:w.skip(x&7)}}d.push([m,M,b,f.ranges.length])}let p=f.shapes(),A=d.map(([w,m,M,b])=>new en(w,m,p,M,b)),y=A.length*Sr+p.values.byteLength+p.ranges.byteLength;n.set(a,{extent:i,features:A,bytes:y})}return n};var kr=127,vr=16384,Rr=["unknown","mvt","png","jpeg","webp","avif"],Tr=(e)=>(4**e-1)/3,Er=(e,t,n)=>{if(e>26)throw Error(`isard: PMTiles level ${e} past 26`);let r=2**e;if(t<0||n<0||t>=r||n>=r)throw Error(`isard: PMTiles tile ${e}/${t}/${n} out of its level`);let[o,s]=[t,n],a=0;for(let i=r/2;i>=1;i/=2){let c=(o&i)>0?1:0,l=(s&i)>0?1:0;if(a+=i*i*(3*c^l),l===0){if(c===1)[o,s]=[i-1-o,i-1-s];[o,s]=[s,o]}}return Tr(e)+a};class sn{bytes;pos=0;constructor(e){this.bytes=e}next(){let e=0,t=1;for(;;){let n=this.bytes[this.pos++];if(n===void 0)throw Error("isard: PMTiles directory truncated");if(e+=(n&127)*t,n<128)return e;if(t*=128,t>9223372036854776000)throw Error("isard: PMTiles varint too long")}}}var rn=(e)=>{let t=new sn(e),n=t.next();if(n>e.length)throw Error("isard: PMTiles directory larger than its bytes");let r=[],o=0;for(let s=0;s<n;s+=1)o+=t.next(),r.push({tileId:o,offset:0,length:0,runLength:1});for(let s of r)s.runLength=t.next();for(let s of r)s.length=t.next();return r.forEach((s,a)=>{let i=t.next(),c=r[a-1];s.offset=i===0&&c?c.offset+c.length:i-1}),r},Ir=(e,t)=>{let[n,r]=[0,e.length-1];while(n<=r){let s=n+r>>1,a=e[s];if(!a)break;if(a.tileId===t)return a;if(a.tileId<t)n=s+1;else r=s-1}let o=e[r];if(!o)return;if(o.runLength===0||t-o.tileId<o.runLength)return o;return},Lr=(e)=>{if(e.length<kr||String.fromCharCode(...e.subarray(0,7))!=="PMTiles")throw Error("isard: not a PMTiles archive");if(e[7]!==3)throw Error(`isard: PMTiles version ${e[7]} (only 3 is read)`);let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=(o)=>Number(t.getBigUint64(o,!0)),r=(o)=>t.getInt32(o,!0)/1e7;return{rootDirectoryOffset:n(8),rootDirectoryLength:n(16),metadataOffset:n(24),metadataLength:n(32),leafDirectoryOffset:n(40),leafDirectoryLength:n(48),tileDataOffset:n(56),tileDataLength:n(64),internalCompression:t.getUint8(97),tileCompression:t.getUint8(98),tileType:Rr[t.getUint8(99)]??"unknown",minZoom:t.getUint8(100),maxZoom:t.getUint8(101),bounds:[r(102),r(106),r(110),r(114)],center:[r(119),r(123),t.getUint8(118)]}},$e=async(e,t)=>{if(t===0||t===1)return e;if(t!==2)throw Error(`isard: PMTiles compression ${t===3?"brotli":"zstd"} is not read (gzip only)`);let n=new Blob([e]).stream().pipeThrough(new DecompressionStream("gzip"));return new Uint8Array(await new Response(n).arrayBuffer())},Fr=67108864;class an{source;head;leaves=new le(64);whole;constructor(e){this.source=e}async range(e,t,n){if(typeof this.source!=="string")return new Uint8Array(await this.source.slice(e,e+t).arrayBuffer());if(this.whole)return(await this.whole).subarray(e,e+t);let r=await fetch(this.source,oe(this.source,{headers:{Range:`bytes=${e}-${e+Math.max(t,1)-1}`},...n?{signal:n}:{}}));if(!r.ok)throw ie(this.source,r.status);if(r.status===206)return new Uint8Array(await r.arrayBuffer());if(Number(r.headers.get("Content-Length"))>Fr)throw await r.body?.cancel(),Error(`isard: ${this.source}: the server ignores range requests (HTTP 206 expected)`);let s=r.arrayBuffer().then((a)=>new Uint8Array(a));return this.whole=s,s.catch(()=>{this.whole=void 0}),(await s).subarray(e,e+t)}load(){return this.head??=(async()=>{let e=await this.range(0,vr),t=Lr(e),{rootDirectoryOffset:n,rootDirectoryLength:r}=t,o=n+r<=e.length?e.subarray(n,n+r):await this.range(n,r),s=rn(await $e(o,t.internalCompression));return{header:t,root:s}})(),this.head.catch(()=>{this.head=void 0}),this.head}async header(){return(await this.load()).header}async metadata(){let{header:e}=await this.load();if(e.metadataLength===0)return{};let t=await this.range(e.metadataOffset,e.metadataLength),n=new TextDecoder().decode(await $e(t,e.internalCompression)),r=JSON.parse(n);return be(r)?r:{}}leaf(e,t){let n=e.leafDirectoryOffset+t.offset,r=this.leaves.get(n);if(r)return r;let o=this.range(n,t.length).then(async(s)=>rn(await $e(s,e.internalCompression)));return o.catch(()=>this.leaves.delete(n)),this.leaves.set(n,o),o}async tile(e,t,n,r){let{header:o,root:s}=await this.load();if(e<o.minZoom||e>o.maxZoom)return;let a=Er(e,t,n),i=s;for(let c=0;c<4;c+=1){let l=Ir(i,a);if(!l)return;if(l.runLength>0){let u=await this.range(o.tileDataOffset+l.offset,l.length,r);return $e(u,o.tileCompression)}i=await this.leaf(o,l)}throw Error("isard: PMTiles directories nested too deep")}}var on=new le(16),Nr=(e)=>{let t=on.get(e);if(t)return t;let n=new an(e);return on.set(e,n),n};var ht=(e,t)=>{let n=/^pmtiles:\/\/(.+)\/(\d+)\/(\d+)\/(\d+)$/.exec(e);if(!n)return!1;let[,r="",o,s,a]=n;return Nr(r).tile(Number(o),Number(s),Number(a),t)};var gt=(e,t)=>{let n=e.sprites.find((o)=>Boolean(o.icons[t])),r=n?.icons[t];return n&&r?{icon:r,image:n.image}:void 0},Oe=new Map,ln=192,Or=16,Ae=new le(ln<<20),un=(e,t=ln)=>Math.max(Or,Math.ceil(t/Math.max(1,e)))<<20,fn=30000,Ye=new Set,j=new Set,yt=new le(64,(e)=>e.then((t)=>setTimeout(()=>t?.close(),0),()=>{return})),mn=(e,t="auto")=>{let n=yt.get(e);if(n)return n;let r=(async()=>{let o=ht(e);if(o){let i=await o;return i&&createImageBitmap(new Blob([i]))}let s={priority:t,signal:AbortSignal.timeout(fn)},a=await fetch(e,oe(e,s));if(a.status===404||a.status===204)return;if(!a.ok)throw ie(e,a.status);return createImageBitmap(await a.blob())})();return r.catch(()=>yt.delete(e)),yt.set(e,r),r},cn=(e,t)=>(Ae.weigh(e,nn(t)),t),ee=(e,t="auto")=>{let n=Ae.get(e);if(n)return n;let r=(async()=>{let o=ht(e);if(o){let s=await o;return s&&cn(e,bt(s))}for(let s=0;;s+=1){let a={priority:t,signal:AbortSignal.timeout(fn)},i=await fetch(e,oe(e,a));if(i.status===404||i.status===204)return;if(i.ok)return cn(e,bt(new Uint8Array(await i.arrayBuffer())));if(s>=2)throw ie(e,i.status);await new Promise((c)=>setTimeout(c,400*(s+1)))}})();return r.catch(()=>Ae.delete(e)),Ae.set(e,r),r},pn=(e,t,n,r)=>{let o=xe(t-1,0,e.maxzoom),s=t-o,a=2**Math.max(0,s),[i,c]=s>=0?[Math.floor(n/a),Math.floor(r/a)]:[n,r],l=G(e.tiles,o,i,c),u=1/a;return{url:l,vz:o,vx:i,vy:c,part:u,ox:n%a*u,oy:r%a*u}},U=(e,t,n,r,o)=>{let s=e[t]?.[n];if(s===void 0)return o;let a=Array.isArray(s)&&!Re(s)?s:ae(s,r);return a===void 0||a===null?o:a},pe=(e,t)=>{let n=ce(e)??[0,0,0,1];return Je([n[0],n[1],n[2],n[3]*t])},Pe=(e,t)=>{if(e.layout?.visibility==="none")return!1;return t>=(e.minzoom??0)&&t<(e.maxzoom??24)},H=(e,t,n,r,o,s)=>{let a=2**e;return[Et((t+o/r)/a),It((n+s/r)/a)]};var Pr=300,dn=(e,t,n)=>{let r=Boolean(U(e,"layout",`${t}-allow-overlap`,n,!1)),o=Boolean(U(e,"layout",`${t}-ignore-placement`,n,!1));if(r&&o)return!0;if(r)return"allow";return o?"ignore":!1},bn=(e,t)=>Array.isArray(e)?[Number(e[0]??t[0]),Number(e[1]??t[1])]:t,Ur=(e)=>{let t=(Array.isArray(e)?e:[e]).map((a)=>Number(a)||0),[n=0,r=n,o=n,s=r]=t;return[n,r,o,s]},Cr=(e,t)=>{if(t==="uppercase")return e.toUpperCase();if(t==="lowercase")return e.toLowerCase();return e},Me=(e,t)=>{let n=0;for(let a=2;a+1<e.length;a+=2)n+=Math.hypot((e[a]??0)-(e[a-2]??0),(e[a+1]??0)-(e[a-1]??0));let r=[];if(!(n>0)||!(t>0))return r;let o=Math.min(t/2,n/2),s=0;for(let a=2;a+1<e.length;a+=2){let[i,c,l,u]=[e[a-2]??0,e[a-1]??0,e[a]??0,e[a+1]??0],d=Math.hypot(l-i,u-c);while(d>0&&o<=s+d){let f=(o-s)/d;r.push([i+(l-i)*f,c+(u-c)*f,i,c,l,u,o]),o+=t}s+=d}return r},Ge=(e,t,n)=>{let[r=0,o=0,s=0,a=0,i=0,c=0]=e,l=Math.hypot(i-s,c-a)||1,u=t%2===0?1:-1,[d,f]=[-(c-a)/l*u,(i-s)/l*u];return[r+d*n,o+f*n,Math.atan2(-d,f)*180/Math.PI]},Wr=(e,t,n)=>{let r=[],o=0;for(let s=2;s+1<e.length;s+=2){let[a,i,c,l]=[e[s-2]??0,e[s-1]??0,e[s]??0,e[s+1]??0],u=Math.hypot(c-a,l-i),[d,f]=[o,o+u];if(o=f,u<=0||f<t||d>n)continue;let p=(A)=>[a+(c-a)*(A-d)/u,i+(l-i)*(A-d)/u];if(r.length===0)r.push(...p(Math.max(t,d)));r.push(...p(Math.min(n,f)))}return r},Br=(e,t,n,r,o)=>{let s=U(e,"layout","icon-rotation-alignment",n,"auto"),a=String(U(e,"layout","icon-text-fit",n,"none")),i=U(e,"layout","icon-text-fit-padding",n,[0,0,0,0]);return{image:t,size:me(e.layout?.["icon-size"])?Number(U(e,"layout","icon-size",n,1)):o(e),anchor:String(U(e,"layout","icon-anchor",n,"center")),offset:bn(U(e,"layout","icon-offset",n,[0,0]),[0,0]),rotate:Number(U(e,"layout","icon-rotate",n,0))||0,alignment:s==="map"||s==="auto"&&r==="line"?"map":"viewport",overlap:dn(e,"icon",n),optional:Boolean(U(e,"layout","icon-optional",n,!1)),fit:a==="width"||a==="height"||a==="both"?a:"none",padding:Ur(i),color:String(U(e,"paint","icon-color",n,"#000")),opacity:Number(U(e,"paint","icon-opacity",n,1))}},Ke=16,Dr=(e,t,n)=>{let r=[],o=new Map,s=4096;e.layers.forEach((c)=>{if(c.type!=="fill-extrusion"||!Pe(c,n))return;let l=t.get(c["source-layer"]??"");if(!l)return;s=l.extent;for(let u of l.features){let d=Z(u,n);if(u.type!==3||!Q(c.filter,d))continue;let f=Number(U(c,"paint","fill-extrusion-height",d,0));if(!(f>0))continue;let p=[1/0,1/0,-1/0,-1/0];for(let A of u.geometry)for(let y=0;y+1<A.length;y+=2){let[w,m]=[A[y]??0,A[y+1]??0];p[0]=Math.min(p[0],w),p[1]=Math.min(p[1],m),p[2]=Math.max(p[2],w),p[3]=Math.max(p[3],m)}r.push({rings:u.geometry,height:f,box:p})}});let a=(c)=>Math.max(0,Math.min(Ke-1,Math.floor(c/s*Ke)));r.forEach(({box:c},l)=>{for(let u=a(c[1]);u<=a(c[3]);u++)for(let d=a(c[0]);d<=a(c[2]);d++){let f=u*Ke+d,p=o.get(f);if(p)p.push(l);else o.set(f,[l])}});let i=(c,l,u)=>{let d=!1;for(let f of c)for(let p=0,A=f.length-2;p+1<f.length;A=p,p+=2){let[y,w,m,M]=[f[p]??0,f[p+1]??0,f[A]??0,f[A+1]??0];if(w>u!==M>u&&l<(m-y)*(u-w)/(M-w)+y)d=!d}return d};return(c,l)=>(o.get(a(l)*Ke+a(c))??[]).reduce((u,d)=>{let f=r[d];return f&&i(f.rings,c,l)?Math.max(u??0,f.height):u},void 0)},hn=async(e,t)=>{let{z:n,x:r,y:o,id:s,priority:a,zoom:i=n,roofs:c=!1}=t,l=G(e.tiles,n,r,o),u=await ee(l,a);if(!u||j.has(s))return[];let d=[],f=c?Dr(e,u,i):()=>{return},p=new Map,A=(m)=>{let M=p.get(m);if(M!==void 0)return M;let b=m.layout?.["text-size"]??16,x=Re(b)?lt(b):b;return p.set(m,x),x},y=new Map,w=(m)=>{let M=y.get(m);if(M!==void 0)return M;let b=m.layout?.["icon-size"]??1,x=Re(b)?lt(b):b;return y.set(m,x),x};return e.layers.forEach((m,M)=>{let b=m.layout??{};if(m.type!=="symbol"||!Pe(m,i))return;if(b["text-field"]===void 0&&b["icon-image"]===void 0)return;let x=u.get(m["source-layer"]??"");if(!x)return;let T={zoom:i,properties:{},type:"Unknown"},E=U(m,"layout","symbol-placement",T,"point")==="line"?"line":"point",_=E==="line"&&U(m,"layout","text-rotation-alignment",T,"auto")!=="viewport";for(let g of x.features){let h=Z(g,i);if(!Q(m.filter,h))continue;let S=ct(b["text-field"],h).trim(),k=ct(b["icon-image"],h).trim();if(!S&&!k)continue;let v=Cr(S,U(m,"layout","text-transform",h,"none")),R=U(m,"layout","text-font",h,["Noto Sans Regular"]),W=Vt(Array.isArray(R)&&typeof R[0]==="string"?R[0]:"Noto Sans Regular"),B={layer:M,text:v,font:W,size:me(m.layout?.["text-size"])?Number(U(m,"layout","text-size",h,16)):A(m),color:String(U(m,"paint","text-color",h,"#000")),haloColor:String(U(m,"paint","text-halo-color",h,"rgba(0,0,0,0)")),haloWidth:Number(U(m,"paint","text-halo-width",h,0)),anchor:String(U(m,"layout","text-anchor",h,"center")),offset:bn(U(m,"layout","text-offset",h,[0,0]),[0,0]),maxWidth:Number(U(m,"layout","text-max-width",h,10)),lineHeight:Number(U(m,"layout","text-line-height",h,1.2)),overlap:dn(m,"text",h),..._?{textAlong:_}:{},...U(m,"layout","text-optional",h,!1)?{textOptional:!0}:{},...k?{icon:Br(m,k,h,E,w)}:{}};if(g.type===1)for(let O of g.geometry)for(let P=0;P+1<O.length;P+=2){let[I,L]=[O[P]??0,O[P+1]??0];if(I<0||L<0||I>=x.extent||L>=x.extent)continue;let[F,C]=H(n,r,o,x.extent,I,L),V=f(I,L);d.push({...B,lon:F,lat:C,...V===void 0?{}:{height:V}})}else if(!v&&E==="line"){let O=Number(U(m,"layout","symbol-spacing",h,250))*x.extent/(512*2**(i-n));for(let P of g.geometry)for(let[I=0,L=0,F=0,C=0,V=0,J=0]of Me(P,Math.max(O,1))){if(I<0||L<0||I>=x.extent||L>=x.extent)continue;let[z,te]=H(n,r,o,x.extent,I,L),[K,ne]=H(n,r,o,x.extent,V,J),[X,re]=H(n,r,o,x.extent,F,C);d.push({...B,lon:z,lat:te,along:[K-X,ne-re]})}}else if(v&&_){let O=x.extent/(512*2**(i-n)),P=Number(U(m,"layout","symbol-spacing",h,250))*O;for(let I of g.geometry){let L=0;for(let F=2;F+1<I.length;F+=2)L+=Math.hypot((I[F]??0)-(I[F-2]??0),(I[F+1]??0)-(I[F-1]??0));if(L<x.extent/32)continue;for(let[F=0,C=0,V=0,J=0,z=0,te=0,K=0]of Me(I,Math.max(P,1))){if(F<0||C<0||F>=x.extent||C>=x.extent)continue;let ne=Math.min(K,L-K,Pr*O),X=Wr(I,K-ne,K+ne),re=[];for(let Ve=0;Ve+1<X.length;Ve+=2)re.push(...H(n,r,o,x.extent,X[Ve]??0,X[Ve+1]??0));let[Se,ke]=H(n,r,o,x.extent,F,C),[nt,Hn]=H(n,r,o,x.extent,z,te),[Jn,jn]=H(n,r,o,x.extent,V,J);d.push({...B,lon:Se,lat:ke,along:[nt-Jn,Hn-jn],...re.length>=4?{path:re}:{}})}}}else{let O,P=0;for(let L of g.geometry){let F=0;for(let C=2;C+1<L.length;C+=2)F+=Math.hypot((L[C]??0)-(L[C-2]??0),(L[C+1]??0)-(L[C-1]??0));if(F>P)P=F,O=L}if(!O||P<x.extent/32)continue;let I=P/2;for(let L=2;L+1<O.length;L+=2){let[F,C,V,J]=[O[L-2]??0,O[L-1]??0,O[L]??0,O[L+1]??0],z=Math.hypot(V-F,J-C);if(z>=I&&z>0){let[te,K]=[F+(V-F)*I/z,C+(J-C)*I/z];if(te<0||K<0||te>=x.extent||K>=x.extent)break;let[ne,X]=H(n,r,o,x.extent,te,K),[re,Se]=H(n,r,o,x.extent,V,J),[ke,nt]=H(n,r,o,x.extent,F,C);d.push({...B,lon:ne,lat:X,...E==="line"?{along:[re-ke,Se-nt]}:{}});break}I-=z}}}}),d};var yn=(e)=>{let t=e.leaf_type,n=typeof e.nature==="string"?e.nature:"";if(t==="needleleaved"||/conif/i.test(n))return 1;if(t==="broadleaved"||/feuillu/i.test(n))return 0;if(t==="mixed"||/mixte/i.test(n))return 0.5;if(e.class==="wood")return e.subclass==="forest"?0.35:0.15;return 0};var Ze=(e,t)=>{let n=e.length/ye,r=n>t?t/n:1,o=[];for(let s=0;s<n;s+=1)if(r>=1||(e[s*ye+Xt]??0)<r)o.push(...e.slice(s*ye,(s+1)*ye));return Float64Array.from(o)},se=(e,t,n,r)=>{let o=Math.imul(e^2654435769,2246822507)^Math.imul(t^3266489909,668265263);return o=Math.imul(o^o>>>15^Math.imul(n,374761393),739982445),o=Math.imul(o^o>>>13^Math.imul(r,695872825),695872825),((o^o>>>16)>>>0)/4294967296},ge=(e,t,n)=>e.reduce((r,o)=>{let s=o.length/2,a=0;for(let i=0,c=s-1;i<s;c=i,i+=1){let[l,u,d,f]=[o[i*2]??0,o[i*2+1]??0,o[c*2]??0,o[c*2+1]??0];if(u>n!==f>n&&t<(d-l)*(n-u)/(f-u)+l)a+=1}return a%2===1?!r:r},!1),Vr=(e,t,n,r,o=Number.POSITIVE_INFINITY)=>{let s=e[0]??[],a=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(let T=0;T+1<s.length;T+=2){let[E,_]=[s[T]??0,s[T+1]??0];a[0]=Math.min(a[0]??E,E),a[1]=Math.min(a[1]??_,_),a[2]=Math.max(a[2]??E,E),a[3]=Math.max(a[3]??_,_)}let[i,c]=[Math.max(0,a[0]??0),Math.max(0,a[1]??0)],[l,u]=[Math.min(t,a[2]??0),Math.min(t,a[3]??0)];if(!(n>0)||i>=l||c>=u)return[];let d=(l-i)/n*((u-c)/n),f=d>o?n*Math.sqrt(d/o):n,[p,A,y,w]=[Math.floor(i/f),Math.ceil(l/f),Math.floor(c/f),Math.ceil(u/f)],[m,M,b]=r,x=Math.imul(m+1,16777619)^Math.imul(M,1540483477)^Math.imul(b,461845907);return Array.from({length:Math.max(0,w-y)},(T,E)=>y+E).flatMap((T)=>Array.from({length:Math.max(0,A-p)},(E,_)=>p+_).flatMap((E)=>{let _=(E+se(x,E,T,1))*f,g=(T+se(x,E,T,2))*f;if(_<0||g<0||_>=t||g>=t||!ge(e,_,g))return[];return[[_,g,se(x,E,T,3)]]}))},gn=async(e,t)=>{let{z:n,x:r,y:o,id:s,spacing:a,maxTrees:i,priority:c}=t,l=G(e.tiles,n,r,o),u=await ee(l,c);if(!u||j.has(s))return;let d=_e(n,o),f=[];e.layers.forEach((w,m)=>{let M=a[m]??0,b=u.get(w["source-layer"]??"");if(!b||!(M>0))return;let x=M/d*b.extent;b.features.forEach((T)=>{if(T.type!==3||!Q(w.filter,Z(T,n)))return;let E=yn(T.properties);T.geometry.reduce((g,h)=>{let S=0;for(let k=0;k+1<h.length;k+=2){let v=(k+2)%h.length;S+=(h[k]??0)*(h[v+1]??0)-(h[v]??0)*(h[k+1]??0)}if(S>0)g.push([h]);else if(S<0)g.at(-1)?.push(h);return g},[]).forEach((g)=>{Vr(g,b.extent,x,[n,r,o],i*4).forEach(([h,S,k])=>{f.push([h,S,k,b.extent,E])})})})});let p=f.length>i?i/f.length:1,A=f.filter(([,,w])=>p>=1||se(Math.floor(w*2147483648),n,r,o)<p),y=new Float64Array(A.length*ye);return A.forEach(([w,m,M,b,x],T)=>{let[E,_]=H(n,r,o,b,w,m),g=se(Math.floor(M*2147483648),7,11,13),h=se(Math.floor(M*2147483648),3,5,17)<x?1:0;y.set([E,_,0.75+0.5*M,Qt(M),g,h],T*ye)}),y};var zr={bus_stop:"shelter",waste_basket:"bin",post_box:"postbox",drinking_water:"fountain",bicycle_parking:"rack"},Hr=new Set(["primary","secondary","tertiary","minor","service","trunk"]),Jr=25,wn={street:[24,3.2],path:[18,1.3]},jr=(e)=>e.filter((t)=>t.type===1),xn=async(e,t)=>{let{z:n,x:r,y:o,id:s,maxObjects:a,priority:i}=t,c=G(e.tiles,n,r,o),l=await ee(c,i);if(!l||j.has(s))return;let u=l.get("poi"),d=l.get("transportation"),f=d?.extent??u?.extent??4096,p=f/_e(n,o),A=(d?.features??[]).filter((_)=>_.type===2&&Hr.has(String(_.properties.class))),y=(l.get("landcover")?.features??[]).filter((_)=>_.type===3&&String(_.properties.class)==="grass").map((_)=>{let g=Array.from(_.geometry[0]??[]),h=g.filter((k,v)=>v%2===0),S=g.filter((k,v)=>v%2===1);return{rings:_.geometry,bounds:[Math.min(...h),Math.min(...S),Math.max(...h),Math.max(...S)]}}),w=(_,g)=>y.some(({rings:h,bounds:[S=0,k=0,v=0,R=0]})=>_>=S&&_<=v&&g>=k&&g<=R&&ge(h,_,g)),m=[],M=(_,g,h,S,k)=>{if(_<0||g<0||_>=f||g>=f)return;let[v,R]=H(n,r,o,f,_,g);m.push(v,R,1,h,S,pt.indexOf(k))},b=Jr*p,x=new Map,T=(_,g)=>(_+32768)*65536+g+32768;A.forEach((_)=>{_.geometry.forEach((g)=>{for(let h=2;h+1<g.length;h+=2){let[S,k,v,R]=[g[h-2]??0,g[h-1]??0,g[h]??0,g[h+1]??0],[W,B]=[Math.floor(Math.min(S,v)/b),Math.floor(Math.max(S,v)/b)],[O,P]=[Math.floor(Math.min(k,R)/b),Math.floor(Math.max(k,R)/b)];for(let I=W;I<=B;I+=1)for(let L=O;L<=P;L+=1){let F=x.get(T(I,L))??[];F.push(S,k,v,R),x.set(T(I,L),F)}}})});let E=(_,g,h)=>{let[S,k,v]=[b*b,0,0],[R,W]=[Math.floor(_/b),Math.floor(g/b)];for(let B=R-1;B<=R+1;B+=1)for(let O=W-1;O<=W+1;O+=1){let P=x.get(T(B,O))??[];for(let I=0;I+3<P.length;I+=4){let[L,F,C,V]=[P[I]??0,P[I+1]??0,P[I+2]??0,P[I+3]??0],[J,z]=[C-L,V-F],te=J*J+z*z,K=te>0?Math.max(0,Math.min(1,((_-L)*J+(g-F)*z)/te)):0,[ne,X]=[L+K*J-_,F+K*z-g],re=ne*ne+X*X;if(re<S)[S,k,v]=[re,ne,X]}}if(k===0&&v===0)return h;return Math.atan2(k,-v)*180/Math.PI};return jr(u?.features??[]).forEach((_)=>{let g=zr[String(_.properties.subclass)];if(!g)return;_.geometry.forEach((h)=>{let[S,k]=[h[0]??0,h[1]??0],v=se(Math.floor(S),Math.floor(k),pt.indexOf(g),31);M(S,k,E(S,k,v*360),v,g)})}),(d?.features??[]).forEach((_)=>{let g=String(_.properties.subclass),h=String(_.properties.class)==="path"&&g==="pedestrian",S=String(_.properties.class)==="path"&&(g==="footway"||g==="path");if(_.type!==2||!(h||S))return;let[k,v]=h?wn.street:wn.path;_.geometry.forEach((R)=>{Me(R,k*p).forEach((W,B)=>{let[O=0,P=0,,,,,I=0]=W;if(S&&!w(O,P))return;let L=se(Math.floor(O),Math.floor(P),Math.floor(I),37);M(...Ge(W,B,v*p),L,"bench")})})}),Ze(m,a)};var _n={flat:1,skillion:1,hipped:2,"half-hipped":2,side_hipped:2,dome:2,onion:2,round:2,gabled:3,saltbox:3,pyramidal:4,cone:4,mansard:5,gambrel:5},qr=255,An=(e)=>e==="generated"?qr:_n[e],Mn=(e,t)=>be(e)?t.map((n)=>e[n]).find((n)=>n!==void 0):void 0,Sn=(e,t)=>{let n=Mn(e,["roof:shape","roof_shape"]);if(t==="flat")return;if(typeof n==="string"&&_n[n]!==void 0)return n;return t==="generated"?"generated":void 0},kn=(e)=>Number(Mn(e,["roof:height","roof_height"])??Number.NaN);var wt=32,q={color:0,second:4,size:8,size2:16,range:24,blur:26,landmark:26,patternRatio:27,fillPattern:28,linePattern:29};class De{static __wrap(e){let t=Object.create(De.prototype);return t.__wbg_ptr=e,vn.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,vn.unregister(this),e}free(){let e=this.__destroy_into_raw();N.__wbg_tessellatedtile_free(e,0)}blockIndices(){return N.tessellatedtile_blockIndices(this.__wbg_ptr)}blockRanges(){let e=N.tessellatedtile_blockRanges(this.__wbg_ptr);var t=Qe(e[0],e[1]).slice();return N.__wbindgen_free(e[0],e[1]*4,4),t}blocks(){return N.tessellatedtile_blocks(this.__wbg_ptr)}bounds(){let e=N.tessellatedtile_bounds(this.__wbg_ptr);var t=Kr(e[0],e[1]).slice();return N.__wbindgen_free(e[0],e[1]*8,8),t}fillRanges(){let e=N.tessellatedtile_fillRanges(this.__wbg_ptr);var t=Qe(e[0],e[1]).slice();return N.__wbindgen_free(e[0],e[1]*4,4),t}indices(){return N.tessellatedtile_indices(this.__wbg_ptr)}lineRanges(){let e=N.tessellatedtile_lineRanges(this.__wbg_ptr);var t=Qe(e[0],e[1]).slice();return N.__wbindgen_free(e[0],e[1]*4,4),t}lineTable(){return N.tessellatedtile_lineTable(this.__wbg_ptr)}pieces(){return N.tessellatedtile_pieces(this.__wbg_ptr)}prism(){return N.tessellatedtile_prism(this.__wbg_ptr)!==0}vertices(){return N.tessellatedtile_vertices(this.__wbg_ptr)}}if(Symbol.dispose)De.prototype[Symbol.dispose]=De.prototype.free;function Tn(e,t,n,r,o,s,a,i,c,l,u,d,f,p,A,y,w){let m=Xe(e,N.__wbindgen_malloc),M=Y,b=de(t,N.__wbindgen_malloc),x=Y,T=de(n,N.__wbindgen_malloc),E=Y,_=de(r,N.__wbindgen_malloc),g=Y,h=de(o,N.__wbindgen_malloc),S=Y,k=Xe(s,N.__wbindgen_malloc),v=Y,R=de(a,N.__wbindgen_malloc),W=Y,B=de(i,N.__wbindgen_malloc),O=Y,P=de(c,N.__wbindgen_malloc),I=Y,L=Rn(l,N.__wbindgen_malloc),F=Y,C=Rn(u,N.__wbindgen_malloc),V=Y,J=Xr(d,N.__wbindgen_malloc),z=Y,te=Xe(f,N.__wbindgen_malloc),K=Y,ne=de(p,N.__wbindgen_malloc),X=Y,re=Xe(w,N.__wbindgen_malloc),Se=Y,ke=N.tessellateVectorTile(m,M,b,x,T,E,_,g,h,S,k,v,R,W,B,O,P,I,L,F,C,V,J,z,te,K,ne,X,A,y,re,Se);return De.__wrap(ke)}function $r(){return{__proto__:null,"./isard_tess_bg.js":{__proto__:null,__wbg___wbindgen_throw_41e9ee4f547fc59a:function(t,n){throw Error(Zr(t,n))},__wbg_new_from_slice_37a3c3a194266cb8:function(t,n){return new Uint32Array(Qe(t,n))},__wbg_new_from_slice_9a868026ffa4208a:function(t,n){return new Uint8Array(Gr(t,n))},__wbg_new_from_slice_ca6ad97db1f4779a:function(t,n){return new Float32Array(Yr(t,n))},__wbindgen_init_externref_table:function(){let t=N.__wbindgen_externrefs,n=t.grow(4);t.set(0,void 0),t.set(n+0,void 0),t.set(n+1,null),t.set(n+2,!0),t.set(n+3,!1)}}}}var vn=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e)=>N.__wbg_tessellatedtile_free(e,1));function Yr(e,t){return e=e>>>0,En().subarray(e/4,e/4+t)}function Kr(e,t){return e=e>>>0,In().subarray(e/8,e/8+t)}function Qe(e,t){return e=e>>>0,Ln().subarray(e/4,e/4+t)}function Gr(e,t){return e=e>>>0,_t().subarray(e/1,e/1+t)}var Ue=null;function En(){if(Ue===null||Ue.byteLength===0)Ue=new Float32Array(N.memory.buffer);return Ue}var Ce=null;function In(){if(Ce===null||Ce.byteLength===0)Ce=new Float64Array(N.memory.buffer);return Ce}function Zr(e,t){return eo(e>>>0,t)}var We=null;function Ln(){if(We===null||We.byteLength===0)We=new Uint32Array(N.memory.buffer);return We}var Be=null;function _t(){if(Be===null||Be.byteLength===0)Be=new Uint8Array(N.memory.buffer);return Be}function de(e,t){let n=t(e.length*4,4)>>>0;return Ln().set(e,n/4),Y=e.length,n}function Rn(e,t){let n=t(e.length*1,1)>>>0;return _t().set(e,n/1),Y=e.length,n}function Xr(e,t){let n=t(e.length*4,4)>>>0;return En().set(e,n/4),Y=e.length,n}function Xe(e,t){let n=t(e.length*8,8)>>>0;return In().set(e,n/8),Y=e.length,n}var et=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});et.decode();var Qr=2146435072,xt=0;function eo(e,t){if(xt+=t,xt>=Qr)et=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),et.decode(),xt=t;return et.decode(_t().subarray(e,e+t))}var Y=0,to,no,N;function ro(e,t){return no=e,N=e.exports,to=t,Ue=null,Ce=null,We=null,Be=null,N.__wbindgen_start(),N}async function oo(e,t){if(typeof Response==="function"&&e instanceof Response){if(!e.ok)throw Error(`failed to fetch Wasm: ${e.status} ${e.statusText} fetching '${e.url}'`);if(typeof WebAssembly.instantiateStreaming==="function")try{return await WebAssembly.instantiateStreaming(e,t)}catch(o){if(n(e.type)&&e.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",o);else throw o}let r=await e.arrayBuffer();return await WebAssembly.instantiate(r,t)}else{let r=await WebAssembly.instantiate(e,t);if(r instanceof WebAssembly.Instance)return{instance:r,module:e};else return r}function n(r){switch(r){case"basic":case"cors":case"default":return!0}return!1}}async function Fn(e){if(N!==void 0)return N;if(e!==void 0)if(Object.getPrototypeOf(e)===Object.prototype)({module_or_path:e}=e);else console.warn("using deprecated parameters for the initialization function; pass a single object instead");if(e===void 0)e=new URL("isard_tess_bg.wasm",import.meta.url);let t=$r();if(typeof e==="string"||typeof Request==="function"&&e instanceof Request||typeof URL==="function"&&e instanceof URL)e=fetch(e);let{instance:n,module:r}=await oo(await e,t);return ro(n,r)}var tt=async(e,t)=>{let{z:n,x:r,y:o,id:s,priority:a}=t,i=G(e.tiles,n,r,o),c=await ee(i,a),l={points:[],ringStart:[],polygonStart:[],feature:[]},u=[];if(!c||j.has(s))return;let d=new Set,f=2**n;return e.layers.forEach((p)=>{let A=c.get(p["source-layer"]??"");if(!A)return;A.features.forEach((y)=>{if(y.type!==3||d.has(y)||!Q(p.filter,Z(y,n)))return;d.add(y);let w=u.length;u.push(y.properties),y.geometry.forEach((m)=>{let M=0;for(let b=0;b+1<m.length;b+=2){let x=(b+2)%m.length;M+=(m[b]??0)*(m[x+1]??0)-(m[x]??0)*(m[b+1]??0)}if(M===0)return;if(M>0||l.polygonStart.length===0||l.feature.at(-1)!==w)l.polygonStart.push(l.ringStart.length),l.feature.push(w);l.ringStart.push(l.points.length/2);for(let b=0;b+1<m.length;b+=2)l.points.push((r+(m[b]??0)/A.extent)/f,(o+(m[b+1]??0)/A.extent)/f)})})}),l.ringStart.push(l.points.length/2),l.polygonStart.push(l.ringStart.length-1),{arrays:{points:Float64Array.from(l.points),ringStart:Uint32Array.from(l.ringStart),polygonStart:Uint32Array.from(l.polygonStart),feature:Uint32Array.from(l.feature)},properties:u}},so=new Set(["theatre","museum","place_of_worship","castle","monument","attraction","town_hall"]),io=(e)=>(e?.get("poi")?.features??[]).filter((t)=>t.type===1&&so.has(String(t.properties.class))).flatMap((t)=>t.geometry.flatMap((n)=>Array.from(n))),Nn=(e)=>{let[t,n,r,o]=[1/0,1/0,-1/0,-1/0];for(let s=0;s+1<e.length;s+=2)[t,n]=[Math.min(t,e[s]??0),Math.min(n,e[s+1]??0)],[r,o]=[Math.max(r,e[s]??0),Math.max(o,e[s+1]??0)];return[t,n,r,o]},ao=(e,t)=>{if(t.length===0)return!1;let[n,r,o,s]=Nn(e[0]??[]);for(let a=0;a+1<t.length;a+=2){let[i,c]=[t[a]??0,t[a+1]??0];if(i>=n&&i<=o&&c>=r&&c<=s&&ge(e,i,c))return!0}return!1},co=(e)=>{let t=e.length>2&&e[0]===e[e.length-2]&&e[1]===e[e.length-1],n=Math.max(1,e.length/2-(t?1:0)),[r,o]=[0,0];for(let s=0;s<n;s+=1)[r,o]=[r+(e[s*2]??0),o+(e[s*2+1]??0)];return[r/n,o/n]},lo=(e,t)=>{let n=e.filter((a)=>a.type===3),r=n.filter((a)=>ao(a.geometry,t)),o=new Set(r);if(r.length===0)return o;let s=n.map((a)=>{let i=a.geometry[0]??[];return{f:a,box:Nn(i),middle:co(i)}});return s.filter(({f:a})=>o.has(a)).forEach((a)=>{let[i,c,l,u]=a.box,d=a.f.geometry;s.forEach(({f,box:[p,A,y,w],middle:m})=>{if(o.has(f)||y<i||p>l||w<c||A>u)return;if(ge(d,...m)||ge(f.geometry,...a.middle))o.add(f)})}),o},uo={line:(e)=>e!==1,circle:(e)=>e===1,fill:(e)=>e===3,extrusion:(e)=>e===3},fo=(e,t)=>{let n=Sn(e,t);return[n===void 0?0:An(n)??0,kn(e)]},mo=24,po=(e,t,n,r)=>{if(!at(e.filter))return Q(e.filter,Z(t,n))?[0,0]:void 0;let o,s=0;for(let a=n-1;a<=r;a+=1)if(Q(e.filter,Z(t,a)))o??=a,s=a+1;else if(o!==void 0)break;return o===void 0?void 0:[o<=n-1?0:o,s>r?99:s]},bo=(e,t)=>{let n=Array.from(e),r=[[0,0,(o)=>o>=0],[0,t,(o)=>o<=t],[1,0,(o)=>o>=0],[1,t,(o)=>o<=t]];for(let[o,s,a]of r){let i=[],c=n.length/2;for(let l=0;l<c;l+=1){let[u,d]=[n[l*2]??0,n[l*2+1]??0],f=(l+1)%c,[p,A]=[n[f*2]??0,n[f*2+1]??0],[y,w]=o===0?[u,p]:[d,A];if(a(y))i.push(u,d);if(a(y)!==a(w)){let m=(s-y)/(w-y);i.push(o===0?s:u+(p-u)*m,o===0?d+(A-d)*m:s)}}if(n=i,n.length===0)break}return n},ho=0.00048828125,yo=(e,t)=>{let n=e.length/2;if(n<=2)return Array.from(e);let r=new Uint8Array(n),o=[[0,n-1]],s=t*t;r[0]=1,r[n-1]=1;while(o.length>0){let[a,i]=o.pop()??[0,0],[c,l,u,d]=[e[a*2]??0,e[a*2+1]??0,e[i*2]??0,e[i*2+1]??0],[f,p]=[u-c,d-l],A=f*f+p*p,[y,w]=[-1,s];for(let m=a+1;m<i;m+=1){let[M,b]=[(e[m*2]??0)-c,(e[m*2+1]??0)-l],x=A>0?Math.max(0,Math.min(1,(M*f+b*p)/A)):0,T=(M-x*f)**2+(b-x*p)**2;if(T>w)[y,w]=[m,T]}if(y>=0)r[y]=1,o.push([a,y],[y,i])}return Array.from(e).filter((a,i)=>r[i>>1]===1)},go=(e,t)=>{let n=[],r=[],o=()=>{if(r.length>=4)n.push(r);r=[]};for(let s=2;s+1<e.length;s+=2){let[a,i,c,l]=[e[s-2]??0,e[s-1]??0,e[s]??0,e[s+1]??0],[u,d]=[c-a,l-i],[f,p]=[0,1];for(let[A,y]of[[-u,a],[u,t-a],[-d,i],[d,t-i]])if(A===0){if(y<0)p=-1}else if(A<0)f=Math.max(f,y/A);else p=Math.min(p,y/A);if(f>p){o();continue}if(r.length===0||f>0)o(),r.push(a+u*f,i+d*f);if(r.push(a+u*p,i+d*p),p<1)o()}return o(),n},wo=(e,t)=>e>=t?[e-0.5,e+1,e+3,e+6]:[e-0.5,e-0.16666666666666666,e+0.16666666666666666,e+0.5],xo=(e,t,n,r,o)=>{let s=2**n,[a,i]=[r*t,o*t],c=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];e.forEach((p)=>{for(let A=0;A+1<p.length;A+=2){let[y,w]=[(p[A]??0)*s-a,(p[A+1]??0)*s-i];c[0]=Math.min(c[0]??y,y),c[1]=Math.min(c[1]??w,w),c[2]=Math.max(c[2]??y,y),c[3]=Math.max(c[3]??w,w)}});let[l=0,u=0,d=0,f=0]=c;if(d<=0||f<=0||l>=t||u>=t)return;return e.map((p)=>Array.from(p,(A,y)=>A*s-(y%2===0?a:i)))},_o=(e)=>{let t=[],n=[],r=[],o=[];return{add:(i,c,l,u,d,f=!1)=>{let p=(b,x,T)=>U(c,"paint",b,{...l,zoom:T},x),A=`${c.type}-opacity`,y=me(c.paint?.[A]),w=(b)=>{let[x,T,E,_]=ce(p(f?"fill-outline-color":`${c.type}-color`,"#000",b))??[0,0,0,1];return[x,T,E,_*(y?Number(p(A,1,b)):1)]},m=Array(wt).fill(0),M=e[3]-e[0]>1.5?e[1]:e[3];if(m.splice(q.color,8,...w(e[0]),...w(M)),m.splice(q.range,2,...d),!f&&["fill","background","line","fill-extrusion"].includes(c.type)){let b=p(`${c.type}-pattern`,"",(e[0]+M)/2);if(typeof b==="string"&&b){let x=n.indexOf(b);m[c.type==="fill"||c.type==="background"?q.fillPattern:q.linePattern]=(x>=0?x:n.push(b)-1)+1}}if(c.type==="circle"){let b=(e[0]+M)/2,[x,T,E,_]=ce(p("circle-stroke-color","#000",b))??[0,0,0,1];m.splice(q.color,8,...w(b),x,T,E,_*Number(p("circle-stroke-opacity",1,b)))}return e.forEach((b,x)=>{if(m[q.size+x]=b,f){m[q.size+4+x]=1;return}if(c.type==="circle"){m[q.size+4+x]=Math.max(0,Number(p("circle-radius",5,b))||0),m[q.size2+x]=b,m[q.size2+4+x]=Math.max(0,Number(p("circle-stroke-width",0,b))||0);return}if(c.type==="fill-extrusion"){m[q.size+4+x]=Math.max(0,Number(p("fill-extrusion-height",0,b))||0),m[q.size2+x]=b,m[q.size2+4+x]=Math.max(0,Number(p("fill-extrusion-base",0,b))||0);return}if(c.type!=="line")return;if(x===0)m[q.blur]=Math.max(0,Number(p("line-blur",0,(e[0]+M)/2))||0);let T=Number(p("line-width",1,b)),E=Number(p("line-gap-width",0,b));m[q.size+4+x]=Math.max(0,E>0?E+2*T:T),m[q.size2+x]=b,m[q.size2+4+x]=Number(p("line-offset",0,b))||0}),t.push(...m),r.push(u),o.push(i),r.length-1},landmark:(i)=>{t[i*wt+q.landmark]=1},styles:t,patterns:n,properties:r,sublayer:o}},Ao=(e,t,n)=>{let r={points:[],ringStart:[],polygonStart:[],feature:[],roofs:[],roofHeights:[],roofOutlines:[],roofOutlineStart:[]},o={points:[],start:[],feature:[]},s={points:[],feature:[]},a={fill:[],line:[],circle:[]},i=(u,d,f)=>[(e+u/f)/n,(t+d/f)/n],c=(u,d,f)=>{r.polygonStart.push(r.ringStart.length),r.feature.push(u),r.roofs.push(d),r.roofHeights.push(f),r.roofOutlineStart.push(r.roofOutlines.length/2)},l=()=>{a.fill.push(r.polygonStart.length),a.line.push(o.start.length),a.circle.push(s.feature.length)};return{sublayer:l,background:(u)=>{c(u,0,Number.NaN),r.ringStart.push(r.points.length/2),r.points.push(e/n,t/n,(e+1)/n,t/n,(e+1)/n,(t+1)/n,e/n,(t+1)/n)},circles:(u,d,f)=>{u.forEach((p)=>{for(let A=0;A+1<p.length;A+=2){let[y=0,w=0]=[p[A],p[A+1]];if(y<0||w<0||y>=f||w>=f)continue;s.points.push(...i(y,w,f)),s.feature.push(d)}})},lines:(u,d,f,p)=>{u.forEach((A)=>{let y=d&&A.length>=2?[...Array.from(A),A[0]??0,A[1]??0]:A;go(y,p).forEach((w)=>{let m=yo(w,p*ho);o.start.push(o.points.length/2),o.feature.push(f);for(let M=0;M+1<m.length;M+=2)o.points.push(...i(m[M]??0,m[M+1]??0,p))})})},polygons:(u,d,[f,p],A)=>{let y=!1;u.forEach((w)=>{let m=0;for(let b=0;b+1<w.length;b+=2){let x=(b+2)%w.length;m+=(w[b]??0)*(w[x+1]??0)-(w[x]??0)*(w[b+1]??0)}if(m===0)return;if(m<0&&!y)return;let M=bo(w,A);if(m>0)y=M.length>=6;if(M.length<6)return;if(m>0){if(c(d,f,p),f>1&&Array.from(w).some((b)=>b<0||b>A))for(let b=0;b+1<w.length;b+=2)r.roofOutlines.push(...i(w[b]??0,w[b+1]??0,A))}r.ringStart.push(r.points.length/2);for(let b=0;b+1<M.length;b+=2)r.points.push(...i(M[b]??0,M[b+1]??0,A))})},done:()=>(l(),r.ringStart.push(r.points.length/2),r.polygonStart.push(r.ringStart.length-1),r.roofOutlineStart.push(r.roofOutlines.length/2),o.start.push(o.points.length/2),{fills:{points:Float64Array.from(r.points),ringStart:Uint32Array.from(r.ringStart),polygonStart:Uint32Array.from(r.polygonStart),feature:Uint32Array.from(r.feature),fillStart:Uint32Array.from(a.fill),roofs:Uint8Array.from(r.roofs),roofHeights:Float32Array.from(r.roofHeights),roofOutlines:Float64Array.from(r.roofOutlines),roofOutlineStart:Uint32Array.from(r.roofOutlineStart),roofMetres:rt((t+0.5)/n)},lines:{points:Float64Array.from(o.points),start:Uint32Array.from(o.start),feature:Uint32Array.from(o.feature),lineStart:Uint32Array.from(a.line)},circles:{points:Float64Array.from(s.points),feature:Uint32Array.from(s.feature),circleStart:Uint32Array.from(a.circle)},tile:Float64Array.of(e/n,t/n,(e+1)/n,(t+1)/n)})}},On=async(e,t,n)=>{let{z:r,x:o,y:s,id:a,priority:i,deepest:c=e.maxzoom,roofs:l="data",covered:u=[]}=t,d=Math.max(0,r-e.maxzoom),[f,p,A]=[r-d,Math.floor(o/2**d),Math.floor(s/2**d)],[y,w]=[o-p*2**d,s-A*2**d],m=await ee(G(e.tiles,f,p,A),i);if(j.has(a))return;let M=io(m),b=new Map,x=(g)=>{let h=b.get(g)??(M.length>0?lo(g,M):new Set);return b.set(g,h),h},T=(g,h)=>{if(u.length===0)return!1;let S=g.geometry[0],[k,v]=[S?.[0]??0,S?.[1]??0],[R,W]=H(f,p,A,h,k,v);for(let B=0;B+3<u.length;B+=4)if(R>=(u[B]??0)&&W>=(u[B+1]??0)&&R<=(u[B+2]??0)){if(W<=(u[B+3]??0))return!0}return!1},E=_o(wo(r,Math.max(c,e.maxzoom))),_=r>=Math.max(c,e.maxzoom)?mo:r;return e.layers.forEach((g,h)=>{n?.sublayer();let S=je(g),k=g.type==="fill"&&g.paint?.["fill-outline-color"]!==void 0&&g.paint?.["fill-antialias"]!==!1;if(!S)return;if(g.type==="background"){let R=E.add(h,g,{zoom:r,properties:{},type:"Unknown"},{},[0,0]);n?.background(R);return}let v=m?.get(g["source-layer"]??"");v?.features.forEach((R)=>{if(!uo[S](R.type))return;if(S==="extrusion"&&T(R,v.extent))return;let W=Z(R,r),B=po(g,R,r,_);if(!B)return;let O=d>0?xo(R.geometry,v.extent,d,y,w):R.geometry;if(!O)return;let P=E.add(h,g,W,R.properties,B),I=k?E.add(h,g,W,R.properties,B,!0):-1;if(S==="extrusion"&&x(v.features).has(R))E.landmark(P);if(!n)return;if(S==="circle"){n.circles(O,P,v.extent);return}if(S==="line"){n.lines(O,R.type===3,P,v.extent);return}if(I>=0)n.lines(O,!0,I,v.extent);let L=S==="extrusion"?fo(R.properties,l):[0,Number.NaN];n.polygons(O,P,L,v.extent)})}),E},Pn=async(e,t)=>{let n=await On(e,t);return n&&{styles:Float32Array.from(n.styles),patterns:n.patterns}},Un=async(e,t)=>{let n=Ao(t.x,t.y,2**t.z),r=await On(e,t,n);if(!r)return;return{...n.done(),styles:Float32Array.from(r.styles),patterns:r.patterns,properties:r.properties,sublayer:Uint16Array.from(r.sublayer)}},we={},Cn=()=>{if(!we.url)return Promise.resolve(!1);let e=we.ready??Fn({module_or_path:we.url}).then(()=>!0,(t)=>(console.warn("isard: the tessellation module failed to load, the main thread does its work",t),!1));return we.ready=e,e},Wn=(e,t,n)=>{let{fills:r,lines:o}=e;try{let s=Tn(r.points,r.ringStart,r.polygonStart,r.feature,r.fillStart,o.points,o.start,o.feature,o.lineStart,t,r.roofs??new Uint8Array,r.roofHeights??new Float32Array,r.roofOutlines??new Float64Array,r.roofOutlineStart??new Uint32Array,r.roofMetres??0,n,e.tile??new Float64Array),a={vertices:s.vertices(),indices:s.indices(),fillRanges:s.fillRanges(),prism:s.prism(),pieces:s.pieces(),lineTable:s.lineTable(),lineRanges:s.lineRanges(),blocks:s.blocks(),blockIndices:s.blockIndices(),blockRanges:s.blockRanges(),bounds:s.bounds()};return s.free(),a}catch(s){console.warn("isard: the tessellation module failed, the main thread does its work",s),we.ready=Promise.resolve(!1);return}};var Mo={primary:8,secondary:7,tertiary:6,minor:5,service:4},Bn=async(e,t)=>{let{z:n,x:r,y:o,id:s,spacing:a,maxLamps:i,priority:c}=t,l=G(e.tiles,n,r,o),u=await ee(l,c);if(!u||j.has(s))return;let d=_e(n,o),f=new Set,p=[];return e.layers.forEach((A)=>{let y=u.get(A["source-layer"]??"");if(!y)return;let w=y.extent/d;y.features.forEach((m)=>{let M=Mo[String(m.properties.class)];if(m.type!==2||M===void 0||f.has(m)||!Q(A.filter,Z(m,n)))return;f.add(m),m.geometry.forEach((b)=>{Me(b,a*w).forEach((x,T)=>{let[E,_,g]=Ge(x,T,M*w);if(E<0||_<0||E>=y.extent||_>=y.extent)return;let[h,S]=H(n,r,o,y.extent,E,_),k=se(Math.floor(E),Math.floor(_),Math.floor(x[6]??0),29);p.push(h,S,1,g,k,0)})})})}),Ze(p,i)};var So=new Set(["butt","round","square"]),ko=new Set(["bevel","miter","round"]),vo=(e)=>So.has(e),Ro=(e)=>ko.has(e),To=(e)=>vo(e)?e:"butt",Eo=(e)=>Ro(e)?e:"miter",Io=(e,t)=>{if(e.patterns.has(t))return e.patterns.get(t);let r=(()=>{let o=gt(e,t);if(!o||!(o.icon.width>0)||!(o.icon.height>0))return;let{icon:s}=o,a=new OffscreenCanvas(s.width,s.height);return a.getContext("2d")?.drawImage(o.image,s.x,s.y,s.width,s.height,0,0,s.width,s.height),a})();return e.patterns.set(t,r),r},At=new Map,Lo=(e)=>{let t=At.get(e)?.pop()??new OffscreenCanvas(e,e),n=t.getContext("2d",{willReadFrequently:!0});if(!n)throw Error("isard: no 2D context");return n.setTransform(1,0,0,1,0,0),n.globalAlpha=1,n.setLineDash([]),n.clearRect(0,0,e,e),{canvas:t,g:n}},Fo=(e)=>{let t=At.get(e.width)??[];if(At.set(e.width,t),t.length<4)t.push(e)},No=(e,t,n)=>{if(n)return Promise.resolve(e.transferToImageBitmap());return createImageBitmap(t.getImageData(0,0,e.width,e.height),{premultiplyAlpha:"none"})},Dn=async(e,t)=>{let{z:n,x:r,y:o,size:s,id:a,priority:i}=t,c=pn(e,n,r,o),l=await ee(c.url,i);if(j.has(a))return;let{canvas:u,g:d}=Lo(s);try{return await Oo(e,c,l,u,d,n,r,o,s,a,i)}finally{Fo(u)}},Oo=async(e,t,n,r,o,s,a,i,c,l,u)=>{let d=Math.max(0,s-1),f=c/256,p=!1,A=!1;for(let y of e.layers){if(!Pe(y,d))continue;let w={zoom:d,properties:{},type:"Unknown"};if(y.type==="background"){let g=U(y,"paint","background-color",w,"#000"),h=Number(U(y,"paint","background-opacity",w,1));if(o.fillStyle=pe(g,h),o.fillRect(0,0,c,c),(ce(g)??[0,0,0,1])[3]*h>=1)A=!0;p=!0;continue}if(y.type==="raster"){let g=y.source===void 0?void 0:e.rasters[y.source];if(!g)continue;let h=xe(s-(g.tileSize>=512?1:0),0,g.maxzoom),S=2**(s-h),k=G(g.tiles,h,Math.floor(a/S),Math.floor(i/S)),v=await mn(k,u);if(j.has(l))return;if(!v)continue;let[R,W]=[v.width/S,v.height/S];o.globalAlpha=Number(U(y,"paint","raster-opacity",w,1)),o.drawImage(v,a%S*R,i%S*W,R,W,0,0,c,c),o.globalAlpha=1,p=!0;continue}let m=n?.get(y["source-layer"]??"");if(!m)continue;let M=c/(m.extent*t.part),[b,x]=[t.ox*m.extent,t.oy*m.extent],T=(g,h)=>{o.beginPath();for(let S of g.geometry){for(let k=0;k+1<S.length;k+=2){let[v,R]=[((S[k]??0)-b)*M,((S[k+1]??0)-x)*M];if(k===0)o.moveTo(v,R);else o.lineTo(v,R)}if(h)o.closePath()}},E=new Map,_=(g,h,S,k)=>{let v=E.get(h),R=v??me(y[g]?.[h]);if(v===void 0)E.set(h,R);return U(y,g,h,R?S:w,k)};for(let g of m.features){let h=Z(g,d);if(!Q(y.filter,h))continue;if(y.type==="fill-extrusion"&&g.type===3)T(g,!0),o.fillStyle=pe(_("paint","fill-extrusion-color",h,"#000"),Number(_("paint","fill-extrusion-opacity",h,1))),o.fill("evenodd"),p=!0;else if(y.type==="fill"&&g.type===3){let S=Number(_("paint","fill-opacity",h,1)),k=_("paint","fill-pattern",h,void 0);T(g,!0);let v=typeof k==="string"?gt(e,k)?.icon:void 0,R=v&&typeof k==="string"&&Io(e,k);if(v&&R){let W=o.createPattern(R,"repeat");if(W)W.setTransform(new DOMMatrix().scale(f/(v.pixelRatio??1))),o.globalAlpha=S,o.fillStyle=W,o.fill("evenodd"),o.globalAlpha=1}else{o.fillStyle=pe(_("paint","fill-color",h,"#000"),S),o.fill("evenodd");let W=_("paint","fill-outline-color",h,void 0);if(W!==void 0)o.strokeStyle=pe(W,S),o.lineWidth=f,o.setLineDash([]),o.stroke()}p=!0}else if(y.type==="line"&&g.type!==1){let S=Number(_("paint","line-width",h,1));if(S<=0)continue;let k=Number(_("paint","line-gap-width",h,0));o.strokeStyle=pe(_("paint","line-color",h,"#000"),Number(_("paint","line-opacity",h,1))),o.lineWidth=(k>0?k+2*S:S)*f,o.lineCap=To(_("layout","line-cap",h,"butt")),o.lineJoin=Eo(_("layout","line-join",h,"miter"));let v=_("paint","line-dasharray",h,void 0);o.setLineDash(Array.isArray(v)?v.map((R)=>Number(R)*S*f):[]),T(g,g.type===3),o.stroke(),p=!0}else if(y.type==="circle"&&g.type===1){let S=Number(_("paint","circle-radius",h,5))*f;o.fillStyle=pe(_("paint","circle-color",h,"#000"),Number(_("paint","circle-opacity",h,1)));let k=Number(_("paint","circle-stroke-width",h,0))*f;o.strokeStyle=pe(_("paint","circle-stroke-color",h,"#000"),Number(_("paint","circle-stroke-opacity",h,1))),o.lineWidth=k;for(let v of g.geometry)for(let R=0;R+1<v.length;R+=2)if(o.beginPath(),o.arc(((v[R]??0)-b)*M,((v[R+1]??0)-x)*M,S,0,2*Math.PI),o.fill(),k>0)o.stroke();p=!0}}}if(!p&&!n)return null;return No(r,o,A)};var Vn=async(e,t)=>{let{z:n,tiles:r,bounds:o,width:s,height:a,iterations:i,module:c,priority:l,id:u}=t,[d,f,p,A]=o,y=[],w=[],m=[],M=2**n;for(let b=0;b+1<r.length;b+=2){let x=r[b]??0,T=(x%M+M)%M,E=(x-T)/M,_=await tt(e,{z:n,x:T,y:r[b+1]??0,id:u,priority:l});if(j.has(u))throw Error("aborted");if(!_)continue;let{points:g,ringStart:h,polygonStart:S}=_.arrays;for(let k=0;k+1<S.length;k++){let[v,R]=[S[k]??0,S[k+1]??0],W=h[v]??0,B=h[R]??0,[O,P,I,L]=[1/0,1/0,-1/0,-1/0];for(let F=W;F<B;F++){let[C,V]=[(g[F*2]??0)+E,g[F*2+1]??0];O=Math.min(O,C),P=Math.min(P,V),I=Math.max(I,C),L=Math.max(L,V)}if(I<d||O>p||L<f||P>A)continue;m.push(w.length);for(let F=v;F<R;F++){w.push(y.length/2);for(let C=h[F]??0;C<(h[F+1]??0);C++)y.push(((g[C*2]??0)+E-d)/(p-d)*s,((g[C*2+1]??0)-f)/(A-f)*a)}}}return w.push(y.length/2),m.push(w.length-1),Gt({points:Float64Array.from(y),ringStart:Uint32Array.from(w),polygonStart:Uint32Array.from(m)},s,a,i,c)};var Mt=new Map,Po={},zn=Rt(),ue=(e,t=[])=>self.postMessage(e,t),Uo=({fills:e,lines:t,circles:n,styles:r,sublayer:o,mesh:s})=>[e.points,e.ringStart,e.polygonStart,e.feature,e.fillStart,e.roofs,e.roofHeights,e.roofOutlines,e.roofOutlineStart,t.points,t.start,t.feature,t.lineStart,n?.points,n?.feature,n?.circleStart,r,o,s?.vertices,s?.indices,s?.fillRanges,s?.pieces,s?.lineTable,s?.lineRanges,s?.blocks,s?.blockIndices,s?.blockRanges,s?.bounds].flatMap((a)=>a?[a.buffer]:[]),Co={render:async(e,t)=>{let n=await Dn(e,t);return n?[{image:n},[n]]:void 0},labels:async(e,t)=>[{labels:await hn(e,t)},[]],polygons:async(e,t)=>{let n=await tt(e,t);if(!n)return;let{points:r,ringStart:o,polygonStart:s,feature:a}=n.arrays;return[{polygons:n},[r.buffer,o.buffer,s.buffer,a.buffer]]},trees:async(e,t)=>{let n=await gn(e,t);return n&&[{trees:n},[n.buffer]]},furniture:async(e,t)=>{let n=await xn(e,t);return n&&[{furniture:n},[n.buffer]]},lamps:async(e,t)=>{let n=await Bn(e,t);return n&&[{lamps:n},[n.buffer]]},street:async(e,t)=>{let n=await Vn(e,t);return[{street:n},[n.eastU,n.eastV,n.northU,n.northV].map((r)=>r.buffer)]},vectors:async(e,t)=>{if(t.styles){let a=await Pn(e,t);return a&&[a,[a.styles.buffer]]}let n=await Un(e,t);if(!n)return;let r=Uint8Array.from(e.layers,(a)=>je(a)==="extrusion"?1:0),o=await Cn()?Wn(n,r,t.prism===!0):void 0,s=o?{...n,mesh:o}:n;return[{vectors:s},Uo(s)]}},Wo=(e,t,n)=>Co[t](e,n);self.onmessage=async({data:e})=>{if(e.type==="headers"){vt(e.rules);return}if(e.type==="tess"){we.url=e.url;return}if(e.type==="init"){if(e.workers!==void 0)Ae.capacity=un(e.workers,e.cached);Oe.set(e.key,{tiles:e.tiles,maxzoom:e.maxzoom,layers:e.layers,rasters:e.rasters??{},sprites:e.sprites??[],patterns:new Map});return}if(e.type==="drop"){Oe.get(e.key)?.sprites.forEach((t)=>{t.image.close()}),Oe.delete(e.key);return}if(e.type==="abort"){if(Ye.has(e.id))j.add(e.id);Mt.get(e.id)?.abort();return}if(e.type==="heights"||e.type==="reproject"||e.type==="grids"){await Do(e);return}Ye.add(e.id);try{let t=Oe.get(e.key);if(!t)throw Error(`isard: no renderer ${e.key}`);let n=await Wo(t,e.type,e);if(n)ue({id:e.id,...n[0]},n[1]);else ue({id:e.id,missing:!0})}catch(t){ue({id:e.id,error:String(t)})}finally{Ye.delete(e.id),j.delete(e.id)}};var Bo=async(e,t)=>(await St(e,oe(e,{signal:t}))).arrayBuffer(),Do=async(e)=>{let t=new AbortController;Mt.set(e.id,t);try{if(e.type==="grids"){let{module:n,url:r,bytes:o}=e,s=o??(r?await Bo(r,t.signal):new ArrayBuffer(0)),{grids:a,values:i}=await Zt(new Uint8Array(s),n);ue({id:e.id,grids:a,values:i},i.map((c)=>c.buffer))}else if(e.type==="heights"){let n=await Lt(e.url,e.encoding,e.floor,t.signal,Po);if(n)ue({id:e.id,heights:n},[n.buffer]);else ue({id:e.id,missing:!0})}else{zn.cache.capacity=e.cached;let n=await zn.draw(e.job,t.signal);if(n)ue({id:e.id,image:n},[n]);else ue({id:e.id,missing:!0})}}catch(n){ue({id:e.id,error:String(n)})}finally{Mt.delete(e.id)}};
|
|
1
|
+
var ie=(e,t)=>Error(`isard: ${String(e)}: HTTP ${t}`),St=async(e,t)=>{let n=await fetch(e,t);if(!n.ok)throw ie(e,n.status);return n};class le{capacity;evict;entries=new Map;weights=new Map;total=0;constructor(e,t){this.capacity=e;this.evict=t}get size(){return this.entries.size}get(e){let t=this.entries.get(e);if(t!==void 0)this.entries.delete(e),this.entries.set(e,t);return t}has(e){return this.entries.has(e)}set(e,t){this.delete(e),this.entries.set(e,t),this.total+=1,this.trim()}weigh(e,t){if(!this.entries.has(e))return;this.total+=t-(this.weights.get(e)??1),this.weights.set(e,t),this.trim()}delete(e){if(!this.entries.has(e))return!1;return this.total-=this.weights.get(e)??1,this.weights.delete(e),this.entries.delete(e)}trim(){for(let[e,t]of this.entries){if(this.total<=this.capacity||this.entries.size<=1)break;this.delete(e),this.evict?.(t,e)}}values(){return this.entries.values()}clear(){this.entries.clear(),this.weights.clear(),this.total=0}}var kt=[];var vt=(e)=>{kt=e};var oe=(e,t={})=>{let n=String(e),r=kt.filter(([s])=>n.startsWith(s));if(r.length===0)return t;let o=new Headers(t.headers);return r.forEach(([,s])=>{Object.entries(s).forEach(([a,i])=>{o.set(a,i)})}),{...t,headers:o}};var qn=96,$n=(e,t,n,r,o,s)=>{let a=new Uint8ClampedArray(s*s*4),i=s/o,c=o+1;for(let l=0;l<s;l+=1){let u=(l+0.5)/i,d=Math.min(o-1,Math.floor(u)),f=u-d;for(let p=0;p<s;p+=1){let x=(p+0.5)/i,y=Math.min(o-1,Math.floor(x)),A=x-y,m=2*(d*c+y),S=m+2*c,b=(1-A)*(1-f),w=A*(1-f),T=(1-A)*f,E=A*f,_=b*r[m]+w*r[m+2]+T*r[S]+E*r[S+2],g=b*r[m+1]+w*r[m+3]+T*r[S+1]+E*r[S+3],h=_-0.5,M=g-0.5;if(!(h>-1&&M>-1&&h<t&&M<n))continue;let k=Math.floor(h),v=Math.floor(M),R=h-k,W=M-v,B=0,O=0,P=0,I=0;for(let F=0;F<4;F+=1){let C=k+(F&1),V=v+(F>>1);if(C<0||V<0||C>=t||V>=n)continue;let J=4*(V*t+C),z=(F&1?R:1-R)*(F>>1?W:1-W)*e[J+3];B+=z*e[J],O+=z*e[J+1],P+=z*e[J+2],I+=z}if(I<=0)continue;let L=4*(l*s+p);a[L]=B/I,a[L+1]=O/I,a[L+2]=P/I,a[L+3]=I}}return a},Rt=(e=qn)=>{let t=new Map,n=new Set,r=(l)=>{n.delete(l),l.then((u)=>u?.close(),()=>{return})},o=(l)=>{if(t.has(l))n.add(l);else r(l)},s=new le(e,o),a=(l)=>{let u=(t.get(l)??1)-1;if(u>0)t.set(l,u);else if(t.delete(l),n.has(l))r(l)},i=(l)=>{let u=()=>{let f=(async()=>{let p=await fetch(l,oe(l));if(p.status===404||p.status===204||p.status===410)return null;if(!p.ok)throw ie(l,p.status);return createImageBitmap(await p.blob())})();return f.catch(()=>s.delete(l)),s.set(l,f),f},d=s.get(l)??u();return t.set(d,(t.get(d)??0)+1),d};return{draw:async(l,u)=>{let d=l.sources.map((f)=>[f,i(f.url)]);try{let f=await Promise.all(d.map(async([m,S])=>[m,await S]));if(u.throwIfAborted(),!f.some(([,m])=>m))return null;let x=new OffscreenCanvas(l.width,l.height).getContext("2d",{willReadFrequently:!0});if(!x)throw Error("isard: no 2D canvas to reproject the tiles");f.forEach(([m,S])=>{if(S)x.drawImage(S,m.x,m.y,m.w,m.h)});let y=x.getImageData(0,0,l.width,l.height).data,A=$n(y,l.width,l.height,l.mesh,l.n,l.size);return createImageBitmap(new ImageData(A,l.size,l.size),{premultiplyAlpha:"none"})}finally{d.forEach(([,f])=>{a(f)})}},cache:s,close:()=>{[...s.values()].forEach(o),s.clear()}}};var xe=(e,t,n)=>Math.max(t,Math.min(n,e));var Go=Math.PI/180,Tt=40075016.686,Zo=Tt/360;var Et=(e)=>e*360-180,It=(e)=>Math.atan(Math.sinh(Math.PI*(1-2*e)))*180/Math.PI;var rt=(e)=>Tt*Math.cos(Math.atan(Math.sinh(Math.PI*(1-2*e)))),_e=(e,t)=>rt((t+0.5)/2**e)/2**e,G=(e,t,n,r)=>e.replaceAll("{z}",String(t)).replaceAll("{x}",String(n)).replaceAll("{y}",String(r));var fe=256,Yn=(e,t,n=Number.NEGATIVE_INFINITY)=>{let r=e.length>>2,o=new Float32Array(r);if(t==="terrarium")for(let s=0,a=0;s<r;s+=1,a+=4){let i=e[a]*256+e[a+1]+e[a+2]/256-32768;o[s]=i>n?i:n}else for(let s=0,a=0;s<r;s+=1,a+=4){let i=-1e4+(e[a]*65536+e[a+1]*256+e[a+2])*0.1;o[s]=i>n?i:n}return o},Lt=async(e,t,n,r,o)=>{let s=await fetch(e,oe(e,{signal:r}));if(s.status===404||s.status===204||s.status===410)return null;if(!s.ok)throw ie(e,s.status);let a=await createImageBitmap(await s.blob(),{premultiplyAlpha:"none",colorSpaceConversion:"none"});try{o.canvas??=new OffscreenCanvas(fe,fe);let i=o.canvas.getContext("2d",{willReadFrequently:!0});if(!i)throw Error("isard: no 2D context");return i.imageSmoothingEnabled=!1,i.clearRect(0,0,fe,fe),i.drawImage(a,0,0,fe,fe),Yn(i.getImageData(0,0,fe,fe).data,t,n)}finally{a.close()}};var Kn="aliceblue f0f8ff antiquewhite faebd7 aqua 00ffff aquamarine 7fffd4 azure f0ffff beige f5f5dc bisque ffe4c4 black 000000 blanchedalmond ffebcd blue 0000ff blueviolet 8a2be2 brown a52a2a burlywood deb887 cadetblue 5f9ea0 chartreuse 7fff00 chocolate d2691e coral ff7f50 cornflowerblue 6495ed cornsilk fff8dc crimson dc143c cyan 00ffff darkblue 00008b darkcyan 008b8b darkgoldenrod b8860b darkgray a9a9a9 darkgreen 006400 darkgrey a9a9a9 darkkhaki bdb76b darkmagenta 8b008b darkolivegreen 556b2f darkorange ff8c00 darkorchid 9932cc darkred 8b0000 darksalmon e9967a darkseagreen 8fbc8f darkslateblue 483d8b darkslategray 2f4f4f darkslategrey 2f4f4f darkturquoise 00ced1 darkviolet 9400d3 deeppink ff1493 deepskyblue 00bfff dimgray 696969 dimgrey 696969 dodgerblue 1e90ff firebrick b22222 floralwhite fffaf0 forestgreen 228b22 fuchsia ff00ff gainsboro dcdcdc ghostwhite f8f8ff gold ffd700 goldenrod daa520 gray 808080 green 008000 greenyellow adff2f grey 808080 honeydew f0fff0 hotpink ff69b4 indianred cd5c5c indigo 4b0082 ivory fffff0 khaki f0e68c lavender e6e6fa lavenderblush fff0f5 lawngreen 7cfc00 lemonchiffon fffacd lightblue add8e6 lightcoral f08080 lightcyan e0ffff lightgoldenrodyellow fafad2 lightgray d3d3d3 lightgreen 90ee90 lightgrey d3d3d3 lightpink ffb6c1 lightsalmon ffa07a lightseagreen 20b2aa lightskyblue 87cefa lightslategray 778899 lightslategrey 778899 lightsteelblue b0c4de lightyellow ffffe0 lime 00ff00 limegreen 32cd32 linen faf0e6 magenta ff00ff maroon 800000 mediumaquamarine 66cdaa mediumblue 0000cd mediumorchid ba55d3 mediumpurple 9370db mediumseagreen 3cb371 mediumslateblue 7b68ee mediumspringgreen 00fa9a mediumturquoise 48d1cc mediumvioletred c71585 midnightblue 191970 mintcream f5fffa mistyrose ffe4e1 moccasin ffe4b5 navajowhite ffdead navy 000080 oldlace fdf5e6 olive 808000 olivedrab 6b8e23 orange ffa500 orangered ff4500 orchid da70d6 palegoldenrod eee8aa palegreen 98fb98 paleturquoise afeeee palevioletred db7093 papayawhip ffefd5 peachpuff ffdab9 peru cd853f pink ffc0cb plum dda0dd powderblue b0e0e6 purple 800080 rebeccapurple 663399 red ff0000 rosybrown bc8f8f royalblue 4169e1 saddlebrown 8b4513 salmon fa8072 sandybrown f4a460 seagreen 2e8b57 seashell fff5ee sienna a0522d silver c0c0c0 skyblue 87ceeb slateblue 6a5acd slategray 708090 slategrey 708090 snow fffafa springgreen 00ff7f steelblue 4682b4 tan d2b48c teal 008080 thistle d8bfd8 tomato ff6347 turquoise 40e0d0 violet ee82ee wheat f5deb3 white ffffff whitesmoke f5f5f5 yellow ffff00 yellowgreen 9acd32",ot,Gn=(e)=>{if(!ot){let t=Kn.split(" ");ot=new Map(Array.from({length:Math.floor(t.length/2)},(n,r)=>[t[2*r]??"",t[2*r+1]??""]))}return ot.get(e)},ze=(e)=>Number.isFinite(e)?xe(e,0,1):0,Ft=(e)=>{if(!/^[0-9a-f]+$/.test(e)||![3,4,6,8].includes(e.length))return;let t=e.length<=4?[...e].map((r)=>r+r).join(""):e,n=(r)=>Number.parseInt(t.slice(r,r+2),16)/255;return[n(0),n(2),n(4),t.length===8?n(6):1]},Zn=(e)=>{if(e===void 0)return 1;return ze(e.endsWith("%")?Number.parseFloat(e)/100:Number.parseFloat(e))},Xn=(e,t,n)=>{let r=n<0.5?n*(1+t):n+t-n*t,o=2*n-r,s=(a)=>{let i=(a%1+1)%1;if(i<0.16666666666666666)return o+(r-o)*6*i;if(i<0.5)return r;if(i<0.6666666666666666)return o+(r-o)*(0.6666666666666666-i)*6;return o};return[s(e+0.3333333333333333),s(e),s(e-0.3333333333333333)]},Nt=(e)=>{if(typeof e!=="string")return;let t=e.trim().toLowerCase();if(t.startsWith("#"))return Ft(t.slice(1));if(t==="transparent")return[0,0,0,0];let n=Gn(t);if(n)return Ft(n);let r=/^(rgba?|hsla?)\(([^)]*)\)$/.exec(t);if(!r?.[1]||r[2]===void 0)return;let o=r[2].split(/[\s,/]+/).filter(Boolean);if(o.length<3||o.slice(0,3).some((u)=>Number.isNaN(Number.parseFloat(u))))return;let s=Zn(o[3]);if(r[1].startsWith("rgb")){let u=(d)=>ze(d.endsWith("%")?Number.parseFloat(d)/100:Number.parseFloat(d)/255);return[u(o[0]??""),u(o[1]??""),u(o[2]??""),s]}let a=Number.parseFloat(o[0]??"")/360,[i,c,l]=Xn(a,ze(Number.parseFloat(o[1]??"")/100),ze(Number.parseFloat(o[2]??"")/100));return[i,c,l,s]};var be=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e);var Qn=["Unknown","Point","LineString","Polygon"],Z=(e,t)=>({zoom:t,properties:e.properties,type:Qn[e.type]??"Unknown"}),ce=(e)=>Nt(e),Je=([e,t,n,r])=>`rgba(${Math.round(e*255)},${Math.round(t*255)},${Math.round(n*255)},${r})`,Ct=(e,t,n,r=1)=>{let o=n-t;if(o===0)return 0;let s=e-t;return r===1?s/o:(r**s-1)/(r**o-1)},it=(e,t,n)=>{if(typeof e==="number"&&typeof t==="number")return e+(t-e)*n;let r=ce(e),o=ce(t);if(r&&o){let s=(a)=>r[a]+(o[a]-r[a])*n;return Je([s(0),s(1),s(2),s(3)])}if(Array.isArray(e)&&Array.isArray(t))return e.map((s,a)=>it(s,t[a],n));return n<0.5?e:t},Wt=(e)=>typeof e==="object"&&e!==null&&!Array.isArray(e)&&Array.isArray(e.stops),er=(e,t)=>{let n=e.property===void 0?t.zoom:t.properties[e.property],r=e.stops,o=e.type??(e.property===void 0||typeof r[0]?.[0]==="number"?"exponential":"categorical");if(o==="identity")return n??e.default;if(o==="categorical")return r.find(([u])=>u===n)?.[1]??e.default;if(typeof n!=="number"||!r.length)return e.default??r[0]?.[1];let s=([u])=>{if(Array.isArray(u))return Number.NaN;return be(u)?Number(u.zoom):Number(u)},a=r[0];if(!a)return e.default;if(n<=s(a))return a[1];let i=r.findIndex((u,d)=>d>0&&Boolean(r[d-1])&&Boolean(u)&&n<s(u)),[c,l]=[r[i-1],r[i]];if(i<0||!c||!l)return r.at(-1)?.[1];if(o==="interval")return c[1];return it(c[1],l[1],Ct(n,s(c),s(l),e.base??1))},st=(e)=>e,Ot={"<":(e,t)=>e<t,"<=":(e,t)=>e<=t,">":(e,t)=>e>t,">=":(e,t)=>e>=t},Bt=(e,t,n)=>{let r=(a)=>typeof a==="object"&&a!==null?String(a):a,[o,s]=[r(t),r(n)];return typeof o==="string"&&typeof s==="string"?Ot[e](o,s):Ot[e](Number(o),Number(s))},He=(e,t)=>{if(t==="$type")return e.type;return typeof t==="string"?e.properties[t]:void 0},tr=new Set(["literal","zoom","get","has","!has","properties","id","geometry-type","concat","format","image","number-format","to-number","to-string","to-boolean","to-color","number","string","boolean","typeof","length","at","upcase","downcase","coalesce","!","all","any","==","!=","<","<=",">",">=","in","case","match","step","interpolate","interpolate-hcl","interpolate-lab","rgb","rgba","+","-","*","/","%","^","min","max","abs","round","floor","ceil","sqrt","ln","log10","log2","pi","e"]),Re=(e)=>Array.isArray(e)&&typeof e[0]==="string"&&tr.has(e[0]),Pt=new Set,ve=(e)=>e===void 0||e===null?"":String(e),ae=(e,t)=>{if(Wt(e))return er(e,t);if(!Array.isArray(e))return e;let[n,...r]=e;if(typeof n!=="string")return e;let o=(i)=>ae(r[i]??null,t),s=(i)=>Number(o(i)),a=()=>r.map((i,c)=>s(c));switch(n){case"literal":return r[0];case"zoom":return t.zoom;case"get":return He(t,o(0));case"has":return He(t,o(0))!==void 0;case"!has":return He(t,o(0))===void 0;case"properties":return t.properties;case"id":return null;case"geometry-type":return t.type;case"concat":return r.map((i,c)=>ve(o(c))).join("");case"format":return r.map((i,c)=>i!==null&&typeof i==="object"&&!Array.isArray(i)?"":ve(o(c))).join("");case"image":return o(0);case"number-format":{let i=be(r[1])?r[1]:{},c=(u)=>{let d=i[u];return typeof d==="number"?d:void 0},l=s(0);if(!Number.isFinite(l))return"";return l.toLocaleString(typeof i.locale==="string"?i.locale:void 0,{minimumFractionDigits:c("min-fraction-digits"),maximumFractionDigits:c("max-fraction-digits")})}case"to-number":{for(let i=0;i<r.length;i+=1){let c=o(i),l=typeof c==="string"&&c.trim()===""?Number.NaN:Number(c);if(c!==null&&c!==void 0&&!Number.isNaN(l))return l}return 0}case"to-string":return ve(o(0));case"to-boolean":{let i=o(0);return!(i===""||i===0||i===!1||i===null||i===void 0||Number.isNaN(i))}case"to-color":case"number":case"string":case"boolean":{let i={"to-color":(c)=>ce(c)!==void 0,number:(c)=>typeof c==="number",string:(c)=>typeof c==="string",boolean:(c)=>typeof c==="boolean"};for(let c=0;c<r.length;c+=1){let l=o(c);if(i[n]?.(l))return l}return r.length?o(r.length-1):null}case"typeof":{let i=o(0);if(i===null||i===void 0)return"null";return Array.isArray(i)?"array":typeof i}case"length":{let i=o(0);return typeof i==="string"||Array.isArray(i)?i.length:0}case"at":{let i=o(1);return Array.isArray(i)?i[s(0)]??null:null}case"upcase":return ve(o(0)).toUpperCase();case"downcase":return ve(o(0)).toLowerCase();case"coalesce":for(let i=0;i<r.length;i+=1){let c=o(i);if(c!==void 0&&c!==null)return c}return null;case"!":return!o(0);case"all":return r.every((i,c)=>Boolean(o(c)));case"any":return r.some((i,c)=>Boolean(o(c)));case"==":return o(0)===o(1);case"!=":return o(0)!==o(1);case"<":case"<=":case">":case">=":return Bt(n,o(0),o(1));case"in":{let i=o(1),c=o(0);if(typeof i==="string")return i.includes(String(c));return Array.isArray(i)&&i.includes(c)}case"case":{let i=r.findIndex((c,l)=>l%2===0&&l+1<r.length&&Boolean(o(l)));return i<0?o(r.length-1):o(i+1)}case"match":{let i=o(0),c=r.findIndex((l,u)=>u%2===1&&u+1<r.length&&(Array.isArray(l)?st(l).includes(i):l===i));return c<0?o(r.length-1):o(c+1)}case"step":{let i=s(0),c=o(1);for(let l=2;l+1<r.length;l+=2)if(i>=Number(r[l]))c=o(l+1);else break;return c}case"interpolate":case"interpolate-hcl":case"interpolate-lab":{let i=r[0],c=s(1),l=Array.isArray(i)&&i[0]==="exponential"?Number(i[1]):1,u=Array.from({length:Math.floor((r.length-2)/2)},(y,A)=>[Number(r[2+2*A]),r[3+2*A]??null]),d=u[0];if(!d)return null;if(c<=d[0])return ae(d[1],t);let f=u.findIndex((y,A)=>A>0&&c<y[0]),[p,x]=[u[f-1],u[f]];if(f<0||!p||!x)return ae(u.at(-1)?.[1]??null,t);return it(ae(p[1],t),ae(x[1],t),Ct(c,p[0],x[0],l))}case"rgb":case"rgba":return Je([s(0)/255,s(1)/255,s(2)/255,r.length>3?s(3):1]);case"+":return a().reduce((i,c)=>i+c,0);case"*":return a().reduce((i,c)=>i*c,1);case"-":return r.length===1?-s(0):s(0)-s(1);case"/":return s(0)/s(1);case"%":return s(0)%s(1);case"^":return s(0)**s(1);case"min":return Math.min(...a());case"max":return Math.max(...a());case"abs":return Math.abs(s(0));case"round":return Math.sign(s(0))*Math.round(Math.abs(s(0)));case"floor":return Math.floor(s(0));case"ceil":return Math.ceil(s(0));case"sqrt":return Math.sqrt(s(0));case"ln":return Math.log(s(0));case"log10":return Math.log10(s(0));case"log2":return Math.log2(s(0));case"pi":return Math.PI;case"e":return Math.E;default:if(!Pt.has(n))Pt.add(n),console.warn(`isard: the style expression "${n}" is not supported`);return null}},nr=new Set(["==","!=","<","<=",">",">="]),je=(e)=>{if(e.type==="line")return"line";if(e.type==="fill-extrusion")return"extrusion";if(e.type==="circle")return"circle";return e.type==="fill"||e.type==="background"?"fill":void 0},rr=(e)=>{let[t,n,...r]=e;if(typeof t!=="string"||typeof n!=="string"||r.some(Array.isArray))return!1;if(nr.has(t))return e.length===3;if(t==="in")return e.length!==3||!Array.isArray(e[2]);return t==="!in"||t==="has"||t==="!has"},or=(e,t)=>{let[n,r,...o]=e,s=He(t,r);switch(n){case"==":return s===o[0];case"!=":return s!==o[0];case"<":case"<=":case">":case">=":return Bt(n,s,o[0]);case"in":return st(o).includes(s);case"!in":return!st(o).includes(s);case"has":return s!==void 0;case"!has":return s===void 0;default:return!0}},Ut=new WeakMap,Dt=(e)=>{if(!Array.isArray(e))return()=>Boolean(e);let t=Ut.get(e);if(t)return t;let r=(()=>{let o=e[0];if(o==="all"||o==="any"||o==="none"){let s=e.slice(1).map(Dt);if(o==="all")return(a)=>s.every((i)=>i(a));if(o==="any")return(a)=>s.some((i)=>i(a));return(a)=>!s.some((i)=>i(a))}if(rr(e))return(s)=>or(e,s);return(s)=>Boolean(ae(e,s))})();return Ut.set(e,r),r},Q=(e,t)=>{if(e===void 0||e===null)return!0;return Dt(e)(t)},at=(e)=>Array.isArray(e)&&(e[0]==="zoom"||e.some(at)),sr=new Set(["get","has","!has","geometry-type","properties","id"]),me=(e)=>{if(e!==void 0&&Wt(e))return e.property!==void 0;if(!Array.isArray(e))return!1;if(sr.has(e[0]))return!0;return e.some((t)=>me(t))},ct=(e,t)=>{if(e===void 0||e===null)return"";if(typeof e==="string")return e.replace(/\{([^}]+)\}/g,(r,o)=>{let s=t.properties[o];return s===void 0?"":String(s)});let n=ae(e,t);if(Array.isArray(n))return n.filter((r)=>typeof r==="string").join("");return n===void 0||n===null?"":String(n)},Vt=(e)=>/Regular|Bold|Italic|Semibold|Light|Medium|Black/.test(e)?e:`${e} Regular`,lt=(e)=>{let t=new Set,n=(i)=>i.filter((c,l)=>l>=3&&l%2===1).map(Number),r=(i)=>{if(!Array.isArray(i))return;let c=(l)=>Array.isArray(l)&&l[0]==="zoom";if((i[0]==="interpolate"||i[0]==="interpolate-hcl"||i[0]==="interpolate-lab")&&c(i[2]))n(i).forEach((l)=>{t.add(l)});else if(i[0]==="step"&&c(i[1]))n(i).forEach((l)=>{t.add(l),t.add(l-0.01)});i.forEach(r)};r(e);let o=[...t].filter(Number.isFinite);if(o.length===0)o.push(0);let[s,a]=[Math.min(...o),Math.max(...o)];return o.push(...Array.from({length:Math.floor(a)-Math.ceil(s)+1},(i,c)=>Math.ceil(s)+c)),[...new Set(o)].sort((i,c)=>i-c).map((i)=>[i,Number(ae(e,{zoom:i,properties:{},type:"Unknown"}))])};class Fe{static __wrap(e){let t=Object.create(Fe.prototype);return t.__wbg_ptr=e,zt.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,zt.unregister(this),e}free(){let e=this.__destroy_into_raw();D.__wbg_gridset_free(e,0)}count(){return D.gridset_count(this.__wbg_ptr)>>>0}meta(e){let t,n;try{let r=D.gridset_meta(this.__wbg_ptr,e);return t=r[0],n=r[1],ft(r[0],r[1])}finally{D.__wbindgen_free(t,n,1)}}values(e){return D.gridset_values(this.__wbg_ptr,e)}}if(Symbol.dispose)Fe.prototype[Symbol.dispose]=Fe.prototype.free;class Ne{static __wrap(e){let t=Object.create(Ne.prototype);return t.__wbg_ptr=e,Ht.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,Ht.unregister(this),e}free(){let e=this.__destroy_into_raw();D.__wbg_streetflow_free(e,0)}eastU(){return D.streetflow_eastU(this.__wbg_ptr)}eastV(){return D.streetflow_eastV(this.__wbg_ptr)}northU(){return D.streetflow_northU(this.__wbg_ptr)}northV(){return D.streetflow_northV(this.__wbg_ptr)}}if(Symbol.dispose)Ne.prototype[Symbol.dispose]=Ne.prototype.free;function jt(e){let t=fr(e,D.__wbindgen_malloc),n=he,r=D.readGrids(t,n);if(r[2])throw pr(r[1]);return Fe.__wrap(r[0])}function qt(e,t,n,r,o,s){let a=mr(e,D.__wbindgen_malloc),i=he,c=Jt(t,D.__wbindgen_malloc),l=he,u=Jt(n,D.__wbindgen_malloc),d=he,f=D.streetFlow(a,i,c,l,u,d,r,o,s);return Ne.__wrap(f)}function ir(){return{__proto__:null,"./isard_grid_bg.js":{__proto__:null,__wbg___wbindgen_throw_41e9ee4f547fc59a:function(t,n){throw Error(ft(t,n))},__wbg_new_from_slice_ca6ad97db1f4779a:function(t,n){return new Float32Array(ar(t,n))},__wbindgen_generic_0000000000000001:function(t,n){return ft(t,n)},__wbindgen_init_externref_table:function(){let t=D.__wbindgen_externrefs,n=t.grow(4);t.set(0,void 0),t.set(n+0,void 0),t.set(n+1,null),t.set(n+2,!0),t.set(n+3,!1)}}}}var zt=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e)=>D.__wbg_gridset_free(e,1)),Ht=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e)=>D.__wbg_streetflow_free(e,1));function ar(e,t){return e=e>>>0,cr().subarray(e/4,e/4+t)}var Te=null;function cr(){if(Te===null||Te.byteLength===0)Te=new Float32Array(D.memory.buffer);return Te}var Ee=null;function lr(){if(Ee===null||Ee.byteLength===0)Ee=new Float64Array(D.memory.buffer);return Ee}function ft(e,t){return br(e>>>0,t)}var Ie=null;function ur(){if(Ie===null||Ie.byteLength===0)Ie=new Uint32Array(D.memory.buffer);return Ie}var Le=null;function $t(){if(Le===null||Le.byteLength===0)Le=new Uint8Array(D.memory.buffer);return Le}function Jt(e,t){let n=t(e.length*4,4)>>>0;return ur().set(e,n/4),he=e.length,n}function fr(e,t){let n=t(e.length*1,1)>>>0;return $t().set(e,n/1),he=e.length,n}function mr(e,t){let n=t(e.length*8,8)>>>0;return lr().set(e,n/8),he=e.length,n}function pr(e){let t=D.__wbindgen_externrefs.get(e);return D.__externref_table_dealloc(e),t}var qe=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});qe.decode();var dr=2146435072,ut=0;function br(e,t){if(ut+=t,ut>=dr)qe=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),qe.decode(),ut=t;return qe.decode($t().subarray(e,e+t))}var he=0,hr,yr,D;function gr(e,t){return yr=e,D=e.exports,hr=t,Te=null,Ee=null,Ie=null,Le=null,D.__wbindgen_start(),D}async function wr(e,t){if(typeof Response==="function"&&e instanceof Response){if(!e.ok)throw Error(`failed to fetch Wasm: ${e.status} ${e.statusText} fetching '${e.url}'`);if(typeof WebAssembly.instantiateStreaming==="function")try{return await WebAssembly.instantiateStreaming(e,t)}catch(o){if(n(e.type)&&e.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",o);else throw o}let r=await e.arrayBuffer();return await WebAssembly.instantiate(r,t)}else{let r=await WebAssembly.instantiate(e,t);if(r instanceof WebAssembly.Instance)return{instance:r,module:e};else return r}function n(r){switch(r){case"basic":case"cors":case"default":return!0}return!1}}async function Yt(e){if(D!==void 0)return D;if(e!==void 0)if(Object.getPrototypeOf(e)===Object.prototype)({module_or_path:e}=e);else console.warn("using deprecated parameters for the initialization function; pass a single object instead");if(e===void 0)e=new URL("isard_grid_bg.wasm",import.meta.url);let t=ir();if(typeof e==="string"||typeof Request==="function"&&e instanceof Request||typeof URL==="function"&&e instanceof URL)e=fetch(e);let{instance:n,module:r}=await wr(await e,t);return gr(n,r)}var mt={},Kt=async(e)=>{let t=mt.ready??Yt({module_or_path:e});mt.ready=t,await t.catch((n)=>{throw mt.ready=void 0,n})},Gt=async(e,t,n,r,o)=>{await Kt(o);let s=qt(e.points,e.ringStart,e.polygonStart,t,n,r);try{return{eastU:s.eastU(),eastV:s.eastV(),northU:s.northU(),northV:s.northV()}}finally{s.free()}},xr=(e)=>typeof e==="object"&&e!==null&&("name"in e)&&("width"in e)&&("height"in e)&&("bounds"in e)&&Array.isArray(e.bounds),Zt=async(e,t)=>{await Kt(t);let n=jt(e);try{let r=[],o=[];for(let s=0;s<n.count();s++){let a=JSON.parse(n.meta(s));if(!xr(a))throw Error("isard: a grid without its description");r.push(a),o.push(n.values(s))}return{grids:r,values:o}}finally{n.free()}};var ye=6,Xt=4;var Qt=(e)=>e*7919%360,pt=["shelter","bin","postbox","fountain","rack","bench"];class en{type;store;index;constructor(e,t,n){this.type=e;this.store=t;this.index=n}get geometry(){let{values:e,ranges:t,spans:n}=this.store,r=[],o=n[this.index*4+1]??0;for(let s=n[this.index*4]??0;s<o;s+=2)r.push(e.subarray(t[s],t[s+1]));return r}get properties(){let{store:e}=this;if(!e.made)e.made=[],setTimeout(()=>{e.made=void 0});let t=e.made[this.index]??this.made();return e.made[this.index]=t,t}made(){let{tags:e,keys:t,properties:n,spans:r}=this.store,o={},s=r[this.index*4+3]??0;for(let a=r[this.index*4+2]??0;a<s;a+=2)o[t[e[a]??0]??""]=n[e[a+1]??0]??"";return o}}class dt{buf;end;pos;constructor(e,t=0,n=e.length){this.buf=e;this.end=n;this.pos=t}varint(){let e=0;for(let t=0;t<70;t+=7){let n=this.buf[this.pos++]??0;if(e+=(n&127)*2**t,n<128)break}return e}int64(){let e=0,t=0;for(let n=0;n<10;n+=1){let r=this.buf[this.pos++]??0,o=r&127;if(n<4)e|=o<<7*n;else if(n===4)e|=(o&15)<<28,t|=o>>4;else t|=o<<7*n-32;if(r<128)break}return(t|0)*4294967296+(e>>>0)}sint(){let e=this.varint();return e%2===1?-(e+1)/2:e/2}sub(){let e=this.varint(),t=Math.min(this.pos+e,this.end),n=new dt(this.buf,this.pos,t);return this.pos=t,n}string(){let e=this.varint(),t=Math.min(this.pos+e,this.end),n=_r.decode(this.buf.subarray(this.pos,t));return this.pos=t,n}float(){let e=this.pos+4<=this.end?this.view().getFloat32(this.pos,!0):0;return this.pos+=4,e}double(){let e=this.pos+8<=this.end?this.view().getFloat64(this.pos,!0):0;return this.pos+=8,e}view(){return new DataView(this.buf.buffer,this.buf.byteOffset,this.buf.byteLength)}skip(e){if(e===0)this.varint();else if(e===1)this.pos+=8;else if(e===2)this.pos+=this.varint();else if(e===5)this.pos+=4}get more(){return this.pos<this.end}}var _r=new TextDecoder,Ar=(e)=>{let t="";while(e.more){let n=e.varint();switch(n>>3){case 1:t=e.string();break;case 2:t=e.float();break;case 3:t=e.double();break;case 4:t=e.int64();break;case 5:t=e.varint();break;case 6:t=e.sint();break;case 7:t=e.varint()!==0;break;default:e.skip(n&7)}}return t};class tn{values=new Int32Array(1024);length=0;ranges=[];push(e,t){if(this.length+2>this.values.length){let n=new Int32Array(this.values.length*2);n.set(this.values),this.values=n}this.values[this.length++]=e,this.values[this.length++]=t}shapes(){return{values:this.values.slice(0,this.length),ranges:Uint32Array.from(this.ranges)}}}var Mr=(e,t)=>{let[n,r]=[0,0],o=-1,s=()=>{if(o>=0)t.ranges.push(o,t.length)};while(e.more){let a=e.varint(),i=a&7,c=a>>3;if(i===7){if(o>=0&&t.length>o)t.push(t.values[o]??0,t.values[o+1]??0);continue}for(let l=0;l<c&&e.more;l+=1){if(n+=e.sint(),r+=e.sint(),i===1)s(),o=t.length;if(o>=0)t.push(n,r)}}s()},nn=(e)=>[...e.values()].reduce((t,n)=>t+n.bytes,0),Sr=70,kr=40,bt=(e,t)=>{let n=new Map,r=new dt(e);while(r.more){let o=r.varint();if(o>>3!==3){r.skip(o&7);continue}let s=r.sub(),a="",i=4096,c=[],l=[],u=[];while(s.more){let b=s.varint();switch(b>>3){case 1:a=s.string();break;case 2:u.push(s.sub());break;case 3:c.push(s.string());break;case 4:l.push(Ar(s.sub()));break;case 5:i=s.varint();break;default:s.skip(b&7)}}if(t&&!t.has(a))continue;let d=[],f=[],p=new tn,x=[];for(let b of u){let w=1,T=p.ranges.length,E=x.length;while(b.more){let _=b.varint();switch(_>>3){case 2:{let g=b.sub();while(g.more){let h=g.varint(),M=g.varint();if(h<c.length&&M<l.length)x.push(h,M)}break}case 3:w=Math.min(3,Math.max(1,b.varint()));break;case 4:Mr(b.sub(),p);break;default:b.skip(_&7)}}d.push(w),f.push(T,p.ranges.length,E,x.length)}let y={...p.shapes(),tags:Math.max(c.length,l.length)<=65536?Uint16Array.from(x):Uint32Array.from(x),keys:c,properties:l,spans:Uint32Array.from(f)},A=d.map((b,w)=>new en(b,y,w)),m=[...c,...l].reduce((b,w)=>b+kr+(typeof w==="string"?w.length:0),0),S=A.length*Sr+y.values.byteLength+y.ranges.byteLength+y.tags.byteLength+y.spans.byteLength+m;n.set(a,{extent:i,features:A,bytes:S})}return n};var vr=127,Rr=16384,Tr=["unknown","mvt","png","jpeg","webp","avif"],Er=(e)=>(4**e-1)/3,Ir=(e,t,n)=>{if(e>26)throw Error(`isard: PMTiles level ${e} past 26`);let r=2**e;if(t<0||n<0||t>=r||n>=r)throw Error(`isard: PMTiles tile ${e}/${t}/${n} out of its level`);let[o,s]=[t,n],a=0;for(let i=r/2;i>=1;i/=2){let c=(o&i)>0?1:0,l=(s&i)>0?1:0;if(a+=i*i*(3*c^l),l===0){if(c===1)[o,s]=[i-1-o,i-1-s];[o,s]=[s,o]}}return Er(e)+a};class sn{bytes;pos=0;constructor(e){this.bytes=e}next(){let e=0,t=1;for(;;){let n=this.bytes[this.pos++];if(n===void 0)throw Error("isard: PMTiles directory truncated");if(e+=(n&127)*t,n<128)return e;if(t*=128,t>9223372036854776000)throw Error("isard: PMTiles varint too long")}}}var rn=(e)=>{let t=new sn(e),n=t.next();if(n>e.length)throw Error("isard: PMTiles directory larger than its bytes");let r=[],o=0;for(let s=0;s<n;s+=1)o+=t.next(),r.push({tileId:o,offset:0,length:0,runLength:1});for(let s of r)s.runLength=t.next();for(let s of r)s.length=t.next();return r.forEach((s,a)=>{let i=t.next(),c=r[a-1];s.offset=i===0&&c?c.offset+c.length:i-1}),r},Lr=(e,t)=>{let[n,r]=[0,e.length-1];while(n<=r){let s=n+r>>1,a=e[s];if(!a)break;if(a.tileId===t)return a;if(a.tileId<t)n=s+1;else r=s-1}let o=e[r];if(!o)return;if(o.runLength===0||t-o.tileId<o.runLength)return o;return},Fr=(e)=>{if(e.length<vr||String.fromCharCode(...e.subarray(0,7))!=="PMTiles")throw Error("isard: not a PMTiles archive");if(e[7]!==3)throw Error(`isard: PMTiles version ${e[7]} (only 3 is read)`);let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=(o)=>Number(t.getBigUint64(o,!0)),r=(o)=>t.getInt32(o,!0)/1e7;return{rootDirectoryOffset:n(8),rootDirectoryLength:n(16),metadataOffset:n(24),metadataLength:n(32),leafDirectoryOffset:n(40),leafDirectoryLength:n(48),tileDataOffset:n(56),tileDataLength:n(64),internalCompression:t.getUint8(97),tileCompression:t.getUint8(98),tileType:Tr[t.getUint8(99)]??"unknown",minZoom:t.getUint8(100),maxZoom:t.getUint8(101),bounds:[r(102),r(106),r(110),r(114)],center:[r(119),r(123),t.getUint8(118)]}},$e=async(e,t)=>{if(t===0||t===1)return e;if(t!==2)throw Error(`isard: PMTiles compression ${t===3?"brotli":"zstd"} is not read (gzip only)`);let n=new Blob([e]).stream().pipeThrough(new DecompressionStream("gzip"));return new Uint8Array(await new Response(n).arrayBuffer())},Nr=67108864;class an{source;head;leaves=new le(64);whole;constructor(e){this.source=e}async range(e,t,n){if(typeof this.source!=="string")return new Uint8Array(await this.source.slice(e,e+t).arrayBuffer());if(this.whole)return(await this.whole).subarray(e,e+t);let r=await fetch(this.source,oe(this.source,{headers:{Range:`bytes=${e}-${e+Math.max(t,1)-1}`},...n?{signal:n}:{}}));if(!r.ok)throw ie(this.source,r.status);if(r.status===206)return new Uint8Array(await r.arrayBuffer());if(Number(r.headers.get("Content-Length"))>Nr)throw await r.body?.cancel(),Error(`isard: ${this.source}: the server ignores range requests (HTTP 206 expected)`);let s=r.arrayBuffer().then((a)=>new Uint8Array(a));return this.whole=s,s.catch(()=>{this.whole=void 0}),(await s).subarray(e,e+t)}load(){return this.head??=(async()=>{let e=await this.range(0,Rr),t=Fr(e),{rootDirectoryOffset:n,rootDirectoryLength:r}=t,o=n+r<=e.length?e.subarray(n,n+r):await this.range(n,r),s=rn(await $e(o,t.internalCompression));return{header:t,root:s}})(),this.head.catch(()=>{this.head=void 0}),this.head}async header(){return(await this.load()).header}async metadata(){let{header:e}=await this.load();if(e.metadataLength===0)return{};let t=await this.range(e.metadataOffset,e.metadataLength),n=new TextDecoder().decode(await $e(t,e.internalCompression)),r=JSON.parse(n);return be(r)?r:{}}leaf(e,t){let n=e.leafDirectoryOffset+t.offset,r=this.leaves.get(n);if(r)return r;let o=this.range(n,t.length).then(async(s)=>rn(await $e(s,e.internalCompression)));return o.catch(()=>this.leaves.delete(n)),this.leaves.set(n,o),o}async tile(e,t,n,r){let{header:o,root:s}=await this.load();if(e<o.minZoom||e>o.maxZoom)return;let a=Ir(e,t,n),i=s;for(let c=0;c<4;c+=1){let l=Lr(i,a);if(!l)return;if(l.runLength>0){let u=await this.range(o.tileDataOffset+l.offset,l.length,r);return $e(u,o.tileCompression)}i=await this.leaf(o,l)}throw Error("isard: PMTiles directories nested too deep")}}var on=new le(16),Or=(e)=>{let t=on.get(e);if(t)return t;let n=new an(e);return on.set(e,n),n};var ht=(e,t)=>{let n=/^pmtiles:\/\/(.+)\/(\d+)\/(\d+)\/(\d+)$/.exec(e);if(!n)return!1;let[,r="",o,s,a]=n;return Or(r).tile(Number(o),Number(s),Number(a),t)};var gt=(e,t)=>{let n=e.sprites.find((o)=>Boolean(o.icons[t])),r=n?.icons[t];return n&&r?{icon:r,image:n.image}:void 0},Oe=new Map,ln=192,Pr=16,Ae=new le(ln<<20),un=(e,t=ln)=>Math.max(Pr,Math.ceil(t/Math.max(1,e)))<<20,fn=30000,Ye=new Set,j=new Set,yt=new le(64,(e)=>e.then((t)=>setTimeout(()=>t?.close(),0),()=>{return})),mn=(e,t="auto")=>{let n=yt.get(e);if(n)return n;let r=(async()=>{let o=ht(e);if(o){let i=await o;return i&&createImageBitmap(new Blob([i]))}let s={priority:t,signal:AbortSignal.timeout(fn)},a=await fetch(e,oe(e,s));if(a.status===404||a.status===204)return;if(!a.ok)throw ie(e,a.status);return createImageBitmap(await a.blob())})();return r.catch(()=>yt.delete(e)),yt.set(e,r),r},cn=(e,t)=>(Ae.weigh(e,nn(t)),t),ee=(e,t="auto")=>{let n=Ae.get(e);if(n)return n;let r=(async()=>{let o=ht(e);if(o){let s=await o;return s&&cn(e,bt(s))}for(let s=0;;s+=1){let a={priority:t,signal:AbortSignal.timeout(fn)},i=await fetch(e,oe(e,a));if(i.status===404||i.status===204)return;if(i.ok)return cn(e,bt(new Uint8Array(await i.arrayBuffer())));if(s>=2)throw ie(e,i.status);await new Promise((c)=>setTimeout(c,400*(s+1)))}})();return r.catch(()=>Ae.delete(e)),Ae.set(e,r),r},pn=(e,t,n,r)=>{let o=xe(t-1,0,e.maxzoom),s=t-o,a=2**Math.max(0,s),[i,c]=s>=0?[Math.floor(n/a),Math.floor(r/a)]:[n,r],l=G(e.tiles,o,i,c),u=1/a;return{url:l,vz:o,vx:i,vy:c,part:u,ox:n%a*u,oy:r%a*u}},U=(e,t,n,r,o)=>{let s=e[t]?.[n];if(s===void 0)return o;let a=Array.isArray(s)&&!Re(s)?s:ae(s,r);return a===void 0||a===null?o:a},pe=(e,t)=>{let n=ce(e)??[0,0,0,1];return Je([n[0],n[1],n[2],n[3]*t])},Pe=(e,t)=>{if(e.layout?.visibility==="none")return!1;return t>=(e.minzoom??0)&&t<(e.maxzoom??24)},H=(e,t,n,r,o,s)=>{let a=2**e;return[Et((t+o/r)/a),It((n+s/r)/a)]};var Ur=300,dn=(e,t,n)=>{let r=Boolean(U(e,"layout",`${t}-allow-overlap`,n,!1)),o=Boolean(U(e,"layout",`${t}-ignore-placement`,n,!1));if(r&&o)return!0;if(r)return"allow";return o?"ignore":!1},bn=(e,t)=>Array.isArray(e)?[Number(e[0]??t[0]),Number(e[1]??t[1])]:t,Cr=(e)=>{let t=(Array.isArray(e)?e:[e]).map((a)=>Number(a)||0),[n=0,r=n,o=n,s=r]=t;return[n,r,o,s]},Wr=(e,t)=>{if(t==="uppercase")return e.toUpperCase();if(t==="lowercase")return e.toLowerCase();return e},Me=(e,t)=>{let n=0;for(let a=2;a+1<e.length;a+=2)n+=Math.hypot((e[a]??0)-(e[a-2]??0),(e[a+1]??0)-(e[a-1]??0));let r=[];if(!(n>0)||!(t>0))return r;let o=Math.min(t/2,n/2),s=0;for(let a=2;a+1<e.length;a+=2){let[i,c,l,u]=[e[a-2]??0,e[a-1]??0,e[a]??0,e[a+1]??0],d=Math.hypot(l-i,u-c);while(d>0&&o<=s+d){let f=(o-s)/d;r.push([i+(l-i)*f,c+(u-c)*f,i,c,l,u,o]),o+=t}s+=d}return r},Ge=(e,t,n)=>{let[r=0,o=0,s=0,a=0,i=0,c=0]=e,l=Math.hypot(i-s,c-a)||1,u=t%2===0?1:-1,[d,f]=[-(c-a)/l*u,(i-s)/l*u];return[r+d*n,o+f*n,Math.atan2(-d,f)*180/Math.PI]},Br=(e,t,n)=>{let r=[],o=0;for(let s=2;s+1<e.length;s+=2){let[a,i,c,l]=[e[s-2]??0,e[s-1]??0,e[s]??0,e[s+1]??0],u=Math.hypot(c-a,l-i),[d,f]=[o,o+u];if(o=f,u<=0||f<t||d>n)continue;let p=(x)=>[a+(c-a)*(x-d)/u,i+(l-i)*(x-d)/u];if(r.length===0)r.push(...p(Math.max(t,d)));r.push(...p(Math.min(n,f)))}return r},Dr=(e,t,n,r,o)=>{let s=U(e,"layout","icon-rotation-alignment",n,"auto"),a=String(U(e,"layout","icon-text-fit",n,"none")),i=U(e,"layout","icon-text-fit-padding",n,[0,0,0,0]);return{image:t,size:me(e.layout?.["icon-size"])?Number(U(e,"layout","icon-size",n,1)):o(e),anchor:String(U(e,"layout","icon-anchor",n,"center")),offset:bn(U(e,"layout","icon-offset",n,[0,0]),[0,0]),rotate:Number(U(e,"layout","icon-rotate",n,0))||0,alignment:s==="map"||s==="auto"&&r==="line"?"map":"viewport",overlap:dn(e,"icon",n),optional:Boolean(U(e,"layout","icon-optional",n,!1)),fit:a==="width"||a==="height"||a==="both"?a:"none",padding:Cr(i),color:String(U(e,"paint","icon-color",n,"#000")),opacity:Number(U(e,"paint","icon-opacity",n,1))}},Ke=16,Vr=(e,t,n)=>{let r=[],o=new Map,s=4096;e.layers.forEach((c)=>{if(c.type!=="fill-extrusion"||!Pe(c,n))return;let l=t.get(c["source-layer"]??"");if(!l)return;s=l.extent;for(let u of l.features){let d=Z(u,n);if(u.type!==3||!Q(c.filter,d))continue;let f=Number(U(c,"paint","fill-extrusion-height",d,0));if(!(f>0))continue;let p=[1/0,1/0,-1/0,-1/0];for(let x of u.geometry)for(let y=0;y+1<x.length;y+=2){let[A,m]=[x[y]??0,x[y+1]??0];p[0]=Math.min(p[0],A),p[1]=Math.min(p[1],m),p[2]=Math.max(p[2],A),p[3]=Math.max(p[3],m)}r.push({rings:u.geometry,height:f,box:p})}});let a=(c)=>Math.max(0,Math.min(Ke-1,Math.floor(c/s*Ke)));r.forEach(({box:c},l)=>{for(let u=a(c[1]);u<=a(c[3]);u++)for(let d=a(c[0]);d<=a(c[2]);d++){let f=u*Ke+d,p=o.get(f);if(p)p.push(l);else o.set(f,[l])}});let i=(c,l,u)=>{let d=!1;for(let f of c)for(let p=0,x=f.length-2;p+1<f.length;x=p,p+=2){let[y,A,m,S]=[f[p]??0,f[p+1]??0,f[x]??0,f[x+1]??0];if(A>u!==S>u&&l<(m-y)*(u-A)/(S-A)+y)d=!d}return d};return(c,l)=>(o.get(a(l)*Ke+a(c))??[]).reduce((u,d)=>{let f=r[d];return f&&i(f.rings,c,l)?Math.max(u??0,f.height):u},void 0)},hn=async(e,t)=>{let{z:n,x:r,y:o,id:s,priority:a,zoom:i=n,roofs:c=!1}=t,l=G(e.tiles,n,r,o),u=await ee(l,a);if(!u||j.has(s))return[];let d=[],f=c?Vr(e,u,i):()=>{return},p=new Map,x=(m)=>{let S=p.get(m);if(S!==void 0)return S;let b=m.layout?.["text-size"]??16,w=Re(b)?lt(b):b;return p.set(m,w),w},y=new Map,A=(m)=>{let S=y.get(m);if(S!==void 0)return S;let b=m.layout?.["icon-size"]??1,w=Re(b)?lt(b):b;return y.set(m,w),w};return e.layers.forEach((m,S)=>{let b=m.layout??{};if(m.type!=="symbol"||!Pe(m,i))return;if(b["text-field"]===void 0&&b["icon-image"]===void 0)return;let w=u.get(m["source-layer"]??"");if(!w)return;let T={zoom:i,properties:{},type:"Unknown"},E=U(m,"layout","symbol-placement",T,"point")==="line"?"line":"point",_=E==="line"&&U(m,"layout","text-rotation-alignment",T,"auto")!=="viewport";for(let g of w.features){let h=Z(g,i);if(!Q(m.filter,h))continue;let M=ct(b["text-field"],h).trim(),k=ct(b["icon-image"],h).trim();if(!M&&!k)continue;let v=Wr(M,U(m,"layout","text-transform",h,"none")),R=U(m,"layout","text-font",h,["Noto Sans Regular"]),W=Vt(Array.isArray(R)&&typeof R[0]==="string"?R[0]:"Noto Sans Regular"),B={layer:S,text:v,font:W,size:me(m.layout?.["text-size"])?Number(U(m,"layout","text-size",h,16)):x(m),color:String(U(m,"paint","text-color",h,"#000")),haloColor:String(U(m,"paint","text-halo-color",h,"rgba(0,0,0,0)")),haloWidth:Number(U(m,"paint","text-halo-width",h,0)),anchor:String(U(m,"layout","text-anchor",h,"center")),offset:bn(U(m,"layout","text-offset",h,[0,0]),[0,0]),maxWidth:Number(U(m,"layout","text-max-width",h,10)),lineHeight:Number(U(m,"layout","text-line-height",h,1.2)),overlap:dn(m,"text",h),..._?{textAlong:_}:{},...U(m,"layout","text-optional",h,!1)?{textOptional:!0}:{},...k?{icon:Dr(m,k,h,E,A)}:{}};if(g.type===1)for(let O of g.geometry)for(let P=0;P+1<O.length;P+=2){let[I,L]=[O[P]??0,O[P+1]??0];if(I<0||L<0||I>=w.extent||L>=w.extent)continue;let[F,C]=H(n,r,o,w.extent,I,L),V=f(I,L);d.push({...B,lon:F,lat:C,...V===void 0?{}:{height:V}})}else if(!v&&E==="line"){let O=Number(U(m,"layout","symbol-spacing",h,250))*w.extent/(512*2**(i-n));for(let P of g.geometry)for(let[I=0,L=0,F=0,C=0,V=0,J=0]of Me(P,Math.max(O,1))){if(I<0||L<0||I>=w.extent||L>=w.extent)continue;let[z,te]=H(n,r,o,w.extent,I,L),[K,ne]=H(n,r,o,w.extent,V,J),[X,re]=H(n,r,o,w.extent,F,C);d.push({...B,lon:z,lat:te,along:[K-X,ne-re]})}}else if(v&&_){let O=w.extent/(512*2**(i-n)),P=Number(U(m,"layout","symbol-spacing",h,250))*O;for(let I of g.geometry){let L=0;for(let F=2;F+1<I.length;F+=2)L+=Math.hypot((I[F]??0)-(I[F-2]??0),(I[F+1]??0)-(I[F-1]??0));if(L<w.extent/32)continue;for(let[F=0,C=0,V=0,J=0,z=0,te=0,K=0]of Me(I,Math.max(P,1))){if(F<0||C<0||F>=w.extent||C>=w.extent)continue;let ne=Math.min(K,L-K,Ur*O),X=Br(I,K-ne,K+ne),re=[];for(let Ve=0;Ve+1<X.length;Ve+=2)re.push(...H(n,r,o,w.extent,X[Ve]??0,X[Ve+1]??0));let[Se,ke]=H(n,r,o,w.extent,F,C),[nt,Hn]=H(n,r,o,w.extent,z,te),[Jn,jn]=H(n,r,o,w.extent,V,J);d.push({...B,lon:Se,lat:ke,along:[nt-Jn,Hn-jn],...re.length>=4?{path:re}:{}})}}}else{let O,P=0;for(let L of g.geometry){let F=0;for(let C=2;C+1<L.length;C+=2)F+=Math.hypot((L[C]??0)-(L[C-2]??0),(L[C+1]??0)-(L[C-1]??0));if(F>P)P=F,O=L}if(!O||P<w.extent/32)continue;let I=P/2;for(let L=2;L+1<O.length;L+=2){let[F,C,V,J]=[O[L-2]??0,O[L-1]??0,O[L]??0,O[L+1]??0],z=Math.hypot(V-F,J-C);if(z>=I&&z>0){let[te,K]=[F+(V-F)*I/z,C+(J-C)*I/z];if(te<0||K<0||te>=w.extent||K>=w.extent)break;let[ne,X]=H(n,r,o,w.extent,te,K),[re,Se]=H(n,r,o,w.extent,V,J),[ke,nt]=H(n,r,o,w.extent,F,C);d.push({...B,lon:ne,lat:X,...E==="line"?{along:[re-ke,Se-nt]}:{}});break}I-=z}}}}),d};var yn=(e)=>{let t=e.leaf_type,n=typeof e.nature==="string"?e.nature:"";if(t==="needleleaved"||/conif/i.test(n))return 1;if(t==="broadleaved"||/feuillu/i.test(n))return 0;if(t==="mixed"||/mixte/i.test(n))return 0.5;if(e.class==="wood")return e.subclass==="forest"?0.35:0.15;return 0};var Ze=(e,t)=>{let n=e.length/ye,r=n>t?t/n:1,o=[];for(let s=0;s<n;s+=1)if(r>=1||(e[s*ye+Xt]??0)<r)o.push(...e.slice(s*ye,(s+1)*ye));return Float64Array.from(o)},se=(e,t,n,r)=>{let o=Math.imul(e^2654435769,2246822507)^Math.imul(t^3266489909,668265263);return o=Math.imul(o^o>>>15^Math.imul(n,374761393),739982445),o=Math.imul(o^o>>>13^Math.imul(r,695872825),695872825),((o^o>>>16)>>>0)/4294967296},ge=(e,t,n)=>e.reduce((r,o)=>{let s=o.length/2,a=0;for(let i=0,c=s-1;i<s;c=i,i+=1){let[l,u,d,f]=[o[i*2]??0,o[i*2+1]??0,o[c*2]??0,o[c*2+1]??0];if(u>n!==f>n&&t<(d-l)*(n-u)/(f-u)+l)a+=1}return a%2===1?!r:r},!1),zr=(e,t,n,r,o=Number.POSITIVE_INFINITY)=>{let s=e[0]??[],a=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(let T=0;T+1<s.length;T+=2){let[E,_]=[s[T]??0,s[T+1]??0];a[0]=Math.min(a[0]??E,E),a[1]=Math.min(a[1]??_,_),a[2]=Math.max(a[2]??E,E),a[3]=Math.max(a[3]??_,_)}let[i,c]=[Math.max(0,a[0]??0),Math.max(0,a[1]??0)],[l,u]=[Math.min(t,a[2]??0),Math.min(t,a[3]??0)];if(!(n>0)||i>=l||c>=u)return[];let d=(l-i)/n*((u-c)/n),f=d>o?n*Math.sqrt(d/o):n,[p,x,y,A]=[Math.floor(i/f),Math.ceil(l/f),Math.floor(c/f),Math.ceil(u/f)],[m,S,b]=r,w=Math.imul(m+1,16777619)^Math.imul(S,1540483477)^Math.imul(b,461845907);return Array.from({length:Math.max(0,A-y)},(T,E)=>y+E).flatMap((T)=>Array.from({length:Math.max(0,x-p)},(E,_)=>p+_).flatMap((E)=>{let _=(E+se(w,E,T,1))*f,g=(T+se(w,E,T,2))*f;if(_<0||g<0||_>=t||g>=t||!ge(e,_,g))return[];return[[_,g,se(w,E,T,3)]]}))},gn=async(e,t)=>{let{z:n,x:r,y:o,id:s,spacing:a,maxTrees:i,priority:c}=t,l=G(e.tiles,n,r,o),u=await ee(l,c);if(!u||j.has(s))return;let d=_e(n,o),f=[];e.layers.forEach((A,m)=>{let S=a[m]??0,b=u.get(A["source-layer"]??"");if(!b||!(S>0))return;let w=S/d*b.extent;b.features.forEach((T)=>{if(T.type!==3||!Q(A.filter,Z(T,n)))return;let E=yn(T.properties);T.geometry.reduce((g,h)=>{let M=0;for(let k=0;k+1<h.length;k+=2){let v=(k+2)%h.length;M+=(h[k]??0)*(h[v+1]??0)-(h[v]??0)*(h[k+1]??0)}if(M>0)g.push([h]);else if(M<0)g.at(-1)?.push(h);return g},[]).forEach((g)=>{zr(g,b.extent,w,[n,r,o],i*4).forEach(([h,M,k])=>{f.push([h,M,k,b.extent,E])})})})});let p=f.length>i?i/f.length:1,x=f.filter(([,,A])=>p>=1||se(Math.floor(A*2147483648),n,r,o)<p),y=new Float64Array(x.length*ye);return x.forEach(([A,m,S,b,w],T)=>{let[E,_]=H(n,r,o,b,A,m),g=se(Math.floor(S*2147483648),7,11,13),h=se(Math.floor(S*2147483648),3,5,17)<w?1:0;y.set([E,_,0.75+0.5*S,Qt(S),g,h],T*ye)}),y};var Hr={bus_stop:"shelter",waste_basket:"bin",post_box:"postbox",drinking_water:"fountain",bicycle_parking:"rack"},Jr=new Set(["primary","secondary","tertiary","minor","service","trunk"]),jr=25,wn={street:[24,3.2],path:[18,1.3]},qr=(e)=>e.filter((t)=>t.type===1),xn=async(e,t)=>{let{z:n,x:r,y:o,id:s,maxObjects:a,priority:i}=t,c=G(e.tiles,n,r,o),l=await ee(c,i);if(!l||j.has(s))return;let u=l.get("poi"),d=l.get("transportation"),f=d?.extent??u?.extent??4096,p=f/_e(n,o),x=(d?.features??[]).filter((_)=>_.type===2&&Jr.has(String(_.properties.class))),y=(l.get("landcover")?.features??[]).filter((_)=>_.type===3&&String(_.properties.class)==="grass").map((_)=>{let g=Array.from(_.geometry[0]??[]),h=g.filter((k,v)=>v%2===0),M=g.filter((k,v)=>v%2===1);return{rings:_.geometry,bounds:[Math.min(...h),Math.min(...M),Math.max(...h),Math.max(...M)]}}),A=(_,g)=>y.some(({rings:h,bounds:[M=0,k=0,v=0,R=0]})=>_>=M&&_<=v&&g>=k&&g<=R&&ge(h,_,g)),m=[],S=(_,g,h,M,k)=>{if(_<0||g<0||_>=f||g>=f)return;let[v,R]=H(n,r,o,f,_,g);m.push(v,R,1,h,M,pt.indexOf(k))},b=jr*p,w=new Map,T=(_,g)=>(_+32768)*65536+g+32768;x.forEach((_)=>{_.geometry.forEach((g)=>{for(let h=2;h+1<g.length;h+=2){let[M,k,v,R]=[g[h-2]??0,g[h-1]??0,g[h]??0,g[h+1]??0],[W,B]=[Math.floor(Math.min(M,v)/b),Math.floor(Math.max(M,v)/b)],[O,P]=[Math.floor(Math.min(k,R)/b),Math.floor(Math.max(k,R)/b)];for(let I=W;I<=B;I+=1)for(let L=O;L<=P;L+=1){let F=w.get(T(I,L))??[];F.push(M,k,v,R),w.set(T(I,L),F)}}})});let E=(_,g,h)=>{let[M,k,v]=[b*b,0,0],[R,W]=[Math.floor(_/b),Math.floor(g/b)];for(let B=R-1;B<=R+1;B+=1)for(let O=W-1;O<=W+1;O+=1){let P=w.get(T(B,O))??[];for(let I=0;I+3<P.length;I+=4){let[L,F,C,V]=[P[I]??0,P[I+1]??0,P[I+2]??0,P[I+3]??0],[J,z]=[C-L,V-F],te=J*J+z*z,K=te>0?Math.max(0,Math.min(1,((_-L)*J+(g-F)*z)/te)):0,[ne,X]=[L+K*J-_,F+K*z-g],re=ne*ne+X*X;if(re<M)[M,k,v]=[re,ne,X]}}if(k===0&&v===0)return h;return Math.atan2(k,-v)*180/Math.PI};return qr(u?.features??[]).forEach((_)=>{let g=Hr[String(_.properties.subclass)];if(!g)return;_.geometry.forEach((h)=>{let[M,k]=[h[0]??0,h[1]??0],v=se(Math.floor(M),Math.floor(k),pt.indexOf(g),31);S(M,k,E(M,k,v*360),v,g)})}),(d?.features??[]).forEach((_)=>{let g=String(_.properties.subclass),h=String(_.properties.class)==="path"&&g==="pedestrian",M=String(_.properties.class)==="path"&&(g==="footway"||g==="path");if(_.type!==2||!(h||M))return;let[k,v]=h?wn.street:wn.path;_.geometry.forEach((R)=>{Me(R,k*p).forEach((W,B)=>{let[O=0,P=0,,,,,I=0]=W;if(M&&!A(O,P))return;let L=se(Math.floor(O),Math.floor(P),Math.floor(I),37);S(...Ge(W,B,v*p),L,"bench")})})}),Ze(m,a)};var _n={flat:1,skillion:1,hipped:2,"half-hipped":2,side_hipped:2,dome:2,onion:2,round:2,gabled:3,saltbox:3,pyramidal:4,cone:4,mansard:5,gambrel:5},$r=255,An=(e)=>e==="generated"?$r:_n[e],Mn=(e,t)=>be(e)?t.map((n)=>e[n]).find((n)=>n!==void 0):void 0,Sn=(e,t)=>{let n=Mn(e,["roof:shape","roof_shape"]);if(t==="flat")return;if(typeof n==="string"&&_n[n]!==void 0)return n;return t==="generated"?"generated":void 0},kn=(e)=>Number(Mn(e,["roof:height","roof_height"])??Number.NaN);var wt=32,q={color:0,second:4,size:8,size2:16,range:24,blur:26,landmark:26,patternRatio:27,fillPattern:28,linePattern:29};class De{static __wrap(e){let t=Object.create(De.prototype);return t.__wbg_ptr=e,vn.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,vn.unregister(this),e}free(){let e=this.__destroy_into_raw();N.__wbg_tessellatedtile_free(e,0)}blockIndices(){return N.tessellatedtile_blockIndices(this.__wbg_ptr)}blockRanges(){let e=N.tessellatedtile_blockRanges(this.__wbg_ptr);var t=Qe(e[0],e[1]).slice();return N.__wbindgen_free(e[0],e[1]*4,4),t}blocks(){return N.tessellatedtile_blocks(this.__wbg_ptr)}bounds(){let e=N.tessellatedtile_bounds(this.__wbg_ptr);var t=Gr(e[0],e[1]).slice();return N.__wbindgen_free(e[0],e[1]*8,8),t}fillRanges(){let e=N.tessellatedtile_fillRanges(this.__wbg_ptr);var t=Qe(e[0],e[1]).slice();return N.__wbindgen_free(e[0],e[1]*4,4),t}indices(){return N.tessellatedtile_indices(this.__wbg_ptr)}lineRanges(){let e=N.tessellatedtile_lineRanges(this.__wbg_ptr);var t=Qe(e[0],e[1]).slice();return N.__wbindgen_free(e[0],e[1]*4,4),t}lineTable(){return N.tessellatedtile_lineTable(this.__wbg_ptr)}pieces(){return N.tessellatedtile_pieces(this.__wbg_ptr)}prism(){return N.tessellatedtile_prism(this.__wbg_ptr)!==0}vertices(){return N.tessellatedtile_vertices(this.__wbg_ptr)}}if(Symbol.dispose)De.prototype[Symbol.dispose]=De.prototype.free;function Tn(e,t,n,r,o,s,a,i,c,l,u,d,f,p,x,y,A){let m=Xe(e,N.__wbindgen_malloc),S=Y,b=de(t,N.__wbindgen_malloc),w=Y,T=de(n,N.__wbindgen_malloc),E=Y,_=de(r,N.__wbindgen_malloc),g=Y,h=de(o,N.__wbindgen_malloc),M=Y,k=Xe(s,N.__wbindgen_malloc),v=Y,R=de(a,N.__wbindgen_malloc),W=Y,B=de(i,N.__wbindgen_malloc),O=Y,P=de(c,N.__wbindgen_malloc),I=Y,L=Rn(l,N.__wbindgen_malloc),F=Y,C=Rn(u,N.__wbindgen_malloc),V=Y,J=Qr(d,N.__wbindgen_malloc),z=Y,te=Xe(f,N.__wbindgen_malloc),K=Y,ne=de(p,N.__wbindgen_malloc),X=Y,re=Xe(A,N.__wbindgen_malloc),Se=Y,ke=N.tessellateVectorTile(m,S,b,w,T,E,_,g,h,M,k,v,R,W,B,O,P,I,L,F,C,V,J,z,te,K,ne,X,x,y,re,Se);return De.__wrap(ke)}function Yr(){return{__proto__:null,"./isard_tess_bg.js":{__proto__:null,__wbg___wbindgen_throw_41e9ee4f547fc59a:function(t,n){throw Error(Xr(t,n))},__wbg_new_from_slice_37a3c3a194266cb8:function(t,n){return new Uint32Array(Qe(t,n))},__wbg_new_from_slice_9a868026ffa4208a:function(t,n){return new Uint8Array(Zr(t,n))},__wbg_new_from_slice_ca6ad97db1f4779a:function(t,n){return new Float32Array(Kr(t,n))},__wbindgen_init_externref_table:function(){let t=N.__wbindgen_externrefs,n=t.grow(4);t.set(0,void 0),t.set(n+0,void 0),t.set(n+1,null),t.set(n+2,!0),t.set(n+3,!1)}}}}var vn=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry((e)=>N.__wbg_tessellatedtile_free(e,1));function Kr(e,t){return e=e>>>0,En().subarray(e/4,e/4+t)}function Gr(e,t){return e=e>>>0,In().subarray(e/8,e/8+t)}function Qe(e,t){return e=e>>>0,Ln().subarray(e/4,e/4+t)}function Zr(e,t){return e=e>>>0,_t().subarray(e/1,e/1+t)}var Ue=null;function En(){if(Ue===null||Ue.byteLength===0)Ue=new Float32Array(N.memory.buffer);return Ue}var Ce=null;function In(){if(Ce===null||Ce.byteLength===0)Ce=new Float64Array(N.memory.buffer);return Ce}function Xr(e,t){return to(e>>>0,t)}var We=null;function Ln(){if(We===null||We.byteLength===0)We=new Uint32Array(N.memory.buffer);return We}var Be=null;function _t(){if(Be===null||Be.byteLength===0)Be=new Uint8Array(N.memory.buffer);return Be}function de(e,t){let n=t(e.length*4,4)>>>0;return Ln().set(e,n/4),Y=e.length,n}function Rn(e,t){let n=t(e.length*1,1)>>>0;return _t().set(e,n/1),Y=e.length,n}function Qr(e,t){let n=t(e.length*4,4)>>>0;return En().set(e,n/4),Y=e.length,n}function Xe(e,t){let n=t(e.length*8,8)>>>0;return In().set(e,n/8),Y=e.length,n}var et=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});et.decode();var eo=2146435072,xt=0;function to(e,t){if(xt+=t,xt>=eo)et=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),et.decode(),xt=t;return et.decode(_t().subarray(e,e+t))}var Y=0,no,ro,N;function oo(e,t){return ro=e,N=e.exports,no=t,Ue=null,Ce=null,We=null,Be=null,N.__wbindgen_start(),N}async function so(e,t){if(typeof Response==="function"&&e instanceof Response){if(!e.ok)throw Error(`failed to fetch Wasm: ${e.status} ${e.statusText} fetching '${e.url}'`);if(typeof WebAssembly.instantiateStreaming==="function")try{return await WebAssembly.instantiateStreaming(e,t)}catch(o){if(n(e.type)&&e.headers.get("Content-Type")!=="application/wasm")console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n",o);else throw o}let r=await e.arrayBuffer();return await WebAssembly.instantiate(r,t)}else{let r=await WebAssembly.instantiate(e,t);if(r instanceof WebAssembly.Instance)return{instance:r,module:e};else return r}function n(r){switch(r){case"basic":case"cors":case"default":return!0}return!1}}async function Fn(e){if(N!==void 0)return N;if(e!==void 0)if(Object.getPrototypeOf(e)===Object.prototype)({module_or_path:e}=e);else console.warn("using deprecated parameters for the initialization function; pass a single object instead");if(e===void 0)e=new URL("isard_tess_bg.wasm",import.meta.url);let t=Yr();if(typeof e==="string"||typeof Request==="function"&&e instanceof Request||typeof URL==="function"&&e instanceof URL)e=fetch(e);let{instance:n,module:r}=await so(await e,t);return oo(n,r)}var tt=async(e,t)=>{let{z:n,x:r,y:o,id:s,priority:a}=t,i=G(e.tiles,n,r,o),c=await ee(i,a),l={points:[],ringStart:[],polygonStart:[],feature:[]},u=[];if(!c||j.has(s))return;let d=new Set,f=2**n;return e.layers.forEach((p)=>{let x=c.get(p["source-layer"]??"");if(!x)return;x.features.forEach((y)=>{if(y.type!==3||d.has(y)||!Q(p.filter,Z(y,n)))return;d.add(y);let A=u.length;u.push(y.properties),y.geometry.forEach((m)=>{let S=0;for(let b=0;b+1<m.length;b+=2){let w=(b+2)%m.length;S+=(m[b]??0)*(m[w+1]??0)-(m[w]??0)*(m[b+1]??0)}if(S===0)return;if(S>0||l.polygonStart.length===0||l.feature.at(-1)!==A)l.polygonStart.push(l.ringStart.length),l.feature.push(A);l.ringStart.push(l.points.length/2);for(let b=0;b+1<m.length;b+=2)l.points.push((r+(m[b]??0)/x.extent)/f,(o+(m[b+1]??0)/x.extent)/f)})})}),l.ringStart.push(l.points.length/2),l.polygonStart.push(l.ringStart.length-1),{arrays:{points:Float64Array.from(l.points),ringStart:Uint32Array.from(l.ringStart),polygonStart:Uint32Array.from(l.polygonStart),feature:Uint32Array.from(l.feature)},properties:u}},io=new Set(["theatre","museum","place_of_worship","castle","monument","attraction","town_hall"]),ao=(e)=>(e?.get("poi")?.features??[]).filter((t)=>t.type===1&&io.has(String(t.properties.class))).flatMap((t)=>t.geometry.flatMap((n)=>Array.from(n))),Nn=(e)=>{let[t,n,r,o]=[1/0,1/0,-1/0,-1/0];for(let s=0;s+1<e.length;s+=2)[t,n]=[Math.min(t,e[s]??0),Math.min(n,e[s+1]??0)],[r,o]=[Math.max(r,e[s]??0),Math.max(o,e[s+1]??0)];return[t,n,r,o]},co=(e,t)=>{if(t.length===0)return!1;let[n,r,o,s]=Nn(e[0]??[]);for(let a=0;a+1<t.length;a+=2){let[i,c]=[t[a]??0,t[a+1]??0];if(i>=n&&i<=o&&c>=r&&c<=s&&ge(e,i,c))return!0}return!1},lo=(e)=>{let t=e.length>2&&e[0]===e[e.length-2]&&e[1]===e[e.length-1],n=Math.max(1,e.length/2-(t?1:0)),[r,o]=[0,0];for(let s=0;s<n;s+=1)[r,o]=[r+(e[s*2]??0),o+(e[s*2+1]??0)];return[r/n,o/n]},uo=(e,t)=>{let n=e.filter((a)=>a.type===3),r=n.filter((a)=>co(a.geometry,t)),o=new Set(r);if(r.length===0)return o;let s=n.map((a)=>{let i=a.geometry[0]??[];return{f:a,box:Nn(i),middle:lo(i)}});return s.filter(({f:a})=>o.has(a)).forEach((a)=>{let[i,c,l,u]=a.box,d=a.f.geometry;s.forEach(({f,box:[p,x,y,A],middle:m})=>{if(o.has(f)||y<i||p>l||A<c||x>u)return;if(ge(d,...m)||ge(f.geometry,...a.middle))o.add(f)})}),o},fo={line:(e)=>e!==1,circle:(e)=>e===1,fill:(e)=>e===3,extrusion:(e)=>e===3},mo=(e,t)=>{let n=Sn(e,t);return[n===void 0?0:An(n)??0,kn(e)]},po=24,bo=(e,t,n,r)=>{if(!at(e.filter))return Q(e.filter,Z(t,n))?[0,0]:void 0;let o,s=0;for(let a=n-1;a<=r;a+=1)if(Q(e.filter,Z(t,a)))o??=a,s=a+1;else if(o!==void 0)break;return o===void 0?void 0:[o<=n-1?0:o,s>r?99:s]},ho=(e,t)=>{let n=Array.from(e),r=[[0,0,(o)=>o>=0],[0,t,(o)=>o<=t],[1,0,(o)=>o>=0],[1,t,(o)=>o<=t]];for(let[o,s,a]of r){let i=[],c=n.length/2;for(let l=0;l<c;l+=1){let[u,d]=[n[l*2]??0,n[l*2+1]??0],f=(l+1)%c,[p,x]=[n[f*2]??0,n[f*2+1]??0],[y,A]=o===0?[u,p]:[d,x];if(a(y))i.push(u,d);if(a(y)!==a(A)){let m=(s-y)/(A-y);i.push(o===0?s:u+(p-u)*m,o===0?d+(x-d)*m:s)}}if(n=i,n.length===0)break}return n},yo=0.00048828125,go=(e,t)=>{let n=e.length/2;if(n<=2)return Array.from(e);let r=new Uint8Array(n),o=[[0,n-1]],s=t*t;r[0]=1,r[n-1]=1;while(o.length>0){let[a,i]=o.pop()??[0,0],[c,l,u,d]=[e[a*2]??0,e[a*2+1]??0,e[i*2]??0,e[i*2+1]??0],[f,p]=[u-c,d-l],x=f*f+p*p,[y,A]=[-1,s];for(let m=a+1;m<i;m+=1){let[S,b]=[(e[m*2]??0)-c,(e[m*2+1]??0)-l],w=x>0?Math.max(0,Math.min(1,(S*f+b*p)/x)):0,T=(S-w*f)**2+(b-w*p)**2;if(T>A)[y,A]=[m,T]}if(y>=0)r[y]=1,o.push([a,y],[y,i])}return Array.from(e).filter((a,i)=>r[i>>1]===1)},wo=(e,t)=>{let n=[],r=[],o=()=>{if(r.length>=4)n.push(r);r=[]};for(let s=2;s+1<e.length;s+=2){let[a,i,c,l]=[e[s-2]??0,e[s-1]??0,e[s]??0,e[s+1]??0],[u,d]=[c-a,l-i],[f,p]=[0,1];for(let[x,y]of[[-u,a],[u,t-a],[-d,i],[d,t-i]])if(x===0){if(y<0)p=-1}else if(x<0)f=Math.max(f,y/x);else p=Math.min(p,y/x);if(f>p){o();continue}if(r.length===0||f>0)o(),r.push(a+u*f,i+d*f);if(r.push(a+u*p,i+d*p),p<1)o()}return o(),n},xo=(e,t)=>e>=t?[e-0.5,e+1,e+3,e+6]:[e-0.5,e-0.16666666666666666,e+0.16666666666666666,e+0.5],_o=(e,t,n,r,o)=>{let s=2**n,[a,i]=[r*t,o*t],c=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];e.forEach((p)=>{for(let x=0;x+1<p.length;x+=2){let[y,A]=[(p[x]??0)*s-a,(p[x+1]??0)*s-i];c[0]=Math.min(c[0]??y,y),c[1]=Math.min(c[1]??A,A),c[2]=Math.max(c[2]??y,y),c[3]=Math.max(c[3]??A,A)}});let[l=0,u=0,d=0,f=0]=c;if(d<=0||f<=0||l>=t||u>=t)return;return e.map((p)=>Array.from(p,(x,y)=>x*s-(y%2===0?a:i)))},Ao=(e)=>{let t=[],n=[],r=[],o=[];return{add:(i,c,l,u,d,f=!1)=>{let p=(b,w,T)=>U(c,"paint",b,{...l,zoom:T},w),x=`${c.type}-opacity`,y=me(c.paint?.[x]),A=(b)=>{let[w,T,E,_]=ce(p(f?"fill-outline-color":`${c.type}-color`,"#000",b))??[0,0,0,1];return[w,T,E,_*(y?Number(p(x,1,b)):1)]},m=Array(wt).fill(0),S=e[3]-e[0]>1.5?e[1]:e[3];if(m.splice(q.color,8,...A(e[0]),...A(S)),m.splice(q.range,2,...d),!f&&["fill","background","line","fill-extrusion"].includes(c.type)){let b=p(`${c.type}-pattern`,"",(e[0]+S)/2);if(typeof b==="string"&&b){let w=n.indexOf(b);m[c.type==="fill"||c.type==="background"?q.fillPattern:q.linePattern]=(w>=0?w:n.push(b)-1)+1}}if(c.type==="circle"){let b=(e[0]+S)/2,[w,T,E,_]=ce(p("circle-stroke-color","#000",b))??[0,0,0,1];m.splice(q.color,8,...A(b),w,T,E,_*Number(p("circle-stroke-opacity",1,b)))}return e.forEach((b,w)=>{if(m[q.size+w]=b,f){m[q.size+4+w]=1;return}if(c.type==="circle"){m[q.size+4+w]=Math.max(0,Number(p("circle-radius",5,b))||0),m[q.size2+w]=b,m[q.size2+4+w]=Math.max(0,Number(p("circle-stroke-width",0,b))||0);return}if(c.type==="fill-extrusion"){m[q.size+4+w]=Math.max(0,Number(p("fill-extrusion-height",0,b))||0),m[q.size2+w]=b,m[q.size2+4+w]=Math.max(0,Number(p("fill-extrusion-base",0,b))||0);return}if(c.type!=="line")return;if(w===0)m[q.blur]=Math.max(0,Number(p("line-blur",0,(e[0]+S)/2))||0);let T=Number(p("line-width",1,b)),E=Number(p("line-gap-width",0,b));m[q.size+4+w]=Math.max(0,E>0?E+2*T:T),m[q.size2+w]=b,m[q.size2+4+w]=Number(p("line-offset",0,b))||0}),t.push(...m),r.push(u),o.push(i),r.length-1},landmark:(i)=>{t[i*wt+q.landmark]=1},styles:t,patterns:n,properties:r,sublayer:o}},Mo=(e,t,n)=>{let r={points:[],ringStart:[],polygonStart:[],feature:[],roofs:[],roofHeights:[],roofOutlines:[],roofOutlineStart:[]},o={points:[],start:[],feature:[]},s={points:[],feature:[]},a={fill:[],line:[],circle:[]},i=(u,d,f)=>[(e+u/f)/n,(t+d/f)/n],c=(u,d,f)=>{r.polygonStart.push(r.ringStart.length),r.feature.push(u),r.roofs.push(d),r.roofHeights.push(f),r.roofOutlineStart.push(r.roofOutlines.length/2)},l=()=>{a.fill.push(r.polygonStart.length),a.line.push(o.start.length),a.circle.push(s.feature.length)};return{sublayer:l,background:(u)=>{c(u,0,Number.NaN),r.ringStart.push(r.points.length/2),r.points.push(e/n,t/n,(e+1)/n,t/n,(e+1)/n,(t+1)/n,e/n,(t+1)/n)},circles:(u,d,f)=>{u.forEach((p)=>{for(let x=0;x+1<p.length;x+=2){let[y=0,A=0]=[p[x],p[x+1]];if(y<0||A<0||y>=f||A>=f)continue;s.points.push(...i(y,A,f)),s.feature.push(d)}})},lines:(u,d,f,p)=>{u.forEach((x)=>{let y=d&&x.length>=2?[...Array.from(x),x[0]??0,x[1]??0]:x;wo(y,p).forEach((A)=>{let m=go(A,p*yo);o.start.push(o.points.length/2),o.feature.push(f);for(let S=0;S+1<m.length;S+=2)o.points.push(...i(m[S]??0,m[S+1]??0,p))})})},polygons:(u,d,[f,p],x)=>{let y=!1;u.forEach((A)=>{let m=0;for(let b=0;b+1<A.length;b+=2){let w=(b+2)%A.length;m+=(A[b]??0)*(A[w+1]??0)-(A[w]??0)*(A[b+1]??0)}if(m===0)return;if(m<0&&!y)return;let S=ho(A,x);if(m>0)y=S.length>=6;if(S.length<6)return;if(m>0){if(c(d,f,p),f>1&&Array.from(A).some((b)=>b<0||b>x))for(let b=0;b+1<A.length;b+=2)r.roofOutlines.push(...i(A[b]??0,A[b+1]??0,x))}r.ringStart.push(r.points.length/2);for(let b=0;b+1<S.length;b+=2)r.points.push(...i(S[b]??0,S[b+1]??0,x))})},done:()=>(l(),r.ringStart.push(r.points.length/2),r.polygonStart.push(r.ringStart.length-1),r.roofOutlineStart.push(r.roofOutlines.length/2),o.start.push(o.points.length/2),{fills:{points:Float64Array.from(r.points),ringStart:Uint32Array.from(r.ringStart),polygonStart:Uint32Array.from(r.polygonStart),feature:Uint32Array.from(r.feature),fillStart:Uint32Array.from(a.fill),roofs:Uint8Array.from(r.roofs),roofHeights:Float32Array.from(r.roofHeights),roofOutlines:Float64Array.from(r.roofOutlines),roofOutlineStart:Uint32Array.from(r.roofOutlineStart),roofMetres:rt((t+0.5)/n)},lines:{points:Float64Array.from(o.points),start:Uint32Array.from(o.start),feature:Uint32Array.from(o.feature),lineStart:Uint32Array.from(a.line)},circles:{points:Float64Array.from(s.points),feature:Uint32Array.from(s.feature),circleStart:Uint32Array.from(a.circle)},tile:Float64Array.of(e/n,t/n,(e+1)/n,(t+1)/n)})}},On=async(e,t,n)=>{let{z:r,x:o,y:s,id:a,priority:i,deepest:c=e.maxzoom,roofs:l="data",covered:u=[]}=t,d=Math.max(0,r-e.maxzoom),[f,p,x]=[r-d,Math.floor(o/2**d),Math.floor(s/2**d)],[y,A]=[o-p*2**d,s-x*2**d],m=await ee(G(e.tiles,f,p,x),i);if(j.has(a))return;let S=ao(m),b=new Map,w=(g)=>{let h=b.get(g)??(S.length>0?uo(g,S):new Set);return b.set(g,h),h},T=(g,h)=>{if(u.length===0)return!1;let M=g.geometry[0],[k,v]=[M?.[0]??0,M?.[1]??0],[R,W]=H(f,p,x,h,k,v);for(let B=0;B+3<u.length;B+=4)if(R>=(u[B]??0)&&W>=(u[B+1]??0)&&R<=(u[B+2]??0)){if(W<=(u[B+3]??0))return!0}return!1},E=Ao(xo(r,Math.max(c,e.maxzoom))),_=r>=Math.max(c,e.maxzoom)?po:r;return e.layers.forEach((g,h)=>{n?.sublayer();let M=je(g),k=g.type==="fill"&&g.paint?.["fill-outline-color"]!==void 0&&g.paint?.["fill-antialias"]!==!1;if(!M)return;if(g.type==="background"){let R=E.add(h,g,{zoom:r,properties:{},type:"Unknown"},{},[0,0]);n?.background(R);return}let v=m?.get(g["source-layer"]??"");v?.features.forEach((R)=>{if(!fo[M](R.type))return;if(M==="extrusion"&&T(R,v.extent))return;let W=Z(R,r),B=bo(g,R,r,_);if(!B)return;let O=d>0?_o(R.geometry,v.extent,d,y,A):R.geometry;if(!O)return;let P=E.add(h,g,W,R.properties,B),I=k?E.add(h,g,W,R.properties,B,!0):-1;if(M==="extrusion"&&w(v.features).has(R))E.landmark(P);if(!n)return;if(M==="circle"){n.circles(O,P,v.extent);return}if(M==="line"){n.lines(O,R.type===3,P,v.extent);return}if(I>=0)n.lines(O,!0,I,v.extent);let L=M==="extrusion"?mo(R.properties,l):[0,Number.NaN];n.polygons(O,P,L,v.extent)})}),E},Pn=async(e,t)=>{let n=await On(e,t);return n&&{styles:Float32Array.from(n.styles),patterns:n.patterns}},Un=async(e,t)=>{let n=Mo(t.x,t.y,2**t.z),r=await On(e,t,n);if(!r)return;return{...n.done(),styles:Float32Array.from(r.styles),patterns:r.patterns,properties:r.properties,sublayer:Uint16Array.from(r.sublayer)}},we={},Cn=()=>{if(!we.url)return Promise.resolve(!1);let e=we.ready??Fn({module_or_path:we.url}).then(()=>!0,(t)=>(console.warn("isard: the tessellation module failed to load, the main thread does its work",t),!1));return we.ready=e,e},Wn=(e,t,n)=>{let{fills:r,lines:o}=e;try{let s=Tn(r.points,r.ringStart,r.polygonStart,r.feature,r.fillStart,o.points,o.start,o.feature,o.lineStart,t,r.roofs??new Uint8Array,r.roofHeights??new Float32Array,r.roofOutlines??new Float64Array,r.roofOutlineStart??new Uint32Array,r.roofMetres??0,n,e.tile??new Float64Array),a={vertices:s.vertices(),indices:s.indices(),fillRanges:s.fillRanges(),prism:s.prism(),pieces:s.pieces(),lineTable:s.lineTable(),lineRanges:s.lineRanges(),blocks:s.blocks(),blockIndices:s.blockIndices(),blockRanges:s.blockRanges(),bounds:s.bounds()};return s.free(),a}catch(s){console.warn("isard: the tessellation module failed, the main thread does its work",s),we.ready=Promise.resolve(!1);return}};var So={primary:8,secondary:7,tertiary:6,minor:5,service:4},Bn=async(e,t)=>{let{z:n,x:r,y:o,id:s,spacing:a,maxLamps:i,priority:c}=t,l=G(e.tiles,n,r,o),u=await ee(l,c);if(!u||j.has(s))return;let d=_e(n,o),f=new Set,p=[];return e.layers.forEach((x)=>{let y=u.get(x["source-layer"]??"");if(!y)return;let A=y.extent/d;y.features.forEach((m)=>{let S=So[String(m.properties.class)];if(m.type!==2||S===void 0||f.has(m)||!Q(x.filter,Z(m,n)))return;f.add(m),m.geometry.forEach((b)=>{Me(b,a*A).forEach((w,T)=>{let[E,_,g]=Ge(w,T,S*A);if(E<0||_<0||E>=y.extent||_>=y.extent)return;let[h,M]=H(n,r,o,y.extent,E,_),k=se(Math.floor(E),Math.floor(_),Math.floor(w[6]??0),29);p.push(h,M,1,g,k,0)})})})}),Ze(p,i)};var ko=new Set(["butt","round","square"]),vo=new Set(["bevel","miter","round"]),Ro=(e)=>ko.has(e),To=(e)=>vo.has(e),Eo=(e)=>Ro(e)?e:"butt",Io=(e)=>To(e)?e:"miter",Lo=(e,t)=>{if(e.patterns.has(t))return e.patterns.get(t);let r=(()=>{let o=gt(e,t);if(!o||!(o.icon.width>0)||!(o.icon.height>0))return;let{icon:s}=o,a=new OffscreenCanvas(s.width,s.height);return a.getContext("2d")?.drawImage(o.image,s.x,s.y,s.width,s.height,0,0,s.width,s.height),a})();return e.patterns.set(t,r),r},At=new Map,Fo=(e)=>{let t=At.get(e)?.pop()??new OffscreenCanvas(e,e),n=t.getContext("2d",{willReadFrequently:!0});if(!n)throw Error("isard: no 2D context");return n.setTransform(1,0,0,1,0,0),n.globalAlpha=1,n.setLineDash([]),n.clearRect(0,0,e,e),{canvas:t,g:n}},No=(e)=>{let t=At.get(e.width)??[];if(At.set(e.width,t),t.length<4)t.push(e)},Oo=(e,t,n)=>{if(n)return Promise.resolve(e.transferToImageBitmap());return createImageBitmap(t.getImageData(0,0,e.width,e.height),{premultiplyAlpha:"none"})},Dn=async(e,t)=>{let{z:n,x:r,y:o,size:s,id:a,priority:i}=t,c=pn(e,n,r,o),l=await ee(c.url,i);if(j.has(a))return;let{canvas:u,g:d}=Fo(s);try{return await Po(e,c,l,u,d,n,r,o,s,a,i)}finally{No(u)}},Po=async(e,t,n,r,o,s,a,i,c,l,u)=>{let d=Math.max(0,s-1),f=c/256,p=!1,x=!1;for(let y of e.layers){if(!Pe(y,d))continue;let A={zoom:d,properties:{},type:"Unknown"};if(y.type==="background"){let g=U(y,"paint","background-color",A,"#000"),h=Number(U(y,"paint","background-opacity",A,1));if(o.fillStyle=pe(g,h),o.fillRect(0,0,c,c),(ce(g)??[0,0,0,1])[3]*h>=1)x=!0;p=!0;continue}if(y.type==="raster"){let g=y.source===void 0?void 0:e.rasters[y.source];if(!g)continue;let h=xe(s-(g.tileSize>=512?1:0),0,g.maxzoom),M=2**(s-h),k=G(g.tiles,h,Math.floor(a/M),Math.floor(i/M)),v=await mn(k,u);if(j.has(l))return;if(!v)continue;let[R,W]=[v.width/M,v.height/M];o.globalAlpha=Number(U(y,"paint","raster-opacity",A,1)),o.drawImage(v,a%M*R,i%M*W,R,W,0,0,c,c),o.globalAlpha=1,p=!0;continue}let m=n?.get(y["source-layer"]??"");if(!m)continue;let S=c/(m.extent*t.part),[b,w]=[t.ox*m.extent,t.oy*m.extent],T=(g,h)=>{o.beginPath();for(let M of g.geometry){for(let k=0;k+1<M.length;k+=2){let[v,R]=[((M[k]??0)-b)*S,((M[k+1]??0)-w)*S];if(k===0)o.moveTo(v,R);else o.lineTo(v,R)}if(h)o.closePath()}},E=new Map,_=(g,h,M,k)=>{let v=E.get(h),R=v??me(y[g]?.[h]);if(v===void 0)E.set(h,R);return U(y,g,h,R?M:A,k)};for(let g of m.features){let h=Z(g,d);if(!Q(y.filter,h))continue;if(y.type==="fill-extrusion"&&g.type===3)T(g,!0),o.fillStyle=pe(_("paint","fill-extrusion-color",h,"#000"),Number(_("paint","fill-extrusion-opacity",h,1))),o.fill("evenodd"),p=!0;else if(y.type==="fill"&&g.type===3){let M=Number(_("paint","fill-opacity",h,1)),k=_("paint","fill-pattern",h,void 0);T(g,!0);let v=typeof k==="string"?gt(e,k)?.icon:void 0,R=v&&typeof k==="string"&&Lo(e,k);if(v&&R){let W=o.createPattern(R,"repeat");if(W)W.setTransform(new DOMMatrix().scale(f/(v.pixelRatio??1))),o.globalAlpha=M,o.fillStyle=W,o.fill("evenodd"),o.globalAlpha=1}else{o.fillStyle=pe(_("paint","fill-color",h,"#000"),M),o.fill("evenodd");let W=_("paint","fill-outline-color",h,void 0);if(W!==void 0)o.strokeStyle=pe(W,M),o.lineWidth=f,o.setLineDash([]),o.stroke()}p=!0}else if(y.type==="line"&&g.type!==1){let M=Number(_("paint","line-width",h,1));if(M<=0)continue;let k=Number(_("paint","line-gap-width",h,0));o.strokeStyle=pe(_("paint","line-color",h,"#000"),Number(_("paint","line-opacity",h,1))),o.lineWidth=(k>0?k+2*M:M)*f,o.lineCap=Eo(_("layout","line-cap",h,"butt")),o.lineJoin=Io(_("layout","line-join",h,"miter"));let v=_("paint","line-dasharray",h,void 0);o.setLineDash(Array.isArray(v)?v.map((R)=>Number(R)*M*f):[]),T(g,g.type===3),o.stroke(),p=!0}else if(y.type==="circle"&&g.type===1){let M=Number(_("paint","circle-radius",h,5))*f;o.fillStyle=pe(_("paint","circle-color",h,"#000"),Number(_("paint","circle-opacity",h,1)));let k=Number(_("paint","circle-stroke-width",h,0))*f;o.strokeStyle=pe(_("paint","circle-stroke-color",h,"#000"),Number(_("paint","circle-stroke-opacity",h,1))),o.lineWidth=k;for(let v of g.geometry)for(let R=0;R+1<v.length;R+=2)if(o.beginPath(),o.arc(((v[R]??0)-b)*S,((v[R+1]??0)-w)*S,M,0,2*Math.PI),o.fill(),k>0)o.stroke();p=!0}}}if(!p&&!n)return null;return Oo(r,o,x)};var Vn=async(e,t)=>{let{z:n,tiles:r,bounds:o,width:s,height:a,iterations:i,module:c,priority:l,id:u}=t,[d,f,p,x]=o,y=[],A=[],m=[],S=2**n;for(let b=0;b+1<r.length;b+=2){let w=r[b]??0,T=(w%S+S)%S,E=(w-T)/S,_=await tt(e,{z:n,x:T,y:r[b+1]??0,id:u,priority:l});if(j.has(u))throw Error("aborted");if(!_)continue;let{points:g,ringStart:h,polygonStart:M}=_.arrays;for(let k=0;k+1<M.length;k++){let[v,R]=[M[k]??0,M[k+1]??0],W=h[v]??0,B=h[R]??0,[O,P,I,L]=[1/0,1/0,-1/0,-1/0];for(let F=W;F<B;F++){let[C,V]=[(g[F*2]??0)+E,g[F*2+1]??0];O=Math.min(O,C),P=Math.min(P,V),I=Math.max(I,C),L=Math.max(L,V)}if(I<d||O>p||L<f||P>x)continue;m.push(A.length);for(let F=v;F<R;F++){A.push(y.length/2);for(let C=h[F]??0;C<(h[F+1]??0);C++)y.push(((g[C*2]??0)+E-d)/(p-d)*s,((g[C*2+1]??0)-f)/(x-f)*a)}}}return A.push(y.length/2),m.push(A.length-1),Gt({points:Float64Array.from(y),ringStart:Uint32Array.from(A),polygonStart:Uint32Array.from(m)},s,a,i,c)};var Mt=new Map,Uo={},zn=Rt(),ue=(e,t=[])=>self.postMessage(e,t),Co=({fills:e,lines:t,circles:n,styles:r,sublayer:o,mesh:s})=>[e.points,e.ringStart,e.polygonStart,e.feature,e.fillStart,e.roofs,e.roofHeights,e.roofOutlines,e.roofOutlineStart,t.points,t.start,t.feature,t.lineStart,n?.points,n?.feature,n?.circleStart,r,o,s?.vertices,s?.indices,s?.fillRanges,s?.pieces,s?.lineTable,s?.lineRanges,s?.blocks,s?.blockIndices,s?.blockRanges,s?.bounds].flatMap((a)=>a?[a.buffer]:[]),Wo={render:async(e,t)=>{let n=await Dn(e,t);return n?[{image:n},[n]]:void 0},labels:async(e,t)=>[{labels:await hn(e,t)},[]],polygons:async(e,t)=>{let n=await tt(e,t);if(!n)return;let{points:r,ringStart:o,polygonStart:s,feature:a}=n.arrays;return[{polygons:n},[r.buffer,o.buffer,s.buffer,a.buffer]]},trees:async(e,t)=>{let n=await gn(e,t);return n&&[{trees:n},[n.buffer]]},furniture:async(e,t)=>{let n=await xn(e,t);return n&&[{furniture:n},[n.buffer]]},lamps:async(e,t)=>{let n=await Bn(e,t);return n&&[{lamps:n},[n.buffer]]},street:async(e,t)=>{let n=await Vn(e,t);return[{street:n},[n.eastU,n.eastV,n.northU,n.northV].map((r)=>r.buffer)]},vectors:async(e,t)=>{if(t.styles){let a=await Pn(e,t);return a&&[a,[a.styles.buffer]]}let n=await Un(e,t);if(!n)return;let r=Uint8Array.from(e.layers,(a)=>je(a)==="extrusion"?1:0),o=await Cn()?Wn(n,r,t.prism===!0):void 0,s=o?{...n,mesh:o}:n;return[{vectors:s},Co(s)]}},Bo=(e,t,n)=>Wo[t](e,n);self.onmessage=async({data:e})=>{if(e.type==="headers"){vt(e.rules);return}if(e.type==="tess"){we.url=e.url;return}if(e.type==="init"){if(e.workers!==void 0)Ae.capacity=un(e.workers,e.cached);Oe.set(e.key,{tiles:e.tiles,maxzoom:e.maxzoom,layers:e.layers,rasters:e.rasters??{},sprites:e.sprites??[],patterns:new Map});return}if(e.type==="drop"){Oe.get(e.key)?.sprites.forEach((t)=>{t.image.close()}),Oe.delete(e.key);return}if(e.type==="abort"){if(Ye.has(e.id))j.add(e.id);Mt.get(e.id)?.abort();return}if(e.type==="heights"||e.type==="reproject"||e.type==="grids"){await Vo(e);return}Ye.add(e.id);try{let t=Oe.get(e.key);if(!t)throw Error(`isard: no renderer ${e.key}`);let n=await Bo(t,e.type,e);if(n)ue({id:e.id,...n[0]},n[1]);else ue({id:e.id,missing:!0})}catch(t){ue({id:e.id,error:String(t)})}finally{Ye.delete(e.id),j.delete(e.id)}};var Do=async(e,t)=>(await St(e,oe(e,{signal:t}))).arrayBuffer(),Vo=async(e)=>{let t=new AbortController;Mt.set(e.id,t);try{if(e.type==="grids"){let{module:n,url:r,bytes:o}=e,s=o??(r?await Do(r,t.signal):new ArrayBuffer(0)),{grids:a,values:i}=await Zt(new Uint8Array(s),n);ue({id:e.id,grids:a,values:i},i.map((c)=>c.buffer))}else if(e.type==="heights"){let n=await Lt(e.url,e.encoding,e.floor,t.signal,Uo);if(n)ue({id:e.id,heights:n},[n.buffer]);else ue({id:e.id,missing:!0})}else{zn.cache.capacity=e.cached;let n=await zn.draw(e.job,t.signal);if(n)ue({id:e.id,image:n},[n]);else ue({id:e.id,missing:!0})}}catch(n){ue({id:e.id,error:String(n)})}finally{Mt.delete(e.id)}};
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=7BDBB96C2C5D0DA264756E2164756E21
|
|
4
4
|
//# sourceMappingURL=basemap.worker.js.map
|