1var Ig=Object.defineProperty;var Ng=(t,e,i)=>e in t?Ig(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i;var g=(t,e,i)=>Ng(t,typeof e!="symbol"?e+"":e,i);import{r as se,g as Lg}from"./vendor-utils-CbQo5LZA.js";const Dg="modulepreload",Bg=function(t){return"/"+t},Ja={},ec=function(e,i,n){let s=Promise.resolve();if(i&&i.length>0){let o=function(l){return Promise.all(l.map(f=>Promise.resolve(f).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),c=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));s=o(i.map(l=>{if(l=Bg(l),l in Ja)return;Ja[l]=!0;const f=l.endsWith(".css"),h=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${h}`))return;const u=document.createElement("link");if(u.rel=f?"stylesheet":Dg,f||(u.as="script"),u.crossOrigin="",u.href=l,c&&u.setAttribute("nonce",c),document.head.appendChild(u),f)return new Promise((d,p)=>{u.addEventListener("load",d),u.addEventListener("error",()=>p(new Error(`Unable to preload CSS for ${l}`)))})}))}function r(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return s.then(o=>{for(const a of o||[])a.status==="rejected"&&r(a.reason);return e().catch(r)})};function Qn(t,e){if(!t)throw new Error(e||"loader assertion failed.")}const ta=!!(typeof process!="object"||String(process)!=="[object process]"||process.browser),tc=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version);tc&&parseFloat(tc[1]);const fn=globalThis,zt=globalThis.process||{},Fg=globalThis.navigator||{};function gh(t){var n,s;if(typeof window<"u"&&((n=window.process)==null?void 0:n.type)==="renderer"||typeof process<"u"&&((s=process.versions)!=null&&s.electron))return!0;const i=typeof navigator<"u"&&navigator.userAgent;return!!(i&&i.indexOf("Electron")>=0)}function Lt(){return!(typeof process=="object"&&String(process)==="[object process]"&&!(process!=null&&process.browser))||gh()}function kg(t){return Lt()?gh()?"Electron":(Fg.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown":"Node"}const ph="4.1.1";function ia(t,e){if(!t)throw new Error("Assertion failed")}function _h(t){if(!t)return 0;let e;switch(typeof t){case"number":e=t;break;case"object":e=t.logLevel||t.priority||0;break;default:return 0}return ia(Number.isFinite(e)&&e>=0),e}function Ug(t){const{logLevel:e,message:i}=t;t.logLevel=_h(e);const n=t.args?Array.from(t.args):[];for(;n.length&&n.shift()!==i;);switch(typeof e){case"string":case"function":i!==void 0&&n.unshift(i),t.message=e;break;case"object":Object.assign(t,e);break}typeof t.message=="function"&&(t.message=t.message());const s=typeof t.message;return ia(s==="string"||s==="object"),Object.assign(t,{args:n},t.opts)}const Ht=()=>{};class zg{constructor({level:e=0}={}){this.userData={},this._onceCache=new Set,this._level=e}set level(e){this.setLevel(e)}get level(){return this.getLevel()}setLevel(e){return this._level=e,this}getLevel(){return this._level}warn(e,...i){return this._log("warn",0,e,i,{once:!0})}error(e,...i){return this._log("error",0,e,i)}log(e,i,...n){return this._log("log",e,i,n)}info(e,i,...n){return this._log("info",e,i,n)}once(e,i,...n){return this._log("once",e,i,n,{once:!0})}_log(e,i,n,s,r={}){const o=Ug({logLevel:i,message:n,args:this._buildArgs(i,n,s),opts:r});return this._createLogFunction(e,o,r)}_buildArgs(e,i,n){return[e,i,...n]}_createLogFunction(e,i,n){if(!this._shouldLog(i.logLevel))return Ht;const s=this._getOnceTag(n.tag??i.tag??i.message);if((n.once||i.once)&&s!==void 0){if(this._onceCache.has(s))return Ht;this._onceCache.add(s)}return this._emit(e,i)}_shouldLog(e){return this.getLevel()>=_h(e)}_getOnceTag(e){if(e!==void 0)try{return typeof e=="string"?e:String(e)}catch{return}}}function Wg(t){try{const e=window[t],i="__storage_test__";return e.setItem(i,i),e.removeItem(i),e}catch{return null}}class Vg{constructor(e,i,n="sessionStorage"){this.storage=Wg(n),this.id=e,this.config=i,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){const i=JSON.stringify(this.config);this.storage.setItem(this.id,i)}}_loadConfiguration(){let e={};
vendor: 5,784 bytes, line 1
1if(this.storage){const i=this.storage.getItem(this.id);e=i?JSON.parse(i):{}}return Object.assign(this.config,e),this}}function $g(t){let e;return t<10?e=`${t.toFixed(2)}ms`:t<100?e=`${t.toFixed(1)}ms`:t<1e3?e=`${t.toFixed(0)}ms`:e=`${(t/1e3).toFixed(2)}s`,e}function jg(t,e=8){const i=Math.max(e-t.length,0);return`${" ".repeat(i)}${t}`}var Jn;(function(t){t[t.BLACK=30]="BLACK",t[t.RED=31]="RED",t[t.GREEN=32]="GREEN",t[t.YELLOW=33]="YELLOW",t[t.BLUE=34]="BLUE",t[t.MAGENTA=35]="MAGENTA",t[t.CYAN=36]="CYAN",t[t.WHITE=37]="WHITE",t[t.BRIGHT_BLACK=90]="BRIGHT_BLACK",t[t.BRIGHT_RED=91]="BRIGHT_RED",t[t.BRIGHT_GREEN=92]="BRIGHT_GREEN",t[t.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",t[t.BRIGHT_BLUE=94]="BRIGHT_BLUE",t[t.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",t[t.BRIGHT_CYAN=96]="BRIGHT_CYAN",t[t.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(Jn||(Jn={}));const Hg=10;function ic(t){return typeof t!="string"?t:(t=t.toUpperCase(),Jn[t]||Jn.WHITE)}function Xg(t,e,i){return!Lt&&typeof t=="string"&&(e&&(t=`\x1B[${ic(e)}m${t}\x1B[39m`),i&&(t=`\x1B[${ic(i)+Hg}m${t}\x1B[49m`)),t}function Yg(t,e=["constructor"]){const i=Object.getPrototypeOf(t),n=Object.getOwnPropertyNames(i),s=t;for(const r of n){const o=s[r];typeof o=="function"&&(e.find(a=>r===a)||(s[r]=o.bind(t)))}}function Ti(){var e,i,n;let t;if(Lt()&&fn.performance)t=(i=(e=fn==null?void 0:fn.performance)==null?void 0:e.now)==null?void 0:i.call(e);else if("hrtime"in zt){const s=(n=zt==null?void 0:zt.hrtime)==null?void 0:n.call(zt);t=s[0]*1e3+s[1]/1e6}else t=Date.now();return t}const Wt={debug:Lt()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},nr={enabled:!0,level:0};class tn extends zg{constructor({id:e}={id:""}){super({level:0}),this.VERSION=ph,this._startTs=Ti(),this._deltaTs=Ti(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new Vg(`__probe-${this.id}__`,{[this.id]:nr}),this.timeStamp(`${this.id} started`),Yg(this),Object.seal(this)}isEnabled(){return this._getConfiguration().enabled}getLevel(){return this._getConfiguration().level}getTotal(){return Number((Ti()-this._startTs).toPrecision(10))}getDelta(){return Number((Ti()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._updateConfiguration({enabled:e}),this}setLevel(e){return this._updateConfiguration({level:e}),this}get(e){return this._getConfiguration()[e]}set(e,i){this._updateConfiguration({[e]:i})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,i){if(!e)throw new Error(i||"Assertion failed")}warn(e,...i){return this._log("warn",0,e,i,{method:Wt.warn,once:!0})}error(e,...i){return this._log("error",0,e,i,{method:Wt.error})}deprecated(e,i){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${i}\` instead`)}removed(e,i){return this.error(`\`${e}\` has been removed. Use \`${i}\` instead`)}probe(e,i,...n){return this._log("log",e,i,n,{method:Wt.log,time:!0,once:!0})}log(e,i,...n){return this._log("log",e,i,n,{method:Wt.debug})}info(e,i,...n){return this._log("info",e,i,n,{method:console.info})}once(e,i,...n){return this._log("once",e,i,n,{method:Wt.debug||Wt.info,once:!0})}table(e,i,n){return i?this._log("table",e,i,n&&[n]||[],{method:console.table||Ht,tag:qg(i)}):Ht}time(e,i){return this._log("time",e,i,[],{method:console.time?console.time:console.info})}timeEnd(e,i){return this._log("time",e,i,[],{method:console.timeEnd?console.timeEnd:console.info})}timeStamp(e,i){return this._log("time",e,i,[],{method:console.timeStamp||Ht})}group(e,i,n={collapsed:!1}){const s=(n.collapsed?console.groupCollapsed:console.group)||console.info;return this._log("group",e,i,[],{method:s})}groupCollapsed(e,i,n={}){return this.group(e,i,Object.assign({},n,{collapsed:!0}))}groupEnd(e){return this._log("groupEnd",e,"",[],{method:console.groupEnd||Ht})}withGroup(e,i,n){this.group(e,i)();try{n()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&super._shouldLog(e)}_emit(e,i){const n=i.method;ia(n),i.total=this.getTotal(),i.delta=this.getDelta(),this._deltaTs=Ti();const s=Kg(this.id,i.message,i);return n.bind(console,s,...i.args)}_getConfiguration(){return this._storage.config[this.id]||this._updateConfiguration(nr),this._storage.config[this.id]}_updateConfiguration(e){const i=this._storage.config[this.id]||{...nr};this._storage.setConfiguration({[this.id]:{...i,...e}})}}tn.VERSION=ph;function Kg(t,e,i){if(typeof e=="string"){const n=i.time?jg($g(i.total)):"";e=i.time?`${t}: ${n} ${e}`:`${t}: ${e}`,e=Xg(e,i.color,i.background)}return e}function qg(t){for(const e in t)for(const i in t[e])return i||"untitled";return"empty"}const sr="4.4.1",Zg=sr[0]>="0"&&sr[0]<="9"?`v${sr}`:"";function Gg(){const t=new tn({id:"loaders.gl"});return globalThis.loaders||(globalThis.loaders={}),globalThis.loaders.log=t,globalThis.loaders.version=Zg,globalThis.probe||(globalThis.probe={}),globalThis.probe.loaders=t,t}const Qg=Gg(),Jg=t=>typeof t=="boolean",Ve=t=>typeof t=="function",Dt=t=>t!==null&&typeof t=="object",nc=t=>Dt(t)&&t.constructor==={}.constructor,mh=t=>typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer,na=t=>Dt(t)&&typeof t.byteLength=="number"&&typeof t.slice=="function",ep=t=>!!t&&Ve(t[Symbol.iterator]),tp=t=>!!t&&Ve(t[Symbol.asyncIterator]),Bt=t=>typeof Response<"u"&&t instanceof Response||Dt(t)&&Ve(t.arrayBuffer)&&Ve(t.text)&&Ve(t.json),Ft=t=>typeof Blob<"u"&&t instanceof Blob,ip=t=>typeof ReadableStream<"u"&&t instanceof ReadableStream||Dt(t)&&Ve(t.tee)&&Ve(t.cancel)&&Ve(t.getReader),np=t=>Dt(t)&&Ve(t.read)&&Ve(t.pipe)&&Jg(t.readable),yh=t=>ip(t)||np(t);function sp(t,e){return bh(t||{},e)}
1function bh(t,e,i=0){if(i>3)return e;const n={...t};for(const[s,r]of Object.entries(e))r&&typeof r=="object"&&!Array.isArray(r)?n[s]=bh(n[s]||{},e[s],i+1):n[s]=e[s];return n}const rp="latest";function op(){var t;return(t=globalThis._loadersgl_)!=null&&t.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.4.1"),globalThis._loadersgl_.version}const ap=op();function ut(t,e){if(!t)throw new Error(e||"loaders.gl assertion failed.")}const At=typeof process!="object"||String(process)!=="[object process]"||process.browser,cp=typeof window<"u"&&typeof window.orientation<"u",sc=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version);sc&&parseFloat(sc[1]);class lp{constructor(e,i){g(this,"name");g(this,"workerThread");g(this,"isRunning",!0);g(this,"result");g(this,"_resolve",()=>{});g(this,"_reject",()=>{});this.name=e,this.workerThread=i,this.result=new Promise((n,s)=>{this._resolve=n,this._reject=s})}postMessage(e,i){this.workerThread.postMessage({source:"loaders.gl",type:e,payload:i})}done(e){ut(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){ut(this.isRunning),this.isRunning=!1,this._reject(e)}}class rr{terminate(){}}const or=new Map;function fp(t){ut(t.source&&!t.url||!t.source&&t.url);let e=or.get(t.source||t.url);return e||(t.url&&(e=hp(t.url),or.set(t.url,e)),t.source&&(e=vh(t.source),or.set(t.source,e))),ut(e),e}function hp(t){if(!t.startsWith("http"))return t;const e=up(t);return vh(e)}function vh(t){const e=new Blob([t],{type:"application/javascript"});return URL.createObjectURL(e)}function up(t){return`try { 2 importScripts('${t}'); 3} catch (error) { 4 console.error(error); 5 throw error; 6}`}function Th(t,e=!0,i){const n=i||new Set;if(t){if(rc(t))n.add(t);else if(rc(t.buffer))n.add(t.buffer);else if(!ArrayBuffer.isView(t)){if(e&&typeof t=="object")for(const s in t)Th(t[s],e,n)}}return i===void 0?Array.from(n):[]}function rc(t){return t?t instanceof ArrayBuffer||typeof MessagePort<"u"&&t instanceof MessagePort||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas:!1}const ar=()=>{};class Qr{constructor(e){g(this,"name");g(this,"source");g(this,"url");g(this,"terminated",!1);g(this,"worker");g(this,"onMessage");g(this,"onError");g(this,"_loadableURL","");const{name:i,source:n,url:s}=e;ut(n||s),this.name=i,this.source=n,this.url=s,this.onMessage=ar,this.onError=r=>console.log(r),this.worker=At?this._createBrowserWorker():this._createNodeWorker()}static isSupported(){return typeof Worker<"u"&&At||typeof rr<"u"&&!At}destroy(){this.onMessage=ar,this.onError=ar,this.worker.terminate(),this.terminated=!0}get isRunning(){return!!this.onMessage}postMessage(e,i){i=i||Th(e),this.worker.postMessage(e,i)}_getErrorFromErrorEvent(e){let i="Failed to load ";return i+=`worker ${this.name} from ${this.url}. `,e.message&&(i+=`${e.message} in `),e.lineno&&(i+=`:${e.lineno}:${e.colno}`),new Error(i)}_createBrowserWorker(){this._loadableURL=fp({source:this.source,url:this.url});const e=new Worker(this._loadableURL,{name:this.name});return e.onmessage=i=>{i.data?this.onMessage(i.data):this.onError(new Error("No data received"))},e.onerror=i=>{this.onError(this._getErrorFromErrorEvent(i)),this.terminated=!0},e.onmessageerror=i=>console.error(i),e}_createNodeWorker(){let e;if(this.url){const n=this.url.includes(":/")||this.url.startsWith("/")?this.url:`./${this.url}`,s=this.url.endsWith(".ts")||this.url.endsWith(".mjs")?"module":"commonjs";e=new rr(n,{eval:!1,type:s})}else if(this.source)e=new rr(this.source,{eval:!0});else throw new Error("no worker");return e.on("message",i=>{this.onMessage(i)}),e.on("error",i=>{this.onError(i)}),e.on("exit",i=>{}),e}}class dp{constructor(e){g(this,"name","unnamed");g(this,"source");g(this,"url");g(this,"maxConcurrency",1);g(this,"maxMobileConcurrency",1);g(this,"onDebug",()=>{});g(this,"reuseWorkers",!0);g(this,"props",{});g(this,"jobQueue",[]);g(this,"idleQueue",[]);g(this,"count",0);g(this,"isDestroyed",!1);this.source=e.source,this.url=e.url,this.setProps(e)}static isSupported(){return Qr.isSupported()}
6destroy(){this.idleQueue.forEach(e=>e.destroy()),this.isDestroyed=!0}setProps(e){this.props={...this.props,...e},e.name!==void 0&&(this.name=e.name),e.maxConcurrency!==void 0&&(this.maxConcurrency=e.maxConcurrency),e.maxMobileConcurrency!==void 0&&(this.maxMobileConcurrency=e.maxMobileConcurrency),e.reuseWorkers!==void 0&&(this.reuseWorkers=e.reuseWorkers),e.onDebug!==void 0&&(this.onDebug=e.onDebug)}async startJob(e,i=(s,r,o)=>s.done(o),n=(s,r)=>s.error(r)){const s=new Promise(r=>(this.jobQueue.push({name:e,onMessage:i,onError:n,onStart:r}),this));return this._startQueuedJob(),await s}async _startQueuedJob(){if(!this.jobQueue.length)return;const e=this._getAvailableWorker();if(!e)return;const i=this.jobQueue.shift();if(i){this.onDebug({message:"Starting job",name:i.name,workerThread:e,backlog:this.jobQueue.length});const n=new lp(i.name,e);e.onMessage=s=>i.onMessage(n,s.type,s.payload),e.onError=s=>i.onError(n,s),i.onStart(n);try{await n.result}catch(s){console.error(`Worker exception: ${s}`)}finally{this.returnWorkerToQueue(e)}}}returnWorkerToQueue(e){!At||this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(e.destroy(),this.count--):this.idleQueue.push(e),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count<this._getMaxConcurrency()){this.count++;const e=`${this.name.toLowerCase()} (#${this.count} of ${this.maxConcurrency})`;return new Qr({name:e,source:this.source,url:this.url})}return null}_getMaxConcurrency(){return cp?this.maxMobileConcurrency:this.maxConcurrency}}const gp={maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:!0,onDebug:()=>{}},ot=class ot{constructor(e){g(this,"props");g(this,"workerPools",new Map);this.props={...gp},this.setProps(e),this.workerPools=new Map}static isSupported(){return Qr.isSupported()}static getWorkerFarm(e={}){return ot._workerFarm=ot._workerFarm||new ot({}),ot._workerFarm.setProps(e),ot._workerFarm}destroy(){for(const e of this.workerPools.values())e.destroy();this.workerPools=new Map}setProps(e){this.props={...this.props,...e};for(const i of this.workerPools.values())i.setProps(this._getWorkerPoolProps())}getWorkerPool(e){const{name:i,source:n,url:s}=e;let r=this.workerPools.get(i);return r||(r=new dp({name:i,source:n,url:s}),r.setProps(this._getWorkerPoolProps()),this.workerPools.set(i,r)),r}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}};g(ot,"_workerFarm");let es=ot;function pp(t,e={}){var o;const i=e[t.id]||{},n=At?`${t.id}-worker.js`:`${t.id}-worker-node.js`;let s=i.workerUrl;if(!s&&t.id==="compression"&&(s=e.workerUrl),(e._workerType||((o=e==null?void 0:e.core)==null?void 0:o._workerType))==="test"&&(At?s=`modules/${t.module}/dist/${n}`:s=`modules/${t.module}/src/workers/${t.id}-worker-node.ts`),!s){let a=t.version;a==="latest"&&(a=rp);const c=a?`@${a}`:"";s=`https://unpkg.com/@loaders.gl/${t.module}${c}/dist/${n}`}return ut(s),s}function _p(t,e=ap){ut(t,"no worker provided");const i=t.version;return!(!e||!i)}function mp(t,e){var s,r;if(!es.isSupported())return!1;const i=(e==null?void 0:e._nodeWorkers)??((s=e==null?void 0:e.core)==null?void 0:s._nodeWorkers);if(!At&&!i)return!1;const n=(e==null?void 0:e.worker)??((r=e==null?void 0:e.core)==null?void 0:r.worker);return!!(t.worker&&n)}async function yp(t,e,i,n,s){const r=t.id,o=pp(t,i),c=es.getWorkerFarm(i==null?void 0:i.core).getWorkerPool({name:r,url:o});i=JSON.parse(JSON.stringify(i)),n=JSON.parse(JSON.stringify(n||{}));const l=await c.startJob("process-on-worker",bp.bind(null,s));return l.postMessage("process",{input:e,options:i,context:n}),await(await l.result).result}async function bp(t,e,i,n){switch(i){case"done":e.done(n);break;case"error":e.error(new Error(n.error));break;case"process":const{id:s,input:r,options:o}=n;try{const a=await t(r,o);e.postMessage("done",{id:s,result:a})}catch(a){const c=a instanceof Error?a.message:"unknown error";e.postMessage("error",{id:s,error:c})}break;
vendor: 3,987 bytes, line 6
6default:console.warn(`parse-with-worker unknown message ${i}`)}}function vp(t,e,i){if(i=i||t.byteLength,t.byteLength<i||e.byteLength<i)return!1;const n=new Uint8Array(t),s=new Uint8Array(e);for(let r=0;r<n.length;++r)if(n[r]!==s[r])return!1;return!0}function Tp(...t){return Ap(t)}function Ap(t){const e=t.map(r=>r instanceof ArrayBuffer?new Uint8Array(r):r),i=e.reduce((r,o)=>r+o.byteLength,0),n=new Uint8Array(i);let s=0;for(const r of e)n.set(r,s),s+=r.byteLength;return n.buffer}async function wp(t){const e=[];for await(const i of t)e.push(Sp(i));return Tp(...e)}function Sp(t){if(t instanceof ArrayBuffer)return t;if(ArrayBuffer.isView(t)){const{buffer:e,byteOffset:i,byteLength:n}=t;return oc(e,i,n)}return oc(t)}function oc(t,e=0,i=t.byteLength-e){const n=new Uint8Array(t,e,i),s=new Uint8Array(n.length);return s.set(n),s.buffer}function ac(){let t;if(typeof window<"u"&&window.performance)t=window.performance.now();else if(typeof process<"u"&&process.hrtime){const e=process.hrtime();t=e[0]*1e3+e[1]/1e6}else t=Date.now();return t}class cc{constructor(e,i){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=e,this.type=i,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=ac(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(ac()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}}class nn{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,i="count"){return this._getOrCreate({name:e,type:i})}get size(){return Object.keys(this.stats).length}reset(){for(const e of Object.values(this.stats))e.reset();return this}forEach(e){for(const i of Object.values(this.stats))e(i)}getTable(){const e={};return this.forEach(i=>{e[i.name]={time:i.time||0,count:i.count||0,average:i.getAverageTime()||0,hz:i.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(i=>this._getOrCreate(i))}_getOrCreate(e){const{name:i,type:n}=e;let s=this.stats[i];return s||(e instanceof cc?s=e:s=new cc(i,n),this.stats[i]=s),s}}const Ep="Queued Requests",xp="Active Requests",Pp="Cancelled Requests",Rp="Queued Requests Ever",Cp="Active Requests Ever",Mp={id:"request-scheduler",throttleRequests:!0,maxRequests:6,debounceTime:0};class C2{constructor(e={}){g(this,"props");g(this,"stats");g(this,"activeRequestCount",0);g(this,"requestQueue",[]);g(this,"requestMap",new Map);g(this,"updateTimer",null);this.props={...Mp,...e},this.stats=new nn({id:this.props.id}),this.stats.get(Ep),this.stats.get(xp),this.stats.get(Pp),this.stats.get(Rp),this.stats.get(C
6p)}setProps(e){e.throttleRequests!==void 0&&(this.props.throttleRequests=e.throttleRequests),e.maxRequests!==void 0&&(this.props.maxRequests=e.maxRequests),e.debounceTime!==void 0&&(this.props.debounceTime=e.debounceTime)}scheduleRequest(e,i=()=>0){if(!this.props.throttleRequests)return Promise.resolve({done:()=>{}});if(this.requestMap.has(e))return this.requestMap.get(e);const n={handle:e,priority:0,getPriority:i},s=new Promise(r=>(n.resolve=r,n));return this.requestQueue.push(n),this.requestMap.set(e,s),this._issueNewRequests(),s}_issueRequest(e){const{handle:i,resolve:n}=e;let s=!1;const r=()=>{s||(s=!0,this.requestMap.delete(i),this.activeRequestCount--,this._issueNewRequests())};return this.activeRequestCount++,n?n({done:r}):Promise.resolve({done:r})}_issueNewRequests(){this.updateTimer!==null&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>this._issueNewRequestsAsync(),this.props.debounceTime)}_issueNewRequestsAsync(){this.updateTimer!==null&&clearTimeout(this.updateTimer),this.updateTimer=null;const e=Math.max(this.props.maxRequests-this.activeRequestCount,0);if(e!==0){this._updateAllRequests();for(let i=0;i<e;++i){const n=this.requestQueue.shift();n&&this._issueRequest(n)}}}_updateAllRequests(){const e=this.requestQueue;for(let i=0;i<e.length;++i){const n=e[i];this._updateRequest(n)||(e.splice(i,1),this.requestMap.delete(n.handle),i--)}e.sort((i,n)=>i.priority-n.priority)}_updateRequest(e){return e.priority=e.getPriority(e.handle),e.priority<0?(e.resolve(null),!1):!0}}let Op="";const lc={};function Ip(t){for(const e in lc)if(t.startsWith(e)){const i=lc[e];t=t.replace(e,i)}return!t.startsWith("http://")&&!t.startsWith("https://")&&(t=`${Op}${t}`),t}function Ah(t){return t&&typeof t=="object"&&t.isBuffer}function sa(t){if(Ah(t))return t;if(t instanceof ArrayBuffer)return t;if(mh(t))return Jr(t);if(ArrayBuffer.isView(t)){const e=t.buffer;return t.byteOffset===0&&t.byteLength===t.buffer.byteLength?e:e.slice(t.byteOffset,t.byteOffset+t.byteLength)}if(typeof t=="string"){const e=t;return new TextEncoder().encode(e).buffer}if(t&&typeof t=="object"&&t._toArrayBuffer)return t._toArrayBuffer();throw new Error("toArrayBuffer")}function wh(t){if(t instanceof ArrayBuffer)return t;if(mh(t))return Jr(t);const{buffer:e,byteOffset:i,byteLength:n}=t;return e instanceof ArrayBuffer&&i===0&&n===e.byteLength?e:Jr(e,i,n)}function Jr(t,e=0,i=t.byteLength-e){const n=new Uint8Array(t,e,i),s=new Uint8Array(n.length);return s.set(n),s.buffer}function Np(t){return ArrayBuffer.isView(t)?t:new Uint8Array(t)}function Sh(t){const e=t?t.lastIndexOf("/"):-1;return e>=0?t.substr(e+1):t}function Eh(t){const e=t?t.lastIndexOf("/"):-1;return e>=0?t.substr(0,e):""}class Lp extends Error{constructor(i,n){super(i);g(this,"reason");g(this,"url");g(this,"response");this.reason=n.reason,this.url=n.url,this.response=n.response}}const Dp=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,Bp=/^([-\w.]+\/[-\w.+]+)/;function fc(t,e){return t.toLowerCase()===e.toLowerCase()}function Fp(t){const e=Bp.exec(t);return e?e[1]:t}function hc(t){const e=Dp.exec(t);return e?e[1]:""}const xh=/\?.*/;function kp(t){const e=t.match(xh);return e&&e[0]}function Ws(t){return t.replace(xh,"")}function Up(t){if(t.length<50)return t;const e=t.slice(t.length-15);return`${t.substr(0,32)}...${e}`}function Vs(t){return Bt(t)?t.url:Ft(t)?("name"in t?t.name:"")||"":typeof t=="string"?t:""}function $s(t){if(Bt(t)){const e=t.headers.get("content-type")||"",i=Ws(t.url);return Fp(e)||hc(i)}return Ft(t)?t.type||"":typeof t=="string"?hc(t):""}function zp(t){return Bt(t)?t.headers["content-length"]||-1:Ft(t)?t.size:typeof t=="string"?t.length:t instanceof ArrayBuffer||ArrayBuffer.isView(t)?t.byteLength:-1}async function Ph(t){if(Bt(t))return t;const e={},i=zp(t);i>=0&&(e["content-length"]=String(i));const n=Vs(t),s=$s(t);
6s&&(e["content-type"]=s);const r=await $p(t);r&&(e["x-first-bytes"]=r),typeof t=="string"&&(t=new TextEncoder().encode(t));const o=new Response(t,{headers:e});return Object.defineProperty(o,"url",{value:n}),o}async function Wp(t){if(!t.ok)throw await Vp(t)}async function Vp(t){const e=Up(t.url);let i=`Failed to fetch resource (${t.status}) ${t.statusText}: ${e}`;i=i.length>100?`${i.slice(0,100)}...`:i;const n={reason:t.statusText,url:t.url,response:t};try{const s=t.headers.get("Content-Type");n.reason=!t.bodyUsed&&(s!=null&&s.includes("application/json"))?await t.json():await t.text()}catch{}return new Lp(i,n)}async function $p(t){if(typeof t=="string")return`data:,${t.slice(0,5)}`;if(t instanceof Blob){const i=t.slice(0,5);return await new Promise(n=>{const s=new FileReader;s.onload=r=>{var o;return n((o=r==null?void 0:r.target)==null?void 0:o.result)},s.readAsDataURL(i)})}if(t instanceof ArrayBuffer){const i=t.slice(0,5);return`data:base64,${jp(i)}`}return null}function jp(t){let e="";const i=new Uint8Array(t);for(let n=0;n<i.byteLength;n++)e+=String.fromCharCode(i[n]);return btoa(e)}function Hp(t){return!Xp(t)&&!Yp(t)}function Xp(t){return t.startsWith("http:")||t.startsWith("https:")}function Yp(t){return t.startsWith("data:")}async function uc(t,e){var i,n;if(typeof t=="string"){const s=Ip(t);return Hp(s)&&(i=globalThis.loaders)!=null&&i.fetchNode?(n=globalThis.loaders)==null?void 0:n.fetchNode(s,e):await fetch(s,e)}return await Ph(t)}const hn=new tn({id:"loaders.gl"});class Kp{log(){return()=>{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}}class qp{constructor(){g(this,"console");this.console=console}log(...e){return this.console.log.bind(this.console,...e)}info(...e){return this.console.info.bind(this.console,...e)}warn(...e){return this.console.warn.bind(this.console,...e)}error(...e){return this.console.error.bind(this.console,...e)}}const eo={core:{baseUrl:void 0,fetch:null,mimeType:void 0,fallbackMimeType:void 0,ignoreRegisteredLoaders:void 0,nothrow:!1,log:new qp,useLocalLibraries:!1,CDN:"https://unpkg.com/@loaders.gl",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:ta,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]}},Zp={baseUri:"core.baseUrl",fetch:"core.fetch",mimeType:"core.mimeType",fallbackMimeType:"core.fallbackMimeType",ignoreRegisteredLoaders:"core.ignoreRegisteredLoaders",nothrow:"core.nothrow",log:"core.log",useLocalLibraries:"core.useLocalLibraries",CDN:"core.CDN",worker:"core.worker",maxConcurrency:"core.maxConcurrency",maxMobileConcurrency:"core.maxMobileConcurrency",reuseWorkers:"core.reuseWorkers",_nodeWorkers:"core.nodeWorkers",_workerType:"core._workerType",_worker:"core._workerType",limit:"core.limit",_limitMB:"core._limitMB",batchSize:"core.batchSize",batchDebounceMs:"core.batchDebounceMs",metadata:"core.metadata",transforms:"core.transforms",throws:"nothrow",dataType:"(no longer used)",uri:"core.baseUrl",method:"core.fetch.method",headers:"core.fetch.headers",body:"core.fetch.body",mode:"core.fetch.mode",credentials:"core.fetch.credentials",cache:"core.fetch.cache",redirect:"core.fetch.redirect",referrer:"core.fetch.referrer",referrerPolicy:"core.fetch.referrerPolicy",integrity:"core.fetch.integrity",keepalive:"
6core.fetch.keepalive",signal:"core.fetch.signal"},ra=["baseUrl","fetch","mimeType","fallbackMimeType","ignoreRegisteredLoaders","nothrow","log","useLocalLibraries","CDN","worker","maxConcurrency","maxMobileConcurrency","reuseWorkers","_nodeWorkers","_workerType","limit","_limitMB","batchSize","batchDebounceMs","metadata","transforms"];function Rh(){globalThis.loaders=globalThis.loaders||{};const{loaders:t}=globalThis;return t._state||(t._state={}),t._state}function Ch(){const t=Rh();return t.globalOptions=t.globalOptions||{...eo,core:{...eo.core}},Rt(t.globalOptions)}function Gp(t,e,i,n){return i=i||[],i=Array.isArray(i)?i:[i],Qp(t,i),Rt(e_(e,t,n))}function Rt(t){const e=i_(t);Mh(e);for(const i of ra)e.core&&e.core[i]!==void 0&&delete e[i];return e.core&&e.core._workerType!==void 0&&delete e._worker,e}function Qp(t,e){dc(t,null,eo,Zp,e);for(const i of e){const n=t&&t[i.id]||{},s=i.options&&i.options[i.id]||{},r=i.deprecatedOptions&&i.deprecatedOptions[i.id]||{};dc(n,i.id,s,r,e)}}function dc(t,e,i,n,s){const r=e||"Top level",o=e?`${e}.`:"";for(const a in t){const c=!e&&Dt(t[a]),l=a==="baseUri"&&!e,f=a==="workerUrl"&&e;if(!(a in i)&&!l&&!f){if(a in n)hn.level>0&&hn.warn(`${r} loader option '${o}${a}' no longer supported, use '${n[a]}'`)();else if(!c&&hn.level>0){const h=Jp(a,s);hn.warn(`${r} loader option '${o}${a}' not recognized. ${h}`)()}}}}function Jp(t,e){const i=t.toLowerCase();let n="";for(const s of e)for(const r in s.options){if(t===r)return`Did you mean '${s.id}.${r}'?`;const o=r.toLowerCase();(i.startsWith(o)||o.startsWith(i))&&(n=n||`Did you mean '${s.id}.${r}'?`)}return n}function e_(t,e,i){var o;const n=t.options||{},s={...n};n.core&&(s.core={...n.core}),Mh(s),((o=s.core)==null?void 0:o.log)===null&&(s.core={...s.core,log:new Kp}),gc(s,Rt(Ch()));const r=Rt(e);return gc(s,r),t_(s,i),n_(s),s}function gc(t,e){for(const i in e)if(i in e){const n=e[i];nc(n)&&nc(t[i])?t[i]={...t[i],...e[i]}:t[i]=e[i]}}function t_(t,e){var n;if(!e)return;((n=t.core)==null?void 0:n.baseUrl)!==void 0||(t.core||(t.core={}),t.core.baseUrl=Eh(Ws(e)))}function i_(t){const e={...t};return t.core&&(e.core={...t.core}),e}function Mh(t){t.baseUri!==void 0&&(t.core||(t.core={}),t.core.baseUrl===void 0&&(t.core.baseUrl=t.baseUri));for(const i of ra)if(t[i]!==void 0){const s=t.core=t.core||{};s[i]===void 0&&(s[i]=t[i])}const e=t._worker;e!==void 0&&(t.core||(t.core={}),t.core._workerType===void 0&&(t.core._workerType=e))}function n_(t){const e=t.core;if(e)for(const i of ra)e[i]!==void 0&&(t[i]=e[i])}function oa(t){return t?(Array.isArray(t)&&(t=t[0]),Array.isArray(t==null?void 0:t.extensions)):!1}function aa(t){Qn(t,"null loader"),Qn(oa(t),"invalid loader");let e;return Array.isArray(t)&&(e=t[1],t=t[0],t={...t,options:{...t.options,...e}}),(t!=null&&t.parseTextSync||t!=null&&t.parseText)&&(t.text=!0),t.text||(t.binary=!0),t}const Oh=()=>{const t=Rh();return t.loaderRegistry=t.loaderRegistry||[],t.loaderRegistry};function s_(t){const e=Oh();t=Array.isArray(t)?t:[t];for(const i of t){const n=aa(i);e.find(s=>n===s)||e.unshift(n)}}function r_(){return Oh()}const o_=/\.([^.]+)$/;async function a_(t,e=[],i,n){if(!Ih(t))return null;const s=Rt(i||{});if(s.core||(s.core={}),t instanceof Response&&pc(t)){const o=await t.clone().text(),a=un(o,e,{...s,core:{...s.core,nothrow:!0}},n);if(a)return a}let r=un(t,e,{...s,core:{...s.core,nothrow:!0}},n);if(r)return r;if(Ft(t)&&(t=await t.slice(0,10).arrayBuffer(),r=un(t,e,s,n)),!r&&t instanceof Response&&pc(t)){const o=await t.clone().text();r=un(o,e,s,n)}if(!r&&!s.core.nothrow)throw new Error(Nh(t));return r}function pc(t){const e=$s(t);return!!(e&&(e.startsWith("text/")||e==="application/json"||e.endsWith("+json")))}function un(t,e=[],i,n){if(!Ih(t))return null;const s=Rt(i||{});if(s.core||(s.core={}),e&&!Array.isArray(e))return aa(e);let r=[];e&&(r=r.concat(e)),s.core.ignoreRegisteredLoaders||r.push(...r_()),l_(r);const o=c_(t,r,s,n);if(!o&&!s.core.nothrow)throw new Error(Nh(t));return o}function c_(t,e,i,n){var l,f,h,u,d;const s=Vs(t),r=$s(t),o=Ws(s)||(n==null?void 0:n.url);let a=null,c="";return(l=i==null?void 0:i.core)!=null&&l.mimeType&&(a=cr(e,(f=i==null?void 0:i.core)==null?void 0:f.mimeType),c=`match forced by supplied MIME type ${(h=i==null?void 0:i.core)==null?void 0:h.mimeType}`),a=a||f_(e,o),c=c||(a?`matched url ${o}`:""),a=a||cr(e,r),c=c||(a?`matched MIME type ${r}`:""),a=a||u_(e,t),c=c||(a?`matched initial data ${Lh(t)}`:""),(u=i==null?void 0:i.core)!=null&&u.fallbackMimeType&&(a=a||cr(e,(d=i==null?void 0:i.core)==null?void 0:d.fallbackMimeType),c=c||(a?`matched fallback MIME type ${r}`:"")),c&&Qg.log(1,`selectLoader selected ${a==null?void 0:a.name}: ${c}.`),a}function Ih(t){return!(t instanceof Response&&t.status===204)}function Nh(t){const e=Vs(t),i=$s(t);let n="No valid loader found (";n+=e?`${Sh(e)}, `:"no url provided, ",n+=`MIME type: ${i?`"${i}"`:"not provided"}, `;const s=t?Lh(t):"";return n+=s?` first bytes: "${s}"`:"first bytes: not available",n+=")",n}function l_(t){for(const e of t)aa(e)}function f_(t,e){const i=e&&o_.exec(e),n=i&&i[1];return n?h_(t,n):null}function h_(t,e){e=e.toLowerCase();for(const i of t)for(const n of i.extensions)if(n.toLowerCase()===e)return i;return null}function cr(t,e){var i;for(const n of t)if((i=n.mimeTypes)!=null&&i.some(s=>
vendor: 8,432 bytes, line 6
6fc(e,s))||fc(e,`application/x.${n.id}`))return n;return null}function u_(t,e){if(!e)return null;for(const i of t)if(typeof e=="string"){if(d_(e,i))return i}else if(ArrayBuffer.isView(e)){if(_c(e.buffer,e.byteOffset,i))return i}else if(e instanceof ArrayBuffer&&_c(e,0,i))return i;return null}function d_(t,e){return e.testText?e.testText(t):(Array.isArray(e.tests)?e.tests:[e.tests]).some(n=>t.startsWith(n))}function _c(t,e,i){return(Array.isArray(i.tests)?i.tests:[i.tests]).some(s=>g_(t,e,i,s))}function g_(t,e,i,n){if(na(n))return vp(n,t,n.byteLength);switch(typeof n){case"function":return n(wh(t));case"string":const s=to(t,e,n.length);return n===s;default:return!1}}function Lh(t,e=5){return typeof t=="string"?t.slice(0,e):ArrayBuffer.isView(t)?to(t.buffer,t.byteOffset,e):t instanceof ArrayBuffer?to(t,0,e):""}function to(t,e,i){if(t.byteLength<e+i)return"";const n=new DataView(t);let s="";for(let r=0;r<i;r++)s+=String.fromCharCode(n.getUint8(e+r));return s}const p_=256*1024;function*__(t,e){const i=(e==null?void 0:e.chunkSize)||p_;let n=0;const s=new TextEncoder;for(;n<t.length;){const r=Math.min(t.length-n,i),o=t.slice(n,n+r);n+=r,yield wh(s.encode(o))}}const m_=256*1024;function*y_(t,e={}){const{chunkSize:i=m_}=e;let n=0;for(;n<t.byteLength;){const s=Math.min(t.byteLength-n,i),r=new ArrayBuffer(s),o=new Uint8Array(t,n,s);new Uint8Array(r).set(o),n+=s,yield r}}const b_=1024*1024;async function*v_(t,e){const i=(e==null?void 0:e.chunkSize)||b_;let n=0;for(;n<t.size;){const s=n+i,r=await t.slice(n,s).arrayBuffer();n=s,yield r}}function mc(t,e){return ta?T_(t,e):A_(t)}async function*T_(t,e){const i=t.getReader();let n;try{for(;;){const s=n||i.read();e!=null&&e._streamReadAhead&&(n=i.read());const{done:r,value:o}=await s;if(r)return;yield sa(o)}}catch{i.releaseLock()}}async function*A_(t,e){for await(const i of t)yield sa(i)}function w_(t,e){if(typeof t=="string")return __(t,e);if(t instanceof ArrayBuffer)return y_(t,e);if(Ft(t))return v_(t,e);if(yh(t))return mc(t,e);if(Bt(t)){const i=t.body;if(!i)throw new Error("Readable stream not available on Response");return mc(i,e)}throw new Error("makeIterator")}const Dh="Cannot convert supplied data type";function S_(t,e,i){if(e.text&&typeof t=="string")return t;if(Ah(t)&&(t=t.buffer),na(t)){const n=Np(t);return e.text&&!e.binary?new TextDecoder("utf8").decode(n):sa(n)}throw new Error(Dh)}async function E_(t,e,i){if(typeof t=="string"||na(t))return S_(t,e);if(Ft(t)&&(t=await Ph(t)),Bt(t))return await Wp(t),e.binary?await t.arrayBuffer():await t.text();if(yh(t)&&(t=w_(t,i)),ep(t)||tp(t))return wp(t);throw new Error(Dh)}function Bh(t,e){var r;const i=Ch(),n=t||i,s=n.fetch??((r=n.core)==null?void 0:r.fetch);return typeof s=="function"?s:Dt(s)?o=>uc(o,s):e!=null&&e.fetch?e==null?void 0:e.fetch:uc}function x_(t,e,i){if(i)return i;const n={fetch:Bh(e,t),...t};if(n.url){const s=Ws(n.url);n.baseUrl=s,n.queryString=kp(n.url),n.filename=Sh(s),n.baseUrl=Eh(s)}return Array.isArray(n.loaders)||(n.loaders=null),n}function P_(t,e){if(t&&!Array.isArray(t))return t;let i;if(t&&(i=Array.isArray(t)?t:[t]),e&&e.loaders){const n=Array.isArray(e.loaders)?e.loaders:[e.loaders];i=i?[...i,...n]:n}return i&&i.length?i:void 0}async function ts(t,e,i,n){e&&!Array.isArray(e)&&!oa(e)&&(n=void 0,i=e,e=void 0),t=await t,i=i||{};const s=Vs(t),o=P_(e,n),a=await a_(t,o,i);if(!a)return null;const c=Gp(i,a,o,s);return n=x_({url:s,_parse:ts,loaders:o},c,n||null),await R_(a,t,c,n)}async function R_(t,e,i,n){if(_p(t),i=sp(t.options,i),Bt(e)){const{ok:r,redirected:o,status:a,statusText:c,type:l,url:f}=e,h=Object.fromEntries(e.headers.entries());n.response={headers:h,ok:r,redirected:o,status:a,statusText:c,type:l,url:f}}e=await E_(e,t,i);const s=t;if(s.parseTextSync&&typeof e=="string")return s.parseTextSync(e,i,n);if(mp(t,i))return await yp(t,e,i,n,ts);if(s.parseText&&typeof e=="string")return await s.parseText(e,i,n);if(s.parse)return await s.parse(e,i,n);throw ut(!s.parseSync),new Error(`${t.id} loader - no parser found and worker is disabled`)}function C_(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function M_(t){return Array.isArray(t)?t.length===0||typeof t[0]=="number":!1}function O_(t){return C_(t)||M_(t)}async function is(t,e,i,n){var c;let s,r;!Array.isArray(e)&&!oa(e)?(s=[],r=e):(s=e,r=i);const o=Bh(r);let a=t;return typeof t=="string"&&(a=await o(t)),Ft(t)&&(a=await o(t)),typeof t=="string"&&((c=Rt(r||{}).core)!=null&&c.baseUrl||(r={...r,core:{...r==null?void 0:r.core,baseUrl:t}})),Array.isArray(s)?await ts(a,s,r):await ts(a,s,r)}const I_="4.4.1";var dh;const N_=(dh=globalThis.loaders)==null?void 0:dh.parseImageNode,io=typeof Image<"u",no=typeof ImageBitmap<"u",L_=!!N_,so=ta?!0:L_;function D_(t){switch(t){case"auto":return no||io||so;case"imagebitmap":return no;case"image":return io;case"data":return so;default:throw new Error(`@loaders.gl/images: image ${t} not supported in this environment`)}}function B_(){if(no)return"imagebitmap";if(io)return"image";if(so)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function F_(t){const e=U_(t);if(!e)throw new Error("Not an image");return e}function k_(t){switch(F_(t)){case"data":return t;case"image":case"imagebitmap":const e=document.createElement("canvas"),i=e.getContext("2d");if(!i)throw new Error("getImageData");return e.width=t.width,e.height=t.height,i.drawImage(t,0,0),i.getImageData(0,0,t.width,t.height);default:throw new Error("getImageData")}}function U_(t){return typeof ImageBitmap<"u"&&t instanceof ImageBitmap?"imagebitmap":typeof Image<"u"&&t instanceof Image?"image":t&&typeof t=="object"&&t.data&&t.width&&t.height?"data":null}const z_=/^data:image\/svg\+xml/,W_=/\.svg((\?|#).*)?$/;function ca(t){return t&&(z_.test(t)||W_.test(t))}function V_(t,e){if(ca(e)){let n=new TextDecoder().decode(t);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(n=unescape(encodeURIComponent(n)))}catch(r){throw new Error(r.message)}return`data:image/svg+xml;base64,${btoa(n)}`}return Fh(t,e)}function Fh(t,e){if(ca(e))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(t)])}async function kh(t,e,i){const n=V_(t,i),s=self.URL||self.webkitURL,r=typeof n!="string"&&s.createObjectURL(n);try{return await $_(r||n,e)}finally{r&&s.revokeObjectURL(r)}}async function $_(t,e){const i=new Image;return i.src=t,e.image&&e.image.decode&&i.decode?(await i.decode(),i):await new Promise((n,s)=>{try{i.onload=()=>n(i),i.onerror=r=>{const o=r instanceof Error?r.message:"error";s(new Error(o))}}catch(r){s(r)}})}let yc=!0;async function j_(t,e,i){let n;ca(i)?n=await kh(t,e,i):n=Fh(t,i);const s=e&&e.imagebitmap;return await H_(n,s)}async function H_(t,e=null){if((X_(e)||!yc)&&(e=null),e)try{return await createImageBitmap(t,e)}catch(i){console.warn(i),yc=!1}return await createImageBitmap(t)}function X_(t){if(!t)return!0;for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}function Y_(t){return!G_(t,"ftyp",4)||(t[8]&96)===0?null:K_(t)}function K_(t){switch(q_(t,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function q_(t,e,i){return String.fromCharCode(...t.slice(e,i))}function Z_(t){return[...t].map(e=>e.charCodeAt(0))}function G_(t,e,i=0){const n=Z_(e);for(let s=0;s<n.length;++s)if(n[s]!==t[s+i])return!1;return!0}const ze=!1,Li=!0;function Uh(t){const e=sn(t);return J_(e)||im(e)||em(e)||tm(e)||Q_(e)}function Q_(t){const e=new Uint8Array(t instanceof DataView?t.buffer:t),i=Y_(e);return i?{mimeType:i.mimeType,width:0,height:0}:null}function J_(t){const e=sn(t);return e.byteLength>=24&&e.getUint32(0,ze)===2303741511?{mimeType:"image/png",width:e.getUint32(16,ze),height:e.getUint32(20,ze)}:null}function em(t){const e=sn(t);return e.byteLength>=10&&e.getUint32(0,ze)===1195984440?{mimeType:"image/gif",width:e.getUint16(6,Li),height:e.getUint16(8,Li)}:null}function tm(t){const e=sn(t);return e.byteLength>=14&&e.getUint16(0,ze)===16973&&e.getUint32(2,Li)===e.byteLength?{mimeType:"image/bmp",width:e.getUint32(18,Li),height:e.getUint32(22,Li)}:null}function im(t){const e=sn(t);if(!(e.byteLength>=3&&e.getUint16(0,ze)===65496&&e.getUint8(2)===255))return null;const{tableMarkers:n,sofMarkers:s}=nm();let r=2;for(;r+9<e.byteLength;){const o=e.getUint16(r,ze);if(s.has(o))return{mimeType:"image/jpeg",height:e.getUint16(r+5,ze),width:e.getUint16(r+7,ze)}
6;if(!n.has(o))return null;r+=2,r+=e.getUint16(r,ze)}return null}function nm(){const t=new Set([65499,65476,65484,65501,65534]);for(let i=65504;i<65520;++i)t.add(i);return{tableMarkers:t,sofMarkers:new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502])}}function sn(t){if(t instanceof DataView)return t;if(ArrayBuffer.isView(t))return new DataView(t.buffer);if(t instanceof ArrayBuffer)return new DataView(t);throw new Error("toDataView")}async function sm(t,e){var s;const{mimeType:i}=Uh(t)||{},n=(s=globalThis.loaders)==null?void 0:s.parseImageNode;return Qn(n),await n(t,i)}async function rm(t,e,i){e=e||{};const s=(e.image||{}).type||"auto",{url:r}=i||{},o=om(s);let a;switch(o){case"imagebitmap":a=await j_(t,e,r);break;case"image":a=await kh(t,e,r);break;case"data":a=await sm(t);break;default:Qn(!1)}return s==="data"&&(a=k_(a)),a}function om(t){switch(t){case"auto":case"data":return B_();default:return D_(t),t}}const am=["png","jpg","jpeg","gif","webp","bmp","ico","svg","avif"],cm=["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],lm={image:{type:"auto",decode:!0}},fm={dataType:null,batchType:null,id:"image",module:"images",name:"Images",version:I_,mimeTypes:cm,extensions:am,parse:rm,tests:[t=>!!Uh(new DataView(t))],options:lm},j=new tn({id:"deck"});let ro={};function hm(t){ro=t}function ge(t,e,i,n){j.level>0&&ro[t]&&ro[t].call(null,e,i,n)}function um(t){const e=t[0],i=t[t.length-1];return e==="{"&&i==="}"||e==="["&&i==="]"}const dm={dataType:null,batchType:null,id:"JSON",name:"JSON",module:"",version:"",options:{},extensions:["json","geojson"],mimeTypes:["application/json","application/geo+json"],testText:um,parseTextSync:JSON.parse};function gm(){const t="9.3.1",e=globalThis.deck&&globalThis.deck.VERSION;if(e&&e!==t)throw new Error(`deck.gl - multiple versions detected: ${e} vs ${t}`);return e||(j.log(1,`deck.gl ${t}`)(),globalThis.deck={...globalThis.deck,VERSION:t,version:t,log:j,_registerLoggers:hm},s_([dm,[fm,{imagebitmap:{premultiplyAlpha:"none"}}]])),t}const pm=gm();function rn(t,e){var i;if(!t){const n=new Error(e||"shadertools: assertion failed.");throw(i=Error.captureStackTrace)==null||i.call(Error,n,rn),n}}const lr={number:{type:"number",validate(t,e){return Number.isFinite(t)&&typeof e=="object"&&(e.max===void 0||t<=e.max)&&(e.min===void 0||t>=e.min)}},array:{type:"array",validate(t,e){return Array.isArray(t)||ArrayBuffer.isView(t)}}};function _m(t){const e={};for(const[i,n]of Object.entries(t))e[i]=mm(n);return e}function mm(t){let e=bc(t);if(e!=="object")return{value:t,...lr[e],type:e};if(typeof t=="object")return t?t.type!==void 0?{...t,...lr[t.type],type:t.type}:t.value===void 0?{type:"object",value:t}:(e=bc(t.value),{...t,...lr[e],type:e}):{type:"object",value:null};throw new Error("props")}function bc(t){return Array.isArray(t)||ArrayBuffer.isView(t)?"array":typeof t}const ym=`#ifdef MODULE_LOGDEPTH 7 logdepth_adjustPosition(gl_Position); 8#endif 9`,bm=`#ifdef MODULE_MATERIAL 10 fragColor = material_filterColor(fragColor); 11#endif 12 13#ifdef MODULE_LIGHTING 14 fragColor = lighting_filterColor(fragColor); 15#endif 16 17#ifdef MODULE_FOG 18 fragColor = fog_filterColor(fragColor); 19#endif 20 21#ifdef MODULE_PICKING 22 fragColor = picking_filterHighlightColor(fragColor); 23 fragColor = picking_filterPickingColor(fragColor); 24#endif 25 26#ifdef MODULE_LOGDEPTH 27 logdepth_setFragDepth(); 28#endif 29`,vm={vertex:ym,fragment:bm},vc=/void\s+main\s*\([^)]*\)\s*\{\n?/,Tc=/}\n?[^{}]*$/,fr=[],zn="__LUMA_INJECT_DECLARATIONS__";function Tm(t){const e={vertex:{},fragment:{}};for(const i in t){let n=t[i];const s=Am(i);typeof n=="string"&&(n={order:0,injection:n}),e[s][i]=n}return e}function Am(t){const e=t.slice(0,2);switch(e){case"vs":return"vertex";case"fs":return"fragment";default:throw new Error(e)}}function ns(t,e,i,n=!1){const s=e==="vertex";for(const r in i){const o=i[r];o.sort((c,l)=>c.order-l.order),fr.length=o.length;for(let c=0,l=o.length;c<l;++c)fr[c]=o[c].injection;const a=`${fr.join(` 30`)} 31`;switch(r){case"vs:#decl":s&&(t=t.replace(zn,a));break;case"vs:#main-start":s&&(t=t.replace(vc,c=>c+a));break;case"vs:#main-end":s&&(t=t.replace(Tc,c=>a+c));break;case"fs:#decl":s||(t=t.replace(zn,a));break;case"fs:#main-start":s||(t=t.replace(vc,c=>c+a));break;case"fs:#main-end":s||(t=t.replace(Tc,c=>a+c));break;default:t=t.replace(r,c=>c+a)}}return t=t.replace(zn,""),n&&(t=t.replace(/\}\s*$/,r=>r+vm[e])),t}function ss(t){t.map(e=>wm(e))}function wm(t){if(t.instance)return;ss(t.dependencies||[]);const{propTypes:e={},deprecations:i=[],inject:n={}}=t,s={normalizedInjections:Tm(n),parsedDeprecations:Sm(i)};e&&(s.propValidators=_m(e)),t.instance=s;let r={};e&&(r=Object.entries(e).reduce((o,[a,c])=>{const l=c==null?void 0:c.value;return l&&(o[a]=l),o},{})),t.defaultUniforms={...t.defaultUniforms,...r}}
31function zh(t,e,i){var n;(n=t.deprecations)==null||n.forEach(s=>{var r;(r=s.regex)!=null&&r.test(e)&&(s.deprecated?i.deprecated(s.old,s.new)():i.removed(s.old,s.new)())})}function Sm(t){return t.forEach(e=>{switch(e.type){case"function":e.regex=new RegExp(`\\b${e.old}\\(`);break;default:e.regex=new RegExp(`${e.type} ${e.old};`)}}),t}function la(t){ss(t);const e={},i={};Wh({modules:t,level:0,moduleMap:e,moduleDepth:i});const n=Object.keys(i).sort((s,r)=>i[r]-i[s]).map(s=>e[s]);return ss(n),n}function Wh(t){const{modules:e,level:i,moduleMap:n,moduleDepth:s}=t;if(i>=5)throw new Error("Possible loop in shader dependency graph");for(const r of e)n[r.name]=r,(s[r.name]===void 0||s[r.name]<i)&&(s[r.name]=i);for(const r of e)r.dependencies&&Wh({modules:r.dependencies,level:i+1,moduleMap:n,moduleDepth:s})}const Em=/^(?:uniform\s+)?(?:(?:lowp|mediump|highp)\s+)?[A-Za-z0-9_]+(?:<[^>]+>)?\s+([A-Za-z0-9_]+)(?:\s*\[[^\]]+\])?\s*;/,xm=/((?:layout\s*\([^)]*\)\s*)*)uniform\s+([A-Za-z_][A-Za-z0-9_]*)\s*\{([\s\S]*?)\}\s*([A-Za-z_][A-Za-z0-9_]*)?\s*;/g;function Vh(t){return`${t.name}Uniforms`}function Pm(t,e){const i=e==="wgsl"?t.source:e==="vertex"?t.vs:t.fs;if(!i)return null;const n=Vh(t);return Om(i,e==="wgsl"?"wgsl":"glsl",n)}function Rm(t,e){const i=Object.keys(t.uniformTypes||{});if(!i.length)return null;const n=Pm(t,e);return n?{moduleName:t.name,uniformBlockName:Vh(t),stage:e,expectedUniformNames:i,actualUniformNames:n,matches:Lm(i,n)}:null}function Cm(t,e,i={}){var r,o;const n=Rm(t,e);if(!n||n.matches)return n;const s=Dm(n);return(o=(r=i.log)==null?void 0:r.error)==null||o.call(r,s,n)(),i.throwOnError!==!1&&rn(!1,s),n}function $h(t){var n;const e=[],i=Bm(t);for(const s of i.matchAll(xm)){const r=((n=s[1])==null?void 0:n.trim())||null;e.push({blockName:s[2],body:s[3],instanceName:s[4]||null,layoutQualifier:r,hasLayoutQualifier:!!r,isStd140:!!(r&&/\blayout\s*\([^)]*\bstd140\b[^)]*\)/.exec(r))})}return e}function Mm(t,e,i,n){var o;const s=$h(t).filter(a=>!a.isStd140),r=new Set;for(const a of s){if(r.has(a.blockName))continue;r.add(a.blockName);const c="",l=a.hasLayoutQualifier?`declares ${Fm(a.layoutQualifier)} instead of layout(std140)`:"does not declare layout(std140)",f=`${c}${e} shader uniform block ${a.blockName} ${l}. luma.gl host-side shader block packing assumes explicit layout(std140) for GLSL uniform blocks. Add \`layout(std140)\` to the block declaration.`;(o=i==null?void 0:i.warn)==null||o.call(i,f,a)()}return s}function Om(t,e,i){const n=e==="wgsl"?Im(t,i):Nm(t,i);if(!n)return null;const s=[];for(const r of n.split(` 32`)){const o=r.replace(/\/\/.*$/,"").trim();if(!o||o.startsWith("#"))continue;const a=e==="wgsl"?o.match(/^([A-Za-z0-9_]+)\s*:/):o.match(Em);a&&s.push(a[1])}return s}function Im(t,e){const i=new RegExp(`\\bstruct\\s+${e}\\b`,"m").exec(t);if(!i)return null;const n=t.indexOf("{",i.index);if(n<0)return null;let s=0;for(let r=n;r<t.length;r++){const o=t[r];if(o==="{"){s++;continue}if(o==="}"&&(s--,s===0))return t.slice(n+1,r)}return null}function Nm(t,e){const i=$h(t).find(n=>n.blockName===e);return(i==null?void 0:i.body)||null}function Lm(t,e){if(t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(t[i]!==e[i])return!1;return!0}function Dm(t){const{expectedUniformNames:e,actualUniformNames:i}=t,n=e.filter(a=>!i.includes(a)),s=i.filter(a=>!e.includes(a)),r=[`Expected ${e.length} fields, found ${i.length}.`],o=km(e,i);return o&&r.push(o),n.length&&r.push(`Missing from shader block (${n.length}): ${Ac(n)}.`),s.length&&r.push(`Unexpected in shader block (${s.length}): ${Ac(s)}.`),e.length<=12&&i.length<=12&&(n.length||s.length)&&(r.push(`Expected: ${e.join(", ")}.`),r.push(`Actual: ${i.join(", ")}.`)),`${t.moduleName}: ${t.stage} shader uniform block ${t.uniformBlockName} does not match module.uniformTypes. ${r.join(" ")}`}function Bm(t){return t.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*$/gm,"")}function Fm(t){return t.replace(/\s+/g," ").trim()}function km(t,e){const i=Math.min(t.length,e.length);for(let n=0;n<i;n++)if(t[n]!==e[n])return`First mismatch at field ${n+1}: expected ${t[n]}, found ${e[n]}.`;return t.length>e.length?`Shader block ends after field ${e.length}; expected next field ${t[e.length]}.`:e.length>t.length?`Shader block has extra field ${e.length}: ${e[t.length]}.`:null}function Ac(t,e=8){if(t.length<=e)return t.join(", ");const i=t.length-e;return`${t.slice(0,e).join(", ")}, ... (${i} more)`}function Um(t){switch(t==null?void 0:t.gpu.toLowerCase()){case"apple":return`#define APP
32LE_GPU 33// Apple optimizes away the calculation necessary for emulated fp64 34#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1 35#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1 36// Intel GPU doesn't have full 32 bits precision in same cases, causes overflow 37#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1 38`;case"nvidia":return`#define NVIDIA_GPU 39// Nvidia optimizes away the calculation necessary for emulated fp64 40#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1 41`;case"intel":return`#define INTEL_GPU 42// Intel optimizes away the calculation necessary for emulated fp64 43#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1 44// Intel's built-in 'tan' function doesn't have acceptable precision 45#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1 46// Intel GPU doesn't have full 32 bits precision in same cases, causes overflow 47#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1 48`;case"amd":return`#define AMD_GPU 49`;default:return`#define DEFAULT_GPU 50// Prevent driver from optimizing away the calculation necessary for emulated fp64 51#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1 52// Headless Chrome's software shader 'tan' function doesn't have acceptable precision 53#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1 54// If the GPU doesn't have full 32 bits precision, will causes overflow 55#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1 56`}}function zm(t,e){var n;if(Number(((n=t.match(/^#version[ \t]+(\d+)/m))==null?void 0:n[1])||100)!==300)throw new Error("luma.gl v9 only supports GLSL 3.00 shader sources");switch(e){case"vertex":return t=wc(t,Wm),t;case"fragment":return t=wc(t,Vm),t;default:throw new Error(e)}}const jh=[[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/,`#version 300 es 57`],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],Wm=[...jh,[oo("attribute"),"in $1"],[oo("varying"),"out $1"]],Vm=[...jh,[oo("varying"),"in $1"]];function wc(t,e){for(const[i,n]of e)t=t.replace(i,n);return t}function oo(t){return new RegExp(`\\b${t}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`,"g")}function Hh(t,e){let i="";for(const n in t){const s=t[n];if(i+=`void ${s.signature} { 58`,s.header&&(i+=` ${s.header}`),e[n]){const r=e[n];r.sort((o,a)=>o.order-a.order);for(const o of r)i+=` ${o.injection} 59`}s.footer&&(i+=` ${s.footer}`),i+=`} 60`}return i}function Xh(t){const e={vertex:{},fragment:{}};for(const i of t){let n,s;typeof i!="string"?(n=i,s=n.hook):(n={},s=i),s=s.trim();const[r,o]=s.split(":"),a=s.replace(/\(.+/,""),c=Object.assign(n,{signature:o});switch(r){case"vs":e.vertex[a]=c;break;case"fs":e.fragment[a]=c;break;default:throw new Error(r)}}return e}function $m(t,e){return{name:jm(t,e),language:"glsl",version:Hm(t)}}function jm(t,e="unnamed"){const n=/#define[^\S\r\n]*SHADER_NAME[^\S\r\n]*([A-Za-z0-9_-]+)\s*/.exec(t);return n?n[1]:e}function Hm(t){let e=100;const i=t.match(/[^\s]+/g);if(i&&i.length>=2&&i[0]==="#version"){const n=parseInt(i[1],10);Number.isFinite(n)&&(e=n)}if(e!==100&&e!==300)throw new Error(`Invalid GLSL version ${e}`);return e}const Ae="(?:var<\\s*(uniform|storage(?:\\s*,\\s*[A-Za-z_][A-Za-z0-9_]*)?)\\s*>|var)\\s+([A-Za-z_][A-Za-z0-9_]*)",we="\\s*",Xi=[new RegExp(`@binding\\(\\s*(auto|\\d+)\\s*\\)${we}@group\\(\\s*(\\d+)\\s*\\)${we}${Ae}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${we}@binding\\(\\s*(auto|\\d+)\\s*\\)${we}${Ae}`,"g")],ao=[new RegExp(`@binding\\(\\s*(auto|\\d+)\\s*\\)${we}@group\\(\\s*(\\d+)\\s*\\)${we}${Ae}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${we}@binding\\(\\s*(auto|\\d+)\\s*\\)${we}${Ae}`,"g")],Xm=[new RegExp(`@binding\\(\\s*(\\d+)\\s*\\)${we}@group\\(\\s*(\\d+)\\s*\\)${we}${Ae}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${we}@binding\\(\\s*(\\d+)\\s*\\)${we}${Ae}`,"g")],Ym=[new RegExp(`@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${Ae}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)\\s*${Ae}`,"g"),new RegExp(`@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${Ae}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${Ae}`,"g")];function fa(t){const e=t.split("");let i=0,n=0,s=!1,r=!1,o=!1;for(;i<t.length;){const a=t[i],c=t[i+1];if(r){o?o=!1:a==="\\"?o=!0:a==='"'&&(r=!1),i++;continue}if(s){a===` 61`||a==="\r"?s=!1:e[i]=" ",i++;continue}if(n>0){if(a==="/"&&c==="*"){e[i]=" ",e[i+1]=" ",n++,i+=2;continue}if(a==="*"&&c==="/"){e[i]=" ",e[i+1]=" ",n--,i+=2;continue}a!==` 62`&&a!=="\r"&&(e[i]=" "),i++;continue}if(a==='"'){r=!0,i++;continue}if(a==="/"&&c==="/"){e[i]=" ",e[i+1]=" ",s=!0,i+=2;continue}if(a==="/"&&c==="*"){e[i]=" ",e[i+1]=" ",n=1,i+=2;continue}i++}return e.join("")}function di(t,e){var s;const i=fa(t),n=[];for(const r of e){r.lastIndex=0;let o;for(o=r.exec(i);o;){const a=r===e[0],c=o.index,l=o[0].length;n.push({match:t.slice(c,c+l),index:c,length:l,bindingToken:o[a?1:2],groupToken:o[a?2:1],accessDeclaration:(s=o[3])==null?void 0:s.trim(),name:o[4]}),o=r.exec(i)}}return n.sort((r,o)=>r.index-o.index)}function Yh(t,e,i){const n=di(t,e);if(!n.length)return t;let s="",r=0;for(const o of n)s+=t.slice(r,o.index),s+=i(o),r=o.index+o.length;return s+=t.slice(r),s}function Kh(t){return/@binding\(\s*auto\s*\)/.test(fa(t))}function Km(t,e){return di(t,e===Xi||e===ao?Ym:e).find(n=>n.bindingToken==="auto")}const Sc=[new RegExp(`@binding\\(\\s*(\\d+)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${Ae}\\s*:\\s*([^;]+);`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(\\d+)\\s*\\)\\s*${Ae}\\s*:\\s*([^;]+);`,"g")];function qh(t,e=[]){var r;const i=fa(t),n=new Map;for(const o of e)n.set(Ec(o.name,o.group,o.location),o.moduleName);const s=[];for(const o of Sc){o.lastIndex=0;let a;for(a=o.exec(i);a;){const c=o===Sc[0],l=Number(a[c?1:2]),f=Number(a[c?2:1]),h=(r=a[3])==null?void 0:r.trim(),u=a[4],d=a[5].trim(),p=n.get(Ec(u,f,l));s.push(qm({name:u,group:f,binding:l,owner:p?"module":"application",moduleName:p,accessDeclaration:h,resourceType:d})),a=o.exec(i)}}return s.sort((o,a)=>o.group!==a.group?o.group-a.group:o.binding!==a.binding?o.binding-a.binding:o.name.localeCompare(a.name))}function qm(t){const e={name:t.name,group:t.group,binding:t.binding,owner:t.owner,kind:"unknown",moduleName:t.moduleName,resourceType:t.resourceType};if(t.accessDeclaration){const i=t.accessDeclaration.split(",").map(n=>n.trim());if(i[0]==="uniform")return{...e,kind:"uniform",access:"uniform"};if(i[0]==="storage"){const n=i[1]||"read_write";return{...e,kind:n==="read"?"read-only-storage":"storage",access:n}}}return t.resourceType==="sampler"||t.resourceType==="sampler_comparison"?{...e,kind:"sampler",samplerKind:t.resourceType==="sampler_comparison"?"comparison":"filtering"}:t.resourceType.startsWith("texture_storage_")?{...e,kind:"storage-texture",access:Gm(t.resourceType),viewDimension:xc(t.resourceType)}:t.resourceType.startsWith("texture_")?{...e,kind:"texture",viewDimension:xc(t.resourceType),sampleType:Zm(t.resourceType),multisampled:t.resourceType.startsWith("texture_multisampled_")}:e}function Ec(t,e,i){return`${e}:${i}:${t}`}function xc(t){if(t.includes("cube_array"))return"cube-array";if(t.includes("2d_array"))return"2d-array";if(t.includes("cube"))return"cube";if(t.includes("3d"))return"3d";if(t.includes("2d"))return"2d";if(t.includes("1d"))return"1d"}function Zm(t){if(t.startsWith("texture_depth_"))return"depth";if(t.includes("<i32>"))return"sint";if(t.includes("<u32>"))return"uint";if(t.includes("<f32>"))return"float"}function Gm(t){const e=/,\s*([A-Za-z_][A-Za-z0-9_]*)\s*>$/.exec(t);return e==null?void 0:e[1]}const ha=` 63 64${zn} 65`,Yi=100,Qm=`precision highp float; 66`;function Jm(t){const e=la(t.modules||[]),{source:i,bindingAssignments:n}=ty(t.platformInfo,{...t,source:t.source,stage:"vertex",modules:e});return{source:i,getUniforms:Zh(e),bindingAssignments:n,bindingTable:qh(i,n)}}function ey(t){const{vs:e,fs:i}=t,n=la(t.modules||[]);return{vs:Pc(t.platformInfo,{...t,source:e,stage:"vertex",modules:n}),fs:Pc(t.platformInfo,{...t,source:i,stage:"fragment",modules:n}),getUniforms:Zh(n)}}function ty(t,e){var v;const{source:i,stage:n,modules:s,hookFunctions:r=[],inject:o={},log:a}=e;rn(typeof i=="string","shader source must be a string");const c=i;let l="";const f=Xh(r),h={},u={},d={};for(const S in o){const E=typeof o[S]=="string"?{injection:o[S],order:0}:o[S],x=/^(v|f)s:(#)?([\w-]+)$/.exec(S);if(x){const M=x[2],O=x[3];M?O==="decl"?u[S]=[E]:d[S]=[E]:h[S]=[E]}else d[S]=[E]}const p=s,_=sy(c),m=ny(_.source),b=cy(p,e._bindingRegistry,m),A=[];for(const S of p){a&&zh(S,c,a);const E=ry(Gh(S,"wgsl",a),S,{usedBindingsByGroup:m,bindingRegistry:e._bindingRegistry,reservedBindingKeysByGroup:b});A.push(...E.bindingAssignments);const x=E.source;l+=x;const M=((v=S.injections)==null?void 0:v[n])||{};for(const O in M){const N=/^(v|f)s:#([\w-]+)$/.exec(O);if(N){const B=N[2]==="decl"?u:d;B[O]=B[O]||[],B[O].push(M[O])}else h[O]=h[O]||[],h[O].push(M[O])}}return l+=ha,l=ns(l,n,u),l+=Hh(f[n],h),l+=dy(A),l+=_.source,l=ns(l,n,d),uy(l),{source:l,bindingAssignments:A}}function Pc(t,e){var x;const{source:i,stage:n,language:s="glsl",modules:r,defines:o={},hookFunctions:a=[],inject:c={},prologue:l=!0,log:f}=e;rn(typeof i=="string","shader source must be a string");const h=s==="glsl"?$m(i).version:-1,u=t.shaderLanguageVersion,d=h===100?"#version 100":"#version 300 es",_=i.split(` 67`).slice(1).join(` 68`),m={};r.forEach(M=>{Object.assign(m,M.defines)}),Object.assign(m,o);let b="";switch(s){case"wgsl":break;case"glsl":b=l?`${d} 69 70// ----- PROLOGUE ------------------------- 71${`#define SHADER_TYPE_${n.toUpperCase()}`} 72 73${Um(t)} 74${n==="fragment"?Qm:""} 75 76// ----- APPLICATION DEFINES ------------------------- 77 78${iy(m)} 79 80`:`${d} 81`;break}const A=Xh(a),v={},S={},E={};for(const M in c){const O=typeof c[M]=="string"?{injection:c[M],order:0}:c[M],N=/^(v|f)s:(#)?([\w-]+)$/.exec(M);if(N){const D=N[2],B=N[3];D?B==="decl"?S[M]=[O]:E[M]=[O]:v[M]=[O]}else E[M]=[O]}for(const M of r){f&&zh(M,_,f);const O=Gh(M,n,f);b+=O;const N=((x=M.instance)==null?void 0:x.normalizedInjections[n])||{};for(const D in N){const B=/^(v|f)s:#([\w-]+)$/.exec(D);if(B){const z=B[2]==="decl"?S:E;z[D]=z[D]||[],z[D].push(N[D])}else v[D]=v[D]||[],v[D].push(N[D])}}return b+="// ----- MAIN SHADER SOURCE -------------------------",b+=ha,b=ns(b,
81n,S),b+=Hh(A[n],v),b+=_,b=ns(b,n,E),s==="glsl"&&h!==u&&(b=zm(b,n)),s==="glsl"&&Mm(b,n,f),b.trim()}function Zh(t){return function(i){var s;const n={};for(const r of t){const o=(s=r.getUniforms)==null?void 0:s.call(r,i,n);Object.assign(n,o)}return n}}function iy(t={}){let e="";for(const i in t){const n=t[i];(n||Number.isFinite(n))&&(e+=`#define ${i.toUpperCase()} ${t[i]} 82`)}return e}function Gh(t,e,i){let n;switch(e){case"vertex":n=t.vs||"";break;case"fragment":n=t.fs||"";break;case"wgsl":n=t.source||"";break;default:rn(!1)}if(!t.name)throw new Error("Shader module must have a name");Cm(t,e,{log:i});const s=t.name.toUpperCase().replace(/[^0-9a-z]/gi,"_");let r=`// ----- MODULE ${t.name} --------------- 83 84`;return e!=="wgsl"&&(r+=`#define MODULE_${s} 85`),r+=`${n} 86`,r}function ny(t){const e=new Map;for(const i of di(t,Xm)){const n=Number(i.bindingToken),s=Number(i.groupToken);ua(s,n,i.name),ni(e,s,n,`application binding "${i.name}"`)}return e}function sy(t){const e=di(t,ao),i=new Map;for(const r of e){if(r.bindingToken==="auto")continue;const o=Number(r.bindingToken),a=Number(r.groupToken);ua(a,o,r.name),ni(i,a,o,`application binding "${r.name}"`)}const n={sawSupportedBindingDeclaration:e.length>0},s=Yh(t,ao,r=>ay(r,i,n));if(Kh(t)&&!n.sawSupportedBindingDeclaration)throw new Error('Unsupported @binding(auto) declaration form in application WGSL. Use adjacent "@group(N)" and "@binding(auto)" decorators followed by a bindable "var" declaration.');return{source:s}}function ry(t,e,i){const n=[],r={sawSupportedBindingDeclaration:di(t,Xi).length>0,nextHintedBindingLocation:typeof e.firstBindingSlot=="number"?e.firstBindingSlot:null},o=Yh(t,Xi,a=>oy(a,{module:e,context:i,bindingAssignments:n,relocationState:r}));if(Kh(t)&&!r.sawSupportedBindingDeclaration)throw new Error(`Unsupported @binding(auto) declaration form in module "${e.name}". Use adjacent "@group(N)" and "@binding(auto)" decorators followed by a bindable "var" declaration.`);return{source:o,bindingAssignments:n}}function oy(t,e){var u,d;const{module:i,context:n,bindingAssignments:s,relocationState:r}=e,{match:o,bindingToken:a,groupToken:c,name:l}=t,f=Number(c);if(a==="auto"){const p=Qh(f,i.name,l),_=(u=n.bindingRegistry)==null?void 0:u.get(p),m=_!==void 0?_:r.nextHintedBindingLocation===null?Cc(f,n.usedBindingsByGroup):Cc(f,n.usedBindingsByGroup,r.nextHintedBindingLocation);return Rc(i.name,f,m,l),_!==void 0&&ly(n.reservedBindingKeysByGroup,f,m,p)?(s.push({moduleName:i.name,name:l,group:f,location:m}),o.replace(/@binding\(\s*auto\s*\)/,`@binding(${m})`)):(ni(n.usedBindingsByGroup,f,m,`module "${i.name}" binding "${l}"`),(d=n.bindingRegistry)==null||d.set(p,m),s.push({moduleName:i.name,name:l,group:f,location:m}),r.nextHintedBindingLocation!==null&&_===void 0&&(r.nextHintedBindingLocation=m+1),o.replace(/@binding\(\s*auto\s*\)/,`@binding(${m})`))}const h=Number(a);return Rc(i.name,f,h,l),ni(n.usedBindingsByGroup,f,h,`module "${i.name}" binding "${l}"`),s.push({moduleName:i.name,name:l,group:f,location:h}),o}function ay(t,e,i){const{match:n,bindingToken:s,groupToken:r,name:o}=t,a=Number(r);if(s==="auto"){const c=hy(a,e);return ua(a,c,o),ni(e,a,c,`application binding "${o}"`),n.replace(/@binding\(\s*auto\s*\)/,`@binding(${c})`)}return i.sawSupportedBindingDeclaration=!0,n}function cy(t,e,i){const n=new Map;if(!e)return n;for(const s of t)for(const r of fy(s)){const o=Qh(r.group,s.name,r.name),a=e.get(o);if(a!==void 0){const c=n.get(r.group)||new Map,l=c.get(a);if(l&&l!==o)throw new Error(`Duplicate WGSL binding reservation for modules "${l}" and "${o}": group ${r.group}, binding ${a}.`);ni(i,r.group,a,`registered module binding "${o}
86"`),c.set(a,o),n.set(r.group,c)}}return n}function ly(t,e,i,n){const s=t.get(e);if(!s)return!1;const r=s.get(i);if(!r)return!1;if(r!==n)throw new Error(`Registered module binding "${n}" collided with "${r}": group ${e}, binding ${i}.`);return!0}function fy(t){const e=[],i=t.source||"";for(const n of di(i,Xi))e.push({name:n.name,group:Number(n.groupToken)});return e}function ua(t,e,i){if(t===0&&e>=Yi)throw new Error(`Application binding "${i}" in group 0 uses reserved binding ${e}. Application-owned explicit group-0 bindings must stay below ${Yi}.`)}function Rc(t,e,i,n){if(e===0&&i<Yi)throw new Error(`Module "${t}" binding "${n}" in group 0 uses reserved application binding ${i}. Module-owned explicit group-0 bindings must be ${Yi} or higher.`)}function ni(t,e,i,n){const s=t.get(e)||new Set;if(s.has(i))throw new Error(`Duplicate WGSL binding assignment for ${n}: group ${e}, binding ${i}.`);s.add(i),t.set(e,s)}function Cc(t,e,i){const n=e.get(t)||new Set;let s=i??(t===0?Yi:n.size>0?Math.max(...n)+1:0);for(;n.has(s);)s++;return s}function hy(t,e){const i=e.get(t)||new Set;let n=0;for(;i.has(n);)n++;return n}function uy(t){const e=Km(t,Xi);if(!e)return;const i=gy(t,e.index);throw i?new Error(`Unresolved @binding(auto) for module "${i}" binding "${e.name}" remained in assembled WGSL source.`):py(t,e.index)?new Error(`Unresolved @binding(auto) for application binding "${e.name}" remained in assembled WGSL source.`):new Error(`Unresolved @binding(auto) remained in assembled WGSL source near "${_y(e.match)}".`)}function dy(t){if(t.length===0)return"";let e=`// ----- MODULE WGSL BINDING ASSIGNMENTS --------------- 87`;for(const i of t)e+=`// ${i.moduleName}.${i.name} -> @group(${i.group}) @binding(${i.location}) 88`;return e+=` 89`,e}function Qh(t,e,i){return`${t}:${e}:${i}`}function gy(t,e){const i=/^\/\/ ----- MODULE ([^\n]+) ---------------$/gm;let n,s;for(s=i.exec(t);s&&s.index<=e;)n=s[1],s=i.exec(t);return n}function py(t,e){const i=t.indexOf(ha);return i>=0?e>i:!0}function _y(t){return t.replace(/\s+/g," ").trim()}const da="([a-zA-Z_][a-zA-Z0-9_]*)",my=new RegExp(`^\\s*\\#\\s*ifdef\\s*${da}\\s*$`),yy=new RegExp(`^\\s*\\#\\s*ifndef\\s*${da}\\s*(?:\\/\\/.*)?$`),by=/^\s*\#\s*else\s*(?:\/\/.*)?$/,vy=/^\s*\#\s*endif\s*$/,Ty=new RegExp(`^\\s*\\#\\s*ifdef\\s*${da}\\s*(?:\\/\\/.*)?$`),Ay=/^\s*\#\s*endif\s*(?:\/\/.*)?$/;function wy(t,e){var o,a;const i=t.split(` 90`),n=[],s=[];let r=!0;for(const c of i){const l=c.match(Ty)||c.match(my),f=c.match(yy),h=c.match(by),u=c.match(Ay)||c.match(vy);if(l||f){const d=(o=l||f)==null?void 0:o[1],p=!!((a=e==null?void 0:e.defines)!=null&&a[d]),_=l?p:!p,m=r&&_;s.push({parentActive:r,branchTaken:_,active:m}),r=m}else if(h){const d=s[s.length-1];if(!d)throw new Error("Encountered #else without matching #ifdef or #ifndef");d.active=d.parentActive&&!d.branchTaken,d.branchTaken=!0,r=d.active}else u?(s.pop(),r=s.length?s[s.length-1].active:!0):r&&n.push(c)}if(s.length>0)throw new Error("Unterminated conditional block in shader source");return n.join(` 91`)}const bt=class bt{constructor(){g(this,"_hookFunctions",[]);g(this,"_defaultModules",[]);g(this,"_wgslBindingRegistry",new Map)}static getDefaultShaderAssembler(){return bt.defaultShaderAssembler=bt.defaultShaderAssembler||new bt,bt.defaultShaderAssembler}addDefaultModule(e){this._defaultModules.find(i=>i.name===(typeof e=="string"?e:e.name))||this._defaultModules.push(e)}removeDefaultModule(e){const i=typeof e=="string"?e:e.name;this._defaultModules=this._defaultModules.filter(n=>n.name!==i)}addShaderHook(e,i){i&&(e=Object.assign(i,{hook:e})),this._hookFunctions.push(e)}assembleWGSLShader(e){const i=this._getModuleList(e.modules),n=this._hookFunctions,{source:s,getUniforms:r,bindingAssignments:o}=Jm({...e,source:e.source,_bindingRegistry:this._wgslBindingRegistry,modules:i,hookFunctions:n}),a={...i.reduce((l,f)=>(Object.assign(l,f.defines),l),{}),...e.defines},c=e.platformInfo.shaderLanguage==="wgsl"?wy(s,{defines:a}):s;return{source:c,getUniforms:r,modules:i,bindingAssignments:o,bindingTable:qh(c,o)}}assembleGLSLShaderPair(e){const i=this._getModuleList(e.modules),n=this._hookFunctions;return{...ey({...e,vs:e.vs,fs:e.fs,modules:i,hookFunctions:n}),modules:i}}_getModuleList(e=[]){const i=new Array(this._defaultModules.length+e.length),n={};let s=0;for(let r=0,o=this._defaultModules.length;r<o;++r){const a=this._defaultModules[r],c=a.name;i[s++]=a,n[c]=!0}for(let r=0,o=e.length;r<o;++r){const a=e[r],c=a.name;n[c]||(i[s++]=a,n[c]=!0)}return i.length=s,ss(i),i}};g(bt,"defaultShaderAssembler");let rs=bt;const Sy=`out vec4 transform_output; 92void main() { 93 transform_output = vec4(0); 94}`,Ey=`#version 300 es 95${Sy}`;function xy(t){const{input:e,inputChannels:i,output:n}={};if(!e)return Ey;if(!i)throw new Error("inputChannels");const s=Py(i),r=Ry(e,i);return`#version 300 es 96in ${s} ${e}; 97out vec4 ${n}; 98void main() { 99 ${n} = ${r}; 100}`}function Py(t){switch(t){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error(`invalid channels: ${t}`)}}function Ry(t,e){switch(e){case 1:return`vec4(${t}, 0.0, 0.0, 1.0)`;case 2:return`vec4(${t}, 0.0, 1.0)`;case 3:return`vec4(${t}
100, 1.0)`;case 4:return t;default:throw new Error(`invalid channels: ${e}`)}}const Cy={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...Cy}};const _e=globalThis.mathgl.config;function My(t,{precision:e=_e.precision}={}){return t=Oy(t),`${parseFloat(t.toPrecision(e))}`}function Ct(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Re(t,e,i){return Ny(t,n=>Math.max(e,Math.min(i,n)))}function wt(t,e,i){return Ct(t)?t.map((n,s)=>wt(n,e[s],i)):i*e+(1-i)*t}function Ki(t,e,i){const n=_e.EPSILON;try{if(t===e)return!0;if(Ct(t)&&Ct(e)){if(t.length!==e.length)return!1;for(let s=0;s<t.length;++s)if(!Ki(t[s],e[s]))return!1;return!0}return t&&t.equals?t.equals(e):e&&e.equals?e.equals(t):typeof t=="number"&&typeof e=="number"?Math.abs(t-e)<=_e.EPSILON*Math.max(1,Math.abs(t),Math.abs(e)):!1}finally{_e.EPSILON=n}}function Oy(t){return Math.round(t/_e.EPSILON)*_e.EPSILON}function Iy(t){return t.clone?t.clone():new Array(t.length)}function Ny(t,e,i){if(Ct(t)){const n=t;i=i||Iy(n);for(let s=0;s<i.length&&s<n.length;++s){const r=typeof t=="number"?t:t[s];i[s]=e(r,s,i)}return i}return e(t)}class ga extends Array{clone(){return new this.constructor().copy(this)}fromArray(e,i=0){for(let n=0;n<this.ELEMENTS;++n)this[n]=e[n+i];return this.check()}toArray(e=[],i=0){for(let n=0;n<this.ELEMENTS;++n)e[i+n]=this[n];return e}toObject(e){return e}from(e){return Array.isArray(e)?this.copy(e):this.fromObject(e)}to(e){return e===this?this:Ct(e)?this.toArray(e):this.toObject(e)}toTarget(e){return e?this.to(e):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(_e)}formatString(e){let i="";for(let n=0;n<this.ELEMENTS;++n)i+=(n>0?", ":"")+My(this[n],e);return`${e.printTypes?this.constructor.name:""}[${i}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let i=0;i<this.ELEMENTS;++i)if(!Ki(this[i],e[i]))return!1;return!0}exactEquals(e){if(!e||this.length!==e.length)return!1;for(let i=0;i<this.ELEMENTS;++i)if(this[i]!==e[i])return!1;return!0}negate(){for(let e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}lerp(e,i,n){if(n===void 0)return this.lerp(this,e,i);for(let s=0;s<this.ELEMENTS;++s){const r=e[s],o=typeof i=="number"?i:i[s];this[s]=r+n*(o-r)}return this.check()}min(e){for(let i=0;i<this.ELEMENTS;++i)this[i]=Math.min(e[i],this[i]);return this.check()}max(e){for(let i=0;i<this.ELEMENTS;++i)this[i]=Math.max(e[i],this[i]);return this.check()}clamp(e,i){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e[n]),i[n]);return this.check()}add(...e){for(const i of e)for(let n=0;n<this.ELEMENTS;++n)this[n]+=i[n];return this.check()}subtract(...e){for(const i of e)for(let n=0;n<this.ELEMENTS;++n)this[n]-=i[n];return this.check()}scale(e){if(typeof e=="number")for(let i=0;i<this.ELEMENTS;++i)this[i]*=e;else for(let i=0;i<this.ELEMENTS&&i<e.length;++i)this[i]*=e[i];return this.check()}multiplyByScalar(e){for(let i=0;i<this.ELEMENTS;++i)this[i]*=e;return this.check()}check(){if(_e.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let e=this.length===this.ELEMENTS;for(let i=0;i<this.ELEMENTS;++i)e=e&&Number.isFinite(this[i]);return e}sub(e){return this.subtract(e)}setScalar(e){for(let i=0;i<this.ELEMENTS;++i)this[i]=e;return this.check()}addScalar(e){for(let i=0;i<this.ELEMENTS;++i)this[i]+=e;return this.check()}subScalar(e){return this.addScalar(-e)}multiplyScalar(e){for(let i=0;i<this.ELEMENTS;++i)this[i]*=e;return this.check()}divideScalar(e){return this.multiplyByScalar(1/e)}clampScalar(e,i){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e),i);return this.check()}get elements(){return this}}function Ly(t,e){if(t.length!==e)return!1;for(let i=0;i<t.length;++i)if(!Number.isFinite(t[i]))return!1;return!0}function ee(t){if(!Number.isFinite(t))throw new Error(`Invalid number ${JSON.stringify(t)}`);return t}function Di(t,e,i=""){if(_e.debug&&!Ly(t,e))throw new Error(`math.gl: ${i}
100 some fields set to invalid numbers'`);return t}function Mc(t,e){if(!t)throw new Error(`math.gl assertion ${e}`)}class Jh extends ga{get x(){return this[0]}set x(e){this[0]=ee(e)}get y(){return this[1]}set y(e){this[1]=ee(e)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let e=0;for(let i=0;i<this.ELEMENTS;++i)e+=this[i]*this[i];return e}magnitudeSquared(){return this.lengthSquared()}distance(e){return Math.sqrt(this.distanceSquared(e))}distanceSquared(e){let i=0;for(let n=0;n<this.ELEMENTS;++n){const s=this[n]-e[n];i+=s*s}return ee(i)}dot(e){let i=0;for(let n=0;n<this.ELEMENTS;++n)i+=this[n]*e[n];return ee(i)}normalize(){const e=this.magnitude();if(e!==0)for(let i=0;i<this.ELEMENTS;++i)this[i]/=e;return this.check()}multiply(...e){for(const i of e)for(let n=0;n<this.ELEMENTS;++n)this[n]*=i[n];return this.check()}divide(...e){for(const i of e)for(let n=0;n<this.ELEMENTS;++n)this[n]/=i[n];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(e){return this.distance(e)}distanceToSquared(e){return this.distanceSquared(e)}getComponent(e){return Mc(e>=0&&e<this.ELEMENTS,"index is out of range"),ee(this[e])}setComponent(e,i){return Mc(e>=0&&e<this.ELEMENTS,"index is out of range"),this[e]=i,this.check()}addVectors(e,i){return this.copy(e).add(i)}subVectors(e,i){return this.copy(e).subtract(i)}multiplyVectors(e,i){return this.copy(e).multiply(i)}addScaledVector(e,i){return this.add(new this.constructor(e).multiplyScalar(i))}}const Bi=1e-6;let Ne=typeof Float32Array<"u"?Float32Array:Array;function Dy(){const t=new Ne(2);return Ne!=Float32Array&&(t[0]=0,t[1]=0),t}function Oc(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t}function By(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t}function Fy(t,e){return t[0]=-e[0],t[1]=-e[1],t}function eu(t,e,i,n){const s=e[0],r=e[1];return t[0]=s+n*(i[0]-s),t[1]=r+n*(i[1]-r),t}function ky(t,e,i){const n=e[0],s=e[1];return t[0]=i[0]*n+i[3]*s+i[6],t[1]=i[1]*n+i[4]*s+i[7],t}function Uy(t,e,i){const n=e[0],s=e[1];return t[0]=i[0]*n+i[4]*s+i[12],t[1]=i[1]*n+i[5]*s+i[13],t}const zy=By;(function(){const t=Dy();return function(e,i,n,s,r,o){let a,c;for(i||(i=2),n||(n=0),s?c=Math.min(s*i+n,e.length):c=e.length,a=n;a<c;a+=i)t[0]=e[a],t[1]=e[a+1],r(t,t,o),e[a]=t[0],e[a+1]=t[1];return e}})();function Wy(t,e,i){const n=e[0],s=e[1],r=i[3]*n+i[7]*s||1;return t[0]=(i[0]*n+i[4]*s)/r,t[1]=(i[1]*n+i[5]*s)/r,t}function tu(t,e,i){const n=e[0],s=e[1],r=e[2],o=i[3]*n+i[7]*s+i[11]*r||1;return t[0]=(i[0]*n+i[4]*s+i[8]*r)/o,t[1]=(i[1]*n+i[5]*s+i[9]*r)/o,t[2]=(i[2]*n+i[6]*s+i[10]*r)/o,t}
vendor: 28,308 bytes, lines 100-119
100function Vy(t,e,i){const n=e[0],s=e[1];return t[0]=i[0]*n+i[2]*s,t[1]=i[1]*n+i[3]*s,t[2]=e[2],t}function $y(t,e,i){const n=e[0],s=e[1];return t[0]=i[0]*n+i[2]*s,t[1]=i[1]*n+i[3]*s,t[2]=e[2],t[3]=e[3],t}function iu(t,e,i){const n=e[0],s=e[1],r=e[2];return t[0]=i[0]*n+i[3]*s+i[6]*r,t[1]=i[1]*n+i[4]*s+i[7]*r,t[2]=i[2]*n+i[5]*s+i[8]*r,t[3]=e[3],t}function nu(){const t=new Ne(3);return Ne!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function jy(t){const e=t[0],i=t[1],n=t[2];return Math.sqrt(e*e+i*i+n*n)}function Ic(t,e,i){const n=new Ne(3);return n[0]=t,n[1]=e,n[2]=i,n}function Hy(t,e,i){return t[0]=e[0]-i[0],t[1]=e[1]-i[1],t[2]=e[2]-i[2],t}function Xy(t){const e=t[0],i=t[1],n=t[2];return e*e+i*i+n*n}function Yy(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t}function Ky(t,e){const i=e[0],n=e[1],s=e[2];let r=i*i+n*n+s*s;return r>0&&(r=1/Math.sqrt(r)),t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}function su(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Wn(t,e,i){const n=e[0],s=e[1],r=e[2],o=i[0],a=i[1],c=i[2];return t[0]=s*c-r*a,t[1]=r*o-n*c,t[2]=n*a-s*o,t}function qy(t,e,i,n){const s=e[0],r=e[1],o=e[2];return t[0]=s+n*(i[0]-s),t[1]=r+n*(i[1]-r),t[2]=o+n*(i[2]-o),t}function pa(t,e,i){const n=e[0],s=e[1],r=e[2];let o=i[3]*n+i[7]*s+i[11]*r+i[15];return o=o||1,t[0]=(i[0]*n+i[4]*s+i[8]*r+i[12])/o,t[1]=(i[1]*n+i[5]*s+i[9]*r+i[13])/o,t[2]=(i[2]*n+i[6]*s+i[10]*r+i[14])/o,t}function ru(t,e,i){const n=e[0],s=e[1],r=e[2];return t[0]=n*i[0]+s*i[3]+r*i[6],t[1]=n*i[1]+s*i[4]+r*i[7],t[2]=n*i[2]+s*i[5]+r*i[8],t}function ou(t,e,i){const n=i[0],s=i[1],r=i[2],o=i[3],a=e[0],c=e[1],l=e[2];let f=s*l-r*c,h=r*a-n*l,u=n*c-s*a,d=s*u-r*h,p=r*f-n*u,_=n*h-s*f;const m=o*2;return f*=m,h*=m,u*=m,d*=2,p*=2,_*=2,t[0]=a+f+d,t[1]=c+h+p,t[2]=l+u+_,t}function Zy(t,e,i,n){const s=[],r=[];return s[0]=e[0]-i[0],s[1]=e[1]-i[1],s[2]=e[2]-i[2],r[0]=s[0],r[1]=s[1]*Math.cos(n)-s[2]*Math.sin(n),r[2]=s[1]*Math.sin(n)+s[2]*Math.cos(n),t[0]=r[0]+i[0],t[1]=r[1]+i[1],t[2]=r[2]+i[2],t}function Gy(t,e,i,n){const s=[],r=[];return s[0]=e[0]-i[0],s[1]=e[1]-i[1],s[2]=e[2]-i[2],r[0]=s[2]*Math.sin(n)+s[0]*Math.cos(n),r[1]=s[1],r[2]=s[2]*Math.cos(n)-s[0]*Math.sin(n),t[0]=r[0]+i[0],t[1]=r[1]+i[1],t[2]=r[2]+i[2],t}function Qy(t,e,i,n){const s=[],r=[];return s[0]=e[0]-i[0],s[1]=e[1]-i[1],s[2]=e[2]-i[2],r[0]=s[0]*Math.cos(n)-s[1]*Math.sin(n),r[1]=s[0]*Math.sin(n)+s[1]*Math.cos(n),r[2]=s[2],t[0]=r[0]+i[0],t[1]=r[1]+i[1],t[2]=r[2]+i[2],t}function Jy(t,e){const i=t[0],n=t[1],s=t[2],r=e[0],o=e[1],a=e[2],c=Math.sqrt((i*i+n*n+s*s)*(r*r+o*o+a*a)),l=c&&su(t,e)/c;return Math.acos(Math.min(Math.max(l,-1),1))}const au=Hy,cu=jy,hr=Xy;(function(){const t=nu();return function(e,i,n,s,r,o){let a,c;for(i||(i=3),n||(n=0),s?c=Math.min(s*i+n,e.length):c=e.length,a=n;a<c;a+=i)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],r(t,t,o),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2];return e}})();const ur=[0,0,0];let dn;class je extends Jh{static get ZERO(){return dn||(dn=new je(0,0,0),Object.freeze(dn)),dn}constructor(e=0,i=0,n=0){super(-0,-0,-0),arguments.length===1&&Ct(e)?this.copy(e):(_e.debug&&(ee(e),ee(i),ee(n)),this[0]=e,this[1]=i,this[2]=n)}set(e,i,n){return this[0]=e,this[1]=i,this[2]=n,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this.check()}fromObject(e){return _e.debug&&(ee(e.x),ee(e.y),ee(e.z)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e}get ELEMENTS(){return 3}get z(){return this[2]}set z(e){this[2]=ee(e)}angle(e){return Jy(this,e)}cross(e){return Wn(this,this,e),this.check()}rotateX({radians:e,origin:i=ur}){return Zy(this,this,i,e),this.check()}rotateY({radians:e,origin:i=ur}){return Gy(this,this,i,e),this.check()}rotateZ({radians:e,origin:i=ur}){return Qy(this,this,i,e),this.check()}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return pa(this,this,e),this.check()}transformAsVector(e){return tu(this,this,e),this.check()}transformByMatrix3(e){return ru(this,this,e),this.check()}transformByMatrix2(e){return Vy(this,this,e),this.check()}transformByQuaternion(e){return ou(this,this,e),this.check()}}let gn;class _a extends Jh{static get ZERO(){return gn||(gn=new _a(0,0,0,0),Object.freeze(gn)),gn}constructor(e=0,i=0,n=0,s=0){super(-0,-0,-0,-0),Ct(e)&&arguments.length===1?this.copy(e):(_e.debug&&(ee(e),ee(i),ee(n),ee(s)),this[0]=e,this[1]=i,this[2]=n,this[3]=s)}set(e,i,n,s){return this[0]=e,this[1]=i,this[2]=n,this[3]=s,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this.check()}fromObject(e){return _e.debug&&(ee(e.x),ee(e.y),ee(e.z),ee(e.w)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this[3]=e.w,this}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e.w=this[3],e}get ELEMENTS(){return 4}get z(){return this[2]}set z(e){this[2]=ee(e)}get w(){return this[3]}set w(e){this[3]=ee(e)}transform(e){return pa(this,this,e),this.check()}transformByMatrix3(e){return iu(this,this,e),this.check()}transformByMatrix2(e){return $y(this,this,e),this.check()}transformByQuaternion(e){return ou(this,this,e),this.check()}applyMatrix4(e){return e.transform(this,this),this}}class lu extends ga{toString(){let e="[";if(_e.printRowMajor){e+="row-major:";for(let i=0;i<this.RANK;++i)for(let n=0;n<this.RANK;++n)e+=` ${this[n*this.RANK+i]}`}else{e+="column-major:";for(let i=0;i<this.ELEMENTS;++i)e+=` ${this[i]}`}return e+="]",e}getElementIndex(e,i){return i*this.RANK+e}getElement(e,i){return this[i*this.RANK+e]}setElement(e,i,n){return this[i*this.RANK+e]=ee(n),this}getColumn(e,i=new Array(this.RANK).fill(-0)){const n=e*this.RANK;for(let s=0;s<this.RANK;++s)i[s]=this[n+s];return i}setColumn(e,i){const n=e*this.RANK;for(let s=0;s<this.RANK;++s)this[n+s]=i[s];return this}}function eb(){const t=new Ne(9);return Ne!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function tb(t,e){if(t===e){const i=e[1],n=e[2],s=e[5];t[1]=e[3],t[2]=e[6],t[3]=i,t[5]=e[7],t[6]=n,t[7]=s}else t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8];return t}function ib(t,e){const i=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],c=e[6],l=e[7],f=e[8],h=f*o-a*l,u=-f*r+a*c,d=l*r-o*c;let p=i*h+n*u+s*d;return p?(p=1/p,t[0]=h*p,t[1]=(-f*n+s*l)*p,t[2]=(a*n-s*o)*p,t[3]=u*p,t[4]=(f*i-s*c)*p,t[5]=(-a*i+s*r)*p,t[6]=d*p,t[7]=(-l*i+n*c)*p,t[8]=(o*i-n*r)*p,t):null}function nb(t){const e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],c=t[7],l=t[8];return e*(l*r-o*c)+i*(-l*s+o*a)+n*(c*s-r*a)}function Nc(t,e,i){const n=e[0],s=e[1],r=e[2],o=e[3],a=e[4],c=e[5],l=e[6],f=e[7],h=e[8],u=i[0],d=i[1],p=i[2],_=i[3],m=i[4],b=i[5],A=i[6],v=i[7],S=i[8];return t[0]=u*n+d*o+p*l,t[1]=u*s+d*a+p*f,t[2]=u*r+d*c+p*h,t[3]=_*n+m*o+b*l,t[4]=_*s+m*a+b*f,t[5]=_*r+m*c+b*h,t[6]=A*n+v*o+S*l,t[7]=A*s+v*a+S*f,t[8]=A*r+v*c+S*h,t}function sb(t,e,i){const n=e[0],s=e[1],r=e[2],o=e[3],a=e[4],c=e[5],l=e[6],f=e[7],h=e[8],u=i[0],d=i[1];return t[0]=n,t[1]=s,t[2]=r,t[3]=o,t[4]=a,t[5]=c,t[6]=u*n+d*o+l,t[7]=u*s+d*a+f,t[8]=u*r+d*c+h,t}function rb(t,e,i){const n=e[0],s=e[1],r=e[2],o=e[3],a=e[4],c=e[5],l=e[6],f=e[7],h=e[8],u=Math.sin(i),d=Math.cos(i);return t[0]=d*n+u*o,t[1]=d*s+u*a,t[2]=d*r+u*c,t[3]=d*o-u*n,t[4]=d*a-u*s,t[5]=d*c-u*r,t[6]=l,t[7]=f,t[8]=h,t}function Lc(t,e,i){const n=i[0],s=i[1];return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=s*e[3],t[4]=s*e[4],t[5]=s*e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t}function ob(t,e){const i=e[0],n=e[1],s=e[2],r=e[3],o=i+i,a=n+n,c=s+s,l=i*o,f=n*o,h=n*a,u=s*o,d=s*a,p=s*c,_=r*o,m=r*a,b=r*c;return t[0]=1-h-p,t[3]=f-b,t[6]=u+m,t[1]=f+b,t[4]=1-l-p,t[7]=d-_,t[2]=u-m,t[5]=d+_,t[8]=1-l-h,t}var co;(function(t){t[t.COL0ROW0=0]="COL0ROW0",t[t.COL0ROW1=1]="COL0ROW1",t[t.COL0ROW2=2]="COL0ROW2",t[t.COL1ROW0=3]="COL1ROW0",t[t.COL1ROW1=4]="COL1ROW1",t[t.COL1ROW2=5]="COL1ROW2",t[t.COL2ROW0=6]="COL2ROW0",t[t.COL2ROW1=7]="COL2ROW1",t[t.COL2ROW2=8]="COL2ROW2"})(co||(co={}));const ab=Object.freeze([1,0,0,0,1,0,0,0,1]);class fu extends lu{static get IDENTITY(){return lb()}static get ZERO(){return cb()}get ELEMENTS(){return 9}get RANK(){return 3}get INDICES(){return co}constructor(e,...i){super(-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):i.length>0?this.copy([e,...i]):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this.check()}identity(){return this.copy(ab)}fromObject(e){return this.check()}fromQuaternion(e){return ob(this,e),this.check()}set(e,i,n,s,r,o,a,c,l){return this[0]=e,this[1]=i,this[2]=n,this[3]=s,this[4]=r,this[5]=o,this[6]=a,this[7]=c,this[8]=l,this.check()}setRowMajor(e,i,n,s,r,o,a,c,l){return this[0]=e,this[1]=s,this[2]=a,this[3]=i,this[4]=r,this[5]=c,this[6]=n,this[7]=o,this[8]=l,this.check()}determinant(){return nb(this)}transpose(){return tb(this,this),this.check()}invert(){return ib(this,this),this.check()}multiplyLeft(e){return Nc(this,e,this),this.check()}multiplyRight(e){return Nc(this,this,e),this.check()}rotate(e){return rb(this,this,e),this.check()}scale(e){return Array.isArray(e)?Lc(this,this,e):Lc(this,this,[e,e]),this.check()}translate(e){return sb(this,this,e),this.check()}transform(e,i){let n;switch(e.length){case 2:n=ky(i||[-0,-0],e,this);break;case 3:n=ru(i||[-0,-0,-0],e,this);break;case 4:n=iu(i||[-0,-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Di(n,e.length),n}transformVector(e,i){return this.transform(e,i)}transformVector2(e,i){return this.transform(e,i)}transformVector3(e,i){return this.transform(e,i)}}let pn,_n=null;function cb(){return pn||(pn=new fu([0,0,0,0,0,0,0,0,0]),Object.freeze(pn)),pn}function lb(){return _n||(_n=new fu,Object.freeze(_n)),_n}function fb(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function hb(t,e){if(t===e){const i=e[1],n=e[2],s=e[3],r=e[6],o=e[7],a=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=i,t[6]=e[9],t[7]=e[13],t[8]=n,t[9]=r,t[11]=e[14],t[12]=s,t[13]=o,t[14]=a}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function lo(t,e){const i=e[0],n=e[1],s=e[2],r=e[3],o=e[4],a=e[5],c=e[6],l=e[7],f=e[8],h=e[9],u=e[10],d=e[11],p=e[12],_=e[13],m=e[14],b=e[15],A=i*a-n*o,v=i*c-s*o,S=i*l-r*o,E=n*c-s*a,x=n*l-r*a,M=s*l-r*c,O=f*_-h*p,N=f*m-u*p,D=f*b-d*p,B=h*m-u*_,F=h*b-d*_,z=u*b-d*m;let U=A*z-v*F+S*B+E*D-x*N+M*O;return U?(U=1/U,t[0]=(a*z-c*F+l*B)*U,t[1]=(s*F-n*z-r*B)*U,t[2]=(_*M-m*x+b*E)*U,t[3]=(u*x-h*M-d*E)*U,t[4]=(c*D-o*z-l*N)*U,t[5]=(i*z-s*D+r*N)*U,t[6]=(m*S-p*M-b*v)*U,t[7]=(f*M-u*S+d*v)*U,t[8]=(o*F-a*D+l*O)*U,t[9]=(n*D-i*F-r*O)*U,t[10]=(p*x-_*S+b*A)*U,t[11]=(h*S-f*x-d*A)*U,t[12]=(a*N-o*B-c*O)*U,t[13]=(i*B-n*N+s*O)*U,t[14]=(_*v-p*E-m*A)*U,t[15]=(f*E-h*v+u*A)*U,t):null}function ub(t){const e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],a=t[6],c=t[7],l=t[8],f=t[9],h=t[10],u=t[11],d=t[12],p=t[13],_=t[14],m=t[15],b=e*o-i*r,A=e*a-n*r,v=i*a-n*o,S=l*p-f*d,E=l*_-h*d,x=f*_-h*p,M=e*x-i*E+n*S,O=r*x-o*E+a*S,N=l*v-f*A+h*b,D=d*v-p*A+_*b;return c*M-s*O+m*N-u*D}function St(t,e,i){const n=e[0],s=e[1],r=e[2],o=e[3],a=e[4],c=e[5],l=e[6],f=e[7],h=e[8],u=e[9],d=e[10],p=e[11],_=e[12],m=e[13],b=e[14],A=e[15];let v=i[0],S=i[1],E=i[2],x=i[3];return t[0]=v*n+S*a+E*h+x*_,t[1]=v*s+S*c+E*u+x*m,t[2]=v*r+S*l+E*d+x*b,t[3]=v*o+S*f+E*p+x*A,v=i[4],S=i[5],E=i[6],x=i[7],t[4]=v*n+S*a+E*h+x*_,t[5]=v*s+S*c+E*u+x*m,t[6]=v*r+S*l+E*d+x*b,t[7]=v*o+S*f+E*p+x*A,v=i[8],S=i[9],E=i[10],x=i[11],t[8]=v*n+S*a+E*h+x*_,t[9]=v*s+S*c+E*u+x*m,t[10]=v*r+S*l+E*d+x*b,t[11]=v*o+S*f+E*p+x*A,v=i[12],S=i[13],E=i[14],x=i[15],t[12]=v*n+S*a+E*h+x*_,t[13]=v*s+S*c+E*u+x*m,t[14]=v*r+S*l+E*d+x*b,t[15]=v*o+S*f+E*p+x*A,t}function os(t,e,i){const n=i[0],s=i[1],r=i[2];let o,a,c,l,f,h,u,d,p,_,m,b;return e===t?(t[12]=e[0]*n+e[4]*s+e[8]*r+e[12],t[13]=e[1]*n+e[5]*s+e[9]*r+e[13],t[14]=e[2]*n+e[6]*s+e[10]*r+e[14],t[15]=e[3]*n+e[7]*s+e[11]*r+e[15]):(o=e[0],a=e[1],c=e[2],l=e[3],f=e[4],h=e[5],u=e[6],d=e[7],p=e[8],_=e[9],m=e[10],b=e[11],t[0]=o,t[1]=a,t[2]=c,t[3]=l,t[4]=f,t[5]=h,t[6]=u,t[7]=d,t[8]=p,t[9]=_,t[10]=m,t[11]=b,t[12]=o*n+f*s+p*r+e[12],t[13]=a*n+h*s+_*r+e[13],t[14]=c*n+u*s+m*r+e[14],t[15]=l*n+d*s+b*r+e[15]),t}function ma(t,e,i){const n=i[0],s=i[1],r=i[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*s,t[5]=e[5]*s,t[6]=e[6]*s,t[7]=e[7]*s,t[8]=e[8]*r,t[9]=e[9]*r,t[10]=e[10]*r,t[11]=e[11]*r,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function db(t,e,i,n){let s=n[0],r=n[1],o=n[2],a=Math.sqrt(s*s+r*r+o*o),c,l,f,h,u,d,p,_,m,b,A,v,S,E,x,M,O,N,D,B,F,z,U,q;return a<Bi?null:(a=1/a,s*=a,r*=a,o*=a,l=Math.sin(i),c=Math.cos(i),f=1-c,h=e[0],u=e[1],d=e[2],p=e[3],_=e[4],m=e[5],b=e[6],A=e[7],v=e[8],S=e[9],E=e[10],x=e[11],M=s*s*f+c,O=r*s*f+o*l,N=o*s*f-r*l,D=s*r*f-o*l,B=r*r*f+c,F=o*r*f+s*l,z=s*o*f+r*l,U=r*o*f-s*l,q=o*o*f+c,t[0]=h*M+_*O+v*N,t[1]=u*M+m*O+S*N,t[2]=d*M+b*O+E*N,t[3]=p*M+A*O+x*N,t[4]=h*D+_*B+v*F,t[5]=u*D+m*B+S*F,t[6]=d*D+b*B+E*F,t[7]=p*D+A*B+x*F,t[8]=h*z+_*U+v*q,t[9]=u*z+m*U+S*q,t[10]=d*z+b*U+E*q,t[11]=p*z+A*U+x*q,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)}function hu(t,e,i){const n=Math.sin(i),s=Math.cos(i),r=e[4],o=e[5],a=e[6],c=e[7],l=e[8],f=e[9],h=e[10],u=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=r*s+l*n,t[5]=o*s+f*n,t[6]=a*s+h*n,t[7]=c*s+u*n,t[8]=l*s-r*n,t[9]=f*s-o*n,t[10]=h*s-a*n,t[11]=u*s-c*n,t}function gb(t,e,i){const n=Math.sin(i),s=Math.cos(i),r=e[0],o=e[1],a=e[2],c=e[3],l=e[8],f=e[9],h=e[10],u=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=r*s-l*n,t[1]=o*s-f*n,t[2]=a*s-h*n,t[3]=c*s-u*n,t[8]=r*n+l*s,t[9]=o*n+f*s,t[10]=a*n+h*s,t[11]=c*n+u*s,t}function uu(t,e,i){const n=Math.sin(i),s=Math.cos(i),r=e[0],o=e[1],a=e[2],c=e[3],l=e[4],f=e[5],h=e[6],u=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=r*s+l*n,t[1]=o*s+f*n,t[2]=a*s+h*n,t[3]=c*s+u*n,t[4]=l*s-r*n,t[5]=f*s-o*n,t[6]=h*s-a*n,t[7]=u*s-c*n,t}function M2(t,e){const i=e[0],n=e[1],s=e[2],r=e[4],o=e[5],a=e[6],c=e[8],l=e[9],f=e[10];return t[0]=Math.sqrt(i*i+n*n+s*s),t[1]=Math.sqrt(r*r+o*o+a*a),t[2]=Math.sqrt(c*c+l*l+f*f),t}function pb(t,e){const i=e[0],n=e[1],s=e[2],r=e[3],o=i+i,a=n+n,c=s+s,l=i*o,f=n*o,h=n*a,u=s*o,d=s*a,p=s*c,_=r*o,m=r*a,b=r*c;return t[0]=1-h-p,t[1]=f+b,t[2]=u-m,t[3]=0,t[4]=f-b,t[5]=1-l-p,t[6]=d+_,t[7]=0,t[8]=u+m,t[9]=d-_,t[10]=1-l-h,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function _b(t,e,i,n,s,r,o){const a=1/(i-e),c=1/(s-n),l=1/(r-o);return t[0]=r*2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=r*2*c,t[6]=0,t[7]=0,t[8]=(i+e)*a,t[9]=(s+n)*c,t[10]=(o+r)*l,t[11]=-1,t[12]=0,t[13]=0,t[14]=o*r*2*l,t[15]=0,t}function mb(t,e,i,n,s){const r=1/Math.tan(e/2);if(t[0]=r/i,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=r,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,s!=null&&s!==1/0){const o=1/(n-s);t[10]=(s+n)*o,t[14]=2*s*n*o}else t[10]=-1,t[14]=-2*n;return t}const yb=mb;function bb(t,e,i,n,s,r,o){const a=1/(e-i),c=1/(n-s),l=1/(r-o);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*l,t[11]=0,t[12]=(e+i)*a,t[13]=(s+n)*c,t[14]=(o+r)*l,t[15]=1,t}const vb=bb;function Tb(t,e,i,n){let s,r,o,a,c,l,f,h,u,d;const p=e[0],_=e[1],m=e[2],b=n[0],A=n[1],v=n[2],S=i[0],E=i[1],x=i[2];return Math.abs(p-S)<Bi&&Math.abs(_-E)<Bi&&Math.abs(m-x)<Bi?fb(t):(h=p-S,u=_-E,d=m-x,s=1/Math.sqrt(h*h+u*u+d*d),h*=s,u*=s,d*=s,r=A*d-v*u,o=v*h-b*d,a=b*u-A*h,s=Math.sqrt(r*r+o*o+a*a),s?(s=1/s,r*=s,o*=s,a*=s):(r=0,o=0,a=0),c=u*a-d*o,l=d*r-h*a,f=h*o-u*r,s=Math.sqrt(c*c+l*l+f*f),s?(s=1/s,c*=s,l*=s,f*=s):(c=0,l=0,f=0),t[0]=r,t[1]=c,t[2]=h,t[3]=0,t[4]=o,t[5]=l,t[6]=u,t[7]=0,t[8]=a,t[9]=f,t[10]=d,t[11]=0,t[12]=-(r*p+o*_+a*m),t[13]=-(c*p+l*_+f*m),t[14]=-(h*p+u*_+d*m),t[15]=1,t)}function Ab(){const t=new Ne(4);return Ne!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function wb(t,e,i){return t[0]=e[0]+i[0],t[1]=e[1]+i[1],t[2]=e[2]+i[2],t[3]=e[3]+i[3],t}function ya(t,e,i){return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i,t}function Sb(t){const e=t[0],i=t[1],n=t[2],s=t[3];return Math.sqrt(e*e+i*i+n*n+s*s)}function Eb(t){const e=t[0],i=t[1],n=t[2],s=t[3];return e*e+i*i+n*n+s*s}function xb(t,e){const i=e[0],n=e[1],s=e[2],r=e[3];let o=i*i+n*n+s*s+r*r;return o>0&&(o=1/Math.sqrt(o)),t[0]=i*o,t[1]=n*o,t[2]=s*o,t[3]=r*o,t}function Pb(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]}function Rb(t,e,i,n){const s=e[0],r=e[1],o=e[2],a=e[3];return t[0]=s+n*(i[0]-s),t[1]=r+n*(i[1]-r),t[2]=o+n*(i[2]-o),t[3]=a+n*(i[3]-a),t}function gi(t,e,i){const n=e[0],s=e[1],r=e[2],o=e[3];return t[0]=i[0]*n+i[4]*s+i[8]*r+i[12]*o,t[1]=i[1]*n+i[5]*s+i[9]*r+i[13]*o,t[2]=i[2]*n+i[6]*s+i[10]*r+i[14]*o,t[3]=i[3]*n+i[7]*s+i[11]*r+i[15]*o,t}function Cb(t,e,i){const n=e[0],s=e[1],r=e[2],o=i[0],a=i[1],c=i[2],l=i[3],f=l*n+a*r-c*s,h=l*s+c*n-o*r,u=l*r+o*s-a*n,d=-o*n-a*s-c*r;return t[0]=f*l+d*-o+h*-c-u*-a,t[1]=h*l+d*-a+u*-o-f*-c,t[2]=u*l+d*-c+f*-a-h*-o,t[3]=e[3],t}(function(){const t=Ab();return function(e,i,n,s,r,o){let a,c;for(i||(i=4),n||(n=0),s?c=Math.min(s*i+n,e.length):c=e.length,a=n;a<c;a+=i)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],t[3]=e[a+3],r(t,t,o),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2],e[a+3]=t[3];return e}})();var fo;(function(t){t[t.COL0ROW0=0]="COL0ROW0",t[t.COL0ROW1=1]="COL0ROW1",t[t.COL0ROW2=2]="COL0ROW2",t[t.COL0ROW3=3]="COL0ROW3",t[t.COL1ROW0=4]="COL1ROW0",t[t.COL1ROW1=5]="COL1ROW1",t[t.COL1ROW2=6]="COL1ROW2",t[t.COL1ROW3=7]="COL1ROW3",t[t.COL2ROW0=8]="COL2ROW0",t[t.COL2ROW1=9]="COL2ROW1",t[t.COL2ROW2=10]="COL2ROW2",t[t.COL2ROW3=11]="COL2ROW3",t[t.COL3ROW0=12]="COL3ROW0",t[t.COL3ROW1=13]="COL3ROW1",t[t.COL3ROW2=14]="COL3ROW2",t[t.COL3ROW3=15]="COL3ROW3"})(fo||(fo={}));const Mb=45*Math.PI/180,Ob=1,dr=.1,gr=500,Ib=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);class Le extends lu{static get IDENTITY(){return Lb()}static get ZERO(){return Nb()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return fo}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,i,n,s,r,o,a,c,l,f,h,u,d,p,_,m){return this[0]=e,this[1]=i,this[2]=n,this[3]=s,this[4]=r,this[5]=o,this[6]=a,this[7]=c,this[8]=l,this[9]=f,this[10]=h,this[11]=u,this[12]=d,this[13]=p,this[14]=_,this[15]=m,this.check()}setRowMajor(e,i,n,s,r,o,a,c,l,f,h,u,d,p,_,m){return this[0]=e,this[1]=r,this[2]=l,this[3]=d,this[4]=i,this[5]=o,this[6]=f,this[7]=p,this[8]=n,this[9]=a,this[10]=h,this[11]=_,this[12]=s,this[13]=c,this[14]=u,this[15]=m,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(Ib)}fromObject(e){return this.check()}fromQuaternion(e){return pb(this,e),this.check()}frustum(e){const{left:i,right:n,bottom:s,top:r,near:o=dr,far:a=gr}=e;return a===1/0?Db(this,i,n,s,r,o):_b(this,i,n,s,r,o,a),this.check()}lookAt(e){const{eye:i,center:n=[0,0,0],up:s=[0,1,0]}=e;return Tb(this,i,n,s),this.check()}ortho(e){const{left:i,right:n,bottom:s,top:r,near:o=dr,far:a=gr}=e;return vb(this,i,n,s,r,o,a),this.check()}orthographic(e){const{fovy:i=Mb,aspect:n=Ob,focalDistance:s=1,near:r=dr,far:o=gr}=e;Dc(i);const a=i/2,c=s*Math.tan(a),l=c*n;return this.ortho({left:-l,right:l,bottom:-c,top:c,near:r,far:o})}perspective(e){const{fovy:i=45*Math.PI/180,aspect:n=1,near:s=.1,far:r=500}=e;return Dc(i),yb(this,i,n,s,r),this.check()}determinant(){return ub(this)}getScale(e=[-0,-0,-0]){return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}getTranslation(e=[-0,-0,-0]){return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}getRotation(e,i){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],i=i||[-0,-0,-0];const n=this.getScale(i),s=1/n[0],r=1/n[1],o=1/n[2];return e[0]=this[0]*s,e[1]=this[1]*r,e[2]=this[2]*o,e[3]=0,e[4]=this[4]*s,e[5]=this[5]*r,e[6]=this[6]*o,e[7]=0,e[8]=this[8]*s,e[9]=this[9]*r,e[10]=this[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,i){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0],i=i||[-0,-0,-0];const n=this.getScale(i),s=1/n[0],r=1/n[1],o=1/n[2];return e[0]=this[0]*s,e[1]=this[1]*r,e[2]=this[2]*o,e[3]=this[4]*s,e[4]=this[5]*r,e[5]=this[6]*o,e[6]=this[8]*s,e[7]=this[9]*r,e[8]=this[10]*o,e}transpose(){return hb(this,this),this.check()}invert(){return lo(this,this),this.check()}multiplyLeft(e){return St(this,e,this),this.check()}multiplyRight(e){return St(this,this,e),this.check()}rotateX(e){return hu(this,this,e),this.check()}rotateY(e){return gb(this,this,e),this.check()}rotateZ(e){return uu(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,i){return db(this,this,e,i),this.check()}scale(e){return ma(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return os(this,this,e),this.check()}transform(e,i){return e.length===4?(i=gi(i||[-0,-0,-0,-0],e,this),Di(i,4),i):this.transformAsPoint(e,i)}transformAsPoint(e,i){const{length:n}=e;let s;switch(n){case 2:s=Uy(i||[-0,-0],e,this);break;case 3:s=pa(i||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Di(s,e.length),s}transformAsVector(e,i){let n;switch(e.length){case 2:n=Wy(i||[-0,-0],e,this);break;case 3:n=tu(i||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Di(n,e.length),n}transformPoint(e,i){return this.transformAsPoint(e,i)}transformVector(e,i){return this.transformAsPoint(e,i)}transformDirection(e,i){return this.transformAsVector(e,i)}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,i,n){return this.identity().translate([e,i,n])}}let mn,yn;function Nb(){return mn||(mn=new Le([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(mn)),mn}function Lb(){return yn||(yn=new Le,Object.freeze(yn)),yn}function Dc(t){if(t>Math.PI*2)throw Error("expected radians")}function Db(t,e,i,n,s,r){const o=2*r/(i-e),a=2*r/(s-n),c=(i+e)/(i-e),l=(s+n)/(s-n),f=-1,h=-1,u=-2*r;return t[0]=o,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=c,t[9]=l,t[10]=f,t[11]=h,t[12]=0,t[13]=0,t[14]=u,t[15]=0,t}function Bc(){const t=new Ne(4);return Ne!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function Bb(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function du(t,e,i){i=i*.5;const n=Math.sin(i);return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=Math.cos(i),t}function Fc(t,e,i){const n=e[0],s=e[1],r=e[2],o=e[3],a=i[0],c=i[1],l=i[2],f=i[3];return t[0]=n*f+o*a+s*l-r*c,t[1]=s*f+o*c+r*a-n*l,t[2]=r*f+o*l+n*c-s*a,t[3]=o*f-n*a-s*c-r*l,t}function Fb(t,e,i){i*=.5;const n=e[0],s=e[1],r=e[2],o=e[3],a=Math.sin(i),c=Math.cos(i);return t[0]=n*c+o*a,t[1]=s*c+r*a,t[2]=r*c-s*a,t[3]=o*c-n*a,t}function kb(t,e,i){i*=.5;const n=e[0],s=e[1],r=e[2],o=e[3],a=Math.sin(i),c=Math.cos(i);return t[0]=n*c-r*a,t[1]=s*c+o*a,t[2]=r*c+n*a,t[3]=o*c-s*a,t}function Ub(t,e,i){i*=.5;const n=e[0],s=e[1],r=e[2],o=e[3],a=Math.sin(i),c=Math.cos(i);return t[0]=n*c+s*a,t[1]=s*c-n*a,t[2]=r*c+o*a,t[3]=o*c-r*a,t}function zb(t,e){const i=e[0],n=e[1],s=e[2];return t[0]=i,t[1]=n,t[2]=s,t[3]=Math.sqrt(Math.abs(1-i*i-n*n-s*s)),t}function Vn(t,e,i,n){const s=e[0],r=e[1],o=e[2],a=e[3];let c=i[0],l=i[1],f=i[2],h=i[3],u,d,p,_,m;return u=s*c+r*l+o*f+a*h,u<0&&(u=-u,c=-c,l=-l,f=-f,h=-h),1-u>Bi?(d=Math.acos(u),m=Math.sin(d),p=Math.sin((1-n)*d)/m,_=Math.sin(n*d)/m):(p=1-n,_=n),t[0]=p*s+_*c,t[1]=p*r+_*l,t[2]=p*o+_*f,t[3]=p*a+_*h,t}function Wb(t,e){const i=e[0],n=e[1],s=e[2],r=e[3],o=i*i+n*n+s*s+r*r,a=o?1/o:0;return t[0]=-i*a,t[1]=-n*a,t[2]=-s*a,t[3]=r*a,t}function Vb(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t}function gu(t,e){const i=e[0]+e[4]+e[8];let n;if(i>0)n=Math.sqrt(i+1),t[3]=.5*n,n=.5/n,t[0]=(e[5]-e[7])*n,t[1]=(e[6]-e[2])*n,t[2]=(e[1]-e[3])*n;else{let s=0;e[4]>e[0]&&(s=1),e[8]>e[s*3+s]&&(s=2);const r=(s+1)%3,o=(s+2)%3;n=Math.sqrt(e[s*3+s]-e[r*3+r]-e[o*3+o]+1),t[s]=.5*n,n=.5/n,t[3]=(e[r*3+o]-e[o*3+r])*n,t[r]=(e[r*3+s]+e[s*3+r])*n,t[o]=(e[o*3+s]+e[s*3+o])*n}return t}const $b=wb,jb=ya,Hb=Pb,Xb=Rb,Yb=Sb,Kb=Eb,pu=xb,qb=(function(){const t=nu(),e=Ic(1,0,0),i=Ic(0,1,0);return function(n,s,r){const o=su(s,r);return o<-.999999?(Wn(t,e,s),cu(t)<1e-6&&Wn(t,i,s),Ky(t,t),du(n,t,Math.PI),n):o>.999999?(n[0]=0,n[1]=0,n[2]=0,n[3]=1,n):(Wn(t,s,r),n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=1+o,pu(n,n))}})();(function(){const t=Bc(),e=Bc();return function(i,n,s,r,o,a){return Vn(t,n,o,a),Vn(e,s,r,a),Vn(i,t,e,2*a*(1-a)),i}})();(function(){const t=eb();return function(e,i,n,s){return t[0]=n[0],t[3]=n[1],t[6]=n[2],t[1]=s[0],t[4]=s[1],t[7]=s[2],t[2]=-i[0],t[5]=-i[1],t[8]=-i[2],pu(e,gu(e,t))}})();const Zb=[0,0,0,1];class O2 extends ga{constructor(e=0,i=0,n=0,s=1){super(-0,-0,-0,-0),Array.isArray(e)&&arguments.length===1?this.copy(e):this.set(e,i,n,s)}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this.check()}set(e,i,n,s){return this[0]=e,this[1]=i,this[2]=n,this[3]=s,this.check()}fromObject(e){return this[0]=e.x,this[1]=e.y,this[2]=e.z,this[3]=e.w,this.check()}fromMatrix3(e){return gu(this,e),this.check()}fromAxisRotation(e,i){return du(this,e,i),this.check()}identity(){return Bb(this),this.check()}setAxisAngle(e,i){return this.fromAxisRotation(e,i)}get ELEMENTS(){return 4}get x(){return this[0]}set x(e){this[0]=ee(e)}get y(){return this[1]}set y(e){this[1]=ee(e)}get z(){return this[2]}set z(e){this[2]=ee(e)}get w(){return this[3]}set w(e){this[3]=ee(e)}len(){return Yb(this)}lengthSquared(){return Kb(this)}dot(e){return Hb(this,e)}rotationTo(e,i){return qb(this,e,i),this.check()}add(e){return $b(this,this,e),this.check()}calculateW(){return zb(this,this),this.check()}conjugate(){return Vb(this,this),this.check()}invert(){return Wb(this,this),this.check()}lerp(e,i,n){return n===void 0?this.lerp(this,e,i):(Xb(this,e,i,n),this.check())}multiplyRight(e){return Fc(this,this,e),this.check()}multiplyLeft(e){return Fc(this,e,this),this.check()}normalize(){const e=this.len(),i=e>0?1/e:0;return this[0]=this[0]*i,this[1]=this[1]*i,this[2]=this[2]*i,this[3]=this[3]*i,e===0&&(this[3]=1),this.check()}rotateX(e){return Fb(this,this,e),this.check()}rotateY(e){return kb(this,this,e),this.check()}rotateZ(e){return Ub(this,this,e),this.check()}scale(e){return jb(this,this,e),this.check()}slerp(e,i,n){let s,r,o;switch(arguments.length){case 1:({start:s=Zb,target:r,ratio:o}=e);break;case 2:s=this,r=e,o=i;break;default:s=e,r=i,o=n}return Vn(this,s,r,o),this.check()}transformVector4(e,i=new _a){return Cb(i,e,this),Di(i,4)}lengthSq(){return this.lengthSquared()}setFromAxisAngle(e,i){return this.setAxisAngle(e,i)}premultiply(e){return this.multiplyLeft(e)}multiply(e){return this.multiplyRight(e)}}const I2=1e-15,N2=1e-20;function _u(t,e=[],i=0){const n=Math.fround(t),s=t-n;return e[i]=n,e[i+1]=s,e}function Gb(t){return t-Math.fround(t)}function Qb(t){const e=new Float32Array(32);for(let i=0;i<4;++i)for(let n=0;n<4;++n){const s=i*4+n;_u(t[n*4+i],e,s*2)}return e}function mu(t,e=!0){return t??e}function yu(t=[0,0,0],e=!0){return e?t.map(i=>i/255):[...t]}function Jb(t,e=!0){const i=yu(t.slice(0,3),e),n=Number.isFinite(t[3]),s=n?t[3]:1;return[i[0],i[1],i[2],e&&n?s/255:s]}const e0=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND 101 102// All these functions are for substituting tan() function from Intel GPU only 103const float TWO_PI = 6.2831854820251465; 104const float PI_2 = 1.5707963705062866; 105const float PI_16 = 0.1963495463132858; 106 107const float SIN_TABLE_0 = 0.19509032368659973; 108const float SIN_TABLE_1 = 0.3826834261417389; 109const float SIN_TABLE_2 = 0.5555702447891235; 110const float SIN_TABLE_3 = 0.7071067690849304; 111 112const float COS_TABLE_0 = 0.9807852506637573; 113const float COS_TABLE_1 = 0.9238795042037964; 114const float COS_TABLE_2 = 0.8314695954322815; 115const float COS_TABLE_3 = 0.7071067690849304; 116 117const float INVERSE_FACTORIAL_3 = 1.666666716337204e-01; // 1/3! 118const float INVERSE_FACTORIAL_5 = 8.333333767950535e-03; // 1/5! 119const float INVERSE_FACTORIAL_7 = 1.9841270113829523e-04; // 1/7!
120const float INVERSE_FACTORIAL_9 = 2.75573188446287533e-06; // 1/9! 121 122float sin_taylor_fp32(float a) { 123 float r, s, t, x; 124 125 if (a == 0.0) { 126 return 0.0; 127 } 128 129 x = -a * a; 130 s = a; 131 r = a; 132 133 r = r * x; 134 t = r * INVERSE_FACTORIAL_3; 135 s = s + t; 136 137 r = r * x; 138 t = r * INVERSE_FACTORIAL_5; 139 s = s + t; 140 141 r = r * x; 142 t = r * INVERSE_FACTORIAL_7; 143 s = s + t; 144 145 r = r * x; 146 t = r * INVERSE_FACTORIAL_9; 147 s = s + t; 148 149 return s; 150} 151 152void sincos_taylor_fp32(float a, out float sin_t, out float cos_t) { 153 if (a == 0.0) { 154 sin_t = 0.0; 155 cos_t = 1.0; 156 } 157 sin_t = sin_taylor_fp32(a); 158 cos_t = sqrt(1.0 - sin_t * sin_t); 159} 160 161float tan_taylor_fp32(float a) { 162 float sin_a; 163 float cos_a; 164 165 if (a == 0.0) { 166 return 0.0; 167 } 168 169 // 2pi range reduction 170 float z = floor(a / TWO_PI); 171 float r = a - TWO_PI * z; 172 173 float t; 174 float q = floor(r / PI_2 + 0.5); 175 int j = int(q); 176 177 if (j < -2 || j > 2) { 178 return 1.0 / 0.0; 179 } 180 181 t = r - PI_2 * q; 182 183 q = floor(t / PI_16 + 0.5); 184 int k = int(q); 185 int abs_k = int(abs(float(k))); 186 187 if (abs_k > 4) { 188 return 1.0 / 0.0; 189 } else { 190 t = t - PI_16 * q; 191 } 192 193 float u = 0.0; 194 float v = 0.0; 195 196 float sin_t, cos_t; 197 float s, c; 198 sincos_taylor_fp32(t, sin_t, cos_t); 199 200 if (k == 0) { 201 s = sin_t; 202 c = cos_t; 203 } else { 204 if (abs(float(abs_k) - 1.0) < 0.5) { 205 u = COS_TABLE_0; 206 v = SIN_TABLE_0; 207 } else if (abs(float(abs_k) - 2.0) < 0.5) { 208 u = COS_TABLE_1; 209 v = SIN_TABLE_1; 210 } else if (abs(float(abs_k) - 3.0) < 0.5) { 211 u = COS_TABLE_2; 212 v = SIN_TABLE_2; 213 } else if (abs(float(abs_k) - 4.0) < 0.5) { 214 u = COS_TABLE_3; 215 v = SIN_TABLE_3; 216 } 217 if (k > 0) { 218 s = u * sin_t + v * cos_t; 219 c = u * cos_t - v * sin_t; 220 } else { 221 s = u * sin_t - v * cos_t; 222 c = u * cos_t + v * sin_t; 223 } 224 } 225 226 if (j == 0) { 227 sin_a = s; 228 cos_a = c; 229 } else if (j == 1) { 230 sin_a = c; 231 cos_a = -s; 232 } else if (j == -1) { 233 sin_a = -c; 234 cos_a = s; 235 } else { 236 sin_a = -s; 237 cos_a = -c; 238 } 239 return sin_a / cos_a; 240} 241#endif 242 243float tan_fp32(float a) { 244#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND 245 return tan_taylor_fp32(a); 246#else 247 return tan(a); 248#endif 249} 250`,t0={name:"fp32",vs:e0},kc=` 251layout(std140) uniform fp64arithmeticUniforms { 252 uniform float ONE; 253 uniform float SPLIT; 254} fp64; 255 256/* 257About LUMA_FP64_CODE_ELIMINATION_WORKAROUND 258 259The purpose of this workaround is to prevent shader compilers from 260optimizing away necessary arithmetic operations by swapping their sequences 261or transform the equation to some 'equivalent' form. 262 263These helpers implement Dekker/Veltkamp-style error tracking. If the compiler 264folds constants or reassociates the arithmetic, the high/low split can stop 265tracking the rounding error correctly. That failure mode tends to look fine in 266simple coordinate setup, but then breaks down inside iterative arithmetic such 267as fp64 Mandelbrot loops. 268 269The method is to multiply an artifical variable, ONE, which will be known to 270the compiler to be 1 only at runtime. The whole expression is then represented 271as a polynomial with respective to ONE. In the coefficients of all terms, only one a 272and one b should appear 273 274err = (a + b) * ONE^6 - a * ONE^5 - (a + b) * ONE^4 + a * ONE^3 - b - (a + b) * ONE^2 + a * ONE 275*/ 276 277float prevent_fp64_optimization(float value) { 278#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) 279 return value + fp64.ONE * 0.0; 280#else 281 return value; 282#endif 283} 284 285// Divide float number to high and low floats to extend fraction bits 286vec2 split(float a) { 287 // Keep SPLIT as a runtime uniform so the compiler cannot fold the Dekker 288 // split into a constant expression and reassociate the recovery steps. 289 float split = prevent_fp64_optimization(fp64.SPLIT); 290 float t = prevent_fp64_optimization(a * split); 291 float temp = t - a; 292 float a_hi = t - temp; 293 float a_lo = a - a_hi; 294 return vec2(a_hi, a_lo); 295} 296 297// Divide float number again when high float uses too many fraction bits 298vec2 split2(vec2 a) { 299 vec2 b = split(a.x); 300 b.y += a.y; 301 return b; 302} 303 304// Special sum operation when a > b 305vec2 quickTwoSum(float a, float b) { 306#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) 307 float sum = (a + b) * fp64.ONE; 308 float err = b - (sum - a) * fp64.ONE; 309#else 310 float sum = a + b; 311 float err = b - (sum - a); 312#endif 313 return vec2(sum, err); 314} 315 316// General sum operation 317vec2 twoSum(float a, float b) { 318 float s = (a + b); 319#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) 320 float v = (s * fp64.ONE - a) * fp64.ONE; 321 float err = (a - (s - v) * fp64.ONE) * fp64.ONE * fp64.ONE * fp64.ONE + (b - v); 322#else 323 float v = s - a; 324 float err = (a - (s - v)) + (b - v); 325#endif 326 return vec2(s, err); 327} 328 329vec2 twoSub(float a, float b) { 330 float s = (a - b); 331#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) 332 float v = (s * fp64.ONE - a) * fp64.ONE; 333 float err = (a - (s - v) * fp64.ONE) * fp64.ONE * fp64.ONE * fp64.ONE - (b + v); 334#else 335 float v = s - a; 336 float err = (a - (s - v)) - (b + v); 337#endif 338 return vec2(s, err); 339} 340 341vec2 twoSqr(float a) { 342 float prod = a * a; 343 vec2 a_fp64 = split(a); 344#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) 345 float err = ((a_fp64.x * a_fp64.x - prod) * fp64.ONE + 2.0 * a_fp64.x * 346 a_fp64.y * fp64.ONE * fp64.ONE) + a_fp64.y * a_fp64.y * fp64.ONE * fp64.ONE * fp64.ONE; 347#else 348 float err = ((a_fp64.x * a_fp64.x - prod) + 2.0 * a_fp64.x * a_fp64.y) + a_fp64.y * a_fp64.y; 349#endif 350 return vec2(prod, err); 351} 352 353vec2 twoProd(float a, float b) { 354 float prod = a * b; 355 vec2 a_fp64 = split(a); 356 vec2 b_fp64 = split(b); 357 // twoProd is especially sensitive because mul_fp64 and div_fp64 both depend 358 // on the split terms and cross terms staying in the original evaluation 359 // order. If the compiler folds or reassociates them, the low part tends to 360 // collapse to zero or NaN on some drivers. 361 float highProduct = prevent_fp64_optimization(a_fp64.x * b_fp64.x); 362 float crossProduct1 = prevent_fp64_optimization(a_fp64.x * b_fp64.y); 363 float crossProduct2 = prevent_fp64_optimization(a_fp64.y * b_fp64.x); 364 float lowProduct = prevent_fp64_optimization(a_fp64.y * b_fp64.y); 365#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) 366 float err1 = (highProduct - prod) * fp64.ONE; 367 float err2 = crossProduct1 * fp64.ONE * fp64.ONE; 368 float err3 = crossProduct2 * fp64.ONE * fp64.ONE * fp64.ONE; 369 float err4 = lowProduct * fp64.ONE * fp64.ONE * fp64.ONE * fp64.ONE; 370#else 371 float err1 = highProduct - prod; 372 float err2 = crossProduct1; 373 float err3 = crossProduct2; 374 float err4 = lowProduct; 375#endif 376 float err = ((err1 + err2) + err3) + err4; 377 return vec2(prod, err); 378} 379 380vec2 sum_fp64(vec2 a, vec2 b) { 381 vec2 s, t;
382 s = twoSum(a.x, b.x); 383 t = twoSum(a.y, b.y); 384 s.y += t.x; 385 s = quickTwoSum(s.x, s.y); 386 s.y += t.y; 387 s = quickTwoSum(s.x, s.y); 388 return s; 389} 390 391vec2 sub_fp64(vec2 a, vec2 b) { 392 vec2 s, t; 393 s = twoSub(a.x, b.x); 394 t = twoSub(a.y, b.y); 395 s.y += t.x; 396 s = quickTwoSum(s.x, s.y); 397 s.y += t.y; 398 s = quickTwoSum(s.x, s.y); 399 return s; 400} 401 402vec2 mul_fp64(vec2 a, vec2 b) { 403 vec2 prod = twoProd(a.x, b.x); 404 // y component is for the error 405 prod.y += a.x * b.y; 406#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND) 407 prod = split2(prod); 408#endif 409 prod = quickTwoSum(prod.x, prod.y); 410 prod.y += a.y * b.x; 411#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND) 412 prod = split2(prod); 413#endif 414 prod = quickTwoSum(prod.x, prod.y); 415 return prod; 416} 417 418vec2 div_fp64(vec2 a, vec2 b) { 419 float xn = 1.0 / b.x; 420#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND) 421 vec2 yn = mul_fp64(a, vec2(xn, 0)); 422#else 423 vec2 yn = a * xn; 424#endif 425 float diff = (sub_fp64(a, mul_fp64(b, yn))).x; 426 vec2 prod = twoProd(xn, diff); 427 return sum_fp64(yn, prod); 428} 429 430vec2 sqrt_fp64(vec2 a) { 431 if (a.x == 0.0 && a.y == 0.0) return vec2(0.0, 0.0); 432 if (a.x < 0.0) return vec2(0.0 / 0.0, 0.0 / 0.0); 433 434 float x = 1.0 / sqrt(a.x); 435 float yn = a.x * x; 436#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND) 437 vec2 yn_sqr = twoSqr(yn) * fp64.ONE; 438#else 439 vec2 yn_sqr = twoSqr(yn); 440#endif 441 float diff = sub_fp64(a, yn_sqr).x; 442 vec2 prod = twoProd(x * 0.5, diff); 443#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND) 444 return sum_fp64(split(yn), prod); 445#else 446 return sum_fp64(vec2(yn, 0.0), prod); 447#endif 448} 449`,i0=`struct Fp64ArithmeticUniforms { 450 ONE: f32, 451 SPLIT: f32, 452}; 453 454@group(0) @binding(auto) var<uniform> fp64arithmetic : Fp64ArithmeticUniforms; 455 456fn fp64_nan(seed: f32) -> f32 { 457 let nanBits = 0x7fc00000u | select(0u, 1u, seed < 0.0); 458 return bitcast<f32>(nanBits); 459} 460 461fn fp64_runtime_zero() -> f32 { 462 return fp64arithmetic.ONE * 0.0; 463} 464 465fn prevent_fp64_optimization(value: f32) -> f32 { 466#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND 467 return value + fp64_runtime_zero(); 468#else 469 return value; 470#endif 471} 472 473fn split(a: f32) -> vec2f { 474 let splitValue = prevent_fp64_optimization(fp64arithmetic.SPLIT + fp64_runtime_zero()); 475 let t = prevent_fp64_optimization(a * splitValue); 476 let temp = prevent_fp64_optimization(t - a); 477 let aHi = prevent_fp64_optimization(t - temp); 478 let aLo = prevent_fp64_optimization(a - aHi); 479 return vec2f(aHi, aLo); 480} 481 482fn split2(a: vec2f) -> vec2f { 483 var b = split(a.x); 484 b.y = b.y + a.y; 485 return b; 486} 487 488fn quickTwoSum(a: f32, b: f32) -> vec2f { 489#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND 490 let sum = prevent_fp64_optimization((a + b) * fp64arithmetic.ONE); 491 let err = prevent_fp64_optimization(b - (sum - a) * fp64arithmetic.ONE); 492#else 493 let sum = prevent_fp64_optimization(a + b); 494 let err = prevent_fp64_optimization(b - (sum - a)); 495#endif 496 return vec2f(sum, err); 497} 498 499fn twoSum(a: f32, b: f32) -> vec2f { 500 let s = prevent_fp64_optimization(a + b); 501#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND 502 let v = prevent_fp64_optimization((s * fp64arithmetic.ONE - a) * fp64arithmetic.ONE); 503 let err = 504 prevent_fp64_optimization((a - (s - v) * fp64arithmetic.ONE) * 505 fp64arithmetic.ONE * 506 fp64arithmetic.ONE * 507 fp64arithmetic.ONE) + 508 prevent_fp64_optimization(b - v); 509#else 510 let v = prevent_fp64_optimization(s - a); 511 let err = prevent_fp64_optimization(a - (s - v)) + prevent_fp64_optimization(b - v); 512#endif 513 return vec2f(s, err); 514} 515 516fn twoSub(a: f32, b: f32) -> vec2f { 517 let s = prevent_fp64_optimization(a - b); 518#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND 519 let v = prevent_fp64_optimization((s * fp64arithmetic.ONE - a) * fp64arithmetic.ONE); 520 let err = 521 prevent_fp64_optimization((a - (s - v) * fp64arithmetic.ONE) * 522 fp64arithmetic.ONE * 523 fp64arithmetic.ONE * 524 fp64arithmetic.ONE) - 525 prevent_fp64_optimization(b + v); 526#else 527 let v = prevent_fp64_optimization(s - a); 528 let err = prevent_fp64_optimization(a - (s - v)) - prevent_fp64_optimization(b + v); 529#endif 530 return vec2f(s, err); 531} 532 533fn twoSqr(a: f32) -> vec2f { 534 let prod = prevent_fp64_optimization(a * a); 535 let aFp64 = split(a); 536 let highProduct = prevent_fp64_optimization(aFp64.x * aFp64.x); 537 let crossProduct = prevent_fp64_optimization(2.0 * aFp64.x * aFp64.y); 538 let lowProduct = prevent_fp64_optimization(aFp64.y * aFp64.y); 539#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND 540 let err = 541 (prevent_fp64_optimization(highProduct - prod) * fp64arithmetic.ONE + 542 crossProduct * fp64arithmetic.ONE * fp64arithmetic.ONE) + 543 lowProduct * fp64arithmetic.ONE * fp64arithmetic.ONE * fp64arithmetic.ONE; 544#else 545 let err = ((prevent_fp64_optimization(highProduct - prod) + crossProduct) + lowProduct); 546#endif 547 return vec2f(prod, err); 548} 549 550fn twoProd(a: f32, b: f32) -> vec2f { 551 let prod = prevent_fp64_optimization(a * b); 552 let aFp64 = split(a); 553 let bFp64 = split(b); 554 let highProduct = prevent_fp64_optimization(aFp64.x * bFp64.x); 555 let crossProduct1 = prevent_fp64_optimization(aFp64.x * bFp64.y
555); 556 let crossProduct2 = prevent_fp64_optimization(aFp64.y * bFp64.x); 557 let lowProduct = prevent_fp64_optimization(aFp64.y * bFp64.y); 558#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND 559 let err1 = (highProduct - prod) * fp64arithmetic.ONE; 560 let err2 = crossProduct1 * fp64arithmetic.ONE * fp64arithmetic.ONE; 561 let err3 = crossProduct2 * fp64arithmetic.ONE * fp64arithmetic.ONE * fp64arithmetic.ONE; 562 let err4 = 563 lowProduct * 564 fp64arithmetic.ONE * 565 fp64arithmetic.ONE * 566 fp64arithmetic.ONE * 567 fp64arithmetic.ONE; 568#else 569 let err1 = highProduct - prod; 570 let err2 = crossProduct1; 571 let err3 = crossProduct2; 572 let err4 = lowProduct; 573#endif 574 let err12InputA = prevent_fp64_optimization(err1); 575 let err12InputB = prevent_fp64_optimization(err2); 576 let err12 = prevent_fp64_optimization(err12InputA + err12InputB); 577 let err123InputA = prevent_fp64_optimization(err12); 578 let err123InputB = prevent_fp64_optimization(err3); 579 let err123 = prevent_fp64_optimization(err123InputA + err123InputB); 580 let err1234InputA = prevent_fp64_optimization(err123); 581 let err1234InputB = prevent_fp64_optimization(err4); 582 let err = prevent_fp64_optimization(err1234InputA + err1234InputB); 583 return vec2f(prod, err); 584} 585 586fn sum_fp64(a: vec2f, b: vec2f) -> vec2f { 587 var s = twoSum(a.x, b.x); 588 let t = twoSum(a.y, b.y); 589 s.y = prevent_fp64_optimization(s.y + t.x); 590 s = quickTwoSum(s.x, s.y); 591 s.y = prevent_fp64_optimization(s.y + t.y); 592 s = quickTwoSum(s.x, s.y); 593 return s; 594} 595 596fn sub_fp64(a: vec2f, b: vec2f) -> vec2f { 597 var s = twoSub(a.x, b.x); 598 let t = twoSub(a.y, b.y); 599 s.y = prevent_fp64_optimization(s.y + t.x); 600 s = quickTwoSum(s.x, s.y); 601 s.y = prevent_fp64_optimization(s.y + t.y); 602 s = quickTwoSum(s.x, s.y); 603 return s; 604} 605 606fn mul_fp64(a: vec2f, b: vec2f) -> vec2f { 607 var prod = twoProd(a.x, b.x); 608 let crossProduct1 = prevent_fp64_optimization(a.x * b.y); 609 prod.y = prevent_fp64_optimization(prod.y + crossProduct1); 610#ifdef LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 611 prod = split2(prod); 612#endif 613 prod = quickTwoSum(prod.x, prod.y); 614 let crossProduct2 = prevent_fp64_optimization(a.y * b.x); 615 prod.y = prevent_fp64_optimization(prod.y + crossProduct2); 616#ifdef LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 617 prod = split2(prod); 618#endif 619 prod = quickTwoSum(prod.x, prod.y); 620 return prod; 621} 622 623fn div_fp64(a: vec2f, b: vec2f) -> vec2f { 624 let xn = prevent_fp64_optimization(1.0 / b.x); 625 let yn = mul_fp64(a, vec2f(xn, fp64_runtime_zero())); 626 let diff = prevent_fp64_optimization(sub_fp64(a, mul_fp64(b, yn)).x); 627 let prod = twoProd(xn, diff); 628 return sum_fp64(yn, prod); 629} 630 631fn sqrt_fp64(a: vec2f) -> vec2f { 632 if (a.x == 0.0 && a.y == 0.0) { 633 return vec2f(0.0, 0.0); 634 } 635 if (a.x < 0.0) { 636 let nanValue = fp64_nan(a.x); 637 return vec2f(nanValue, nanValue); 638 } 639 640 let x = prevent_fp64_optimization(1.0 / sqrt(a.x)); 641 let yn = prevent_fp64_optimization(a.x * x); 642#ifdef LUMA_FP64_CODE_ELIMINATION_WORKAROUND 643 let ynSqr = twoSqr(yn) * fp64arithmetic.ONE; 644#else 645 let ynSqr = twoSqr(yn); 646#endif 647 let diff = prevent_fp64_optimization(sub_fp64(a, ynSqr).x); 648 let prod = twoProd(prevent_fp64_optimization(x * 0.5), diff); 649#ifdef LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 650 return sum_fp64(split(yn), prod); 651#else 652 return sum_fp64(vec2f(yn, 0.0), prod); 653#endif 654} 655`,n0={ONE:1,SPLIT:4097},s0={name:"fp64arithmetic",source:i0,fs:kc,vs:kc,defaultUniforms:n0,uniformTypes:{ONE:"f32",SPLIT:"f32"},fp64ify:_u,fp64LowPart:Gb,fp64ifyMatrix4:Qb},Uc=`layout(std140) uniform floatColorsUniforms { 656 float useByteColors; 657} floatColors; 658 659vec3 floatColors_normalize(vec3 inputColor) { 660 return floatColors.useByteColors > 0.5 ? inputColor / 255.0 : inputColor; 661} 662 663vec4 floatColors_normalize(vec4 inputColor) { 664 return floatColors.useByteColors > 0.5 ? inputColor / 255.0 : inputColor; 665} 666 667vec4 floatColors_premultiplyAlpha(vec4 inputColor) { 668 return vec4(inputColor.rgb * inputColor.a, inputColor.a); 669} 670 671vec4 floatColors_unpremultiplyAlpha(vec4 inputColor) { 672 return inputColor.a > 0.0 ? vec4(inputColor.rgb / inputColor.a, inputColor.a) : vec4(0.0); 673} 674 675vec4 floatColors_premultiply_alpha(vec4 inputColor) {
676 return floatColors_premultiplyAlpha(inputColor); 677} 678 679vec4 floatColors_unpremultiply_alpha(vec4 inputColor) { 680 return floatColors_unpremultiplyAlpha(inputColor); 681} 682`,r0=`struct floatColorsUniforms { 683 useByteColors: f32 684}; 685 686@group(0) @binding(auto) var<uniform> floatColors : floatColorsUniforms; 687 688fn floatColors_normalize(inputColor: vec3<f32>) -> vec3<f32> { 689 return select(inputColor, inputColor / 255.0, floatColors.useByteColors > 0.5); 690} 691 692fn floatColors_normalize4(inputColor: vec4<f32>) -> vec4<f32> { 693 return select(inputColor, inputColor / 255.0, floatColors.useByteColors > 0.5); 694} 695 696fn floatColors_premultiplyAlpha(inputColor: vec4<f32>) -> vec4<f32> { 697 return vec4<f32>(inputColor.rgb * inputColor.a, inputColor.a); 698} 699 700fn floatColors_unpremultiplyAlpha(inputColor: vec4<f32>) -> vec4<f32> { 701 return select( 702 vec4<f32>(0.0), 703 vec4<f32>(inputColor.rgb / inputColor.a, inputColor.a), 704 inputColor.a > 0.0 705 ); 706} 707 708fn floatColors_premultiply_alpha(inputColor: vec4<f32>) -> vec4<f32> { 709 return floatColors_premultiplyAlpha(inputColor); 710} 711
712fn floatColors_unpremultiply_alpha(inputColor: vec4<f32>) -> vec4<f32> { 713 return floatColors_unpremultiplyAlpha(inputColor); 714} 715`,o0={name:"floatColors",props:{},uniforms:{},vs:Uc,fs:Uc,source:r0,uniformTypes:{useByteColors:"f32"},defaultUniforms:{useByteColors:!0}},a0=[0,1,1,1],c0=`layout(std140) uniform pickingUniforms { 716 float isActive; 717 float isAttribute; 718 float isHighlightActive; 719 float useByteColors; 720 vec3 highlightedObjectColor; 721 vec4 highlightColor; 722} picking; 723 724out vec4 picking_vRGBcolor_Avalid; 725 726// Normalize unsigned byte color to 0-1 range 727vec3 picking_normalizeColor(vec3 color) { 728 return picking.useByteColors > 0.5 ? color / 255.0 : color; 729} 730 731// Normalize unsigned byte color to 0-1 range 732vec4 picking_normalizeColor(vec4 color) { 733 return picking.useByteColors > 0.5 ? color / 255.0 : color; 734} 735 736bool picking_isColorZero(vec3 color) { 737 return dot(color, vec3(1.0)) < 0.00001; 738} 739 740bool picking_isColorValid(vec3 color) { 741 return dot(color, vec3(1.0)) > 0.00001; 742} 743 744// Check if this vertex is highlighted 745bool isVertexHighlighted(vec3 vertexColor) { 746 vec3 highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor); 747 return 748 bool(picking.isHighlightActive) && picking_isColorZero(abs(vertexColor - highlightedObjectColor)); 749} 750 751// Set the current picking color 752void picking_setPickingColor(vec3 pickingColor) { 753 pickingColor = picking_normalizeColor(pickingColor); 754 755 if (bool(picking.isActive)) { 756 // Use alpha as the validity flag. If pickingColor is [0, 0, 0] fragment is non-pickable 757 picking_vRGBcolor_Avalid.a = float(picking_isColorValid(pickingColor)); 758 759 if (!bool(picking.isAttribute)) { 760 // Stores the picking color so that the fragment shader can render it during picking 761 picking_vRGBcolor_Avalid.rgb = pickingColor; 762 } 763 } else { 764 // Do the comparison with selected item color in vertex shader as it should mean fewer compares 765 picking_vRGBcolor_Avalid.a = float(isVertexHighlighted(pickingColor)); 766 } 767} 768 769void picking_setPickingAttribute(float value) { 770 if (bool(picking.isAttribute)) { 771 picking_vRGBcolor_Avalid.r = value; 772 } 773} 774 775void picking_setPickingAttribute(vec2 value) { 776 if (bool(picking.isAttribute)) { 777 picking_vRGBcolor_Avalid.rg = value; 778 } 779} 780 781void picking_setPickingAttribute(vec3 value) { 782 if (bool(picking.isAttribute)) { 783 picking_vRGBcolor_Avalid.rgb = value; 784 } 785} 786`,l0=`layout(std140) uniform pickingUniforms { 787 float isActive; 788 float isAttribute; 789 float isHighlightActive; 790 float useByteColors; 791 vec3 highlightedObjectColor; 792 vec4 highlightColor; 793} picking; 794 795in vec4 picking_vRGBcolor_Avalid; 796 797/* 798 * Returns highlight color if this item is selected. 799 */ 800vec4 picking_filterHighlightColor(vec4 color) { 801 // If we are still picking, we don't highlight 802 if (picking.isActive > 0.5) { 803 return color; 804 } 805 806 bool selected = bool(picking_vRGBcolor_Avalid.a); 807 808 if (selected) { 809 // Blend in highlight color based on its alpha value 810 float highLightAlpha = picking.highlightColor.a; 811 float blendedAlpha = highLightAlpha + color.a * (1.0 - highLightAlpha); 812 float highLightRatio = highLightAlpha / blendedAlpha; 813 814 vec3 blendedRGB = mix(color.rgb, picking.highlightColor.rgb, highLightRatio); 815 return vec4(blendedRGB, blendedAlpha); 816 } else { 817 return color; 818 } 819} 820 821/* 822 * Returns picking color if picking enabled else unmodified argument. 823 */ 824vec4 picking_filterPickingColor(vec4 color) { 825 if (bool(picking.isActive)) { 826 if (picking_vRGBcolor_Avalid.a == 0.0) { 827 discard; 828 } 829 return picking_vRGBcolor_Avalid; 830 } 831 return color; 832} 833 834/* 835 * Returns picking color if picking is enabled if not 836 * highlight color if this item is selected, otherwise unmodified argument. 837 */ 838vec4 picking_filterColor(vec4 color) { 839 vec4 highlightColor = picking_filterHighlightColor(color); 840 return picking_filterPickingColor(highlightColor); 841} 842`,zc={props:{},uniforms:{},name:"picking",uniformTypes:{isActive:"f32",isAttribute:"f32",isHighlightActive:"f32",useByteColors:"f32",highlightedObjectColor:"vec3<f32>",highlightColor:"vec4<f32>"},defaultUniforms:{isActive:!1,isAttribute:!1,isHighlightActive:!1,useByteColors:!0,highlightedObjectColor:[0,0,0],highlightColor:a0},vs:c0,fs:l0,getUniforms:f0};function f0(t={},e){const i={},n=mu(t.useByteColors,!0);if(t.highlightedObjectColor!==void 0)if(t.highlightedObjectColor===null)i.isHighlightActive=!1;else{i.isHighlightActive=!0;const s=t.highlightedObjectColor.slice(0,3);i.highlightedObjectColor=s}return t.highlightColor&&(i.highlightColor=Jb(t.highlightColor,n)),t.isActive!==void 0&&(i.isActive=!!t.isActive,i.isAttribute=!!t.isAttribute),t.useByteColors!==void 0&&(i.useByteColors=!!t.useByteColors),i}const h0="GPU Time and Memory",u0=["Adapter","GPU","GPU Type","GPU Backend","Frame Rate","CPU Time","GPU Time","GPU Memory","Buffer Memory","Texture Memory","Referenced Buffer Memory","Referenced Texture Memory","Swap Chain Texture"],Wc=new WeakMap,Vc=new WeakMap;class d0{constructor(){g(this,"stats",new Map)}getStats(e){return this.get(e)}get(e){this.stats.has(e)||this.stats.set(e,new nn({id:e}));const i=this.stats.get(e);return e===h0&&g0(i,u0),i}}const bu=new d0;function g0(t,e){const i=t.stats;let n=!1;for(const c of e)i[c]||(t.get(c),n=!0);const s=Object.keys(i).length,r=Wc.get(t);if(!n&&(r==null?void 0:r.orderedStatNames)===e&&r.statCount===s)return;const o={};let a=Vc.get(e);a||(a=new Set(e),Vc.set(e,a));for(const c of e)i[c]&&(o[c]=i[c]);for(const[c,l]of Object.entries(i))a.has(c)||(o[c]=l);for(const c of Object.keys(i))delete i[c];Object.assign(i,o),Wc.set(t,{orderedStatNames:e,statCount:s})}const R=new tn({id:"luma.gl"}),pr={};function on(t="id"){pr[t]=pr[t]||1;const e=pr[t]++;return`${t}-${e}`}const p0="cpu-hotspot-profiler",$c="GPU Resource Counts",jc="Resource Counts",Hc="GPU Time and Memory",_0=["Resources","Buffers","Textures","Samplers","TextureViews","Framebuffers","QuerySets","Shaders","RenderPipelines","ComputePipelines","PipelineLayouts","VertexArrays","RenderPasss","ComputePasss","CommandEncoders","CommandBuffers"],m0=["Resources","Buffers","Textures","Samplers","TextureViews","Framebuffers","QuerySets","Shaders","RenderPipelines","SharedRenderPipelines","ComputePipelines","PipelineLayouts","VertexArrays","RenderPasss","ComputePasss","CommandEncoders","CommandBuffers"],y0=_0.flatMap(t=>[`${t} Created`,`${t} Active`]),b0=m0.flatMap(t=>[`${t} Created`,`${t} Active`]),Xc=new WeakMap,Yc=new WeakMap;var Gr;let H=(Gr=class{constructor(e,i,n){g(this,"id");g(this,"props");g(this,"userData",{});g(this,"_device");g(this,"destroyed",!1);g(this,"allocatedBytes",0);g(this,"allocatedBytesName",null);g(this,"_attachedResources",new Set);if(!e)throw new Error("no device");this._device=e,this.props=v0(i,n);const s=this.props.id!=="undefined"?this.props.id:on(this[Symbol.toStringTag]);this.props.id=s,this.id=s,this.userData=this.props.userData||{},this.addStats()}toString(){return`${this[Symbol.toStringTag]||this.constructor.name}:"${this.id}"`}destroy(){this.destroyed||this.destroyResource()}delete(){return this.destroy(),this}getProps(){return this.props}attachResource(e){this._attachedResources.add(e)}detachResource(e){this._attachedResources.delete(e)}destroyAttachedResource(e){this._attachedResources.delete(e)&&e.destroy()}destroyAttachedResources(){for(const e of this._attachedResources)e.destroy();this._attachedResources=new Set}destroyResource(){this.destroyed||(this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0)}removeStats(){const e=Ci(this._device),i=e?et():0,n=[this._device.statsManager.getStats($c),this._device.statsManager.getStats(jc)],s=qc(this._device);for(const o of n)Kc(o,s);const r=this.getStatsName();for(const o of n)o.get("Resources Active").decrementCount(),o.get(`${r}s Active`).decrementCount();e&&(e.statsBookkeepingCalls=(e.statsBookkeepingCalls||0)+1,e.statsBookkeepingTimeMs=(e.statsBookkeepingTimeMs||0)+(et()-i))}trackAllocatedMemory(e,i=this.getStatsName()){const n=Ci(this._device),s=n?et():0,r=this._device.statsManager.getStats(Hc);this.allocatedBytes>0&&this.allocatedBytesName&&(r.get("GPU Memory").subtractCount(this.allocatedBytes),r.get(`${this.allocatedBytesName} Memory`).subtractCount(this.allocatedBytes)),r.get("GPU Memory").addCount(e),r.get(`${i} Memory`).addCount(e),n&&(n.statsBookkeepingCalls=(n.statsBookkeepingCalls||0)+1,n.statsBookkeepingTimeMs=(n.statsBookkeepingTimeMs||0)+(et()-s)),this.allocatedBytes=e,this.allocatedBytesName=i}trackReferencedMemory(e,i=this.getStatsName()){this.trackAllocatedMemory(e,`Referenced ${i}`)}trackDeallocatedMemory(e=this.getStatsName()){if(this.allocatedBytes===0){this.allocatedBytesName=null;return}const i=Ci(this._device),n=i?et():0,s=this._device.statsManager.getStats(Hc);s.get("GPU Memory").subtractCount(this.allocatedBytes),s.get(`${this.allocatedBytesName||e} Memory`).subtractCount(this.allocatedBytes),i&&(i.statsBookkeepingCalls=(i.statsBookkeepingCalls||0)+1,i.statsBookkeepingTimeMs=(i.statsBookkeepingTimeMs||0)+(et()-n)),this.allocatedBytes=0,this.allocatedBytesName=null}trackDeallocatedReferencedMemory(e=this.getStatsName()){this.trackDeallocatedMemory(`Referenced ${e}`)}addStats(){const e=this.getStatsName(),i=Ci(this._device),n=i?et():0,s=[this._device.statsManager.getStats($c),this._device.statsManager.getStats(jc)],r=qc(this._device);for(const o of s)Kc(o,r);for(const o of s)o.get("Resources Created").incrementCount(),o.get("Resources Active").incrementCount(),o.get(`${e}s Created`).incrementCount(),o.get(`${e}s Active`).incrementCount();i&&(i.statsBookkeepingCalls=(i.statsBookkeepingCalls||0)+1,i.statsBookkeepingTimeMs=(i.statsBookkeepingTimeMs||0)+(et()-n)),T0(this._device,e)}getStatsName(){return A0(this)}},g(Gr,"defaultProps",{id:"undefined",handle:void 0,userData:void 0}),Gr);function v0(t,e){const i={...e};for(const n in t)t[n]!==void 0&&(i[n]=t[n]);return i}function Kc(t,e){const i=t.stats;let n=!1;for(const c of e)i[c]||(t.get(c),n=!0);const s=Object.keys(i).length,r=Xc.get(t);if(!n&&(r==null?void 0:r.orderedStatNames)===e&&r.statCount===s)return;const o={};let a=Yc.get(e);a||(a=new Set(e),Yc.set(e,a));for(const c of e)i[c]&&(o[c]=i[c]);for(const[c,l]of Object.entries(i))a.has(c)||(o[c]=l);for(const c of Object.keys(i))delete i[c];Object.assign(i,o),Xc.set(t,{orderedStatNames:e,statCount:s})}function qc(t){return t.type==="webgl"?b0:y0}function Ci(t){const e=t.userData[p0];return e!=null&&e.enabled?e:null}function et(){var t,e;return((e=(t=globalThis.performance)==null?void 0:t.now)==null?void 0:e.call(t))??Date.now()}function T0(t,e){const i=Ci(t);if(!(!i||!i.activeDefaultFramebufferAcquireDepth))switch(i.transientCanvasResourceCreates=(i.transientCanvasResourceCreates||0)+1,e){case"Texture":i.transientCanvasTextureCreates=(i.transientCanvasTextureCreates||0)+1;break;case"TextureView":i.transientCanvasTextureViewCreates=(i.transientCanvasTextureViewCreates||0)+1;break;case"Sampler":i.transientCanvasSamplerCreates=(i.transientCanvasSamplerCreates||0)+1;break;case"Framebuffer":i.transientCanvasFramebufferCreates=(i.transientCanvasFramebufferCreates||0)+1;break}}function A0(t){let e=Object.getPrototypeOf(t);for(;e;){const i=Object.getPrototypeOf(e);if(!i||i===H.prototype)return w0(e)||t[Symbol.toStringTag]||t.constructor.name;e=i}return t[Symbol.toStringTag]||t.constructor.name}function w0(t){const e=Object.getOwnPropertyDescriptor(t,Symbol.toStringTag);return typeof(e==null?void 0:e.get)=="function"?e.get.call(t):typeof(e==null?void 0:e.value)=="str
842ing"?e.value:null}const he=class he extends H{constructor(i,n){const s={...n};(n.usage||0)&he.INDEX&&!n.indexType&&(n.data instanceof Uint32Array?s.indexType="uint32":n.data instanceof Uint16Array?s.indexType="uint16":n.data instanceof Uint8Array&&(s.indexType="uint8")),delete s.data;super(i,s,he.defaultProps);g(this,"usage");g(this,"indexType");g(this,"updateTimestamp");g(this,"debugData",new ArrayBuffer(0));this.usage=s.usage||0,this.indexType=s.indexType,this.updateTimestamp=i.incrementTimestamp()}get[Symbol.toStringTag](){return"Buffer"}clone(i){return this.device.createBuffer({...this.props,...i})}_setDebugData(i,n,s){let r=null,o;ArrayBuffer.isView(i)?(r=i,o=i.buffer):o=i;const a=Math.min(i?i.byteLength:s,he.DEBUG_DATA_MAX_LENGTH);if(o===null)this.debugData=new ArrayBuffer(a);else{const c=Math.min((r==null?void 0:r.byteOffset)||0,o.byteLength),l=Math.max(0,o.byteLength-c),f=Math.min(a,l);this.debugData=new Uint8Array(o,c,f).slice().buffer}}};g(he,"INDEX",16),g(he,"VERTEX",32),g(he,"UNIFORM",64),g(he,"STORAGE",128),g(he,"INDIRECT",256),g(he,"QUERY_RESOLVE",512),g(he,"MAP_READ",1),g(he,"MAP_WRITE",2),g(he,"COPY_SRC",4),g(he,"COPY_DST",8),g(he,"DEBUG_DATA_MAX_LENGTH",32),g(he,"defaultProps",{...H.defaultProps,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",onMapped:void 0});let Z=he;
842class S0{getDataTypeInfo(e){const[i,n,s]=_r[e],r=e.includes("norm"),o=!r&&!e.startsWith("float"),a=e.startsWith("s");return{signedType:i,primitiveType:n,byteLength:s,normalized:r,integer:o,signed:a}}getNormalizedDataType(e){const i=e;switch(i){case"uint8":return"unorm8";case"sint8":return"snorm8";case"uint16":return"unorm16";case"sint16":return"snorm16";default:return i}}alignTo(e,i){switch(i){case 1:return e;case 2:return e+e%2;default:return e+(4-e%4)%4}}getDataType(e){const i=ArrayBuffer.isView(e)?e.constructor:e;if(i===Uint8ClampedArray)return"uint8";const n=Object.values(_r).find(s=>i===s[4]);if(!n)throw new Error(i.name);return n[0]}getTypedArrayConstructor(e){const[,,,,i]=_r[e];return i}}const qe=new S0,_r={uint8:["uint8","u32",1,!1,Uint8Array],sint8:["sint8","i32",1,!1,Int8Array],unorm8:["uint8","f32",1,!0,Uint8Array],snorm8:["sint8","f32",1,!0,Int8Array],uint16:["uint16","u32",2,!1,Uint16Array],sint16:["sint16","i32",2,!1,Int16Array],unorm16:["uint16","u32",2,!0,Uint16Array],snorm16:["sint16","i32",2,!0,Int16Array],float16:["float16","f16",2,!1,Uint16Array],float32:["float32","f32",4,!1,Float32Array],uint32:["uint32","u32",4,!1,Uint32Array],sint32:["sint32","i32",4,!1,Int32Array]};class E0{getVertexFormatInfo(e){let i;e.endsWith("-webgl")&&(e.replace("-webgl",""),i=!0);const[n,s]=e.split("x"),r=n,o=s?parseInt(s):1,a=qe.getDataTypeInfo(r),c={type:r,components:o,byteLength:a.byteLength*o,integer:a.integer,signed:a.signed,normalized:a.normalized};return i&&(c.webglOnly=!0),c}makeVertexFormat(e,i,n){const s=n?qe.getNormalizedDataType(e):e;switch(s){case"unorm8":return i===1?"unorm8":i===3?"unorm8x3-webgl":`${s}x${i}`;case"snorm8":return i===1?"snorm8":i===3?"snorm8x3-webgl":`${s}x${i}`;case"uint8":case"sint8":if(i===1||i===3)throw new Error(`size: ${i}`);return`${s}x${i}`;case"uint16":return i===1?"uint16":i===3?"uint16x3-webgl":`${s}x${i}`;case"sint16":return i===1?"sint16":i===3?"sint16x3-webgl":`${s}x${i}`;case"unorm16":return i===1?"unorm16":i===3?"unorm16x3-webgl":`${s}x${i}`;case"snorm16":return i===1?"snorm16":i===3?"snorm16x3-webgl":`${s}x${i}`;case"float16":if(i===1||i===3)throw new Error(`size: ${i}`);return`${s}x${i}`;default:return i===1?s:`${s}x${i}`}}getVertexFormatFromAttribute(e,i,n){if(!i||i>4)throw new Error(`size ${i}`);const s=i,r=qe.getDataType(e);return this.makeVertexFormat(r,s,n)}getCompatibleVertexFormat(e){let i;switch(e.primitiveType){case"f32":i="float32";break;case"i32":i="sint32";break;case"u32":i="uint32";break;case"f16":return e.components<=2?"float16x2":"float16x4"}return e.components===1?i:`${i}x${e.components}`}}const qi=new E0,de="texture-compression-bc",G="texture-compression-astc",ke="texture-compression-etc2",x0="texture-compression-etc1-webgl",bn="texture-compression-pvrtc-webgl",mr="texture-compression-atc-webgl",vn="float32-renderable-webgl",yr="float16-renderable-webgl",P0="rgb9e5ufloat-renderable-webgl",br="snorm8-renderable-webgl",tt="norm16-webgl",vr="norm16-renderable-webgl",Tr="snorm16-renderable-webgl",Tn="float32-filterable",Zc="float16-filterable-webgl";function vu(t){const e=Tu[t];if(!e)throw new Error(`Unsupported texture format ${t}`);return e}function R0(){return Tu}const C0={r8unorm:{},rg8unorm:{},"rgb8unorm-webgl":{},rgba8unorm:{},"rgba8unorm-srgb":{},r8snorm:{render:br},rg8snorm:{render:br},"rgb8snorm-webgl":{},rgba8snorm:{render:br},r8uint:{},rg8uint:{},rgba8uint:{},r8sint:{},rg8sint:{},rgba8sint:{},bgra8unorm:{},"bgra8unorm-srgb":{},r16unorm:{f:tt,render:vr},rg16unorm:{f:tt,render:vr},"rgb16unorm-webgl":{f:tt,render:!1},rgba16unorm:{f:tt,render:vr},r16snorm:{f:tt,render:Tr},rg16snorm:{f:tt,render:Tr},"rgb16snorm-webgl":{f:tt,render:!1},rgba16snorm:{f:tt,render:Tr},r16uint:{},rg16uint:{},rgba16uint:{},r16sint:{},rg16sint:{},rgba16sint:{},r16float:{render:yr,filter:"float16-filterable-webgl"},rg16float:{render:yr,filter:Zc},rgba16float:{render:yr,filter:Zc},r32uint:{},rg32uint:{},rgba32uint:{},r32sint:{},rg32sint:{},rgba32sint:{},r32float:{render:vn,filter:Tn},rg32float:{render:!1,filter:Tn},"rgb32float-webgl":{render:vn,filter:Tn},rgba32float:{render:vn,filter:Tn},"rgba4unorm-webgl":{channels:"rgba",bitsPerChannel:[4,4,4,4],packed:!0},"rgb565unorm-webgl":{channels:"rgb",bitsPerChannel:[5,6,5,0],packed:!0},"rgb5a1unorm-webgl":{channels:"rgba",bitsPerChannel:[5,5,5,1],packed:!0},rgb9e5ufloat:{channels:"rgb",packed:!0,render:P0},rg11b10ufloat:{channels:"rgb",bitsPerChannel:[11,11,10,0],packed:!0,p:1,render:vn},rgb10a2unorm:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1},rgb10a2uint:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1},stencil8:{attachment:"stencil",bitsPerChannel:[8,0,0,0],dataType:"uint8"},depth16unorm:{attachment:"depth",bitsPerChannel:[16,0,0,0],dataType:"uint16"},depth24plus:{attachment:"depth",bitsPerChannel:[24,0,0,0],dataType:"uint32"},depth32float:{attachment:"depth",bitsPerChannel:[32,0,0,0],dataType:"float32"},"depth24plus-stencil8":{attachment:"depth-stencil",bitsPerChannel:[24,8,0,0],packed:!0},"depth32float-stencil8":{attachment:"depth-stencil",bitsPerChannel:[32,8,0,0],packed:!0}}
842,M0={"bc1-rgb-unorm-webgl":{f:de},"bc1-rgb-unorm-srgb-webgl":{f:de},"bc1-rgba-unorm":{f:de},"bc1-rgba-unorm-srgb":{f:de},"bc2-rgba-unorm":{f:de},"bc2-rgba-unorm-srgb":{f:de},"bc3-rgba-unorm":{f:de},"bc3-rgba-unorm-srgb":{f:de},"bc4-r-unorm":{f:de},"bc4-r-snorm":{f:de},"bc5-rg-unorm":{f:de},"bc5-rg-snorm":{f:de},"bc6h-rgb-ufloat":{f:de},"bc6h-rgb-float":{f:de},"bc7-rgba-unorm":{f:de},"bc7-rgba-unorm-srgb":{f:de},"etc2-rgb8unorm":{f:ke},"etc2-rgb8unorm-srgb":{f:ke},"etc2-rgb8a1unorm":{f:ke},"etc2-rgb8a1unorm-srgb":{f:ke},"etc2-rgba8unorm":{f:ke},"etc2-rgba8unorm-srgb":{f:ke},"eac-r11unorm":{f:ke},"eac-r11snorm":{f:ke},"eac-rg11unorm":{f:ke},"eac-rg11snorm":{f:ke},"astc-4x4-unorm":{f:G},"astc-4x4-unorm-srgb":{f:G},"astc-5x4-unorm":{f:G},"astc-5x4-unorm-srgb":{f:G},"astc-5x5-unorm":{f:G},"astc-5x5-unorm-srgb":{f:G},"astc-6x5-unorm":{f:G},"astc-6x5-unorm-srgb":{f:G},"astc-6x6-unorm":{f:G},"astc-6x6-unorm-srgb":{f:G},"astc-8x5-unorm":{f:G},"astc-8x5-unorm-srgb":{f:G},"astc-8x6-unorm":{f:G},"astc-8x6-unorm-srgb":{f:G},"astc-8x8-unorm":{f:G},"astc-8x8-unorm-srgb":{f:G},"astc-10x5-unorm":{f:G},"astc-10x5-unorm-srgb":{f:G},"astc-10x6-unorm":{f:G},"astc-10x6-unorm-srgb":{f:G},"astc-10x8-unorm":{f:G},"astc-10x8-unorm-srgb":{f:G},"astc-10x10-unorm":{f:G},"astc-10x10-unorm-srgb":{f:G},"astc-12x10-unorm":{f:G},"astc-12x10-unorm-srgb":{f:G},"astc-12x12-unorm":{f:G},"astc-12x12-unorm-srgb":{f:G},"pvrtc-rgb4unorm-webgl":{f:bn},"pvrtc-rgba4unorm-webgl":{f:bn},"pvrtc-rgb2unorm-webgl":{f:bn},"pvrtc-rgba2unorm-webgl":{f:bn},"etc1-rbg-unorm-webgl":{f:x0},"atc-rgb-unorm-webgl":{f:mr},"atc-rgba-unorm-webgl":{f:mr},"atc-rgbai-unorm-webgl":{f:mr}},Tu={...C0,...M0},O0=/^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/,I0=["rgb","rgba","bgra"],N0=["depth","stencil"],L0=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"];class D0{isColor(e){return I0.some(i=>e.startsWith(i))}isDepthStencil(e){return N0.some(i=>e.startsWith(i))}isCompressed(e){return L0.some(i=>e.startsWith(i))}getInfo(e){return Au(e)}getCapabilities(e){return F0(e)}computeMemoryLayout(e){return B0(e)}}const Ce=new D0;function B0({format:t,width:e,height:i,depth:n,byteAlignment:s}){const r=Ce.getInfo(t),{bytesPerPixel:o,bytesPerBlock:a=o,blockWidth:c=1,blockHeight:l=1,compressed:f=!1}=r,h=f?Math.ceil(e/c):e,u=f?Math.ceil(i/l):i,d=h*a,p=Math.ceil(d/s)*s,_=u,m=p*_*n;return{bytesPerPixel:o,bytesPerRow:p,rowsPerImage:_,depthOrArrayLayers:n,bytesPerImage:p*_,byteLength:m}}function F0(t){const e=vu(t),i={format:t,create:e.f??!0,render:e.render??!0,filter:e.filter??!0,blend:e.blend??!0,store:e.store??!0},n=Au(t),s=t.startsWith("depth")||t.startsWith("stencil"),r=n==null?void 0:n.signed,o=n==null?void 0:n.integer,a=n==null?void 0:n.webgl,c=!!(n!=null&&n.compressed);return i.render&&(i.render=!s&&!c),i.filter&&(i.filter=!s&&!r&&!o&&!a),i}function Au(t){let e=k0(t);if(Ce.isCompressed(t)){e.channels="rgb",e.components=3,e.bytesPerPixel=1,e.srgb=!1,e.compressed=!0,e.bytesPerBlock=z0(t);const n=U0(t);n&&(e.blockWidth=n.blockWidth,e.blockHeight=n.blockHeight)}const i=e.packed?null:O0.exec(t);if(i){const[,n,s,r,o,a]=i,c=`${r}${s}`,l=qe.getDataTypeInfo(c),f=l.byteLength*8,h=(n==null?void 0:n.length)??1,u=[f,h>=2?f:0,h>=3?f:0,h>=4?f:0];e={format:t,attachment:e.attachment,dataType:l.signedType,components:h,channels:n,integer:l.integer,signed:l.signed,normalized:l.normalized,bitsPerChannel:u,bytesPerPixel:l.byteLength*h,packed:e.packed,srgb:e.srgb},a==="-webgl"&&(e.webgl=!0),o==="-srgb"&&(e.srgb=!0)}return t.endsWith("-webgl")&&(e.webgl=!0),t.endsWith("-srgb")&&(e.srgb=!0),e}function k0(t){var r;const e=vu(t),i=e.bytesPerPixel||1,n=e.bitsPerChannel||[8,8,8,8];return delete e.bitsPerChannel,delete e.bytesPerPixel,delete e.f,delete e.render,delete e.filter,delete e.blend,delete e.store,{...e,format:t,attachment:e.attachment||"color",channels:e.channels||"r",components:e.components||((r=e.channels)==null?void 0:r.length)||1,bytesPerPixel:i,bitsPerChannel:n,dataType:e.dataType||"uint8",srgb:e.srgb??!1,packed:e.packed??!1,webgl:e.webgl??!1,integer:e.integer??!1,signed:e.signed??!1,normalized:e.normalized??!1,compressed:e.compressed??!1}}function U0(t){const i=/.*-(\d+)x(\d+)-.*/.exec(t);if(i){const[,n,s]=i;return{blockWidth:Number(n),blockHeight:Number(s)}}return t.startsWith("bc")||t.startsWith("etc1")||t.startsWith("etc2")||t.startsWith("eac")||t.startsWith("atc")?{blockWidth:4,blockHeight:4}:t.startsWith("pvrtc-rgb4")||t.startsWith("pvrtc-rgba4")?{blockWidth:4,blockHeight:4}:t.startsWith("pvrtc-rgb2")||t.startsWith("pvrtc-rgba2")?{blockWidth:8,blockHeight:4}:null}function z0(t){return t.startsWith("bc1")||t.startsWith("bc4")||t.startsWith("etc1")||t.startsWith("etc2-rgb8")||t.startsWith("etc2-rgb8a1")||t.startsWith("eac-r11")||t==="atc-rgb-unorm-webgl"?8:t.startsWith("bc2")||t.startsWith("bc3")||t.startsWith("bc5")||t.startsWith("bc6h")||t.startsWith("bc7")||t.startsWith("etc2-rgba8")||t.startsWith("eac-rg11")||t.startsWith("astc")||t==="atc-rgba-unorm-webgl"||t==="atc-rgbai-unorm-webgl"?16:t.startsWith("pvrtc")?8:16}function ba(t){return typeof ImageData<"u"&&t instanceof ImageData||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement||typeof VideoFrame<"u"&&t instanceof VideoFrame||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas}function wu(t){if(typeof ImageData<"u"&&t instanceof ImageData||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas)return{width:t.width,height:t.height};if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement)return{width:t.naturalWi
842dth,height:t.naturalHeight};if(typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement)return{width:t.videoWidth,height:t.videoHeight};if(typeof VideoFrame<"u"&&t instanceof VideoFrame)return{width:t.displayWidth,height:t.displayHeight};throw new Error("Unknown image type")}class W0{}function V0(t,e){const i=ho(t),n=e.map(ho).filter(s=>s!==void 0);return[i,...n].filter(s=>s!==void 0)}function ho(t){var e;if(t!==void 0){if(t===null||typeof t=="string"||typeof t=="number"||typeof t=="boolean")return t;if(t instanceof Error)return t.message;if(Array.isArray(t))return t.map(ho);if(typeof t=="object"){if($0(t)){const i=String(t);if(i!=="[object Object]")return i}return j0(t)?H0(t):((e=t.constructor)==null?void 0:e.name)||"Object"}return String(t)}}function $0(t){return"toString"in t&&typeof t.toString=="function"&&t.toString!==Object.prototype.toString}function j0(t){return"message"in t&&"type"in t}function H0(t){const e=typeof t.type=="string"?t.type:"message",i=typeof t.message=="string"?t.message:"",n=typeof t.lineNum=="number"?t.lineNum:null,s=typeof t.linePos=="number"?t.linePos:null,r=n!==null&&s!==null?` @ ${n}:${s}`:n!==null?` @ ${n}`:"";return`${e}${r}: ${i}`.trim()}class X0{constructor(e=[],i){g(this,"features");g(this,"disabledFeatures");this.features=new Set(e),this.disabledFeatures=i||{}}*[Symbol.iterator](){yield*this.features}has(e){var i;return!((i=this.disabledFeatures)!=null&&i[e])&&this.features.has(e)}}const Ss=class Ss{constructor(e){g(this,"id");g(this,"props");g(this,"userData",{});g(this,"statsManager",bu);g(this,"_factories",{});g(this,"timestamp",0);g(this,"_reused",!1);g(this,"_moduleData",{});g(this,"_textureCaps",{});g(this,"_debugGPUTimeQuery",null);this.props={...Ss.defaultProps,...e},this.id=this.props.id||on(this[Symbol.toStringTag].toLowerCase())}get[Symbol.toStringTag](){return"Device"}toString(){return`Device(${this.id})`}getVertexFormatInfo(e){return qi.getVertexFormatInfo(e)}isVertexFormatSupported(e){return!0}getTextureFormatInfo(e){return Ce.getInfo(e)}getTextureFormatCapabilities(e){let i=this._textureCaps[e];if(!i){const n=this._getDeviceTextureFormatCapabilities(e);i=this._getDeviceSpecificTextureFormatCapabilities(n),this._textureCaps[e]=i}return i}getMipLevelCount(e,i,n=1){const s=Math.max(e,i,n);return 1+Math.floor(Math.log2(s))}isExternalImage(e){return ba(e)}getExternalImageSize(e){return wu(e)}isTextureFormatSupported(e){return this.getTextureFormatCapabilities(e).create}isTextureFormatFilterable(e){return this.getTextureFormatCapabilities(e).filter}isTextureFormatRenderable(e){return this.getTextureFormatCapabilities(e).render}isTextureFormatCompressed(e){return Ce.isCompressed(e)}getSupportedCompressedTextureFormats(){const e=[];for(const i of Object.keys(R0()))this.isTextureFormatCompressed(i)&&this.isTextureFormatSupported(i)&&e.push(i);return e}pushDebugGroup(e){this.commandEncoder.pushDebugGroup(e)}popDebugGroup(){var e;(e=this.commandEncoder)==null||e.popDebugGroup()}insertDebugMarker(e){var i;(i=this.commandEncoder)==null||i.insertDebugMarker(e)}loseDevice(){return!1}incrementTimestamp(){return this.timestamp++}reportError(e,i,...n){if(!this.props.onError(e,i)){const r=V0(i,n);return R.error(this.type==="webgl"?"%cWebGL":"%cWebGPU","color: white; background: red; padding: 2px 6px; border-radius: 3px;",e.message,...r)}return()=>{}}debug(){if(this.props.debug)debugger;else R.once(0,`'Type luma.log.set({debug: true}) in console to enable debug breakpoints', 843or create a device with the 'debug: true' prop.`)()}getDefaultCanvasContext(){if(!this.canvasContext)throw new Error("Device has no default CanvasContext. See props.createCanvasContext");return this.canvasContext}createFence(){throw new Error("createFence() not implemented")}beginRenderPass(e){return this.commandEncoder.beginRenderPass(e)}beginComputePass(e){return this.commandEncoder.beginComputePass(e)}generateMipmapsWebGPU(e){throw new Error("not implemented")}_createSharedRenderPipelineWebGL(e){throw new Error("_createSharedRenderPipelineWebGL() not implemented")}_createBindGroupLayoutWebGPU(e,i){throw new Error("_createBindGroupLayoutWebGPU() not implemented")}_createBindGroupWebGPU(e,i,n,s,r){throw new Error("_createBindGroupWebGPU() not implemented")}_supportsDebugGPUTime(){return this.features.has("timestamp-query")&&!!(this.props.debug||this.props.debugGPUTime)}_enableDebugGPUTime(e=256){if(!this._supportsDebugGPUTime())return null;if(this._debugGPUTimeQuery)return this._debugGPUTimeQuery;try{this._debugGPUTimeQuery=this.createQuerySet({type:"timestamp",count:e}),this.commandEncoder=this.createCommandEncoder({id:this.commandEncoder.props.id,timeProfilingQuerySet:this._debugGPUTimeQuery})}catch{this._debugGPUTimeQuery=null}return this._debugGPUTimeQuery}_disableDebugGPUTime(){this._debugGPUTimeQuery&&(this.commandEncoder.getTimeProfilingQuerySet()===this._debugGPUTimeQuery&&(this.commandEncoder=this.createCommandEncoder({id:this.commandEncoder.props.id})),this._debugGPUTimeQuery.destroy(),this._debugGPUTimeQuery=null)}_isDebugGPUTimeEnabled(){return this._debugGPUTimeQuery!==null}getCanvasContext(){return this.getDefaultCanvasContext()}readPixelsToArrayWebGL(e,i){throw new Error("not implemented")}readPixelsToBufferWebGL(e,i){throw new Error("not implemented")}setParametersWebGL(e){throw new Error("not implemented")}getParametersWebGL(e){throw new Error("not implemented")}withParametersWebGL(e,i){throw new Error("not implemented")}clearWebGL(e){throw new Error("not implemented")}resetWebGL(){throw new Error("not implemented")}getModuleData(e){var i;return(i=this._moduleData)[e]||(i[e]={}),this._moduleData[e]}static _getCanvasContextProps(e){return e.createCanvasContext===!0?{}:e.createCanvasContext}_getDeviceTextureFormatCapabilities(e){const i=Ce.getCapabilities(e),n=r=>(typeof r=="string"?this.features.has(r):r)??!0,s=n(i.create);return{format:e,create:s,render:s&&n(i.render),filter:s&&n(i.filter),blend:s&&n(i.blend),store:s&&n(i.store)}}_normalizeBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});const i={...e};if((e.usage||0)&Z.INDEX&&(e.indexType||(e.data instanceof Uint32Array?i.indexType="uint32":e.data instanceof Uint16Array?i.indexType="uint16":e.data instanceof Uint8Array&&(i.data=new Uint16Array(e.data),i.indexType="uint16")),!i.indexType))throw new Error("indices buffer content must be of type uint16 or uint32");return i}};g(Ss,"defaultProps",{id:null,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,createCanvasContext:void 0,webgl:{},onError:(e,i)=>{},onResize:(e,i)=>{const[n,s]=e.getDevicePixelSize();R.log(1,`${e} resized => ${n}x${s}px`)()},onPositionChange:(e,i)=>{const[n,s]=e.getPosition();R.log(1,`${e} repositioned => ${n},${s}`)()},onVisibilityChange:e=>R.log(1,`${e} Visibility changed ${e.isVisible}`)(),onDevicePixelRatioChange:(e,i)=>R.log(1,`${e} DPR changed ${i.oldRatio} => ${e.devicePixelRatio}`)(),debug:K0(),debugGPUTime:!1,debugShaders:R.get("debug-shaders")||void 0,debugFramebuffers:!!R.get("debug-framebuffers"),debugFactories:!!R.get("debug-factories"),debugWebGL:!!R.get("debug-webgl"),debugSpectorJS:void 0,debugSpectorJSUrl:void 0,_reuseDevices:!1,_requestMaxLimits:!0,_cacheShaders:!0,_destroyShaders:!1,_cachePipelines:!0,_sharePipelines:!0,_destroyPipelines:!1,_initializeFeatures:!0,_disabledFeatures:{"compilation-status-async-webgl":!0},_handle:void 0});let Mt=Ss;function Y0(t,e){return t!=null?!!t:e!==void 0?e!=="production":!1}function K0(){return Y0(R.get("debug"),q0())}function q0(){const t=globalThis.process;if(t!=null&&t.env)return t.env.NODE_ENV}const Z0="set luma.log.level=1 (or higher) to trace rendering",Gc="No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.",$i=class $i{constructor(){g(this,"stats",bu);g(this,"log",R);g(this,"VERSION","9.3.2");g(this,"spector");g(this,"preregisteredAdapters",new Map);if(globalThis.luma){if(globalThis.luma.VERSION!==this.VERSION)throw R.error(`Found luma.gl ${globalThis.luma.VERSION} while initialzing ${this.VERSION}`)(),R.error("'yarn why @luma.gl/core' can help identify the source of the conflict")(),new Error("luma.gl - multiple versions detected: see console log");R.error("This version of luma.gl has already been initialized")()}R.log(1,`${this.VERSION} - ${Z0}`)(),globalThis.luma=this}async createDevice(e={}){const i={...$i.defaultProps,...e},n=this.selectAdapter(i.type,i.adapters);if(!n)throw new Error(Gc);return i.waitForPageLoad&&await n.pageLoaded,await n.create(i)}async attachDevice(e,i){var r;const n=this._getTypeFromHandle(e,i.adapters),s=n&&this.selectAdapter(n,i.adapters);if(!s)throw new Error(Gc);return await((r=s==null?void 0:s.attach)==null?void 0:r.call(s,e,i))}registerAdapters(e){for(const i of e)this.preregisteredAdapters.set(i.type,i)}
843getSupportedAdapters(e=[]){const i=this._getAdapterMap(e);return Array.from(i).map(([,n])=>n).filter(n=>{var s;return(s=n.isSupported)==null?void 0:s.call(n)}).map(n=>n.type)}getBestAvailableAdapterType(e=[]){var s,r;const i=["webgpu","webgl","null"],n=this._getAdapterMap(e);for(const o of i)if((r=(s=n.get(o))==null?void 0:s.isSupported)!=null&&r.call(s))return o;return null}selectAdapter(e,i=[]){let n=e;e==="best-available"&&(n=this.getBestAvailableAdapterType(i));const s=this._getAdapterMap(i);return n&&s.get(n)||null}enforceWebGL2(e=!0,i=[]){var r;const s=this._getAdapterMap(i).get("webgl");s||R.warn("enforceWebGL2: webgl adapter not found")(),(r=s==null?void 0:s.enforceWebGL2)==null||r.call(s,e)}setDefaultDeviceProps(e){Object.assign($i.defaultProps,e)}_getAdapterMap(e=[]){const i=new Map(this.preregisteredAdapters);for(const n of e)i.set(n.type,n);return i}_getTypeFromHandle(e,i=[]){return e instanceof WebGL2RenderingContext?"webgl":typeof GPUDevice<"u"&&e instanceof GPUDevice||e!=null&&e.queue?"webgpu":e===null?"null":(e instanceof WebGLRenderingContext?R.warn("WebGL1 is not supported",e)():R.warn("Unknown handle type",e)(),null)}};g($i,"defaultProps",{...Mt.defaultProps,type:"best-available",adapters:void 0,waitForPageLoad:!0});let uo=$i;const go=new uo;class G0{get pageLoaded(){return ev()}}const Q0=Lt()&&typeof document<"u",J0=()=>Q0&&document.readyState==="complete";let An=null;function ev(){return An||(J0()||typeof window>"u"?An=Promise.resolve():An=new Promise(t=>window.addEventListener("load",()=>t()))),An}class tv{constructor(e){g(this,"props");g(this,"_resizeObserver");g(this,"_intersectionObserver");g(this,"_observeDevicePixelRatioTimeout",null);g(this,"_observeDevicePixelRatioMediaQuery",null);g(this,"_handleDevicePixelRatioChange",()=>this._refreshDevicePixelRatio());g(this,"_trackPositionInterval",null);g(this,"_started",!1);this.props=e}get started(){return this._started}start(){if(!(this._started||!this.props.canvas)){this._started=!0,this._intersectionObserver||(this._intersectionObserver=new IntersectionObserver(e=>this.props.onIntersection(e))),this._resizeObserver||(this._resizeObserver=new ResizeObserver(e=>this.props.onResize(e))),this._intersectionObserver.observe(this.props.canvas);try{this._resizeObserver.observe(this.props.canvas,{box:"device-pixel-content-box"})}catch{this._resizeObserver.observe(this.props.canvas,{box:"content-box"})}this._observeDevicePixelRatioTimeout=setTimeout(()=>this._refreshDevicePixelRatio(),0),this.props.trackPosition&&this._trackPosition()}}stop(){var e,i;this._started&&(this._started=!1,this._observeDevicePixelRatioTimeout&&(clearTimeout(this._observeDevicePixelRatioTimeout),this._observeDevicePixelRatioTimeout=null),this._observeDevicePixelRatioMediaQuery&&(this._observeDevicePixelRatioMediaQuery.removeEventListener("change",this._handleDevicePixelRatioChange),this._observeDevicePixelRatioMediaQuery=null),this._trackPositionInterval&&(clearInterval(this._trackPositionInterval),this._trackPositionInterval=null),(e=this._resizeObserver)==null||e.disconnect(),(i=this._intersectionObserver)==null||i.disconnect())}_refreshDevicePixelRatio(){var e;this._started&&(this.props.onDevicePixelRatioChange(),(e=this._observeDevicePixelRatioMediaQuery)==null||e.removeEventListener("change",this._handleDevicePixelRatioChange),this._observeDevicePixelRatioMediaQuery=matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`),this._observeDevicePixelRatioMediaQuery.addEventListener("change",this._handleDevicePixelRatioChange,{once:!0}))}_trackPosition(e=100){this._trackPositionInterval||(this._trackPositionInterval=setInterval(()=>{this._started?this.props.onPositionChange():this._trackPositionInterval&&(clearInterval(this._trackPositionInterval),this._trackPositionInterval=null)},e))}}function iv(){let t,e;return{promise:new Promise((n,s)=>{t=n,e=s}),resolve:t,reject:e}}function Su(t,e){var i;if(!t){const n=new Error(e??"luma.gl assertion failed.");throw(i=Error.captureStackTrace)==null||i.call(Error,n,Su),n}}function va(t,e){return Su(t,e),t}const Qt=class Qt{constructor(e){g(this,"id");g(this,"props");g(this,"canvas");g(this,"htmlCanvas");g(this,"offscreenCanvas");g(this,"type");g(this,"initialized");g(this,"isInitialized",!1);g(this,"isVisible",!0);g(this,"cssWidth");g(this,"cssHeight");g(this,"devicePixelRatio");g(this,"devicePixelWidth");g(this,"devicePixelHeight");g(this,"drawingBufferWidth");g(this,"drawingBufferHeight");g(this,"_initializedResolvers",iv());g(this,"_canvasObserver");g(this,"_position",[0,0]);g(this,"destroyed",!1);g(this,"_needsDrawingBufferResize",!0);var i,n;this.props={...Qt.defaultProps,...e},e=this.props,this.initialized=this._initializedResolvers.promise,Lt()?e.canvas?typeof e.canvas=="string"?this.canvas=sv(e.canvas):this.canvas=e.canvas:this.canvas=rv(e):this.canvas={width:e.width||1,height:e.height||1},Qt.isHTMLCanvas(this.canvas)?(this.id=e.id||this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):Qt.isOffscreenCanvas(this.canvas)?(this.id=e.id||"offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas):(this.id=e.id||"node-canvas-context",this.type="node"),this.cssWidth=((i=this.htmlCanvas)==null?void 0:i.clientWidth)||this.canvas.width,this.cssHeight=((n=this.htmlCanvas)==null?void 0:n.clientHeight)||this.canvas.height,this.devicePixelWidth=this.canvas.width,this.devicePixelHeight=this.canvas.height,this.drawingBufferWidth=this.canvas.width,this.drawingBufferHeight=this.canvas.height,this.devicePixelRatio=globalThis.devicePixelRatio||1,this._position=[0,0],this._canvasObserver=new tv({canvas:this.htmlCanvas,trackPosition:this.props.trackPosition,onResize:s=>this._handleResize(s),onIntersection:s=>this._handleIntersection(s),onDevicePixelRatioChange:()=>this._observeDevicePixelRatio(),onPositionChange:()=>this.updatePosition()})}static isHTMLCanvas(e){return typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement}static isOffscreenCanvas(e){return typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas}toString(){return`${this[Symbol.toStringTag]}(${this.id})`}destroy(){this.destroyed||(this.destroyed=!0,this._stopObservers(),this.device=null)}setProps(e){return"useDevicePixels"in e&&(this.props.useDevicePixels=e.useDevicePixels||!1,this._updateDrawingBufferSize()),this}getCurrentFramebuffer(e){return this._resizeDrawingBufferIfNeeded(),this._getCurrentFramebuffer(e)}getCSSSize(){return[this.cssWidth,this.cssHeight]}getPosition(){return this._position}getDevicePixelSize(){return[this.devicePixelWidth,this.devicePixelHeight]}getDrawingBufferSize(){return[this.drawingBufferWidth,this.drawingBufferHeight]}getMaxDrawingBufferSize(){const e=this.device.limits.maxTextureDimension2D;return[e,e]}setDrawingBufferSize(e,i){e=Math.floor(e),i=Math.floor(i),!(this.drawingBufferWidth===e&&this.drawingBufferHeight===i)&&(this.drawingBufferWidth=e,this.drawingBufferHeight=i,this._needsDrawingBufferResize=!0)}getDevicePixelRatio(){return typeof window<"u"&&window.devicePixelRatio||1}cssToDevicePixels(e,i=!0){const n=this.cssToDeviceRatio(),[s,r]=this.getDrawingBufferSize();return ov(e,n,s,r,i)}getPixelSize(){return this.getDevicePixelSize()}getAspect(){const[e,i]=this.getDrawingBufferSize();return e>0&&i>0?e/i:1}cssToDeviceRatio(){try{const[e]=this.getDrawingBufferSize(),[i]=this.getCSSSize();return i?e/i:1}catch{return 1}}resize(e){this.setDrawingBufferSize(e.width,e.height)}_setAutoCreatedCanvasId(e){var i;((i=this.htmlCanvas)==null?void 0:i.id)==="lumagl-auto-created-canvas"&&(this.htmlCanvas.id=e)}_startObservers(){this.destroyed||this._canvasObserver.start()}_stopObservers(){this._canvasObserver.stop()}_handleIntersection(e){if(this.destroyed)return;const i=e.find(s=>
843s.target===this.canvas);if(!i)return;const n=i.isIntersecting;this.isVisible!==n&&(this.isVisible=n,this.device.props.onVisibilityChange(this))}_handleResize(e){var l,f,h,u,d;if(this.destroyed)return;const i=e.find(p=>p.target===this.canvas);if(!i)return;const n=va((l=i.contentBoxSize)==null?void 0:l[0]);this.cssWidth=n.inlineSize,this.cssHeight=n.blockSize;const s=this.getDevicePixelSize(),r=((h=(f=i.devicePixelContentBoxSize)==null?void 0:f[0])==null?void 0:h.inlineSize)||n.inlineSize*devicePixelRatio,o=((d=(u=i.devicePixelContentBoxSize)==null?void 0:u[0])==null?void 0:d.blockSize)||n.blockSize*devicePixelRatio,[a,c]=this.getMaxDrawingBufferSize();this.devicePixelWidth=Math.max(1,Math.min(r,a)),this.devicePixelHeight=Math.max(1,Math.min(o,c)),this._updateDrawingBufferSize(),this.device.props.onResize(this,{oldPixelSize:s})}_updateDrawingBufferSize(){if(this.props.autoResize)if(typeof this.props.useDevicePixels=="number"){const e=this.props.useDevicePixels;this.setDrawingBufferSize(this.cssWidth*e,this.cssHeight*e)}else this.props.useDevicePixels?this.setDrawingBufferSize(this.devicePixelWidth,this.devicePixelHeight):this.setDrawingBufferSize(this.cssWidth,this.cssHeight);this._initializedResolvers.resolve(),this.isInitialized=!0,this.updatePosition()}_resizeDrawingBufferIfNeeded(){this._needsDrawingBufferResize&&(this._needsDrawingBufferResize=!1,(this.drawingBufferWidth!==this.canvas.width||this.drawingBufferHeight!==this.canvas.height)&&(this.canvas.width=this.drawingBufferWidth,this.canvas.height=this.drawingBufferHeight,this._configureDevice()))}_observeDevicePixelRatio(){var i,n;if(this.destroyed||!this._canvasObserver.started)return;const e=this.devicePixelRatio;this.devicePixelRatio=window.devicePixelRatio,this.updatePosition(),(n=(i=this.device.props).onDevicePixelRatioChange)==null||n.call(i,this,{oldRatio:e})}updatePosition(){var i,n,s;if(this.destroyed)return;const e=(i=this.htmlCanvas)==null?void 0:i.getBoundingClientRect();if(e){const r=[e.left,e.top];if(this._position??(this._position=r),r[0]!==this._position[0]||r[1]!==this._position[1]){const a=this._position;this._position=r,(s=(n=this.device.props).onPositionChange)==null||s.call(n,this,{oldPosition:a})}}}};g(Qt,"defaultProps",{id:void 0,canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,alphaMode:"opaque",colorSpace:"srgb",trackPosition:!1});let si=Qt;function nv(t){if(typeof t=="string"){const e=document.getElementById(t);if(!e)throw new Error(`${t} is not an HTML element`);return e}return t||document.body}function sv(t){const e=document.getElementById(t);if(!si.isHTMLCanvas(e))throw new Error("Object is not a canvas element");return e}function rv(t){const{width:e,height:i}=t,n=document.createElement("canvas");n.id=on("lumagl-auto-created-canvas"),n.width=e||1,n.height=i||1,n.style.width=Number.isFinite(e)?`${e}px`:"100%",n.style.height=Number.isFinite(i)?`${i}px`:"100%",t!=null&&t.visible||(n.style.visibility="hidden");const s=nv((t==null?void 0:t.container)||null);return s.insertBefore(n,s.firstChild),n}function ov(t,e,i,n,s){const r=t,o=Qc(r[0],e,i);let a=Jc(r[1],e,n,s),c=Qc(r[0]+1,e,i);const l=c===i-1?c:c-1;c=Jc(r[1]+1,e,n,s);let f;return s?(c=c===0?c:c+1,f=a,a=c):f=c===n-1?c:c-1,{x:o,y:a,width:Math.max(l-o+1,1),height:Math.max(f-a+1,1)}}function Qc(t,e,i){return Math.min(Math.round(t*e),i-1)}function Jc(t,e,i,n){return n?Math.max(0,i-1-Math.round(t*e)):Math.min(Math.round(t*e),i-1)}class Eu extends si{}g(Eu,"defaultProps",si.defaultProps);class av extends si{}const ji=class ji extends H{get[Symbol.toStringTag](){return"Sampler"}constructor(e,i){i=ji.normalizeProps(e,i),super(e,i,ji.defaultProps)}static normalizeProps(e,i){return i}};g(ji,"defaultProps",{...H.defaultProps,type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"none",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1});let ri=ji;const cv={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},ne=class ne extends H{constructor(i,n,s){n=ne.normalizeProps(i,n);super(i,n,ne.defaultProps);g(this,"dimension");g(this,"baseDimension");g(this,"format");g(this,"width");g(this,"height");g(this,"depth");g(this,"mipLevels");g(this,"samples");g(this,"byteAlignment");g(this,"ready",Promise.resolve(this));g(this,"isReady",!0);g(this,"updateTimestamp");if(this.dimension=this.props.dimension,this.baseDimension=cv[this.dimension],this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.mipLevels=this.props.mipLevels,this.samples=this.props.samples||1,this.dimension==="cube"&&(this.depth=6),this.props.width===void 0||this.props.height===void 0)if(i.isExternalImage(n.data)){const r=i.getExternalImageSize(n.data);this.width=(r==null?void 0:r.width)||1,this.height=(r==null?void 0:r.height)||1}else this.width=1,this.height=1,(this.props.width===void 0||this.props.height===void 0)&&R.warn(`${this} created with undefined width or height. This is deprecated. Use DynamicTexture instead.`)();this.byteAlignment=(s==null?void 0:s.byteAlignment)||1,this.updateTimestamp=i.incrementTimestamp()}get[Symbol.toStringTag](){return"Texture"}toString(){return`Texture(${this.id},${this.format},${this.width}x${this.height})`}clone(i){return this.device.createTexture({...this.props,...i})}setSampler(i){this.sampler=i instanceof ri?i:this.device.createSampler(i)}copyImageData(i){const{data:n,depth:s,...r}=i;this.writeData(n,{...r,depthOrArrayLayers:r.depthOrArrayLayers??s})}computeMemoryLayout(i={}){const n=this._normalizeTextureReadOptions(i),{width:s=this.width,height:r=this.height,depthOrArrayLayers:o=this.depth}=n,{format:a,byteAlignment:c}=this;return Ce.computeMemoryLayout({format:a,width:s,height:r,depth:o,b
vendor: 4,260 bytes, line 843
843yteAlignment:c})}readBuffer(i,n){throw new Error("readBuffer not implemented")}readDataAsync(i){throw new Error("readBuffer not implemented")}writeBuffer(i,n){throw new Error("readBuffer not implemented")}writeData(i,n){throw new Error("readBuffer not implemented")}readDataSyncWebGL(i){throw new Error("readDataSyncWebGL not available")}generateMipmapsWebGL(){throw new Error("generateMipmapsWebGL not available")}static normalizeProps(i,n){const s={...n},{width:r,height:o}=s;return typeof r=="number"&&(s.width=Math.max(1,Math.ceil(r))),typeof o=="number"&&(s.height=Math.max(1,Math.ceil(o))),s}_initializeData(i){this.device.isExternalImage(i)?this.copyExternalImage({image:i,width:this.width,height:this.height,depth:this.depth,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1}):i&&this.copyImageData({data:i,mipLevel:0,x:0,y:0,z:0,aspect:"all"})}_normalizeCopyImageDataOptions(i){const{data:n,depth:s,...r}=i,o=this._normalizeTextureWriteOptions({...r,depthOrArrayLayers:r.depthOrArrayLayers??s});return{data:n,depth:o.depthOrArrayLayers,...o}}_normalizeCopyExternalImageOptions(i){const n=ne._omitUndefined(i),s=n.mipLevel??0,r=this._getMipLevelSize(s),o=this.device.getExternalImageSize(i.image),a={...ne.defaultCopyExternalImageOptions,...r,...o,...n};return a.width=Math.min(a.width,r.width-a.x),a.height=Math.min(a.height,r.height-a.y),a.depth=Math.min(a.depth,r.depthOrArrayLayers-a.z),a}_normalizeTextureReadOptions(i){const n=ne._omitUndefined(i),s=n.mipLevel??0,r=this._getMipLevelSize(s),o={...ne.defaultTextureReadOptions,...r,...n};return o.width=Math.min(o.width,r.width-o.x),o.height=Math.min(o.height,r.height-o.y),o.depthOrArrayLayers=Math.min(o.depthOrArrayLayers,r.depthOrArrayLayers-o.z),o}_getSupportedColorReadOptions(i){const n=this._normalizeTextureReadOptions(i),s=Ce.getInfo(this.format);switch(this._validateColorReadAspect(n),this._validateColorReadFormat(s),this.dimension){case"2d":case"cube":case"cube-array":case"2d-array":case"3d":return n;default:throw new Error(`${this} color readback does not support ${this.dimension} textures`)}}_validateColorReadAspect(i){if(i.aspect!=="all")throw new Error(`${this} color readback only supports aspect 'all'`)}_validateColorReadFormat(i){if(i.compressed)throw new Error(`${this} color readback does not support compressed formats (${this.format})`);switch(i.attachment){case"color":return;case"depth":throw new Error(`${this} color readback does not support depth formats (${this.format})`);case"stencil":throw new Error(`${this} color readback does not support stencil formats (${this.format})`);case"depth-stencil":throw new Error(`${this} color readback does not support depth-stencil formats (${this.format})`);default:throw new Error(`${this} color readback does not support format ${this.format}`)}}_normalizeTextureWriteOptions(i){const n=ne._omitUndefined(i),s=n.mipLevel??0,r=this._getMipLevelSize(s),o={...ne.defaultTextureWriteOptions,...r,...n};o.width=Math.min(o.width,r.width-o.x),o.height=Math.min(o.height,r.height-o.y),o.depthOrArrayLayers=Math.min(o.depthOrArrayLayers,r.depthOrArrayLayers-o.z);const a=Ce.computeMemoryLayout({format:this.format,width:o.width,height:o.height,depth:o.depthOrArrayLayers,byteAlignment:this.byteAlignment}),c=a.bytesPerPixel*o.width;if(o.bytesPerRow=n.bytesPerRow??a.bytesPerRow,o.rowsPerImage=n.rowsPerImage??o.height,o.bytesPerRow<c)throw new Error(`bytesPerRow (${o.bytesPerRow}) must be at least ${c} for ${this.format}`);if(o.rowsPerImage<o.height)throw new Error(`rowsPerImage (${o.rowsPerImage}) must be at least ${o.height} for ${this.format}`);const l=this.device.getTextureFormatInfo(this.format).bytesPerPixel;if(l&&o.bytesPerRow%l!==0)throw new Error(`bytesPerRow (${o.bytesPerRow}) must be a multiple of bytesPerPixel (${l}) for ${this.format}`);return o}_getMipLevelSize(i){const n=Math.max(1,this.width>>i),s=this.baseDimension==="1d"?1:Math.max(1,this.height>>i),r=this.dimension==="3d"?Math.max(1,this.depth>>i):this.depth;return{width:n,height:s,depthOrArrayLayers:r}}getAllocatedByteLength(){let i=0;for(let n=0;n<this.mipLevels;n++){const{width:s,height:r,depthOrArrayLayers:o}=this._getMipLevelSize(n);i+=Ce.computeMemoryLayout({format:this.format,width:s,height:r,depth:o,b
843yteAlignment:1}).byteLength}return i*this.samples}static _omitUndefined(i){return Object.fromEntries(Object.entries(i).filter(([,n])=>n!==void 0))}};g(ne,"SAMPLE",4),g(ne,"STORAGE",8),g(ne,"RENDER",16),g(ne,"COPY_SRC",1),g(ne,"COPY_DST",2),g(ne,"TEXTURE",4),g(ne,"RENDER_ATTACHMENT",16),g(ne,"defaultProps",{...H.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",usage:ne.SAMPLE|ne.RENDER|ne.COPY_DST,width:void 0,height:void 0,depth:1,mipLevels:1,samples:void 0,sampler:{},view:void 0}),g(ne,"defaultCopyDataOptions",{data:void 0,byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,width:void 0,height:void 0,depthOrArrayLayers:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all"}),g(ne,"defaultCopyExternalImageOptions",{image:void 0,sourceX:0,sourceY:0,width:void 0,height:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1}),g(ne,"defaultTextureReadOptions",{x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:"all"}),g(ne,"defaultTextureWriteOptions",{byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:"all"});let Q=ne;const Es=class Es extends H{get[Symbol.toStringTag](){return"TextureView"}constructor(e,i){super(e,i,Es.defaultProps)}};g(Es,"defaultProps",{...H.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0});let as=Es;function lv(t,e,i){let n="";const s=e.split(/\r?\n/),r=t.slice().sort((o,a)=>o.lineNum-a.lineNum);switch((i==null?void 0:i.showSourceCode)||"no"){case"all":let o=0;for(let a=1;a<=s.length;a++){const c=s[a-1],l=r[o];for(c&&l&&(n+=xu(c,a,i));r.length>o&&l.lineNum===a;){const f=r[o++];f&&(n+=Ar(f,s,f.lineNum,{...i,inlineSource:!1}))}}for(;r.length>o;){const a=r[o++];a&&(n+=Ar(a,[],0,{...i,inlineSource:!1}))}return n;case"issues":case"no":for(const a of t)n+=Ar(a,s,a.lineNum,{inlineSource:(i==null?void 0:i.showSourceCode)!=="no"});return n}}function Ar(t,e,i,n){if(n!=null&&n.inlineSource){const r=fv(e,i),o=t.linePos>0?`${" ".repeat(t.linePos+5)}^^^ 844`:"";return` 845${r}${o}${t.type.toUpperCase()}: ${t.message} 846 847`}const s=t.type==="error"?"red":"orange";return n!=null&&n.html?`<div class='luma-compiler-log-${t.type}' style="color:${s};"><b> ${t.type.toUpperCase()}: ${t.message}</b></div>`:`${t.type.toUpperCase()}: ${t.message}`}function fv(t,e,i){let n="";for(let s=e-2;s<=e;s++){const r=t[s-1];r!==void 0&&(n+=xu(r,e,i))}return n}function xu(t,e,i){const n=i!=null&&i.html?uv(t):t;return`${hv(String(e),4)}: ${n}${i!=null&&i.html?"<br/>":` 848`}`}function hv(t,e){let i="";for(let n=t.length;n<e;++n)i+=" ";return i+t}function uv(t){return t.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}const xs=class xs extends H{constructor(i,n){n={...n,debugShaders:n.debugShaders||i.props.debugShaders||"errors"};super(i,{id:dv(n),...n},xs.defaultProps);g(this,"stage");g(this,"source");g(this,"compilationStatus","pending");this.stage=this.props.stage,this.source=this.props.source}get[Symbol.toStringTag](){return"Shader"}getCompilationInfoSync(){return null}getTranslatedSource(){return null}async debugShader(){const i=this.props.debugShaders;switch(i){case"never":return;case"errors":if(this.compilationStatus==="success")return;break}const n=await this.getCompilationInfo();i==="warnings"&&(n==null?void 0:n.length)===0||this._displayShaderLog(n,this.id)}_displayShaderLog(i,n){if(typeof document>"u"||!(document!=null&&document.createElement))return;const s=n,r=`${this.stage} shader "${s}"`,o=lv(i,this.source,{showSourceCode:"all",html:!0}),a=this.getTranslatedSource(),c=document.createElement("div");c.innerHTML=`<h1>Compilation error in ${r}</h1> 849<div style="display:flex;position:fixed;top:10px;right:20px;gap:2px;"> 850<button id="copy">Copy source</button><br/> 851<button id="close">Close</button> 852</div> 853<code><pre>${o}</pre></code>`,a&&(c.innerHTML+=`<br /><h1>Translated Source</h1><br /><br /><code><pre>${a}</pre></code>`),c.style.top="0",c.style.left="0",c.style.background="white",c.style.position="fixed",c.style.zIndex="9999",c.style.maxWidth="100vw",c.style.maxHeight="100vh",c.style.overflowY="auto",document.body.appendChild(c);const l=c.querySelector(".luma-compiler-log-error");l==null||l.scrollIntoView(),c.querySelector("button#close").onclick=()=>{c.remove()},c.querySelector("button#copy").onclick=()=>{navigator.clipboard.writeText(this.source)}}};g(xs,"defaultProps",{...H.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debugShaders:void 0});let cs=xs;function dv(t){return gv(t.source)||t.id||on(`unnamed ${t.stage}-shader`)}
853function gv(t,e="unnamed"){const n=/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(t);return(n==null?void 0:n[1])??e}const Ps=class Ps extends H{constructor(i,n={}){super(i,n,Ps.defaultProps);g(this,"width");g(this,"height");this.width=this.props.width,this.height=this.props.height}get[Symbol.toStringTag](){return"Framebuffer"}clone(i){const n=this.colorAttachments.map(r=>r.texture.clone(i)),s=this.depthStencilAttachment&&this.depthStencilAttachment.texture.clone(i);return this.device.createFramebuffer({...this.props,...i,colorAttachments:n,depthStencilAttachment:s})}resize(i){let n=!i;if(i){const[s,r]=Array.isArray(i)?i:[i.width,i.height];n=n||r!==this.height||s!==this.width,this.width=s,this.height=r}n&&(R.log(2,`Resizing framebuffer ${this.id} to ${this.width}x${this.height}`)(),this.resizeAttachments(this.width,this.height))}autoCreateAttachmentTextures(){if(this.props.colorAttachments.length===0&&!this.props.depthStencilAttachment)throw new Error("Framebuffer has noattachments");this.colorAttachments=this.props.colorAttachments.map((n,s)=>{if(typeof n=="string"){const r=this.createColorTexture(n,s);return this.attachResource(r),r.view}return n instanceof Q?n.view:n});const i=this.props.depthStencilAttachment;if(i)if(typeof i=="string"){const n=this.createDepthStencilTexture(i);this.attachResource(n),this.depthStencilAttachment=n.view}else i instanceof Q?this.depthStencilAttachment=i.view:this.depthStencilAttachment=i}createColorTexture(i,n){return this.device.createTexture({id:`${this.id}-color-attachment-${n}`,usage:Q.RENDER_ATTACHMENT,format:i,width:this.width,height:this.height,sampler:{magFilter:"linear",minFilter:"linear"}})}createDepthStencilTexture(i){return this.device.createTexture({id:`${this.id}-depth-stencil-attachment`,usage:Q.RENDER_ATTACHMENT,format:i,width:this.width,height:this.height})}resizeAttachments(i,n){if(this.colorAttachments.forEach((s,r)=>{const o=s.texture.clone({width:i,height:n});this.destroyAttachedResource(s),this.colorAttachments[r]=o.view,this.attachResource(o.view)}),this.depthStencilAttachment){const s=this.depthStencilAttachment.texture.clone({width:i,height:n});this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=s.view,this.attachResource(s)}this.updateAttachments()}};g(Ps,"defaultProps",{...H.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null});let ls=Ps;const Rs=class Rs extends H{constructor(i,n){super(i,n,Rs.defaultProps);g(this,"shaderLayout");g(this,"bufferLayout");g(this,"linkStatus","pending");g(this,"hash","");g(this,"sharedRenderPipeline",null);this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[],this.sharedRenderPipeline=this.props._sharedRenderPipeline||null}get[Symbol.toStringTag](){return"RenderPipeline"}get isPending(){var i;return this.linkStatus==="pending"||this.vs.compilationStatus==="pending"||((i=this.fs)==null?void 0:i.compilationStatus)==="pending"}get isErrored(){var i;return this.linkStatus==="error"||this.vs.compilationStatus==="error"||((i=this.fs)==null?void 0:i.compilationStatus)==="error"}};g(Rs,"defaultProps",{...H.defaultProps,vs:null,vertexEntryPoint:"vertexMain",vsConstants:{},fs:null,fragmentEntryPoint:"fragmentMain",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",colorAttachmentFormats:void 0,depthStencilAttachmentFormat:void 0,parameters:{},varyings:void 0,bufferMode:void 0,disableWarnings:!1,_sharedRenderPipeline:void 0,bindings:void 0,bindGroups:void 0});let at=Rs;class pv extends H{get[Symbol.toStringTag](){return"SharedRenderPipeline"}constructor(e,i){super(e,i,{...H.defaultProps,handle:void 0,vs:void 0,fs:void 0,varyings:void 0,bufferMode:void 0})}}const Cs=class Cs extends H{constructor(i,n){super(i,n,Cs.defaultProps);g(this,"hash","");g(this,"shaderLayout");this.shaderLayout=n.shaderLayout}get[Symbol.toStringTag](){return"ComputePipeline"}};g(Cs,"defaultProps",{...H.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0});let fs=Cs;const Ms=class Ms{constructor(e){g(this,"device");g(this,"_hashCounter",0);g(this,"_hashes",{});g(this,"_renderPipelineCache",{});g(this,"_computePipelineCache",{});g(this,"_sharedRenderPipelineCache",{});this.device=e}static getDefaultPipelineFactory(e){const i=e.getModuleData("@luma.gl/core");return i.defaultPipelineFactory||(i.defaultPipelineFactory=new Ms(e)),i.defaultPipelineFactory}get[Symbol.toStringTag](){return"PipelineFactory"}toString(){return`PipelineFactory(${this.device.id})`}createRenderPipeline(e){var o;if(!this.device.props._cachePipelines)return this.device.createRenderPipeline(e);const i={...at.defaultProps,...e},n=this._renderPipelineCache,s=this._hashRenderPipeline(i);let r=(o=n[s])==null?void 0:o.resource;if(r)n[s].useCount++,this.device.props.debugFactories&&R.log(3,`${this}: ${n[s].resource} reused, count=${n[s].useCount}, (id=${e.id})`)();else{const a=this.device.type==="webgl"&&this.device.props._sharePipelines?this.createSharedRenderPipeline(i):void 0;r=this.device.createRenderPipeline({...i,id:i.id?`${i.id}-cached`:on("unnamed-cached"),_sharedRenderPipeline:a}),r.hash=s,n[s]={resource:r,useCount:1},this.device.props.debugFactories&&R.log(3,`${this}: ${r} created, count=${n[s].useCount}`)()}return r}createComputePipeline(e){var o;if(!this.device.props._cachePipelines)return this.device.createComputePipeline(e);const i={...fs.defaultProps,...e},n=this._computePipelineCache,s=this._hashComputePipeline(i);let r=(o=n[s])==null?void 0:o.resource;return r?(n[s].useCount++,this.device.props.debugFactories&&R.log(3,`${this}: ${n[s].resource} reused, count=${n[s].useCount}, (id=${e.id})`)()):(r=this.device.createComputePipeline({...i,id:i.id?`${i.id}-cached`:void 0}),r.hash=s,n[s]={resource:r,useCount:1},this.device.props.debugFactories&&R.log(3,`${this}: ${r} created, count=${n[s].useCount}`)()),r}release(e){if(!this.device.props._cachePipelines){e.destroy();return}const i=this._getCache(e),n=e.hash;i[n].useCount--,i[n].useCount===0?(this._destroyPipeline(e),this.device.props.debugFactories&&R.log(3,`${this}: ${e} released and destroyed`)()):i[n].useCount<0?(R.error(`${this}: ${e} released, useCount < 0, resetting`)(),i[n].useCount=0):this.device.props.debugFactories&&R.log(3,`${this}: ${e} released, count=${i[n].useCount}`)()}createSharedRenderPipeline(e){const i=this._hashSharedRenderPipeline(e);let n=this._sharedRenderPipelineCache[i];return n||(n={resource:this.device._createSharedRenderPipelineWebGL(e),useCount:0},this._sharedRenderPipelineCache[i]=n),n.useCount++,n.resource}releaseSharedRenderPipeline(e){if(!e.sharedRenderPipeline)return;const i=this._hashSharedRenderPipeline(e.sharedRenderPipeline.props),n=this._sharedRenderPipelineCache[i];n&&(n.useCount--,n.useCount===0&&(n.resource.destroy(),delete this._sharedRenderPipelineCache[i]))}_destroyPipeline(e){const i=this._getCache(e);return this.device.props._destroyPipelines?(delete i[e.hash],e.destroy(),e instanceof at&&this.releaseSharedRenderPipeline(e),!0):!1}_getCache(e){let i;if(e instanceof fs&&(i=this._computePipelineCache),e instanceof at&&(i=this._renderPipelineCache),!i)throw new Error(`${this}`);
853if(!i[e.hash])throw new Error(`${this}: ${e} matched incorrect entry`);return i}_hashComputePipeline(e){const{type:i}=this.device,n=this._getHash(e.shader.source),s=this._getHash(JSON.stringify(e.shaderLayout));return`${i}/C/${n}SL${s}`}_hashRenderPipeline(e){const i=e.vs?this._getHash(e.vs.source):0,n=e.fs?this._getHash(e.fs.source):0,s=this._getWebGLVaryingHash(e),r=this._getHash(JSON.stringify(e.shaderLayout)),o=this._getHash(JSON.stringify(e.bufferLayout)),{type:a}=this.device;switch(a){case"webgl":const c=this._getHash(JSON.stringify(e.parameters));return`${a}/R/${i}/${n}V${s}T${e.topology}P${c}SL${r}BL${o}`;case"webgpu":default:const l=this._getHash(JSON.stringify({vertexEntryPoint:e.vertexEntryPoint,fragmentEntryPoint:e.fragmentEntryPoint})),f=this._getHash(JSON.stringify(e.parameters)),h=this._getWebGPUAttachmentHash(e);return`${a}/R/${i}/${n}V${s}T${e.topology}EP${l}P${f}SL${r}BL${o}A${h}`}}_hashSharedRenderPipeline(e){const i=e.vs?this._getHash(e.vs.source):0,n=e.fs?this._getHash(e.fs.source):0,s=this._getWebGLVaryingHash(e);return`webgl/S/${i}/${n}V${s}`}_getHash(e){return this._hashes[e]===void 0&&(this._hashes[e]=this._hashCounter++),this._hashes[e]}_getWebGLVaryingHash(e){const{varyings:i=[],bufferMode:n=null}=e;return this._getHash(JSON.stringify({varyings:i,bufferMode:n}))}_getWebGPUAttachmentHash(e){var s;const i=e.colorAttachmentFormats??[this.device.preferredColorFormat],n=(s=e.parameters)!=null&&s.depthWriteEnabled?e.depthStencilAttachmentFormat||this.device.preferredDepthF
853ormat:null;return this._getHash(JSON.stringify({colorAttachmentFormats:i,depthStencilAttachmentFormat:n}))}};g(Ms,"defaultProps",{...at.defaultProps});let po=Ms;const Os=class Os{constructor(e){g(this,"device");g(this,"_cache",{});this.device=e}static getDefaultShaderFactory(e){const i=e.getModuleData("@luma.gl/core");return i.defaultShaderFactory||(i.defaultShaderFactory=new Os(e)),i.defaultShaderFactory}get[Symbol.toStringTag](){return"ShaderFactory"}toString(){return`${this[Symbol.toStringTag]}(${this.device.id})`}createShader(e){if(!this.device.props._cacheShaders)return this.device.createShader(e);const i=this._hashShader(e);let n=this._cache[i];if(n)n.useCount++,this.device.props.debugFactories&&R.log(3,`${this}: Reusing shader ${n.resource.id} count=${n.useCount}`)();else{const s=this.device.createShader({...e,id:e.id?`${e.id}-cached`:void 0});this._cache[i]=n={resource:s,useCount:1},this.device.props.debugFactories&&R.log(3,`${this}: Created new shader ${s.id}`)()}return n.resource}release(e){if(!this.device.props._cacheShaders){e.destroy();return}const i=this._hashShader(e),n=this._cache[i];if(n)if(n.useCount--,n.useCount===0)this.device.props._destroyShaders&&(delete this._cache[i],n.resource.destroy(),this.device.props.debugFactories&&R.log(3,`${this}: Releasing shader ${e.id}, destroyed`)());else{if(n.useCount<0)throw new Error(`ShaderFactory: Shader ${e.id} released too many times`);this.device.props.debugFactories&&R.log(3,`${this}: Releasing shader ${e.id} count=${n.useCount}`)()}}_hashShader(e){return`${e.stage}:${e.source}`}};g(Os,"defaultProps",{...cs.defaultProps});let _o=Os;function _v(t,e,i){const n=t.bindings.find(s=>s.name===e||`${s.name.toLocaleLowerCase()}uniforms`===e.toLocaleLowerCase());return n||R.warn(`Binding ${e} not set: Not found in shader layout.`)(),n||null}function Pu(t,e){if(!e)return{};if(mv(e))return Object.fromEntries(Object.entries(e).map(([s,r])=>[Number(s),{...r}]));const i={};for(const[n,s]of Object.entries(e)){const r=_v(t,n),o=(r==null?void 0:r.group)??0;i[o]||(i[o]={}),i[o][n]=s}return i}function el(t){const e={};for(const i of Object.values(t))Object.assign(e,i);return e}function mv(t){const e=Object.keys(t);return e.length>0&&e.every(i=>/^\d+$/.test(i))}const Pe=class Pe extends H{get[Symbol.toStringTag](){return"RenderPass"}constructor(e,i){i=Pe.normalizeProps(e,i),super(e,i,Pe.defaultProps)}static normalizeProps(e,i){return i}};g(Pe,"defaultClearColor",[0,0,0,1]),g(Pe,"defaultClearDepth",1),g(Pe,"defaultClearStencil",0),g(Pe,"defaultProps",{...H.defaultProps,framebuffer:null,parameters:void 0,clearColor:Pe.defaultClearColor,clearColors:void 0,clearDepth:Pe.defaultClearDepth,clearStencil:Pe.defaultClearStencil,depthReadOnly:!1,stencilReadOnly:!1,discard:!1,occlusionQuerySet:void 0,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0});let mo=Pe;const Is=class Is extends H{constructor(i,n){super(i,n,Is.defaultProps);g(this,"_timeProfilingQuerySet",null);g(this,"_timeProfilingSlotCount",0);g(this,"_gpuTimeMs");this._timeProfilingQuerySet=n.timeProfilingQuerySet??null,this._timeProfilingSlotCount=0,this._gpuTimeMs=void 0}get[Symbol.toStringTag](){return"CommandEncoder"}async resolveTimeProfilingQuerySet(){if(this._gpuTimeMs=void 0,!this._timeProfilingQuerySet)return;const i=Math.floor(this._timeProfilingSlotCount/2);if(i<=0)return;const n=i*2,s=await this._timeProfilingQuerySet.readResults({firstQuery:0,queryCount:n});let r=0n;for(let o=0;o<n;o+=2)r+=s[o+1]-s[o];this._gpuTimeMs=Number(r)/1e6}getTimeProfilingSlotCount(){return this._timeProfilingSlotCount}getTimeProfilingQuerySet(){return this._timeProfilingQuerySet}_applyTimeProfilingToPassProps(i){const n=i||{};if(!this._supportsTimestampQueries()||!this._timeProfilingQuerySet||n.timestampQuerySet!==void 0||n.beginTimestampIndex!==void 0||n.endTimestampIndex!==void 0)return n;const s=this._timeProfilingSlotCount;return s+1>=this._timeProfilingQuerySet.props.count?n:(this._timeProfilingSlotCount+=2,{...n,timestampQuerySet:this._timeProfilingQuerySet,beginTimestampIndex:s,endTimestampIndex:s+1})}_supportsTimestampQueries(){return this.device.features.has("timestamp-query")}};g(Is,"defaultProps",{...H.defaultProps,measureExecutionTime:void 0,timeProfilingQuerySet:void 0});let yo=Is;const Ns=class Ns extends H{get[Symbol.toStringTag](){return"CommandBuffer"}constructor(e,i){super(e,i,Ns.defaultProps)}};g(Ns,"defaultProps",{...H.defaultProps});let bo=Ns;function Ta(t){const e=Aa(t),i=Sv[e];
853if(!i)throw new Error(`Unsupported variable shader type: ${t}`);return i}function yv(t){const e=Ru(t),i=wv[e];if(!i)throw new Error(`Unsupported attribute shader type: ${t}`);const[n,s]=i,r=n==="i32"||n==="u32",o=n!=="u32",a=Av[n]*s;return{primitiveType:n,components:s,byteLength:a,integer:r,signed:o}}class bv{getVariableShaderTypeInfo(e){return Ta(e)}getAttributeShaderTypeInfo(e){return yv(e)}makeShaderAttributeType(e,i){return vv(e,i)}resolveAttributeShaderTypeAlias(e){return Ru(e)}resolveVariableShaderTypeAlias(e){return Aa(e)}}function vv(t,e){return e===1?t:`vec${e}<${t}>`}function Ru(t){return Ev[t]||t}function Aa(t){return xv[t]||t}const Tv=new bv,Av={f32:4,f16:2,i32:4,u32:4},wv={f32:["f32",1],"vec2<f32>":["f32",2],"vec3<f32>":["f32",3],"vec4<f32>":["f32",4],f16:["f16",1],"vec2<f16>":["f16",2],"vec3<f16>":["f16",3],"vec4<f16>":["f16",4],i32:["i32",1],"vec2<i32>":["i32",2],"vec3<i32>":["i32",3],"vec4<i32>":["i32",4],u32:["u32",1],"vec2<u32>":["u32",2],"vec3<u32>":["u32",3],"vec4<u32>":["u32",4]},Sv={f32:{type:"f32",components:1},f16:{type:"f16",components:1},i32:{type:"i32",components:1},u32:{type:"u32",components:1},"vec2<f32>":{type:"f32",components:2},"vec3<f32>":{type:"f32",components:3},"vec4<f32>":{type:"f32",components:4},"vec2<f16>":{type:"f16",components:2},"vec3<f16>":{type:"f16",components:3},"vec4<f16>":{type:"f16",components:4},"vec2<i32>":{type:"i32",components:2},"vec3<i32>":{type:"i32",components:3},"vec4<i32>":{type:"i32",components:4},"vec2<u32>":{type:"u32",components:2},"vec3<u32>":{type:"u32",components:3},"vec4<u32>":{type:"u32",components:4},"mat2x2<f32>":{type:"f32",components:4},"mat2x3<f32>":{type:"f32",components:6},"mat2x4<f32>":{type:"f32",components:8},"mat3x2<f32>":{type:"f32",components:6},"mat3x3<f32>":{type:"f32",components:9},"mat3x4<f32>":{type:"f32",components:12},"mat4x2<f32>":{type:"f32",components:8},"mat4x3<f32>":{type:"f32",components:12},"mat4x4<f32>":{type:"f32",components:16},"mat2x2<f16>":{type:"f16",components:4},"mat2x3<f16>":{type:"f16",components:6},"mat2x4<f16>":{type:"f16",components:8},"mat3x2<f16>":{type:"f16",components:6},"mat3x3<f16>":{type:"f16",components:9},"mat3x4<f16>":{type:"f16",components:12},"mat4x2<f16>":{type:"f16",components:8},"mat4x3<f16>":{type:"f16",components:12},"mat4x4<f16>":{type:"f16",components:16},"mat2x2<i32>":{type:"i32",components:4},"mat2x3<i32>":{type:"i32",components:6},"mat2x4<i32>":{type:"i32",components:8},"mat3x2<i32>":{type:"i32",components:6},"mat3x3<i32>":{type:"i32",components:9},"mat3x4<i32>":{type:"i32",components:12},"mat4x2<i32>":{type:"i32",components:8},"mat4x3<i32>":{type:"i32",components:12},"mat4x4<i32>":{type:"i32",components:16},"mat2x2<u32>":{type:"u32",components:4},"mat2x3<u32>":{type:"u32",components:6},"mat2x4<u32>":{type:"u32",components:8},"mat3x2<u32>":{type:"u32",components:6},"mat3x3<u32>":{type:"u32",components:9},"mat3x4<u32>":{type:"u32",components:12},"mat4x2<u32>":{type:"u32",components:8},"mat4x3<u32>":{type:"u32",components:12},"mat4x4<u32>":{type:"u32",components:16}},Ev={vec2i:"vec2<i32>",vec3i:"vec3<i32>",vec4i:"vec4<i32>",vec2u:"vec2<u32>",vec3u:"vec3<u32>",vec4u:"vec4<u32>",vec2f:"vec2<f32>",vec3f:"vec3<f32>",vec4f:"vec4<f32>",vec2h:"vec2<f16>",vec3h:"vec3<f16>",vec4h:"vec4<f16>"},xv={vec2i:"vec2<i32>",vec3i:"vec3<i32>",vec4i:"vec4<i32>",vec2u:"vec2<u32>",vec3u:"vec3<u32>",vec4u:"vec4<u32>",vec2f:"vec2<f32>",vec3f:"vec3<f32>",vec4f:"vec4<f32>",vec2h:"vec2<f16>",vec3h:"vec3<f16>",vec4h:"vec4<f16>",mat2x2f:"mat2x2<f32>",mat2x3f:"mat2x3<f32>",mat2x4f:"mat2x4<f32>",mat3x2f:"mat3x2<f32>",mat3x3f:"mat3x3<f32>",mat3x4f:"mat3x4<f32>",mat4x2f:"mat4x2<f32>",mat4x3f:"mat4x3<f32>",mat4x4f:"mat4x4<f32>",mat2x2i:"mat2x2<i32>",mat2x3i:"mat2x3<i32>",mat2x4i:"mat2x4<i32>",mat3x2i:"mat3x2<i32>",mat3x3i:"mat3x3<i32>",mat3x4i:"mat3x4<i32>",mat4x2i:"mat4x2<i32>",mat4x3i:"mat4x3<i32>",mat4x4i:"mat4x4<i32>",mat2x2u:"mat2x2<u32>",mat2x3u:"mat2x3<u32>",mat2x4u:"mat2x4<u32>",mat3x2u:"mat3x2<u32>",mat3x3u:"mat3x3<u32>",mat3x4u:"mat3x4<u32>",mat4x2u:"mat4x2<u32>",mat4x3u:"mat4x3<u32>",mat4x4u:"mat4x4<u32>",mat2x2h:"mat2x2<f16>",mat2x3h:"mat2x3<f16>
853",mat2x4h:"mat2x4<f16>",mat3x2h:"mat3x2<f16>",mat3x3h:"mat3x3<f16>",mat3x4h:"mat3x4<f16>",mat4x2h:"mat4x2<f16>",mat4x3h:"mat4x3<f16>",mat4x4h:"mat4x4<f16>"};function Cu(t,e){const i={};for(const n of t.attributes){const s=Rv(t,e,n.name);s&&(i[n.name]=s)}return i}function Pv(t,e,i=16){const n=Cu(t,e),s=new Array(i).fill(null);for(const r of Object.values(n))s[r.location]=r;return s}function Rv(t,e,i){const n=Cv(t,i),s=Mv(e,i);if(!n)return null;const r=Tv.getAttributeShaderTypeInfo(n.type),o=qi.getCompatibleVertexFormat(r),a=(s==null?void 0:s.vertexFormat)||o,c=qi.getVertexFormatInfo(a);return{attributeName:(s==null?void 0:s.attributeName)||n.name,bufferName:(s==null?void 0:s.bufferName)||n.name,location:n.location,shaderType:n.type,primitiveType:r.primitiveType,shaderComponents:r.components,vertexFormat:a,bufferDataType:c.type,bufferComponents:c.components,normalized:c.normalized,integer:r.integer,stepMode:(s==null?void 0:s.stepMode)||n.stepMode||"vertex",byteOffset:(s==null?void 0:s.byteOffset)||0,byteStride:(s==null?void 0:s.byteStride)||0}}function Cv(t,e){const i=t.attributes.find(n=>n.name===e);return i||R.warn(`shader layout attribute "${e}" not present in shader`),i||null}function Mv(t,e){Ov(t);let i=Iv(t,e);return i||(i=Nv(t,e),i)?i:(R.warn(`layout for attribute "${e}" not present in buffer layout`),null)}function Ov(t){for(const e of t)(e.attributes&&e.format||!e.attributes&&!e.format)&&R.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}function Iv(t,e){for(const i of t)if(i.format&&i.name===e)return{attributeName:i.name,bufferName:e,stepMode:i.stepMode,vertexFormat:i.format,byteOffset:0,byteStride:i.byteStride||0};return null}function Nv(t,e){var i;for(const n of t){let s=n.byteStride;if(typeof n.byteStride!="number")for(const o of n.attributes||[]){const a=qi.getVertexFormatInfo(o.format);s+=a.byteLength}const r=(i=n.attributes)==null?void 0:i.find(o=>o.attribute===e);if(r)return{attributeName:r.attribute,bufferName:n.name,stepMode:n.stepMode,vertexFormat:r.format,byteOffset:r.byteOffset,byteStride:s}}return null}const Ls=class Ls extends H{constructor(i,n){super(i,n,Ls.defaultProps);g(this,"maxVertexAttributes");g(this,"attributeInfos");g(this,"indexBuffer",null);g(this,"attributes");this.maxVertexAttributes=i.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null),this.attributeInfos=Pv(n.shaderLayout,n.bufferLayout,this.maxVertexAttributes)}get[Symbol.toStringTag](){return"VertexArray"}setConstantWebGL(i,n){this.device.reportError(new Error("constant attributes not supported"),this)()}};g(Ls,"defaultProps",{...H.defaultProps,shaderLayout:void 0,bufferLayout:[]});let vo=Ls;const Ds=class Ds extends H{get[Symbol.toStringTag](){return"TransformFeedback"}constructor(e,i){super(e,i,Ds.defaultProps)}};g(Ds,"defaultProps",{...H.defaultProps,layout:void 0,buffers:{}});let To=Ds;const Bs=class Bs extends H{get[Symbol.toStringTag](){return"QuerySet"}constructor(e,i){super(e,i,Bs.defaultProps)}};g(Bs,"defaultProps",{...H.defaultProps,type:void 0,count:void 0});let Ao=Bs;const Fs=class Fs extends H{get[Symbol.toStringTag](){return"Fence"}constructor(e,i={}){super(e,i,Fs.defaultProps)}};g(Fs,"defaultProps",{...H.defaultProps});let wo=Fs;function Ke(t,e){switch(e){case 1:return t;case 2:return t+t%2;default:return t+(4-t%4)%4}}function Mu(t){const[,,,,e]=Lv[t];return e}const Lv={uint8:["uint8","u32",1,!1,Uint8Array],sint8:["sint8","i32",1,!1,Int8Array],unorm8:["uint8","f32",1,!0,Uint8Array],snorm8:["sint8","f32",1,!0,Int8Array],uint16:["uint16","u32",2,!1,Uint16Array],sint16:["sint16","i32",2,!1,Int16Array],unorm16:["uint16","u32",2,!0,Uint16Array],snorm16:["sint16","i32",2,!0,Int16Array],float16:["float16","f16",2,!1,Uint16Array],float32:["float32","f32",4,!1,Float32Array],uint32:["uint32","u32",4,!1,Uint32Array],sint32:["sint32","i32",4,!1,Int32Array]};function Dv(t,e={}){const i={...t},n=e.layout??"std140",s={};let r=0;for(const[o,a]of Object.entries(i))r=So(s,o,a,r,n);return r=Ke(r,dt(i,n)),{layout:n,byteLength:r*4,uniformTypes:i,fields:s}}function js(t,e){const i=Aa(t),n=Ta(i),s=/^mat(\d)x(\d)<.+>$/.exec(i);if(s){const o=Number(s[1]),a=Number(s[2]),c=tl(a,i,n.type),l=Fv(c.size,c.alignment,e);return{alignment:c.alignment,size:o*l,components:o*a,columns:o,rows:a,columnStride:l,shaderType:i,type:n.type}}const r=/^vec(\d)<.+>$/.exec(i);return r?tl(Number(r[1]),i,n.type):{alignment:1,size:1,components:1,columns:1,rows:1,columnStride:1,shaderType:i,type:n.type}}function Ou(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function So(t,e,i,n,s){if(typeof i=="string"){const r=js(i,s),o=Ke(n,r.alignment);return t[e]={offset:o,...r},o+r.size}if(Array.isArray(i)){if(Array.isArray(i[0]))throw new Error(`Nested arrays are not supported for ${e}`);const r=i[0],o=i[1],a=Nu(r,s),c=Ke(n,dt(i,s));for(let l=0;l<o;l++)So(t,`${e}[${l}]`,r,c+l*a,s);return c+a*o}if(Ou(i)){const r=dt(i,s);let o=Ke(n,r);for(const[a,c]of Object.entries(i))o=So(t,`${e}.${a}`,c,o,s);return Ke(o,r)}throw new Error(`Unsupported CompositeShaderType for ${e}`)}function Iu(t,e){if(typeof t=="string")return js(t,e).size;if(Array.isArray(t)){const n=t[0],s=t[1];if(Array.isArray(n))throw new Error("Nested arrays are not supported");return Nu(n,e)*s}let i=0;for(const n of Object.values(t)){const s=n;i=Ke(i,dt(s,e)),i+=Iu(s,e)}return Ke(i,dt(t,e))}function dt(t,e){if(typeof t=="string")return js(t,e).alignment;if(Array.isArray(t)){const n=t[0],s=dt(n,e);return Lu(e)?Math.max(s,4):s}let i=1;for(const n of Object.values(t)){const s=dt(n,e);i=Math.max(i,s)}return kv(e)?Math.max(i,4):i}function tl(t,e,i,n){return{alignment:t===2?2:4,size:t===3?3:t,components:t,columns:1,rows:t,columnStride:t===3?3:t,shaderType:e,type:i}}function Nu(t,e){const i=Iu(t,e),n=dt(t,e);return Bv(i,n,e)}function Bv(t,e,i){return Ke(t,Lu(i)?4:e)}function Fv(t,e,i){return i==="std140"?4:Ke(t,e)}function Lu(t){return t==="std140"||t==="wgsl-uniform"}function kv(t){return t==="std140"||t==="wgsl-uniform"}let wn;function Du(t){return(!wn||wn.byteLength<t)&&(wn=new ArrayBuffer(t)),wn}function Uv(t,e){const i=Du(t.BYTES_PER_ELEMENT*e);return new t(i,0,e)}function zv(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function hs(t){return Array.isArray(t)?t.length===0||typeof t[0]=="number":zv(t)}class Wv{constructor(e){g(this,"layout");this.layout=e}has(e){return!!this.layout.fields[e]}get(e){const i=this.layout.fields[e];return i?{offset:i.offset,size:i.size}:void 0}getFlatUniformValues(e){const i={};for(const[n,s]of Object.entries(e)){const r=this.layout.uniformTypes[n];r?this._flattenCompositeValue(i,n,r,s):this.layout.fields[n]&&(i[n]=s)}return i}getData(e){const i=Du(this.layout.byteLength);new Uint8Array(i,0,this.layout.byteLength).fill(0);const n={i32:new Int32Array(i),u32:new Uint32Array(i),f32:new Float32Array(i),f16:new Uint16Array(i)},s=this.getFlatUniformValues(e);for(const[r,o]of Object.entries(s))this._writeLeafValue(n,r,o);return new Uint8Array(i,0,this.layout.byteLength)}_flattenCompositeValue(e,i,n,s){if(s!==void 0){if(typeof n=="string"||this.layout.fields[i]){e[i]=s;return}if(Array.isArray(n)){const r=n[0],o=n[1];if(Array.isArray(r))throw new Error(`Nested arrays are not supported for ${i}`);if(typeof r=="string"&&hs(s)){this._flattenPackedArray(e,i,r,o,s);return}if(!Array.isArray(s)){R.warn(`Unsupported uniform array value for ${i}:`,s)();return}for(let a=0;a<Math.min(s.length,o);a++){const c=s[a];c!==void 0&&this._flattenCompositeValue(e,`${i}[${a}]`,r,c)}return}if(Ou(n)&&Vv(s)){for(const[r,o]of Object.entries(s)){if(o===void 0)continue;const a=`${i}.${r}`;this._flattenCompositeValue(e,a,n[r],o)}return}R.warn(`Unsupported uniform value for ${i}:`,s)()}}_flattenPackedArray(e,i,n,s,r){const o=r,c=js(n,this.layout.layout).components;for(let l=0;l<s;l++){const f=l*c;if(f>=o.length)break;c===1?e[`${i}[${l}]`]=Number(o[f]):e[`${i}[${l}]`]=$v(r,f,f+c)}}_writeLeafValue(e,i,n){const s=this.layout.fields[i];if(!s){R.warn(`Uniform ${i} not found in layout`)();return}const{type:r,components:o,columns:a,rows:c,offset:l,columnStride:f}=s,h=e[r];if(o===1){h[l]=Number(n);return}const u=n;if(a===1){for(let p=0;p<o;p++)h[l+p]=Number(u[p]??0);return}let d=0;for(let p=0;p<a;p++){const _=l+p*f;for(let m=0;m<c;m++)h[_+m]=Number(u[d++]??0)}}}function Vv(t){return!!t&&typeof t=="object"&&!Array.isArray(t)&&!ArrayBuffer.isView(t)}function $v(t,e,i){return Array.prototype.slice.call(t,e,i)}const jv=128;function Hv(t,e,i=16){if(t===e)return!0;const n=t,s=e;if(!hs(n)||!hs(s)||n.length!==s.length)return!1;const r=Math.min(i,jv);if(n.length>r)return!1;for(let o=0;o<n.length;++o)if(s[o]!==n[o])return!1;return!0}function Xv(t){return hs(t)?t.slice():t}class Yv{constructor(e){g(this,"name");g(this,"uniforms",{});g(this,"modifiedUniforms",{});g(this,"modified",!0);g(this,"bindingLayout",{});g(this,"needsRedraw","initialized");var i;if(this.name=(e==null?void 0:e.name)||"unnamed",e!=null&&e.name&&(e!=null&&e.shaderLayout)){const n=(i=e==null?void 0:e.shaderLayout.bindings)==null?void 0:i.find(r=>r.type==="uniform"&&r.name===(e==null?void 0:e.name));if(!n)throw new Error(e==null?void 0:e.name);const s=n;for(const r of s.uniforms||[])this.bindingLayout[r.name]=r}}setUniforms(e){for(const[i,n]of Object.entries(e))this._setUniform(i,n),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${i}=${n}`)}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}
853_setUniform(e,i){Hv(this.uniforms[e],i)||(this.uniforms[e]=Xv(i),this.modifiedUniforms[e]=!0,this.modified=!0)}}const Kv=1024;class qv{constructor(e,i){g(this,"device");g(this,"uniformBlocks",new Map);g(this,"shaderBlockLayouts",new Map);g(this,"shaderBlockWriters",new Map);g(this,"uniformBuffers",new Map);this.device=e;for(const[n,s]of Object.entries(i)){const r=n,o=Dv(s.uniformTypes??{},{layout:s.layout??Zv(e)}),a=new Wv(o);this.shaderBlockLayouts.set(r,o),this.shaderBlockWriters.set(r,a);const c=new Yv({name:n});c.setUniforms(a.getFlatUniformValues(s.defaultUniforms||{})),this.uniformBlocks.set(r,c)}}destroy(){for(const e of this.uniformBuffers.values())e.destroy()}setUniforms(e){var i;for(const[n,s]of Object.entries(e)){const r=n,o=this.shaderBlockWriters.get(r),a=o==null?void 0:o.getFlatUniformValues(s||{});(i=this.uniformBlocks.get(r))==null||i.setUniforms(a||{})}this.updateUniformBuffers()}getUniformBufferByteLength(e){var n;const i=((n=this.shaderBlockLayouts.get(e))==null?void 0:n.byteLength)||0;return Math.max(i,Kv)}getUniformBufferData(e){var s;const i=((s=this.uniformBlocks.get(e))==null?void 0:s.getAllUniforms())||{},n=this.shaderBlockWriters.get(e);return(n==null?void 0:n.getData(i))||new Uint8Array(0)}createUniformBuffer(e,i){i&&this.setUniforms(i);const n=this.getUniformBufferByteLength(e),s=this.device.createBuffer({usage:Z.UNIFORM|Z.COPY_DST,byteLength:n}),r=this.getUniformBufferData(e);return s.write(r),s}getManagedUniformBuffer(e){if(!this.uniformBuffers.get(e)){const i=this.getUniformBufferByteLength(e),n=this.device.createBuffer({usage:Z.UNIFORM|Z.COPY_DST,byteLength:i});this.uniformBuffers.set(e,n)}return this.uniformBuffers.get(e)}updateUniformBuffers(){let e=!1;for(const i of this.uniformBlocks.keys()){const n=this.updateUniformBuffer(i);e||(e=n)}return e&&R.log(3,`UniformStore.updateUniformBuffers(): ${e}`)(),e}updateUniformBuffer(e){var r;const i=this.uniformBlocks.get(e);let n=this.uniformBuffers.get(e),s=!1;if(n&&(i!=null&&i.needsRedraw)){s||(s=i.needsRedraw);const o=this.getUniformBufferData(e);n=this.uniformBuffers.get(e),n==null||n.write(o);const a=(r=this.uniformBlocks.get(e))==null?void 0:r.getAllUniforms();R.log(4,`Writing to uniform buffer ${String(e)}`,o,a)()}return s}}function Zv(t){return t.type==="webgpu"?"wgsl-uniform":"std140"}const il=`precision highp int; 854 855// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX)) 856struct AmbientLight { 857 vec3 color; 858}; 859 860struct PointLight { 861 vec3 color; 862 vec3 position; 863 vec3 attenuation; // 2nd order x:Constant-y:Linear-z:Exponential 864}; 865 866struct SpotLight { 867 vec3 color; 868 vec3 position; 869 vec3 direction; 870 vec3 attenuation; 871 vec2 coneCos; 872}; 873 874struct DirectionalLight { 875 vec3 color; 876 vec3 direction; 877}; 878 879struct UniformLight { 880 vec3 color; 881 vec3 position; 882 vec3 direction; 883 vec3 attenuation; 884 vec2 coneCos; 885}; 886 887layout(std140) uniform lightingUniforms { 888 int enabled; 889 int directionalLightCount; 890 int pointLightCount; 891 int spotLightCount; 892 vec3 ambientColor; 893 UniformLight lights[5]; 894} lighting; 895 896PointLight lighting_getPointLight(int index) { 897 UniformLight light = lighting.lights[index]; 898 return PointLight(light.color, light.position, light.attenuation); 899} 900 901SpotLight lighting_getSpotLight(int index) { 902 UniformLight light = lighting.lights[lighting.pointLightCount + index]; 903 return SpotLight(light.color, light.position, light.direction, light.attenuation, light.coneCos); 904} 905 906DirectionalLight lighting_getDirectionalLight(int index) { 907 UniformLight light = 908 lighting.lights[lighting.pointLightCount + lighting.spotLightCount + index]; 909 return DirectionalLight(light.color, light.direction); 910} 911 912float getPointLightAttenuation(PointLight pointLight, float distance) { 913 return pointLight.attenuation.x 914 + pointLight.attenuation.y * distance 915 + pointLight.attenuation.z * distance * distance; 916} 917 918float getSpotLightAttenuation(SpotLight spotLight, vec3 positionWorldspace) { 919 vec3 light_direction = normalize(positionWorldspace - spotLight.position); 920 float coneFactor = smoothstep( 921 spotLight.coneCos.y, 922 spotLight.coneCos.x, 923 dot(normalize(spotLight.direction), light_direction) 924 ); 925 float distanceAttenuation = getPointLightAttenuation( 926 PointLight(spotLight.color, spotLight.position, spotLight.attenuation), 927 distance(spotLight.position, positionWorldspace) 928 ); 929 return distanceAttenuation / max(coneFactor, 0.0001); 930} 931 932// #endif 933`,Gv=`// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX)) 934const MAX_LIGHTS: i32 = 5; 935 936struct AmbientLight { 937 color: vec3<f32>, 938}; 939 940struct PointLight { 941 color: vec3<f32>, 942 position: vec3<f32>, 943 attenuation: vec3<f32>, // 2nd order x:Constant-y:Linear-z:Exponential 944}; 945 946struct SpotLight { 947 color: vec3<f32>, 948 position: vec3<f32>, 949 direction: vec3<f32>, 950 attenuation: vec3<f32>, 951 coneCos: vec2<f32>, 952}; 953 954struct DirectionalLight { 955 color: vec3<f32>, 956 direction: vec3<f32>, 957}; 958 959struct UniformLight { 960 color: vec3<f32>, 961 position: vec3<f32>, 962 direction: vec3<f32>, 963 attenuation: vec3<f32>, 964 coneCos: vec2<f32>, 965}; 966 967struct lightingUniforms { 968 enabled: i32, 969 directionalLightCount: i32, 970 pointLightCount: i32, 971 spotLightCount: i32, 972 ambientColor: vec3<f32>, 973 lights: array<UniformLight, 5>, 974}; 975 976@group(2) @binding(auto) var<uniform> lighting : lightingUniforms; 977 978fn lighting_getPointLight(index: i32) -> PointLight { 979 let light = lighting.lights[index]; 980 return PointLight(light.color, light.position, light.attenuation); 981} 982 983fn lighting_getSpotLight(index: i32) -> SpotLight { 984 let light = lighting.lights[lighting.pointLightCount + index]; 985 return SpotLight(light.color, light.position, light.direction, light.attenuation, light.coneCos); 986} 987 988fn lighting_getDirectionalLight(index: i32) -> DirectionalLight { 989 let light = lighting.lights[lighting.pointLightCount + lighting.spotLightCount + index]; 990 return DirectionalLight(light.color, light.direction); 991} 992 993fn getPointLightAttenuation(pointLight: PointLight, distance: f32) -> f32 { 994 return pointLight.attenuation.x
995 + pointLight.attenuation.y * distance 996 + pointLight.attenuation.z * distance * distance; 997} 998 999fn getSpotLightAttenuation(spotLight: SpotLight, positionWorldspace: vec3<f32>) -> f32 { 1000 let lightDirection = normalize(positionWorldspace - spotLight.position); 1001 let coneFactor = smoothstep( 1002 spotLight.coneCos.y, 1003 spotLight.coneCos.x, 1004 dot(normalize(spotLight.direction), lightDirection) 1005 ); 1006 let distanceAttenuation = getPointLightAttenuation( 1007 PointLight(spotLight.color, spotLight.position, spotLight.attenuation), 1008 distance(spotLight.position, positionWorldspace) 1009 ); 1010 return distanceAttenuation / max(coneFactor, 0.0001); 1011} 1012`,yt=5,Qv={color:"vec3<f32>",position:"vec3<f32>",direction:"vec3<f32>",attenuation:"vec3<f32>",coneCos:"vec2<f32>"},Jv={props:{},uniforms:{},name:"lighting",defines:{},uniformTypes:{enabled:"i32",directionalLightCount:"i32",pointLightCount:"i32",spotLightCount:"i32",ambientColor:"vec3<f32>",lights:[Qv,yt]},defaultUniforms:$n(),bindingLayout:[{name:"lighting",group:2}],firstBindingSlot:0,source:Gv,vs:il,fs:il,getUniforms:eT};function eT(t,e={}){if(t=t&&{...t},!t)return $n();t.lights&&(t={...t,...iT(t.lights),lights:void 0});const{useByteColors:i,ambientLight:n,pointLights:s,spotLights:r,directionalLights:o}=t||{};if(!(n||s&&s.length>0||r&&r.length>0||o&&o.length>0))return{...$n(),enabled:0};const c={...$n(),...tT({useByteColors:i,ambientLight:n,pointLights:s,spotLights:r,directionalLights:o})};return t.enabled!==void 0&&(c.enabled=t.enabled?1:0),c}function tT({useByteColors:t,ambientLight:e,pointLights:i=[],spotLights:n=[],directionalLights:s=[]}){const r=Bu();let o=0,a=0,c=0,l=0;for(const f of i){if(o>=yt)break;r[o]={...r[o],color:Sn(f,t),position:f.position,attenuation:f.attenuation||[1,0,0]},o++,a++}for(const f of n){if(o>=yt)break;r[o]={...r[o],color:Sn(f,t),position:f.position,direction:f.direction,attenuation:f.attenuation||[1,0,0],coneCos:sT(f)},o++,c++}for(const f of s){if(o>=yt)break;r[o]={...r[o],color:Sn(f,t),direction:f.direction},o++,l++}return i.length+n.length+s.length>yt&&R.warn(`MAX_LIGHTS exceeded, truncating to ${yt}`)(),{ambientColor:Sn(e,t),directionalLightCount:l,pointLightCount:a,spotLightCount:c,lights:r}}function iT(t){var i,n,s;const e={pointLights:[],spotLights:[],directionalLights:[]};for(const r of t||[])switch(r.type){case"ambient":e.ambientLight=r;break;case"directional":(i=e.directionalLights)==null||i.push(r);break;case"point":(n=e.pointLights)==null||n.push(r);break;case"spot":(s=e.spotLights)==null||s.push(r);break}return e}function Sn(t={},e){const{color:i=[0,0,0],intensity:n=1}=t;return yu(i,mu(e,!0)).map(r=>r*n)}function $n(){return{enabled:1,directionalLightCount:0,pointLightCount:0,spotLightCount:0,ambientColor:[.1,.1,.1],lights:Bu()}}function Bu(){return Array.from({length:yt},()=>nT())}function nT(){return{color:[1,1,1],position:[1,1,2],direction:[1,1,1],attenuation:[1,0,0],coneCos:[1,0]}}function sT(t){const e=t.innerConeAngle??0,i=t.outerConeAngle??Math.PI/4;return[Math.cos(e),Math.cos(i)]}const rT=`layout(std140) uniform phongMaterialUniforms { 1013 uniform bool unlit; 1014 uniform float ambient; 1015 uniform float diffuse; 1016 uniform float shininess; 1017 uniform vec3 specularColor; 1018} material; 1019`,oT=`layout(std140) uniform phongMaterialUniforms { 1020 uniform bool unlit; 1021 uniform float ambient; 1022 uniform float diffuse; 1023 uniform float shininess; 1024 uniform vec3 specularColor; 1025} material; 1026 1027vec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_direction, vec3 normal_worldspace, vec3 color) { 1028 vec3 halfway_direction = normalize(light_direction + view_direction); 1029 float lambertian = dot(light_direction, normal_worldspace); 1030 float specular = 0.0; 1031 if (lambertian > 0.0) { 1032 float specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0); 1033 specular = pow(specular_angle, material.shininess); 1034 } 1035 lambertian = max(lambertian, 0.0); 1036 return (lambertian * material.diffuse * surfaceColor + specular * floatColors_normalize(material.specularColor)) * color; 1037} 1038 1039vec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) { 1040 vec3 lightColor = surfaceColor; 1041 1042 if (material.unlit) { 1043 return surfaceColor; 1044 } 1045 1046 if (lighting.enabled == 0) { 1047 return lightColor; 1048 } 1049 1050 vec3 view_direction = normalize(cameraPosition - position_worldspace); 1051 lightColor = material.ambient * surfaceColor * lighting.ambientColor; 1052 1053 for (int i = 0; i < lighting.pointLightCount; i++) { 1054 PointLight pointLight = lighting_getPointLight(i); 1055 vec3 light_position_worldspace = pointLight.position; 1056 vec3 light_direction = normalize(light_position_worldspace - position_worldspace); 1057 float light_attenuation = getPointLightAttenuation(pointLight, distance(light_position_worldspace, position_worldspace)); 1058 lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color / light_attenuation); 1059 } 1060 1061 for (int i = 0; i < lighting.spotLightCount; i++) { 1062 SpotLight spotLight = lighting_getSpotLight(i); 1063 vec3 light_position_worldspace = spotLight.position; 1064 vec3 light_direction = normalize(light_position_worldspace - position_worldspace); 1065 float light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace); 1066 lightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, spotLight.color / light_attenuation); 1067 } 1068 1069 for (int i = 0; i < lighting.directionalLightCount; i++) { 1070 DirectionalLight directionalLight = lighting_getDirectionalLight(i); 1071 lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color); 1072 } 1073 1074 return lightColor; 1075} 1076`,aT=`struct phongMaterialUniforms { 1077 unlit: u32, 1078 ambient: f32, 1079 diffuse: f32, 1080 shininess: f32, 1081 specularColor: vec3<f32>, 1082}; 1083 1084@group(3) @binding(auto) var<uniform> phongMaterial : phongMaterialUniforms; 1085 1086fn lighting_getLightColor(surfaceColor: vec3<f32>, light_direction: vec3<f32>, view_direction: vec3<f32>, normal_worldspace: vec3<f32>, color: vec3<f32>) -> vec3<f32> { 1087 let halfway_direction: vec3<f32> = normalize(light_direction + view_direction); 1088 var lambertian: f32 = dot(light_direction, normal_worldspace); 1089 var specular: f32 = 0.0; 1090 if (lambertian > 0.0) { 1091 let specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0); 1092 specular = pow(specular_angle, phongMaterial.shininess); 1093 } 1094 lambertian = max(lambertian, 0.0); 1095 return ( 1096 lambertian * phongMaterial.diffuse * surfaceColor + 1097 specular * floatColors_normalize(phongMaterial.specularColor) 1098 ) * color; 1099} 1100 1101fn lighting_getLightColor2(surfaceColor: vec3<f32>, cameraPosition: vec3<f32>, position_worldspace: vec3<f32>, normal_worldspace: vec3<f32>) -> vec3<f32> { 1102 var lightColor: vec3<f32> = surfaceColor; 1103 1104 if (phongMaterial.unlit != 0u) { 1105 return surfaceColor; 1106 } 1107 1108 if (lighting.enabled == 0) { 1109 return lightColor; 1110 } 1111 1112 let view_direction: vec3<f32> = normalize(cameraPosition - position_worldspace); 1113 lightColor = phongMaterial.ambient * surfaceColor * lighting.ambientColor; 1114 1115 for (var i: i32 = 0; i < lighting.pointLightCount; i++) { 1116 let pointLight: PointLight = lighting_getPointLight(i); 1117 let light_position_worldspace: vec3<f32> = pointLight.position; 1118 let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace); 1119 let light_attenuation = getPointLightAttenuation( 1120 pointLight, 1121 distance(light_position_worldspace, position_worldspace) 1122 ); 1123 lightColor += lighting_getLightColor( 1124 surfaceColor, 1125 light_direction, 1126 view_direction, 1127 normal_worldspace, 1128 pointLight.color / light_attenuation 1129 ); 1130 } 1131 1132 for (var i: i32 = 0; i < lighting.spotLightCount; i++) { 1133 let spotLight: SpotLight = lighting_getSpotLight(i); 1134 let light_position_worldspace: vec3<f32> = spotLight.position; 1135 let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace); 1136 let light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace); 1137 lightColor += lighting_getLightColor( 1138 surfaceColor, 1139 light_direction, 1140 view_direction, 1141 normal_worldspace, 1142 spotLight.color / light_attenuation 1143 ); 1144 } 1145 1146 for (var i: i32 = 0; i < lighting.directionalLightCount; i++) { 1147 let directionalLight: DirectionalLight = lighting_getDirectionalLight(i); 1148 lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color); 1149 } 1150 1151 return lightColor; 1152} 1153 1154fn lighting_getSpecularLightColor(cameraPosition: vec3<f32>, position_worldspace: vec3<f32>, normal_worldspace: vec3<f32>) -> vec3<f32>{ 1155 var lightColor = vec3<f32>(0, 0, 0); 1156 let surfaceColor = vec3<f32>(0, 0, 0); 1157 1158 if (lighting.enabled != 0) { 1159 let view_direction = normalize(cameraPosition - position_worldspace); 1160 1161 for (var i: i32 = 0; i < lighting.pointLightCount; i++) { 1162 let pointLight: PointLight = lighting_getPointLight(i); 1163 let light_position_worldspace: vec3<f32> = pointLight.position; 1164 let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace); 1165 let light_attenuation = getPointLightAttenuation( 1166 pointLight, 1167 distance(light_position_worldspace, position_worldspace) 1168 ); 1169 lightColor += lighting_getLightColor( 1170 surfaceColor, 1171 light_direction, 1172 view_direction, 1173 normal_worldspace, 1174 pointLight.color / light_attenuation 1175 ); 1176 } 1177 1178 for (var i: i32 = 0; i < lighting.spotLightCount; i++) { 1179 let spotLight: SpotLight = lighting_getSpotLight(i); 1180 let light_position_worldspace: vec3<f32> = spotLight.position; 1181 let light_direction: vec3<f32> = normalize(light_position_worldspace - position_worldspace); 1182 let light_attenuation = getSpotLightAttenuation(spotLight, position_worldspace); 1183 lightColor += lighting_getLightColor( 1184 surfaceColor, 1185 light_direction, 1186 view_direction, 1187 normal_worldspace, 1188 spotLight.color / light_attenuation 1189 ); 1190 } 1191 1192 for (var i: i32 = 0; i < lighting.directionalLightCount; i++) { 1193 let directionalLight: DirectionalLight = lighting_getDirectionalLight(i); 1194 lightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color); 1195 } 1196 } 1197 return lightColor; 1198} 1199`,cT=[38.25,38.25,38.25],Fu={props:{},name:"gouraudMaterial",bindingLayout:[{name:"gouraudMaterial",group:3}],vs:oT.replace("phongMaterial","gouraudMaterial"),fs:rT.replace("phongMaterial","gouraudMaterial"),source:aT.replaceAll("phongMaterial","gouraudMaterial"),defines:{LIGHTING_VERTEX:!0},dependencies:[Jv,o0],uniformTypes:{unlit:"i32",ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3<f32>"},defaultUniforms:{unlit:!1,ambient:.35,diffuse:.6,shininess:32,specularColor:cT},getUniforms(t){return{...Fu.defaultUniforms,...t}}},lT=`struct LayerUniforms { 1200 opacity: f32, 1201}; 1202 1203@group(0) @binding(auto) 1204var<uniform> layer: LayerUniforms; 1205`,nl=`layout(std140) uniform layerUniforms { 1206 uniform float opacity; 1207} layer; 1208`,fT={name:"layer",source:lT,vs:nl,fs:nl,getUniforms:t=>({opacity:Math.pow(t.opacity,1/2.2)}),uniformTypes:{opacity:"f32"}},hT=` 1209 1210@must_use 1211fn deckgl_premultiplied_alpha(fragColor: vec4<f32>) -> vec4<f32> { 1212 return vec4(fragColor.rgb * fragColor.a, fragColor.a); 1213}; 1214`,wa={name:"color",dependencies:[],source:hT,getUniforms:t=>({})},uT=`const SMOOTH_EDGE_RADIUS: f32 = 0.5; 1215 1216struct VertexGeometry { 1217 position: vec4<f32>, 1218 worldPosition: vec3<f32>, 1219 worldPositionAlt: vec3<f32>, 1220 normal: vec3<f32>, 1221 uv: vec2<f32>, 1222 pickingColor: vec3<f32>, 1223}; 1224 1225var<private> geometry_: VertexGeometry = VertexGeometry( 1226 vec4<f32>(0.0, 0.0, 1.0, 0.0), 1227 vec3<f32>(0.0, 0.0, 0.0), 1228 vec3<f32>(0.0, 0.0, 0.0), 1229 vec3<f32>(0.0, 0.0, 0.0), 1230 vec2<f32>(0.0, 0.0), 1231 vec3<f32>(0.0, 0.0, 0.0) 1232); 1233 1234struct FragmentGeometry { 1235 uv: vec2<f32>, 1236}; 1237 1238var<private> fragmentGeometry: FragmentGeometry; 1239 1240fn smoothedge(edge: f32, x: f32) -> f32 { 1241 return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x); 1242} 1243`,ku="#define SMOOTH_EDGE_RADIUS 0.5",dT=`${ku} 1244 1245struct VertexGeometry { 1246 vec4 position; 1247 vec3 worldPosition; 1248 vec3 worldPositionAlt; 1249 vec3 normal; 1250 vec2 uv; 1251 vec3 pickingColor; 1252} geometry = VertexGeometry( 1253 vec4(0.0, 0.0, 1.0, 0.0), 1254 vec3(0.0), 1255 vec3(0.0), 1256 vec3(0.0), 1257 vec2(0.0), 1258 vec3(0.0) 1259); 1260`,gT=`${ku} 1261 1262struct FragmentGeometry { 1263 vec2 uv; 1264} geometry; 1265 1266float smoothedge(float edge, float x) { 1267 return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x); 1268} 1269`,Uu={name:"geometry",source:uT,vs:dT,fs:gT},pT=25;var ce;(function(t){t[t.Start=1]="Start",t[t.Move=2]="Move",t[t.End=4]="End",t[t.Cancel=8]="Cancel"})(ce||(ce={}));var le;(function(t){t[t.None=0]="None",t[t.Left=1]="Left",t[t.Right=2]="Right",t[t.Up=4]="Up",t[t.Down=8]="Down",t[t.Horizontal=3]="Horizontal",t[t.Vertical=12]="Vertical",t[t.All=15]="All"})(le||(le={}));var $;(function(t){t[t.Possible=1]="Possible",t[t.Began=2]="Began",t[t.Changed=4]="Changed",t[t.Ended=8]="Ended",t[t.Recognized=8]="Recognized",t[t.Cancelled=16]="Cancelled",t[t.Failed=32]="Failed"})($||($={}));const _T="compute",mT="auto",Eo="manipulation",jn="none",xo="pan-x",Po="pan-y";function yT(t){if(t.includes(jn))return jn;const e=t.includes(xo),i=t.includes(Po);return e&&i?jn:e||i?e?xo:Po:t.includes(Eo)?Eo:mT}class bT{constructor(e,i){this.actions="",this.manager=e,this.set(i)}set(e){e===_T&&(e=this.compute()),this.manager.element&&(this.manager.element.style.touchAction=e,this.actions=e)}update(){this.set(this.manager.options.touchAction)}compute(){let e=[];for(const i of this.manager.recognizers)i.options.enable&&(e=e.concat(i.getTouchAction()));return yT(e.join(" "))}}function us(t){return t.trim().split(/\s+/g)}
vendor: 8,590 bytes, line 1269
1269function wr(t,e,i){if(t)for(const n of us(e))t.addEventListener(n,i,!1)}function Sr(t,e,i){if(t)for(const n of us(e))t.removeEventListener(n,i,!1)}function sl(t){return(t.ownerDocument||t).defaultView}function vT(t,e){let i=t;for(;i;){if(i===e)return!0;i=i.parentNode}return!1}function zu(t){const e=t.length;if(e===1)return{x:Math.round(t[0].clientX),y:Math.round(t[0].clientY)};let i=0,n=0,s=0;for(;s<e;)i+=t[s].clientX,n+=t[s].clientY,s++;return{x:Math.round(i/e),y:Math.round(n/e)}}function rl(t){const e=[];let i=0;for(;i<t.pointers.length;)e[i]={clientX:Math.round(t.pointers[i].clientX),clientY:Math.round(t.pointers[i].clientY)},i++;return{timeStamp:Date.now(),pointers:e,center:zu(e),deltaX:t.deltaX,deltaY:t.deltaY}}function Wu(t,e){const i=e.x-t.x,n=e.y-t.y;return Math.sqrt(i*i+n*n)}function ol(t,e){const i=e.clientX-t.clientX,n=e.clientY-t.clientY;return Math.sqrt(i*i+n*n)}function TT(t,e){const i=e.x-t.x,n=e.y-t.y;return Math.atan2(n,i)*180/Math.PI}function al(t,e){const i=e.clientX-t.clientX,n=e.clientY-t.clientY;return Math.atan2(n,i)*180/Math.PI}function Vu(t,e){return t===e?le.None:Math.abs(t)>=Math.abs(e)?t<0?le.Left:le.Right:e<0?le.Up:le.Down}function AT(t,e){const i=e.center;let n=t.offsetDelta,s=t.prevDelta;const r=t.prevInput;return(e.eventType===ce.Start||(r==null?void 0:r.eventType)===ce.End)&&(s=t.prevDelta={x:(r==null?void 0:r.deltaX)||0,y:(r==null?void 0:r.deltaY)||0},n=t.offsetDelta={x:i.x,y:i.y}),{deltaX:s.x+(i.x-n.x),deltaY:s.y+(i.y-n.y)}}function $u(t,e,i){return{x:e/t||0,y:i/t||0}}function wT(t,e){return ol(e[0],e[1])/ol(t[0],t[1])}function ST(t,e){return al(e[1],e[0])-al(t[1],t[0])}function ET(t,e){const i=t.lastInterval||e,n=e.timeStamp-i.timeStamp;let s,r,o,a;if(e.eventType!==ce.Cancel&&(n>pT||i.velocity===void 0)){const c=e.deltaX-i.deltaX,l=e.deltaY-i.deltaY,f=$u(n,c,l);r=f.x,o=f.y,s=Math.abs(f.x)>Math.abs(f.y)?f.x:f.y,a=Vu(c,l),t.lastInterval=e}else s=i.velocity,r=i.velocityX,o=i.velocityY,a=i.direction;e.velocity=s,e.velocityX=r,e.velocityY=o,e.direction=a}function xT(t,e){const{session:i}=t,{pointers:n}=e,{length:s}=n;i.firstInput||(i.firstInput=rl(e)),s>1&&!i.firstMultiple?i.firstMultiple=rl(e):s===1&&(i.firstMultiple=!1);const{firstInput:r,firstMultiple:o}=i,a=o?o.center:r.center,c=e.center=zu(n);e.timeStamp=Date.now(),e.deltaTime=e.timeStamp-r.timeStamp,e.angle=TT(a,c),e.distance=Wu(a,c);const{deltaX:l,deltaY:f}=AT(i,e);e.deltaX=l,e.deltaY=f,e.offsetDirection=Vu(e.deltaX,e.deltaY);const h=$u(e.deltaTime,e.deltaX,e.deltaY);e.overallVelocityX=h.x,e.overallVelocityY=h.y,e.overallVelocity=Math.abs(h.x)>Math.abs(h.y)?h.x:h.y,e.scale=o?wT(o.pointers,n):1,e.rotation=o?ST(o.pointers,n):0,e.maxPointers=i.prevInput?e.pointers.length>i.prevInput.maxPointers?e.pointers.length:i.prevInput.maxPointers:e.pointers.length;let u=t.element;return vT(e.srcEvent.target,u)&&(u=e.srcEvent.target),e.target=u,ET(i,e),e}function PT(t,e,i){const n=i.pointers.length,s=i.changedPointers.length,r=e&ce.Start&&n-s===0,o=e&(ce.End|ce.Cancel)&&n-s===0;i.isFirst=!!r,i.isFinal=!!o,r&&(t.session={}),i.eventType=e;const a=xT(t,i);t.emit("hammer.input",a),t.recognize(a),t.session.prevInput=a}let RT=class{constructor(e){this.evEl="",this.evWin="",this.evTarget="",this.domHandler=i=>{this.manager.options.enable&&this.handler(i)},this.manager=e,this.element=e.element,this.target=e.options.inputTarget||e.element}callback(e,i){PT(this.manager,e,i)}init(){wr(this.element,this.evEl,this.domHandler),wr(this.target,this.evTarget,this.domHandler),wr(sl(this.element),this.evWin,this.domHandler)}destroy(){Sr(this.element,this.evEl,this.domHandler),Sr(this.target,this.evTarget,this.domHandler),Sr(sl(this.element),this.evWin,this.domHandler)}};const CT={pointerdown:ce.Start,pointermove:ce.Move,pointerup:ce.End,pointercancel:ce.Cancel,pointerout:ce.Cancel},MT="pointerdown",OT="pointermove pointerup pointercancel";class IT extends RT{constructor(e){super(e),this.evEl=MT,this.evWin=OT,this.store=this.manager.session.pointerEvents=[],this.init()}handler(e){const{store:i}=this;let n=!1;const s=CT[e.type],r=e.pointerType,o=r==="touch";let a=i.findIndex(c=>c.pointerId===e.pointerId);s&ce.Start&&(e.buttons||o)?a<0&&(i.push(e),a=i.length-1):s&(ce.End|ce.Cancel)&&(n=!0),!(a<0)&&(i[a]=e,this.callback(s,{pointers:i,changedPointers:[e],eventType:s,pointerType:r,srcEvent:e}),n&&i.splice(a,1))}}const NT=["","webkit","Moz","MS","ms","o"];function LT(t,e){const i=e[0].toUpperCase()+e.slice(1);for(const n of NT){const s=n?n+i:e;if(s in t)return s}}const DT=1,cl=2,ll={touchAction:"compute",enable:!0,inputTarget:null,cssProps:{userSelect:"none",userDrag:"none",touchCallout:"none",tapHighlightColor:"rgba(0,0,0,0)"}};class BT{constructor(e,i){this.options={...ll,...i,cssProps:{...ll.cssProps,...i.cssProps},inputTarget:i.inputTarget||e},this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=e,this.input=new IT(this),this.touchAction=new bT(this,this.options.touchAction),this.toggleCssProps(!0)}set(e){return Object.assign(this.options,e),e.touchAction&&this.touchAction.update(),e.inputTarget&&(this.input.destroy(),this.input.target=e.inputTarget,this.input.init()),this}stop(e){this.session.stopped=e?cl:DT}recognize(e){const{session:i}=this;if(i.stopped)return;this.session.prevented&&e.srcEvent.preventDefault();let n;const{recognizers:s}=this;let{curRecognizer:r}=i;(!r||r&&r.state&$.Recognized)&&(r=i.curRecognizer=null);let o=0;for(;o<s.length;)n=s[o],i.stopped!==cl&&(!r||n===r||n.canRecognizeWith(r))?n.recognize(e):n.reset(),!r&&n.state&($.Began|$.Changed|$.Ended)&&(r=i.curRecognizer=n),o++}get(e){const{recognizers:i}=this;for(let n=0;n<i.length;n++)if(i[n].options.event===e)return i[n];return null}add(e){if(Array.isArray(e)){for(const n of e)this.add(n);return this}const i=this.get(e.options.event);return i&&this.remove(i),this.recognizers.push(e),e.manager=this,this.touchAction.update(),e}remove(e){if(Array.isArray(e)){for(const n of e)this.remove(n);return this}const i=typeof e=="string"?this.get(e):e;if(i){const{recognizers:n}=this,s=n.indexOf(i);s!==-1&&(n.splice(s,1),this.touchAction.update())}return this}on(e,i){if(!e||!i)return;const{handlers:n}=this;for(const s of us(e))n[s]=n[s]||[],n[s].push(i)}off(e,i){if(!e)return;const{handlers:n}=this;for(const s of us(e))i?n[s]&&n[s].splice(n[s].indexOf(i),1):delete n[s]}emit(e,i){const n=this.handlers[e]&&this.handlers[e].slice();if(!n||!n.length)return;const s=i;s.type=e,s.preventDefault=function(){i.srcEvent.preventDefault()};let r=0;for(;r<n.length;)n[r](s),r++}destroy(){this.toggleCssProps(!1),this.handlers={},this.session={},this.input.destroy(),this.element=null}toggleCssProps(e){const{element:i}=this;if(i){for(const[n,s]of Object.entries(this.options.cssProps)){const r=LT(i.style,n);e?(this.oldCssProps[r]=i.style[r],i.style[r]=s):i.style[r]=this.oldCssProps[r]||""}e||(this.oldCssProps={})}}}let FT=1;function kT(){return FT++}function fl(t){return t&$.Cancelled?"cancel":t&$.Ended?"end":t&$.Changed?"move":t&$.Began?"start":""}class ju{constructor(e){this.options=e,this.id=kT(),this.state=$.Possible,this.simultaneous={},this.requireFail=[]}set(e){return Object.assign(this.options,e),this.manager.touchAction.update(),this}recognizeWith(e){if(Array.isArray(e)){for(const s of e)this.recognizeWith(s);return this}let i;if(typeof e=="string"){if(i=this.manager.get(e),!i)throw new Error(`Cannot find recognizer ${e}`)}else i=e;const{simultaneous:n}=this;return n[i.id]||(n[i.id]=i,i.recognizeWith(this)),this}dropRecognizeWith(e){if(Array.isArray(e)){for(const n of e)this.dropRecognizeWith(n);return this}let i;return typeof e=="string"?i=this.manager.get(e):i=e,i&&delete this.simultaneous[i.id],this}requireFailure(e){if(Array.isArray(e)){for(const s of e)this.requireFailure(s);return this}let i;if(typeof e=="string"){if(i=this.manager.get(e),!i)throw new Error(`Cannot find recognizer ${e}`)}else i=e;const{requireFail:n}=this;return n.indexOf(i)===-1&&(n.push(i),i.requireFailure(this)),this}dropRequireFailure(e){if(Array.isArray(e)){for(const n of e)this.dropRequireFailure(n);return this}let i;if(typeof e=="string"?i=this.manager.get(e):i=e,i){const n=this.requireFail.indexOf(i);n>-1&&this.requireFail.splice(n,1)}return this}hasRequireFailures(){return!!this.requireFail.find(e=>e.options.enable)}canRecognizeWith(e){return!!this.simultaneous[e.id]}emit(e){if(!e)return;const{state:i}=this;i<$.Ended&&this.manager.emit(this.options.event+fl(i),e),this.manager.emit(this.options.event,e),e.additionalEvent&&this.manager.emit(e.additionalEvent,e),i>=$.Ended&&this.manager.emit(this.options.event+fl(i),e)}
1269tryEmit(e){this.canEmit()?this.emit(e):this.state=$.Failed}canEmit(){let e=0;for(;e<this.requireFail.length;){if(!(this.requireFail[e].state&($.Failed|$.Possible)))return!1;e++}return!0}recognize(e){const i={...e};if(!this.options.enable){this.reset(),this.state=$.Failed;return}this.state&($.Recognized|$.Cancelled|$.Failed)&&(this.state=$.Possible),this.state=this.process(i),this.state&($.Began|$.Changed|$.Ended|$.Cancelled)&&this.tryEmit(i)}getEventNames(){return[this.options.event]}reset(){}}class Hu extends ju{attrTest(e){const i=this.options.pointers;return i===0||e.pointers.length===i}process(e){const{state:i}=this,{eventType:n}=e,s=i&($.Began|$.Changed),r=this.attrTest(e);return s&&(n&ce.Cancel||!r)?i|$.Cancelled:s||r?n&ce.End?i|$.Ended:i&$.Began?i|$.Changed:$.Began:$.Failed}}class hl extends ju{constructor(e={}){super({enable:!0,event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10,...e}),this.pTime=null,this.pCenter=null,this._timer=null,this._input=null,this.count=0}getTouchAction(){return[Eo]}process(e){const{options:i}=this,n=e.pointers.length===i.pointers,s=e.distance<i.threshold,r=e.deltaTime<i.time;if(this.reset(),e.eventType&ce.Start&&this.count===0)return this.failTimeout();if(s&&r&&n){if(e.eventType!==ce.End)return this.failTimeout();const o=this.pTime?e.timeStamp-this.pTime<i.interval:!0,a=!this.pCenter||Wu(this.pCenter,e.center)<i.posThreshold;if(this.pTime=e.timeStamp,this.pCenter=e.center,!a||!o?this.count=1:this.count+=1,this._input=e,this.count%i.taps===0)return this.hasRequireFailures()?(this._timer=setTimeout(()=>{this.state=$.Recognized,this.tryEmit(this._input)},i.interval),$.Began):$.Recognized}return $.Failed}failTimeout(){return this._timer=setTimeout(()=>{this.state=$.Failed},this.options.interval),$.Failed}reset(){clearTimeout(this._timer)}emit(e){this.state===$.Recognized&&(e.tapCount=this.count,this.manager.emit(this.options.event,e))}}const UT=["","start","move","end","cancel","up","down","left","right"];class ul extends Hu{constructor(e={}){super({enable:!0,pointers:1,event:"pan",threshold:10,direction:le.All,...e}),this.pX=null,this.pY=null}getTouchAction(){const{options:{direction:e}}=this,i=[];return e&le.Horizontal&&i.push(Po),e&le.Vertical&&i.push(xo),i}getEventNames(){return UT.map(e=>this.options.event+e)}directionTest(e){const{options:i}=this;let n=!0,{distance:s}=e,{direction:r}=e;const o=e.deltaX,a=e.deltaY;return r&i.direction||(i.direction&le.Horizontal?(r=o===0?le.None:o<0?le.Left:le.Right,n=o!==this.pX,s=Math.abs(e.deltaX)):(r=a===0?le.None:a<0?le.Up:le.Down,n=a!==this.pY,s=Math.abs(e.deltaY))),e.direction=r,n&&s>i.threshold&&!!(r&i.direction)}attrTest(e){return super.attrTest(e)&&(!!(this.state&$.Began)||!(this.state&$.Began)&&this.directionTest(e))}emit(e){this.pX=e.deltaX,this.pY=e.deltaY;const i=le[e.direction].toLowerCase();i&&(e.additionalEvent=this.options.event+i),super.emit(e)}}const zT=["","start","move","end","cancel","in","out"];class WT extends Hu{constructor(e={}){super({enable:!0,event:"pinch",threshold:0,pointers:2,...e})}getTouchAction(){return[jn]}getEventNames(){return zT.map(e=>this.options.event+e)}attrTest(e){return super.attrTest(e)&&(Math.abs(e.scale-1)>this.options.threshold||!!(this.state&$.Began))}emit(e){if(e.scale!==1){const i=e.scale<1?"in":"out";e.additionalEvent=this.options.event+i}super.emit(e)}}class Hs{constructor(e,i,n){this.element=e,this.callback=i,this.options=n}}const VT=typeof navigator<"u"&&navigator.userAgent?navigator.userAgent.toLowerCase():"",$T=VT.indexOf("firefox")!==-1,dl=4.000244140625,jT=40,HT=.25;class XT extends Hs{constructor(e,i,n){super(e,i,{enable:!0,...n}),this.handleEvent=s=>{if(!this.options.enable)return;let r=s.deltaY;globalThis.WheelEvent&&($T&&s.deltaMode===globalThis.WheelEvent.DOM_DELTA_PIXEL&&(r/=globalThis.devicePixelRatio),s.deltaMode===globalThis.WheelEvent.DOM_DELTA_LINE&&(r*=jT)),r!==0&&r%dl===0&&(r=Math.floor(r/dl)),s.shiftKey&&r&&(r=r*HT),this.callback({type:"wheel",center:{x:s.clientX,y:s.clientY},delta:-r,srcEvent:s,pointerType:"mouse",target:s.target})},e.addEventListener("wheel",this.handleEvent,{passive:!1})}destroy(){this.element.removeEventListener("wheel",this.handleEvent)}enableEventType(e,i){e==="wheel"&&(this.options.enable=i)}}const gl=["mousedown","mousemove","mouseup","mouseover","mouseout","mouseleave"];class YT extends Hs{constructor(e,i,n){super(e,i,{enable:!0,...n}),this.handleEvent=r=>{this.handleOverEvent(r),this.handleOutEvent(r),this.handleEnterEvent(r),this.handleLeaveEvent(r),this.handleMoveEvent(r)},this.pressed=!1;const{enable:s}=this.options;this.enableMoveEvent=s,this.enableLeaveEvent=s,this.enableEnterEvent=s,this.enableOutEvent=s,this.enableOverEvent=s,gl.forEach(r=>e.addEventListener(r,this.handleEvent))}
1269destroy(){gl.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,i){switch(e){case"pointermove":this.enableMoveEvent=i;break;case"pointerover":this.enableOverEvent=i;break;case"pointerout":this.enableOutEvent=i;break;case"pointerenter":this.enableEnterEvent=i;break;case"pointerleave":this.enableLeaveEvent=i;break}}handleOverEvent(e){this.enableOverEvent&&e.type==="mouseover"&&this._emit("pointerover",e)}handleOutEvent(e){this.enableOutEvent&&e.type==="mouseout"&&this._emit("pointerout",e)}handleEnterEvent(e){this.enableEnterEvent&&e.type==="mouseenter"&&this._emit("pointerenter",e)}handleLeaveEvent(e){this.enableLeaveEvent&&e.type==="mouseleave"&&this._emit("pointerleave",e)}handleMoveEvent(e){if(this.enableMoveEvent)switch(e.type){case"mousedown":e.button>=0&&(this.pressed=!0);break;case"mousemove":e.buttons===0&&(this.pressed=!1),this.pressed||this._emit("pointermove",e);break;case"mouseup":this.pressed=!1;break}}_emit(e,i){this.callback({type:e,center:{x:i.clientX,y:i.clientY},srcEvent:i,pointerType:"mouse",target:i.target})}}const pl=["keydown","keyup"];class KT extends Hs{constructor(e,i,n){super(e,i,{enable:!0,tabIndex:0,...n}),this.handleEvent=s=>{const r=s.target||s.srcElement;r.tagName==="INPUT"&&r.type==="text"||r.tagName==="TEXTAREA"||(this.enableDownEvent&&s.type==="keydown"&&this.callback({type:"keydown",srcEvent:s,key:s.key,target:s.target}),this.enableUpEvent&&s.type==="keyup"&&this.callback({type:"keyup",srcEvent:s,key:s.key,target:s.target}))},this.enableDownEvent=this.options.enable,this.enableUpEvent=this.options.enable,e.tabIndex=this.options.tabIndex,e.style.outline="none",pl.forEach(s=>e.addEventListener(s,this.handleEvent))}destroy(){pl.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,i){e==="keydown"&&(this.enableDownEvent=i),e==="keyup"&&(this.enableUpEvent=i)}}class qT extends Hs{constructor(e,i,n){super(e,i,n),this.handleEvent=s=>{this.options.enable&&this.callback({type:"contextmenu",center:{x:s.clientX,y:s.clientY},srcEvent:s,pointerType:"mouse",target:s.target})},e.addEventListener("contextmenu",this.handleEvent)}destroy(){this.element.removeEventListener("contextmenu",this.handleEvent)}enableEventType(e,i){e==="contextmenu"&&(this.options.enable=i)}}const _l=1,Ro=2,ml=4,ZT={pointerdown:_l,pointermove:Ro,pointerup:ml,mousedown:_l,mousemove:Ro,mouseup:ml},GT=0,QT=1,JT=2,eA=1,tA=2,iA=4;function nA(t){const e=ZT[t.srcEvent.type];if(!e)return null;const{buttons:i,button:n}=t.srcEvent;let s=!1,r=!1,o=!1;return e===Ro?(s=!!(i&eA),r=!!(i&iA),o=!!(i&tA)):(s=n===GT,r=n===QT,o=n===JT),{leftButton:s,middleButton:r,rightButton:o}}function sA(t,e){const i=t.center;if(!i)return null;const n=e.getBoundingClientRect(),s=n.width/e.offsetWidth||1,r=n.height/e.offsetHeight||1,o={x:(i.x-n.left-e.clientLeft)/s,y:(i.y-n.top-e.clientTop)/r};return{center:i,offsetCenter:o}}const rA={srcElement:"root",priority:0};class oA{constructor(e,i){this.handleEvent=n=>{if(this.isEmpty())return;const s=this._normalizeEvent(n);let r=n.srcEvent.target;for(;r&&r!==s.rootElement;){if(this._emit(s,r),s.handled)return;r=r.parentNode}this._emit(s,"root")},this.eventManager=e,this.recognizerName=i,this.handlers=[],this.handlersByElement=new Map,this._active=!1}isEmpty(){return!this._active}add(e,i,n,s=!1,r=!1){const{handlers:o,handlersByElement:a}=this,c={...rA,...n};let l=a.get(c.srcElement);l||(l=[],a.set(c.srcElement,l));const f={type:e,handler:i,srcElement:c.srcElement,priority:c.priority};s&&(f.once=!0),r&&(f.passive=!0),o.push(f),this._active=this._active||!f.passive;let h=l.length-1;for(;h>=0&&!(l[h].priority>=f.priority);)h--;l.splice(h+1,0,f)}remove(e,i){const{handlers:n,handlersByElement:s}=this;for(let r=n.length-1;r>=0;r--){const o=n[r];if(o.type===e&&o.handler===i){n.splice(r,1);const a=s.get(o.srcElement);a.splice(a.indexOf(o),1),a.length===0&&s.delete(o.srcElement)}}this._active=n.some(r=>!r.passive)}_emit(e,i){const n=this.handlersByElement.get(i);if(n){let s=!1;const r=()=>{e.handled=!0},o=()=>{e.handled=!0,s=!0},a=[];for(let c=0;c<n.length;c++){const{type:l,handler:f,once:h}=n[c];if(f({...e,type:l,stopPropagation:r,stopImmediatePropagation:o}),h&&a.push(n[c]),s)break}for(let c=0;c<a.length;c++){const{type:l,handler:f}=a[c];this.remove(l,f)}}}_normalizeEvent(e){const i=this.eventManager.getElement();return{...e,...nA(e),...sA(e,i),preventDefault:()=>{e.srcEvent.preventDefault()},stopImmediatePropagation:null,stopPropagation:null,handled:!1,rootElement:i}}}function aA(t){if("recognizer"in t)return t;let e;const i=Array.isArray(t)?[...t]:[t];if(typeof i[0]=="function"){const n=i.shift(),s=i.shift()||{};e=new n(s)}else e=i.shift();return{recognizer:e,recognizeWith:typeof i[0]=="string"?[i[0]]:i[0],requireFailure:typeof i[1]=="string"?[i[1]]:i[1]}}class cA{constructor(e=null,i={}){if(this._onBasicInput=n=>{this.manager.emit(n.srcEvent.type,n)},this._onOtherEvent=n=>{this.manager.emit(n.type,n)},this.options={recognizers:[],events:{},touchAction:"compute",tabIndex:0,cssProps:{},...i},this.events=new Map,this.element=e,!!e){this.manager=new BT(e,this.options);for(const n of this.options.recognizers){const{recognizer:s,recognizeWith:r,requireFailure:o}=aA(n);this.manager.add(s),r&&s.recognizeWith(r),o&&s.requireFailure(o)}this.manager.on("hammer.input",this._onBasicInput),this.wheelInput=new XT(e,this._onOtherEvent,{enable:!1}),this.moveInput=new YT(e,this._onOtherEvent,{enable:!1}
1269),this.keyInput=new KT(e,this._onOtherEvent,{enable:!1,tabIndex:i.tabIndex}),this.contextmenuInput=new qT(e,this._onOtherEvent,{enable:!1}),this.on(this.options.events)}}getElement(){return this.element}destroy(){this.element&&(this.wheelInput.destroy(),this.moveInput.destroy(),this.keyInput.destroy(),this.contextmenuInput.destroy(),this.manager.destroy())}on(e,i,n){this._addEventHandler(e,i,n,!1)}once(e,i,n){this._addEventHandler(e,i,n,!0)}watch(e,i,n){this._addEventHandler(e,i,n,!1,!0)}off(e,i){this._removeEventHandler(e,i)}_toggleRecognizer(e,i){var r,o,a,c;const{manager:n}=this;if(!n)return;const s=n.get(e);s&&(s.set({enable:i}),n.touchAction.update()),(r=this.wheelInput)==null||r.enableEventType(e,i),(o=this.moveInput)==null||o.enableEventType(e,i),(a=this.keyInput)==null||a.enableEventType(e,i),(c=this.contextmenuInput)==null||c.enableEventType(e,i)}_addEventHandler(e,i,n,s,r){if(typeof e!="string"){n=i;for(const[l,f]of Object.entries(e))this._addEventHandler(l,f,n,s,r);return}const{manager:o,events:a}=this;if(!o)return;let c=a.get(e);if(!c){const l=this._getRecognizerName(e)||e;c=new oA(this,l),a.set(e,c),o&&o.on(e,c.handleEvent)}c.add(e,i,n,s,r),c.isEmpty()||this._toggleRecognizer(c.recognizerName,!0)}_removeEventHandler(e,i){if(typeof e!="string"){for(const[r,o]of Object.entries(e))this._removeEventHandler(r,o);return}const{events:n}=this,s=n.get(e);if(s&&(s.remove(e,i),s.isEmpty())){const{recognizerName:r}=s;let o=!1;for(const a of n.values())if(a.recognizerName===r&&!a.isEmpty()){o=!0;break}o||this._toggleRecognizer(r,!1)}}_getRecognizerName(e){var i;return(i=this.manager.recognizers.find(n=>n.getEventNames().includes(e)))==null?void 0:i.options.event}}const ds={DEFAULT:"default",LNGLAT:"lnglat",METER_OFFSETS:"meter-offsets",LNGLAT_OFFSETS:"lnglat-offsets",CARTESIAN:"cartesian"};Object.defineProperty(ds,"IDENTITY",{get:()=>(j.deprecated("COORDINATE_SYSTEM.IDENTITY","COORDINATE_SYSTEM.CARTESIAN")(),ds.CARTESIAN)});const ye={WEB_MERCATOR:1,GLOBE:2,WEB_MERCATOR_AUTO_OFFSET:4,IDENTITY:0},He={common:0,meters:1,pixels:2},Hn={click:"onClick",dblclick:"onClick",panstart:"onDragStart",panmove:"onDrag",panend:"onDragEnd"},yl={multipan:[ul,{threshold:10,direction:le.Vertical,pointers:2}],pinch:[WT,{},null,["multipan"]],pan:[ul,{threshold:1},["pinch"],["multipan"]],dblclick:[hl,{event:"dblclick",taps:2}],click:[hl,{event:"click"},null,["dblclick"]]};function lA(t,e){if(t===e)return!0;if(Array.isArray(t)){const i=t.length;if(!e||e.length!==i)return!1;for(let n=0;n<i;n++)if(t[n]!==e[n])return!1;return!0}return!1}function an(t){let e={},i;return n=>{for(const s in n)if(!lA(n[s],e[s])){i=t(n),e=n;break}return i}}const bl=[0,0,0,0],fA=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0],Xu=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],hA=[0,0,0],Yu=[0,0,0],uA={default:-1,cartesian:0,lnglat:1,"meter-offsets":2,"lnglat-offsets":3};function Xs(t){const e=uA[t];if(e===void 0)throw new Error(`Invalid coordinateSystem: ${t}`);return e}const dA=an(_A);function Ku(t,e,i=Yu){i.length<3&&(i=[i[0],i[1],0]);let n=i,s,r=!0;switch(e==="lnglat-offsets"||e==="meter-offsets"?s=i:s=t.isGeospatial?[Math.fround(t.longitude),Math.fround(t.latitude),0]:null,t.projectionMode){case ye.WEB_MERCATOR:(e==="lnglat"||e==="cartesian")&&(s=[0,0,0],r=!1);break;case ye.WEB_MERCATOR_AUTO_OFFSET:e==="lnglat"?n=s:e==="cartesian"&&(n=[Math.fround(t.center[0]),Math.fround(t.center[1]),0],s=t.unprojectPosition(n),n[0]-=i[0],n[1]-=i[1],n[2]-=i[2]);break;case ye.IDENTITY:n=t.position.map(Math.fround),n[2]=n[2]||0;break;case ye.GLOBE:r=!1,s=null;break;default:r=!1}return{geospatialOrigin:s,shaderCoordinateOrigin:n,offsetMode:r}}function gA(t,e,i){const{viewMatrixUncentered:n,projectionMatrix:s}=t;let{viewMatrix:r,viewProjectionMatrix:o}=t,a=bl,c=bl,l=t.cameraPosition;const{geospatialOrigin:f,shaderCoordinateOrigin:h,offsetMode:u}=Ku(t,e,i);return u&&(c=t.projectPosition(f||h),l=[l[0]-c[0],l[1]-c[1],l[2]-c[2]],c[3]=1,a=gi([],c,o),r=n||r,o=St([],s,r),o=St([],o,fA)),{viewMatrix:r,viewProjectionMatrix:o,projectionCenter:a,originCommon:c,cameraPosCommon:l,shaderCoordinateOrigin:h,geospatialOrigin:f}}function pA({viewport:t,devicePixelRatio:e=1,modelMatrix:i=null,coordinateSystem:n="default",coordinateOrigin:s=Yu,autoWrapLongitude:r=!1}){n==="default"&&(n=t.isGeospatial?"lnglat":"cartesian");const o=dA({viewport:t,devicePixelRatio:e,coordinateSystem:n,coordinateOrigin:s});return o.wrapLongitude=r,o.modelMatrix=i||Xu,o}function _A({viewport:t,devicePixelRatio:e,coordinateSystem:i,coordinateOrigin:n}){const{projectionCenter:s,viewProjectionMatrix:r,originCommon:o,cameraPosCommon:a,shaderCoordinateOrigin:c,geospatialOrigin:l}=gA(t,i,n),f=t.getDistanceScales(),h=[t.width*e,t.height*e],u=gi([],[0,0,-t.focalDistance,1],t.projectionMatrix)[3]||1,d={coordinateSystem:Xs(i),projectionMode:t.projectionMode,coordinateOrigin:c,commonOrigin:o.slice(0,3),center:s,pseudoMeters:!!t._pseudoMeters,viewportSize:h,devicePixelRatio:e,focalDistance:u,commonUnitsPerMeter:f.unitsPerMeter,commonUnitsPerWorldUnit:f.unitsPerMeter,commonUnitsPerWorldUnit2:hA,scale:t.scale,wrapLongitude:!1,viewProjectionMatrix:r,modelMatrix:Xu,cameraPosition:a};if(l){const p=t.getDistanceScales(l);switch(i){case"meter-offsets":d.commonUnitsPerWorldUnit=p.unitsPerMeter,d.commonUnitsPerWorldUnit2=p.unitsPerMeter2;break;case"lnglat":case"lnglat-offsets":t._pseudoMeters||(d.commonUnitsPerMeter=p.unitsPerMeter),d.commonUnitsPerWorldUnit=p.unitsPerDegree,d.commonUnitsPerWorldUnit2=p.unitsPerDegree2;break;case"cartesian":d.commonUnitsPerWorldUnit=[1,1,p.unitsPerMeter[2]],d.commonUnitsPerWorldUnit2=[0,0,p.unitsPerMeter2[2]];break}}return d}const mA=["default","lnglat","meter-offsets","lnglat-offsets","cartesian"],yA=mA.map(t=>`const COORDINATE_SYSTEM_${t.toUpperCase().replaceAll("-","_")}: i32 = ${Xs(t)};`).join(""),bA=Object.keys(ye).map(t=>`const PROJECTION_MODE_${t}: i32 = ${ye[t]};`).join(""),vA=Object.keys(He).map(t=>`const UNIT_${t.toUpperCase()}: i32 = ${He[t]};`).join(""),TA=`${yA} 1270${bA} 1271${vA} 1272 1273const TILE_SIZE: f32 = 512.0; 1274const PI: f32 = 3.1415926536; 1275const WORLD_SCALE: f32 = TILE_SIZE / (PI * 2.0); 1276const ZERO_64_LOW: vec3<f32> = vec3<f32>(0.0, 0.0, 0.0); 1277const EARTH_RADIUS: f32 = 6370972.0; // meters 1278const GLOBE_RADIUS: f32 = 256.0; 1279 1280// ----------------------------------------------------------------------------- 1281// Uniform block (converted from GLSL uniform block) 1282// ----------------------------------------------------------------------------- 1283struct ProjectUniforms { 1284 wrapLongitude: i32, 1285 coordinateSystem: i32, 1286 commonUnitsPerMeter: vec3<f32>, 1287 projectionMode: i32, 1288 scale: f32, 1289 commonUnitsPerWorldUnit: vec3<f32>, 1290 commonUnitsPerWorldUnit2: vec3<f32>, 1291 center: vec4<f32>, 1292 modelMatrix: mat4x4<f32>, 1293 viewProjectionMatrix: mat4x4<f32>, 1294 viewportSize: vec2<f32>, 1295 devicePixelRatio: f32, 1296 focalDistance: f32, 1297 cameraPosition: vec3<f32>, 1298 coordinateOrigin: vec3<f32>, 1299 commonOrigin: vec3<f32>, 1300 pseudoMeters: i32, 1301}; 1302 1303@group(0) @binding(auto) 1304var<uniform> project: ProjectUniforms; 1305 1306// ----------------------------------------------------------------------------- 1307// Geometry data shared across the project helpers. 1308// The active layer shader is responsible for populating this private module 1309// state before calling the project functions below. 1310// ----------------------------------------------------------------------------- 1311 1312// Structure to carry additional geometry data used by deck.gl filters. 1313struct Geometry { 1314 worldPosition: vec3<f32>, 1315 worldPositionAlt: vec3<f32>, 1316 position: vec4<f32>, 1317 normal: vec3<f32>, 1318 uv: vec2<f32>, 1319 pickingColor: vec3<f32>, 1320}; 1321 1322var<private> geometry: Geometry; 1323`,AA=`${TA} 1324 1325// ----------------------------------------------------------------------------- 1326// Functions 1327// ----------------------------------------------------------------------------- 1328 1329// Returns an adjustment factor for commonUnitsPerMeter 1330fn _project_size_at_latitude(lat: f32) -> f32 { 1331 let y = clamp(lat, -89.9, 89.9); 1332 return 1.0 / cos(radians(y)); 1333} 1334 1335// Overloaded version: scales a value in meters at a given latitude. 1336fn _project_size_at_latitude_m(meters: f32, lat: f32) -> f32 { 1337 return meters * project.commonUnitsPerMeter.z * _project_size_at_latitude(lat); 1338} 1339 1340// Computes a non-linear scale factor based on geometry. 1341// (Note: This function relies on "geometry" being provided.) 1342fn project_size() -> f32 { 1343 if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR && 1344 project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT && 1345 project.pseudoMeters == 0) { 1346 if (geometry.position.w == 0.0) { 1347 return _project_size_at_latitude(geometry.worldPosition.y); 1348 } 1349 let y: f32 = geometry.position.y / TILE_SIZE * 2.0 - 1.0; 1350 let y2 = y * y; 1351 let y4 = y2 * y2; 1352 let y6 = y4 * y2; 1353 return 1.0 + 4.9348 * y2 + 4.0587 * y4 + 1.5642 * y6; 1354 } 1355 return 1.0; 1356} 1357 1358// Overloads to scale offsets (meters to world units) 1359fn project_size_float(meters: f32) -> f32 { 1360 return meters * project.commonUnitsPerMeter.z * project_size(); 1361} 1362 1363fn project_size_vec2(meters: vec2<f32>) -> vec2<f32> { 1364 return meters * project.commonUnitsPerMeter.xy * project_size(); 1365} 1366 1367fn project_size_vec3(meters: vec3<f32>) -> vec3<f32> { 1368 return meters * project.commonUnitsPerMeter * project_size(); 1369} 1370 1371fn project_size_vec4(meters: vec4<f32>) -> vec4<f32> { 1372 return vec4<f32>(meters.xyz * project.commonUnitsPerMeter, meters.w); 1373} 1374 1375// Returns a rotation matrix aligning the z‑axis with the given up vector. 1376fn project_get_orientation_matrix(up: vec3<f32>) -> mat3x3<f32> { 1377 let uz = normalize(up); 1378 let ux = select( 1379 vec3<f32>(1.0, 0.0, 0.0), 1380 normalize(vec3<f32>(uz.y, -uz.x, 0.0)), 1381 abs(uz.z) == 1.0 1382 ); 1383 let uy = cross(uz, ux); 1384 return mat3x3<f32>(ux, uy, uz); 1385} 1386 1387// Since WGSL does not support "out" parameters, we return a struct. 1388struct RotationResult { 1389 needsRotation: bool, 1390 transform: mat3x3<f32>, 1391}; 1392 1393fn project_needs_rotation(commonPosition: vec3<f32>) -> RotationResult { 1394 if (project.projectionMode == PROJECTION_MODE_GLOBE) { 1395 return RotationResult(true, project_get_orientation_matrix(commonPosition)); 1396 } else { 1397 return RotationResult(false, mat3x3<f32>()); // identity alternative if needed 1398 }; 1399} 1400 1401// Projects a normal vector from the current coordinate system to world space. 1402fn project_normal(vector: vec3<f32>) -> vec3<f32> { 1403 let normal_modelspace = project.modelMatrix * vec4<f32>(vector, 0.0); 1404 var n = normalize(normal_modelspace.xyz * project.commonUnitsPerMeter); 1405 let rotResult = project_needs_rotation(geometry.position.xyz); 1406 if (rotResult.needsRotation) { 1407 n = rotResult.transform * n; 1408 } 1409 return n; 1410} 1411 1412// Applies a scale offset based on y-offset (dy) 1413fn project_offset_(offset: vec4<f32>) -> vec4<f32> { 1414 let dy: f32 = offset.y; 1415 let commonUnitsPerWorldUnit = project.commonUnitsPerWorldUnit + project.commonUnitsPerWorldUnit2 * dy; 1416 return vec4<f32>(offset.xyz * commonUnitsPerWorldUnit, offset.w); 1417} 1418 1419// Projects lng/lat coordinates to a unit tile [0,1] 1420fn project_mercator_(lnglat: vec2<f32>) -> vec2<f32> { 1421 var x = lnglat.x; 1422 if (project.wrapLongitude != 0) { 1423 x = ((x + 180.0) % 360.0) - 180.0; 1424 } 1425 let y = clamp(lnglat.y, -89.9, 89.9); 1426 return vec2<f32>( 1427 radians(x) + PI, 1428 PI + log(tan(PI * 0.25 + radians(y) * 0.5)) 1429 ) * WORLD_SCALE; 1430} 1431 1432// Projects lng/lat/z coordinates for a globe projection. 1433fn project_globe_(lnglatz: vec3<f32>) -> vec3<f32> { 1434 let lambda = radians(lnglatz.x); 1435 let phi = radians(lnglatz.y); 1436 let cosPhi = cos(phi); 1437 let D = (lnglatz.z / EARTH_RADIUS + 1.0) * GLOBE_RADIUS; 1438 return vec3<f32>( 1439 sin(lambda) * cosPhi, 1440 -cos(lambda) * cosPhi, 1441 sin(phi) 1442 ) * D; 1443} 1444 1445// Projects positions (with an optional 64-bit low part) from the input 1446// coordinate system to the common space. 1447fn project_position_vec4_f64(position: vec4<f32>, position64Low: vec3<f32>) -> vec4<f32> { 1448 var position_world = project.modelMatrix * position; 1449 1450 // Work around for a Mac+NVIDIA bug: 1451 if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR) { 1452 if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) { 1453 return vec4<f32>( 1454 project_mercator_(position_world.xy), 1455 _project_size_at_latitude_m(position_world.z, position_world.y), 1456 position_world.w 1457 ); 1458 } 1459 if (project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN) {
1460 position_world = vec4f(position_world.xyz + project.coordinateOrigin, position_world.w); 1461 } 1462 } 1463 if (project.projectionMode == PROJECTION_MODE_GLOBE) { 1464 if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) { 1465 return vec4<f32>( 1466 project_globe_(position_world.xyz), 1467 position_world.w 1468 ); 1469 } 1470 } 1471 if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) { 1472 if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) { 1473 if (abs(position_world.y - project.coordinateOrigin.y) > 0.25) { 1474 return vec4<f32>( 1475 project_mercator_(position_world.xy) - project.commonOrigin.xy, 1476 project_size_float(position_world.z), 1477 position_world.w 1478 ); 1479 } 1480 } 1481 } 1482 if (project.projectionMode == PROJECTION_MODE_IDENTITY || 1483 (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET && 1484 (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT || 1485 project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN))) { 1486 position_world = vec4f(position_world.xyz - project.coordinateOrigin, position_world.w); 1487 } 1488 1489 return project_offset_(position_world) + 1490 project_offset_(project.modelMatrix * vec4<f32>(position64Low, 0.0)); 1491} 1492 1493// Overloaded versions for different input types. 1494fn project_position_vec4_f32(position: vec4<f32>) -> vec4<f32> { 1495 return project_position_vec4_f64(position, ZERO_64_LOW); 1496} 1497 1498fn project_position_vec3_f64(position: vec3<f32>, position64Low: vec3<f32>) -> vec3<f32> { 1499 let projected_position = project_position_vec4_f64(vec4<f32>(position, 1.0), position64Low); 1500 return projected_position.xyz; 1501} 1502 1503fn project_position_vec3_f32(position: vec3<f32>) -> vec3<f32> { 1504 let projected_position = project_position_vec4_f64(vec4<f32>(position, 1.0), ZERO_64_LOW); 1505 return projected_position.xyz; 1506} 1507 1508fn project_position_vec2_f32(position: vec2<f32>) -> vec2<f32> { 1509 let projected_position = project_position_vec4_f64(vec4<f32>(position, 0.0, 1.0), ZERO_64_LOW); 1510 return projected_position.xy; 1511} 1512 1513// Transforms a common space position to clip space. 1514fn project_common_position_to_clipspace_with_projection(position: vec4<f32>, viewProjectionMatrix: mat4x4<f32>, center: vec4<f32>) -> vec4<f32> { 1515 return viewProjectionMatrix * position + center; 1516} 1517 1518// Uses the project viewProjectionMatrix and center. 1519fn project_common_position_to_clipspace(position: vec4<f32>) -> vec4<f32> { 1520 return project_common_position_to_clipspace_with_projection(position, project.viewProjectionMatrix, project.center); 1521} 1522 1523// Returns a clip space offset corresponding to a given number of screen pixels. 1524fn project_pixel_size_to_clipspace(pixels: vec2<f32>) -> vec2<f32> { 1525 let offset = pixels / project.viewportSize * project.devicePixelRatio * 2.0; 1526 return offset * project.focalDistance; 1527} 1528 1529fn project_meter_size_to_pixel(meters: f32) -> f32 { 1530 return project_size_float(meters) * project.scale; 1531} 1532 1533fn project_unit_size_to_pixel(size: f32, unit: i32) -> f32 { 1534 if (unit == UNIT_METERS) { 1535 return project_meter_size_to_pixel(size); 1536 } else if (unit == UNIT_COMMON) { 1537 return size * project.scale; 1538 } 1539 // UNIT_PIXELS: no scaling applied. 1540 return size; 1541} 1542 1543fn project_pixel_size_float(pixels: f32) -> f32 { 1544 return pixels / project.scale; 1545} 1546 1547fn project_pixel_size_vec2(pixels: vec2<f32>) -> vec2<f32> { 1548 return pixels / project.scale; 1549} 1550`,wA=["default","lnglat","meter-offsets","lnglat-offsets","cartesian"],SA=wA.map(t=>`const int COORDINATE_SYSTEM_${t.toUpperCase().replaceAll("-","_")} = ${Xs(t)};`).join(""),EA=Object.keys(ye).map(t=>`const int PROJECTION_MODE_${t} = ${ye[t]};`).join(""),xA=Object.keys(He).map(t=>`const int UNIT_${t.toUpperCase()} = ${He[t]};`).join(""),PA=`${SA} 1551${EA} 1552${xA
vendor: 6,166 bytes, lines 1552-1744
1552} 1553layout(std140) uniform projectUniforms { 1554bool wrapLongitude; 1555int coordinateSystem; 1556vec3 commonUnitsPerMeter; 1557int projectionMode; 1558float scale; 1559vec3 commonUnitsPerWorldUnit; 1560vec3 commonUnitsPerWorldUnit2; 1561vec4 center; 1562mat4 modelMatrix; 1563mat4 viewProjectionMatrix; 1564vec2 viewportSize; 1565float devicePixelRatio; 1566float focalDistance; 1567vec3 cameraPosition; 1568vec3 coordinateOrigin; 1569vec3 commonOrigin; 1570bool pseudoMeters; 1571} project; 1572const float TILE_SIZE = 512.0; 1573const float PI = 3.1415926536; 1574const float WORLD_SCALE = TILE_SIZE / (PI * 2.0); 1575const vec3 ZERO_64_LOW = vec3(0.0); 1576const float EARTH_RADIUS = 6370972.0; 1577const float GLOBE_RADIUS = 256.0; 1578float project_size_at_latitude(float lat) { 1579float y = clamp(lat, -89.9, 89.9); 1580return 1.0 / cos(radians(y)); 1581} 1582float project_size() { 1583if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR && 1584project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT && 1585project.pseudoMeters == false) { 1586if (geometry.position.w == 0.0) { 1587return project_size_at_latitude(geometry.worldPosition.y); 1588} 1589float y = geometry.position.y / TILE_SIZE * 2.0 - 1.0; 1590float y2 = y * y; 1591float y4 = y2 * y2; 1592float y6 = y4 * y2; 1593return 1.0 + 4.9348 * y2 + 4.0587 * y4 + 1.5642 * y6; 1594} 1595return 1.0; 1596} 1597float project_size_at_latitude(float meters, float lat) { 1598return meters * project.commonUnitsPerMeter.z * project_size_at_latitude(lat); 1599} 1600float project_size(float meters) { 1601return meters * project.commonUnitsPerMeter.z * project_size(); 1602} 1603vec2 project_size(vec2 meters) { 1604return meters * project.commonUnitsPerMeter.xy * project_size(); 1605} 1606vec3 project_size(vec3 meters) { 1607return meters * project.commonUnitsPerMeter * project_size(); 1608} 1609vec4 project_size(vec4 meters) { 1610return vec4(meters.xyz * project.commonUnitsPerMeter, meters.w); 1611} 1612mat3 project_get_orientation_matrix(vec3 up) { 1613vec3 uz = normalize(up); 1614vec3 ux = abs(uz.z) == 1.0 ? vec3(1.0, 0.0, 0.0) : normalize(vec3(uz.y, -uz.x, 0)); 1615vec3 uy = cross(uz, ux); 1616return mat3(ux, uy, uz); 1617} 1618bool project_needs_rotation(vec3 commonPosition, out mat3 transform) { 1619if (project.projectionMode == PROJECTION_MODE_GLOBE) { 1620transform = project_get_orientation_matrix(commonPosition); 1621return true; 1622} 1623return false; 1624} 1625vec3 project_normal(vec3 vector) { 1626vec4 normal_modelspace = project.modelMatrix * vec4(vector, 0.0); 1627vec3 n = normalize(normal_modelspace.xyz * project.commonUnitsPerMeter); 1628mat3 rotation; 1629if (project_needs_rotation(geometry.position.xyz, rotation)) { 1630n = rotation * n; 1631} 1632return n; 1633} 1634vec4 project_offset_(vec4 offset) { 1635float dy = offset.y; 1636vec3 commonUnitsPerWorldUnit = project.commonUnitsPerWorldUnit + project.commonUnitsPerWorldUnit2 * dy; 1637return vec4(offset.xyz * commonUnitsPerWorldUnit, offset.w); 1638} 1639vec2 project_mercator_(vec2 lnglat) { 1640float x = lnglat.x; 1641if (project.wrapLongitude) { 1642x = mod(x + 180., 360.0) - 180.; 1643} 1644float y = clamp(lnglat.y, -89.9, 89.9); 1645return vec2( 1646radians(x) + PI, 1647PI + log(tan_fp32(PI * 0.25 + radians(y) * 0.5)) 1648) * WORLD_SCALE; 1649} 1650vec3 project_globe_(vec3 lnglatz) { 1651float lambda = radians(lnglatz.x); 1652float phi = radians(lnglatz.y); 1653float cosPhi = cos(phi); 1654float D = (lnglatz.z / EARTH_RADIUS + 1.0) * GLOBE_RADIUS; 1655return vec3( 1656sin(lambda) * cosPhi, 1657-cos(lambda) * cosPhi, 1658sin(phi) 1659) * D; 1660} 1661vec4 project_position(vec4 position, vec3 position64Low) { 1662vec4 position_world = project.modelMatrix * position; 1663if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR) { 1664if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) { 1665return vec4( 1666project_mercator_(position_world.xy), 1667project_size_at_latitude(position_world.z, position_world.y), 1668position_world.w 1669); 1670} 1671if (project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN) { 1672position_world.xyz += project.coordinateOrigin; 1673} 1674} 1675if (project.projectionMode == PROJECTION_MODE_GLOBE) { 1676if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) { 1677return vec4( 1678project_globe_(position_world.xyz), 1679position_world.w 1680); 1681} 1682} 1683if (project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) { 1684if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT) { 1685if (abs(position_world.y - project.coordinateOrigin.y) > 0.25) { 1686return vec4( 1687project_mercator_(position_world.xy) - project.commonOrigin.xy, 1688project_size(position_world.z), 1689position_world.w 1690); 1691} 1692} 1693} 1694if (project.projectionMode == PROJECTION_MODE_IDENTITY || 1695(project.projectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET && 1696(project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT || 1697project.coordinateSystem == COORDINATE_SYSTEM_CARTESIAN))) { 1698position_world.xyz -= project.coordinateOrigin; 1699} 1700return project_offset_(position_world) + project_offset_(project.modelMatrix * vec4(position64Low, 0.0)); 1701} 1702vec4 project_position(vec4 position) { 1703return project_position(position, ZERO_64_LOW); 1704} 1705vec3 project_position(vec3 position, vec3 position64Low) { 1706vec4 projected_position = project_position(vec4(position, 1.0), position64Low); 1707return projected_position.xyz; 1708} 1709vec3 project_position(vec3 position) { 1710vec4 projected_position = project_position(vec4(position, 1.0), ZERO_64_LOW); 1711return projected_position.xyz; 1712} 1713vec2 project_position(vec2 position) { 1714vec4 projected_position = project_position(vec4(position, 0.0, 1.0), ZERO_64_LOW); 1715return projected_position.xy; 1716} 1717vec4 project_common_position_to_clipspace(vec4 position, mat4 viewProjectionMatrix, vec4 center) { 1718return viewProjectionMatrix * position + center; 1719} 1720vec4 project_common_position_to_clipspace(vec4 position) { 1721return project_common_position_to_clipspace(position, project.viewProjectionMatrix, project.center); 1722} 1723vec2 project_pixel_size_to_clipspace(vec2 pixels) { 1724vec2 offset = pixels / project.viewportSize * project.devicePixelRatio * 2.0; 1725return offset * project.focalDistance; 1726} 1727float project_size_to_pixel(float meters) { 1728return project_size(meters) * project.scale; 1729} 1730vec2 project_size_to_pixel(vec2 meters) { 1731return project_size(meters) * project.scale; 1732} 1733float project_size_to_pixel(float size, int unit) { 1734if (unit == UNIT_METERS) return project_size_to_pixel(size); 1735if (unit == UNIT_COMMON) return size * project.scale; 1736return size; 1737} 1738float project_pixel_size(float pixels) { 1739return pixels / project.scale; 1740} 1741vec2 project_pixel_size(vec2 pixels) { 1742return pixels / project.scale; 1743} 1744`,
1744RA={};function CA(t=RA){return"viewport"in t?pA(t):{}}const Sa={name:"project",dependencies:[t0,Uu],source:AA,vs:PA,getUniforms:CA,uniformTypes:{wrapLongitude:"f32",coordinateSystem:"i32",commonUnitsPerMeter:"vec3<f32>",projectionMode:"i32",scale:"f32",commonUnitsPerWorldUnit:"vec3<f32>",commonUnitsPerWorldUnit2:"vec3<f32>",center:"vec4<f32>",modelMatrix:"mat4x4<f32>",viewProjectionMatrix:"mat4x4<f32>",viewportSize:"vec2<f32>",devicePixelRatio:"f32",focalDistance:"f32",cameraPosition:"vec3<f32>",coordinateOrigin:"vec3<f32>",commonOrigin:"vec3<f32>",pseudoMeters:"f32"}},MA=`// Define a structure to hold both the clip-space position and the common position. 1745struct ProjectResult { 1746 clipPosition: vec4<f32>, 1747 commonPosition: vec4<f32>, 1748}; 1749 1750// This function mimics the GLSL version with the 'out' parameter by returning both values. 1751fn project_position_to_clipspace_and_commonspace( 1752 position: vec3<f32>, 1753 position64Low: vec3<f32>, 1754 offset: vec3<f32> 1755) -> ProjectResult { 1756 // Compute the projected position. 1757 let projectedPosition: vec3<f32> = project_position_vec3_f64(position, position64Low); 1758 1759 // Start with the provided offset. 1760 var finalOffset: vec3<f32> = offset; 1761 1762 // Get whether a rotation is needed and the rotation matrix. 1763 let rotationResult = project_needs_rotation(projectedPosition); 1764 1765 // If rotation is needed, update the offset. 1766 if (rotationResult.needsRotation) { 1767 finalOffset = rotationResult.transform * offset; 1768 } 1769 1770 // Compute the common position. 1771 let commonPosition: vec4<f32> = vec4<f32>(projectedPosition + finalOffset, 1.0); 1772 1773 // Convert to clip-space. 1774 let clipPosition: vec4<f32> = project_common_position_to_clipspace(commonPosition); 1775 1776 return ProjectResult(clipPosition, commonPosition); 1777} 1778 1779// A convenience overload that returns only the clip-space position. 1780fn project_position_to_clipspace( 1781 position: vec3<f32>, 1782 position64Low: vec3<f32>, 1783 offset: vec3<f32> 1784) -> vec4<f32> { 1785 return project_position_to_clipspace_and_commonspace(position, position64Low, offset).clipPosition; 1786} 1787`,OA=`vec4 project_position_to_clipspace( 1788 vec3 position, vec3 position64Low, vec3 offset, out vec4 commonPosition 1789) { 1790 vec3 projectedPosition = project_position(position, position64Low); 1791 mat3 rotation; 1792 if (project_needs_rotation(projectedPosition, rotation)) { 1793 // offset is specified as ENU 1794 // when in globe projection, rotate offset so that the ground alighs with the surface of the globe 1795 offset = rotation * offset; 1796 } 1797 commonPosition = vec4(projectedPosition + offset, 1.0); 1798 return project_common_position_to_clipspace(commonPosition); 1799} 1800 1801vec4 project_position_to_clipspace( 1802 vec3 position, vec3 position64Low, vec3 offset 1803) { 1804 vec4 commonPosition; 1805 return project_position_to_clipspace(position, position64Low, offset, commonPosition); 1806} 1807`,kt={name:"project32",dependencies:[Sa],source:MA,vs:OA};function IA(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Jt(t,e){const i=gi([],e,t);return ya(i,i,1/i[3]),i}function Co(t,e,i){return t<e?e:t>i?i:t}function NA(t){return Math.log(t)*Math.LOG2E}const qu=Math.log2||NA;function Ze(t,e){if(!t)throw new Error(e||"@math.gl/web-mercator: assertion failed.")}const Me=Math.PI,Zu=Me/4,Se=Me/180,Mo=180/Me,oi=512,gs=4003e4,ct=85.051129,LA=1.5;function DA(t){return qu(t)}function gt(t){const[e,i]=t;Ze(Number.isFinite(e)),Ze(Number.isFinite(i)&&i>=-90&&i<=90,"invalid latitude");const n=e*Se,s=i*Se,r=oi*(n+Me)/(2*Me),o=oi*(Me+Math.log(Math.tan(Zu+s*.5)))/(2*Me);return[r,o]}function ai(t){const[e,i]=t,n=e/oi*(2*Me)-Me,s=2*(Math.atan(Math.exp(i/oi*(2*Me)-Me))-Zu);return[n*Mo,s*Mo]}function BA(t){const{latitude:e}=t;Ze(Number.isFinite(e));const i=Math.cos(e*Se);return DA(gs*i)-9}function Er(t){const e=Math.cos(t*Se);return oi/gs/e}function Oo(t){const{latitude:e,longitude:i,highPrecision:n=!1}=t;Ze(Number.isFinite(e)&&Number.isFinite(i));const s=oi,r=Math.cos(e*Se),o=s/360,a=o/r,c=s/gs/r,l={unitsPerMeter:[c,c,c],metersPerUnit:[1/c,1/c,1/c],unitsPerDegree:[o,a,c],degreesPerUnit:[1/o,1/a,1/c]};if(n){const f=Se*Math.tan(e*Se)/r,h=o*f/2,u=s/gs*f,d=u/a*c;l.unitsPerDegree2=[0,h,u],l.unitsPerMeter2=[d,0,d]}return l}function Gu(t,e){const[i,n,s]=t,[r,o,a]=e,{unitsPerMeter:c,unitsPerMeter2:l}=Oo({longitude:i,latitude:n,highPrecision:!0}),f=gt(t);f[0]+=r*(c[0]+l[0]*o),f[1]+=o*(c[1]+l[1]*o);const h=ai(f),u=(s||0)+(a||0);return Number.isFinite(s)||Number.isFinite(a)?[h[0],h[1],u]:h}function FA(t){const{height:e,pitch:i,bearing:n,altitude:s,scale:r,center:o}=t,a=IA();os(a,a,[0,0,-s]),hu(a,a,-i*Se),uu(a,a,n*Se);const c=r/e;return ma(a,a,[c,c,c]),o&&os(a,a,Yy([],o)),a}function kA(t){const{width:e,height:i,altitude:n,pitch:s=0,offset:r,center:o,scale:a,nearZMultiplier:c=1,farZMultiplier:l=1}=t;let{fovy:f=Zi(LA)}=t;n!==void 0&&(f=Zi(n));const h=f*Se,u=s*Se,d=Ea(f);let p=d;o&&(p+=o[2]*a/Math.cos(u)/i);const _=h*(.5+(r?r[1]:0)/i),m=Math.sin(_)*p/Math.sin(Co(Math.PI/2-u-_,.01,Math.PI-.01)),b=Math.sin(u)*m+p,A=p*10,v=Math.min(b*l,A);return{fov:h,aspect:e/i,focalDistance:d,near:c,far:v}}function Zi(t){return 2*Math.atan(.5/t)*Mo}function Ea(t){return .5/Math.tan(.5*t*Se)}function Qu(t,e){const[i,n,s=0]=t;return Ze(Number.isFinite(i)&&Number.isFinite(n)&&Number.isFinite(s)),Jt(e,[i,n,s,1])}function xa(t,e,i=0){const[n,s,r]=t;if(Ze(Number.isFinite(n)&&Number.isFinite(s),"invalid pixel coordinate"),Number.isFinite(r))return Jt(e,[n,s,r,1]);const o=Jt(e,[n,s,0,1]),a=Jt(e,[n,s,1,1]),c=o[2],l=a[2],f=c===l?0:((i||0)-c)/(l-c);return eu([],o,a,f)}function UA(t){const{width:e,height:i,bounds:n,minExtent:s=0,maxZoom:r=24,offset:o=[0,0]}=t,[[a,c],[l,f]]=n,h=zA(t.padding),u=gt([a,Co(f,-ct,ct)]),d=gt([l,Co(c,-ct,ct)]),p=[Math.max(Math.abs(d[0]-u[0]),s),Math.max(Math.abs(d[1]-u[1]),s)],_=[e-h.left-h.right-Math.abs(o[0])*2,i-h.top-h.bottom-Math.abs(o[1])*2];Ze(_[0]>0&&_[1]>0);const m=_[0]/p[0],b=_[1]/p[1],A=(h.right-h.left)/2/m,v=(h.top-h.bottom)/2/b,S=[(d[0]+u[0])/2+A,(d[1]+u[1])/2+v],E=ai(S),x=Math.min(r,qu(Math.abs(Math.min(m,b))));return Ze(Number.isFinite(x)),{longitude:E[0],latitude:E[1],zoom:x}}function zA(t=0){return typeof t=="number"?{top:t,bottom:t,left:t,right:t}:(Ze(Number.isFinite(t.top)&&Number.isFinite(t.bottom)&&Number.isFinite(t.left)&&Number.isFinite(t.right)),t)}const vl=Math.PI/180;function WA(t,e=0){const{width:i,height:n,unproject:s}=t,r={targetZ:e},o=s([0,n],r),a=s([i,n],r);let c,l;const f=t.fovy?.5*t.fovy*vl:Math.atan(.5/t.altitude),h=(90-t.pitch)*vl;return f>h-.01?(c=Tl(t,0,e),l=Tl(t,i,e)):(c=s([0,0],r),l=s([i,0],r)),[o,a,l,c]}function Tl(t,e,i){const{pixelUnprojectionMatrix:n}
1807=t,s=Jt(n,[e,0,1,1]),r=Jt(n,[e,t.height,1,1]),a=(i*t.distanceScales.unitsPerMeter[2]-s[2])/(r[2]-s[2]),c=eu([],s,r,a),l=ai(c);return l.push(i),l}const Ju=` 1808layout(std140) uniform shadowUniforms { 1809 bool drawShadowMap; 1810 bool useShadowMap; 1811 vec4 color; 1812 highp int lightId; 1813 float lightCount; 1814 mat4 viewProjectionMatrix0; 1815 mat4 viewProjectionMatrix1; 1816 vec4 projectCenter0; 1817 vec4 projectCenter1; 1818} shadow; 1819`,VA=` 1820const int max_lights = 2; 1821 1822out vec3 shadow_vPosition[max_lights]; 1823 1824vec4 shadow_setVertexPosition(vec4 position_commonspace) { 1825 mat4 viewProjectionMatrices[max_lights]; 1826 viewProjectionMatrices[0] = shadow.viewProjectionMatrix0; 1827 viewProjectionMatrices[1] = shadow.viewProjectionMatrix1; 1828 vec4 projectCenters[max_lights]; 1829 projectCenters[0] = shadow.projectCenter0; 1830 projectCenters[1] = shadow.projectCenter1; 1831 1832 if (shadow.drawShadowMap) { 1833 return project_common_position_to_clipspace(position_commonspace, viewProjectionMatrices[shadow.lightId], projectCenters[shadow.lightId]); 1834 } 1835 if (shadow.useShadowMap) { 1836 for (int i = 0; i < max_lights; i++) { 1837 if(i < int(shadow.lightCount)) { 1838 vec4 shadowMap_position = project_common_position_to_clipspace(position_commonspace, viewProjectionMatrices[i], projectCenters[i]); 1839 shadow_vPosition[i] = (shadowMap_position.xyz / shadowMap_position.w + 1.0) / 2.0; 1840 } 1841 } 1842 } 1843 return gl_Position; 1844} 1845`,$A=` 1846${Ju} 1847${VA} 1848`,jA=` 1849const int max_lights = 2; 1850uniform sampler2D shadow_uShadowMap0; 1851uniform sampler2D shadow_uShadowMap1; 1852 1853in vec3 shadow_vPosition[max_lights]; 1854 1855const vec4 bitPackShift = vec4(1.0, 255.0, 65025.0, 16581375.0); 1856const vec4 bitUnpackShift = 1.0 / bitPackShift; 1857const vec4 bitMask = vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0); 1858 1859float shadow_getShadowWeight(vec3 position, sampler2D shadowMap) { 1860 vec4 rgbaDepth = texture(shadowMap, position.xy); 1861 1862 float z = dot(rgbaDepth, bitUnpackShift); 1863 return smoothstep(0.001, 0.01, position.z - z); 1864} 1865 1866vec4 shadow_filterShadowColor(vec4 color) { 1867 if (shadow.drawShadowMap) { 1868 vec4 rgbaDepth = fract(gl_FragCoord.z * bitPackShift); 1869 rgbaDepth -= rgbaDepth.gbaa * bitMask; 1870 return rgbaDepth; 1871 } 1872 if (shadow.useShadowMap) { 1873 float shadowAlpha = 0.0; 1874 shadowAlpha += shadow_getShadowWeight(shadow_vPosition[0], shadow_uShadowMap0); 1875 if(shadow.lightCount > 1.0) { 1876 shadowAlpha += shadow_getShadowWeight(shadow_vPosition[1], shadow_uShadowMap1); 1877 } 1878 shadowAlpha *= shadow.color.a / shadow.lightCount; 1879 float blendedAlpha = shadowAlpha + color.a * (1.0 - shadowAlpha); 1880 1881 return vec4( 1882 mix(color.rgb, shadow.color.rgb, shadowAlpha / blendedAlpha), 1883 blendedAlpha 1884 ); 1885 } 1886 return color; 1887} 1888`,HA=` 1889${Ju} 1890${jA} 1891`,XA=an(GA),YA=an(QA),KA=[0,0,0,1],qA=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0];function ZA(t,e){const[i,n,s]=t,r=xa([i,n,s],e);return Number.isFinite(s)?r:[r[0],r[1],0]}function GA({viewport:t,center:e}){return new Le(t.viewProjectionMatrix).invert().transform(e)}function QA({viewport:t,shadowMatrices:e}){const i=[],n=t.pixelUnprojectionMatrix,s=t.isGeospatial?void 0:1,r=[[0,0,s],[t.width,0,s],[0,t.height,s],[t.width,t.height,s],[0,0,-1],[t.width,0,-1],[0,t.height,-1],[t.width,t.height,-1]].map(o=>ZA(o,n));for(const o of e){const a=o.clone().translate(new je(t.center).negate()),c=r.map(f=>a.transform(f)),l=new Le().ortho({left:Math.min(...c.map(f=>
1891f[0])),right:Math.max(...c.map(f=>f[0])),bottom:Math.min(...c.map(f=>f[1])),top:Math.max(...c.map(f=>f[1])),near:Math.min(...c.map(f=>-f[2])),far:Math.max(...c.map(f=>-f[2]))});i.push(l.multiplyRight(o))}return i}function JA(t){const{shadowEnabled:e=!0,project:i}=t;if(!e||!i||!t.shadowMatrices||!t.shadowMatrices.length)return{drawShadowMap:!1,useShadowMap:!1,shadow_uShadowMap0:t.dummyShadowMap,shadow_uShadowMap1:t.dummyShadowMap};const n=Sa.getUniforms(i),s=XA({viewport:i.viewport,center:n.center}),r=[],o=YA({shadowMatrices:t.shadowMatrices,viewport:i.viewport}).slice();for(let c=0;c<t.shadowMatrices.length;c++){const l=o[c],f=l.clone().translate(new je(i.viewport.center).negate());n.coordinateSystem===Xs("lnglat")&&n.projectionMode===ye.WEB_MERCATOR?(o[c]=f,r[c]=s):(o[c]=l.clone().multiplyRight(qA),r[c]=f.transform(s))}const a={drawShadowMap:!!t.drawToShadowMap,useShadowMap:t.shadowMaps?t.shadowMaps.length>0:!1,color:t.shadowColor||KA,lightId:t.shadowLightId||0,lightCount:t.shadowMatrices.length,shadow_uShadowMap0:t.dummyShadowMap,shadow_uShadowMap1:t.dummyShadowMap};for(let c=0;c<o.length;c++)a[`viewProjectionMatrix${c}`]=o[c],a[`projectCenter${c}`]=r[c];for(let c=0;c<2;c++)a[`shadow_uShadowMap${c}`]=t.shadowMaps&&t.shadowMaps[c]||t.dummyShadowMap;return a}const Al={name:"shadow",dependencies:[Sa],vs:$A,fs:HA,inject:{"vs:DECKGL_FILTER_GL_POSITION":` 1892 position = shadow_setVertexPosition(geometry.position); 1893 `,"fs:DECKGL_FILTER_COLOR":` 1894 color = shadow_filterShadowColor(color); 1895 `},getUniforms:JA,uniformTypes:{drawShadowMap:"f32",useShadowMap:"f32",color:"vec4<f32>",lightId:"i32",lightCount:"f32",viewProjectionMatrix0:"mat4x4<f32>",viewProjectionMatrix1:"mat4x4<f32>",projectCenter0:"vec4<f32>",projectCenter1:"vec4<f32>"}},ew=`struct pickingUniforms { 1896 isActive: f32, 1897 isAttribute: f32, 1898 isHighlightActive: f32, 1899 useByteColors: f32, 1900 highlightedObjectColor: vec3<f32>, 1901 highlightColor: vec4<f32>, 1902}; 1903 1904@group(0) @binding(auto) var<uniform> picking: pickingUniforms; 1905 1906fn picking_normalizeColor(color: vec3<f32>) -> vec3<f32> { 1907 return select(color, color / 255.0, picking.useByteColors > 0.5); 1908} 1909 1910fn picking_normalizeColor4(color: vec4<f32>) -> vec4<f32> { 1911 return select(color, color / 255.0, picking.useByteColors > 0.5); 1912} 1913 1914fn picking_isColorZero(color: vec3<f32>) -> bool { 1915 return dot(color, vec3<f32>(1.0)) < 0.00001; 1916} 1917 1918fn picking_isColorValid(color: vec3<f32>) -> bool { 1919 return dot(color, vec3<f32>(1.0)) > 0.00001; 1920} 1921`,Ut={...zc,source:ew,defaultUniforms:{...zc.defaultUniforms,useByteColors:!0},inject:{"vs:DECKGL_FILTER_GL_POSITION":` 1922 // for picking depth values 1923 picking_setPickingAttribute(position.z / position.w); 1924 `,"vs:DECKGL_FILTER_COLOR":` 1925 picking_setPickingColor(geometry.pickingColor); 1926 `,"fs:DECKGL_FILTER_COLOR":{order:99,injection:` 1927 // use highlight color if this fragment belongs to the selected object. 1928 color = picking_filterHighlightColor(color); 1929 1930 // use picking color if rendering to picking FBO. 1931 color = picking_filterPickingColor(color); 1932 `}}},tw=[Uu],iw=["vs:DECKGL_FILTER_SIZE(inout vec3 size, VertexGeometry geometry)","vs:DECKGL_FILTER_GL_POSITION(inout vec4 position, VertexGeometry geometry)","vs:DECKGL_FILTER_COLOR(inout vec4 color, VertexGeometry geometry)","fs:DECKGL_FILTER_COLOR(inout vec4 color, FragmentGeometry geometry)"],nw=[];function sw(t){const e=rs.getDefaultShaderAssembler();for(const n of tw)e.addDefaultModule(n);e._hookFunctions.length=0;const i=t==="glsl"?iw:nw;for(const n of i)e.addShaderHook(n);return e}const rw=[255,255,255],ow=1;let aw=0;class cw{constructor(e={}){this.type="ambient";const{color:i=rw}=e,{intensity:n=ow}=e;this.id=e.id||`ambient-${aw++}`,this.color=i,this.intensity=n}}const lw=[255,255,255],fw=1,hw=[0,0,-1];let uw=0;class wl{constructor(e={}){this.type="directional";const{color:i=lw}=e,{intensity:n=fw}=e,{direction:s=hw}=e,{_shadow:r=!1}=e;this.id=e.id||`directional-${uw++}`,this.color=i,this.intensity=n,this.type="directional",this.direction=new je(s).normalize().toArray(),this.shadow=r}getProjectedLight(e){return this}}class dw{constructor(e,i={id:"pass"}){const{id:n}=i;this.id=n,this.device=e,this.props={...i}}setProps(e){Object.assign(this.props,e)}render(e){}cleanup(){}}const gw={depthWriteEnabled:!0,depthCompare:"less-equal",blendColorOperation:"add",blendColorSrcFactor:"src-alpha",blendColorDstFactor:"one",blendAlphaOperation:"add",blendAlphaSrcFactor:"one-minus-dst-alpha",blendAlphaDstFactor:"one"};class Pa extends dw{constructor(){super(...arguments),this._lastRenderIndex=-1}render(e){this._render(e)}_render(e){const i=this.device.canvasContext,n=e.target??i.getCurrentFramebuffer(),[s,r]=i.getDrawingBufferSize(),o=e.clearCanvas??!0,a=e.clearColor??(o?[0,0,0,0]:!1),c=o?1:!1,l=o?0:!1,f=e.colorMask??15,h={viewport:[0,0,s,r]};e.colorMask&&(h.colorMask=f),e.scissorRect&&(h.scissorRect=e.scissorRect);const u=this.device.beginRenderPass({framebuffer:n,parameters:h,clearColor:a,clearDepth:c,clearStencil:l});try{return this._drawLayers(u,e)}finally{u.end(),this.device.submit()}}_drawLayers(e,i){const{target:n,shaderModuleProps:s,viewports:r,views:o,onViewportActive:a,clearStack:c=!0}=i;i.pass=i.pass||"unknown",c&&(this._lastRenderIndex=-1);const l=[];for(const f of r){const h=o&&o[f.id];a==null||a(f);const u=this._getDrawLayerParams(f,i),d=f.subViewports||[f];for(const p of d){const _=this._drawLayersInViewport(e,{target:n,shaderModuleProps:s,viewport:p,view:h,pass:i.pass,layers:i.layers},u);l.push(_)}}return l}_getDrawLayerParams(e,{layers:i,pass:n,isPicking:s=!1,layerFilter:r,cullRect:o,effects:a,shaderModuleProps:c},l=!1){var p;const f=[],h=ed(this._lastRenderIndex+1),u={layer:i[0],viewport:e,isPicking:s,renderPass:n,cullRect:o},d={};for(let _=0;_<i.length;_++){const m=i[_],b=this._shouldDrawLayer(m,u,r,d),A={shouldDrawLayer:b};if(b&&!l){A.shouldDrawLayer=!0,A.layerRenderIndex=h(m,b),A.shaderModuleProps=this._getShaderModuleProps(m,a,n,c);const v=m.context.device.type==="webgpu"?gw:null;A.layerParameters={...v,...(p=m.context.deck)==null?void 0:p.props.parameters,...this.getLayerParameters(m,_,e)}}f[_]=A}return f}_drawLayersInViewport(e,{layers:i,shaderModuleProps:n,pass:s,target:r,viewport:o,view:a},c){const l=pw(this.device,{shaderModuleProps:n,target:r,viewport:o});if(a){const{clear:h,clearColor:u,clearDepth:d,clearStencil:p}=a.props;if(h){let _=[0,0,0,0],m=1,b=0;Array.isArray(u)?_=[...u.slice(0,3),u[3]||255].map(v=>v/255):u===!1&&(_=!1),d!==void 0&&(m=d),p!==void 0&&(b=p),this.device.beginRenderPass({framebuffer:r,parameters:{viewport:l,scissorRect:l},clearColor:_,clearDepth:m,clearStencil:b}).end()}}const f={totalCount:i.length,visibleCount:0,compositeCount:0,pickableCount:0};e.setParameters({viewport:l});for(let h=0;h<i.length;h++){const u=i[h],d=c[h],{shouldDrawLayer:p}=d;if(p&&u.props.pickable&&f.pickableCount++,u.isComposite&&f.compositeCount++,u.isDrawable&&d.shouldDrawLayer){const{layerRenderIndex:_,shaderModuleProps:m,layerParameters:b}=d;f.visibleCount++,this._lastRenderIndex=Math.max(this._lastRenderIndex,_),m.project&&(m.project.viewport=o),u.context.renderPass=e;try{u._drawLayer({renderPass:e,shaderModuleProps:m,uniforms:{layerIndex:_},parameters:b})}catch(A){u.raiseError(A,`drawing ${u} to ${s}`)}}}return f}shouldDrawLayer(e){return!0}getShaderModuleProps(e,i,n){return null}getLayerParameters(e,i,n){return e.props.parameters}_shouldDrawLayer(e,i,n,s){if(!(e.props.visible&&this.shouldDrawLayer(e)))return!1;i.layer=e;let o=e.parent;for(;o;){if(!o.props.visible||!o.filterSubLayer(i))return!1;i.layer=o,o=o.parent}if(n){const a=i.layer.id;if(a in s||(s[a]=n(i)),!s[a])return!1}return e.activateViewport(i.viewport),!0}_getShaderModuleProps(e,i,n,s){var c,l;const r=this.device.canvasContext.cssToDeviceRatio(),o=((c=e.internalState)==null?void 0:c.propsInTransition)||e.props,a={layer:o,picking:{isActive:!1},project:{viewport:e.context.viewport,devicePixelRatio:r,modelMatrix:o.modelMatrix,coordinateSystem:o.coordinateSystem,coordinateOrigin:o.coordinateOrigin,autoWrapLongitude:e.wrapLongitude}};if(i)for(const f of i)Sl(a,(l=f.getShaderModuleProps)==null?void 0:l.call(f,e,a));
vendor: 5,171 bytes, line 1932
1932return Sl(a,this.getShaderModuleProps(e,i,a),s)}}function ed(t=0,e={}){const i={},n=(s,r)=>{const o=s.props._offset,a=s.id,c=s.parent&&s.parent.id;let l;if(c&&!(c in e)&&n(s.parent,!1),c in i){const f=i[c]=i[c]||ed(e[c],e);l=f(s,r),i[a]=f}else Number.isFinite(o)?(l=o+(e[c]||0),i[a]=null):l=t;return r&&l>=t&&(t=l+1),e[a]=l,l};return n}function pw(t,{shaderModuleProps:e,target:i,viewport:n}){var c;const s=((c=e==null?void 0:e.project)==null?void 0:c.devicePixelRatio)??t.canvasContext.cssToDeviceRatio(),[,r]=t.canvasContext.getDrawingBufferSize(),o=i?i.height:r,a=n;return[a.x*s,o-(a.y+a.height)*s,a.width*s,a.height*s]}function Sl(t,...e){for(const i of e)if(i)for(const n in i)t[n]?Object.assign(t[n],i[n]):t[n]=i[n];return t}class _w extends Pa{constructor(e,i){super(e,i);const n=e.createTexture({format:"rgba8unorm",width:1,height:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),s=e.createTexture({format:"depth16unorm",width:1,height:1});this.fbo=e.createFramebuffer({id:"shadowmap",width:1,height:1,colorAttachments:[n],depthStencilAttachment:s})}delete(){this.fbo&&(this.fbo.destroy(),this.fbo=null)}getShadowMap(){return this.fbo.colorAttachments[0].texture}render(e){const i=this.fbo,n=this.device.canvasContext.cssToDeviceRatio(),s=e.viewports[0],r=s.width*n,o=s.height*n,a=[1,1,1,1];(r!==i.width||o!==i.height)&&i.resize({width:r,height:o}),super.render({...e,clearColor:a,target:i,pass:"shadow"})}getLayerParameters(e,i,n){return{...e.props.parameters,blend:!1,depthWriteEnabled:!0,depthCompare:"less-equal"}}shouldDrawLayer(e){return e.props.shadowEnabled!==!1}getShaderModuleProps(e,i,n){return{shadow:{project:n.project,drawToShadowMap:!0}}}}const mw={color:[255,255,255],intensity:1},El=[{color:[255,255,255],intensity:1,direction:[-1,3,-1]},{color:[255,255,255],intensity:.9,direction:[1,-8,-2.5]}],yw=[0,0,0,200/255];class td{constructor(e={}){this.id="lighting-effect",this.shadowColor=yw,this.shadow=!1,this.directionalLights=[],this.pointLights=[],this.shadowPasses=[],this.dummyShadowMap=null,this.setProps(e)}setup(e){this.context=e;const{device:i,deck:n}=e;this.shadow&&!this.dummyShadowMap&&(this._createShadowPasses(i),n._addDefaultShaderModule(Al),this.dummyShadowMap=i.createTexture({width:1,height:1}))}setProps(e){this.ambientLight=void 0,this.directionalLights=[],this.pointLights=[];for(const i in e){const n=e[i];switch(n.type){case"ambient":this.ambientLight=n;break;case"directional":this.directionalLights.push(n);break;case"point":this.pointLights.push(n);break}}this._applyDefaultLights(),this.shadow=this.directionalLights.some(i=>i.shadow),this.context&&this.setup(this.context),this.props=e}preRender({layers:e,layerFilter:i,viewports:n,onViewportActive:s,views:r}){if(this.shadow){this.shadowMatrices=this._calculateMatrices();for(let o=0;o<this.shadowPasses.length;o++)this.shadowPasses[o].render({layers:e,layerFilter:i,viewports:n,onViewportActive:s,views:r,shaderModuleProps:{shadow:{shadowLightId:o,dummyShadowMap:this.dummyShadowMap,shadowMatrices:this.shadowMatrices}}})}}getShaderModuleProps(e,i){const n=this.shadow?{project:i.project,shadowMaps:this.shadowPasses.map(o=>o.getShadowMap()),dummyShadowMap:this.dummyShadowMap,shadowColor:this.shadowColor,shadowMatrices:this.shadowMatrices}:{},s={enabled:!0,lights:this._getLights(e)},r=e.props.material;return{shadow:n,lighting:s,phongMaterial:r,gouraudMaterial:r}}cleanup(e){for(const i of this.shadowPasses)i.delete();this.shadowPasses.length=0,this.dummyShadowMap&&(this.dummyShadowMap.destroy(),this.dummyShadowMap=null,e.deck._removeDefaultShaderModule(Al))}_calculateMatrices(){const e=[];for(const i of this.directionalLights){const n=new Le().lookAt({eye:new je(i.direction).negate()});e.push(n)}return e}_createShadowPasses(e){for(let i=0;i<this.directionalLights.length;i++){const n=new _w(e);this.shadowPasses[i]=n}}_applyDefaultLights(){const{ambientLight:e,pointLights:i,directionalLights:n}=this;!e&&i.length===0&&n.length===0&&(this.ambientLight=new cw(mw),this.directionalLights.push(new wl(El[0]),new wl(El[1])))}_getLights(e){const i=[];this.ambientLight&&i.push(this.ambientLight);for(const n of this.pointLights)i.push(n.getProjectedLight({layer:e}));for(const n of this.directionalLights)i.push(n.getProjectedLight({layer:e}));return i}}class bw{constructor(e={}){this._pool=[],this.opts={overAlloc:2,poolSize:100},this.setOptions(e)}setOptions(e){Object.assign(this.opts,e)}allocate(e,i,{size:n=1,type:s,padding:r=0,copy:o=!1,initialize:a=!1,maxCount:c}){const l=s||e&&e.constructor||Float32Array,f=i*n+r;if(ArrayBuffer.isView(e)){if(f<=e.length)return e;if(f*e.BYTES_PER_ELEMENT<=e.buffer.byteLength)return new l(e.buffer,0,f)}let h=1/0;c&&(h=c*n+r);const u=this._allocate(l,f,a,h);return e&&o?u.set(e):a||u.fill(0,0,4),this._release(e),u}release(e){this._release(e)}_allocate(e,i,n,s){let r=Math.max(Math.ceil(i*this.opts.overAlloc),1);r>s&&(r=s);const o=this._pool,a=e.BYTES_PER_ELEMENT*r,c=o.findIndex(l=>l.byteLength>=a);if(c>=0){const l=new e(o.splice(c,1)[0],0,r);return n&&l.fill(0),l}return new e(r)}_release(e){if(!ArrayBuffer.isView(e))return;const i=this._pool,{buffer:n}
vendor: 8,287 bytes, line 1932
1932=e,{byteLength:s}=n,r=i.findIndex(o=>o.byteLength>=s);r<0?i.push(n):(r>0||i.length<this.opts.poolSize)&&i.splice(r,0,n),i.length>this.opts.poolSize&&i.shift()}}const ci=new bw;function Mi(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function xl(t,e){const i=t%e;return i<0?e+i:i}function vw(t){return[t[12],t[13],t[14]]}function Tw(t){return{left:Vt(t[3]+t[0],t[7]+t[4],t[11]+t[8],t[15]+t[12]),right:Vt(t[3]-t[0],t[7]-t[4],t[11]-t[8],t[15]-t[12]),bottom:Vt(t[3]+t[1],t[7]+t[5],t[11]+t[9],t[15]+t[13]),top:Vt(t[3]-t[1],t[7]-t[5],t[11]-t[9],t[15]-t[13]),near:Vt(t[3]+t[2],t[7]+t[6],t[11]+t[10],t[15]+t[14]),far:Vt(t[3]-t[2],t[7]-t[6],t[11]-t[10],t[15]-t[14])}}const Pl=new je;function Vt(t,e,i,n){Pl.set(t,e,i);const s=Pl.len();return{distance:n/s,normal:new je(-t/s,-e/s,-i/s)}}function Aw(t){return t-Math.fround(t)}let Ai;function xr(t,e){const{size:i=1,startIndex:n=0}=e,s=e.endIndex!==void 0?e.endIndex:t.length,r=(s-n)/i;Ai=ci.allocate(Ai,r,{type:Float32Array,size:i*2});let o=n,a=0;for(;o<s;){for(let c=0;c<i;c++){const l=t[o++];Ai[a+c]=l,Ai[a+c+i]=Aw(l)}a+=i*2}return Ai.subarray(0,r*i*2)}function ww(t){let e=null,i=!1;for(const n of t)n&&(e?(i||(e=[[e[0][0],e[0][1]],[e[1][0],e[1][1]]],i=!0),e[0][0]=Math.min(e[0][0],n[0][0]),e[0][1]=Math.min(e[0][1],n[0][1]),e[1][0]=Math.max(e[1][0],n[1][0]),e[1][1]=Math.max(e[1][1],n[1][1])):e=n);return e}const Sw=Math.PI/180,Ew=Mi(),Rl=[0,0,0],xw={unitsPerMeter:[1,1,1],metersPerUnit:[1,1,1]};function Pw({width:t,height:e,orthographic:i,fovyRadians:n,focalDistance:s,padding:r,near:o,far:a}){const c=t/e,l=i?new Le().orthographic({fovy:n,aspect:c,focalDistance:s,near:o,far:a}):new Le().perspective({fovy:n,aspect:c,near:o,far:a});if(r){const{left:f=0,right:h=0,top:u=0,bottom:d=0}=r,p=Re((f+t-h)/2,0,t)-t/2,_=Re((u+e-d)/2,0,e)-e/2;l[8]-=p*2/t,l[9]+=_*2/e}return l}class pi{constructor(e={}){this._frustumPlanes={},this.id=e.id||this.constructor.displayName||"viewport",this.x=e.x||0,this.y=e.y||0,this.width=e.width||1,this.height=e.height||1,this.zoom=e.zoom||0,this.padding=e.padding,this.distanceScales=e.distanceScales||xw,this.focalDistance=e.focalDistance||1,this.position=e.position||Rl,this.modelMatrix=e.modelMatrix||null;const{longitude:i,latitude:n}=e;this.isGeospatial=Number.isFinite(n)&&Number.isFinite(i),this._initProps(e),this._initMatrices(e),this.equals=this.equals.bind(this),this.project=this.project.bind(this),this.unproject=this.unproject.bind(this),this.projectPosition=this.projectPosition.bind(this),this.unprojectPosition=this.unprojectPosition.bind(this),this.projectFlat=this.projectFlat.bind(this),this.unprojectFlat=this.unprojectFlat.bind(this)}get subViewports(){return null}get metersPerPixel(){return this.distanceScales.metersPerUnit[2]/this.scale}get projectionMode(){return this.isGeospatial?this.zoom<12?ye.WEB_MERCATOR:ye.WEB_MERCATOR_AUTO_OFFSET:ye.IDENTITY}equals(e){return e instanceof pi?this===e?!0:e.width===this.width&&e.height===this.height&&e.scale===this.scale&&Ki(e.projectionMatrix,this.projectionMatrix)&&Ki(e.viewMatrix,this.viewMatrix):!1}project(e,{topLeft:i=!0}={}){const n=this.projectPosition(e),s=Qu(n,this.pixelProjectionMatrix),[r,o]=s,a=i?o:this.height-o;return e.length===2?[r,a]:[r,a,s[2]]}unproject(e,{topLeft:i=!0,targetZ:n}={}){const[s,r,o]=e,a=i?r:this.height-r,c=n&&n*this.distanceScales.unitsPerMeter[2],l=xa([s,a,o],this.pixelUnprojectionMatrix,c),[f,h,u]=this.unprojectPosition(l);return Number.isFinite(o)?[f,h,u]:Number.isFinite(n)?[f,h,n]:[f,h]}projectPosition(e){const[i,n]=this.projectFlat(e),s=(e[2]||0)*this.distanceScales.unitsPerMeter[2];return[i,n,s]}unprojectPosition(e){const[i,n]=this.unprojectFlat(e),s=(e[2]||0)*this.distanceScales.metersPerUnit[2];return[i,n,s]}projectFlat(e){if(this.isGeospatial){const i=gt(e);return i[1]=Re(i[1],-318,830),i}return e}unprojectFlat(e){return this.isGeospatial?ai(e):e}getBounds(e={}){const i={targetZ:e.z||0},n=this.unproject([0,0],i),s=this.unproject([this.width,0],i),r=this.unproject([0,this.height],i),o=this.unproject([this.width,this.height],i);return[Math.min(n[0],s[0],r[0],o[0]),Math.min(n[1],s[1],r[1],o[1]),Math.max(n[0],s[0],r[0],o[0]),Math.max(n[1],s[1],r[1],o[1])]}getDistanceScales(e){return e&&this.isGeospatial?Oo({longitude:e[0],latitude:e[1],highPrecision:!0}):this.distanceScales}containsPixel({x:e,y:i,width:n=1,height:s=1}){return e<this.x+this.width&&this.x<e+n&&i<this.y+this.height&&this.y<i+s}getFrustumPlanes(){return this._frustumPlanes.near?this._frustumPlanes:(Object.assign(this._frustumPlanes,Tw(this.viewProjectionMatrix)),this._frustumPlanes)}panByPosition(e,i,n){return null}_initProps(e){const i=e.longitude,n=e.latitude;this.isGeospatial&&(Number.isFinite(e.zoom)||(this.zoom=BA({latitude:n})+Math.log2(this.focalDistance)),this.distanceScales=e.distanceScales||Oo({latitude:n,longitude:i}));const s=Math.pow(2,this.zoom);this.scale=s;const{position:r,modelMatrix:o}=e;let a=Rl;if(r&&(a=o?new Le(o).transformAsVector(r,[]):r),this.isGeospatial){const c=this.projectPosition([i,n,0]);this.center=new je(a).scale(this.distanceScales.unitsPerMeter).add(c)}else this.center=this.projectPosition(a)}_initMatrices(e){const{viewMatrix:i=Ew,projectionMatrix:n=null,orthographic:s=!1,fovyRadians:r,fovy:o=75,near:a=.1,far:c=1e3,padding:l=null,focalDistance:f=1}=e;this.viewMatrixUncentered=i,this.viewMatrix=new Le().multiplyRight(i).translate(new je(this.center).negate()),this.projectionMatrix=n||Pw({width:this.width,height:this.height,orthographic:s,fovyRadians:r||o*Sw,focalDistance:f,padding:l,near:a,far:c});const h=Mi();St(h,h,this.projectionMatrix),St(h,h,this.viewMatrix),this.viewProjectionMatrix=h,this.viewMatrixInverse=lo([],this.viewMatrix)||this.viewMatrix,this.cameraPosition=vw(this.viewMatrixInverse);const u=Mi(),d=Mi();ma(u,u,[this.width/2,-this.height/2,1]),os(u,u,[1,-1,0]),St(d,u,this.viewProjectionMatrix),this.pixelProjectionMatrix=d,this.pixelUnprojectionMatrix=lo(Mi(),this.pixelProjectionMatrix),this.pixelUnprojectionMatrix||j.warn("Pixel project matrix not invertible")()}}pi.displayName="Viewport";class li extends pi{constructor(e={}){const{latitude:i=0,longitude:n=0,zoom:s=0,pitch:r=0,bearing:o=0,nearZMultiplier:a=.1,farZMultiplier:c=1.01,nearZ:l,farZ:f,orthographic:h=!1,projectionMatrix:u,repeat:d=!1,worldOffset:p=0,position:_,padding:m,legacyMeterSizes:b=!1}=e;let{width:A,height:v,altitude:S=1.5}=e;const E=Math.pow(2,s);A=A||1,v=v||1;let x,M=null;if(u)S=u[5]/2,x=Zi(S);else{e.fovy?(x=e.fovy,S=Ea(x)):x=Zi(S);let N;if(m){const{top:D=0,bottom:B=0}=m;N=[0,Re((D+v-B)/2,0,v)-v/2]}M=kA({width:A,height:v,scale:E,center:_&&[0,0,_[2]*Er(i)],offset:N,pitch:r,fovy:x,nearZMultiplier:a,farZMultiplier:c}),Number.isFinite(l)&&(M.near=l),Number.isFinite(f)&&(M.far=f)}let O=FA({height:v,pitch:r,bearing:o,scale:E,altitude:S});p&&(O=new Le().translate([512*p,0,0]).multiplyLeft(O)),super({...e,width:A,height:v,viewMatrix:O,longitude:n,latitude:i,zoom:s,...M,fovy:x,focalDistance:S}),this.latitude=i,this.longitude=n,this.zoom=s,this.pitch=r,this.bearing=o,this.altitude=S,this.fovy=x,this.orthographic=h,this._subViewports=d?[]:null,this._pseudoMeters=b,Object.freeze(this)}get subViewports(){if(this._subViewports&&!this._subViewports.length){const e=this.getBounds(),i=Math.floor((e[0]+180)/360),n=Math.ceil((e[2]-180)/360);for(let s=i;s<=n;s++){const r=s?new li({...this,worldOffset:s}):this;this._subViewports.push(r)}}return this._subViewports}projectPosition(e){if(this._pseudoMeters)return super.projectPosition(e);const[i,n]=this.projectFlat(e),s=(e[2]||0)*Er(e[1]);return[i,n,s]}unprojectPosition(e){if(this._pseudoMeters)return super.unprojectPosition(e);const[i,n]=this.unprojectFlat(e),s=(e[2]||0)/Er(n);return[i,n,s]}addMetersToLngLat(e,i){return Gu(e,i)}panByPosition(e,i,n){const s=xa(i,this.pixelUnprojectionMatrix),r=this.projectFlat(e),o=Oc([],r,Fy([],s)),a=Oc([],this.center,o),[c,l]=this.unprojectFlat(a);return{longitude:c,latitude:l}}panByPosition3D(e,i){const n=e[2]||0,s=zy([],e,this.unproject(i,{targetZ:n}));return{longitude:this.longitude+s[0],latitude:this.latitude+s[1]}}getBounds(e={}){const i=WA(this,e.z||0);return[Math.min(i[0][0],i[1][0],i[2][0],i[3][0]),Math.min(i[0][1],i[1][1],i[2][1],i[3][1]),Math.max(i[0][0],i[1][0],i[2][0],i[3][0]),Math.max(i[0][1],i[1][1],i[2][1],i[3][1])]}fitBounds(e,i={}){const{width:n,height:s}
vendor: 1,779 bytes, line 1932
1932=this,{longitude:r,latitude:o,zoom:a}=UA({width:n,height:s,bounds:e,...i});return new li({width:n,height:s,longitude:r,latitude:o,zoom:a})}}li.displayName="WebMercatorViewport";const Cl=[0,0,0];function Pr(t,e,i=!1){const n=e.projectPosition(t);if(i&&e instanceof li){const[s,r,o=0]=t,a=e.getDistanceScales([s,r]);n[2]=o*a.unitsPerMeter[2]}return n}function Rw(t){const{viewport:e,modelMatrix:i,coordinateOrigin:n}=t;let{coordinateSystem:s,fromCoordinateSystem:r,fromCoordinateOrigin:o}=t;return s==="default"&&(s=e.isGeospatial?"lnglat":"cartesian"),r===void 0?r=s:r==="default"&&(r=e.isGeospatial?"lnglat":"cartesian"),o===void 0&&(o=n),{viewport:e,coordinateSystem:s,coordinateOrigin:n,modelMatrix:i,fromCoordinateSystem:r,fromCoordinateOrigin:o}}function Ra(t,{viewport:e,modelMatrix:i,coordinateSystem:n,coordinateOrigin:s,offsetMode:r}){let[o,a,c=0]=t;switch(i&&([o,a,c]=gi([],[o,a,c,1],i)),n){case"default":return Ra(t,{viewport:e,modelMatrix:i,coordinateSystem:e.isGeospatial?"lnglat":"cartesian",coordinateOrigin:s,offsetMode:r});case"lnglat":return Pr([o,a,c],e,r);case"lnglat-offsets":return Pr([o+s[0],a+s[1],c+(s[2]||0)],e,r);case"meter-offsets":return Pr(Gu(s,[o,a,c]),e,r);case"cartesian":return e.isGeospatial?[o+s[0],a+s[1],c+s[2]]:e.projectPosition([o,a,c]);default:throw new Error(`Invalid coordinateSystem: ${n}`)}}function id(t,e){const{viewport:i,coordinateSystem:n,coordinateOrigin:s,modelMatrix:r,fromCoordinateSystem:o,fromCoordinateOrigin:a}=Rw(e),{autoOffset:c=!0}=e,{geospatialOrigin:l=Cl,shaderCoordinateOrigin:f=Cl,offsetMode:h=!1}=c?Ku(i,n,s):{},u=Ra(t,{viewport:i,modelMatrix:r,coordinateSystem:o,coordinateOrigin:a,offsetMode:h});if(h){const d=i.projectPosition(l||f);au(u,u,d)}return u}const Cw=[255,255,255],Mw=1,Ow=[1,0,0],Iw=[0,0,1];let Nw=0;
1932class B2{constructor(e={}){this.type="point";const{color:i=Cw}=e,{intensity:n=Mw}=e,{position:s=Iw}=e;this.id=e.id||`point-${Nw++}`,this.color=i,this.intensity=n,this.type="point",this.position=s,this.attenuation=Lw(e),this.projectedLight={...this}}getProjectedLight({layer:e}){const{projectedLight:i}=this,n=e.context.viewport,{coordinateSystem:s,coordinateOrigin:r}=e.props,o=id(this.position,{viewport:n,coordinateSystem:s,coordinateOrigin:r,fromCoordinateSystem:n.isGeospatial?ds.LNGLAT:ds.CARTESIAN,fromCoordinateOrigin:[0,0,0]});return i.color=this.color,i.intensity=this.intensity,i.position=o,i}}function Lw(t){return t.attenuation?t.attenuation:Ow}let Dw=1,Bw=1;class nd{constructor(){g(this,"time",0);g(this,"channels",new Map);g(this,"animations",new Map);g(this,"playing",!1);g(this,"lastEngineTime",-1)}addChannel(e){const{delay:i=0,duration:n=Number.POSITIVE_INFINITY,rate:s=1,repeat:r=1}=e,o=Dw++,a={time:0,delay:i,duration:n,rate:s,repeat:r};return this._setChannelTime(a,this.time),this.channels.set(o,a),o}removeChannel(e){this.channels.delete(e);for(const[i,n]of this.animations)n.channel===e&&this.detachAnimation(i)}isFinished(e){const i=this.channels.get(e);return i===void 0?!1:this.time>=i.delay+i.duration*i.repeat}getTime(e){if(e===void 0)return this.time;const i=this.channels.get(e);return i===void 0?-1:i.time}setTime(e){this.time=Math.max(0,e);const i=this.channels.values();for(const s of i)this._setChannelTime(s,this.time);const n=this.animations.values();for(const s of n){const{animation:r,channel:o}=s;r.setTime(this.getTime(o))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(e,i){const n=Bw++;return this.animations.set(n,{animation:e,channel:i}),e.setTime(this.getTime(i)),n}detachAnimation(e){this.animations.delete(e)}update(e){this.playing&&(this.lastEngineTime===-1&&(this.lastEngineTime=e),this.setTime(this.time+(e-this.lastEngineTime)),this.lastEngineTime=e)}_setChannelTime(e,i){const n=i-e.delay,s=e.duration*e.repeat;n>=s?e.time=e.duration*e.rate:(e.time=Math.max(0,n)%e.duration,e.time*=e.rate)}}function Fw(t){const e=typeof window<"u"?window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame:null;return e?e.call(window,t):setTimeout(()=>t(typeof performance<"u"?performance.now():Date.now()),1e3/60)}function kw(t){const e=typeof window<"u"?window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame:null;if(e){e.call(window,t);return}clearTimeout(t)}let Uw=0;const zw="Animation Loop",ks=class ks{constructor(e){g(this,"device",null);g(this,"canvas",null);g(this,"props");g(this,"animationProps",null);g(this,"timeline",null);g(this,"stats");g(this,"sharedStats");g(this,"cpuTime");g(this,"gpuTime");g(this,"frameRate");g(this,"display");g(this,"_needsRedraw","initialized");g(this,"_initialized",!1);g(this,"_running",!1);g(this,"_animationFrameId",null);g(this,"_nextFramePromise",null);g(this,"_resolveNextFrame",null);g(this,"_cpuStartTime",0);g(this,"_error",null);g(this,"_lastFrameTime",0);if(this.props={...ks.defaultAnimationLoopProps,...e},e=this.props,!e.device)throw new Error("No device provided");this.stats=e.stats||new nn({id:`animation-loop-${Uw++}`}),this.sharedStats=go.stats.get(zw),this.frameRate=this.stats.get("Frame Rate"),this.frameRate.setSampleSize(1),this.cpuTime=this.stats.get("CPU Time"),this.gpuTime=this.stats.get("GPU Time"),this.setProps({autoResizeViewport:e.autoResizeViewport}),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onMouseleave=this._onMouseleave.bind(this)}destroy(){var e;this.stop(),this._setDisplay(null),(e=this.device)==null||e._disableDebugGPUTime()}delete(){this.destroy()}reportError(e){this.props.onError(e),this._error=e}setNeedsRedraw(e){return this._needsRedraw=this._needsRedraw||e,this}needsRedraw(){const e=this._needsRedraw;return this._needsRedraw=!1,e}setProps(e){return"autoResizeViewport"in e&&(this.props.autoResizeViewport=e.autoResizeViewport||!1),this}
1932async start(){if(this._running)return this;this._running=!0;try{let e;if(!this._initialized){if(this._initialized=!0,await this._initDevice(),this._initialize(),!this._running)return null;await this.props.onInitialize(this._getAnimationProps())}return this._running?(e!==!1&&(this._cancelAnimationFrame(),this._requestAnimationFrame()),this):null}catch(e){const i=e instanceof Error?e:new Error("Unknown error");throw this.props.onError(i),i}}stop(){return this._running&&(this.animationProps&&!this._error&&this.props.onFinalize(this.animationProps),this._cancelAnimationFrame(),this._nextFramePromise=null,this._resolveNextFrame=null,this._running=!1,this._lastFrameTime=0),this}redraw(e){var i;return(i=this.device)!=null&&i.isLost||this._error?this:(this._beginFrameTimers(e),this._setupFrame(),this._updateAnimationProps(),this._renderFrame(this._getAnimationProps()),this._clearNeedsRedraw(),this._resolveNextFrame&&(this._resolveNextFrame(this),this._nextFramePromise=null,this._resolveNextFrame=null),this._endFrameTimers(),this)}attachTimeline(e){return this.timeline=e,this.timeline}detachTimeline(){this.timeline=null}waitForRender(){return this.setNeedsRedraw("waitForRender"),this._nextFramePromise||(this._nextFramePromise=new Promise(e=>{this._resolveNextFrame=e})),this._nextFramePromise}async toDataURL(){if(this.setNeedsRedraw("toDataURL"),await this.waitForRender(),this.canvas instanceof HTMLCanvasElement)return this.canvas.toDataURL();throw new Error("OffscreenCanvas")}_initialize(){var e;this._startEventHandling(),this._initializeAnimationProps(),this._updateAnimationProps(),this._resizeViewport(),(e=this.device)==null||e._enableDebugGPUTime()}_setDisplay(e){this.display&&(this.display.destroy(),this.display.animationLoop=null),e&&(e.animationLoop=this),this.display=e}_requestAnimationFrame(){this._running&&(this._animationFrameId=Fw(this._animationFrame.bind(this)))}_cancelAnimationFrame(){this._animationFrameId!==null&&(kw(this._animationFrameId),this._animationFrameId=null)}_animationFrame(e){this._running&&(this.redraw(e),this._requestAnimationFrame())}_renderFrame(e){var i;if(this.display){this.display._renderFrame(e);return}this.props.onRender(this._getAnimationProps()),(i=this.device)==null||i.submit()}_clearNeedsRedraw(){this._needsRedraw=!1}_setupFrame(){this._resizeViewport()}_initializeAnimationProps(){var s;const e=(s=this.device)==null?void 0:s.getDefaultCanvasContext();if(!this.device||!e)throw new Error("loop");const i=e==null?void 0:e.canvas,n=e.props.useDevicePixels;this.animationProps={animationLoop:this,device:this.device,canvasContext:e,canvas:i,useDevicePixels:n,timeline:this.timeline,needsRedraw:!1,width:1,height:1,aspect:1,time:0,startTime:Date.now(),engineTime:0,tick:0,tock:0,_mousePosition:null}}_getAnimationProps(){if(!this.animationProps)throw new Error("animationProps");return this.animationProps}_updateAnimationProps(){if(!this.animationProps)return;const{width:e,height:i,aspect:n}=this._getSizeAndAspect();(e!==this.animationProps.width||i!==this.animationProps.height)&&this.setNeedsRedraw("drawing buffer resized"),n!==this.animationProps.aspect&&this.setNeedsRedraw("drawing buffer aspect changed"),this.animationProps.width=e,this.animationProps.height=i,this.animationProps.aspect=n,this.animationProps.needsRedraw=this._needsRedraw,this.animationProps.engineTime=Date.now()-this.animationProps.startTime,this.timeline&&this.timeline.update(this.animationProps.engineTime),this.animationProps.tick=Math.floor(this.animationProps.time/1e3*60),this.animationProps.tock++,this.animationProps.time=this.timeline?this.timeline.getTime():this.animationProps.engineTime}async _initDevice(){if(this.device=await this.props.device,!this.device)throw new Error("No device provided");this.canvas=this.device.getDefaultCanvasContext().canvas||null}_createInfoDiv(){if(this.canvas&&this.props.onAddHTML){const e=document.createElement("div");document.body.appendChild(e),e.style.position="relative";const i=document.createElement("div");i.style.position="absolute",i.style.left="10px",i.style.bottom="10px",i.style.width="300px",i.style.background="white",this.canvas instanceof HTMLCanvasElement&&e.appendChild(this.canvas),e.appendChild(i);const n=this.props.onAddHTML(i);n&&(i.innerHTML=n)}}_getSizeAndAspect(){if(!this.device)return{width:1,height:1,aspect:1};const[e,i]=this.device.getDefaultCanvasContext().getDrawingBufferSize(),n=e>0&&i>0?e/i:1;return{width:e,height:i,aspect:n}}_resizeViewport(){this.props.autoResizeViewport&&this.device.gl&&this.device.gl.viewport(0,0,this.device.gl.drawingBufferWidth,this.device.gl.drawingBufferHeight)}_beginFrameTimers(e){var n;const i=e??(typeof performance<"u"?performance.now():Date.now());if(this._lastFrameTime){const s=i-this._lastFrameTime;s>0&&this.frameRate.addTime(s)}this._lastFrameTime=i,(n=this.device)!=null&&n._isDebugGPUTimeEnabled()&&this._consumeEncodedGpuTime(),this.cpuTime.timeStart()}_endFrameTimers(){var e;(e=this.device)!=null&&e._isDebugGPUTimeEnabled()&&this._consumeEncodedGpuTime(),this.cpuTime.timeEnd(),this._updateSharedStats()}_consumeEncodedGpuTime(){if(!this.device)return;const e=this.device.commandEncoder._gpuTimeMs;e!==void 0&&(this.gpuTime.addTime(e),this.device.commandEncoder._gpuTimeMs=void 0)}_updateSharedStats(){if(this.stats!==this.sharedStats){for(const e of Object.keys(this.sharedStats.stats)
1932)this.stats.stats[e]||delete this.sharedStats.stats[e];this.stats.forEach(e=>{const i=this.sharedStats.get(e.name,e.type);i.sampleSize=e.sampleSize,i.time=e.time,i.count=e.count,i.samples=e.samples,i.lastTiming=e.lastTiming,i.lastSampleTime=e.lastSampleTime,i.lastSampleCount=e.lastSampleCount,i._count=e._count,i._time=e._time,i._samples=e._samples,i._startTime=e._startTime,i._timerPending=e._timerPending})}}_startEventHandling(){this.canvas&&(this.canvas.addEventListener("mousemove",this._onMousemove.bind(this)),this.canvas.addEventListener("mouseleave",this._onMouseleave.bind(this)))}_onMousemove(e){e instanceof MouseEvent&&(this._getAnimationProps()._mousePosition=[e.offsetX,e.offsetY])}_onMouseleave(e){this._getAnimationProps()._mousePosition=null}};g(ks,"defaultAnimationLoopProps",{device:null,onAddHTML:()=>"",onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:e=>console.error(e),stats:void 0,autoResizeViewport:!1});let Io=ks;const Rr={};function Ys(t="id"){Rr[t]=Rr[t]||1;const e=Rr[t]++;return`${t}-${e}`}class Ml{constructor(e){g(this,"id");g(this,"userData",{});g(this,"topology");g(this,"bufferLayout",[]);g(this,"vertexCount");g(this,"indices");g(this,"attributes");if(this.id=e.id||Ys("geometry"),this.topology=e.topology,this.indices=e.indices||null,this.attributes=e.attributes,this.vertexCount=e.vertexCount,this.bufferLayout=e.bufferLayout||[],this.indices&&!(this.indices.usage&Z.INDEX))throw new Error("Index buffer must have INDEX usage")}destroy(){var e;(e=this.indices)==null||e.destroy();for(const i of Object.values(this.attributes))i.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices||null}_calculateVertexCount(e){return e.byteLength/12}}function Ww(t,e){if(e instanceof Ml)return e;const i=Vw(t,e),{attributes:n,bufferLayout:s}=$w(t,e);return new Ml({topology:e.topology||"triangle-list",bufferLayout:s,vertexCount:e.vertexCount,indices:i,attributes:n})}function Vw(t,e){if(!e.indices)return;const i=e.indices.value;return t.createBuffer({usage:Z.INDEX,data:i})}function $w(t,e){const i=[],n={};for(const[r,o]of Object.entries(e.attributes)){let a=r;switch(r){case"POSITION":a="positions";break;case"NORMAL":a="normals";break;case"TEXCOORD_0":a="texCoords";break;case"TEXCOORD_1":a="texCoords1";break;case"COLOR_0":a="colors";break}if(o){n[a]=t.createBuffer({data:o.value,id:`${r}-buffer`});const{value:c,size:l,normalized:f}=o;if(l===void 0)throw new Error(`Attribute ${r} is missing a size`);i.push({name:a,format:qi.getVertexFormatFromAttribute(c,l,f)})}}const s=e._calculateVertexCount(e.attributes,e.indices);return{attributes:n,bufferLayout:i,vertexCount:s}}function jw(t,e){var s;const i={},n="Values";if(t.attributes.length===0&&!((s=t.varyings)!=null&&s.length))return{"No attributes or varyings":{[n]:"N/A"}};for(const r of t.attributes)if(r){const o=`${r.location} ${r.name}: ${r.type}`;i[`in ${o}`]={[n]:r.stepMode||"vertex"}}for(const r of t.varyings||[]){const o=`${r.location} ${r.name}`;i[`out ${o}`]={[n]:JSON.stringify(r)}}return i}const En="__debugFramebufferState",Cr=8;function Hw(t,e,i){if(t.device.type!=="webgl")return;const n=Kw(t.device);if(!n.flushing){if(Zw(t)){Xw(t,i,n);return}e&&qw(e)&&e.handle!==null&&(n.queuedFramebuffers.includes(e)||n.queuedFramebuffers.push(e))}}function Xw(t,e,i){if(i.queuedFramebuffers.length===0)return;const n=t.device,{gl:s}=n,r=s.getParameter(36010),o=s.getParameter(36006),[a,c]=t.device.getDefaultCanvasContext().getDrawingBufferSize();let l=Ol(e.top,Cr);const f=Ol(e.left,Cr);i.flushing=!0;try{for(const h of i.queuedFramebuffers){const[u,d,p,_,m]=Yw({framebuffer:h,targetWidth:a,targetHeight:c,topPx:l,leftPx:f,minimap:e.minimap});s.bindFramebuffer(36008,h.handle),s.bindFramebuffer(36009,null),s.blitFramebuffer(0,0,h.width,h.height,u,d,p,_,16384,9728),l+=m+Cr}}finally{s.bindFramebuffer(36008,r),s.bindFramebuffer(36009,o),i.flushing=!1}}function Yw(t){const{framebuffer:e,targetWidth:i,targetHeight:n,topPx:s,leftPx:r}=t,o=Math.max(Math.floor(i/4),1),a=Math.max(Math.floor(n/4),1),c=Math.min(o/e.width,a/e.height),l=Math.max(Math.floor(e.width*c),1),f=Math.max(Math.floor(e.height*c),1),h=r,u=Math.max(n-s-f,0),d=h+l,p=u+f;return[h,u,d,p,f]}function Kw(t){var e;return(e=t.userData)[En]||(e[En]={flushing:!1,queuedFramebuffers:[]}),t.userData[En]}function qw(t){return"colorAttachments"in t}function Zw(t){const e=t.props.framebuffer;return!e||e.handle===null}function Ol(t,e){if(!t)return e;const i=Number.parseInt(t,10);return Number.isFinite(i)?i:e}function No(t,e,i){if(t===e)return!0;
1932if(!i||!t||!e)return!1;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(!No(t[n],e[n],i-1))return!1;return!0}if(Array.isArray(e))return!1;if(typeof t=="object"&&typeof e=="object"){const n=Object.keys(t),s=Object.keys(e);if(n.length!==s.length)return!1;for(const r of n)if(!e.hasOwnProperty(r)||!No(t[r],e[r],i-1))return!1;return!0}return!1}class Mr{constructor(e){g(this,"bufferLayouts");this.bufferLayouts=e}getBufferLayout(e){return this.bufferLayouts.find(i=>i.name===e)||null}getAttributeNamesForBuffer(e){var i;return e.attributes?(i=e.attributes)==null?void 0:i.map(n=>n.attribute):[e.name]}mergeBufferLayouts(e,i){const n=[...e];for(const s of i){const r=n.findIndex(o=>o.name===s.name);r<0?n.push(s):n[r]=s}return n}getBufferIndex(e){const i=this.bufferLayouts.findIndex(n=>n.name===e);return i===-1&&R.warn(`BufferLayout: Missing buffer for "${e}".`)(),i}}function Il(t,e){let i=1/0;for(const n of t){const s=e[n];s!==void 0&&(i=Math.min(i,s))}return i}function Gw(t,e){const i=Object.fromEntries(t.attributes.map(s=>[s.name,s.location])),n=e.slice();return n.sort((s,r)=>{const o=s.attributes?s.attributes.map(f=>f.attribute):[s.name],a=r.attributes?r.attributes.map(f=>f.attribute):[r.name],c=Il(o,i),l=Il(a,i);return c-l}),n}function Nl(t,e){if(!t||!e.some(n=>{var s;return(s=n.bindingLayout)==null?void 0:s.length}))return t;const i={...t,bindings:t.bindings.map(n=>({...n}))};"attributes"in(t||{})&&(i.attributes=(t==null?void 0:t.attributes)||[]);for(const n of e)for(const s of n.bindingLayout||[])for(const r of Jw(s.name)){const o=i.bindings.find(a=>a.name===r);(o==null?void 0:o.group)===0&&(o.group=s.group)}return i}function Qw(t){return!!(t.uniformTypes&&!eS(t.uniformTypes))}function Jw(t){const e=new Set([t,`${t}Uniforms`]);return t.endsWith("Uniforms")||e.add(`${t}Sampler`),[...e]}function eS(t){for(const e in t)return!1;return!0}function tS(t){return O_(t)||typeof t=="number"||typeof t=="boolean"}function iS(t,e={}){const i={bindings:{},uniforms:{}};return Object.keys(t).forEach(n=>{const s=t[n];Object.prototype.hasOwnProperty.call(e,n)||tS(s)?i.uniforms[n]=s:i.bindings[n]=s}),i}class nS{constructor(e,i){g(this,"options",{disableWarnings:!1});g(this,"modules");g(this,"moduleUniforms");g(this,"moduleBindings");Object.assign(this.options,i);const n=la(Object.values(e).filter(sS));for(const s of n)e[s.name]=s;R.log(1,"Creating ShaderInputs with modules",Object.keys(e))(),this.modules=e,this.moduleUniforms={},this.moduleBindings={};for(const[s,r]of Object.entries(e))r&&(this._addModule(r),r.name&&s!==r.name&&!this.options.disableWarnings&&R.warn(`Module name: ${s} vs ${r.name}`)())}destroy(){}setProps(e){var i;for(const n of Object.keys(e)){const s=n,r=e[s]||{},o=this.modules[s];if(!o)this.options.disableWarnings||R.warn(`Module ${n} not found`)();else{const a=this.moduleUniforms[s],c=this.moduleBindings[s],l=((i=o.getUniforms)==null?void 0:i.call(o,r,a))||r,{uniforms:f,bindings:h}=iS(l,o.uniformTypes);this.moduleUniforms[s]=Ll(a,f,o.uniformTypes),this.moduleBindings[s]={...c,...h}}}}getModules(){return Object.values(this.modules)}getUniformValues(){return this.moduleUniforms}getBindingValues(){const e={};for(const i of Object.values(this.moduleBindings))Object.assign(e,i);return e}getDebugTable(){var i;const e={};for(const[n,s]of Object.entries(this.moduleUniforms))for(const[r,o]of Object.entries(s))e[`${n}.${r}`]={type:(i=this.modules[n].uniformTypes)==null?void 0:i[r],value:String(o)};return e}_addModule(e){const i=e.name;this.moduleUniforms[i]=Ll({},e.defaultUniforms||{},e.uniformTypes),this.moduleBindings[i]={}}}function Ll(t={},e={},i={}){const n={...t};for(const[s,r]of Object.entries(e))r!==void 0&&(n[s]=Lo(t[s],r,i[s]));return n}function Lo(t,e,i){if(!i||typeof i=="string")return Fi(e);if(Array.isArray(i)){if(Do(e)||!Array.isArray(e))return Fi(e);const o=Array.isArray(t)&&!Do(t)?[...t]:[],a=o.slice();for(let c=0;c<e.length;c++){const l=e[c];l!==void 0&&(a[c]=Lo(o[c],l,i[0]))}return a}if(!Bo(e))return Fi(e);const n=i,s=Bo(t)?t:{},r={...s};for(const[o,a]of Object.entries(e))a!==void 0&&(r[o]=Lo(s[o],a,n[o]));return r}function Fi(t){return ArrayBuffer.isView(t)?Array.prototype.slice.call(t):Array.isArray(t)?Do(t)?t.slice():t.map(i=>i===void 0?void 0:Fi(i)):Bo(t)?Object.fromEntries(Object.entries(t).map(([e,i])=>[e,i===void 0?void 0:Fi(i)])):t}function Do(t){return ArrayBuffer.isView(t)||Array.isArray(t)&&(t.length===0||typeof t[0]=="number")}function Bo(t){return!!t&&typeof t=="object"&&!Array.isArray(t)&&!ArrayBuffer.isView(t)}
1932function sS(t){return!!(t!=null&&t.dependencies)}const sd={"+X":0,"-X":1,"+Y":2,"-Y":3,"+Z":4,"-Z":5};function wi(t){return t?Array.isArray(t)?t[0]??null:t:null}function rS(t){const{dimension:e,data:i}=t;if(!i)return null;switch(e){case"1d":{const n=wi(i);if(!n)return null;const{width:s}=Si(n);return{width:s,height:1}}case"2d":{const n=wi(i);return n?Si(n):null}case"3d":case"2d-array":{if(!Array.isArray(i)||i.length===0)return null;const n=wi(i[0]);return n?Si(n):null}case"cube":{const n=Object.keys(i)[0]??null;if(!n)return null;const s=i[n],r=wi(s);return r?Si(r):null}case"cube-array":{if(!Array.isArray(i)||i.length===0)return null;const n=i[0],s=Object.keys(n)[0]??null;if(!s)return null;const r=wi(n[s]);return r?Si(r):null}default:return null}}function Si(t){if(ba(t))return wu(t);if(typeof t=="object"&&"width"in t&&"height"in t)return{width:t.width,height:t.height};throw new Error("Unsupported mip-level data")}function oS(t){return typeof t=="object"&&t!==null&&"data"in t&&"width"in t&&"height"in t}function aS(t){return ArrayBuffer.isView(t)}function rd(t){const{textureFormat:e,format:i}=t;if(e&&i&&e!==i)throw new Error(`Conflicting texture formats "${e}" and "${i}" provided for the same mip level`);return e??i}function od(t){const e=sd[t];if(e===void 0)throw new Error(`Invalid cube face: ${t}`);return e}function cS(t,e){return 6*t+od(e)}function ad(t){throw new Error("setTexture1DData not supported in WebGL.")}function lS(t){return Array.isArray(t)?t:[t]}function _i(t,e,i,n){const s=lS(e),r=t,o=[];for(let a=0;a<s.length;a++){const c=s[a];if(ba(c))o.push({type:"external-image",image:c,z:r,mipLevel:a});else if(oS(c))o.push({type:"texture-data",data:c,textureFormat:rd(c),z:r,mipLevel:a});else if(aS(c)&&i)o.push({type:"texture-data",data:{data:c,width:Math.max(1,i.width>>a),height:Math.max(1,i.height>>a),...n?{format:n}:{}},textureFormat:n,z:r,mipLevel:a});else throw new Error("Unsupported 2D mip-level payload")}return o}function cd(t){const e=[];for(let i=0;i<t.length;i++)e.push(..._i(i,t[i]));return e}function ld(t){const e=[];for(let i=0;i<t.length;i++)e.push(..._i(i,t[i]));return e}function fd(t){const e=[];for(const[i,n]of Object.entries(t)){const s=od(i);e.push(..._i(s,n))}return e}function hd(t){const e=[];return t.forEach((i,n)=>{for(const[s,r]of Object.entries(i)){const o=cS(n,s);e.push(..._i(o,r))}}),e}const Us=class Us{constructor(e,i){g(this,"device");g(this,"id");g(this,"props");g(this,"_texture",null);g(this,"_sampler",null);g(this,"_view",null);g(this,"ready");g(this,"isReady",!1);g(this,"destroyed",!1);g(this,"resolveReady",()=>{});g(this,"rejectReady",()=>{});this.device=e;const n=Ys("dynamic-texture"),s=i;this.props={...Us.defaultProps,id:n,...i,data:null},this.id=this.props.id,this.ready=new Promise((r,o)=>{this.resolveReady=r,this.rejectReady=o}),this.initAsync(s)}get texture(){if(!this._texture)throw new Error("Texture not initialized yet");return this._texture}get sampler(){if(!this._sampler)throw new Error("Sampler not initialized yet");return this._sampler}get view(){if(!this._view)throw new Error("View not initialized yet");return this._view}get[Symbol.toStringTag](){return"DynamicTexture"}toString(){var n,s;const e=((n=this._texture)==null?void 0:n.width)??this.props.width??"?",i=((s=this._texture)==null?void 0:s.height)??this.props.height??"?";return`DynamicTexture:"${this.id}":${e}x${i}px:(${this.isReady?"ready":"loading..."})`}async initAsync(e){try{const i=await this._loadAllData(e);this._checkNotDestroyed();const n=i.data?fS({...i,width:e.width,height:e.height,format:e.format}):[],s="format"in e&&e.format!==void 0,r="usage"in e&&e.usage!==void 0,a=(()=>{if(this.props.width&&this.props.height)return{width:this.props.width,height:this.props.height};const _=rS(i);return _||{width:this.props.width||1,height:this.props.height||1}})();if(!a||a.width<=0||a.height<=0)throw new Error(`${this} size could not be determined or was zero`);const c=hS(this.device,n,a,{format:s?e.format:void 0}),l=c.format??this.props.format,f={...this.props,...a,format:l,mipLevels:1,data:void 0};this.device.isTextureFormatCompressed(l)&&!r&&(f.usage=Q.SAMPLE|Q.COPY_DST);const h=this.props.mipmaps&&!c.hasExplicitMipChain&&!this.device.isTextureFormatCompressed(l);if(this.device.type==="webgpu"&&h){const _=this.props.dimension==="3d"?Q.SAMPLE|Q.STORAGE|Q.COPY_DST|Q.COPY_SRC:Q.SAMPLE|Q.RENDER|Q.COPY_DST|Q.COPY_SRC;f.usage|=_}const u=this.device.getMipLevelCount(f.width,f.height),d=c.hasExplicitMipChain?c.mipLevels:this.props.mipLevels==="auto"?u:Math.max(1,Math.min(u,this.props.mipLevels??1)),p={...f,mipLevels:d};this._texture=this.device.createTexture(p),this._sampler=this.texture.sampler,this._view=this.texture.view,c.subresources.length&&this._setTextureSubresources(c.subresources),this.props.mipmaps&&!c.hasExplicitMipChain&&!h&&R.warn(`${this} skipping auto-generated mipmaps for compressed texture format`)(),h&&this.generateMipmaps(),this.isReady=!0,this.resolveReady(this.texture),R.info(0,`${this} created`)()}catch(i){const n=i instanceof Error?i:new Error(String(i));this.rejectReady(n)}}destroy(){this._texture&&(this._texture.destroy(),this._texture=null,this._sampler=null,this._view=null),this.destroyed=!0}generateMipmaps(){this.device.type==="webgl"?this.texture.generateMipmapsWebGL():this.device.type==="webgpu"?this.device.generateMipmapsWebGPU(this.texture):R.warn(`${this} mipmaps not supported on ${this.device.type}`)}setSampler(e={}){this._checkReady();const i=e instanceof ri?e:this.device.createSampler(e);this.texture.setSampler(i),this._sampler=i}async readBuffer(e={}){this.isReady||await this.ready;
1932const i=e.width??this.texture.width,n=e.height??this.texture.height,s=e.depthOrArrayLayers??this.texture.depth,r=this.texture.computeMemoryLayout({width:i,height:n,depthOrArrayLayers:s}),o=this.device.createBuffer({byteLength:r.byteLength,usage:Z.COPY_DST|Z.MAP_READ});this.texture.readBuffer({...e,width:i,height:n,depthOrArrayLayers:s},o);const a=this.device.createFence();return await a.signaled,a.destroy(),o}async readAsync(e={}){this.isReady||await this.ready;const i=e.width??this.texture.width,n=e.height??this.texture.height,s=e.depthOrArrayLayers??this.texture.depth,r=this.texture.computeMemoryLayout({width:i,height:n,depthOrArrayLayers:s}),o=await this.readBuffer(e),a=await o.readAsync(0,r.byteLength);return o.destroy(),a.buffer}resize(e){if(this._checkReady(),e.width===this.texture.width&&e.height===this.texture.height)return!1;const i=this.texture;return this._texture=i.clone(e),this._sampler=this.texture.sampler,this._view=this.texture.view,i.destroy(),R.info(`${this} resized`),!0}getCubeFaceIndex(e){const i=sd[e];if(i===void 0)throw new Error(`Invalid cube face: ${e}`);return i}getCubeArrayFaceIndex(e,i){return 6*e+this.getCubeFaceIndex(i)}setTexture1DData(e){if(this._checkReady(),this.texture.props.dimension!=="1d")throw new Error(`${this} is not 1d`);const i=ad();this._setTextureSubresources(i)}setTexture2DData(e,i=0){if(this._checkReady(),this.texture.props.dimension!=="2d")throw new Error(`${this} is not 2d`);const n=_i(i,e);this._setTextureSubresources(n)}setTexture3DData(e){if(this.texture.props.dimension!=="3d")throw new Error(`${this} is not 3d`);const i=cd(e);this._setTextureSubresources(i)}setTextureArrayData(e){if(this.texture.props.dimension!=="2d-array")throw new Error(`${this} is not 2d-array`);const i=ld(e);this._setTextureSubresources(i)}setTextureCubeData(e){if(this.texture.props.dimension!=="cube")throw new Error(`${this} is not cube`);const i=fd(e);this._setTextureSubresources(i)}setTextureCubeArrayData(e){if(this.texture.props.dimension!=="cube-array")throw new Error(`${this} is not cube-array`);const i=hd(e);this._setTextureSubresources(i)}_setTextureSubresources(e){for(const i of e){const{z:n,mipLevel:s}=i;switch(i.type){case"external-image":const{image:r,flipY:o}=i;this.texture.copyExternalImage({image:r,z:n,mipLevel:s,flipY:o});break;case"texture-data":const{data:a,textureFormat:c}=i;
1932if(c&&c!==this.texture.format)throw new Error(`${this} mip level ${s} uses format "${c}" but texture format is "${this.texture.format}"`);this.texture.writeData(a.data,{x:0,y:0,z:n,width:a.width,height:a.height,depthOrArrayLayers:1,mipLevel:s});break;default:throw new Error("Unsupported 2D mip-level payload")}}}async _loadAllData(e){const i=await Fo(e.data);return{dimension:e.dimension??"2d",data:i??null}}_checkNotDestroyed(){this.destroyed&&R.warn(`${this} already destroyed`)}_checkReady(){this.isReady||R.warn(`${this} Cannot perform this operation before ready`)}};g(Us,"defaultProps",{...Q.defaultProps,dimension:"2d",data:null,mipmaps:!1});let Xt=Us;function fS(t){if(!t.data)return[];const e=t.width&&t.height?{width:t.width,height:t.height}:void 0,i="format"in t?t.format:void 0;switch(t.dimension){case"1d":return ad();case"2d":return _i(0,t.data,e,i);case"3d":return cd(t.data);case"2d-array":return ld(t.data);case"cube":return fd(t.data);case"cube-array":return hd(t.data);default:throw new Error(`Unhandled dimension ${t.dimension}`)}}function hS(t,e,i,n){if(e.length===0)return{subresources:e,mipLevels:1,format:n.format,hasExplicitMipChain:!1};const s=new Map;for(const f of e){const h=s.get(f.z)??[];h.push(f),s.set(f.z,h)}const r=e.some(f=>f.mipLevel>0);let o=n.format,a=Number.POSITIVE_INFINITY;const c=[];for(const[f,h]of s){const u=[...h].sort((A,v)=>A.mipLevel-v.mipLevel),d=u[0];if(!d||d.mipLevel!==0)throw new Error(`DynamicTexture: slice ${f} is missing mip level 0`);const p=Bl(t,d);if(p.width!==i.width||p.height!==i.height)throw new Error(`DynamicTexture: slice ${f} base level dimensions ${p.width}x${p.height} do not match expected ${i.width}x${i.height}`);const _=Dl(d);if(_){if(o&&o!==_)throw new Error(`DynamicTexture: slice ${f} base level format "${_}" does not match texture format "${o}"`);o=_}const m=o&&t.isTextureFormatCompressed(o)?uS(t,p.width,p.height,o):t.getMipLevelCount(p.width,p.height);let b=0;for(let A=0;A<u.length;A++){const v=u[A];if(!v||v.mipLevel!==A||A>=m)break;const S=Bl(t,v),E=Math.max(1,p.width>>A),x=Math.max(1,p.height>>A);if(S.width!==E||S.height!==x)break;const M=Dl(v);if(M&&(o||(o=M),M!==o))break;b++,c.push(v)}a=Math.min(a,b)}const l=Number.isFinite(a)?Math.max(1,a):1;return{subresources:c.filter(f=>f.mipLevel<l),mipLevels:l,format:o,hasExplicitMipChain:r}}function Dl(t){if(t.type==="texture-data")return t.textureFormat??rd(t.data)}function Bl(t,e){switch(e.type){case"external-image":return t.getExternalImageSize(e.image);case"texture-data":return{width:e.data.width,height:e.data.height};default:throw new Error("Unsupported texture subresource")}}function uS(t,e,i,n){const{blockWidth:s=1,blockHeight:r=1}=t.getTextureFormatInfo(n);let o=1;for(let a=1;;a++){const c=Math.max(1,e>>a),l=Math.max(1,i>>a);if(c<s||l<r)break;o++}return o}async function Fo(t){if(t=await t,Array.isArray(t))return await Promise.all(t.map(Fo));if(t&&typeof t=="object"&&t.constructor===Object){const e=t,i=await Promise.all(Object.values(e).map(Fo)),n=Object.keys(e),s={};for(let r=0;r<n.length;r++)s[n[r]]=i[r];return s}return t}const it=2,dS=1e4,Fl="render pipeline initialization failed",zs=class zs{constructor(e,i){g(this,"device");g(this,"id");g(this,"source");g(this,"vs");g(this,"fs");g(this,"pipelineFactory");g(this,"shaderFactory");g(this,"userData",{});g(this,"parameters");g(this,"topology");g(this,"bufferLayout");g(this,"isInstanced");g(this,"instanceCount",0);g(this,"vertexCount");g(this,"indexBuffer",null);g(this,"bufferAttributes",{});g(this,"constantAttributes",{});g(this,"bindings",{});g(this,"vertexArray");g(this,"transformFeedback",null);g(this,"pipeline");g(this,"shaderInputs");g(this,"material",null);g(this,"_uniformStore");g(this,"_attributeInfos",{});g(this,"_gpuGeometry",null);g(this,"props");g(this,"_pipelineNeedsUpdate","newly created");g(this,"_needsRedraw","initializing");g(this,"_destroyed",!1);g(this,"_lastDrawTimestamp",-1);g(this,"_bindingTable",[]);g(this,"_lastLogTime",0);g(this,"_logOpen",!1);g(this,"_drawCount",0);var c,l,f,h;this.props={...zs.defaultProps,...i},i=this.props,this.id=i.id||Ys("model"),this.device=e,Object.assign(this.userData,i.userData),this.material=i.material||null;const n=Object.fromEntries(((c=this.props.modules)==null?void 0:c.map(u=>[u.name,u]))||[]),s=i.shaderInputs||new nS(n,{disableWarnings:this.props.disableWarnings});this.setShaderInputs(s);const r=gS(e),o=(((l=this.props.modules)==null?void 0:l.length)>0?this.props.modules:(f=this.shaderInputs)==null?void 0:f.getModules())||[];if(this.props.shaderLayout=Nl(this.props.shaderLayout,o)||null,this.device.type==="webgpu"&&this.props.source){const{source:u,getUniforms:d,bindingTable:p}=this.props.shaderAssembler.assembleWGSLShader({platformInfo:r,...this.props,modules:o});this.source=u,this._getModuleUniforms=d,this._bindingTable=p;const _=(h=e.getShaderLayout)==null?void 0:h.call(e,this.source);this.props.shaderLayout=Nl(this.props.shaderLayout||_||null,o)||null}else{const{vs:u,fs:d,getUniforms:p}=this.props.shaderAssembler.assembleGLSLShaderPair({platformInfo:r,...this.props,modules:o});this.vs=u,this.fs=d,this._getModuleUniforms=p,this._bindingTable=[]}this.vertexCount=this.props.vertexCount,this.instanceCount=this.props.instanceCount,this.topology=this.props.topology,this.bufferLayout=this.props.bufferLayout,this.parameters=this.props.parameters,i.geometry&&this.setGeometry(i.geometry),this.pipelineFactory=i.pipelineFactory||po.getDefaultPipelineFactory(this.device),this.shaderFactory=i.shaderFactory||_o.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=e.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),"isInstanced"in i&&(this.isInstanced=i.isInstanced),i.instanceCount&&this.setInstanceCount(i.instanceCount),i.vertexCount&&this.setVertexCount(i.vertexCount),i.indexBuffer&&this.setIndexBuffer(i.indexBuffer),i.attributes&&this.setAttributes(i.attributes),i.constantAttributes&&this.setConstantAttributes(i.constantAttributes),i.bindings&&this.setBindings(i.bindings),i.transformFeedback&&(this.transformFeedback=i.transformFeedback)}get[Symbol.toStringTag](){return"Model"}toString(){return`Model(${this.id})`}destroy(){var e;this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.pipeline.vs),this.pipeline.fs&&this.pipeline.fs!==this.pipeline.vs&&this.shaderFactory.release(this.pipeline.fs),this._uniformStore.destroy(),(e=this._gpuGeometry)==null||e.destroy(),this._destroyed=!0)}needsRedraw(){this._getBindingsUpdateTimestamp()>this._lastDrawTimestamp&&this.setNeedsRedraw("contents of bound textures or buffers updated");const e=this._needsRedraw;return this._needsRedraw=!1,e}setNeedsRedraw(e){this._needsRedraw||(this._needsRedraw=e)}getBindingDebugTable(){return this._bindingTable}predraw(){this.updateShaderInputs(),this.pipeline=this._updatePipeline()}draw(e){const i=this._areBindingsLoading();if(i)return R.info(it,`>>> DRAWING ABORTED ${this.id}: ${i} not loaded`)(),!1;try{e.pushDebugGroup(`${this}.predraw(${e})`),this.predraw()}finally{e.popDebugGroup()}let n,s=this.pipeline.isErrored;try{if(e.pushDebugGroup(`${this}.draw(${e})`),this._logDrawCallStart(),this.pipeline=this._updatePipeline(),s=this.pipeline.isErrored,s)R.info(it,`>>> DRAWING ABORTED ${this.id}: ${Fl}`)(),n=!1;else{const r=this._getBindings(),o=this._getBindGroups(),{indexBuffer:a}=this.vertexArray,c=a?a.byteLength/(a.indexType==="uint32"?4:2):void 0;n=this.pipeline.draw({renderPass:e,vertexArray:this.vertexArray,isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.instanceCount,indexCount:c,transformFeedback:this.transformFeedback||void 0,bindings:r,bindGroups:o,_bindGroupCacheKeys:this._getBindGroupCacheKeys(),uniforms:this.props.uniforms,parameters:this.parameters,topology:this.topology})}}finally{e.popDebugGroup(),this._logDrawCallEnd()}return this._logFramebuffer(e),n?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):s?this._needsRedraw=Fl:this._needsRedraw="waiting for resource initialization",n}setGeometry(e){var n;(n=this._gpuGeometry)==null||n.destroy();const i=e&&Ww(this.device,e);if(i){this.setTopology(i.topology||"triangle-list");const s=new Mr(this.bufferLayout);this.bufferLayout=s.mergeBufferLayouts(i.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(i)}this._gpuGeometry=i}setTopology(e){e!==this.topology&&(this.topology=e,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(e){const i=new Mr(this.bufferLayout);this.bufferLayout=this._gpuGeometry?i.mergeBufferLayouts(e,this._gpuGeometry.bufferLayout):e,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry)}setParameters(e){No(e,this.parameters,2)||(this.parameters=e,this._setPipelineNeedsUpdate("parameters"))}setInstanceCount(e){this.instanceCount=e,this.isInstanced===void 0&&e>0&&(this.isInstanced=!0),this.setNeedsRedraw("instanceCount")}setVertexCount(e){this.vertexCount=e,this.setNeedsRedraw("vertexCount")}setShaderInputs(e){var i;this.shaderInputs=e,this._uniformStore=new qv(this.device,this.shaderInputs.modules);for(const[n,s]of Object.entries(this.shaderInputs.modules))if(Qw(s)&&!((i=this.material)!=null&&i.ownsModule(n))){const r=this._uniformStore.getManagedUniformBuffer(n);this.bindings[`${n}Uniforms`]=r}this.setNeedsRedraw("shaderInputs")}setMaterial(e){this.material=e,this.setNeedsRedraw("material")}updateShaderInputs(){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues()),this.setBindings(this._getNonMaterialBindings(this.shaderInputs.getBindingValues())),this.setNeedsRedraw("shaderInputs")}setBindings(e){Object.assign(this.bindings,e),this.setNeedsRedraw("bindings")}setTransformFeedback(e){this.transformFeedback=e,this.setNeedsRedraw("transformFeedback")}setIndexBuffer(e){this.vertexArray.setIndexBuffer(e),this.setNeedsRedraw("indexBuffer")}setAttributes(e,i){const n=(i==null?void 0:i.disableWarnings)??this.props.disableWarnings;e.indices&&R.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)(),this.bufferLayout=Gw(this.pipeline.shaderLayout,this.bufferLayout);const s=new Mr(this.bufferLayout);for(const[r,o]of Object.entries(e)){const a=s.getBufferLayout(r);if(!a){n||R.warn(`Model(${this.id}): Missing layout for buffer "${r}".`)();continue}const c=s.getAttributeNamesForBuffer(a);let l=!1;for(const f of c){const h=this._attributeInfos[f];if(h){const u=this.device.type==="webgpu"?s.getBufferIndex(h.bufferName):h.location;this.vertexArray.setBuffer(u,o),l=!0}}!l&&!n&&R.warn(`Model(${this.id}): Ignoring buffer "${o.id}" for unknown attribute "${r}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(e,i){for(const[n,s]of Object.entries(e)){const r=this._attributeInfos[n];r?this.vertexArray.setConstantWebGL(r.location,s):((i==null?void 0:i.disableWarnings)??this.props.disableWarnings)||R.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${n}"`)()}this.setNeedsRedraw("constants")}_areBindingsLoading(){var e;
1932for(const i of Object.values(this.bindings))if(i instanceof Xt&&!i.isReady)return i.id;for(const i of Object.values(((e=this.material)==null?void 0:e.bindings)||{}))if(i instanceof Xt&&!i.isReady)return i.id;return!1}_getBindings(){const e={};for(const[i,n]of Object.entries(this.bindings))n instanceof Xt?n.isReady&&(e[i]=n.texture):e[i]=n;return e}_getBindGroups(){var n;const e=((n=this.pipeline)==null?void 0:n.shaderLayout)||this.props.shaderLayout||{bindings:[]},i=e.bindings.length?Pu(e,this._getBindings()):{0:this._getBindings()};if(!this.material)return i;for(const[s,r]of Object.entries(this.material.getBindingsByGroup())){const o=Number(s);i[o]={...i[o]||{},...r}}return i}_getBindGroupCacheKeys(){var i;const e=(i=this.material)==null?void 0:i.getBindGroupCacheKey(3);return e?{3:e}:{}}_getBindingsUpdateTimestamp(){var i;let e=0;for(const n of Object.values(this.bindings))n instanceof as?e=Math.max(e,n.texture.updateTimestamp):n instanceof Z||n instanceof Q?e=Math.max(e,n.updateTimestamp):n instanceof Xt?e=n.texture?Math.max(e,n.texture.updateTimestamp):1/0:n instanceof ri||(e=Math.max(e,n.buffer.updateTimestamp));return Math.max(e,((i=this.material)==null?void 0:i.getBindingsUpdateTimestamp())||0)}_setGeometryAttributes(e){const i={...e.attributes};for(const[n]of Object.entries(i))!this.pipeline.shaderLayout.attributes.find(s=>s.name===n)&&n!=="positions"&&delete i[n];this.vertexCount=e.vertexCount,this.setIndexBuffer(e.indices||null),this.setAttributes(e.attributes,{disableWarnings:!0}),this.setAttributes(i,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate||(this._pipelineNeedsUpdate=e),this.setNeedsRedraw(e)}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null,i=null;this.pipeline&&(R.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.pipeline.vs,i=this.pipeline.fs),this._pipelineNeedsUpdate=!1;const n=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debugShaders:this.props.debugShaders});let s=null;this.source?s=n:this.fs&&(s=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"fragment",source:this.source||this.fs,debugShaders:this.props.debugShaders})),this.pipeline=this.pipelineFactory.createRenderPipeline({...this.props,bindings:void 0,bufferLayout:this.bufferLayout,topology:this.topology,parameters:this.parameters,bindGroups:this._getBindGroups(),vs:n,fs:s}),this._attributeInfos=Cu(this.pipeline.shaderLayout,this.bufferLayout),e&&this.shaderFactory.release(e),i&&i!==e&&this.shaderFactory.release(i)}return this.pipeline}_logDrawCallStart(){const e=R.level>3?0:dS;R.level<2||Date.now()-this._lastLogTime<e||(this._lastLogTime=Date.now(),this._logOpen=!0,R.group(it,`>>> DRAWING MODEL ${this.id}`,{collapsed:R.level<=2})())}_logDrawCallEnd(){if(this._logOpen){const e=jw(this.pipeline.shaderLayout,this.id);R.table(it,e)();const i=this.shaderInputs.getDebugTable();R.table(it,i)();const n=this._getAttributeDebugTable();R.table(it,this._attributeInfos)(),R.table(it,n)(),R.groupEnd(it)(),this._logOpen=!1}}_logFramebuffer(e){const i=this.device.props.debugFramebuffers;if(this._drawCount++,!i)return;const n=e.props.framebuffer;Hw(e,n,{id:(n==null?void 0:n.id)||`${this.id}-framebuffer`,minimap:!0})}_getAttributeDebugTable(){const e={};for(const[i,n]of Object.entries(this._attributeInfos)){const s=this.vertexArray.attributes[n.location];e[n.location]={name:i,type:n.shaderType,values:s?this._getBufferOrConstantValues(s,n.bufferDataType):"null"}}if(this.vertexArray.indexBuffer){const{indexBuffer:i}=this.vertexArray,n=i.indexType==="uint32"?new Uint32Array(i.debugData):new Uint16Array(i.debugData);e.indices={name:"indices",type:i.indexType,values:n.toString()}}return e}_getBufferOrConstantValues(e,i){const n=qe.getTypedArrayConstructor(i);return(e instanceof Z?new n(e.debugData):e).toString()}_getNonMaterialBindings(e){if(!this.material)return e;const i={};for(const[n,s]of Object.entries(e))this.material.ownsBinding(n)||(i[n]=s);return i}};g(zs,"defaultProps",{...at.defaultProps,source:void 0,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],geometry:null,indexBuffer:null,attributes:{},constantAttributes:{},bindings:{},uniforms:{},varyings:[],isInstanced:void 0,instanceCount:0,vertexCount:0,shaderInputs:void 0,material:void 0,pipelineFactory:void 0,shaderFactory:void 0,transformFeedback:void 0,shaderAssembler:rs.getDefaultShaderAssembler(),debugShaders:void 0,disableWarnings:void 0});let ve=zs;function gS(t){return{type:t.type,shaderLanguage:t.info.shadingLanguage,shaderLanguageVersion:t.info.shadingLanguageVersion,gpu:t.info.gpu,features:t.features}}const Hi=class Hi{constructor(e,i=Hi.defaultProps){g(this,"device");g(this,"model");g(this,"transformFeedback");if(!Hi.isSupported(e))throw new Error("BufferTransform not yet implemented on WebGPU");this.device=e,this.model=new ve(this.device,{id:i.id||"buffer-transform-model",fs:i.fs||xy(),topology:i.topology||"point-list",varyings:i.outputs||i.varyings,...i}),this.transformFeedback=this.device.createTransformFeedback({layout:this.model.pipeline.shaderLayout,buffers:i.feedbackBuffers}),this.model.setTransformFeedback(this.transformFeedback),Object.seal(this)}static isSupported(e){var i;return((i=e==null?void 0:e.info)==null?void 0:i.type)==="webgl"}destroy(){this.model&&this.model.destroy()}delete(){this.destroy()}run(e){e!=null&&e.inputBuffers&&this.model.setAttributes(e.inputBuffers),e!=null&&e.outputBuffers&&this.transformFeedback.setBuffers(e.outputBuffers);const i=this.device.beginRenderPass(e);this.model.draw(i),i.end()}getBuffer(e){return this.transformFeedback.getBuffer(e)}readAsync(e){const i=this.getBuffer(e);if(!i)throw new Error("BufferTransform#getBuffer");if(i instanceof Z)return i.readAsync();const{buffer:n,byteOffset:s=0,byteLength:r=n.byteLength}=i;return n.readAsync(s,r)}};g(Hi,"defaultProps",{...ve.defaultProps,outputs:void 0,feedbackBuffers:void 0});let Gi=Hi;class Ot{constructor(e){g(this,"id");g(this,"topology");g(this,"vertexCount");g(this,"indices");g(this,"attributes");g(this,"userData",{});const{attributes:i={},indices:n=null,vertexCount:s=null}=e;this.id=e.id||Ys("geometry"),this.topology=e.topology,n&&(this.indices=ArrayBuffer.isView(n)?{value:n,size:1}:n),this.attributes={};for(const[r,o]of Object.entries(i)){const a=ArrayBuffer.isView(o)?{value:o}:o;if(!ArrayBuffer.isView(a.value))throw new Error(`${this._print(r)}: must be typed array or object with value as typed array`);if((r==="POSITION"||r==="positions")&&!a.size&&(a.size=3),r==="indices"){if(this.indices)throw new Error("Multiple indices detected");this.indices=a}else this.attributes[r]=a}this.indices&&this.indices.isIndexed!==void 0&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=s||this._calculateVertexCount(this.attributes,this.indices)}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(e){return`Geometry ${this.id} attribute ${e}`}_setAttributes(e,i){return this}_calculateVertexCount(e,i){if(i)return i.value.length;let n=1/0;for(const s of Object.values(e)){const{value:r,size:o,constant:a}=s;!a&&r&&o!==void 0&&o>=1&&(n=Math.min(n,r.length/o))}return n}}const pS={blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"zero",blendAlphaOperation:"add",blendAlphaSrcFactor:"
1932constant",blendAlphaDstFactor:"zero"};class ud extends Pa{constructor(){super(...arguments),this._colorEncoderState=null}render(e){return"pickingFBO"in e?this._drawPickingBuffer(e):{decodePickingColor:null,stats:super._render(e)}}_drawPickingBuffer({layers:e,layerFilter:i,views:n,viewports:s,onViewportActive:r,pickingFBO:o,deviceRect:{x:a,y:c,width:l,height:f},cullRect:h,effects:u,pass:d="picking",pickZ:p,shaderModuleProps:_,clearColor:m}){this.pickZ=p;const b=this._resetColorEncoder(p),A=[a,c,l,f],v=super._render({target:o,layers:e,layerFilter:i,views:n,viewports:s,onViewportActive:r,cullRect:h,effects:u==null?void 0:u.filter(E=>E.useInPicking),pass:d,isPicking:!0,shaderModuleProps:_,clearColor:m??[0,0,0,0],colorMask:15,scissorRect:A});return this._colorEncoderState=null,{decodePickingColor:b&&_S.bind(null,b),stats:v}}shouldDrawLayer(e){const{pickable:i,operation:n}=e.props;return i&&n.includes("draw")||n.includes("terrain")||n.includes("mask")}getShaderModuleProps(e,i,n){return{picking:{isActive:1,isAttribute:this.pickZ},lighting:{enabled:!1}}}getLayerParameters(e,i,n){var a;const s={...e.props.parameters},{pickable:r,operation:o}=e.props;return this._colorEncoderState?r&&o.includes("draw")?(Object.assign(s,pS),s.blend=!0,this.device.type==="webgpu"?s.blendConstant=kl(this._colorEncoderState,e,n):s.blendColor=kl(this._colorEncoderState,e,n),o.includes("terrain")&&((a=e.state)!=null&&a._hasPickingCover)&&(s.blendAlphaSrcFactor="one")):o.includes("terrain")&&(s.blend=!1):s.blend=!1,s}_resetColorEncoder(e){return this._colorEncoderState=e?null:{byLayer:new Map,byAlpha:[]},this._colorEncoderState}}function kl(t,e,i){const{byLayer:n,byAlpha:s}=t;let r,o=n.get(e);return o?(o.viewports.push(i),r=o.a):(r=n.size+1,r<=255?(o={a:r,layer:e,viewports:[i]},n.set(e,o),s[r]=o):(j.warn("Too many pickable layers, only picking the first 255")(),r=0)),[0,0,0,r/255]}function _S(t,e){const i=t.byAlpha[e[3]];return i&&{pickedLayer:i.layer,pickedViewports:i.viewports,pickedObjectIndex:i.layer.decodePickingColor(e)}}const jt={NO_STATE:"Awaiting state",MATCHED:"Matched. State transferred from previous layer",INITIALIZED:"Initialized",AWAITING_GC:"Discarded. Awaiting garbage collection",AWAITING_FINALIZATION:"No longer matched. Awaiting garbage collection",FINALIZED:"Finalized! Awaiting garbage collection"},ps=Symbol.for("component"),ht=Symbol.for("propTypes"),Or=Symbol.for("deprecatedProps"),ei=Symbol.for("asyncPropDefaults"),It=Symbol.for("asyncPropOriginal"),lt=Symbol.for("asyncPropResolved");function Ca(t,e=()=>!0){return Array.isArray(t)?dd(t,e,[]):e(t)?[t]:[]}function dd(t,e,i){let n=-1;for(;++n<t.length;){const s=t[n];Array.isArray(s)?dd(s,e,i):e(s)&&i.push(s)}return i}function mS({target:t,source:e,start:i=0,count:n=1}){const s=e.length,r=n*s;let o=0;for(let a=i;o<s;o++)t[a++]=e[o];for(;o<r;)o<r-o?(t.copyWithin(i+o,i,i+o),o*=2):(t.copyWithin(i+o,i,i+r-o),o=r);return t}class yS{constructor(e,i,n){this._loadCount=0,this._subscribers=new Set,this.id=e,this.context=n,this.setData(i)}subscribe(e){this._subscribers.add(e)}unsubscribe(e){this._subscribers.delete(e)}inUse(){return this._subscribers.size>0}delete(){}getData(){return this.isLoaded?this._error?Promise.reject(this._error):this._content:this._loader.then(()=>this.getData())}setData(e,i){if(e===this._data&&!i)return;this._data=e;const n=++this._loadCount;let s=e;typeof e=="string"&&(s=is(e)),s instanceof Promise?(this.isLoaded=!1,this._loader=s.then(r=>{this._loadCount===n&&(this.isLoaded=!0,this._error=void 0,this._content=r)}).catch(r=>{this._loadCount===n&&(this.isLoaded=!0,this._error=r||!0)})):(this.isLoaded=!0,this._error=void 0,this._content=e);for(const r of this._subscribers)r.onChange(this.getData())}}class bS{constructor(e){var i;this.protocol=e.protocol||"resource://",this._context={device:e.device,gl:(i=e.device)==null?void 0:i.gl,resourceManager:this},this._resources={},this._consumers={},this._pruneRequest=null}contains(e){return e.startsWith(this.protocol)?!0:e in this._resources}add({resourceId:e,data:i,forceUpdate:n=!1,persistent:s=!0}){let r=this._resources[e];r?r.setData(i,n):(r=new yS(e,i,this._context),this._resources[e]=r),r.persistent=s}remove(e){const i=this._resources[e];i&&(i.delete(),delete this._resources[e])}unsubscribe({consumerId:e}){const i=this._consumers[e];if(i){for(const n in i){const s=i[n],r=this._resources[s.resourceId];r&&r.unsubscribe(s)}delete this._consumers[e],this.prune()}}subscribe({resourceId:e,onChange:i,consumerId:n,requestId:s="default"}){const{_resources:r,protocol:o}=this;e.startsWith(o)&&(e=e.replace(o,""),r[e]||this.add({resourceId:e,data:null,persistent:!1}));const a=r[e];if(this._track(n,s,a,i),a)return a.getData()}prune(){this._pruneRequest||(this._pruneRequest=setTimeout(()=>this._prune(),0))}finalize(){for(const e in this._resources)this._resources[e].delete()}_track(e,i,n,s){const r=this._consumers,o=r[e]=r[e]||{};let a=o[i];const c=a&&a.resourceId&&this._resources[a.resourceId];c&&(c.unsubscribe(a),this.prune()),n&&(a?(a.onChange=s,a.resourceId=n.id):a={onChange:s,resourceId:n.id},o[i]=a,n.subscribe(a))}_prune(){this._pruneRequest=null;for(const e of Object.keys(this._resources)){const i=this._resources[e];!i.persistent&&!i.inUse()&&(i.delete(),delete this._resources[e])}}}const vS="layerManager.setLayers",TS="layerManager.activateViewport";class AS{constructor(e,i){var a;this._lastRenderedLayers=[],this._needsRedraw=!1,this._needsUpdate=!1,this._nextLayers=null,this._debug=!1,this._defaultShaderModulesChanged=!1,this.activateViewport=c=>{ge(TS,this,c),c&&(this.context.viewport=c)};const{deck:n,stats:s,viewport:r,timeline:o}=i||{};this.layers=[],this.resourceManager=new bS({device:e,protocol:"deck://"}),this.context={mousePosition:null,userData:{},layerManager:this,device:e,gl:e==null?void 0:e.gl,deck:n,shaderAssembler:sw(((a=e==null?void 0:e.info)==null?void 0:a.shadingLanguage)||"glsl"),defaultShaderModules:[fT],renderPass:void 0,stats:s||new nn({id:"deck.gl"}),viewport:r||new pi({id:"DEFAULT-INITIAL-VIEWPORT"}),timeline:o||new nd,resourceManager:this.resourceManager,onError:void 0},Object.seal(this)}finalize(){this.resourceManager.finalize();for(const e of this.layers)this._finalizeLayer(e)}needsRedraw(e={clearRedrawFlags:!1}){let i=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);for(const n of this.layers){const s=n.getNeedsRedraw(e);i=i||s}return i}needsUpdate(){return this._nextLayers&&this._nextLayers!==this._lastRenderedLayers?"layers changed":this._defaultShaderModulesChanged?"shader modules changed":this._needsUpdate}setNeedsRedraw(e){this._needsRedraw=this._needsRedraw||e}setNeedsUpdate(e){this._needsUpdate=this._needsUpdate||e}getLayers({layerIds:e}={}){return e?this.layers.filter(i=>e.find(n=>i.id.indexOf(n)===0)):this.layers}setProps(e){"debug"in e&&(this._debug=e.debug),"userData"in e&&(this.context.userData=e.userData),"layers"in e&&(this._nextLayers=e.layers
vendor: 4,149 bytes, line 1932
1932),"onError"in e&&(this.context.onError=e.onError)}setLayers(e,i){ge(vS,this,i,e),this._lastRenderedLayers=e;const n=Ca(e,Boolean);for(const s of n)s.context=this.context;this._updateLayers(this.layers,n)}updateLayers(){const e=this.needsUpdate();e&&(this.setNeedsRedraw(`updating layers: ${e}`),this.setLayers(this._nextLayers||this._lastRenderedLayers,e)),this._nextLayers=null}addDefaultShaderModule(e){const{defaultShaderModules:i}=this.context;i.find(n=>n.name===e.name)||(i.push(e),this._defaultShaderModulesChanged=!0)}removeDefaultShaderModule(e){const{defaultShaderModules:i}=this.context,n=i.findIndex(s=>s.name===e.name);n>=0&&(i.splice(n,1),this._defaultShaderModulesChanged=!0)}_handleError(e,i,n){n.raiseError(i,`${e} of ${n}`)}_updateLayers(e,i){const n={};for(const o of e)n[o.id]?j.warn(`Multiple old layers with same id ${o.id}`)():n[o.id]=o;if(this._defaultShaderModulesChanged){for(const o of e)o.setNeedsUpdate(),o.setChangeFlags({extensionsChanged:!0});this._defaultShaderModulesChanged=!1}const s=[];this._updateSublayersRecursively(i,n,s),this._finalizeOldLayers(n);let r=!1;for(const o of s)if(o.hasUniformTransition()){r=`Uniform transition in ${o}`;break}this._needsUpdate=r,this.layers=s}_updateSublayersRecursively(e,i,n){for(const s of e){s.context=this.context;const r=i[s.id];r===null&&j.warn(`Multiple new layers with same id ${s.id}`)(),i[s.id]=null;let o=null;try{this._debug&&r!==s&&s.validateProps(),r?(this._transferLayerState(r,s),this._updateLayer(s)):this._initializeLayer(s),n.push(s),o=s.isComposite?s.getSubLayers():null}catch(a){this._handleError("matching",a,s)}o&&this._updateSublayersRecursively(o,i,n)}}_finalizeOldLayers(e){for(const i in e){const n=e[i];n&&this._finalizeLayer(n)}}_initializeLayer(e){try{e._initialize(),e.lifecycle=jt.INITIALIZED}catch(i){this._handleError("initialization",i,e)}}_transferLayerState(e,i){i._transferState(e),i.lifecycle=jt.MATCHED,i!==e&&(e.lifecycle=jt.AWAITING_GC)}_updateLayer(e){try{e._update()}catch(i){this._handleError("update",i,e)}}_finalizeLayer(e){this._needsRedraw=this._needsRedraw||`finalized ${e}`,e.lifecycle=jt.AWAITING_FINALIZATION;try{e._finalize(),e.lifecycle=jt.FINALIZED}catch(i){this._handleError("finalization",i,e)}}}function be(t,e,i){if(t===e)return!0;if(!i||!t||!e)return!1;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(!be(t[n],e[n],i-1))return!1;return!0}if(Array.isArray(e))return!1;if(typeof t=="object"&&typeof e=="object"){const n=Object.keys(t),s=Object.keys(e);if(n.length!==s.length)return!1;for(const r of n)if(!e.hasOwnProperty(r)||!be(t[r],e[r],i-1))return!1;return!0}return!1}class wS{constructor(e){this.views=[],this.width=100,this.height=100,this.viewState={},this.controllers={},this.timeline=e.timeline,this._viewports=[],this._viewportMap={},this._isUpdating=!1,this._needsRedraw="First render",this._needsUpdate="Initialize",this._eventManager=e.eventManager,this._eventCallbacks={onViewStateChange:e.onViewStateChange,onInteractionStateChange:e.onInteractionStateChange},this._pickPosition=e.pickPosition,Object.seal(this),this.setProps(e)}finalize(){for(const e in this.controllers){const i=this.controllers[e];i&&i.finalize()}this.controllers={}}needsRedraw(e={clearRedrawFlags:!1}){const i=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),i}setNeedsUpdate(e){this._needsUpdate=this._needsUpdate||e,this._needsRedraw=this._needsRedraw||e}updateViewStates(){for(const e in this.controllers){const i=this.controllers[e];i&&i.updateTransition()}}getViewports(e){return e?this._viewports.filter(i=>i.containsPixel(e)):this._viewports}getViews(){const e={};return this.views.forEach(i=>{e[i.id]=i}),e}getView(e){return this.views.find(i=>i.id===e)}getViewState(e){const i=typeof e=="string"?this.getView(e):e,n=i&&this.viewState[i.getViewStateId()]||this.viewState;return i?i.filterViewState(n):n}getViewport(e){return this._viewportMap[e]}unproject(e,i){const n=this.getViewports(),s={x:e[0],y:e[1]};for(let r=n.length-1;r>=0;--r){const o=n[r];if(o.containsPixel(s)){const a=e.slice();return a[0]-=o.x,a[1]-=o.y,o.unproject(a,i)}}return null}
1932setProps(e){e.views&&this._setViews(e.views),e.viewState&&this._setViewState(e.viewState),("width"in e||"height"in e)&&this._setSize(e.width,e.height),"pickPosition"in e&&(this._pickPosition=e.pickPosition),this._isUpdating||this._update()}_update(){this._isUpdating=!0,this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._isUpdating=!1}_setSize(e,i){(e!==this.width||i!==this.height)&&(this.width=e,this.height=i,this.setNeedsUpdate("Size changed"))}_setViews(e){e=Ca(e,Boolean),this._diffViews(e,this.views)&&this.setNeedsUpdate("views changed"),this.views=e}_setViewState(e){e?(!be(e,this.viewState,3)&&this.setNeedsUpdate("viewState changed"),this.viewState=e):j.warn("missing `viewState` or `initialViewState`")()}_createController(e,i){const n=i.type;return new n({timeline:this.timeline,eventManager:this._eventManager,onViewStateChange:this._eventCallbacks.onViewStateChange,onStateChange:this._eventCallbacks.onInteractionStateChange,makeViewport:r=>{var o;return(o=this.getView(e.id))==null?void 0:o.makeViewport({viewState:r,width:this.width,height:this.height})},pickPosition:this._pickPosition})}_updateController(e,i,n,s){const r=e.controller;if(r&&n){const o={...i,...r,id:e.id,x:n.x,y:n.y,width:n.width,height:n.height};return(!s||s.constructor!==r.type)&&(s=this._createController(e,o)),s&&s.setProps(o),s}return null}_rebuildViewports(){const{views:e}=this,i=this.controllers;this._viewports=[],this.controllers={};let n=!1;for(let s=e.length;s--;){const r=e[s],o=this.getViewState(r),a=r.makeViewport({viewState:o,width:this.width,height:this.height});let c=i[r.id];const l=!!r.controller;l&&!c&&(n=!0),(n||!l)&&c&&(c.finalize(),c=null),this.controllers[r.id]=this._updateController(r,o,a,c),a&&this._viewports.unshift(a)}for(const s in i){const r=i[s];r&&!this.controllers[s]&&r.finalize()}this._buildViewportMap()}_buildViewportMap(){this._viewportMap={},this._viewports.forEach(e=>{e.id&&(this._viewportMap[e.id]=this._viewportMap[e.id]||e)})}_diffViews(e,i){return e.length!==i.length?!0:e.some((n,s)=>!e[s].equals(i[s]))}}const SS=/^(?:\d+\.?\d*|\.\d+)$/;function nt(t){switch(typeof t){case"number":if(!Number.isFinite(t))throw new Error(`Could not parse position string ${t}`);return{type:"literal",value:t};case"string":try{const e=ES(t);return new xS(e).parseExpression()}catch(e){const i=e instanceof Error?e.message:String(e);throw new Error(`Could not parse position string ${t}: ${i}`)}default:throw new Error(`Could not parse position string ${t}`)}}function ko(t,e){switch(t.type){case"literal":return t.value;case"percentage":return Math.round(t.value*e);case"binary":const i=ko(t.left,e),n=ko(t.right,e);return t.operator==="+"?i+n:i-n;default:throw new Error("Unknown layout expression type")}}function st(t,e){return ko(t,e)}function ES(t){const e=[];let i=0;for(;i<t.length;){const n=t[i];if(/\s/.test(n)){i++;continue}if(n==="+"||n==="-"||n==="("||n===")"||n==="%"){e.push({type:"symbol",value:n}),i++;continue}if(Ul(n)||n==="."){const s=i;let r=n===".";for(i++;i<t.length;){const a=t[i];if(Ul(a)){i++;continue}if(a==="."&&!r){r=!0,i++;continue}break}const o=t.slice(s,i);if(!SS.test(o))throw new Error("Invalid number token");e.push({type:"number",value:parseFloat(o)});continue}if(zl(n)){const s=i;for(;i<t.length&&zl(t[i]);)i++;const r=t.slice(s,i).toLowerCase();e.push({type:"word",value:r});continue}throw new Error("Invalid token in position string")}return e}class xS{constructor(e){this.index=0,this.tokens=e}parseExpression(){const e=this.parseBinaryExpression();if(this.index<this.tokens.length)throw new Error("Unexpected token at end of expression");return e}parseBinaryExpression(){let e=this.parseFactor(),i=this.peek();for(;PS(i);){this.index++;const n=this.parseFactor();e={type:"binary",operator:i.value,left:e,right:n},i=this.peek()}return e}parseFactor(){const e=this.peek();if(!e)throw new Error("Unexpected end of expression");if(e.type==="symbol"&&e.value==="+")return this.index++,this.parseFactor();if(e.type==="symbol"&&e.value==="-"){this.index++;const i=this.parseFactor();return{type:"binary",operator:"-",left:{type:"literal",value:0},right:i}}if(e.type==="symbol"&&e.value==="("){this.index++;const i=this.parseBinaryExpression();if(!this.consumeSymbol(")"))throw new Error("Missing closing parenthesis");return i}if(e.type==="word"&&e.value==="calc"){if(this.index++,!this.consumeSymbol("("))throw new Error("Missing opening parenthesis after calc");const i=this.parseBinaryExpression();if(!this.consumeSymbol(")"))throw new Error("Missing closing parenthesis");return i}if(e.type==="number"){this.index++;const i=e.value,n=this.peek();return n&&n.type==="symbol"&&n.value==="%"?(this.index++,{type:"percentage",value:i/100}):n&&n.type==="word"&&n.value==="px"?(this.index++,{type:"literal",value:i}):{type:"literal",value:i}}throw new Error("Unexpected token in expression")}consumeSymbol(e){const i=this.peek();return i&&i.type==="symbol"&&i.value===e?(this.index++,!0):!1}peek(){return this.tokens[this.index]||null}}function Ul(t){return t>="0"&&t<="9"}function zl(t){return t>="a"&&t<="z"||t>="A"&&t<="Z"}function PS(t){return!!(t&&t.type==="symbol"&&(t.value==="+"||t.value==="-"))}function RS(t,e){const i={...t};for(const n in e)n!=="id"&&(Array.isArray(i[n])&&Array.isArray(e[n])?i[n]=CS(i[n],e[n]):i[n]=e[n]);return i}function CS(t,e){t=t.slice();for(let i=0;i<e.length;i++){const n=e[i];Number.isFinite(n)&&(t[i]=n)}return t}class fi{constructor(e){const{id:i,x:n=0,y:s=0,width:r="100%",height:o="100%",padding:a=null}=e;this.id=i||this.constructor.displayName||"view",this.props={...e,id:this.id},this._x=nt(n),this._y=nt(s),this._width=nt(r),this._height=nt(o),this._padding=a&&{left:nt(a.left||0),right:nt(a.right||0),top:nt(a.top||0),bottom:nt(a.bottom||0)}
1932,this.equals=this.equals.bind(this),Object.seal(this)}equals(e){return this===e?!0:this.constructor===e.constructor&&be(this.props,e.props,2)}clone(e){const i=this.constructor;return new i({...this.props,...e})}makeViewport({width:e,height:i,viewState:n}){n=this.filterViewState(n);const s=this.getDimensions({width:e,height:i});if(!s.height||!s.width)return null;const r=this.getViewportType(n);return new r({...n,...this.props,...s})}getViewStateId(){const{viewState:e}=this.props;return typeof e=="string"?e:(e==null?void 0:e.id)||this.id}filterViewState(e){return this.props.viewState&&typeof this.props.viewState=="object"?this.props.viewState.id?RS(e,this.props.viewState):this.props.viewState:e}getDimensions({width:e,height:i}){const n={x:st(this._x,e),y:st(this._y,i),width:st(this._width,e),height:st(this._height,i)};return this._padding&&(n.padding={left:st(this._padding.left,e),top:st(this._padding.top,i),right:st(this._padding.right,e),bottom:st(this._padding.bottom,i)}),n}get controller(){const e=this.props.controller;return e?e===!0?{type:this.ControllerType}:typeof e=="function"?{type:e}:{type:this.ControllerType,...e}:null}}class Ks{constructor(e){this._inProgress=!1,this._handle=null,this.time=0,this.settings={duration:0},this._timeline=e}get inProgress(){return this._inProgress}start(e){var i,n;this.cancel(),this.settings=e,this._inProgress=!0,(n=(i=this.settings).onStart)==null||n.call(i,this)}end(){var e,i;this._inProgress&&(this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1,(i=(e=this.settings).onEnd)==null||i.call(e,this))}cancel(){var e,i;this._inProgress&&((i=(e=this.settings).onInterrupt)==null||i.call(e,this),this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1)}update(){var e,i;if(!this._inProgress)return!1;if(this._handle===null){const{_timeline:n,settings:s}=this;this._handle=n.addChannel({delay:n.getTime(),duration:s.duration})}return this.time=this._timeline.getTime(this._handle),this._onUpdate(),(i=(e=this.settings).onUpdate)==null||i.call(e,this),this._timeline.isFinished(this._handle)&&this.end(),!0}_onUpdate(){}}const Wl=()=>{},Uo={BREAK:1,SNAP_TO_END:2,IGNORE:3},MS=t=>t,OS=Uo.BREAK;class IS{constructor(e){this._onTransitionUpdate=i=>{const{time:n,settings:{interpolator:s,startProps:r,endProps:o,duration:a,easing:c}}=i,l=c(n/a),f=s.interpolateProps(r,o,l);this.propsInTransition=this.getControllerState({...this.props,...f}).getViewportProps(),this.onViewStateChange({viewState:this.propsInTransition,oldViewState:this.props})},this.getControllerState=e.getControllerState,this.propsInTransition=null,this.transition=new Ks(e.timeline),this.onViewStateChange=e.onViewStateChange||Wl,this.onStateChange=e.onStateChange||Wl}finalize(){this.transition.cancel()}getViewportInTransition(){return this.propsInTransition}processViewStateChange(e){let i=!1;const n=this.props;if(this.props=e,!n||this._shouldIgnoreViewportChange(n,e))return!1;if(this._isTransitionEnabled(e)){let s=n;if(this.transition.inProgress){const{interruption:r,endProps:o}=this.transition.settings;s={...n,...r===Uo.SNAP_TO_END?o:this.propsInTransition||n}}this._triggerTransition(s,e),i=!0}else this.transition.cancel();return i}updateTransition(){this.transition.update()}_isTransitionEnabled(e){const{transitionDuration:i,transitionInterpolator:n}=e;return(i>0||i==="auto")&&!!n}_isUpdateDueToCurrentTransition(e){return this.transition.inProgress&&this.propsInTransition?this.transition.settings.interpolator.arePropsEqual(e,this.propsInTransition):!1}_shouldIgnoreViewportChange(e,i){return this.transition.inProgress?this.transition.settings.interruption===Uo.IGNORE||this._isUpdateDueToCurrentTransition(i):this._isTransitionEnabled(i)?i.transitionInterpolator.arePropsEqual(e,i):!0}_triggerTransition(e,i){const n=this.getControllerState(e),s=this.getControllerState(i).shortestPathFrom(n),r=i.transitionInterpolator,o=r.getDuration?r.getDuration(e,i):i.transitionDuration;if(o===0)return;const a=r.initializeProps(e,s);this.propsInTransition={};const c={duration:o,easing:i.transitionEasing||MS,interpolator:r,interruption:i.transitionInterruption||OS,startProps:a.start,endProps:a.end,onStart:i.onTransitionStart,onUpdate:this._onTransitionUpdate,onInterrupt:this._onTransitionEnd(i.onTransitionInterrupt),onEnd:this._onTransitionEnd(i.onTransitionEnd)};this.transition.start(c),this.onStateChange({inTransition:!0}),this.updateTransition()}_onTransitionEnd(e){return i=>{this.propsInTransition=null,this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1}),e==null||e(i)}}}function fe(t,e){if(!t)throw new Error(e||"deck.gl: assertion failed.")}class NS{constructor(e){const{compare:i,extract:n,required:s}=e;this._propsToCompare=i,this._propsToExtract=n||i,this._requiredProps=s}
1932arePropsEqual(e,i){for(const n of this._propsToCompare)if(!(n in e)||!(n in i)||!Ki(e[n],i[n]))return!1;return!0}initializeProps(e,i){const n={},s={};for(const r of this._propsToExtract)(r in e||r in i)&&(n[r]=e[r],s[r]=i[r]);return this._checkRequiredProps(n),this._checkRequiredProps(s),{start:n,end:s}}getDuration(e,i){return i.transitionDuration}_checkRequiredProps(e){this._requiredProps&&this._requiredProps.forEach(i=>{const n=e[i];fe(Number.isFinite(n)||Array.isArray(n),`${i} is required for transition`)})}}const xn=Math.PI/180,Vl=180/Math.PI,Xn=6370972,Yt=256;function LS(){const t=Yt/Xn,e=Math.PI/180*Yt;return{unitsPerMeter:[t,t,t],unitsPerMeter2:[0,0,0],metersPerUnit:[1/t,1/t,1/t],unitsPerDegree:[e,e,t],unitsPerDegree2:[0,0,0],degreesPerUnit:[1/e,1/e,1/t]}}class gd extends pi{constructor(e={}){const{longitude:i=0,zoom:n=0,nearZMultiplier:s=.5,farZMultiplier:r=1,resolution:o=10}=e;let{latitude:a=0,height:c,altitude:l=1.5,fovy:f}=e;a=Math.max(Math.min(a,ct),-ct),c=c||1,f?l=Ea(f):f=Zi(l);const h=Math.pow(2,n-Pn(a)),u=e.nearZ??s,d=e.farZ??(l+Yt*2*h/c)*r,p=new Le().lookAt({eye:[0,-l,0],up:[0,0,1]});p.rotateX(a*xn),p.rotateZ(-i*xn),p.scale(h/c),super({...e,height:c,viewMatrix:p,longitude:i,latitude:a,zoom:n,distanceScales:LS(),fovy:f,focalDistance:l,near:u,far:d}),this.scale=h,this.latitude=a,this.longitude=i,this.fovy=f,this.resolution=o}get projectionMode(){return ye.GLOBE}getDistanceScales(){return this.distanceScales}getBounds(e={}){const i={targetZ:e.z||0},n=this.unproject([0,this.height/2],i),s=this.unproject([this.width/2,0],i),r=this.unproject([this.width,this.height/2],i),o=this.unproject([this.width/2,this.height],i);return r[0]<this.longitude&&(r[0]+=360),n[0]>this.longitude&&(n[0]-=360),[Math.min(n[0],r[0],s[0],o[0]),Math.min(n[1],r[1],s[1],o[1]),Math.max(n[0],r[0],s[0],o[0]),Math.max(n[1],r[1],s[1],o[1])]}unproject(e,{topLeft:i=!0,targetZ:n}={}){const[s,r,o]=e,a=i?r:this.height-r,{pixelUnprojectionMatrix:c}=this;let l;if(Number.isFinite(o))l=Ir(c,[s,a,o,1]);else{const d=Ir(c,[s,a,-1,1]),p=Ir(c,[s,a,1,1]),_=((n||0)/Xn+1)*Yt,m=hr(au([],d,p)),b=hr(d),A=hr(p),S=4*((4*b*A-(m-b-A)**2)/16)/m,E=Math.sqrt(b-S),x=Math.sqrt(Math.max(0,_*_-S)),M=(E-x)/Math.sqrt(m);l=qy([],d,p,M)}const[f,h,u]=this.unprojectPosition(l);return Number.isFinite(o)?[f,h,u]:Number.isFinite(n)?[f,h,n]:[f,h]}projectPosition(e){const[i,n,s=0]=e,r=i*xn,o=n*xn,a=Math.cos(o),c=(s/Xn+1)*Yt;return[Math.sin(r)*a*c,-Math.cos(r)*a*c,Math.sin(o)*c]}unprojectPosition(e){const[i,n,s]=e,r=cu(e),o=Math.asin(s/r),c=Math.atan2(i,-n)*Vl,l=o*Vl,f=(r/Yt-1)*Xn;return[c,l,f]}projectFlat(e){return e}unprojectFlat(e){return e}panByPosition([e,i,n],s,r){const a=.25/Math.pow(2,this.zoom-Pn(this.latitude)),c=e+a*(r[0]-s[0]);let l=i-a*(r[1]-s[1]);l=Math.max(Math.min(l,ct),-ct);const f={longitude:c,latitude:l,zoom:n-Pn(i)};return f.zoom+=Pn(f.latitude),f}}gd.displayName="GlobeViewport";function Pn(t){const e=Math.PI*Math.cos(t*Math.PI/180);return Math.log2(e)}function Ir(t,e){const i=gi([],e,t);return ya(i,i,1/i[3]),i}const DS=["longitude","latitude","zoom","bearing","pitch"],BS=["longitude","latitude","zoom"];class pd extends NS{constructor(e={}){const i=Array.isArray(e)?e:e.transitionProps,n=Array.isArray(e)?{}:e;n.transitionProps=Array.isArray(i)?{compare:i,required:i}:i||{compare:DS,required:BS},super(n.transitionProps),this.opts=n}initializeProps(e,i){const n=super.initializeProps(e,i),{makeViewport:s,around:r}=this.opts;if(s&&r)if(s(e)instanceof gd)j.warn("around not supported in GlobeView")();else{const a=s(e),c=s(i),l=a.unproject(r);n.start.around=r,Object.assign(n.end,{around:c.project(l),aroundPosition:l,width:i.width,height:i.height})}return n}interpolateProps(e,i,n){const s={};for(const r of this._propsToExtract)s[r]=wt(e[r]||0,i[r]||0,n);if(i.aroundPosition&&this.opts.makeViewport){const r=this.opts.makeViewport({...i,...s});Object.assign(s,r.panByPosition(i.aroundPosition,wt(e.around,i.around,n)))}return s}}const Ye={transitionDuration:0},FS=300,Rn=t=>1-(1-t)*(1-t),$t={WHEEL:["wheel"],PAN:["panstart","panmove","panend"],PINCH:["pinchstart","pinchmove","pinchend"],MULTI_PAN:["multipanstart","multipanmove","multipanend"],DOUBLE_CLICK:["dblclick"],KEYBOARD:["keydown"]},_t={};class kS{constructor(e){this.state={},this._events={},this._interactionState={isDragging:!1},this._customEvents=[],this._eventStartBlocked=null,this._panMove=!1,this.invertPan=!1,this.dragMode="rotate",this.inertia=0,this.scrollZoom=!0,this.dragPan=!0,this.dragRotate=!0,this.doubleClickZoom=!0,this.touchZoom=!0,this.touchRotate=!1,this.keyboard=!0,this.transitionManager=new IS({...e,getControllerState:i=>new this.ControllerState(i),onViewStateChange:this._onTransition.bind(this),onStateChange:this._setInteractionState.bind(this)}),this.handleEvent=this.handleEvent.bind(this),this.eventManager=e.eventManager,this.onViewStateChange=e.onViewStateChange||(()=>{}),this.onStateChange=e.onStateChange||(()=>{}),this.makeViewport=e.makeViewport,this.pickPosition=e.pickPosition}set events(e){this.toggleEvents(this._customEvents,!1),this.toggleEvents(e,!0),this._customEvents=e,this.props&&this.setProps(this.props)}finalize(){var e;
vendor: 9,791 bytes, line 1932
1932for(const i in this._events)this._events[i]&&((e=this.eventManager)==null||e.off(i,this.handleEvent));this.transitionManager.finalize()}handleEvent(e){this._controllerState=void 0;const i=this._eventStartBlocked;switch(e.type){case"panstart":return i?!1:this._onPanStart(e);case"panmove":return this._onPan(e);case"panend":return this._onPanEnd(e);case"pinchstart":return i?!1:this._onPinchStart(e);case"pinchmove":return this._onPinch(e);case"pinchend":return this._onPinchEnd(e);case"multipanstart":return i?!1:this._onMultiPanStart(e);case"multipanmove":return this._onMultiPan(e);case"multipanend":return this._onMultiPanEnd(e);case"dblclick":return this._onDoubleClick(e);case"wheel":return this._onWheel(e);case"keydown":return this._onKeyDown(e);default:return!1}}get controllerState(){return this._controllerState=this._controllerState||new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state}),this._controllerState}getCenter(e){const{x:i,y:n}=this.props,{offsetCenter:s}=e;return[s.x-i,s.y-n]}isPointInBounds(e,i){const{width:n,height:s}=this.props;if(i&&i.handled)return!1;const r=e[0]>=0&&e[0]<=n&&e[1]>=0&&e[1]<=s;return r&&i&&i.stopPropagation(),r}isFunctionKeyPressed(e){const{srcEvent:i}=e;return!!(i.metaKey||i.altKey||i.ctrlKey||i.shiftKey)}isDragging(){return this._interactionState.isDragging||!1}blockEvents(e){const i=setTimeout(()=>{this._eventStartBlocked===i&&(this._eventStartBlocked=null)},e);this._eventStartBlocked=i}setProps(e){e.dragMode&&(this.dragMode=e.dragMode);const i=this.props;this.props=e,"transitionInterpolator"in e||(e.transitionInterpolator=this._getTransitionProps().transitionInterpolator),this.transitionManager.processViewStateChange(e);const{inertia:n}=e;this.inertia=Number.isFinite(n)?n:n===!0?FS:0;const{scrollZoom:s=!0,dragPan:r=!0,dragRotate:o=!0,doubleClickZoom:a=!0,touchZoom:c=!0,touchRotate:l=!1,keyboard:f=!0}=e,h=!!this.onViewStateChange;if(this.toggleEvents($t.WHEEL,h&&s),this.toggleEvents($t.PAN,h),this.toggleEvents($t.PINCH,h&&(c||l)),this.toggleEvents($t.MULTI_PAN,h&&l),this.toggleEvents($t.DOUBLE_CLICK,h&&a),this.toggleEvents($t.KEYBOARD,h&&f),this.scrollZoom=s,this.dragPan=r,this.dragRotate=o,this.doubleClickZoom=a,this.touchZoom=c,this.touchRotate=l,this.keyboard=f,(!i||i.height!==e.height||i.width!==e.width||i.maxBounds!==e.maxBounds)&&e.maxBounds){const d=new this.ControllerState({...e,makeViewport:this.makeViewport}),p=d.getViewportProps();Object.keys(p).some(m=>!be(p[m],e[m],1))&&this.updateViewport(d)}}updateTransition(){this.transitionManager.updateTransition()}toggleEvents(e,i){this.eventManager&&e.forEach(n=>{this._events[n]!==i&&(this._events[n]=i,i?this.eventManager.on(n,this.handleEvent):this.eventManager.off(n,this.handleEvent))})}updateViewport(e,i=null,n={}){const s={...e.getViewportProps(),...i},r=this.controllerState!==e;if(this.state=e.getState(),this._setInteractionState(n),r){const o=this.controllerState&&this.controllerState.getViewportProps();this.onViewStateChange&&this.onViewStateChange({viewState:s,interactionState:this._interactionState,oldViewState:o,viewId:this.props.id})}}_onTransition(e){this.onViewStateChange({...e,interactionState:this._interactionState,viewId:this.props.id})}_setInteractionState(e){Object.assign(this._interactionState,e),this.onStateChange(this._interactionState)}_onPanStart(e){const i=this.getCenter(e);if(!this.isPointInBounds(i,e))return!1;let n=this.isFunctionKeyPressed(e)||e.rightButton||!1;(this.invertPan||this.dragMode==="pan")&&(n=!n);const s=this.controllerState[n?"panStart":"rotateStart"]({pos:i});return this._panMove=n,this.updateViewport(s,Ye,{isDragging:!0}),!0}_onPan(e){return this.isDragging()?this._panMove?this._onPanMove(e):this._onPanRotate(e):!1}_onPanEnd(e){return this.isDragging()?this._panMove?this._onPanMoveEnd(e):this._onPanRotateEnd(e):!1}_onPanMove(e){if(!this.dragPan)return!1;const i=this.getCenter(e),n=this.controllerState.pan({pos:i});return this.updateViewport(n,Ye,{isDragging:!0,isPanning:!0}),!0}_onPanMoveEnd(e){const{inertia:i}=this;if(this.dragPan&&i&&e.velocity){const n=this.getCenter(e),s=[n[0]+e.velocityX*i/2,n[1]+e.velocityY*i/2],r=this.controllerState.pan({pos:s}).panEnd();this.updateViewport(r,{...this._getTransitionProps(),transitionDuration:i,transitionEasing:Rn},{isDragging:!1,isPanning:!0})}else{const n=this.controllerState.panEnd();this.updateViewport(n,null,{isDragging:!1,isPanning:!1})}return!0}_onPanRotate(e){if(!this.dragRotate)return!1;const i=this.getCenter(e),n=this.controllerState.rotate({pos:i});return this.updateViewport(n,Ye,{isDragging:!0,isRotating:!0}),!0}_onPanRotateEnd(e){const{inertia:i}=this;if(this.dragRotate&&i&&e.velocity){const n=this.getCenter(e),s=[n[0]+e.velocityX*i/2,n[1]+e.velocityY*i/2],r=this.controllerState.rotate({pos:s}).rotateEnd();this.updateViewport(r,{...this._getTransitionProps(),transitionDuration:i,transitionEasing:Rn},{isDragging:!1,isRotating:!0})}else{const n=this.controllerState.rotateEnd();this.updateViewport(n,null,{isDragging:!1,isRotating:!1})}return!0}_onWheel(e){if(!this.scrollZoom)return!1;const i=this.getCenter(e);if(!this.isPointInBounds(i,e))return!1;e.srcEvent.preventDefault();const{speed:n=.01,smooth:s=!1}=this.scrollZoom===!0?{}:this.scrollZoom,{delta:r}=e;let o=2/(1+Math.exp(-Math.abs(r*n)));r<0&&o!==0&&(o=1/o);const a=s?{...this._getTransitionProps({around:i}),transitionDuration:250}:Ye,c=this.controllerState.zoom({pos:i,scale:o});return this.updateViewport(c,a,{isZooming:!0,isPanning:!0}),s||this._setInteractionState({isZooming:!1,isPanning:!1}),!0}_onMultiPanStart(e){const i=this.getCenter(e);if(!this.isPointInBounds(i,e))return!1;const n=this.controllerState.rotateStart({pos:i});return this.updateViewport(n,Ye,{isDragging:!0}),!0}_onMultiPan(e){if(!this.touchRotate||!this.isDragging())return!1;const i=this.getCenter(e);i[0]-=e.deltaX;const n=this.controllerState.rotate({pos:i});return this.updateViewport(n,Ye,{isDragging:!0,isRotating:!0}),!0}_onMultiPanEnd(e){if(!this.isDragging())return!1;const{inertia:i}=this;if(this.touchRotate&&i&&e.velocityY){const n=this.getCenter(e),s=[n[0],n[1]+=e.velocityY*i/2],r=this.controllerState.rotate({pos:s});this.updateViewport(r,{...this._getTransitionProps(),transitionDuration:i,transitionEasing:Rn},{isDragging:!1,isRotating:!0}),this.blockEvents(i)}else{const n=this.controllerState.rotateEnd();this.updateViewport(n,null,{isDragging:!1,isRotating:!1})}return!0}_onPinchStart(e){const i=this.getCenter(e);if(!this.isPointInBounds(i,e))return!1;const n=this.controllerState.zoomStart({pos:i}).rotateStart({pos:i});return _t._startPinchRotation=e.rotation,_t._lastPinchEvent=e,this.updateViewport(n,Ye,{isDragging:!0}),!0}_onPinch(e){if(!this.touchZoom&&!this.touchRotate||!this.isDragging())return!1;let i=this.controllerState;if(this.touchZoom){const{scale:n}=e,s=this.getCenter(e);i=i.zoom({pos:s,scale:n})}if(this.touchRotate){const{rotation:n}=e;i=i.rotate({deltaAngleX:_t._startPinchRotation-n})}return this.updateViewport(i,Ye,{isDragging:!0,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:this.touchRotate}),_t._lastPinchEvent=e,!0}_onPinchEnd(e){if(!this.isDragging())return!1;const{inertia:i}=this,{_lastPinchEvent:n}=_t;if(this.touchZoom&&i&&n&&e.scale!==n.scale){const s=this.getCenter(e);let r=this.controllerState.rotateEnd();const o=Math.log2(e.scale),a=(o-Math.log2(n.scale))/(e.deltaTime-n.deltaTime),c=Math.pow(2,o+a*i/2);r=r.zoom({pos:s,scale:c}).zoomEnd(),this.updateViewport(r,{...this._getTransitionProps({around:s}),transitionDuration:i,transitionEasing:Rn},{isDragging:!1,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:!1}),this.blockEvents(i)}else{const s=this.controllerState.zoomEnd().rotateEnd();this.updateViewport(s,null,{isDragging:!1,isPanning:!1,isZooming:!1,isRotating:!1})}return _t._startPinchRotation=null,_t._lastPinchEvent=null,!0}_onDoubleClick(e){if(!this.doubleClickZoom)return!1;const i=this.getCenter(e);if(!this.isPointInBounds(i,e))return!1;const n=this.isFunctionKeyPressed(e),s=this.controllerState.zoom({pos:i,scale:n?.5:2});return this.updateViewport(s,this._getTransitionProps({around:i}),{isZooming:!0,isPanning:!0}),this.blockEvents(100),!0}_onKeyDown(e){if(!this.keyboard)return!1;const i=this.isFunctionKeyPressed(e),{zoomSpeed:n,moveSpeed:s,rotateSpeedX:r,rotateSpeedY:o}=this.keyboard===!0?{}:this.keyboard,{controllerState:a}=this;let c;const l={};switch(e.srcEvent.code){case"Minus":c=i?a.zoomOut(n).zoomOut(n):a.zoomOut(n),l.isZooming=!0;break;case"Equal":c=i?a.zoomIn(n).zoomIn(n):a.zoomIn(n),l.isZooming=!0;break;case"ArrowLeft":i?(c=a.rotateLeft(r),l.isRotating=!0):(c=a.moveLeft(s),l.isPanning=!0);break;case"ArrowRight":i?(c=a.rotateRight(r),l.isRotating=!0):(c=a.moveRight(s),l.isPanning=!0);break;case"ArrowUp":i?(c=a.rotateUp(o),l.isRotating=!0):(c=a.moveUp(s),l.isPanning=!0);break;case"ArrowDown":i?(c=a.rotateDown(o),l.isRotating=!0):(c=a.moveDown(s),l.isPanning=!0);break;default:return!1}return this.updateViewport(c,this._getTransitionProps(),l),!0}_getTransitionProps(e){const{transition:i}=this;return!i||!i.transitionInterpolator?Ye:e?{...i,transitionInterpolator:new pd({...e,...i.transitionInterpolator.opts,makeViewport:this.controllerState.makeViewport})}:i}}class US{constructor(e,i,n){this.makeViewport=n,this._viewportProps=this.applyConstraints(e),this._state=i}getViewportProps(){return this._viewportProps}getState(){return this._state}}const $l=5,zS=1.2,jl=512,_d=[[-1/0,-90],[1/0,90]];function Cn([t,e]){if(Math.abs(e)>90&&(e=Math.sign(e)*90),Number.isFinite(t)){const[n,s]=gt([t,e]);return[n,Re(s,0,jl)]}const[,i]=gt([0,e]);return[t,Re(i,0,jl)]}class WS extends US{constructor(e){const{width:i,height:n,latitude:s,longitude:r,zoom:o,bearing:a=0,pitch:c=0,altitude:l=1.5,position:f=[0,0,0],maxZoom:h=20,minZ
1932oom:u=0,maxPitch:d=60,minPitch:p=0,startPanLngLat:_,startZoomLngLat:m,startRotatePos:b,startRotateLngLat:A,startBearing:v,startPitch:S,startZoom:E,normalize:x=!0}=e;fe(Number.isFinite(r)),fe(Number.isFinite(s)),fe(Number.isFinite(o));const M=e.maxBounds||(x?_d:null);super({width:i,height:n,latitude:s,longitude:r,zoom:o,bearing:a,pitch:c,altitude:l,maxZoom:h,minZoom:u,maxPitch:d,minPitch:p,normalize:x,position:f,maxBounds:M},{startPanLngLat:_,startZoomLngLat:m,startRotatePos:b,startRotateLngLat:A,startBearing:v,startPitch:S,startZoom:E},e.makeViewport),this.getAltitude=e.getAltitude}panStart({pos:e}){return this._getUpdatedState({startPanLngLat:this._unproject(e)})}pan({pos:e,startPos:i}){const n=this.getState().startPanLngLat||this._unproject(i);if(!n)return this;const r=this.makeViewport(this.getViewportProps()).panByPosition(n,e);return this._getUpdatedState(r)}panEnd(){return this._getUpdatedState({startPanLngLat:null})}rotateStart({pos:e}){var n;const i=(n=this.getAltitude)==null?void 0:n.call(this,e);return this._getUpdatedState({startRotatePos:e,startRotateLngLat:i!==void 0?this._unproject3D(e,i):void 0,startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:e,deltaAngleX:i=0,deltaAngleY:n=0}){const{startRotatePos:s,startRotateLngLat:r,startBearing:o,startPitch:a}=this.getState();if(!s||o===void 0||a===void 0)return this;let c;if(e?c=this._getNewRotation(e,s,a,o):c={bearing:o+i,pitch:a+n},r){const l=this.makeViewport({...this.getViewportProps(),...c}),f="panByPosition3D"in l?"panByPosition3D":"panByPosition";return this._getUpdatedState({...c,...l[f](r,s)})}return this._getUpdatedState(c)}rotateEnd(){return this._getUpdatedState({startRotatePos:null,startRotateLngLat:null,startBearing:null,startPitch:null})}zoomStart({pos:e}){return this._getUpdatedState({startZoomLngLat:this._unproject(e),startZoom:this.getViewportProps().zoom})}zoom({pos:e,startPos:i,scale:n}){let{startZoom:s,startZoomLngLat:r}=this.getState();if(r||(s=this.getViewportProps().zoom,r=this._unproject(i)||this._unproject(e)),!r)return this;const o=this._constrainZoom(s+Math.log2(n)),a=this.makeViewport({...this.getViewportProps(),zoom:o});return this._getUpdatedState({zoom:o,...a.panByPosition(r,e)})}zoomEnd(){return this._getUpdatedState({startZoomLngLat:null,startZoom:null})}zoomIn(e=2){return this._zoomFromCenter(e)}zoomOut(e=2){return this._zoomFromCenter(1/e)}moveLeft(e=100){return this._panFromCenter([e,0])}moveRight(e=100){return this._panFromCenter([-e,0])}moveUp(e=100){return this._panFromCenter([0,e])}moveDown(e=100){return this._panFromCenter([0,-e])}rotateLeft(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing-e})}rotateRight(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing+e})}rotateUp(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch+e})}rotateDown(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch-e})}shortestPathFrom(e){const i=e.getViewportProps(),n={...this.getViewportProps()},{bearing:s,longitude:r}=n;return Math.abs(s-i.bearing)>180&&(n.bearing=s<0?s+360:s-360),Math.abs(r-i.longitude)>180&&(n.longitude=r<0?r+360:r-360),n}applyConstraints(e){const{maxPitch:i,minPitch:n,pitch:s,longitude:r,bearing:o,normalize:a,maxBounds:c}=e;if(a&&((r<-180||r>180)&&(e.longitude=xl(r+180,360)-180),(o<-180||o>180)&&(e.bearing=xl(o+180,360)-180)),e.pitch=Re(s,n,i),e.zoom=this._constrainZoom(e.zoom,e),c){const l=Cn(c[0]),f=Cn(c[1]),h=2**e.zoom,u=e.width/2/h,d=e.height/2/h,[p,_]=ai([l[0]+u,l[1]+d]),[m,b]=ai([f[0]-u,f[1]-d]);e.longitude=Re(e.longitude,p,m),e.latitude=Re(e.latitude,_,b)}return e}_constrainZoom(e,i){i||(i=this.getViewportProps());const{maxZoom:n,maxBounds:s}=i,r=s!==null&&i.width>0&&i.height>0;let{minZoom:o}=i;if(r){const a=Cn(s[0]),c=Cn(s[1]),l=c[0]-a[0],f=c[1]-a[1];Number.isFinite(l)&&l>0&&(o=Math.max(o,Math.log2(i.width/l))),Number.isFinite(f)&&f>0&&(o=Math.max(o,Math.log2(i.height/f))),o>n&&(o=n)}return Re(e,o,n)}_zoomFromCenter(e){const{width:i,height:n}=this.getViewportProps();return this.zoom({pos:[i/2,n/2],scale:e})}_panFromCenter(e){const{width:i,height:n}=this.getViewportProps();return this.pan({startPos:[i/2,n/2],pos:[i/2+e[0],n/2+e[1]]})}_getUpdatedState(e){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.get
1932State(),...e})}_unproject(e){const i=this.makeViewport(this.getViewportProps());return e&&i.unproject(e)}_unproject3D(e,i){return this.makeViewport(this.getViewportProps()).unproject(e,{targetZ:i})}_getNewRotation(e,i,n,s){const r=e[0]-i[0],o=e[1]-i[1],a=e[1],c=i[1],{width:l,height:f}=this.getViewportProps(),h=r/l;let u=0;o>0?Math.abs(f-c)>$l&&(u=o/(c-f)*zS):o<0&&c>$l&&(u=1-a/c),u=Re(u,-1,1);const{minPitch:d,maxPitch:p}=this.getViewportProps(),_=s+180*h;let m=n;return u>0?m=n+u*(p-n):u<0&&(m=n-u*(d-n)),{pitch:m,bearing:_}}}class VS extends kS{constructor(){super(...arguments),this.ControllerState=WS,this.transition={transitionDuration:300,transitionInterpolator:new pd({transitionProps:{compare:["longitude","latitude","zoom","bearing","pitch","position"],required:["longitude","latitude","zoom"]}})},this.dragMode="pan",this.rotationPivot="center",this._getAltitude=e=>{if(this.rotationPivot==="2d")return 0;if(this.rotationPivot==="3d"&&this.pickPosition){const{x:i,y:n}=this.props,s=this.pickPosition(i+e[0],n+e[1]);if(s&&s.coordinate&&s.coordinate.length>=3)return s.coordinate[2]}}}setProps(e){"rotationPivot"in e&&(this.rotationPivot=e.rotationPivot||"center"),e.getAltitude=this._getAltitude,e.position=e.position||[0,0,0],e.maxBounds=e.maxBounds||(e.normalize===!1?null:_d),super.setProps(e)}updateViewport(e,i=null,n={}){const s=e.getState();n.isDragging&&s.startRotateLngLat?n={...n,rotationPivotPosition:s.startRotateLngLat}:n.isDragging===!1&&(n={...n,rotationPivotPosition:void 0}),super.updateViewport(e,i,n)}}class md extends fi{constructor(e={}){super(e)}getViewportType(){return li}get ControllerType(){return VS}}md.displayName="MapView";const $S=new td;function jS(t,e){const i=t.order??1/0,n=e.order??1/0;return i-n}class HS{constructor(e){this._resolvedEffects=[],this._defaultEffects=[],this.effects=[],this._context=e,this._needsRedraw="Initial render",this._setEffects([])}addDefaultEffect(e){const i=this._defaultEffects;if(!i.find(n=>n.id===e.id)){const n=i.findIndex(s=>jS(s,e)>0);n<0?i.push(e):i.splice(n,0,e),e.setup(this._context),this._setEffects(this.effects)}}setProps(e){"effects"in e&&(be(e.effects,this.effects,1)||this._setEffects(e.effects))}needsRedraw(e={clearRedrawFlags:!1}){const i=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),i}getEffects(){return this._resolvedEffects}_setEffects(e){const i={};for(const s of this.effects)i[s.id]=s;const n=[];for(const s of e){const r=i[s.id];let o=s;r&&r!==s?r.setProps?(r.setProps(s.props),o=r):r.cleanup(this._context):r||s.setup(this._context),n.push(o),delete i[s.id]}for(const s in i)i[s].cleanup(this._context);this.effects=n,this._resolvedEffects=n.concat(this._defaultEffects),e.some(s=>s instanceof td)||this._resolvedEffects.push($S),this._needsRedraw="effects changed"}finalize(){for(const e of this._resolvedEffects)e.cleanup(this._context);this.effects.length=0,this._resolvedEffects.length=0,this._defaultEffects.length=0}}class XS extends Pa{shouldDrawLayer(e){const{operation:i}=e.props;return i.includes("draw")||i.includes("terrain")}render(e){return this._render(e)}}const YS="deckRenderer.renderLayers";class KS{constructor(e,i={}){this.device=e,this.stats=i.stats,this.layerFilter=null,this.drawPickingColors=!1,this.drawLayersPass=new XS(e),this.pickLayersPass=new ud(e),this.renderCount=0,this._needsRedraw="Initial render",this.renderBuffers=[],this.lastPostProcessEffect=null}setProps(e){this.layerFilter!==e.layerFilter&&(this.layerFilter=e.layerFilter,this._needsRedraw="layerFilter changed"),this.drawPickingColors!==e.drawPickingColors&&(this.drawPickingColors=e.drawPickingColors,this._needsRedraw="drawPickingColors changed")}renderLayers(e){if(!e.viewports.length)return;const i=this.drawPickingColors?this.pickLayersPass:this.drawLayersPass,n={layerFilter:this.layerFilter,isPicking:this.drawPickingColors,...e};n.effects&&this._preRender(n.effects,n);const s=this.lastPostProcessEffect?this.renderBuffers[0]:n.target;this.lastPostProcessEffect&&(n.clearColor=[0,0,0,0],n.clearCanvas=!0);const r=i.render({...n,target:s}),o="stats"in r?r.stats:r;n.effects&&(this.lastPostProcessEffect&&(n.clearCanvas=e.clearCanvas===void 0?!0:e.clearCanvas),this._postRender(n.effects,n)),this.renderCount++,ge(YS,this,o,e),this._updateStats(o)}needsRedraw(e={clearRedrawFlags:!1}){const i=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),i}finalize(){const{renderBuffers:e}=this;for(const i of e)i.delete();e.length=0}_updateStats(e){if(!this.stats)return;let i=0;for(const{visibleCount:n}of e)i+=n;this.stats.get("Layers rendered").addCount(i)}_preRender(e,i){this.lastPostProcessEffect=null,i.preRenderStats=i.preRenderStats||{};for(const n of e)i.preRenderStats[n.id]=n.preRender(i),n.postRender&&(this.lastPostProcessEffect=n.id);this.lastPostProcessEffect&&this._resizeRenderBuffers()}_resizeRenderBuffers(){const{renderBuffers:e}=this,i=this.device.canvasContext.getDrawingBufferSize(),[n,s]=i;e.length===0&&[0,1].map(r=>{const o=this.device.createTexture({sampler:{minFilter:"linear",magFilter:"linear"},width:n,height:s});
vendor: 2,801 bytes, line 1932
1932e.push(this.device.createFramebuffer({id:`deck-renderbuffer-${r}`,colorAttachments:[o]}))});for(const r of e)r.resize(i)}_postRender(e,i){const{renderBuffers:n}=this,s={...i,inputBuffer:n[0],swapBuffer:n[1]};for(const r of e)if(r.postRender){s.target=r.id===this.lastPostProcessEffect?i.target:void 0;const o=r.postRender(s);s.inputBuffer=o,s.swapBuffer=o===n[0]?n[1]:n[0]}}}const qS={pickedColor:null,pickedObjectIndex:-1};function Hl({pickedColors:t,decodePickingColor:e,deviceX:i,deviceY:n,deviceRadius:s,deviceRect:r}){const{x:o,y:a,width:c,height:l}=r;let f=s*s,h=-1,u=0;for(let d=0;d<l;d++){const p=d+a-n,_=p*p;if(_>f)u+=4*c;else for(let m=0;m<c;m++){if(t[u+3]-1>=0){const A=m+o-i,v=A*A+_;v<=f&&(f=v,h=u)}u+=4}}if(h>=0){const d=t.slice(h,h+4),p=e(d);if(p){const _=Math.floor(h/4/c),m=h/4-_*c;return{...p,pickedColor:d,pickedX:o+m,pickedY:a+_}}j.error("Picked non-existent layer. Is picking buffer corrupt?")()}return qS}function Xl({pickedColors:t,decodePickingColor:e}){const i=new Map;if(t){for(let n=0;n<t.length;n+=4)if(t[n+3]-1>=0){const r=t.slice(n,n+4),o=r.join(",");if(!i.has(o)){const a=e(r);a?i.set(o,{...a,color:r}):j.error("Picked non-existent layer. Is picking buffer corrupt?")()}}}return Array.from(i.values())}function zo({pickInfo:t,viewports:e,pixelRatio:i,x:n,y:s,z:r}){let o=e[0];e.length>1&&(o=ZS((t==null?void 0:t.pickedViewports)||e,{x:n,y:s}));let a;if(o){const c=[n-o.x,s-o.y];r!==void 0&&(c[2]=r),a=o.unproject(c)}return{color:null,layer:null,viewport:o,index:-1,picked:!1,x:n,y:s,pixel:[n,s],coordinate:a,devicePixel:t&&"pickedX"in t?[t.pickedX,t.pickedY]:void 0,pixelRatio:i}}function Yl(t){const{pickInfo:e,lastPickedInfo:i,mode:n,layers:s}=t,{pickedColor:r,pickedLayer:o,pickedObjectIndex:a}=e,c=o?[o]:[];if(n==="hover"){const h=i.index,u=i.layerId,d=o?o.props.id:null;if(d!==u||a!==h){if(d!==u){const p=s.find(_=>_.props.id===u);p&&c.unshift(p)}i.layerId=d,i.index=a,i.info=null}}const l=zo(t),f=new Map;return f.set(null,l),c.forEach(h=>{let u={...l};h===o&&(u.color=r,u.index=a,u.picked=!0),u=Wo({layer:h,info:u,mode:n});const d=u.layer;h===o&&n==="hover"&&(i.info=u),f.set(d.id,u),n==="hover"&&d.updateAutoHighlight(u)}),f}function Wo({layer:t,info:e,mode:i}){for(;t&&e;){const n=e.layer||null;e.sourceLayer=n,e.layer=t,e=t.getPickingInfo({info:e,mode:i,sourceLayer:n}),t=t.parent}return e}function ZS(t,e){for(let i=t.length-1;i>=0;i--){const n=t[i];if(n.containsPixel(e))return n}return t[0]}class GS{constructor(e,i={}){this._pickable=!0,this.device=e,this.stats=i.stats,this.pickLayersPass=new ud(e),this.lastPickedInfo={index:-1,layerId:null,info:null}}setProps(e){"layerFilter"in e&&(this.layerFilter=e.layerFilter),"_pickable"in e&&(this._pickable=e._pickable)}finalize(){this.pickingFBO&&this.pickingFBO.destroy(),this.depthFBO&&this.depthFBO.destroy()}
1932pickObjectAsync(e){return this._pickClosestObjectAsync(e)}pickObjectsAsync(e){return this._pickVisibleObjectsAsync(e)}pickObject(e){return this._pickClosestObject(e)}pickObjects(e){return this._pickVisibleObjects(e)}getLastPickedObject({x:e,y:i,layers:n,viewports:s},r=this.lastPickedInfo.info){const o=r&&r.layer&&r.layer.id,a=r&&r.viewport&&r.viewport.id,c=o?n.find(u=>u.id===o):null,l=a&&s.find(u=>u.id===a)||s[0],f=l&&l.unproject([e-l.x,i-l.y]);return{...r,...{x:e,y:i,viewport:l,coordinate:f,layer:c}}}_resizeBuffer(){var i,n;if(!this.pickingFBO){const s=this.device.createTexture({format:"rgba8unorm",width:1,height:1,usage:Q.RENDER_ATTACHMENT|Q.COPY_SRC});if(this.pickingFBO=this.device.createFramebuffer({colorAttachments:[s],depthStencilAttachment:"depth16unorm"}),this.device.isTextureFormatRenderable("rgba32float")){const r=this.device.createTexture({format:"rgba32float",width:1,height:1,usage:Q.RENDER_ATTACHMENT|Q.COPY_SRC}),o=this.device.createFramebuffer({colorAttachments:[r],depthStencilAttachment:"depth16unorm"});this.depthFBO=o}}const{canvas:e}=this.device.getDefaultCanvasContext();(i=this.pickingFBO)==null||i.resize({width:e.width,height:e.height}),(n=this.depthFBO)==null||n.resize({width:e.width,height:e.height})}_getPickable(e){if(this._pickable===!1)return null;const i=e.filter(n=>this.pickLayersPass.shouldDrawLayer(n)&&!n.isComposite);return i.length?i:null}async _pickClosestObjectAsync({layers:e,views:i,viewports:n,x:s,y:r,radius:o=0,depth:a=1,mode:c="query",unproject3D:l,onViewportActive:f,effects:h}){const u=this.device.canvasContext.cssToDeviceRatio(),d=this._getPickable(e);if(!d||n.length===0)return{result:[],emptyInfo:zo({viewports:n,x:s,y:r,pixelRatio:u})};this._resizeBuffer();const p=this.device.canvasContext.cssToDevicePixels([s,r],!0),_=[p.x+Math.floor(p.width/2),p.y+Math.floor(p.height/2)],m=Math.round(o*u),{width:b,height:A}=this.pickingFBO,v=this._getPickingRect({deviceX:_[0],deviceY:_[1],deviceRadius:m,deviceWidth:b,deviceHeight:A}),S={x:s-o,y:r-o,width:o*2+1,height:o*2+1};let E;const x=[],M=new Set;for(let O=0;O<a;O++){let N;if(v){const F=await this._drawAndSampleAsync({layers:d,views:i,viewports:n,onViewportActive:f,deviceRect:v,cullRect:S,effects:h,pass:`picking:${c}`});N=Hl({...F,deviceX:_[0],deviceY:_[1],deviceRadius:m,deviceRect:v})}else N={pickedColor:null,pickedObjectIndex:-1};let D;const B=this._getDepthLayers(N,d,l);if(B.length>0){const{pickedColors:F}=await this._drawAndSampleAsync({layers:B,views:i,viewports:n,onViewportActive:f,deviceRect:{x:N.pickedX??_[0],y:N.pickedY??_[1],width:1,height:1},cullRect:S,effects:h,pass:`picking:${c}:z`},!0);F[3]&&(D=F[0])}N.pickedLayer&&O+1<a&&(M.add(N.pickedLayer),N.pickedLayer.disablePickingIndex(N.pickedObjectIndex)),E=Yl({pickInfo:N,lastPickedInfo:this.lastPickedInfo,mode:c,layers:d,viewports:n,x:s,y:r,z:D,pixelRatio:u});for(const F of E.values())F.layer&&x.push(F);if(!N.pickedColor)break}for(const O of M)O.restorePickingColors();return{result:x,emptyInfo:E.get(null)}}_pickClosestObject({layers:e,views:i,viewports:n,x:s,y:r,radius:o=0,depth:a=1,mode:c="query",unproject3D:l,onViewportActive:f,effects:h}){const u=this.device.canvasContext.cssToDeviceRatio(),d=this._getPickable(e);if(!d||n.length===0)return{result:[],emptyInfo:zo({viewports:n,x:s,y:r,pixelRatio:u})};this._resizeBuffer();const p=this.device.canvasContext.cssToDevicePixels([s,r],!0),_=[p.x+Math.floor(p.width/2),p.y+Math.floor(p.height/2)],m=Math.round(o*u),{width:b,height:A}=this.pickingFBO,v=this._getPickingRect({deviceX:_[0],deviceY:_[1],deviceRadius:m,deviceWidth:b,deviceHeight:A}),S={x:s-o,y:r-o,width:o*2+1,height:o*2+1};let E;const x=[],M=new Set;for(let O=0;O<a;O++){let N;if(v){const F=this._drawAndSample({layers:d,views:i,viewports:n,onViewportActive:f,deviceRect:v,cullRect:S,effects:h,pass:`picking:${c}`});N=Hl({...F,deviceX:_[0],deviceY:_[1],deviceRadius:m,deviceRect:v})}else N={pickedColor:null,pickedObjectIndex:-1};let D;const B=this._getDepthLayers(N,d,l);if(B.length>0){const{pickedColors:F}=this._drawAndSample({layers:B,views:i,viewports:n,onViewportActive:f,deviceRect:{x:N.pickedX??_[0],y:N.pickedY??_[1],width:1,height:1},cullRect:S,effects:h,pass:`picking:${c}:z`},!0);F[3]&&(D=F[0])}N.pickedLayer&&O+1<a&&(M.add(N.pickedLayer),N.pickedLayer.disablePickingIndex(N.pickedObjectIndex)),E=Yl({pickInfo:N,lastPickedInfo:this.lastPickedInfo,mode:c,layers:d,viewports:n,x:s,y:r,z:D,pixelRatio:u});for(const F of E.values())F.layer&&x.push(F);if(!N.pickedColor)break}for(const O of M)O.restorePickingColors();return{result:x,emptyInfo:E.get(null)}}async _pickVisibleObjectsAsync({layers:e,views:i,viewports:n,x:s,y:r,width:o=1,height:a=1,mode:c="query",maxObjects:l=null,onViewportActive:f,effects:h}){const u=this._getPickable(e);if(!u||n.length===0)return[];this._resizeBuffer();const d=this.device.canvasContext.cssToDeviceRatio(),p=this.device.canvasContext.cssToDevicePixels([s,r],!0),_=p.x,m=p.y+p.height,b=this.device.canvasContext.cssToDevicePixels([s+o,r+a],!0),A=b.x+b.width,v=b.y,S={x:_,y:v,width:A-_,height:m-v},E=await this._drawAndSampleAsync({layers:u,views:i,viewports:n,onViewportActive:f,deviceRect:S,cullRect:{x:s,y:r,width:o,height:a},effects:h,pass:`picking:${c}`}),x=Xl(E),M=new Map,O=[],N=Number.isFinite(l);for(let D=0;D<x.length&&!(N&&O.length>=l);D++){const B=x[D];let F={color:B.pickedColor,layer:null,index:B.pickedObjectIndex,picked:!0,x:s,y:r,pixelRatio:d};F=Wo({layer:B.pickedLayer,info:F,mode:c});const z=F.layer.id;M.has(z)||M.set(z,new Set);const U=M.get(z),q=F.object??F.index;U.has(q)||(U.add(q),O.push(F))}return O}_pickVisibleObjects({layers:e,views:i,viewports:n,x:s,y:r,width:o=1,height:a=1,mode:c="query",maxObjects:l=null,onViewportActive:f,effects:h}){const u=this._getPickable(e);if(!u||n.length===0)return[];this._resizeBuffer();const d=this.device.canvasContext.cssToDeviceRatio(),p=this.device.canvasContext.cssToDevicePixels([s,r],!0),_=p.x,m=p.y+p.height,b=this.device.canvasContext.cssToDevicePixels([s+o,r+a],!0),A=b.x+b.width,v=b.y,S={x:_,y:v,width:A-_,height:m-v},E=this._drawAndSample({layers:u,views:i,viewports:n,onViewportActive:f,deviceRect:S,cullRect:{x:s,y:r,width:o,height:a},effects:h,pass:`picking:${c}`}),x=Xl(E),M=new Map,O=[],N=Number.isFinite(l);for(let D=0;D<x.length&&!(N&&O.length>=l);D++){const B=x[D];let F={color:B.pickedColor,layer:null,index:B.pickedObjectIndex,picked:!0,x:s,y:r,pixelRatio:d};F=Wo({layer:B.pickedLayer,info:F,mode:c});const z=F.layer.id;M.has(z)||M.set(z,new Set);const U=M.get(z),q=F.object??F.index;U.has(q)||(U.add(q),O.push(F))}return O}async _drawAndSampleAsync({layers:e,views:i,viewports:n,onViewportActive:s,deviceRect:r,cullRect:o,effects:a,pass:c},l=!1){var S;const f=l?this.depthFBO:this.pickingFBO,h={layers:e,layerFilter:this.layerFilter,views:i,viewports:n,onViewportActive:s,pickingFBO:f,deviceRect:r,cullRect:o,effects:a,pass:c,pickZ:l,preRenderStats:{},isPicking:!0};for(const E of a)E.useInPicking&&(h.preRenderStats[E.id]=E.preRender(h));const{decodePickingColor:u,stats:d}=this.pickLayersPass.render(h);this._updateStats(d);const{x:p,y:_,width:m,height:b}=r,A=(S=f.colorAttachments[0])==null?void 0:S.texture;if(!A)throw new Error("Picking framebuffer color attachment is missing");const v=await this._readTextureDataAsync(A,{x:p,y:_,width:m,height:b},l?Float32Array:Uint8Array);if(!l){let E=!1;for(let x=3;x<v.length;x+=4)if(v[x]!==0){E=!0;break}!E&&v.length>0&&j.warn("Async pick readback returned only zero alpha values",{deviceRect:r,bytes:Array.from(v.subarray(0,Math.min(v.length,16)))})()}return{pickedColors:v,decodePickingColor:u}}async _readTextureDataAsync(e,i,n){const{width:s,height:r}=i,o=e.computeMemoryLayout(i),a=this.device.createBuffer({byteLength:o.byteLength,usage:Z.COPY_DST|Z.MAP_READ});try{e.readBuffer(i,a);const c=await a.readAsync(0,o.byteLength),l=n.BYTES_PER_ELEMENT;if(o.bytesPerRow%l!==0)throw new Error(`Texture readback row stride ${o.bytesPerRow} is not aligned to ${l}-byte elements.`);const f=new n(c.buffer,c.byteOffset,o.byteLength/l),h=s*4,u=o.bytesPerRow/l;if(u<h)throw new Error(`Texture readback row stride ${u} is smaller than packed row length ${h}.`);const d=new n(s*r*4);for(let p=0;p<r;p++){const _=p*u;d.set(f.subarray(_,_+h),p*h)}return d}finally{a.destroy()}}_drawAndSample({layers:e,views:i,viewports:n,onViewportActive:s,deviceRect:r,cullRect:o,effects:a,pass:c},l=!1){const f=l?this.depthFBO:this.pickingFBO,h={layers:e,layerFilter:this.layerFilter,views:i,viewports:n,onViewportActive:s,pickingFBO:f,deviceRect:r,cullRect:o,effects:a,pass:c,pickZ:l,preRenderStats:{},isPicking:!0};for(const v of a)v.useInPicking&&(h.preRenderStats[v.id]=v.preRender(h));const{decodePickingColor:u,stats:d}=this.pickLayersPass.render(h);this._updateStats(d);const{x:p,y:_,width:m,height:b}=r,A=new(l?Float32Array:Uint8Array)(m*b*4);return this.device.readPixelsToArrayWebGL(f,{sourceX:p,sourceY:_,sourceW
1932idth:m,sourceHeight:b,target:A}),{pickedColors:A,decodePickingColor:u}}_updateStats(e){if(!this.stats)return;let i=0;for(const{visibleCount:n}of e)i+=n;this.stats.get("Layers picked").addCount(i)}_getDepthLayers(e,i,n){var o;if(!n||!this.depthFBO)return[];const{pickedLayer:s}=e,r=((o=s==null?void 0:s.state)==null?void 0:o.terrainDrawMode)==="drape";return s&&!r?[s]:i.filter(a=>a.props.operation.includes("terrain"))}_getPickingRect({deviceX:e,deviceY:i,deviceRadius:n,deviceWidth:s,deviceHeight:r}){const o=Math.max(0,e-n),a=Math.max(0,i-n),c=Math.min(s,e+n+1)-o,l=Math.min(r,i+n+1)-a;return c<=0||l<=0?null:{x:o,y:a,width:c,height:l}}}const QS={"top-left":{top:0,left:0},"top-right":{top:0,right:0},"bottom-left":{bottom:0,left:0},"bottom-right":{bottom:0,right:0},fill:{top:0,left:0,bottom:0,right:0}},JS="top-left",Kl="root";class eE{constructor({deck:e,parentElement:i}){this.defaultWidgets=[],this.widgets=[],this.resolvedWidgets=[],this.containers={},this.lastViewports={},this.deck=e,i==null||i.classList.add("deck-widget-container"),this.parentElement=i}getWidgets(){return this.resolvedWidgets}setProps(e){if(e.widgets&&!be(e.widgets,this.widgets,1)){const i=e.widgets.filter(Boolean);this._setWidgets(i)}}finalize(){for(const e of this.getWidgets())this._removeWidget(e);this.defaultWidgets.length=0,this.resolvedWidgets.length=0;for(const e in this.containers)this.containers[e].remove()}addDefault(e){this.defaultWidgets.find(i=>i.id===e.id)||(this._addWidget(e),this.defaultWidgets.push(e),this._setWidgets(this.widgets))}onRedraw({viewports:e,layers:i}){var s,r;const n=e.reduce((o,a)=>(o[a.id]=a,o),{});for(const o of this.getWidgets()){const{viewId:a}=o;if(a){const c=n[a];c&&(o.onViewportChange&&o.onViewportChange(c),(s=o.onRedraw)==null||s.call(o,{viewports:[c],layers:i}))}else{if(o.onViewportChange)for(const c of e)o.onViewportChange(c);(r=o.onRedraw)==null||r.call(o,{viewports:e,layers:i})}}this.lastViewports=n,this._updateContainers()}onHover(e,i){var n,s;for(const r of this.getWidgets()){const{viewId:o}=r;(!o||o===((n=e.viewport)==null?void 0:n.id))&&((s=r.onHover)==null||s.call(r,e,i))}}onEvent(e,i){var s,r;const n=Hn[i.type];if(n)for(const o of this.getWidgets()){const{viewId:a}=o;(!a||a===((s=e.viewport)==null?void 0:s.id))&&((r=o[n])==null||r.call(o,e,i))}}_setWidgets(e){const i={};for(const n of this.resolvedWidgets)i[n.id]=n;this.resolvedWidgets.length=0;for(const n of this.defaultWidgets)i[n.id]=null,this.resolvedWidgets.push(n);for(let n of e){const s=i[n.id];s?s.viewId!==n.viewId||s.placement!==n.placement?(this._removeWidget(s),this._addWidget(n)):n!==s&&(s.setProps(n.props),n=s):this._addWidget(n),i[n.id]=null,this.resolvedWidgets.push(n)}for(const n in i){const s=i[n];s&&this._removeWidget(s)}this.widgets=e}_addWidget(e){const{viewId:i=null,placement:n=JS}=e,s=e.props._container??i;e.widgetManager=this,e.deck=this.deck,e.rootElement=e._onAdd({deck:this.deck,viewId:i}),e.rootElement&&this._getContainer(s,n).append(e.rootElement),e.updateHTML()}_removeWidget(e){var i;(i=e.onRemove)==null||i.call(e),e.rootElement&&e.rootElement.remove(),e.rootElement=void 0,e.deck=void 0,e.widgetManager=void 0}_getContainer(e,i){var o;if(e&&typeof e!="string")return e;const n=e||Kl;let s=this.containers[n];s||(s=document.createElement("div"),s.style.pointerEvents="none",s.style.position="absolute",s.style.overflow="hidden",(o=this.parentElement)==null||o.append(s),this.containers[n]=s);let r=s.querySelector(`.${i}`);return r||(r=globalThis.document.createElement("div"),r.className=i,r.style.position="absolute",r.style.zIndex="2",Object.assign(r.style,QS[i]),s.append(r)),r}_updateContainers(){const e=this.deck.width,i=this.deck.height;for(const n in this.containers){const s=this.lastViewports[n]||null,r=n===Kl||s,o=this.containers[n];r?(o.style.display="block",o.style.left=`${s?s.x:0}px`,o.style.top=`${s?s.y:0}px`,o.style.width=`${s?s.width:e}px`,o.style.height=`${s?s.height:i}px`):o.style.display="none"}}}function ql(t,e){e&&Object.entries(e).map(([i,n])=>{i.startsWith("--")?t.style.setProperty(i,n):t.style[i]=n})}function tE(t,e){e&&Object.keys(e).map(i=>{i.startsWith("--")?t.style.removeProperty(i):t.style[i]=""})}class Ma{constructor(e){this.viewId=null,this.props={...this.constructor.defaultProps,...e},this.id=this.props.id}setProps(e){const i=this.props,n=this.rootElement;n&&i.className!==e.className&&(i.className&&n.classList.remove(i.className),e.className&&n.classList.add(e.className)),n&&!be(i.style,e.style,1)&&(tE(n,i.style),ql(n,e.style)),Object.assign(this.props,e),this.updateHTML()}updateHTML(){this.rootElement&&this.onRenderHTML(this.rootElement)}get viewIds(){var e;return this.viewId?[this.viewId]:((e=this.deck)==null?void 0:e.getViews().map(i=>i.id))??[]}getViewState(e){var i,n;return((n=(i=this.deck)==null?void 0:i.viewManager)==null?void 0:n.getViewState(e))||{}}setViewState(e,i){var n;(n=this.deck)==null||n._onViewStateChange({viewId:e,viewState:i,interactionState:{}})}onCreateRootElement(){const e=["deck-widget",this.className,this.props.className],i=document.createElement("div");return e.filter(n=>typeof n=="string"&&n.length>
19320).forEach(n=>i.classList.add(n)),ql(i,this.props.style),i}_onAdd(e){return this.onAdd(e)??this.onCreateRootElement()}onAdd(e){}onRemove(){}onViewportChange(e){}onRedraw(e){}onHover(e,i){}onClick(e,i){}onDrag(e,i){}onDragStart(e,i){}onDragEnd(e,i){}}Ma.defaultProps={id:"widget",style:{},_container:null,className:""};const iE={zIndex:"1",position:"absolute",pointerEvents:"none",color:"#a0a7b4",backgroundColor:"#29323c",padding:"10px",top:"0",left:"0",display:"none"};class yd extends Ma{constructor(e={}){super(e),this.id="default-tooltip",this.placement="fill",this.className="deck-tooltip",this.isVisible=!1,this.setProps(e)}onCreateRootElement(){const e=document.createElement("div");return e.className=this.className,Object.assign(e.style,iE),e}onRenderHTML(e){}onViewportChange(e){var i;this.isVisible&&e.id===((i=this.lastViewport)==null?void 0:i.id)&&!e.equals(this.lastViewport)&&this.setTooltip(null),this.lastViewport=e}onHover(e){const{deck:i}=this,n=i&&i.props.getTooltip;if(!n)return;const s=n(e);this.setTooltip(s,e.x,e.y)}setTooltip(e,i,n){const s=this.rootElement;if(s){if(typeof e=="string")s.innerText=e;else if(e)e.text&&(s.innerText=e.text),e.html&&(s.innerHTML=e.html),e.className&&(s.className=e.className);else{this.isVisible=!1,s.style.display="none";return}this.isVisible=!0,s.style.display="block",s.style.transform=`translate(${i}px, ${n}px)`,e&&typeof e=="object"&&"style"in e&&Object.assign(s.style,e.style)}}}yd.defaultProps={...Ma.defaultProps};var Kt;(
vendor: 32,708 bytes, line 1932
1932function(t){t[t.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",t[t.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",t[t.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",t[t.POINTS=0]="POINTS",t[t.LINES=1]="LINES",t[t.LINE_LOOP=2]="LINE_LOOP",t[t.LINE_STRIP=3]="LINE_STRIP",t[t.TRIANGLES=4]="TRIANGLES",t[t.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",t[t.TRIANGLE_FAN=6]="TRIANGLE_FAN",t[t.ZERO=0]="ZERO",t[t.ONE=1]="ONE",t[t.SRC_COLOR=768]="SRC_COLOR",t[t.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",t[t.SRC_ALPHA=770]="SRC_ALPHA",t[t.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",t[t.DST_ALPHA=772]="DST_ALPHA",t[t.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",t[t.DST_COLOR=774]="DST_COLOR",t[t.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",t[t.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",t[t.CONSTANT_COLOR=32769]="CONSTANT_COLOR",t[t.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",t[t.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",t[t.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",t[t.FUNC_ADD=32774]="FUNC_ADD",t[t.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",t[t.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",t[t.BLEND_EQUATION=32777]="BLEND_EQUATION",t[t.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",t[t.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",t[t.BLEND_DST_RGB=32968]="BLEND_DST_RGB",t[t.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",t[t.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",t[t.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",t[t.BLEND_COLOR=32773]="BLEND_COLOR",t[t.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",t[t.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",t[t.LINE_WIDTH=2849]="LINE_WIDTH",t[t.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",t[t.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",t[t.CULL_FACE_MODE=2885]="CULL_FACE_MODE",t[t.FRONT_FACE=2886]="FRONT_FACE",t[t.DEPTH_RANGE=2928]="DEPTH_RANGE",t[t.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",t[t.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",t[t.DEPTH_FUNC=2932]="DEPTH_FUNC",t[t.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",t[t.STENCIL_FUNC=2962]="STENCIL_FUNC",t[t.STENCIL_FAIL=2964]="STENCIL_FAIL",t[t.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",t[t.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",t[t.STENCIL_REF=2967]="STENCIL_REF",t[t.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",t[t.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",t[t.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",t[t.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",t[t.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",t[t.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",t[t.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",t[t.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",t[t.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",t[t.VIEWPORT=2978]="VIEWPORT",t[t.SCISSOR_BOX=3088]="SCISSOR_BOX",t[t.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",t[t.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",t[t.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",t[t.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",t[t.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",t[t.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",t[t.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",t[t.RED_BITS=3410]="RED_BITS",t[t.GREEN_BITS=3411]="GREEN_BITS",t[t.BLUE_BITS=3412]="BLUE_BITS",t[t.ALPHA_BITS=3413]="ALPHA_BITS",t[t.DEPTH_BITS=3414]="DEPTH_BITS",t[t.STENCIL_BITS=3415]="STENCIL_BITS",t[t.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",t[t.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",t[t.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",t[t.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",t[t.SAMPLES=32937]="SAMPLES",t[t.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",t[t.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",t[t.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",t[t.VENDOR=7936]="VENDOR",t[t.RENDERER=7937]="RENDERER",t[t.VERSION=7938]="VERSION",t[t.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",t[t.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",t[t.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",t[t.STATIC_DRAW=35044]="STATIC_DRAW",t[t.STREAM_DRAW=35040]="STREAM_DRAW",t[t.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",t[t.ARRAY_BUFFER=34962]="ARRAY_BUFFER",t[t.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",t[t.BUFFER_SIZE=34660]="BUFFER_SIZE",t[t.BUFFER_USAGE=34661]="BUFFER_USAGE",t[t.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",t[t.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",t[t.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",t[t.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",t[t.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",t[t.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",t[t.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",t[t.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",t[t.CULL_FACE=2884]="CULL_FACE",t[t.FRONT=1028]="FRONT",t[t.BACK=1029]="BACK",t[t.FRONT_AND_BACK=1032]="FRONT_AND_BACK",t[t.BLEND=3042]="BLEND",t[t.DEPTH_TEST=2929]="DEPTH_TEST",t[t.DITHER=3024]="DITHER",t[t.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",t[t.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",t[t.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",t[t.SCISSOR_TEST=3089]="SCISSOR_TEST",t[t.STENCIL_TEST=2960]="STENCIL_TEST",t[t.NO_ERROR=0]="NO_ERROR",t[t.INVALID_ENUM=1280]="INVALID_ENUM",t[t.INVALID_VALUE=1281]="INVALID_VALUE",t[t.INVALID_OPERATION=1282]="INVALID_OPERATION",t[t.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",t[t.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",t[t.CW=2304]="CW",t[t.CCW=2305]="CCW",t[t.DONT_CARE=4352]="DONT_CARE",t[t.FASTEST=4353]="FASTEST",t[t.NICEST=4354]="NICEST",t[t.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",t[t.BYTE=5120]="BYTE",t[t.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",t[t.SHORT=5122]="SHORT",t[t.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",t[t.INT=5124]="INT",t[t.UNSIGNED_INT=5125]="UNSIGNED_INT",t[t.FLOAT=5126]="FLOAT",t[t.DOUBLE=5130]="DOUBLE",t[t.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",t[t.ALPHA=6406]="ALPHA",t[t.RGB=6407]="RGB",t[t.RGBA=6408]="RGBA",t[t.LUMINANCE=6409]="LUMINANCE",t[t.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",t[t.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",t[t.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",t[t.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",t[t.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",t[t.VERTEX_SHADER=35633]="VERTEX_SHADER",t[t.COMPILE_STATUS=35713]="COMPILE_STATUS",t[t.DELETE_STATUS=35712]="DELETE_STATUS",t[t.LINK_STATUS=35714]="LINK_STATUS",t[t.VALIDATE_STATUS=35715]="VALIDATE_STATUS",t[t.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",t[t.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",t[t.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",t[t.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",t[t.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",t[t.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",t[t.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",t[t.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",t[t.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",t[t.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",t[t.SHADER_TYPE=35663]="SHADER_TYPE",t[t.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",t[t.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",t[t.NEVER=512]="NEVER",t[t.LESS=513]="LESS",t[t.EQUAL=514]="EQUAL",t[t.LEQUAL=515]="LEQUAL",t[t.GREATER=516]="GREATER",t[t.NOTEQUAL=517]="NOTEQUAL",t[t.GEQUAL=518]="GEQUAL",t[t.ALWAYS=519]="ALWAYS",t[t.KEEP=7680]="KEEP",t[t.REPLACE=7681]="REPLACE",t[t.INCR=7682]="INCR",t[t.DECR=7683]="DECR",t[t.INVERT=5386]="INVERT",t[t.INCR_WRAP=34055]="INCR_WRAP",t[t.DECR_WRAP=34056]="DECR_WRAP",t[t.NEAREST=9728]="NEAREST",t[t.LINEAR=9729]="LINEAR",t[t.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",t[t.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",t[t.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",t[t.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",t[t.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",t[t.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",t[t.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",t[t.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",t[t.TEXTURE_2D=3553]="TEXTURE_2D",t[t.TEXTURE=5890]="TEXTURE",t[t.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",t[t.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",t[t.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",t[t.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",t[t.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",t[t.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",t[t.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",t[t.TEXTURE0=33984]="TEXTURE0",t[t.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",t[t.REPEAT=10497]="REPEAT",t[t.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",t[t.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",t[t.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",t[t.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",t[t.FLOAT_VEC2=35664]="FLOAT_VEC2",t[t.FLOAT_VEC3=35665]="FLOAT_VEC3",t[t.FLOAT_VEC4=35666]="FLOAT_VEC4",t[t.INT_VEC2=35667]="INT_VEC2",t[t.INT_VEC3=35668]="INT_VEC3",t[t.INT_VEC4=35669]="INT_VEC4",t[t.BOOL=35670]="BOOL",t[t.BOOL_VEC2=35671]="BOOL_VEC2",t[t.BOOL_VEC3=35672]="BOOL_VEC3",t[t.BOOL_VEC4=35673]="BOOL_VEC4",t[t.FLOAT_MAT2=35674]="FLOAT_MAT2",t[t.FLOAT_MAT3=35675]="FLOAT_MAT3",t[t.FLOAT_MAT4=35676]="FLOAT_MAT4",t[t.SAMPLER_2D=35678]="SAMPLER_2D",t[t.SAMPLER_CUBE=35680]="SAMPLER_CUBE",t[t.LOW_FLOAT=36336]="LOW_FLOAT",t[t.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",t[t.HIGH_FLOAT=36338]="HIGH_FLOAT",t[t.LOW_INT=36339]="LOW_INT",t[t.MEDIUM_INT=36340]="MEDIUM_INT",t[t.HIGH_INT=36341]="HIGH_INT",t[t.FRAMEBUFFER=36160]="FRAMEBUFFER",t[t.RENDERBUFFER=36161]="RENDERBUFFER",t[t.RGBA4=32854]="RGBA4",t[t.RGB5_A1=32855]="RGB5_A1",t[t.RGB565=36194]="RGB565",t[t.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",t[t.STENCIL_INDEX=6401]="STENCIL_INDEX",t[t.STENCIL_INDEX8=36168]="STENCIL_INDEX8",t[t.DEPTH_STENCIL=34041]="DEPTH_STENCIL",t[t.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",t[t.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",t[t.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",t[t.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",t[t.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",t[t.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",t[t.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",t[t.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",t[t.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",t[t.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",t[t.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",t[t.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",t[t.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",t[t.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",t[t.NONE=0]="NONE",t[t.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",t[t.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",t[t.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",t[t.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",t[t.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",t[t.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",t[t.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",t[t.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",t[t.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",t[t.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",t[t.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",t[t.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",t[t.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",t[t.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",t[t.READ_BUFFER=3074]="READ_BUFFER",t[t.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",t[t.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",t[t.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",t[t.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",t[t.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",t[t.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",t[t.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",t[t.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",t[t.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",t[t.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",t[t.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",t[t.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",t[t.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",t[t.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",t[t.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",t[t.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",t[t.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",t[t.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",t[t.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",t[t.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",t[t.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",t[t.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",t[t.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",t[t.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",t[t.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",t[t.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",t[t.RED=6403]="RED",t[t.RGB8=32849]="RGB8",t[t.RGBA8=32856]="RGBA8",t[t.RGB10_A2=32857]="RGB10_A2",t[t.TEXTURE_3D=32879]="TEXTURE_3D",t[t.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",t[t.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",t[t.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",t[t.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",t[t.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",t[t.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",t[t.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",t[t.SRGB=35904]="SRGB",t[t.SRGB8=35905]="SRGB8",t[t.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",t[t.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",t[t.RGBA32F=34836]="RGBA32F",t[t.RGB32F=34837]="RGB32F",t[t.RGBA16F=34842]="RGBA16F",t[t.RGB16F=34843]="RGB16F",t[t.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",t[t.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",t[t.R11F_G11F_B10F=35898]="R11F_G11F_B10F",t[t.RGB9_E5=35901]="RGB9_E5",t[t.RGBA32UI=36208]="RGBA32UI",t[t.RGB32UI=36209]="RGB32UI",t[t.RGBA16UI=36214]="RGBA16UI",t[t.RGB16UI=36215]="RGB16UI",t[t.RGBA8UI=36220]="RGBA8UI",t[t.RGB8UI=36221]="RGB8UI",t[t.RGBA32I=36226]="RGBA32I",t[t.RGB32I=36227]="RGB32I",t[t.RGBA16I=36232]="RGBA16I",t[t.RGB16I=36233]="RGB16I",t[t.RGBA8I=36238]="RGBA8I",t[t.RGB8I=36239]="RGB8I",t[t.RED_INTEGER=36244]="RED_INTEGER",t[t.RGB_INTEGER=36248]="RGB_INTEGER",t[t.RGBA_INTEGER=36249]="RGBA_INTEGER",t[t.R8=33321]="R8",t[t.RG8=33323]="RG8",t[t.R16F=33325]="R16F",t[t.R32F=33326]="R32F",t[t.RG16F=33327]="RG16F",t[t.RG32F=33328]="RG32F",t[t.R8I=33329]="R8I",t[t.R8UI=33330]="R8UI",t[t.R16I=33331]="R16I",t[t.R16UI=33332]="R16UI",t[t.R32I=33333]="R32I",t[t.R32UI=33334]="R32UI",t[t.RG8I=33335]="RG8I",t[t.RG8UI=33336]="RG8UI",t[t.RG16I=33337]="RG16I",t[t.RG16UI=33338]="RG16UI",t[t.RG32I=33339]="RG32I",t[t.RG32UI=33340]="RG32UI",t[t.R8_SNORM=36756]="R8_SNORM",t[t.RG8_SNORM=36757]="RG8_SNORM",t[t.RGB8_SNORM=36758]="RGB8_SNORM",t[t.RGBA8_SNORM=36759]="RGBA8_SNORM",t[t.RGB10_A2UI=36975]="RGB10_A2UI",t[t.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",t[t.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",t[t.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",t[t.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",t[t.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",t[t.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",t[t.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",t[t.HALF_FLOAT=5131]="HALF_FLOAT",t[t.RG=33319]="RG",t[t.RG_INTEGER=33320]="RG_INTEGER",t[t.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",t[t.CURRENT_QUERY=34917]="CURRENT_QUERY",t[t.QUERY_RESULT=34918]="QUERY_RESULT",t[t.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",t[t.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",t[t.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",t[t.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",t[t.DRAW_BUFFER0=34853]="DRAW_BUFFER0",t[t.DRAW_BUFFER1=34854]="DRAW_BUFFER1",t[t.DRAW_BUFFER2=34855]="DRAW_BUFFER2",t[t.DRAW_BUFFER3=34856]="DRAW_BUFFER3",t[t.DRAW_BUFFER4=34857]="DRAW_BUFFER4",t[t.DRAW_BUFFER5=34858]="DRAW_BUFFER5",t[t.DRAW_BUFFER6=34859]="DRAW_BUFFER6",t[t.DRAW_BUFFER7=34860]="DRAW_BUFFER7",t[t.DRAW_BUFFER8=34861]="DRAW_BUFFER8",t[t.DRAW_BUFFER9=34862]="DRAW_BUFFER9",t[t.DRAW_BUFFER10=34863]="DRAW_BUFFER10",t[t.DRAW_BUFFER11=34864]="DRAW_BUFFER11",t[t.DRAW_BUFFER12=34865]="DRAW_BUFFER12",t[t.DRAW_BUFFER13=34866]="DRAW_BUFFER13",t[t.DRAW_BUFFER14=34867]="DRAW_BUFFER14",t[t.DRAW_BUFFER15=34868]="DRAW_BUFFER15",t[t.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",t[t.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",t[t.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",t[t.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",t[t.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",t[t.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",t[t.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",t[t.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",t[t.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",t[t.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",t[t.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",t[t.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",t[t.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",t[t.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",t[t.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",t[t.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",t[t.SAMPLER_3D=35679]="SAMPLER_3D",t[t.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",t[t.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",t[t.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",t[t.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",t[t.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",t[t.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",t[t.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",t[t.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",t[t.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",t[t.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",t[t.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",t[t.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",t[t.MAX_SAMPLES=36183]="MAX_SAMPLES",t[t.SAMPLER_BINDING=35097]="SAMPLER_BINDING",t[t.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",t[t.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",t[t.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",t[t.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",t[t.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",t[t.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",t[t.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",t[t.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",t[t.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",t[t.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",t[t.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",t[t.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",t[t.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",t[t.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",t[t.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",t[t.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",t[t.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",t[t.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",t[t.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",t[t.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",t[t.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",t[t.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",t[t.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",t[t.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",t[t.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",t[t.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",t[t.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",t[t.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",t[t.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",t[t.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",t[t.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",t[t.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",t[t.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",t[t.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",t[t.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",t[t.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",t[t.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",t[t.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",t[t.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",t[t.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",t[t.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",t[t.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",t[t.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",t[t.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",t[t.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",t[t.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",t[t.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",t[t.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",t[t.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",t[t.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",t[t.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",t[t.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",t[t.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",t[t.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",t[t.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",t[t.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",t[t.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",t[t.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",t[t.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",t[t.UNIFORM_TYPE=35383]="UNIFORM_TYPE",t[t.UNIFORM_SIZE=35384]="UNIFORM_SIZE",t[t.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",t[t.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",t[t.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",t[t.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",t[t.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",t[t.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",t[t.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",t[t.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",t[t.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",t[t.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",t[t.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",t[t.OBJECT_TYPE=37138]="OBJECT_TYPE",t[t.SYNC_CONDITION=37139]="SYNC_CONDITION",t[t.SYNC_STATUS=37140]="SYNC_STATUS",t[t.SYNC_FLAGS=37141]="SYNC_FLAGS",t[t.SYNC_FENCE=37142]="SYNC_FENCE",t[t.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",t[t.UNSIGNALED=37144]="UNSIGNALED",t[t.SIGNALED=37145]="SIGNALED",t[t.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",t[t.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",t[t.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",t[t.WAIT_FAILED=37149]="WAIT_FAILED",t[t.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",t[t.COLOR=6144]="COLOR",t[t.DEPTH=6145]="DEPTH",t[t.STENCIL=6146]="STENCIL",t[t.MIN=32775]="MIN",t[t.MAX=32776]="MAX",t[t.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",t[t.STREAM_READ=35041]="STREAM_READ",t[t.STREAM_COPY=35042]="STREAM_COPY",t[t.STATIC_READ=35045]="STATIC_READ",t[t.STATIC_COPY=35046]="STATIC_COPY",t[t.DYNAMIC_READ=35049]="DYNAMIC_READ",t[t.DYNAMIC_COPY=35050]="DYNAMIC_COPY",t[t.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",t[t.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",t[t.INVALID_INDEX=4294967295]="INVALID_INDEX",t[t.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",t[t.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",t[t.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",t[t.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",t[t.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",t[t.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",t[t.R16_EXT=33322]="R16_EXT",t[t.RG16_EXT=33324]="RG16_EXT",t[t.RGB16_EXT=32852]="RGB16_EXT",t[t.RGBA16_EXT=32859]="RGBA16_EXT",t[t.R16_SNORM_EXT=36760]="R16_SNORM_EXT",t[t.RG16_SNORM_EXT=36761]="RG16_SNORM_EXT",t[t.RGB16_SNORM_EXT=36762]="RGB16_SNORM_EXT",t[t.RGBA16_SNORM_EXT=36763]="RGBA16_SNORM_EXT",t[t.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",t[t.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",t[t.COMPRESSED_RED_RGTC1_EXT=36283]="COMPRESSED_RED_RGTC1_EXT",t[t.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]="COMPRESSED_SIGNED_RED_RGTC1_EXT",t[t.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]="COMPRESSED_RED_GREEN_RGTC2_EXT",t[t.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]="COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT",t[t.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",t[t.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",t[t.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",t[t.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",t[t.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",t[t.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",t[t.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",t[t.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",t[t.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",t[t.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",t[t.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",t[t.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",t[t.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",t[t.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",t[t.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",t[t.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",t[t.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",t[t.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",t[t.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",t[t.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",t[t.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",t[t.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",t[t.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",t[t.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",t[t.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",t[t.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",t[t.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",t[t.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",t[t.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",t[t.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",t[t.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",t[t.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR",t[t.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",t[t.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",t[t.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",t[t.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",t[t.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",t[t.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",t[t.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT",t[t.COMPLETION_STATUS_KHR=37297]="COMPLETION_STATUS_KHR",t[t.DEPTH_CLAMP_EXT=34383]="DEPTH_CLAMP_EXT",t[t.FIRST_VERTEX_CONVENTION_WEBGL=36429]="FIRST_VERTEX_CONVENTION_WEBGL",t[t.LAST_VERTEX_CONVENTION_WEBGL=36430]="LAST_VERTEX_CONVENTION_WEBGL",t[t.PROVOKING_VERTEX_WEBL=36431]="PROVOKING_VERTEX_WEBL",t[t.POLYGON_MODE_WEBGL=2880]="POLYGON_MODE_WEBGL",t[t.POLYGON_OFFSET_LINE_WEBGL=10754]="POLYGON_OFFSET_LINE_WEBGL",t[t.LINE_WEBGL=6913]="LINE_WEBGL",t[t.FILL_WEBGL=6914]="FILL_WEBGL",t[t.MAX_CLIP_DISTANCES_WEBGL=3378]="MAX_CLIP_DISTANCES_WEBGL",t[t.MAX_CULL_DISTANCES_WEBGL=33529]="MAX_CULL_DISTANCES_WEBGL",t[t.MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL=33530]="MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL",t[t.CLIP_DISTANCE0_WEBGL=12288]="CLIP_DISTANCE0_WEBGL",t[t.CLIP_DISTANCE1_WEBGL=12289]="CLIP_DISTANCE1_WEBGL",t[t.CLIP_DISTANCE2_WEBGL=12290]="CLIP_DISTANCE2_WEBGL",t[t.CLIP_DISTANCE3_WEBGL=12291]="CLIP_DISTANCE3_WEBGL",t[t.CLIP_DISTANCE4_WEBGL=12292]="CLIP_DISTANCE4_WEBGL",t[t.CLIP_DISTANCE5_WEBGL=12293]="CLIP_DISTANCE5_WEBGL",t[t.CLIP_DISTANCE6_WEBGL=12294]="CLIP_DISTANCE6_WEBGL",t[t.CLIP_DISTANCE7_WEBGL=12295]="CLIP_DISTANCE7_WEBGL",t[t.POLYGON_OFFSET_CLAMP_EXT=36379]="POLYGON_OFFSET_CLAMP_EXT",t[t.LOWER_LEFT_EXT=36001]="LOWER_LEFT_EXT",t[t.UPPER_LEFT_EXT=36002]="UPPER_LEFT_EXT",t[t.NEGATIVE_ONE_TO_ONE_EXT=37726]="NEGATIVE_ONE_TO_ONE_EXT",t[t.ZERO_TO_ONE_EXT=37727]="ZERO_TO_ONE_EXT",t[t.CLIP_ORIGIN_EXT=37724]="CLIP_ORIGIN_EXT",t[t.CLIP_DEPTH_MODE_EXT=37725]="CLIP_DEPTH_MODE_EXT",t[t.SRC1_COLOR_WEBGL=35065]="SRC1_COLOR_WEBGL",t[t.SRC1_ALPHA_WEBGL=34185]="SRC1_ALPHA_WEBGL",t[t.ONE_MINUS_SRC1_COLOR_WEBGL=35066]="ONE_MINUS_SRC1_COLOR_WEBGL",t[t.ONE_MINUS_SRC1_ALPHA_WEBGL=35067]="ONE_MINUS_SRC1_ALPHA_WEBGL",t[t.MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL=35068]="MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL",t[t.MIRROR_CLAMP_TO_EDGE_EXT=34627]="MIRROR_CLAMP_TO_EDGE_EXT"}
1932)(Kt||(Kt={}));const nE={WEBGL_depth_texture:{UNSIGNED_INT_24_8_WEBGL:34042},OES_element_index_uint:{},OES_texture_float:{},OES_texture_half_float:{HALF_FLOAT_OES:5131},EXT_color_buffer_float:{},OES_standard_derivatives:{FRAGMENT_SHADER_DERIVATIVE_HINT_OES:35723},EXT_frag_depth:{},EXT_blend_minmax:{MIN_EXT:32775,MAX_EXT:32776},EXT_shader_texture_lod:{}},sE=t=>({drawBuffersWEBGL(e){return t.drawBuffers(e)},COLOR_ATTACHMENT0_WEBGL:36064,COLOR_ATTACHMENT1_WEBGL:36065,COLOR_ATTACHMENT2_WEBGL:36066,COLOR_ATTACHMENT3_WEBGL:36067}),rE=t=>({VERTEX_ARRAY_BINDING_OES:34229,createVertexArrayOES(){return t.createVertexArray()},deleteVertexArrayOES(e){return t.deleteVertexArray(e)},isVertexArrayOES(e){return t.isVertexArray(e)},bindVertexArrayOES(e){return t.bindVertexArray(e)}}),oE=t=>({VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE:35070,drawArraysInstancedANGLE(...e){return t.drawArraysInstanced(...e)},drawElementsInstancedANGLE(...e){return t.drawElementsInstanced(...e)},vertexAttribDivisorANGLE(...e){return t.vertexAttribDivisor(...e)}});function aE(t=!0){const e=HTMLCanvasElement.prototype;if(!t&&e.originalGetContext){e.getContext=e.originalGetContext,e.originalGetContext=void 0;return}e.originalGetContext=e.getContext,e.getContext=function(i,n){if(i==="webgl"||i==="experimental-webgl"){const s=this.originalGetContext("webgl2",n);return s instanceof HTMLElement&&cE(s),s}return this.originalGetContext(i,n)}}function cE(t){t.getExtension("EXT_color_buffer_float");const e={...nE,WEBGL_disjoint_timer_query:t.getExtension("EXT_disjoint_timer_query_webgl2"),WEBGL_draw_buffers:sE(t),OES_vertex_array_object:rE(t),ANGLE_instanced_arrays:oE(t)},i=t.getExtension;t.getExtension=function(s){const r=i.call(t,s);return r||(s in e?e[s]:null)};const n=t.getSupportedExtensions;t.getSupportedExtensions=function(){const s=n.apply(t)||[];return s==null?void 0:s.concat(Object.keys(e))}}async function bd(t,e){const i=document.getElementsByTagName("head")[0];if(!i)throw new Error("loadScript");const n=document.createElement("script");return n.setAttribute("type","text/javascript"),n.setAttribute("src",t),new Promise((s,r)=>{n.onload=s,n.onerror=o=>r(new Error(`Unable to load script '${t}': ${o}`)),i.appendChild(n)})}function _s(t){const e=t.luma||{_polyfilled:!1,extensions:{},softwareRenderer:!1};return e._polyfilled??(e._polyfilled=!1),e.extensions||(e.extensions={}),t.luma=e,e}const lE=1;let J=null,Zl=!1;const Oa={debugSpectorJS:R.get("debug-spectorjs"),debugSpectorJSUrl:"https://cdn.jsdelivr.net/npm/[email protected]/dist/spector.bundle.js",gl:void 0};async function fE(t){if(!globalThis.SPECTOR)try{await bd(t.debugSpectorJSUrl||Oa.debugSpectorJSUrl)}catch(e){R.warn(String(e))}}function hE(t){var e;if(t={...Oa,...t},!t.debugSpectorJS)return null;if(!J&&globalThis.SPECTOR&&!((e=globalThis.luma)!=null&&e.spector)){R.probe(lE,"SPECTOR found and initialized. Start with `luma.spector.displayUI()`")();const{Spector:i}=globalThis.SPECTOR;J=new i,globalThis.luma&&(globalThis.luma.spector=J)}if(!J)return null;if(Zl||(Zl=!0,J.spyCanvases(),J==null||J.onCaptureStarted.add(i=>R.info("Spector capture started:",i)()),J==null||J.onCapture.add(i=>{R.info("Spector capture complete:",i)(),J==null||J.getResultUI(),J==null||J.resultView.display(),J==null||J.resultView.addCapture(i)})),t.gl){const i=t.gl,n=_s(i),s=n.device;J==null||J.startCapture(t.gl,500),n.device=s,new Promise(r=>setTimeout(r,2e3)).then(r=>{R.info("Spector capture stopped after 2 seconds")(),J==null||J.stopCapture()})}return J}const uE="https://unpkg.com/[email protected]/index.js";function vd(t){return t.luma=t.luma||{},t.luma}async function dE(){Lt()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await bd(uE))}function gE(t,e={}){return e.debugWebGL||e.traceWebGL?_E(t,e):pE(t)}function pE(t){const e=vd(t);return e.realContext?e.realContext:t}function _E(t,e){if(!globalThis.WebGLDebugUtils)return R.warn("webgl-debug not loaded")(),t;
1932const i=vd(t);if(i.debugContext)return i.debugContext;globalThis.WebGLDebugUtils.init({...Kt,...t});const n=globalThis.WebGLDebugUtils.makeDebugContext(t,mE.bind(null,e),yE.bind(null,e));for(const o in Kt)!(o in n)&&typeof Kt[o]=="number"&&(n[o]=Kt[o]);class s{}Object.setPrototypeOf(n,Object.getPrototypeOf(t)),Object.setPrototypeOf(s,n);const r=Object.create(s);return i.realContext=t,i.debugContext=r,r.luma=i,r.debug=!0,r}function Gl(t,e){e=Array.from(e).map(n=>n===void 0?"undefined":n);let i=globalThis.WebGLDebugUtils.glFunctionArgsToString(t,e);return i=`${i.slice(0,100)}${i.length>100?"...":""}`,`gl.${t}(${i})`}function mE(t,e,i,n){n=Array.from(n).map(a=>a===void 0?"undefined":a);const s=globalThis.WebGLDebugUtils.glEnumToString(e),r=globalThis.WebGLDebugUtils.glFunctionArgsToString(i,n),o=`${s} in gl.${i}(${r})`;R.error("%cWebGL","color: white; background: red; padding: 2px 6px; border-radius: 3px;",o)();debugger;throw new Error(o)}function yE(t,e,i){let n="";t.traceWebGL&&R.level>=1&&(n=Gl(e,i),R.info(1,"%cWebGL","color: white; background: blue; padding: 2px 6px; border-radius: 3px;",n)());for(const s of i)if(s===void 0){n=n||Gl(e,i);debugger}}const Ei=1;class bE extends G0{constructor(){super();g(this,"type","webgl");Mt.defaultProps={...Mt.defaultProps,...Oa}}enforceWebGL2(i){aE(i)}isSupported(){return typeof WebGL2RenderingContext<"u"}isDeviceHandle(i){return typeof WebGL2RenderingContext<"u"&&i instanceof WebGL2RenderingContext?!0:(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext&&R.warn("WebGL1 is not supported",i)(),!1)}async attach(i,n={}){const{WebGLDevice:s}=await ec(async()=>{const{WebGLDevice:a}=await Promise.resolve().then(()=>uf);return{WebGLDevice:a}},void 0);if(i instanceof s)return i;const r=s.getDeviceFromContext(i);if(r)return r;if(!vE(i))throw new Error("Invalid WebGL2RenderingContext");const o=n.createCanvasContext===!0?{}:n.createCanvasContext;return new s({...n,_handle:i,createCanvasContext:{canvas:i.canvas,autoResize:!1,...o}})}async create(i={}){const{WebGLDevice:n}=await ec(async()=>{const{WebGLDevice:o}=await Promise.resolve().then(()=>uf);return{WebGLDevice:o}},void 0),s=[];(i.debugWebGL||i.debug)&&s.push(dE()),i.debugSpectorJS&&s.push(fE(i));const r=await Promise.allSettled(s);for(const o of r)o.status==="rejected"&&R.error(`Failed to initialize debug libraries ${o.reason}`)();try{const o=new n(i);R.groupCollapsed(Ei,`WebGLDevice ${o.id} created`)();const a=`${o._reused?"Reusing":"Created"} device with WebGL2 ${o.props.debug?"debug ":""}context: ${o.info.vendor}, ${o.info.renderer} for canvas: ${o.canvasContext.id}`;return R.probe(Ei,a)(),R.table(Ei,o.info)(),o}finally{R.groupEnd(Ei)(),R.info(Ei,"%cWebGL call tracing: luma.log.set('debug-webgl') ","color: white; background: blue; padding: 2px 6px; border-radius: 3px;")()}}}function vE(t){return typeof WebGL2RenderingContext<"u"&&t instanceof WebGL2RenderingContext?!0:!!(t&&typeof t.createVertexArray=="function")}const Nr=new bE,Ia={3042:!1,32773:new Float32Array([0,0,0,0]),32777:32774,34877:32774,32969:1,32968:0,32971:1,32970:0,3106:new Float32Array([0,0,0,0]),3107:[!0,!0,!0,!0],2884:!1,2885:1029,2929:!1,2931:1,2932:513,2928:new Float32Array([0,1]),2930:!0,3024:!0,35725:null,36006:null,36007:null,34229:null,34964:null,2886:2305,33170:4352,2849:1,32823:!1,32824:0,10752:0,32926:!1,32928:!1,32938:1,32939:!1,3089:!1,3088:new Int32Array([0,0,1024,1024]),2960:!1,2961:0,2968:4294967295,36005:4294967295,2962:519,2967:0,2963:4294967295,34816:519,36003:0,36004:4294967295,2964:7680,2965:7680,2966:7680,34817:7680,34818:7680,34819:7680,2978:[0,0,1024,1024],36389:null,36662:null,36663:null,35053:null,35055:null,35723:4352,36010:null,35977:!1,3333:4,3317:4,37440:!1,37441:!1,37443:37444,3330:0,3332:0,3331:0,3314:0,32878:0,3316:0,3315:0,32877:0},ae=(t,e,i)=>e?t.enable(i):t.disable(i),Ql=(t,e,i)=>t.hint(i,e),me=(t,e,i)=>t.pixelStorei(i,e),Jl=(t,e,i)=>{const n=i===36006?36009:36008;return t.bindFramebuffer(n,e)},xi=(t,e,i)=>{const s={34964:34962,36662:36662,36663:36663,35053:35051,35055:35052}[i];t.bindBuffer(s,e)};function Lr(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}const TE={3042:ae,32773:(t,e)=>
vendor: 5,169 bytes, line 1932
1932t.blendColor(...e),32777:"blendEquation",34877:"blendEquation",32969:"blendFunc",32968:"blendFunc",32971:"blendFunc",32970:"blendFunc",3106:(t,e)=>t.clearColor(...e),3107:(t,e)=>t.colorMask(...e),2884:ae,2885:(t,e)=>t.cullFace(e),2929:ae,2931:(t,e)=>t.clearDepth(e),2932:(t,e)=>t.depthFunc(e),2928:(t,e)=>t.depthRange(...e),2930:(t,e)=>t.depthMask(e),3024:ae,35723:Ql,35725:(t,e)=>t.useProgram(e),36007:(t,e)=>t.bindRenderbuffer(36161,e),36389:(t,e)=>{var i;return(i=t.bindTransformFeedback)==null?void 0:i.call(t,36386,e)},34229:(t,e)=>t.bindVertexArray(e),36006:Jl,36010:Jl,34964:xi,36662:xi,36663:xi,35053:xi,35055:xi,2886:(t,e)=>t.frontFace(e),33170:Ql,2849:(t,e)=>t.lineWidth(e),32823:ae,32824:"polygonOffset",10752:"polygonOffset",35977:ae,32926:ae,32928:ae,32938:"sampleCoverage",32939:"sampleCoverage",3089:ae,3088:(t,e)=>t.scissor(...e),2960:ae,2961:(t,e)=>t.clearStencil(e),2968:(t,e)=>t.stencilMaskSeparate(1028,e),36005:(t,e)=>t.stencilMaskSeparate(1029,e),2962:"stencilFuncFront",2967:"stencilFuncFront",2963:"stencilFuncFront",34816:"stencilFuncBack",36003:"stencilFuncBack",36004:"stencilFuncBack",2964:"stencilOpFront",2965:"stencilOpFront",2966:"stencilOpFront",34817:"stencilOpBack",34818:"stencilOpBack",34819:"stencilOpBack",2978:(t,e)=>t.viewport(...e),34383:ae,10754:ae,12288:ae,12289:ae,12290:ae,12291:ae,12292:ae,12293:ae,12294:ae,12295:ae,3333:me,3317:me,37440:me,37441:me,37443:me,3330:me,3332:me,3331:me,3314:me,32878:me,3316:me,3315:me,32877:me,framebuffer:(t,e)=>{const i=e&&"handle"in e?e.handle:e;return t.bindFramebuffer(36160,i)},blend:(t,e)=>e?t.enable(3042):t.disable(3042),blendColor:(t,e)=>t.blendColor(...e),blendEquation:(t,e)=>{const i=typeof e=="number"?[e,e]:e;t.blendEquationSeparate(...i)},blendFunc:(t,e)=>{const i=(e==null?void 0:e.length)===2?[...e,...e]:e;t.blendFuncSeparate(...i)},clearColor:(t,e)=>t.clearColor(...e),clearDepth:(t,e)=>t.clearDepth(e),clearStencil:(t,e)=>t.clearStencil(e),colorMask:(t,e)=>t.colorMask(...e),cull:(t,e)=>e?t.enable(2884):t.disable(2884),cullFace:(t,e)=>t.cullFace(e),depthTest:(t,e)=>e?t.enable(2929):t.disable(2929),depthFunc:(t,e)=>t.depthFunc(e),depthMask:(t,e)=>t.depthMask(e),depthRange:(t,e)=>t.depthRange(...e),dither:(t,e)=>e?t.enable(3024):t.disable(3024),derivativeHint:(t,e)=>{t.hint(35723,e)},frontFace:(t,e)=>t.frontFace(e),mipmapHint:(t,e)=>t.hint(33170,e),lineWidth:(t,e)=>t.lineWidth(e),polygonOffsetFill:(t,e)=>e?t.enable(32823):t.disable(32823),polygonOffset:(t,e)=>t.polygonOffset(...e),sampleCoverage:(t,e)=>t.sampleCoverage(e[0],e[1]||!1),scissorTest:(t,e)=>e?t.enable(3089):t.disable(3089),scissor:(t,e)=>t.scissor(...e),stencilTest:(t,e)=>e?t.enable(2960):t.disable(2960),stencilMask:(t,e)=>{e=Lr(e)?e:[e,e];const[i,n]=e;t.stencilMaskSeparate(1028,i),t.stencilMaskSeparate(1029,n)},stencilFunc:(t,e)=>{e=Lr(e)&&e.length===3?[...e,...e]:e;const[i,n,s,r,o,a]=e;t.stencilFuncSeparate(1028,i,n,s),t.stencilFuncSeparate(1029,r,o,a)},stencilOp:(t,e)=>{e=Lr(e)&&e.length===3?[...e,...e]:e;const[i,n,s,r,o,a]=e;t.stencilOpSeparate(1028,i,n,s),t.stencilOpSeparate(1029,r,o,a)},viewport:(t,e)=>t.viewport(...e)};function oe(t,e,i){return e[t]!==void 0?e[t]:i[t]}const AE={blendEquation:(t,e,i)=>t.blendEquationSeparate(oe(32777,e,i),oe(34877,e,i)),blendFunc:(t,e,i)=>t.blendFuncSeparate(oe(32969,e,i),oe(32968,e,i),oe(32971,e,i),oe(32970,e,i)),polygonOffset:(t,e,i)=>t.polygonOffset(oe(32824,e,i),oe(10752,e,i)),sampleCoverage:(t,e,i)=>t.sampleCoverage(oe(32938,e,i),oe(32939,e,i)),stencilFuncFront:(t,e,i)=>t.stencilFuncSeparate(1028,oe(2962,e,i),oe(2967,e,i),oe(2963,e,i)),stencilFuncBack:(t,e,i)=>t.stencilFuncSeparate(1029,oe(34816,e,i),oe(36003,e,i),oe(36004,e,i)),stencilOpFront:(t,e,i)=>t.stencilOpSeparate(1028,oe(2964,e,i),oe(2965,e,i),oe(2966,e,i)),stencilOpBack:(t,e,i)=>t.stencilOpSeparate(1029,oe(34817,e,i),oe(34818,e,i),oe(34819,e,i))},ef={enable:(t,e)=>t({[e]:!0}),disable:(t,e)=>t({[e]:!1}),pixelStorei:(t,e,i)=>t({[e]:i}),hint:(t,e,i)=>t({[e]:i}),useProgram:(t,e)=>t({35725:e}),bindRenderbuffer:(t,e,i)=>t({36007:i}),bindTransformFeedback:(t,e,i)=>t({36389:i}),bindVertexArray:(t,e)=>t({34229:e}),bindFramebuffer:(t,e,i)=>{switch(e){case 36160:return t({36006:i,36010:i});case 36009:return t({36006:i});case 36008:return t({36010:i});default:return null}},bindBuffer:(t,e,i)=>{const n={34962:[34964],36662:[36662],36663:[36663],35051:[35053],35052:[35055]}[e];return n?t({[n]:i}):{valueChanged:!0}},blendColor:(t,e,i,n,s)=>t({32773:new Float32Array([e,i,n,s])}),blendEquation:(t,e)=>t({32777:e,34877:e}),blendEquationSeparate:(t,e,i)=>t({32777:e,34877:i}),blendFunc:(t,e,i)=>t({32969:e,32968:i,32971:e,32970:i}),blendFuncSeparate:(t,e,i,n,s)=>t({32969:e,32968:i,32971:n,32970:s}),clearColor:(t,e,i,n,s)=>t({3106:new Float32Array([e,i,n,s])}),clearDepth:(t,e)=>t({2931:e}),clearStencil:(t,e)=>t({2961:e}),colorMask:(t,e,i,n,s)=>t({3107:[e,i,n,s]}),cullFace:(t,e)=>t({2885:e}),depthFunc:(t,e)=>t({2932:e}),depthRange:(t,e,i)=>t({2928:new Float32Array([e,i])}),depthMask:(t,e)=>t({2930:e}),frontFace:(t,e)=>t({2886:e}),lineWidth:(t,e)=>t({2849:e}),polygonOffset:(t,e,i)=>t({32824:e,10752:i}),sampleCoverage:(t,e,i)=>t({32938:e,32939:i}),scissor:(t,e,i,n,s)=>
1932t({3088:new Int32Array([e,i,n,s])}),stencilMask:(t,e)=>t({2968:e,36005:e}),stencilMaskSeparate:(t,e,i)=>t({[e===1028?2968:36005]:i}),stencilFunc:(t,e,i,n)=>t({2962:e,2967:i,2963:n,34816:e,36003:i,36004:n}),stencilFuncSeparate:(t,e,i,n,s)=>t({[e===1028?2962:34816]:i,[e===1028?2967:36003]:n,[e===1028?2963:36004]:s}),stencilOp:(t,e,i,n)=>t({2964:e,2965:i,2966:n,34817:e,34818:i,34819:n}),stencilOpSeparate:(t,e,i,n,s)=>t({[e===1028?2964:34817]:i,[e===1028?2965:34818]:n,[e===1028?2966:34819]:s}),viewport:(t,e,i,n,s)=>t({2978:[e,i,n,s]})},Ue=(t,e)=>t.isEnabled(e),tf={3042:Ue,2884:Ue,2929:Ue,3024:Ue,32823:Ue,32926:Ue,32928:Ue,3089:Ue,2960:Ue,35977:Ue},wE=new Set([34016,36388,36387,35983,35368,34965,35739,35738,3074,34853,34854,34855,34856,34857,34858,34859,34860,34861,34862,34863,34864,34865,34866,34867,34868,35097,32873,35869,32874,34068]);function mi(t,e){var s;if(EE(e))return;const i={};for(const r in e){const o=Number(r),a=TE[r];a&&(typeof a=="string"?i[a]=!0:a(t,e[r],o))}const n=(s=t.lumaState)==null?void 0:s.cache;if(n)for(const r in i){const o=AE[r];o(t,e,n)}}function Td(t,e=Ia){if(typeof e=="number"){const s=e,r=tf[s];return r?r(t,s):t.getParameter(s)}const i=Array.isArray(e)?e:Object.keys(e),n={};for(const s of i){const r=tf[s];n[s]=r?r(t,Number(s)):t.getParameter(Number(s))}return n}function SE(t){mi(t,Ia)}function EE(t){for(const e in t)return!1;return!0}function xE(t,e){if(t===e)return!0;if(nf(t)&&nf(e)&&t.length===e.length){for(let i=0;i<t.length;++i)if(t[i]!==e[i])return!1;return!0}return!1}function nf(t){return Array.isArray(t)||ArrayBuffer.isView(t)}class Et{constructor(e,i){g(this,"gl");g(this,"program",null);g(this,"stateStack",[]);g(this,"enable",!0);g(this,"cache",null);g(this,"log");g(this,"initialized",!1);this.gl=e,this.log=(i==null?void 0:i.log)||(()=>{}),this._updateCache=this._updateCache.bind(this),Object.seal(this)}static get(e){return e.lumaState}push(e={}){this.stateStack.push({})}pop(){const e=this.stateStack[this.stateStack.length-1];mi(this.gl,e),this.stateStack.pop()}trackState(e,i){if(this.cache=i!=null&&i.copyState?Td(e):Object.assign({},Ia),this.initialized)throw new Error("WebGLStateTracker");this.initialized=!0,this.gl.lumaState=this,RE(e);for(const n in ef){const s=ef[n];PE(e,n,s)}sf(e,"getParameter"),sf(e,"isEnabled")}_updateCache(e){let i=!1,n;const s=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(const r in e){const o=e[r],a=this.cache[r];xE(o,a)||(i=!0,n=a,s&&!(r in s)&&(s[r]=a),this.cache[r]=o)}return{valueChanged:i,oldValue:n}}}function sf(t,e){const i=t[e].bind(t);t[e]=function(s){if(s===void 0||wE.has(s))return i(s);const r=Et.get(t);return s in r.cache||(r.cache[s]=i(s)),r.enable?r.cache[s]:i(s)},Object.defineProperty(t[e],"name",{value:`${e}-from-cache`,configurable:!1})}function PE(t,e,i){if(!t[e])return;const n=t[e].bind(t);t[e]=function(...r){const o=Et.get(t),{valueChanged:a,oldValue:c}=i(o._updateCache,...r);return a&&n(...r),c},Object.defineProperty(t[e],"name",{value:`${e}-to-cache`,configurable:!1})}function RE(t){const e=t.useProgram.bind(t);t.useProgram=function(n){const s=Et.get(t);s.program!==n&&(e(n),s.program=n)}}function CE(t,e,i){let n="";const s=c=>{const l=c.statusMessage;l&&(n||(n=l))};t.addEventListener("webglcontextcreationerror",s,!1);const r=i.failIfMajorPerformanceCaveat!==!0,o={preserveDrawingBuffer:!0,...i,failIfMajorPerformanceCaveat:!0};let a=null;try{a||(a=t.getContext("webgl2",o)),!a&&o.failIfMajorPerformanceCaveat&&(n||(n="Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow."));let c=!1;if(!a&&r&&(o.failIfMajorPerformanceCaveat=!1,a=t.getContext("webgl2",o),c=!0),a||(a=t.getContext("webgl",{}),a&&(a=null,n||(n="Your browser only supports WebGL1"))),!a)throw n||(n="Your browser does not support WebGL"),new Error(`Failed to create WebGL context: ${n}`);const l=_s(a);l.softwareRenderer=c;const{onContextLost:f,onContextRestored:h}=e;return t.addEventListener("webglcontextlost",u=>f(u),!1),t.addEventListener("webglcontextrestored",u=>h(u),!1),a}finally{t.removeEventListener("webglcontextcreationerror",s,!1)}}function Nt(t,e,i){return i[e]===void 0&&(i[e]=t.getExtension(e)||null),i[e]}function ME(t,e){const i=t.getParameter(7936),n=t.getParameter(7937);Nt(t,"WEBGL_debug_renderer_info",e);const s=e.WEBGL_debug_renderer_info,r=t.getParameter(s?s.UNMASKED_VENDOR_WEBGL:7936),o=t.getParameter(s?s.UNMASKED_RENDERER_WEBGL:7937),a=r||i,c=o||n,l=t.getParameter(7938),f=Ad(a,c),h=OE(a,c),u=IE(a,c);return{type:"webgl",gpu:f,gpuType:u,gpuBackend:h,vendor:a,renderer:c,version:l,shadingLanguage:"glsl",shadingLanguageVersion:300}}function Ad(t,e){return/NVIDIA/i.exec(t)||/NVIDIA/i.exec(e)?"nvidia":/INTEL/i.exec(t)||/INTEL/i.exec(e)?"intel":/Apple/i.exec(t)||/Apple/i.exec(e)?"apple":/AMD/i.exec(t)||/AMD/i.exec(e)||/ATI/i.exec(t)||/ATI/i.exec(e)?"amd":/SwiftShader/i.exec(t)||/SwiftShader/i.exec(e)?"software":"unknown"}function OE(t,e){return/Metal/i.exec(t)||/Metal/i.exec(e)?"metal":
vendor: 4,447 bytes, line 1932
1932/ANGLE/i.exec(t)||/ANGLE/i.exec(e)?"opengl":"unknown"}function IE(t,e){if(/SwiftShader/i.exec(t)||/SwiftShader/i.exec(e))return"cpu";switch(Ad(t,e)){case"apple":return NE(t,e)?"integrated":"unknown";case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}function NE(t,e){return/Apple (M\d|A\d|GPU)/i.test(`${t} ${e}`)}function wd(t){switch(t){case"uint8":return 5121;case"sint8":return 5120;case"unorm8":return 5121;case"snorm8":return 5120;case"uint16":return 5123;case"sint16":return 5122;case"unorm16":return 5123;case"snorm16":return 5122;case"uint32":return 5125;case"sint32":return 5124;case"float16":return 5131;case"float32":return 5126}throw new Error(String(t))}const Oi="WEBGL_compressed_texture_s3tc",Ii="WEBGL_compressed_texture_s3tc_srgb",qt="EXT_texture_compression_rgtc",Zt="EXT_texture_compression_bptc",LE="WEBGL_compressed_texture_etc",DE="WEBGL_compressed_texture_astc",BE="WEBGL_compressed_texture_etc1",FE="WEBGL_compressed_texture_pvrtc",kE="WEBGL_compressed_texture_atc",UE="EXT_texture_norm16",rf="EXT_render_snorm",Sd="EXT_color_buffer_float",Dr="snorm8-renderable-webgl",Br="norm16-renderable-webgl",Fr="snorm16-renderable-webgl",kr="float16-renderable-webgl",Mn="float32-renderable-webgl",zE="rgb9e5ufloat-renderable-webgl",Na={"float32-renderable-webgl":{extensions:[Sd]},"float16-renderable-webgl":{extensions:["EXT_color_buffer_half_float"]},"rgb9e5ufloat-renderable-webgl":{extensions:["WEBGL_render_shared_exponent"]},"snorm8-renderable-webgl":{extensions:[rf]},"norm16-webgl":{extensions:[UE]},"norm16-renderable-webgl":{features:["norm16-webgl"]},"snorm16-renderable-webgl":{features:["norm16-webgl"],extensions:[rf]},"float32-filterable":{extensions:["OES_texture_float_linear"]},"float16-filterable-webgl":{extensions:["OES_texture_half_float_linear"]},"texture-filterable-anisotropic-webgl":{extensions:["EXT_texture_filter_anisotropic"]},"texture-blend-float-webgl":{extensions:["EXT_float_blend"]},"texture-compression-bc":{extensions:[Oi,Ii,qt,Zt]},"texture-compression-bc5-webgl":{extensions:[qt]},"texture-compression-bc7-webgl":{extensions:[Zt]},"texture-compression-etc2":{extensions:[LE]},"texture-compression-astc":{extensions:[DE]},"texture-compression-etc1-webgl":{extensions:[BE]},"texture-compression-pvrtc-webgl":{extensions:[FE]},"texture-compression-atc-webgl":{extensions:[kE]}};function WE(t){return t in Na}function Ed(t,e,i){return xd(t,e,i,new Set)}function xd(t,e,i,n){const s=Na[e];if(!s||n.has(e))return!1;n.add(e);const r=(s.features||[]).every(o=>xd(t,o,i,n));return n.delete(e),r?(s.extensions||[]).every(o=>!!Nt(t,o,i)):!1}const qs={r8unorm:{gl:33321,rb:!0},r8snorm:{gl:36756,r:Dr},r8uint:{gl:33330,rb:!0},r8sint:{gl:33329,rb:!0},rg8unorm:{gl:33323,rb:!0},rg8snorm:{gl:36757,r:Dr},rg8uint:{gl:33336,rb:!0},rg8sint:{gl:33335,rb:!0},r16uint:{gl:33332,rb:!0},r16sint:{gl:33331,rb:!0},r16float:{gl:33325,rb:!0,r:kr},r16unorm:{gl:33322,rb:!0,r:Br},r16snorm:{gl:36760,r:Fr},"rgba4unorm-webgl":{gl:32854,rb:!0},"rgb565unorm-webgl":{gl:36194,rb:!0},"rgb5a1unorm-webgl":{gl:32855,rb:!0},"rgb8unorm-webgl":{gl:32849},"rgb8snorm-webgl":{gl:36758},rgba8unorm:{gl:32856},"rgba8unorm-srgb":{gl:35907},rgba8snorm:{gl:36759,r:Dr},rgba8uint:{gl:36220},rgba8sint:{gl:36238},bgra8unorm:{},"bgra8unorm-srgb":{},rg16uint:{gl:33338},rg16sint:{gl:33337},rg16float:{gl:33327,rb:!0,r:kr},rg16unorm:{gl:33324,r:Br},rg16snorm:{gl:36761,r:Fr},r32uint:{gl:33334,rb:!0},r32sint:{gl:33333,rb:!0},r32float:{gl:33326,r:Mn},rgb9e5ufloat:{gl:35901,r:zE},rg11b10ufloat:{gl:35898,rb:!0},rgb10a2unorm:{gl:32857,rb:!0},rgb10a2uint:{gl:36975,rb:!0},"rgb16unorm-webgl":{gl:32852,r:!1},"rgb16snorm-webgl":{gl:36762,r:!1},rg32uint:{gl:33340,rb:!0},rg32sint:{gl:33339,rb:!0},rg32float:{gl:33328,rb:!0,r:Mn},rgba16uint:{gl:36214,rb:!0},rgba16sint:{gl:36232,rb:!0},rgba16float:{gl:34842,r:kr},rgba16unorm:{gl:32859,rb:!0,r:Br},rgba16snorm:{gl:36763,r:Fr},"rgb32float-webgl":{gl:34837,x:Sd,r:Mn,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,rb:!0},rgba32sint:{gl:36226,rb:!0},rgba32float:{gl:34836,rb:!0,r:Mn},stencil8:{gl:36168,rb:!0},depth16unorm:{gl:33189,dataFormat:6402,types:[5123],rb:!0},depth24plus:{gl:33190,dataFormat:6402,types:[5125]},depth32float:{gl:36012,dataFormat:6402,types:[5126],rb:!0},"depth24plus-stencil8":{gl:35056,rb:!0,depthTexture:!0,dataFormat:34041,types:[34042]},"depth32float-stencil8":{gl:36013,dataFormat:34041,types:[36269],rb:!0}
1932,"bc1-rgb-unorm-webgl":{gl:33776,x:Oi},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:Ii},"bc1-rgba-unorm":{gl:33777,x:Oi},"bc1-rgba-unorm-srgb":{gl:35916,x:Ii},"bc2-rgba-unorm":{gl:33778,x:Oi},"bc2-rgba-unorm-srgb":{gl:35918,x:Ii},"bc3-rgba-unorm":{gl:33779,x:Oi},"bc3-rgba-unorm-srgb":{gl:35919,x:Ii},"bc4-r-unorm":{gl:36283,x:qt},"bc4-r-snorm":{gl:36284,x:qt},"bc5-rg-unorm":{gl:36285,x:qt},"bc5-rg-snorm":{gl:36286,x:qt},"bc6h-rgb-ufloat":{gl:36495,x:Zt},"bc6h-rgb-float":{gl:36494,x:Zt},"bc7-rgba-unorm":{gl:36492,x:Zt},"bc7-rgba-unorm-srgb":{gl:36493,x:Zt},"etc2-rgb8unorm":{gl:37492},"etc2-rgb8unorm-srgb":{gl:37494},"etc2-rgb8a1unorm":{gl:37496},"etc2-rgb8a1unorm-srgb":{gl:37497},"etc2-rgba8unorm":{gl:37493},"etc2-rgba8unorm-srgb":{gl:37495},"eac-r11unorm":{gl:37488},"eac-r11snorm":{gl:37489},"eac-rg11unorm":{gl:37490},"eac-rg11snorm":{gl:37491},"astc-4x4-unorm":{gl:37808},"astc-4x4-unorm-srgb":{gl:37840},"astc-5x4-unorm":{gl:37809},"astc-5x4-unorm-srgb":{gl:37841},"astc-5x5-unorm":{gl:37810},"astc-5x5-unorm-srgb":{gl:37842},"astc-6x5-unorm":{gl:37811},"astc-6x5-unorm-srgb":{gl:37843},"astc-6x6-unorm":{gl:37812},"astc-6x6-unorm-srgb":{gl:37844},"astc-8x5-unorm":{gl:37813},"astc-8x5-unorm-srgb":{gl:37845},"astc-8x6-unorm":{gl:37814},"astc-8x6-unorm-srgb":{gl:37846},"astc-8x8-unorm":{gl:37815},"astc-8x8-unorm-srgb":{gl:37847},"astc-10x5-unorm":{gl:37816},"astc-10x5-unorm-srgb":{gl:37848},"astc-10x6-unorm":{gl:37817},"astc-10x6-unorm-srgb":{gl:37849},"astc-10x8-unorm":{gl:37818},"astc-10x8-unorm-srgb":{gl:37850},"astc-10x10-unorm":{gl:37819},"astc-10x10-unorm-srgb":{gl:37851},"astc-12x10-unorm":{gl:37820},"astc-12x10-unorm-srgb":{gl:37852},"astc-12x12-unorm":{gl:37821},"astc-12x12-unorm-srgb":{gl:37853},"pvrtc-rgb4unorm-webgl":{gl:35840},"pvrtc-rgba4unorm-webgl":{gl:35842},"pvrtc-rgb2unorm-webgl":{gl:35841},"pvrtc-rgba2unorm-webgl":{gl:35843},"etc1-rbg-unorm-webgl":{gl:36196},"atc-rgb-unorm-webgl":{gl:35986},"atc-rgba-unorm-webgl":{gl:35986},"atc-rgbai-unorm-webgl":{gl:34798}};function VE(t,e,i){let n=e.create;const s=qs[e.format];(s==null?void 0:s.gl)===void 0&&(n=!1),s!=null&&s.x&&(n=n&&!!Nt(t,s.x,i)),e.format==="stencil8"&&(n=!1);const r=(s==null?void 0:s.r)===!1?!1:(s==null?void 0:s.r)===void 0||Ed(t,s.r,i),o=n&&e.render&&r&&$E(t,e.format,i);return{format:e.format,create:n&&e.create,render:o,filter:n&&e.filter,blend:n&&e.blend,store:n&&e.store}}function $E(t,e,i){const n=qs[e],s=n==null?void 0:n.gl;if(s===void 0||n!=null&&n.x&&!Nt(t,n.x,i))return!1;const r=t.getParameter(32873),o=t.getParameter(36006),a=t.createTexture(),c=t.createFramebuffer();if(!a||!c)return!1;const l=0;let f=Number(t.getError());for(;f!==l;)f=t.getError();let h=!1;try{if(t.bindTexture(3553,a),t.texStorage2D(3553,1,s,1,1),Number(t.getError())!==l)return!1;t.bindFramebuffer(36160,c),t.framebufferTexture2D(36160,36064,3553,a,0),h=Number(t.checkFramebufferStatus(36160))===36053&&Number(t.getError())===l}finally{t.bindFramebuffer(36160,o),t.deleteFramebuffer(c),t.bindTexture(3553,r),t.deleteTexture(a)}return h}function Pd(t){var s;const e=qs[t],i=XE(t),n=Ce.getInfo(t);return n.compressed&&(e.dataFormat=i),{internalFormat:i,format:(e==null?void 0:e.dataFormat)||HE(n.channels,n.integer,n.normalized,i),type:n.dataType?wd(n.dataType):((s=e==null?void 0:e.types)==null?void 0:s[0])||5121,compressed:n.compressed||!1}}function jE(t){switch(Ce.getInfo(t).attachment){case"depth":return 36096;case"stencil":return 36128;case"depth-stencil":return 33306;default:throw new Error(`Not a depth stencil format: ${t}`)}}function HE(t,e,i,n){if(n===6408||n===6407)return n;switch(t){case"r":return e&&!i?36244:6403;case"rg":return e&&!i?33320:33319;case"rgb":return e&&!i?36248:6407;case"rgba":return e&&!i?36249:6408;case"bgra":throw new Error("bgra pixels not supported by WebGL");default:return 6408}}function XE(t){const e=qs[t],i=e==null?void 0:e.gl;if(i===void 0)throw new Error(`Unsupported texture format ${t}`);return i}const of={"depth-clip-control":"EXT_depth_clamp","timestamp-query":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","polygon-mode-webgl":"WEBGL_polygon_mode","provoking-vertex-webgl":"WEBGL_provoking_vertex","shader-clip-cull-distance-webgl":"WEBGL_clip_cull_distance","shader-noperspective-interpolation-webgl":"NV_shader_noperspective_interpolation","shader-conservative-depth-webgl":"EXT_conservative_depth"};class YE extends X0{constructor(i,n,s){super([],s);g(this,"gl");g(this,"extensions");g(this,"testedFeatures",new Set);this.gl=i,this.extensions=n,Nt(i,"EXT_color_buffer_float",n)}*[Symbol.iterator](){const i=this.getFeatures();for(const n of i)this.has(n)&&(yield n);return[]}has(i){var n;return(n=this.disabledFeatures)!=null&&n[i]?!1:(this.testedFeatures.has(i)||(this.testedFeatures.add(i),WE(i)&&Ed(this.gl,i,this.extensions)&&this.features.add(i),this.getWebGLFeature(i)&&this.features.add(i)),this.features.has(i))}initializeFeatures(){const i=this.getFeatures().filter(n=>n!=="polygon-mode-webgl");for(const n of i)this.has(n)}getFeatures(){return[...Object.keys(of),...Object.keys(Na)]}getWebGLFeature(i){const n=of[i];return typeof n=="string"?!!Nt(this.gl,n,this.extensions):!!n}}class KE extends W0{constructor(i){super();g(this,"gl");g(this,"limits",{});this.gl=i}get maxTextureDimension1D(){return 0}get maxTextureDimension2D(){return this.getParameter(3379)}get maxTextureDimension3D(){return this.getParameter(32883)}get maxTextureArrayLayers(){return this.getParameter(35071)}get maxBindGroups(){return 0}get maxDynamicUniformBuffersPerPipelineLayout(){return 0}get maxDynamicStorageBuffersPerPipelineLayout(){return 0}get maxSampledTexturesPerShaderStage(){return this.getParameter(35660)}get maxSamplersPerShaderStage(){return this.getParameter(35661)}get maxStorageBuffersPerShaderStage(){return 0}get maxStorageTexturesPerShaderStage(){return 0}get maxUniformBuffersPerShaderStage(){return this.getParameter(35375)}get maxUniformBufferBindingSize(){return this.getParameter(35376)}get maxStorageBufferBindingSize(){return 0}get minUniformBufferOffsetAlignment(){return this.getParameter(35380)}get minStorageBufferOffsetAlignment(){return 0}get maxVertexBuffers(){return 16}get maxVertexAttributes(){return this.getParameter(34921)}get maxVertexBufferArrayStride(){return 2048}get maxInterStageShaderVariables(){return this.getParameter(35659)}get maxComputeWorkgroupStorageSize(){return 0}get maxComputeInvocationsPerWorkgroup(){return 0}get maxComputeWorkgroupSizeX(){return 0}get maxComputeWorkgroupSizeY(){return 0}get maxComputeWorkgroupSizeZ(){return 0}get maxComputeWorkgroupsPerDimension(){return 0}getParameter(i){return this.limits[i]===void 0&&(this.limits[i]=this.gl.getParameter(i)),this.limits[i]||0}}class ki extends ls{constructor(i,n){super(i,n);g(this,"device");g(this,"gl");g(this,"handle");g(this,"colorAttachments",[]);g(this,"depthStencilAttachment",null);const s=n.handle===null;this.device=i,this.gl=i.gl,this.handle=this.props.handle||s?this.props.handle:this.gl.createFramebuffer(),s||(i._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),this.autoCreateAttachmentTextures(),this.updateAttachments())}destroy(){super.destroy(),!this.destroyed&&this.handle!==null&&this.gl.deleteFramebuffer(this.handle)}updateAttachments(){const i=this.gl.bindFramebuffer(36160,this.handle);for(let n=0;n<this.colorAttachments.length;++n){const s=this.colorAttachments[n];if(s){const r=36064+n;this._attachTextureView(r,s)}}if(this.depthStencilAttachment){const n=jE(this.depthStencilAttachment.props.format);this._attachTextureView(n,this.depthStencilAttachment)}if(this.device.props.debug){const n=this.gl.checkFramebufferStatus(36160);if(n!==36053)throw new Error(`Framebuffer ${ZE(n)}`)}this.gl.bindFramebuffer(36160,i)}_attachTextureView(i,n){const{gl:s}=this.device,{texture:r}=n,o=n.props.baseMipLevel,a=n.props.baseArrayLayer;switch(s.bindTexture(r.glTarget,r.handle),r.glTarget){case 35866:case 32879:s.framebufferTextureLayer(36160,i,r.handle,o,a);break;case 34067:const c=qE(a);s.framebufferTexture2D(36160,i,c,r.handle,o);break;case 3553:s.framebufferTexture2D(36160,i,3553,r.handle,o);break;default:throw new Error("Illegal texture type")}s.bindTexture(r.glTarget,null)}resizeAttachments(i,n){if(this.handle===null){this.width=i,this.height=n;return}super.resizeAttachments(i,n)}}function qE(t){return t<34069?t+34069:t}function ZE(t){switch(t){case 36053:return"success";case 36054:return"Mismatched attachments";case 36055:return"No attachments";case 36057:return"Height/width mismatch";case 36061:return"Unsupported or split attachments";case 36182:return"Samples mismatch";default:return`${t}`}}
1932class GE extends Eu{constructor(i,n){super(n);g(this,"device");g(this,"handle",null);g(this,"_framebuffer",null);this.device=i,this._setAutoCreatedCanvasId(`${this.device.id}-canvas`),this._configureDevice()}get[Symbol.toStringTag](){return"WebGLCanvasContext"}_configureDevice(){var n,s,r;(this.drawingBufferWidth!==((n=this._framebuffer)==null?void 0:n.width)||this.drawingBufferHeight!==((s=this._framebuffer)==null?void 0:s.height))&&((r=this._framebuffer)==null||r.resize([this.drawingBufferWidth,this.drawingBufferHeight]))}_getCurrentFramebuffer(){return this._framebuffer||(this._framebuffer=new ki(this.device,{id:"canvas-context-framebuffer",handle:null,width:this.drawingBufferWidth,height:this.drawingBufferHeight})),this._framebuffer}}class QE extends av{constructor(i,n={}){super(n);g(this,"device");g(this,"handle",null);g(this,"context2d");this.device=i;const s=`${this[Symbol.toStringTag]}(${this.id})`;if(!this.device.getDefaultCanvasContext().offscreenCanvas)throw new Error(`${s}: WebGL PresentationContext requires the default CanvasContext canvas to be an OffscreenCanvas`);const o=this.canvas.getContext("2d");if(!o)throw new Error(`${s}: Failed to create 2d presentation context`);this.context2d=o,this._setAutoCreatedCanvasId(`${this.device.id}-presentation-canvas`),this._configureDevice(),this._startObservers()}get[Symbol.toStringTag](){return"WebGLPresentationContext"}present(){this._resizeDrawingBufferIfNeeded(),this.device.submit();const i=this.device.getDefaultCanvasContext(),[n,s]=i.getDrawingBufferSize();if(!(this.drawingBufferWidth===0||this.drawingBufferHeight===0||n===0||s===0||i.canvas.width===0||i.canvas.height===0)){if(n!==this.drawingBufferWidth||s!==this.drawingBufferHeight||i.canvas.width!==this.drawingBufferWidth||i.canvas.height!==this.drawingBufferHeight)throw new Error(`${this[Symbol.toStringTag]}(${this.id}): Default canvas context size ${n}x${s} does not match presentation size ${this.drawingBufferWidth}x${this.drawingBufferHeight}`);this.context2d.clearRect(0,0,this.drawingBufferWidth,this.drawingBufferHeight),this.context2d.drawImage(i.canvas,0,0)}}_configureDevice(){}_getCurrentFramebuffer(i){const n=this.device.getDefaultCanvasContext();return n.setDrawingBufferSize(this.drawingBufferWidth,this.drawingBufferHeight),n.getCurrentFramebuffer(i)}}const Ur={};function JE(t="id"){Ur[t]=Ur[t]||1;const e=Ur[t]++;return`${t}-${e}`}class Ui extends Z{constructor(i,n={}){super(i,n);g(this,"device");g(this,"gl");g(this,"handle");g(this,"glTarget");g(this,"glUsage");g(this,"glIndexType",5123);g(this,"byteLength",0);g(this,"bytesUsed",0);this.device=i,this.gl=this.device.gl;const s=typeof n=="object"?n.handle:void 0;this.handle=s||this.gl.createBuffer(),i._setWebGLDebugMetadata(this.handle,this,{spector:{...this.props,data:typeof this.props.data}}),this.glTarget=ex(this.props.usage),this.glUsage=tx(this.props.usage),this.glIndexType=this.props.indexType==="uint32"?5125:5123,n.data?this._initWithData(n.data,n.byteOffset,n.byteLength):this._initWithByteLength(n.byteLength||0)}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.props.handle?this.trackDeallocatedReferencedMemory("Buffer"):(this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle)),this.destroyed=!0,this.handle=null)}_initWithData(i,n=0,s=i.byteLength+n){const r=this.glTarget;this.gl.bindBuffer(r,this.handle),this.gl.bufferData(r,s,this.glUsage),this.gl.bufferSubData(r,n,i),this.gl.bindBuffer(r,null),this.bytesUsed=s,this.byteLength=s,this._setDebugData(i,n,s),this.props.handle?this.trackReferencedMemory(s,"Buffer"):this.trackAllocatedMemory(s)}_initWithByteLength(i){let n=i;i===0&&(n=new Float32Array(0));const s=this.glTarget;return this.gl.bindBuffer(s,this.handle),this.gl.bufferData(s,n,this.glUsage),this.gl.bindBuffer(s,null),this.bytesUsed=i,this.byteLength=i,this._setDebugData(null,0,i),this.props.handle?this.trackReferencedMemory(i,"Buffer"):this.trackAllocatedMemory(i),this}write(i,n=0){const s=ArrayBuffer.isView(i)?i:new Uint8Array(i),r=36663;this.gl.bindBuffer(r,this.handle),this.gl.bufferSubData(r,n,s),this.gl.bindBuffer(r,null),this._setDebugData(i,n,i.byteLength)}async mapAndWriteAsync(i,n=0,s=this.byteLength-n){const r=new ArrayBuffer(s);await i(r,"copied"),this.write(r,n)}
1932async readAsync(i=0,n){return this.readSyncWebGL(i,n)}async mapAndReadAsync(i,n=0,s){const r=await this.readAsync(n,s);return await i(r.buffer,"copied")}readSyncWebGL(i=0,n){n=n??this.byteLength-i;const s=new Uint8Array(n),r=0;return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,i,s,r,n),this.gl.bindBuffer(36662,null),this._setDebugData(s,i,n),s}}function ex(t){return t&Z.INDEX?34963:t&Z.VERTEX?34962:t&Z.UNIFORM?35345:34962}function tx(t){return t&Z.INDEX||t&Z.VERTEX?35044:t&Z.UNIFORM?35048:35044}function ix(t){var n;const e=t.split(/\r?\n/),i=[];for(const s of e){if(s.length<=1)continue;const r=s.trim(),o=s.split(":"),a=(n=o[0])==null?void 0:n.trim();if(o.length===2){const[p,_]=o;if(!p||!_){i.push({message:r,type:On(a||"info"),lineNum:0,linePos:0});continue}i.push({message:_.trim(),type:On(p),lineNum:0,linePos:0});continue}const[c,l,f,...h]=o;if(!c||!l||!f){i.push({message:o.slice(1).join(":").trim()||r,type:On(a||"info"),lineNum:0,linePos:0});continue}let u=parseInt(f,10);Number.isNaN(u)&&(u=0);let d=parseInt(l,10);Number.isNaN(d)&&(d=0),i.push({message:h.join(":").trim(),type:On(c),lineNum:u,linePos:d})}return i}function On(t){const e=["warning","error","info"],i=t.toLowerCase();return e.includes(i)?i:"info"}class nx extends cs{constructor(i,n){super(i,n);g(this,"device");g(this,"handle");switch(this.device=i,this.props.stage){case"vertex":this.handle=this.props.handle||this.device.gl.createShader(35633);break;case"fragment":this.handle=this.props.handle||this.device.gl.createShader(35632);break;default:throw new Error(this.props.stage)}i._setWebGLDebugMetadata(this.handle,this,{spector:this.props});const s=this._compile(this.source);s&&typeof s.catch=="function"&&s.catch(()=>{this.compilationStatus="error"})}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0,this.handle.de
1932stroyed=!0)}get asyncCompilationStatus(){return this._waitForCompilationComplete().then(()=>(this._getCompilationStatus(),this.compilationStatus))}async getCompilationInfo(){return await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){const i=this.device.gl.getShaderInfoLog(this.handle);return i?ix(i):[]}getTranslatedSource(){const n=this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders;return(n==null?void 0:n.getTranslatedShaderSource(this.handle))||null}_compile(i){i=i.startsWith("#version ")?i:`#version 300 es 1933${i}`;const{gl:n}=this.device;if(n.shaderSource(this.handle,i),n.compileShader(this.handle),!this.device.props.debug){this.compilationStatus="pending";return}if(!this.device.features.has("compilation-status-async-webgl")){if(this._getCompilationStatus(),this.debugShader(),this.compilationStatus==="error")throw new Error(`GLSL compilation errors in ${this.props.stage} shader ${this.props.id}`);return}return R.once(1,"Shader compilation is asynchronous")(),this._waitForCompilationComplete().then(()=>{R.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader()})}async _waitForCompilationComplete(){const i=async r=>await new Promise(o=>setTimeout(o,r));if(!this.device.features.has("compilation-status-async-webgl")){await i(10);return}const{gl:s}=this.device;for(;;){if(s.getShaderParameter(this.handle,37297))return;await i(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,35713)?"success":"error"}}function sx(t,e,i,n){if(cx(e))return n(t);const s=t;s.pushState();try{return rx(t,e),mi(s.gl,i),n(t)}finally{s.popState()}}function rx(t,e){const i=t,{gl:n}=i;if(e.cullMode)switch(e.cullMode){case"none":n.disable(2884);break;case"front":n.enable(2884),n.cullFace(1028);break;case"back":n.enable(2884),n.cullFace(1029);break}if(e.frontFace&&n.frontFace(xt("frontFace",e.frontFace,{ccw:2305,cw:2304})),e.unclippedDepth&&t.features.has("depth-clip-control")&&n.enable(34383),e.depthBias!==void 0&&(n.enable(32823),n.polygonOffset(e.depthBias,e.depthBiasSlopeScale||0)),e.provokingVertex&&t.features.has("provoking-vertex-webgl")){const r=i.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex,o=xt("provokingVertex",e.provokingVertex,{first:36429,last:36430});r==null||r.provokingVertexWEBGL(o)}if((e.polygonMode||e.polygonOffsetLine)&&t.features.has("polygon-mode-webgl")){if(e.polygonMode){const r=i.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode,o=xt("polygonMode",e.polygonMode,{fill:6914,line:6913});r==null||r.polygonModeWEBGL(1028,o),r==null||r.polygonModeWEBGL(1029,o)}e.polygonOffsetLine&&n.enable(10754)}if(t.features.has("shader-clip-cull-distance-webgl")&&(e.clipDistance0&&n.enable(12288),e.clipDistance1&&n.enable(12289),e.clipDistance2&&n.enable(12290),e.clipDistance3&&n.enable(12291),e.clipDistance4&&n.enable(12292),e.clipDistance5&&n.enable(12293),e.clipDistance6&&n.enable(12294),e.clipDistance7&&n.enable(12295)),e.depthWriteEnabled!==void 0&&n.depthMask(ax("depthWriteEnabled",e.depthWriteEnabled)),e.depthCompare&&(e.depthCompare!=="always"?n.enable(2929):n.disable(2929),n.depthFunc(Vo("depthCompare",e.depthCompare))),e.clearDepth!==void 0&&n.clearDepth(e.clearDepth),e.stencilWriteMask){const s=e.stencilWriteMask;n.stencilMaskSeparate(1028,s),n.stencilMaskSeparate(1029,s)}if(e.stencilReadMask&&R.warn("stencilReadMask not supported under WebGL"),e.stencilCompare){const s=e.stencilReadMask||4294967295,r=Vo("depthCompare",e.stencilCompare);e.stencilCompare!=="always"?n.enable(2960):n.disable(2960),n.stencilFuncSeparate(1028,r,0,s),n.stencilFuncSeparate(1029,r,0,s)}if(e.stencilPassOperation&&e.stencilFailOperation&&e.stencilDepthFailOperation){const s=zr("stencilPassOperation",e.stencilPassOperation),r=zr("stencilFailOperation",e.stencilFailOperation),o=zr("stencilDepthFailOperation",e.stencilDepthFailOperation);n.stencilOpSeparate(1028,r,o,s),n.stencilOpSeparate(1029,r,o,s)}switch(e.blend){case!0:n.enable(3042);break;case!1:n.disable(3042);break}if(e.blendColorOperation||e.blendAlphaOperation){const s=af("blendColorOperation",e.blendColorOperation||"add"),r=af("blendAlphaOperation",e.blendAlphaOperation||"add");n.blendEquationSeparate(s,r);const o=In("blendColorSrcFactor",e.blendColorSrcFactor||"one"),a=In("blendColorDstFactor",e.blendColorDstFactor||"zero"),c=In("blendAlphaSrcFactor",e.blendAlphaSrcFactor||"one"),l=In("blendAlphaDstFactor",e.blendAlphaDstFactor||"zero");
1933n.blendFuncSeparate(o,a,c,l)}}function Vo(t,e){return xt(t,e,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function zr(t,e){return xt(t,e,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function af(t,e){return xt(t,e,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function In(t,e,i="color"){return xt(t,e,{one:1,zero:0,src:768,"one-minus-src":769,dst:774,"one-minus-dst":775,"src-alpha":770,"one-minus-src-alpha":771,"dst-alpha":772,"one-minus-dst-alpha":773,"src-alpha-saturated":776,constant:i==="color"?32769:32771,"one-minus-constant":i==="color"?32770:32772,src1:768,"one-minus-src1":769,"src1-alpha":770,"one-minus-src1-alpha":771})}function ox(t,e){return`Illegal parameter ${e} for ${t}`}function xt(t,e,i){if(!(e in i))throw new Error(ox(t,e));return i[e]}function ax(t,e){return e}function cx(t){let e=!0;for(const i in t){e=!1;break}return e}function Rd(t){const e={};return t.addressModeU&&(e[10242]=Wr(t.addressModeU)),t.addressModeV&&(e[10243]=Wr(t.addressModeV)),t.addressModeW&&(e[32882]=Wr(t.addressModeW)),t.magFilter&&(e[10240]=$o(t.magFilter)),(t.minFilter||t.mipmapFilter)&&(e[10241]=lx(t.minFilter||"linear",t.mipmapFilter)),t.lodMinClamp!==void 0&&(e[33082]=t.lodMinClamp),t.lodMaxClamp!==void 0&&(e[33083]=t.lodMaxClamp),t.type==="comparison-sampler"&&(e[34892]=34894),t.compare&&(e[34893]=Vo("compare",t.compare)),t.maxAnisotropy&&(e[34046]=t.maxAnisotropy),e}function Wr(t){switch(t){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function $o(t){switch(t){case"nearest":return 9728;case"linear":return 9729}}function lx(t,e="none"){if(!e)return $o(t);switch(e){case"none":return $o(t);case"nearest":switch(t){case"nearest":return 9984;case"linear":return 9985}break;case"linear":switch(t){case"nearest":return 9986;case"linear":return 9987}}}class fx extends ri{constructor(i,n){super(i,n);g(this,"device");g(this,"handle");g(this,"parameters");this.device=i,this.parameters=Rd(n),this.handle=n.handle||this.device.gl.createSampler(),this._setSamplerParameters(this.parameters)}destroy(){this.handle&&(this.device.gl.deleteSampler(this.handle),this.handle=void 0)}toString(){return`Sampler(${this.id},${JSON.stringify(this.props)})`}_setSamplerParameters(i){for(const[n,s]of Object.entries(i)){const r=Number(n);switch(r){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,r,s);break;default:this.device.gl.samplerParameteri(this.handle,r,s);break}}}}function vt(t,e,i){if(hx(e))return i(t);const{nocatch:n=!0}=e,s=Et.get(t);s.push(),mi(t,e);let r;if(n)r=i(t),s.pop();else try{r=i(t)}finally{s.pop()}return r}function hx(t){for(const e in t)return!1;return!0}class Gt extends as{constructor(i,n){super(i,{...Q.defaultProps,...n});g(this,"device");g(this,"gl");g(this,"handle");g(this,"texture");this.device=i,this.gl=this.device.gl,this.handle=null,this.texture=n.texture}}function Cd(t){return ux[t]}const ux={5124:"sint32",5125:"uint32",5122:"sint16",5123:"uint16",5120:"sint8",5121:"uint8",5126:"float32",5131:"float16",33635:"uint16",32819:"uint16",32820:"uint16",33640:"uint32",35899:"uint32",35902:"uint32",34042:"uint32",36269:"uint32"};class zi extends Q{constructor(i,n){super(i,n,{byteAlignment:1});g(this,"device");g(this,"gl");g(this,"handle");g(this,"sampler");g(this,"view");g(this,"glTarget");g(this,"glFormat");g(this,"glType");g(this,"glInternalFormat");g(this,"compressed");g(this,"_textureUnit",0);g(this,"_framebuffer",null);g(this,"_framebufferAttachmentKey",null);this.device=i,this.gl=this.device.gl;const s=Pd(this.props.format);this.glTarget=px(this.props.dimension),this.glInternalFormat=s.internalFormat,this.glFormat=s.format,this.glType=s.type,this.compressed=s.compressed,this.handle=this.props.handle||this.gl.createTexture(),this.device._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),this.gl.bindTexture(this.glTarget,this.handle);const{dimension:r,width:o,height:a,depth:c,mipLevels:l,glTarget:f,glInternalFormat:h}=this;if(!this.compressed)switch(r){case"2d":case"cube":this.gl.texStorage2D(f,l,h,o,a);break;case"2d-array":case"3d":this.gl.texStorage3D(f,l,h,o,a,c);break;default:throw new Error(r)}this.gl.bindTexture(this.glTarget,null),this._initializeData(n.data),this.props.handle?this.trackReferencedMemory(this.getAllocatedByteLength(),"Texture"):this.trackAllocatedMemory(this.getAllocatedByteLength(),"Texture"),this.setSampler(this.props.sampler),this.view=new Gt(this.device,{...this.props,texture:this}),Object.seal(this)}destroy(){var i;this.handle&&((i=this._framebuffer)==null||i.destroy(),this._framebuffer=null,this._framebufferAttachmentKey=null,this.removeStats(),this.props.handle?this.trackDeallocatedReferencedMemory("Texture"):(this.gl.deleteTexture(this.handle),this.trackDeallocatedMemory("Texture")),this.destroyed=!0)}createView(i){return new Gt(this.device,{...i,texture:this})}setSampler(i={}){super.setSampler(i);const n=Rd(this.sampler.props);this._setSamplerParameters(n)}copyExternalImage(i){const n=this._normalizeCopyExternalImageOptions(i);if(n.sourceX||n.sourceY)throw new Error("WebGL does not support sourceX/sourceY)");const{glFormat:s,glType:r}=this,{image:o,depth:a,mipLevel:c,x:l,y:f,z:h,width:u,height:d}=n,p=Nn(this.glTarget,this.dimension,h),_=n.flipY?{37440:!0}:{};return this.gl.bindTexture(this.glTarget,this.handle),vt(this.gl,_,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(p,c,l,f,u,d,s,r,o);break;case"2d-array":case"3d":this.gl.texSubImage3D(p,c,l,f,h,u,d,a,s,r,o);break;default:}}),this.gl.bindTexture(this.glTarget,null),{width:n.width,height:n.height}}copyImageData(i){super.copyImageData(i)}readBuffer(i={}
vendor: 4,817 bytes, line 1933
1933,n){if(!n)throw new Error(`${this} readBuffer requires a destination buffer`);const s=this._getSupportedColorReadOptions(i),r=i.byteOffset??0,o=this.computeMemoryLayout(s);if(n.byteLength<r+o.byteLength)throw new Error(`${this} readBuffer target is too small (${n.byteLength} < ${r+o.byteLength})`);const a=n;this.gl.bindBuffer(35051,a.handle);try{this._readColorTextureLayers(s,o,c=>{this.gl.readPixels(s.x,s.y,s.width,s.height,this.glFormat,this.glType,r+c)})}finally{this.gl.bindBuffer(35051,null)}return n}async readDataAsync(i={}){throw new Error(`${this} readDataAsync is deprecated; use readBuffer() with an explicit destination buffer or DynamicTexture.readAsync()`)}writeBuffer(i,n={}){const s=this._normalizeTextureWriteOptions(n),{width:r,height:o,depthOrArrayLayers:a,mipLevel:c,byteOffset:l,x:f,y:h,z:u}=s,{glFormat:d,glType:p,compressed:_}=this,m=Nn(this.glTarget,this.dimension,u);if(_)throw new Error("writeBuffer for compressed textures is not implemented in WebGL");const{bytesPerPixel:b}=this.device.getTextureFormatInfo(this.format),A=b?s.bytesPerRow/b:void 0,v={3317:this.byteAlignment,...A!==void 0?{3314:A}:{},32878:s.rowsPerImage};this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,i.handle),vt(this.gl,v,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(m,c,f,h,r,o,d,p,l);break;case"2d-array":case"3d":this.gl.texSubImage3D(m,c,f,h,u,r,o,a,d,p,l);break;default:}}),this.gl.bindBuffer(35052,null),this.gl.bindTexture(this.glTarget,null)}writeData(i,n={}){const s=this._normalizeTextureWriteOptions(n),r=ArrayBuffer.isView(i)?i:new Uint8Array(i),{width:o,height:a,depthOrArrayLayers:c,mipLevel:l,x:f,y:h,z:u,byteOffset:d}=s,{glFormat:p,glType:_,compressed:m}=this,b=Nn(this.glTarget,this.dimension,u);let A;if(!m){const{bytesPerPixel:O}=this.device.getTextureFormatInfo(this.format);O&&(A=s.bytesPerRow/O)}const v=this.compressed?{}:{3317:this.byteAlignment,...A!==void 0?{3314:A}:{},32878:s.rowsPerImage},S=gx(r,d),E=m?dx(r,d):r,x=this._getMipLevelSize(l),M=f===0&&h===0&&u===0&&o===x.width&&a===x.height&&c===x.depthOrArrayLayers;this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,null),vt(this.gl,v,()=>{switch(this.dimension){case"2d":case"cube":m?M?this.gl.compressedTexImage2D(b,l,p,o,a,0,E):this.gl.compressedTexSubImage2D(b,l,f,h,o,a,p,E):this.gl.texSubImage2D(b,l,f,h,o,a,p,_,r,S);break;case"2d-array":case"3d":m?M?this.gl.compressedTexImage3D(b,l,p,o,a,c,0,E):this.gl.compressedTexSubImage3D(b,l,f,h,u,o,a,c,p,E):this.gl.texSubImage3D(b,l,f,h,u,o,a,c,p,_,r,S);break;default:}}),this.gl.bindTexture(this.glTarget,null)}_getRowByteAlignment(i,n){return 1}_getFramebuffer(){return this._framebuffer||(this._framebuffer=this.device.createFramebuffer({id:`framebuffer-for-${this.id}`,width:this.width,height:this.height,colorAttachments:[this]})),this._framebuffer}readDataSyncWebGL(i={}){const n=this._getSupportedColorReadOptions(i),s=this.computeMemoryLayout(n),r=Cd(this.glType),o=Mu(r),a=new o(s.byteLength/o.BYTES_PER_ELEMENT);return this._readColorTextureLayers(n,s,c=>{const l=new o(a.buffer,a.byteOffset+c,s.bytesPerImage/o.BYTES_PER_ELEMENT);this.gl.readPixels(n.x,n.y,n.width,n.height,this.glFormat,this.glType,l)}),a.buffer}_readColorTextureLayers(i,n,s){const r=this._getFramebuffer(),o=n.bytesPerRow/n.bytesPerPixel,a={3333:this.byteAlignment,...o!==i.width?{3330:o}:{}},c=this.gl.getParameter(3074),l=this.gl.bindFramebuffer(36160,r.handle);try{this.gl.readBuffer(36064),vt(this.gl,a,()=>{for(let f=0;f<i.depthOrArrayLayers;f++)this._attachReadSubresource(r,i.mipLevel,i.z+f),s(f*n.bytesPerImage)})}finally{this.gl.bindFramebuffer(36160,l||null),this.gl.readBuffer(c)}}_attachReadSubresource(i,n,s){const r=`${n}:${s}`;if(this._framebufferAttachmentKey!==r){switch(this.dimension){case"2d":this.gl.framebufferTexture2D(36160,36064,3553,this.handle,n);break;case"cube":this.gl.framebufferTexture2D(36160,36064,Nn(this.glTarget,this.dimension,s),this.handle,n);break;case"2d-array":case"3d":this.gl.framebufferTextureLayer(36160,36064,this.handle,n,s);break;default:throw new Error(`${this} color readback does not support ${this.dimension} textures`)}if(this.device.props.debug){const o=Number(this.gl.checkFramebufferStatus(36160));if(o!==36053)throw new Error(`${i} incomplete for ${this} readback (${o})`)}this._framebufferAttachmentKey=r}}generateMipmapsWebGL(i){if(!(!(this.device.isTextureFormatRenderable(this.props.format)&&this.device.isTextureFormatFilterable(this.props.format))&&(R.warn(`${this} is not renderable or filterable, may not be able to generate mipmaps`)(),!(i!=null&&i.force))))try{this.gl.bindTexture(this.glTarget,this.handle),this.gl.generateMipmap(this.glTarget)}catch(s){R.warn(`Error generating mipmap for ${this}: ${s.message}`)()}finally{this.gl.bindTexture(this.glTarget,null)}}
1933_setSamplerParameters(i){R.log(2,`${this.id} sampler parameters`,this.device.getGLKeys(i))(),this.gl.bindTexture(this.glTarget,this.handle);for(const[n,s]of Object.entries(i)){const r=Number(n),o=s;switch(r){case 33082:case 33083:this.gl.texParameterf(this.glTarget,r,o);break;case 10240:case 10241:this.gl.texParameteri(this.glTarget,r,o);break;case 10242:case 10243:case 32882:this.gl.texParameteri(this.glTarget,r,o);break;case 34046:this.device.features.has("texture-filterable-anisotropic-webgl")&&this.gl.texParameteri(this.glTarget,r,o);break;case 34892:case 34893:this.gl.texParameteri(this.glTarget,r,o);break}}this.gl.bindTexture(this.glTarget,null)}_getActiveUnit(){return this.gl.getParameter(34016)-33984}_bind(i){const{gl:n}=this;return i!==void 0&&(this._textureUnit=i,n.activeTexture(33984+i)),n.bindTexture(this.glTarget,this.handle),i}_unbind(i){const{gl:n}=this;return i!==void 0&&(this._textureUnit=i,n.activeTexture(33984+i)),n.bindTexture(this.glTarget,null),i}}function dx(t,e=0){return e?new t.constructor(t.buffer,t.byteOffset+e,(t.byteLength-e)/t.BYTES_PER_ELEMENT):t}function gx(t,e){if(e%t.BYTES_PER_ELEMENT!==0)throw new Error(`Texture byteOffset ${e} must align to typed array element size ${t.BYTES_PER_ELEMENT}`);return e/t.BYTES_PER_ELEMENT}function px(t){switch(t){case"1d":break;case"2d":return 3553;case"3d":return 32879;case"cube":return 34067;case"2d-array":return 35866}throw new Error(t)}function Nn(t,e,i){return e==="cube"?34069+i:t}function _x(t,e,i,n){const s=t;let r=n;r===!0&&(r=1),r===!1&&(r=0);const o=typeof r=="number"?[r]:r;switch(i){case 35678:case 35680:case 35679:case 35682:case 36289:case 36292:case 36293:case 36298:case 36299:case 36300:case 36303:case 36306:case 36307:case 36308:case 36311:if(typeof n!="number")throw new Error("samplers must be set to integers");return t.uniform1i(e,n);case 5126:return t.uniform1fv(e,o);case 35664:return t.uniform2fv(e,o);case 35665:return t.uniform3fv(e,o);case 35666:return t.uniform4fv(e,o);case 5124:return t.uniform1iv(e,o);case 35667:return t.uniform2iv(e,o);case 35668:return t.uniform3iv(e,o);case 35669:return t.uniform4iv(e,o);case 35670:return t.uniform1iv(e,o);case 35671:return t.uniform2iv(e,o);case 35672:return t.uniform3iv(e,o);case 35673:return t.uniform4iv(e,o);case 5125:return s.uniform1uiv(e,o,1);case 36294:return s.uniform2uiv(e,o,2);case 36295:return s.uniform3uiv(e,o,3);case 36296:return s.uniform4uiv(e,o,4);case 35674:return t.uniformMatrix2fv(e,!1,o);case 35675:return t.uniformMatrix3fv(e,!1,o);case 35676:return t.uniformMatrix4fv(e,!1,o);case 35685:return s.uniformMatrix2x3fv(e,!1,o);case 35686:return s.uniformMatrix2x4fv(e,!1,o);case 35687:return s.uniformMatrix3x2fv(e,!1,o);case 35688:return s.uniformMatrix3x4fv(e,!1,o);case 35689:return s.uniformMatrix4x2fv(e,!1,o);case 35690:return s.uniformMatrix4x3fv(e,!1,o)}throw new Error("Illegal uniform")}function mx(t){switch(t){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 3;case"triangle-list":return 4;case"triangle-strip":return 5;default:throw new Error(t)}}function yx(t){switch(t){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 1;case"triangle-list":return 4;case"triangle-strip":return 4;default:throw new Error(t)}}class bx extends at{constructor(i,n){super(i,n);g(this,"device");g(this,"handle");g(this,"vs");g(this,"fs");g(this,"introspectedLayout");g(this,"bindings",{});g(this,"uniforms",{});g(this,"varyings",null);g(this,"_uniformCount",0);g(this,"_uniformSetters",{});this.device=i;const s=this.sharedRenderPipeline||this.device._createSharedRenderPipelineWebGL(n);this.sharedRenderPipeline=s,this.handle=s.handle,this.vs=s.vs,this.fs=s.fs,this.linkStatus=s.linkStatus,this.introspectedLayout=s.introspectedLayout,this.device._setWebGLDebugMetadata(this.handle,this,{spector:{id:this.props.id}}),this.shaderLayout=n.shaderLayout?vx(this.introspectedLayout,n.shaderLayout):this.introspectedLayout}get[Symbol.toStringTag](){return"WEBGLRenderPipeline"}destroy(){this.destroyed||(this.sharedRenderPipeline&&!this.props._sharedRenderPipeline&&this.sharedRenderPipeline.destroy(),this.destroyResource())}setBindings(i,n){const s=el(Pu(this.shaderLayout,i));for(const[r,o]of Object.entries(s)){const a=Md(this.shaderLayout,r);if(a){switch(o||R.warn(`Unsetting binding "${r}" in render pipeline "${this.id}"`)(),a.type){case"uniform":if(!(o instanceof Ui)&&!(o.buffer instanceof Ui))throw new Error("buffer value");break;case"texture":if(!(o instanceof Gt||o instanceof zi||o instanceof ki))throw new Error(`${this} Bad texture binding for ${r}`);break;case"sampler":R.warn(`Ignoring sampler ${r}`)();break;default:throw new Error(a.type)}this.bindings[r]=o}
1933else{const c=this.shaderLayout.bindings.map(l=>`"${l.name}"`).join(", ");n!=null&&n.disableWarnings||R.warn(`No binding "${r}" in render pipeline "${this.id}", expected one of ${c}`,o)()}}}draw(i){var A;this._syncLinkStatus();const n=i.bindGroups?el(i.bindGroups):i.bindings||this.bindings,{renderPass:s,parameters:r=this.props.parameters,topology:o=this.props.topology,vertexArray:a,vertexCount:c,instanceCount:l,isInstanced:f=!1,firstVertex:h=0,transformFeedback:u,uniforms:d=this.uniforms}=i,p=mx(o),_=!!a.indexBuffer,m=(A=a.indexBuffer)==null?void 0:A.glIndexType;if(this.linkStatus!=="success")return R.info(2,`RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)(),!1;if(!this._areTexturesRenderable(n))return R.info(2,`RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)(),!1;this.device.gl.useProgram(this.handle),a.bindBeforeRender(s),u&&u.begin(this.props.topology),this._applyBindings(n,{disableWarnings:this.props.disableWarnings}),this._applyUniforms(d);const b=s;return sx(this.device,r,b.glParameters,()=>{_&&f?this.device.gl.drawElementsInstanced(p,c||0,m,h,l||0):_?this.device.gl.drawElements(p,c||0,m,h):f?this.device.gl.drawArraysInstanced(p,h,c||0,l||0):this.device.gl.drawArrays(p,h,c||0),u&&u.end()}),a.unbindAfterRender(s),!0}_areTexturesRenderable(i){let n=!0;for(const s of this.shaderLayout.bindings)cf(i,s.name)||(R.warn(`Binding ${s.name} not found in ${this.id}`)(),n=!1);return n}_applyBindings(i,n){if(this._syncLinkStatus(),this.linkStatus!=="success")return;const{gl:s}=this.device;s.useProgram(this.handle);let r=0,o=0;for(const a of this.shaderLayout.bindings){const c=cf(i,a.name);if(!c)throw new Error(`No value for binding ${a.name} in ${this.id}`);switch(a.type){case"uniform":const{name:l}=a,f=s.getUniformBlockIndex(this.handle,l);if(f===4294967295)throw new Error(`Invalid uniform block name ${l}`);if(s.uniformBlockBinding(this.handle,f,o),c instanceof Ui)s.bindBufferBase(35345,o,c.handle);else{const u=c;s.bindBufferRange(35345,o,u.buffer.handle,u.offset||0,u.size||u.buffer.byteLength-(u.offset||0))}o+=1;break;case"texture":if(!(c instanceof Gt||c instanceof zi||c instanceof ki))throw new Error("texture");let h;if(c instanceof Gt)h=c.texture;else if(c instanceof zi)h=c;else if(c instanceof ki&&c.colorAttachments[0]instanceof Gt)R.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),h=c.colorAttachments[0].texture;else throw new Error("No texture");s.activeTexture(33984+r),s.bindTexture(h.glTarget,h.handle),r+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${a.type}' not supported in WebGL`)}}}_applyUniforms(i){for(const n of this.shaderLayout.uniforms||[]){const{name:s,location:r,type:o,textureUnit:a}=n,c=i[s]??a;c!==void 0&&_x(this.device.gl,r,o,c)}}_syncLinkStatus(){this.linkStatus=this.sharedRenderPipeline.linkStatus}}function vx(t,e){const i={...t,attributes:t.attributes.map(n=>({...n})),bindings:t.bindings.map(n=>({...n}))};for(const n of(e==null?void 0:e.attributes)||[]){const s=i.attributes.find(r=>r.name===n.name);s?(s.type=n.type||s.type,s.stepMode=n.stepMode||s.stepMode):R.warn(`shader layout attribute ${n.name} not present in shader`)}for(const n of(e==null?void 0:e.bindings)||[]){const s=Md(i,n.name);if(!s){R.warn(`shader layout binding ${n.name} not present in shader`);continue}Object.assign(s,n)}return i}function Md(t,e){return t.bindings.find(i=>i.name===e||i.name===`${e}Uniforms`||`${i.name}Uniforms`===e)}function cf(t,e){return t[e]||t[`${e}Uniforms`]||t[e.replace(/Uniforms$/,"")]}function Tx(t){return Sx[t]}function La(t){return wx[t]}function Od(t){return!!Id[t]}function Ax(t){return Id[t]}const wx={5126:"f32",35664:"vec2<f32>",35665:"vec3<f32>",35666:"vec4<f32>",5124:"i32",35667:"vec2<i32>",35668:"vec3<i32>",35669:"vec4<i32>",5125:"u32",36294:"vec2<u32>",36295:"vec3<u32>",36296:"vec4<u32>",35670:"f32",35671:"vec2<f32>",35672:"vec3<f32>",35673:"vec4<f32>",35674:"mat2x2<f32>",35685:"mat2x3<f32>",35686:"mat2x4<f32>",35687:"mat3x2<f32>",35675:"mat3x3<f32>",35688:"mat3x4<f32>",35689:"mat4x2<f32>",35690:"mat4x3<f32>",35676:"mat4x4<f32>"},Id={35678:{viewDimension:"2d",sampleType:"float"},35680:{viewDimension:"cube",sampleType:"float"},35679:{viewDimension:"3d",sampleType:"float"},35682:{viewDimension:"3d",sampleType:"depth"},36289:{viewDimension:"2d-array",sampleType:"float"},36292:{viewDimension:"2d-array",sampleType:"depth"},36293:{viewDimension:"cube",sampleType:"float"},36298:{viewDimension:"2d",sampleType:"sint"},36299:{viewDimension:"3d",sampleType:"sint"},36300:{viewDimension:"cube",sampleType:"sint"},36303:{viewDimension:"2d-array",sampleType:"uint"},36306:{viewDimension:"2d",sampleType:"uint"},36307:{viewDimension:"3d",sampleType:"uint"},36308:{viewDimension:"cube",sampleType:"uint"},36311:{viewDimension:"2d-array",sampleType:"uint"}},Sx={uint8:5121,sint8:5120,unorm8:5121,snorm8:5120,uint16:5123,sint16:5122,unorm16:5123,snorm16:5122,uint32:5125,sint32:5124,float16:5131,float32:5126};function Ex(t,e){const i={attributes:[],bindings:[]};i.attributes=xx(t,e);const n=Cx(t,e);
1933for(const a of n){const c=a.uniforms.map(l=>({name:l.name,format:l.format,byteOffset:l.byteOffset,byteStride:l.byteStride,arrayLength:l.arrayLength}));i.bindings.push({type:"uniform",name:a.name,group:0,location:a.location,visibility:(a.vertex?1:0)&(a.fragment?2:0),minBindingSize:a.byteLength,uniforms:c})}const s=Rx(t,e);let r=0;for(const a of s)if(Od(a.type)){const{viewDimension:c,sampleType:l}=Ax(a.type);i.bindings.push({type:"texture",name:a.name,group:0,location:r,viewDimension:c,sampleType:l}),a.textureUnit=r,r+=1}s.length&&(i.uniforms=s);const o=Px(t,e);return o!=null&&o.length&&(i.varyings=o),i}function xx(t,e){const i=[],n=t.getProgramParameter(e,35721);for(let s=0;s<n;s++){const r=t.getActiveAttrib(e,s);if(!r)throw new Error("activeInfo");const{name:o,type:a}=r,c=t.getAttribLocation(e,o);if(c>=0){const l=La(a),f=/instance/i.test(o)?"instance":"vertex";i.push({name:o,location:c,stepMode:f,type:l})}}return i.sort((s,r)=>s.location-r.location),i}function Px(t,e){const i=[],n=t.getProgramParameter(e,35971);for(let s=0;s<n;s++){const r=t.getTransformFeedbackVarying(e,s);if(!r)throw new Error("activeInfo");const{name:o,type:a,size:c}=r,l=La(a),{type:f,components:h}=Ta(l);i.push({location:s,name:o,type:f,size:c*h})}return i.sort((s,r)=>s.location-r.location),i}function Rx(t,e){const i=[],n=t.getProgramParameter(e,35718);for(let s=0;s<n;s++){const r=t.getActiveUniform(e,s);if(!r)throw new Error("activeInfo");const{name:o,size:a,type:c}=r,{name:l,isArray:f}=Mx(o);let h=t.getUniformLocation(e,l);const u={location:h,name:l,size:a,type:c,isArray:f};if(i.push(u),u.size>1)for(let d=0;d<u.size;d++){const p=`${l}[${d}]`;h=t.getUniformLocation(e,p);const _={...u,name:p,location:h};i.push(_)}}return i}function Cx(t,e){const i=(r,o)=>t.getActiveUniformBlockParameter(e,r,o),n=[],s=t.getProgramParameter(e,35382);for(let r=0;r<s;r++){const o={name:t.getActiveUniformBlockName(e,r)||"",location:i(r,35391),byteLength:i(r,35392),vertex:i(r,35396),fragment:i(r,35398),uniformCount:i(r,35394),uniforms:[]},a=i(r,35395)||[],c=t.getActiveUniforms(e,a,35383),l=t.getActiveUniforms(e,a,35384),f=t.getActiveUniforms(e,a,35387),h=t.getActiveUniforms(e,a,35388);for(let p=0;p<o.uniformCount;++p){const _=a[p];if(_!==void 0){const m=t.getActiveUniform(e,_);if(!m)throw new Error("activeInfo");const b=La(c[p]);o.uniforms.push({name:m.name,format:b,type:c[p],arrayLength:l[p],byteOffset:f[p],byteStride:h[p]})}}const u=new Set(o.uniforms.map(p=>p.name.split(".")[0]).filter(p=>!!p)),d=o.name.replace(/Uniforms$/,"");if(u.size===1&&!u.has(o.name)&&!u.has(d)){const[p]=u;R.warn(`Uniform block "${o.name}" uses GLSL instance "${p}". luma.gl binds uniform buffers by block name ("${o.name}") and alias ("${d}"). Prefer matching the instance name to one of those to avoid confusing silent mismatches.`)()}n.push(o)}return n.sort((r,o)=>r.location-o.location),n}function Mx(t){if(t[t.length-1]!=="]")return{name:t,length:1,isArray:!1};const i=/([^[]*)(\[[0-9]+\])?/.exec(t);return{name:va(i==null?void 0:i[1],`Failed to parse GLSL uniform name ${t}`),length:i!=null&&i[2]?1:0,isArray:!!(i!=null&&i[2])}}const lf=4;class Ox extends pv{constructor(i,n){super(i,n);g(this,"device");g(this,"handle");g(this,"vs");g(this,"fs");g(this,"introspectedLayout",{attributes:[],bindings:[],uniforms:[]});g(this,"linkStatus","pending");this.device=i,this.handle=n.handle||this.device.gl.createProgram(),this.vs=n.vs,this.fs=n.fs,n.varyings&&n.varyings.length>0&&this.device.gl.transformFeedbackVaryings(this.handle,n.varyings,n.bufferMode||35981),this._linkShaders(),R.time(3,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.introspectedLayout=Ex(this.device.gl,this.handle),R.timeEnd(3,`RenderPipeline ${this.id} - shaderLayout introspection`)()}destroy(){this.destroyed||(this.device.gl.useProgram(null),this.device.gl.deleteProgram(this.handle),this.handle.de
1933stroyed=!0,this.destroyResource())}async _linkShaders(){const{gl:i}=this.device;if(i.attachShader(this.handle,this.vs.handle),i.attachShader(this.handle,this.fs.handle),R.time(lf,`linkProgram for ${this.id}`)(),i.linkProgram(this.handle),R.timeEnd(lf,`linkProgram for ${this.id}`)(),!this.device.features.has("compilation-status-async-webgl")){const s=this._getLinkStatus();this._reportLinkStatus(s);return}R.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),R.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();const n=this._getLinkStatus();this._reportLinkStatus(n)}async _reportLinkStatus(i){var n;switch(i){case"success":return;default:const s=i==="link-error"?"Link error":"Validation error";switch(this.vs.compilationStatus){case"error":throw this.vs.debugShader(),new Error(`${this} ${s} during compilation of ${this.vs}`);case"pending":await this.vs.asyncCompilationStatus,this.vs.debugShader();break}switch((n=this.fs)==null?void 0:n.compilationStatus){case"error":throw this.fs.debugShader(),new Error(`${this} ${s} during compilation of ${this.fs}`);case"pending":await this.fs.asyncCompilationStatus,this.fs.debugShader();break}const r=this.device.gl.getProgramInfoLog(this.handle);this.device.reportError(new Error(`${s} during ${i}: ${r}`),this)(),this.device.debug()}}_getLinkStatus(){const{gl:i}=this.device;return i.getProgramParameter(this.handle,35714)?(this._initializeSamplerUniforms(),i.validateProgram(this.handle),i.getProgramParameter(this.handle,35715)?(this.linkStatus="success","success"):(this.linkStatus="error","validation-error")):(this.linkStatus="error","link-error")}_initializeSamplerUniforms(){const{gl:i}=this.device;i.useProgram(this.handle);let n=0;const s=i.getProgramParameter(this.handle,35718);for(let r=0;r<s;r++){const o=i.getActiveUniform(this.handle,r);if(o&&Od(o.type)){const a=o.name.endsWith("[0]"),c=a?o.name.slice(0,-3):o.name,l=i.getUniformLocation(this.handle,c);l!==null&&(n=this._assignSamplerUniform(l,o,a,n))}}}_assignSamplerUniform(i,n,s,r){const{gl:o}=this.device;if(s&&n.size>1){const a=Int32Array.from({length:n.size},(c,l)=>r+l);return o.uniform1iv(i,a),r+n.size}return o.uniform1i(i,r),r+1}async _waitForLinkComplete(){const i=async r=>await new Promise(o=>setTimeout(o,r));if(!this.device.features.has("compilation-status-async-webgl")){await i(10);return}const{gl:s}=this.device;for(;;){if(s.getProgramParameter(this.handle,37297))return;await i(10)}}}class Ix extends bo{constructor(i,n={}){super(i,n);g(this,"device");g(this,"handle",null);g(this,"commands",[]);this.device=i}_executeCommands(i=this.commands){for(const n of i)switch(n.name){case"copy-buffer-to-buffer":Nx(this.device,n.options);break;case"copy-buffer-to-texture":Lx(this.device,n.options);break;case"copy-texture-to-buffer":Dx(this.device,n.options);break;case"copy-texture-to-texture":Bx(this.device,n.options);break;default:throw new Error(n.name)}}}function Nx(t,e){const i=e.sourceBuffer,n=e.destinationBuffer;t.gl.bindBuffer(36662,i.handle),t.gl.bindBuffer(36663,n.handle),t.gl.copyBufferSubData(36662,36663,e.sourceOffset??0,e.destinationOffset??0,e.size),t.gl.bindBuffer(36662,null),t.gl.bindBuffer(36663,null)}function Lx(t,e){throw new Error("copyBufferToTexture is not supported in WebGL")}function Dx(t,e){const{sourceTexture:i,mipLevel:n=0,aspect:s="all",width:r=e.sourceTexture.width,height:o=e.sourceTexture.height,depthOrArrayLayers:a,origin:c=[0,0,0],destinationBuffer:l,byteOffset:f=0,bytesPerRow:h,rowsPerImage:u}=e;if(i instanceof Q){i.readBuffer({x:c[0]??0,y:c[1]??0,z:c[2]??0,width:r,height:o,depthOrArrayLayers:a,mipLevel:n,aspect:s,byteOffset:f},l);return}if(s!=="all")throw new Error("aspect not supported in WebGL");if(n!==0||a!==void 0||h||u)throw new Error("not implemented");const{framebuffer:d,destroyFramebuffer:p}=Nd(i);let _;try{const m=l,b=r||d.width,A=o||d.height,v=va(d.colorAttachments[0]),S=Pd(v.texture.props.format),E=S.format,x=S.type;t.gl.bindBuffer(35051,m.handle),_=t.gl.bindFramebuffer(36160,d.handle),t.gl.readPixels(c[0],c[1],b,A,E,x,f)}finally{t.gl.bindBuffer(35051,null),_!==void 0&&t.gl.bindFramebuffer(36160,_),p&&d.destroy()}}function Bx(t,e){const{sourceTexture:i,destinationMipLevel:n=0,origin:s=[0,0],destinationOrigin:r=[0,0,0],destinationTexture:o}=e;let{width:a=e.destinationTexture.width,height:c=e.destinationTexture.height}=e;const{framebuffer:l,destroyFramebuffer:f}=Nd(i),[h=0,u=0]=s,[d,p,_]=r,m=t.gl.bindFramebuffer(36160,l.handle);let b,A;if(o instanceof zi)b=o,a=Number.isFinite(a)?a:b.width,c=Number.isFinite(c)?c:b.height,b._bind(0),A=b.glTarget;else throw new Error("invalid destination");switch(A){case 3553:case 34067:t.gl.copyTexSubImage2D(A,n,d,p,h,u,a,c);break;case 35866:case 32879:t.gl.copyTexSubImage3D(A,n,d,p,_,h,u,a,c);break}b&&b._unbind(),t.gl.bindFramebuffer(36160,m),f&&l.destroy()}function Nd(t){if(t instanceof Q){const{width:e,height:i,id:n}=t;
1933return{framebuffer:t.device.createFramebuffer({id:`framebuffer-for-${n}`,width:e,height:i,colorAttachments:[t]}),destroyFramebuffer:!0}}return{framebuffer:t,destroyFramebuffer:!1}}const Fx=[1,2,4,8];class kx extends mo{constructor(i,n){var a;super(i,n);g(this,"device");g(this,"handle",null);g(this,"glParameters",{});this.device=i;const s=this.props.framebuffer,r=!s||s.handle===null;r&&i.getDefaultCanvasContext()._resizeDrawingBufferIfNeeded();let o;if(!((a=n==null?void 0:n.parameters)!=null&&a.viewport))if(r){const[c,l]=i.getDefaultCanvasContext().getDrawingBufferSize();o=[0,0,c,l]}else{const{width:c,height:l}=s;o=[0,0,c,l]}if(this.device.pushState(),this.setParameters({viewport:o,...this.props.parameters}),r)this.device.gl.drawBuffers([1029]);else{const c=s.colorAttachments.map((l,f)=>36064+f);this.device.gl.drawBuffers(c)}this.clear(),this.props.timestampQuerySet&&this.props.beginTimestampIndex!==void 0&&this.props.timestampQuerySet.writeTimestamp(this.props.beginTimestampIndex)}end(){this.destroyed||(this.props.timestampQuerySet&&this.props.endTimestampIndex!==void 0&&this.props.timestampQuerySet.writeTimestamp(this.props.endTimestampIndex),this.device.popState(),this.destroy())}pushDebugGroup(i){}popDebugGroup(){}insertDebugMarker(i){}setParameters(i={}){const n={...this.glParameters};n.framebuffer=this.props.framebuffer||null,this.props.depthReadOnly&&(n.depthMask=!this.props.depthReadOnly),n.stencilMask=this.props.stencilReadOnly?0:1,n[35977]=this.props.discard,i.viewport&&(i.viewport.length>=6?(n.viewport=i.viewport.slice(0,4),n.depthRange=[i.viewport[4],i.viewport[5]]):n.viewport=i.viewport),i.scissorRect&&(n.scissorTest=!0,n.scissor=i.scissorRect),i.blendConstant&&(n.blendColor=i.blendConstant),i.stencilReference!==void 0&&(n[2967]=i.stencilReference,n[36003]=i.stencilReference),"colorMask"in i&&(n.colorMask=Fx.map(s=>!!(s&i.colorMask))),this.glParameters=n,mi(this.device.gl,n)}beginOcclusionQuery(i){const n=this.props.occlusionQuerySet;n==null||n.beginOcclusionQuery()}endOcclusionQuery(){const i=this.props.occlusionQuerySet;i==null||i.endOcclusionQuery()}clear(){const i={...this.glParameters};let n=0;this.props.clearColors&&this.props.clearColors.forEach((s,r)=>{s&&this.clearColorBuffer(r,s)}),this.props.clearColor!==!1&&this.props.clearColors===void 0&&(n|=16384,i.clearColor=this.props.clearColor),this.props.clearDepth!==!1&&(n|=256,i.clearDepth=this.props.clearDepth),this.props.clearStencil!==!1&&(n|=1024,i.clearStencil=this.props.clearStencil),n!==0&&vt(this.device.gl,i,()=>{this.device.gl.clear(n)})}clearColorBuffer(i=0,n=[0,0,0,0]){vt(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(n.constructor){case Int8Array:case Int16Array:case Int32Array:this.device.gl.clearBufferiv(6144,i,n);break;case Uint8Array:case Uint8ClampedArray:case Uint16Array:case Uint32Array:this.device.gl.clearBufferuiv(6144,i,n);break;case Float32Array:this.device.gl.clearBufferfv(6144,i,n);break;default:throw new Error("clearColorBuffer: color must be typed array")}})}}class ff extends yo{constructor(i,n){super(i,n);g(this,"device");g(this,"handle",null);g(this,"commandBuffer");this.device=i,this.commandBuffer=new Ix(i,{id:`${this.props.id}-command-buffer`})}destroy(){this.destroyResource()}finish(i){return i!=null&&i.id&&this.commandBuffer.id!==i.id&&(this.commandBuffer.id=i.id,this.commandBuffer.props.id=i.id),this.destroy(),this.commandBuffer}beginRenderPass(i={}){return new kx(this.device,this._applyTimeProfilingToPassProps(i))}beginComputePass(i={}){throw new Error("ComputePass not supported in WebGL")}copyBufferToBuffer(i){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:i})}copyBufferToTexture(i){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:i})}copyTextureToBuffer(i){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:i})}copyTextureToTexture(i){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:i})}pushDebugGroup(i){}popDebugGroup(){}insertDebugMarker(i){}resolveQuerySet(i,n,s){throw new Error("resolveQuerySet is not supported in WebGL")}writeTimestamp(i,n){i.writeTimestamp(n)}}function Ux(t){const{target:e,source:i,start:n=0,count:s=1}=t,r=i.length,o=s*r;let a=0;for(let c=n;a<r;a++)e[c++]=i[a]??0;for(;a<o;)a<o-a?(e.copyWithin(n+a,n,n+a),a*=2):(e.copyWithin(n+a,n,n+o-a),a=o);return t.target}class Da extends vo{constructor(i,n){super(i,n);g(this,"device");g(this,"handle");g(this,"buffer",null);g(this,"bufferValue",null);this.device=i,this.handle=this.device.gl.createVertexArray()}get[Symbol.toStringTag](){return"VertexArray"}static isConstantAttributeZeroSupported(i){return kg()==="Chrome"}destroy(){var i;super.destroy(),this.buffer&&((i=this.buffer)==null||i.destroy()),this.handle&&(this.device.gl.deleteVertexArray(this.handle),this.handle=void 0)}setIndexBuffer(i){const n=i;if(n&&n.glTarget!==34963)throw new Error("Use .setBuffer()");this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34963,n?n.handle:null),this.indexBuffer=n,this.device.gl.bindVertexArray(null)}setBuffer(i,n){const s=n;
1933if(s.glTarget===34963)throw new Error("Use .setIndexBuffer()");const{size:r,type:o,stride:a,offset:c,normalized:l,integer:f,divisor:h}=this._getAccessor(i);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,s.handle),f?this.device.gl.vertexAttribIPointer(i,r,o,a,c):this.device.gl.vertexAttribPointer(i,r,o,l,a,c),this.device.gl.bindBuffer(34962,null),this.device.gl.enableVertexAttribArray(i),this.device.gl.vertexAttribDivisor(i,h||0),this.attributes[i]=s,this.device.gl.bindVertexArray(null)}setConstantWebGL(i,n){this._enable(i,!1),this.attributes[i]=n}bindBeforeRender(){this.device.gl.bindVertexArray(this.handle),this._applyConstantAttributes()}unbindAfterRender(){this.device.gl.bindVertexArray(null)}_applyConstantAttributes(){for(let i=0;i<this.maxVertexAttributes;++i){const n=this.attributes[i];ArrayBuffer.isView(n)&&this.device.setConstantAttributeWebGL(i,n)}}_getAccessor(i){const n=this.attributeInfos[i];if(!n)throw new Error(`Unknown attribute location ${i}`);const s=wd(n.bufferDataType);return{size:n.bufferComponents,type:s,stride:n.byteStride,offset:n.byteOffset,normalized:n.normalized,integer:n.integer,divisor:n.stepMode==="instance"?1:0}}_enable(i,n=!0){const r=Da.isConstantAttributeZeroSupported(this.device)||i!==0;(n||r)&&(i=Number(i),this.device.gl.bindVertexArray(this.handle),n?this.device.gl.enableVertexAttribArray(i):this.device.gl.disableVertexAttribArray(i),this.device.gl.bindVertexArray(null))}getConstantBuffer(i,n){const s=zx(n),r=s.byteLength*i,o=s.length*i;if(this.buffer&&r!==this.buffer.byteLength)throw new Error(`Buffer size is immutable, byte length ${r} !== ${this.buffer.byteLength}.`);let a=!this.buffer;if(this.buffer=this.buffer||this.device.createBuffer({byteLength:r}),a||(a=!Wx(s,this.bufferValue)),a){const c=Uv(n.constructor,o);Ux({target:c,source:s,start:0,count:o}),this.buffer.write(c),this.bufferValue=n}return this.buffer}}function zx(t){return Array.isArray(t)?new Float32Array(t):t}function Wx(t,e){if(!t||!e||t.length!==e.length||t.constructor!==e.constructor)return!1;for(let i=0;i<t.length;++i)if(t[i]!==e[i])return!1;return!0}class Vx extends To{constructor(i,n){super(i,n);g(this,"device");g(this,"gl");g(this,"handle");g(this,"layout");g(this,"buffers",{});g(this,"unusedBuffers",{});g(this,"bindOnUse",!0);g(this,"_bound",!1);this.device=i,this.gl=i.gl,this.handle=this.props.handle||this.gl.createTransformFeedback(),this.layout=this.props.layout,n.buffers&&this.setBuffers(n.buffers),Object.seal(this)}destroy(){this.gl.deleteTransformFeedback(this.handle),super.destroy()}begin(i="point-list"){this.gl.bindTransformFeedback(36386,this.handle),this.bindOnUse&&this._bindBuffers(),this.gl.beginTransformFeedback(yx(i))}end(){this.gl.endTransformFeedback(),this.bindOnUse&&this._unbindBuffers(),this.gl.bindTransformFeedback(36386,null)}setBuffers(i){this.buffers={},this.unusedBuffers={},this.bind(()=>{for(const[n,s]of Object.entries(i))this.setBuffer(n,s)})}setBuffer(i,n){const s=this._getVaryingIndex(i),{buffer:r,byteLength:o,byteOffset:a}=this._getBufferRange(n);if(s<0){this.unusedBuffers[i]=r,R.warn(`${this.id} unusedBuffers varying buffer ${i}`)();return}this.buffers[s]={buffer:r,byteLength:o,byteOffset:a},this.bindOnUse||this._bindBuffer(s,r,a,o)}getBuffer(i){if(hf(i))return this.buffers[i]||null;const n=this._getVaryingIndex(i);return this.buffers[n]??null}bind(i=this.handle){if(typeof i!="function")return this.gl.bindTransformFeedback(36386,i),this;let n;return this._bound?n=i():(this.gl.bindTransformFeedback(36386,this.handle),this._bound=!0,n=i(),this._bound=!1,this.gl.bindTransformFeedback(36386,null)),n}unbind(){this.bind(null)}_getBufferRange(i){if(i instanceof Ui)return{buffer:i,byteOffset:0,byteLength:i.byteLength};const{buffer:n,byteOffset:s=0,byteLength:r=i.buffer.byteLength}=i;return{buffer:n,byteOffset:s,byteLength:r}}_getVaryingIndex(i){if(hf(i))return Number(i);for(const n of this.layout.varyings||[])if(i===n.name)return n.location;return-1}_bindBuffers(){for(const[i,n]of Object.entries(this.buffers)){const{buffer:s,byteLength:r,byteOffset:o}=this._getBufferRange(n);this._bindBuffer(Number(i),s,o,r)}}_unbindBuffers(){for(const i in this.buffers)this.gl.bindBufferBase(35982,Number(i),null)}_bindBuffer(i,n,s=0,r){const o=n&&n.handle;!o||r===void 0?this.gl.bindBufferBase(35982,i,o):this.gl.bindBufferRange(35982,i,o,s,r)}}function hf(t){return typeof t=="number"?Number.isInteger(t):/^\d+$/.test(t)}class $x extends Ao{constructor(i,n){super(i,n);g(this,"device");g(this,"handle");g(this,"_timestampPairs",[]);g(this,"_pendingReads",new Set);g(this,"_occlusionQuery",null);g(this,"_occlusionActive",!1);if(this.device=i,n.type==="timestamp"){if(n.count<2)throw new Error("Timestamp QuerySet requires at least two query slots");this._timestampPairs=new Array(Math.ceil(n.count/2)).fill(null).map(()=>({activeQuery:null,completedQueries:[]})),this.handle=null}else{if(n.count>1)throw new Error("WebGL occlusion QuerySet can only have one value");const s=this.device.gl.createQuery();if(!s)throw new Error("WebGL query not supported");this.handle=s}Object.seal(this)}get[Symbol.toStringTag](){return"QuerySet"}destroy(){if(!this.destroyed){this.handle&&this.device.gl.deleteQuery(this.handle);for(const i of this._timestampPairs){i.activeQuery&&(this._cancelPendingQuery(i.activeQuery),this.device.gl.deleteQuery(i.activeQuery.handle));for(const n of i.completedQueries)this._cancelPendingQuery(n),this.device.gl.deleteQuery(n.handle)}this._occlusionQuery&&(this._cancelPendingQuery(this._occlusionQuery),this.device.gl.deleteQuery(this._occlusionQuery.handle));
vendor: 4,038 bytes, line 1933
1933for(const i of Array.from(this._pendingReads))this._cancelPendingQuery(i);this.destroyResource()}}isResultAvailable(i){return this.props.type==="timestamp"?i===void 0?this._timestampPairs.some((n,s)=>this._isTimestampPairAvailable(s)):this._isTimestampPairAvailable(this._getTimestampPairIndex(i)):this._occlusionQuery?this._pollQueryAvailability(this._occlusionQuery):!1}async readResults(i){const n=(i==null?void 0:i.firstQuery)||0,s=(i==null?void 0:i.queryCount)||this.props.count-n;if(this._validateRange(n,s),this.props.type==="timestamp"){const r=new Array(s).fill(0n),o=Math.floor(n/2),a=Math.floor((n+s-1)/2);for(let c=o;c<=a;c++){const l=await this._consumeTimestampPairResult(c),f=c*2,h=f+1;f>=n&&f<n+s&&(r[f-n]=0n),h>=n&&h<n+s&&(r[h-n]=l)}return r}if(!this._occlusionQuery)throw new Error("Occlusion query has not been started");return[await this._consumeQueryResult(this._occlusionQuery)]}async readTimestampDuration(i,n){if(this.props.type!=="timestamp")throw new Error("Timestamp durations require a timestamp QuerySet");if(i<0||n>=this.props.count||n<=i)throw new Error("Timestamp duration range is out of bounds");if(i%2!==0||n!==i+1)throw new Error("WebGL timestamp durations require adjacent even/odd query indices");const s=await this._consumeTimestampPairResult(this._getTimestampPairIndex(i));return Number(s)/1e6}beginOcclusionQuery(){if(this.props.type!=="occlusion")throw new Error("Occlusion queries require an occlusion QuerySet");if(!this.handle)throw new Error("WebGL occlusion query is not available");if(this._occlusionActive)throw new Error("Occlusion query is already active");this.device.gl.beginQuery(35887,this.handle),this._occlusionQuery={handle:this.handle,promise:null,result:null,disjoint:!1,cancelled:!1,pollRequestId:null,resolve:null,reject:null},this._occlusionActive=!0}endOcclusionQuery(){if(!this._occlusionActive)throw new Error("Occlusion query is not active");this.device.gl.endQuery(35887),this._occlusionActive=!1}writeTimestamp(i){if(this.props.type!=="timestamp")throw new Error("Timestamp writes require a timestamp QuerySet");const n=this._getTimestampPairIndex(i),s=this._timestampPairs[n];if(i%2===0){if(s.activeQuery)throw new Error("Timestamp query pair is already active");const r=this.device.gl.createQuery();if(!r)throw new Error("WebGL query not supported");const o={handle:r,promise:null,result:null,disjoint:!1,cancelled:!1,pollRequestId:null,resolve:null,reject:null};this.device.gl.beginQuery(35007,r),s.activeQuery=o;return}if(!s.activeQuery)throw new Error("Timestamp query pair was ended before it was started");this.device.gl.endQuery(35007),s.completedQueries.push(s.activeQuery),s.activeQuery=null}_validateRange(i,n){if(i<0||n<0||i+n>this.props.count)throw new Error("Query read range is out of bounds")}_getTimestampPairIndex(i){if(i<0||i>=this.props.count)throw new Error("Query index is out of bounds");return Math.floor(i/2)}_isTimestampPairAvailable(i){const n=this._timestampPairs[i];return!n||n.completedQueries.length===0?!1:this._pollQueryAvailability(n.completedQueries[0])}_pollQueryAvailability(i){if(i.cancelled||this.destroyed)return i.result=0n,!0;if(i.result!==null||i.disjoint)return!0;if(!this.device.gl.getQueryParameter(i.handle,34919))return!1;const s=!!this.device.gl.getParameter(36795);return i.disjoint=s,i.result=s?0n:BigInt(this.device.gl.getQueryParameter(i.handle,34918)),!0}async _consumeTimestampPairResult(i){const n=this._timestampPairs[i];if(!n||n.completedQueries.length===0)throw new Error("Timestamp query pair has no completed result");const s=n.completedQueries.shift();try{return await this._consumeQueryResult(s)}finally{this.device.gl.deleteQuery(s.handle)}}_consumeQueryResult(i){return i.promise||(this._pendingReads.add(i),i.promise=new Promise((n,s)=>{i.resolve=n,i.reject=s;const r=()=>{if(i.pollRequestId=null,i.cancelled||this.destroyed){this._pendingReads.delete(i),i.promise=null,i.resolve=null,i.reject=null,n(0n);return}if(!this._pollQueryAvailability(i)){i.pollRequestId=this._requestAnimationFrame(r);return}
1933this._pendingReads.delete(i),i.promise=null,i.resolve=null,i.reject=null,i.disjoint?s(new Error("GPU timestamp query was invalidated by a disjoint event")):n(i.result||0n)};r()})),i.promise}_cancelPendingQuery(i){if(this._pendingReads.delete(i),i.cancelled=!0,i.pollRequestId!==null&&(this._cancelAnimationFrame(i.pollRequestId),i.pollRequestId=null),i.resolve){const n=i.resolve;i.promise=null,i.resolve=null,i.reject=null,n(0n)}}_requestAnimationFrame(i){return requestAnimationFrame(i)}_cancelAnimationFrame(i){cancelAnimationFrame(i)}}class jx extends wo{constructor(i,n={}){super(i,{});g(this,"device");g(this,"gl");g(this,"handle");g(this,"signaled");g(this,"_signaled",!1);this.device=i,this.gl=i.gl;const s=this.props.handle||this.gl.fenceSync(this.gl.SYNC_GPU_COMMANDS_COMPLETE,0);if(!s)throw new Error("Failed to create WebGL fence");this.handle=s,this.signaled=new Promise(r=>{const o=()=>{const a=this.gl.clientWaitSync(this.handle,0,0);a===this.gl.ALREADY_SIGNALED||a===this.gl.CONDITION_SATISFIED?(this._signaled=!0,r()):setTimeout(o,1)};o()})}isSignaled(){if(this._signaled)return!0;const i=this.gl.getSyncParameter(this.handle,this.gl.SYNC_STATUS);return this._signaled=i===this.gl.SIGNALED,this._signaled}destroy(){this.destroyed||this.gl.deleteSync(this.handle)}}function Ld(t){switch(t){case 6406:case 33326:case 6403:case 36244:return 1;case 33339:case 33340:case 33328:case 33320:case 33319:return 2;case 6407:case 36248:case 34837:return 3;case 6408:case 36249:case 34836:return 4;default:return 0}}function Hx(t){switch(t){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return 0}}function Xx(t,e){var A;const{sourceX:i=0,sourceY:n=0,sourceAttachment:s=0}=e||{};let{target:r=null,sourceWidth:o,sourceHeight:a,sourceDepth:c,sourceFormat:l,sourceType:f}=e||{};const{framebuffer:h,deleteFramebuffer:u}=Dd(t),{gl:d,handle:p}=h;o||(o=h.width),a||(a=h.height);const _=(A=h.colorAttachments[s])==null?void 0:A.texture;if(!_)throw new Error(`Invalid framebuffer attachment ${s}`);c=(_==null?void 0:_.depth)||1,l||(l=(_==null?void 0:_.glFormat)||6408),f||(f=(_==null?void 0:_.glType)||5121),r=qx(r,f,l,o,a);const m=qe.getDataType(r);f=f||Tx(m);const b=d.bindFramebuffer(36160,p);return d.readBuffer(36064+s),d.readPixels(i,n,o,a,l,f,r),d.readBuffer(36064),d.bindFramebuffer(36160,b||null),u&&h.destroy(),r}function Yx(t,e){const{target:i,sourceX:n=0,sourceY:s=0,sourceFormat:r=6408,targetByteOffset:o=0}=e||{};let{sourceWidth:a,sourceHeight:c,sourceType:l}=e||{};const{framebuffer:f,deleteFramebuffer:h}=Dd(t);a=a||f.width,c=c||f.height;const u=f;l=l||5121;let d=i;if(!d){const _=Ld(r),m=Hx(l),b=o+a*c*_*m;d=u.device.createBuffer({byteLength:b})}const p=t.device.createCommandEncoder();return p.copyTextureToBuffer({sourceTexture:t,width:a,height:c,origin:[n,s],destinationBuffer:d,byteOffset:o}),p.destroy(),h&&f.destroy(),d}function Dd(t){return t instanceof ls?{framebuffer:t,deleteFramebuffer:!1}:{framebuffer:Kx(t),deleteFramebuffer:!0}}function Kx(t,e){const{device:i,width:n,height:s,id:r}=t;return i.createFramebuffer({...e,id:`framebuffer-for-${r}`,width:n,height:s,colorAttachments:[t]})}
1933function qx(t,e,i,n,s,r){if(t)return t;e||(e=5121);const o=Cd(e),a=qe.getTypedArrayConstructor(o),c=Ld(i);return new a(n*s*c)}class Pt extends Mt{constructor(i){var h;super({...i,id:i.id||JE("webgl-device")});g(this,"type","webgl");g(this,"handle");g(this,"features");g(this,"limits");g(this,"info");g(this,"canvasContext");g(this,"preferredColorFormat","rgba8unorm");g(this,"preferredDepthFormat","depth24plus");g(this,"commandEncoder");g(this,"lost");g(this,"_resolveContextLost");g(this,"gl");g(this,"_constants");g(this,"extensions");g(this,"_polyfilled",!1);g(this,"spectorJS");const n=Mt._getCanvasContextProps(i);if(!n)throw new Error("WebGLDevice requires props.createCanvasContext to be set");const s=((h=n.canvas)==null?void 0:h.gl)??null;let r=Pt.getDeviceFromContext(s);if(r)throw new Error(`WebGL context already attached to device ${r.id}`);this.canvasContext=new GE(this,n),this.lost=new Promise(u=>{this._resolveContextLost=u});const o={...i.webgl};n.alphaMode==="premultiplied"&&(o.premultipliedAlpha=!0),i.powerPreference!==void 0&&(o.powerPreference=i.powerPreference),i.failIfMajorPerformanceCaveat!==void 0&&(o.failIfMajorPerformanceCaveat=i.failIfMajorPerformanceCaveat);const c=this.props._handle||CE(this.canvasContext.canvas,{onContextLost:u=>{var d;return(d=this._resolveContextLost)==null?void 0:d.call(this,{reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."})},onContextRestored:u=>console.log("WebGL context restored")},o);if(!c)throw new Error("WebGL context creation failed");if(r=Pt.getDeviceFromContext(c),r){if(i._reuseDevices)return R.log(1,`Not creating a new Device, instead returning a reference to Device ${r.id} already attached to WebGL context`,r)(),this.canvasContext.destroy(),r._reused=!0,r;throw new Error(`WebGL context already attached to device ${r.id}`)}this.handle=c,this.gl=c,this.spectorJS=hE({...this.props,gl:this.handle});const l=_s(this.handle);l.device=this,l.extensions||(l.extensions={}),this.extensions=l.extensions,this.info=ME(this.gl,this.extensions),this.limits=new KE(this.gl),this.features=new YE(this.gl,this.extensions,this.props._disabledFeatures),this.props._initializeFeatures&&this.features.initializeFeatures(),new Et(this.gl,{log:(...u)=>R.log(1,...u)()}).trackState(this.gl,{copyState:!1}),(i.debug||i.debugWebGL)&&(this.gl=gE(this.gl,{debugWebGL:!0,traceWebGL:i.debugWebGL}),R.warn("WebGL debug mode activated. Performance reduced.")()),i.debugWebGL&&(R.level=Math.max(R.level,1)),this.commandEncoder=new ff(this,{id:`${this}-command-encoder`}),this.canvasContext._startObservers()}static getDeviceFromContext(i){var n;return i?((n=i.luma)==null?void 0:n.device)??null:null}get[Symbol.toStringTag](){return"WebGLDevice"}toString(){return`${this[Symbol.toStringTag]}(${this.id})`}isVertexFormatSupported(i){switch(i){case"unorm8x4-bgra":return!1;default:return!0}}destroy(){var i;if((i=this.commandEncoder)==null||i.destroy(),!this.props._reuseDevices&&!this._reused){const n=_s(this.handle);n.device=null}}get isLost(){return this.gl.isContextLost()}createCanvasContext(i){throw new Error("WebGL only supports a single canvas")}createPresentationContext(i){return new QE(this,i||{})}createBuffer(i){const n=this._normalizeBufferProps(i);return new Ui(this,n)}createTexture(i){return new zi(this,i)}createExternalTexture(i){throw new Error("createExternalTexture() not implemented")}createSampler(i){return new fx(this,i)}createShader(i){return new nx(this,i)}createFramebuffer(i){return new ki(this,i)}createVertexArray(i){return new Da(this,i)}createTransformFeedback(i){return new Vx(this,i)}createQuerySet(i){return new $x(this,i)}createFence(){return new jx(this)}createRenderPipeline(i){return new bx(this,i)}_createSharedRenderPipelineWebGL(i){return new Ox(this,i)}createComputePipeline(i){throw new Error("ComputePipeline not supported in WebGL")}createCommandEncoder(i={}){return new ff(this,i)}submit(i){let n=null;i||({submittedCommandEncoder:n,commandBuffer:i}=this._finalizeDefaultCommandEncoderForSubmit());try{i._executeCommands(),n&&n.resolveTimeProfilingQuerySet().then(()=>{this.commandEncoder._gpuTimeMs=n._gpuTimeMs}).catch(()=>{})}finally{i.destroy()}}_finalizeDefaultCommandEncoderForSubmit(){const i=this.commandEncoder,n=i.finish();return this.commandEncoder.destroy(),this.commandEncoder=this.createCommandEncoder({id:i.props.id,timeProfilingQuerySet:i.getTimeProfilingQuerySet()}),{submittedCommandEncoder:i,commandBuffer:n}}readPixelsToArrayWebGL(i,n){return Xx(i,n)}readPixelsToBufferWebGL(i,n){return Yx(i,n)}setParametersWebGL(i){mi(this.gl,i)}getParametersWebGL(i){return Td(this.gl,i)}withParametersWebGL(i,n){return vt(this.gl,i,n)}resetWebGL(){R.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),SE(this.gl)}_getDeviceSpecificTextureFormatCapabilities(i){return VE(this.gl,i,this.extensions)}loseDevice(){var r;let i=!1;const s=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return s&&(i=!0,s.loseContext()),(r=this._resolveContextLost)==null||r.call(this,{reason:"destroyed",message:"Application triggered context loss"}),i}pushState(){Et.get(this.gl).push()}popState(){Et.get(this.gl).pop()}getGLKey(i,n){const s=Number(i);for(const r in this.gl)if(this.gl[r]===s)return`GL.${r}`;return n!=null&&n.emptyIfUnknown?"":String(i)}getGLKeys(i){const n={emptyIfUnknown:!0};return Object.entries(i).reduce((s,[r,o])=>(s[`${r}:${this.getGLKey(r,n)}`]=`${o}:${this.getGLKey(o,n)}`,s),{})}setConstantAttributeWebGL(i,n){const s=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(s).fill(null);const r=this._constants[i];switch(r&&Jx(r,n)&&R.info(1,`setConstantAttributeWebGL(${i}) could have been skipped, value unchanged`)(),this._constants[i]=n,n.constructor){case Float32Array:Zx(this,i,n);break;case Int32Array:Gx(this,i,n);break;case Uint32Array:Qx(this,i,n);break;default:throw new Error("constant")}}getExtension(i){return Nt(this.gl,i,this.extensions),this.extensions}_setWebGLDebugMetadata(i,n,s){i.luma=n;const r={props:s.spector,id:s.spector.id};i.__SPECTOR_Metadata=r}}function Zx(t,e,i){switch(i.length){case 1:t.gl.vertexAttrib1fv(e,i);break;case 2:t.gl.vertexAttrib2fv(e,i);break;case 3:t.gl.vertexAttrib3fv(e,i);break;case 4:t.gl.vertexAttrib4fv(e,i);break}}function Gx(t,e,i){t.gl.vertexAttribI4iv(e,i)}function Qx(t,e,i){t.gl.vertexAttribI4uiv(e,i)}function Jx(t,e){if(!t||!e||t.length!==e.length||t.constructor!==e.constructor)return!1;for(let i=0;i<t.length;++i)if(t[i]!==e[i])return!1;return!0}const uf=Object.freeze(Object.defineProperty({__proto__:null,WebGLDevice:Pt},Symbol.toStringTag,{value:"Module"}));function rt(){}const e3=({isDragging:t})=>t?"grabbing":"grab",Bd={id:"",width:"100%",height:"100%",style:null,viewState:null,initialViewState:null,pickingRadius:0,pickAsync:"auto",layerFilter:null,parameters:{},parent:null,device:null,deviceProps:{},gl:null,canvas:null,layers:[],effects:[],views:null,controller:null,useDevicePixels:!0,touchAction:"none",eventRecognizerOptions:{},_framebuffer:null,_animate:!1,_pickable:!0,_typedArrayManagerProps:{},_customRender:null,widgets:[],onDeviceInitialized:rt,onWebGLInitialized:rt,onResize:rt,onViewStateChange:rt,onInteractionStateChange:rt,onBeforeRender:rt,onAfterRender:rt,onLoad:rt,onError:t=>j.error(t.message,t.cause)(),onHover:null,onClick:null,onDragStart:null,onDrag:null,onDragEnd:null,_onMetrics:null,getCursor:e3,getTooltip:null,debug:!1,drawPickingColors:!1};class Ba{constructor(e){var n;this.width=0,this.height=0,this.userData={},this.device=null,this.canvas=null,this.viewManager=null,this.layerManager=null,this.effectManager=null,this.deckRenderer=null,this.deckPicker=null,this.eventManager=null,this.widgetManager=null,this.tooltip=null,this.animationLoop=null,this.cursorState={isHovering:!1,isDragging:!1},this.stats=new nn({id:"deck.gl"}),this.metrics={fps:0,setPropsTime:0,layersCount:0,drawLayersCount:0,updateLayersCount:0,updateAttributesCount:0,updateAttributesTime:0,framesRedrawn:0,pickTime:0,pickCount:0,pickLayersCount:0,gpuTime:0,gpuTimePerFrame:0,cpuTime:0,cpuTimePerFrame:0,bufferMemory:0,textureMemory:0,renderbufferMemory:0,gpuMemory:0},this._metricsCounter=0,this._hoverPickSequence=0,this._pointerDownPickSequence=0,this._needsRedraw="Initial render",this._pickRequest={mode:"hover",x:-1,y:-1,radius:0,event:null,unproject3D:!1},this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=null,this._onPointerMove=s=>{const{_pickRequest:r}=this;if(s.type==="pointerleave")r.x=-1,r.y=-1,r.radius=0;else{if(s.leftButton||s.rightButton)return;{const o=s.offsetCenter;if(!o)return;r.x=o.x,r.y=o.y,r.radius=this.props.pickingRadius}}this.layerManager&&(this.layerManager.context.mousePosition={x:r.x,y:r.y}),r.event=s},this._onEvent=s=>{const r=Hn[s.type],o=s.offsetCenter;if(!r||!o||!this.layerManager)return;const a=this.layerManager.getLayers(),c=this._getInternalPickingMode();if(!c)return;if(c==="sync"){const f=s.type==="click"&&this._shouldUnproject3D(a)?this._getFirstPickedInfo(this._pickPointSync(this._getPointPickOptions(o.x,o.y,{unproject3D:!0},a))):this._getLastPointerDownPickingInfo(o.x,o.y,a);this._dispatchPickingEvent(f,s);return}(this._lastPointerDownInfoPromise||Promise.resolve(this._getLastPointerDownPickingInfo(o.x,o.y,a))).then(f=>{this._dispatchPickingEvent(f,s)}).catch(f=>{var h,u;return(u=(h=this.props).onError)==null?void 0:u.call(h,f)})},this._onPointerDown=s=>{var f;const r=s.offsetCenter;if(!r)return;const o=this._getInternalPickingMode();if(!o)return;const a=((f=this.layerManager)==null?void 0:f.getLayers())||[],c=++this._pointerDownPickSequence;if(o==="sync"){const h=this._pickPointSync({x:r.x,y:r.y,radius:this.props.pickingRadius}),u=this._getFirstPickedInfo(h);this._lastPointerDownInfo=u,this._lastPointerDownInfoPromise=Promise.resolve(u);return}const l=this._pickPointAsync(this._getPointPickOptions(r.x,r.y,{},a)).then(h=>this._getFirstPickedInfo(h)).then(h=>(c===this._pointerDownPickSequence&&(this._lastPointerDownInfo=h),h)).catch(h=>{var d,p;(p=(d=this.props).onError)==null||p.call(d,h);const u=this.deckPicker&&this.viewManager?this._getLastPointerDownPickingInfo(r.x,r.y,a):{};return c===this._pointerDownPickSequence&&(this._lastPointerDownInfo=u),u});this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=l},this.props={...Bd,...e},e=this.props,e.viewState&&e.initialViewState&&j.warn("View state tracking is disabled. Use either `initialViewState` for auto update or `viewState` for manual update.")(),this.viewState=this.props.initialViewState,e.device&&(this.device=e.device);let i=this.device;if(!i&&e.gl){e.gl instanceof WebGLRenderingContext&&j.error("WebGL1 context not supported.")();const s=(n=this.props.deviceProps)==null?void 0:n.onResize;i=Nr.attach(e.gl,{_cacheShaders:!0,_cachePipelines:!0,...this.props.deviceProps,onResize:(r,o)=>{const{width:a,height:c}=r.canvas;r.setDrawingBufferSize(a,c),this._needsRedraw="Canvas resized",s==null||s(r,o)}})}i||(i=this._createDevice(e)),this.animationLoop=this._createAnimationLoop(i,e),this.setProps(e),e._typedArrayManagerProps&&ci.setOptions(e._typedArrayManagerProps),this.animationLoop.start()}finalize(){var e,i,n,s,r,o,a,c,l,f;(e=this.animationLoop)==null||e.stop(),(i=this.animationLoop)==null||i.destroy(),this.animationLoop=null,this._hoverPickSequence++,this._pointerDownPickSequence++,this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=null,(n=this.layerManager)==null||n.finalize(),this.layerManager=null,(s=this.viewManager)==null||s.finalize(),this.viewManager=null,(r=this.effectManager)==null||r.finalize(),this.effectManager=null,(o=this.deckRenderer)==null||o.finalize(),this.deckRenderer=null,(a=this.deckPicker)==null||a.finalize(),this.deckPicker=null,(c=this.eventManager)==null||c.destroy(),this.eventManager=null,(l=this.widgetManager)==null||l.finalize(),this.widgetManager=null,!this.props.canvas&&!this.props.device&&!this.props.gl&&this.canvas&&((f=this.canvas.parentElement)==null||f.removeChild(this.canvas),this.canvas=null)}setProps(e){var n,s,r,o,a,c,l,f;this.stats.get("setProps Time").timeStart(),"onLayerHover"in e&&j.removed("onLayerHover","onHover")(),"onLayerClick"in e&&j.removed("onLayerClick","onClick")(),e.initialViewState&&!be(this.props.initialViewState,e.initialViewState,3)&&(this.viewState=e.initialViewState),Object.assign(this.props,e),this._val
1933idateInternalPickingMode(),this._setCanvasSize(this.props);const i=Object.create(this.props);Object.assign(i,{views:this._getViews(),width:this.width,height:this.height,viewState:this._getViewState()}),e.device&&e.device.id!==((n=this.device)==null?void 0:n.id)&&((s=this.animationLoop)==null||s.stop(),this.canvas!==((r=e.device.canvasContext)==null?void 0:r.canvas)&&((o=this.canvas)==null||o.remove(),(a=this.eventManager)==null||a.destroy(),this.canvas=null),j.log(`recreating animation loop for new device! id=${e.device.id}`)(),this.animationLoop=this._createAnimationLoop(e.device,e),this.animationLoop.start()),(c=this.animationLoop)==null||c.setProps(i),e.useDevicePixels!==void 0&&((f=(l=this.device)==null?void 0:l.canvasContext)!=null&&f.setProps)&&this.device.canvasContext.setProps({useDevicePixels:e.useDevicePixels}),this.layerManager&&(this.viewManager.setProps(i),this.layerManager.activateViewport(this.getViewports()[0]),this.layerManager.setProps(i),this.effectManager.setProps(i),this.deckRenderer.setProps(i),this.deckPicker.setProps(i),this.widgetManager.setProps(i)),this.stats.get("setProps Time").timeEnd()}needsRedraw(e={clearRedrawFlags:!1}){if(!this.layerManager)return!1;if(this.props._animate)return"Deck._animate";let i=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);const n=this.viewManager.needsRedraw(e),s=this.layerManager.needsRedraw(e),r=this.effectManager.needsRedraw(e),o=this.deckRenderer.needsRedraw(e);return i=i||n||s||r||o,i}redraw(e){if(!this.layerManager)return;let i=this.needsRedraw({clearRedrawFlags:!0});i=e||i,i&&(this.stats.get("Redraw Count").incrementCount(),this.props._customRender?this.props._customRender(i):this._drawLayers(i))}get isInitialized(){return this.viewManager!==null}getViews(){return fe(this.viewManager),this.viewManager.views}getView(e){return fe(this.viewManager),this.viewManager.getView(e)}getViewports(e){return fe(this.viewManager),this.viewManager.getViewports(e)}getCanvas(){return this.canvas}async pickObjectAsync(e){const i=(await this._pickAsync("pickObjectAsync","pickObject Time",e)).result;return i.length?i[0]:null}async pickObjectsAsync(e){return await this._pickAsync("pickObjectsAsync","pickObjects Time",e)}pickObject(e){const i=this._pick("pickObject","pickObject Time",e).result;return i.length?i[0]:null}pickMultipleObjects(e){return e.depth=e.depth||10,this._pick("pickObject","pickMultipleObjects Time",e).result}pickObjects(e){return this._pick("pickObjects","pickObjects Time",e)}_pickPositionForController(e,i){return this._getInternalPickingMode()!=="sync"?null:this.pickObject({x:e,y:i,radius:0,unproject3D:!0})}_addResources(e,i=!1){for(const n in e)this.layerManager.resourceManager.add({resourceId:n,data:e[n],forceUpdate:i})}_removeResources(e){for(const i of e)this.layerManager.resourceManager.remove(i)}_addDefaultEffect(e){this.effectManager.addDefaultEffect(e)}_addDefaultShaderModule(e){this.layerManager.addDefaultShaderModule(e)}_removeDefaultShaderModule(e){var i;(i=this.layerManager)==null||i.removeDefaultShaderModule(e)}_resolveInternalPickingMode(){var n,s;const{pickAsync:e}=this.props,i=((n=this.device)==null?void 0:n.type)||((s=this.props.deviceProps)==null?void 0:s.type);if(e==="auto")return i==="webgpu"?"async":"sync";if(e==="sync"&&i==="webgpu")throw new Error('`pickAsync: "sync"` is not supported when Deck is using a WebGPU device.');return e}_getInternalPickingMode(){var e,i;try{return this._resolveInternalPickingMode()}catch(n){return(i=(e=this.props).onError)==null||i.call(e,n),null}}_validateInternalPickingMode(){this._getInternalPickingMode()}_getFirstPickedInfo({result:e,emptyInfo:i}){return e[0]||i}_shouldUnproject3D(e=(i=>(i=this.layerManager)==null?void 0:i.getLayers())()||[]){return e.some(n=>n.props.pickable==="3d")}_getPointPickOptions(e,i,n={},s=(r=>(r=this.layerManager)==null?void 0:r.getLayers())()||[]){return{x:e,y:i,radius:this.props.pickingRadius,unproject3D:this._shouldUnproject3D(s),...n}}_pickPointSync(e){return this._pick("pickObject","pickObject Time",e)}_pickPointAsync(e){return this._pickAsync("pickObjectAsync","pickObject Time",e)}
1933_getLastPointerDownPickingInfo(e,i,n=(s=>(s=this.layerManager)==null?void 0:s.getLayers())()||[]){return this.deckPicker.getLastPickedObject({x:e,y:i,layers:n,viewports:this.getViewports({x:e,y:i})},this._lastPointerDownInfo)}_applyHoverCallbacks({result:e,emptyInfo:i},n){var o,a,c;if(!this.widgetManager)return;this.cursorState.isHovering=e.length>0;let s=i,r=!1;for(const l of e)s=l,r=((o=l.layer)==null?void 0:o.onHover(l,n))||r;r||((c=(a=this.props).onHover)==null||c.call(a,s,n),this.widgetManager.onHover(s,n))}_dispatchPickingEvent(e,i){if(!this.layerManager||!this.widgetManager)return;const n=Hn[i.type];if(!n)return;const{layer:s}=e,r=s&&(s[n]||s.props[n]),o=this.props[n];let a=!1;r&&(a=r.call(s,e,i)),a||(o==null||o(e,i),this.widgetManager.onEvent(e,i))}_pickAsync(e,i,n){fe(this.deckPicker);const{stats:s}=this;s.get("Pick Count").incrementCount(),s.get(i).timeStart();const r=this.deckPicker[e]({layers:this.layerManager.getLayers(n),views:this.viewManager.getViews(),viewports:this.getViewports(n),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...n});return s.get(i).timeEnd(),r}_pick(e,i,n){fe(this.deckPicker);const{stats:s}=this;s.get("Pick Count").incrementCount(),s.get(i).timeStart();const r=this.deckPicker[e]({layers:this.layerManager.getLayers(n),views:this.viewManager.getViews(),viewports:this.getViewports(n),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...n});return s.get(i).timeEnd(),r}_createCanvas(e){let i=e.canvas;return typeof i=="string"&&(i=document.getElementById(i),fe(i)),i||(i=document.createElement("canvas"),i.id=e.id||"deckgl-overlay",e.width&&typeof e.width=="number"&&(i.width=e.width),e.height&&typeof e.height=="number"&&(i.height=e.height),(e.parent||document.body).appendChild(i)),Object.assign(i.style,e.style),i}_setCanvasSize(e){var s;if(!this.canvas)return;const{width:i,height:n}=e;if(i||i===0){const r=Number.isFinite(i)?`${i}px`:i;this.canvas.style.width=r}if(n||n===0){const r=Number.isFinite(n)?`${n}px`:n;this.canvas.style.position=((s=e.style)==null?void 0:s.position)||"absolute",this.canvas.style.height=r}}_updateCanvasSize(){var s,r;const{canvas:e}=this;if(!e)return;const i=e.clientWidth??e.width,n=e.clientHeight??e.height;(i!==this.width||n!==this.height)&&(this.width=i,this.height=n,(s=this.viewManager)==null||s.setProps({width:i,height:n}),(r=this.layerManager)==null||r.activateViewport(this.getViewports()[0]),this.props.onResize({width:i,height:n}))}_createAnimationLoop(e,i){const{gl:n,onError:s}=i;return new Io({device:e,autoResizeDrawingBuffer:!n,autoResizeViewport:!1,onInitialize:r=>this._setDevice(r.device),onRender:this._onRenderFrame.bind(this),onError:s})}_createDevice(e){var a,c,l;const i=(a=this.props.deviceProps)==null?void 0:a.createCanvasContext,n=typeof i=="object"?i:void 0,s={adapters:[],_cacheShaders:!0,_cachePipelines:!0,...e.deviceProps};s.adapters.includes(Nr)||s.adapters.push(Nr);const r={alphaMode:((c=this.props.deviceProps)==null?void 0:c.type)==="webgpu"?"premultiplied":void 0},o=(l=this.props.deviceProps)==null?void 0:l.onResize;return go.createDevice({_reuseDevices:!0,type:"webgl",...s,createCanvasContext:{...r,...n,canvas:this._createCanvas(e),useDevicePixels:this.props.useDevicePixels,autoResize:!0},onResize:(f,h)=>{this._needsRedraw="Canvas resized",o==null||o(f,h)}})}_getViewState(){return this.props.viewState||this.viewState}_getViews(){const{views:e}=this.props,i=Array.isArray(e)?e:e?[e]:[new md({id:"default-view"})];return i.length&&this.props.controller&&(i[0].props.controller=this.props.controller),i}_onContextLost(){const{onError:e}=this.props;this.animationLoop&&e&&e(new Error("WebGL context is lost"))}_pickAndCallback(){var i;const{_pickRequest:e}=this;if(e.event){const n=e.event,s=((i=this.layerManager)==null?void 0:i.getLayers())||[],r=this._getPointPickOptions(e.x,e.y,{radius:e.radius,mode:e.mode},s),o=this._getInternalPickingMode(),a=++this._hoverPickSequence;if(e.event=null,!o)return;if(o==="sync"){this._applyHoverCallbacks(this._pickPointSync(r),n);return}this._pickPointAsync(r).then(({result:c,emptyInfo:l})=>{a===this._hoverPickSequence&&this._applyHoverCallbacks({result:c,emptyInfo:l},n)}).catch(c=>{var l,f;return(f=(l=this.props).onError)==null?void 0:f.call(l,c)})}}
1933_updateCursor(){const e=this.props.parent||this.canvas;e&&(e.style.cursor=this.props.getCursor(this.cursorState))}_setDevice(e){var o,a,c,l;if(this.device=e,this._validateInternalPickingMode(),!this.animationLoop)return;this.canvas||(this.canvas=(o=this.device.canvasContext)==null?void 0:o.canvas,!this.canvas.isConnected&&this.props.parent&&this.props.parent.insertBefore(this.canvas,this.props.parent.firstChild)),this.device.type==="webgl"&&this.device.setParametersWebGL({blend:!0,blendFunc:[770,771,1,771],polygonOffsetFill:!0,depthTest:!0,depthFunc:515}),this.props.onDeviceInitialized(this.device),this.device.type==="webgl"&&this.props.onWebGLInitialized(this.device.gl);const i=new nd;i.play(),this.animationLoop.attachTimeline(i);const n=((a=this.props.parent)==null?void 0:a.querySelector(".deck-events-root"))||this.canvas;this.eventManager=new cA(n,{touchAction:this.props.touchAction,recognizers:Object.keys(yl).map(f=>{var b;const[h,u,d,p]=yl[f],_=(b=this.props.eventRecognizerOptions)==null?void 0:b[f],m={...u,..._,event:f};return{recognizer:new h(m),recognizeWith:d,requestFailure:p}}),events:{pointerdown:this._onPointerDown,pointermove:this._onPointerMove,pointerleave:this._onPointerMove}});for(const f in Hn)this.eventManager.on(f,this._onEvent);this.viewManager=new wS({timeline:i,eventManager:this.eventManager,onViewStateChange:this._onViewStateChange.bind(this),onInteractionStateChange:this._onInteractionStateChange.bind(this),pickPosition:this._pickPositionForController.bind(this),views:this._getViews(),viewState:this._getViewState(),width:this.width,height:this.height});const s=this.viewManager.getViewports()[0];this.layerManager=new AS(this.device,{deck:this,stats:this.stats,viewport:s,timeline:i}),this.effectManager=new HS({deck:this,device:this.device}),this.deckRenderer=new KS(this.device,{stats:this.stats}),this.deckPicker=new GS(this.device,{stats:this.stats});const r=((c=this.props.parent)==null?void 0:c.querySelector(".deck-widgets-root"))||((l=this.canvas)==null?void 0:l.parentElement);this.widgetManager=new eE({deck:this,parentElement:r}
vendor: 59,812 bytes, lines 1933-2013
1933),this.widgetManager.addDefault(new yd),this.setProps(this.props),this._updateCanvasSize(),this.props.onLoad()}_drawLayers(e,i){var o;const{device:n,gl:s}=this.layerManager.context;this.props.onBeforeRender({device:n,gl:s});const r={target:this.props._framebuffer,layers:this.layerManager.getLayers(),viewports:this.viewManager.getViewports(),onViewportActive:this.layerManager.activateViewport,views:this.viewManager.getViews(),pass:"screen",effects:this.effectManager.getEffects(),...i};(o=this.deckRenderer)==null||o.renderLayers(r),r.pass==="screen"&&this.widgetManager.onRedraw({viewports:r.viewports,layers:r.layers}),this.props.onAfterRender({device:n,gl:s})}_onRenderFrame(){this._getFrameStats(),this._metricsCounter++%60===0&&(this._getMetrics(),this.stats.reset(),j.table(4,this.metrics)(),this.props._onMetrics&&this.props._onMetrics(this.metrics)),this._updateCanvasSize(),this._updateCursor(),this.layerManager.updateLayers(),this._pickAndCallback(),this.redraw(),this.viewManager&&this.viewManager.updateViewStates()}_onViewStateChange(e){const i=this.props.onViewStateChange(e)||e.viewState;this.viewState&&(this.viewState={...this.viewState,[e.viewId]:i},this.props.viewState||this.viewManager&&this.viewManager.setProps({viewState:this.viewState}))}_onInteractionStateChange(e){this.cursorState.isDragging=e.isDragging||!1,this.props.onInteractionStateChange(e)}_getFrameStats(){const{stats:e}=this;e.get("frameRate").timeEnd(),e.get("frameRate").timeStart();const i=this.animationLoop.stats;e.get("GPU Time").addTime(i.get("GPU Time").lastTiming),e.get("CPU Time").addTime(i.get("CPU Time").lastTiming)}_getMetrics(){var s;const{metrics:e,stats:i}=this;e.fps=i.get("frameRate").getHz(),e.setPropsTime=i.get("setProps Time").time,e.updateAttributesTime=i.get("Update Attributes").time,e.framesRedrawn=i.get("Redraw Count").count,e.pickTime=i.get("pickObject Time").time+i.get("pickMultipleObjects Time").time+i.get("pickObjects Time").time,e.pickCount=i.get("Pick Count").count,e.layersCount=((s=this.layerManager)==null?void 0:s.layers.length)??0,e.drawLayersCount=i.get("Layers rendered").lastSampleCount,e.pickLayersCount=i.get("Layers picked").lastSampleCount,e.updateAttributesCount=i.get("Layers updated").count,e.updateAttributesCount=i.get("Attributes updated").count,e.gpuTime=i.get("GPU Time").time,e.cpuTime=i.get("CPU Time").time,e.gpuTimePerFrame=i.get("GPU Time").getAverageTime(),e.cpuTimePerFrame=i.get("CPU Time").getAverageTime();const n=go.stats.get("GPU Time and Memory");e.bufferMemory=n.get("Buffer Memory").count,e.textureMemory=n.get("Texture Memory").count,e.renderbufferMemory=n.get("Renderbuffer Memory").count,e.gpuMemory=n.get("GPU Memory").count}}Ba.defaultProps=Bd;Ba.VERSION=pm;function t3(t){switch(t){case"float64":return Float64Array;case"uint8":case"unorm8":return Uint8ClampedArray;default:return Mu(t)}}const i3=qe.getDataType.bind(qe);function Ln(t,e,i){if(e.size>4)return null;const n=i==="webgpu"&&e.type==="uint8"?"unorm8":e.type;return{attribute:t,format:e.size>1?`${n}x${e.size}`:e.type,byteOffset:e.offset||0}}function Tt(t){return t.stride||t.size*t.bytesPerElement}function n3(t,e){return t.type===e.type&&t.size===e.size&&Tt(t)===Tt(e)&&(t.offset||0)===(e.offset||0)}function jo(t,e){e.offset&&j.removed("shaderAttribute.offset","vertexOffset, elementOffset")();const i=Tt(t),n=e.vertexOffset!==void 0?e.vertexOffset:t.vertexOffset||0,s=e.elementOffset||0,r=n*i+s*t.bytesPerElement+(t.offset||0);return{...e,offset:r,stride:i}}function s3(t,e){const i=jo(t,e);return{high:i,low:{...i,offset:i.offset+t.size*4}}}class r3{constructor(e,i,n){this._buffer=null,this.device=e,this.id=i.id||"",this.size=i.size||1;const s=i.logicalType||i.type,r=s==="float64";let{defaultValue:o}=i;o=Number.isFinite(o)?[o]:o||new Array(this.size).fill(0);let a;r?a="float32":!s&&i.isIndexed?a="uint32":a=s||"float32";let c=t3(s||a);this.doublePrecision=r,r&&i.fp64===!1&&(c=Float32Array),this.value=null,this.settings={...i,defaultType:c,defaultValue:o,logicalType:s,type:a,normalized:a.includes("norm"),size:this.size,bytesPerElement:c.BYTES_PER_ELEMENT},this.state={...n,externalBuffer:null,bufferAccessor:this.settings,allocatedValue:null,numInstances:0,bounds:null,constant:!1}}get isConstant(){return this.state.constant}get buffer(){return this._buffer}get byteOffset(){const e=this.getAccessor();return e.vertexOffset?e.vertexOffset*Tt(e):0}get numInstances(){return this.state.numInstances}set numInstances(e){this.state.numInstances=e}delete(){this._buffer&&(this._buffer.delete(),this._buffer=null),ci.release(this.state.allocatedValue)}getBuffer(){return this.state.constant?null:this.state.externalBuffer||this._buffer}getValue(e=this.id,i=null){const n={};if(this.state.constant){const s=this.value;if(i){const r=jo(this.getAccessor(),i),o=r.offset/s.BYTES_PER_ELEMENT,a=r.size||this.size;n[e]=s.subarray(o,o+a)}else n[e]=s}else n[e]=this.getBuffer();return this.doublePrecision&&(this.value instanceof Float64Array?n[`${e}64Low`]=n[e]:n[`${e}64Low`]=new Float32Array(this.size)),n}_getBufferLayout(e=this.id,i=null){const n=this.getAccessor(),s=[],r={name:this.id,byteStride:Tt(n)};if(this.doublePrecision){const o=s3(n,i||{});s.push(Ln(e,{...n,...o.high},this.device.type),Ln(`${e}64Low`,{...n,...o.low},this.device.type))}else if(i){const o=jo(n,i);s.push(Ln(e,{...n,...o},this.device.type))}else s.push(Ln(e,n,this.device.type));return r.attributes=s.filter(Boolean),r}setAccessor(e){this.state.bufferAccessor=e}getAccessor(){return this.state.bufferAccessor}getBounds(){if(this.state.bounds)return this.state.bounds;let e=null;if(this.state.constant&&this.value){const i=Array.from(this.value);e=[i,i]}else{const{value:i,numInstances:n,size:s}=this,r=n*s;if(i&&r&&i.length>=r){const o=new Array(s).fill(1/0),a=new Array(s).fill(-1/0);for(let c=0;c<r;)for(let l=0;l<s;l++){const f=i[c++];f<o[l]&&(o[l]=f),f>a[l]&&(a[l]=f)}e=[o,a]}}return this.state.bounds=e,e}setData(e){const{state:i}=this;let n;ArrayBuffer.isView(e)?n={value:e}:e instanceof Z?n={buffer:e}:n=e;const s={...this.settings,...n};if(ArrayBuffer.isView(n.value)){if(!n.type)if(this.doublePrecision&&n.value instanceof Float64Array)s.type="float32";else{const o=i3(n.value);s.type=s.normalized?o.replace("int","norm"):o}s.bytesPerElement=n.value.BYTES_PER_ELEMENT,s.stride=Tt(s)}if(i.bounds=null,n.constant){let r=n.value;if(r=this._normalizeValue(r,[],0),this.settings.normalized&&(r=this.normalizeConstant(r)),!(!i.constant||!this._areValuesEqual(r,this.value)))return!1;i.externalBuffer=null,i.constant=!0,this.value=ArrayBuffer.isView(r)?r:new Float32Array(r)}else if(n.buffer){const r=n.buffer;i.externalBuffer=r,i.constant=!1,this.value=n.value||null}else if(n.value){this._checkExternalBuffer(n);let r=n.value;i.externalBuffer=null,i.constant=!1,this.value=r;let{buffer:o}=this;const a=Tt(s),c=(s.vertexOffset||0)*a;if(this.doublePrecision&&r instanceof Float64Array&&(r=xr(r,s)),this.settings.isIndexed){const f=this.settings.defaultType;r.constructor!==f&&(r=new f(r))}const l=r.byteLength+c+a*2;(!o||o.byteLength<l)&&(o=this._createBuffer(l)),o.write(r,c)}return this.setAccessor(s),!0}updateSubBuffer(e={}){this.state.bounds=null;const i=this.value,{startOffset:n=0,endOffset:s}=e;this.buffer.write(this.doublePrecision&&i instanceof Float64Array?xr(i,{size:this.size,startIndex:n,endIndex:s}):i.subarray(n,s),n*i.BYTES_PER_ELEMENT+this.byteOffset)}allocate(e,i=!1){const{state:n}=this,s=n.allocatedValue,r=ci.allocate(s,e+1,{size:this.size,type:this.settings.defaultType,copy:i});this.value=r;const{byteOffset:o}=this;let{buffer:a}=this;return(!a||a.byteLength<r.byteLength+o)&&(a=this._createBuffer(r.byteLength+o),i&&s&&a.write(s instanceof Float64Array?xr(s,this):s,o)),n.allocatedValue=r,n.constant=!1,n.externalBuffer=null,this.setAccessor(this.settings),!0}_checkExternalBuffer(e){const{value:i}=e;if(!ArrayBuffer.isView(i))throw new Error(`Attribute ${this.id} value is not TypedArray`);const n=this.settings.defaultType;let s=!1;if(this.doublePrecision&&(s=i.BYTES_PER_ELEMENT<4),s)throw new Error(`Attribute ${this.id} does not support ${i.constructor.name}`);!(i instanceof n)&&this.settings.normalized&&!("normalized"in e)&&j.warn(`Attribute ${this.id} is normalized`)()}normalizeConstant(e){switch(this.settings.type){case"snorm8":return new Float32Array(e).map(i=>(i+128)/255*2-1);case"snorm16":return new Float32Array(e).map(i=>(i+32768)/65535*2-1);case"unorm8":return new Float32Array(e).map(i=>i/255);case"unorm16":return new Float32Array(e).map(i=>i/65535);default:return e}}_normalizeValue(e,i,n){const{defaultValue:s,size:r}=this.settings;if(Number.isFinite(e))return i[n]=e,i;if(!e){let o=r;for(;--o>=0;)i[n+o]=s[o];return i}switch(r){case 4:i[n+3]=Number.isFinite(e[3])?e[3]:s[3];case 3:i[n+2]=Number.isFinite(e[2])?e[2]:s[2];case 2:i[n+1]=Number.isFinite(e[1])?e[1]:s[1];case 1:i[n+0]=Number.isFinite(e[0])?e[0]:s[0];break;default:let o=r;for(;--o>=0;)i[n+o]=Number.isFinite(e[o])?e[o]:s[o]}return i}_areValuesEqual(e,i){if(!e||!i)return!1;const{size:n}=this;for(let s=0;s<n;s++)if(e[s]!==i[s])return!1;return!0}_createBuffer(e){var s;this._buffer&&this._buffer.destroy();const{isIndexed:i,type:n}=this.settings;return this._buffer=this.device.createBuffer({...(s=this._buffer)==null?void 0:s.props,id:this.id,usage:(i?Z.INDEX:Z.VERTEX)|Z.COPY_DST,indexType:i?n:void 0,byteLength:e}),this._buffer}}const df=[],gf=[];function cn(t,e=0,i=1/0){let n=df;const s={index:-1,data:t,target:[]};return t?typeof t[Symbol.iterator]=="function"?n=t:t.length>0&&(gf.length=t.length,n=gf):n=df,(e>0||Number.isFinite(i))&&(n=(Array.isArray(n)?n:Array.from(n)).slice(e,i),s.index=e-1),{iterable:n,objectInfo:s}}function Fd(t){return t&&t[Symbol.asyncIterator]}function kd(t,e){const{size:i,stride:n,offset:s,startIndices:r,nested:o}=e,a=t.BYTES_PER_ELEMENT,c=n?n/a:i,l=s?s/a:0,f=Math.floor((t.length-l)/c);return(h,{index:u,target:d})=>{if(!r){const b=u*c+l;for(let A=0;A<i;A++)d[A]=t[b+A];return d}const p=r[u],_=r[u+1]||f;let m;if(o){m=new Array(_-p);for(let b=p;b<_;b++){const A=b*c+l;d=new Array(i);for(let v=0;v<i;v++)d[v]=t[A+v];m[b-p]=d}}else if(c===i)m=t.subarray(p*i+l,_*i+l);else{m=new t.constructor((_-p)*i);let b=0;for(let A=p;A<_;A++){const v=A*c+l;for(let S=0;S<i;S++)m[b++]=t[v+S]}}return m}}const o3=[],Yn=[[0,1/0]];function a3(t,e){if(t===Yn||(e[0]<0&&(e[0]=0),e[0]>=e[1]))return t;const i=[],n=t.length;let s=0;for(let r=0;r<n;r++){const o=t[r];o[1]<e[0]?(i.push(o),s=r+1):o[0]>e[1]?i.push(o):e=[Math.min(o[0],e[0]),Math.max(o[1],e[1])]}return i.splice(s,0,e),i}const c3={interpolation:{duration:0,easing:t=>t},spring:{stiffness:.05,damping:.5}};function Ud(t,e){if(!t)return null;Number.isFinite(t)&&(t={type:"interpolation",duration:t});const i=t.type||"interpolation";return{...c3[i],...e,...t,type:i}}class zd extends r3{constructor(e,i){super(e,i,{startIndices:null,lastExternalBuffer:null,binaryValue:null,binaryAccessor:null,needsUpdate:!0,needsRedraw:!1,layoutChanged:!1,updateRanges:Yn}),this.constant=!1,this.settings.update=i.update||(i.accessor?this._autoUpdater:void 0),Object.seal(this.settings),Object.seal(this.state),this._validateAttributeUpdaters()}get startIndices(){return this.state.startIndices}set startIndices(e){this.state.startIndices=e}needsUpdate(){return this.state.needsUpdate}needsRedraw({clearChangedFlags:e=!1}={}){const i=this.state.needsRedraw;return this.state.needsRedraw=i&&!e,i}layoutChanged(){return this.state.layoutChanged}setAccessor(e){var i;(i=this.state).layoutChanged||(i.layoutChanged=!n3(e,this.getAccessor())),super.setAccessor(e)}getUpdateTriggers(){const{accessor:e}=this.settings;return[this.id].concat(typeof e!="function"&&e||[])}supportsTransition(){return!!this.settings.transition}getTransitionSetting(e){if(!e||!this.supportsTransition())return null;const{accessor:i}=this.settings,n=this.settings.transition,s=Array.isArray(i)?e[i.find(r=>e[r])]:e[i];return Ud(s,n)}setNeedsUpdate(e=this.id,i){if(this.state.needsUpdate=this.state.needsUpdate||e,this.setNeedsRedraw(e),i){const{startRow:n=0,endRow:s=1/0}=i;this.state.updateRanges=a3(this.state.updateRanges,[n,s])}else this.state.updateRanges=Yn}clearNeedsUpdate(){this.state.needsUpdate=!1,this.state.updateRanges=o3}setNeedsRedraw(e=this.id){this.state.needsRedraw=this.state.needsRedraw||e}allocate(e){const{state:i,settings:n}=this;return n.noAlloc?!1:n.update?(super.allocate(e,i.updateRanges!==Yn),!0):!1}updateBuffer({numInstances:e,data:i,props:n,context:s}){if(!this.needsUpdate())return!1;const{state:{updateRanges:r},settings:{update:o,noAlloc:a}}=this;let c=!0;if(o){for(const[l,f]of r)o.call(s,this,{data:i,startRow:l,endRow:f,props:n,numInstances:e});if(this.value)if(this.constant||!this.buffer||this.buffer.byteLength<this.value.byteLength+this.byteOffset)this.constant?this.setConstantValue(s,this.value):this.setData({value:this.value,constant:this.constant}),this.constant=!1;else for(const[l,f]of r){const h=Number.isFinite(l)?this.getVertexOffset(l):0,u=Number.isFinite(f)?this.getVertexOffset(f):a||!Number.isFinite(e)?this.value.length:e*this.size;super.updateSubBuffer({startOffset:h,endOffset:u})}this._checkAttributeArray()}else c=!1;return this.clearNeedsUpdate(),this.setNeedsRedraw(),c}setConstantValue(e,i){if(i===void 0||typeof i=="function")return!1;const n=this.settings.transform&&e?this.settings.transform.call(e,i):i;return this.device.type==="webgpu"?this.setConstantBufferValue(n,this.numInstances):(this.setData({constant:!0,value:n})&&this.setNeedsRedraw(),this.clearNeedsUpdate(),!0)}setConstantBufferValue(e,i){const n=this.settings.defaultType,s=this._normalizeValue(e,new n(this.size),0);if(this._hasConstantBufferValue(s,i))return this.constant=!1,this.clearNeedsUpdate(),!1;const r=new n(Math.max(i,1)*this.size);for(let a=0;a<r.length;a+=this.size)r.set(s,a);const o=this.setData({value:r});return this.constant=!1,this.clearNeedsUpdate(),o&&this.setNeedsRedraw(),o}_hasConstantBufferValue(e,i){const n=this.value,s=Math.max(i,1)*this.size;if(!ArrayBuffer.isView(n)||n.length!==s||n.length%this.size!==0)return!1;for(let r=0;r<n.length;r+=this.size)for(let o=0;o<this.size;o++)if(n[r+o]!==e[o])return!1;return!0}setExternalBuffer(e){const{state:i}=this;return e?(this.clearNeedsUpdate(),i.lastExternalBuffer===e||(i.lastExternalBuffer=e,this.setNeedsRedraw(),this.setData(e)),!0):(i.lastExternalBuffer=null,!1)}setBinaryValue(e,i=null){const{state:n,settings:s}=this;if(!e)return n.binaryValue=null,n.binaryAccessor=null,!1;if(s.noAlloc)return!1;if(n.binaryValue===e)return this.clearNeedsUpdate(),!0;if(n.binaryValue=e,this.setNeedsRedraw(),s.transform||i!==this.startIndices){ArrayBuffer.isView(e)&&(e={value:e});const o=e;fe(ArrayBuffer.isView(o.value),`invalid ${s.accessor}`);const a=!!o.size&&o.size!==this.size;return n.binaryAccessor=kd(o.value,{size:o.size||this.size,stride:o.stride,offset:o.offset,startIndices:i,nested:a}),!1}return this.clearNeedsUpdate(),this.setData(e),!0}getVertexOffset(e){const{startIndices:i}=this;return(i?e<i.length?i[e]:this.numInstances:e)*this.size}getValue(){const e=this.settings.shaderAttributes,i=super.getValue();if(!e)return i;for(const n in e)Object.assign(i,super.getValue(n,e[n]));return i}getBufferLayout(e){this.state.layoutChanged=!1;const i=this.settings.shaderAttributes,n=super._getBufferLayout(),{stepMode:s}=this.settings;if(s==="dynamic"?n.stepMode=e?e.isInstanced?"instance":"vertex":"instance":n.stepMode=s??"vertex",!i)return n;for(const r in i){const o=super._getBufferLayout(r,i[r]);n.attributes.push(...o.attributes)}return n}_autoUpdater(e,{data:i,startRow:n,endRow:s,props:r,numInstances:o}){const{settings:a,state:c,value:l,size:f,startIndices:h}=e,{accessor:u,transform:d}=a,p=c.binaryAccessor||(typeof u=="function"?u:r[u]);fe(typeof p=="function",`accessor "${u}" is not a function`);let _=e.getVertexOffset(n);const{iterable:m,objectInfo:b}=cn(i,n,s);for(const A of m){b.index++;let v=p(A,b);if(d&&(v=d.call(this,v)),h){const S=(b.index<h.length-1?h[b.index+1]:o)-h[b.index];if(v&&Array.isArray(v[0])){let E=_;for(const x of v)e._normalizeValue(x,l,E),E+=f}else v&&v.length>f?l.set(v,_):(e._normalizeValue(v,b.target,0),mS({target:l,source:b.target,start:_,count:S}));_+=S*f}else e._normalizeValue(v,l,_),_+=f}}_validateAttributeUpdaters(){const{settings:e}=this;if(!(e.noAlloc||typeof e.update=="function"))throw new Error(`Attribute ${this.id} missing update or accessor`)}_checkAttributeArray(){const{value:e}=this,i=Math.min(4,this.size);if(e&&e.length>=i){let n=!0;switch(i){case 4:n=n&&Number.isFinite(e[3]);case 3:n=n&&Number.isFinite(e[2]);case 2:n=n&&Number.isFinite(e[1]);case 1:n=n&&Number.isFinite(e[0]);break;default:n=!1}if(!n)throw new Error(`Illegal attribute generated for ${this.id}`)}}}function Vr(t){const{source:e,target:i,start:n=0,size:s,getData:r}=t,o=t.end||i.length,a=e.length,c=o-n;if(a>c){i.set(e.subarray(0,c),n);return}if(i.set(e,n),!r)return;let l=a;for(;l<c;){const f=r(l,e);for(let h=0;h<s;h++)i[n+l]=f[h]||0,l++}}function l3({source:t,target:e,size:i,getData:n,sourceStartIndices:s,targetStartIndices:r}){if(!s||!r)return Vr({source:t,target:e,size:i,getData:n}),e;let o=0,a=0;const c=n&&((f,h)=>n(f+a,h)),l=Math.min(s.length,r.length);for(let f=1;f<l;f++){const h=s[f]*i,u=r[f]*i;Vr({source:t.subarray(o,h),target:e,start:a,end:u,size:i,getData:c}),o=h,a=u}return a<e.length&&Vr({source:[],target:e,start:a,size:i,getData:c}),e}function f3(t){const{device:e,settings:i,value:n}=t,s=new zd(e,i);return s.setData({value:n instanceof Float64Array?new Float64Array(0):new Float32Array(0),normalized:i.normalized}),s}function Wd(t){switch(t){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error(`No defined attribute type for size "${t}"`)}}function Vd(t){switch(t){case 1:return"float32";case 2:return"float32x2";case 3:return"float32x3";case 4:return"float32x4";default:throw new Error("invalid type size")}}function $d(t){t.push(t.shift())}function h3(t,e){const{doublePrecision:i,settings:n,value:s,size:r}=t,o=i&&s instanceof Float64Array?2:1;let a=0;const{shaderAttributes:c}=t.settings;if(c)for(const l of Object.values(c))a=Math.max(a,l.vertexOffset??0);return(n.noAlloc?s.length:(e+a)*r)*o}function jd({device:t,source:e,target:i}){return(!i||i.byteLength<e.byteLength)&&(i==null||i.destroy(),i=t.createBuffer({byteLength:e.byteLength,usage:e.usage})),i}function Hd({device:t,buffer:e,attribute:i,fromLength:n,toLength:s,fromStartIndices:r,getData:o=a=>a}){const a=i.doublePrecision&&i.value instanceof Float64Array?2:1,c=i.size*a,l=i.byteOffset,f=i.settings.bytesPerElement<4?l/i.settings.bytesPerElement*4:l,h=i.startIndices,u=r&&h,d=i.isConstant;if(!u&&e&&n>=s)return e;const p=i.value instanceof Float64Array?Float32Array:i.value.constructor,_=d?i.value:new p(i.getBuffer().readSyncWebGL(l,s*p.BYTES_PER_ELEMENT).buffer);if(i.settings.normalized&&!d){const v=o;o=(S,E)=>i.normalizeConstant(v(S,E))}const m=d?(v,S)=>o(_,S):(v,S)=>o(_.subarray(v+l,v+l+c),S),b=e?new Float32Array(e.readSyncWebGL(f,n*4).buffer):new Float32Array(0),A=new Float32Array(s);return l3({source:b,target:A,sourceStartIndices:r,targetStartIndices:h,size:c,getData:m}),(!e||e.byteLength<A.byteLength+f)&&(e==null||e.destroy(),e=t.createBuffer({byteLength:A.byteLength+f,usage:35050})),e.write(A,f),e}class Xd{constructor({device:e,attribute:i,timeline:n}){this.buffers=[],this.currentLength=0,this.device=e,this.transition=new Ks(n),this.attribute=i,this.attributeInTransition=f3(i),this.currentStartIndices=i.startIndices}get inProgress(){return this.transition.inProgress}start(e,i,n=1/0){this.settings=e,this.currentStartIndices=this.attribute.startIndices,this.currentLength=h3(this.attribute,i),this.transition.start({...e,duration:n})}update(){const e=this.transition.update();return e&&this.onUpdate(),e}setBuffer(e){this.attributeInTransition.setData({buffer:e,normalized:this.attribute.settings.normalized,value:this.attributeInTransition.value})}cancel(){this.transition.cancel()}delete(){this.cancel();for(const e of this.buffers)e.destroy();this.buffers.length=0}}class u3 extends Xd{constructor({device:e,attribute:i,timeline:n}){super({device:e,attribute:i,timeline:n}),this.type="interpolation",this.transform=_3(e,i)}start(e,i){const n=this.currentLength,s=this.currentStartIndices;if(super.start(e,i,e.duration),e.duration<=0){this.transition.cancel();return}const{buffers:r,attribute:o}=this;$d(r),r[0]=Hd({device:this.device,buffer:r[0],attribute:o,fromLength:n,toLength:this.currentLength,fromStartIndices:s,getData:e.enter}),r[1]=jd({device:this.device,source:r[0],target:r[1]}),this.setBuffer(r[1]);const{transform:a}=this,c=a.model;let l=Math.floor(this.currentLength/o.size);Yd(o)&&(l/=2),c.setVertexCount(l),o.isConstant?(c.setAttributes({aFrom:r[0]}),c.setConstantAttributes({aTo:o.value})):c.setAttributes({aFrom:r[0],aTo:o.getBuffer()}),a.transformFeedback.setBuffers({vCurrent:r[1]})}onUpdate(){const{duration:e,easing:i}=this.settings,{time:n}=this.transition;let s=n/e;i&&(s=i(s));const{model:r}=this.transform,o={time:s};r.shaderInputs.setProps({interpolation:o}),this.transform.run({discard:!0})}delete(){super.delete(),this.transform.destroy()}}const d3=`layout(std140) uniform interpolationUniforms { 1934 float time; 1935} interpolation; 1936`,pf={name:"interpolation",vs:d3,uniformTypes:{time:"f32"}},g3=`#version 300 es 1937#define SHADER_NAME interpolation-transition-vertex-shader 1938 1939in ATTRIBUTE_TYPE aFrom; 1940in ATTRIBUTE_TYPE aTo; 1941out ATTRIBUTE_TYPE vCurrent; 1942 1943void main(void) { 1944 vCurrent = mix(aFrom, aTo, interpolation.time); 1945 gl_Position = vec4(0.0); 1946} 1947`,p3=`#version 300 es 1948#define SHADER_NAME interpolation-transition-vertex-shader 1949 1950in ATTRIBUTE_TYPE aFrom; 1951in ATTRIBUTE_TYPE aFrom64Low; 1952in ATTRIBUTE_TYPE aTo; 1953in ATTRIBUTE_TYPE aTo64Low; 1954out ATTRIBUTE_TYPE vCurrent; 1955out ATTRIBUTE_TYPE vCurrent64Low; 1956 1957vec2 mix_fp64(vec2 a, vec2 b, float x) { 1958 vec2 range = sub_fp64(b, a); 1959 return sum_fp64(a, mul_fp64(range, vec2(x, 0.0))); 1960} 1961 1962void main(void) { 1963 for (int i=0; i<ATTRIBUTE_SIZE; i++) { 1964 vec2 value = mix_fp64(vec2(aFrom[i], aFrom64Low[i]), vec2(aTo[i], aTo64Low[i]), interpolation.time); 1965 vCurrent[i] = value.x; 1966 vCurrent64Low[i] = value.y; 1967 } 1968 gl_Position = vec4(0.0); 1969} 1970`;function Yd(t){return t.doublePrecision&&t.value instanceof Float64Array}function _3(t,e){const i=e.size,n=Wd(i),s=Vd(i),r=e.getBufferLayout();return Yd(e)?new Gi(t,{vs:p3,bufferLayout:[{name:"aFrom",byteStride:8*i,attributes:[{attribute:"aFrom",format:s,byteOffset:0},{attribute:"aFrom64Low",format:s,byteOffset:4*i}]},{name:"aTo",byteStride:8*i,attributes:[{attribute:"aTo",format:s,byteOffset:0},{attribute:"aTo64Low",format:s,byteOffset:4*i}]}],modules:[s0,pf],defines:{ATTRIBUTE_TYPE:n,ATTRIBUTE_SIZE:i},moduleSettings:{},varyings:["vCurrent","vCurrent64Low"],bufferMode:35980,disableWarnings:!0}):new Gi(t,{vs:g3,bufferLayout:[{name:"aFrom",format:s},{name:"aTo",format:r.attributes[0].format}],modules:[pf],defines:{ATTRIBUTE_TYPE:n},varyings:["vCurrent"],disableWarnings:!0})}class m3 extends Xd{constructor({device:e,attribute:i,timeline:n}){super({device:e,attribute:i,timeline:n}),this.type="spring",this.texture=w3(e),this.framebuffer=S3(e,this.texture),this.transform=A3(e,i)}start(e,i){const n=this.currentLength,s=this.currentStartIndices;super.start(e,i);const{buffers:r,attribute:o}=this;for(let c=0;c<2;c++)r[c]=Hd({device:this.device,buffer:r[c],attribute:o,fromLength:n,toLength:this.currentLength,fromStartIndices:s,getData:e.enter});r[2]=jd({device:this.device,source:r[0],target:r[2]}),this.setBuffer(r[1]);const{model:a}=this.transform;a.setVertexCount(Math.floor(this.currentLength/o.size)),o.isConstant?a.setConstantAttributes({aTo:o.value}):a.setAttributes({aTo:o.getBuffer()})}onUpdate(){const{buffers:e,transform:i,framebuffer:n,transition:s}=this,r=this.settings;i.model.setAttributes({aPrev:e[0],aCur:e[1]}),i.transformFeedback.setBuffers({vNext:e[2]});const o={stiffness:r.stiffness,damping:r.damping};i.model.shaderInputs.setProps({spring:o}),i.run({framebuffer:n,discard:!1,parameters:{viewport:[0,0,1,1]},clearColor:[0,0,0,0]}),$d(e),this.setBuffer(e[1]),this.device.readPixelsToArrayWebGL(n)[0]>0||s.end()}delete(){super.delete(),this.transform.destroy(),this.texture.destroy(),this.framebuffer.destroy()}}const y3=`layout(std140) uniform springUniforms { 1971 float damping; 1972 float stiffness; 1973} spring; 1974`,b3={name:"spring",vs:y3,uniformTypes:{damping:"f32",stiffness:"f32"}},v3=`#version 300 es 1975#define SHADER_NAME spring-transition-vertex-shader 1976 1977#define EPSILON 0.00001 1978 1979in ATTRIBUTE_TYPE aPrev; 1980in ATTRIBUTE_TYPE aCur; 1981in ATTRIBUTE_TYPE aTo; 1982out ATTRIBUTE_TYPE vNext; 1983out float vIsTransitioningFlag; 1984 1985ATTRIBUTE_TYPE getNextValue(ATTRIBUTE_TYPE cur, ATTRIBUTE_TYPE prev, ATTRIBUTE_TYPE dest) { 1986 ATTRIBUTE_TYPE velocity = cur - prev; 1987 ATTRIBUTE_TYPE delta = dest - cur; 1988 ATTRIBUTE_TYPE force = delta * spring.stiffness; 1989 ATTRIBUTE_TYPE resistance = velocity * spring.damping; 1990 return force - resistance + velocity + cur; 1991} 1992 1993void main(void) { 1994 bool isTransitioning = length(aCur - aPrev) > EPSILON || length(aTo - aCur) > EPSILON; 1995 vIsTransitioningFlag = isTransitioning ? 1.0 : 0.0; 1996 1997 vNext = getNextValue(aCur, aPrev, aTo); 1998 gl_Position = vec4(0, 0, 0, 1); 1999 gl_PointSize = 100.0; 2000} 2001`,T3=`#version 300 es 2002#define SHADER_NAME spring-transition-is-transitioning-fragment-shader 2003 2004in float vIsTransitioningFlag; 2005 2006out vec4 fragColor; 2007 2008void main(void) { 2009 if (vIsTransitioningFlag == 0.0) { 2010 discard; 2011 } 2012 fragColor = vec4(1.0); 2013}`;function A3(t,e){const i=Wd(e.size),n=Vd(e.size);return new Gi(t,{vs:v3,fs:T3,bufferLayout:[{name:"aPrev",format:n},{name:"aCur",format:n},{name:"aTo",format:e.getBufferLayout().attributes[0].format}],varyings:["vNext"],modules:[b3],defines:{ATTRIBUTE_TYPE:i},parameters:{depthCompare:"always",blendColorOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"max",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"}})}function w3(t){return t.createTexture({data:new Uint8Array(4),format:"rgba8unorm",width:1,height:1})}function S3(t,e){return t.createFramebuffer({id:"spring-transition-is-transitioning-framebuffer",width:1,height:1,colorAttachments:[e]})}const E3={interpolation:u3,spring:m3};class x3{constructor(e,{id:i,timeline:n}){if(!e)throw new Error("AttributeTransitionManager is constructed without device");this.id=i,this.device=e,this.timeline=n,this.transitions={},this.needsRedraw=!1,this.numInstances=1}finalize(){for(const e in this.transitions)this._removeTransition(e)}update({attributes:e,transitions:i,numInstances:n}){this.numInstances=n||1;for(const s in e){const r=e[s],o=r.getTransitionSetting(i);o&&this._updateAttribute(s,r,o)}for(const s in this.transitions){const r=e[s];(!r||!r.getTransitionSetting(i))&&this._removeTransition(s)}}hasAttribute(e){const i=this.transitions[e];return i&&i.inProgress}getAttributes(){const e={};for(const i in this.transitions){const n=this.transitions[i];n.inProgress&&(e[i]=n.attributeInTransition)}return e}run(){if(this.numInstances===0)return!1;for(const i in this.transitions)this.transitions[i].update()&&(this.needsRedraw=!0);const e=this.needsRedraw;return this.needsRedraw=!1,e}_removeTransition(e){this.transitions[e].delete(),delete this.transitions[e]}_updateAttribute(e,i,n){const s=this.transitions[e];let r=!s||s.type!==n.type;if(r){s&&this._removeTransition(e);const o=E3[n.type];o?this.transitions[e]=new o({attribute:i,timeline:this.timeline,device:this.device}):(j.error(`unsupported transition type '${n.type}'`)(),r=!1)}(r||i.needsRedraw())&&(this.needsRedraw=!0,this.transitions[e].start(n,this.numInstances))}}const _f="attributeManager.invalidate",P3="attributeManager.updateStart",R3="attributeManager.updateEnd",C3="attribute.updateStart",M3="attribute.allocate",O3="attribute.updateEnd";class I3{constructor(e,{id:i="attribute-manager",stats:n,timeline:s}={}){this.mergeBoundsMemoized=an(ww),this.id=i,this.device=e,this.attributes={},this.updateTriggers={},this.needsRedraw=!0,this.userData={},this.stats=n,this.attributeTransitionManager=new x3(e,{id:`${i}-transitions`,timeline:s}),Object.seal(this)}finalize(){for(const e in this.attributes)this.attributes[e].delete();this.attributeTransitionManager.finalize()}getNeedsRedraw(e={clearRedrawFlags:!1}){const i=this.needsRedraw;return this.needsRedraw=this.needsRedraw&&!e.clearRedrawFlags,i&&this.id}setNeedsRedraw(){this.needsRedraw=!0}add(e){this._add(e)}addInstanced(e){this._add(e,{stepMode:"instance"})}remove(e){for(const i of e)this.attributes[i]!==void 0&&(this.attributes[i].delete(),delete this.attributes[i])}invalidate(e,i){const n=this._invalidateTrigger(e,i);ge(_f,this,e,n)}invalidateAll(e){for(const i in this.attributes)this.attributes[i].setNeedsUpdate(i,e);ge(_f,this,"all")}update({data:e,numInstances:i,startIndices:n=null,transitions:s,props:r={},buffers:o={},context:a={}}){let c=!1;ge(P3,this),this.stats&&this.stats.get("Update Attributes").timeStart();for(const l in this.attributes){const f=this.attributes[l],h=f.settings.accessor;f.startIndices=n,f.numInstances=i,r[l]&&j.removed(`props.${l}`,`data.attributes.${l}`)(),f.setExternalBuffer(o[l])||f.setBinaryValue(typeof h=="string"?o[h]:void 0,e.startIndices)||typeof h=="string"&&!o[h]&&f.setConstantValue(a,r[h])||f.needsUpdate()&&(c=!0,this._updateAttribute({attribute:f,numInstances:i,data:e,props:r,context:a})),this.needsRedraw=this.needsRedraw||f.needsRedraw()}c&&ge(R3,this,i),this.stats&&(this.stats.get("Update Attributes").timeEnd(),c&&this.stats.get("Attributes updated").incrementCount()),this.attributeTransitionManager.update({attributes:this.attributes,numInstances:i,transitions:s})}updateTransition(){const{attributeTransitionManager:e}=this,i=e.run();return this.needsRedraw=this.needsRedraw||i,i}getAttributes(){return{...this.attributes,...this.attributeTransitionManager.getAttributes()}}getBounds(e){const i=e.map(n=>{var s;return(s=this.attributes[n])==null?void 0:s.getBounds()});return this.mergeBoundsMemoized(i)}getChangedAttributes(e={clearChangedFlags:!1}){const{attributes:i,attributeTransitionManager:n}=this,s={...n.getAttributes()};for(const r in i){const o=i[r];o.needsRedraw(e)&&!n.hasAttribute(r)&&(s[r]=o)}return s}getBufferLayouts(e){return Object.values(this.getAttributes()).map(i=>i.getBufferLayout(e))}_add(e,i){for(const n in e){const s=e[n],r={...s,id:n,size:s.isIndexed&&1||s.size||1,...i};this.attributes[n]=new zd(this.device,r)}this._mapUpdateTriggersToAttributes()}_mapUpdateTriggersToAttributes(){const e={};for(const i in this.attributes)this.attributes[i].getUpdateTriggers().forEach(s=>{e[s]||(e[s]=[]),e[s].push(i)});this.updateTriggers=e}_invalidateTrigger(e,i){const{attributes:n,updateTriggers:s}=this,r=s[e];return r&&r.forEach(o=>{const a=n[o];a&&a.setNeedsUpdate(a.id,i)}),r}_updateAttribute(e){const{attribute:i,numInstances:n}=e;if(ge(C3,i),i.constant){i.setConstantValue(e.context,i.value);return}i.allocate(n)&&ge(M3,i,n),i.updateBuffer(e)&&(this.needsRedraw=!0,ge(O3,i,n))}}class N3 extends Ks{get value(){return this._value}_onUpdate(){const{time:e,settings:{fromValue:i,toValue:n,duration:s,easing:r}}=this,o=r(e/s);this._value=wt(i,n,o)}}const mf=1e-5;function yf(t,e,i,n,s){const r=e-t,a=(i-e)*s,c=-r*n;return a+c+r+e}function L3(t,e,i,n,s){if(Array.isArray(i)){const r=[];for(let o=0;o<i.length;o++)r[o]=yf(t[o],e[o],i[o],n,s);return r}return yf(t,e,i,n,s)}function bf(t,e){if(Array.isArray(t)){let i=0;for(let n=0;n<t.length;n++){const s=t[n]-e[n];i+=s*s}return Math.sqrt(i)}return Math.abs(t-e)}class D3 extends Ks{get value(){return this._currValue}_onUpdate(){const{fromValue:e,toValue:i,damping:n,stiffness:s}=this.settings,{_prevValue:r=e,_currValue:o=e}=this;let a=L3(r,o,i,n,s);const c=bf(a,i),l=bf(a,o);c<mf&&l<mf&&(a=i,this.end()),this._prevValue=o,this._currValue=a}}const B3={interpolation:N3,spring:D3};class F3{constructor(e){this.transitions=new Map,this.timeline=e}get active(){return this.transitions.size>0}add(e,i,n,s){const{transitions:r}=this;if(r.has(e)){const c=r.get(e),{value:l=c.settings.fromValue}=c;i=l,this.remove(e)}if(s=Ud(s),!s)return;const o=B3[s.type];if(!o){j.error(`unsupported transition type '${s.type}'`)();return}const a=new o(this.timeline);a.start({...s,fromValue:i,toValue:n}),r.set(e,a)}remove(e){const{transitions:i}=this;i.has(e)&&(i.get(e).cancel(),i.delete(e))}update(){const e={};for(const[i,n]of this.transitions)n.update(),e[i]=n.value,n.inProgress||this.remove(i);return e}clear(){for(const e of this.transitions.keys())this.remove(e)}}function k3(t){const e=t[ht];for(const i in e){const n=e[i],{validate:s}=n;if(s&&!s(t[i],n))throw new Error(`Invalid prop ${i}: ${t[i]}`)}}function U3(t,e){const i=Kd({newProps:t,oldProps:e,propTypes:t[ht],ignoreProps:{data:null,updateTriggers:null,extensions:null,transitions:null}}),n=W3(t,e);let s=!1;return n||(s=V3(t,e)),{dataChanged:n,propsChanged:i,updateTriggersChanged:s,extensionsChanged:$3(t,e),transitionsChanged:z3(t,e)}}function z3(t,e){if(!t.transitions)return!1;const i={},n=t[ht];let s=!1;for(const r in t.transitions){const o=n[r],a=o&&o.type;(a==="number"||a==="color"||a==="array")&&Ho(t[r],e[r],o)&&(i[r]=!0,s=!0)}return s?i:!1}function Kd({newProps:t,oldProps:e,ignoreProps:i={},propTypes:n={},triggerName:s="props"}){if(e===t)return!1;if(typeof t!="object"||t===null)return`${s} changed shallowly`;if(typeof e!="object"||e===null)return`${s} changed shallowly`;for(const r of Object.keys(t))if(!(r in i)){if(!(r in e))return`${s}.${r} added`;const o=Ho(t[r],e[r],n[r]);if(o)return`${s}.${r} ${o}`}for(const r of Object.keys(e))if(!(r in i)){if(!(r in t))return`${s}.${r} dropped`;if(!Object.hasOwnProperty.call(t,r)){const o=Ho(t[r],e[r],n[r]);if(o)return`${s}.${r} ${o}`}}return!1}function Ho(t,e,i){let n=i&&i.equal;return n&&!n(t,e,i)||!n&&(n=t&&e&&t.equals,n&&!n.call(t,e))?"changed deeply":!n&&e!==t?"changed shallowly":null}function W3(t,e){if(e===null)return"oldProps is null, initial diff";let i=!1;const{dataComparator:n,_dataDiff:s}=t;return n?n(t.data,e.data)||(i="Data comparator detected a change"):t.data!==e.data&&(i="A new data container was supplied"),i&&s&&(i=s(t.data,e.data)||i),i}function V3(t,e){if(e===null)return{all:!0};if("all"in t.updateTriggers&&vf(t,e,"all"))return{all:!0};const i={};let n=!1;for(const s in t.updateTriggers)s!=="all"&&vf(t,e,s)&&(i[s]=!0,n=!0);return n?i:!1}function $3(t,e){if(e===null)return!0;const i=e.extensions,{extensions:n}=t;if(n===i)return!1;if(!i||!n||n.length!==i.length)return!0;for(let s=0;s<n.length;s++)if(!n[s].equals(i[s]))return!0;return!1}function vf(t,e,i){let n=t.updateTriggers[i];n=n??{};let s=e.updateTriggers[i];return s=s??{},Kd({oldProps:s,newProps:n,triggerName:i})}const j3="count(): argument not an object",H3="count(): argument not a container";function X3(t){if(!K3(t))throw new Error(j3);if(typeof t.count=="function")return t.count();if(Number.isFinite(t.size))return t.size;if(Number.isFinite(t.length))return t.length;if(Y3(t))return Object.keys(t).length;throw new Error(H3)}function Y3(t){return t!==null&&typeof t=="object"&&t.constructor===Object}function K3(t){return t!==null&&typeof t=="object"}function Tf(t,e){if(!e)return t;const i={...t,...e};if("defines"in e&&(i.defines={...t.defines,...e.defines}),"modules"in e&&(i.modules=(t.modules||[]).concat(e.modules),e.modules.some(n=>n.name==="project64"))){const n=i.modules.findIndex(s=>s.name==="project32");n>=0&&i.modules.splice(n,1)}if("inject"in e)if(!t.inject)i.inject=e.inject;else{const n={...t.inject};for(const s in e.inject)n[s]=(n[s]||"")+e.inject[s];i.inject=n}return i}const q3={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},Xo={};function Z3(t,e,i,n){if(i instanceof Q)return i;i.constructor&&i.constructor.name!=="Object"&&(i={data:i});let s=null;i.compressed&&(s={minFilter:"linear",mipmapFilter:i.data.length>1?"nearest":"linear"});const{width:r,height:o}=i.data,a=e.createTexture({...i,sampler:{...q3,...s,...n},mipLevels:e.getMipLevelCount(r,o)});return e.type==="webgl"?a.generateMipmapsWebGL():e.type==="webgpu"&&e.generateMipmapsWebGPU(a),Xo[a.id]=t,a}function G3(t,e){!e||!(e instanceof Q)||Xo[e.id]===t&&(e.delete(),delete Xo[e.id])}const Q3={boolean:{validate(t,e){return!0},equal(t,e,i){return!!t==!!e}},number:{validate(t,e){return Number.isFinite(t)&&(!("max"in e)||t<=e.max)&&(!("min"in e)||t>=e.min)}},color:{validate(t,e){return e.optional&&!t||Yo(t)&&(t.length===3||t.length===4)},equal(t,e,i){return be(t,e,1)}},accessor:{validate(t,e){const i=ms(t);return i==="function"||i===ms(e.value)},equal(t,e,i){return typeof e=="function"?!0:be(t,e,1)}},array:{validate(t,e){return e.optional&&!t||Yo(t)},equal(t,e,i){const{compare:n}=i,s=Number.isInteger(n)?n:n?1:0;return n?be(t,e,s):t===e}},object:{equal(t,e,i){if(i.ignore)return!0;const{compare:n}=i,s=Number.isInteger(n)?n:n?1:0;return n?be(t,e,s):t===e}},function:{validate(t,e){return e.optional&&!t||typeof t=="function"},equal(t,e,i){return!i.compare&&i.ignore!==!1||t===e}},data:{transform:(t,e,i)=>{if(!t)return t;const{dataTransform:n}=i.props;return n?n(t):typeof t.shape=="string"&&t.shape.endsWith("-table")&&Array.isArray(t.data)?t.data:t}},image:{transform:(t,e,i)=>{const n=i.context;return!n||!n.device?null:Z3(i.id,n.device,t,{...e.parameters,...i.props.textureParameters})},release:(t,e,i)=>{G3(i.id,t)}}};function J3(t){const e={},i={},n={};for(const[s,r]of Object.entries(t)){const o=r==null?void 0:r.deprecatedFor;if(o)n[s]=Array.isArray(o)?o:[o];else{const a=eP(s,r);e[s]=a,i[s]=a.value}}return{propTypes:e,defaultProps:i,deprecatedProps:n}}function eP(t,e){switch(ms(e)){case"object":return Pi(t,e);case"array":return Pi(t,{type:"array",value:e,compare:!1});case"boolean":return Pi(t,{type:"boolean",value:e});case"number":return Pi(t,{type:"number",value:e});case"function":return Pi(t,{type:"function",value:e,compare:!0});default:return{name:t,type:"unknown",value:e}}}function Pi(t,e){return"type"in e?{name:t,...Q3[e.type],...e}:"value"in e?{name:t,type:ms(e.value),...e}:{name:t,type:"object",value:e}}function Yo(t){return Array.isArray(t)||ArrayBuffer.isView(t)}function ms(t){return Yo(t)?"array":t===null?"null":typeof t}function tP(t,e){let i;for(let r=e.length-1;r>=0;r--){const o=e[r];"extensions"in o&&(i=o.extensions)}const n=Ko(t.constructor,i),s=Object.create(n);s[ps]=t,s[It]={},s[lt]={};for(let r=0;r<e.length;++r){const o=e[r];for(const a in o)s[a]=o[a]}return Object.freeze(s),s}const iP="_mergedDefaultProps";function Ko(t,e){if(!(t instanceof Zs.constructor))return{};let i=iP;if(e)for(const s of e){const r=s.constructor;r&&(i+=`:${r.extensionName||r.name}`)}const n=qd(t,i);return n||(t[i]=nP(t,e||[]))}function nP(t,e){if(!t.prototype)return null;const n=Object.getPrototypeOf(t),s=Ko(n),r=qd(t,"defaultProps")||{},o=J3(r),a=Object.assign(Object.create(null),s,o.defaultProps),c=Object.assign(Object.create(null),s==null?void 0:s[ht],o.propTypes),l=Object.assign(Object.create(null),s==null?void 0:s[Or],o.deprecatedProps);for(const f of e){const h=Ko(f.constructor);h&&(Object.assign(a,h),Object.assign(c,h[ht]),Object.assign(l,h[Or]))}return sP(a,t),oP(a,c),rP(a,l),a[ht]=c,a[Or]=l,e.length===0&&!Fa(t,"_propTypes")&&(t._propTypes=c),a}function sP(t,e){const i=cP(e);Object.defineProperties(t,{id:{writable:!0,value:i}})}function rP(t,e){for(const i in e)Object.defineProperty(t,i,{enumerable:!1,set(n){const s=`${this.id}: ${i}`;for(const r of e[i])Fa(this,r)||(this[r]=n);j.deprecated(s,e[i].join("/"))()}})}function oP(t,e){const i={},n={};for(const s in e){const r=e[s],{name:o,value:a}=r;r.async&&(i[o]=a,n[o]=aP(o))}t[ei]=i,t[It]={},Object.defineProperties(t,n)}function aP(t){return{enumerable:!0,set(e){typeof e=="string"||e instanceof Promise||Fd(e)?this[It][t]=e:this[lt][t]=e},get(){if(this[lt]){if(t in this[lt])return this[lt][t]||this[ei][t];if(t in this[It]){const e=this[ps]&&this[ps].internalState;if(e&&e.hasAsyncProp(t))return e.getAsyncProp(t)||this[ei][t]}}return this[ei][t]}}}function Fa(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function qd(t,e){return Fa(t,e)&&t[e]}function cP(t){const e=t.componentName;return e||j.warn(`${t.name}.componentName not specified`)(),e||t.name}let lP=0;class Zs{constructor(...e){this.props=tP(this,e),this.id=this.props.id,this.count=lP++}clone(e){const{props:i}=this,n={};for(const s in i[ei])s in i[lt]?n[s]=i[lt][s]:s in i[It]&&(n[s]=i[It][s]);return new this.constructor({...i,...n,...e})}}Zs.componentName="Component";Zs.defaultProps={};const fP=Object.freeze({});class hP{constructor(e){this.component=e,this.asyncProps={},this.onAsyncPropUpdated=()=>{},this.oldProps=null,this.oldAsyncProps=null}finalize(){for(const e in this.asyncProps){const i=this.asyncProps[e];i&&i.type&&i.type.release&&i.type.release(i.resolvedValue,i.type,this.component)}this.asyncProps={},this.component=null,this.resetOldProps()}getOldProps(){return this.oldAsyncProps||this.oldProps||fP}resetOldProps(){this.oldAsyncProps=null,this.oldProps=this.component?this.component.props:null}hasAsyncProp(e){return e in this.asyncProps}getAsyncProp(e){const i=this.asyncProps[e];return i&&i.resolvedValue}isAsyncPropLoading(e){if(e){const i=this.asyncProps[e];return!!(i&&i.pendingLoadCount>0&&i.pendingLoadCount!==i.resolvedLoadCount)}for(const i in this.asyncProps)if(this.isAsyncPropLoading(i))return!0;return!1}reloadAsyncProp(e,i){this._watchPromise(e,Promise.resolve(i))}setAsyncProps(e){this.component=e[ps]||this.component;const i=e[lt]||{},n=e[It]||e,s=e[ei]||{};for(const r in i){const o=i[r];this._createAsyncPropData(r,s[r]),this._updateAsyncProp(r,o),i[r]=this.getAsyncProp(r)}for(const r in n){const o=n[r];this._createAsyncPropData(r,s[r]),this._updateAsyncProp(r,o)}}_fetch(e,i){return null}_onResolve(e,i){}_onError(e,i){}_updateAsyncProp(e,i){if(this._didAsyncInputValueChange(e,i)){if(typeof i=="string"&&(i=this._fetch(e,i)),i instanceof Promise){this._watchPromise(e,i);return}if(Fd(i)){this._resolveAsyncIterable(e,i);return}this._setPropValue(e,i)}}_freezeAsyncOldProps(){if(!this.oldAsyncProps&&this.oldProps){this.oldAsyncProps=Object.create(this.oldProps);for(const e in this.asyncProps)Object.defineProperty(this.oldAsyncProps,e,{enumerable:!0,value:this.oldProps[e]})}}_didAsyncInputValueChange(e,i){const n=this.asyncProps[e];return i===n.resolvedValue||i===n.lastValue?!1:(n.lastValue=i,!0)}_setPropValue(e,i){this._freezeAsyncOldProps();const n=this.asyncProps[e];n&&(i=this._postProcessValue(n,i),n.resolvedValue=i,n.pendingLoadCount++,n.resolvedLoadCount=n.pendingLoadCount)}_setAsyncPropValue(e,i,n){const s=this.asyncProps[e];s&&n>=s.resolvedLoadCount&&i!==void 0&&(this._freezeAsyncOldProps(),s.resolvedValue=i,s.resolvedLoadCount=n,this.onAsyncPropUpdated(e,i))}_watchPromise(e,i){const n=this.asyncProps[e];if(n){n.pendingLoadCount++;const s=n.pendingLoadCount;i.then(r=>{this.component&&(r=this._postProcessValue(n,r),this._setAsyncPropValue(e,r,s),this._onResolve(e,r))}).catch(r=>{this._onError(e,r)})}}async _resolveAsyncIterable(e,i){if(e!=="data"){this._setPropValue(e,i);return}const n=this.asyncProps[e];if(!n)return;n.pendingLoadCount++;const s=n.pendingLoadCount;let r=[],o=0;for await(const a of i){if(!this.component)return;const{dataTransform:c}=this.component.props;c?r=c(a,r):r=r.concat(a),Object.defineProperty(r,"__diff",{enumerable:!1,value:[{startRow:o,endRow:r.length}]}),o=r.length,this._setAsyncPropValue(e,r,s)}this._onResolve(e,r)}_postProcessValue(e,i){const n=e.type;return n&&this.component&&(n.release&&n.release(e.resolvedValue,n,this.component),n.transform)?n.transform(i,n,this.component):i}_createAsyncPropData(e,i){if(!this.asyncProps[e]){const s=this.component&&this.component.props[ht];this.asyncProps[e]={type:s&&s[e],lastValue:null,resolvedValue:i,pendingLoadCount:0,resolvedLoadCount:0}}}}class uP extends hP{constructor({attributeManager:e,layer:i}){super(i),this.attributeManager=e,this.needsRedraw=!0,this.needsUpdate=!0,this.subLayers=null,this.usesPickingColorCache=!1}get layer(){return this.component}_fetch(e,i){const n=this.layer,s=n==null?void 0:n.props.fetch;return s?s(i,{propName:e,layer:n}):super._fetch(e,i)}_onResolve(e,i){const n=this.layer;if(n){const s=n.props.onDataLoad;e==="data"&&s&&s(i,{propName:e,layer:n})}}_onError(e,i){const n=this.layer;n&&n.raiseError(i,`loading ${e} of ${this.layer}`)}}const dP="layer.changeFlag",gP="layer.initialize",pP="layer.update",_P="layer.finalize",mP="layer.matched",Af=2**24-1,yP=Object.freeze([]),bP=an(({oldViewport:t,viewport:e})=>t.equals(e));let xe=new Uint8ClampedArray(0);const vP={data:{type:"data",value:yP,async:!0},dataComparator:{type:"function",value:null,optional:!0},_dataDiff:{type:"function",value:t=>t&&t.__diff,optional:!0},dataTransform:{type:"function",value:null,optional:!0},onDataLoad:{type:"function",value:null,optional:!0},onError:{type:"function",value:null,optional:!0},fetch:{type:"function",value:(t,{propName:e,layer:i,loaders:n,loadOptions:s,signal:r})=>{var c;const{resourceManager:o}=i.context;s=s||i.getLoadOptions(),n=n||i.props.loaders,r&&(s={...s,core:{...s==null?void 0:s.core,fetch:{...(c=s==null?void 0:s.core)==null?void 0:c.fetch,signal:r}}});let a=o.contains(t);return!a&&!s&&(o.add({resourceId:t,data:is(t,n),persistent:!1}),a=!0),a?o.subscribe({resourceId:t,onChange:l=>{var f;return(f=i.internalState)==null?void 0:f.reloadAsyncProp(e,l)},consumerId:i.id,requestId:e}):is(t,n,s)}},updateTriggers:{},visible:!0,pickable:!1,opacity:{type:"number",min:0,max:1,value:1},operation:"draw",onHover:{type:"function",value:null,optional:!0},onClick:{type:"function",value:null,optional:!0},onDragStart:{type:"function",value:null,optional:!0},onDrag:{type:"function",value:null,optional:!0},onDragEnd:{type:"function",value:null,optional:!0},coordinateSystem:"default",coordinateOrigin:{type:"array",value:[0,0,0],compare:!0},modelMatrix:{type:"array",value:null,compare:!0,optional:!0},wrapLongitude:!1,positionFormat:"XYZ",colorFormat:"RGBA",parameters:{type:"object",value:{},optional:!0,compare:2},loadOptions:{type:"object",value:null,optional:!0,ignore:!0},transitions:null,extensions:[],loaders:{type:"array",value:[],optional:!0,ignore:!0},getPolygonOffset:{type:"function",value:({layerIndex:t})=>[0,-t*100]},highlightedObjectIndex:null,autoHighlight:!1,highlightColor:{type:"accessor",value:[0,0,128,128]}};class Fe extends Zs{constructor(){super(...arguments),this.internalState=null,this.lifecycle=jt.NO_STATE,this.parent=null}static get componentName(){return Object.prototype.hasOwnProperty.call(this,"layerName")?this.layerName:""}get root(){let e=this;for(;e.parent;)e=e.parent;return e}toString(){return`${this.constructor.layerName||this.constructor.name}({id: '${this.props.id}'})`}project(e){fe(this.internalState);const i=this.internalState.viewport||this.context.viewport,n=Ra(e,{viewport:i,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem}),[s,r,o]=Qu(n,i.pixelProjectionMatrix);return e.length===2?[s,r]:[s,r,o]}unproject(e){return fe(this.internalState),(this.internalState.viewport||this.context.viewport).unproject(e)}projectPosition(e,i){fe(this.internalState);const n=this.internalState.viewport||this.context.viewport;return id(e,{viewport:n,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem,...i})}get isComposite(){return!1}get isDrawable(){return!0}setState(e){this.setChangeFlags({stateChanged:!0}),Object.assign(this.state,e),this.setNeedsRedraw()}setNeedsRedraw(){this.internalState&&(this.internalState.needsRedraw=!0)}setNeedsUpdate(){this.internalState&&(this.context.layerManager.setNeedsUpdate(String(this)),this.internalState.needsUpdate=!0)}get isLoaded(){return this.internalState?!this.internalState.isAsyncPropLoading():!1}get wrapLongitude(){return this.props.wrapLongitude}isPickable(){return this.props.pickable&&this.props.visible}getModels(){const e=this.state;return e&&(e.models||e.model&&[e.model])||[]}setShaderModuleProps(...e){for(const i of this.getModels())i.shaderInputs.setProps(...e)}getAttributeManager(){return this.internalState&&this.internalState.attributeManager}getCurrentLayer(){return this.internalState&&this.internalState.layer}getLoadOptions(){return this.props.loadOptions}use64bitPositions(){const{coordinateSystem:e}=this.props;return e==="default"||e==="lnglat"||e==="cartesian"}onHover(e,i){return this.props.onHover&&this.props.onHover(e,i)||!1}onClick(e,i){return this.props.onClick&&this.props.onClick(e,i)||!1}nullPickingColor(){return[0,0,0]}encodePickingColor(e,i=[]){return i[0]=e+1&255,i[1]=e+1>>8&255,i[2]=e+1>>8>>8&255,i}decodePickingColor(e){fe(e instanceof Uint8Array);const[i,n,s]=e;return i+n*256+s*65536-1}getNumInstances(){return Number.isFinite(this.props.numInstances)?this.props.numInstances:this.state&&this.state.numInstances!==void 0?this.state.numInstances:X3(this.props.data)}getStartIndices(){return this.props.startIndices?this.props.startIndices:this.state&&this.state.startIndices?this.state.startIndices:null}getBounds(){var e;return(e=this.getAttributeManager())==null?void 0:e.getBounds(["positions","instancePositions"])}getShaders(e){e=Tf(e,{disableWarnings:!0,modules:this.context.defaultShaderModules});for(const i of this.props.extensions)e=Tf(e,i.getShaders.call(this,i));return e}shouldUpdateState(e){return e.changeFlags.propsOrDataChanged}updateState(e){const i=this.getAttributeManager(),{dataChanged:n}=e.changeFlags;if(n&&i)if(Array.isArray(n))for(const s of n)i.invalidateAll(s);else i.invalidateAll();if(i){const{props:s}=e,r=this.internalState.hasPickingBuffer,o=Number.isInteger(s.highlightedObjectIndex)||!!s.pickable||s.extensions.some(a=>a.getNeedsPickingBuffer.call(this,a));if(r!==o){this.internalState.hasPickingBuffer=o;const{pickingColors:a,instancePickingColors:c}=i.attributes,l=a||c;l&&(o&&l.constant&&(l.constant=!1,i.invalidate(l.id)),!l.value&&!o&&(l.constant=!0,l.value=[0,0,0]))}}}finalizeState(e){for(const n of this.getModels())n.destroy();const i=this.getAttributeManager();i&&i.finalize(),this.context&&this.context.resourceManager.unsubscribe({consumerId:this.id}),this.internalState&&(this.internalState.uniformTransitions.clear(),this.internalState.finalize())}draw(e){for(const i of this.getModels())i.draw(e.renderPass)}getPickingInfo({info:e,mode:i,sourceLayer:n}){const{index:s}=e;return s>=0&&Array.isArray(this.props.data)&&(e.object=this.props.data[s]),e}raiseError(e,i){var n,s,r,o;i&&(e=new Error(`${i}: ${e.message}`,{cause:e})),(s=(n=this.props).onError)!=null&&s.call(n,e)||(o=(r=this.context)==null?void 0:r.onError)==null||o.call(r,e,this)}getNeedsRedraw(e={clearRedrawFlags:!1}){return this._getNeedsRedraw(e)}needsUpdate(){return this.internalState?this.internalState.needsUpdate||this.hasUniformTransition()||this.shouldUpdateState(this._getUpdateParams()):!1}hasUniformTransition(){var e;return((e=this.internalState)==null?void 0:e.uniformTransitions.active)||!1}activateViewport(e){if(!this.internalState)return;const i=this.internalState.viewport;this.internalState.viewport=e,(!i||!bP({oldViewport:i,viewport:e}))&&(this.setChangeFlags({viewportChanged:!0}),this.isComposite?this.needsUpdate()&&this.setNeedsUpdate():this._update())}invalidateAttribute(e="all"){const i=this.getAttributeManager();i&&(e==="all"?i.invalidateAll():i.invalidate(e))}updateAttributes(e){let i=!1;for(const n in e)e[n].layoutChanged()&&(i=!0);for(const n of this.getModels())this._setModelAttributes(n,e,i)}_updateAttributes(){const e=this.getAttributeManager();if(!e)return;const i=this.props,n=this.getNumInstances(),s=this.getStartIndices();e.update({data:i.data,numInstances:n,startIndices:s,props:i,transitions:i.transitions,buffers:i.data.attributes,context:this});const r=e.getChangedAttributes({clearChangedFlags:!0});this.updateAttributes(r)}_updateAttributeTransition(){const e=this.getAttributeManager();e&&e.updateTransition()}_updateUniformTransition(){const{uniformTransitions:e}=this.internalState;if(e.active){const i=e.update(),n=Object.create(this.props);for(const s in i)Object.defineProperty(n,s,{value:i[s]});return n}return this.props}calculateInstancePickingColors(e,{numInstances:i}){if(e.constant)return;const n=Math.floor(xe.length/4);if(this.internalState.usesPickingColorCache=!0,n<i){i>Af&&j.warn("Layer has too many data objects. Picking might not be able to distinguish all objects.")(),xe=ci.allocate(xe,i,{size:4,copy:!0,maxCount:Math.max(i,Af)});const s=Math.floor(xe.length/4),r=[0,0,0];for(let o=n;o<s;o++)this.encodePickingColor(o,r),xe[o*4+0]=r[0],xe[o*4+1]=r[1],xe[o*4+2]=r[2],xe[o*4+3]=0}e.value=xe.subarray(0,i*4)}_setModelAttributes(e,i,n=!1){var a;if(!Object.keys(i).length)return;if(n){const c=this.getAttributeManager();e.setBufferLayout(c.getBufferLayouts(e)),i=c.getAttributes()}const s=((a=e.userData)==null?void 0:a.excludeAttributes)||{},r={},o={};for(const c in i){if(s[c])continue;const l=i[c].getValue();for(const f in l){const h=l[f];h instanceof Z?i[c].settings.isIndexed?e.setIndexBuffer(h):r[f]=h:h&&(o[f]=h)}}e.setAttributes(r),e.setConstantAttributes(o)}disablePickingIndex(e){const i=this.props.data;if(!("attributes"in i)){this._disablePickingIndex(e);return}const{pickingColors:n,instancePickingColors:s}=this.getAttributeManager().attributes,r=n||s,o=r&&i.attributes&&i.attributes[r.id];if(o&&o.value){const a=o.value,c=this.encodePickingColor(e);for(let l=0;l<i.length;l++){const f=r.getVertexOffset(l);a[f]===c[0]&&a[f+1]===c[1]&&a[f+2]===c[2]&&this._disablePickingIndex(l)}}else this._disablePickingIndex(e)}_disablePickingIndex(e){const{pickingColors:i,instancePickingColors:n}=this.getAttributeManager().attributes,s=i||n;if(!s)return;const r=s.getVertexOffset(e),o=s.getVertexOffset(e+1);s.buffer.write(new Uint8Array(o-r),r)}restorePickingColors(){const{pickingColors:e,instancePickingColors:i}=this.getAttributeManager().attributes,n=e||i;n&&(this.internalState.usesPickingColorCache&&n.value.buffer!==xe.buffer&&(n.value=xe.subarray(0,n.value.length)),n.updateSubBuffer({startOffset:0}))}_initialize(){fe(!this.internalState),ge(gP,this);const e=this._getAttributeManager();e&&e.addInstanced({instancePickingColors:{type:"uint8",size:4,noAlloc:!0,update:this.calculateInstancePickingColors}}),this.internalState=new uP({attributeManager:e,layer:this}),this._clearChangeFlags(),this.state={},Object.defineProperty(this.state,"attributeManager",{get:()=>(j.deprecated("layer.state.attributeManager","layer.getAttributeManager()")(),e)}),this.internalState.uniformTransitions=new F3(this.context.timeline),this.internalState.onAsyncPropUpdated=this._onAsyncPropUpdated.bind(this),this.internalState.setAsyncProps(this.props),this.initializeState(this.context);for(const i of this.props.extensions)i.initializeState.call(this,this.context,i);this.setChangeFlags({dataChanged:"init",propsChanged:"init",viewportChanged:!0,extensionsChanged:!0}),this._update()}_transferState(e){ge(mP,this,this===e);const{state:i,internalState:n}=e;this!==e&&(this.internalState=n,this.state=i,this.internalState.setAsyncProps(this.props),this._diffProps(this.props,this.internalState.getOldProps()))}_update(){const e=this.needsUpdate();if(ge(pP,this,e),!e)return;this.context.stats.get("Layer updates").incrementCount();const i=this.props,n=this.context,s=this.internalState,r=n.viewport,o=this._updateUniformTransition();s.propsInTransition=o,n.viewport=s.viewport||r,this.props=o;try{const a=this._getUpdateParams(),c=this.getModels();if(n.device)this.updateState(a);else try{this.updateState(a)}catch{}for(const f of this.props.extensions)f.updateState.call(this,a,f);this.setNeedsRedraw(),this._updateAttributes();const l=this.getModels()[0]!==c[0];this._postUpdate(a,l)}finally{n.viewport=r,this.props=i,this._clearChangeFlags(),s.needsUpdate=!1,s.resetOldProps()}}_finalize(){ge(_P,this),this.finalizeState(this.context);for(const e of this.props.extensions)e.finalizeState.call(this,this.context,e)}_drawLayer({renderPass:e,shaderModuleProps:i=null,uniforms:n={},parameters:s={}}){this._updateAttributeTransition();const r=this.props,o=this.context;this.props=this.internalState.propsInTransition||r;try{i&&this.setShaderModuleProps(i);const{getPolygonOffset:a}=this.props,c=a&&a(n)||[0,0];o.device instanceof Pt&&o.device.setParametersWebGL({polygonOffset:c});const l=o.device instanceof Pt?null:TP(s);if(AP(this.getModels(),e,s,l),o.device instanceof Pt)o.device.withParametersWebGL(s,()=>{const f={renderPass:e,shaderModuleProps:i,uniforms:n,parameters:s,context:o};for(const h of this.props.extensions)h.draw.call(this,f,h);this.draw(f)});else{l!=null&&l.renderPassParameters&&e.setParameters(l.renderPassParameters);const f={renderPass:e,shaderModuleProps:i,uniforms:n,parameters:s,context:o};for(const h of this.props.extensions)h.draw.call(this,f,h);this.draw(f)}}finally{this.props=r}}getChangeFlags(){var e;return(e=this.internalState)==null?void 0:e.changeFlags}setChangeFlags(e){if(!this.internalState)return;const{changeFlags:i}=this.internalState;for(const s in e)if(e[s]){let r=!1;switch(s){case"dataChanged":const o=e[s],a=i[s];o&&Array.isArray(a)&&(i.dataChanged=Array.isArray(o)?a.concat(o):o,r=!0);default:i[s]||(i[s]=e[s],r=!0)}r&&ge(dP,this,s,e)}const n=!!(i.dataChanged||i.updateTriggersChanged||i.propsChanged||i.extensionsChanged);i.propsOrDataChanged=n,i.somethingChanged=n||i.viewportChanged||i.stateChanged}_clearChangeFlags(){this.internalState.changeFlags={dataChanged:!1,propsChanged:!1,updateTriggersChanged:!1,viewportChanged:!1,stateChanged:!1,extensionsChanged:!1,propsOrDataChanged:!1,somethingChanged:!1}}_diffProps(e,i){var s;const n=U3(e,i);if(n.updateTriggersChanged)for(const r in n.updateTriggersChanged)n.updateTriggersChanged[r]&&this.invalidateAttribute(r);if(n.transitionsChanged)for(const r in n.transitionsChanged)this.internalState.uniformTransitions.add(r,i[r],e[r],(s=e.transitions)==null?void 0:s[r]);return this.setChangeFlags(n)}validateProps(){k3(this.props)}updateAutoHighlight(e){this.props.autoHighlight&&!Number.isInteger(this.props.highlightedObjectIndex)&&this._updateAutoHighlight(e)}_updateAutoHighlight(e){const i={highlightedObjectColor:e.picked?e.color:null},{highlightColor:n}=this.props;e.picked&&typeof n=="function"&&(i.highlightColor=n(e)),this.setShaderModuleProps({picking:i}),this.setNeedsRedraw()}_getAttributeManager(){const e=this.context;return new I3(e.device,{id:this.props.id,stats:e.stats,timeline:e.timeline})}_postUpdate(e,i){const{props:n,oldProps:s}=e,r=this.state.model;r!=null&&r.isInstanced&&r.setInstanceCount(this.getNumInstances());const{autoHighlight:o,highlightedObjectIndex:a,highlightColor:c}=n;if(i||s.autoHighlight!==o||s.highlightedObjectIndex!==a||s.highlightColor!==c){const l={};Array.isArray(c)&&(l.highlightColor=c),(i||s.autoHighlight!==o||a!==s.highlightedObjectIndex)&&(l.highlightedObjectColor=Number.isFinite(a)&&a>=0?this.encodePickingColor(a):null),this.setShaderModuleProps({picking:l})}}_getUpdateParams(){return{props:this.props,oldProps:this.internalState.getOldProps(),context:this.context,changeFlags:this.internalState.changeFlags}}_getNeedsRedraw(e){if(!this.internalState)return!1;let i=!1;i=i||this.internalState.needsRedraw&&this.id;const n=this.getAttributeManager(),s=n?n.getNeedsRedraw(e):!1;if(i=i||s,i)for(const r of this.props.extensions)r.onNeedsRedraw.call(this,r);return this.internalState.needsRedraw=this.internalState.needsRedraw&&!e.clearRedrawFlags,i}_onAsyncPropUpdated(){this._diffProps(this.props,this.internalState.getOldProps()),this.setNeedsUpdate()}}Fe.defaultProps=vP;Fe.layerName="Layer";function TP(t){const{blendConstant:e,...i}=t;return e?{pipelineParameters:i,renderPassParameters:{blendConstant:e}}:{pipelineParameters:i}}function AP(t,e,i,n){for(const s of t)s.device.type==="webgpu"?(wP(s,e),s.setParameters({...s.parameters,...n==null?void 0:n.pi
2013pelineParameters})):s.setParameters(i)}function wP(t,e){var o,a;const i=e.props.framebuffer||(e.framebuffer??null);if(!i)return;const n=i.colorAttachments.map(c=>{var l;return((l=c==null?void 0:c.texture)==null?void 0:l.format)??null}),s=(a=(o=i.depthStencilAttachment)==null?void 0:o.texture)==null?void 0:a.format,r=t;(!SP(r.props.colorAttachmentFormats,n)||r.props.depthStencilAttachmentFormat!==s)&&(r.props.colorAttachmentFormats=n,r.props.depthStencilAttachmentFormat=s,r._setPipelineNeedsUpdate("attachment formats"))}function SP(t,e){if(t===e)return!0;if(!t||!e||t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(t[i]!==e[i])return!1;return!0}const EP="compositeLayer.renderLayers";class ka extends Fe{get isComposite(){return!0}get isDrawable(){return!1}get isLoaded(){return super.isLoaded&&this.getSubLayers().every(e=>e.isLoaded)}getSubLayers(){return this.internalState&&this.internalState.subLayers||[]}initializeState(e){}setState(e){super.setState(e),this.setNeedsUpdate()}getPickingInfo({info:e}){const{object:i}=e;return i&&i.__source&&i.__source.parent&&i.__source.parent.id===this.id&&(e.object=i.__source.object,e.index=i.__source.index),e}filterSubLayer(e){return!0}shouldRenderSubLayer(e,i){return i&&i.length}getSubLayerClass(e,i){const{_subLayerProps:n}=this.props;return n&&n[e]&&n[e].type||i}getSubLayerRow(e,i,n){return e.__source={parent:this,object:i,index:n},e}getSubLayerAccessor(e){if(typeof e=="function"){const i={index:-1,data:this.props.data,target:[]};return(n,s)=>n&&n.__source?(i.index=n.__source.index,e(n.__source.object,i)):e(n,s)}return e}getSubLayerProps(e={}){var M;const{opacity:i,pickable:n,visible:s,parameters:r,getPolygonOffset:o,highlightedObjectIndex:a,autoHighlight:c,highlightColor:l,coordinateSystem:f,coordinateOrigin:h,wrapLongitude:u,positionFormat:d,modelMatrix:p,extensions:_,fetch:m,operation:b,_subLayerProps:A}=this.props,v={id:"",updateTriggers:{},opacity:i,pickable:n,visible:s,parameters:r,getPolygonOffset:o,highlightedObjectIndex:a,autoHighlight:c,highlightColor:l,coordinateSystem:f,coordinateOrigin:h,wrapLongitude:u,positionFormat:d,modelMatrix:p,extensions:_,fetch:m,operation:b},S=A&&e.id&&A[e.id],E=S&&S.updateTriggers,x=e.id||"sublayer";if(S){const O=this.props[ht],N=e.type?e.type._propTypes:{};for(const D in S){const B=N[D]||O[D];B&&B.type==="accessor"&&(S[D]=this.getSubLayerAccessor(S[D]))}}Object.assign(v,e,S),v.id=`${this.props.id}-${x}`,v.updateTriggers={all:(M=this.props.updateTriggers)==null?void 0:M.all,...e.updateTriggers,...E};for(const O of _){const N=O.getSubLayerProps.call(this,O);N&&Object.assign(v,N,{updateTriggers:Object.assign(v.updateTriggers,N.updateTriggers)})}return v}
2013_updateAutoHighlight(e){for(const i of this.getSubLayers())i.updateAutoHighlight(e)}_getAttributeManager(){return null}_postUpdate(e,i){let n=this.internalState.subLayers;const s=!n||this.needsUpdate();if(s){const r=this.renderLayers();n=Ca(r,Boolean),this.internalState.subLayers=n}ge(EP,this,s,n);for(const r of n)r.parent=this}}ka.layerName="CompositeLayer";class Zd{constructor(e){this.indexStarts=[0],this.vertexStarts=[0],this.vertexCount=0,this.instanceCount=0;const{attributes:i={}}=e;this.typedArrayManager=ci,this.attributes={},this._attributeDefs=i,this.opts=e,this.updateGeometry(e)}updateGeometry(e){Object.assign(this.opts,e);const{data:i,buffers:n={},getGeometry:s,geometryBuffer:r,positionFormat:o,dataChanged:a,normalize:c=!0}=this.opts;if(this.data=i,this.getGeometry=s,this.positionSize=r&&r.size||(o==="XY"?2:3),this.buffers=n,this.normalize=c,r&&(fe(i.startIndices),this.getGeometry=this.getGeometryFromBuffer(r),c||(n.vertexPositions=r)),this.geometryBuffer=n.vertexPositions,Array.isArray(a))for(const l of a)this._rebuildGeometry(l);else this._rebuildGeometry()}updatePartialGeometry({startRow:e,endRow:i}){this._rebuildGeometry({startRow:e,endRow:i})}getGeometryFromBuffer(e){const i=e.value||e;return ArrayBuffer.isView(i)?kd(i,{size:this.positionSize,offset:e.offset,stride:e.stride,startIndices:this.data.startIndices}):null}_allocate(e,i){const{attributes:n,buffers:s,_attributeDefs:r,typedArrayManager:o}=this;for(const a in r)if(a in s)o.release(n[a]),n[a]=null;else{const c=r[a];c.copy=i,n[a]=o.allocate(n[a],e,c)}}_forEachGeometry(e,i,n){const{data:s,getGeometry:r}=this,{iterable:o,objectInfo:a}=cn(s,i,n);for(const c of o){a.index++;const l=r?r(c,a):null;e(l,a.index)}}_rebuildGeometry(e){if(!this.data)return;let{indexStarts:i,vertexStarts:n,instanceCount:s}=this;const{data:r,geometryBuffer:o}=this,{startRow:a=0,endRow:c=1/0}=e||{},l={};if(e||(i=[0],n=[0]),this.normalize||!o)this._forEachGeometry((h,u)=>{const d=h&&this.normalizeGeometry(h);l[u]=d,n[u+1]=n[u]+(d?this.getGeometrySize(d):0)},a,c),s=n[n.length-1];else if(n=r.startIndices,s=n[r.length]||0,ArrayBuffer.isView(o))s=s||o.length/this.positionSize;else if(o instanceof Z){const h=this.positionSize*4;s=s||o.byteLength/h}else if(o.buffer){const h=o.stride||this.positionSize*4;s=s||o.buffer.byteLength/h}else if(o.value){const h=o.value,u=o.stride/h.BYTES_PER_ELEMENT||this.positionSize;s=s||h.length/u}this._allocate(s,!!e),this.indexStarts=i,this.vertexStarts=n,this.instanceCount=s;const f={};this._forEachGeometry((h,u)=>{const d=l[u]||h;f.vertexStart=n[u],f.indexStart=i[u];const p=u<n.length-1?n[u+1]:s;f.geometrySize=p-n[u],f.geometryIndex=u,this.updateGeometryAttributes(d,f)},a,c),this.vertexCount=i[i.length-1]}}const xP=typeof window<"u"?se.useLayoutEffect:se.useEffect;function ys(t,e){for(;t;){if(t===e)return!0;t=Object.getPrototypeOf(t)}return!1}const PP={position:"absolute",zIndex:-1};function Gd(t,e){if(typeof t=="function")return t(e);if(Array.isArray(t))return t.map(i=>Gd(i,e));if(Gs(t)){if(RP(t))return e.style=PP,se.cloneElement(t,e);if(CP(t))return se.cloneElement(t,e)}return t}function Gs(t){return t&&typeof t=="object"&&"type"in t||!1}function RP(t){var e;return(e=t.props)==null?void 0:e.mapStyle}function CP(t){const e=t.type;return e&&e.deckGLViewProps}function qo(t){if(typeof t=="function")return se.createElement(fi,{},t);if(Array.isArray(t))return t.map(qo);if(Gs(t)){if(t.type===se.Fragment)return qo(t.props.children);if(ys(t.type,fi))return t}return t}function MP({children:t,layers:e=[],views:i}){const n=[],s=[],r={};return se.Children.forEach(qo(t),o=>{if(Gs(o)){const a=o.type;if(ys(a,Fe)){const c=OP(a,o.props);s.push(c)}else n.push(o);if(ys(a,fi)&&a!==fi&&o.props.id){const c=new a(o.props);r[c.id]=c}}else o&&n.push(o)}),Object.keys(r).length>0&&(Array.isArray(i)?i.forEach(o=>{r[o.id]=o}):i&&(r[i.id]=i),i=Object.values(r)),e=s.length>0?[s,e]:e,{layers:e,children:n,views:i}}function OP(t,e){const i={},n=t.defaultProps||{};for(const s in e)n[s]!==e[s]&&(i[s]=e[s]);return new t(i)}const IP=se.createContext();function NP({children:t,deck:e,ContextProvider:i=IP.Provider}){const{viewManager:n}=e||{};if(!n||!n.views.length)return[];const s={},r=n.views[0].id;for(const o of t){let a=r,c=o;
2013Gs(o)&&ys(o.type,fi)&&(a=o.props.id||r,c=o.props.children);const l=n.getViewport(a),f=n.getViewState(a);if(l){f.padding=l.padding;const{x:h,y:u,width:d,height:p}=l;c=Gd(c,{x:h,y:u,width:d,height:p,viewport:l,viewState:f}),s[a]||(s[a]={viewport:l,children:[]}),s[a].children.push(c)}}return Object.keys(s).map(o=>{const{viewport:a,children:c}=s[o],{x:l,y:f,width:h,height:u}=a,d={position:"absolute",left:l,top:f,width:h,height:u},p=`view-${o}`,_=se.createElement("div",{key:p,id:p,style:d},...c),m={deck:e,viewport:a,container:e.canvas.offsetParent,eventManager:e.eventManager,onViewStateChange:A=>{A.viewId=o,e._onViewStateChange(A)},widgets:[]},b=`view-${o}-context`;return se.createElement(i,{key:b,value:m},_)})}const LP={mixBlendMode:null};function DP({width:t,height:e,style:i}){const n={position:"absolute",zIndex:0,left:0,top:0,width:t,height:e},s={left:0,top:0};if(i)for(const r in i)r in LP?s[r]=i[r]:n[r]=i[r];return{containerStyle:n,canvasStyle:s}}function BP(t){return{get deck(){return t.deck},pickObjectAsync:e=>t.deck.pickObjectAsync(e),pickObjectsAsync:e=>t.deck.pickObjectsAsync(e),pickObject:e=>t.deck.pickObject(e),pickMultipleObjects:e=>t.deck.pickMultipleObjects(e),pickObjects:e=>t.deck.pickObjects(e)}}function Qd(t){t.redrawReason&&(t.deck._drawLayers(t.redrawReason),t.redrawReason=null)}function FP(t,e,i){var s,r,o;const n=new e({...i,_customRender:((o=(r=(s=i.deviceProps)==null?void 0:s.adapters)==null?void 0:r[0])==null?void 0:o.type)==="webgpu"?void 0:a=>{t.redrawReason=a;const c=n.getViewports();t.lastRenderedViewports!==c?t.forceUpdate():Qd(t)}});return n}function kP(t,e){const[i,n]=se.useState(0),r=se.useRef({control:null,version:i,forceUpdate:()=>n(E=>E+1)}).current,o=se.useRef(null),a=se.useRef(null),c=se.useMemo(()=>MP(t),[t.layers,t.views,t.children]);let l=!0;const f=E=>{var x;return l&&t.viewState?(r.viewStateUpdateRequested=E,null):(r.viewStateUpdateRequested=null,(
2013x=t.onViewStateChange)==null?void 0:x.call(t,E))},h=E=>{var x;l?r.interactionStateUpdateRequested=E:(r.interactionStateUpdateRequested=null,(x=t.onInteractionStateChange)==null||x.call(t,E))},u=se.useMemo(()=>{const E={widgets:[],...t,style:null,width:"100%",height:"100%",parent:o.current,canvas:a.current,layers:c.layers,onViewStateChange:f,onInteractionStateChange:h};return c.views&&(E.views=c.views),delete E._customRender,r.deck&&(r.deck.setProps(E),r.deck.isInitialized&&(r.lastRenderedViewports=r.deck.getViewports())),E},[t]);se.useEffect(()=>{const E=t.Deck||Ba;return r.deck=FP(r,E,{...u,parent:o.current,canvas:a.current}),()=>{var x;return(x=r.deck)==null?void 0:x.finalize()}},[]),xP(()=>{var M;Qd(r);const{viewStateUpdateRequested:E,interactionStateUpdateRequested:x}=r;E&&f(E),x&&h(x),(M=r.deck)!=null&&M.isInitialized&&r.deck.redraw("Initial render")}),se.useImperativeHandle(e,()=>BP(r),[]);const d=r.deck&&r.deck.isInitialized?r.deck.getViewports():void 0,{ContextProvider:p,width:_="100%",height:m="100%",id:b,style:A}=t,{containerStyle:v,canvasStyle:S}=se.useMemo(()=>DP({width:_,height:m,style:A}),[_,m,A]);if(!r.viewStateUpdateRequested&&r.lastRenderedViewports===d||r.version!==i){r.lastRenderedViewports=d,r.version=i;const E=NP({children:c.children,deck:r.deck,ContextProvider:p}),x=se.createElement("canvas",{key:"canvas",id:b||"deckgl-overlay",ref:a,style:S}),M=se.createElement("div",{key:"deck-events-root",className:"deck-events-root",style:{width:_,height:m}},[x,E]),O=se.createElement("div",{key:"deck-widgets-root",className:"deck-widgets-root"});r.control=se.createElement("div",{id:`${b||"deckgl"}-wrapper`,ref:o,style:v},[M,O])}return l=!1,r.control}const F2=se.forwardRef(kP),Jd=["top","right","bottom","left"],wf=["start","end"],Sf=Jd.reduce((t,e)=>
2013t.concat(e,e+"-"+wf[0],e+"-"+wf[1]),[]),Xe=Math.min,pe=Math.max,bs=Math.round,$e=t=>({x:t,y:t}),UP={left:"right",right:"left",bottom:"top",top:"bottom"};function Zo(t,e,i){return pe(t,Xe(e,i))}function Ge(t,e){return typeof t=="function"?t(e):t}function Ee(t){return t.split("-")[0]}function Ie(t){return t.split("-")[1]}function eg(t){return t==="x"?"y":"x"}function Ua(t){return t==="y"?"height":"width"}function We(t){const e=t[0];return e==="t"||e==="b"?"y":"x"}function za(t){return eg(We(t))}function tg(t,e,i){i===void 0&&(i=!1);const n=Ie(t),s=za(t),r=Ua(s);let o=s==="x"?n===(i?"end":"start")?"right":"left":n==="start"?"bottom":"top";return e.reference[r]>e.floating[r]&&(o=Ts(o)),[o,Ts(o)]}function zP(t){const e=Ts(t);return[vs(t),e,vs(e)]}function vs(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const Ef=["left","right"],xf=["right","left"],WP=["top","bottom"],VP=["bottom","top"];function $P(t,e,i){switch(t){case"top":case"bottom":return i?e?xf:Ef:e?Ef:xf;case"left":case"right":return e?WP:VP;default:return[]}}function jP(t,e,i,n){const s=Ie(t);let r=$P(Ee(t),i==="start",n);return s&&(r=r.map(o=>o+"-"+s),e&&(r=r.concat(r.map(vs)))),r}function Ts(t){const e=Ee(t);return UP[e]+t.slice(e.length)}function HP(t){return{top:0,right:0,bottom:0,left:0,...t}}function Wa(t){return typeof t!="number"?HP(t):{top:t,right:t,bottom:t,left:t}}function hi(t){const{x:e,y:i,width:n,height:s}=t;return{width:n,height:s,top:i,left:e,right:e+n,bottom:i+s,x:e,y:i}}function Pf(t,e,i){let{reference:n,floating:s}=t;const r=We(e),o=za(e),a=Ua(o),c=Ee(e),l=r==="y",f=n.x+n.width/2-s.width/2,h=n.y+n.height/2-s.height/2,u=n[a]/2-s[a]/2;let d;switch(c){case"top":d={x:f,y:n.y-s.height};break;case"bottom":d={x:f,y:n.y+n.height};break;case"right":d={x:n.x+n.width,y:h};break;case"left":d={x:n.x-s.width,y:h};break;default:d={x:n.x,y:n.y}}switch(Ie(e)){case"start":d[o]-=u*(i&&l?-1:1);break;case"end":d[o]+=u*(i&&l?-1:1);break}return d}async function XP(t,e){var i;e===void 0&&(e={});const{x:n,y:s,platform:r,rects:o,elements:a,strategy:c}=t,{boundary:l="clippingAncestors",rootBoundary:f="viewport",elementContext:h="floating",altBoundary:u=!1,padding:d=0}=Ge(e,t),p=Wa(d),m=a[u?h==="floating"?"reference":"floating":h],b=hi(await r.getClippingRect({element:(i=await(r.isElement==null?void 0:r.isElement(m)))==null||i?m:m.contextElement||await(r.getDocumentElement==null?void 0:r.getDocumentElement(a.floating)),boundary:l,rootBoundary:f,strategy:c})),A=h==="floating"?{x:n,y:s,width:o.floating.width,height:o.floating.height}:o.reference,v=await(r.getOffsetParent==null?void 0:r.getOffsetParent(a.floating)),S=await(r.isElement==null?void 0:r.isElement(v))?await(r.getScale==null?void 0:r.getScale(v))||{x:1,y:1}:{x:1,y:1},E=hi(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:A,offsetParent:v,strategy:c}):A);return{top:(b.top-E.top+p.top)/S.y,bottom:(E.bottom-b.bottom+p.bottom)/S.y,left:(b.left-E.left+p.left)/S.x,right:(E.right-b.right+p.right)/S.x}}const YP=50,KP=async(t,e,i)=>{const{placement:n="bottom",strategy:s="absolute",middleware:r=[],platform:o}=i,a=o.detectOverflow?o:{...o,detectOverflow:XP},c=await(o.isRTL==null?void 0:o.isRTL(e));let l=await o.getElementRects({reference:t,floating:e,strategy:s}),{x:f,y:h}=Pf(l,n,c),u=n,d=0;const p={};for(let _=0;_<r.length;_++){const m=r[_];if(!m)continue;const{name:b,fn:A}=m,{x:v,y:S,data:E,reset:x}=await A({x:f,y:h,initialPlacement:n,placement:u,strategy:s,middlewareData:p,rects:l,platform:a,elements:{reference:t,floating:e}});f=v??f,h=S??h,p[b]={...p[b],...E},x&&d<YP&&(d++,typeof x=="object"&&(x.placement&&(u=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:t,floating:e,strategy:s}):x.rects),{x:f,y:h}=Pf(l,u,c)),_=-1)}return{x:f,y:h,placement:u,strategy:s,middlewareData:p}},qP=t=>({name:"arrow",options:t,async fn(e){const{x:i,y:n,placement:s,rects:r,platform:o,elements:a,middlewareData:c}=e,{element:l,padding:f=0}=Ge(t,e)||{};if(l==null)return{};const h=Wa(f),u={x:i,y:n},d=za(s),p=Ua(d),_=await o.getDimensions(l),m=d==="y",b=m?"top":"left",A=m?"bottom":"right",v=m?"clientHeight":"clientWidth",S=r.reference[p]+r.reference[d]-u[d]-r.floating[p],E=u[d]-r.reference[d],x=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l));let M=x?x[v]:0;(!M||!await(o.isElement==null?void 0:o.isElement(x)))&&(M=a.floating[v]||r.floating[p]);const O=S/2-E/2,N=M/2-_[p]/2-1,D=Xe(h[b],N),B=Xe(h[A],N),F=D,z=M-_[p]-B,U=M/2-_[p]/2+O,q=Zo(F,U,z),y=!c.arrow&&Ie(s)!=null&&U!==q&&r.reference[p]/2-(U<F?D:B)-_[p]/2<0,w=y?U<F?U-F:U-z:0;return{[d]:u[d]+w,data:{[d]:q,centerOffset:U-q-w,...y&&{alignmentOffset:w}},reset:y}}});function ZP(t,e,i){return(t?[...i.filter(s=>Ie(s)===t),...i.filter(s=>Ie(s)!==t)]:i.filter(s=>Ee(s)===s)).filter(s=>t?Ie(s)===t||(e?vs(s)!==s:!1):!0)}const GP=function(t){return t===void 0&&(t={}),{name:"autoPlacement",options:t,async fn(e){var i,n,s;const{rects:r,middlewareData:o,placement:a,platform:c,elements:l}=e,{crossAxis:f=!1,alignment:h,allowedPlacements:u=Sf,autoAlignment:d=!0,...p}=Ge(t,e),_=h!==void 0||u===Sf?ZP(h||null,d,u):u,m=await c.detectOverflow(e,p),b=((i=o.autoPlacement)==null?void 0:i.index)||0,A=_[b];if(A==null)return{};const v=tg(A,r,await(c.isRTL==null?void 0:c.isRTL(l.floating)));if(a!==A)return{reset:{placement:_[0]}};const S=[m[Ee(A)],m[v[0]],m[v[1]]],E=[...((n=o.autoPlacement)==null?void 0:n.overflows)||[],{placement:A,overflows:S}],x=_[b+1];if(x)return{data:{index:b+1,overflows:E},reset:{placement:x}};const M=E.map(D=>{const B=Ie(D.placement);return[D.placement,B&&f?D.overflows.slice(0,2).reduce((F,z)=>F+z,0):D.overflows[0],D.overflows]}).sort((D,B)=>D[1]-B[1]),N=((s=M.filter(D=>D[2].slice(0,Ie(D[0])?2:3).every(B=>B<=0))[0])==null?void 0:s[0])||M[0][0];return N!==a?{data:{index:b+1,overflows:E},reset:{placement:N}}:{}}}},QP=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var i,n;const{placement:s,middlewareData:r,rects:o,initialPlacement:a,platform:c,elements:l}=e,{mainAxis:f=!0,crossAxis:h=!0,fallbackPlacements:u,fallbackStrategy:d="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:_=!0,...m}=Ge(t,e);if((i=r.arrow)!=null&&i.alignmentOffset)return{};const b=Ee(s),A=We(a),v=Ee(a)===a,S=await(c.isRTL==null?void 0:c.isRTL(l.floating)),E=u||(v||!_?[Ts(a)]:zP(a)),x=p!=="none";!u&&x&&E.push(...jP(a,_,p,S));const M=[a,...E],O=await c.detectOverflow(e,m),N=[];let D=((n=r.flip)==null?void 0:n.overflows)||[];if(f&&N.push(O[b]),h){const U=tg(s,o,S);N.push(O[U[0]],O[U[1]])}if(D=[...D,{placement:s,overflows:N}],!N.every(U=>U<=0)){var B,F;const U=(((B=r.flip)==null?void 0:B.index)||0)+1,q=M[U];if(q&&(!(h==="alignment"?A!==We(q):!1)||D.every(T=>We(T.placement)===A?T.overflows[0]>0:!0)))return{data:{index:U,overflows:D},reset:{placement:q}};let y=(F=D.filter(w=>w.overflows[0]<=0).sort((w,T)=>w.overflows[1]-T.overflows[1])[0])==null?void 0:F.placement;if(!y)switch(d){case"bestFit":{var z;const w=(z=D.filter(T=>{if(x){const P=We(T.placement);return P===A||P==="y"}return!0}).map(T=>[T.placement,T.overflows.filter(P=>P>0).reduce((P,C)=>P+C,0)]).sort((T,P)=>T[1]-P[1])[0])==null?void 0:z[0];w&&(y=w);break}case"initialPlacement":y=a;break}if(s!==y)return{reset:{placement:y}}}return{}}}};function Rf(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function Cf(t){return Jd.some(e=>t[e]>=0)}const JP=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:i,platform:n}=e,{strategy:s="referenceHidden",...r}=Ge(t,e);switch(s){case"referenceHidden":{const o=await n.detectOverflow(e,{...r,elementContext:"reference"}),a=Rf(o,i.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:Cf(a)}}}case"escaped":{const o=await n.detectOverflow(e,{...r,altBoundary:!0}),a=Rf(o,i.floating);return{data:{escapedOffsets:a,escaped:Cf(a)}}}default:return{}}}}};function ig(t){const e=Xe(...t.map(r=>r.left)),i=Xe(...t.map(r=>r.top)),n=pe(...t.map(r=>r.right)),s=pe(...t.map(r=>r.bottom));return{x:e,y:i,width:n-e,height:s-i}}function eR(t){const e=t.slice().sort((s,r)=>s.y-r.y),i=[];let n=null;for(let s=0;s<e.length;s++){const r=e[s];!n||r.y-n.y>n.height/2?i.push([r]):i[i.length-1].push(r),n=r}return i.map(s=>hi(ig(s)))}const tR=function(t){return t===void 0&&(t={}),{name:"inline",options:t,async fn(e){const{placement:i,elements:n,rects:s,platform:r,strategy:o}=e,{padding:a=2,x:c,y:l}=Ge(t,e),f=Array.from(await(r.getClientRects==null?void 0:r.getClientRects(n.reference))||[]),h=eR(f),u=hi(ig(f)),d=Wa(a);function p(){if(h.length===2&&h[0].left>h[1].right&&c!=null&&l!=null)return h.find(m=>c>m.left-d.left&&c<m.right+d.right&&l>m.top-d.top&&l<m.bottom+d.bottom)||u;if(h.length>=2){if(We(i)==="y"){const D=h[0],B=h[h.length-1],F=Ee(i)==="top",z=D.top,U=B.bottom,q=F?D.left:B.left,y=F?D.right:B.right,w=y-q,T=U-z;return{top:z,bottom:U,left:q,right:y,width:w,height:T,x:q,y:z}}const m=Ee(i)==="left",b=pe(...h.map(D=>D.right)),A=Xe(...h.map(D=>D.left)),v=h.filter(D=>m?D.left===A:D.right===b),S=v[0].top,E=v[v.length-1].bottom,x=A,M=b,O=M-x,N=E-S;return{top:S,bottom:E,left:x,right:M,width:O,height:N,x,y:S}}return u}const _=await r.getElementRects({reference:{getBoundingClientRect:p},floating:n.floating,strategy:o});return s.reference.x!==_.reference.x||s.reference.y!==_.reference.y||s.reference.width!==_.reference.width||s.reference.height!==_.reference.height?{reset:{rects:_}}:{}}}},iR=new Set(["left","top"]);async function nR(t,e){const{placement:i,platform:n,elements:s}=t,r=await(n.isRTL==null?void 0:n.isRTL(s.floating)),o=Ee(i),a=Ie(i),c=We(i)==="y",l=iR.has(o)?-1:1,f=r&&c?-1:1,h=Ge(e,t);let{mainAxis:u,crossAxis:d,alignmentAxis:p}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}
vendor: 4,089 bytes, line 2013
2013:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return a&&typeof p=="number"&&(d=a==="end"?p*-1:p),c?{x:d*f,y:u*l}:{x:u*l,y:d*f}}const sR=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var i,n;const{x:s,y:r,placement:o,middlewareData:a}=e,c=await nR(e,t);return o===((i=a.offset)==null?void 0:i.placement)&&(n=a.arrow)!=null&&n.alignmentOffset?{}:{x:s+c.x,y:r+c.y,data:{...c,placement:o}}}}},rR=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:i,y:n,placement:s,platform:r}=e,{mainAxis:o=!0,crossAxis:a=!1,limiter:c={fn:b=>{let{x:A,y:v}=b;return{x:A,y:v}}},...l}=Ge(t,e),f={x:i,y:n},h=await r.detectOverflow(e,l),u=We(Ee(s)),d=eg(u);let p=f[d],_=f[u];if(o){const b=d==="y"?"top":"left",A=d==="y"?"bottom":"right",v=p+h[b],S=p-h[A];p=Zo(v,p,S)}if(a){const b=u==="y"?"top":"left",A=u==="y"?"bottom":"right",v=_+h[b],S=_-h[A];_=Zo(v,_,S)}const m=c.fn({...e,[d]:p,[u]:_});return{...m,data:{x:m.x-i,y:m.y-n,enabled:{[d]:o,[u]:a}}}}}},oR=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var i,n;const{placement:s,rects:r,platform:o,elements:a}=e,{apply:c=()=>{},...l}=Ge(t,e),f=await o.detectOverflow(e,l),h=Ee(s),u=Ie(s),d=We(s)==="y",{width:p,height:_}=r.floating;let m,b;h==="top"||h==="bottom"?(m=h,b=u===(await(o.isRTL==null?void 0:o.isRTL(a.floating))?"start":"end")?"left":"right"):(b=h,m=u==="end"?"top":"bottom");const A=_-f.top-f.bottom,v=p-f.left-f.right,S=Xe(_-f[m],A),E=Xe(p-f[b],v),x=!e.middlewareData.shift;let M=S,O=E;if((i=e.middlewareData.shift)!=null&&i.enabled.x&&(O=v),(n=e.middlewareData.shift)!=null&&n.enabled.y&&(M=A),x&&!u){const D=pe(f.left,0),B=pe(f.right,0),F=pe(f.top,0),z=pe(f.bottom,0);d?O=p-2*(D!==0||B!==0?D+B:pe(f.left,f.right)):M=_-2*(F!==0||z!==0?F+z:pe(f.top,f.bottom))}await c({...e,availableWidth:O,availableHeight:M});const N=await o.getDimensions(a.floating);return p!==N.width||_!==N.height?{reset:{rects:!0}}:{}}}};function Qs(){return typeof window<"u"}function yi(t){return ng(t)?(t.nodeName||"").toLowerCase():"#document"}function Te(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Qe(t){var e;return(e=(ng(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function ng(t){return Qs()?t instanceof Node||t instanceof Te(t).Node:!1}function De(t){return Qs()?t instanceof Element||t instanceof Te(t).Element:!1}function Je(t){return Qs()?t instanceof HTMLElement||t instanceof Te(t).HTMLElement:!1}function Mf(t){return!Qs()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Te(t).ShadowRoot}function ln(t){const{overflow:e,overflowX:i,overflowY:n,display:s}=Be(t);return/auto|scroll|overlay|hidden|clip/.test(e+n+i)&&s!=="inline"&&s!=="contents"}function aR(t){return/^(table|td|th)$/.test(yi(t))}function Js(t){try{if(t.matches(":popover-open"))return!0}catch{}try{return t.matches(":modal")}catch{return!1}}const cR=/transform|translate|scale|rotate|perspective|filter/,lR=/paint|layout|strict|content/,mt=t=>!!t&&t!=="none";let $r;function Va(t){const e=De(t)?Be(t):t;return mt(e.transform)||mt(e.translate)||mt(e.scale)||mt(e.rotate)||mt(e.perspective)||!$a()&&(mt(e.backdropFilter)||mt(e.filter))||cR.test(e.willChange||"")||lR.test(e.contain||"")}function fR(t){let e=pt(t);for(;Je(e)&&!ui(e);){if(Va(e))return e;if(Js(e))return null;e=pt(e)}return null}function $a(){return $r==null&&($r=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),$r}function ui(t){return/^(html|body|#document)$/.test(yi(t))}function Be(t){return Te(t).getComputedStyle(t)}function er(t){return De(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function pt(t){if(yi(t)==="html")return t;const e=t.assignedSlot||t.parentNode||Mf(t)&&t.host||Qe(t);return Mf(e)?e.host:e}function sg(t){const e=pt(t);return ui(e)?t.ownerDocument?t.ownerDocument.body:t.body:Je(e)&&ln(e)?e:sg(e)}function rg(t,e,i){var n;e===void 0&&(e=[]);const s=sg(t),r=s===((n=t.ownerDocument)==null?void 0:n.body),o=Te(s);
vendor: 4,286 bytes, line 2013
2013return r?(Go(o),e.concat(o,o.visualViewport||[],ln(s)?s:[],[])):e.concat(s,rg(s,[]))}function Go(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function og(t){const e=Be(t);let i=parseFloat(e.width)||0,n=parseFloat(e.height)||0;const s=Je(t),r=s?t.offsetWidth:i,o=s?t.offsetHeight:n,a=bs(i)!==r||bs(n)!==o;return a&&(i=r,n=o),{width:i,height:n,$:a}}function ag(t){return De(t)?t:t.contextElement}function ti(t){const e=ag(t);if(!Je(e))return $e(1);const i=e.getBoundingClientRect(),{width:n,height:s,$:r}=og(e);let o=(r?bs(i.width):i.width)/n,a=(r?bs(i.height):i.height)/s;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}const hR=$e(0);function cg(t){const e=Te(t);return!$a()||!e.visualViewport?hR:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function uR(t,e,i){return e===void 0&&(e=!1),!i||e&&i!==Te(t)?!1:e}function Qi(t,e,i,n){e===void 0&&(e=!1),i===void 0&&(i=!1);const s=t.getBoundingClientRect(),r=ag(t);let o=$e(1);e&&(n?De(n)&&(o=ti(n)):o=ti(t));const a=uR(r,i,n)?cg(r):$e(0);let c=(s.left+a.x)/o.x,l=(s.top+a.y)/o.y,f=s.width/o.x,h=s.height/o.y;if(r){const u=Te(r),d=n&&De(n)?Te(n):n;let p=u,_=Go(p);for(;_&&n&&d!==p;){const m=ti(_),b=_.getBoundingClientRect(),A=Be(_),v=b.left+(_.clientLeft+parseFloat(A.paddingLeft))*m.x,S=b.top+(_.clientTop+parseFloat(A.paddingTop))*m.y;c*=m.x,l*=m.y,f*=m.x,h*=m.y,c+=v,l+=S,p=Te(_),_=Go(p)}}return hi({width:f,height:h,x:c,y:l})}function tr(t,e){const i=er(t).scrollLeft;return e?e.left+i:Qi(Qe(t)).left+i}function lg(t,e){const i=t.getBoundingClientRect(),n=i.left+e.scrollLeft-tr(t,i),s=i.top+e.scrollTop;return{x:n,y:s}}function dR(t){let{elements:e,rect:i,offsetParent:n,strategy:s}=t;const r=s==="fixed",o=Qe(n),a=e?Js(e.floating):!1;if(n===o||a&&r)return i;let c={scrollLeft:0,scrollTop:0},l=$e(1);const f=$e(0),h=Je(n);if((h||!h&&!r)&&((yi(n)!=="body"||ln(o))&&(c=er(n)),h)){const d=Qi(n);l=ti(n),f.x=d.x+n.clientLeft,f.y=d.y+n.clientTop}const u=o&&!h&&!r?lg(o,c):$e(0);return{width:i.width*l.x,height:i.height*l.y,x:i.x*l.x-c.scrollLeft*l.x+f.x+u.x,y:i.y*l.y-c.scrollTop*l.y+f.y+u.y}}function gR(t){return Array.from(t.getClientRects())}function pR(t){const e=Qe(t),i=er(t),n=t.ownerDocument.body,s=pe(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),r=pe(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let o=-i.scrollLeft+tr(t);const a=-i.scrollTop;return Be(n).direction==="rtl"&&(o+=pe(e.clientWidth,n.clientWidth)-s),{width:s,height:r,x:o,y:a}}const Of=25;function _R(t,e){const i=Te(t),n=Qe(t),s=i.visualViewport;let r=n.clientWidth,o=n.clientHeight,a=0,c=0;if(s){r=s.width,o=s.height;const f=$a();(!f||f&&e==="fixed")&&(a=s.offsetLeft,c=s.offsetTop)}const l=tr(n);if(l<=0){const f=n.ownerDocument,h=f.body,u=getComputedStyle(h),d=f.compatMode==="CSS1Compat"&&parseFloat(u.marginLeft)+parseFloat(u.marginRight)||0,p=Math.abs(n.clientWidth-h.clientWidth-d);p<=Of&&(r-=p)}else l<=Of&&(r+=l);return{width:r,height:o,x:a,y:c}}function mR(t,e){const i=Qi(t,!0,e==="fixed"),n=i.top+t.clientTop,s=i.left+t.clientLeft,r=Je(t)?ti(t):$e(1),o=t.clientWidth*r.x,a=t.clientHeight*r.y,c=s*r.x,l=n*r.y;return{width:o,height:a,x:c,y:l}}function If(t,e,i){let n;if(e==="viewport")n=_R(t,i);else if(e==="document")n=pR(Qe(t));else if(De(e))n=mR(e,i);else{const s=cg(t);n={x:e.x-s.x,y:e.y-s.y,width:e.width,height:e.height}}return hi(n)}function fg(t,e){const i=pt(t);return i===e||!De(i)||ui(i)?!1:Be(i).position==="fixed"||fg(i,e)}function yR(t,e){const i=e.get(t);if(i)return i;let n=rg(t,[]).filter(a=>De(a)&&yi(a)!=="body"),s=null;const r=Be(t).position==="fixed";let o=r?pt(t):t;for(;De(o)&&!ui(o);){const a=Be(o),c=Va(o);!c&&a.position==="fixed"&&(s=null),(r?!c&&!s:!c&&a.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||ln(o)&&!c&&fg(t,o))?n=n.filter(f=>f!==o):s=a,o=pt(o)}return e.set(t,n),n}function bR(t){let{element:e,boundary:i,rootBoundary:n,strategy:s}=t;const o=[...i==="clippingAncestors"?Js(e)?[]:yR(e,this._c):[].concat(i),n],a=If(e,o[0],s);let c=a.top,l=a.right,f=a.bottom,h=a.left;for(let u=1;u<o.length;u++){const d=If(e,o[u],s);c=pe(d.top,c),l=Xe(d.right,l),f=Xe(d.bottom,f),h=pe(d.left,h)}return{width:l-h,height:f-c,x:h,y:c}}function vR(t){const{width:e,height:i}=og(t);return{width:e,height:i}}
2013function TR(t,e,i){const n=Je(e),s=Qe(e),r=i==="fixed",o=Qi(t,!0,r,e);let a={scrollLeft:0,scrollTop:0};const c=$e(0);function l(){c.x=tr(s)}if(n||!n&&!r)if((yi(e)!=="body"||ln(s))&&(a=er(e)),n){const d=Qi(e,!0,r,e);c.x=d.x+e.clientLeft,c.y=d.y+e.clientTop}else s&&l();r&&!n&&s&&l();const f=s&&!n&&!r?lg(s,a):$e(0),h=o.left+a.scrollLeft-c.x-f.x,u=o.top+a.scrollTop-c.y-f.y;return{x:h,y:u,width:o.width,height:o.height}}function jr(t){return Be(t).position==="static"}function Nf(t,e){if(!Je(t)||Be(t).position==="fixed")return null;if(e)return e(t);let i=t.offsetParent;return Qe(t)===i&&(i=i.ownerDocument.body),i}function hg(t,e){const i=Te(t);if(Js(t))return i;if(!Je(t)){let s=pt(t);for(;s&&!ui(s);){if(De(s)&&!jr(s))return s;s=pt(s)}return i}let n=Nf(t,e);for(;n&&aR(n)&&jr(n);)n=Nf(n,e);return n&&ui(n)&&jr(n)&&!Va(n)?i:n||fR(t)||i}const AR=async function(t){const e=this.getOffsetParent||hg,i=this.getDimensions,n=await i(t.floating);return{reference:TR(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function wR(t){return Be(t).direction==="rtl"}const SR={convertOffsetParentRelativeRectToViewportRelativeRect:dR,getDocumentElement:Qe,getClippingRect:bR,getOffsetParent:hg,getElementRects:AR,getClientRects:gR,getDimensions:vR,getScale:ti,isElement:De,isRTL:wR},k2=sR,U2=GP,z2=rR,W2=QP,V2=oR,$2=JP,j2=qP,H2=tR,X2=(t,e,i)=>{const n=new Map,s={platform:SR,...i},r={...s.platform,_c:n};return KP(t,e,{...s,platform:r})},ER=new Uint32Array([0,2,1,0,3,2]),xR=new Float32Array([0,1,0,0,1,0,1,1]);function PR(t,e){if(!e)return RR(t);const i=Math.max(Math.abs(t[0][0]-t[3][0]),Math.abs(t[1][0]-t[2][0])),n=Math.max(Math.abs(t[1][1]-t[0][1]),Math.abs(t[2][1]-t[3][1])),s=Math.ceil(i/e)+1,r=Math.ceil(n/e)+1,o=(s-1)*(r-1)*6,a=new Uint32Array(o),c=new Float32Array(s*r*2),l=new Float64Array(s*r*3);let f=0,h=0;for(let u=0;u<s;u++){const d=u/(s-1);for(let p=0;p<r;p++){const _=p/(r-1),m=CR(t,d,_);l[f*3+0]=m[0],l[f*3+1]=m[1],l[f*3+2]=m[2]||0,c[f*2+0]=d,c[f*2+1]=1-_,u>0&&p>0&&(a[h++]=f-r,a[h++]=f-r-1,a[h++]=f-1,a[h++]=f-r,a[h++]=f-1,a[h++]=f),f++}}return{vertexCount:o,positions:l,indices:a,texCoords:c}}function RR(t){const e=new Float64Array(12);for(let i=0;i<t.length;i++)e[i*3+0]=t[i][0],e[i*3+1]=t[i][1],e[i*3+2]=t[i][2]||0;return{vertexCount:6,positions:e,indices:ER,texCoords:xR}}function CR(t,e,i){return wt(wt(t[0],t[1],i),wt(t[3],t[2],i),e)}const Lf=`layout(std140) uniform bitmapUniforms { 2014 vec4 bounds; 2015 float coordinateConversion; 2016 float desaturate; 2017 vec3 tintColor; 2018 vec4 transparentColor; 2019} bitmap; 2020`,MR={name:"bitmap",vs:Lf,fs:Lf,uniformTypes:{bounds:"vec4<f32>",coordinateConversion:"f32",desaturate:"f32",tintColor:"vec3<f32>",transparentColor:"vec4<f32>"}},OR=`#version 300 es 2021#define SHADER_NAME bitmap-layer-vertex-shader 2022 2023in vec2 texCoords; 2024in vec3 positions; 2025in vec3 positions64Low; 2026 2027out vec2 vTexCoord; 2028out vec2 vTexPos; 2029 2030const vec3 pickingColor = vec3(1.0, 0.0, 0.0); 2031 2032void main(void) { 2033 geometry.worldPosition = positions; 2034 geometry.uv = texCoords; 2035 geometry.pickingColor = pickingColor; 2036 2037 gl_Position = project_position_to_clipspace(positions, positions64Low, vec3(0.0), geometry.position); 2038 DECKGL_FILTER_GL_POSITION(gl_Position, geometry); 2039 2040 vTexCoord = texCoords; 2041 2042 if (bitmap.coordinateConversion < -0.5) { 2043 vTexPos = geometry.position.xy + project.commonOrigin.xy; 2044 } else if (bitmap.coordinateConversion > 0.5) { 2045 vTexPos = geometry.worldPosition.xy; 2046 } 2047 2048 vec4 color = vec4(0.0); 2049 DECKGL_FILTER_COLOR(color, geometry); 2050} 2051`,IR=` 2052vec3 packUVsIntoRGB(vec2 uv) { 2053 // Extract the top 8 bits. We want values to be truncated down so we can add a fraction 2054 vec2 uv8bit = floor(uv * 256.); 2055 2056 // Calculate the normalized remainders of u and v parts that do not fit into 8 bits 2057 // Scale and clamp to 0-1 range 2058 vec2 uvFraction = fract(uv * 256.); 2059 vec2 uvFraction4bit = floor(uvFraction * 16.); 2060 2061 // Remainder can be encoded in blue channel, encode as 4 bits for pixel coordinates 2062 float fractions = uvFraction4bit.x + uvFraction4bit.y * 16.; 2063 2064 return vec3(uv8bit, fractions) / 255.; 2065} 2066`,NR=`#version 300 es 2067#define SHADER_NAME bitmap-layer-fragment-shader 2068 2069#ifdef GL_ES 2070precision highp float; 2071#endif 2072 2073uniform sampler2D bitmapTexture; 2074 2075in vec2 vTexCoord; 2076in vec2 vTexPos; 2077 2078out vec4 fragColor; 2079 2080/* projection utils */ 2081const float TILE_SIZE = 512.0; 2082const float PI = 3.1415926536; 2083const float WORLD_SCALE = TILE_SIZE / PI / 2.0; 2084 2085// from degrees to Web Mercator 2086vec2 lnglat_to_mercator(vec2 lnglat) { 2087 float x = lnglat.x; 2088 float y = clamp(lnglat.y, -89.9, 89.9); 2089 return vec2( 2090 radians(x) + PI, 2091 PI + log(tan(PI * 0.25 + radians(y) * 0.5)) 2092 ) * WORLD_SCALE; 2093} 2094 2095// from Web Mercator to degrees 2096vec2 mercator_to_lnglat(vec2 xy) { 2097 xy /= WORLD_SCALE; 2098 return degrees(vec2( 2099 xy.x - PI, 2100 atan(exp(xy.y - PI)) * 2.0 - PI * 0.5 2101 )); 2102} 2103/* End projection utils */ 2104 2105// apply desaturation 2106vec3 color_desaturate(vec3 color) { 2107 float luminance = (color.r + color.g + color.b) * 0.333333333; 2108 return mix(color, vec3(luminance), bitmap.desaturate); 2109} 2110 2111// apply tint
2112vec3 color_tint(vec3 color) { 2113 return color * bitmap.tintColor; 2114} 2115 2116// blend with background color 2117vec4 apply_opacity(vec3 color, float alpha) { 2118 if (bitmap.transparentColor.a == 0.0) { 2119 return vec4(color, alpha); 2120 } 2121 float blendedAlpha = alpha + bitmap.transparentColor.a * (1.0 - alpha); 2122 float highLightRatio = alpha / blendedAlpha; 2123 vec3 blendedRGB = mix(bitmap.transparentColor.rgb, color, highLightRatio); 2124 return vec4(blendedRGB, blendedAlpha); 2125} 2126 2127vec2 getUV(vec2 pos) { 2128 return vec2( 2129 (pos.x - bitmap.bounds[0]) / (bitmap.bounds[2] - bitmap.bounds[0]), 2130 (pos.y - bitmap.bounds[3]) / (bitmap.bounds[1] - bitmap.bounds[3]) 2131 ); 2132} 2133 2134${IR} 2135 2136void main(void) { 2137 vec2 uv = vTexCoord; 2138 if (bitmap.coordinateConversion < -0.5) { 2139 vec2 lnglat = mercator_to_lnglat(vTexPos); 2140 uv = getUV(lnglat); 2141 } else if (bitmap.coordinateConversion > 0.5) { 2142 vec2 commonPos = lnglat_to_mercator(vTexPos); 2143 uv = getUV(commonPos); 2144 } 2145 vec4 bitmapColor = texture(bitmapTexture, uv); 2146 2147 fragColor = apply_opacity(color_tint(color_desaturate(bitmapColor.rgb)), bitmapColor.a * layer.opacity); 2148 2149 geometry.uv = uv; 2150 DECKGL_FILTER_COLOR(fragColor, geometry); 2151 2152 if (bool(picking.isActive) && !bool(picking.isAttribute)) { 2153 // Since instance information is not used, we can use picking color for pixel index 2154 fragColor.rgb = packUVsIntoRGB(uv); 2155 } 2156} 2157`,LR={image:{type:"image",value:null,async:!0},bounds:{type:"array",value:[1,0,0,1],compare:!0},_imageCoordinateSystem:"default",desaturate:{type:"number",min:0,max:1,value:0},transparentColor:{type:"color",value:[0,0,0,0]},tintColor:{type:"color",value:[255,255,255]},textureParameters:{type:"object",ignore:!0,value:null}};class ug extends Fe{getShaders(){return super.getShaders({vs:OR,fs:NR,modules:[kt,Ut,MR]})}initializeState(){const e=this.getAttributeManager();e.remove(["instancePickingColors"]);const i=!0;e.add({indices:{size:1,isIndexed:!0,update:n=>n.value=this.state.mesh.indices,noAlloc:i},positions:{size:3,type:"float64",fp64:this.use64bitPositions(),update:n=>n.value=this.state.mesh.positions,noAlloc:i},texCoords:{size:2,update:n=>n.value=this.state.mesh.texCoords,noAlloc:i}})}updateState({props:e,oldProps:i,changeFlags:n}){var r;const s=this.getAttributeManager();if(n.extensionsChanged&&((r=this.state.model)==null||r.destroy(),this.state.model=this._getModel(),s.invalidateAll()),e.bounds!==i.bounds){const o=this.state.mesh,a=this._createMesh();this.state.model.setVertexCount(a.vertexCount);for(const c in a)o&&o[c]!==a[c]&&s.invalidate(c);this.setState({mesh:a,...this._getCoordinateUniforms()})}else e._imageCoordinateSystem!==i._imageCoordinateSystem&&this.setState(this._getCoordinateUniforms())}getPickingInfo(e){const{image:i}=this.props,n=e.info;if(!n.color||!i)return n.bitmap=null,n;const{width:s,height:r}=i;n.index=0;const o=DR(n.color);return n.bitmap={size:{width:s,height:r},uv:o,pixel:[Math.floor(o[0]*s),Math.floor(o[1]*r)]},n}disablePickingIndex(){this.setState({disablePicking:!0})}restorePickingColors(){this.setState({disablePicking:!1})}_updateAutoHighlight(e){super._updateAutoHighlight({...e,color:this.encodePickingColor(0)})}_createMesh(){const{bounds:e}=this.props;let i=e;return Df(e)&&(i=[[e[0],e[1]],[e[0],e[3]],[e[2],e[3]],[e[2],e[1]]]),PR(i,this.context.viewport.resolution)}_getModel(){return new ve(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),topology:"triangle-list",isInstanced:!1})}draw(e){const{shaderModuleProps:i}=e,{model:n,coordinateConversion:s,bounds:r,disablePicking:o}=this.state,{image:a,desaturate:c,transparentColor:l,tintColor:f}=this.props;if(!(i.picking.isActive&&o)&&a&&n){const h={bitmapTexture:a,bounds:r,coordinateConversion:s,desaturate:c,tintColor:f.slice(0,3).map(u=>u/255),transparentColor:l.map(u=>u/255)};n.shaderInputs.setProps({bitmap:h}),n.draw(this.context.renderPass)}}_getCoordinateUniforms(){let{_imageCoordinateSystem:e}=this.props;if(e!=="default"){const{bounds:i}=this.props;if(!Df(i))throw new Error("_imageCoordinateSystem only supports rectangular bounds");const n=this.context.viewport.resolution?"lnglat":"cartesian";if(e=e==="lnglat"?"lnglat":"cartesian",e==="lnglat"&&n==="cartesian")return{coordinateConversion:-1,bounds:i};if(e==="cartesian"&&n==="lnglat"){const s=gt([i[0],i[1]]),r=gt([i[2],i[3]]);return{coordinateConversion:1,bounds:[s[0],s[1],r[0],r[1]]}}}return{coordinateConversion:0,bounds:[0,0,0,0]}}}ug.layerName="BitmapLayer";ug.defaultProps=LR;function DR(t){const[e,i,n]=t,s=(n&240)/256,r=(n&15)/16;return[(e+r)/256,(i+s)/256]}function Df(t){return Number.isFinite(t[0])}const Bf=`layout(std140) uniform iconUniforms { 2158 float sizeScale; 2159 vec2 iconsTextureDim; 2160 float sizeBasis;
2161 float sizeMinPixels; 2162 float sizeMaxPixels; 2163 bool billboard; 2164 highp int sizeUnits; 2165 float alphaCutoff; 2166} icon; 2167`,BR={name:"icon",vs:Bf,fs:Bf,uniformTypes:{sizeScale:"f32",iconsTextureDim:"vec2<f32>",sizeBasis:"f32",sizeMinPixels:"f32",sizeMaxPixels:"f32",billboard:"f32",sizeUnits:"i32",alphaCutoff:"f32"}},FR=`#version 300 es 2168#define SHADER_NAME icon-layer-vertex-shader 2169in vec2 positions; 2170in vec3 instancePositions; 2171in vec3 instancePositions64Low; 2172in float instanceSizes; 2173in float instanceAngles; 2174in vec4 instanceColors; 2175in vec3 instancePickingColors; 2176in vec4 instanceIconFrames; 2177in float instanceColorModes; 2178in vec2 instanceOffsets; 2179in vec2 instancePixelOffset; 2180out float vColorMode; 2181out vec4 vColor; 2182out vec2 vTextureCoords; 2183out vec2 uv; 2184vec2 rotate_by_angle(vec2 vertex, float angle) { 2185float angle_radian = angle * PI / 180.0; 2186float cos_angle = cos(angle_radian); 2187float sin_angle = sin(angle_radian); 2188mat2 rotationMatrix = mat2(cos_angle, -sin_angle, sin_angle, cos_angle); 2189return rotationMatrix * vertex; 2190} 2191void main(void) { 2192geometry.worldPosition = instancePositions; 2193geometry.uv = positions; 2194geometry.pickingColor = instancePickingColors; 2195uv = positions; 2196vec2 iconSize = instanceIconFrames.zw; 2197float sizePixels = clamp( 2198project_size_to_pixel(instanceSizes * icon.sizeScale, icon.sizeUnits),
2199icon.sizeMinPixels, icon.sizeMaxPixels 2200); 2201float iconConstraint = icon.sizeBasis == 0.0 ? iconSize.x : iconSize.y; 2202float instanceScale = iconConstraint == 0.0 ? 0.0 : sizePixels / iconConstraint; 2203vec2 pixelOffset = positions / 2.0 * iconSize + instanceOffsets; 2204pixelOffset = rotate_by_angle(pixelOffset, instanceAngles) * instanceScale; 2205pixelOffset += instancePixelOffset; 2206pixelOffset.y *= -1.0; 2207if (icon.billboard) { 2208gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position); 2209DECKGL_FILTER_GL_POSITION(gl_Position, geometry); 2210vec3 offset = vec3(pixelOffset, 0.0); 2211DECKGL_FILTER_SIZE(offset, geometry); 2212gl_Position.xy += project_pixel_size_to_clipspace(offset.xy); 2213} else { 2214vec3 offset_common = vec3(project_pixel_size(pixelOffset), 0.0); 2215DECKGL_FILTER_SIZE(offset_common, geometry); 2216gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset_common, geometry.position); 2217DECKGL_FILTER_GL_POSITION(gl_Position, geometry); 2218} 2219vTextureCoords = mix( 2220instanceIconFrames.xy, 2221instanceIconFrames.xy + iconSize, 2222(positions.xy + 1.0) / 2.0 2223) / icon.iconsTextureDim; 2224vColor = instanceColors; 2225DECKGL_FILTER_COLOR(vColor, geometry); 2226vColorMode = instanceColorModes; 2227} 2228`,kR=`#version 300 es 2229#define SHADER_NAME icon-layer-fragment-shader 2230precision highp float; 2231uniform sampler2D iconsTexture; 2232in float vColorMode; 2233in vec4 vColor; 2234in vec2 vTextureCoords; 2235in vec2 uv; 2236out vec4 fragColor; 2237void main(void) { 2238geometry.uv = uv; 2239vec4 texColor = texture(iconsTexture, vTextureCoords); 2240vec3 color = mix(texColor.rgb, vColor.rgb, vColorMode); 2241float a = texColor.a * layer.opacity * vColor.a; 2242if (a < icon.alphaCutoff) { 2243discard; 2244} 2245fragColor = vec4(color, a); 2246DECKGL_FILTER_COLOR(fragColor, geometry); 2247} 2248`,UR=`struct IconUniforms { 2249 sizeScale: f32, 2250 iconsTextureDim: vec2<f32>, 2251 sizeBasis: f32, 2252 sizeMinPixels: f32, 2253 sizeMaxPixels: f32, 2254 billboard: i32, 2255 sizeUnits: i32, 2256 alphaCutoff: f32 2257}; 2258 2259@group(0) @binding(auto) var<uniform> icon: IconUniforms; 2260@group(0) @binding(auto) var iconsTexture : texture_2d<f32>; 2261@group(0) @binding(auto) var iconsTextureSampler : sampler; 2262 2263fn rotate_by_angle(vertex: vec2<f32>, angle_deg: f32) -> vec2<f32> { 2264 let angle_radian = angle_deg * PI / 180.0; 2265 let c = cos(angle_radian); 2266 let s = sin(angle_radian); 2267 let rotation = mat2x2<f32>(vec2<f32>(c, s), vec2<f32>(-s, c)); 2268 return rotation * vertex; 2269} 2270 2271struct Attributes { 2272 @location(0) positions: vec2<f32>, 2273 2274 @location(1) instancePositions: vec3<f32>, 2275 @location(2) instancePositions64Low: vec3<f32>, 2276 @location(3) instanceSizes: f32, 2277 @location(4) instanceAngles: f32, 2278 @location(5) instanceColors: vec4<f32>, 2279 @location(6) instancePickingColors: vec3<f32>, 2280 @location(7) instanceIconFrames: vec4<f32>, 2281 @location(8) instanceColorModes: f32, 2282 @location(9) instanceOffsets: vec2<f32>, 2283 @location(10) instancePixelOffset: vec2<f32>, 2284}; 2285 2286struct Varyings { 2287 @builtin(position) position: vec4<f32>, 2288 2289 @location(0) vColorMode: f32, 2290 @location(1) vColor: vec4<f32>, 2291 @location(2) vTextureCoords: vec2<f32>, 2292 @location(3) uv: vec2<f32>, 2293 @location(4) pickingColor: vec3<f32>, 2294}; 2295 2296@vertex 2297fn vertexMain(inp: Attributes) -> Varyings { 2298 // write geometry fields used by filters + FS 2299 geometry.worldPosition = inp.instancePositions; 2300 geometry.uv = inp.positions; 2301 geometry.pickingColor = inp.instancePickingColors; 2302 2303 var outp: Varyings; 2304 outp.uv = inp.positions; 2305 2306 let iconSize = inp.instanceIconFrames.zw; 2307 2308 // convert size in meters to pixels, then clamp 2309 let sizePixels = clamp( 2310 project_unit_size_to_pixel(inp.instanceSizes * icon.sizeScale, icon.sizeUnits),
2311 icon.sizeMinPixels, icon.sizeMaxPixels 2312 ); 2313 2314 // scale icon height to match instanceSize 2315 let iconConstraint = select(iconSize.y, iconSize.x, icon.sizeBasis == 0.0); 2316 let instanceScale = select(sizePixels / iconConstraint, 0.0, iconConstraint == 0.0); 2317 2318 // scale and rotate vertex in "pixel" units; then add per-instance pixel offset 2319 var pixelOffset = inp.positions / 2.0 * iconSize + inp.instanceOffsets; 2320 pixelOffset = rotate_by_angle(pixelOffset, inp.instanceAngles) * instanceScale; 2321 pixelOffset = pixelOffset + inp.instancePixelOffset; 2322 pixelOffset.y = pixelOffset.y * -1.0; 2323 2324 if (icon.billboard != 0) { 2325 var pos = project_position_to_clipspace(inp.instancePositions, inp.instancePositions64Low, vec3<f32>(0.0)); // TODO, &geometry.position); 2326 // DECKGL_FILTER_GL_POSITION(pos, geometry); 2327 2328 var offset = vec3<f32>(pixelOffset, 0.0); 2329 // DECKGL_FILTER_SIZE(offset, geometry); 2330 let clipOffset = project_pixel_size_to_clipspace(offset.xy); 2331 pos = vec4<f32>(pos.x + clipOffset.x, pos.y + clipOffset.y, pos.z, pos.w); 2332 outp.position = pos; 2333 } else { 2334 var offset_common = vec3<f32>(project_pixel_size_vec2(pixelOffset), 0.0); 2335 // DECKGL_FILTER_SIZE(offset_common, geometry); 2336 var pos = project_position_to_clipspace(inp.instancePositions, inp.instancePositions64Low, offset_common); // TODO, &geometry.position); 2337 // DECKGL_FILTER_GL_POSITION(pos, geometry); 2338 outp.position = pos; 2339 } 2340 2341 let uvMix = (inp.positions.xy + vec2<f32>(1.0, 1.0)) * 0.5; 2342 outp.vTextureCoords = mix(inp.instanceIconFrames.xy, inp.instanceIconFrames.xy + iconSize, uvMix) / icon.iconsTextureDim; 2343 2344 outp.vColor = inp.instanceColors; 2345 // DECKGL_FILTER_COLOR(outp.vColor, geometry); 2346 2347 outp.vColorMode = inp.instanceColorModes; 2348 outp.pickingColor = inp.instancePickingColors; 2349 2350 return outp; 2351} 2352 2353@fragment 2354fn fragmentMain(inp: Varyings) -> @location(0) vec4<f32> { 2355 // expose to deck.gl filter hooks 2356 geometry.uv = inp.uv; 2357 2358 let texColor = textureSample(iconsTexture, iconsTextureSampler, inp.vTextureCoords); 2359 2360 // if colorMode == 0, use pixel color from the texture 2361 // if colorMode == 1 (or picking), use texture as transparency mask 2362 let rgb = mix(texColor.rgb, inp.vColor.rgb, inp.vColorMode); 2363 let a = texColor.a * layer.opacity * inp.vColor.a; 2364 2365 if (a < icon.alphaCutoff) { 2366 discard; 2367 } 2368 2369 if (picking.isActive > 0.5) { 2370 if (!picking_isColorValid(inp.pickingColor)) { 2371 discard; 2372 } 2373 return vec4<f32>(inp.pickingColor, 1.0); 2374 } 2375 2376 var fragColor = deckgl_premultiplied_alpha(vec4<f32>(rgb, a)); 2377 2378 if (picking.isHighlightActive > 0.5) { 2379 let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor); 2380 if (picking_isColorZero(abs(inp.pickingColor - highlightedObjectColor))) { 2381 let highLightAlpha = picking.highlightColor.a; 2382 let blendedAlpha = highLightAlpha + fragColor.a * (1.0 - highLightAlpha); 2383 if (blendedAlpha > 0.0) { 2384 let highLightRatio = highLightAlpha / blendedAlpha; 2385 fragColor = vec4<f32>( 2386 mix(fragColor.rgb, picking.highlightColor.rgb, highLightRatio), 2387 blendedAlpha 2388 ); 2389 } else { 2390 fragColor = vec4<f32>(fragColor.rgb, 0.0); 2391 } 2392 } 2393 } 2394 2395 return fragColor; 2396} 2397`,zR=1024,WR=4,Ff=()=>{},kf={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},VR={x:0,y:0,width:0,height:0};function $R(t){return Math.pow(2,Math.ceil(Math.log2(t)))}function jR(t,e,i,n){const s=Math.min(i/e.width,n/e.height),r=Math.floor(e.width*s),o=Math.floor(e.height*s);return s===1?{image:e,width:r,height:o}:(t.canvas.height=o,t.canvas.width=r,t.clearRect(0,0,r,o),t.drawImage(e,0,0,e.width,e.height,0,0,r,o),{image:t.canvas,width:r,height:o})}function Ji(t){return t&&(t.id||t.url)}function dg(t){const{device:e}=t;e.type==="webgl"?t.generateMipmapsWebGL():e.type==="webgpu"&&e.generateMipmapsWebGPU(t)}function HR(t,e,i,n){const{width:s,height:r,device:o}=t,a=o.createTexture({format:"rgba8unorm",width:e,height:i,sampler:n,mipLevels:o.getMipLevelCount(e,i)}),c=o.createCommandEncoder();
2397c.copyTextureToTexture({sourceTexture:t,destinationTexture:a,width:s,height:r});const l=c.finish();return o.submit(l),dg(a),t.destroy(),a}function Uf(t,e,i){for(let n=0;n<e.length;n++){const{icon:s,xOffset:r}=e[n],o=Ji(s);t[o]={...s,x:r,y:i}}}function XR({icons:t,buffer:e,mapping:i={},xOffset:n=0,yOffset:s=0,rowHeight:r=0,canvasWidth:o}){let a=[];for(let c=0;c<t.length;c++){const l=t[c],f=Ji(l);if(!i[f]){const{height:h,width:u}=l;n+u+e>o&&(Uf(i,a,s),n=0,s=r+s+e,r=0,a=[]),a.push({icon:l,xOffset:n}),n=n+u+e,r=Math.max(r,h)}}return a.length>0&&Uf(i,a,s),{mapping:i,rowHeight:r,xOffset:n,yOffset:s,canvasWidth:o,canvasHeight:$R(r+s+e)}}function YR(t,e,i){if(!t||!e)return null;i=i||{};const n={},{iterable:s,objectInfo:r}=cn(t);for(const o of s){r.index++;const a=e(o,r),c=Ji(a);if(!a)throw new Error("Icon is missing.");if(!a.url)throw new Error("Icon url is missing.");!n[c]&&(!i[c]||a.url!==i[c].url)&&(n[c]={...a,source:o,sourceIndex:r.index})}return n}class KR{constructor(e,{onUpdate:i=Ff,onError:n=Ff}){this._loadOptions=null,this._texture=null,this._externalTexture=null,this._mapping={},this._samplerParameters=null,this._pendingCount=0,this._autoPacking=!1,this._xOffset=0,this._yOffset=0,this._rowHeight=0,this._buffer=WR,this._canvasWidth=zR,this._canvasHeight=0,this._canvas=null,this.device=e,this.onUpdate=i,this.onError=n}finalize(){var e;(e=this._texture)==null||e.delete()}getTexture(){return this._texture||this._externalTexture}getIconMapping(e){const i=this._autoPacking?Ji(e):e;return this._mapping[i]||VR}setProps({loadOptions:e,autoPacking:i,iconAtlas:n,iconMapping:s,textureParameters:r}){var o;e&&(this._loadOptions=e),i!==void 0&&(this._autoPacking=i),s&&(this._mapping=s),n&&((o=this._texture)==null||o.delete(),this._texture=null,this._externalTexture=n),r&&(this._samplerParameters=r)}get isLoaded(){return this._pendingCount===0}packIcons(e,i){if(!this._autoPacking||typeof document>"u")return;const n=Object.values(YR(e,i,this._mapping)||{});if(n.length>0){const{mapping:s,xOffset:r,yOffset:o,rowHeight:a,canvasHeight:c}=XR({icons:n,buffer:this._buffer,canvasWidth:this._canvasWidth,mapping:this._mapping,rowHeight:this._rowHeight,xOffset:this._xOffset,yOffset:this._yOffset});this._rowHeight=a,this._mapping=s,this._xOffset=r,this._yOffset=o,this._canvasHeight=c,this._texture||(this._texture=this.device.createTexture({format:"rgba8unorm",data:null,width:this._canvasWidth,height:this._canvasHeight,sampler:this._samplerParameters||kf,mipLevels:this.device.getMipLevelCount(this._canvasWidth,this._canvasHeight)})),this._texture.height!==this._canvasHeight&&(this._texture=HR(this._texture,this._canvasWidth,this._canvasHeight,this._samplerParameters||kf)),this.onUpdate(!0),this._canvas=this._canvas||document.createElement("canvas"),this._loadIcons(n)}}_loadIcons(e){const i=this._canvas.getContext("2d",{willReadFrequently:!0});for(const n of e)this._pendingCount++,is(n.url,this._loadOptions).then(s=>{var m;const r=Ji(n),o=this._mapping[r],{x:a,y:c,width:l,height:f}=o,{image:h,width:u,height:d}=jR(i,s,l,f),p=a+(l-u)/2,_=c+(f-d)/2;(m=this._texture)==null||m.copyExternalImage({image:h,x:p,y:_,width:u,height:d}),o.x=p,o.y=_,o.width=u,o.height=d,this._texture&&dg(this._texture),this.onUpdate(u!==l||d!==f)}).catch(s=>{this.onError({url:n.url,source:n.source,sourceIndex:n.sourceIndex,loadOptions:this._loadOptions,error:s})}).finally(()=>{this._pendingCount--})}}const gg=[0,0,0,255],qR={iconAtlas:{type:"image",value:null,async:!0},iconMapping:{type:"object",value:{},async:!0},sizeScale:{type:"number",value:1,min:0},billboard:!0,sizeUnits:"pixels",sizeBasis:"height",sizeMinPixels:{type:"number",min:0,value:0},sizeMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},alphaCutoff:{type:"number",value:.05,min:0,max:1},getPosition:{type:"accessor",value:t=>t.position},getIcon:{type:"accessor",value:t=>t.icon},getColor:{type:"accessor",value:gg},getSize:{type:"accessor",value:1},getAngle:{type:"accessor",value:0},getPixelOffset:{type:"accessor",value:[0,0]},onIconError:{type:"function",value:null,optional:!0},textureParameters:{type:"object",ignore:!0,value:null}};class ir extends Fe{getShaders(){return super.getShaders({vs:FR,fs:kR,source:UR,modules:[kt,wa,Ut,BR]})}initializeState(){this.state={iconManager:new KR(this.context.device,{onUp
2397date:this._onUpdate.bind(this),onError:this._onError.bind(this)})},this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceSizes:{size:1,transition:!0,accessor:"getSize",defaultValue:1},instanceIconDefs:{size:7,accessor:"getIcon",transform:this.getInstanceIconDef,shaderAttributes:{instanceOffsets:{size:2,elementOffset:0},instanceIconFrames:{size:4,elementOffset:2},instanceColorModes:{size:1,elementOffset:6}}},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getColor",defaultValue:gg},instanceAngles:{size:1,transition:!0,accessor:"getAngle"},instancePixelOffset:{size:2,transition:!0,accessor:"getPixelOffset"}})}updateState(e){var d;super.updateState(e);const{props:i,oldProps:n,changeFlags:s}=e,r=this.getAttributeManager(),{iconAtlas:o,iconMapping:a,data:c,getIcon:l,textureParameters:f}=i,{iconManager:h}=this.state;if(typeof o=="string")return;const u=o||this.internalState.isAsyncPropLoading("iconAtlas");h.setProps({loadOptions:i.loadOptions,autoPacking:!u,iconAtlas:o,iconMapping:u?a:null,textureParameters:f}),u?n.iconMapping!==i.iconMapping&&r.invalidate("getIcon"):(s.dataChanged||s.updateTriggersChanged&&(s.updateTriggersChanged.all||s.updateTriggersChanged.getIcon))&&h.packIcons(c,l),s.extensionsChanged&&((d=this.state.model)==null||d.destroy(),this.state.model=this._getModel(),r.invalidateAll())}get isLoaded(){return super.isLoaded&&this.state.iconManager.isLoaded}finalizeState(e){super.finalizeState(e),this.state.iconManager.finalize()}draw({uniforms:e}
2397){const{sizeScale:i,sizeBasis:n,sizeMinPixels:s,sizeMaxPixels:r,sizeUnits:o,billboard:a,alphaCutoff:c}=this.props,{iconManager:l}=this.state,f=l.getTexture();if(f){const h=this.state.model,u={iconsTexture:f,iconsTextureDim:[f.width,f.height],sizeUnits:He[o],sizeScale:i,sizeBasis:n==="height"?1:0,sizeMinPixels:s,sizeMaxPixels:r,billboard:a,alphaCutoff:c};h.shaderInputs.setProps({icon:u}),h.draw(this.context.renderPass)}}_getModel(){const e=[-1,-1,1,-1,-1,1,1,1];return new ve(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new Ot({topology:"triangle-strip",attributes:{positions:{size:2,value:new Float32Array(e)}}}),isInstanced:!0})}_onUpdate(e){var i;e?((i=this.getAttributeManager())==null||i.invalidate("getIcon"),this.setNeedsUpdate()):this.setNeedsRedraw()}_onError(e){var n;const i=(n=this.getCurrentLayer())==null?void 0:n.props.onIconError;i?i(e):j.error(e.error.message)()}getInstanceIconDef(e){const{x:i,y:n,width:s,height:r,mask:o,anchorX:a=s/2,anchorY:c=r/2}=this.state.iconManager.getIconMapping(e);return[s/2-a,r/2-c,i,n,s,r,o?1:0]}}ir.defaultProps=qR;ir.layerName="IconLayer";const zf=`layout(std140) uniform lineUniforms { 2398 float widthScale; 2399 float widthMinPixels; 2400 float widthMaxPixels; 2401 float useShortestPath; 2402 highp int widthUnits; 2403} line; 2404`,ZR={name:"line",source:"",vs:zf,fs:zf,uniformTypes:{widthScale:"f32",widthMinPixels:"f32",widthMaxPixels:"f32",useShortestPath:"f32",widthUnits:"i32"}},GR=`// ---------- Helper Structures & Functions ---------- 2405 2406// Placeholder filter functions. 2407fn deckgl_filter_size(offset: vec3<f32>, geometry: Geometry) -> vec3<f32> { 2408 return offset; 2409} 2410fn deckgl_filter_gl_position(p: vec4<f32>, geometry: Geometry) -> vec4<f32> { 2411 if (picking.isAttribute > 0.5) { 2412 // For depth picking, write normalized depth into the picking payload. 2413 // This mirrors the legacy DECKGL_FILTER_GL_POSITION hook on WebGL. 2414 } 2415 return p; 2416} 2417 2418// Compute an extrusion offset given a line direction (in clipspace), 2419// an offset direction (-1 or 1), and a width in pixels. 2420// Assumes a uniform "project" with a viewportSize field is available. 2421fn getExtrusionOffset(line_clipspace: vec2<f32>, offset_direction: f32, width: f32) -> vec2<f32> { 2422 // project.viewportSize should be provided as a uniform (not shown here) 2423 let dir_screenspace = normalize(line_clipspace * project.viewportSize); 2424 // Rotate by 90°: (x,y) becomes (-y,x) 2425 let rotated = vec2<f32>(-dir_screenspace.y, dir_screenspace.x); 2426 return rotated * offset_direction * width / 2.0; 2427} 2428 2429// Splits the line between two points at a given x coordinate. 2430// Interpolates the y and z components. 2431fn splitLine(a: vec3<f32>, b: vec3<f32>, x: f32) -> vec3<f32> { 2432 let t: f32 = (x - a.x) / (b.x - a.x); 2433 return vec3<f32>(x, a.yz + t * (b.yz - a.yz)); 2434} 2435 2436// ---------- Uniforms & Global Structures ---------- 2437 2438struct LineUniforms { 2439 widthScale: f32, 2440 widthMinPixels: f32, 2441 widthMaxPixels: f32, 2442 useShortestPath: f32, 2443 widthUnits: i32, 2444}; 2445 2446@group(0) @binding(0) 2447var<uniform> line: LineUniforms; 2448 2449 2450 2451// ---------- Vertex Output Structure ---------- 2452 2453struct Varyings { 2454 @builtin(position) gl_Position: vec4<f32>, 2455 @location(0) vColor: vec4<f32>, 2456 @location(1) uv: vec2<f32>, 2457 @location(2) pickingColor: vec3<f32>, 2458}; 2459 2460// ---------- Vertex Shader Entry Point ---------- 2461 2462@vertex 2463fn vertexMain( 2464 @location(0) positions: vec3<f32>, 2465 @location(1) instanceSourcePositions: vec3<f32>, 2466 @location(2) instanceTargetPositions: vec3<f32>, 2467 @location(3) instanceSourcePositions64Low: vec3<f32>, 2468 @location(4) instanceTargetPositions64Low: vec3<f32>, 2469 @location(5) instanceColors: vec4<f32>, 2470 @location(6) instancePickingColors: vec3<f32>, 2471 @location(7) instanceWidths: f32 2472) -> Varyings { 2473 geometry.worldPosition = instanceSourcePositions; 2474 geometry.worldPositionAlt = instanceTargetPositions; 2475 2476 var source_world: vec3<f32> = instanceSourcePositions; 2477 var target_world: vec3<f32> = instanceTargetPositions; 2478 var source_world_64low: vec3<f32> = instanceSourcePositions64Low; 2479 var target_world_64low: vec3<f32> = instanceTargetPositions64Low; 2480 2481 // Apply shortest-path adjustments if needed. 2482 if (line.useShortestPath > 0.5 || line.useShortestPath < -0.5) { 2483 source_world.x = (source_world.x + 180.0 % 360.0) - 180.0; 2484 target_world.x = (target_world.x + 180.0 % 360.0) - 180.0; 2485 let deltaLng: f32 = target_world.x - source_world.x; 2486 2487 if (deltaLng * line.useShortestPath > 180.0) { 2488 source_world.x = source_world.x + 360.0 * line.useShortestPath; 2489 source_world = splitLine(source_world, target_world, 180.0 * line.useShortestPath); 2490 source_world_64low = vec3<f32>(0.0, 0.0, 0.0); 2491 } else if (deltaLng * line.useShortestPath < -180.0) { 2492 target_world.x = target_world.x + 360.0 * line.useShortestPath; 2493 target_world = splitLine(source_world, target_world, 180.0 * line.useShortestPath); 2494 target_world_64low = vec3<f32>(0.0, 0.0, 0.0); 2495 } else if (line.useShortestPath < 0.0) { 2496 var abortOut: Varyings; 2497 abortOut.gl_Position = vec4<f32>(0.0); 2498 abortOut.vColor = vec4<f32>(0.0); 2499 abortOut.uv = vec2<f32>(0.0); 2500 return abortOut; 2501 } 2502 } 2503 2504 // Project Pos and target positions to clip space. 2505 let sourceResult = project_position_to_clipspace_and_commonspace(source_world, source_world_64low, vec3<f32>(0.0)); 2506 let targetResult = project_position_to_clipspace_and_commonspace(target_world, target_world_64low, vec3<f32>(0.0)); 2507 let sourcePos: vec4<f32> = sourceResult.clipPosition; 2508 let targetPos: vec4<f32> = targetResult.clipPosition; 2509 let source_commonspace: vec4<f32> = sourceResult.commonPosition; 2510 let target_commonspace: vec4<f32> = targetResult.commonPosition; 2511 2512 // Interpolate along the line segment. 2513 let segmentIndex: f32 = positions.x; 2514 let p: vec4<f32> = sourcePos + segmentIndex * (targetPos - sourcePos); 2515 geometry.position = source_commonspace + segmentIndex * (target_commonspace - source_commonspace); 2516 let uv: vec2<f32> = positions.xy; 2517 geometry.uv = uv; 2518 geometry.pickingColor = instancePickingColors; 2519 2520 // Determine width in pixels. 2521 let widthPixels: f32 = clamp( 2522 project_unit_size_to_pixel(instanceWidths * line.widthScale, line.widthUnits), 2523 line.widthMinPixels, line.widthMaxPixels 2524 ); 2525 2526 // Compute extrusion offset. 2527 let extrusion: vec2<f32> = getExtrusionOffset(targetPos.xy - sourcePos.xy, positions.y, widthPixels); 2528 let offset: vec3<f32> = vec3<f32>(extrusion, 0.0); 2529 2530 // Apply deck.gl filter functions. 2531 let filteredOffset = deckgl_filter_size(offset, geometry); 2532 let filteredP = deckgl_filter_gl_position(p, geometry); 2533 2534 let clipOffset: vec2<f32> = project_pixel_size_to_clipspace(filteredOffset.xy); 2535 let finalPosition: vec4<f32>
2535 = filteredP + vec4<f32>(clipOffset, 0.0, 0.0); 2536 2537 // Compute color. 2538 var vColor: vec4<f32> = vec4<f32>(instanceColors.rgb, instanceColors.a * layer.opacity); 2539 // vColor = deckgl_filter_color(vColor, geometry); 2540 2541 var output: Varyings; 2542 output.gl_Position = finalPosition; 2543 output.vColor = vColor; 2544 output.uv = uv; 2545 output.pickingColor = instancePickingColors; 2546 return output; 2547} 2548 2549@fragment 2550fn fragmentMain( 2551 @location(0) vColor: vec4<f32>, 2552 @location(1) uv: vec2<f32>, 2553 @location(2) pickingColor: vec3<f32> 2554) -> @location(0) vec4<f32> { 2555 // Create and initialize geometry with the provided uv. 2556 var geometry: Geometry; 2557 geometry.uv = uv; 2558 2559 // Start with the input color. 2560 var fragColor: vec4<f32> = vColor; 2561 2562 if (picking.isActive > 0.5) { 2563 if (!picking_isColorValid(pickingColor)) { 2564 discard; 2565 } 2566 return vec4<f32>(pickingColor, 1.0); 2567 } 2568 2569 if (picking.isHighlightActive > 0.5) { 2570 let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor); 2571 if (picking_isColorZero(abs(pickingColor - highlightedObjectColor))) { 2572 let highLightAlpha = picking.highlightColor.a; 2573 let blendedAlpha = highLightAlpha + fragColor.a * (1.0 - highLightAlpha); 2574 if (blendedAlpha > 0.0) { 2575 let highLightRatio = highLightAlpha / blendedAlpha; 2576 fragColor = vec4<f32>( 2577 mix(fragColor.rgb, picking.highlightColor.rgb, highLightRatio), 2578 blendedAlpha 2579 ); 2580 } else { 2581 fragColor = vec4<f32>(fragColor.rgb, 0.0); 2582 } 2583 } 2584 } 2585 2586 // Apply premultiplied alpha as required by transparent canvas 2587 fragColor = deckgl_premultiplied_alpha(fragColor); 2588 2589 return fragColor; 2590} 2591`,QR=`#version 300 es 2592#define SHADER_NAME line-layer-vertex-shader 2593in vec3 positions; 2594in vec3 instanceSourcePositions; 2595in vec3 instanceTargetPositions; 2596in vec3 instanceSourcePositions64Low; 2597in vec3 instanceTargetPositions64Low; 2598in vec4 instanceColors; 2599in vec3 instancePickingColors; 2600in float instanceWidths; 2601out vec4 vColor; 2602out vec2 uv; 2603vec2 getExtrusionOffset(vec2 line_clipspace, float offset_direction, float width) { 2604vec2 dir_screenspace = normalize(line_clipspace * project.viewportSize); 2605dir_screenspace = vec2(-dir_screenspace.y, dir_screenspace.x); 2606return dir_screenspace * offset_direction * width / 2.0; 2607} 2608vec3 splitLine(vec3 a, vec3 b, float x) { 2609float t = (x - a.x) / (b.x - a.x); 2610return vec3(x, mix(a.yz, b.yz, t)); 2611} 2612void main(void) { 2613geometry.worldPosition = instanceSourcePositions; 2614geometry.worldPositionAlt = instanceTargetPositions; 2615vec3 source_world = instanceSourcePositions; 2616vec3 target_world = instanceTargetPositions; 2617vec3 source_world_64low = instanceSourcePositions64Low; 2618vec3 target_world_64low = instanceTargetPositions64Low; 2619if (line.useShortestPath > 0.5 || line.useShortestPath < -0.5) {
2620source_world.x = mod(source_world.x + 180., 360.0) - 180.; 2621target_world.x = mod(target_world.x + 180., 360.0) - 180.; 2622float deltaLng = target_world.x - source_world.x; 2623if (deltaLng * line.useShortestPath > 180.) { 2624source_world.x += 360. * line.useShortestPath; 2625source_world = splitLine(source_world, target_world, 180. * line.useShortestPath); 2626source_world_64low = vec3(0.0); 2627} else if (deltaLng * line.useShortestPath < -180.) { 2628target_world.x += 360. * line.useShortestPath; 2629target_world = splitLine(source_world, target_world, 180. * line.useShortestPath); 2630target_world_64low = vec3(0.0); 2631} else if (line.useShortestPath < 0.) { 2632gl_Position = vec4(0.); 2633return; 2634} 2635} 2636vec4 source_commonspace; 2637vec4 target_commonspace; 2638vec4 source = project_position_to_clipspace(source_world, source_world_64low, vec3(0.), source_commonspace); 2639vec4 target = project_position_to_clipspace(target_world, target_world_64low, vec3(0.), target_commonspace); 2640float segmentIndex = positions.x; 2641vec4 p = mix(source, target, segmentIndex); 2642geometry.position = mix(source_commonspace, target_commonspace, segmentIndex); 2643uv = positions.xy; 2644geometry.uv = uv; 2645geometry.pickingColor = instancePickingColors; 2646float widthPixels = clamp( 2647project_size_to_pixel(instanceWidths * line.widthScale, line.widthUnits), 2648line.widthMinPixels, line.widthMaxPixels 2649); 2650vec3 offset = vec3( 2651getExtrusionOffset(target.xy - source.xy, positions.y, widthPixels), 26520.0); 2653DECKGL_FILTER_SIZE(offset, geometry); 2654DECKGL_FILTER_GL_POSITION(p, geometry); 2655gl_Position = p + vec4(project_pixel_size_to_clipspace(offset.xy), 0.0, 0.0); 2656vColor = vec4(instanceColors.rgb, instanceColors.a * layer.opacity); 2657DECKGL_FILTER_COLOR(vColor, geometry); 2658} 2659`,JR=`#version 300 es 2660#define SHADER_NAME line-layer-fragment-shader 2661precision highp float; 2662in vec4 vColor; 2663in vec2 uv; 2664out vec4 fragColor; 2665void main(void) { 2666geometry.uv = uv; 2667fragColor = vColor; 2668DECKGL_FILTER_COLOR(fragColor, geometry); 2669} 2670`,eC=[0,0,0,255],tC={getSourcePosition:{type:"accessor",value:t=>t.sourcePosition},getTargetPosition:{type:"accessor",value:t=>t.targetPosition},getColor:{type:"accessor",value:eC},getWidth:{type:"accessor",value:1},widthUnits:"pixels",widthScale:{type:"number",value:1,min:0},widthMinPixels:{type:"number",value:0,min:0},widthMaxPixels:{type:"number",value:Number.MAX_SAFE_INTEGER,min:0}};class pg extends Fe{getBounds(){var e;return(e=this.getAttributeManager())==null?void 0:e.getBounds(["instanceSourcePositions","instanceTargetPositions"])}getShaders(){return super.getShaders({vs:QR,fs:JR,source:GR,modules:[kt,wa,Ut,ZR]})}get wrapLongitude(){return!1}initializeState(){this.getAttributeManager().addInstanced({instanceSourcePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getSourcePosition"},instanceTargetPositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getTargetPosition"},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getColor",defaultValue:[0,0,0,255]},instanceWidths:{size:1,transition:!0,accessor:"getWidth",defaultValue:1}})}updateState(e){var i;super.updateState(e),e.changeFlags.extensionsChanged&&((i=this.state.model)==null||i.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){const{widthUnits:i,widthScale:n,widthMinPixels:s,widthMaxPixels:r,wrapLongitude:o}=this.props,a=this.state.model,c={widthUnits:He[i],widthScale:n,widthMinPixels:s,widthMaxPixels:r,useShortestPath:o?1:0};a.shaderInputs.setProps({line:c}),a.draw(this.context.renderPass),o&&(a.shaderInputs.setProps({line:{...c,useShortestPath:-1}}),a.draw(this.context.renderPass))}_getModel(){const e=[0,-1,0,0,1,0,1,-1,0,1,1,0];return new ve(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new Ot({topology:"triangle-strip",attributes:{positions:{size:3,value:new Float32Array(e)}}}),isInstanced:!0})}}pg.layerName="LineLayer";pg.defaultProps=tC;const Wf=`layout(std140) uniform scatterplotUniforms { 2671 float radiusScale; 2672 float radiusMinPixels; 2673 float radiusMaxPixels; 2674 float lineWidthScale; 2675 float lineWidthMinPixels; 2676 float lineWidthMaxPixels; 2677 float stroked; 2678 float filled; 2679 bool antialiasing; 2680 bool billboard; 2681 highp int radiusUnits; 2682 highp int lineWidthUnits; 2683} scatterplot; 2684`,iC={name:"scatterplot",vs:Wf,fs:Wf,source:"",uniformTypes:{radiu
2684sScale:"f32",radiusMinPixels:"f32",radiusMaxPixels:"f32",lineWidthScale:"f32",lineWidthMinPixels:"f32",lineWidthMaxPixels:"f32",stroked:"f32",filled:"f32",antialiasing:"f32",billboard:"f32",radiusUnits:"i32",lineWidthUnits:"i32"}},nC=`#version 300 es 2685#define SHADER_NAME scatterplot-layer-vertex-shader 2686in vec3 positions; 2687in vec3 instancePositions; 2688in vec3 instancePositions64Low; 2689in float instanceRadius; 2690in float instanceLineWidths; 2691in vec4 instanceFillColors; 2692in vec4 instanceLineColors; 2693in vec3 instancePickingColors; 2694out vec4 vFillColor; 2695out vec4 vLineColor; 2696out vec2 unitPosition; 2697out float innerUnitRadius; 2698out float outerRadiusPixels; 2699void main(void) { 2700geometry.worldPosition = instancePositions; 2701outerRadiusPixels = clamp( 2702project_size_to_pixel(scatterplot.radiusScale * instanceRadius, scatterplot.radiusUnits), 2703scatterplot.radiusMinPixels, scatterplot.radiusMaxPixels 2704); 2705float lineWidthPixels = clamp( 2706project_size_to_pixel(scatterplot.lineWidthScale * instanceLineWidths, scatterplot.lineWidthUnits), 2707scatterplot.lineWidthMinPixels, scatterplot.lineWidthMaxPixels 2708); 2709outerRadiusPixels += scatterplot.stroked * lineWidthPixels / 2.0; 2710float edgePadding = scatterplot.antialiasing ? (outerRadiusPixels + SMOOTH_EDGE_RADIUS) / outerRadiusPixels : 1.0; 2711unitPosition = edgePadding * positions.xy; 2712geometry.uv = unitPosition; 2713geometry.pickingColor = instancePickingColors; 2714innerUnitRadius = 1.0 - scatterplot.stroked * lineWidthPixels / outerRadiusPixels; 2715if (scatterplot.billboard) { 2716gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position); 2717DECKGL_FILTER_GL_POSITION(gl_Position, geometry); 2718vec3 offset = edgePadding * positions * outerRadiusPixels; 2719DECKGL_FILTER_SIZE(offset, geometry); 2720gl_Position.xy += project_pixel_size_to_clipspace(offset.xy); 2721} else { 2722vec3 offset = edgePadding * positions * project_pixel_size(outerRadiusPixels); 2723DECKGL_FILTER_SIZE(offset, geometry); 2724gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset, geometry.position); 2725DECKGL_FILTER_GL_POSITION(gl_Position, geometry); 2726} 2727vFillColor = vec4(instanceFillColors.rgb, instanceFillColors.a * layer.opacity); 2728DECKGL_FILTER_COLOR(vFillColor, geometry); 2729vLineColor = vec4(instanceLineColors.rgb, instanceLineColors.a * layer.opacity); 2730DECKGL_FILTER_COLOR(vLineColor, geometry); 2731} 2732`,sC=`#version 300 es 2733#define SHADER_NAME scatterplot-layer-fragment-shader 2734precision highp float; 2735in vec4 vFillColor; 2736in vec4 vLineColor; 2737in vec2 unitPosition; 2738in float innerUnitRadius; 2739in float outerRadiusPixels; 2740out vec4 fragColor; 2741void main(void) { 2742geometry.uv = unitPosition; 2743float distToCenter = length(unitPosition) * outerRadiusPixels; 2744float inCircle = scatterplot.antialiasing ? 2745smoothedge(distToCenter, outerRadiusPixels) : 2746step(distToCenter, outerRadiusPixels); 2747if (inCircle == 0.0) { 2748discard; 2749} 2750if (scatterplot.stroked > 0.5) { 2751float isLine = scatterplot.antialiasing ? 2752smoothedge(innerUnitRadius * outerRadiusPixels, distToCenter) : 2753step(innerUnitRadius * outerRadiusPixels, distToCenter); 2754if (scatterplot.filled > 0.5) { 2755fragColor = mix(vFillColor, vLineColor, isLine); 2756} else { 2757if (isLine == 0.0) { 2758discard; 2759} 2760fragColor = vec4(vLineColor.rgb, vLineColor.a * isLine); 2761} 2762} else if (scatterplot.filled < 0.5) { 2763discard; 2764} else { 2765fragColor = vFillColor; 2766} 2767fragColor.a *= inCircle; 2768DECKGL_FILTER_COLOR(fragColor, geometry); 2769} 2770`,rC=`// Main shaders 2771 2772struct ScatterplotUniforms { 2773 radiusScale: f32, 2774 radiusMinPixels: f32, 2775 radiusMaxPixels: f32, 2776 lineWidthScale: f32, 2777 lineWidthMinPixels: f32, 2778 lineWidthMaxPixels: f32, 2779 stroked: f32, 2780 filled: i32, 2781 antialiasing: i32, 2782 billboard: i32, 2783 radiusUnits: i32, 2784 lineWidthUnits: i32, 2785}; 2786 2787struct ConstantAttributeUniforms { 2788 instancePositions: vec3<f32>, 2789 instancePositions64Low: vec3<f32>, 2790 instanceRadius: f32, 2791 instanceLineWidths: f32, 2792 instanceFillColors: vec4<f32>, 2793 instanceLineColors: vec4<f32>, 2794 instancePickingColors: vec3<f32>, 2795 2796 instancePositionsConstant: i32, 2797 instancePositions64LowConstant: i32, 2798 instanceRadiusConstant: i32, 2799 instanceLineWidthsConstant: i32, 2800 instanceFillColorsConstant: i32, 2801 instanceLineColorsConstant: i32, 2802 instancePickingColorsConstant: i32 2803}; 2804 2805@group(0) @binding(0) var<uniform> scatterplot: ScatterplotUniforms; 2806 2807struct ConstantAttributes { 2808 instancePositions: vec3<f32>, 2809 instancePositions64Low: vec3<f32>, 2810 instanceRadius: f32, 2811 instanceLineWidths: f32, 2812 instanceFillColors: vec4<f32>, 2813 instanceLineColors: vec4<f32>, 2814 instancePickingColors: vec3<f32> 2815}; 2816 2817const constants = ConstantAttributes( 2818 vec3<f32>(0.0), 2819 vec3<f32>(0.0), 2820 0.0, 2821 0.0, 2822 vec4<f32>(0.0, 0.0, 0.0, 1.0), 2823 vec4<f32>(0.0, 0.0, 0.0, 1.0), 2824 vec3<f32>(0.0) 2825); 2826 2827struct Attributes { 2828 @builtin(instance_index) instanceIndex : u32, 2829 @builtin(vertex_index) vertexIndex : u32, 2830 @location(0) positions: vec3<f32>, 2831 @location(1) instancePositions: vec3<f32>, 2832 @location(2) instancePositions64Low: vec3<f32>, 2833 @location(3) instanceRadius: f32, 2834 @location(4) instanceLineWidths: f32, 2835 @location(5) instanceFillColors: vec4<f32>, 2836 @location(6) instanceLineColors: vec4<f32>, 2837 @location(7) instancePickingColors: vec3<f32>, 2838}; 2839
2840struct Varyings { 2841 @builtin(position) position: vec4<f32>, 2842 @location(0) vFillColor: vec4<f32>, 2843 @location(1) vLineColor: vec4<f32>, 2844 @location(2) unitPosition: vec2<f32>, 2845 @location(3) innerUnitRadius: f32, 2846 @location(4) outerRadiusPixels: f32, 2847 @location(5) pickingColor: vec3<f32>, 2848}; 2849 2850@vertex 2851fn vertexMain(attributes: Attributes) -> Varyings { 2852 var varyings: Varyings; 2853 2854 // Draw an inline geometry constant array clip space triangle to verify that rendering works. 2855 // var positions = array<vec2<f32>, 3>(vec2(0.0, 0.5), vec2(-0.5, -0.5), vec2(0.5, -0.5)); 2856 // if (attributes.instanceIndex == 0) { 2857 // varyings.position = vec4<f32>(positions[attributes.vertexIndex], 0.0, 1.0); 2858 // return varyings; 2859 // } 2860 2861 geometry.worldPosition = attributes.instancePositions; 2862 2863 // Multiply out radius and clamp to limits 2864 varyings.outerRadiusPixels = clamp( 2865 project_unit_size_to_pixel(scatterplot.radiusScale * attributes.instanceRadius, scatterplot.radiusUnits), 2866 scatterplot.radiusMinPixels, scatterplot.radiusMaxPixels 2867 ); 2868 2869 // Multiply out line width and clamp to limits 2870 let lineWidthPixels = clamp( 2871 project_unit_size_to_pixel(scatterplot.lineWidthScale * attributes.instanceLineWidths, scatterplot.lineWidthUnits), 2872 scatterplot.lineWidthMinPixels, scatterplot.lineWidthMaxPixels 2873 ); 2874 2875 // outer radius needs to offset by half stroke width 2876 varyings.outerRadiusPixels += scatterplot.stroked * lineWidthPixels / 2.0; 2877 // Expand geometry to accommodate edge smoothing 2878 let edgePadding = select( 2879 (varyings.outerRadiusPixels + SMOOTH_EDGE_RADIUS) / varyings.outerRadiusPixels, 2880 1.0, 2881 scatterplot.antialiasing != 0 2882 ); 2883 2884 // position on the containing square in [-1, 1] space 2885 varyings.unitPosition = edgePadding * attributes.positions.xy; 2886 geometry.uv = varyings.unitPosition; 2887 geometry.pickingColor = attributes.instancePickingColors; 2888 2889 varyings.innerUnitRadius = 1.0 - scatterplot.stroked * lineWidthPixels / varyings.outerRadiusPixels; 2890 2891 if (scatterplot.billboard != 0) { 2892 varyings.position = project_position_to_clipspace(attributes.instancePositions, attributes.instancePositions64Low, vec3<f32>(0.0)); // TODO , geometry.position); 2893 // DECKGL_FILTER_GL_POSITION(varyings.position, geometry); 2894 let offset = attributes.positions; // * edgePadding * varyings.outerRadiusPixels; 2895 // DECKGL_FILTER_SIZE(offset, geometry); 2896 let clipPixels = project_pixel_size_to_clipspace(offset.xy); 2897 varyings.position.x = clipPixels.x; 2898 varyings.position.y = clipPixels.y; 2899 } else { 2900 let offset = edgePadding * attributes.positions * project_pixel_size_float(varyings.outerRadiusPixels); 2901 // DECKGL_FILTER_SIZE(offset, geometry); 2902 varyings.position = project_position_to_clipspace(attributes.instancePositions, attributes.instancePositions64Low, offset); // TODO , geometry.position); 2903 // DECKGL_FILTER_GL_POSITION(varyings.position, geometry); 2904 } 2905 2906 // Apply opacity to instance color, or return instance picking color 2907 varyings.vFillColor = vec4<f32>(attributes.instanceFillColors.rgb, attributes.instanceFillColors.a * layer.opacity); 2908 // DECKGL_FILTER_COLOR(varyings.vFillColor, geometry); 2909 varyings.vLineColor = vec4<f32>(attributes.instanceLineColors.rgb, attributes.instanceLineColors.a * layer.opacity); 2910 // DECKGL_FILTER_COLOR(varyings.vLineColor, geometry); 2911 varyings.pickingColor = attributes.instancePickingColors; 2912 2913 return varyings; 2914} 2915 2916@fragment 2917fn fragmentMain(varyings: Varyings) -> @location(0) vec4<f32> { 2918 // var geometry: Geometry; 2919 // geometry.uv = unitPosition; 2920 2921 let distToCenter = length(varyings.unitPosition) * varyings.outerRadiusPixels; 2922 let inCircle = select( 2923 smoothedge(distToCenter, varyings.outerRadiusPixels), 2924 step(distToCenter, varyings.outerRadiusPixels), 2925 scatterplot.antialiasing != 0 2926 ); 2927 2928 if (inCircle == 0.0) { 2929 discard; 2930 } 2931 2932 var fragColor: vec4<f32>; 2933 2934 if (scatterplot.stroked != 0) { 2935 let isLine = select( 2936 smoothedge(varyings.innerUnitRadius * varyings.outerRadiusPixels, distToCenter), 2937 step(varyings.innerUnitRadius * varyings.outerRadiusPixels, distToCenter), 2938 scatterplot.antialiasing != 0 2939 ); 2940 2941 if (scatterplot.filled != 0) { 2942 fragColor = mix(varyings.vFillColor, varyings.vLineColor, isLine); 2943 } else { 2944 if (isLine == 0.0) { 2945 discard; 2946 } 2947 fragColor = vec4<f32>(varyings.vLineColor.rgb, varyings.vLineColor.a * isLine); 2948 } 2949 } else if (scatterplot.filled == 0) { 2950 discard; 2951 } else { 2952 fragColor = varyings.vFillColor; 2953 } 2954 2955 fragColor.a *= inCircle; 2956 2957 if (picking.isActive > 0.5) { 2958 if (!picking_isColorValid(varyings.pickingColor)) { 2959 discard; 2960 } 2961 return vec4<f32>(varyings.pickingColor, 1.0); 2962 } 2963 2964 if (picking.isHighlightActive > 0.5) { 2965 let highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor); 2966 if (picking_isColorZero(abs(varyings.pickingColor - highlightedObjectColor))) { 2967 let highLightAlpha = picking.highlightColor.a; 2968 let blendedAlpha = highLightAlpha + fragColor.a * (1.0 - highLightAlpha); 2969 if (blendedAlpha > 0.0) { 2970 let highLightRatio = highLightAlpha / blendedAlpha; 2971 fragColor = vec4<f32>( 2972 mix(fragColor.rgb, picking.highlightColor.rgb, highLightRatio), 2973 blendedAlpha 2974 ); 2975 } else { 2976 fragColor = vec4<f32>(fragColor.rgb, 0.0); 2977 } 2978 } 2979 } 2980 2981 // Apply premultiplied alpha as required by transparent canvas 2982 fragColor = deckgl_premultiplied_alpha(fragColor); 2983 2984 return fragColor; 2985 // return vec4<f32>(0, 0, 1, 1); 2986} 2987`,Vf=[0,0,0,255],oC={radiusUnits:"meters",radiusScale:{type:"number",min:0,value:1},radiusMinPixels:{type:"number",min:0,value:0},radiusMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},lineWidthUnits:"meters",lineWidthScale:{type:"number",min:0,value:1},lineWidthMinPixels:{type:"number",min:0,value:0},lineWidthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},stroked:!1,filled:!0,billboard:!1,antialiasing:!0,getPosition:{type:"accessor",value:t=>t.position},getRadius:{type:"accessor",value:1},getFillColor:{type:"accessor",value:Vf},getLineColor:{type:"accessor",value:Vf},getLineWidth:{type:"accessor",value:1},strokeWidth:{deprecatedFor:"getLineWidth"},outline:{deprecatedFor:"stroked"},getColor:{deprecatedFor:["getFillColor","getLineColor"]}};
vendor: 4,551 bytes, line 2987
2987class ja extends Fe{getShaders(){return super.getShaders({vs:nC,fs:sC,source:rC,modules:[kt,wa,Ut,iC]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceRadius:{size:1,transition:!0,accessor:"getRadius",defaultValue:1},instanceFillColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getFillColor",defaultValue:[0,0,0,255]},instanceLineColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getLineColor",defaultValue:[0,0,0,255]},instanceLineWidths:{size:1,transition:!0,accessor:"getLineWidth",defaultValue:1}})}updateState(e){var i;super.updateState(e),e.changeFlags.extensionsChanged&&((i=this.state.model)==null||i.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){const{radiusUnits:i,radiusScale:n,radiusMinPixels:s,radiusMaxPixels:r,stroked:o,filled:a,billboard:c,antialiasing:l,lineWidthUnits:f,lineWidthScale:h,lineWidthMinPixels:u,lineWidthMaxPixels:d}=this.props,p={stroked:o,filled:a,billboard:c,antialiasing:l,radiusUnits:He[i],radiusScale:n,radiusMinPixels:s,radiusMaxPixels:r,lineWidthUnits:He[f],lineWidthScale:h,lineWidthMinPixels:u,lineWidthMaxPixels:d},_=this.state.model;_.shaderInputs.setProps({scatterplot:p}),_.draw(this.context.renderPass)}_getModel(){const e=[-1,-1,0,1,-1,0,-1,1,0,1,1,0];return new ve(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new Ot({topology:"triangle-strip",attributes:{positions:{size:3,value:new Float32Array(e)}}}),isInstanced:!0})}}ja.defaultProps=oC;ja.layerName="ScatterplotLayer";const _g={CLOCKWISE:1,COUNTER_CLOCKWISE:-1};function mg(t,e,i={}){return aC(t,i)!==e?(lC(t,i),!0):!1}function aC(t,e={}){return Math.sign(cC(t,e))}const $f={x:0,y:1,z:2};function cC(t,e={}){const{start:i=0,end:n=t.length,plane:s="xy"}=e,r=e.size||2;let o=0;const a=$f[s[0]],c=$f[s[1]];for(let l=i,f=n-r;l<n;l+=r)o+=(t[l+a]-t[f+a])*(t[l+c]+t[f+c]),f=l;return o/2}function lC(t,e){const{start:i=0,end:n=t.length,size:s=2}=e,r=(n-i)/s,o=Math.floor(r/2);for(let a=0;a<o;++a){const c=i+a*s,l=i+(r-1-a)*s;for(let f=0;f<s;++f){const h=t[c+f];t[c+f]=t[l+f],t[l+f]=h}}}function Oe(t,e){const i=e.length,n=t.length;if(n>0){let s=!0;for(let r=0;r<i;r++)if(t[n-i+r]!==e[r]){s=!1;break}if(s)return!1}for(let s=0;s<i;s++)t[n+s]=e[s];return!0}function Qo(t,e){const i=e.length;for(let n=0;n<i;n++)t[n]=e[n]}function en(t,e,i,n,s=[]){const r=n+e*i;for(let o=0;o<i;o++)s[o]=t[r+o];return s}function Jo(t,e,i,n,s=[]){let r,o;if(i&8)r=(n[3]-t[1])/(e[1]-t[1]),o=3;else if(i&4)r=(n[1]-t[1])/(e[1]-t[1]),o=1;else if(i&2)r=(n[2]-t[0])/(e[0]-t[0]),o=2;else if(i&1)r=(n[0]-t[0])/(e[0]-t[0]),o=0;else return null;for(let a=0;a<t.length;a++)s[a]=(o&1)===a?n[o]:r*(e[a]-t[a])+t[a];return s}function Kn(t,e){let i=0;return t[0]<e[0]?i|=1:t[0]>e[2]&&(i|=2),t[1]<e[1]?i|=4:t[1]>e[3]&&(i|=8),i}function yg(t,e){const{size:i=2,broken:n=!1,gridResolution:s=10,gridOffset:r=[0,0],startIndex:o=0,endIndex:a=t.length}=e||{},c=(a-o)/i;let l=[];const f=[l],h=en(t,0,i,o);let u,d;const p=vg(h,s,r,[]),_=[];Oe(l,h);for(let m=1;m<c;m++){for(u=en(t,m,i,o,u),d=Kn(u,p);d;){Jo(h,u,d,p,_);const b=Kn(_,p);b&&(Jo(h,_,b,p,_),d=b),Oe(l,_),Qo(h,_),hC(p,s,d),n&&l.length>i&&(l=[],f.push(l),Oe(l,h)),d=Kn(u,p)}Oe(l,u),Qo(h,u)}return n?f:f[0]}const jf=0,fC=1;function bg(t,e=null,i){if(!t.length)return[];const{size:n=2,gridResolution:s=10,gridOffset:r=[0,0],edgeTypes:o=!1}=i||{},a=[],c=[{pos:t,types:o?new Array(t.length/n).fill(fC):null,holes:e||[]}],l=[[],[]];let f=[];for(;c.length;){const{pos:h,types:u,holes:d}=c.shift();uC(h,n,d[0]||h.length,l),f=vg(l[0],s,r,f);const p=Kn(l[1],f);if(p){let _=Hf(h,u,n,0,d[0]||h.length,f,p);const m={pos:_[0].pos,types:_[0].types,holes:[]},b={pos:_[1].pos,types:_[1].types,holes:[]};c.push(m,b);for(let A=0;A<d.length;A++)_=Hf(h,u,n,d[A],d[A+1]||h.length,f,p),_[0]&&(m.holes.push(m.pos.length),m.pos=Dn(m.pos,_[0].pos),o&&(m.types=Dn(m.types,_[0].types))),_[1]&&(b.holes.push(b.pos.length),b.pos=Dn(b.pos,_[1].pos),o&&(b.types=Dn(b.types,_[1].types)))}else{const _={positions:h};o&&(_.edgeTypes=u),d.length&&(_.holeIndices=d),a.push(_)}}return a}function Hf(t,e,i,n,s,r,o){const a=(s-n)/i,c=[],l=[],f=[],h=[],u=[];let d,p,_;const m=en(t,a-1,i,n);let b=Math.sign(o&8?m[1]-r[3]:m[0]-r[2]),A=e&&e[a-1],v=0,S=0;for(let E=0;E<a;E++)d=en(t,E,i,n,d),p=Math.sign(o&8?d[1]-r[3]:d[0]-r[2]),_=e&&e[n/i+E],p&&b&&b!==p&&
vendor: 6,130 bytes, lines 2987-3053
2987(Jo(m,d,o,r,u),Oe(c,u)&&f.push(A),Oe(l,u)&&h.push(A)),p<=0?(Oe(c,d)&&f.push(_),v-=p):f.length&&(f[f.length-1]=jf),p>=0?(Oe(l,d)&&h.push(_),S+=p):h.length&&(h[h.length-1]=jf),Qo(m,d),b=p,A=_;return[v?{pos:c,types:e&&f}:null,S?{pos:l,types:e&&h}:null]}function vg(t,e,i,n){const s=Math.floor((t[0]-i[0])/e)*e+i[0],r=Math.floor((t[1]-i[1])/e)*e+i[1];return n[0]=s,n[1]=r,n[2]=s+e,n[3]=r+e,n}function hC(t,e,i){i&8?(t[1]+=e,t[3]+=e):i&4?(t[1]-=e,t[3]-=e):i&2?(t[0]+=e,t[2]+=e):i&1&&(t[0]-=e,t[2]-=e)}function uC(t,e,i,n){let s=1/0,r=-1/0,o=1/0,a=-1/0;for(let c=0;c<i;c+=e){const l=t[c],f=t[c+1];s=l<s?l:s,r=l>r?l:r,o=f<o?f:o,a=f>a?f:a}return n[0][0]=s,n[0][1]=o,n[1][0]=r,n[1][1]=a,n}function Dn(t,e){for(let i=0;i<e.length;i++)t.push(e[i]);return t}const dC=85.051129;function gC(t,e){const{size:i=2,startIndex:n=0,endIndex:s=t.length,normalize:r=!0}=e||{},o=t.slice(n,s);Tg(o,i,0,s-n);const a=yg(o,{size:i,broken:!0,gridResolution:360,gridOffset:[-180,-180]});if(r)for(const c of a)Ag(c,i);return a}function pC(t,e=null,i){const{size:n=2,normalize:s=!0,edgeTypes:r=!1}=i||{};e=e||[];const o=[],a=[];let c=0,l=0;for(let h=0;h<=e.length;h++){const u=e[h]||t.length,d=l,p=_C(t,n,c,u);for(let _=p;_<u;_++)o[l++]=t[_];for(let _=c;_<p;_++)o[l++]=t[_];Tg(o,n,d,l),mC(o,n,d,l,i==null?void 0:i.maxLatitude),c=u,a[h]=l}a.pop();const f=bg(o,a,{size:n,gridResolution:360,gridOffset:[-180,-180],edgeTypes:r});if(s)for(const h of f)Ag(h.positions,n);return f}function _C(t,e,i,n){let s=-1,r=-1;for(let o=i+1;o<n;o+=e){const a=Math.abs(t[o]);a>s&&(s=a,r=o-1)}return r}function mC(t,e,i,n,s=dC){const r=t[i],o=t[n-e];if(Math.abs(r-o)>180){const a=en(t,0,e,i);a[0]+=Math.round((o-r)/360)*360,Oe(t,a),a[1]=Math.sign(a[1])*s,Oe(t,a),a[0]=r,Oe(t,a)}}function Tg(t,e,i,n){let s=t[0],r;for(let o=i;o<n;o+=e){r=t[o];const a=r-s;(a>180||a<-180)&&(r-=Math.round(a/360)*360),t[o]=s=r}}function Ag(t,e){let i;const n=t.length/e;for(let r=0;r<n&&(i=t[r*e],(i+180)%360===0);r++);const s=-Math.round(i/360)*360;if(s!==0)for(let r=0;r<n;r++)t[r*e]+=s}function yC(t,e,i,n){let s;if(Array.isArray(t[0])){const r=t.length*e;s=new Array(r);for(let o=0;o<t.length;o++)for(let a=0;a<e;a++)s[o*e+a]=t[o][a]||0}else s=t;return i?yg(s,{size:e,gridResolution:i}):n?gC(s,{size:e}):s}const bC=1,vC=2,Hr=4;class TC extends Zd{constructor(e){super({...e,attributes:{positions:{size:3,padding:18,initialize:!0,type:e.fp64?Float64Array:Float32Array},segmentTypes:{size:1,type:Uint8ClampedArray}}})}get(e){return this.attributes[e]}getGeometryFromBuffer(e){return this.normalize?super.getGeometryFromBuffer(e):null}normalizeGeometry(e){return this.normalize?yC(e,this.positionSize,this.opts.resolution,this.opts.wrapLongitude):e}getGeometrySize(e){if(Xf(e)){let n=0;for(const s of e)n+=this.getGeometrySize(s);return n}const i=this.getPathLength(e);return i<2?0:this.isClosed(e)?i<3?0:i+2:i}updateGeometryAttributes(e,i){if(i.geometrySize!==0)if(e&&Xf(e))for(const n of e){const s=this.getGeometrySize(n);i.geometrySize=s,this.updateGeometryAttributes(n,i),i.vertexStart+=s}else this._updateSegmentTypes(e,i),this._updatePositions(e,i)}_updateSegmentTypes(e,i){const n=this.attributes.segmentTypes,s=e?this.isClosed(e):!1,{vertexStart:r,geometrySize:o}=i;n.fill(0,r,r+o),s?(n[r]=Hr,n[r+o-2]=Hr):(n[r]+=bC,n[r+o-2]+=vC),n[r+o-1]=Hr}_updatePositions(e,i){const{positions:n}=this.attributes;if(!n||!e)return;const{vertexStart:s,geometrySize:r}=i,o=new Array(3);for(let a=s,c=0;c<r;a++,c++)this.getPointOnPath(e,c,o),n[a*3]=o[0],n[a*3+1]=o[1],n[a*3+2]=o[2]}getPathLength(e){return e.length/this.positionSize}getPointOnPath(e,i,n=[]){const{positionSize:s}=this;i*s>=e.length&&(i+=1-e.length/s);const r=i*s;return n[0]=e[r],n[1]=e[r+1],n[2]=s===3&&e[r+2]||0,n}isClosed(e){if(!this.normalize)return!!this.opts.loop;const{positionSize:i}=this,n=e.length-i;return e[0]===e[n]&&e[1]===e[n+1]&&(i===2||e[2]===e[n+2])}}function Xf(t){return Array.isArray(t[0])}const Yf=`layout(std140) uniform pathUniforms { 2988 float widthScale; 2989 float widthMinPixels; 2990 float widthMaxPixels; 2991 float jointType; 2992 float capType; 2993 float miterLimit; 2994 bool billboard; 2995 highp int widthUnits; 2996} path; 2997`,AC={name:"path",vs:Yf,fs:Yf,uniformTypes:{widthScale:"f32",widthMinPixels:"f32",widthMaxPixels:"f32",jointType:"f32",capType:"f32",miterLimit:"f32",billboard:"f32",widthUnits:"i32"}},wC=`#version 300 es 2998#define SHADER_NAME path-layer-vertex-shader 2999in vec2 positions; 3000in float instanceTypes; 3001in vec3 instanceStartPositions; 3002in vec3 instanceEndPositions; 3003in vec3 instanceLeftPositions; 3004in vec3 instanceRightPositions; 3005in vec3 instanceLeftPositions64Low; 3006in vec3 instanceStartPositions64Low; 3007in vec3 instanceEndPositions64Low; 3008in vec3 instanceRightPositions64Low; 3009in float instanceStrokeWidths; 3010in vec4 instanceColors; 3011in vec3 instancePickingColors; 3012uniform float opacity; 3013out vec4 vColor; 3014out vec2 vCornerOffset; 3015out float vMiterLength; 3016out vec2 vPathPosition; 3017out float vPathLength; 3018out float vJointType; 3019const float EPSILON = 0.001; 3020const vec3 ZERO_OFFSET = vec3(0.0); 3021float flipIfTrue(bool flag) { 3022return -(float(flag) * 2. - 1.); 3023} 3024vec3 getLineJoinOffset( 3025vec3 prevPoint, vec3 currPoint, vec3 nextPoint, 3026vec2 width 3027) { 3028bool isEnd = positions.x > 0.0; 3029float sideOfPath = positions.y; 3030float isJoint = float(sideOfPath == 0.0); 3031vec3 deltaA3 = (currPoint - prevPoint); 3032vec3 deltaB3 = (nextPoint - currPoint); 3033mat3 rotationMatrix; 3034bool needsRotation = !path.billboard && project_needs_rotation(currPoint, rotationMatrix); 3035if (needsRotation) { 3036deltaA3 = deltaA3 * rotationMatrix; 3037deltaB3 = deltaB3 * rotationMatrix; 3038} 3039vec2 deltaA = deltaA3.xy / width; 3040vec2 deltaB = deltaB3.xy / width; 3041float lenA = length(deltaA); 3042float lenB = length(deltaB); 3043vec2 dirA = lenA > 0. ? normalize(deltaA) : vec2(0.0, 0.0); 3044vec2 dirB = lenB > 0. ? normalize(deltaB) : vec2(0.0, 0.0); 3045vec2 perpA = vec2(-dirA.y, dirA.x); 3046vec2 perpB = vec2(-dirB.y, dirB.x); 3047vec2 tangent = dirA + dirB; 3048tangent = length(tangent) > 0. ? normalize(tangent) : perpA; 3049vec2 miterVec = vec2(-tangent.y, tangent.x); 3050vec2 dir = isEnd ? dirA : dirB; 3051vec2 perp = isEnd ? perpA : perpB; 3052float L = isEnd ? lenA : lenB; 3053float sinHalfA = abs(dot(miterVec, perp));
3054float cosHalfA = abs(dot(dirA, miterVec)); 3055float turnDirection = flipIfTrue(dirA.x * dirB.y >= dirA.y * dirB.x); 3056float cornerPosition = sideOfPath * turnDirection; 3057float miterSize = 1.0 / max(sinHalfA, EPSILON); 3058miterSize = mix( 3059min(miterSize, max(lenA, lenB) / max(cosHalfA, EPSILON)), 3060miterSize, 3061step(0.0, cornerPosition) 3062); 3063vec2 offsetVec = mix(miterVec * miterSize, perp, step(0.5, cornerPosition)) 3064* (sideOfPath + isJoint * turnDirection); 3065bool isStartCap = lenA == 0.0 || (!isEnd && (instanceTypes == 1.0 || instanceTypes == 3.0)); 3066bool isEndCap = lenB == 0.0 || (isEnd && (instanceTypes == 2.0 || instanceTypes == 3.0)); 3067bool isCap = isStartCap || isEndCap; 3068if (isCap) { 3069offsetVec = mix(perp * sideOfPath, dir * path.capType * 4.0 * flipIfTrue(isStartCap), isJoint); 3070vJointType = path.capType; 3071} else { 3072vJointType = path.jointType; 3073} 3074vPathLength = L; 3075vCornerOffset = offsetVec; 3076vMiterLength = dot(vCornerOffset, miterVec * turnDirection); 3077vMiterLength = isCap ? isJoint : vMiterLength; 3078vec2 offsetFromStartOfPath = vCornerOffset + deltaA * float(isEnd); 3079vPathPosition = vec2( 3080dot(offsetFromStartOfPath, perp), 3081dot(offsetFromStartOfPath, dir) 3082); 3083geometry.uv = vPathPosition; 3084float isValid = step(instanceTypes, 3.5); 3085vec3 offset = vec3(offsetVec * width * isValid, 0.0); 3086if (needsRotation) { 3087offset = rotationMatrix * offset; 3088} 3089return offset; 3090} 3091void clipLine(inout vec4 position, vec4 refPosition) { 3092if (position.w < EPSILON) { 3093float r = (EPSILON - refPosition.w) / (position.w - refPosition.w); 3094position = refPosition + (position - refPosition) * r; 3095} 3096} 3097void main() { 3098geometry.pickingColor = instancePickingColors; 3099vColor = vec4(instanceColors.rgb, instanceColors.a * layer.opacity); 3100float isEnd = positions.x; 3101vec3 prevPosition = mix(instanceLeftPositions, instanceStartPositions, isEnd); 3102vec3 prevPosition64Low = mix(instanceLeftPositions64Low, instanceStartPositions64Low, isEnd); 3103vec3 currPosition = mix(instanceStartPositions, instanceEndPositions, isEnd); 3104vec3 currPosition64Low = mix(instanceStartPositions64Low, instanceEndPositions64Low, isEnd); 3105vec3 nextPosition = mix(instanceEndPositions, instanceRightPositions, isEnd); 3106vec3 nextPosition64Low = mix(instanceEndPositions64Low, instanceRightPositions64Low, isEnd); 3107geometry.worldPosition = currPosition; 3108vec2 widthPixels = vec2(clamp( 3109project_size_to_pixel(instanceStrokeWidths * path.widthScale, path.widthUnits), 3110path.widthMinPixels, path.widthMaxPixels) / 2.0); 3111vec3 width; 3112if (path.billboard) { 3113vec4 prevPositionScreen = project_position_to_clipspace(prevPosition, prevPosition64Low, ZERO_OFFSET); 3114vec4 currPositionScreen = project_position_to_clipspace(currPosition, currPosition64Low, ZERO_OFFSET, geometry.position); 3115vec4 nextPositionScreen = project_position_to_clipspace(nextPosition, nextPosition64Low, ZERO_OFFSET); 3116clipLine(prevPositionScreen, currPositionScreen); 3117clipLine(nextPositionScreen, currPositionScreen); 3118clipLine(currPositionScreen, mix(nextPositionScreen, prevPositionScreen, isEnd)); 3119width = vec3(widthPixels, 0.0); 3120DECKGL_FILTER_SIZE(width, geometry); 3121vec3 offset = getLineJoinOffset( 3122prevPositionScreen.xyz / prevPositionScreen.w, 3123currPositionScreen.xyz / currPositionScreen.w, 3124nextPositionScreen.xyz / nextPositionScreen.w, 3125project_pixel_size_to_clipspace(width.xy) 3126); 3127DECKGL_FILTER_GL_POSITION(currPositionScreen, geometry); 3128gl_Position = vec4(currPositionScreen.xyz + offset * currPositionScreen.w, currPositionScreen.w); 3129} else { 3130prevPosition = project_position(prevPosition, prevPosition64Low); 3131currPosition = project_position(currPosition, currPosition64Low); 3132nextPosition = project_position(nextPosition, nextPosition64Low); 3133width = vec3(project_pixel_size(widthPixels), 0.0); 3134DECKGL_FILTER_SIZE(width, geometry); 3135vec3 offset = getLineJoinOffset(prevPosition, currPosition, nextPosition, width.xy); 3136geometry.position = vec4(currPosition + offset, 1.0); 3137gl_Position = project_common_position_to_clipspace(geometry.position); 3138DECKGL_FILTER_GL_POSITION(gl_Position, geometry); 3139} 3140DECKGL_FILTER_COLOR(vColor, geometry); 3141} 3142`,SC=`#version 300 es 3143#define SHADER_NAME path-layer-fragment-shader 3144precision highp float; 3145in vec4 vColor; 3146in vec2 vCornerOffset; 3147in float vMiterLength; 3148in vec2 vPathPosition; 3149in float vPathLength; 3150in float vJointType; 3151out vec4 fragColor; 3152void main(void) { 3153geometry.uv = vPathPosition; 3154if (vPathPosition.y < 0.0 || vPathPosition.y > vPathLength) { 3155if (vJointType > 0.5 && length(vCornerOffset) > 1.0) { 3156discard; 3157} 3158if (vJointType < 0.5 && vMiterLength > path.miterLimit + 1.0) { 3159discard; 3160} 3161} 3162fragColor = vColor; 3163DECKGL_FILTER_COLOR(fragColor, geometry); 3164} 3165`,wg=[0,0,0,255],EC={widthUnits:"meters",widthScale:{type:"number",min:0,value:1},widthMinPixels:{type:"number",min:0,value:0},widthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},jointRounded:!1,capRounded:!1,miterLimit:{type:"number",min:0,value:4},billboard:!1,_pathType:null,getPath:{type:"accessor",value:t=>t.path},getColor:{type:"accessor",value:wg},getWidth:{type:"accessor",value:1}
3165,rounded:{deprecatedFor:["jointRounded","capRounded"]}},Xr={enter:(t,e)=>e.length?e.subarray(e.length-t.length):t};class Ha extends Fe{getShaders(){return super.getShaders({vs:wC,fs:SC,modules:[kt,Ut,AC]})}get wrapLongitude(){return!1}getBounds(){var e;return(e=this.getAttributeManager())==null?void 0:e.getBounds(["vertexPositions"])}initializeState(){this.getAttributeManager().addInstanced({vertexPositions:{size:3,vertexOffset:1,type:"float64",fp64:this.use64bitPositions(),transition:Xr,accessor:"getPath",update:this.calculatePositions,noAlloc:!0,shaderAttributes:{instanceLeftPositions:{vertexOffset:0},instanceStartPositions:{vertexOffset:1},instanceEndPositions:{vertexOffset:2},instanceRightPositions:{vertexOffset:3}}},instanceTypes:{size:1,type:"uint8",update:this.calculateSegmentTypes,noAlloc:!0},instanceStrokeWidths:{size:1,accessor:"getWidth",transition:Xr,defaultValue:1},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",accessor:"getColor",transition:Xr,defaultValue:wg},instancePickingColors:{size:4,type:"uint8",accessor:(n,{index:s,target:r})=>this.encodePickingColor(n&&n.__source?n.__source.index:s,r)}}),this.setState({pathTesselator:new TC({fp64:this.use64bitPositions()})})}updateState(e){var o;super.updateState(e);const{props:i,changeFlags:n}=e,s=this.getAttributeManager();if(n.dataChanged||n.updateTriggersChanged&&(n.updateTriggersChanged.all||n.updateTriggersChanged.getPath)){const{pathTesselator:a}=this.state,c=i.data.attributes||{};a.updateGeometry({data:i.data,geometryBuffer:c.getPath,buffers:c,normalize:!i._pathType,loop:i._pathType==="loop",getGeometry:i.getPath,positionFormat:i.positionFormat,wrapLongitude:i.wrapLongitude,resolution:this.context.viewport.resolution,dataChanged:n.dataChanged}),this.setState({numInstances:a.instanceCount,startIndices:a.vertexStarts}),n.dataChanged||s.invalidateAll()}n.extensionsChanged&&((o=this.state.model)==null||o.destroy(),this.state.model=this._getModel(),s.invalidateAll())}getPickingInfo(e){const i=super.getPickingInfo(e),{index:n}=i,s=this.props.data;return s[0]&&s[0].__source&&(i.object=s.find(r=>r.__source.index===n)),i}disablePickingIndex(e){const i=this.props.data;if(i[0]&&i[0].__source)for(let n=0;n<i.length;n++)i[n].__source.index===e&&this._disablePickingIndex(n);else super.disablePickingIndex(e)}draw({uniforms:e}){const{jointRounded:i,capRounded:n,billboard:s,miterLimit:r,widthUnits:o,widthScale:a,widthMinPixels:c,widthMaxPixels:l}=this.props,f=this.state.model,h={jointType:Number(i),capType:Number(n),billboard:s,widthUnits:He[o],widthScale:a,miterLimit:r,widthMinPixels:c,widthMaxPixels:l};f.shaderInputs.setProps({path:h}),f.draw(this.context.renderPass)}_getModel(){const e=[0,1,2,1,4,2,1,3,4,3,5,4],i=[0,0,0,-1,0,1,1,-1,1,1,1,0];return new ve(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new Ot({topology:"triangle-list",attributes:{indices:new Uint16Array(e),positions:{value:new Float32Array(i),size:2}}}),isInstanced:!0})}calculatePositions(e){const{pathTesselator:i}=this.state;e.startIndices=i.vertexStarts,e.value=i.get("positions")}calculateSegmentTypes(e){const{pathTesselator:i}=this.state;e.startIndices=i.vertexStarts,e.value=i.get("segmentTypes")}}Ha.defaultProps=EC;Ha.layerName="PathLayer";var Bn={exports:{}},Kf;function xC(){if(Kf)return Bn.exports;Kf=1,Bn.exports=t,Bn.exports.default=t;function t(y,w,T){T=T||2;var P=w&&w.length,C=P?w[0]*T:y.length,I=e(y,0,C,T,!0),L=[];if(!I||I.next===I.prev)return L;var k,V,W,re,te,X,ue;if(P&&(I=c(y,w,I,T)),y.length>80*T){k=W=y[0],V=re=y[1];for(var ie=T;ie<C;ie+=T)te=y[ie],X=y[ie+1],te<k&&(k=te),X<V&&(V=X),te>W&&(W=te),X>re&&(re=X);ue=Math.max(W-k,re-V),ue=ue!==0?32767/ue:0}return n(I,L,T,k,V,ue,0),L}function e(y,w,T,P,C){var I,L;if(C===q(y,w,T,P)>0)for(I=w;I<T;I+=P)L=F(I,y[I],y[I+1],L);else for(I=T-P;I>=w;I-=P)L=F(I,y[I],y[I+1],L);return L&&S(L,L.next)&&(z(L),L=L.next),L}function i(y,w){if(!y)return y;w||(w=y);var T=y,P;do if(P=!1,!T.steiner&&(S(T,T.next)||v(T.prev,T,T.next)===0)){if(z(T),T=w=T.prev,T===T.next)break;P=!0}else T=T.next;while(P||T!==w);return w}
vendor: 12,803 bytes, lines 3165-3250
3165function n(y,w,T,P,C,I,L){if(y){!L&&I&&d(y,P,C,I);for(var k=y,V,W;y.prev!==y.next;){if(V=y.prev,W=y.next,I?r(y,P,C,I):s(y)){w.push(V.i/T|0),w.push(y.i/T|0),w.push(W.i/T|0),z(y),y=W.next,k=W.next;continue}if(y=W,y===k){L?L===1?(y=o(i(y),w,T),n(y,w,T,P,C,I,2)):L===2&&a(y,w,T,P,C,I):n(i(y),w,T,P,C,I,1);break}}}}function s(y){var w=y.prev,T=y,P=y.next;if(v(w,T,P)>=0)return!1;for(var C=w.x,I=T.x,L=P.x,k=w.y,V=T.y,W=P.y,re=C<I?C<L?C:L:I<L?I:L,te=k<V?k<W?k:W:V<W?V:W,X=C>I?C>L?C:L:I>L?I:L,ue=k>V?k>W?k:W:V>W?V:W,ie=P.next;ie!==w;){if(ie.x>=re&&ie.x<=X&&ie.y>=te&&ie.y<=ue&&b(C,k,I,V,L,W,ie.x,ie.y)&&v(ie.prev,ie,ie.next)>=0)return!1;ie=ie.next}return!0}function r(y,w,T,P){var C=y.prev,I=y,L=y.next;if(v(C,I,L)>=0)return!1;for(var k=C.x,V=I.x,W=L.x,re=C.y,te=I.y,X=L.y,ue=k<V?k<W?k:W:V<W?V:W,ie=re<te?re<X?re:X:te<X?te:X,bi=k>V?k>W?k:W:V>W?V:W,vi=re>te?re>X?re:X:te>X?te:X,Ga=_(ue,ie,w,T,P),Qa=_(bi,vi,w,T,P),Y=y.prevZ,K=y.nextZ;Y&&Y.z>=Ga&&K&&K.z<=Qa;){if(Y.x>=ue&&Y.x<=bi&&Y.y>=ie&&Y.y<=vi&&Y!==C&&Y!==L&&b(k,re,V,te,W,X,Y.x,Y.y)&&v(Y.prev,Y,Y.next)>=0||(Y=Y.prevZ,K.x>=ue&&K.x<=bi&&K.y>=ie&&K.y<=vi&&K!==C&&K!==L&&b(k,re,V,te,W,X,K.x,K.y)&&v(K.prev,K,K.next)>=0))return!1;K=K.nextZ}for(;Y&&Y.z>=Ga;){if(Y.x>=ue&&Y.x<=bi&&Y.y>=ie&&Y.y<=vi&&Y!==C&&Y!==L&&b(k,re,V,te,W,X,Y.x,Y.y)&&v(Y.prev,Y,Y.next)>=0)return!1;Y=Y.prevZ}for(;K&&K.z<=Qa;){if(K.x>=ue&&K.x<=bi&&K.y>=ie&&K.y<=vi&&K!==C&&K!==L&&b(k,re,V,te,W,X,K.x,K.y)&&v(K.prev,K,K.next)>=0)return!1;K=K.nextZ}return!0}function o(y,w,T){var P=y;do{var C=P.prev,I=P.next.next;!S(C,I)&&E(C,P,P.next,I)&&N(C,I)&&N(I,C)&&(w.push(C.i/T|0),w.push(P.i/T|0),w.push(I.i/T|0),z(P),z(P.next),P=y=I),P=P.next}while(P!==y);return i(P)}function a(y,w,T,P,C,I){var L=y;do{for(var k=L.next.next;k!==L.prev;){if(L.i!==k.i&&A(L,k)){var V=B(L,k);L=i(L,L.next),V=i(V,V.next),n(L,w,T,P,C,I,0),n(V,w,T,P,C,I,0);return}k=k.next}L=L.next}while(L!==y)}function c(y,w,T,P){var C=[],I,L,k,V,W;for(I=0,L=w.length;I<L;I++)k=w[I]*P,V=I<L-1?w[I+1]*P:y.length,W=e(y,k,V,P,!1),W===W.next&&(W.steiner=!0),C.push(m(W));for(C.sort(l),I=0;I<C.length;I++)T=f(C[I],T);return T}function l(y,w){return y.x-w.x}function f(y,w){var T=h(y,w);if(!T)return w;var P=B(T,y);return i(P,P.next),i(T,T.next)}function h(y,w){var T=w,P=y.x,C=y.y,I=-1/0,L;do{if(C<=T.y&&C>=T.next.y&&T.next.y!==T.y){var k=T.x+(C-T.y)*(T.next.x-T.x)/(T.next.y-T.y);if(k<=P&&k>I&&(I=k,L=T.x<T.next.x?T:T.next,k===P))return L}T=T.next}while(T!==w);if(!L)return null;var V=L,W=L.x,re=L.y,te=1/0,X;T=L;do P>=T.x&&T.x>=W&&P!==T.x&&b(C<re?P:I,C,W,re,C<re?I:P,C,T.x,T.y)&&(X=Math.abs(C-T.y)/(P-T.x),N(T,y)&&(X<te||X===te&&(T.x>L.x||T.x===L.x&&u(L,T)))&&(L=T,te=X)),T=T.next;while(T!==V);return L}function u(y,w){return v(y.prev,y,w.prev)<0&&v(w.next,y,y.next)<0}function d(y,w,T,P){var C=y;do C.z===0&&(C.z=_(C.x,C.y,w,T,P)),C.prevZ=C.prev,C.nextZ=C.next,C=C.next;while(C!==y);C.prevZ.nextZ=null,C.prevZ=null,p(C)}function p(y){var w,T,P,C,I,L,k,V,W=1;do{for(T=y,y=null,I=null,L=0;T;){for(L++,P=T,k=0,w=0;w<W&&(k++,P=P.nextZ,!!P);w++);for(V=W;k>0||V>0&&P;)k!==0&&(V===0||!P||T.z<=P.z)?(C=T,T=T.nextZ,k--):(C=P,P=P.nextZ,V--),I?I.nextZ=C:y=C,C.prevZ=I,I=C;T=P}I.nextZ=null,W*=2}while(L>1);return y}function _(y,w,T,P,C){return y=(y-T)*C|0,w=(w-P)*C|0,y=(y|y<<8)&16711935,y=(y|y<<4)&252645135,y=(y|y<<2)&858993459,y=(y|y<<1)&1431655765,w=(w|w<<8)&16711935,w=(w|w<<4)&252645135,w=(w|w<<2)&858993459,w=(w|w<<1)&1431655765,y|w<<1}function m(y){var w=y,T=y;do(w.x<T.x||w.x===T.x&&w.y<T.y)&&(T=w),w=w.next;while(w!==y);return T}function b(y,w,T,P,C,I,L,k){return(C-L)*(w-k)>=(y-L)*(I-k)&&(y-L)*(P-k)>=(T-L)*(w-k)&&(T-L)*(I-k)>=(C-L)*(P-k)}function A(y,w){return y.next.i!==w.i&&y.prev.i!==w.i&&!O(y,w)&&(N(y,w)&&N(w,y)&&D(y,w)&&(v(y.prev,y,w.prev)||v(y,w.prev,w))||S(y,w)&&v(y.prev,y,y.next)>0&&v(w.prev,w,w.next)>0)}function v(y,w,T){return(w.y-y.y)*(T.x-w.x)-(w.x-y.x)*(T.y-w.y)}function S(y,w){return y.x===w.x&&y.y===w.y}function E(y,w,T,P){var C=M(v(y,w,T)),I=M(v(y,w,P)),L=M(v(T,P,y)),k=M(v(T,P,w));return!!(C!==I&&L!==k||C===0&&x(y,T,w)||I===0&&x(y,P,w)||L===0&&x(T,y,P)||k===0&&x(T,w,P))}function x(y,w,T){return w.x<=Math.max(y.x,T.x)&&w.x>=Math.min(y.x,T.x)&&w.y<=Math.max(y.y,T.y)&&w.y>=Math.min(y.y,T.y)}function M(y){return y>0?1:y<0?-1:0}function O(y,w){var T=y;do{if(T.i!==y.i&&T.next.i!==y.i&&T.i!==w.i&&T.next.i!==w.i&&E(T,T.next,y,w))return!0;T=T.next}while(T!==y);return!1}function N(y,w){return v(y.prev,y,y.next)<0?v(y,w,y.next)>=0&&v(y,y.prev,w)>=0:v(y,w,y.prev)<0||v(y,y.next,w)<0}function D(y,w){var T=y,P=!1,C=(y.x+w.x)/2,I=(y.y+w.y)/2;do T.y>I!=T.next.y>I&&T.next.y!==T.y&&C<(T.next.x-T.x)*(I-T.y)/(T.next.y-T.y)+T.x&&(P=!P),T=T.next;while(T!==y);return P}function B(y,w){var T=new U(y.i,y.x,y.y),P=new U(w.i,w.x,w.y),C=y.next,I=w.prev;return y.next=w,w.prev=y,T.next=C,C.prev=T,P.next=T,T.prev=P,I.next=P,P.prev=I,P}function F(y,w,T,P){var C=new U(y,w,T);return P?(C.next=P.next,C.prev=P,P.next.prev=C,P.next=C):(C.prev=C,C.next=C),C}function z(y){y.next.prev=y.prev,y.prev.next=y.next,y.prevZ&&(y.prevZ.nextZ=y.nextZ),y.nextZ&&(y.nextZ.prevZ=y.prevZ)}function U(y,w,T){this.i=y,this.x=w,this.y=T,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}t.deviation=function(y,w,T,P){var C=w&&w.length,I=C?w[0]*T:y.length,L=Math.abs(q(y,0,I,T));if(C)for(var k=0,V=w.length;k<V;k++){var W=w[k]*T,re=k<V-1?w[k+1]*T:y.length;L-=Math.abs(q(y,W,re,T))}var te=0;for(k=0;k<P.length;k+=3){var X=P[k]*T,ue=P[k+1]*T,ie=P[k+2]*T;te+=Math.abs((y[X]-y[ie])*(y[ue+1]-y[X+1])-(y[X]-y[ue])*(y[ie+1]-y[X+1]))}return L===0&&te===0?0:Math.abs((te-L)/L)};function q(y,w,T,P){for(var C=0,I=w,L=T-P;I<T;I+=P)C+=(y[L]-y[I])*(y[I+1]+y[L+1]),L=I;return C}return t.flatten=function(y){for(var w=y[0][0].length,T={vertices:[],holes:[],dimensions:w},P=0,C=0;C<y.length;C++){for(var I=0;I<y[C].length;I++)for(var L=0;L<w;L++)T.vertices.push(y[C][I][L]);C>0&&(P+=y[C-1].length,T.holes.push(P))}return T},Bn.exports}var PC=xC();const RC=Lg(PC),Fn=_g.CLOCKWISE,qf=_g.COUNTER_CLOCKWISE,ft={};function CC(t){if(t=t&&t.positions||t,!Array.isArray(t)&&!ArrayBuffer.isView(t))throw new Error("invalid polygon")}function Ni(t){return"positions"in t?t.positions:t}function qn(t){return"holeIndices"in t?t.holeIndices:null}function MC(t){return Array.isArray(t[0])}function OC(t){return t.length>=1&&t[0].length>=2&&Number.isFinite(t[0][0])}function IC(t){const e=t[0],i=t[t.length-1];return e[0]===i[0]&&e[1]===i[1]&&e[2]===i[2]}function NC(t,e,i,n){for(let s=0;s<e;s++)if(t[i+s]!==t[n-e+s])return!1;return!0}function Zf(t,e,i,n,s){let r=e;const o=i.length;for(let a=0;a<o;a++)for(let c=0;c<n;c++)t[r++]=i[a][c]||0;if(!IC(i))for(let a=0;a<n;a++)t[r++]=i[0][a]||0;return ft.start=e,ft.end=r,ft.size=n,mg(t,s,ft),r}function Gf(t,e,i,n,s=0,r,o){r=r||i.length;const a=r-s;if(a<=0)return e;let c=e;for(let l=0;l<a;l++)t[c++]=i[s+l];if(!NC(i,n,s,r))for(let l=0;l<n;l++)t[c++]=i[s+l];return ft.start=e,ft.end=c,ft.size=n,mg(t,o,ft),c}function LC(t,e){CC(t);const i=[],n=[];if("positions"in t){const{positions:s,holeIndices:r}=t;if(r){let o=0;for(let a=0;a<=r.length;a++)o=Gf(i,o,s,e,r[a-1],r[a],a===0?Fn:qf),n.push(o);return n.pop(),{positions:i,holeIndices:n}}t=s}if(!MC(t))return Gf(i,0,t,e,0,i.length,Fn),i;if(!OC(t)){let s=0;for(const[r,o]of t.entries())s=Zf(i,s,o,e,r===0?Fn:qf),n.push(s);return n.pop(),{positions:i,holeIndices:n}}return Zf(i,0,t,e,Fn),i}function Yr(t,e,i){const n=t.length/3;let s=0;for(let r=0;r<n;r++){const o=(r+1)%n;s+=t[r*3+e]*t[o*3+i],s-=t[o*3+e]*t[r*3+i]}return Math.abs(s/2)}function Qf(t,e,i,n){const s=t.length/3;for(let r=0;r<s;r++){const o=r*3,a=t[o+0],c=t[o+1],l=t[o+2];t[o+e]=a,t[o+i]=c,t[o+n]=l}}function DC(t,e,i,n){let s=qn(t);s&&(s=s.map(a=>a/e));let r=Ni(t);const o=n&&e===3;if(i){const a=r.length;r=r.slice();const c=[];for(let l=0;l<a;l+=e){c[0]=r[l],c[1]=r[l+1],o&&(c[2]=r[l+2]);const f=i(c);r[l]=f[0],r[l+1]=f[1],o&&(r[l+2]=f[2])}}if(o){const a=Yr(r,0,1),c=Yr(r,0,2),l=Yr(r,1,2);if(!a&&!c&&!l)return[];a>c&&a>l||(c>l?(i||(r=r.slice()),Qf(r,0,2,1)):(i||(r=r.slice()),Qf(r,2,0,1)))}return RC(r,s,e)}class BC extends Zd{constructor(e){const{fp64:i,IndexType:n=Uint32Array}=e;super({...e,attributes:{positions:{size:3,type:i?Float64Array:Float32Array},vertexValid:{type:Uint16Array,size:1},indices:{type:n,size:1}}})}get(e){const{attributes:i}=this;return e==="indices"?i.indices&&i.indices.subarray(0,this.vertexCount):i[e]}updateGeometry(e){super.updateGeometry(e);const i=this.buffers.indices;if(i)this.vertexCount=(i.value||i).length;else if(this.data&&!this.getGeometry)throw new Error("missing indices buffer")}normalizeGeometry(e){if(this.normalize){const i=LC(e,this.positionSize);return this.opts.resolution?bg(Ni(i),qn(i),{size:this.positionSize,gridResolution:this.opts.resolution,edgeTypes:!0}):this.opts.wrapLongitude?pC(Ni(i),qn(i),{size:this.positionSize,maxLatitude:86,edgeTypes:!0}):i}return e}getGeometrySize(e){if(Jf(e)){let i=0;for(const n of e)i+=this.getGeometrySize(n);return i}return Ni(e).length/this.positionSize}getGeometryFromBuffer(e){return this.normalize||!this.buffers.indices?super.getGeometryFromBuffer(e):null}updateGeometryAttributes(e,i){if(e&&Jf(e))for(const n of e){const s=this.getGeometrySize(n);i.geometrySize=s,this.updateGeometryAttributes(n,i),i.vertexStart+=s,i.indexStart=this.indexStarts[i.geometryIndex+1]}else{const n=e;this._updateIndices(n,i),this._updatePositions(n,i),this._updateVertexValid(n,i)}}_updateIndices(e,{geometryIndex:i,vertexStart:n,indexStart:s}){const{attributes:r,indexStarts:o,typedArrayManager:a}=this;let c=r.indices;if(!c||!e)return;let l=s;const f=DC(e,this.positionSize,this.opts.preproject,this.opts.full3d);c=a.allocate(c,s+f.length,{copy:!0});for(let h=0;h<f.length;h++)c[l++]=f[h]+n;o[i+1]=s+f.length,r.indices=c}_updatePositions(e,{vertexStart:i,geometrySize:n}){const{attributes:{positions:s},positionSize:r}=this;if(!s||!e)return;const o=Ni(e);for(let a=i,c=0;c<n;a++,c++){const l=o[c*r],f=o[c*r+1],h=r>2?o[c*r+2]:0;s[a*3]=l,s[a*3+1]=f,s[a*3+2]=h}}_updateVertexValid(e,{vertexStart:i,geometrySize:n}){const{positionSize:s}=this,r=this.attributes.vertexValid,o=e&&qn(e);if(e&&e.edgeTypes?r.set(e.edgeTypes,i):r.fill(1,i,i+n),o)for(let a=0;a<o.length;a++)r[i+o[a]/s-1]=0;r[i+n-1]=0}}function Jf(t){return Array.isArray(t)&&t.length>0&&!Number.isFinite(t[0])}const eh=`layout(std140) uniform solidPolygonUniforms { 3166 bool extruded; 3167 bool isWireframe; 3168 float elevationScale; 3169} solidPolygon; 3170`,FC={name:"solidPolygon",vs:eh,fs:eh,uniformTypes:{extruded:"f32",isWireframe:"f32",elevationScale:"f32"}},Sg=`in vec4 fillColors; 3171in vec4 lineColors; 3172in vec3 pickingColors; 3173out vec4 vColor; 3174struct PolygonProps { 3175vec3 positions; 3176vec3 positions64Low; 3177vec3 normal; 3178float elevations; 3179}; 3180vec3 project_offset_normal(vec3 vector) { 3181if (project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT || 3182project.coordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSETS) { 3183return normalize(vector * project.commonUnitsPerWorldUnit); 3184} 3185return project_normal(vector); 3186} 3187void calculatePosition(PolygonProps props) { 3188vec3 pos = props.positions; 3189vec3 pos64Low = props.positions64Low; 3190vec3 normal = props.normal; 3191vec4 colors = solidPolygon.isWireframe ? lineColors : fillColors; 3192geometry.worldPosition = props.positions; 3193geometry.pickingColor = pickingColors; 3194if (solidPolygon.extruded) { 3195pos.z += props.elevations * solidPolygon.elevationScale; 3196} 3197gl_Position = project_position_to_clipspace(pos, pos64Low, vec3(0.), geometry.position); 3198DECKGL_FILTER_GL_POSITION(gl_Position, geometry); 3199if (solidPolygon.extruded) { 3200#ifdef IS_SIDE_VERTEX 3201normal = project_offset_normal(normal); 3202#else 3203normal = project_normal(normal); 3204#endif 3205geometry.normal = normal; 3206vec3 lightColor = lighting_getLightColor(colors.rgb, project.cameraPosition, geometry.position.xyz, geometry.normal); 3207vColor = vec4(lightColor, colors.a * layer.opacity); 3208} else { 3209vColor = vec4(colors.rgb, colors.a * layer.opacity); 3210} 3211DECKGL_FILTER_COLOR(vColor, geometry); 3212} 3213`,kC=`#version 300 es 3214#define SHADER_NAME solid-polygon-layer-vertex-shader 3215in vec3 vertexPositions; 3216in vec3 vertexPositions64Low; 3217in float elevations; 3218${Sg} 3219void main(void) { 3220PolygonProps props; 3221props.positions = vertexPositions; 3222props.positions64Low = vertexPositions64Low; 3223props.elevations = elevations; 3224props.normal = vec3(0.0, 0.0, 1.0); 3225calculatePosition(props); 3226} 3227`,UC=`#version 300 es 3228#define SHADER_NAME solid-polygon-layer-vertex-shader-side 3229#define IS_SIDE_VERTEX 3230in vec2 positions; 3231in vec3 vertexPositions; 3232in vec3 nextVertexPositions; 3233in vec3 vertexPositions64Low; 3234in vec3 nextVertexPositions64Low; 3235in float elevations; 3236in float instanceVertexValid; 3237${Sg} 3238void main(void) { 3239if(instanceVertexValid < 0.5){ 3240gl_Position = vec4(0.); 3241return; 3242} 3243PolygonProps props; 3244vec3 pos; 3245vec3 pos64Low; 3246vec3 nextPos; 3247vec3 nextPos64Low; 3248#if RING_WINDING_ORDER_CW == 1 3249pos = vertexPositions; 3250pos64Low = vertexPositions64Low;
3251nextPos = nextVertexPositions; 3252nextPos64Low = nextVertexPositions64Low; 3253#else 3254pos = nextVertexPositions; 3255pos64Low = nextVertexPositions64Low; 3256nextPos = vertexPositions; 3257nextPos64Low = vertexPositions64Low; 3258#endif 3259props.positions = mix(pos, nextPos, positions.x); 3260props.positions64Low = mix(pos64Low, nextPos64Low, positions.x); 3261props.normal = vec3( 3262pos.y - nextPos.y + (pos64Low.y - nextPos64Low.y), 3263nextPos.x - pos.x + (nextPos64Low.x - pos64Low.x), 32640.0); 3265props.elevations = elevations * positions.y; 3266calculatePosition(props); 3267} 3268`,zC=`#version 300 es 3269#define SHADER_NAME solid-polygon-layer-fragment-shader 3270precision highp float; 3271in vec4 vColor; 3272out vec4 fragColor; 3273void main(void) { 3274fragColor = vColor; 3275geometry.uv = vec2(0.); 3276DECKGL_FILTER_COLOR(fragColor, geometry); 3277} 3278`,As=[0,0,0,255],WC={filled:!0,extruded:!1,wireframe:!1,_normalize:!0,_windingOrder:"CW",_full3d:!1,elevationScale:{type:"number",min:0,value:1},getPolygon:{type:"accessor",value:t=>t.polygon},getElevation:{type:"accessor",value:1e3},getFillColor:{type:"accessor",value:As},getLineColor:{type:"accessor",value:As},material:!0},kn={enter:(t,e)=>e.length?e.subarray(e.length-t.length):t};class Xa extends Fe{getShaders(e){return super.getShaders({vs:e==="top"?kC:UC,fs:zC,defines:{RING_WINDING_ORDER_CW:!this.props._normalize&&this.props._windingOrder==="CCW"?0:1},modules:[kt,Fu,Ut,FC]})}get wrapLongitude(){return!1}getBounds(){var e;return(e=this.getAttributeManager())==null?void 0:e.getBounds(["vertexPositions"])}initializeState(){const{viewport:e}=this.context;let{coordinateSystem:i}=this.props;const{_full3d:n}=this.props;e.isGeospatial&&i==="default"&&(i="lnglat");let s;i==="lnglat"&&(n?s=e.projectPosition.bind(e):s=e.projectFlat.bind(e)),this.setState({numInstances:0,polygonTesselator:new BC({preproject:s,fp64:this.use64bitPositions(),IndexType:Uint32Array})});const r=this.getAttributeManager(),o=!0;r.remove(["instancePickingColors"]),r.add({indices:{size:1,isIndexed:!0,update:this.calculateIndices,noAlloc:o},vertexPositions:{size:3,type:"float64",stepMode:"dynamic",fp64:this.use64bitPositions(),transition:kn,accessor:"getPolygon",update:this.calculatePositions,noAlloc:o,shaderAttributes:{nextVertexPositions:{vertexOffset:1}}},instanceVertexValid:{size:1,type:"uint16",stepMode:"instance",update:this.calculateVertexValid,noAlloc:o},elevations:{size:1,stepMode:"dynamic",transition:kn,accessor:"getElevation"},fillColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:kn,accessor:"getFillColor",defaultValue:As},lineColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:kn,accessor:"getLineColor",defaultValue:As},pickingColors:{size:4,type:"uint8",stepMode:"dynamic",accessor:(a,{index:c,target:l})=>this.encodePickingColor(a&&a.__source?a.__source.index:c,l)}})}getPickingInfo(e){const i=super.getPickingInfo(e),{index:n}=i,s=this.props.data;return s[0]&&s[0].__source&&(i.object=s.find(r=>r.__source.index===n)),i}disablePickingIndex(e){const i=this.props.data;if(i[0]&&i[0].__source)for(let n=0;n<i.length;n++)i[n].__source.index===e&&this._disablePickingIndex(n);else super.disablePickingIndex(e)}draw({uniforms:e}){const{extruded:i,filled:n,wireframe:s,elevationScale:r}=this.props,{topModel:o,sideModel:a,wireframeModel:c,polygonTesselator:l}=this.state,f={extruded:!!i,elevationScale:r,isWireframe:!1};c&&s&&(c.setInstanceCount(l.instanceCount-1),c.shaderInputs.setProps({solidPolygon:{...f,isWireframe:!0}}),c.draw(this.context.renderPass)),a&&n&&(a.setInstanceCount(l.instanceCount-1),a.shaderInputs.setProps({solidPolygon:f}),a.draw(this.context.renderPass)),o&&n&&(o.setVertexCount(l.vertexCount),o.shaderInputs.setProps({solidPolygon:f}),o.draw(this.context.renderPass))}updateState(e){var a;super.updateState(e),this.updateGeometry(e);const{props:i,oldProps:n,changeFlags:s}=e,r=this.getAttributeManager();(s.extensionsChanged||i.filled!==n.filled||i.extruded!==n.extruded)&&((a=this.state.models)==null||a.forEach(c=>c.destroy()),this.setState(this._getModels()),r.invalidateAll())}updateGeometry({props:e,oldProps:i,changeFlags:n}){if(n.dataChanged||n.updateTriggersChanged&&(n.updateTriggersChanged.all||n.updateTriggersChanged.getPolygon)){const{polygonTesselator:r}=this.state,o=e.data.attributes||{};r.updateGeometry({data:e.data,normalize:e._normalize,geometryBuffer:o.getPolygon,buffers:o,getGeometry:e.getPolygon,positionFormat:e.positionFormat,wrapLongitude:e.wrapLongitude,resolution:this.context.viewport.resolution,fp64:this.use64bitPositions(),dataChanged:n.dataChanged,full3d:e._full3d}),this.setState({numInstances:r.instanceCount,startIndices:r.vertexStarts}),n.dataChanged||this.getAttributeManager().invalidateAll()}}_getModels(){const{id:e,filled:i,extruded:n}=this.props;let s,r,o;
3278if(i){const a=this.getShaders("top");a.defines.NON_INSTANCED_MODEL=1;const c=this.getAttributeManager().getBufferLayouts({isInstanced:!1});s=new ve(this.context.device,{...a,id:`${e}-top`,topology:"triangle-list",bufferLayout:c,isIndexed:!0,userData:{excludeAttributes:{instanceVertexValid:!0}}})}if(n){const a=this.getAttributeManager().getBufferLayouts({isInstanced:!0});r=new ve(this.context.device,{...this.getShaders("side"),id:`${e}-side`,bufferLayout:a,geometry:new Ot({topology:"triangle-strip",attributes:{positions:{size:2,value:new Float32Array([1,0,0,0,1,1,0,1])}}}),isInstanced:!0,userData:{excludeAttributes:{indices:!0}}}),o=new ve(this.context.device,{...this.getShaders("side"),id:`${e}-wireframe`,bufferLayout:a,geometry:new Ot({topology:"line-strip",attributes:{positions:{size:2,value:new Float32Array([1,0,0,0,0,1,1,1])}}}),isInstanced:!0,userData:{excludeAttributes:{indices:!0}}})}return{models:[r,o,s].filter(Boolean),topModel:s,sideModel:r,wireframeModel:o}}calculateIndices(e){const{polygonTesselator:i}=this.state;e.startIndices=i.indexStarts,e.value=i.get("indices")}calculatePositions(e){const{polygonTesselator:i}=this.state;e.startIndices=i.vertexStarts,e.value=i.get("positions")}calculateVertexValid(e){e.value=this.state.polygonTesselator.get("vertexValid")}}Xa.defaultProps=WC;Xa.layerName="SolidPolygonLayer";function VC({data:t,getIndex:e,dataRange:i,replace:n}){const{startRow:s=0,endRow:r=1/0}=i,o=t.length;let a=o,c=o;for(let u=0;u<o;u++){const d=e(t[u]);if(a>u&&d>=s&&(a=u),d>=r){c=u;break}}let l=a;const h=c-a!==n.length?t.slice(c):void 0;for(let u=0;u<n.length;u++)t[l++]=n[u];if(h){for(let u=0;u<h.length;u++)t[l++]=h[u];t.length=l}return{startRow:a,endRow:a+n.length}}function $C(t,e){if(!t)return null;const i="startIndices"in t?t.startIndices[e]:e,n=t.featureIds.value[i];return i!==-1?jC(t,n,i):null}function jC(t,e,i){const n={properties:{...t.properties[e]}};for(const s in t.numericProps)n.properties[s]=t.numericProps[s].value[i];return n}function HC(t,e){const i={points:null,lines:null,polygons:null};for(const n in i){const s=t[n].globalFeatureIds.value;i[n]=new Uint8ClampedArray(s.length*4);const r=[];for(let o=0;o<s.length;o++)e(s[o],r),i[n][o*4+0]=r[0],i[n][o*4+1]=r[1],i[n][o*4+2]=r[2],i[n][o*4+3]=255}return i}const th=`layout(std140) uniform sdfUniforms { 3279 float gamma; 3280 bool enabled; 3281 float buffer; 3282 float outlineBuffer; 3283 vec4 outlineColor; 3284} sdf; 3285`,XC={name:"sdf",vs:th,fs:th,uniformTypes:{gamma:"f32",enabled:"f32",buffer:"f32",outlineBuffer:"f32",outlineColor:"vec4<f32>"}},Wi={none:0,start:1,center:2,end:3},YC=`layout(std140) uniform textUniforms {
3286 highp vec2 cutoffPixels; 3287 highp ivec2 align; 3288 highp float fontSize; 3289 bool flipY; 3290} text; 3291 3292#define ALIGN_MODE_START ${Wi.start} 3293#define ALIGN_MODE_CENTER ${Wi.center} 3294#define ALIGN_MODE_END ${Wi.end} 3295`,Eg={name:"text",vs:YC,getUniforms:({contentCutoffPixels:t=[0,0],contentAlignHorizontal:e="none",contentAlignVertical:i="none",fontSize:n,viewport:s})=>({cutoffPixels:t,align:[Wi[e],Wi[i]],fontSize:n,flipY:(s==null?void 0:s.flipY)??!1}),uniformTypes:{cutoffPixels:"vec2<f32>",align:"vec2<i32>",fontSize:"f32",flipY:"f32"}},KC=`#version 300 es 3296#define SHADER_NAME multi-icon-layer-vertex-shader 3297in vec2 positions; 3298in vec3 instancePositions; 3299in vec3 instancePositions64Low; 3300in float instanceSizes; 3301in float instanceAngles; 3302in vec4 instanceColors; 3303in vec3 instancePickingColors; 3304in vec4 instanceIconFrames; 3305in float instanceColorModes; 3306in vec2 instanceOffsets; 3307in vec2 instancePixelOffset; 3308in vec4 instanceClipRect; 3309out float vColorMode; 3310out vec4 vColor; 3311out vec2 vTextureCoords; 3312out vec2 uv; 3313vec2 rotate_by_angle(vec2 vertex, float angle) { 3314float angle_radian = angle * PI / 180.0; 3315float cos_angle = cos(angle_radian); 3316float sin_angle = sin(angle_radian); 3317mat2 rotationMatrix = mat2(cos_angle, -sin_angle, sin_angle, cos_angle); 3318return rotationMatrix * vertex; 3319} 3320float getPixelOffsetFromAlignment(float anchor, float extent, float clipStart, float clipEnd, int mode) { 3321if (clipEnd < clipStart) return 0.0; 3322if (mode == ALIGN_MODE_START) { 3323return max(- (anchor + clipStart), 0.0); 3324} 3325if (mode == ALIGN_MODE_CENTER) { 3326float _min = max(0., anchor + clipStart); 3327float _max = min(extent, anchor + clipEnd); 3328return _min < _max ? (_min + _max) / 2.0 - anchor : 0.0; 3329} 3330if (mode == ALIGN_MODE_END) { 3331return min(extent - (anchor + clipEnd), 0.); 3332} 3333return 0.0; 3334} 3335void main(void) { 3336geometry.worldPosition = instancePositions; 3337geometry.uv = positions; 3338geometry.pickingColor = instancePickingColors; 3339uv = positions; 3340vec2 iconSize = instanceIconFrames.zw; 3341float sizePixels = clamp( 3342project_size_to_pixel(instanceSizes * icon.sizeScale, icon.sizeUnits),
3343icon.sizeMinPixels, icon.sizeMaxPixels 3344); 3345float instanceScale = sizePixels / text.fontSize; 3346vec2 pixelOffset = positions / 2.0 * iconSize + instanceOffsets; 3347pixelOffset = rotate_by_angle(pixelOffset, instanceAngles) * instanceScale; 3348pixelOffset += instancePixelOffset; 3349pixelOffset.y *= -1.0; 3350vec2 anchorPosScreen; 3351if (icon.billboard) { 3352gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position); 3353anchorPosScreen = gl_Position.xy / gl_Position.w; 3354DECKGL_FILTER_GL_POSITION(gl_Position, geometry); 3355vec3 offset = vec3(pixelOffset, 0.0); 3356DECKGL_FILTER_SIZE(offset, geometry); 3357gl_Position.xy += project_pixel_size_to_clipspace(offset.xy); 3358} else { 3359vec3 offset_common = vec3(project_pixel_size(pixelOffset), 0.0); 3360if (text.flipY) { 3361offset_common.y *= -1.; 3362} 3363DECKGL_FILTER_SIZE(offset_common, geometry); 3364vec4 anchorPos = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0)); 3365anchorPosScreen = anchorPos.xy / anchorPos.w; 3366gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset_common, geometry.position); 3367DECKGL_FILTER_GL_POSITION(gl_Position, geometry); 3368} 3369anchorPosScreen = vec2(anchorPosScreen.x + 1.0, 1.0 - anchorPosScreen.y) / 2.0 * project.viewportSize / project.devicePixelRatio; 3370vec2 xy = project_size_to_pixel(instanceClipRect.xy); 3371vec2 wh = project_size_to_pixel(instanceClipRect.zw); 3372if (text.flipY) { 3373xy.y = -xy.y - wh.y; 3374} 3375if (text.align.x > 0 || text.align.y > 0) { 3376vec2 viewportPixels = project.viewportSize / project.devicePixelRatio; 3377vec2 scrollPixels = vec2( 3378getPixelOffsetFromAlignment(anchorPosScreen.x, viewportPixels.x, xy.x, xy.x + wh.x, text.align.x), 3379-getPixelOffsetFromAlignment(anchorPosScreen.y, viewportPixels.y, -xy.y - wh.y, -xy.y, text.align.y) 3380); 3381pixelOffset += scrollPixels; 3382gl_Position.xy += project_pixel_size_to_clipspace(scrollPixels); 3383} 3384if (instanceClipRect.z >= 0.) { 3385if (pixelOffset.x < xy.x || pixelOffset.x > xy.x + wh.x) { 3386gl_Position = vec4(0.0); 3387} 3388else if (text.cutoffPixels.x > 0.) { 3389float vpWidth = project.viewportSize.x / project.devicePixelRatio; 3390float l = max(anchorPosScreen.x + xy.x, 0.0); 3391float r = min(anchorPosScreen.x + xy.x + wh.x, vpWidth); 3392if (r - l < text.cutoffPixels.x) { 3393gl_Position = vec4(0.0); 3394} 3395} 3396} 3397if (instanceClipRect.w >= 0.) { 3398if (pixelOffset.y < xy.y || pixelOffset.y > xy.y + wh.y) { 3399gl_Position = vec4(0.0); 3400} 3401else if (text.cutoffPixels.y > 0.) { 3402float vpHeight = project.viewportSize.y / project.devicePixelRatio; 3403float t = max(anchorPosScreen.y - xy.y - wh.y, 0.0); 3404float b = min(anchorPosScreen.y - xy.y, vpHeight); 3405if (b - t < text.cutoffPixels.y) { 3406gl_Position = vec4(0.0); 3407} 3408} 3409} 3410vTextureCoords = mix( 3411instanceIconFrames.xy, 3412instanceIconFrames.xy + iconSize, 3413(positions.xy + 1.0) / 2.0 3414) / icon.iconsTextureDim; 3415vColor = instanceColors; 3416DECKGL_FILTER_COLOR(vColor, geometry); 3417vColorMode = instanceColorModes; 3418} 3419`,qC=`#version 300 es 3420#define SHADER_NAME multi-icon-layer-fragment-shader 3421precision highp float; 3422uniform sampler2D iconsTexture; 3423in vec4 vColor; 3424in vec2 vTextureCoords; 3425in vec2 uv; 3426out vec4 fragColor; 3427void main(void) { 3428geometry.uv = uv; 3429if (!bool(picking.isActive)) { 3430float alpha = texture(iconsTexture, vTextureCoords).a; 3431vec4 color = vColor; 3432if (sdf.enabled) { 3433float distance = alpha; 3434alpha = smoothstep(sdf.buffer - sdf.gamma, sdf.buffer + sdf.gamma, distance); 3435if (sdf.outlineBuffer > 0.0) { 3436float inFill = alpha; 3437float inBorder = smoothstep(sdf.outlineBuffer - sdf.gamma, sdf.outlineBuffer + sdf.gamma, distance); 3438color = mix(sdf.outlineColor, vColor, inFill); 3439alpha = inBorder; 3440} 3441} 3442float a = alpha * color.a; 3443if (a < icon.alphaCutoff) { 3444discard; 3445} 3446fragColor = vec4(color.rgb, a * layer.opacity); 3447} 3448DECKGL_FILTER_COLOR(fragColor, geometry); 3449} 3450`,Kr=192/256,ZC={getIconOffsets:{type:"accessor",value:t=>t.offsets},getContentBox:{type:"accessor",value:[0,0,-1,-1]},fontSize:1,alphaCutoff:.001,smoothing:.1,outlineWidth:0,outlineColor:{type:"color",value:[0,0,0,255]},contentCutoffPixels:{type:"array",value:[0,0]},contentAlignHorizontal:"none",contentAlignVertical:"none"};class Ya extends ir{getShaders(){const e=super.getShaders();return{...e,modules:[...e.modules,Eg,XC],vs:KC,fs:qC}}initializeState(){super.initializeState();const e=this.getAttributeManager(),i=e.attributes.instanceIconDefs;i.settings.update=this.calculateInstanceIconDefs,e.addInstanced({instancePickingColors:{type:"uint8",size:4,accessor:(n,{index:s,target:r})=>this.encodePickingColor(s,r)},instanceClipRect:{size:4,accessor:"getContentBox",defaultValue:[0,0,-1,-1]}})}updateState(e){super.updateState(e);const{props:i,oldProps:n,changeFlags:s}=e,{outlineColor:r}=i;if(s.updateTriggersChanged&&(s.updateTriggersChanged.getIcon||s.updateTriggersChanged.getIconOffsets)&&this.getAttributeManager().invalidate("instanceIconDefs"),r!==n.outlineColor){const o=[r[0]/255,r[1]/255,r[2]/255,(r[3]??255)/255];this.setState({outlineColor:o})}!i.sdf&&i.outlineWidth&&j.warn(`${this.id}: fontSettings.sdf is required to render outline`)()}draw(e){const{sdf:i,smoothing:n,fontSize:s,outlineWidth:r,contentCutoffPixels:o,contentAlignHorizontal:a,contentAlignVertical:c}=this.props,{outlineColor:l}=this.state,f=r?Math.max(n,Kr*(1-r)):-1,h=this.state.model,u={buffer:Kr,outlineBuffer:f,gamma:n,enabled:!!i,outlineColor:l},d={contentCutoffPixels:o,contentAlignHorizontal:a,contentAlignVertical:c,fontSize:s,viewport:this.context.viewport};if(h.shaderInputs.setProps({sdf:u,text:d}),super.draw(e),i&&r){const{iconManager:p}=this.state;
3450p.getTexture()&&(h.shaderInputs.setProps({sdf:{...u,outlineBuffer:Kr}}),h.draw(this.context.renderPass))}}calculateInstanceIconDefs(e,{startRow:i,endRow:n}){const{data:s,getIcon:r,getIconOffsets:o}=this.props;let a=e.getVertexOffset(i);const c=e.value,{iterable:l,objectInfo:f}=cn(s,i,n);for(const h of l){f.index++;const u=r(h,f),d=o(h,f);if(u){let p=0;for(const _ of Array.from(u)){const m=super.getInstanceIconDef(_);m[0]=d[p*2],m[1]+=d[p*2+1],m[6]=1,c.set(m,a),a+=e.size,p++}}}}}Ya.defaultProps=ZC;Ya.layerName="MultiIconLayer";const Vi=1e20,Ka=new Float64Array(256);for(let t=0;t<256;t++){const e=.5-Math.pow(t/255,.45454545454545453);Ka[t]=e*Math.abs(e)}Ka[255]=-Vi;class GC{constructor({fontSize:e=24,buffer:i=3,radius:n=8,cutoff:s=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:a="normal",lang:c=null}={}){this.buffer=i,this.radius=n,this.cutoff=s,this.lang=c;const l=this.size=e+i*4,f=this._createCanvas(l),h=this.ctx=f.getContext("2d",{willReadFrequently:!0});h.font=`${a} ${o} ${e}px ${r}`,h.textBaseline="alphabetic",h.textAlign="left",h.fillStyle="black",this.gridOuter=new Float64Array(l*l),this.gridInner=new Float64Array(l*l),this.f=new Float64Array(l),this.z=new Float64Array(l+1),this.v=new Uint16Array(l)}_createCanvas(e){if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(e,e);const i=document.createElement("canvas");return i.width=i.height=e,i}draw(e){const{width:i,actualBoundingBoxAscent:n,actualBoundingBoxDescent:s,actualBoundingBoxLeft:r,actualBoundingBoxRight:o}=this.ctx.measureText(e),a=Math.ceil(n),c=Math.floor(r),l=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o)-c)),f=Math.max(0,Math.min(this.size-this.buffer,a+Math.ceil(s))),h=l+2*this.buffer,u=f+2*this.buffer,d=Math.max(h*u,0),p=new Uint8ClampedArray(d),_={data:p,width:h,height:u,glyphWidth:l,glyphHeight:f,glyphTop:a,glyphLeft:c,glyphAdvance:i};if(l===0||f===0)return _;const{ctx:m,buffer:b,gridInner:A,gridOuter:v}=this;this.lang&&(m.lang=this.lang),m.clearRect(b,b,l,f),m.fillText(e,b-c,b+a);const S=m.getImageData(b,b,l,f);v.fill(Vi,0,d),A.fill(0,0,d);let E=3;for(let O=0;O<f;O++){let N=(O+b)*h+b;for(let D=0;D<l;D++,E+=4,N++){const B=S.data[E];if(B===0)continue;const F=Ka[B];v[N]=Math.max(0,F),A[N]=Math.max(0,-F)}}ih(v,0,0,h,u,h,this.f,this.v,this.z),ih(A,b,b,l,f,h,this.f,this.v,this.z);const x=255/this.radius,M=255*(1-this.cutoff);for(let O=0;O<d;O++){const N=Math.sqrt(v[O])-Math.sqrt(A[O]);p[O]=Math.round(M-x*N)}return _}}function ih(t,e,i,n,s,r,o,a,c){for(let l=e;l<e+n;l++)nh(t,i*r+l,r,s,o,a,c);for(let l=i;l<i+s;l++)nh(t,l*r+e,1,n,o,a,c)}function nh(t,e,i,n,s,r,o){r[0]=0,o[0]=-Vi,o[1]=Vi,s[0]=t[e];for(let a=1,c=0,l=0;a<n;a++){s[a]=t[e+a*i];const f=a*a;do{const h=r[c];l=(s[a]-s[h]+f-h*h)/(a-h)/2}while(l<=o[c]&&--c>-1);c++,r[c]=a,o[c]=l,o[c+1]=Vi}for(let a=0,c=0;a<n;a++){for(;o[c+1]<a;)c++;const l=r[c],f=a-l;t[e+a*i]=s[l]+f*f}}const QC=32,JC=[];function e2(t){return Math.pow(2,Math.ceil(Math.log2(t)))}function t2({characterSet:t,measureText:e,buffer:i,maxCanvasWidth:n,mapping:s={},xOffset:r=0,yOffsetMin:o=0,yOffsetMax:a=0}){let c=r,l=o,f=a;for(const h of t)if(!s[h]){const{advance:u,width:d,ascent:p,descent:_}=e(h),m=p+_;c+d+i*2>n&&(c=0,l=f),s[h]={x:c+i,y:l+i,width:d,height:m,advance:u,anchorX:d/2,anchorY:p},c+=d+i*2,f=Math.max(f,l+m+i*2)}return{mapping:s,xOffset:c,yOffsetMin:l,yOffsetMax:f,canvasHeight:e2(f)}}function xg(t,e,i,n){var r;let s=0;for(let o=e;o<i;o++){const a=t[o];s+=((r=n[a])==null?void 0:r.advance)||0}return s}function Pg(t,e,i,n,s,r){let o=e,a=0;for(let c=e;c<i;c++){const l=xg(t,c,c+1,s);a+l>n&&(o<c&&r.push(c),o=c,a=0),a+=l}return a}function i2(t,e,i,n,s,r){let o=e,a=e,c=e,l=0;for(let f=e;f<i;f++)if((t[f]===" "||t[f+1]===" "||f+1===i)&&(c=f+1),c>a){let h=xg(t,a,c,s);l+h>n&&(o<a&&(r.push(a),o=a,l=0),h>n&&(h=Pg(t,a,c,n,s,r),o=r[r.length-1])),a=c,l+=h}return l}function n2(t,e,i,n,s=0,r){r===void 0&&(r=t.length);const o=[];return e==="break-all"?Pg(t,s,r,i,n,o):i2(t,s,r,i,n,o),o}function s2(t,e,i,n,s,r){let o=0,a=0;for(let c=e;c<i;c++){const l=t[c],f=n[l];f&&(a=Math.max(a,f.height))}for(let c=e;c<i;c++){const l=t[c],f=n[l];f?(s[c]=o+f.anchorX,o+=f.advance):(j.warn(`Missing character: ${l} (${l.codePointAt(0)})`)(),s[c]=o,o+=QC)}r[0]=o,r[1]=a}function r2(t,e,i,n,s,r){const o=Array.from(t),a=o.length,c=new Array(a),l=new Array(a),f=new Array(a),h=(n==="break-word"||n==="break-all")&&isFinite(s)&&s>0,u=[0,0],d=[0,0];let p=0,_=e+i/2,m=0,b=0;for(let A=0;A<=a;A++){const v=o[A];if((v===` 3451`||A===a)&&(b=A),b>m){const S=h?n2(o,n,s,r,m,b):JC;for(let E=0;E<=S.length;E++){const x=E===0?m:S[E-1],M=E<S.length?S[E]:b;s2(o,x,M,r,c,d);for(let O=x;O<M;O++)l[O]=_,f[O]=d[0];p++,_+=i,u[0]=Math.max(u[0],d[0])}m=b}v===` 3452`&&(c[m]=0,l[m]=0,f[m]=0,m++)}return u[1]=p*i,{x:c,y:l,rowWidth:f,size:u}}function o2({value:t,length:e,stride:i,offset:n,startIndices:s,characterSet:r}){const o=t.BYTES_PER_ELEMENT,a=i?i/o:1,c=n?n/o:0,l=s[e]||Math.ceil((t.length-c)/a),f=r&&new Set,h=new Array(e);let u=t;if(a>1||c>0){const d=t.constructor;u=new d(l);for(let p=0;p<l;p++)u[p]=t[p*a+c]}for(let d=0;d<e;d++){const p=s[d],_=s[d+1]||l,m=u.subarray(p,_);h[d]=String.fromCodePoint.apply(null,m),f&&m.forEach(f.add,f)}if(f)for(const d of f)r.add(String.fromCodePoint(d));return{texts:h,characterCount:l}}class Rg{constructor(e=5){this._cache={},this._order=[],this.limit=e}get(e){const i=this._cache[e];return i&&(this._deleteOrder(e),this._appendOrder(e)),i}set(e,i){this._cache[e]?(this.delete(e),this._cache[e]=i,this._appendOrder(e)):(Object.keys(this._cache).length===this.limit&&this.delete(this._order[0]),this._cache[e]=i,this._appendOrder(e))}delete(e){this._cache[e]&&(delete this._cache[e],this._deleteOrder(e))}_deleteOrder(e){const i=this._order.indexOf(e);i>=0&&this._order.splice(i,1)}_appendOrder(e){this._order.push(e)}}function a2(){const t=[];for(let e=32;e<128;e++)t.push(String.fromCharCode(e));return t}const ii={fontFamily:"Monaco, monospace",fontWeight:"normal",characterSet:a2(),fontSize:64,buffer:4,sdf:!1,cutoff:.25,radius:12,smoothing:.1}
3452,sh=1024,rh=.9,oh=.3,Cg=3;let ws=new Rg(Cg);function c2(t,e){let i;typeof e=="string"?i=new Set(Array.from(e)):i=new Set(e);const n=ws.get(t);if(!n)return i;for(const s in n.mapping)i.has(s)&&i.delete(s);return i}function l2(t,e){for(let i=0;i<t.length;i++)e.data[4*i+3]=t[i]}function ah(t,e,i,n){t.font=`${n} ${i}px ${e}`,t.fillStyle="#000",t.textBaseline="alphabetic",t.textAlign="left"}function f2(t,e,i){if(i===void 0){const s=t.measureText("A");return s.fontBoundingBoxAscent?{advance:0,width:0,ascent:Math.ceil(s.fontBoundingBoxAscent),descent:Math.ceil(s.fontBoundingBoxDescent)}:{advance:0,width:0,ascent:e*rh,descent:e*oh}}const n=t.measureText(i);return n.actualBoundingBoxAscent?{advance:n.width,width:Math.ceil(n.actualBoundingBoxRight-n.actualBoundingBoxLeft),ascent:Math.ceil(n.actualBoundingBoxAscent),descent:Math.ceil(n.actualBoundingBoxDescent)}:{advance:n.width,width:n.width,ascent:e*rh,descent:e*oh}}function h2(t){j.assert(Number.isFinite(t)&&t>=Cg,"Invalid cache limit"),ws=new Rg(t)}class u2{constructor(){this.props={...ii}}get atlas(){return this._atlas}get mapping(){return this._atlas&&this._atlas.mapping}setProps(e={}){Object.assign(this.props,e),e._getFontRenderer&&(this._getFontRenderer=e._getFontRenderer),this._key=this._getKey();const i=c2(this._key,this.props.characterSet),n=ws.get(this._key);if(n&&i.size===0){this._atlas!==n&&(this._atlas=n);return}const s=this._generateFontAtlas(i,n);this._atlas=s,ws.set(this._key,s)}_generateFontAtlas(e,i){const{fontFamily:n,fontWeight:s,fontSize:r,buffer:o,sdf:a,radius:c,cutoff:l}=this.props;let f=i&&i.data;f||(f=document.createElement("canvas"),f.width=sh);const h=f.getContext("2d",{willReadFrequently:!0});ah(h,n,r,s);const u=S=>f2(h,r,S);let d;this._getFontRenderer?d=this._getFontRenderer(this.props):a&&(d={measure:u,draw:d2(this.props)});const{mapping:p,canvasHeight:_,xOffset:m,yOffsetMin:b,yOffsetMax:A}=t2({measureText:S=>d?d.measure(S):u(S),buffer:o,characterSet:e,maxCanvasWidth:sh,...i&&{mapping:i.mapping,xOffset:i.xOffset,yOffsetMin:i.yOffsetMin,yOffsetMax:i.yOffsetMax}});if(f.height!==_){const S=f.height>0?h.getImageData(0,0,f.width,f.height):null;f.height=_,S&&h.putImageData(S,0,0)}if(ah(h,n,r,s),d)for(const S of e){const E=p[S],{data:x,left:M=0,top:O=0}=d.draw(S),N=E.x-M,D=E.y-O,B=Math.max(0,Math.round(N)),F=Math.max(0,Math.round(D)),z=Math.min(x.width,f.width-B),U=Math.min(x.height,f.height-F);h.putImageData(x,B,F,0,0,z,U),E.x+=B-N,E.y+=F-D}else for(const S of e){const E=p[S];h.fillText(S,E.x,E.y+E.anchorY)}const v=d?d.measure():u();return{baselineOffset:(v.ascent-v.descent)/2,xOffset:m,yOffsetMin:b,yOffsetMax:A,mapping:p,data:f,width:f.width,height:f.height}}_getKey(){const{fontFamily:e,fontWeight:i,fontSize:n,buffer:s,sdf:r,radius:o,cutoff:a}=this.props;return r?`${e} ${i} ${n} ${s} ${o} ${a}`:`${e} ${i} ${n} ${s}`}}function d2({fontSize:t,buffer:e,radius:i,cutoff:n,fontFamily:s,fontWeight:r}){const o=new GC({fontSize:t,buffer:e,radius:i,cutoff:n,fontFamily:s,fontWeight:`${r}`});return a=>{const{data:c,width:l,height:f}=o.draw(a),h=new ImageData(l,f);
3452return l2(c,h),{data:h,left:e,top:e}}}const ch=`layout(std140) uniform textBackgroundUniforms { 3453 bool billboard; 3454 float sizeScale; 3455 float sizeMinPixels; 3456 float sizeMaxPixels; 3457 vec4 borderRadius; 3458 vec4 padding; 3459 highp int sizeUnits; 3460 bool stroked; 3461} textBackground; 3462`,g2={name:"textBackground",vs:ch,fs:ch,uniformTypes:{billboard:"f32",sizeScale:"f32",sizeMinPixels:"f32",sizeMaxPixels:"f32",borderRadius:"vec4<f32>",padding:"vec4<f32>",sizeUnits:"i32",stroked:"f32"}},p2=`#version 300 es 3463#define SHADER_NAME text-background-layer-vertex-shader 3464in vec2 positions; 3465in vec3 instancePositions; 3466in vec3 instancePositions64Low; 3467in vec4 instanceRects; 3468in vec4 instanceClipRect; 3469in float instanceSizes; 3470in float instanceAngles; 3471in vec2 instancePixelOffsets; 3472in float instanceLineWidths; 3473in vec4 instanceFillColors; 3474in vec4 instanceLineColors; 3475in vec3 instancePickingColors; 3476out vec4 vFillColor; 3477out vec4 vLineColor; 3478out float vLineWidth; 3479out vec2 uv; 3480out vec2 dimensions; 3481vec2 rotate_by_angle(vec2 vertex, float angle) { 3482float angle_radian = radians(angle); 3483float cos_angle = cos(angle_radian); 3484float sin_angle = sin(angle_radian); 3485mat2 rotationMatrix = mat2(cos_angle, -sin_angle, sin_angle, cos_angle); 3486return rotationMatrix * vertex; 3487} 3488void main(void) { 3489geometry.worldPosition = instancePositions; 3490geometry.uv = positions; 3491geometry.pickingColor = instancePickingColors; 3492uv = positions; 3493vLineWidth = instanceLineWidths; 3494float sizePixels = clamp( 3495project_size_to_pixel(instanceSizes * textBackground.sizeScale, textBackground.sizeUnits), 3496textBackground.sizeMinPixels, textBackground.sizeMaxPixels 3497); 3498float instanceScale = sizePixels / text.fontSize; 3499dimensions = instanceRects.zw * instanceScale + textBackground.padding.xy + textBackground.padding.zw; 3500vec2 pixelOffset = (positions * instanceRects.zw + instanceRects.xy) * instanceScale + mix(-textBackground.padding.xy, textBackground.padding.zw, positions); 3501pixelOffset = rotate_by_angle(pixelOffset, instanceAngles); 3502pixelOffset += instancePixelOffsets; 3503pixelOffset.y *= -1.0; 3504vec2 xy = project_size_to_pixel(instanceClipRect.xy); 3505vec2 wh = project_size_to_pixel(instanceClipRect.zw); 3506if (text.flipY) { 3507xy.y = -xy.y - wh.y; 3508} 3509if (instanceClipRect.z >= 0.0) { 3510dimensions.x = wh.x; 3511pixelOffset.x = xy.x + uv.x * wh.x + mix(-textBackground.padding.x, textBackground.padding.z, uv.x); 3512} 3513if (instanceClipRect.w >= 0.0) { 3514dimensions.y = wh.y; 3515pixelOffset.y = xy.y + uv.y * wh.y + mix(-textBackground.padding.y, textBackground.padding.w, uv.y); 3516} 3517if (textBackground.billboard) { 3518gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position); 3519DECKGL_FILTER_GL_POSITION(gl_Position, geometry); 3520vec3 offset = vec3(pixelOffset, 0.0); 3521DECKGL_FILTER_SIZE(offset, geometry); 3522gl_Position.xy += project_pixel_size_to_clipspace(offset.xy); 3523} else { 3524vec3 offset_common = vec3(project_pixel_size(pixelOffset), 0.0); 3525if (text.flipY) { 3526offset_common.y *= -1.; 3527} 3528DECKGL_FILTER_SIZE(offset_common, geometry); 3529gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset_common, geometry.position); 3530DECKGL_FILTER_GL_POSITION(gl_Position, geometry); 3531} 3532vFillColor = vec4(instanceFillColors.rgb, instanceFillColors.a * layer.opacity); 3533DECKGL_FILTER_COLOR(vFillColor, geometry); 3534vLineColor = vec4(instanceLineColors.rgb, instanceLineColors.a * layer.opacity); 3535DECKGL_FILTER_COLOR(vLineColor, geometry); 3536} 3537`,_2=`#version 300 es 3538#define SHADER_NAME text-background-layer-fragment-shader 3539precision highp float; 3540in vec4 vFillColor; 3541in vec4 vLineColor; 3542in float vLineWidth; 3543in vec2 uv; 3544in vec2 dimensions; 3545out vec4 fragColor; 3546float round_rect(vec2 p, vec2 size, vec4 radii) { 3547vec2 pixelPositionCB = (p - 0.5) * size; 3548vec2 sizeCB = size * 0.5; 3549float maxBorderRadius = min(size.x, size.y) * 0.5; 3550vec4 borderRadius = vec4(min(radii, maxBorderRadius)); 3551borderRadius.xy = 3552(pixelPositionCB.x > 0.0) ? borderRadius.xy : borderRadius.zw; 3553borderRadius.x = (pixelPositionCB.y > 0.0) ? borderRadius.x : borderRadius.y; 3554vec2 q = abs(pixelPositionCB) - sizeCB + borderRadius.x; 3555return -(min(max(q.x, q.y), 0.0) + length(max(q, 0.0)) - borderRadius.x); 3556} 3557float rect(vec2 p, vec2 size) { 3558vec2 pixelPosition = p * size; 3559return min(min(pixelPosition.x, size.x - pixelPosition.x), 3560min(pixelPosition.y, size.y - pixelPosition.y)); 3561} 3562vec4 get_stroked_fragColor(float dist) { 3563float isBorder = smoothedge(dist, vLineWidth); 3564return mix(vFillColor, vLineColor, isBorder); 3565} 3566void main(void) { 3567geometry.uv = uv;
3568if (textBackground.borderRadius != vec4(0.0)) { 3569float distToEdge = round_rect(uv, dimensions, textBackground.borderRadius); 3570float shapeAlpha = smoothedge(-distToEdge, 0.0); 3571if (shapeAlpha == 0.0) { 3572discard; 3573} 3574if (textBackground.stroked) { 3575fragColor = get_stroked_fragColor(distToEdge); 3576} else { 3577fragColor = vFillColor; 3578} 3579fragColor.a *= shapeAlpha; 3580} else { 3581if (textBackground.stroked) { 3582float distToEdge = rect(uv, dimensions); 3583fragColor = get_stroked_fragColor(distToEdge); 3584} else { 3585fragColor = vFillColor; 3586} 3587} 3588DECKGL_FILTER_COLOR(fragColor, geometry); 3589} 3590`,m2={billboard:!0,sizeScale:1,sizeUnits:"pixels",sizeMinPixels:0,sizeMaxPixels:Number.MAX_SAFE_INTEGER,fontSize:1,borderRadius:{type:"object",value:0},padding:{type:"array",value:[0,0,0,0]},getPosition:{type:"accessor",value:t=>t.position},getSize:{type:"accessor",value:1},getAngle:{type:"accessor",value:0},getPixelOffset:{type:"accessor",value:[0,0]},getBoundingRect:{type:"accessor",value:[0,0,0,0]},getClipRect:{type:"accessor",value:[0,0,-1,-1]},getFillColor:{type:"accessor",value:[0,0,0,255]},getLineColor:{type:"accessor",value:[0,0,0,255]},getLineWidth:{type:"accessor",value:1}};class qa extends Fe{getShaders(){return super.getShaders({vs:p2,fs:_2,modules:[kt,Ut,g2,Eg]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceSizes:{size:1,transition:!0,accessor:"getSize",defaultValue:1},instanceAngles:{size:1,transition:!0,accessor:"getAngle"},instanceRects:{size:4,accessor:"getBoundingRect"},instanceClipRect:{size:4,accessor:"getClipRect",defaultValue:[0,0,-1,-1]},instancePixelOffsets:{size:2,transition:!0,accessor:"getPixelOffset"},instanceFillColors:{size:4,transition:!0,type:"unorm8",accessor:"getFillColor",defaultValue:[0,0,0,255]},instanceLineColors:{size:4,transition:!0,type:"unorm8",accessor:"getLineColor",defaultValue:[0,0,0,255]},instanceLineWidths:{size:1,transition:!0,accessor:"getLineWidth",defaultValue:1}})}updateState(e){var n;super.updateState(e);const{changeFlags:i}=e;i.extensionsChanged&&((n=this.state.model)==null||n.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}
vendor: 6,721 bytes, line 3590
3590){const{billboard:i,sizeScale:n,sizeUnits:s,sizeMinPixels:r,sizeMaxPixels:o,getLineWidth:a,fontSize:c}=this.props;let{padding:l,borderRadius:f}=this.props;l.length<4&&(l=[l[0],l[1],l[0],l[1]]),Array.isArray(f)||(f=[f,f,f,f]);const h=this.state.model,u={billboard:i,stroked:!!a,borderRadius:f,padding:l,sizeUnits:He[s],sizeScale:n,sizeMinPixels:r,sizeMaxPixels:o},d={fontSize:c,viewport:this.context.viewport};h.shaderInputs.setProps({textBackground:u,text:d}),h.draw(this.context.renderPass)}_getModel(){const e=[0,0,1,0,0,1,1,1];return new ve(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new Ot({topology:"triangle-strip",vertexCount:4,attributes:{positions:{size:2,value:new Float32Array(e)}}}),isInstanced:!0})}}qa.defaultProps=m2;qa.layerName="TextBackgroundLayer";const lh={start:1,middle:0,end:-1},fh={top:1,center:0,bottom:-1},qr=[0,0,0,255],y2=1,b2={billboard:!0,sizeScale:1,sizeUnits:"pixels",sizeMinPixels:0,sizeMaxPixels:Number.MAX_SAFE_INTEGER,background:!1,getBackgroundColor:{type:"accessor",value:[255,255,255,255]},getBorderColor:{type:"accessor",value:qr},getBorderWidth:{type:"accessor",value:0},backgroundBorderRadius:{type:"object",value:0},backgroundPadding:{type:"array",value:[0,0,0,0]},characterSet:{type:"object",value:ii.characterSet},fontFamily:ii.fontFamily,fontWeight:ii.fontWeight,lineHeight:y2,outlineWidth:{type:"number",value:0,min:0},outlineColor:{type:"color",value:qr},fontSettings:{type:"object",value:{},compare:1},wordBreak:"break-word",maxWidth:{type:"number",value:-1},contentCutoffPixels:{type:"array",value:[0,0]},contentAlignHorizontal:"none",contentAlignVertical:"none",getText:{type:"accessor",value:t=>t.text},getPosition:{type:"accessor",value:t=>t.position},getColor:{type:"accessor",value:qr},getSize:{type:"accessor",value:32},getAngle:{type:"accessor",value:0},getTextAnchor:{type:"accessor",value:"middle"},getAlignmentBaseline:{type:"accessor",value:"center"},getPixelOffset:{type:"accessor",value:[0,0]},getContentBox:{type:"accessor",value:[0,0,-1,-1]},backgroundColor:{deprecatedFor:["background","getBackgroundColor"]}};class Za extends ka{constructor(){super(...arguments),this.getBoundingRect=(e,i)=>{const{size:[n,s]}=this.transformParagraph(e,i),{getTextAnchor:r,getAlignmentBaseline:o}=this.props,a=lh[typeof r=="function"?r(e,i):r],c=fh[typeof o=="function"?o(e,i):o];return[(a-1)*n/2,(c-1)*s/2,n,s]},this.getIconOffsets=(e,i)=>{const{getTextAnchor:n,getAlignmentBaseline:s}=this.props,{x:r,y:o,rowWidth:a,size:[,c]}=this.transformParagraph(e,i),l=lh[typeof n=="function"?n(e,i):n],f=fh[typeof s=="function"?s(e,i):s],h=r.length,u=new Array(h*2);let d=0;for(let p=0;p<h;p++)u[d++]=(l-1)*a[p]/2+r[p],u[d++]=(f-1)*c/2+o[p];return u}}initializeState(){this.state={styleVersion:0,fontAtlasManager:new u2},this.props.maxWidth>0&&j.once(1,"v8.9 breaking change: TextLayer maxWidth is now relative to text size")()}updateState(e){const{props:i,oldProps:n,changeFlags:s}=e;(s.dataChanged||s.updateTriggersChanged&&(s.updateTriggersChanged.all||s.updateTriggersChanged.getText))&&this._updateText(),(this._updateFontAtlas()||i.lineHeight!==n.lineHeight||i.wordBreak!==n.wordBreak||i.maxWidth!==n.maxWidth)&&this.setState({styleVersion:this.state.styleVersion+1})}getPickingInfo({info:e}){return e.object=e.index>=0?this.props.data[e.index]:null,e}_updateFontAtlas(){const{fontSettings:e,fontFamily:i,fontWeight:n,_getFontRenderer:s}=this.props,{fontAtlasManager:r,characterSet:o}=this.state,a={...e,characterSet:o,fontFamily:i,fontWeight:n,_getFontRenderer:s};if(!r.mapping)return r.setProps(a),!0;for(const c in a)if(a[c]!==r.props[c])return r.setProps(a),!0;return!1}_updateText(){var c;const{data:e,characterSet:i}=this.props,n=(c=e.attributes)==null?void 0:c.getText;let{getText:s}=this.props,r=e.startIndices,o;const a=i==="auto"&&new Set;if(n&&r){const{texts:l,characterCount:f}=o2({...ArrayBuffer.isView(n)?{value:n}:n,length:e.length,startIndices:r,characterSet:a});o=f,s=(h,{index:u})=>l[u]}else{const{iterable:l,objectInfo:f}=cn(e);r=[0],o=0;for(const h of l){f.index++;const u=Array.from(s(h,f)||"");a&&u.forEach(a.add,a),o+=u.length,r.push(o)}}this.setState({getText:s,startIndices:r,numInstances:o,characterSet:a||i})}transformParagraph(e,i){const{fontAtlasManager:n}=this.state,s=n.mapping,{baselineOffset:r}=n.atlas,{fontSize:o}=n.props,a=this.state.getText,{wordBreak:c,lineHeight:l,maxWidth:f}=this.props,h=a(e,i)||"";return r2(h,r,l*o,c,f*o,s)}renderLayers(){const{startIndices:e,numInstances:i,getText:n,fontAtlasManager:{atlas:s,mapping:r},styleVersion:o}=this.state,{data:a,_dataDiff:c,getPosition:l,getColor:f,getSize:h,getAngle:u,getPixelOffset:d,getBackgroundColor:p,getBorderColor:_,getBorderWidth:m,getContentBox:b,backgroundBorderRadius:A,backgroundPadding:v,background:S,billboard:E,fontSettings:x,outlineWidth:M,outlineColor:O,sizeScale:N,sizeUnits:D,sizeMinPixels:B,sizeMaxPixels:F,contentCutoffPixels:z,contentAlignHorizontal:U,contentAlignVertical:q,transitions:y,updateTriggers:w}=this.props,T=this.getSubLayerClass("characters",Ya),P=this.getSubLayerClass("background",qa),{fontSize:C}=this.state.fontAtlasManager.props;return[S&&new P({getFillColor:p,getLineColor:_,getLineWidth:m,borderRadius:A,padding:v,getPosition:l,getSize:h,getAngle:u,getPixelOffset:d,getClipRect:b,billboard:E,sizeScale:N,sizeUnits:D,sizeMinPixels:B,sizeMaxPixels:F,fontSize:C,transitions:y&&{getPosition:y.getPosition,getAngle:y.getAngle,getSize:y.getSize,getFillColor:y.getBackgroundColor,getLineColor:y.getBorderColor,getLineWidth:y.getBorderWidth,getPixelOffset:y.getPixelOffset}},this.getSubLayerProps({id:"background",updateTriggers:{getPosition:w.getPosition,getAngle:w.getAngle,getSize:w.getSize,getFillColor:w.getBackgroundColor,getLineColor:w.getBorderColor,getLineWidth:w.getBorderWidth,getPixelOffset:w.getPixelOffset,getBoundingRect:{getText:w.getText,getTextAnchor:w.getTextAnchor,getAlignmentBaseline:w.getAlignmentBaseline,styleVersion:o}}}),{data:a.attributes&&a.attributes.background?{length:a.length,attributes:a.attributes.background}:a,_dataDiff:c,autoHighlight:!1,getBoundingRect:this.getBoundingRect}),new T({sdf:x.sdf,smoothing:Number.isFinite(x.smoothing)?x.smoothing:ii.smoothing,outlineWidth:M/(x.radius||ii.radius),outlineColor:O,iconAtlas:s,iconMapping:r,getPosition:l,getColor:f,getSize:h,getAngle:u,getPixelOffset:d,getContentBox:b,billboard:E,sizeScale:N,sizeUnits:D,sizeMinPixels:B,sizeMaxPixels:F,fontSize:C,contentCutoffPixels:z,contentAlignHorizontal:U,contentAlignVertical:q,transitions:y&&{getPosition:y.getPosition,getAngle:y.getAngle,getColor:y.getColor,getSize:y.getSize,getPixelOffset:y.getPixelOffset,getContentBox:y.getContentBox}}
3590,this.getSubLayerProps({id:"characters",updateTriggers:{all:w.getText,getPosition:w.getPosition,getAngle:w.getAngle,getColor:w.getColor,getSize:w.getSize,getPixelOffset:w.getPixelOffset,getContentBox:w.getContentBox,getIconOffsets:{getTextAnchor:w.getTextAnchor,getAlignmentBaseline:w.getAlignmentBaseline,styleVersion:o}}}),{data:a,_dataDiff:c,startIndices:e,numInstances:i,getIconOffsets:this.getIconOffsets,getIcon:n})]}static set fontAtlasCacheLimit(e){h2(e)}}Za.defaultProps=b2;Za.layerName="TextLayer";const Zn={circle:{type:ja,props:{filled:"filled",stroked:"stroked",lineWidthMaxPixels:"lineWidthMaxPixels",lineWidthMinPixels:"lineWidthMinPixels",lineWidthScale:"lineWidthScale",lineWidthUnits:"lineWidthUnits",pointRadiusMaxPixels:"radiusMaxPixels",pointRadiusMinPixels:"radiusMinPixels",pointRadiusScale:"radiusScale",pointRadiusUnits:"radiusUnits",pointAntialiasing:"antialiasing",pointBillboard:"billboard",getFillColor:"getFillColor",getLineColor:"getLineColor",getLineWidth:"getLineWidth",getPointRadius:"getRadius"}},icon:{type:ir,props:{iconAtlas:"iconAtlas",iconMapping:"iconMapping",iconSizeMaxPixels:"sizeMaxPixels",iconSizeMinPixels:"sizeMinPixels",iconSizeScale:"sizeScale",iconSizeUnits:"sizeUnits",iconAlphaCutoff:"alphaCutoff",iconBillboard:"billboard",getIcon:"getIcon",getIconAngle:"getAngle",getIconColor:"getColor",getIconPixelOffset:"getPixelOffset",getIconSize:"getSize"}},text:{type:Za,props:{textSizeMaxPixels:"sizeMaxPixels",textSizeMinPi
vendor: 7,198 bytes, line 3590
3590xels:"sizeMinPixels",textSizeScale:"sizeScale",textSizeUnits:"sizeUnits",textBackground:"background",textBackgroundPadding:"backgroundPadding",textFontFamily:"fontFamily",textFontWeight:"fontWeight",textLineHeight:"lineHeight",textMaxWidth:"maxWidth",textOutlineColor:"outlineColor",textOutlineWidth:"outlineWidth",textWordBreak:"wordBreak",textCharacterSet:"characterSet",textBillboard:"billboard",textFontSettings:"fontSettings",getText:"getText",getTextAngle:"getAngle",getTextColor:"getColor",getTextPixelOffset:"getPixelOffset",getTextSize:"getSize",getTextAnchor:"getTextAnchor",getTextAlignmentBaseline:"getAlignmentBaseline",getTextBackgroundColor:"getBackgroundColor",getTextBorderColor:"getBorderColor",getTextBorderWidth:"getBorderWidth"}}},Gn={type:Ha,props:{lineWidthUnits:"widthUnits",lineWidthScale:"widthScale",lineWidthMinPixels:"widthMinPixels",lineWidthMaxPixels:"widthMaxPixels",lineJointRounded:"jointRounded",lineCapRounded:"capRounded",lineMiterLimit:"miterLimit",lineBillboard:"billboard",getLineColor:"getColor",getLineWidth:"getWidth"}},ea={type:Xa,props:{extruded:"extruded",filled:"filled",wireframe:"wireframe",elevationScale:"elevationScale",material:"material",_full3d:"_full3d",getElevation:"getElevation",getFillColor:"getFillColor",getLineColor:"getLineColor"}};function Ri({type:t,props:e}){const i={};for(const n in e)i[n]=t.defaultProps[e[n]];return i}function Zr(t,e){const{transitions:i,updateTriggers:n}=t.props,s={updateTriggers:{},transitions:i&&{getPosition:i.geometry}};for(const r in e){const o=e[r];let a=t.props[r];r.startsWith("get")&&(a=t.getSubLayerAccessor(a),s.updateTriggers[o]=n[r],i&&(s.transitions[o]=i[r])),s[o]=a}return s}function v2(t){if(Array.isArray(t))return t;switch(j.assert(t.type,"GeoJSON does not have type"),t.type){case"Feature":return[t];case"FeatureCollection":return j.assert(Array.isArray(t.features),"GeoJSON does not have features array"),t.features;default:return[{geometry:t}]}}function hh(t,e,i={}){const n={pointFeatures:[],lineFeatures:[],polygonFeatures:[],polygonOutlineFeatures:[]},{startRow:s=0,endRow:r=t.length}=i;for(let o=s;o<r;o++){const a=t[o],{geometry:c}=a;if(c)if(c.type==="GeometryCollection"){j.assert(Array.isArray(c.geometries),"GeoJSON does not have geometries array");const{geometries:l}=c;for(let f=0;f<l.length;f++){const h=l[f];uh(h,n,e,a,o)}}else uh(c,n,e,a,o)}return n}function uh(t,e,i,n,s){const{type:r,coordinates:o}=t,{pointFeatures:a,lineFeatures:c,polygonFeatures:l,polygonOutlineFeatures:f}=e;if(!A2(r,o)){j.warn(`${r} coordinates are malformed`)();return}switch(r){case"Point":a.push(i({geometry:t},n,s));break;case"MultiPoint":o.forEach(h=>{a.push(i({geometry:{type:"Point",coordinates:h}},n,s))});break;case"LineString":c.push(i({geometry:t},n,s));break;case"MultiLineString":o.forEach(h=>{c.push(i({geometry:{type:"LineString",coordinates:h}},n,s))});break;case"Polygon":l.push(i({geometry:t},n,s)),o.forEach(h=>{f.push(i({geometry:{type:"LineString",coordinates:h}},n,s))});break;case"MultiPolygon":o.forEach(h=>{l.push(i({geometry:{type:"Polygon",coordinates:h}},n,s)),h.forEach(u=>{f.push(i({geometry:{type:"LineString",coordinates:u}},n,s))})});break}}const T2={Point:1,MultiPoint:2,LineString:2,MultiLineString:3,Polygon:3,MultiPolygon:4};function A2(t,e){let i=T2[t];for(j.assert(i,`Unknown GeoJSON type ${t}`);e&&--i>0;)e=e[0];return e&&Number.isFinite(e[0])}function Mg(){return{points:{},lines:{},polygons:{},polygonsOutline:{}}}function Un(t){return t.geometry.coordinates}function w2(t,e){const i=Mg(),{pointFeatures:n,lineFeatures:s,polygonFeatures:r,polygonOutlineFeatures:o}=t;return i.points.data=n,i.points._dataDiff=e.pointFeatures&&(()=>e.pointFeatures),i.points.getPosition=Un,i.lines.data=s,i.lines._dataDiff=e.lineFeatures&&(()=>e.lineFeatures),i.lines.getPath=Un,i.polygons.data=r,i.polygons._dataDiff=e.polygonFeatures&&(()=>e.polygonFeatures),i.polygons.getPolygon=Un,i.polygonsOutline.data=o,i.polygonsOutline._dataDiff=e.polygonOutlineFeatures&&(()=>e.polygonOutlineFeatures),i.polygonsOutline.getPath=Un,i}function S2(t,e){const i=Mg(),{points:n,lines:s,polygons:r}=t,o=HC(t,e);i.points.data={length:n.positions.value.length/n.positions.size,attributes:{...n.attributes,getPosition:n.positions,instancePickingColors:{size:4,value:o.points}},properties:n.properties,numericProps:n.numericProps,featureIds:n.featureIds},i.lines.data={length:s.pathIndices.value.length-1,startIndices:s.pathIndices.value,attributes:{...s.attributes,getPath:s.positions,instancePickingColors:{size:4,value:o.lines}},properties:s.properties,numericProps:s.numericProps,featureIds:s.featureIds},i.lines._pathType="open";const a=r.positions.value.length/r.positions.size,c=Array(a).fill(1);for(const l of r.primitivePolygonIndices.value)c[l-1]=0;return i.polygons.data={length:r.polygonIndices.value.length-1,startIndices:r.polygonIndices.value,attributes:{...r.attributes,getPolygon:r.positions,instanceVertexValid:{size:1,value:new Uint16Array(c)},pickingColors:{size:4,value:o.polygons}},properties:r.properties,numericProps:r.numericProps,featureIds:r.featureIds},i.polygons._normalize=!1,r.triangles&&(i.polygons.data.attributes.indices=r.triangles.value),i.polygonsOutline.data={length:r.primitivePolygonIndices.value.length-1,startIndices:r.primitivePolygonIndices.value,attributes:{...r.attributes,getPath:r.positions,instancePickingColors:{size:4,value:o.polygons}},properties:r.properties,numericProps:r.numericProps,featureIds:r.featureIds},i.polygonsOutline._pathType="open",i}const E2=["points","linestrings","polygons"],x2={...Ri(Zn.circle),...Ri(Zn.icon),...Ri(Zn.text),...Ri(Gn),...Ri(ea),stroked:!0,filled:!0,extruded:!1,wireframe:!1,_full3d:!1,iconAtlas:{type:"object",value:null},iconMapping:{type:"object",value:{}},getIcon:{type:"accessor",value:t=>t.properties.icon},getText:{type:"accessor",value:t=>t.properties.text},pointType:"circle",getRadius:{deprecatedFor:"getPointRadius"}};class Og extends ka{initializeState(){this.state={layerProps:{},features:{},featuresDiff:{}}}updateState({props:e,changeFlags:i}){if(!i.dataChanged)return;const{data:n}=this.props,s=n&&"points"in n&&"polygons"in n&&"lines"in n;this.setState({binary:s}),s?this._updateStateBinary({props:e,changeFlags:i}):this._updateStateJSON({props:e,changeFlags:i})}_updateStateBinary({props:e,changeFlags:i}){const n=S2(e.data,this.encodePickingColor);this.setState({layerProps:n})}_updateStateJSON({props:e,changeFlags:i}){const n=v2(e.data),s=this.getSubLayerRow.bind(this);let r={};const o={};if(Array.isArray(i.dataChanged)){const c=this.state.features;for(const l in c)r[l]=c[l].slice(),o[l]=[];for(const l of i.dataChanged){const f=hh(n,s,l);for(const h in c)o[h].push(VC({data:r[h],getIndex:u=>u.__source.index,dataRange:l,replace:f[h]}))}}else r=hh(n,s);const a=w2(r,o);this.setState({features:r,featuresDiff:o,layerProps:a})}getPickingInfo(e){const i=super.getPickingInfo(e),{index:n,sourceLayer:s}=i;return i.featureType=E2.find(r=>s.id.startsWith(`${this.id}-${r}-`)),n>=0&&s.id.startsWith(`${this.id}-points-text`)&&this.state.binary&&(i.index=this.props.data.points.globalFeatureIds.value[n]),i}_updateAutoHighlight(e){const i=`${this.id}-points-`,n=e.featureType==="points";
3590for(const s of this.getSubLayers())s.id.startsWith(i)===n&&s.updateAutoHighlight(e)}_renderPolygonLayer(){var o;const{extruded:e,wireframe:i}=this.props,{layerProps:n}=this.state,s="polygons-fill",r=this.shouldRenderSubLayer(s,(o=n.polygons)==null?void 0:o.data)&&this.getSubLayerClass(s,ea.type);if(r){const a=Zr(this,ea.props),c=e&&i;return c||delete a.getLineColor,a.updateTriggers.lineColors=c,new r(a,this.getSubLayerProps({id:s,updateTriggers:a.updateTriggers}),n.polygons)}return null}_renderLineLayers(){var c,l;const{extruded:e,stroked:i}=this.props,{layerProps:n}=this.state,s="polygons-stroke",r="linestrings",o=!e&&i&&this.shouldRenderSubLayer(s,(c=n.polygonsOutline)==null?void 0:c.data)&&this.getSubLayerClass(s,Gn.type),a=this.shouldRenderSubLayer(r,(l=n.lines)==null?void 0:l.data)&&this.getSubLayerClass(r,Gn.type);if(o||a){const f=Zr(this,Gn.props);return[o&&new o(f,this.getSubLayerProps({id:s,updateTriggers:f.updateTriggers}),n.polygonsOutline),a&&new a(f,this.getSubLayerProps({id:r,updateTriggers:f.updateTriggers}),n.lines)]}return null}_renderPointLayers(){var a;const{pointType:e}=this.props,{layerProps:i,binary:n}=this.state;let{highlightedObjectIndex:s}=this.props;!n&&Number.isFinite(s)&&(s=i.points.data.findIndex(c=>c.__source.index===s));const r=new Set(e.split("+")),o=[];for(const c of r){const l=`points-${c}`,f=Zn[c],h=f&&this.shouldRenderSubLayer(l,(a=i.points)==null?void 0:a.data)&&this.getSubLayerClass(l,f.type);if(h){const u=Zr(this,f.props);let d=i.points;if(c==="text"&&n){const{instancePickingColors:p,..._}=d.data.attributes;d={...d,data:{...d.data,attributes:_}}}o.push(new h(u,this.getSubLayerProps({id:l,updateTriggers:u.updateTriggers,highlightedObjectIndex:s}),d))}}return o}renderLayers(){const{extruded:e}=this.props,i=this._renderPolygonLayer(),n=this._renderLineLayers(),s=this._renderPointLayers();return[!e&&i,n,s,e&&i]}getSubLayerAccessor(e){const{binary:i}=this.state;return!i||typeof e!="function"?super.getSubLayerAccessor(e):(n,s)=>{const{data:r,index:o}=s,a=$C(r,o);return e(a,s)}}}Og.layerName="GeoJsonLayer";Og.defaultProps=x2;export{cw as A,ug as B,ka as C,F2 as D,N2 as E,gd as G,ir as I,pg as L,fu as M,B2 as P,O2 as Q,C2 as R,ja as S,Za as T,je as V,li as W,ec as _,Mc as a,I2 as b,Le as c,Og as d,Ki as e,Ca as f,M2 as g,td as h,W2 as i,j2 as j,V2 as k,gt as l,U2 as m,$2 as n,k2 as o,H2 as p,X2 as q,z2 as s};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.