@naivemap/maplibre-gl-image-layer 0.0.1-alpha.2 → 0.0.1-alpha.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.
@@ -1,15 +1,15 @@
1
- (function(X,j){typeof exports=="object"&&typeof module<"u"?module.exports=j(require("proj4")):typeof define=="function"&&define.amd?define(["proj4"],j):(X=typeof globalThis<"u"?globalThis:X||self,X.ImageLayer=j(X.proj4))})(this,function(X){"use strict";function j(e,t,r=2){const n=t&&t.length,o=n?t[0]*r:e.length;let i=ct(e,0,o,r,!0);const s=[];if(!i||i.next===i.prev)return s;let a,u,c;if(n&&(i=Nr(e,t,i,r)),e.length>80*r){a=1/0,u=1/0;let l=-1/0,m=-1/0;for(let x=r;x<o;x+=r){const d=e[x],f=e[x+1];d<a&&(a=d),f<u&&(u=f),d>l&&(l=d),f>m&&(m=f)}c=Math.max(l-a,m-u),c=c!==0?32767/c:0}return J(i,s,r,a,u,c,0),s}function ct(e,t,r,n,o){let i;if(o===zr(e,t,r,n)>0)for(let s=t;s<r;s+=n)i=xt(s/n|0,e[s],e[s+1],i);else for(let s=r-n;s>=t;s-=n)i=xt(s/n|0,e[s],e[s+1],i);return i&&Z(i,i.next)&&(re(i),i=i.next),i}function C(e,t){if(!e)return e;t||(t=e);let r=e,n;do if(n=!1,!r.steiner&&(Z(r,r.next)||b(r.prev,r,r.next)===0)){if(re(r),r=t=r.prev,r===r.next)break;n=!0}else r=r.next;while(n||r!==t);return t}function J(e,t,r,n,o,i,s){if(!e)return;!s&&i&&wr(e,n,o,i);let a=e;for(;e.prev!==e.next;){const u=e.prev,c=e.next;if(i?Pr(e,n,o,i):Rr(e)){t.push(u.i,e.i,c.i),re(e),e=c.next,a=c.next;continue}if(e=c,e===a){s?s===1?(e=vr(C(e),t),J(e,t,r,n,o,i,2)):s===2&&gr(e,t,r,n,o,i):J(C(e),t,r,n,o,i,1);break}}}function Rr(e){const t=e.prev,r=e,n=e.next;if(b(t,r,n)>=0)return!1;const o=t.x,i=r.x,s=n.x,a=t.y,u=r.y,c=n.y,l=Math.min(o,i,s),m=Math.min(a,u,c),x=Math.max(o,i,s),d=Math.max(a,u,c);let f=n.next;for(;f!==t;){if(f.x>=l&&f.x<=x&&f.y>=m&&f.y<=d&&ee(o,a,i,u,s,c,f.x,f.y)&&b(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Pr(e,t,r,n){const o=e.prev,i=e,s=e.next;if(b(o,i,s)>=0)return!1;const a=o.x,u=i.x,c=s.x,l=o.y,m=i.y,x=s.y,d=Math.min(a,u,c),f=Math.min(l,m,x),h=Math.max(a,u,c),p=Math.max(l,m,x),T=Ue(d,f,t,r,n),F=Ue(h,p,t,r,n);let y=e.prevZ,_=e.nextZ;for(;y&&y.z>=T&&_&&_.z<=F;){if(y.x>=d&&y.x<=h&&y.y>=f&&y.y<=p&&y!==o&&y!==s&&ee(a,l,u,m,c,x,y.x,y.y)&&b(y.prev,y,y.next)>=0||(y=y.prevZ,_.x>=d&&_.x<=h&&_.y>=f&&_.y<=p&&_!==o&&_!==s&&ee(a,l,u,m,c,x,_.x,_.y)&&b(_.prev,_,_.next)>=0))return!1;_=_.nextZ}for(;y&&y.z>=T;){if(y.x>=d&&y.x<=h&&y.y>=f&&y.y<=p&&y!==o&&y!==s&&ee(a,l,u,m,c,x,y.x,y.y)&&b(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;_&&_.z<=F;){if(_.x>=d&&_.x<=h&&_.y>=f&&_.y<=p&&_!==o&&_!==s&&ee(a,l,u,m,c,x,_.x,_.y)&&b(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function vr(e,t){let r=e;do{const n=r.prev,o=r.next.next;!Z(n,o)&&lt(n,r,r.next,o)&&te(n,o)&&te(o,n)&&(t.push(n.i,r.i,o.i),re(r),re(r.next),r=e=o),r=r.next}while(r!==e);return C(r)}function gr(e,t,r,n,o,i){let s=e;do{let a=s.next.next;for(;a!==s.prev;){if(s.i!==a.i&&Or(s,a)){let u=mt(s,a);s=C(s,s.next),u=C(u,u.next),J(s,t,r,n,o,i,0),J(u,t,r,n,o,i,0);return}a=a.next}s=s.next}while(s!==e)}function Nr(e,t,r,n){const o=[];for(let i=0,s=t.length;i<s;i++){const a=t[i]*n,u=i<s-1?t[i+1]*n:e.length,c=ct(e,a,u,n,!1);c===c.next&&(c.steiner=!0),o.push(Cr(c))}o.sort(Ur);for(let i=0;i<o.length;i++)r=Br(o[i],r);return r}function Ur(e,t){let r=e.x-t.x;if(r===0&&(r=e.y-t.y,r===0)){const n=(e.next.y-e.y)/(e.next.x-e.x),o=(t.next.y-t.y)/(t.next.x-t.x);r=n-o}return r}function Br(e,t){const r=Dr(e,t);if(!r)return t;const n=mt(r,e);return C(n,n.next),C(r,r.next)}function Dr(e,t){let r=t;const n=e.x,o=e.y;let i=-1/0,s;if(Z(e,r))return r;do{if(Z(e,r.next))return r.next;if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){const m=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(m<=n&&m>i&&(i=m,s=r.x<r.next.x?r:r.next,m===n))return s}r=r.next}while(r!==t);if(!s)return null;const a=s,u=s.x,c=s.y;let l=1/0;r=s;do{if(n>=r.x&&r.x>=u&&n!==r.x&&ft(o<c?n:i,o,u,c,o<c?i:n,o,r.x,r.y)){const m=Math.abs(o-r.y)/(n-r.x);te(r,e)&&(m<l||m===l&&(r.x>s.x||r.x===s.x&&Lr(s,r)))&&(s=r,l=m)}r=r.next}while(r!==a);return s}function Lr(e,t){return b(e.prev,e,t.prev)<0&&b(t.next,e,e.next)<0}function wr(e,t,r,n){let o=e;do o.z===0&&(o.z=Ue(o.x,o.y,t,r,n)),o.prevZ=o.prev,o.nextZ=o.next,o=o.next;while(o!==e);o.prevZ.nextZ=null,o.prevZ=null,Mr(o)}function Mr(e){let t,r=1;do{let n=e,o;e=null;let i=null;for(t=0;n;){t++;let s=n,a=0;for(let c=0;c<r&&(a++,s=s.nextZ,!!s);c++);let u=r;for(;a>0||u>0&&s;)a!==0&&(u===0||!s||n.z<=s.z)?(o=n,n=n.nextZ,a--):(o=s,s=s.nextZ,u--),i?i.nextZ=o:e=o,o.prevZ=i,i=o;n=s}i.nextZ=null,r*=2}while(t>1);return e}function Ue(e,t,r,n,o){return e=(e-r)*o|0,t=(t-n)*o|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function Cr(e){let t=e,r=e;do(t.x<r.x||t.x===r.x&&t.y<r.y)&&(r=t),t=t.next;while(t!==e);return r}function ft(e,t,r,n,o,i,s,a){return(o-s)*(t-a)>=(e-s)*(i-a)&&(e-s)*(n-a)>=(r-s)*(t-a)&&(r-s)*(i-a)>=(o-s)*(n-a)}function ee(e,t,r,n,o,i,s,a){return!(e===s&&t===a)&&ft(e,t,r,n,o,i,s,a)}function Or(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!Gr(e,t)&&(te(e,t)&&te(t,e)&&kr(e,t)&&(b(e.prev,e,t.prev)||b(e,t.prev,t))||Z(e,t)&&b(e.prev,e,e.next)>0&&b(t.prev,t,t.next)>0)}function b(e,t,r){return(t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function Z(e,t){return e.x===t.x&&e.y===t.y}function lt(e,t,r,n){const o=me(b(e,t,r)),i=me(b(e,t,n)),s=me(b(r,n,e)),a=me(b(r,n,t));return!!(o!==i&&s!==a||o===0&&le(e,r,t)||i===0&&le(e,n,t)||s===0&&le(r,e,n)||a===0&&le(r,t,n))}function le(e,t,r){return t.x<=Math.max(e.x,r.x)&&t.x>=Math.min(e.x,r.x)&&t.y<=Math.max(e.y,r.y)&&t.y>=Math.min(e.y,r.y)}function me(e){return e>0?1:e<0?-1:0}function Gr(e,t){let r=e;do{if(r.i!==e.i&&r.next.i!==e.i&&r.i!==t.i&&r.next.i!==t.i&&lt(r,r.next,e,t))return!0;r=r.next}while(r!==e);return!1}function te(e,t){return b(e.prev,e,e.next)<0?b(e,t,e.next)>=0&&b(e,e.prev,t)>=0:b(e,t,e.prev)<0||b(e,e.next,t)<0}function kr(e,t){let r=e,n=!1;const o=(e.x+t.x)/2,i=(e.y+t.y)/2;do r.y>i!=r.next.y>i&&r.next.y!==r.y&&o<(r.next.x-r.x)*(i-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next;while(r!==e);return n}function mt(e,t){const r=Be(e.i,e.x,e.y),n=Be(t.i,t.x,t.y),o=e.next,i=t.prev;return e.next=t,t.prev=e,r.next=o,o.prev=r,n.next=r,r.prev=n,i.next=n,n.prev=i,n}function xt(e,t,r,n){const o=Be(e,t,r);return n?(o.next=n.next,o.prev=n,n.next.prev=o,n.next=o):(o.prev=o,o.next=o),o}function re(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Be(e,t,r){return{i:e,x:t,y:r,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function zr(e,t,r,n){let o=0;for(let i=t,s=r-n;i<r;i+=n)o+=(e[s]-e[i])*(e[i+1]+e[s+1]),s=i;return o}function dt(e){const t=[],r=[],n=e[0][0].length;let o=0,i=0;for(const s of e){for(const a of s)for(let u=0;u<n;u++)t.push(a[u]);i&&(o+=i,r.push(o)),i=s.length}return{vertices:t,holes:r,dimensions:n}}/* @license twgl.js 5.5.4 Copyright (c) 2015, Gregg Tavares All Rights Reserved.
1
+ (function(j,X){typeof exports=="object"&&typeof module<"u"?module.exports=X(require("proj4")):typeof define=="function"&&define.amd?define(["proj4"],X):(j=typeof globalThis<"u"?globalThis:j||self,j.ImageLayer=X(j.proj4))})(this,function(j){"use strict";function X(e){if(!e||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);return t===null||t===Object.prototype||Object.getPrototypeOf(t)===null?Object.prototype.toString.call(e)==="[object Object]":!1}function Pr(e){return e==="__proto__"}function q(e,t){const r=Object.keys(t);for(let n=0;n<r.length;n++){const o=r[n];if(Pr(o))continue;const i=t[o],s=e[o];Array.isArray(i)?Array.isArray(s)?e[o]=q(s,i):e[o]=q([],i):X(i)?X(s)?e[o]=q(s,i):e[o]=q({},i):(s===void 0||i!==void 0)&&(e[o]=i)}return e}/* @license twgl.js 5.5.4 Copyright (c) 2015, Gregg Tavares All Rights Reserved.
2
2
  Available via the MIT license.
3
- see: http://github.com/greggman/twgl.js for details */const De=5120,ne=5121,Le=5122,we=5123,Me=5124,Ce=5125,Oe=5126,Vr=32819,$r=32820,Hr=33635,Xr=5131,jr=33640,Zr=35899,Wr=35902,Yr=36269,Kr=34042,ht={};{const e=ht;e[De]=Int8Array,e[ne]=Uint8Array,e[Le]=Int16Array,e[we]=Uint16Array,e[Me]=Int32Array,e[Ce]=Uint32Array,e[Oe]=Float32Array,e[Vr]=Uint16Array,e[$r]=Uint16Array,e[Hr]=Uint16Array,e[Xr]=Uint16Array,e[jr]=Uint32Array,e[Zr]=Uint32Array,e[Wr]=Uint32Array,e[Yr]=Uint32Array,e[Kr]=Uint32Array}function Ge(e){if(e instanceof Int8Array)return De;if(e instanceof Uint8Array||e instanceof Uint8ClampedArray)return ne;if(e instanceof Int16Array)return Le;if(e instanceof Uint16Array)return we;if(e instanceof Int32Array)return Me;if(e instanceof Uint32Array)return Ce;if(e instanceof Float32Array)return Oe;throw new Error("unsupported typed array type")}function yt(e){if(e===Int8Array)return De;if(e===Uint8Array||e===Uint8ClampedArray)return ne;if(e===Int16Array)return Le;if(e===Uint16Array)return we;if(e===Int32Array)return Me;if(e===Uint32Array)return Ce;if(e===Float32Array)return Oe;throw new Error("unsupported typed array type")}function Et(e){const t=ht[e];if(!t)throw new Error("unknown gl type");return t}const xe=typeof SharedArrayBuffer<"u"?function(t){return t&&t.buffer&&(t.buffer instanceof ArrayBuffer||t.buffer instanceof SharedArrayBuffer)}:function(t){return t&&t.buffer&&t.buffer instanceof ArrayBuffer};function _t(...e){console.error(...e)}const pt=new Map;function ke(e,t){if(!e||typeof e!="object")return!1;let r=pt.get(t);r||(r=new WeakMap,pt.set(t,r));let n=r.get(e);if(n===void 0){const o=Object.prototype.toString.call(e);n=o.substring(8,o.length-1)===t,r.set(e,n)}return n}function Qr(e,t){return typeof WebGLBuffer<"u"&&ke(t,"WebGLBuffer")}function Tt(e,t){return typeof WebGLTexture<"u"&&ke(t,"WebGLTexture")}function qr(e,t){return typeof WebGLSampler<"u"&&ke(t,"WebGLSampler")}const At=35044,O=34962,Jr=34963,en=34660,tn=5120,rn=5121,nn=5122,on=5123,sn=5124,an=5125,bt=5126,St={attribPrefix:""};function un(e,t,r,n,o){e.bindBuffer(t,r),e.bufferData(t,n,o||At)}function It(e,t,r,n){if(Qr(e,t))return t;r=r||O;const o=e.createBuffer();return un(e,r,o,t,n),o}function Ft(e){return e==="indices"}function cn(e){return e===Int8Array||e===Uint8Array}function fn(e){return e.length?e:e.data}const ln=/coord|texture/i,mn=/color|colour/i;function xn(e,t){let r;if(ln.test(e)?r=2:mn.test(e)?r=4:r=3,t%r>0)throw new Error(`Can not guess numComponents for attribute '${e}'. Tried ${r} but ${t} values is not evenly divisible by ${r}. You should specify it.`);return r}function dn(e,t,r){return e.numComponents||e.size||xn(t,r||fn(e).length)}function Rt(e,t){if(xe(e))return e;if(xe(e.data))return e.data;Array.isArray(e)&&(e={data:e});let r=e.type?ze(e.type):void 0;return r||(Ft(t)?r=Uint16Array:r=Float32Array),new r(e.data)}function hn(e){return typeof e=="number"?e:e?yt(e):bt}function ze(e){return typeof e=="number"?Et(e):e||Float32Array}function yn(e,t){return{buffer:t.buffer,numValues:2*3*4,type:hn(t.type),arrayType:ze(t.type)}}function En(e,t){const r=t.data||t,n=ze(t.type),o=r*n.BYTES_PER_ELEMENT,i=e.createBuffer();return e.bindBuffer(O,i),e.bufferData(O,o,t.drawType||At),{buffer:i,numValues:r,type:yt(n),arrayType:n}}function _n(e,t,r){const n=Rt(t,r);return{arrayType:n.constructor,buffer:It(e,n,void 0,t.drawType),type:Ge(n),numValues:0}}function pn(e,t){const r={};return Object.keys(t).forEach(function(n){if(!Ft(n)){const o=t[n],i=o.attrib||o.name||o.attribName||St.attribPrefix+n;if(o.value){if(!Array.isArray(o.value)&&!xe(o.value))throw new Error("array.value is not array or typedarray");r[i]={value:o.value}}else{let s;o.buffer&&o.buffer instanceof WebGLBuffer?s=yn:typeof o=="number"||typeof o.data=="number"?s=En:s=_n;const{buffer:a,type:u,numValues:c,arrayType:l}=s(e,o,n),m=o.normalize!==void 0?o.normalize:cn(l),x=dn(o,n,c);r[i]={buffer:a,numComponents:x,type:u,normalize:m,stride:o.stride||0,offset:o.offset||0,divisor:o.divisor===void 0?void 0:o.divisor,drawType:o.drawType}}}}),e.bindBuffer(O,null),r}function Tn(e,t){return t===tn||t===rn?1:t===nn||t===on?2:t===sn||t===an||t===bt?4:0}const Ve=["position","positions","a_position"];function An(e,t){let r,n;for(n=0;n<Ve.length&&(r=Ve[n],!(r in t||(r=St.attribPrefix+r,r in t)));++n);n===Ve.length&&(r=Object.keys(t)[0]);const o=t[r];if(!o.buffer)return 1;e.bindBuffer(O,o.buffer);const i=e.getBufferParameter(O,en);e.bindBuffer(O,null);const s=Tn(e,o.type),a=i/s,u=o.numComponents||o.size,c=a/u;if(c%1!==0)throw new Error(`numComponents ${u} not correct for length ${length}`);return c}function $e(e,t,r){const n=pn(e,t),o=Object.assign({},r||{});o.attribs=Object.assign({},r?r.attribs:{},n);const i=t.indices;if(i){const s=Rt(i,"indices");o.indices=It(e,s,Jr),o.numElements=s.length,o.elementType=Ge(s)}else o.numElements||(o.numElements=An(e,o.attribs));return o}function oe(e){return!!e.texStorage2D}const Pt=function(){const e={},t={};function r(n){const o=n.constructor.name;if(!e[o]){for(const i in n)if(typeof n[i]=="number"){const s=t[n[i]];t[n[i]]=s?`${s} | ${i}`:i}e[o]=!0}}return function(o,i){return r(o),t[i]||(typeof i=="number"?`0x${i.toString(16)}`:i)}}(),B={textureColor:new Uint8Array([128,192,255,255]),textureOptions:{},crossOrigin:void 0},ie=xe,vt=function(){let e;return function(){return e=e||(typeof document<"u"&&document.createElement?document.createElement("canvas").getContext("2d"):null),e}}(),gt=6406,N=6407,S=6408,Nt=6409,Ut=6410,se=6402,Bt=34041,de=33071,bn=9728,Sn=9729,D=3553,L=34067,G=32879,k=35866,He=34069,In=34070,Fn=34071,Rn=34072,Pn=34073,vn=34074,Xe=10241,je=10240,he=10242,ye=10243,Dt=32882,gn=33082,Nn=33083,Un=33084,Bn=33085,Dn=34892,Ln=34893,Ze=3317,Lt=3314,wt=32878,Mt=3316,Ct=3315,Ot=32877,wn=37443,Mn=37441,Cn=37440,On=33321,Gn=36756,kn=33325,zn=33326,Vn=33330,$n=33329,Hn=33338,Xn=33337,jn=33340,Zn=33339,Wn=33323,Yn=36757,Kn=33327,Qn=33328,qn=33336,Jn=33335,eo=33332,to=33331,ro=33334,no=33333,oo=32849,io=35905,so=36194,ao=36758,uo=35898,co=35901,fo=34843,lo=34837,mo=36221,xo=36239,ho=36215,yo=36233,Eo=36209,_o=36227,po=32856,To=35907,Ao=36759,bo=32855,So=32854,Io=32857,Fo=34842,Ro=34836,Po=36220,vo=36238,go=36975,No=36214,Uo=36232,Bo=36226,Do=36208,Lo=33189,wo=33190,Mo=36012,Co=36013,Oo=35056,w=5120,A=5121,Ee=5122,W=5123,_e=5124,z=5125,R=5126,Gt=32819,kt=32820,zt=33635,g=5131,ae=36193,We=33640,Go=35899,ko=35902,zo=36269,Vo=34042,pe=33319,Y=33320,Te=6403,K=36244,Q=36248,V=36249;let Ye;function Ae(e){if(!Ye){const t={};t[gt]={textureFormat:gt,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1,2,2,4],type:[A,g,ae,R]},t[Nt]={textureFormat:Nt,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1,2,2,4],type:[A,g,ae,R]},t[Ut]={textureFormat:Ut,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[2,4,4,8],type:[A,g,ae,R]},t[N]={textureFormat:N,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3,6,6,12,2],type:[A,g,ae,R,zt]},t[S]={textureFormat:S,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,8,8,16,2,2],type:[A,g,ae,R,Gt,kt]},t[se]={textureFormat:se,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2,4],type:[z,W]},t[On]={textureFormat:Te,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1],type:[A]},t[Gn]={textureFormat:Te,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[1],type:[w]},t[kn]={textureFormat:Te,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[4,2],type:[R,g]},t[zn]={textureFormat:Te,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[4],type:[R]},t[Vn]={textureFormat:K,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[1],type:[A]},t[$n]={textureFormat:K,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[1],type:[w]},t[eo]={textureFormat:K,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[W]},t[to]={textureFormat:K,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[Ee]},t[ro]={textureFormat:K,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[z]},t[no]={textureFormat:K,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[_e]},t[Wn]={textureFormat:pe,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[2],type:[A]},t[Yn]={textureFormat:pe,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[2],type:[w]},t[Kn]={textureFormat:pe,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[8,4],type:[R,g]},t[Qn]={textureFormat:pe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[8],type:[R]},t[qn]={textureFormat:Y,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[A]},t[Jn]={textureFormat:Y,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[w]},t[Hn]={textureFormat:Y,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[W]},t[Xn]={textureFormat:Y,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[Ee]},t[jn]={textureFormat:Y,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[z]},t[Zn]={textureFormat:Y,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[_e]},t[oo]={textureFormat:N,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3],type:[A]},t[io]={textureFormat:N,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[3],type:[A]},t[so]={textureFormat:N,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3,2],type:[A,zt]},t[ao]={textureFormat:N,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[3],type:[w]},t[uo]={textureFormat:N,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6,4],type:[R,g,Go]},t[co]={textureFormat:N,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6,4],type:[R,g,ko]},t[fo]={textureFormat:N,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6],type:[R,g]},t[lo]={textureFormat:N,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[R]},t[mo]={textureFormat:Q,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[3],type:[A]},t[xo]={textureFormat:Q,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[3],type:[w]},t[ho]={textureFormat:Q,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[6],type:[W]},t[yo]={textureFormat:Q,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[6],type:[Ee]},t[Eo]={textureFormat:Q,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[z]},t[_o]={textureFormat:Q,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[_e]},t[po]={textureFormat:S,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[A]},t[To]={textureFormat:S,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[A]},t[Ao]={textureFormat:S,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[4],type:[w]},t[bo]={textureFormat:S,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,2,4],type:[A,kt,We]},t[So]={textureFormat:S,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,2],type:[A,Gt]},t[Io]={textureFormat:S,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[We]},t[Fo]={textureFormat:S,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[16,8],type:[R,g]},t[Ro]={textureFormat:S,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[16],type:[R]},t[Po]={textureFormat:V,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[A]},t[vo]={textureFormat:V,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[w]},t[go]={textureFormat:V,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[We]},t[No]={textureFormat:V,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[W]},t[Uo]={textureFormat:V,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[Ee]},t[Bo]={textureFormat:V,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[16],type:[_e]},t[Do]={textureFormat:V,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[16],type:[z]},t[Lo]={textureFormat:se,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2,4],type:[W,z]},t[wo]={textureFormat:se,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[z]},t[Mo]={textureFormat:se,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[R]},t[Oo]={textureFormat:Bt,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[Vo]},t[Co]={textureFormat:Bt,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[zo]},Object.keys(t).forEach(function(r){const n=t[r];n.bytesPerElementMap={},n.bytesPerElement.forEach(function(o,i){const s=n.type[i];n.bytesPerElementMap[s]=o})}),Ye=t}return Ye[e]}function $o(e,t){const r=Ae(e);if(!r)throw"unknown internal format";const n=r.bytesPerElementMap[t];if(n===void 0)throw"unknown internal format";return n}function ue(e){const t=Ae(e);if(!t)throw"unknown internal format";return{format:t.textureFormat,type:t.type[0]}}function Vt(e){return(e&e-1)===0}function Ho(e,t,r,n){if(!oe(e))return Vt(t)&&Vt(r);const o=Ae(n);if(!o)throw"unknown internal format";return o.colorRenderable&&o.textureFilterable}function Xo(e){const t=Ae(e);if(!t)throw"unknown internal format";return t.textureFilterable}function jo(e,t,r){return ie(t)?Ge(t):r||A}function be(e,t,r,n,o){if(o%1!==0)throw"can't guess dimensions";if(!r&&!n){const i=Math.sqrt(o/(t===L?6:1));i%1===0?(r=i,n=i):(r=o,n=1)}else if(n){if(!r&&(r=o/n,r%1))throw"can't guess dimensions"}else if(n=o/r,n%1)throw"can't guess dimensions";return{width:r,height:n}}function q(e,t){t.colorspaceConversion!==void 0&&e.pixelStorei(wn,t.colorspaceConversion),t.premultiplyAlpha!==void 0&&e.pixelStorei(Mn,t.premultiplyAlpha),t.flipY!==void 0&&e.pixelStorei(Cn,t.flipY)}function $t(e){e.pixelStorei(Ze,4),oe(e)&&(e.pixelStorei(Lt,0),e.pixelStorei(wt,0),e.pixelStorei(Mt,0),e.pixelStorei(Ct,0),e.pixelStorei(Ot,0))}function Zo(e,t,r,n){n.minMag&&(r.call(e,t,Xe,n.minMag),r.call(e,t,je,n.minMag)),n.min&&r.call(e,t,Xe,n.min),n.mag&&r.call(e,t,je,n.mag),n.wrap&&(r.call(e,t,he,n.wrap),r.call(e,t,ye,n.wrap),(t===G||qr(e,t))&&r.call(e,t,Dt,n.wrap)),n.wrapR&&r.call(e,t,Dt,n.wrapR),n.wrapS&&r.call(e,t,he,n.wrapS),n.wrapT&&r.call(e,t,ye,n.wrapT),n.minLod!==void 0&&r.call(e,t,gn,n.minLod),n.maxLod!==void 0&&r.call(e,t,Nn,n.maxLod),n.baseLevel!==void 0&&r.call(e,t,Un,n.baseLevel),n.maxLevel!==void 0&&r.call(e,t,Bn,n.maxLevel),n.compareFunc!==void 0&&r.call(e,t,Ln,n.compareFunc),n.compareMode!==void 0&&r.call(e,t,Dn,n.compareMode)}function Ht(e,t,r){const n=r.target||D;e.bindTexture(n,t),Zo(e,n,e.texParameteri,r)}function Wo(e){return e=e||B.textureColor,ie(e)?e:new Uint8Array([e[0]*255,e[1]*255,e[2]*255,e[3]*255])}function Ke(e,t,r,n,o,i){r=r||B.textureOptions,i=i||S;const s=r.target||D;if(n=n||r.width,o=o||r.height,e.bindTexture(s,t),Ho(e,n,o,i))e.generateMipmap(s);else{const a=Xo(i)?Sn:bn;e.texParameteri(s,Xe,a),e.texParameteri(s,je,a),e.texParameteri(s,he,de),e.texParameteri(s,ye,de)}}function ce(e){return e.auto===!0||e.auto===void 0&&e.level===void 0}function Qe(e,t){return t=t||{},t.cubeFaceOrder||[He,In,Fn,Rn,Pn,vn]}function qe(e,t){const n=Qe(e,t).map(function(o,i){return{face:o,ndx:i}});return n.sort(function(o,i){return o.face-i.face}),n}function Xt(e,t,r,n){n=n||B.textureOptions;const o=n.target||D,i=n.level||0;let s=r.width,a=r.height;const u=n.internalFormat||n.format||S,c=ue(u),l=n.format||c.format,m=n.type||c.type;if(q(e,n),e.bindTexture(o,t),o===L){const x=r.width,d=r.height;let f,h;if(x/6===d)f=d,h=[0,0,1,0,2,0,3,0,4,0,5,0];else if(d/6===x)f=x,h=[0,0,0,1,0,2,0,3,0,4,0,5];else if(x/3===d/2)f=x/3,h=[0,0,1,0,2,0,0,1,1,1,2,1];else if(x/2===d/3)f=x/2,h=[0,0,1,0,0,1,1,1,0,2,1,2];else throw"can't figure out cube map from element: "+(r.src?r.src:r.nodeName);const p=vt();p?(p.canvas.width=f,p.canvas.height=f,s=f,a=f,qe(e,n).forEach(function(T){const F=h[T.ndx*2+0]*f,y=h[T.ndx*2+1]*f;p.drawImage(r,F,y,f,f,0,0,f,f),e.texImage2D(T.face,i,u,l,m,p.canvas)}),p.canvas.width=1,p.canvas.height=1):typeof createImageBitmap<"u"&&(s=f,a=f,qe(e,n).forEach(function(T){const F=h[T.ndx*2+0]*f,y=h[T.ndx*2+1]*f;e.texImage2D(T.face,i,u,f,f,0,l,m,null),createImageBitmap(r,F,y,f,f,{premultiplyAlpha:"none",colorSpaceConversion:"none"}).then(function(_){q(e,n),e.bindTexture(o,t),e.texImage2D(T.face,i,u,l,m,_),ce(n)&&Ke(e,t,n,s,a,u)})}))}else if(o===G||o===k){const x=Math.min(r.width,r.height),d=Math.max(r.width,r.height),f=d/x;if(f%1!==0)throw"can not compute 3D dimensions of element";const h=r.width===d?1:0,p=r.height===d?1:0;e.pixelStorei(Ze,1),e.pixelStorei(Lt,r.width),e.pixelStorei(wt,0),e.pixelStorei(Ot,0),e.texImage3D(o,i,u,x,x,x,0,l,m,null);for(let T=0;T<f;++T){const F=T*x*h,y=T*x*p;e.pixelStorei(Mt,F),e.pixelStorei(Ct,y),e.texSubImage3D(o,i,0,0,T,x,x,1,l,m,r)}$t(e)}else e.texImage2D(o,i,u,l,m,r);ce(n)&&Ke(e,t,n,s,a,u),Ht(e,t,n)}function fe(){}function Yo(e){if(typeof document<"u"){const t=document.createElement("a");return t.href=e,t.hostname===location.hostname&&t.port===location.port&&t.protocol===location.protocol}else{const t=new URL(location.href).origin;return new URL(e,location.href).origin===t}}function Ko(e,t){return t===void 0&&!Yo(e)?"anonymous":t}function Qo(e,t,r){r=r||fe;let n;if(t=t!==void 0?t:B.crossOrigin,t=Ko(e,t),typeof Image<"u"){n=new Image,t!==void 0&&(n.crossOrigin=t);const o=function(){n.removeEventListener("error",i),n.removeEventListener("load",s),n=null},i=function(){const u="couldn't load image: "+e;_t(u),r(u,n),o()},s=function(){r(null,n),o()};return n.addEventListener("error",i),n.addEventListener("load",s),n.src=e,n}else if(typeof ImageBitmap<"u"){let o,i;const s=function(){r(o,i)},a={};t&&(a.mode="cors"),fetch(e,a).then(function(u){if(!u.ok)throw u;return u.blob()}).then(function(u){return createImageBitmap(u,{premultiplyAlpha:"none",colorSpaceConversion:"none"})}).then(function(u){i=u,setTimeout(s)}).catch(function(u){o=u,setTimeout(s)}),n=null}return n}function jt(e){return typeof ImageBitmap<"u"&&e instanceof ImageBitmap||typeof ImageData<"u"&&e instanceof ImageData||typeof HTMLElement<"u"&&e instanceof HTMLElement}function Je(e,t,r){return jt(e)?(setTimeout(function(){r(null,e)}),e):Qo(e,t,r)}function et(e,t,r){r=r||B.textureOptions;const n=r.target||D;if(e.bindTexture(n,t),r.color===!1)return;const o=Wo(r.color);if(n===L)for(let i=0;i<6;++i)e.texImage2D(He+i,0,S,1,1,0,S,A,o);else n===G||n===k?e.texImage3D(n,0,S,1,1,1,0,S,A,o):e.texImage2D(n,0,S,1,1,0,S,A,o)}function qo(e,t,r,n){return n=n||fe,r=r||B.textureOptions,et(e,t,r),r=Object.assign({},r),Je(r.src,r.crossOrigin,function(i,s){i?n(i,t,s):(Xt(e,t,s,r),n(null,t,s))})}function Jo(e,t,r,n){n=n||fe;const o=r.src;if(o.length!==6)throw"there must be 6 urls for a cubemap";const i=r.level||0,s=r.internalFormat||r.format||S,a=ue(s),u=r.format||a.format,c=r.type||A,l=r.target||D;if(l!==L)throw"target must be TEXTURE_CUBE_MAP";et(e,t,r),r=Object.assign({},r);let m=6;const x=[],d=Qe(e,r);let f;function h(p){return function(T,F){--m,T?x.push(T):F.width!==F.height?x.push("cubemap face img is not a square: "+F.src):(q(e,r),e.bindTexture(l,t),m===5?Qe().forEach(function(y){e.texImage2D(y,i,s,u,c,F)}):e.texImage2D(p,i,s,u,c,F),ce(r)&&e.generateMipmap(l)),m===0&&n(x.length?x:void 0,t,f)}}f=o.map(function(p,T){return Je(p,r.crossOrigin,h(d[T]))})}function ei(e,t,r,n){n=n||fe;const o=r.src,i=r.internalFormat||r.format||S,s=ue(i),a=r.format||s.format,u=r.type||A,c=r.target||k;if(c!==G&&c!==k)throw"target must be TEXTURE_3D or TEXTURE_2D_ARRAY";et(e,t,r),r=Object.assign({},r);let l=o.length;const m=[];let x;const d=r.level||0;let f=r.width,h=r.height;const p=o.length;let T=!0;function F(y){return function(_,$){if(--l,_)m.push(_);else{if(q(e,r),e.bindTexture(c,t),T){T=!1,f=r.width||$.width,h=r.height||$.height,e.texImage3D(c,d,i,f,h,p,0,a,u,null);for(let H=0;H<p;++H)e.texSubImage3D(c,d,0,0,H,f,h,1,a,u,$)}else{let H=$,U;($.width!==f||$.height!==h)&&(U=vt(),H=U.canvas,U.canvas.width=f,U.canvas.height=h,U.drawImage($,0,0,f,h)),e.texSubImage3D(c,d,0,0,y,f,h,1,a,u,H),U&&H===U.canvas&&(U.canvas.width=0,U.canvas.height=0)}ce(r)&&e.generateMipmap(c)}l===0&&n(m.length?m:void 0,t,x)}}x=o.map(function(y,_){return Je(y,r.crossOrigin,F(_))})}function ti(e,t,r,n){n=n||B.textureOptions;const o=n.target||D;e.bindTexture(o,t);let i=n.width,s=n.height,a=n.depth;const u=n.level||0,c=n.internalFormat||n.format||S,l=ue(c),m=n.format||l.format,x=n.type||jo(e,r,l.type);if(ie(r))r instanceof Uint8ClampedArray&&(r=new Uint8Array(r.buffer));else{const p=Et(x);r=new p(r)}const d=$o(c,x),f=r.byteLength/d;if(f%1)throw"length wrong size for format: "+Pt(e,m);let h;if(o===G||o===k)if(!i&&!s&&!a){const p=Math.cbrt(f);if(p%1!==0)throw"can't guess cube size of array of numElements: "+f;i=p,s=p,a=p}else i&&(!s||!a)?(h=be(e,o,s,a,f/i),s=h.width,a=h.height):s&&(!i||!a)?(h=be(e,o,i,a,f/s),i=h.width,a=h.height):(h=be(e,o,i,s,f/a),i=h.width,s=h.height);else h=be(e,o,i,s,f),i=h.width,s=h.height;if($t(e),e.pixelStorei(Ze,n.unpackAlignment||1),q(e,n),o===L){const p=d/r.BYTES_PER_ELEMENT,T=f/6*p;qe(e,n).forEach(F=>{const y=T*F.ndx,_=r.subarray(y,y+T);e.texImage2D(F.face,u,c,i,s,0,m,x,_)})}else o===G||o===k?e.texImage3D(o,u,c,i,s,a,0,m,x,r):e.texImage2D(o,u,c,i,s,0,m,x,r);return{width:i,height:s,depth:a,type:x}}function ri(e,t,r){const n=r.target||D;e.bindTexture(n,t);const o=r.level||0,i=r.internalFormat||r.format||S,s=ue(i),a=r.format||s.format,u=r.type||s.type;if(q(e,r),n===L)for(let c=0;c<6;++c)e.texImage2D(He+c,o,i,r.width,r.height,0,a,u,null);else n===G||n===k?e.texImage3D(n,o,i,r.width,r.height,r.depth,0,a,u,null):e.texImage2D(n,o,i,r.width,r.height,0,a,u,null)}function ni(e,t,r){r=r||fe,t=t||B.textureOptions;const n=e.createTexture(),o=t.target||D;let i=t.width||1,s=t.height||1;const a=t.internalFormat||S;e.bindTexture(o,n),o===L&&(e.texParameteri(o,he,de),e.texParameteri(o,ye,de));let u=t.src;if(u)if(typeof u=="function"&&(u=u(e,t)),typeof u=="string")qo(e,n,t,r);else if(ie(u)||Array.isArray(u)&&(typeof u[0]=="number"||Array.isArray(u[0])||ie(u[0]))){const c=ti(e,n,u,t);i=c.width,s=c.height}else Array.isArray(u)&&(typeof u[0]=="string"||jt(u[0]))?o===L?Jo(e,n,t,r):ei(e,n,t,r):(Xt(e,n,u,t),i=u.width,s=u.height);else ri(e,n,t);return ce(t)&&Ke(e,n,t,i,s,a),Ht(e,n,t),n}const tt=_t;function Zt(e){return typeof document<"u"&&document.getElementById?document.getElementById(e):null}const Se=33984,Ie=34962,oi=34963,ii=35713,si=35714,ai=35632,ui=35633,ci=35981,Wt=35718,fi=35721,li=35971,mi=35382,xi=35396,di=35398,hi=35392,yi=35395,Fe=5126,Yt=35664,Kt=35665,Qt=35666,rt=5124,qt=35667,Jt=35668,er=35669,tr=35670,rr=35671,nr=35672,or=35673,ir=35674,sr=35675,ar=35676,Ei=35678,_i=35680,pi=35679,Ti=35682,Ai=35685,bi=35686,Si=35687,Ii=35688,Fi=35689,Ri=35690,Pi=36289,vi=36292,gi=36293,nt=5125,ur=36294,cr=36295,fr=36296,Ni=36298,Ui=36299,Bi=36300,Di=36303,Li=36306,wi=36307,Mi=36308,Ci=36311,Re=3553,Pe=34067,ot=32879,ve=35866,E={};function lr(e,t){return E[t].bindPoint}function Oi(e,t){return function(r){e.uniform1f(t,r)}}function Gi(e,t){return function(r){e.uniform1fv(t,r)}}function ki(e,t){return function(r){e.uniform2fv(t,r)}}function zi(e,t){return function(r){e.uniform3fv(t,r)}}function Vi(e,t){return function(r){e.uniform4fv(t,r)}}function mr(e,t){return function(r){e.uniform1i(t,r)}}function xr(e,t){return function(r){e.uniform1iv(t,r)}}function dr(e,t){return function(r){e.uniform2iv(t,r)}}function hr(e,t){return function(r){e.uniform3iv(t,r)}}function yr(e,t){return function(r){e.uniform4iv(t,r)}}function $i(e,t){return function(r){e.uniform1ui(t,r)}}function Hi(e,t){return function(r){e.uniform1uiv(t,r)}}function Xi(e,t){return function(r){e.uniform2uiv(t,r)}}function ji(e,t){return function(r){e.uniform3uiv(t,r)}}function Zi(e,t){return function(r){e.uniform4uiv(t,r)}}function Wi(e,t){return function(r){e.uniformMatrix2fv(t,!1,r)}}function Yi(e,t){return function(r){e.uniformMatrix3fv(t,!1,r)}}function Ki(e,t){return function(r){e.uniformMatrix4fv(t,!1,r)}}function Qi(e,t){return function(r){e.uniformMatrix2x3fv(t,!1,r)}}function qi(e,t){return function(r){e.uniformMatrix3x2fv(t,!1,r)}}function Ji(e,t){return function(r){e.uniformMatrix2x4fv(t,!1,r)}}function es(e,t){return function(r){e.uniformMatrix4x2fv(t,!1,r)}}function ts(e,t){return function(r){e.uniformMatrix3x4fv(t,!1,r)}}function rs(e,t){return function(r){e.uniformMatrix4x3fv(t,!1,r)}}function P(e,t,r,n){const o=lr(e,t);return oe(e)?function(i){let s,a;!i||Tt(e,i)?(s=i,a=null):(s=i.texture,a=i.sampler),e.uniform1i(n,r),e.activeTexture(Se+r),e.bindTexture(o,s),e.bindSampler(r,a)}:function(i){e.uniform1i(n,r),e.activeTexture(Se+r),e.bindTexture(o,i)}}function v(e,t,r,n,o){const i=lr(e,t),s=new Int32Array(o);for(let a=0;a<o;++a)s[a]=r+a;return oe(e)?function(a){e.uniform1iv(n,s),a.forEach(function(u,c){e.activeTexture(Se+s[c]);let l,m;!u||Tt(e,u)?(l=u,m=null):(l=u.texture,m=u.sampler),e.bindSampler(r,m),e.bindTexture(i,l)})}:function(a){e.uniform1iv(n,s),a.forEach(function(u,c){e.activeTexture(Se+s[c]),e.bindTexture(i,u)})}}E[Fe]={Type:Float32Array,size:4,setter:Oi,arraySetter:Gi},E[Yt]={Type:Float32Array,size:8,setter:ki,cols:2},E[Kt]={Type:Float32Array,size:12,setter:zi,cols:3},E[Qt]={Type:Float32Array,size:16,setter:Vi,cols:4},E[rt]={Type:Int32Array,size:4,setter:mr,arraySetter:xr},E[qt]={Type:Int32Array,size:8,setter:dr,cols:2},E[Jt]={Type:Int32Array,size:12,setter:hr,cols:3},E[er]={Type:Int32Array,size:16,setter:yr,cols:4},E[nt]={Type:Uint32Array,size:4,setter:$i,arraySetter:Hi},E[ur]={Type:Uint32Array,size:8,setter:Xi,cols:2},E[cr]={Type:Uint32Array,size:12,setter:ji,cols:3},E[fr]={Type:Uint32Array,size:16,setter:Zi,cols:4},E[tr]={Type:Uint32Array,size:4,setter:mr,arraySetter:xr},E[rr]={Type:Uint32Array,size:8,setter:dr,cols:2},E[nr]={Type:Uint32Array,size:12,setter:hr,cols:3},E[or]={Type:Uint32Array,size:16,setter:yr,cols:4},E[ir]={Type:Float32Array,size:32,setter:Wi,rows:2,cols:2},E[sr]={Type:Float32Array,size:48,setter:Yi,rows:3,cols:3},E[ar]={Type:Float32Array,size:64,setter:Ki,rows:4,cols:4},E[Ai]={Type:Float32Array,size:32,setter:Qi,rows:2,cols:3},E[bi]={Type:Float32Array,size:32,setter:Ji,rows:2,cols:4},E[Si]={Type:Float32Array,size:48,setter:qi,rows:3,cols:2},E[Ii]={Type:Float32Array,size:48,setter:ts,rows:3,cols:4},E[Fi]={Type:Float32Array,size:64,setter:es,rows:4,cols:2},E[Ri]={Type:Float32Array,size:64,setter:rs,rows:4,cols:3},E[Ei]={Type:null,size:0,setter:P,arraySetter:v,bindPoint:Re},E[_i]={Type:null,size:0,setter:P,arraySetter:v,bindPoint:Pe},E[pi]={Type:null,size:0,setter:P,arraySetter:v,bindPoint:ot},E[Ti]={Type:null,size:0,setter:P,arraySetter:v,bindPoint:Re},E[Pi]={Type:null,size:0,setter:P,arraySetter:v,bindPoint:ve},E[vi]={Type:null,size:0,setter:P,arraySetter:v,bindPoint:ve},E[gi]={Type:null,size:0,setter:P,arraySetter:v,bindPoint:Pe},E[Ni]={Type:null,size:0,setter:P,arraySetter:v,bindPoint:Re},E[Ui]={Type:null,size:0,setter:P,arraySetter:v,bindPoint:ot},E[Bi]={Type:null,size:0,setter:P,arraySetter:v,bindPoint:Pe},E[Di]={Type:null,size:0,setter:P,arraySetter:v,bindPoint:ve},E[Li]={Type:null,size:0,setter:P,arraySetter:v,bindPoint:Re},E[wi]={Type:null,size:0,setter:P,arraySetter:v,bindPoint:ot},E[Mi]={Type:null,size:0,setter:P,arraySetter:v,bindPoint:Pe},E[Ci]={Type:null,size:0,setter:P,arraySetter:v,bindPoint:ve};function ge(e,t){return function(r){if(r.value)switch(e.disableVertexAttribArray(t),r.value.length){case 4:e.vertexAttrib4fv(t,r.value);break;case 3:e.vertexAttrib3fv(t,r.value);break;case 2:e.vertexAttrib2fv(t,r.value);break;case 1:e.vertexAttrib1fv(t,r.value);break;default:throw new Error("the length of a float constant value must be between 1 and 4!")}else e.bindBuffer(Ie,r.buffer),e.enableVertexAttribArray(t),e.vertexAttribPointer(t,r.numComponents||r.size,r.type||Fe,r.normalize||!1,r.stride||0,r.offset||0),e.vertexAttribDivisor&&e.vertexAttribDivisor(t,r.divisor||0)}}function M(e,t){return function(r){if(r.value)if(e.disableVertexAttribArray(t),r.value.length===4)e.vertexAttrib4iv(t,r.value);else throw new Error("The length of an integer constant value must be 4!");else e.bindBuffer(Ie,r.buffer),e.enableVertexAttribArray(t),e.vertexAttribIPointer(t,r.numComponents||r.size,r.type||rt,r.stride||0,r.offset||0),e.vertexAttribDivisor&&e.vertexAttribDivisor(t,r.divisor||0)}}function Ne(e,t){return function(r){if(r.value)if(e.disableVertexAttribArray(t),r.value.length===4)e.vertexAttrib4uiv(t,r.value);else throw new Error("The length of an unsigned integer constant value must be 4!");else e.bindBuffer(Ie,r.buffer),e.enableVertexAttribArray(t),e.vertexAttribIPointer(t,r.numComponents||r.size,r.type||nt,r.stride||0,r.offset||0),e.vertexAttribDivisor&&e.vertexAttribDivisor(t,r.divisor||0)}}function it(e,t,r){const n=r.size,o=r.count;return function(i){e.bindBuffer(Ie,i.buffer);const s=i.size||i.numComponents||n,a=s/o,u=i.type||Fe,l=E[u].size*s,m=i.normalize||!1,x=i.offset||0,d=l/o;for(let f=0;f<o;++f)e.enableVertexAttribArray(t+f),e.vertexAttribPointer(t+f,a,u,m,l,x+d*f),e.vertexAttribDivisor&&e.vertexAttribDivisor(t+f,i.divisor||0)}}const I={};I[Fe]={size:4,setter:ge},I[Yt]={size:8,setter:ge},I[Kt]={size:12,setter:ge},I[Qt]={size:16,setter:ge},I[rt]={size:4,setter:M},I[qt]={size:8,setter:M},I[Jt]={size:12,setter:M},I[er]={size:16,setter:M},I[nt]={size:4,setter:Ne},I[ur]={size:8,setter:Ne},I[cr]={size:12,setter:Ne},I[fr]={size:16,setter:Ne},I[tr]={size:4,setter:M},I[rr]={size:8,setter:M},I[nr]={size:12,setter:M},I[or]={size:16,setter:M},I[ir]={size:4,setter:it,count:2},I[sr]={size:9,setter:it,count:3},I[ar]={size:16,setter:it,count:4};const ns=/ERROR:\s*\d+:(\d+)/gi;function os(e,t="",r=0){const n=[...t.matchAll(ns)],o=new Map(n.map((i,s)=>{const a=parseInt(i[1]),u=n[s+1],c=u?u.index:t.length,l=t.substring(i.index,c);return[a-1,l]}));return e.split(`
3
+ see: http://github.com/greggman/twgl.js for details */const Be=5120,ee=5121,De=5122,we=5123,Le=5124,Me=5125,Ce=5126,gr=32819,vr=32820,Nr=33635,Ur=5131,Br=33640,Dr=35899,wr=35902,Lr=36269,Mr=34042,ct={};{const e=ct;e[Be]=Int8Array,e[ee]=Uint8Array,e[De]=Int16Array,e[we]=Uint16Array,e[Le]=Int32Array,e[Me]=Uint32Array,e[Ce]=Float32Array,e[gr]=Uint16Array,e[vr]=Uint16Array,e[Nr]=Uint16Array,e[Ur]=Uint16Array,e[Br]=Uint32Array,e[Dr]=Uint32Array,e[wr]=Uint32Array,e[Lr]=Uint32Array,e[Mr]=Uint32Array}function Oe(e){if(e instanceof Int8Array)return Be;if(e instanceof Uint8Array||e instanceof Uint8ClampedArray)return ee;if(e instanceof Int16Array)return De;if(e instanceof Uint16Array)return we;if(e instanceof Int32Array)return Le;if(e instanceof Uint32Array)return Me;if(e instanceof Float32Array)return Ce;throw new Error("unsupported typed array type")}function ft(e){if(e===Int8Array)return Be;if(e===Uint8Array||e===Uint8ClampedArray)return ee;if(e===Int16Array)return De;if(e===Uint16Array)return we;if(e===Int32Array)return Le;if(e===Uint32Array)return Me;if(e===Float32Array)return Ce;throw new Error("unsupported typed array type")}function lt(e){const t=ct[e];if(!t)throw new Error("unknown gl type");return t}const me=typeof SharedArrayBuffer<"u"?function(t){return t&&t.buffer&&(t.buffer instanceof ArrayBuffer||t.buffer instanceof SharedArrayBuffer)}:function(t){return t&&t.buffer&&t.buffer instanceof ArrayBuffer};function mt(...e){console.error(...e)}const xt=new Map;function Ge(e,t){if(!e||typeof e!="object")return!1;let r=xt.get(t);r||(r=new WeakMap,xt.set(t,r));let n=r.get(e);if(n===void 0){const o=Object.prototype.toString.call(e);n=o.substring(8,o.length-1)===t,r.set(e,n)}return n}function Cr(e,t){return typeof WebGLBuffer<"u"&&Ge(t,"WebGLBuffer")}function yt(e,t){return typeof WebGLTexture<"u"&&Ge(t,"WebGLTexture")}function Or(e,t){return typeof WebGLSampler<"u"&&Ge(t,"WebGLSampler")}const ht=35044,C=34962,Gr=34963,kr=34660,zr=5120,Vr=5121,$r=5122,Hr=5123,jr=5124,Xr=5125,dt=5126,Et={attribPrefix:""};function Zr(e,t,r,n,o){e.bindBuffer(t,r),e.bufferData(t,n,o||ht)}function _t(e,t,r,n){if(Cr(e,t))return t;r=r||C;const o=e.createBuffer();return Zr(e,r,o,t,n),o}function pt(e){return e==="indices"}function Wr(e){return e===Int8Array||e===Uint8Array}function Yr(e){return e.length?e:e.data}const Kr=/coord|texture/i,Jr=/color|colour/i;function Qr(e,t){let r;if(Kr.test(e)?r=2:Jr.test(e)?r=4:r=3,t%r>0)throw new Error(`Can not guess numComponents for attribute '${e}'. Tried ${r} but ${t} values is not evenly divisible by ${r}. You should specify it.`);return r}function qr(e,t,r){return e.numComponents||e.size||Qr(t,r||Yr(e).length)}function Tt(e,t){if(me(e))return e;if(me(e.data))return e.data;Array.isArray(e)&&(e={data:e});let r=e.type?ke(e.type):void 0;return r||(pt(t)?r=Uint16Array:r=Float32Array),new r(e.data)}function en(e){return typeof e=="number"?e:e?ft(e):dt}function ke(e){return typeof e=="number"?lt(e):e||Float32Array}function tn(e,t){return{buffer:t.buffer,numValues:2*3*4,type:en(t.type),arrayType:ke(t.type)}}function rn(e,t){const r=t.data||t,n=ke(t.type),o=r*n.BYTES_PER_ELEMENT,i=e.createBuffer();return e.bindBuffer(C,i),e.bufferData(C,o,t.drawType||ht),{buffer:i,numValues:r,type:ft(n),arrayType:n}}function nn(e,t,r){const n=Tt(t,r);return{arrayType:n.constructor,buffer:_t(e,n,void 0,t.drawType),type:Oe(n),numValues:0}}function on(e,t){const r={};return Object.keys(t).forEach(function(n){if(!pt(n)){const o=t[n],i=o.attrib||o.name||o.attribName||Et.attribPrefix+n;if(o.value){if(!Array.isArray(o.value)&&!me(o.value))throw new Error("array.value is not array or typedarray");r[i]={value:o.value}}else{let s;o.buffer&&o.buffer instanceof WebGLBuffer?s=tn:typeof o=="number"||typeof o.data=="number"?s=rn:s=nn;const{buffer:a,type:u,numValues:c,arrayType:m}=s(e,o,n),f=o.normalize!==void 0?o.normalize:Wr(m),x=qr(o,n,c);r[i]={buffer:a,numComponents:x,type:u,normalize:f,stride:o.stride||0,offset:o.offset||0,divisor:o.divisor===void 0?void 0:o.divisor,drawType:o.drawType}}}}),e.bindBuffer(C,null),r}function sn(e,t){return t===zr||t===Vr?1:t===$r||t===Hr?2:t===jr||t===Xr||t===dt?4:0}const ze=["position","positions","a_position"];function an(e,t){let r,n;for(n=0;n<ze.length&&(r=ze[n],!(r in t||(r=Et.attribPrefix+r,r in t)));++n);n===ze.length&&(r=Object.keys(t)[0]);const o=t[r];if(!o.buffer)return 1;e.bindBuffer(C,o.buffer);const i=e.getBufferParameter(C,kr);e.bindBuffer(C,null);const s=sn(e,o.type),a=i/s,u=o.numComponents||o.size,c=a/u;if(c%1!==0)throw new Error(`numComponents ${u} not correct for length ${length}`);return c}function Ve(e,t,r){const n=on(e,t),o=Object.assign({},r||{});o.attribs=Object.assign({},r?r.attribs:{},n);const i=t.indices;if(i){const s=Tt(i,"indices");o.indices=_t(e,s,Gr),o.numElements=s.length,o.elementType=Oe(s)}else o.numElements||(o.numElements=an(e,o.attribs));return o}function te(e){return!!e.texStorage2D}const At=function(){const e={},t={};function r(n){const o=n.constructor.name;if(!e[o]){for(const i in n)if(typeof n[i]=="number"){const s=t[n[i]];t[n[i]]=s?`${s} | ${i}`:i}e[o]=!0}}return function(o,i){return r(o),t[i]||(typeof i=="number"?`0x${i.toString(16)}`:i)}}(),B={textureColor:new Uint8Array([128,192,255,255]),textureOptions:{},crossOrigin:void 0},re=me,bt=function(){let e;return function(){return e=e||(typeof document<"u"&&document.createElement?document.createElement("canvas").getContext("2d"):null),e}}(),St=6406,N=6407,b=6408,Ft=6409,It=6410,ne=6402,Rt=34041,xe=33071,un=9728,cn=9729,D=3553,w=34067,O=32879,G=35866,$e=34069,fn=34070,ln=34071,mn=34072,xn=34073,yn=34074,He=10241,je=10240,ye=10242,he=10243,Pt=32882,hn=33082,dn=33083,En=33084,_n=33085,pn=34892,Tn=34893,Xe=3317,gt=3314,vt=32878,Nt=3316,Ut=3315,Bt=32877,An=37443,bn=37441,Sn=37440,Fn=33321,In=36756,Rn=33325,Pn=33326,gn=33330,vn=33329,Nn=33338,Un=33337,Bn=33340,Dn=33339,wn=33323,Ln=36757,Mn=33327,Cn=33328,On=33336,Gn=33335,kn=33332,zn=33331,Vn=33334,$n=33333,Hn=32849,jn=35905,Xn=36194,Zn=36758,Wn=35898,Yn=35901,Kn=34843,Jn=34837,Qn=36221,qn=36239,eo=36215,to=36233,ro=36209,no=36227,oo=32856,io=35907,so=36759,ao=32855,uo=32854,co=32857,fo=34842,lo=34836,mo=36220,xo=36238,yo=36975,ho=36214,Eo=36232,_o=36226,po=36208,To=33189,Ao=33190,bo=36012,So=36013,Fo=35056,L=5120,A=5121,de=5122,Z=5123,Ee=5124,k=5125,R=5126,Dt=32819,wt=32820,Lt=33635,v=5131,oe=36193,Ze=33640,Io=35899,Ro=35902,Po=36269,go=34042,_e=33319,W=33320,pe=6403,Y=36244,K=36248,z=36249;let We;function Te(e){if(!We){const t={};t[St]={textureFormat:St,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1,2,2,4],type:[A,v,oe,R]},t[Ft]={textureFormat:Ft,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1,2,2,4],type:[A,v,oe,R]},t[It]={textureFormat:It,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[2,4,4,8],type:[A,v,oe,R]},t[N]={textureFormat:N,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3,6,6,12,2],type:[A,v,oe,R,Lt]},t[b]={textureFormat:b,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,8,8,16,2,2],type:[A,v,oe,R,Dt,wt]},t[ne]={textureFormat:ne,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2,4],type:[k,Z]},t[Fn]={textureFormat:pe,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[1],type:[A]},t[In]={textureFormat:pe,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[1],type:[L]},t[Rn]={textureFormat:pe,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[4,2],type:[R,v]},t[Pn]={textureFormat:pe,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[4],type:[R]},t[gn]={textureFormat:Y,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[1],type:[A]},t[vn]={textureFormat:Y,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[1],type:[L]},t[kn]={textureFormat:Y,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[Z]},t[zn]={textureFormat:Y,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[de]},t[Vn]={textureFormat:Y,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[k]},t[$n]={textureFormat:Y,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[Ee]},t[wn]={textureFormat:_e,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[2],type:[A]},t[Ln]={textureFormat:_e,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[2],type:[L]},t[Mn]={textureFormat:_e,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[8,4],type:[R,v]},t[Cn]={textureFormat:_e,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[8],type:[R]},t[On]={textureFormat:W,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[A]},t[Gn]={textureFormat:W,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2],type:[L]},t[Nn]={textureFormat:W,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[Z]},t[Un]={textureFormat:W,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[de]},t[Bn]={textureFormat:W,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[k]},t[Dn]={textureFormat:W,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[Ee]},t[Hn]={textureFormat:N,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3],type:[A]},t[jn]={textureFormat:N,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[3],type:[A]},t[Xn]={textureFormat:N,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[3,2],type:[A,Lt]},t[Zn]={textureFormat:N,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[3],type:[L]},t[Wn]={textureFormat:N,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6,4],type:[R,v,Io]},t[Yn]={textureFormat:N,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6,4],type:[R,v,Ro]},t[Kn]={textureFormat:N,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[12,6],type:[R,v]},t[Jn]={textureFormat:N,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[R]},t[Qn]={textureFormat:K,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[3],type:[A]},t[qn]={textureFormat:K,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[3],type:[L]},t[eo]={textureFormat:K,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[6],type:[Z]},t[to]={textureFormat:K,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[6],type:[de]},t[ro]={textureFormat:K,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[k]},t[no]={textureFormat:K,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[12],type:[Ee]},t[oo]={textureFormat:b,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[A]},t[io]={textureFormat:b,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[A]},t[so]={textureFormat:b,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[4],type:[L]},t[ao]={textureFormat:b,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,2,4],type:[A,wt,Ze]},t[uo]={textureFormat:b,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4,2],type:[A,Dt]},t[co]={textureFormat:b,colorRenderable:!0,textureFilterable:!0,bytesPerElement:[4],type:[Ze]},t[fo]={textureFormat:b,colorRenderable:!1,textureFilterable:!0,bytesPerElement:[16,8],type:[R,v]},t[lo]={textureFormat:b,colorRenderable:!1,textureFilterable:!1,bytesPerElement:[16],type:[R]},t[mo]={textureFormat:z,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[A]},t[xo]={textureFormat:z,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[L]},t[yo]={textureFormat:z,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[Ze]},t[ho]={textureFormat:z,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[Z]},t[Eo]={textureFormat:z,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[8],type:[de]},t[_o]={textureFormat:z,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[16],type:[Ee]},t[po]={textureFormat:z,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[16],type:[k]},t[To]={textureFormat:ne,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[2,4],type:[Z,k]},t[Ao]={textureFormat:ne,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[k]},t[bo]={textureFormat:ne,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[R]},t[Fo]={textureFormat:Rt,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[go]},t[So]={textureFormat:Rt,colorRenderable:!0,textureFilterable:!1,bytesPerElement:[4],type:[Po]},Object.keys(t).forEach(function(r){const n=t[r];n.bytesPerElementMap={},n.bytesPerElement.forEach(function(o,i){const s=n.type[i];n.bytesPerElementMap[s]=o})}),We=t}return We[e]}function vo(e,t){const r=Te(e);if(!r)throw"unknown internal format";const n=r.bytesPerElementMap[t];if(n===void 0)throw"unknown internal format";return n}function ie(e){const t=Te(e);if(!t)throw"unknown internal format";return{format:t.textureFormat,type:t.type[0]}}function Mt(e){return(e&e-1)===0}function No(e,t,r,n){if(!te(e))return Mt(t)&&Mt(r);const o=Te(n);if(!o)throw"unknown internal format";return o.colorRenderable&&o.textureFilterable}function Uo(e){const t=Te(e);if(!t)throw"unknown internal format";return t.textureFilterable}function Bo(e,t,r){return re(t)?Oe(t):r||A}function Ae(e,t,r,n,o){if(o%1!==0)throw"can't guess dimensions";if(!r&&!n){const i=Math.sqrt(o/(t===w?6:1));i%1===0?(r=i,n=i):(r=o,n=1)}else if(n){if(!r&&(r=o/n,r%1))throw"can't guess dimensions"}else if(n=o/r,n%1)throw"can't guess dimensions";return{width:r,height:n}}function J(e,t){t.colorspaceConversion!==void 0&&e.pixelStorei(An,t.colorspaceConversion),t.premultiplyAlpha!==void 0&&e.pixelStorei(bn,t.premultiplyAlpha),t.flipY!==void 0&&e.pixelStorei(Sn,t.flipY)}function Ct(e){e.pixelStorei(Xe,4),te(e)&&(e.pixelStorei(gt,0),e.pixelStorei(vt,0),e.pixelStorei(Nt,0),e.pixelStorei(Ut,0),e.pixelStorei(Bt,0))}function Do(e,t,r,n){n.minMag&&(r.call(e,t,He,n.minMag),r.call(e,t,je,n.minMag)),n.min&&r.call(e,t,He,n.min),n.mag&&r.call(e,t,je,n.mag),n.wrap&&(r.call(e,t,ye,n.wrap),r.call(e,t,he,n.wrap),(t===O||Or(e,t))&&r.call(e,t,Pt,n.wrap)),n.wrapR&&r.call(e,t,Pt,n.wrapR),n.wrapS&&r.call(e,t,ye,n.wrapS),n.wrapT&&r.call(e,t,he,n.wrapT),n.minLod!==void 0&&r.call(e,t,hn,n.minLod),n.maxLod!==void 0&&r.call(e,t,dn,n.maxLod),n.baseLevel!==void 0&&r.call(e,t,En,n.baseLevel),n.maxLevel!==void 0&&r.call(e,t,_n,n.maxLevel),n.compareFunc!==void 0&&r.call(e,t,Tn,n.compareFunc),n.compareMode!==void 0&&r.call(e,t,pn,n.compareMode)}function Ot(e,t,r){const n=r.target||D;e.bindTexture(n,t),Do(e,n,e.texParameteri,r)}function wo(e){return e=e||B.textureColor,re(e)?e:new Uint8Array([e[0]*255,e[1]*255,e[2]*255,e[3]*255])}function Ye(e,t,r,n,o,i){r=r||B.textureOptions,i=i||b;const s=r.target||D;if(n=n||r.width,o=o||r.height,e.bindTexture(s,t),No(e,n,o,i))e.generateMipmap(s);else{const a=Uo(i)?cn:un;e.texParameteri(s,He,a),e.texParameteri(s,je,a),e.texParameteri(s,ye,xe),e.texParameteri(s,he,xe)}}function se(e){return e.auto===!0||e.auto===void 0&&e.level===void 0}function Ke(e,t){return t=t||{},t.cubeFaceOrder||[$e,fn,ln,mn,xn,yn]}function Je(e,t){const n=Ke(e,t).map(function(o,i){return{face:o,ndx:i}});return n.sort(function(o,i){return o.face-i.face}),n}function Gt(e,t,r,n){n=n||B.textureOptions;const o=n.target||D,i=n.level||0;let s=r.width,a=r.height;const u=n.internalFormat||n.format||b,c=ie(u),m=n.format||c.format,f=n.type||c.type;if(J(e,n),e.bindTexture(o,t),o===w){const x=r.width,y=r.height;let l,E;if(x/6===y)l=y,E=[0,0,1,0,2,0,3,0,4,0,5,0];else if(y/6===x)l=x,E=[0,0,0,1,0,2,0,3,0,4,0,5];else if(x/3===y/2)l=x/3,E=[0,0,1,0,2,0,0,1,1,1,2,1];else if(x/2===y/3)l=x/2,E=[0,0,1,0,0,1,1,1,0,2,1,2];else throw"can't figure out cube map from element: "+(r.src?r.src:r.nodeName);const p=bt();p?(p.canvas.width=l,p.canvas.height=l,s=l,a=l,Je(e,n).forEach(function(T){const I=E[T.ndx*2+0]*l,h=E[T.ndx*2+1]*l;p.drawImage(r,I,h,l,l,0,0,l,l),e.texImage2D(T.face,i,u,m,f,p.canvas)}),p.canvas.width=1,p.canvas.height=1):typeof createImageBitmap<"u"&&(s=l,a=l,Je(e,n).forEach(function(T){const I=E[T.ndx*2+0]*l,h=E[T.ndx*2+1]*l;e.texImage2D(T.face,i,u,l,l,0,m,f,null),createImageBitmap(r,I,h,l,l,{premultiplyAlpha:"none",colorSpaceConversion:"none"}).then(function(_){J(e,n),e.bindTexture(o,t),e.texImage2D(T.face,i,u,m,f,_),se(n)&&Ye(e,t,n,s,a,u)})}))}else if(o===O||o===G){const x=Math.min(r.width,r.height),y=Math.max(r.width,r.height),l=y/x;if(l%1!==0)throw"can not compute 3D dimensions of element";const E=r.width===y?1:0,p=r.height===y?1:0;e.pixelStorei(Xe,1),e.pixelStorei(gt,r.width),e.pixelStorei(vt,0),e.pixelStorei(Bt,0),e.texImage3D(o,i,u,x,x,x,0,m,f,null);for(let T=0;T<l;++T){const I=T*x*E,h=T*x*p;e.pixelStorei(Nt,I),e.pixelStorei(Ut,h),e.texSubImage3D(o,i,0,0,T,x,x,1,m,f,r)}Ct(e)}else e.texImage2D(o,i,u,m,f,r);se(n)&&Ye(e,t,n,s,a,u),Ot(e,t,n)}function ae(){}function Lo(e){if(typeof document<"u"){const t=document.createElement("a");return t.href=e,t.hostname===location.hostname&&t.port===location.port&&t.protocol===location.protocol}else{const t=new URL(location.href).origin;return new URL(e,location.href).origin===t}}function Mo(e,t){return t===void 0&&!Lo(e)?"anonymous":t}function Co(e,t,r){r=r||ae;let n;if(t=t!==void 0?t:B.crossOrigin,t=Mo(e,t),typeof Image<"u"){n=new Image,t!==void 0&&(n.crossOrigin=t);const o=function(){n.removeEventListener("error",i),n.removeEventListener("load",s),n=null},i=function(){const u="couldn't load image: "+e;mt(u),r(u,n),o()},s=function(){r(null,n),o()};return n.addEventListener("error",i),n.addEventListener("load",s),n.src=e,n}else if(typeof ImageBitmap<"u"){let o,i;const s=function(){r(o,i)},a={};t&&(a.mode="cors"),fetch(e,a).then(function(u){if(!u.ok)throw u;return u.blob()}).then(function(u){return createImageBitmap(u,{premultiplyAlpha:"none",colorSpaceConversion:"none"})}).then(function(u){i=u,setTimeout(s)}).catch(function(u){o=u,setTimeout(s)}),n=null}return n}function kt(e){return typeof ImageBitmap<"u"&&e instanceof ImageBitmap||typeof ImageData<"u"&&e instanceof ImageData||typeof HTMLElement<"u"&&e instanceof HTMLElement}function Qe(e,t,r){return kt(e)?(setTimeout(function(){r(null,e)}),e):Co(e,t,r)}function qe(e,t,r){r=r||B.textureOptions;const n=r.target||D;if(e.bindTexture(n,t),r.color===!1)return;const o=wo(r.color);if(n===w)for(let i=0;i<6;++i)e.texImage2D($e+i,0,b,1,1,0,b,A,o);else n===O||n===G?e.texImage3D(n,0,b,1,1,1,0,b,A,o):e.texImage2D(n,0,b,1,1,0,b,A,o)}function Oo(e,t,r,n){return n=n||ae,r=r||B.textureOptions,qe(e,t,r),r=Object.assign({},r),Qe(r.src,r.crossOrigin,function(i,s){i?n(i,t,s):(Gt(e,t,s,r),n(null,t,s))})}function Go(e,t,r,n){n=n||ae;const o=r.src;if(o.length!==6)throw"there must be 6 urls for a cubemap";const i=r.level||0,s=r.internalFormat||r.format||b,a=ie(s),u=r.format||a.format,c=r.type||A,m=r.target||D;if(m!==w)throw"target must be TEXTURE_CUBE_MAP";qe(e,t,r),r=Object.assign({},r);let f=6;const x=[],y=Ke(e,r);let l;function E(p){return function(T,I){--f,T?x.push(T):I.width!==I.height?x.push("cubemap face img is not a square: "+I.src):(J(e,r),e.bindTexture(m,t),f===5?Ke().forEach(function(h){e.texImage2D(h,i,s,u,c,I)}):e.texImage2D(p,i,s,u,c,I),se(r)&&e.generateMipmap(m)),f===0&&n(x.length?x:void 0,t,l)}}l=o.map(function(p,T){return Qe(p,r.crossOrigin,E(y[T]))})}function ko(e,t,r,n){n=n||ae;const o=r.src,i=r.internalFormat||r.format||b,s=ie(i),a=r.format||s.format,u=r.type||A,c=r.target||G;if(c!==O&&c!==G)throw"target must be TEXTURE_3D or TEXTURE_2D_ARRAY";qe(e,t,r),r=Object.assign({},r);let m=o.length;const f=[];let x;const y=r.level||0;let l=r.width,E=r.height;const p=o.length;let T=!0;function I(h){return function(_,$){if(--m,_)f.push(_);else{if(J(e,r),e.bindTexture(c,t),T){T=!1,l=r.width||$.width,E=r.height||$.height,e.texImage3D(c,y,i,l,E,p,0,a,u,null);for(let H=0;H<p;++H)e.texSubImage3D(c,y,0,0,H,l,E,1,a,u,$)}else{let H=$,U;($.width!==l||$.height!==E)&&(U=bt(),H=U.canvas,U.canvas.width=l,U.canvas.height=E,U.drawImage($,0,0,l,E)),e.texSubImage3D(c,y,0,0,h,l,E,1,a,u,H),U&&H===U.canvas&&(U.canvas.width=0,U.canvas.height=0)}se(r)&&e.generateMipmap(c)}m===0&&n(f.length?f:void 0,t,x)}}x=o.map(function(h,_){return Qe(h,r.crossOrigin,I(_))})}function zo(e,t,r,n){n=n||B.textureOptions;const o=n.target||D;e.bindTexture(o,t);let i=n.width,s=n.height,a=n.depth;const u=n.level||0,c=n.internalFormat||n.format||b,m=ie(c),f=n.format||m.format,x=n.type||Bo(e,r,m.type);if(re(r))r instanceof Uint8ClampedArray&&(r=new Uint8Array(r.buffer));else{const p=lt(x);r=new p(r)}const y=vo(c,x),l=r.byteLength/y;if(l%1)throw"length wrong size for format: "+At(e,f);let E;if(o===O||o===G)if(!i&&!s&&!a){const p=Math.cbrt(l);if(p%1!==0)throw"can't guess cube size of array of numElements: "+l;i=p,s=p,a=p}else i&&(!s||!a)?(E=Ae(e,o,s,a,l/i),s=E.width,a=E.height):s&&(!i||!a)?(E=Ae(e,o,i,a,l/s),i=E.width,a=E.height):(E=Ae(e,o,i,s,l/a),i=E.width,s=E.height);else E=Ae(e,o,i,s,l),i=E.width,s=E.height;if(Ct(e),e.pixelStorei(Xe,n.unpackAlignment||1),J(e,n),o===w){const p=y/r.BYTES_PER_ELEMENT,T=l/6*p;Je(e,n).forEach(I=>{const h=T*I.ndx,_=r.subarray(h,h+T);e.texImage2D(I.face,u,c,i,s,0,f,x,_)})}else o===O||o===G?e.texImage3D(o,u,c,i,s,a,0,f,x,r):e.texImage2D(o,u,c,i,s,0,f,x,r);return{width:i,height:s,depth:a,type:x}}function Vo(e,t,r){const n=r.target||D;e.bindTexture(n,t);const o=r.level||0,i=r.internalFormat||r.format||b,s=ie(i),a=r.format||s.format,u=r.type||s.type;if(J(e,r),n===w)for(let c=0;c<6;++c)e.texImage2D($e+c,o,i,r.width,r.height,0,a,u,null);else n===O||n===G?e.texImage3D(n,o,i,r.width,r.height,r.depth,0,a,u,null):e.texImage2D(n,o,i,r.width,r.height,0,a,u,null)}function $o(e,t,r){r=r||ae,t=t||B.textureOptions;const n=e.createTexture(),o=t.target||D;let i=t.width||1,s=t.height||1;const a=t.internalFormat||b;e.bindTexture(o,n),o===w&&(e.texParameteri(o,ye,xe),e.texParameteri(o,he,xe));let u=t.src;if(u)if(typeof u=="function"&&(u=u(e,t)),typeof u=="string")Oo(e,n,t,r);else if(re(u)||Array.isArray(u)&&(typeof u[0]=="number"||Array.isArray(u[0])||re(u[0]))){const c=zo(e,n,u,t);i=c.width,s=c.height}else Array.isArray(u)&&(typeof u[0]=="string"||kt(u[0]))?o===w?Go(e,n,t,r):ko(e,n,t,r):(Gt(e,n,u,t),i=u.width,s=u.height);else Vo(e,n,t);return se(t)&&Ye(e,n,t,i,s,a),Ot(e,n,t),n}const et=mt;function zt(e){return typeof document<"u"&&document.getElementById?document.getElementById(e):null}const be=33984,Se=34962,Ho=34963,jo=35713,Xo=35714,Zo=35632,Wo=35633,Yo=35981,Vt=35718,Ko=35721,Jo=35971,Qo=35382,qo=35396,ei=35398,ti=35392,ri=35395,Fe=5126,$t=35664,Ht=35665,jt=35666,tt=5124,Xt=35667,Zt=35668,Wt=35669,Yt=35670,Kt=35671,Jt=35672,Qt=35673,qt=35674,er=35675,tr=35676,ni=35678,oi=35680,ii=35679,si=35682,ai=35685,ui=35686,ci=35687,fi=35688,li=35689,mi=35690,xi=36289,yi=36292,hi=36293,rt=5125,rr=36294,nr=36295,or=36296,di=36298,Ei=36299,_i=36300,pi=36303,Ti=36306,Ai=36307,bi=36308,Si=36311,Ie=3553,Re=34067,nt=32879,Pe=35866,d={};function ir(e,t){return d[t].bindPoint}function Fi(e,t){return function(r){e.uniform1f(t,r)}}function Ii(e,t){return function(r){e.uniform1fv(t,r)}}function Ri(e,t){return function(r){e.uniform2fv(t,r)}}function Pi(e,t){return function(r){e.uniform3fv(t,r)}}function gi(e,t){return function(r){e.uniform4fv(t,r)}}function sr(e,t){return function(r){e.uniform1i(t,r)}}function ar(e,t){return function(r){e.uniform1iv(t,r)}}function ur(e,t){return function(r){e.uniform2iv(t,r)}}function cr(e,t){return function(r){e.uniform3iv(t,r)}}function fr(e,t){return function(r){e.uniform4iv(t,r)}}function vi(e,t){return function(r){e.uniform1ui(t,r)}}function Ni(e,t){return function(r){e.uniform1uiv(t,r)}}function Ui(e,t){return function(r){e.uniform2uiv(t,r)}}function Bi(e,t){return function(r){e.uniform3uiv(t,r)}}function Di(e,t){return function(r){e.uniform4uiv(t,r)}}function wi(e,t){return function(r){e.uniformMatrix2fv(t,!1,r)}}function Li(e,t){return function(r){e.uniformMatrix3fv(t,!1,r)}}function Mi(e,t){return function(r){e.uniformMatrix4fv(t,!1,r)}}function Ci(e,t){return function(r){e.uniformMatrix2x3fv(t,!1,r)}}function Oi(e,t){return function(r){e.uniformMatrix3x2fv(t,!1,r)}}function Gi(e,t){return function(r){e.uniformMatrix2x4fv(t,!1,r)}}function ki(e,t){return function(r){e.uniformMatrix4x2fv(t,!1,r)}}function zi(e,t){return function(r){e.uniformMatrix3x4fv(t,!1,r)}}function Vi(e,t){return function(r){e.uniformMatrix4x3fv(t,!1,r)}}function P(e,t,r,n){const o=ir(e,t);return te(e)?function(i){let s,a;!i||yt(e,i)?(s=i,a=null):(s=i.texture,a=i.sampler),e.uniform1i(n,r),e.activeTexture(be+r),e.bindTexture(o,s),e.bindSampler(r,a)}:function(i){e.uniform1i(n,r),e.activeTexture(be+r),e.bindTexture(o,i)}}function g(e,t,r,n,o){const i=ir(e,t),s=new Int32Array(o);for(let a=0;a<o;++a)s[a]=r+a;return te(e)?function(a){e.uniform1iv(n,s),a.forEach(function(u,c){e.activeTexture(be+s[c]);let m,f;!u||yt(e,u)?(m=u,f=null):(m=u.texture,f=u.sampler),e.bindSampler(r,f),e.bindTexture(i,m)})}:function(a){e.uniform1iv(n,s),a.forEach(function(u,c){e.activeTexture(be+s[c]),e.bindTexture(i,u)})}}d[Fe]={Type:Float32Array,size:4,setter:Fi,arraySetter:Ii},d[$t]={Type:Float32Array,size:8,setter:Ri,cols:2},d[Ht]={Type:Float32Array,size:12,setter:Pi,cols:3},d[jt]={Type:Float32Array,size:16,setter:gi,cols:4},d[tt]={Type:Int32Array,size:4,setter:sr,arraySetter:ar},d[Xt]={Type:Int32Array,size:8,setter:ur,cols:2},d[Zt]={Type:Int32Array,size:12,setter:cr,cols:3},d[Wt]={Type:Int32Array,size:16,setter:fr,cols:4},d[rt]={Type:Uint32Array,size:4,setter:vi,arraySetter:Ni},d[rr]={Type:Uint32Array,size:8,setter:Ui,cols:2},d[nr]={Type:Uint32Array,size:12,setter:Bi,cols:3},d[or]={Type:Uint32Array,size:16,setter:Di,cols:4},d[Yt]={Type:Uint32Array,size:4,setter:sr,arraySetter:ar},d[Kt]={Type:Uint32Array,size:8,setter:ur,cols:2},d[Jt]={Type:Uint32Array,size:12,setter:cr,cols:3},d[Qt]={Type:Uint32Array,size:16,setter:fr,cols:4},d[qt]={Type:Float32Array,size:32,setter:wi,rows:2,cols:2},d[er]={Type:Float32Array,size:48,setter:Li,rows:3,cols:3},d[tr]={Type:Float32Array,size:64,setter:Mi,rows:4,cols:4},d[ai]={Type:Float32Array,size:32,setter:Ci,rows:2,cols:3},d[ui]={Type:Float32Array,size:32,setter:Gi,rows:2,cols:4},d[ci]={Type:Float32Array,size:48,setter:Oi,rows:3,cols:2},d[fi]={Type:Float32Array,size:48,setter:zi,rows:3,cols:4},d[li]={Type:Float32Array,size:64,setter:ki,rows:4,cols:2},d[mi]={Type:Float32Array,size:64,setter:Vi,rows:4,cols:3},d[ni]={Type:null,size:0,setter:P,arraySetter:g,bindPoint:Ie},d[oi]={Type:null,size:0,setter:P,arraySetter:g,bindPoint:Re},d[ii]={Type:null,size:0,setter:P,arraySetter:g,bindPoint:nt},d[si]={Type:null,size:0,setter:P,arraySetter:g,bindPoint:Ie},d[xi]={Type:null,size:0,setter:P,arraySetter:g,bindPoint:Pe},d[yi]={Type:null,size:0,setter:P,arraySetter:g,bindPoint:Pe},d[hi]={Type:null,size:0,setter:P,arraySetter:g,bindPoint:Re},d[di]={Type:null,size:0,setter:P,arraySetter:g,bindPoint:Ie},d[Ei]={Type:null,size:0,setter:P,arraySetter:g,bindPoint:nt},d[_i]={Type:null,size:0,setter:P,arraySetter:g,bindPoint:Re},d[pi]={Type:null,size:0,setter:P,arraySetter:g,bindPoint:Pe},d[Ti]={Type:null,size:0,setter:P,arraySetter:g,bindPoint:Ie},d[Ai]={Type:null,size:0,setter:P,arraySetter:g,bindPoint:nt},d[bi]={Type:null,size:0,setter:P,arraySetter:g,bindPoint:Re},d[Si]={Type:null,size:0,setter:P,arraySetter:g,bindPoint:Pe};function ge(e,t){return function(r){if(r.value)switch(e.disableVertexAttribArray(t),r.value.length){case 4:e.vertexAttrib4fv(t,r.value);break;case 3:e.vertexAttrib3fv(t,r.value);break;case 2:e.vertexAttrib2fv(t,r.value);break;case 1:e.vertexAttrib1fv(t,r.value);break;default:throw new Error("the length of a float constant value must be between 1 and 4!")}else e.bindBuffer(Se,r.buffer),e.enableVertexAttribArray(t),e.vertexAttribPointer(t,r.numComponents||r.size,r.type||Fe,r.normalize||!1,r.stride||0,r.offset||0),e.vertexAttribDivisor&&e.vertexAttribDivisor(t,r.divisor||0)}}function M(e,t){return function(r){if(r.value)if(e.disableVertexAttribArray(t),r.value.length===4)e.vertexAttrib4iv(t,r.value);else throw new Error("The length of an integer constant value must be 4!");else e.bindBuffer(Se,r.buffer),e.enableVertexAttribArray(t),e.vertexAttribIPointer(t,r.numComponents||r.size,r.type||tt,r.stride||0,r.offset||0),e.vertexAttribDivisor&&e.vertexAttribDivisor(t,r.divisor||0)}}function ve(e,t){return function(r){if(r.value)if(e.disableVertexAttribArray(t),r.value.length===4)e.vertexAttrib4uiv(t,r.value);else throw new Error("The length of an unsigned integer constant value must be 4!");else e.bindBuffer(Se,r.buffer),e.enableVertexAttribArray(t),e.vertexAttribIPointer(t,r.numComponents||r.size,r.type||rt,r.stride||0,r.offset||0),e.vertexAttribDivisor&&e.vertexAttribDivisor(t,r.divisor||0)}}function ot(e,t,r){const n=r.size,o=r.count;return function(i){e.bindBuffer(Se,i.buffer);const s=i.size||i.numComponents||n,a=s/o,u=i.type||Fe,m=d[u].size*s,f=i.normalize||!1,x=i.offset||0,y=m/o;for(let l=0;l<o;++l)e.enableVertexAttribArray(t+l),e.vertexAttribPointer(t+l,a,u,f,m,x+y*l),e.vertexAttribDivisor&&e.vertexAttribDivisor(t+l,i.divisor||0)}}const F={};F[Fe]={size:4,setter:ge},F[$t]={size:8,setter:ge},F[Ht]={size:12,setter:ge},F[jt]={size:16,setter:ge},F[tt]={size:4,setter:M},F[Xt]={size:8,setter:M},F[Zt]={size:12,setter:M},F[Wt]={size:16,setter:M},F[rt]={size:4,setter:ve},F[rr]={size:8,setter:ve},F[nr]={size:12,setter:ve},F[or]={size:16,setter:ve},F[Yt]={size:4,setter:M},F[Kt]={size:8,setter:M},F[Jt]={size:12,setter:M},F[Qt]={size:16,setter:M},F[qt]={size:4,setter:ot,count:2},F[er]={size:9,setter:ot,count:3},F[tr]={size:16,setter:ot,count:4};const $i=/ERROR:\s*\d+:(\d+)/gi;function Hi(e,t="",r=0){const n=[...t.matchAll($i)],o=new Map(n.map((i,s)=>{const a=parseInt(i[1]),u=n[s+1],c=u?u.index:t.length,m=t.substring(i.index,c);return[a-1,m]}));return e.split(`
4
4
  `).map((i,s)=>{const a=o.get(s);return`${s+1+r}: ${i}${a?`
5
5
 
6
6
  ^^^ ${a}`:""}`}).join(`
7
- `)}const Er=/^[ \t]*\n/;function _r(e){let t=0;return Er.test(e)&&(t=1,e=e.replace(Er,"")),{lineOffset:t,shaderSource:e}}function is(e,t){return e.errorCallback(t),e.callback&&setTimeout(()=>{e.callback(`${t}
7
+ `)}const lr=/^[ \t]*\n/;function mr(e){let t=0;return lr.test(e)&&(t=1,e=e.replace(lr,"")),{lineOffset:t,shaderSource:e}}function ji(e,t){return e.errorCallback(t),e.callback&&setTimeout(()=>{e.callback(`${t}
8
8
  ${e.errors.join(`
9
- `)}`)}),null}function ss(e,t,r,n){if(n=n||tt,!e.getShaderParameter(r,ii)){const i=e.getShaderInfoLog(r),{lineOffset:s,shaderSource:a}=_r(e.getShaderSource(r)),u=`${os(a,i,s)}
10
- Error compiling ${Pt(e,t)}: ${i}`;return n(u),u}return""}function st(e,t,r){let n,o,i;if(typeof t=="function"&&(r=t,t=void 0),typeof e=="function")r=e,e=void 0;else if(e&&!Array.isArray(e)){const c=e;r=c.errorCallback,e=c.attribLocations,n=c.transformFeedbackVaryings,o=c.transformFeedbackMode,i=c.callback}const s=r||tt,a=[],u={errorCallback(c,...l){a.push(c),s(c,...l)},transformFeedbackVaryings:n,transformFeedbackMode:o,callback:i,errors:a};{let c={};Array.isArray(e)?e.forEach(function(l,m){c[l]=t?t[m]:m}):c=e||{},u.attribLocations=c}return u}const as=["VERTEX_SHADER","FRAGMENT_SHADER"];function us(e,t){if(t.indexOf("frag")>=0)return ai;if(t.indexOf("vert")>=0)return ui}function cs(e,t,r){const n=e.getAttachedShaders(t);for(const o of n)r.has(o)&&e.deleteShader(o);e.deleteProgram(t)}const fs=(e=0)=>new Promise(t=>setTimeout(t,e));function ls(e,t,r){const n=e.createProgram(),{attribLocations:o,transformFeedbackVaryings:i,transformFeedbackMode:s}=st(r);for(let a=0;a<t.length;++a){let u=t[a];if(typeof u=="string"){const c=Zt(u),l=c?c.text:u;let m=e[as[a]];c&&c.type&&(m=us(e,c.type)||m),u=e.createShader(m),e.shaderSource(u,_r(l).shaderSource),e.compileShader(u),e.attachShader(n,u)}}Object.entries(o).forEach(([a,u])=>e.bindAttribLocation(n,u,a));{let a=i;a&&(a.attribs&&(a=a.attribs),Array.isArray(a)||(a=Object.keys(a)),e.transformFeedbackVaryings(n,a,s||ci))}return e.linkProgram(n),n}function ms(e,t,r,n,o){const i=st(r,n,o),s=new Set(t),a=ls(e,t,i);function u(c,l){const m=ds(c,l,i.errorCallback);return m&&cs(c,l,s),m}if(i.callback){xs(e,a).then(()=>{const c=u(e,a);i.callback(c,c?void 0:a)});return}return u(e,a)?void 0:a}async function xs(e,t){const r=e.getExtension("KHR_parallel_shader_compile"),n=r?(i,s)=>i.getProgramParameter(s,r.COMPLETION_STATUS_KHR):()=>!0;let o=0;do await fs(o),o=1e3/60;while(!n(e,t))}function ds(e,t,r){if(r=r||tt,!e.getProgramParameter(t,si)){const o=e.getProgramInfoLog(t);r(`Error in program linking: ${o}`);const s=e.getAttachedShaders(t).map(a=>ss(e,e.getShaderParameter(a,e.SHADER_TYPE),a,r));return`${o}
9
+ `)}`)}),null}function Xi(e,t,r,n){if(n=n||et,!e.getShaderParameter(r,jo)){const i=e.getShaderInfoLog(r),{lineOffset:s,shaderSource:a}=mr(e.getShaderSource(r)),u=`${Hi(a,i,s)}
10
+ Error compiling ${At(e,t)}: ${i}`;return n(u),u}return""}function it(e,t,r){let n,o,i;if(typeof t=="function"&&(r=t,t=void 0),typeof e=="function")r=e,e=void 0;else if(e&&!Array.isArray(e)){const c=e;r=c.errorCallback,e=c.attribLocations,n=c.transformFeedbackVaryings,o=c.transformFeedbackMode,i=c.callback}const s=r||et,a=[],u={errorCallback(c,...m){a.push(c),s(c,...m)},transformFeedbackVaryings:n,transformFeedbackMode:o,callback:i,errors:a};{let c={};Array.isArray(e)?e.forEach(function(m,f){c[m]=t?t[f]:f}):c=e||{},u.attribLocations=c}return u}const Zi=["VERTEX_SHADER","FRAGMENT_SHADER"];function Wi(e,t){if(t.indexOf("frag")>=0)return Zo;if(t.indexOf("vert")>=0)return Wo}function Yi(e,t,r){const n=e.getAttachedShaders(t);for(const o of n)r.has(o)&&e.deleteShader(o);e.deleteProgram(t)}const Ki=(e=0)=>new Promise(t=>setTimeout(t,e));function Ji(e,t,r){const n=e.createProgram(),{attribLocations:o,transformFeedbackVaryings:i,transformFeedbackMode:s}=it(r);for(let a=0;a<t.length;++a){let u=t[a];if(typeof u=="string"){const c=zt(u),m=c?c.text:u;let f=e[Zi[a]];c&&c.type&&(f=Wi(e,c.type)||f),u=e.createShader(f),e.shaderSource(u,mr(m).shaderSource),e.compileShader(u),e.attachShader(n,u)}}Object.entries(o).forEach(([a,u])=>e.bindAttribLocation(n,u,a));{let a=i;a&&(a.attribs&&(a=a.attribs),Array.isArray(a)||(a=Object.keys(a)),e.transformFeedbackVaryings(n,a,s||Yo))}return e.linkProgram(n),n}function Qi(e,t,r,n,o){const i=it(r,n,o),s=new Set(t),a=Ji(e,t,i);function u(c,m){const f=es(c,m,i.errorCallback);return f&&Yi(c,m,s),f}if(i.callback){qi(e,a).then(()=>{const c=u(e,a);i.callback(c,c?void 0:a)});return}return u(e,a)?void 0:a}async function qi(e,t){const r=e.getExtension("KHR_parallel_shader_compile"),n=r?(i,s)=>i.getProgramParameter(s,r.COMPLETION_STATUS_KHR):()=>!0;let o=0;do await Ki(o),o=1e3/60;while(!n(e,t))}function es(e,t,r){if(r=r||et,!e.getProgramParameter(t,Xo)){const o=e.getProgramInfoLog(t);r(`Error in program linking: ${o}`);const s=e.getAttachedShaders(t).map(a=>Xi(e,e.getShaderParameter(a,e.SHADER_TYPE),a,r));return`${o}
11
11
  ${s.filter(a=>a).join(`
12
- `)}`}}function hs(e,t,r,n,o){return ms(e,t,r,n,o)}function pr(e){const t=e.name;return t.startsWith("gl_")||t.startsWith("webgl_")}const ys=/(\.|\[|]|\w+)/g,Es=e=>e>="0"&&e<="9";function _s(e,t,r,n){const o=e.split(ys).filter(a=>a!=="");let i=0,s="";for(;;){const a=o[i++];s+=a;const u=Es(a[0]),c=u?parseInt(a):a;if(u&&(s+=o[i++]),i===o.length){r[c]=t;break}else{const m=o[i++],x=m==="[",d=r[c]||(x?[]:{});r[c]=d,r=d,n[s]=n[s]||function(f){return function(h){Tr(f,h)}}(d),s+=m}}}function ps(e,t){let r=0;function n(a,u,c){const l=u.name.endsWith("[0]"),m=u.type,x=E[m];if(!x)throw new Error(`unknown type: 0x${m.toString(16)}`);let d;if(x.bindPoint){const f=r;r+=u.size,l?d=x.arraySetter(e,m,f,c,u.size):d=x.setter(e,m,f,c,u.size)}else x.arraySetter&&l?d=x.arraySetter(e,c):d=x.setter(e,c);return d.location=c,d}const o={},i={},s=e.getProgramParameter(t,Wt);for(let a=0;a<s;++a){const u=e.getActiveUniform(t,a);if(pr(u))continue;let c=u.name;c.endsWith("[0]")&&(c=c.substr(0,c.length-3));const l=e.getUniformLocation(t,u.name);if(l){const m=n(t,u,l);o[c]=m,_s(c,m,i,o)}}return o}function Ts(e,t){const r={},n=e.getProgramParameter(t,li);for(let o=0;o<n;++o){const i=e.getTransformFeedbackVarying(t,o);r[i.name]={index:o,type:i.type,size:i.size}}return r}function As(e,t){const r=e.getProgramParameter(t,Wt),n=[],o=[];for(let a=0;a<r;++a){o.push(a),n.push({});const u=e.getActiveUniform(t,a);n[a].name=u.name}[["UNIFORM_TYPE","type"],["UNIFORM_SIZE","size"],["UNIFORM_BLOCK_INDEX","blockNdx"],["UNIFORM_OFFSET","offset"]].forEach(function(a){const u=a[0],c=a[1];e.getActiveUniforms(t,o,e[u]).forEach(function(l,m){n[m][c]=l})});const i={},s=e.getProgramParameter(t,mi);for(let a=0;a<s;++a){const u=e.getActiveUniformBlockName(t,a),c={index:e.getUniformBlockIndex(t,u),usedByVertexShader:e.getActiveUniformBlockParameter(t,a,xi),usedByFragmentShader:e.getActiveUniformBlockParameter(t,a,di),size:e.getActiveUniformBlockParameter(t,a,hi),uniformIndices:e.getActiveUniformBlockParameter(t,a,yi)};c.used=c.usedByVertexShader||c.usedByFragmentShader,i[u]=c}return{blockSpecs:i,uniformData:n}}function Tr(e,t){for(const r in t){const n=e[r];typeof n=="function"?n(t[r]):Tr(e[r],t[r])}}function at(e,...t){const r=e.uniformSetters||e,n=t.length;for(let o=0;o<n;++o){const i=t[o];if(Array.isArray(i)){const s=i.length;for(let a=0;a<s;++a)at(r,i[a])}else for(const s in i){const a=r[s];a&&a(i[s])}}}function bs(e,t){const r={},n=e.getProgramParameter(t,fi);for(let o=0;o<n;++o){const i=e.getActiveAttrib(t,o);if(pr(i))continue;const s=e.getAttribLocation(t,i.name),a=I[i.type],u=a.setter(e,s,a);u.location=s,r[i.name]=u}return r}function Ss(e,t){for(const r in t){const n=e[r];n&&n(t[r])}}function Ar(e,t,r){r.vertexArrayObject?e.bindVertexArray(r.vertexArrayObject):(Ss(t.attribSetters||t,r.attribs),r.indices&&e.bindBuffer(oi,r.indices))}function br(e,t){const r=ps(e,t),n=bs(e,t),o={program:t,uniformSetters:r,attribSetters:n};return oe(e)&&(o.uniformBlockSpec=As(e,t),o.transformFeedbackInfo=Ts(e,t)),o}const Is=/\s|{|}|;/;function ut(e,t,r,n,o){const i=st(r,n,o),s=[];if(t=t.map(function(c){if(!Is.test(c)){const l=Zt(c);if(l)c=l.text;else{const m=`no element with id: ${c}`;i.errorCallback(m),s.push(m)}}return c}),s.length)return is(i,"");const a=i.callback;a&&(i.callback=(c,l)=>{a(c,c?void 0:br(e,l))});const u=hs(e,t,i);return u?br(e,u):null}class Fs{constructor(t=[],r=(n,o)=>n<o?-1:n>o?1:0){if(this.data=t,this.length=this.data.length,this.compare=r,this.length>0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(this.length===0)return;const t=this.data[0],r=this.data.pop();return--this.length>0&&(this.data[0]=r,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:r,compare:n}=this,o=r[t];for(;t>0;){const i=t-1>>1,s=r[i];if(n(o,s)>=0)break;r[t]=s,t=i}r[t]=o}_down(t){const{data:r,compare:n}=this,o=this.length>>1,i=r[t];for(;t<o;){let s=(t<<1)+1;const a=s+1;if(a<this.length&&n(r[a],r[s])<0&&(s=a),n(r[s],i)>=0)break;r[t]=r[s],t=s}r[t]=i}}class Rs{constructor(t,r,n,o){this._projector=t,this._verts=r,this._uv=n,this._projVerts=r.map(t),this._trigs=o,this._segs=[],this._segCount=0,this._segTrigs=[],this._queue=new Fs([],function(i,s){return s.epsilon-i.epsilon}),this._vertToSeg=new Array(r.length);for(const i in this._verts)this._vertToSeg[i]=[];for(const i in this._trigs){const s=this._trigs[i],a=s[0],u=s[1],c=s[2];this._segment(a,u,i),this._segment(u,c,i),this._segment(c,a,i)}}_segment(t,r,n,o=1/0){if(this._vertToSeg[t]&&this._vertToSeg[t][r]!==void 0){const l=this._vertToSeg[t][r];return this._segTrigs[l].includes(n)||this._segTrigs[l].push(n),l}const i=this._segCount++;this._segs[i]=[t,r],this._vertToSeg[t][r]=i,this._vertToSeg[r][t]=i,this._segTrigs[i]=[n];const s=[(this._verts[t][0]+this._verts[r][0])/2,(this._verts[t][1]+this._verts[r][1])/2],a=this._projector(s),u=[(this._projVerts[t][0]+this._projVerts[r][0])/2,(this._projVerts[t][1]+this._projVerts[r][1])/2],c=(a[0]-u[0])**2+(a[1]-u[1])**2;return Number.isFinite(c)&&c<o&&this._queue.push({v1:t,v2:r,epsilon:c,midpoint:s,projectedMid:a}),i}output(){return{unprojected:Array.from(this._verts),projected:Array.from(this._projVerts),uv:Array.from(this._uv),trigs:Array.from(this._trigs)}}_stepsWithSameEpsilon=0;lowerEpsilon(t){let r=this._queue.peek().epsilon,n=r;for(;r>=t;)if(this.step(),r=this._queue.peek().epsilon,r===n){if(this._stepsWithSameEpsilon++,this._stepsWithSameEpsilon<500){console.warn("Arrugator stopped due to epsilon stall. Raster may need hints for proper arrugation.");break}}else this._stepsWithSameEpsilon=0,n=r}get epsilon(){return this._queue.peek().epsilon}set epsilon(t){return this.lowerEpsilon(t)}step(){const t=this._queue.pop();return this._splitSegment(t,t.epsilon)}force(){const t=this._queue.data;this._queue.data=[],this._queue.length=0,t.forEach(r=>this._splitSegment(r,1/0))}_splitSegment(t,r){const n=t.v1,o=t.v2,i=this._vertToSeg[n]&&this._vertToSeg[n][o],s=this._segTrigs[i];if(s.length>=3)throw new Error("Somehow a segment is shared by three triangles");delete this._segTrigs[i],delete this._segs[i],delete this._vertToSeg[n][o],delete this._vertToSeg[o][n];const a=this._verts.length;this._projVerts[a]=t.projectedMid,this._verts[a]=t.midpoint,this._vertToSeg[a]=[],this._uv[a]=[(this._uv[n][0]+this._uv[o][0])/2,(this._uv[n][1]+this._uv[o][1])/2];for(const u of s)this._splitTriangle(n,o,a,u,r)}_splitTriangle(t,r,n,o,i=1/0){const s=this._trigs[o];let a,u=!1;if(s[0]===t&&s[1]===r)a=s[2],u=!0;else if(s[1]===t&&s[2]===r)a=s[0],u=!0;else if(s[2]===t&&s[0]===r)a=s[1],u=!0;else if(s[1]===t&&s[0]===r)a=s[2],u=!1;else if(s[2]===t&&s[1]===r)a=s[0],u=!1;else if(s[0]===t&&s[2]===r)a=s[1],u=!1;else throw new Error("Data structure mishap: could not fetch 3rd vertex used in triangle");const c=this._trigs.length;u?(this._trigs[o]=[t,n,a],this._trigs[c]=[n,r,a]):(this._trigs[o]=[n,t,a],this._trigs[c]=[r,n,a]);const l=this._vertToSeg[t]&&this._vertToSeg[t][r],m=this._vertToSeg[r]&&this._vertToSeg[r][a],x=this._vertToSeg[a]&&this._vertToSeg[a][t];function d(f){return f!==o}l!==void 0&&(this._segTrigs[l]=this._segTrigs[l].filter(d)),m!==void 0&&(this._segTrigs[m]=this._segTrigs[m].filter(d)),x!==void 0&&(this._segTrigs[x]=this._segTrigs[x].filter(d)),this._segment(t,n,o,i),this._segment(n,a,o,i),this._segment(a,t,o,i),this._segment(r,n,c,i),this._segment(n,a,c,i),this._segment(a,r,c,i)}}function Sr(e,t,r=100){const n=[-20037508342789244e-9,20037508342789244e-9],o=[t[0],t[3],t[1],t[2]],i=X(e,"EPSG:3857").forward;function s(l){const m=i(l),x=Math.abs((m[0]-n[0])/(20037508342789244e-9*2)),d=Math.abs((m[1]-n[1])/(20037508342789244e-9*2));return[x,d]}const a=[[0,0],[0,1],[1,0],[1,1]],u=new Rs(s,o,a,[[0,1,3],[0,3,2]]);if(r>0){u.force();for(let l=0;l<r;l++)u.step()}const c=u.output();return{pos:c.projected.flat(),uv:c.uv.flat(),trigs:c.trigs.flat()}}const Ps=`
12
+ `)}`}}function ts(e,t,r,n,o){return Qi(e,t,r,n,o)}function xr(e){const t=e.name;return t.startsWith("gl_")||t.startsWith("webgl_")}const rs=/(\.|\[|]|\w+)/g,ns=e=>e>="0"&&e<="9";function os(e,t,r,n){const o=e.split(rs).filter(a=>a!=="");let i=0,s="";for(;;){const a=o[i++];s+=a;const u=ns(a[0]),c=u?parseInt(a):a;if(u&&(s+=o[i++]),i===o.length){r[c]=t;break}else{const f=o[i++],x=f==="[",y=r[c]||(x?[]:{});r[c]=y,r=y,n[s]=n[s]||function(l){return function(E){yr(l,E)}}(y),s+=f}}}function is(e,t){let r=0;function n(a,u,c){const m=u.name.endsWith("[0]"),f=u.type,x=d[f];if(!x)throw new Error(`unknown type: 0x${f.toString(16)}`);let y;if(x.bindPoint){const l=r;r+=u.size,m?y=x.arraySetter(e,f,l,c,u.size):y=x.setter(e,f,l,c,u.size)}else x.arraySetter&&m?y=x.arraySetter(e,c):y=x.setter(e,c);return y.location=c,y}const o={},i={},s=e.getProgramParameter(t,Vt);for(let a=0;a<s;++a){const u=e.getActiveUniform(t,a);if(xr(u))continue;let c=u.name;c.endsWith("[0]")&&(c=c.substr(0,c.length-3));const m=e.getUniformLocation(t,u.name);if(m){const f=n(t,u,m);o[c]=f,os(c,f,i,o)}}return o}function ss(e,t){const r={},n=e.getProgramParameter(t,Jo);for(let o=0;o<n;++o){const i=e.getTransformFeedbackVarying(t,o);r[i.name]={index:o,type:i.type,size:i.size}}return r}function as(e,t){const r=e.getProgramParameter(t,Vt),n=[],o=[];for(let a=0;a<r;++a){o.push(a),n.push({});const u=e.getActiveUniform(t,a);n[a].name=u.name}[["UNIFORM_TYPE","type"],["UNIFORM_SIZE","size"],["UNIFORM_BLOCK_INDEX","blockNdx"],["UNIFORM_OFFSET","offset"]].forEach(function(a){const u=a[0],c=a[1];e.getActiveUniforms(t,o,e[u]).forEach(function(m,f){n[f][c]=m})});const i={},s=e.getProgramParameter(t,Qo);for(let a=0;a<s;++a){const u=e.getActiveUniformBlockName(t,a),c={index:e.getUniformBlockIndex(t,u),usedByVertexShader:e.getActiveUniformBlockParameter(t,a,qo),usedByFragmentShader:e.getActiveUniformBlockParameter(t,a,ei),size:e.getActiveUniformBlockParameter(t,a,ti),uniformIndices:e.getActiveUniformBlockParameter(t,a,ri)};c.used=c.usedByVertexShader||c.usedByFragmentShader,i[u]=c}return{blockSpecs:i,uniformData:n}}function yr(e,t){for(const r in t){const n=e[r];typeof n=="function"?n(t[r]):yr(e[r],t[r])}}function st(e,...t){const r=e.uniformSetters||e,n=t.length;for(let o=0;o<n;++o){const i=t[o];if(Array.isArray(i)){const s=i.length;for(let a=0;a<s;++a)st(r,i[a])}else for(const s in i){const a=r[s];a&&a(i[s])}}}function us(e,t){const r={},n=e.getProgramParameter(t,Ko);for(let o=0;o<n;++o){const i=e.getActiveAttrib(t,o);if(xr(i))continue;const s=e.getAttribLocation(t,i.name),a=F[i.type],u=a.setter(e,s,a);u.location=s,r[i.name]=u}return r}function cs(e,t){for(const r in t){const n=e[r];n&&n(t[r])}}function hr(e,t,r){r.vertexArrayObject?e.bindVertexArray(r.vertexArrayObject):(cs(t.attribSetters||t,r.attribs),r.indices&&e.bindBuffer(Ho,r.indices))}function dr(e,t){const r=is(e,t),n=us(e,t),o={program:t,uniformSetters:r,attribSetters:n};return te(e)&&(o.uniformBlockSpec=as(e,t),o.transformFeedbackInfo=ss(e,t)),o}const fs=/\s|{|}|;/;function Er(e,t,r,n,o){const i=it(r,n,o),s=[];if(t=t.map(function(c){if(!fs.test(c)){const m=zt(c);if(m)c=m.text;else{const f=`no element with id: ${c}`;i.errorCallback(f),s.push(f)}}return c}),s.length)return ji(i,"");const a=i.callback;a&&(i.callback=(c,m)=>{a(c,c?void 0:dr(e,m))});const u=ts(e,t,i);return u?dr(e,u):null}class ls{constructor(t=[],r=(n,o)=>n<o?-1:n>o?1:0){if(this.data=t,this.length=this.data.length,this.compare=r,this.length>0)for(let n=(this.length>>1)-1;n>=0;n--)this._down(n)}push(t){this.data.push(t),this._up(this.length++)}pop(){if(this.length===0)return;const t=this.data[0],r=this.data.pop();return--this.length>0&&(this.data[0]=r,this._down(0)),t}peek(){return this.data[0]}_up(t){const{data:r,compare:n}=this,o=r[t];for(;t>0;){const i=t-1>>1,s=r[i];if(n(o,s)>=0)break;r[t]=s,t=i}r[t]=o}_down(t){const{data:r,compare:n}=this,o=this.length>>1,i=r[t];for(;t<o;){let s=(t<<1)+1;const a=s+1;if(a<this.length&&n(r[a],r[s])<0&&(s=a),n(r[s],i)>=0)break;r[t]=r[s],t=s}r[t]=i}}class ms{constructor(t,r,n,o){this._projector=t,this._verts=r,this._uv=n,this._projVerts=r.map(t),this._trigs=o,this._segs=[],this._segCount=0,this._segTrigs=[],this._queue=new ls([],function(i,s){return s.epsilon-i.epsilon}),this._vertToSeg=new Array(r.length);for(const i in this._verts)this._vertToSeg[i]=[];for(const i in this._trigs){const s=this._trigs[i],a=s[0],u=s[1],c=s[2];this._segment(a,u,i),this._segment(u,c,i),this._segment(c,a,i)}}_segment(t,r,n,o=1/0){if(this._vertToSeg[t]&&this._vertToSeg[t][r]!==void 0){const m=this._vertToSeg[t][r];return this._segTrigs[m].includes(n)||this._segTrigs[m].push(n),m}const i=this._segCount++;this._segs[i]=[t,r],this._vertToSeg[t][r]=i,this._vertToSeg[r][t]=i,this._segTrigs[i]=[n];const s=[(this._verts[t][0]+this._verts[r][0])/2,(this._verts[t][1]+this._verts[r][1])/2],a=this._projector(s),u=[(this._projVerts[t][0]+this._projVerts[r][0])/2,(this._projVerts[t][1]+this._projVerts[r][1])/2],c=(a[0]-u[0])**2+(a[1]-u[1])**2;return Number.isFinite(c)&&c<o&&this._queue.push({v1:t,v2:r,epsilon:c,midpoint:s,projectedMid:a}),i}output(){return{unprojected:Array.from(this._verts),projected:Array.from(this._projVerts),uv:Array.from(this._uv),trigs:Array.from(this._trigs)}}_stepsWithSameEpsilon=0;lowerEpsilon(t){let r=this._queue.peek().epsilon,n=r;for(;r>=t;)if(this.step(),r=this._queue.peek().epsilon,r===n){if(this._stepsWithSameEpsilon++,this._stepsWithSameEpsilon<500){console.warn("Arrugator stopped due to epsilon stall. Raster may need hints for proper arrugation.");break}}else this._stepsWithSameEpsilon=0,n=r}get epsilon(){return this._queue.peek().epsilon}set epsilon(t){return this.lowerEpsilon(t)}step(){const t=this._queue.pop();return this._splitSegment(t,t.epsilon)}force(){const t=this._queue.data;this._queue.data=[],this._queue.length=0,t.forEach(r=>this._splitSegment(r,1/0))}_splitSegment(t,r){const n=t.v1,o=t.v2,i=this._vertToSeg[n]&&this._vertToSeg[n][o],s=this._segTrigs[i];if(s.length>=3)throw new Error("Somehow a segment is shared by three triangles");delete this._segTrigs[i],delete this._segs[i],delete this._vertToSeg[n][o],delete this._vertToSeg[o][n];const a=this._verts.length;this._projVerts[a]=t.projectedMid,this._verts[a]=t.midpoint,this._vertToSeg[a]=[],this._uv[a]=[(this._uv[n][0]+this._uv[o][0])/2,(this._uv[n][1]+this._uv[o][1])/2];for(const u of s)this._splitTriangle(n,o,a,u,r)}_splitTriangle(t,r,n,o,i=1/0){const s=this._trigs[o];let a,u=!1;if(s[0]===t&&s[1]===r)a=s[2],u=!0;else if(s[1]===t&&s[2]===r)a=s[0],u=!0;else if(s[2]===t&&s[0]===r)a=s[1],u=!0;else if(s[1]===t&&s[0]===r)a=s[2],u=!1;else if(s[2]===t&&s[1]===r)a=s[0],u=!1;else if(s[0]===t&&s[2]===r)a=s[1],u=!1;else throw new Error("Data structure mishap: could not fetch 3rd vertex used in triangle");const c=this._trigs.length;u?(this._trigs[o]=[t,n,a],this._trigs[c]=[n,r,a]):(this._trigs[o]=[n,t,a],this._trigs[c]=[r,n,a]);const m=this._vertToSeg[t]&&this._vertToSeg[t][r],f=this._vertToSeg[r]&&this._vertToSeg[r][a],x=this._vertToSeg[a]&&this._vertToSeg[a][t];function y(l){return l!==o}m!==void 0&&(this._segTrigs[m]=this._segTrigs[m].filter(y)),f!==void 0&&(this._segTrigs[f]=this._segTrigs[f].filter(y)),x!==void 0&&(this._segTrigs[x]=this._segTrigs[x].filter(y)),this._segment(t,n,o,i),this._segment(n,a,o,i),this._segment(a,t,o,i),this._segment(r,n,c,i),this._segment(n,a,c,i),this._segment(a,r,c,i)}}function _r(e,t,r=100){const n=[-20037508342789244e-9,20037508342789244e-9],o=[t[0],t[3],t[1],t[2]],i=j(e,"EPSG:3857").forward;function s(m){const f=i(m),x=Math.abs((f[0]-n[0])/(20037508342789244e-9*2)),y=Math.abs((f[1]-n[1])/(20037508342789244e-9*2));return[x,y]}const a=[[0,0],[0,1],[1,0],[1,1]],u=new ms(s,o,a,[[0,1,3],[0,3,2]]);if(r>0){u.force();for(let m=0;m<r;m++)u.step()}const c=u.output();return{pos:c.projected.flat(),uv:c.uv.flat(),trigs:c.trigs.flat()}}function pr(e,t,r=2){const n=t&&t.length,o=n?t[0]*r:e.length;let i=Tr(e,0,o,r,!0);const s=[];if(!i||i.next===i.prev)return s;let a,u,c;if(n&&(i=Es(e,t,i,r)),e.length>80*r){a=1/0,u=1/0;let m=-1/0,f=-1/0;for(let x=r;x<o;x+=r){const y=e[x],l=e[x+1];y<a&&(a=y),l<u&&(u=l),y>m&&(m=y),l>f&&(f=l)}c=Math.max(m-a,f-u),c=c!==0?32767/c:0}return ue(i,s,r,a,u,c,0),s}function Tr(e,t,r,n,o){let i;if(o===gs(e,t,r,n)>0)for(let s=t;s<r;s+=n)i=Fr(s/n|0,e[s],e[s+1],i);else for(let s=r-n;s>=t;s-=n)i=Fr(s/n|0,e[s],e[s+1],i);return i&&Q(i,i.next)&&(le(i),i=i.next),i}function V(e,t){if(!e)return e;t||(t=e);let r=e,n;do if(n=!1,!r.steiner&&(Q(r,r.next)||S(r.prev,r,r.next)===0)){if(le(r),r=t=r.prev,r===r.next)break;n=!0}else r=r.next;while(n||r!==t);return t}function ue(e,t,r,n,o,i,s){if(!e)return;!s&&i&&bs(e,n,o,i);let a=e;for(;e.prev!==e.next;){const u=e.prev,c=e.next;if(i?ys(e,n,o,i):xs(e)){t.push(u.i,e.i,c.i),le(e),e=c.next,a=c.next;continue}if(e=c,e===a){s?s===1?(e=hs(V(e),t),ue(e,t,r,n,o,i,2)):s===2&&ds(e,t,r,n,o,i):ue(V(e),t,r,n,o,i,1);break}}}function xs(e){const t=e.prev,r=e,n=e.next;if(S(t,r,n)>=0)return!1;const o=t.x,i=r.x,s=n.x,a=t.y,u=r.y,c=n.y,m=Math.min(o,i,s),f=Math.min(a,u,c),x=Math.max(o,i,s),y=Math.max(a,u,c);let l=n.next;for(;l!==t;){if(l.x>=m&&l.x<=x&&l.y>=f&&l.y<=y&&ce(o,a,i,u,s,c,l.x,l.y)&&S(l.prev,l,l.next)>=0)return!1;l=l.next}return!0}function ys(e,t,r,n){const o=e.prev,i=e,s=e.next;if(S(o,i,s)>=0)return!1;const a=o.x,u=i.x,c=s.x,m=o.y,f=i.y,x=s.y,y=Math.min(a,u,c),l=Math.min(m,f,x),E=Math.max(a,u,c),p=Math.max(m,f,x),T=at(y,l,t,r,n),I=at(E,p,t,r,n);let h=e.prevZ,_=e.nextZ;for(;h&&h.z>=T&&_&&_.z<=I;){if(h.x>=y&&h.x<=E&&h.y>=l&&h.y<=p&&h!==o&&h!==s&&ce(a,m,u,f,c,x,h.x,h.y)&&S(h.prev,h,h.next)>=0||(h=h.prevZ,_.x>=y&&_.x<=E&&_.y>=l&&_.y<=p&&_!==o&&_!==s&&ce(a,m,u,f,c,x,_.x,_.y)&&S(_.prev,_,_.next)>=0))return!1;_=_.nextZ}for(;h&&h.z>=T;){if(h.x>=y&&h.x<=E&&h.y>=l&&h.y<=p&&h!==o&&h!==s&&ce(a,m,u,f,c,x,h.x,h.y)&&S(h.prev,h,h.next)>=0)return!1;h=h.prevZ}for(;_&&_.z<=I;){if(_.x>=y&&_.x<=E&&_.y>=l&&_.y<=p&&_!==o&&_!==s&&ce(a,m,u,f,c,x,_.x,_.y)&&S(_.prev,_,_.next)>=0)return!1;_=_.nextZ}return!0}function hs(e,t){let r=e;do{const n=r.prev,o=r.next.next;!Q(n,o)&&br(n,r,r.next,o)&&fe(n,o)&&fe(o,n)&&(t.push(n.i,r.i,o.i),le(r),le(r.next),r=e=o),r=r.next}while(r!==e);return V(r)}function ds(e,t,r,n,o,i){let s=e;do{let a=s.next.next;for(;a!==s.prev;){if(s.i!==a.i&&Is(s,a)){let u=Sr(s,a);s=V(s,s.next),u=V(u,u.next),ue(s,t,r,n,o,i,0),ue(u,t,r,n,o,i,0);return}a=a.next}s=s.next}while(s!==e)}function Es(e,t,r,n){const o=[];for(let i=0,s=t.length;i<s;i++){const a=t[i]*n,u=i<s-1?t[i+1]*n:e.length,c=Tr(e,a,u,n,!1);c===c.next&&(c.steiner=!0),o.push(Fs(c))}o.sort(_s);for(let i=0;i<o.length;i++)r=ps(o[i],r);return r}function _s(e,t){let r=e.x-t.x;if(r===0&&(r=e.y-t.y,r===0)){const n=(e.next.y-e.y)/(e.next.x-e.x),o=(t.next.y-t.y)/(t.next.x-t.x);r=n-o}return r}function ps(e,t){const r=Ts(e,t);if(!r)return t;const n=Sr(r,e);return V(n,n.next),V(r,r.next)}function Ts(e,t){let r=t;const n=e.x,o=e.y;let i=-1/0,s;if(Q(e,r))return r;do{if(Q(e,r.next))return r.next;if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){const f=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(f<=n&&f>i&&(i=f,s=r.x<r.next.x?r:r.next,f===n))return s}r=r.next}while(r!==t);if(!s)return null;const a=s,u=s.x,c=s.y;let m=1/0;r=s;do{if(n>=r.x&&r.x>=u&&n!==r.x&&Ar(o<c?n:i,o,u,c,o<c?i:n,o,r.x,r.y)){const f=Math.abs(o-r.y)/(n-r.x);fe(r,e)&&(f<m||f===m&&(r.x>s.x||r.x===s.x&&As(s,r)))&&(s=r,m=f)}r=r.next}while(r!==a);return s}function As(e,t){return S(e.prev,e,t.prev)<0&&S(t.next,e,e.next)<0}function bs(e,t,r,n){let o=e;do o.z===0&&(o.z=at(o.x,o.y,t,r,n)),o.prevZ=o.prev,o.nextZ=o.next,o=o.next;while(o!==e);o.prevZ.nextZ=null,o.prevZ=null,Ss(o)}function Ss(e){let t,r=1;do{let n=e,o;e=null;let i=null;for(t=0;n;){t++;let s=n,a=0;for(let c=0;c<r&&(a++,s=s.nextZ,!!s);c++);let u=r;for(;a>0||u>0&&s;)a!==0&&(u===0||!s||n.z<=s.z)?(o=n,n=n.nextZ,a--):(o=s,s=s.nextZ,u--),i?i.nextZ=o:e=o,o.prevZ=i,i=o;n=s}i.nextZ=null,r*=2}while(t>1);return e}function at(e,t,r,n,o){return e=(e-r)*o|0,t=(t-n)*o|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function Fs(e){let t=e,r=e;do(t.x<r.x||t.x===r.x&&t.y<r.y)&&(r=t),t=t.next;while(t!==e);return r}function Ar(e,t,r,n,o,i,s,a){return(o-s)*(t-a)>=(e-s)*(i-a)&&(e-s)*(n-a)>=(r-s)*(t-a)&&(r-s)*(i-a)>=(o-s)*(n-a)}function ce(e,t,r,n,o,i,s,a){return!(e===s&&t===a)&&Ar(e,t,r,n,o,i,s,a)}function Is(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!Rs(e,t)&&(fe(e,t)&&fe(t,e)&&Ps(e,t)&&(S(e.prev,e,t.prev)||S(e,t.prev,t))||Q(e,t)&&S(e.prev,e,e.next)>0&&S(t.prev,t,t.next)>0)}function S(e,t,r){return(t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function Q(e,t){return e.x===t.x&&e.y===t.y}function br(e,t,r,n){const o=Ue(S(e,t,r)),i=Ue(S(e,t,n)),s=Ue(S(r,n,e)),a=Ue(S(r,n,t));return!!(o!==i&&s!==a||o===0&&Ne(e,r,t)||i===0&&Ne(e,n,t)||s===0&&Ne(r,e,n)||a===0&&Ne(r,t,n))}function Ne(e,t,r){return t.x<=Math.max(e.x,r.x)&&t.x>=Math.min(e.x,r.x)&&t.y<=Math.max(e.y,r.y)&&t.y>=Math.min(e.y,r.y)}function Ue(e){return e>0?1:e<0?-1:0}function Rs(e,t){let r=e;do{if(r.i!==e.i&&r.next.i!==e.i&&r.i!==t.i&&r.next.i!==t.i&&br(r,r.next,e,t))return!0;r=r.next}while(r!==e);return!1}function fe(e,t){return S(e.prev,e,e.next)<0?S(e,t,e.next)>=0&&S(e,e.prev,t)>=0:S(e,t,e.prev)<0||S(e,e.next,t)<0}function Ps(e,t){let r=e,n=!1;const o=(e.x+t.x)/2,i=(e.y+t.y)/2;do r.y>i!=r.next.y>i&&r.next.y!==r.y&&o<(r.next.x-r.x)*(i-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next;while(r!==e);return n}function Sr(e,t){const r=ut(e.i,e.x,e.y),n=ut(t.i,t.x,t.y),o=e.next,i=t.prev;return e.next=t,t.prev=e,r.next=o,o.prev=r,n.next=r,r.prev=n,i.next=n,n.prev=i,n}function Fr(e,t,r,n){const o=ut(e,t,r);return n?(o.next=n.next,o.prev=n,n.next.prev=o,n.next=o):(o.prev=o,o.next=o),o}function le(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function ut(e,t,r){return{i:e,x:t,y:r,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function gs(e,t,r,n){let o=0;for(let i=t,s=r-n;i<r;i+=n)o+=(e[s]-e[i])*(e[i+1]+e[s+1]),s=i;return o}function Ir(e){const t=[],r=[],n=e[0][0].length;let o=0,i=0;for(const s of e){for(const a of s)for(let u=0;u<n;u++)t.push(a[u]);i&&(o+=i,r.push(o)),i=s.length}return{vertices:t,holes:r,dimensions:n}}function Rr(e){if(Object.prototype.hasOwnProperty.call(e,"type")){const t=e.type;if(t==="Polygon"||t==="MultiPolygon")return e;if(t==="Feature"&&(e.geometry.type==="Polygon"||e.geometry.type==="MultiPolygon"))return e.geometry;if(t==="FeatureCollection"){const r=e.features.filter(n=>n.geometry.type==="Polygon"||n.geometry.type==="MultiPolygon");if(r.length===1)return r[0].geometry;if(r.length>1){const n=[];for(const o of r){const i=o.geometry;if(i.type==="MultiPolygon")for(const s of i.coordinates)n.push(s);else n.push(i.coordinates)}return{type:"MultiPolygon",coordinates:n}}else throw new Error("No valid Polygon or MultiPolygon features found")}else throw new Error("Invalid GeoJSON format, only support Polygon, MultiPolygon, Feature, FeatureCollection")}else throw new Error("Invalid GeoJSON format")}function vs(e){return typeof e=="string"?fetch(e).then(t=>t.json()).then(t=>Rr(t)):Promise.resolve(Rr(e))}function Ns(e){let t=[],r=[];if(e.type==="MultiPolygon"){const n=e.coordinates.length;let o=0;for(let i=0;i<n;i++){const s=e.coordinates[i],a=Ir(s),{vertices:u,holes:c,dimensions:m}=a,x=pr(u,c,m).map(y=>y+o);o+=u.length/2;for(let y=0;y<u.length;y++)t.push(u[y]);for(let y=0;y<x.length;y++)r.push(x[y])}}else{const n=Ir(e.coordinates),{vertices:o,holes:i,dimensions:s}=n;t=o,r=pr(o,i,s)}return{vertices:t,indices:r}}const Us=`
13
13
  #ifdef GL_ES
14
14
  precision highp int;
15
15
  precision mediump float;
@@ -21,7 +21,7 @@ void main() {
21
21
  vec4 color = texture2D(u_sampler, v_uv);
22
22
  gl_FragColor = color * u_opacity;
23
23
  }
24
- `,vs=`
24
+ `,Bs=`
25
25
  uniform mat4 u_matrix;
26
26
  attribute vec2 a_pos;
27
27
  attribute vec2 a_uv;
@@ -30,7 +30,7 @@ void main() {
30
30
  gl_Position = u_matrix * vec4(a_pos, 0.0, 1.0);
31
31
  v_uv = a_uv;
32
32
  }
33
- `,Ir=`
33
+ `,Ds=`
34
34
  #ifdef GL_ES
35
35
  precision highp int;
36
36
  precision mediump float;
@@ -39,7 +39,7 @@ precision mediump float;
39
39
  void main() {
40
40
  gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
41
41
  }
42
- `,Fr=`
42
+ `,ws=`
43
43
  uniform mat4 u_matrix;
44
44
  uniform float u_alt;
45
45
  attribute vec2 a_pos;
@@ -73,4 +73,4 @@ void main() {
73
73
  gl_Position = u_matrix * vec4(mercator, 1.0);
74
74
  // gl_Position = u_matrix * vec4(a_pos, 0.0, 1.0);
75
75
  }
76
- `;class gs{id;type="custom";renderingMode="2d";option;map;gl;loaded;arrugado;programInfo;bufferInfo;texture;maskProperty;maskProgramInfo;maskBufferInfo;constructor(t,r){this.id=t,this.option=r,this.loaded=!1,this.maskProperty=Object.assign({type:"in"},r.mask);const{projection:n,coordinates:o}=r;this.arrugado=Sr(n,o,r.arrugatorStep)}onAdd(t,r){if(this.map=t,this.gl=r,this.programInfo=ut(r,[vs,Ps]),this.loadTexture(t,r),this.bufferInfo=$e(r,{a_pos:{numComponents:2,data:this.arrugado.pos},a_uv:{numComponents:2,data:this.arrugado.uv},indices:this.arrugado.trigs}),this.maskProperty.data){const{data:n}=this.maskProperty;n&&(this.maskProgramInfo=ut(r,[Fr,Ir]),this.maskBufferInfo=this.getMaskBufferInfo(r,n))}}onRemove(t,r){this.programInfo&&r.deleteProgram(this.programInfo.program),this.maskProgramInfo&&r.deleteProgram(this.maskProgramInfo.program),this.texture&&r.deleteTexture(this.texture)}render(t,r){if(this.map&&!this.map.painter.terrain&&(this.map.painter.currentStencilSource=void 0,this.map.painter._tileClippingMaskIDs={}),this.loaded&&this.programInfo&&this.bufferInfo){const n=r.defaultProjectionData.mainMatrix;if(t.enable(t.BLEND),t.blendFunc(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA),this.maskProgramInfo&&this.maskBufferInfo){t.useProgram(this.maskProgramInfo.program),t.enable(t.STENCIL_TEST),t.stencilFunc(t.ALWAYS,1,255),t.stencilOp(t.REPLACE,t.REPLACE,t.REPLACE),t.stencilMask(255),t.clear(t.STENCIL_BUFFER_BIT),at(this.maskProgramInfo,{u_matrix:n}),Ar(t,this.maskProgramInfo,this.maskBufferInfo);let o=t.UNSIGNED_SHORT;this.maskBufferInfo.numElements/3>65535&&(t.getExtension("OES_element_index_uint"),o=t.UNSIGNED_INT),t.drawElements(t.TRIANGLES,this.maskBufferInfo.numElements,o,0)}if(t.useProgram(this.programInfo.program),this.maskProgramInfo?.program){const o=this.maskProperty.type==="out"?0:1;t.stencilFunc(t.EQUAL,o,255),t.stencilOp(t.KEEP,t.KEEP,t.KEEP)}at(this.programInfo,{u_matrix:n,u_opacity:this.option.opacity??1,u_sampler:this.texture}),Ar(t,this.programInfo,this.bufferInfo),t.drawElements(t.TRIANGLES,this.arrugado.trigs.length,t.UNSIGNED_SHORT,0),t.clear(t.STENCIL_BUFFER_BIT),t.disable(t.STENCIL_TEST)}}updateImage(t){return this.gl&&this.map&&(this.option.opacity=t.opacity??this.option.opacity,(t.projection||t.coordinates)&&(this.option.projection=t.projection??this.option.projection,this.option.coordinates=t.coordinates??this.option.coordinates,this.arrugado=Sr(this.option.projection,this.option.coordinates,this.option.arrugatorStep),this.bufferInfo=$e(this.gl,{a_pos:{numComponents:2,data:this.arrugado.pos},a_uv:{numComponents:2,data:this.arrugado.uv},indices:this.arrugado.trigs})),t.url||t.resampling?(this.loaded=!1,this.option.url=t.url??this.option.url,this.option.resampling=t.resampling??this.option.resampling,this.loadTexture(this.map,this.gl)):this.map.triggerRepaint()),this}updateMask(t){return this.gl&&this.map&&(t.data?(this.maskProgramInfo||(this.maskProgramInfo=ut(this.gl,[Fr,Ir])),this.maskProperty=Object.assign(this.maskProperty,t),this.maskBufferInfo=this.getMaskBufferInfo(this.gl,this.maskProperty.data)):(this.maskProgramInfo&&this.gl.deleteProgram(this.maskProgramInfo.program),this.maskProgramInfo=void 0,this.maskBufferInfo=void 0),this.map.triggerRepaint()),this}loadTexture(t,r){const n=this.option.resampling==="nearest"?r.NEAREST:r.LINEAR;this.texture=ni(r,{src:this.option.url,crossOrigin:this.option.crossOrigin,minMag:n,flipY:0},()=>{this.loaded=!0,t.triggerRepaint()})}getMaskBufferInfo(t,r){let n=[],o=[];if(r.type==="MultiPolygon"){const i=r.coordinates.length;let s=0;for(let a=0;a<i;a++){const u=r.coordinates[a],c=dt(u),{vertices:l,holes:m,dimensions:x}=c,f=j(l,m,x).map(h=>h+s);s+=l.length/2;for(let h=0;h<l.length;h++)n.push(l[h]);for(let h=0;h<f.length;h++)o.push(f[h])}}else{const i=dt(r.coordinates),{vertices:s,holes:a,dimensions:u}=i;n=s,o=j(s,a,u)}return $e(t,{a_pos:{numComponents:2,data:n},indices:o.length/3>65535?new Uint32Array(o):new Uint16Array(o)})}}return gs});
76
+ `;class Ls{id;type="custom";renderingMode="2d";option;map;gl;loaded;arrugado;programInfo;bufferInfo;texture;maskProperty;maskProgramInfo;maskBufferInfo;constructor(t,r){this.id=t,this.option=r,this.loaded=!1,this.maskProperty=Object.assign({type:"in"},r.mask);const{projection:n,coordinates:o}=r;this.arrugado=_r(n,o,r.arrugatorStep)}onAdd(t,r){this.map=t,this.gl=r,this.programInfo=Er(r,[Bs,Us]),this.loadTexture(t,r),this.bufferInfo=Ve(r,{a_pos:{numComponents:2,data:this.arrugado.pos},a_uv:{numComponents:2,data:this.arrugado.uv},indices:this.arrugado.trigs}),this.maskProperty.data&&this.getMaskBufferInfo(r,this.maskProperty.data).then(n=>{this.maskProgramInfo=Er(r,[ws,Ds]),this.maskBufferInfo=n})}onRemove(t,r){this.programInfo&&r.deleteProgram(this.programInfo.program),this.maskProgramInfo&&r.deleteProgram(this.maskProgramInfo.program),this.texture&&r.deleteTexture(this.texture)}render(t,r){if(!(this.maskProperty.data&&!this.maskBufferInfo)&&this.loaded&&this.programInfo&&this.bufferInfo){const n=Array.isArray(r)?r:r.defaultProjectionData.mainMatrix;if(t.enable(t.BLEND),t.blendFunc(t.ONE,t.ONE_MINUS_SRC_ALPHA),this.maskProgramInfo&&this.maskBufferInfo){this.map&&!this.map.painter.terrain&&(this.map.painter.currentStencilSource=void 0,this.map.painter._tileClippingMaskIDs={}),t.useProgram(this.maskProgramInfo.program),t.enable(t.STENCIL_TEST),t.stencilFunc(t.ALWAYS,1,255),t.stencilOp(t.REPLACE,t.REPLACE,t.REPLACE),t.stencilMask(255),t.clear(t.STENCIL_BUFFER_BIT),st(this.maskProgramInfo,{u_matrix:n}),hr(t,this.maskProgramInfo,this.maskBufferInfo);let o=t.UNSIGNED_SHORT;this.maskBufferInfo.numElements/3>65535&&(t.getExtension("OES_element_index_uint"),o=t.UNSIGNED_INT),t.drawElements(t.TRIANGLES,this.maskBufferInfo.numElements,o,0)}if(t.useProgram(this.programInfo.program),this.maskProgramInfo?.program){const o=this.maskProperty.type==="out"?0:1;t.stencilFunc(t.EQUAL,o,255),t.stencilOp(t.KEEP,t.KEEP,t.KEEP)}st(this.programInfo,{u_matrix:n,u_opacity:this.option.opacity??1,u_sampler:this.texture}),hr(t,this.programInfo,this.bufferInfo),t.drawElements(t.TRIANGLES,this.arrugado.trigs.length,t.UNSIGNED_SHORT,0)}}updateImage(t){!this.map||!this.gl||(this.option.opacity=t.opacity??this.option.opacity,this.option.crossOrigin=t.crossOrigin??this.option.crossOrigin,(t.projection||t.coordinates||t.arrugatorStep)&&(this.option.projection=t.projection??this.option.projection,this.option.coordinates=t.coordinates??this.option.coordinates,this.option.arrugatorStep=t.arrugatorStep??this.option.arrugatorStep,this.arrugado=_r(this.option.projection,this.option.coordinates,this.option.arrugatorStep),this.bufferInfo=Ve(this.gl,{a_pos:{numComponents:2,data:this.arrugado.pos},a_uv:{numComponents:2,data:this.arrugado.uv},indices:this.arrugado.trigs})),t.mask&&(this.maskProperty=q(this.maskProperty,t.mask),t.mask.data?this.getMaskBufferInfo(this.gl,t.mask.data).then(r=>{this.maskBufferInfo=r,this.map?.triggerRepaint()}):t.mask.hasOwnProperty("data")&&t.mask.data===void 0&&(this.maskBufferInfo=void 0)),t.url||t.resampling?(this.option.url=t.url??this.option.url,this.option.resampling=t.resampling??this.option.resampling,this.loadTexture(this.map,this.gl)):this.map.triggerRepaint())}loadTexture(t,r){const n=this.option.resampling==="nearest"?r.NEAREST:r.LINEAR;$o(r,{src:this.option.url,crossOrigin:this.option.crossOrigin,minMag:n,flipY:0,premultiplyAlpha:1},(o,i,s)=>{const a=r.getParameter(r.MAX_TEXTURE_SIZE),{width:u,height:c}=s;if(u>a||c>a)throw new Error(`The texture size exceeds the maximum supported size: ${a}x${a}`);this.texture=i,this.loaded=!0,t.triggerRepaint()})}getMaskBufferInfo(t,r){return vs(r).then(n=>{const{vertices:o,indices:i}=Ns(n);return Ve(t,{a_pos:{numComponents:2,data:o},indices:i.length/3>65535?new Uint32Array(i):new Uint16Array(i)})})}}return Ls});
@@ -0,0 +1,36 @@
1
+ import * as GeoJSON from 'geojson';
2
+ /**
3
+ * The properties for masking the image layer.
4
+ */
5
+ export interface MaskProperty {
6
+ /**
7
+ * The type of mask operation to perform.
8
+ * - 'in': The image will be visible only within the mask area.
9
+ * - 'out': The image will be visible outside the mask area.
10
+ * If not specified, defaults to 'in'.
11
+ * @default 'in'
12
+ */
13
+ type?: 'in' | 'out';
14
+ /**
15
+ * The mask data, supporting inline GeoJSON and remote addresses.
16
+ */
17
+ data: GeoJSON.GeoJSON | string;
18
+ }
19
+ /**
20
+ * Extracts a polygon or multipolygon from GeoJSON data.
21
+ * Supports GeoJSON types: Polygon, MultiPolygon, Feature, and FeatureCollection.
22
+ * @param data
23
+ * @returns
24
+ */
25
+ export declare function extractPolygon(data: GeoJSON.GeoJSON): GeoJSON.Polygon | GeoJSON.MultiPolygon;
26
+ export declare function extractPolygonAsync(data: GeoJSON.GeoJSON | string): Promise<GeoJSON.Polygon | GeoJSON.MultiPolygon>;
27
+ /**
28
+ * 三角化多边形
29
+ * @param poly 多边形
30
+ * @param poly
31
+ * @returns 顶点和三角形索引
32
+ */
33
+ export declare function earcutPolygon(poly: GeoJSON.Polygon | GeoJSON.MultiPolygon): {
34
+ vertices: number[];
35
+ indices: number[];
36
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naivemap/maplibre-gl-image-layer",
3
- "version": "0.0.1-alpha.2",
3
+ "version": "0.0.1-alpha.3",
4
4
  "description": "Load a static image of any projection via Arrugator and Proj4js.",
5
5
  "main": "./dist/index.umd.cjs",
6
6
  "module": "./dist/index.js",
@@ -28,11 +28,13 @@
28
28
  "access": "public"
29
29
  },
30
30
  "peerDependencies": {
31
- "proj4": "^2.8.0",
32
- "maplibre-gl": "^4.0.0 || ^5.0.0"
31
+ "maplibre-gl": "^4.0.0 || ^5.0.0",
32
+ "proj4": "^2.8.0"
33
33
  },
34
34
  "dependencies": {
35
+ "@types/geojson": "^7946.0.16",
35
36
  "earcut": "^3.0.1",
37
+ "es-toolkit": "^1.39.8",
36
38
  "tinyqueue": "^3.0.0",
37
39
  "twgl.js": "^5.5.4"
38
40
  },