@aibee/crc-bmap 0.2.24 → 0.2.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/bmap.cjs.min.js +2 -2
- package/lib/bmap.cjs.min.js.map +2 -2
- package/lib/bmap.esm.js +5 -3
- package/lib/bmap.esm.js.map +2 -2
- package/lib/bmap.esm.min.js +2 -2
- package/lib/bmap.esm.min.js.map +2 -2
- package/lib/bmap.min.js +2 -2
- package/lib/bmap.min.js.map +2 -2
- package/package.json +1 -1
package/lib/bmap.cjs.min.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var ui=Object.create;var Ee=Object.defineProperty;var ci=Object.getOwnPropertyDescriptor;var hi=Object.getOwnPropertyNames;var pi=Object.getPrototypeOf,fi=Object.prototype.hasOwnProperty;var Tt=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports),di=(s,e)=>{for(var t in e)Ee(s,t,{get:e[t],enumerable:!0})},Vn=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of hi(e))!fi.call(s,r)&&r!==t&&Ee(s,r,{get:()=>e[r],enumerable:!(n=ci(e,r))||n.enumerable});return s};var $t=(s,e,t)=>(t=s!=null?ui(pi(s)):{},Vn(e||!s||!s.__esModule?Ee(t,"default",{value:s,enumerable:!0}):t,s)),gi=s=>Vn(Ee({},"__esModule",{value:!0}),s);var Wn=Tt((go,Hn)=>{Hn.exports=function(e,t){return e[0]=t[0],e[1]=t[1],e}});var jn=Tt((mo,qn)=>{var Xn=Wn();qn.exports=function(s,e){Array.isArray(e)||(e=[]),s.length>0&&e.push(Xn([0,0],s[0]));for(var t=0;t<s.length-1;t++){var n=s[t],r=s[t+1],i=n[0],o=n[1],a=r[0],u=r[1],l=[.75*i+.25*a,.75*o+.25*u],c=[.25*i+.75*a,.25*o+.75*u];e.push(l),e.push(c)}return s.length>1&&e.push(Xn([0,0],s[s.length-1])),e}});var Jn=Tt((vo,Zn)=>{var fn=class{constructor(){this.keys=new Set,this.queue=[]}sort(){this.queue.sort((e,t)=>e.priority-t.priority)}set(e,t){let n=Number(t);if(isNaN(n))throw new TypeError('"priority" must be a number');return this.keys.has(e)?this.queue.map(r=>(r.key===e&&Object.assign(r,{priority:n}),r)):(this.keys.add(e),this.queue.push({key:e,priority:n})),this.sort(),this.queue.length}next(){let e=this.queue.shift();return this.keys.delete(e.key),e}isEmpty(){return this.queue.length===0}has(e){return this.keys.has(e)}get(e){return this.queue.find(t=>t.key===e)}};Zn.exports=fn});var er=Tt((xo,tr)=>{function Qn(s,e){let t=new Map;for(let[n,r]of s)n!==e&&r instanceof Map?t.set(n,Qn(r,e)):n!==e&&t.set(n,r);return t}tr.exports=Qn});var ir=Tt((Eo,rr)=>{function Ti(s){let e=Number(s);return!(isNaN(e)||e<=0)}function nr(s){let e=new Map;return Object.keys(s).forEach(n=>{let r=s[n];if(r!==null&&typeof r=="object"&&!Array.isArray(r))return e.set(n,nr(r));if(!Ti(r))throw new Error(`Could not add node at key "${n}", make sure it's a valid node`,r);return e.set(n,Number(r))}),e}rr.exports=nr});var ar=Tt((bo,sr)=>{function or(s){if(!(s instanceof Map))throw new Error(`Invalid graph: Expected Map instead found ${typeof s}`);s.forEach((e,t)=>{if(typeof e=="object"&&e instanceof Map){or(e);return}if(typeof e!="number"||e<=0)throw new Error(`Values must be numbers greater than 0. Found value ${e} at ${t}`)})}sr.exports=or});var gn=Tt((So,cr)=>{var Ci=Jn(),Pi=er(),lr=ir(),ur=ar(),dn=class{constructor(e){e instanceof Map?(ur(e),this.graph=e):e?this.graph=lr(e):this.graph=new Map}addNode(e,t){let n;return t instanceof Map?(ur(t),n=t):n=lr(t),this.graph.set(e,n),this}addVertex(e,t){return this.addNode(e,t)}removeNode(e){return this.graph=Pi(this.graph,e),this}path(e,t,n={}){if(!this.graph.size)return n.cost?{path:null,cost:0}:null;let r=new Set,i=new Ci,o=new Map,a=[],u=0,l=[];if(n.avoid&&(l=[].concat(n.avoid)),l.includes(e))throw new Error(`Starting node (${e}) cannot be avoided`);if(l.includes(t))throw new Error(`Ending node (${t}) cannot be avoided`);for(i.set(e,0);!i.isEmpty();){let c=i.next();if(c.key===t){u=c.priority;let f=c.key;for(;o.has(f);)a.push(f),f=o.get(f);break}r.add(c.key),(this.graph.get(c.key)||new Map).forEach((f,d)=>{if(r.has(d)||l.includes(d))return null;if(!i.has(d))return o.set(d,c.key),i.set(d,c.priority+f);let m=i.get(d).priority,p=c.priority+f;return p<m?(o.set(d,c.key),i.set(d,p)):null})}return a.length?(n.trim?a.shift():a=a.concat([e]),n.reverse||(a=a.reverse()),n.cost?{path:a,cost:u}:a):n.cost?{path:null,cost:0}:null}shortestPath(...e){return this.path(...e)}};cr.exports=dn});var Yi={};di(Yi,{AibeeLoader:()=>zn,BMap:()=>Mn,BMapSelect:()=>Nn,BaseSvg:()=>$,Context:()=>ge,CrLoader:()=>kn,CrNavPath:()=>Ln,Equipment:()=>wn,Events:()=>an,Floor:()=>lt,GlbModel:()=>ue,Graphic:()=>A,GraphicLayer:()=>ie,GroundTexture:()=>Wt,HeatmapElement:()=>ne,HooksName:()=>Vt,HoverHelper:()=>de,Lane:()=>ce,Layer:()=>O,MapTypePolar:()=>Br,MergeGraphic:()=>he,Model:()=>re,MulFloors:()=>Pn,NavPath:()=>In,Navigation:()=>Cn,Overlay:()=>ee,PathDirection:()=>hn,PdrPosition:()=>Dn,Poi:()=>Et,Poi2:()=>X,PoiLayer:()=>Ft,PoiLayer2:()=>oe,RoadNetwork:()=>mn,RoadNetwork2:()=>_n,SelectBox:()=>vn,Selection:()=>fe,Sensor:()=>ye,Shadow:()=>te,SvgLine:()=>se,SvgPolygon:()=>ae,TextTexture:()=>pe,Timer:()=>L,TweenUtil:()=>Nt,UA:()=>on,Wall:()=>le,addAlphaToHexColor:()=>xi,calc_angle:()=>Qe,calc_direction:()=>Se,convertToSnakeCase:()=>yn,createCircle:()=>zt,createLine:()=>Jt,createRect:()=>gt,createSvg:()=>nn,createSvgElement:()=>Zt,createThreeBox:()=>Ri,createThreeLine:()=>Ii,darkenColor:()=>ht,defaultAibeeLoaderOption:()=>ji,defaultConfig:()=>Fr,defaultGraphicOptions:()=>we,defaultOptions:()=>Sr,defaultTextTextureOptions:()=>Ar,dispose:()=>k,distancePointToSegment:()=>cn,generatorKeyByObj:()=>Rt,getAngle:()=>$n,getCenter:()=>Kt,getConfig:()=>Sn,getDirectPath:()=>wi,getDistanceByPathPos:()=>pn,getLength:()=>N,getLongestSideDir:()=>mi,getMinEdgeSquare:()=>tn,getPathLength:()=>ot,getPointEdgeIndex:()=>Ct,getPosByPathDistance:()=>Qt,hasChinese:()=>Je,hexToRgb:()=>be,initDirectionalLight:()=>Ze,initLight:()=>Ke,initShape:()=>it,isAndroid:()=>Ei,isContain:()=>dt,isControl:()=>It,isIphone:()=>kt,isMac:()=>At,isPointInPolygon:()=>en,loadBuildingGround:()=>On,loadExternalStreet:()=>Vi,loadGraphics:()=>Fn,moveOnRoute:()=>Mi,proxyOptions:()=>Pt,removeWeightPath:()=>Kn,setCirclePosition:()=>_t,setLineStartEnd:()=>J,setRectPosition:()=>B,simplifyPath:()=>un,sleepOnePromise:()=>rn,sleepOneRf:()=>yi,smoothPath:()=>ln,strToNumber:()=>vi,timeoutPromise:()=>ct,toWebWorker:()=>Ai,transformGraphicData:()=>W,translatePosToCenter:()=>et,triggerWorker:()=>st,vector3ToDevice:()=>y,xhrGet:()=>bi});module.exports=gi(Yi);var Be=require("three");var L=class{tasks={requestAnimation:new Set,timeout:new Set,interval:new Set};requestAnimationFrame(e){let t=window.requestAnimationFrame(()=>{this.tasks.requestAnimation.delete(t),e()});return this.tasks.requestAnimation.add(t),t}cancelAnimationFrame(e){this.tasks.requestAnimation.delete(e),window.cancelAnimationFrame(e)}setTimeout(e,t){let n=window.setTimeout(()=>{this.tasks.timeout.delete(n),e()},t);return this.tasks.timeout.add(n),n}clearTimeout(e){this.tasks.timeout.delete(e),window.clearTimeout(e)}setInterval(e,t){let n=window.setInterval(()=>{this.tasks.interval.delete(n),e()},t);return this.tasks.interval.add(n),n}clearInterval(e){this.tasks.interval.delete(e),window.clearInterval(e)}dispose(){this.tasks.requestAnimation.forEach(e=>{window.cancelAnimationFrame(e)}),this.tasks.requestAnimation.clear(),this.tasks.timeout.forEach(e=>{window.clearTimeout(e)}),this.tasks.timeout.clear(),this.tasks.interval.forEach(e=>{window.clearInterval(e)}),this.tasks.interval.clear()}};var Y=require("three");function Ke(){let s=new Y.Group,e=new Y.AmbientLight(16777215,2.6);return s.add(e),s}function it(s,e=[]){let t=new Y.Shape(s.map(n=>new Y.Vector2(...n)));return e.length&&e.forEach(n=>{var r=new Y.Path(n.map(i=>new Y.Vector2(...i)));t.holes.push(r)}),t}function Ze(s=16777215,e=1){let t=new Y.DirectionalLight(s,e);return t.castShadow=!0,t.shadow.radius=8,t.shadow.bias=-.001,t.shadow.mapSize.set(256,256),t.shadow.camera.left=-200,t.shadow.camera.right=200,t.shadow.camera.top=200,t.shadow.camera.bottom=-200,t}function k(s,e){if(e&&s.children&&s.children.length&&s.children.forEach(t=>{k(t,e)}),s.isMesh){let t=s;t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach(n=>{n.dispose()}):t.material.dispose())}s.isLight&&s.dispose?.()}function Je(s){return/[\u4E00-\u9FA5]+/g.test(s)}var T=require("three"),Gt=require("@turf/turf");function y(s,e,t,n){let r=s.clone().project(e),i=t/2,o=n/2,a=Math.round(r.x*i+i),u=Math.round(-r.y*o+o);return{x:a,y:u}}function Kt(s){let e=(0,Gt.featureCollection)(s.map(n=>(0,Gt.point)(n)));return(0,Gt.center)(e).geometry.coordinates}function dt(s,e,t){return s.x>=e.x&&s.x<=t.x&&s.y>=e.y&&s.y<=t.y}function mi(s){let e=0,t=new T.Vector3;for(let n=1;n<s.length;n++){let r=new T.Vector3(s[n-1][0],s[n-1][1],0),i=new T.Vector3(s[n][0],s[n][1],0),o=i.distanceTo(r);o>e&&(e=o,t=i.clone().sub(r).normalize())}return t}function N(s,e){return Math.sqrt((e[0]-s[0])**2+(e[1]-s[1])**2)}function ot(s){let e=0;for(let t=0;t<s.length-1;t++)e+=N(s[t],s[t+1]);return e}function Qe(s,e,t){let n=new T.Vector2(e[0]-s[0],e[1]-s[1]),r=new T.Vector2(e[0]-t[0],e[1]-t[1]),o=n.angleTo(r)*180/Math.PI,a=new T.Vector2(e[0]-s[0],e[1]-s[1]);return new T.Vector2(t[0]-s[0],t[1]-s[1]).cross(a)>0?o:-o}function tn(s,e){let t=Math.min(N(s[0][0],s[0][1]),N(s[0][2],s[0][1]))-1;e||(e=Kt(s[0]));let n=_i(e,t),r=new T.Vector2(s[0][0][0],s[0][0][1]),i=new T.Vector2(s[0][1][0],s[0][1][1]),o=new T.Vector2(s[0][2][0],s[0][2][1]),u=(r.distanceTo(i)>i.distanceTo(o)?i.clone().sub(r):o.clone().sub(i)).angleTo(new T.Vector2(0,1)),l=new T.Matrix3;return l.multiply(new T.Matrix3().translate(e[0],e[1])).multiply(new T.Matrix3().rotate(u)).multiply(new T.Matrix3().translate(-e[0],-e[1])),[n.map(c=>{let h=new T.Vector2(c[0],c[1]).applyMatrix3(l);return[h.x,h.y]})]}function _i(s,e){let t=e/2;return[[s[0]-t,s[1]+t],[s[0]+t,s[1]+t],[s[0]+t,s[1]-t],[s[0]-t,s[1]-t],[s[0]-t,s[1]+t]]}function Ct(s,e){let t=0,n=1/0,[r,i]=e;for(let o=0;o<s.length-1;o++){let[a,u]=s[o],[l,c]=s[o+1],h=Math.min(a,l)<=r&&r<=Math.max(a,l),f=Math.min(u,c)<=i&&i<=Math.max(u,c);if(h&&f){let d=Math.abs((l-a)*(i-u)-(c-u)*(r-a));d<n&&(n=d,t=o)}}return t}function en(s,e){let t=s[0],n=s[1],r=!1;for(let i=0,o=e.length-1;i<e.length;o=i++){let a=e[i][0],u=e[i][1],l=e[o][0],c=e[o][1];u>n!=c>n&&t<(l-a)*(n-u)/(c-u)+a&&(r=!r)}return r}function Pt(s,e){return new Proxy(s,{get:(t,n,r)=>Reflect.get(t,n,r),set:(t,n,r,i)=>{let o=Reflect.get(t,n,i),a=Reflect.set(t,n,r,i);return o!==r&&e.dispatchEvent({type:`change-${n}`,value:r}),a}})}function ct(s,e){return Promise.race([s,new Promise((t,n)=>{setTimeout(()=>n(new Error("Promise timeout")),e)})])}function Zt(s){return document.createElementNS("http://www.w3.org/2000/svg",s)}function nn(s,e){let t=Zt("svg");return t.setAttribute("width",s),t.setAttribute("height",e),t.style.cssText="position: absolute; left: 0; top: 0; pointer-events: none;",t}function zt(s="2",e){let t=Zt("circle");return t.setAttribute("r",s),t.setAttribute("fill",e),t}function Jt(s){let e=Zt("line");return e.setAttribute("stroke",s),e}function gt(s,e){let t=Zt("rect");return t.setAttribute("stroke",s),t.setAttribute("fill",e),t}function _t(s,e,t){s.setAttribute("cx",`${e}`),s.setAttribute("cy",`${t}`)}function J(s,e,t){e&&(s.setAttribute("x1",`${e.x}`),s.setAttribute("y1",`${e.y}`)),t&&(s.setAttribute("x2",`${t.x}`),s.setAttribute("y2",`${t.y}`))}function B(s,e,t,n,r){s.setAttribute("x",`${e}`),s.setAttribute("y",`${t}`),s.setAttribute("width",`${n}`),s.setAttribute("height",`${r}`)}function rn(){return Promise.resolve()}function yi(){return new Promise(s=>{requestAnimationFrame(s)})}function vi(s){return parseInt(s.replace("#","0x"),16)}function xi(s,e){let t=parseInt(s.substring(1,3),16),n=parseInt(s.substring(3,5),16),r=parseInt(s.substring(5,7),16),i=Math.round(t*e),o=Math.round(n*e),a=Math.round(r*e);return`#${(1<<24|i<<16|o<<8|a).toString(16).slice(1)}`}function ht(s,e=.85){let t,n,r;if(s.startsWith("#"))t=parseInt(s.substring(1,3),16),n=parseInt(s.substring(3,5),16),r=parseInt(s.substring(5,7),16);else{let o=s.slice(4,-1).split(",");t=parseInt(o[0].trim()),n=parseInt(o[1].trim()),r=parseInt(o[2].trim())}return t=Math.min(Math.floor(t*e),255),n=Math.min(Math.floor(n*e),255),r=Math.min(Math.floor(r*e),255),"#"+((1<<24)+(t<<16)+(n<<8)+r).toString(16).slice(1)}function be(s,e){s=s.replace(/^#/,"");let t=parseInt(s.substring(0,2),16),n=parseInt(s.substring(2,4),16),r=parseInt(s.substring(4,6),16);return e!==void 0?`rgba(${t}, ${n}, ${r}, ${e})`:`rgb(${t}, ${n}, ${r})`}var At=navigator.userAgent.toUpperCase().indexOf("MAC")>=0,on=(window.navigator.userAgent||"").toLocaleLowerCase(),kt=/ios|iphone/i.test(on),Ei=/android|adr|linux/gi.test(on);function It(s){return At?s==="Meta":s==="Control"}var sn="__once__",an=class{events=new Map;on(e,t){if(typeof t!="function")return;let n=this.events.get(e);return n?n.add(t):this.events.set(e,new Set([t]))}once(e,t){if(typeof t!="function")return;let n=`${sn}${e}`,r=this.events.get(n);return r?r.add(t):this.events.set(n,new Set([t]))}off(e,t){let n=this.events.get(e),r=this.events.get(`${sn}${e}`);!n&&!r||(t===void 0&&(n?.clear(),r?.clear()),n?.has(t)&&n.delete(t),r?.has(t)&&r.delete(t))}offAll(){this.events.clear()}emit(e,...t){let n=this.events.get(e),r=this.events.get(`${sn}${e}`);!n&&!r||(n?.forEach(i=>{typeof i=="function"&&i(...t)}),r?.forEach(i=>{typeof i=="function"&&i(...t)}),r?.clear())}};var Vt=(t=>(t.SWITCH_FLOOR_BEFORE="switch_floor_before",t.SWITCH_FLOOR_AFTER="switch_floor_after",t))(Vt||{});function Rt(s){return Object.keys(s).sort().map(e=>`${e}=${s[e]}`).join("&")}function bi(s,e){return new Promise((t,n)=>{let r=new XMLHttpRequest;r.open("GET",s,!0),Object.keys(e.headers||{}).forEach(i=>{r.setRequestHeader(i,e.headers[i])}),e.responseType&&(r.responseType=e.responseType),r.onload=()=>{if(r.status>=200&&r.status<300)if(e.responseType==="arraybuffer")t(r.response);else try{let i=JSON.parse(r.responseText);t(i)}catch(i){n(i)}else n(r.statusText)},r.onerror=()=>{n(r.statusText)},r.send()})}var Ht=require("three"),Yn=$t(jn(),1);function $n(s,e){let t=s.clone().normalize(),n=e.clone().normalize();return Math.acos(t.dot(n))}function Si(s){let e=0;return s.reduce(([t,n],[r,i])=>(e+=Math.sqrt((r-t)**2+(i-n)**2),[r,i])),e/s.length}function ln(s,e=.25){if(Si(s)<e)return s;let t=(0,Yn.default)(s);return ln(t,e)}function un(s,e=!1,t=!0,n=5,r=150,i=3){let o=[],a=!e;if(o.push(s[0]),s.length<2)return o;for(let l=0;l<s.length-2;l+=1){let c=s[l],h=s[l+1],f=s[l+2],d=new Ht.Vector2(c[0]-h[0],c[1]-h[1]),m=new Ht.Vector2(f[0]-h[0],f[1]-h[1]),p=$n(d,m)/Math.PI*180,g=d.length()+m.length();(!a||p<r&&g>.01||g>n)&&(o.push(s[l+1]),a=!0)}if(o.push(s[s.length-1]),!t)return o;let u=[];u.push(o[0]);for(let l=0;l<o.length-2;l+=1){let c=new Ht.Vector2(o[l][0],o[l][1]),h=new Ht.Vector2(o[l+1][0],o[l+1][1]),f=new Ht.Vector2(o[l+2][0],o[l+2][1]),d=c.distanceTo(h)/2,m=f.distanceTo(h)/2,p=h.clone(),g=h.clone();p.add(c.clone().sub(h).normalize().multiplyScalar(d>i?i/2:d)),g.add(f.clone().sub(h).normalize().multiplyScalar(m>i?i/2:m));let E=[[p.x,p.y],[h.x,h.y],[g.x,g.y]];u.push(...ln(E,i/25))}return u.push(o[o.length-1]),Kn(u)}function Kn(s){if(s.length<=1)return s;let e=[],t;return s.forEach(([n,r])=>{t?n===t[0]&&r===t[1]||(t=[n,r],e.push([n,r])):(t=[n,r],e.push([n,r]))}),e}function cn(s,e,t){let n=Math.sqrt((t[0]-e[0])**2+(t[1]-e[1])**2);if(n===0)return{distance:Math.sqrt((s[0]-e[0])**2+(s[1]-e[1])**2),closestPoint:e.slice(0)};let r=Math.max(0,Math.min(1,((s[0]-e[0])*(t[0]-e[0])+(s[1]-e[1])*(t[1]-e[1]))/n**2)),i=[e[0]+r*(t[0]-e[0]),e[1]+r*(t[1]-e[1])];return{distance:Math.sqrt((s[0]-i[0])**2+(s[1]-i[1])**2),closestPoint:i}}function Mi(s,e,t){let[n,r]=s,[i,o]=e,a=Math.sqrt(Math.pow(i-n,2)+Math.pow(o-r,2));if(a===0||a<t)return[...e];let u=t/a,l=n+(i-n)*u,c=r+(o-r)*u;return[l,c]}var hn=(l=>(l.START="start",l.END="end",l.FRONT="front",l.RIGHT="right",l.LEFT="left",l.RIGHT_FRONT="right_front",l.LEFT_FRONT="left_front",l.RIGHT_BACK="right_back",l.LEFT_BACK="left_back",l))(hn||{});function Se(s,e,t){let n=Qe(s,e,t);return 180-Math.abs(n)<15?"front":n>135?"right_front":n<-135?"left_front":n<=135&&n>=60?"right":n>=-135&&n<=-60?"left":n<60&&n>0?"right_back":n>-60&&n<0?"left_back":"front"}function wi(s){if(!s.length)return[];let e=[{direction:"start",distance:N(s[0],s[1]),points:[s[0],s[1]]}];for(let t=2;t<s.length;t++){let n=Se(s[t-2],s[t-1],s[t]);if(n==="front"){let r=e[e.length-1],i=N(s[t-1],s[t]);r.distance+=i,t!==2&&r.points.push(s[t-1])}else e.push({direction:n,distance:N(s[t-1],s[t]),points:[s[t-1],s[t]]})}return e.push({direction:"end",distance:0,points:[s[s.length-1]]}),e}function pn(s,e){if(s.length<2)return-1;let t=0;for(let n=1;n<s.length;n++){let r=s[n-1],i=s[n],o=[e[0]-r[0],e[1]-r[1]],a=[i[0]-r[0],i[1]-r[1]],u=Math.min(i[0],r[0])<=e[0]&&e[0]<=Math.max(i[0],r[0]),l=Math.min(i[1],r[1])<=e[1]&&e[1]<=Math.max(i[1],r[1]);if(u&&l){let c=o[0]*a[1]-o[1]*a[0];if(Math.abs(c)<1e-6){let h=Math.sqrt((e[0]-r[0])**2+(e[1]-r[1])**2);return t+h}}t+=Math.sqrt((i[0]-r[0])**2+(i[1]-r[1])**2)}return-1}function Qt(s,e){if(s.length<2)return s[0]??null;let t=0;for(let n=1;n<s.length;n++){let r=s[n-1],i=s[n],o=Math.sqrt((i[0]-r[0])**2+(i[1]-r[1])**2);if(t+=o,t>=e){let a=(e-(t-o))/o,u=r[0]+(i[0]-r[0])*a,l=r[1]+(i[1]-r[1])*a;return[u,l]}}return null}var pt=$t(gn(),1);var Q="___",mn=class{constructor(e=3){this.lift_priority=e}roadInfo=[];pointMap=new Map;nodeMap=new Map;facilityMap=new Map;straightLadderMap=new Map;escalatorMap=new Map;staircaseMap=new Map;lineMap=new Map;baseRoute=new pt.default;escalatorRoute=new pt.default;straightLadderRoute=new pt.default;initRoute(e){this.clear(),this.roadInfo=e,e.length&&(e.forEach(t=>{t.points.forEach(n=>{let r=`${t.floor}${Q}${n.id}`;if(this.pointMap.set(r,n),this.nodeMap.set(`${n.floor}${Q}${n.nodeId}`,r),n.type==="straightLadder"){let i=this.straightLadderMap.get(n.name)||[];i.push({...n}),this.straightLadderMap.set(n.name,i)}if(n.type==="staircase"){let i=this.staircaseMap.get(n.name)||[];i.push({...n}),this.staircaseMap.set(n.name,i)}if(n.type==="escalator"){let i=this.escalatorMap.get(n.name)||{};n.escalatorDirection==="exit"?i.end={floor:n.floor,id:n.id}:i.start={floor:n.floor,id:n.id},this.escalatorMap.set(n.name,i)}if(n.type==="facility"){let i=this.facilityMap.get(n.targetId)||[];i.push({...n}),this.facilityMap.set(n.targetId,i)}}),t.lines.filter(n=>n.direction!=="no").forEach(n=>{let r=`${t.floor}${Q}${n.from}`,i=`${t.floor}${Q}${n.to}`,o=this.pointMap.get(r)?.cds,a=this.pointMap.get(i)?.cds;if(o?.length&&a?.length){let u=N(o,a);this.addLineItem(r,i,u),n.direction==="double"&&this.addLineItem(i,r,u)}})}),this.initBaseRoute(),this.initEscalatorRoute(),this.initStraightLadderRoute())}addLineItem(e,t,n,r=this.lineMap){let i=r.get(e)||new Map;i.set(t,n),r.set(e,i)}addFacilityToLineMap(e,t,n,r){[...this.straightLadderMap,...this.staircaseMap].forEach(([i,o])=>{if(!(o.length<2))for(let a=0;a<o.length;a++){let u=`${o[a].floor}${Q}${o[a].id}`;for(let l=0;l<o.length;l++)if(a!==l){let c=`${o[l].floor}${Q}${o[l].id}`,h=this.pointMap.get(u)?.cds,f=this.pointMap.get(c)?.cds;if(h?.length&&f?.length)if(o[a].type==="straightLadder"){let d=t;this.addLineItem(u,c,d,r)}else{let d=n;this.addLineItem(u,c,d,r)}}}}),this.escalatorMap.forEach((i,o)=>{if(i.start&&i.end){let a=`${i.start.floor}${Q}${i.start.id}`,u=`${i.end.floor}${Q}${i.end.id}`,l=this.pointMap.get(a)?.cds,c=this.pointMap.get(u)?.cds;if(l?.length&&c?.length){let h=e;this.addLineItem(a,u,h,r)}}})}initBaseRoute(){let e=new Map([...this.lineMap]);this.addFacilityToLineMap(1,this.lift_priority,3e4,e),this.baseRoute=new pt.default(e)}initEscalatorRoute(){let e=new Map([...this.lineMap]),t=1e4;this.addFacilityToLineMap(1*t,this.lift_priority*t,3e4*t,e),this.escalatorRoute=new pt.default(e)}initStraightLadderRoute(){let e=new Map([...this.lineMap]),t=1e4;this.addFacilityToLineMap(3*t,1*t,3e4*t,e),this.straightLadderRoute=new pt.default(e)}checkStart(e){return!(!e.floor||!e.nodeId&&(!e.coord||e.coord.length<2))}checkEnd(e){return e.facility?!0:this.checkStart(e)}transformStart(e){if(e.nodeId){let t=this.nodeMap.get(`${e.floor}${Q}${e.nodeId}`);if(t){let[n,r]=t.split(Q);return{floor:n,id:r}}}if(e.coord?.length){let t=this.roadInfo.find(r=>r.floor===e.floor);if(!t)return null;let n=t.points.reduce((r,i)=>{let o=N(e.coord,i.cds);return o<r.min&&(r.min=o,r.point=i),r},{min:1/0,point:t.points[0]});return{floor:n.point.floor,id:n.point.id}}return null}transformEnd(e){if(e.floor){let t=this.transformStart(e);if(t)return t}return e.facility&&this.facilityMap.get(e.facility)?.length?{floor:e.floor,facility:e.facility}:null}getPath(e,t,n=""){if(!this.checkStart(e))return"start-error";if(!this.checkEnd(t))return"end-error";let r=this.transformStart(e);if(!r)return"no-start";let i=this.transformEnd(t);if(!i)return"no-end";let o=this.getBasePath.bind(this);switch(n){case"escalator":o=this.getEscalatorPath.bind(this);break;case"straightLadder":o=this.getStraightLadderPath.bind(this);break;default:o=this.getBasePath.bind(this);break}if(i.id)return o(r,i);if(i.facility){let a=this.facilityMap.get(i.facility).filter(l=>i.floor?l.floor===i.floor:!0);if(!a.length)return null;let u=a.map(l=>o(r,{floor:l.floor,id:l.id})).filter(l=>!!l);return u.reduce((l,c)=>{let h=c.reduce((f,d)=>f+ot(d.points),0);return h<l.distance&&(l.distance=h,l.path=c),l},{distance:1/0,path:u[0]}).path}}getRoutePath(e,t,n){let r=`${e.floor}${Q}${e.id}`,i=`${t.floor}${Q}${t.id}`,o=n.path(r,i);if(!o)return null;let a=[];return o.map(u=>{let l=this.pointMap.get(u);if(l){let{floor:c}=l;if(a[a.length-1]?.floor===c){let h=a[a.length-1];h.points.push(l.cds),h.endType=l.type,h.destId=l.nodeId,h.distance=ot(h.points)}else a.push({floor:c,points:[l.cds],endType:l.type,destId:l.nodeId,distance:0})}}),a}getBasePath(e,t){return this.getRoutePath(e,t,this.baseRoute)}getEscalatorPath(e,t){return this.getRoutePath(e,t,this.escalatorRoute)}getStraightLadderPath(e,t){return this.getRoutePath(e,t,this.straightLadderRoute)}clear(){this.roadInfo=[],this.pointMap.clear(),this.nodeMap.clear(),this.facilityMap.clear(),this.straightLadderMap.clear(),this.escalatorMap.clear(),this.staircaseMap.clear(),this.lineMap.clear(),this.baseRoute=new pt.default,this.escalatorRoute=new pt.default,this.straightLadderRoute=new pt.default}};var tt=$t(gn(),1);var Me=require("lodash"),G="___",_n=class{constructor(e=3){this.lift_priority=e}roadInfo=[];facilities=[];pointMap=new Map;nodeMap=new Map;facilityMap=new Map;straightLadderMap=new Map;escalatorMap=new Map;rampMap=new Map;staircaseMap=new Map;parkingMap=new Map;lineMap=new Map;baseRoute=new tt.default;escalatorRoute=new tt.default;straightLadderRoute=new tt.default;forwardLineMap=new Map;forwardRoute=new tt.default;isFacilityByType(e){return["facility","escalator","straightLadder","staircase","ramp"].includes(e)}initFacilities(e){this.facilities=e.map(t=>{let n=[];try{n=JSON.parse(t.entry_end_floor)}catch{n=[]}let r=[];try{r=JSON.parse(t.entry_start_floor)}catch{r=[]}return{...t,entry_start_floor:r,entry_end_floor:n}})}initRoute(e,t){this.clear(),this.roadInfo=e,this.initFacilities(t),e.length&&(e.forEach(n=>{n.points.forEach(r=>{r.floor=n.floor;let i=`${n.floor}${G}${r.id}`;if(this.pointMap.set(i,r),this.nodeMap.set(`${n.floor}${G}${r.nodeId}`,i),this.isFacilityByType(r.type)){let o=this.facilities.find(a=>a.id===+r.targetId);if(o){switch(o.entry_infra_type){case"straightLadder":if(o.entry_end_floor.find(c=>c.floor===n.floor)&&o.entry_start_floor.find(c=>c.floor===n.floor)){let c=this.straightLadderMap.get(r.targetId)||[];c.push({...r}),this.straightLadderMap.set(r.targetId,c)}break;case"staircase":if(o.entry_end_floor.find(c=>c.floor===n.floor)&&o.entry_start_floor.find(c=>c.floor===n.floor)){let c=this.staircaseMap.get(r.targetId)||[];c.push({...r}),this.staircaseMap.set(r.targetId,c)}break;case"escalator":let u=this.escalatorMap.get(r.targetId)||[];if(o.entry_start_floor.find(c=>c.floor===n.floor)){let c=u.find(h=>h.end?.floor!==n.floor&&!h.start);c?c.start=r:u.push({start:r})}if(o.entry_end_floor.find(c=>c.floor===n.floor)){let c=u.find(h=>h.start?.floor!==n.floor&&!h.end);c?c.end=r:u.push({end:r})}this.escalatorMap.set(r.targetId,u);break;case"ramp":let l=this.rampMap.get(r.targetId)||[];if(o.entry_start_floor.find(c=>c.floor===n.floor)){let c=l.find(h=>h.end?.floor!==n.floor&&!h.start);c?c.start=r:l.push({start:r})}if(o.entry_end_floor.find(c=>c.floor===n.floor)){let c=l.find(h=>h.start?.floor!==n.floor&&!h.end);c?c.end=r:l.push({end:r})}this.rampMap.set(r.targetId,l);break}let a=this.facilityMap.get(r.targetId)||[];a.push({...r}),this.facilityMap.set(r.targetId,a)}}r.type==="parkingSpace"&&this.parkingMap.set(`${n.floor}${G}${r.name}`,r)}),n.lines.filter(r=>r.direction!=="no").forEach(r=>{let i=`${n.floor}${G}${r.from}`,o=`${n.floor}${G}${r.to}`,a=this.pointMap.get(i)?.cds,u=this.pointMap.get(o)?.cds;if(a?.length&&u?.length){let l=N(a,u);switch(this.addLineItem(i,o,l),this.addLineItem(o,i,l),r.direction){case"double":this.addLineItem(i,o,l,this.forwardLineMap),this.addLineItem(o,i,l,this.forwardLineMap);break;case"single":this.addLineItem(i,o,l,this.forwardLineMap);break;case"back":this.addLineItem(o,i,l,this.forwardLineMap);break}}})}),this.initBaseRoute(),this.initEscalatorRoute(),this.initStraightLadderRoute(),this.initForwardRoute())}addLineItem(e,t,n,r=this.lineMap){let i=r.get(e)||new Map;i.set(t,n),r.set(e,i)}addFacilityToLineMap(e,t,n,r){[...this.straightLadderMap,...this.staircaseMap].forEach(([i,o])=>{if(!(o.length<2))for(let a=0;a<o.length;a++){let u=`${o[a].floor}${G}${o[a].id}`;for(let l=0;l<o.length;l++)if(a!==l){let c=`${o[l].floor}${G}${o[l].id}`,h=this.pointMap.get(u)?.cds,f=this.pointMap.get(c)?.cds;if(h?.length&&f?.length)if(o[a].type==="straightLadder"){let d=t;this.addLineItem(u,c,d,r)}else{let d=n;this.addLineItem(u,c,d,r)}}}}),this.escalatorMap.forEach((i,o)=>{i.forEach(a=>{if(a.start&&a.end){let u=`${a.start.floor}${G}${a.start.id}`,l=`${a.end.floor}${G}${a.end.id}`,c=this.pointMap.get(u)?.cds,h=this.pointMap.get(l)?.cds;if(c?.length&&h?.length){let f=e;this.addLineItem(u,l,f,r)}}})})}initBaseRoute(){let e=new Map((0,Me.cloneDeep)([...this.lineMap]));this.addFacilityToLineMap(1,this.lift_priority,3e4,e),this.baseRoute=new tt.default(e)}initEscalatorRoute(){let e=new Map((0,Me.cloneDeep)([...this.lineMap])),t=1e4;this.addFacilityToLineMap(1*t,this.lift_priority*t,3e4*t,e),this.escalatorRoute=new tt.default(e)}initStraightLadderRoute(){let e=new Map((0,Me.cloneDeep)([...this.lineMap])),t=1e4;this.addFacilityToLineMap(3*t,1*t,3e4*t,e),this.straightLadderRoute=new tt.default(e)}initForwardRoute(){this.rampMap.forEach((e,t)=>{e.forEach(n=>{if(n.start&&n.end){let r=`${n.start.floor}${G}${n.start.id}`,i=`${n.end.floor}${G}${n.end.id}`,o=this.pointMap.get(r)?.cds,a=this.pointMap.get(i)?.cds;o?.length&&a?.length&&this.addLineItem(r,i,10,this.forwardLineMap)}})}),this.forwardRoute=new tt.default(this.forwardLineMap)}checkStart(e){return!(!e.floor||!e.nodeId&&(!e.coord||e.coord.length<2))}checkEnd(e){return e.facility||e.parkingSpace&&e.floor?!0:this.checkStart(e)}transformStart(e){if(e.nodeId){let t=this.nodeMap.get(`${e.floor}${G}${e.nodeId}`);if(t){let[n,r]=t.split(G);return{floor:n,id:r}}}if(e.coord?.length){let t=this.roadInfo.find(r=>r.floor===e.floor);if(!t)return null;let n=t.points.reduce((r,i)=>{let o=N(e.coord,i.cds);return o<r.min&&(r.min=o,r.point=i),r},{min:1/0,point:t.points[0]});return{floor:t.floor,id:n.point.id}}return null}transformEnd(e){if(e.floor){if(e.parkingSpace){let n=this.parkingMap.get(`${e.floor}${G}${e.parkingSpace}`);if(n)return{floor:e.floor,id:n.id}}let t=this.transformStart(e);if(t)return t}return e.facility&&this.facilityMap.get(e.facility)?.length?{floor:e.floor,facility:e.facility}:null}getPath(e,t,n=""){if(!this.checkStart(e))return"start-error";if(!this.checkEnd(t))return"end-error";let r=this.transformStart(e);if(!r)return"no-start";let i=this.transformEnd(t);if(!i)return"no-end";let o=this.getBasePath.bind(this);switch(n){case"escalator":o=this.getEscalatorPath.bind(this);break;case"straightLadder":o=this.getStraightLadderPath.bind(this);break;case"forward":o=this.getForwardPath.bind(this);break;default:o=this.getBasePath.bind(this);break}if(i.id)return o(r,i);if(i.facility){let a=this.facilityMap.get(i.facility).filter(l=>i.floor?l.floor===i.floor:!0);if(!a.length)return null;let u=a.map(l=>o(r,{floor:l.floor,id:l.id})).filter(l=>!!l);return u.reduce((l,c)=>{let h=c.reduce((f,d)=>f+ot(d.points),0);return h<l.distance&&(l.distance=h,l.path=c),l},{distance:1/0,path:u[0]}).path}}getRoutePath(e,t,n){let r=`${e.floor}${G}${e.id}`,i=`${t.floor}${G}${t.id}`,o=n.path(r,i);if(!o)return null;let a=[];return o.map(u=>{let l=this.pointMap.get(u);if(l){let{floor:c}=l,h=l.type;if(this.isFacilityByType(l.type)){let f=this.facilities.find(d=>d.id===+l.targetId);f&&(h=f.entry_infra_type)}if(a[a.length-1]?.floor===c){let f=a[a.length-1];f.points.push(l.cds),f.endType=h,f.destId=l.nodeId,f.distance=ot(f.points)}else a.push({floor:c,points:[l.cds],endType:h,destId:l.nodeId,distance:0})}}),a}getBasePath(e,t){return this.getRoutePath(e,t,this.baseRoute)}getEscalatorPath(e,t){return this.getRoutePath(e,t,this.escalatorRoute)}getStraightLadderPath(e,t){return this.getRoutePath(e,t,this.straightLadderRoute)}getForwardPath(e,t){return this.getRoutePath(e,t,this.forwardRoute)}clear(){this.roadInfo=[],this.pointMap.clear(),this.nodeMap.clear(),this.facilityMap.clear(),this.straightLadderMap.clear(),this.escalatorMap.clear(),this.staircaseMap.clear(),this.lineMap.clear(),this.baseRoute=new tt.default,this.escalatorRoute=new tt.default,this.straightLadderRoute=new tt.default}};var Lt=class{static keySet=new Set;static createKey(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)}static genUniqueKey(){let e=this.createKey();for(;this.keySet.has(e);)e=this.createKey();return e}static removeKey(e){this.keySet.delete(e)}static dispose(){this.keySet.clear()}};function yn(s){return s.replace(/[A-Z]/g,e=>"_"+e.toLowerCase()).replace(/^_/,"")}function st(s,e,t){return new Promise((n,r)=>{let i=Lt.genUniqueKey(),o=({data:a})=>{a.type===`${e}_result`&&a.key===i&&(Lt.removeKey(i),self.removeEventListener("message",o),a.error?r(a.error):n(a.data))};s.addEventListener("message",o),s.postMessage({type:e,key:i,data:t})})}function Ai(s){let e={};for(let n in s)n.startsWith("on")&&(e[yn(n.slice(2))]=s[n]);let t=async({data:n})=>{if(e[n.type])try{let r=await e[n.type](n.data);self.postMessage({type:`${n.type}_result`,key:n.key,data:r})}catch(r){self.postMessage({type:`${n.type}_result`,key:n.key,error:r})}else self.postMessage({type:`${n.type}_result`,key:n.key,error:"no_event"})};return self.addEventListener("message",t),()=>{self.removeEventListener("message",t)}}var at=require("three");function Ii(s,e=16711680){let t=new at.LineBasicMaterial({color:e}),n=new at.BufferGeometry().setFromPoints(s);return new at.Line(n,t)}function Ri(s,e=16711680){let t=new at.LineBasicMaterial({color:e}),n=new at.BoxGeometry(1,1,1),r=new at.Mesh(n,t);return r.position.copy(s),r}function W(s,e,t=0){s.forEach(n=>{n.geometry.coords=JSON.parse(JSON.stringify(n.geometry.cds)),n.geometry.type==="polygon"?(n.geometry.coords.map(r=>{Array.isArray(r)&&r.forEach(i=>{i[0]-=e[0],i[1]-=e[1]})}),n.geometry.otherCds&&(n.geometry.otherCoords=n.geometry.otherCds.map(r=>r.map(i=>et(i,e)))),n.doors?.length&&n.doors.map(r=>{r.coord=et(r.coordinate,e)}),n.center&&(n.center=et(n.center,e))):n.geometry.coords=et(n.geometry.cds,e)});for(let n=0;n<s.length;n++){let r=s[n];r.deltaHeight=1e-5*(t+n+1)}}function et(s,e){return[s[0]-e[0],s[1]-e[1]]}var hr=require("@tweenjs/tween.js"),Nt=class{pauseTween=!1;tweenStore=new Set;group=new hr.Group;constructor(){}update(){this.group.update()}pause(){this.pauseTween=!0,this.getAll().forEach(e=>{this.tweenStore.add(e),e.pause()})}continue(){this.pauseTween&&(this.tweenStore.forEach(e=>{e.resume()}),this.tweenStore.clear(),this.pauseTween=!1)}remove(e){this.group.remove(e)}getAll(){return this.group.getAll()}clear(){this.getAll().forEach(e=>e.stop()),this.group.removeAll()}dispose(){this.clear()}};var S=require("three");var Rr=require("three");var v=require("three");var fr=require("three/examples/jsm/lines/LineMaterial"),V=require("three");function pr(s){return`${s.x}-${s.y}-${s.z}`}var P=class{static lineMaterialMap=new Map;static meshStandardMaterialMap=new Map;static meshBasicMaterialMap=new Map;static shaderMaterialMap=new Map;static line2MaterialMap=new Map;static generateLineMaterialKey({color:e,opacity:t}){return`${e}-${t}`}static createLineMaterial({color:e,opacity:t}){let n=this.generateLineMaterialKey({color:e,opacity:t});if(this.lineMaterialMap.has(n))return this.lineMaterialMap.get(n);let r=new V.LineBasicMaterial({color:new V.Color(e).convertLinearToSRGB(),transparent:!0,opacity:t});return this.lineMaterialMap.set(n,r),r}static createMeshStandardMaterial({color:e,opacity:t}){let n=`${e}-${t}`;if(this.meshStandardMaterialMap.has(n))return this.meshStandardMaterialMap.get(n);let r=new V.MeshStandardMaterial({color:new V.Color(e).convertLinearToSRGB(),roughness:1,transparent:!0,opacity:t,depthWrite:!0});return this.meshStandardMaterialMap.set(n,r),r}static createMeshBasicMaterial({color:e,opacity:t}){let n=`${e}-${t}`;if(this.meshBasicMaterialMap.has(n))return this.meshBasicMaterialMap.get(n);let r=new V.MeshBasicMaterial({color:e,transparent:!0,opacity:t,depthWrite:!0});return this.meshBasicMaterialMap.set(n,r),r}static createShaderMaterial({gradualColor:e,center:t,maxValue:n,opacity:r,direction:i,max:o,min:a}){let u=`${e.toString()}-${pr(t)}-${n}-${r}-${pr(i)}`;if(this.shaderMaterialMap.has(u))return this.shaderMaterialMap.get(u);let l=`
|
|
1
|
+
"use strict";var ui=Object.create;var Ee=Object.defineProperty;var ci=Object.getOwnPropertyDescriptor;var hi=Object.getOwnPropertyNames;var pi=Object.getPrototypeOf,fi=Object.prototype.hasOwnProperty;var Tt=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports),di=(s,e)=>{for(var t in e)Ee(s,t,{get:e[t],enumerable:!0})},Vn=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of hi(e))!fi.call(s,r)&&r!==t&&Ee(s,r,{get:()=>e[r],enumerable:!(n=ci(e,r))||n.enumerable});return s};var $t=(s,e,t)=>(t=s!=null?ui(pi(s)):{},Vn(e||!s||!s.__esModule?Ee(t,"default",{value:s,enumerable:!0}):t,s)),gi=s=>Vn(Ee({},"__esModule",{value:!0}),s);var Wn=Tt((go,Hn)=>{Hn.exports=function(e,t){return e[0]=t[0],e[1]=t[1],e}});var jn=Tt((mo,qn)=>{var Xn=Wn();qn.exports=function(s,e){Array.isArray(e)||(e=[]),s.length>0&&e.push(Xn([0,0],s[0]));for(var t=0;t<s.length-1;t++){var n=s[t],r=s[t+1],i=n[0],o=n[1],a=r[0],u=r[1],l=[.75*i+.25*a,.75*o+.25*u],c=[.25*i+.75*a,.25*o+.75*u];e.push(l),e.push(c)}return s.length>1&&e.push(Xn([0,0],s[s.length-1])),e}});var Jn=Tt((vo,Zn)=>{var fn=class{constructor(){this.keys=new Set,this.queue=[]}sort(){this.queue.sort((e,t)=>e.priority-t.priority)}set(e,t){let n=Number(t);if(isNaN(n))throw new TypeError('"priority" must be a number');return this.keys.has(e)?this.queue.map(r=>(r.key===e&&Object.assign(r,{priority:n}),r)):(this.keys.add(e),this.queue.push({key:e,priority:n})),this.sort(),this.queue.length}next(){let e=this.queue.shift();return this.keys.delete(e.key),e}isEmpty(){return this.queue.length===0}has(e){return this.keys.has(e)}get(e){return this.queue.find(t=>t.key===e)}};Zn.exports=fn});var er=Tt((xo,tr)=>{function Qn(s,e){let t=new Map;for(let[n,r]of s)n!==e&&r instanceof Map?t.set(n,Qn(r,e)):n!==e&&t.set(n,r);return t}tr.exports=Qn});var ir=Tt((Eo,rr)=>{function Ti(s){let e=Number(s);return!(isNaN(e)||e<=0)}function nr(s){let e=new Map;return Object.keys(s).forEach(n=>{let r=s[n];if(r!==null&&typeof r=="object"&&!Array.isArray(r))return e.set(n,nr(r));if(!Ti(r))throw new Error(`Could not add node at key "${n}", make sure it's a valid node`,r);return e.set(n,Number(r))}),e}rr.exports=nr});var ar=Tt((bo,sr)=>{function or(s){if(!(s instanceof Map))throw new Error(`Invalid graph: Expected Map instead found ${typeof s}`);s.forEach((e,t)=>{if(typeof e=="object"&&e instanceof Map){or(e);return}if(typeof e!="number"||e<=0)throw new Error(`Values must be numbers greater than 0. Found value ${e} at ${t}`)})}sr.exports=or});var gn=Tt((So,cr)=>{var Ci=Jn(),Pi=er(),lr=ir(),ur=ar(),dn=class{constructor(e){e instanceof Map?(ur(e),this.graph=e):e?this.graph=lr(e):this.graph=new Map}addNode(e,t){let n;return t instanceof Map?(ur(t),n=t):n=lr(t),this.graph.set(e,n),this}addVertex(e,t){return this.addNode(e,t)}removeNode(e){return this.graph=Pi(this.graph,e),this}path(e,t,n={}){if(!this.graph.size)return n.cost?{path:null,cost:0}:null;let r=new Set,i=new Ci,o=new Map,a=[],u=0,l=[];if(n.avoid&&(l=[].concat(n.avoid)),l.includes(e))throw new Error(`Starting node (${e}) cannot be avoided`);if(l.includes(t))throw new Error(`Ending node (${t}) cannot be avoided`);for(i.set(e,0);!i.isEmpty();){let c=i.next();if(c.key===t){u=c.priority;let f=c.key;for(;o.has(f);)a.push(f),f=o.get(f);break}r.add(c.key),(this.graph.get(c.key)||new Map).forEach((f,d)=>{if(r.has(d)||l.includes(d))return null;if(!i.has(d))return o.set(d,c.key),i.set(d,c.priority+f);let m=i.get(d).priority,p=c.priority+f;return p<m?(o.set(d,c.key),i.set(d,p)):null})}return a.length?(n.trim?a.shift():a=a.concat([e]),n.reverse||(a=a.reverse()),n.cost?{path:a,cost:u}:a):n.cost?{path:null,cost:0}:null}shortestPath(...e){return this.path(...e)}};cr.exports=dn});var Yi={};di(Yi,{AibeeLoader:()=>zn,BMap:()=>Mn,BMapSelect:()=>Nn,BaseSvg:()=>$,Context:()=>ge,CrLoader:()=>kn,CrNavPath:()=>Ln,Equipment:()=>wn,Events:()=>an,Floor:()=>lt,GlbModel:()=>ue,Graphic:()=>A,GraphicLayer:()=>ie,GroundTexture:()=>Wt,HeatmapElement:()=>ne,HooksName:()=>Vt,HoverHelper:()=>de,Lane:()=>ce,Layer:()=>O,MapTypePolar:()=>Br,MergeGraphic:()=>he,Model:()=>re,MulFloors:()=>Pn,NavPath:()=>In,Navigation:()=>Cn,Overlay:()=>ee,PathDirection:()=>hn,PdrPosition:()=>Dn,Poi:()=>Et,Poi2:()=>X,PoiLayer:()=>Ft,PoiLayer2:()=>oe,RoadNetwork:()=>mn,RoadNetwork2:()=>_n,SelectBox:()=>vn,Selection:()=>fe,Sensor:()=>ye,Shadow:()=>te,SvgLine:()=>se,SvgPolygon:()=>ae,TextTexture:()=>pe,Timer:()=>L,TweenUtil:()=>Nt,UA:()=>on,Wall:()=>le,addAlphaToHexColor:()=>xi,calc_angle:()=>Qe,calc_direction:()=>Se,convertToSnakeCase:()=>yn,createCircle:()=>zt,createLine:()=>Jt,createRect:()=>gt,createSvg:()=>nn,createSvgElement:()=>Zt,createThreeBox:()=>Ri,createThreeLine:()=>Ii,darkenColor:()=>ht,defaultAibeeLoaderOption:()=>ji,defaultConfig:()=>Fr,defaultGraphicOptions:()=>we,defaultOptions:()=>Sr,defaultTextTextureOptions:()=>Ar,dispose:()=>k,distancePointToSegment:()=>cn,generatorKeyByObj:()=>Rt,getAngle:()=>$n,getCenter:()=>Kt,getConfig:()=>Sn,getDirectPath:()=>wi,getDistanceByPathPos:()=>pn,getLength:()=>N,getLongestSideDir:()=>mi,getMinEdgeSquare:()=>tn,getPathLength:()=>ot,getPointEdgeIndex:()=>Ct,getPosByPathDistance:()=>Qt,hasChinese:()=>Je,hexToRgb:()=>be,initDirectionalLight:()=>Ze,initLight:()=>Ke,initShape:()=>it,isAndroid:()=>Ei,isContain:()=>dt,isControl:()=>It,isIphone:()=>kt,isMac:()=>At,isPointInPolygon:()=>en,loadBuildingGround:()=>On,loadExternalStreet:()=>Vi,loadGraphics:()=>Fn,moveOnRoute:()=>Mi,proxyOptions:()=>Pt,removeWeightPath:()=>Kn,setCirclePosition:()=>_t,setLineStartEnd:()=>J,setRectPosition:()=>B,simplifyPath:()=>un,sleepOnePromise:()=>rn,sleepOneRf:()=>yi,smoothPath:()=>ln,strToNumber:()=>vi,timeoutPromise:()=>ct,toWebWorker:()=>Ai,transformGraphicData:()=>W,translatePosToCenter:()=>et,triggerWorker:()=>st,vector3ToDevice:()=>y,xhrGet:()=>bi});module.exports=gi(Yi);var Be=require("three");var L=class{tasks={requestAnimation:new Set,timeout:new Set,interval:new Set};requestAnimationFrame(e){let t=window.requestAnimationFrame(()=>{this.tasks.requestAnimation.delete(t),e()});return this.tasks.requestAnimation.add(t),t}cancelAnimationFrame(e){this.tasks.requestAnimation.delete(e),window.cancelAnimationFrame(e)}setTimeout(e,t){let n=window.setTimeout(()=>{this.tasks.timeout.delete(n),e()},t);return this.tasks.timeout.add(n),n}clearTimeout(e){this.tasks.timeout.delete(e),window.clearTimeout(e)}setInterval(e,t){let n=window.setInterval(()=>{this.tasks.interval.delete(n),e()},t);return this.tasks.interval.add(n),n}clearInterval(e){this.tasks.interval.delete(e),window.clearInterval(e)}dispose(){this.tasks.requestAnimation.forEach(e=>{window.cancelAnimationFrame(e)}),this.tasks.requestAnimation.clear(),this.tasks.timeout.forEach(e=>{window.clearTimeout(e)}),this.tasks.timeout.clear(),this.tasks.interval.forEach(e=>{window.clearInterval(e)}),this.tasks.interval.clear()}};var Y=require("three");function Ke(){let s=new Y.Group,e=new Y.AmbientLight(16777215,2.6);return s.add(e),s}function it(s,e=[]){let t=new Y.Shape(s.map(n=>new Y.Vector2(...n)));return e.length&&e.forEach(n=>{var r=new Y.Path(n.map(i=>new Y.Vector2(...i)));t.holes.push(r)}),t}function Ze(s=16777215,e=1){let t=new Y.DirectionalLight(s,e);return t.castShadow=!0,t.shadow.radius=8,t.shadow.bias=-.001,t.shadow.mapSize.set(256,256),t.shadow.camera.left=-200,t.shadow.camera.right=200,t.shadow.camera.top=200,t.shadow.camera.bottom=-200,t}function k(s,e){if(e&&s.children&&s.children.length&&s.children.forEach(t=>{k(t,e)}),s.isMesh){let t=s;t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach(n=>{n.dispose()}):t.material.dispose())}s.isLight&&s.dispose?.()}function Je(s){return/[\u4E00-\u9FA5]+/g.test(s)}var T=require("three"),Gt=require("@turf/turf");function y(s,e,t,n){let r=s.clone().project(e),i=t/2,o=n/2,a=Math.round(r.x*i+i),u=Math.round(-r.y*o+o);return{x:a,y:u}}function Kt(s){let e=(0,Gt.featureCollection)(s.map(n=>(0,Gt.point)(n)));return(0,Gt.center)(e).geometry.coordinates}function dt(s,e,t){return s.x>=e.x&&s.x<=t.x&&s.y>=e.y&&s.y<=t.y}function mi(s){let e=0,t=new T.Vector3;for(let n=1;n<s.length;n++){let r=new T.Vector3(s[n-1][0],s[n-1][1],0),i=new T.Vector3(s[n][0],s[n][1],0),o=i.distanceTo(r);o>e&&(e=o,t=i.clone().sub(r).normalize())}return t}function N(s,e){return Math.sqrt((e[0]-s[0])**2+(e[1]-s[1])**2)}function ot(s){let e=0;for(let t=0;t<s.length-1;t++)e+=N(s[t],s[t+1]);return e}function Qe(s,e,t){let n=new T.Vector2(e[0]-s[0],e[1]-s[1]),r=new T.Vector2(e[0]-t[0],e[1]-t[1]),o=n.angleTo(r)*180/Math.PI,a=new T.Vector2(e[0]-s[0],e[1]-s[1]);return new T.Vector2(t[0]-s[0],t[1]-s[1]).cross(a)>0?o:-o}function tn(s,e){let t=Math.min(N(s[0][0],s[0][1]),N(s[0][2],s[0][1]))-1;e||(e=Kt(s[0]));let n=_i(e,t),r=new T.Vector2(s[0][0][0],s[0][0][1]),i=new T.Vector2(s[0][1][0],s[0][1][1]),o=new T.Vector2(s[0][2][0],s[0][2][1]),u=(r.distanceTo(i)>i.distanceTo(o)?i.clone().sub(r):o.clone().sub(i)).angleTo(new T.Vector2(0,1)),l=new T.Matrix3;return l.multiply(new T.Matrix3().translate(e[0],e[1])).multiply(new T.Matrix3().rotate(u)).multiply(new T.Matrix3().translate(-e[0],-e[1])),[n.map(c=>{let h=new T.Vector2(c[0],c[1]).applyMatrix3(l);return[h.x,h.y]})]}function _i(s,e){let t=e/2;return[[s[0]-t,s[1]+t],[s[0]+t,s[1]+t],[s[0]+t,s[1]-t],[s[0]-t,s[1]-t],[s[0]-t,s[1]+t]]}function Ct(s,e){let t=0,n=1/0,[r,i]=e;for(let o=0;o<s.length-1;o++){let[a,u]=s[o],[l,c]=s[o+1],h=Math.min(a,l)<=r&&r<=Math.max(a,l),f=Math.min(u,c)<=i&&i<=Math.max(u,c);if(h&&f){let d=Math.abs((l-a)*(i-u)-(c-u)*(r-a));d<n&&(n=d,t=o)}}return t}function en(s,e){let t=s[0],n=s[1],r=!1;for(let i=0,o=e.length-1;i<e.length;o=i++){let a=e[i][0],u=e[i][1],l=e[o][0],c=e[o][1];u>n!=c>n&&t<(l-a)*(n-u)/(c-u)+a&&(r=!r)}return r}function Pt(s,e){return new Proxy(s,{get:(t,n,r)=>Reflect.get(t,n,r),set:(t,n,r,i)=>{let o=Reflect.get(t,n,i),a=Reflect.set(t,n,r,i);return o!==r&&e.dispatchEvent({type:`change-${n}`,value:r}),a}})}function ct(s,e){return Promise.race([s,new Promise((t,n)=>{setTimeout(()=>n(new Error("Promise timeout")),e)})])}function Zt(s){return document.createElementNS("http://www.w3.org/2000/svg",s)}function nn(s,e){let t=Zt("svg");return t.setAttribute("width",s),t.setAttribute("height",e),t.style.cssText="position: absolute; left: 0; top: 0; pointer-events: none;",t}function zt(s="2",e){let t=Zt("circle");return t.setAttribute("r",s),t.setAttribute("fill",e),t}function Jt(s){let e=Zt("line");return e.setAttribute("stroke",s),e}function gt(s,e){let t=Zt("rect");return t.setAttribute("stroke",s),t.setAttribute("fill",e),t}function _t(s,e,t){s.setAttribute("cx",`${e}`),s.setAttribute("cy",`${t}`)}function J(s,e,t){e&&(s.setAttribute("x1",`${e.x}`),s.setAttribute("y1",`${e.y}`)),t&&(s.setAttribute("x2",`${t.x}`),s.setAttribute("y2",`${t.y}`))}function B(s,e,t,n,r){s.setAttribute("x",`${e}`),s.setAttribute("y",`${t}`),s.setAttribute("width",`${n}`),s.setAttribute("height",`${r}`)}function rn(){return Promise.resolve()}function yi(){return new Promise(s=>{requestAnimationFrame(s)})}function vi(s){return parseInt(s.replace("#","0x"),16)}function xi(s,e){let t=parseInt(s.substring(1,3),16),n=parseInt(s.substring(3,5),16),r=parseInt(s.substring(5,7),16),i=Math.round(t*e),o=Math.round(n*e),a=Math.round(r*e);return`#${(1<<24|i<<16|o<<8|a).toString(16).slice(1)}`}function ht(s,e=.85){let t,n,r;if(s.startsWith("#"))t=parseInt(s.substring(1,3),16),n=parseInt(s.substring(3,5),16),r=parseInt(s.substring(5,7),16);else{let o=s.slice(4,-1).split(",");t=parseInt(o[0].trim()),n=parseInt(o[1].trim()),r=parseInt(o[2].trim())}return t=Math.min(Math.floor(t*e),255),n=Math.min(Math.floor(n*e),255),r=Math.min(Math.floor(r*e),255),"#"+((1<<24)+(t<<16)+(n<<8)+r).toString(16).slice(1)}function be(s,e){s=s.replace(/^#/,"");let t=parseInt(s.substring(0,2),16),n=parseInt(s.substring(2,4),16),r=parseInt(s.substring(4,6),16);return e!==void 0?`rgba(${t}, ${n}, ${r}, ${e})`:`rgb(${t}, ${n}, ${r})`}var At=navigator.userAgent.toUpperCase().indexOf("MAC")>=0,on=(window.navigator.userAgent||"").toLocaleLowerCase(),kt=/ios|iphone/i.test(on),Ei=/android|adr|linux/gi.test(on);function It(s){return At?s==="Meta":s==="Control"}var sn="__once__",an=class{events=new Map;on(e,t){if(typeof t!="function")return;let n=this.events.get(e);return n?n.add(t):this.events.set(e,new Set([t]))}once(e,t){if(typeof t!="function")return;let n=`${sn}${e}`,r=this.events.get(n);return r?r.add(t):this.events.set(n,new Set([t]))}off(e,t){let n=this.events.get(e),r=this.events.get(`${sn}${e}`);!n&&!r||(t===void 0&&(n?.clear(),r?.clear()),n?.has(t)&&n.delete(t),r?.has(t)&&r.delete(t))}offAll(){this.events.clear()}emit(e,...t){let n=this.events.get(e),r=this.events.get(`${sn}${e}`);!n&&!r||(n?.forEach(i=>{typeof i=="function"&&i(...t)}),r?.forEach(i=>{typeof i=="function"&&i(...t)}),r?.clear())}};var Vt=(t=>(t.SWITCH_FLOOR_BEFORE="switch_floor_before",t.SWITCH_FLOOR_AFTER="switch_floor_after",t))(Vt||{});function Rt(s){return Object.keys(s).sort().map(e=>`${e}=${s[e]}`).join("&")}function bi(s,e){return new Promise((t,n)=>{let r=new XMLHttpRequest;r.open("GET",s,!0),Object.keys(e.headers||{}).forEach(i=>{r.setRequestHeader(i,e.headers[i])}),e.responseType&&(r.responseType=e.responseType),r.onload=()=>{if(r.status>=200&&r.status<300)if(e.responseType==="arraybuffer")t(r.response);else try{let i=JSON.parse(r.responseText);t(i)}catch(i){n(i)}else n(r.statusText)},r.onerror=()=>{n(r.statusText)},r.send()})}var Ht=require("three"),Yn=$t(jn(),1);function $n(s,e){let t=s.clone().normalize(),n=e.clone().normalize();return Math.acos(t.dot(n))}function Si(s){let e=0;return s.reduce(([t,n],[r,i])=>(e+=Math.sqrt((r-t)**2+(i-n)**2),[r,i])),e/s.length}function ln(s,e=.25){if(Si(s)<e)return s;let t=(0,Yn.default)(s);return ln(t,e)}function un(s,e=!1,t=!0,n=5,r=150,i=3){let o=[],a=!e;if(o.push(s[0]),s.length<2)return o;for(let l=0;l<s.length-2;l+=1){let c=s[l],h=s[l+1],f=s[l+2],d=new Ht.Vector2(c[0]-h[0],c[1]-h[1]),m=new Ht.Vector2(f[0]-h[0],f[1]-h[1]),p=$n(d,m)/Math.PI*180,g=d.length()+m.length();(!a||p<r&&g>.01||g>n)&&(o.push(s[l+1]),a=!0)}if(o.push(s[s.length-1]),!t)return o;let u=[];u.push(o[0]);for(let l=0;l<o.length-2;l+=1){let c=new Ht.Vector2(o[l][0],o[l][1]),h=new Ht.Vector2(o[l+1][0],o[l+1][1]),f=new Ht.Vector2(o[l+2][0],o[l+2][1]),d=c.distanceTo(h)/2,m=f.distanceTo(h)/2,p=h.clone(),g=h.clone();p.add(c.clone().sub(h).normalize().multiplyScalar(d>i?i/2:d)),g.add(f.clone().sub(h).normalize().multiplyScalar(m>i?i/2:m));let E=[[p.x,p.y],[h.x,h.y],[g.x,g.y]];u.push(...ln(E,i/25))}return u.push(o[o.length-1]),Kn(u)}function Kn(s){if(s.length<=1)return s;let e=[],t;return s.forEach(([n,r])=>{t?n===t[0]&&r===t[1]||(t=[n,r],e.push([n,r])):(t=[n,r],e.push([n,r]))}),e}function cn(s,e,t){let n=Math.sqrt((t[0]-e[0])**2+(t[1]-e[1])**2);if(n===0)return{distance:Math.sqrt((s[0]-e[0])**2+(s[1]-e[1])**2),closestPoint:e.slice(0)};let r=Math.max(0,Math.min(1,((s[0]-e[0])*(t[0]-e[0])+(s[1]-e[1])*(t[1]-e[1]))/n**2)),i=[e[0]+r*(t[0]-e[0]),e[1]+r*(t[1]-e[1])];return{distance:Math.sqrt((s[0]-i[0])**2+(s[1]-i[1])**2),closestPoint:i}}function Mi(s,e,t){let[n,r]=s,[i,o]=e,a=Math.sqrt(Math.pow(i-n,2)+Math.pow(o-r,2));if(a===0||a<t)return[...e];let u=t/a,l=n+(i-n)*u,c=r+(o-r)*u;return[l,c]}var hn=(l=>(l.START="start",l.END="end",l.FRONT="front",l.RIGHT="right",l.LEFT="left",l.RIGHT_FRONT="right_front",l.LEFT_FRONT="left_front",l.RIGHT_BACK="right_back",l.LEFT_BACK="left_back",l))(hn||{});function Se(s,e,t){let n=Qe(s,e,t);return 180-Math.abs(n)<15?"front":n>135?"right_front":n<-135?"left_front":n<=135&&n>=60?"right":n>=-135&&n<=-60?"left":n<60&&n>0?"right_back":n>-60&&n<0?"left_back":"front"}function wi(s){if(!s.length)return[];let e=[{direction:"start",distance:N(s[0],s[1]),points:[s[0],s[1]]}];for(let t=2;t<s.length;t++){let n=Se(s[t-2],s[t-1],s[t]);if(n==="front"){let r=e[e.length-1],i=N(s[t-1],s[t]);r.distance+=i,t!==2&&r.points.push(s[t-1])}else e.push({direction:n,distance:N(s[t-1],s[t]),points:[s[t-1],s[t]]})}return e.push({direction:"end",distance:0,points:[s[s.length-1]]}),e}function pn(s,e){if(s.length<2)return-1;let t=0;for(let n=1;n<s.length;n++){let r=s[n-1],i=s[n],o=[e[0]-r[0],e[1]-r[1]],a=[i[0]-r[0],i[1]-r[1]],u=Math.min(i[0],r[0])<=e[0]&&e[0]<=Math.max(i[0],r[0]),l=Math.min(i[1],r[1])<=e[1]&&e[1]<=Math.max(i[1],r[1]);if(u&&l){let c=o[0]*a[1]-o[1]*a[0];if(Math.abs(c)<1e-6){let h=Math.sqrt((e[0]-r[0])**2+(e[1]-r[1])**2);return t+h}}t+=Math.sqrt((i[0]-r[0])**2+(i[1]-r[1])**2)}return-1}function Qt(s,e){if(s.length<2)return s[0]??null;let t=0;for(let n=1;n<s.length;n++){let r=s[n-1],i=s[n],o=Math.sqrt((i[0]-r[0])**2+(i[1]-r[1])**2);if(t+=o,t>=e){let a=(e-(t-o))/o,u=r[0]+(i[0]-r[0])*a,l=r[1]+(i[1]-r[1])*a;return[u,l]}}return null}var pt=$t(gn(),1);var Q="___",mn=class{constructor(e=3){this.lift_priority=e}roadInfo=[];pointMap=new Map;nodeMap=new Map;facilityMap=new Map;straightLadderMap=new Map;escalatorMap=new Map;staircaseMap=new Map;lineMap=new Map;baseRoute=new pt.default;escalatorRoute=new pt.default;straightLadderRoute=new pt.default;initRoute(e){this.clear(),this.roadInfo=e,e.length&&(e.forEach(t=>{t.points.forEach(n=>{let r=`${t.floor}${Q}${n.id}`;if(this.pointMap.set(r,n),this.nodeMap.set(`${n.floor}${Q}${n.nodeId}`,r),n.type==="straightLadder"){let i=this.straightLadderMap.get(n.name)||[];i.push({...n}),this.straightLadderMap.set(n.name,i)}if(n.type==="staircase"){let i=this.staircaseMap.get(n.name)||[];i.push({...n}),this.staircaseMap.set(n.name,i)}if(n.type==="escalator"){let i=this.escalatorMap.get(n.name)||{};n.escalatorDirection==="exit"?i.end={floor:n.floor,id:n.id}:i.start={floor:n.floor,id:n.id},this.escalatorMap.set(n.name,i)}if(n.type==="facility"){let i=this.facilityMap.get(n.targetId)||[];i.push({...n}),this.facilityMap.set(n.targetId,i)}}),t.lines.filter(n=>n.direction!=="no").forEach(n=>{let r=`${t.floor}${Q}${n.from}`,i=`${t.floor}${Q}${n.to}`,o=this.pointMap.get(r)?.cds,a=this.pointMap.get(i)?.cds;if(o?.length&&a?.length){let u=N(o,a);this.addLineItem(r,i,u),n.direction==="double"&&this.addLineItem(i,r,u)}})}),this.initBaseRoute(),this.initEscalatorRoute(),this.initStraightLadderRoute())}addLineItem(e,t,n,r=this.lineMap){let i=r.get(e)||new Map;i.set(t,n),r.set(e,i)}addFacilityToLineMap(e,t,n,r){[...this.straightLadderMap,...this.staircaseMap].forEach(([i,o])=>{if(!(o.length<2))for(let a=0;a<o.length;a++){let u=`${o[a].floor}${Q}${o[a].id}`;for(let l=0;l<o.length;l++)if(a!==l){let c=`${o[l].floor}${Q}${o[l].id}`,h=this.pointMap.get(u)?.cds,f=this.pointMap.get(c)?.cds;if(h?.length&&f?.length)if(o[a].type==="straightLadder"){let d=t;this.addLineItem(u,c,d,r)}else{let d=n;this.addLineItem(u,c,d,r)}}}}),this.escalatorMap.forEach((i,o)=>{if(i.start&&i.end){let a=`${i.start.floor}${Q}${i.start.id}`,u=`${i.end.floor}${Q}${i.end.id}`,l=this.pointMap.get(a)?.cds,c=this.pointMap.get(u)?.cds;if(l?.length&&c?.length){let h=e;this.addLineItem(a,u,h,r)}}})}initBaseRoute(){let e=new Map([...this.lineMap]);this.addFacilityToLineMap(1,this.lift_priority,3e4,e),this.baseRoute=new pt.default(e)}initEscalatorRoute(){let e=new Map([...this.lineMap]),t=1e4;this.addFacilityToLineMap(1*t,this.lift_priority*t,3e4*t,e),this.escalatorRoute=new pt.default(e)}initStraightLadderRoute(){let e=new Map([...this.lineMap]),t=1e4;this.addFacilityToLineMap(3*t,1*t,3e4*t,e),this.straightLadderRoute=new pt.default(e)}checkStart(e){return!(!e.floor||!e.nodeId&&(!e.coord||e.coord.length<2))}checkEnd(e){return e.facility?!0:this.checkStart(e)}transformStart(e){if(e.nodeId){let t=this.nodeMap.get(`${e.floor}${Q}${e.nodeId}`);if(t){let[n,r]=t.split(Q);return{floor:n,id:r}}}if(e.coord?.length){let t=this.roadInfo.find(r=>r.floor===e.floor);if(!t)return null;let n=t.points.reduce((r,i)=>{let o=N(e.coord,i.cds);return o<r.min&&(r.min=o,r.point=i),r},{min:1/0,point:t.points[0]});return{floor:n.point.floor,id:n.point.id}}return null}transformEnd(e){if(e.floor){let t=this.transformStart(e);if(t)return t}return e.facility&&this.facilityMap.get(e.facility)?.length?{floor:e.floor,facility:e.facility}:null}getPath(e,t,n=""){if(!this.checkStart(e))return"start-error";if(!this.checkEnd(t))return"end-error";let r=this.transformStart(e);if(!r)return"no-start";let i=this.transformEnd(t);if(!i)return"no-end";let o=this.getBasePath.bind(this);switch(n){case"escalator":o=this.getEscalatorPath.bind(this);break;case"straightLadder":o=this.getStraightLadderPath.bind(this);break;default:o=this.getBasePath.bind(this);break}if(i.id)return o(r,i);if(i.facility){let a=this.facilityMap.get(i.facility).filter(l=>i.floor?l.floor===i.floor:!0);if(!a.length)return null;let u=a.map(l=>o(r,{floor:l.floor,id:l.id})).filter(l=>!!l);return u.reduce((l,c)=>{let h=c.reduce((f,d)=>f+ot(d.points),0);return h<l.distance&&(l.distance=h,l.path=c),l},{distance:1/0,path:u[0]}).path}}getRoutePath(e,t,n){let r=`${e.floor}${Q}${e.id}`,i=`${t.floor}${Q}${t.id}`,o=n.path(r,i);if(!o)return null;let a=[];return o.map(u=>{let l=this.pointMap.get(u);if(l){let{floor:c}=l;if(a[a.length-1]?.floor===c){let h=a[a.length-1];h.points.push(l.cds),h.endType=l.type,h.destId=l.nodeId,h.distance=ot(h.points)}else a.push({floor:c,points:[l.cds],endType:l.type,destId:l.nodeId,distance:0})}}),a}getBasePath(e,t){return this.getRoutePath(e,t,this.baseRoute)}getEscalatorPath(e,t){return this.getRoutePath(e,t,this.escalatorRoute)}getStraightLadderPath(e,t){return this.getRoutePath(e,t,this.straightLadderRoute)}clear(){this.roadInfo=[],this.pointMap.clear(),this.nodeMap.clear(),this.facilityMap.clear(),this.straightLadderMap.clear(),this.escalatorMap.clear(),this.staircaseMap.clear(),this.lineMap.clear(),this.baseRoute=new pt.default,this.escalatorRoute=new pt.default,this.straightLadderRoute=new pt.default}};var tt=$t(gn(),1);var Me=require("lodash"),G="___",_n=class{constructor(e=3){this.lift_priority=e}roadInfo=[];facilities=[];pointMap=new Map;nodeMap=new Map;facilityMap=new Map;straightLadderMap=new Map;escalatorMap=new Map;rampMap=new Map;staircaseMap=new Map;parkingMap=new Map;lineMap=new Map;baseRoute=new tt.default;escalatorRoute=new tt.default;straightLadderRoute=new tt.default;forwardLineMap=new Map;forwardRoute=new tt.default;isFacilityByType(e){return["facility","escalator","straightLadder","staircase","ramp"].includes(e)}initFacilities(e){this.facilities=e.map(t=>{let n=[];try{n=JSON.parse(t.entry_end_floor)}catch{n=[]}let r=[];try{r=JSON.parse(t.entry_start_floor)}catch{r=[]}return{...t,entry_start_floor:r,entry_end_floor:n}})}initRoute(e,t){this.clear(),this.roadInfo=e,this.initFacilities(t),e.length&&(e.forEach(n=>{n.points.forEach(r=>{r.floor=n.floor;let i=`${n.floor}${G}${r.id}`;if(this.pointMap.set(i,r),this.nodeMap.set(`${n.floor}${G}${r.nodeId}`,i),this.isFacilityByType(r.type)){let o=this.facilities.find(a=>a.id===+r.targetId);if(o){switch(o.entry_infra_type){case"straightLadder":if(o.entry_end_floor.find(c=>c.floor===n.floor)&&o.entry_start_floor.find(c=>c.floor===n.floor)){let c=this.straightLadderMap.get(r.targetId)||[];c.push({...r}),this.straightLadderMap.set(r.targetId,c)}break;case"staircase":if(o.entry_end_floor.find(c=>c.floor===n.floor)&&o.entry_start_floor.find(c=>c.floor===n.floor)){let c=this.staircaseMap.get(r.targetId)||[];c.push({...r}),this.staircaseMap.set(r.targetId,c)}break;case"escalator":let u=this.escalatorMap.get(r.targetId)||[];if(o.entry_start_floor.find(c=>c.floor===n.floor)){let c=u.find(h=>h.end?.floor!==n.floor&&!h.start);c?c.start=r:u.push({start:r})}if(o.entry_end_floor.find(c=>c.floor===n.floor)){let c=u.find(h=>h.start?.floor!==n.floor&&!h.end);c?c.end=r:u.push({end:r})}this.escalatorMap.set(r.targetId,u);break;case"ramp":let l=this.rampMap.get(r.targetId)||[];if(o.entry_start_floor.find(c=>c.floor===n.floor)){let c=l.find(h=>h.end?.floor!==n.floor&&!h.start);c?c.start=r:l.push({start:r})}if(o.entry_end_floor.find(c=>c.floor===n.floor)){let c=l.find(h=>h.start?.floor!==n.floor&&!h.end);c?c.end=r:l.push({end:r})}this.rampMap.set(r.targetId,l);break}let a=this.facilityMap.get(r.targetId)||[];a.push({...r}),this.facilityMap.set(r.targetId,a)}}r.type==="parkingSpace"&&this.parkingMap.set(`${n.floor}${G}${r.name}`,r)}),n.lines.filter(r=>r.direction!=="no").forEach(r=>{let i=`${n.floor}${G}${r.from}`,o=`${n.floor}${G}${r.to}`,a=this.pointMap.get(i)?.cds,u=this.pointMap.get(o)?.cds;if(a?.length&&u?.length){let l=N(a,u);switch(this.addLineItem(i,o,l),this.addLineItem(o,i,l),r.direction){case"double":this.addLineItem(i,o,l,this.forwardLineMap),this.addLineItem(o,i,l,this.forwardLineMap);break;case"single":this.addLineItem(i,o,l,this.forwardLineMap);break;case"back":this.addLineItem(o,i,l,this.forwardLineMap);break}}})}),this.initBaseRoute(),this.initEscalatorRoute(),this.initStraightLadderRoute(),this.initForwardRoute())}addLineItem(e,t,n,r=this.lineMap){let i=r.get(e)||new Map;i.set(t,n),r.set(e,i)}addFacilityToLineMap(e,t,n,r){[...this.straightLadderMap,...this.staircaseMap].forEach(([i,o])=>{if(!(o.length<2))for(let a=0;a<o.length;a++){let u=`${o[a].floor}${G}${o[a].id}`;for(let l=0;l<o.length;l++)if(a!==l){let c=`${o[l].floor}${G}${o[l].id}`,h=this.pointMap.get(u)?.cds,f=this.pointMap.get(c)?.cds;if(h?.length&&f?.length)if(o[a].type==="straightLadder"){let d=t;this.addLineItem(u,c,d,r)}else{let d=n;this.addLineItem(u,c,d,r)}}}}),this.escalatorMap.forEach((i,o)=>{i.forEach(a=>{if(a.start&&a.end){let u=`${a.start.floor}${G}${a.start.id}`,l=`${a.end.floor}${G}${a.end.id}`,c=this.pointMap.get(u)?.cds,h=this.pointMap.get(l)?.cds;if(c?.length&&h?.length){let f=e;this.addLineItem(u,l,f,r)}}})})}initBaseRoute(){let e=new Map((0,Me.cloneDeep)([...this.lineMap]));this.addFacilityToLineMap(1,this.lift_priority,3e4,e),this.baseRoute=new tt.default(e)}initEscalatorRoute(){let e=new Map((0,Me.cloneDeep)([...this.lineMap])),t=1e4;this.addFacilityToLineMap(1*t,this.lift_priority*t,3e4*t,e),this.escalatorRoute=new tt.default(e)}initStraightLadderRoute(){let e=new Map((0,Me.cloneDeep)([...this.lineMap])),t=1e4;this.addFacilityToLineMap(3*t,1*t,3e4*t,e),this.straightLadderRoute=new tt.default(e)}initForwardRoute(){this.rampMap.forEach((e,t)=>{e.forEach(n=>{if(n.start&&n.end){let r=`${n.start.floor}${G}${n.start.id}`,i=`${n.end.floor}${G}${n.end.id}`,o=this.pointMap.get(r)?.cds,a=this.pointMap.get(i)?.cds;o?.length&&a?.length&&this.addLineItem(r,i,10,this.forwardLineMap)}})}),this.forwardRoute=new tt.default(this.forwardLineMap)}checkStart(e){return!(!e.floor||!e.nodeId&&(!e.coord||e.coord.length<2))}checkEnd(e){return e.facility||e.parkingSpace&&e.floor?!0:this.checkStart(e)}transformStart(e){if(e.nodeId){let t=this.nodeMap.get(`${e.floor}${G}${e.nodeId}`);if(t){let[n,r]=t.split(G);return{floor:n,id:r}}}if(e.coord?.length){let t=this.roadInfo.find(r=>r.floor===e.floor);if(!t)return null;let n=t.points.reduce((r,i)=>{let o=N(e.coord,i.cds);return o<r.min&&(r.min=o,r.point=i),r},{min:1/0,point:t.points[0]});return{floor:t.floor,id:n.point.id}}return null}transformEnd(e){if(e.floor){if(e.parkingSpace){let n=this.parkingMap.get(`${e.floor}${G}${e.parkingSpace}`);if(n)return{floor:e.floor,id:n.id}}let t=this.transformStart(e);if(t)return t}return e.facility&&this.facilities.filter(r=>+r.type_id==+e.facility).map(r=>r.id).map(r=>this.facilityMap.get(`${r}`)).flat(2)?.length?{floor:e.floor,facility:e.facility}:null}getPath(e,t,n=""){if(!this.checkStart(e))return"start-error";if(!this.checkEnd(t))return"end-error";let r=this.transformStart(e);if(!r)return"no-start";let i=this.transformEnd(t);if(!i)return"no-end";let o=this.getBasePath.bind(this);switch(n){case"escalator":o=this.getEscalatorPath.bind(this);break;case"straightLadder":o=this.getStraightLadderPath.bind(this);break;case"forward":o=this.getForwardPath.bind(this);break;default:o=this.getBasePath.bind(this);break}if(i.id)return o(r,i);if(i.facility){let u=this.facilities.filter(c=>+c.type_id==+t.facility).map(c=>c.id).map(c=>this.facilityMap.get(`${c}`)).flat(2).filter(c=>c).filter(c=>i.floor?c.floor===i.floor:!0);if(!u.length)return null;let l=u.map(c=>o(r,{floor:c.floor,id:c.id})).filter(c=>!!c);return l.reduce((c,h)=>{let f=h.reduce((d,m)=>d+ot(m.points),0);return f<c.distance&&(c.distance=f,c.path=h),c},{distance:1/0,path:l[0]}).path}}getRoutePath(e,t,n){let r=`${e.floor}${G}${e.id}`,i=`${t.floor}${G}${t.id}`,o=n.path(r,i);if(!o)return null;let a=[];return o.map(u=>{let l=this.pointMap.get(u);if(l){let{floor:c}=l,h=l.type;if(this.isFacilityByType(l.type)){let f=this.facilities.find(d=>d.id===+l.targetId);f&&(h=f.entry_infra_type)}if(a[a.length-1]?.floor===c){let f=a[a.length-1];f.points.push(l.cds),f.endType=h,f.destId=l.nodeId,f.distance=ot(f.points)}else a.push({floor:c,points:[l.cds],endType:h,destId:l.nodeId,distance:0})}}),a}getBasePath(e,t){return this.getRoutePath(e,t,this.baseRoute)}getEscalatorPath(e,t){return this.getRoutePath(e,t,this.escalatorRoute)}getStraightLadderPath(e,t){return this.getRoutePath(e,t,this.straightLadderRoute)}getForwardPath(e,t){return this.getRoutePath(e,t,this.forwardRoute)}clear(){this.roadInfo=[],this.pointMap.clear(),this.nodeMap.clear(),this.facilityMap.clear(),this.straightLadderMap.clear(),this.escalatorMap.clear(),this.staircaseMap.clear(),this.lineMap.clear(),this.baseRoute=new tt.default,this.escalatorRoute=new tt.default,this.straightLadderRoute=new tt.default}};var Lt=class{static keySet=new Set;static createKey(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)}static genUniqueKey(){let e=this.createKey();for(;this.keySet.has(e);)e=this.createKey();return e}static removeKey(e){this.keySet.delete(e)}static dispose(){this.keySet.clear()}};function yn(s){return s.replace(/[A-Z]/g,e=>"_"+e.toLowerCase()).replace(/^_/,"")}function st(s,e,t){return new Promise((n,r)=>{let i=Lt.genUniqueKey(),o=({data:a})=>{a.type===`${e}_result`&&a.key===i&&(Lt.removeKey(i),self.removeEventListener("message",o),a.error?r(a.error):n(a.data))};s.addEventListener("message",o),s.postMessage({type:e,key:i,data:t})})}function Ai(s){let e={};for(let n in s)n.startsWith("on")&&(e[yn(n.slice(2))]=s[n]);let t=async({data:n})=>{if(e[n.type])try{let r=await e[n.type](n.data);self.postMessage({type:`${n.type}_result`,key:n.key,data:r})}catch(r){self.postMessage({type:`${n.type}_result`,key:n.key,error:r})}else self.postMessage({type:`${n.type}_result`,key:n.key,error:"no_event"})};return self.addEventListener("message",t),()=>{self.removeEventListener("message",t)}}var at=require("three");function Ii(s,e=16711680){let t=new at.LineBasicMaterial({color:e}),n=new at.BufferGeometry().setFromPoints(s);return new at.Line(n,t)}function Ri(s,e=16711680){let t=new at.LineBasicMaterial({color:e}),n=new at.BoxGeometry(1,1,1),r=new at.Mesh(n,t);return r.position.copy(s),r}function W(s,e,t=0){s.forEach(n=>{n.geometry.coords=JSON.parse(JSON.stringify(n.geometry.cds)),n.geometry.type==="polygon"?(n.geometry.coords.map(r=>{Array.isArray(r)&&r.forEach(i=>{i[0]-=e[0],i[1]-=e[1]})}),n.geometry.otherCds&&(n.geometry.otherCoords=n.geometry.otherCds.map(r=>r.map(i=>et(i,e)))),n.doors?.length&&n.doors.map(r=>{r.coord=et(r.coordinate,e)}),n.center&&(n.center=et(n.center,e))):n.geometry.coords=et(n.geometry.cds,e)});for(let n=0;n<s.length;n++){let r=s[n];r.deltaHeight=1e-5*(t+n+1)}}function et(s,e){return[s[0]-e[0],s[1]-e[1]]}var hr=require("@tweenjs/tween.js"),Nt=class{pauseTween=!1;tweenStore=new Set;group=new hr.Group;constructor(){}update(){this.group.update()}pause(){this.pauseTween=!0,this.getAll().forEach(e=>{this.tweenStore.add(e),e.pause()})}continue(){this.pauseTween&&(this.tweenStore.forEach(e=>{e.resume()}),this.tweenStore.clear(),this.pauseTween=!1)}remove(e){this.group.remove(e)}getAll(){return this.group.getAll()}clear(){this.getAll().forEach(e=>e.stop()),this.group.removeAll()}dispose(){this.clear()}};var S=require("three");var Rr=require("three");var v=require("three");var fr=require("three/examples/jsm/lines/LineMaterial"),V=require("three");function pr(s){return`${s.x}-${s.y}-${s.z}`}var P=class{static lineMaterialMap=new Map;static meshStandardMaterialMap=new Map;static meshBasicMaterialMap=new Map;static shaderMaterialMap=new Map;static line2MaterialMap=new Map;static generateLineMaterialKey({color:e,opacity:t}){return`${e}-${t}`}static createLineMaterial({color:e,opacity:t}){let n=this.generateLineMaterialKey({color:e,opacity:t});if(this.lineMaterialMap.has(n))return this.lineMaterialMap.get(n);let r=new V.LineBasicMaterial({color:new V.Color(e).convertLinearToSRGB(),transparent:!0,opacity:t});return this.lineMaterialMap.set(n,r),r}static createMeshStandardMaterial({color:e,opacity:t}){let n=`${e}-${t}`;if(this.meshStandardMaterialMap.has(n))return this.meshStandardMaterialMap.get(n);let r=new V.MeshStandardMaterial({color:new V.Color(e).convertLinearToSRGB(),roughness:1,transparent:!0,opacity:t,depthWrite:!0});return this.meshStandardMaterialMap.set(n,r),r}static createMeshBasicMaterial({color:e,opacity:t}){let n=`${e}-${t}`;if(this.meshBasicMaterialMap.has(n))return this.meshBasicMaterialMap.get(n);let r=new V.MeshBasicMaterial({color:e,transparent:!0,opacity:t,depthWrite:!0});return this.meshBasicMaterialMap.set(n,r),r}static createShaderMaterial({gradualColor:e,center:t,maxValue:n,opacity:r,direction:i,max:o,min:a}){let u=`${e.toString()}-${pr(t)}-${n}-${r}-${pr(i)}`;if(this.shaderMaterialMap.has(u))return this.shaderMaterialMap.get(u);let l=`
|
|
2
2
|
uniform vec3 uColor;
|
|
3
3
|
uniform vec3 uGradualColor;
|
|
4
4
|
uniform vec3 center;
|
|
@@ -3702,7 +3702,7 @@ void main() {
|
|
|
3702
3702
|
float std_dev = sqrt( squared_mean - mean * mean );
|
|
3703
3703
|
gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
|
|
3704
3704
|
}\`;function UO(r,t,e){let o=new Xh,a=new tr,c=new tr,p=new qi,d=new Jg({depthPacking:VI}),g=new Kg,y={},_=e.maxTextureSize,w={[Mu]:Ho,[Ho]:Mu,[Wa]:Wa},x=new Za({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new tr},radius:{value:4}},vertexShader:DO,fragmentShader:FO}),T=x.clone();T.defines.HORIZONTAL_PASS=1;let P=new rl;P.setAttribute("position",new Cs(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let I=new fa(P,x),M=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=I1;let E=this.type;this.render=function(z,$,q){if(M.enabled===!1||M.autoUpdate===!1&&M.needsUpdate===!1||z.length===0)return;let D=r.getRenderTarget(),G=r.getActiveCubeFace(),Q=r.getActiveMipmapLevel(),_t=r.state;_t.setBlending(xu),_t.buffers.color.setClear(1,1,1,1),_t.buffers.depth.setTest(!0),_t.setScissorTest(!1);let Z=E!==Ha&&this.type===Ha,Dt=E===Ha&&this.type!==Ha;for(let et=0,vt=z.length;et<vt;et++){let It=z[et],Pt=It.shadow;if(Pt===void 0){console.warn("THREE.WebGLShadowMap:",It,"has no shadow.");continue}if(Pt.autoUpdate===!1&&Pt.needsUpdate===!1)continue;a.copy(Pt.mapSize);let Et=Pt.getFrameExtents();if(a.multiply(Et),c.copy(Pt.mapSize),(a.x>_||a.y>_)&&(a.x>_&&(c.x=Math.floor(_/Et.x),a.x=c.x*Et.x,Pt.mapSize.x=c.x),a.y>_&&(c.y=Math.floor(_/Et.y),a.y=c.y*Et.y,Pt.mapSize.y=c.y)),Pt.map===null||Z===!0||Dt===!0){let Y=this.type!==Ha?{minFilter:vo,magFilter:vo}:{};Pt.map!==null&&Pt.map.dispose(),Pt.map=new $a(a.x,a.y,Y),Pt.map.texture.name=It.name+".shadowMap",Pt.camera.updateProjectionMatrix()}r.setRenderTarget(Pt.map),r.clear();let yt=Pt.getViewportCount();for(let Y=0;Y<yt;Y++){let ht=Pt.getViewport(Y);p.set(c.x*ht.x,c.y*ht.y,c.x*ht.z,c.y*ht.w),_t.viewport(p),Pt.updateMatrices(It,Y),o=Pt.getFrustum(),U($,q,Pt.camera,It,this.type)}Pt.isPointLightShadow!==!0&&this.type===Ha&&N(Pt,q),Pt.needsUpdate=!1}E=this.type,M.needsUpdate=!1,r.setRenderTarget(D,G,Q)};function N(z,$){let q=t.update(I);x.defines.VSM_SAMPLES!==z.blurSamples&&(x.defines.VSM_SAMPLES=z.blurSamples,T.defines.VSM_SAMPLES=z.blurSamples,x.needsUpdate=!0,T.needsUpdate=!0),z.mapPass===null&&(z.mapPass=new $a(a.x,a.y)),x.uniforms.shadow_pass.value=z.map.texture,x.uniforms.resolution.value=z.mapSize,x.uniforms.radius.value=z.radius,r.setRenderTarget(z.mapPass),r.clear(),r.renderBufferDirect($,null,q,x,I,null),T.uniforms.shadow_pass.value=z.mapPass.texture,T.uniforms.resolution.value=z.mapSize,T.uniforms.radius.value=z.radius,r.setRenderTarget(z.map),r.clear(),r.renderBufferDirect($,null,q,T,I,null)}function A(z,$,q,D){let G=null,Q=q.isPointLight===!0?z.customDistanceMaterial:z.customDepthMaterial;if(Q!==void 0)G=Q;else if(G=q.isPointLight===!0?g:d,r.localClippingEnabled&&$.clipShadows===!0&&Array.isArray($.clippingPlanes)&&$.clippingPlanes.length!==0||$.displacementMap&&$.displacementScale!==0||$.alphaMap&&$.alphaTest>0||$.map&&$.alphaTest>0){let _t=G.uuid,Z=$.uuid,Dt=y[_t];Dt===void 0&&(Dt={},y[_t]=Dt);let et=Dt[Z];et===void 0&&(et=G.clone(),Dt[Z]=et),G=et}if(G.visible=$.visible,G.wireframe=$.wireframe,D===Ha?G.side=$.shadowSide!==null?$.shadowSide:$.side:G.side=$.shadowSide!==null?$.shadowSide:w[$.side],G.alphaMap=$.alphaMap,G.alphaTest=$.alphaTest,G.map=$.map,G.clipShadows=$.clipShadows,G.clippingPlanes=$.clippingPlanes,G.clipIntersection=$.clipIntersection,G.displacementMap=$.displacementMap,G.displacementScale=$.displacementScale,G.displacementBias=$.displacementBias,G.wireframeLinewidth=$.wireframeLinewidth,G.linewidth=$.linewidth,q.isPointLight===!0&&G.isMeshDistanceMaterial===!0){let _t=r.properties.get(G);_t.light=q}return G}function U(z,$,q,D,G){if(z.visible===!1)return;if(z.layers.test($.layers)&&(z.isMesh||z.isLine||z.isPoints)&&(z.castShadow||z.receiveShadow&&G===Ha)&&(!z.frustumCulled||o.intersectsObject(z))){z.modelViewMatrix.multiplyMatrices(q.matrixWorldInverse,z.matrixWorld);let Z=t.update(z),Dt=z.material;if(Array.isArray(Dt)){let et=Z.groups;for(let vt=0,It=et.length;vt<It;vt++){let Pt=et[vt],Et=Dt[Pt.materialIndex];if(Et&&Et.visible){let yt=A(z,Et,D,G);r.renderBufferDirect(q,null,Z,yt,z,Pt)}}}else if(Dt.visible){let et=A(z,Dt,D,G);r.renderBufferDirect(q,null,Z,et,z,null)}}let _t=z.children;for(let Z=0,Dt=_t.length;Z<Dt;Z++)U(_t[Z],$,q,D,G)}}function BO(r,t,e){let o=e.isWebGL2;function a(){let k=!1,ut=new qi,nt=null,lt=new qi(0,0,0,0);return{setMask:function(dt){nt!==dt&&!k&&(r.colorMask(dt,dt,dt,dt),nt=dt)},setLocked:function(dt){k=dt},setClear:function(dt,at,Bt,qt,we){we===!0&&(dt*=qt,at*=qt,Bt*=qt),ut.set(dt,at,Bt,qt),lt.equals(ut)===!1&&(r.clearColor(dt,at,Bt,qt),lt.copy(ut))},reset:function(){k=!1,nt=null,lt.set(-1,0,0,0)}}}function c(){let k=!1,ut=null,nt=null,lt=null;return{setTest:function(dt){dt?le(r.DEPTH_TEST):Qt(r.DEPTH_TEST)},setMask:function(dt){ut!==dt&&!k&&(r.depthMask(dt),ut=dt)},setFunc:function(dt){if(nt!==dt){switch(dt){case vI:r.depthFunc(r.NEVER);break;case _I:r.depthFunc(r.ALWAYS);break;case xI:r.depthFunc(r.LESS);break;case Pg:r.depthFunc(r.LEQUAL);break;case EI:r.depthFunc(r.EQUAL);break;case wI:r.depthFunc(r.GEQUAL);break;case MI:r.depthFunc(r.GREATER);break;case SI:r.depthFunc(r.NOTEQUAL);break;default:r.depthFunc(r.LEQUAL)}nt=dt}},setLocked:function(dt){k=dt},setClear:function(dt){lt!==dt&&(r.clearDepth(dt),lt=dt)},reset:function(){k=!1,ut=null,nt=null,lt=null}}}function p(){let k=!1,ut=null,nt=null,lt=null,dt=null,at=null,Bt=null,qt=null,we=null;return{setTest:function(oe){k||(oe?le(r.STENCIL_TEST):Qt(r.STENCIL_TEST))},setMask:function(oe){ut!==oe&&!k&&(r.stencilMask(oe),ut=oe)},setFunc:function(oe,Ve,je){(nt!==oe||lt!==Ve||dt!==je)&&(r.stencilFunc(oe,Ve,je),nt=oe,lt=Ve,dt=je)},setOp:function(oe,Ve,je){(at!==oe||Bt!==Ve||qt!==je)&&(r.stencilOp(oe,Ve,je),at=oe,Bt=Ve,qt=je)},setLocked:function(oe){k=oe},setClear:function(oe){we!==oe&&(r.clearStencil(oe),we=oe)},reset:function(){k=!1,ut=null,nt=null,lt=null,dt=null,at=null,Bt=null,qt=null,we=null}}}let d=new a,g=new c,y=new p,_=new WeakMap,w=new WeakMap,x={},T={},P=new WeakMap,I=[],M=null,E=!1,N=null,A=null,U=null,z=null,$=null,q=null,D=null,G=!1,Q=null,_t=null,Z=null,Dt=null,et=null,vt=r.getParameter(r.MAX_COMBINED_TEXTURE_IMAGE_UNITS),It=!1,Pt=0,Et=r.getParameter(r.VERSION);Et.indexOf("WebGL")!==-1?(Pt=parseFloat(/^WebGL (\\d)/.exec(Et)[1]),It=Pt>=1):Et.indexOf("OpenGL ES")!==-1&&(Pt=parseFloat(/^OpenGL ES (\\d)/.exec(Et)[1]),It=Pt>=2);let yt=null,Y={},ht=r.getParameter(r.SCISSOR_BOX),Mt=r.getParameter(r.VIEWPORT),zt=new qi().fromArray(ht),At=new qi().fromArray(Mt);function $t(k,ut,nt,lt){let dt=new Uint8Array(4),at=r.createTexture();r.bindTexture(k,at),r.texParameteri(k,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(k,r.TEXTURE_MAG_FILTER,r.NEAREST);for(let Bt=0;Bt<nt;Bt++)o&&(k===r.TEXTURE_3D||k===r.TEXTURE_2D_ARRAY)?r.texImage3D(ut,0,r.RGBA,1,1,lt,0,r.RGBA,r.UNSIGNED_BYTE,dt):r.texImage2D(ut+Bt,0,r.RGBA,1,1,0,r.RGBA,r.UNSIGNED_BYTE,dt);return at}let ue={};ue[r.TEXTURE_2D]=$t(r.TEXTURE_2D,r.TEXTURE_2D,1),ue[r.TEXTURE_CUBE_MAP]=$t(r.TEXTURE_CUBE_MAP,r.TEXTURE_CUBE_MAP_POSITIVE_X,6),o&&(ue[r.TEXTURE_2D_ARRAY]=$t(r.TEXTURE_2D_ARRAY,r.TEXTURE_2D_ARRAY,1,1),ue[r.TEXTURE_3D]=$t(r.TEXTURE_3D,r.TEXTURE_3D,1,1)),d.setClear(0,0,0,1),g.setClear(1),y.setClear(0),le(r.DEPTH_TEST),g.setFunc(Pg),de(!1),Ue(l_),le(r.CULL_FACE),te(xu);function le(k){x[k]!==!0&&(r.enable(k),x[k]=!0)}function Qt(k){x[k]!==!1&&(r.disable(k),x[k]=!1)}function me(k,ut){return T[k]!==ut?(r.bindFramebuffer(k,ut),T[k]=ut,o&&(k===r.DRAW_FRAMEBUFFER&&(T[r.FRAMEBUFFER]=ut),k===r.FRAMEBUFFER&&(T[r.DRAW_FRAMEBUFFER]=ut)),!0):!1}function Xt(k,ut){let nt=I,lt=!1;if(k)if(nt=P.get(ut),nt===void 0&&(nt=[],P.set(ut,nt)),k.isWebGLMultipleRenderTargets){let dt=k.texture;if(nt.length!==dt.length||nt[0]!==r.COLOR_ATTACHMENT0){for(let at=0,Bt=dt.length;at<Bt;at++)nt[at]=r.COLOR_ATTACHMENT0+at;nt.length=dt.length,lt=!0}}else nt[0]!==r.COLOR_ATTACHMENT0&&(nt[0]=r.COLOR_ATTACHMENT0,lt=!0);else nt[0]!==r.BACK&&(nt[0]=r.BACK,lt=!0);lt&&(e.isWebGL2?r.drawBuffers(nt):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(nt))}function Ee(k){return M!==k?(r.useProgram(k),M=k,!0):!1}let ft={[Vl]:r.FUNC_ADD,[aI]:r.FUNC_SUBTRACT,[uI]:r.FUNC_REVERSE_SUBTRACT};if(o)ft[p_]=r.MIN,ft[d_]=r.MAX;else{let k=t.get("EXT_blend_minmax");k!==null&&(ft[p_]=k.MIN_EXT,ft[d_]=k.MAX_EXT)}let He={[lI]:r.ZERO,[cI]:r.ONE,[fI]:r.SRC_COLOR,[R1]:r.SRC_ALPHA,[yI]:r.SRC_ALPHA_SATURATE,[gI]:r.DST_COLOR,[pI]:r.DST_ALPHA,[hI]:r.ONE_MINUS_SRC_COLOR,[L1]:r.ONE_MINUS_SRC_ALPHA,[mI]:r.ONE_MINUS_DST_COLOR,[dI]:r.ONE_MINUS_DST_ALPHA};function te(k,ut,nt,lt,dt,at,Bt,qt){if(k===xu){E===!0&&(Qt(r.BLEND),E=!1);return}if(E===!1&&(le(r.BLEND),E=!0),k!==sI){if(k!==N||qt!==G){if((A!==Vl||$!==Vl)&&(r.blendEquation(r.FUNC_ADD),A=Vl,$=Vl),qt)switch(k){case Yl:r.blendFuncSeparate(r.ONE,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case c_:r.blendFunc(r.ONE,r.ONE);break;case f_:r.blendFuncSeparate(r.ZERO,r.ONE_MINUS_SRC_COLOR,r.ZERO,r.ONE);break;case h_:r.blendFuncSeparate(r.ZERO,r.SRC_COLOR,r.ZERO,r.SRC_ALPHA);break;default:console.error("THREE.WebGLState: Invalid blending: ",k);break}else switch(k){case Yl:r.blendFuncSeparate(r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA);break;case c_:r.blendFunc(r.SRC_ALPHA,r.ONE);break;case f_:r.blendFuncSeparate(r.ZERO,r.ONE_MINUS_SRC_COLOR,r.ZERO,r.ONE);break;case h_:r.blendFunc(r.ZERO,r.SRC_COLOR);break;default:console.error("THREE.WebGLState: Invalid blending: ",k);break}U=null,z=null,q=null,D=null,N=k,G=qt}return}dt=dt||ut,at=at||nt,Bt=Bt||lt,(ut!==A||dt!==$)&&(r.blendEquationSeparate(ft[ut],ft[dt]),A=ut,$=dt),(nt!==U||lt!==z||at!==q||Bt!==D)&&(r.blendFuncSeparate(He[nt],He[lt],He[at],He[Bt]),U=nt,z=lt,q=at,D=Bt),N=k,G=!1}function fe(k,ut){k.side===Wa?Qt(r.CULL_FACE):le(r.CULL_FACE);let nt=k.side===Ho;ut&&(nt=!nt),de(nt),k.blending===Yl&&k.transparent===!1?te(xu):te(k.blending,k.blendEquation,k.blendSrc,k.blendDst,k.blendEquationAlpha,k.blendSrcAlpha,k.blendDstAlpha,k.premultipliedAlpha),g.setFunc(k.depthFunc),g.setTest(k.depthTest),g.setMask(k.depthWrite),d.setMask(k.colorWrite);let lt=k.stencilWrite;y.setTest(lt),lt&&(y.setMask(k.stencilWriteMask),y.setFunc(k.stencilFunc,k.stencilRef,k.stencilFuncMask),y.setOp(k.stencilFail,k.stencilZFail,k.stencilZPass)),kt(k.polygonOffset,k.polygonOffsetFactor,k.polygonOffsetUnits),k.alphaToCoverage===!0?le(r.SAMPLE_ALPHA_TO_COVERAGE):Qt(r.SAMPLE_ALPHA_TO_COVERAGE)}function de(k){Q!==k&&(k?r.frontFace(r.CW):r.frontFace(r.CCW),Q=k)}function Ue(k){k!==rI?(le(r.CULL_FACE),k!==_t&&(k===l_?r.cullFace(r.BACK):k===iI?r.cullFace(r.FRONT):r.cullFace(r.FRONT_AND_BACK))):Qt(r.CULL_FACE),_t=k}function be(k){k!==Z&&(It&&r.lineWidth(k),Z=k)}function kt(k,ut,nt){k?(le(r.POLYGON_OFFSET_FILL),(Dt!==ut||et!==nt)&&(r.polygonOffset(ut,nt),Dt=ut,et=nt)):Qt(r.POLYGON_OFFSET_FILL)}function ye(k){k?le(r.SCISSOR_TEST):Qt(r.SCISSOR_TEST)}function Vn(k){k===void 0&&(k=r.TEXTURE0+vt-1),yt!==k&&(r.activeTexture(k),yt=k)}function $n(k,ut,nt){nt===void 0&&(yt===null?nt=r.TEXTURE0+vt-1:nt=yt);let lt=Y[nt];lt===void 0&&(lt={type:void 0,texture:void 0},Y[nt]=lt),(lt.type!==k||lt.texture!==ut)&&(yt!==nt&&(r.activeTexture(nt),yt=nt),r.bindTexture(k,ut||ue[k]),lt.type=k,lt.texture=ut)}function j(){let k=Y[yt];k!==void 0&&k.type!==void 0&&(r.bindTexture(k.type,null),k.type=void 0,k.texture=void 0)}function H(){try{r.compressedTexImage2D.apply(r,arguments)}catch(k){console.error("THREE.WebGLState:",k)}}function rt(){try{r.compressedTexImage3D.apply(r,arguments)}catch(k){console.error("THREE.WebGLState:",k)}}function Wt(){try{r.texSubImage2D.apply(r,arguments)}catch(k){console.error("THREE.WebGLState:",k)}}function Gt(){try{r.texSubImage3D.apply(r,arguments)}catch(k){console.error("THREE.WebGLState:",k)}}function Ct(){try{r.compressedTexSubImage2D.apply(r,arguments)}catch(k){console.error("THREE.WebGLState:",k)}}function he(){try{r.compressedTexSubImage3D.apply(r,arguments)}catch(k){console.error("THREE.WebGLState:",k)}}function Kt(){try{r.texStorage2D.apply(r,arguments)}catch(k){console.error("THREE.WebGLState:",k)}}function tt(){try{r.texStorage3D.apply(r,arguments)}catch(k){console.error("THREE.WebGLState:",k)}}function C(){try{r.texImage2D.apply(r,arguments)}catch(k){console.error("THREE.WebGLState:",k)}}function L(){try{r.texImage3D.apply(r,arguments)}catch(k){console.error("THREE.WebGLState:",k)}}function F(k){zt.equals(k)===!1&&(r.scissor(k.x,k.y,k.z,k.w),zt.copy(k))}function J(k){At.equals(k)===!1&&(r.viewport(k.x,k.y,k.z,k.w),At.copy(k))}function X(k,ut){let nt=w.get(ut);nt===void 0&&(nt=new WeakMap,w.set(ut,nt));let lt=nt.get(k);lt===void 0&&(lt=r.getUniformBlockIndex(ut,k.name),nt.set(k,lt))}function pt(k,ut){let lt=w.get(ut).get(k);_.get(ut)!==lt&&(r.uniformBlockBinding(ut,lt,k.__bindingPointIndex),_.set(ut,lt))}function st(){r.disable(r.BLEND),r.disable(r.CULL_FACE),r.disable(r.DEPTH_TEST),r.disable(r.POLYGON_OFFSET_FILL),r.disable(r.SCISSOR_TEST),r.disable(r.STENCIL_TEST),r.disable(r.SAMPLE_ALPHA_TO_COVERAGE),r.blendEquation(r.FUNC_ADD),r.blendFunc(r.ONE,r.ZERO),r.blendFuncSeparate(r.ONE,r.ZERO,r.ONE,r.ZERO),r.colorMask(!0,!0,!0,!0),r.clearColor(0,0,0,0),r.depthMask(!0),r.depthFunc(r.LESS),r.clearDepth(1),r.stencilMask(4294967295),r.stencilFunc(r.ALWAYS,0,4294967295),r.stencilOp(r.KEEP,r.KEEP,r.KEEP),r.clearStencil(0),r.cullFace(r.BACK),r.frontFace(r.CCW),r.polygonOffset(0,0),r.activeTexture(r.TEXTURE0),r.bindFramebuffer(r.FRAMEBUFFER,null),o===!0&&(r.bindFramebuffer(r.DRAW_FRAMEBUFFER,null),r.bindFramebuffer(r.READ_FRAMEBUFFER,null)),r.useProgram(null),r.lineWidth(1),r.scissor(0,0,r.canvas.width,r.canvas.height),r.viewport(0,0,r.canvas.width,r.canvas.height),x={},yt=null,Y={},T={},P=new WeakMap,I=[],M=null,E=!1,N=null,A=null,U=null,z=null,$=null,q=null,D=null,G=!1,Q=null,_t=null,Z=null,Dt=null,et=null,zt.set(0,0,r.canvas.width,r.canvas.height),At.set(0,0,r.canvas.width,r.canvas.height),d.reset(),g.reset(),y.reset()}return{buffers:{color:d,depth:g,stencil:y},enable:le,disable:Qt,bindFramebuffer:me,drawBuffers:Xt,useProgram:Ee,setBlending:te,setMaterial:fe,setFlipSided:de,setCullFace:Ue,setLineWidth:be,setPolygonOffset:kt,setScissorTest:ye,activeTexture:Vn,bindTexture:$n,unbindTexture:j,compressedTexImage2D:H,compressedTexImage3D:rt,texImage2D:C,texImage3D:L,updateUBOMapping:X,uniformBlockBinding:pt,texStorage2D:Kt,texStorage3D:tt,texSubImage2D:Wt,texSubImage3D:Gt,compressedTexSubImage2D:Ct,compressedTexSubImage3D:he,scissor:F,viewport:J,reset:st}}function zO(r,t,e,o,a,c,p){let d=a.isWebGL2,g=a.maxTextures,y=a.maxCubemapSize,_=a.maxTextureSize,w=a.maxSamples,x=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,T=typeof navigator=="undefined"?!1:/OculusBrowser/g.test(navigator.userAgent),P=new WeakMap,I,M=new WeakMap,E=!1;try{E=typeof OffscreenCanvas!="undefined"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch(j){}function N(j,H){return E?new OffscreenCanvas(j,H):Dh("canvas")}function A(j,H,rt,Wt){let Gt=1;if((j.width>Wt||j.height>Wt)&&(Gt=Wt/Math.max(j.width,j.height)),Gt<1||H===!0)if(typeof HTMLImageElement!="undefined"&&j instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&j instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&j instanceof ImageBitmap){let Ct=H?Fg:Math.floor,he=Ct(Gt*j.width),Kt=Ct(Gt*j.height);I===void 0&&(I=N(he,Kt));let tt=rt?N(he,Kt):I;return tt.width=he,tt.height=Kt,tt.getContext("2d").drawImage(j,0,0,he,Kt),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+j.width+"x"+j.height+") to ("+he+"x"+Kt+")."),tt}else return"data"in j&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+j.width+"x"+j.height+")."),j;return j}function U(j){return X_(j.width)&&X_(j.height)}function z(j){return d?!1:j.wrapS!==Hs||j.wrapT!==Hs||j.minFilter!==vo&&j.minFilter!==Ts}function $(j,H){return j.generateMipmaps&&H&&j.minFilter!==vo&&j.minFilter!==Ts}function q(j){r.generateMipmap(j)}function D(j,H,rt,Wt,Gt=!1){if(d===!1)return H;if(j!==null){if(r[j]!==void 0)return r[j];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+j+"'")}let Ct=H;if(H===r.RED&&(rt===r.FLOAT&&(Ct=r.R32F),rt===r.HALF_FLOAT&&(Ct=r.R16F),rt===r.UNSIGNED_BYTE&&(Ct=r.R8)),H===r.RED_INTEGER&&(rt===r.UNSIGNED_BYTE&&(Ct=r.R8UI),rt===r.UNSIGNED_SHORT&&(Ct=r.R16UI),rt===r.UNSIGNED_INT&&(Ct=r.R32UI),rt===r.BYTE&&(Ct=r.R8I),rt===r.SHORT&&(Ct=r.R16I),rt===r.INT&&(Ct=r.R32I)),H===r.RG&&(rt===r.FLOAT&&(Ct=r.RG32F),rt===r.HALF_FLOAT&&(Ct=r.RG16F),rt===r.UNSIGNED_BYTE&&(Ct=r.RG8)),H===r.RGBA){let he=Gt?Rh:yr.getTransfer(Wt);rt===r.FLOAT&&(Ct=r.RGBA32F),rt===r.HALF_FLOAT&&(Ct=r.RGBA16F),rt===r.UNSIGNED_BYTE&&(Ct=he===Pr?r.SRGB8_ALPHA8:r.RGBA8),rt===r.UNSIGNED_SHORT_4_4_4_4&&(Ct=r.RGBA4),rt===r.UNSIGNED_SHORT_5_5_5_1&&(Ct=r.RGB5_A1)}return(Ct===r.R16F||Ct===r.R32F||Ct===r.RG16F||Ct===r.RG32F||Ct===r.RGBA16F||Ct===r.RGBA32F)&&t.get("EXT_color_buffer_float"),Ct}function G(j,H,rt){return $(j,rt)===!0||j.isFramebufferTexture&&j.minFilter!==vo&&j.minFilter!==Ts?Math.log2(Math.max(H.width,H.height))+1:j.mipmaps!==void 0&&j.mipmaps.length>0?j.mipmaps.length:j.isCompressedTexture&&Array.isArray(j.image)?H.mipmaps.length:1}function Q(j){return j===vo||j===g_||j===jd?r.NEAREST:r.LINEAR}function _t(j){let H=j.target;H.removeEventListener("dispose",_t),Dt(H),H.isVideoTexture&&P.delete(H)}function Z(j){let H=j.target;H.removeEventListener("dispose",Z),vt(H)}function Dt(j){let H=o.get(j);if(H.__webglInit===void 0)return;let rt=j.source,Wt=M.get(rt);if(Wt){let Gt=Wt[H.__cacheKey];Gt.usedTimes--,Gt.usedTimes===0&&et(j),Object.keys(Wt).length===0&&M.delete(rt)}o.remove(j)}function et(j){let H=o.get(j);r.deleteTexture(H.__webglTexture);let rt=j.source,Wt=M.get(rt);delete Wt[H.__cacheKey],p.memory.textures--}function vt(j){let H=j.texture,rt=o.get(j),Wt=o.get(H);if(Wt.__webglTexture!==void 0&&(r.deleteTexture(Wt.__webglTexture),p.memory.textures--),j.depthTexture&&j.depthTexture.dispose(),j.isWebGLCubeRenderTarget)for(let Gt=0;Gt<6;Gt++){if(Array.isArray(rt.__webglFramebuffer[Gt]))for(let Ct=0;Ct<rt.__webglFramebuffer[Gt].length;Ct++)r.deleteFramebuffer(rt.__webglFramebuffer[Gt][Ct]);else r.deleteFramebuffer(rt.__webglFramebuffer[Gt]);rt.__webglDepthbuffer&&r.deleteRenderbuffer(rt.__webglDepthbuffer[Gt])}else{if(Array.isArray(rt.__webglFramebuffer))for(let Gt=0;Gt<rt.__webglFramebuffer.length;Gt++)r.deleteFramebuffer(rt.__webglFramebuffer[Gt]);else r.deleteFramebuffer(rt.__webglFramebuffer);if(rt.__webglDepthbuffer&&r.deleteRenderbuffer(rt.__webglDepthbuffer),rt.__webglMultisampledFramebuffer&&r.deleteFramebuffer(rt.__webglMultisampledFramebuffer),rt.__webglColorRenderbuffer)for(let Gt=0;Gt<rt.__webglColorRenderbuffer.length;Gt++)rt.__webglColorRenderbuffer[Gt]&&r.deleteRenderbuffer(rt.__webglColorRenderbuffer[Gt]);rt.__webglDepthRenderbuffer&&r.deleteRenderbuffer(rt.__webglDepthRenderbuffer)}if(j.isWebGLMultipleRenderTargets)for(let Gt=0,Ct=H.length;Gt<Ct;Gt++){let he=o.get(H[Gt]);he.__webglTexture&&(r.deleteTexture(he.__webglTexture),p.memory.textures--),o.remove(H[Gt])}o.remove(H),o.remove(j)}let It=0;function Pt(){It=0}function Et(){let j=It;return j>=g&&console.warn("THREE.WebGLTextures: Trying to use "+j+" texture units while this GPU supports only "+g),It+=1,j}function yt(j){let H=[];return H.push(j.wrapS),H.push(j.wrapT),H.push(j.wrapR||0),H.push(j.magFilter),H.push(j.minFilter),H.push(j.anisotropy),H.push(j.internalFormat),H.push(j.format),H.push(j.type),H.push(j.generateMipmaps),H.push(j.premultiplyAlpha),H.push(j.flipY),H.push(j.unpackAlignment),H.push(j.colorSpace),H.join()}function Y(j,H){let rt=o.get(j);if(j.isVideoTexture&&Vn(j),j.isRenderTargetTexture===!1&&j.version>0&&rt.__version!==j.version){let Wt=j.image;if(Wt===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if(Wt.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{me(rt,j,H);return}}e.bindTexture(r.TEXTURE_2D,rt.__webglTexture,r.TEXTURE0+H)}function ht(j,H){let rt=o.get(j);if(j.version>0&&rt.__version!==j.version){me(rt,j,H);return}e.bindTexture(r.TEXTURE_2D_ARRAY,rt.__webglTexture,r.TEXTURE0+H)}function Mt(j,H){let rt=o.get(j);if(j.version>0&&rt.__version!==j.version){me(rt,j,H);return}e.bindTexture(r.TEXTURE_3D,rt.__webglTexture,r.TEXTURE0+H)}function zt(j,H){let rt=o.get(j);if(j.version>0&&rt.__version!==j.version){Xt(rt,j,H);return}e.bindTexture(r.TEXTURE_CUBE_MAP,rt.__webglTexture,r.TEXTURE0+H)}let At={[Lg]:r.REPEAT,[Hs]:r.CLAMP_TO_EDGE,[Ng]:r.MIRRORED_REPEAT},$t={[vo]:r.NEAREST,[g_]:r.NEAREST_MIPMAP_NEAREST,[jd]:r.NEAREST_MIPMAP_LINEAR,[Ts]:r.LINEAR,[LI]:r.LINEAR_MIPMAP_NEAREST,[jc]:r.LINEAR_MIPMAP_LINEAR},ue={[YI]:r.NEVER,[tR]:r.ALWAYS,[$I]:r.LESS,[JI]:r.LEQUAL,[ZI]:r.EQUAL,[jI]:r.GEQUAL,[KI]:r.GREATER,[QI]:r.NOTEQUAL};function le(j,H,rt){if(rt?(r.texParameteri(j,r.TEXTURE_WRAP_S,At[H.wrapS]),r.texParameteri(j,r.TEXTURE_WRAP_T,At[H.wrapT]),(j===r.TEXTURE_3D||j===r.TEXTURE_2D_ARRAY)&&r.texParameteri(j,r.TEXTURE_WRAP_R,At[H.wrapR]),r.texParameteri(j,r.TEXTURE_MAG_FILTER,$t[H.magFilter]),r.texParameteri(j,r.TEXTURE_MIN_FILTER,$t[H.minFilter])):(r.texParameteri(j,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(j,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),(j===r.TEXTURE_3D||j===r.TEXTURE_2D_ARRAY)&&r.texParameteri(j,r.TEXTURE_WRAP_R,r.CLAMP_TO_EDGE),(H.wrapS!==Hs||H.wrapT!==Hs)&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),r.texParameteri(j,r.TEXTURE_MAG_FILTER,Q(H.magFilter)),r.texParameteri(j,r.TEXTURE_MIN_FILTER,Q(H.minFilter)),H.minFilter!==vo&&H.minFilter!==Ts&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.")),H.compareFunction&&(r.texParameteri(j,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(j,r.TEXTURE_COMPARE_FUNC,ue[H.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){let Wt=t.get("EXT_texture_filter_anisotropic");if(H.magFilter===vo||H.minFilter!==jd&&H.minFilter!==jc||H.type===_u&&t.has("OES_texture_float_linear")===!1||d===!1&&H.type===tf&&t.has("OES_texture_half_float_linear")===!1)return;(H.anisotropy>1||o.get(H).__currentAnisotropy)&&(r.texParameterf(j,Wt.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(H.anisotropy,a.getMaxAnisotropy())),o.get(H).__currentAnisotropy=H.anisotropy)}}function Qt(j,H){let rt=!1;j.__webglInit===void 0&&(j.__webglInit=!0,H.addEventListener("dispose",_t));let Wt=H.source,Gt=M.get(Wt);Gt===void 0&&(Gt={},M.set(Wt,Gt));let Ct=yt(H);if(Ct!==j.__cacheKey){Gt[Ct]===void 0&&(Gt[Ct]={texture:r.createTexture(),usedTimes:0},p.memory.textures++,rt=!0),Gt[Ct].usedTimes++;let he=Gt[j.__cacheKey];he!==void 0&&(Gt[j.__cacheKey].usedTimes--,he.usedTimes===0&&et(H)),j.__cacheKey=Ct,j.__webglTexture=Gt[Ct].texture}return rt}function me(j,H,rt){let Wt=r.TEXTURE_2D;(H.isDataArrayTexture||H.isCompressedArrayTexture)&&(Wt=r.TEXTURE_2D_ARRAY),H.isData3DTexture&&(Wt=r.TEXTURE_3D);let Gt=Qt(j,H),Ct=H.source;e.bindTexture(Wt,j.__webglTexture,r.TEXTURE0+rt);let he=o.get(Ct);if(Ct.version!==he.__version||Gt===!0){e.activeTexture(r.TEXTURE0+rt);let Kt=yr.getPrimaries(yr.workingColorSpace),tt=H.colorSpace===As?null:yr.getPrimaries(H.colorSpace),C=H.colorSpace===As||Kt===tt?r.NONE:r.BROWSER_DEFAULT_WEBGL;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,H.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,H.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,H.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,C);let L=z(H)&&U(H.image)===!1,F=A(H.image,L,!1,_);F=$n(H,F);let J=U(F)||d,X=c.convert(H.format,H.colorSpace),pt=c.convert(H.type),st=D(H.internalFormat,X,pt,H.colorSpace,H.isVideoTexture);le(Wt,H,J);let k,ut=H.mipmaps,nt=d&&H.isVideoTexture!==!0,lt=he.__version===void 0||Gt===!0,dt=G(H,F,J);if(H.isDepthTexture)st=r.DEPTH_COMPONENT,d?H.type===_u?st=r.DEPTH_COMPONENT32F:H.type===vu?st=r.DEPTH_COMPONENT24:H.type===ju?st=r.DEPTH24_STENCIL8:st=r.DEPTH_COMPONENT16:H.type===_u&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),H.format===tl&&st===r.DEPTH_COMPONENT&&H.type!==dm&&H.type!==vu&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),H.type=vu,pt=c.convert(H.type)),H.format===Ql&&st===r.DEPTH_COMPONENT&&(st=r.DEPTH_STENCIL,H.type!==ju&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),H.type=ju,pt=c.convert(H.type))),lt&&(nt?e.texStorage2D(r.TEXTURE_2D,1,st,F.width,F.height):e.texImage2D(r.TEXTURE_2D,0,st,F.width,F.height,0,X,pt,null));else if(H.isDataTexture)if(ut.length>0&&J){nt&<&&e.texStorage2D(r.TEXTURE_2D,dt,st,ut[0].width,ut[0].height);for(let at=0,Bt=ut.length;at<Bt;at++)k=ut[at],nt?e.texSubImage2D(r.TEXTURE_2D,at,0,0,k.width,k.height,X,pt,k.data):e.texImage2D(r.TEXTURE_2D,at,st,k.width,k.height,0,X,pt,k.data);H.generateMipmaps=!1}else nt?(lt&&e.texStorage2D(r.TEXTURE_2D,dt,st,F.width,F.height),e.texSubImage2D(r.TEXTURE_2D,0,0,0,F.width,F.height,X,pt,F.data)):e.texImage2D(r.TEXTURE_2D,0,st,F.width,F.height,0,X,pt,F.data);else if(H.isCompressedTexture)if(H.isCompressedArrayTexture){nt&<&&e.texStorage3D(r.TEXTURE_2D_ARRAY,dt,st,ut[0].width,ut[0].height,F.depth);for(let at=0,Bt=ut.length;at<Bt;at++)k=ut[at],H.format!==Vs?X!==null?nt?e.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,at,0,0,0,k.width,k.height,F.depth,X,k.data,0,0):e.compressedTexImage3D(r.TEXTURE_2D_ARRAY,at,st,k.width,k.height,F.depth,0,k.data,0,0):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):nt?e.texSubImage3D(r.TEXTURE_2D_ARRAY,at,0,0,0,k.width,k.height,F.depth,X,pt,k.data):e.texImage3D(r.TEXTURE_2D_ARRAY,at,st,k.width,k.height,F.depth,0,X,pt,k.data)}else{nt&<&&e.texStorage2D(r.TEXTURE_2D,dt,st,ut[0].width,ut[0].height);for(let at=0,Bt=ut.length;at<Bt;at++)k=ut[at],H.format!==Vs?X!==null?nt?e.compressedTexSubImage2D(r.TEXTURE_2D,at,0,0,k.width,k.height,X,k.data):e.compressedTexImage2D(r.TEXTURE_2D,at,st,k.width,k.height,0,k.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):nt?e.texSubImage2D(r.TEXTURE_2D,at,0,0,k.width,k.height,X,pt,k.data):e.texImage2D(r.TEXTURE_2D,at,st,k.width,k.height,0,X,pt,k.data)}else if(H.isDataArrayTexture)nt?(lt&&e.texStorage3D(r.TEXTURE_2D_ARRAY,dt,st,F.width,F.height,F.depth),e.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,0,F.width,F.height,F.depth,X,pt,F.data)):e.texImage3D(r.TEXTURE_2D_ARRAY,0,st,F.width,F.height,F.depth,0,X,pt,F.data);else if(H.isData3DTexture)nt?(lt&&e.texStorage3D(r.TEXTURE_3D,dt,st,F.width,F.height,F.depth),e.texSubImage3D(r.TEXTURE_3D,0,0,0,0,F.width,F.height,F.depth,X,pt,F.data)):e.texImage3D(r.TEXTURE_3D,0,st,F.width,F.height,F.depth,0,X,pt,F.data);else if(H.isFramebufferTexture){if(lt)if(nt)e.texStorage2D(r.TEXTURE_2D,dt,st,F.width,F.height);else{let at=F.width,Bt=F.height;for(let qt=0;qt<dt;qt++)e.texImage2D(r.TEXTURE_2D,qt,st,at,Bt,0,X,pt,null),at>>=1,Bt>>=1}}else if(ut.length>0&&J){nt&<&&e.texStorage2D(r.TEXTURE_2D,dt,st,ut[0].width,ut[0].height);for(let at=0,Bt=ut.length;at<Bt;at++)k=ut[at],nt?e.texSubImage2D(r.TEXTURE_2D,at,0,0,X,pt,k):e.texImage2D(r.TEXTURE_2D,at,st,X,pt,k);H.generateMipmaps=!1}else nt?(lt&&e.texStorage2D(r.TEXTURE_2D,dt,st,F.width,F.height),e.texSubImage2D(r.TEXTURE_2D,0,0,0,X,pt,F)):e.texImage2D(r.TEXTURE_2D,0,st,X,pt,F);$(H,J)&&q(Wt),he.__version=Ct.version,H.onUpdate&&H.onUpdate(H)}j.__version=H.version}function Xt(j,H,rt){if(H.image.length!==6)return;let Wt=Qt(j,H),Gt=H.source;e.bindTexture(r.TEXTURE_CUBE_MAP,j.__webglTexture,r.TEXTURE0+rt);let Ct=o.get(Gt);if(Gt.version!==Ct.__version||Wt===!0){e.activeTexture(r.TEXTURE0+rt);let he=yr.getPrimaries(yr.workingColorSpace),Kt=H.colorSpace===As?null:yr.getPrimaries(H.colorSpace),tt=H.colorSpace===As||he===Kt?r.NONE:r.BROWSER_DEFAULT_WEBGL;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,H.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,H.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,H.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,tt);let C=H.isCompressedTexture||H.image[0].isCompressedTexture,L=H.image[0]&&H.image[0].isDataTexture,F=[];for(let at=0;at<6;at++)!C&&!L?F[at]=A(H.image[at],!1,!0,y):F[at]=L?H.image[at].image:H.image[at],F[at]=$n(H,F[at]);let J=F[0],X=U(J)||d,pt=c.convert(H.format,H.colorSpace),st=c.convert(H.type),k=D(H.internalFormat,pt,st,H.colorSpace),ut=d&&H.isVideoTexture!==!0,nt=Ct.__version===void 0||Wt===!0,lt=G(H,J,X);le(r.TEXTURE_CUBE_MAP,H,X);let dt;if(C){ut&&nt&&e.texStorage2D(r.TEXTURE_CUBE_MAP,lt,k,J.width,J.height);for(let at=0;at<6;at++){dt=F[at].mipmaps;for(let Bt=0;Bt<dt.length;Bt++){let qt=dt[Bt];H.format!==Vs?pt!==null?ut?e.compressedTexSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+at,Bt,0,0,qt.width,qt.height,pt,qt.data):e.compressedTexImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+at,Bt,k,qt.width,qt.height,0,qt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):ut?e.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+at,Bt,0,0,qt.width,qt.height,pt,st,qt.data):e.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+at,Bt,k,qt.width,qt.height,0,pt,st,qt.data)}}}else{dt=H.mipmaps,ut&&nt&&(dt.length>0&<++,e.texStorage2D(r.TEXTURE_CUBE_MAP,lt,k,F[0].width,F[0].height));for(let at=0;at<6;at++)if(L){ut?e.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+at,0,0,0,F[at].width,F[at].height,pt,st,F[at].data):e.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+at,0,k,F[at].width,F[at].height,0,pt,st,F[at].data);for(let Bt=0;Bt<dt.length;Bt++){let we=dt[Bt].image[at].image;ut?e.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+at,Bt+1,0,0,we.width,we.height,pt,st,we.data):e.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+at,Bt+1,k,we.width,we.height,0,pt,st,we.data)}}else{ut?e.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+at,0,0,0,pt,st,F[at]):e.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+at,0,k,pt,st,F[at]);for(let Bt=0;Bt<dt.length;Bt++){let qt=dt[Bt];ut?e.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+at,Bt+1,0,0,pt,st,qt.image[at]):e.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+at,Bt+1,k,pt,st,qt.image[at])}}}$(H,X)&&q(r.TEXTURE_CUBE_MAP),Ct.__version=Gt.version,H.onUpdate&&H.onUpdate(H)}j.__version=H.version}function Ee(j,H,rt,Wt,Gt,Ct){let he=c.convert(rt.format,rt.colorSpace),Kt=c.convert(rt.type),tt=D(rt.internalFormat,he,Kt,rt.colorSpace);if(!o.get(H).__hasExternalTextures){let L=Math.max(1,H.width>>Ct),F=Math.max(1,H.height>>Ct);Gt===r.TEXTURE_3D||Gt===r.TEXTURE_2D_ARRAY?e.texImage3D(Gt,Ct,tt,L,F,H.depth,0,he,Kt,null):e.texImage2D(Gt,Ct,tt,L,F,0,he,Kt,null)}e.bindFramebuffer(r.FRAMEBUFFER,j),ye(H)?x.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,Wt,Gt,o.get(rt).__webglTexture,0,kt(H)):(Gt===r.TEXTURE_2D||Gt>=r.TEXTURE_CUBE_MAP_POSITIVE_X&&Gt<=r.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&r.framebufferTexture2D(r.FRAMEBUFFER,Wt,Gt,o.get(rt).__webglTexture,Ct),e.bindFramebuffer(r.FRAMEBUFFER,null)}function ft(j,H,rt){if(r.bindRenderbuffer(r.RENDERBUFFER,j),H.depthBuffer&&!H.stencilBuffer){let Wt=d===!0?r.DEPTH_COMPONENT24:r.DEPTH_COMPONENT16;if(rt||ye(H)){let Gt=H.depthTexture;Gt&&Gt.isDepthTexture&&(Gt.type===_u?Wt=r.DEPTH_COMPONENT32F:Gt.type===vu&&(Wt=r.DEPTH_COMPONENT24));let Ct=kt(H);ye(H)?x.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,Ct,Wt,H.width,H.height):r.renderbufferStorageMultisample(r.RENDERBUFFER,Ct,Wt,H.width,H.height)}else r.renderbufferStorage(r.RENDERBUFFER,Wt,H.width,H.height);r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.RENDERBUFFER,j)}else if(H.depthBuffer&&H.stencilBuffer){let Wt=kt(H);rt&&ye(H)===!1?r.renderbufferStorageMultisample(r.RENDERBUFFER,Wt,r.DEPTH24_STENCIL8,H.width,H.height):ye(H)?x.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,Wt,r.DEPTH24_STENCIL8,H.width,H.height):r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,H.width,H.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.RENDERBUFFER,j)}else{let Wt=H.isWebGLMultipleRenderTargets===!0?H.texture:[H.texture];for(let Gt=0;Gt<Wt.length;Gt++){let Ct=Wt[Gt],he=c.convert(Ct.format,Ct.colorSpace),Kt=c.convert(Ct.type),tt=D(Ct.internalFormat,he,Kt,Ct.colorSpace),C=kt(H);rt&&ye(H)===!1?r.renderbufferStorageMultisample(r.RENDERBUFFER,C,tt,H.width,H.height):ye(H)?x.renderbufferStorageMultisampleEXT(r.RENDERBUFFER,C,tt,H.width,H.height):r.renderbufferStorage(r.RENDERBUFFER,tt,H.width,H.height)}}r.bindRenderbuffer(r.RENDERBUFFER,null)}function He(j,H){if(H&&H.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(e.bindFramebuffer(r.FRAMEBUFFER,j),!(H.depthTexture&&H.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");(!o.get(H.depthTexture).__webglTexture||H.depthTexture.image.width!==H.width||H.depthTexture.image.height!==H.height)&&(H.depthTexture.image.width=H.width,H.depthTexture.image.height=H.height,H.depthTexture.needsUpdate=!0),Y(H.depthTexture,0);let Wt=o.get(H.depthTexture).__webglTexture,Gt=kt(H);if(H.depthTexture.format===tl)ye(H)?x.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.TEXTURE_2D,Wt,0,Gt):r.framebufferTexture2D(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.TEXTURE_2D,Wt,0);else if(H.depthTexture.format===Ql)ye(H)?x.framebufferTexture2DMultisampleEXT(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.TEXTURE_2D,Wt,0,Gt):r.framebufferTexture2D(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.TEXTURE_2D,Wt,0);else throw new Error("Unknown depthTexture format")}function te(j){let H=o.get(j),rt=j.isWebGLCubeRenderTarget===!0;if(j.depthTexture&&!H.__autoAllocateDepthBuffer){if(rt)throw new Error("target.depthTexture not supported in Cube render targets");He(H.__webglFramebuffer,j)}else if(rt){H.__webglDepthbuffer=[];for(let Wt=0;Wt<6;Wt++)e.bindFramebuffer(r.FRAMEBUFFER,H.__webglFramebuffer[Wt]),H.__webglDepthbuffer[Wt]=r.createRenderbuffer(),ft(H.__webglDepthbuffer[Wt],j,!1)}else e.bindFramebuffer(r.FRAMEBUFFER,H.__webglFramebuffer),H.__webglDepthbuffer=r.createRenderbuffer(),ft(H.__webglDepthbuffer,j,!1);e.bindFramebuffer(r.FRAMEBUFFER,null)}function fe(j,H,rt){let Wt=o.get(j);H!==void 0&&Ee(Wt.__webglFramebuffer,j,j.texture,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,0),rt!==void 0&&te(j)}function de(j){let H=j.texture,rt=o.get(j),Wt=o.get(H);j.addEventListener("dispose",Z),j.isWebGLMultipleRenderTargets!==!0&&(Wt.__webglTexture===void 0&&(Wt.__webglTexture=r.createTexture()),Wt.__version=H.version,p.memory.textures++);let Gt=j.isWebGLCubeRenderTarget===!0,Ct=j.isWebGLMultipleRenderTargets===!0,he=U(j)||d;if(Gt){rt.__webglFramebuffer=[];for(let Kt=0;Kt<6;Kt++)if(d&&H.mipmaps&&H.mipmaps.length>0){rt.__webglFramebuffer[Kt]=[];for(let tt=0;tt<H.mipmaps.length;tt++)rt.__webglFramebuffer[Kt][tt]=r.createFramebuffer()}else rt.__webglFramebuffer[Kt]=r.createFramebuffer()}else{if(d&&H.mipmaps&&H.mipmaps.length>0){rt.__webglFramebuffer=[];for(let Kt=0;Kt<H.mipmaps.length;Kt++)rt.__webglFramebuffer[Kt]=r.createFramebuffer()}else rt.__webglFramebuffer=r.createFramebuffer();if(Ct)if(a.drawBuffers){let Kt=j.texture;for(let tt=0,C=Kt.length;tt<C;tt++){let L=o.get(Kt[tt]);L.__webglTexture===void 0&&(L.__webglTexture=r.createTexture(),p.memory.textures++)}}else console.warn("THREE.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(d&&j.samples>0&&ye(j)===!1){let Kt=Ct?H:[H];rt.__webglMultisampledFramebuffer=r.createFramebuffer(),rt.__webglColorRenderbuffer=[],e.bindFramebuffer(r.FRAMEBUFFER,rt.__webglMultisampledFramebuffer);for(let tt=0;tt<Kt.length;tt++){let C=Kt[tt];rt.__webglColorRenderbuffer[tt]=r.createRenderbuffer(),r.bindRenderbuffer(r.RENDERBUFFER,rt.__webglColorRenderbuffer[tt]);let L=c.convert(C.format,C.colorSpace),F=c.convert(C.type),J=D(C.internalFormat,L,F,C.colorSpace,j.isXRRenderTarget===!0),X=kt(j);r.renderbufferStorageMultisample(r.RENDERBUFFER,X,J,j.width,j.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+tt,r.RENDERBUFFER,rt.__webglColorRenderbuffer[tt])}r.bindRenderbuffer(r.RENDERBUFFER,null),j.depthBuffer&&(rt.__webglDepthRenderbuffer=r.createRenderbuffer(),ft(rt.__webglDepthRenderbuffer,j,!0)),e.bindFramebuffer(r.FRAMEBUFFER,null)}}if(Gt){e.bindTexture(r.TEXTURE_CUBE_MAP,Wt.__webglTexture),le(r.TEXTURE_CUBE_MAP,H,he);for(let Kt=0;Kt<6;Kt++)if(d&&H.mipmaps&&H.mipmaps.length>0)for(let tt=0;tt<H.mipmaps.length;tt++)Ee(rt.__webglFramebuffer[Kt][tt],j,H,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+Kt,tt);else Ee(rt.__webglFramebuffer[Kt],j,H,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+Kt,0);$(H,he)&&q(r.TEXTURE_CUBE_MAP),e.unbindTexture()}else if(Ct){let Kt=j.texture;for(let tt=0,C=Kt.length;tt<C;tt++){let L=Kt[tt],F=o.get(L);e.bindTexture(r.TEXTURE_2D,F.__webglTexture),le(r.TEXTURE_2D,L,he),Ee(rt.__webglFramebuffer,j,L,r.COLOR_ATTACHMENT0+tt,r.TEXTURE_2D,0),$(L,he)&&q(r.TEXTURE_2D)}e.unbindTexture()}else{let Kt=r.TEXTURE_2D;if((j.isWebGL3DRenderTarget||j.isWebGLArrayRenderTarget)&&(d?Kt=j.isWebGL3DRenderTarget?r.TEXTURE_3D:r.TEXTURE_2D_ARRAY:console.error("THREE.WebGLTextures: THREE.Data3DTexture and THREE.DataArrayTexture only supported with WebGL2.")),e.bindTexture(Kt,Wt.__webglTexture),le(Kt,H,he),d&&H.mipmaps&&H.mipmaps.length>0)for(let tt=0;tt<H.mipmaps.length;tt++)Ee(rt.__webglFramebuffer[tt],j,H,r.COLOR_ATTACHMENT0,Kt,tt);else Ee(rt.__webglFramebuffer,j,H,r.COLOR_ATTACHMENT0,Kt,0);$(H,he)&&q(Kt),e.unbindTexture()}j.depthBuffer&&te(j)}function Ue(j){let H=U(j)||d,rt=j.isWebGLMultipleRenderTargets===!0?j.texture:[j.texture];for(let Wt=0,Gt=rt.length;Wt<Gt;Wt++){let Ct=rt[Wt];if($(Ct,H)){let he=j.isWebGLCubeRenderTarget?r.TEXTURE_CUBE_MAP:r.TEXTURE_2D,Kt=o.get(Ct).__webglTexture;e.bindTexture(he,Kt),q(he),e.unbindTexture()}}}function be(j){if(d&&j.samples>0&&ye(j)===!1){let H=j.isWebGLMultipleRenderTargets?j.texture:[j.texture],rt=j.width,Wt=j.height,Gt=r.COLOR_BUFFER_BIT,Ct=[],he=j.stencilBuffer?r.DEPTH_STENCIL_ATTACHMENT:r.DEPTH_ATTACHMENT,Kt=o.get(j),tt=j.isWebGLMultipleRenderTargets===!0;if(tt)for(let C=0;C<H.length;C++)e.bindFramebuffer(r.FRAMEBUFFER,Kt.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+C,r.RENDERBUFFER,null),e.bindFramebuffer(r.FRAMEBUFFER,Kt.__webglFramebuffer),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0+C,r.TEXTURE_2D,null,0);e.bindFramebuffer(r.READ_FRAMEBUFFER,Kt.__webglMultisampledFramebuffer),e.bindFramebuffer(r.DRAW_FRAMEBUFFER,Kt.__webglFramebuffer);for(let C=0;C<H.length;C++){Ct.push(r.COLOR_ATTACHMENT0+C),j.depthBuffer&&Ct.push(he);let L=Kt.__ignoreDepthValues!==void 0?Kt.__ignoreDepthValues:!1;if(L===!1&&(j.depthBuffer&&(Gt|=r.DEPTH_BUFFER_BIT),j.stencilBuffer&&(Gt|=r.STENCIL_BUFFER_BIT)),tt&&r.framebufferRenderbuffer(r.READ_FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.RENDERBUFFER,Kt.__webglColorRenderbuffer[C]),L===!0&&(r.invalidateFramebuffer(r.READ_FRAMEBUFFER,[he]),r.invalidateFramebuffer(r.DRAW_FRAMEBUFFER,[he])),tt){let F=o.get(H[C]).__webglTexture;r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,F,0)}r.blitFramebuffer(0,0,rt,Wt,0,0,rt,Wt,Gt,r.NEAREST),T&&r.invalidateFramebuffer(r.READ_FRAMEBUFFER,Ct)}if(e.bindFramebuffer(r.READ_FRAMEBUFFER,null),e.bindFramebuffer(r.DRAW_FRAMEBUFFER,null),tt)for(let C=0;C<H.length;C++){e.bindFramebuffer(r.FRAMEBUFFER,Kt.__webglMultisampledFramebuffer),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0+C,r.RENDERBUFFER,Kt.__webglColorRenderbuffer[C]);let L=o.get(H[C]).__webglTexture;e.bindFramebuffer(r.FRAMEBUFFER,Kt.__webglFramebuffer),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,r.COLOR_ATTACHMENT0+C,r.TEXTURE_2D,L,0)}e.bindFramebuffer(r.DRAW_FRAMEBUFFER,Kt.__webglMultisampledFramebuffer)}}function kt(j){return Math.min(w,j.samples)}function ye(j){let H=o.get(j);return d&&j.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&H.__useRenderToTexture!==!1}function Vn(j){let H=p.render.frame;P.get(j)!==H&&(P.set(j,H),j.update())}function $n(j,H){let rt=j.colorSpace,Wt=j.format,Gt=j.type;return j.isCompressedTexture===!0||j.isVideoTexture===!0||j.format===Og||rt!==Ya&&rt!==As&&(yr.getTransfer(rt)===Pr?d===!1?t.has("EXT_sRGB")===!0&&Wt===Vs?(j.format=Og,j.minFilter=Ts,j.generateMipmaps=!1):H=Fh.sRGBToLinear(H):(Wt!==Vs||Gt!==wu)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",rt)),H}this.allocateTextureUnit=Et,this.resetTextureUnits=Pt,this.setTexture2D=Y,this.setTexture2DArray=ht,this.setTexture3D=Mt,this.setTextureCube=zt,this.rebindTextures=fe,this.setupRenderTarget=de,this.updateRenderTargetMipmap=Ue,this.updateMultisampleRenderTarget=be,this.setupDepthRenderbuffer=te,this.setupFrameBufferTexture=Ee,this.useMultisampledRTT=ye}function GO(r,t,e){let o=e.isWebGL2;function a(c,p=As){let d,g=yr.getTransfer(p);if(c===wu)return r.UNSIGNED_BYTE;if(c===F1)return r.UNSIGNED_SHORT_4_4_4_4;if(c===U1)return r.UNSIGNED_SHORT_5_5_5_1;if(c===NI)return r.BYTE;if(c===OI)return r.SHORT;if(c===dm)return r.UNSIGNED_SHORT;if(c===D1)return r.INT;if(c===vu)return r.UNSIGNED_INT;if(c===_u)return r.FLOAT;if(c===tf)return o?r.HALF_FLOAT:(d=t.get("OES_texture_half_float"),d!==null?d.HALF_FLOAT_OES:null);if(c===DI)return r.ALPHA;if(c===Vs)return r.RGBA;if(c===FI)return r.LUMINANCE;if(c===UI)return r.LUMINANCE_ALPHA;if(c===tl)return r.DEPTH_COMPONENT;if(c===Ql)return r.DEPTH_STENCIL;if(c===Og)return d=t.get("EXT_sRGB"),d!==null?d.SRGB_ALPHA_EXT:null;if(c===BI)return r.RED;if(c===B1)return r.RED_INTEGER;if(c===zI)return r.RG;if(c===z1)return r.RG_INTEGER;if(c===G1)return r.RGBA_INTEGER;if(c===tg||c===eg||c===ng||c===rg)if(g===Pr)if(d=t.get("WEBGL_compressed_texture_s3tc_srgb"),d!==null){if(c===tg)return d.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(c===eg)return d.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(c===ng)return d.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(c===rg)return d.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(d=t.get("WEBGL_compressed_texture_s3tc"),d!==null){if(c===tg)return d.COMPRESSED_RGB_S3TC_DXT1_EXT;if(c===eg)return d.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(c===ng)return d.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(c===rg)return d.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(c===m_||c===y_||c===v_||c===__)if(d=t.get("WEBGL_compressed_texture_pvrtc"),d!==null){if(c===m_)return d.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(c===y_)return d.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(c===v_)return d.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(c===__)return d.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(c===GI)return d=t.get("WEBGL_compressed_texture_etc1"),d!==null?d.COMPRESSED_RGB_ETC1_WEBGL:null;if(c===x_||c===E_)if(d=t.get("WEBGL_compressed_texture_etc"),d!==null){if(c===x_)return g===Pr?d.COMPRESSED_SRGB8_ETC2:d.COMPRESSED_RGB8_ETC2;if(c===E_)return g===Pr?d.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:d.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(c===w_||c===M_||c===S_||c===b_||c===T_||c===A_||c===C_||c===P_||c===I_||c===R_||c===L_||c===N_||c===O_||c===D_)if(d=t.get("WEBGL_compressed_texture_astc"),d!==null){if(c===w_)return g===Pr?d.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:d.COMPRESSED_RGBA_ASTC_4x4_KHR;if(c===M_)return g===Pr?d.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:d.COMPRESSED_RGBA_ASTC_5x4_KHR;if(c===S_)return g===Pr?d.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:d.COMPRESSED_RGBA_ASTC_5x5_KHR;if(c===b_)return g===Pr?d.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:d.COMPRESSED_RGBA_ASTC_6x5_KHR;if(c===T_)return g===Pr?d.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:d.COMPRESSED_RGBA_ASTC_6x6_KHR;if(c===A_)return g===Pr?d.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:d.COMPRESSED_RGBA_ASTC_8x5_KHR;if(c===C_)return g===Pr?d.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:d.COMPRESSED_RGBA_ASTC_8x6_KHR;if(c===P_)return g===Pr?d.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:d.COMPRESSED_RGBA_ASTC_8x8_KHR;if(c===I_)return g===Pr?d.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:d.COMPRESSED_RGBA_ASTC_10x5_KHR;if(c===R_)return g===Pr?d.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:d.COMPRESSED_RGBA_ASTC_10x6_KHR;if(c===L_)return g===Pr?d.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:d.COMPRESSED_RGBA_ASTC_10x8_KHR;if(c===N_)return g===Pr?d.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:d.COMPRESSED_RGBA_ASTC_10x10_KHR;if(c===O_)return g===Pr?d.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:d.COMPRESSED_RGBA_ASTC_12x10_KHR;if(c===D_)return g===Pr?d.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:d.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(c===ig||c===F_||c===U_)if(d=t.get("EXT_texture_compression_bptc"),d!==null){if(c===ig)return g===Pr?d.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:d.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(c===F_)return d.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(c===U_)return d.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(c===kI||c===B_||c===z_||c===G_)if(d=t.get("EXT_texture_compression_rgtc"),d!==null){if(c===ig)return d.COMPRESSED_RED_RGTC1_EXT;if(c===B_)return d.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(c===z_)return d.COMPRESSED_RED_GREEN_RGTC2_EXT;if(c===G_)return d.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return c===ju?o?r.UNSIGNED_INT_24_8:(d=t.get("WEBGL_depth_texture"),d!==null?d.UNSIGNED_INT_24_8_WEBGL:null):r[c]!==void 0?r[c]:null}return{convert:a}}var Qg=class extends ls{constructor(t=[]){super(),this.isArrayCamera=!0,this.cameras=t}},Xl=class extends ha{constructor(){super(),this.isGroup=!0,this.type="Group"}},kO={type:"move"},Qc=class{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Xl,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new Xl,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new Rt,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new Rt),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Xl,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new Rt,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new Rt),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){let e=this._hand;if(e)for(let o of t.hand.values())this._getHandJoint(e,o)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,o){let a=null,c=null,p=null,d=this._targetRay,g=this._grip,y=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(y&&t.hand){p=!0;for(let I of t.hand.values()){let M=e.getJointPose(I,o),E=this._getHandJoint(y,I);M!==null&&(E.matrix.fromArray(M.transform.matrix),E.matrix.decompose(E.position,E.rotation,E.scale),E.matrixWorldNeedsUpdate=!0,E.jointRadius=M.radius),E.visible=M!==null}let _=y.joints["index-finger-tip"],w=y.joints["thumb-tip"],x=_.position.distanceTo(w.position),T=.02,P=.005;y.inputState.pinching&&x>T+P?(y.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!y.inputState.pinching&&x<=T-P&&(y.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else g!==null&&t.gripSpace&&(c=e.getPose(t.gripSpace,o),c!==null&&(g.matrix.fromArray(c.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.matrixWorldNeedsUpdate=!0,c.linearVelocity?(g.hasLinearVelocity=!0,g.linearVelocity.copy(c.linearVelocity)):g.hasLinearVelocity=!1,c.angularVelocity?(g.hasAngularVelocity=!0,g.angularVelocity.copy(c.angularVelocity)):g.hasAngularVelocity=!1));d!==null&&(a=e.getPose(t.targetRaySpace,o),a===null&&c!==null&&(a=c),a!==null&&(d.matrix.fromArray(a.transform.matrix),d.matrix.decompose(d.position,d.rotation,d.scale),d.matrixWorldNeedsUpdate=!0,a.linearVelocity?(d.hasLinearVelocity=!0,d.linearVelocity.copy(a.linearVelocity)):d.hasLinearVelocity=!1,a.angularVelocity?(d.hasAngularVelocity=!0,d.angularVelocity.copy(a.angularVelocity)):d.hasAngularVelocity=!1,this.dispatchEvent(kO)))}return d!==null&&(d.visible=a!==null),g!==null&&(g.visible=c!==null),y!==null&&(y.visible=p!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){let o=new Xl;o.matrixAutoUpdate=!1,o.visible=!1,t.joints[e.jointName]=o,t.add(o)}return t.joints[e.jointName]}},jg=class extends Ws{constructor(t,e,o,a,c,p,d,g,y,_){if(_=_!==void 0?_:tl,_!==tl&&_!==Ql)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");o===void 0&&_===tl&&(o=vu),o===void 0&&_===Ql&&(o=ju),super(null,a,c,p,d,g,_,o,y),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=d!==void 0?d:vo,this.minFilter=g!==void 0?g:vo,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.compareFunction=t.compareFunction,this}toJSON(t){let e=super.toJSON(t);return this.compareFunction!==null&&(e.compareFunction=this.compareFunction),e}},tm=class extends Su{constructor(t,e){super();let o=this,a=null,c=1,p=null,d="local-floor",g=1,y=null,_=null,w=null,x=null,T=null,P=null,I=e.getContextAttributes(),M=null,E=null,N=[],A=[],U=new ls;U.layers.enable(1),U.viewport=new qi;let z=new ls;z.layers.enable(2),z.viewport=new qi;let $=[U,z],q=new Qg;q.layers.enable(1),q.layers.enable(2);let D=null,G=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(ht){let Mt=N[ht];return Mt===void 0&&(Mt=new Qc,N[ht]=Mt),Mt.getTargetRaySpace()},this.getControllerGrip=function(ht){let Mt=N[ht];return Mt===void 0&&(Mt=new Qc,N[ht]=Mt),Mt.getGripSpace()},this.getHand=function(ht){let Mt=N[ht];return Mt===void 0&&(Mt=new Qc,N[ht]=Mt),Mt.getHandSpace()};function Q(ht){let Mt=A.indexOf(ht.inputSource);if(Mt===-1)return;let zt=N[Mt];zt!==void 0&&(zt.update(ht.inputSource,ht.frame,y||p),zt.dispatchEvent({type:ht.type,data:ht.inputSource}))}function _t(){a.removeEventListener("select",Q),a.removeEventListener("selectstart",Q),a.removeEventListener("selectend",Q),a.removeEventListener("squeeze",Q),a.removeEventListener("squeezestart",Q),a.removeEventListener("squeezeend",Q),a.removeEventListener("end",_t),a.removeEventListener("inputsourceschange",Z);for(let ht=0;ht<N.length;ht++){let Mt=A[ht];Mt!==null&&(A[ht]=null,N[ht].disconnect(Mt))}D=null,G=null,t.setRenderTarget(M),T=null,x=null,w=null,a=null,E=null,Y.stop(),o.isPresenting=!1,o.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ht){c=ht,o.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ht){d=ht,o.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return y||p},this.setReferenceSpace=function(ht){y=ht},this.getBaseLayer=function(){return x!==null?x:T},this.getBinding=function(){return w},this.getFrame=function(){return P},this.getSession=function(){return a},this.setSession=async function(ht){if(a=ht,a!==null){if(M=t.getRenderTarget(),a.addEventListener("select",Q),a.addEventListener("selectstart",Q),a.addEventListener("selectend",Q),a.addEventListener("squeeze",Q),a.addEventListener("squeezestart",Q),a.addEventListener("squeezeend",Q),a.addEventListener("end",_t),a.addEventListener("inputsourceschange",Z),I.xrCompatible!==!0&&await e.makeXRCompatible(),a.renderState.layers===void 0||t.capabilities.isWebGL2===!1){let Mt={antialias:a.renderState.layers===void 0?I.antialias:!0,alpha:!0,depth:I.depth,stencil:I.stencil,framebufferScaleFactor:c};T=new XRWebGLLayer(a,e,Mt),a.updateRenderState({baseLayer:T}),E=new $a(T.framebufferWidth,T.framebufferHeight,{format:Vs,type:wu,colorSpace:t.outputColorSpace,stencilBuffer:I.stencil})}else{let Mt=null,zt=null,At=null;I.depth&&(At=I.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,Mt=I.stencil?Ql:tl,zt=I.stencil?ju:vu);let $t={colorFormat:e.RGBA8,depthFormat:At,scaleFactor:c};w=new XRWebGLBinding(a,e),x=w.createProjectionLayer($t),a.updateRenderState({layers:[x]}),E=new $a(x.textureWidth,x.textureHeight,{format:Vs,type:wu,depthTexture:new jg(x.textureWidth,x.textureHeight,zt,void 0,void 0,void 0,void 0,void 0,void 0,Mt),stencilBuffer:I.stencil,colorSpace:t.outputColorSpace,samples:I.antialias?4:0});let ue=t.properties.get(E);ue.__ignoreDepthValues=x.ignoreDepthValues}E.isXRRenderTarget=!0,this.setFoveation(g),y=null,p=await a.requestReferenceSpace(d),Y.setContext(a),Y.start(),o.isPresenting=!0,o.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(a!==null)return a.environmentBlendMode};function Z(ht){for(let Mt=0;Mt<ht.removed.length;Mt++){let zt=ht.removed[Mt],At=A.indexOf(zt);At>=0&&(A[At]=null,N[At].disconnect(zt))}for(let Mt=0;Mt<ht.added.length;Mt++){let zt=ht.added[Mt],At=A.indexOf(zt);if(At===-1){for(let ue=0;ue<N.length;ue++)if(ue>=A.length){A.push(zt),At=ue;break}else if(A[ue]===null){A[ue]=zt,At=ue;break}if(At===-1)break}let $t=N[At];$t&&$t.connect(zt)}}let Dt=new Rt,et=new Rt;function vt(ht,Mt,zt){Dt.setFromMatrixPosition(Mt.matrixWorld),et.setFromMatrixPosition(zt.matrixWorld);let At=Dt.distanceTo(et),$t=Mt.projectionMatrix.elements,ue=zt.projectionMatrix.elements,le=$t[14]/($t[10]-1),Qt=$t[14]/($t[10]+1),me=($t[9]+1)/$t[5],Xt=($t[9]-1)/$t[5],Ee=($t[8]-1)/$t[0],ft=(ue[8]+1)/ue[0],He=le*Ee,te=le*ft,fe=At/(-Ee+ft),de=fe*-Ee;Mt.matrixWorld.decompose(ht.position,ht.quaternion,ht.scale),ht.translateX(de),ht.translateZ(fe),ht.matrixWorld.compose(ht.position,ht.quaternion,ht.scale),ht.matrixWorldInverse.copy(ht.matrixWorld).invert();let Ue=le+fe,be=Qt+fe,kt=He-de,ye=te+(At-de),Vn=me*Qt/be*Ue,$n=Xt*Qt/be*Ue;ht.projectionMatrix.makePerspective(kt,ye,Vn,$n,Ue,be),ht.projectionMatrixInverse.copy(ht.projectionMatrix).invert()}function It(ht,Mt){Mt===null?ht.matrixWorld.copy(ht.matrix):ht.matrixWorld.multiplyMatrices(Mt.matrixWorld,ht.matrix),ht.matrixWorldInverse.copy(ht.matrixWorld).invert()}this.updateCamera=function(ht){if(a===null)return;q.near=z.near=U.near=ht.near,q.far=z.far=U.far=ht.far,(D!==q.near||G!==q.far)&&(a.updateRenderState({depthNear:q.near,depthFar:q.far}),D=q.near,G=q.far);let Mt=ht.parent,zt=q.cameras;It(q,Mt);for(let At=0;At<zt.length;At++)It(zt[At],Mt);zt.length===2?vt(q,U,z):q.projectionMatrix.copy(U.projectionMatrix),Pt(ht,q,Mt)};function Pt(ht,Mt,zt){zt===null?ht.matrix.copy(Mt.matrixWorld):(ht.matrix.copy(zt.matrixWorld),ht.matrix.invert(),ht.matrix.multiply(Mt.matrixWorld)),ht.matrix.decompose(ht.position,ht.quaternion,ht.scale),ht.updateMatrixWorld(!0),ht.projectionMatrix.copy(Mt.projectionMatrix),ht.projectionMatrixInverse.copy(Mt.projectionMatrixInverse),ht.isPerspectiveCamera&&(ht.fov=Dg*2*Math.atan(1/ht.projectionMatrix.elements[5]),ht.zoom=1)}this.getCamera=function(){return q},this.getFoveation=function(){if(!(x===null&&T===null))return g},this.setFoveation=function(ht){g=ht,x!==null&&(x.fixedFoveation=ht),T!==null&&T.fixedFoveation!==void 0&&(T.fixedFoveation=ht)};let Et=null;function yt(ht,Mt){if(_=Mt.getViewerPose(y||p),P=Mt,_!==null){let zt=_.views;T!==null&&(t.setRenderTargetFramebuffer(E,T.framebuffer),t.setRenderTarget(E));let At=!1;zt.length!==q.cameras.length&&(q.cameras.length=0,At=!0);for(let $t=0;$t<zt.length;$t++){let ue=zt[$t],le=null;if(T!==null)le=T.getViewport(ue);else{let me=w.getViewSubImage(x,ue);le=me.viewport,$t===0&&(t.setRenderTargetTextures(E,me.colorTexture,x.ignoreDepthValues?void 0:me.depthStencilTexture),t.setRenderTarget(E))}let Qt=$[$t];Qt===void 0&&(Qt=new ls,Qt.layers.enable($t),Qt.viewport=new qi,$[$t]=Qt),Qt.matrix.fromArray(ue.transform.matrix),Qt.matrix.decompose(Qt.position,Qt.quaternion,Qt.scale),Qt.projectionMatrix.fromArray(ue.projectionMatrix),Qt.projectionMatrixInverse.copy(Qt.projectionMatrix).invert(),Qt.viewport.set(le.x,le.y,le.width,le.height),$t===0&&(q.matrix.copy(Qt.matrix),q.matrix.decompose(q.position,q.quaternion,q.scale)),At===!0&&q.cameras.push(Qt)}}for(let zt=0;zt<N.length;zt++){let At=A[zt],$t=N[zt];At!==null&&$t!==void 0&&$t.update(At,Mt,y||p)}Et&&Et(ht,Mt),Mt.detectedPlanes&&o.dispatchEvent({type:"planesdetected",data:Mt}),P=null}let Y=new q1;Y.setAnimationLoop(yt),this.setAnimationLoop=function(ht){Et=ht},this.dispose=function(){}}};function HO(r,t){function e(M,E){M.matrixAutoUpdate===!0&&M.updateMatrix(),E.value.copy(M.matrix)}function o(M,E){E.color.getRGB(M.fogColor.value,W1(r)),E.isFog?(M.fogNear.value=E.near,M.fogFar.value=E.far):E.isFogExp2&&(M.fogDensity.value=E.density)}function a(M,E,N,A,U){E.isMeshBasicMaterial||E.isMeshLambertMaterial?c(M,E):E.isMeshToonMaterial?(c(M,E),w(M,E)):E.isMeshPhongMaterial?(c(M,E),_(M,E)):E.isMeshStandardMaterial?(c(M,E),x(M,E),E.isMeshPhysicalMaterial&&T(M,E,U)):E.isMeshMatcapMaterial?(c(M,E),P(M,E)):E.isMeshDepthMaterial?c(M,E):E.isMeshDistanceMaterial?(c(M,E),I(M,E)):E.isMeshNormalMaterial?c(M,E):E.isLineBasicMaterial?(p(M,E),E.isLineDashedMaterial&&d(M,E)):E.isPointsMaterial?g(M,E,N,A):E.isSpriteMaterial?y(M,E):E.isShadowMaterial?(M.color.value.copy(E.color),M.opacity.value=E.opacity):E.isShaderMaterial&&(E.uniformsNeedUpdate=!1)}function c(M,E){M.opacity.value=E.opacity,E.color&&M.diffuse.value.copy(E.color),E.emissive&&M.emissive.value.copy(E.emissive).multiplyScalar(E.emissiveIntensity),E.map&&(M.map.value=E.map,e(E.map,M.mapTransform)),E.alphaMap&&(M.alphaMap.value=E.alphaMap,e(E.alphaMap,M.alphaMapTransform)),E.bumpMap&&(M.bumpMap.value=E.bumpMap,e(E.bumpMap,M.bumpMapTransform),M.bumpScale.value=E.bumpScale,E.side===Ho&&(M.bumpScale.value*=-1)),E.normalMap&&(M.normalMap.value=E.normalMap,e(E.normalMap,M.normalMapTransform),M.normalScale.value.copy(E.normalScale),E.side===Ho&&M.normalScale.value.negate()),E.displacementMap&&(M.displacementMap.value=E.displacementMap,e(E.displacementMap,M.displacementMapTransform),M.displacementScale.value=E.displacementScale,M.displacementBias.value=E.displacementBias),E.emissiveMap&&(M.emissiveMap.value=E.emissiveMap,e(E.emissiveMap,M.emissiveMapTransform)),E.specularMap&&(M.specularMap.value=E.specularMap,e(E.specularMap,M.specularMapTransform)),E.alphaTest>0&&(M.alphaTest.value=E.alphaTest);let N=t.get(E).envMap;if(N&&(M.envMap.value=N,M.flipEnvMap.value=N.isCubeTexture&&N.isRenderTargetTexture===!1?-1:1,M.reflectivity.value=E.reflectivity,M.ior.value=E.ior,M.refractionRatio.value=E.refractionRatio),E.lightMap){M.lightMap.value=E.lightMap;let A=r._useLegacyLights===!0?Math.PI:1;M.lightMapIntensity.value=E.lightMapIntensity*A,e(E.lightMap,M.lightMapTransform)}E.aoMap&&(M.aoMap.value=E.aoMap,M.aoMapIntensity.value=E.aoMapIntensity,e(E.aoMap,M.aoMapTransform))}function p(M,E){M.diffuse.value.copy(E.color),M.opacity.value=E.opacity,E.map&&(M.map.value=E.map,e(E.map,M.mapTransform))}function d(M,E){M.dashSize.value=E.dashSize,M.totalSize.value=E.dashSize+E.gapSize,M.scale.value=E.scale}function g(M,E,N,A){M.diffuse.value.copy(E.color),M.opacity.value=E.opacity,M.size.value=E.size*N,M.scale.value=A*.5,E.map&&(M.map.value=E.map,e(E.map,M.uvTransform)),E.alphaMap&&(M.alphaMap.value=E.alphaMap,e(E.alphaMap,M.alphaMapTransform)),E.alphaTest>0&&(M.alphaTest.value=E.alphaTest)}function y(M,E){M.diffuse.value.copy(E.color),M.opacity.value=E.opacity,M.rotation.value=E.rotation,E.map&&(M.map.value=E.map,e(E.map,M.mapTransform)),E.alphaMap&&(M.alphaMap.value=E.alphaMap,e(E.alphaMap,M.alphaMapTransform)),E.alphaTest>0&&(M.alphaTest.value=E.alphaTest)}function _(M,E){M.specular.value.copy(E.specular),M.shininess.value=Math.max(E.shininess,1e-4)}function w(M,E){E.gradientMap&&(M.gradientMap.value=E.gradientMap)}function x(M,E){M.metalness.value=E.metalness,E.metalnessMap&&(M.metalnessMap.value=E.metalnessMap,e(E.metalnessMap,M.metalnessMapTransform)),M.roughness.value=E.roughness,E.roughnessMap&&(M.roughnessMap.value=E.roughnessMap,e(E.roughnessMap,M.roughnessMapTransform)),t.get(E).envMap&&(M.envMapIntensity.value=E.envMapIntensity)}function T(M,E,N){M.ior.value=E.ior,E.sheen>0&&(M.sheenColor.value.copy(E.sheenColor).multiplyScalar(E.sheen),M.sheenRoughness.value=E.sheenRoughness,E.sheenColorMap&&(M.sheenColorMap.value=E.sheenColorMap,e(E.sheenColorMap,M.sheenColorMapTransform)),E.sheenRoughnessMap&&(M.sheenRoughnessMap.value=E.sheenRoughnessMap,e(E.sheenRoughnessMap,M.sheenRoughnessMapTransform))),E.clearcoat>0&&(M.clearcoat.value=E.clearcoat,M.clearcoatRoughness.value=E.clearcoatRoughness,E.clearcoatMap&&(M.clearcoatMap.value=E.clearcoatMap,e(E.clearcoatMap,M.clearcoatMapTransform)),E.clearcoatRoughnessMap&&(M.clearcoatRoughnessMap.value=E.clearcoatRoughnessMap,e(E.clearcoatRoughnessMap,M.clearcoatRoughnessMapTransform)),E.clearcoatNormalMap&&(M.clearcoatNormalMap.value=E.clearcoatNormalMap,e(E.clearcoatNormalMap,M.clearcoatNormalMapTransform),M.clearcoatNormalScale.value.copy(E.clearcoatNormalScale),E.side===Ho&&M.clearcoatNormalScale.value.negate())),E.iridescence>0&&(M.iridescence.value=E.iridescence,M.iridescenceIOR.value=E.iridescenceIOR,M.iridescenceThicknessMinimum.value=E.iridescenceThicknessRange[0],M.iridescenceThicknessMaximum.value=E.iridescenceThicknessRange[1],E.iridescenceMap&&(M.iridescenceMap.value=E.iridescenceMap,e(E.iridescenceMap,M.iridescenceMapTransform)),E.iridescenceThicknessMap&&(M.iridescenceThicknessMap.value=E.iridescenceThicknessMap,e(E.iridescenceThicknessMap,M.iridescenceThicknessMapTransform))),E.transmission>0&&(M.transmission.value=E.transmission,M.transmissionSamplerMap.value=N.texture,M.transmissionSamplerSize.value.set(N.width,N.height),E.transmissionMap&&(M.transmissionMap.value=E.transmissionMap,e(E.transmissionMap,M.transmissionMapTransform)),M.thickness.value=E.thickness,E.thicknessMap&&(M.thicknessMap.value=E.thicknessMap,e(E.thicknessMap,M.thicknessMapTransform)),M.attenuationDistance.value=E.attenuationDistance,M.attenuationColor.value.copy(E.attenuationColor)),E.anisotropy>0&&(M.anisotropyVector.value.set(E.anisotropy*Math.cos(E.anisotropyRotation),E.anisotropy*Math.sin(E.anisotropyRotation)),E.anisotropyMap&&(M.anisotropyMap.value=E.anisotropyMap,e(E.anisotropyMap,M.anisotropyMapTransform))),M.specularIntensity.value=E.specularIntensity,M.specularColor.value.copy(E.specularColor),E.specularColorMap&&(M.specularColorMap.value=E.specularColorMap,e(E.specularColorMap,M.specularColorMapTransform)),E.specularIntensityMap&&(M.specularIntensityMap.value=E.specularIntensityMap,e(E.specularIntensityMap,M.specularIntensityMapTransform))}function P(M,E){E.matcap&&(M.matcap.value=E.matcap)}function I(M,E){let N=t.get(E).light;M.referencePosition.value.setFromMatrixPosition(N.matrixWorld),M.nearDistance.value=N.shadow.camera.near,M.farDistance.value=N.shadow.camera.far}return{refreshFogUniforms:o,refreshMaterialUniforms:a}}function VO(r,t,e,o){let a={},c={},p=[],d=e.isWebGL2?r.getParameter(r.MAX_UNIFORM_BUFFER_BINDINGS):0;function g(N,A){let U=A.program;o.uniformBlockBinding(N,U)}function y(N,A){let U=a[N.id];U===void 0&&(P(N),U=_(N),a[N.id]=U,N.addEventListener("dispose",M));let z=A.program;o.updateUBOMapping(N,z);let $=t.render.frame;c[N.id]!==$&&(x(N),c[N.id]=$)}function _(N){let A=w();N.__bindingPointIndex=A;let U=r.createBuffer(),z=N.__size,$=N.usage;return r.bindBuffer(r.UNIFORM_BUFFER,U),r.bufferData(r.UNIFORM_BUFFER,z,$),r.bindBuffer(r.UNIFORM_BUFFER,null),r.bindBufferBase(r.UNIFORM_BUFFER,A,U),U}function w(){for(let N=0;N<d;N++)if(p.indexOf(N)===-1)return p.push(N),N;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function x(N){let A=a[N.id],U=N.uniforms,z=N.__cache;r.bindBuffer(r.UNIFORM_BUFFER,A);for(let $=0,q=U.length;$<q;$++){let D=U[$];if(T(D,$,z)===!0){let G=D.__offset,Q=Array.isArray(D.value)?D.value:[D.value],_t=0;for(let Z=0;Z<Q.length;Z++){let Dt=Q[Z],et=I(Dt);typeof Dt=="number"?(D.__data[0]=Dt,r.bufferSubData(r.UNIFORM_BUFFER,G+_t,D.__data)):Dt.isMatrix3?(D.__data[0]=Dt.elements[0],D.__data[1]=Dt.elements[1],D.__data[2]=Dt.elements[2],D.__data[3]=Dt.elements[0],D.__data[4]=Dt.elements[3],D.__data[5]=Dt.elements[4],D.__data[6]=Dt.elements[5],D.__data[7]=Dt.elements[0],D.__data[8]=Dt.elements[6],D.__data[9]=Dt.elements[7],D.__data[10]=Dt.elements[8],D.__data[11]=Dt.elements[0]):(Dt.toArray(D.__data,_t),_t+=et.storage/Float32Array.BYTES_PER_ELEMENT)}r.bufferSubData(r.UNIFORM_BUFFER,G,D.__data)}}r.bindBuffer(r.UNIFORM_BUFFER,null)}function T(N,A,U){let z=N.value;if(U[A]===void 0){if(typeof z=="number")U[A]=z;else{let $=Array.isArray(z)?z:[z],q=[];for(let D=0;D<$.length;D++)q.push($[D].clone());U[A]=q}return!0}else if(typeof z=="number"){if(U[A]!==z)return U[A]=z,!0}else{let $=Array.isArray(U[A])?U[A]:[U[A]],q=Array.isArray(z)?z:[z];for(let D=0;D<$.length;D++){let G=$[D];if(G.equals(q[D])===!1)return G.copy(q[D]),!0}}return!1}function P(N){let A=N.uniforms,U=0,z=16,$=0;for(let q=0,D=A.length;q<D;q++){let G=A[q],Q={boundary:0,storage:0},_t=Array.isArray(G.value)?G.value:[G.value];for(let Z=0,Dt=_t.length;Z<Dt;Z++){let et=_t[Z],vt=I(et);Q.boundary+=vt.boundary,Q.storage+=vt.storage}if(G.__data=new Float32Array(Q.storage/Float32Array.BYTES_PER_ELEMENT),G.__offset=U,q>0){$=U%z;let Z=z-$;$!==0&&Z-Q.boundary<0&&(U+=z-$,G.__offset=U)}U+=Q.storage}return $=U%z,$>0&&(U+=z-$),N.__size=U,N.__cache={},this}function I(N){let A={boundary:0,storage:0};return typeof N=="number"?(A.boundary=4,A.storage=4):N.isVector2?(A.boundary=8,A.storage=8):N.isVector3||N.isColor?(A.boundary=16,A.storage=12):N.isVector4?(A.boundary=16,A.storage=16):N.isMatrix3?(A.boundary=48,A.storage=48):N.isMatrix4?(A.boundary=64,A.storage=64):N.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",N),A}function M(N){let A=N.target;A.removeEventListener("dispose",M);let U=p.indexOf(A.__bindingPointIndex);p.splice(U,1),r.deleteBuffer(a[A.id]),delete a[A.id],delete c[A.id]}function E(){for(let N in a)r.deleteBuffer(a[N]);p=[],a={},c={}}return{bind:g,update:y,dispose:E}}var em=class{constructor(t={}){let{canvas:e=nR(),context:o=null,depth:a=!0,stencil:c=!0,alpha:p=!1,antialias:d=!1,premultipliedAlpha:g=!0,preserveDrawingBuffer:y=!1,powerPreference:_="default",failIfMajorPerformanceCaveat:w=!1}=t;this.isWebGLRenderer=!0;let x;o!==null?x=o.getContextAttributes().alpha:x=p;let T=new Uint32Array(4),P=new Int32Array(4),I=null,M=null,E=[],N=[];this.domElement=e,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this._outputColorSpace=Wi,this._useLegacyLights=!1,this.toneMapping=Eu,this.toneMappingExposure=1;let A=this,U=!1,z=0,$=0,q=null,D=-1,G=null,Q=new qi,_t=new qi,Z=null,Dt=new Er(0),et=0,vt=e.width,It=e.height,Pt=1,Et=null,yt=null,Y=new qi(0,0,vt,It),ht=new qi(0,0,vt,It),Mt=!1,zt=new Xh,At=!1,$t=!1,ue=null,le=new no,Qt=new tr,me=new Rt,Xt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};function Ee(){return q===null?Pt:1}let ft=o;function He(K,xt){for(let Lt=0;Lt<K.length;Lt++){let wt=K[Lt],Ot=e.getContext(wt,xt);if(Ot!==null)return Ot}return null}try{let K={alpha:!0,depth:a,stencil:c,antialias:d,premultipliedAlpha:g,preserveDrawingBuffer:y,powerPreference:_,failIfMajorPerformanceCaveat:w};if("setAttribute"in e&&e.setAttribute("data-engine",\`three.js r\${pm}\`),e.addEventListener("webglcontextlost",ut,!1),e.addEventListener("webglcontextrestored",nt,!1),e.addEventListener("webglcontextcreationerror",lt,!1),ft===null){let xt=["webgl2","webgl","experimental-webgl"];if(A.isWebGL1Renderer===!0&&xt.shift(),ft=He(xt,K),ft===null)throw He(xt)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}typeof WebGLRenderingContext!="undefined"&&ft instanceof WebGLRenderingContext&&console.warn("THREE.WebGLRenderer: WebGL 1 support was deprecated in r153 and will be removed in r163."),ft.getShaderPrecisionFormat===void 0&&(ft.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(K){throw console.error("THREE.WebGLRenderer: "+K.message),K}let te,fe,de,Ue,be,kt,ye,Vn,$n,j,H,rt,Wt,Gt,Ct,he,Kt,tt,C,L,F,J,X,pt;function st(){te=new cN(ft),fe=new iN(ft,te,t),te.init(fe),J=new GO(ft,te,fe),de=new BO(ft,te,fe),Ue=new pN(ft),be=new TO,kt=new zO(ft,te,de,be,fe,J,Ue),ye=new sN(A),Vn=new lN(A),$n=new MR(ft,fe),X=new nN(ft,te,$n,fe),j=new fN(ft,$n,Ue,X),H=new yN(ft,j,$n,Ue),C=new mN(ft,fe,kt),he=new oN(be),rt=new bO(A,ye,Vn,te,fe,X,he),Wt=new HO(A,be),Gt=new CO,Ct=new OO(te,fe),tt=new eN(A,ye,Vn,de,H,x,g),Kt=new UO(A,H,fe),pt=new VO(ft,Ue,fe,de),L=new rN(ft,te,Ue,fe),F=new hN(ft,te,Ue,fe),Ue.programs=rt.programs,A.capabilities=fe,A.extensions=te,A.properties=be,A.renderLists=Gt,A.shadowMap=Kt,A.state=de,A.info=Ue}st();let k=new tm(A,ft);this.xr=k,this.getContext=function(){return ft},this.getContextAttributes=function(){return ft.getContextAttributes()},this.forceContextLoss=function(){let K=te.get("WEBGL_lose_context");K&&K.loseContext()},this.forceContextRestore=function(){let K=te.get("WEBGL_lose_context");K&&K.restoreContext()},this.getPixelRatio=function(){return Pt},this.setPixelRatio=function(K){K!==void 0&&(Pt=K,this.setSize(vt,It,!1))},this.getSize=function(K){return K.set(vt,It)},this.setSize=function(K,xt,Lt=!0){if(k.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}vt=K,It=xt,e.width=Math.floor(K*Pt),e.height=Math.floor(xt*Pt),Lt===!0&&(e.style.width=K+"px",e.style.height=xt+"px"),this.setViewport(0,0,K,xt)},this.getDrawingBufferSize=function(K){return K.set(vt*Pt,It*Pt).floor()},this.setDrawingBufferSize=function(K,xt,Lt){vt=K,It=xt,Pt=Lt,e.width=Math.floor(K*Lt),e.height=Math.floor(xt*Lt),this.setViewport(0,0,K,xt)},this.getCurrentViewport=function(K){return K.copy(Q)},this.getViewport=function(K){return K.copy(Y)},this.setViewport=function(K,xt,Lt,wt){K.isVector4?Y.set(K.x,K.y,K.z,K.w):Y.set(K,xt,Lt,wt),de.viewport(Q.copy(Y).multiplyScalar(Pt).floor())},this.getScissor=function(K){return K.copy(ht)},this.setScissor=function(K,xt,Lt,wt){K.isVector4?ht.set(K.x,K.y,K.z,K.w):ht.set(K,xt,Lt,wt),de.scissor(_t.copy(ht).multiplyScalar(Pt).floor())},this.getScissorTest=function(){return Mt},this.setScissorTest=function(K){de.setScissorTest(Mt=K)},this.setOpaqueSort=function(K){Et=K},this.setTransparentSort=function(K){yt=K},this.getClearColor=function(K){return K.copy(tt.getClearColor())},this.setClearColor=function(){tt.setClearColor.apply(tt,arguments)},this.getClearAlpha=function(){return tt.getClearAlpha()},this.setClearAlpha=function(){tt.setClearAlpha.apply(tt,arguments)},this.clear=function(K=!0,xt=!0,Lt=!0){let wt=0;if(K){let Ot=!1;if(q!==null){let Zt=q.texture.format;Ot=Zt===G1||Zt===z1||Zt===B1}if(Ot){let Zt=q.texture.type,jt=Zt===wu||Zt===vu||Zt===dm||Zt===ju||Zt===F1||Zt===U1,Te=tt.getClearColor(),ge=tt.getClearAlpha(),Ne=Te.r,pe=Te.g,Oe=Te.b;jt?(T[0]=Ne,T[1]=pe,T[2]=Oe,T[3]=ge,ft.clearBufferuiv(ft.COLOR,0,T)):(P[0]=Ne,P[1]=pe,P[2]=Oe,P[3]=ge,ft.clearBufferiv(ft.COLOR,0,P))}else wt|=ft.COLOR_BUFFER_BIT}xt&&(wt|=ft.DEPTH_BUFFER_BIT),Lt&&(wt|=ft.STENCIL_BUFFER_BIT),ft.clear(wt)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){e.removeEventListener("webglcontextlost",ut,!1),e.removeEventListener("webglcontextrestored",nt,!1),e.removeEventListener("webglcontextcreationerror",lt,!1),Gt.dispose(),Ct.dispose(),be.dispose(),ye.dispose(),Vn.dispose(),H.dispose(),X.dispose(),pt.dispose(),rt.dispose(),k.dispose(),k.removeEventListener("sessionstart",oe),k.removeEventListener("sessionend",Ve),ue&&(ue.dispose(),ue=null),je.stop()};function ut(K){K.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),U=!0}function nt(){console.log("THREE.WebGLRenderer: Context Restored."),U=!1;let K=Ue.autoReset,xt=Kt.enabled,Lt=Kt.autoUpdate,wt=Kt.needsUpdate,Ot=Kt.type;st(),Ue.autoReset=K,Kt.enabled=xt,Kt.autoUpdate=Lt,Kt.needsUpdate=wt,Kt.type=Ot}function lt(K){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",K.statusMessage)}function dt(K){let xt=K.target;xt.removeEventListener("dispose",dt),at(xt)}function at(K){Bt(K),be.remove(K)}function Bt(K){let xt=be.get(K).programs;xt!==void 0&&(xt.forEach(function(Lt){rt.releaseProgram(Lt)}),K.isShaderMaterial&&rt.releaseShaderCache(K))}this.renderBufferDirect=function(K,xt,Lt,wt,Ot,Zt){xt===null&&(xt=Xt);let jt=Ot.isMesh&&Ot.matrixWorld.determinant()<0,Te=hr(K,xt,Lt,wt,Ot);de.setMaterial(wt,jt);let ge=Lt.index,Ne=1;if(wt.wireframe===!0){if(ge=j.getWireframeAttribute(Lt),ge===void 0)return;Ne=2}let pe=Lt.drawRange,Oe=Lt.attributes.position,Tn=pe.start*Ne,Bn=(pe.start+pe.count)*Ne;Zt!==null&&(Tn=Math.max(Tn,Zt.start*Ne),Bn=Math.min(Bn,(Zt.start+Zt.count)*Ne)),ge!==null?(Tn=Math.max(Tn,0),Bn=Math.min(Bn,ge.count)):Oe!=null&&(Tn=Math.max(Tn,0),Bn=Math.min(Bn,Oe.count));let rr=Bn-Tn;if(rr<0||rr===1/0)return;X.setup(Ot,wt,Te,Lt,ge);let Ji,pr=L;if(ge!==null&&(Ji=$n.get(ge),pr=F,pr.setIndex(Ji)),Ot.isMesh)wt.wireframe===!0?(de.setLineWidth(wt.wireframeLinewidth*Ee()),pr.setMode(ft.LINES)):pr.setMode(ft.TRIANGLES);else if(Ot.isLine){let ze=wt.linewidth;ze===void 0&&(ze=1),de.setLineWidth(ze*Ee()),Ot.isLineSegments?pr.setMode(ft.LINES):Ot.isLineLoop?pr.setMode(ft.LINE_LOOP):pr.setMode(ft.LINE_STRIP)}else Ot.isPoints?pr.setMode(ft.POINTS):Ot.isSprite&&pr.setMode(ft.TRIANGLES);if(Ot.isInstancedMesh)pr.renderInstances(Tn,rr,Ot.count);else if(Lt.isInstancedBufferGeometry){let ze=Lt._maxInstanceCount!==void 0?Lt._maxInstanceCount:1/0,Is=Math.min(Lt.instanceCount,ze);pr.renderInstances(Tn,rr,Is)}else pr.render(Tn,rr)},this.compile=function(K,xt){function Lt(wt,Ot,Zt){wt.transparent===!0&&wt.side===Wa&&wt.forceSinglePass===!1?(wt.side=Ho,wt.needsUpdate=!0,Me(wt,Ot,Zt),wt.side=Mu,wt.needsUpdate=!0,Me(wt,Ot,Zt),wt.side=Wa):Me(wt,Ot,Zt)}M=Ct.get(K),M.init(),N.push(M),K.traverseVisible(function(wt){wt.isLight&&wt.layers.test(xt.layers)&&(M.pushLight(wt),wt.castShadow&&M.pushShadow(wt))}),M.setupLights(A._useLegacyLights),K.traverse(function(wt){let Ot=wt.material;if(Ot)if(Array.isArray(Ot))for(let Zt=0;Zt<Ot.length;Zt++){let jt=Ot[Zt];Lt(jt,K,wt)}else Lt(Ot,K,wt)}),N.pop(),M=null};let qt=null;function we(K){qt&&qt(K)}function oe(){je.stop()}function Ve(){je.start()}let je=new q1;je.setAnimationLoop(we),typeof self!="undefined"&&je.setContext(self),this.setAnimationLoop=function(K){qt=K,k.setAnimationLoop(K),K===null?je.stop():je.start()},k.addEventListener("sessionstart",oe),k.addEventListener("sessionend",Ve),this.render=function(K,xt){if(xt!==void 0&&xt.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(U===!0)return;K.matrixWorldAutoUpdate===!0&&K.updateMatrixWorld(),xt.parent===null&&xt.matrixWorldAutoUpdate===!0&&xt.updateMatrixWorld(),k.enabled===!0&&k.isPresenting===!0&&(k.cameraAutoUpdate===!0&&k.updateCamera(xt),xt=k.getCamera()),K.isScene===!0&&K.onBeforeRender(A,K,xt,q),M=Ct.get(K,N.length),M.init(),N.push(M),le.multiplyMatrices(xt.projectionMatrix,xt.matrixWorldInverse),zt.setFromProjectionMatrix(le),$t=this.localClippingEnabled,At=he.init(this.clippingPlanes,$t),I=Gt.get(K,E.length),I.init(),E.push(I),ur(K,xt,0,A.sortObjects),I.finish(),A.sortObjects===!0&&I.sort(Et,yt),this.info.render.frame++,At===!0&&he.beginShadows();let Lt=M.state.shadowsArray;if(Kt.render(Lt,K,xt),At===!0&&he.endShadows(),this.info.autoReset===!0&&this.info.reset(),tt.render(I,K),M.setupLights(A._useLegacyLights),xt.isArrayCamera){let wt=xt.cameras;for(let Ot=0,Zt=wt.length;Ot<Zt;Ot++){let jt=wt[Ot];Qn(I,K,jt,jt.viewport)}}else Qn(I,K,xt);q!==null&&(kt.updateMultisampleRenderTarget(q),kt.updateRenderTargetMipmap(q)),K.isScene===!0&&K.onAfterRender(A,K,xt),X.resetDefaultState(),D=-1,G=null,N.pop(),N.length>0?M=N[N.length-1]:M=null,E.pop(),E.length>0?I=E[E.length-1]:I=null};function ur(K,xt,Lt,wt){if(K.visible===!1)return;if(K.layers.test(xt.layers)){if(K.isGroup)Lt=K.renderOrder;else if(K.isLOD)K.autoUpdate===!0&&K.update(xt);else if(K.isLight)M.pushLight(K),K.castShadow&&M.pushShadow(K);else if(K.isSprite){if(!K.frustumCulled||zt.intersectsSprite(K)){wt&&me.setFromMatrixPosition(K.matrixWorld).applyMatrix4(le);let jt=H.update(K),Te=K.material;Te.visible&&I.push(K,jt,Te,Lt,me.z,null)}}else if((K.isMesh||K.isLine||K.isPoints)&&(!K.frustumCulled||zt.intersectsObject(K))){let jt=H.update(K),Te=K.material;if(wt&&(K.boundingSphere!==void 0?(K.boundingSphere===null&&K.computeBoundingSphere(),me.copy(K.boundingSphere.center)):(jt.boundingSphere===null&&jt.computeBoundingSphere(),me.copy(jt.boundingSphere.center)),me.applyMatrix4(K.matrixWorld).applyMatrix4(le)),Array.isArray(Te)){let ge=jt.groups;for(let Ne=0,pe=ge.length;Ne<pe;Ne++){let Oe=ge[Ne],Tn=Te[Oe.materialIndex];Tn&&Tn.visible&&I.push(K,jt,Tn,Lt,me.z,Oe)}}else Te.visible&&I.push(K,jt,Te,Lt,me.z,null)}}let Zt=K.children;for(let jt=0,Te=Zt.length;jt<Te;jt++)ur(Zt[jt],xt,Lt,wt)}function Qn(K,xt,Lt,wt){let Ot=K.opaque,Zt=K.transmissive,jt=K.transparent;M.setupLightsView(Lt),At===!0&&he.setGlobalState(A.clippingPlanes,Lt),Zt.length>0&&wr(Ot,Zt,xt,Lt),wt&&de.viewport(Q.copy(wt)),Ot.length>0&&Ir(Ot,xt,Lt),Zt.length>0&&Ir(Zt,xt,Lt),jt.length>0&&Ir(jt,xt,Lt),de.buffers.depth.setTest(!0),de.buffers.depth.setMask(!0),de.buffers.color.setMask(!0),de.setPolygonOffset(!1)}function wr(K,xt,Lt,wt){let Ot=fe.isWebGL2;ue===null&&(ue=new $a(1,1,{generateMipmaps:!0,type:te.has("EXT_color_buffer_half_float")?tf:wu,minFilter:jc,samples:Ot?4:0})),A.getDrawingBufferSize(Qt),Ot?ue.setSize(Qt.x,Qt.y):ue.setSize(Fg(Qt.x),Fg(Qt.y));let Zt=A.getRenderTarget();A.setRenderTarget(ue),A.getClearColor(Dt),et=A.getClearAlpha(),et<1&&A.setClearColor(16777215,.5),A.clear();let jt=A.toneMapping;A.toneMapping=Eu,Ir(K,Lt,wt),kt.updateMultisampleRenderTarget(ue),kt.updateRenderTargetMipmap(ue);let Te=!1;for(let ge=0,Ne=xt.length;ge<Ne;ge++){let pe=xt[ge],Oe=pe.object,Tn=pe.geometry,Bn=pe.material,rr=pe.group;if(Bn.side===Wa&&Oe.layers.test(wt.layers)){let Ji=Bn.side;Bn.side=Ho,Bn.needsUpdate=!0,er(Oe,Lt,wt,Tn,Bn,rr),Bn.side=Ji,Bn.needsUpdate=!0,Te=!0}}Te===!0&&(kt.updateMultisampleRenderTarget(ue),kt.updateRenderTargetMipmap(ue)),A.setRenderTarget(Zt),A.setClearColor(Dt,et),A.toneMapping=jt}function Ir(K,xt,Lt){let wt=xt.isScene===!0?xt.overrideMaterial:null;for(let Ot=0,Zt=K.length;Ot<Zt;Ot++){let jt=K[Ot],Te=jt.object,ge=jt.geometry,Ne=wt===null?jt.material:wt,pe=jt.group;Te.layers.test(Lt.layers)&&er(Te,xt,Lt,ge,Ne,pe)}}function er(K,xt,Lt,wt,Ot,Zt){K.onBeforeRender(A,xt,Lt,wt,Ot,Zt),K.modelViewMatrix.multiplyMatrices(Lt.matrixWorldInverse,K.matrixWorld),K.normalMatrix.getNormalMatrix(K.modelViewMatrix),Ot.onBeforeRender(A,xt,Lt,wt,K,Zt),Ot.transparent===!0&&Ot.side===Wa&&Ot.forceSinglePass===!1?(Ot.side=Ho,Ot.needsUpdate=!0,A.renderBufferDirect(Lt,xt,wt,Ot,K,Zt),Ot.side=Mu,Ot.needsUpdate=!0,A.renderBufferDirect(Lt,xt,wt,Ot,K,Zt),Ot.side=Wa):A.renderBufferDirect(Lt,xt,wt,Ot,K,Zt),K.onAfterRender(A,xt,Lt,wt,Ot,Zt)}function Me(K,xt,Lt){xt.isScene!==!0&&(xt=Xt);let wt=be.get(K),Ot=M.state.lights,Zt=M.state.shadowsArray,jt=Ot.state.version,Te=rt.getParameters(K,Ot.state,Zt,xt,Lt),ge=rt.getProgramCacheKey(Te),Ne=wt.programs;wt.environment=K.isMeshStandardMaterial?xt.environment:null,wt.fog=xt.fog,wt.envMap=(K.isMeshStandardMaterial?Vn:ye).get(K.envMap||wt.environment),Ne===void 0&&(K.addEventListener("dispose",dt),Ne=new Map,wt.programs=Ne);let pe=Ne.get(ge);if(pe!==void 0){if(wt.currentProgram===pe&&wt.lightsStateVersion===jt)return nr(K,Te),pe}else Te.uniforms=rt.getUniforms(K),K.onBuild(Lt,Te,A),K.onBeforeCompile(Te,A),pe=rt.acquireProgram(Te,ge),Ne.set(ge,pe),wt.uniforms=Te.uniforms;let Oe=wt.uniforms;(!K.isShaderMaterial&&!K.isRawShaderMaterial||K.clipping===!0)&&(Oe.clippingPlanes=he.uniform),nr(K,Te),wt.needsLights=Zn(K),wt.lightsStateVersion=jt,wt.needsLights&&(Oe.ambientLightColor.value=Ot.state.ambient,Oe.lightProbe.value=Ot.state.probe,Oe.directionalLights.value=Ot.state.directional,Oe.directionalLightShadows.value=Ot.state.directionalShadow,Oe.spotLights.value=Ot.state.spot,Oe.spotLightShadows.value=Ot.state.spotShadow,Oe.rectAreaLights.value=Ot.state.rectArea,Oe.ltc_1.value=Ot.state.rectAreaLTC1,Oe.ltc_2.value=Ot.state.rectAreaLTC2,Oe.pointLights.value=Ot.state.point,Oe.pointLightShadows.value=Ot.state.pointShadow,Oe.hemisphereLights.value=Ot.state.hemi,Oe.directionalShadowMap.value=Ot.state.directionalShadowMap,Oe.directionalShadowMatrix.value=Ot.state.directionalShadowMatrix,Oe.spotShadowMap.value=Ot.state.spotShadowMap,Oe.spotLightMatrix.value=Ot.state.spotLightMatrix,Oe.spotLightMap.value=Ot.state.spotLightMap,Oe.pointShadowMap.value=Ot.state.pointShadowMap,Oe.pointShadowMatrix.value=Ot.state.pointShadowMatrix);let Tn=pe.getUniforms(),Bn=Zl.seqWithValue(Tn.seq,Oe);return wt.currentProgram=pe,wt.uniformsList=Bn,pe}function nr(K,xt){let Lt=be.get(K);Lt.outputColorSpace=xt.outputColorSpace,Lt.instancing=xt.instancing,Lt.instancingColor=xt.instancingColor,Lt.skinning=xt.skinning,Lt.morphTargets=xt.morphTargets,Lt.morphNormals=xt.morphNormals,Lt.morphColors=xt.morphColors,Lt.morphTargetsCount=xt.morphTargetsCount,Lt.numClippingPlanes=xt.numClippingPlanes,Lt.numIntersection=xt.numClipIntersection,Lt.vertexAlphas=xt.vertexAlphas,Lt.vertexTangents=xt.vertexTangents,Lt.toneMapping=xt.toneMapping}function hr(K,xt,Lt,wt,Ot){xt.isScene!==!0&&(xt=Xt),kt.resetTextureUnits();let Zt=xt.fog,jt=wt.isMeshStandardMaterial?xt.environment:null,Te=q===null?A.outputColorSpace:q.isXRRenderTarget===!0?q.texture.colorSpace:Ya,ge=(wt.isMeshStandardMaterial?Vn:ye).get(wt.envMap||jt),Ne=wt.vertexColors===!0&&!!Lt.attributes.color&&Lt.attributes.color.itemSize===4,pe=!!Lt.attributes.tangent&&(!!wt.normalMap||wt.anisotropy>0),Oe=!!Lt.morphAttributes.position,Tn=!!Lt.morphAttributes.normal,Bn=!!Lt.morphAttributes.color,rr=Eu;wt.toneMapped&&(q===null||q.isXRRenderTarget===!0)&&(rr=A.toneMapping);let Ji=Lt.morphAttributes.position||Lt.morphAttributes.normal||Lt.morphAttributes.color,pr=Ji!==void 0?Ji.length:0,ze=be.get(wt),Is=M.state.lights;if(At===!0&&($t===!0||K!==G)){let ci=K===G&&wt.id===D;he.setState(wt,K,ci)}let De=!1;wt.version===ze.__version?(ze.needsLights&&ze.lightsStateVersion!==Is.state.version||ze.outputColorSpace!==Te||Ot.isInstancedMesh&&ze.instancing===!1||!Ot.isInstancedMesh&&ze.instancing===!0||Ot.isSkinnedMesh&&ze.skinning===!1||!Ot.isSkinnedMesh&&ze.skinning===!0||Ot.isInstancedMesh&&ze.instancingColor===!0&&Ot.instanceColor===null||Ot.isInstancedMesh&&ze.instancingColor===!1&&Ot.instanceColor!==null||ze.envMap!==ge||wt.fog===!0&&ze.fog!==Zt||ze.numClippingPlanes!==void 0&&(ze.numClippingPlanes!==he.numPlanes||ze.numIntersection!==he.numIntersection)||ze.vertexAlphas!==Ne||ze.vertexTangents!==pe||ze.morphTargets!==Oe||ze.morphNormals!==Tn||ze.morphColors!==Bn||ze.toneMapping!==rr||fe.isWebGL2===!0&&ze.morphTargetsCount!==pr)&&(De=!0):(De=!0,ze.__version=wt.version);let Xo=ze.currentProgram;De===!0&&(Xo=Me(wt,xt,Ot));let Fi=!1,Yo=!1,Ka=!1,Se=Xo.getUniforms(),Ki=ze.uniforms;if(de.useProgram(Xo.program)&&(Fi=!0,Yo=!0,Ka=!0),wt.id!==D&&(D=wt.id,Yo=!0),Fi||G!==K){Se.setValue(ft,"projectionMatrix",K.projectionMatrix),Se.setValue(ft,"viewMatrix",K.matrixWorldInverse);let ci=Se.map.cameraPosition;ci!==void 0&&ci.setValue(ft,me.setFromMatrixPosition(K.matrixWorld)),fe.logarithmicDepthBuffer&&Se.setValue(ft,"logDepthBufFC",2/(Math.log(K.far+1)/Math.LN2)),(wt.isMeshPhongMaterial||wt.isMeshToonMaterial||wt.isMeshLambertMaterial||wt.isMeshBasicMaterial||wt.isMeshStandardMaterial||wt.isShaderMaterial)&&Se.setValue(ft,"isOrthographic",K.isOrthographicCamera===!0),G!==K&&(G=K,Yo=!0,Ka=!0)}if(Ot.isSkinnedMesh){Se.setOptional(ft,Ot,"bindMatrix"),Se.setOptional(ft,Ot,"bindMatrixInverse");let ci=Ot.skeleton;ci&&(fe.floatVertexTextures?(ci.boneTexture===null&&ci.computeBoneTexture(),Se.setValue(ft,"boneTexture",ci.boneTexture,kt),Se.setValue(ft,"boneTextureSize",ci.boneTextureSize)):console.warn("THREE.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}let li=Lt.morphAttributes;if((li.position!==void 0||li.normal!==void 0||li.color!==void 0&&fe.isWebGL2===!0)&&C.update(Ot,Lt,Xo),(Yo||ze.receiveShadow!==Ot.receiveShadow)&&(ze.receiveShadow=Ot.receiveShadow,Se.setValue(ft,"receiveShadow",Ot.receiveShadow)),wt.isMeshGouraudMaterial&&wt.envMap!==null&&(Ki.envMap.value=ge,Ki.flipEnvMap.value=ge.isCubeTexture&&ge.isRenderTargetTexture===!1?-1:1),Yo&&(Se.setValue(ft,"toneMappingExposure",A.toneMappingExposure),ze.needsLights&&lr(Ki,Ka),Zt&&wt.fog===!0&&Wt.refreshFogUniforms(Ki,Zt),Wt.refreshMaterialUniforms(Ki,wt,Pt,It,ue),Zl.upload(ft,ze.uniformsList,Ki,kt)),wt.isShaderMaterial&&wt.uniformsNeedUpdate===!0&&(Zl.upload(ft,ze.uniformsList,Ki,kt),wt.uniformsNeedUpdate=!1),wt.isSpriteMaterial&&Se.setValue(ft,"center",Ot.center),Se.setValue(ft,"modelViewMatrix",Ot.modelViewMatrix),Se.setValue(ft,"normalMatrix",Ot.normalMatrix),Se.setValue(ft,"modelMatrix",Ot.matrixWorld),wt.isShaderMaterial||wt.isRawShaderMaterial){let ci=wt.uniformsGroups;for(let Ce=0,Ou=ci.length;Ce<Ou;Ce++)if(fe.isWebGL2){let Qa=ci[Ce];pt.update(Qa,Xo),pt.bind(Qa,Xo)}else console.warn("THREE.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return Xo}function lr(K,xt){K.ambientLightColor.needsUpdate=xt,K.lightProbe.needsUpdate=xt,K.directionalLights.needsUpdate=xt,K.directionalLightShadows.needsUpdate=xt,K.pointLights.needsUpdate=xt,K.pointLightShadows.needsUpdate=xt,K.spotLights.needsUpdate=xt,K.spotLightShadows.needsUpdate=xt,K.rectAreaLights.needsUpdate=xt,K.hemisphereLights.needsUpdate=xt}function Zn(K){return K.isMeshLambertMaterial||K.isMeshToonMaterial||K.isMeshPhongMaterial||K.isMeshStandardMaterial||K.isShadowMaterial||K.isShaderMaterial&&K.lights===!0}this.getActiveCubeFace=function(){return z},this.getActiveMipmapLevel=function(){return $},this.getRenderTarget=function(){return q},this.setRenderTargetTextures=function(K,xt,Lt){be.get(K.texture).__webglTexture=xt,be.get(K.depthTexture).__webglTexture=Lt;let wt=be.get(K);wt.__hasExternalTextures=!0,wt.__hasExternalTextures&&(wt.__autoAllocateDepthBuffer=Lt===void 0,wt.__autoAllocateDepthBuffer||te.has("WEBGL_multisampled_render_to_texture")===!0&&(console.warn("THREE.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),wt.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(K,xt){let Lt=be.get(K);Lt.__webglFramebuffer=xt,Lt.__useDefaultFramebuffer=xt===void 0},this.setRenderTarget=function(K,xt=0,Lt=0){q=K,z=xt,$=Lt;let wt=!0,Ot=null,Zt=!1,jt=!1;if(K){let ge=be.get(K);ge.__useDefaultFramebuffer!==void 0?(de.bindFramebuffer(ft.FRAMEBUFFER,null),wt=!1):ge.__webglFramebuffer===void 0?kt.setupRenderTarget(K):ge.__hasExternalTextures&&kt.rebindTextures(K,be.get(K.texture).__webglTexture,be.get(K.depthTexture).__webglTexture);let Ne=K.texture;(Ne.isData3DTexture||Ne.isDataArrayTexture||Ne.isCompressedArrayTexture)&&(jt=!0);let pe=be.get(K).__webglFramebuffer;K.isWebGLCubeRenderTarget?(Array.isArray(pe[xt])?Ot=pe[xt][Lt]:Ot=pe[xt],Zt=!0):fe.isWebGL2&&K.samples>0&&kt.useMultisampledRTT(K)===!1?Ot=be.get(K).__webglMultisampledFramebuffer:Array.isArray(pe)?Ot=pe[Lt]:Ot=pe,Q.copy(K.viewport),_t.copy(K.scissor),Z=K.scissorTest}else Q.copy(Y).multiplyScalar(Pt).floor(),_t.copy(ht).multiplyScalar(Pt).floor(),Z=Mt;if(de.bindFramebuffer(ft.FRAMEBUFFER,Ot)&&fe.drawBuffers&&wt&&de.drawBuffers(K,Ot),de.viewport(Q),de.scissor(_t),de.setScissorTest(Z),Zt){let ge=be.get(K.texture);ft.framebufferTexture2D(ft.FRAMEBUFFER,ft.COLOR_ATTACHMENT0,ft.TEXTURE_CUBE_MAP_POSITIVE_X+xt,ge.__webglTexture,Lt)}else if(jt){let ge=be.get(K.texture),Ne=xt||0;ft.framebufferTextureLayer(ft.FRAMEBUFFER,ft.COLOR_ATTACHMENT0,ge.__webglTexture,Lt||0,Ne)}D=-1},this.readRenderTargetPixels=function(K,xt,Lt,wt,Ot,Zt,jt){if(!(K&&K.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Te=be.get(K).__webglFramebuffer;if(K.isWebGLCubeRenderTarget&&jt!==void 0&&(Te=Te[jt]),Te){de.bindFramebuffer(ft.FRAMEBUFFER,Te);try{let ge=K.texture,Ne=ge.format,pe=ge.type;if(Ne!==Vs&&J.convert(Ne)!==ft.getParameter(ft.IMPLEMENTATION_COLOR_READ_FORMAT)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}let Oe=pe===tf&&(te.has("EXT_color_buffer_half_float")||fe.isWebGL2&&te.has("EXT_color_buffer_float"));if(pe!==wu&&J.convert(pe)!==ft.getParameter(ft.IMPLEMENTATION_COLOR_READ_TYPE)&&!(pe===_u&&(fe.isWebGL2||te.has("OES_texture_float")||te.has("WEBGL_color_buffer_float")))&&!Oe){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}xt>=0&&xt<=K.width-wt&&Lt>=0&&Lt<=K.height-Ot&&ft.readPixels(xt,Lt,wt,Ot,J.convert(Ne),J.convert(pe),Zt)}finally{let ge=q!==null?be.get(q).__webglFramebuffer:null;de.bindFramebuffer(ft.FRAMEBUFFER,ge)}}},this.copyFramebufferToTexture=function(K,xt,Lt=0){let wt=Math.pow(2,-Lt),Ot=Math.floor(xt.image.width*wt),Zt=Math.floor(xt.image.height*wt);kt.setTexture2D(xt,0),ft.copyTexSubImage2D(ft.TEXTURE_2D,Lt,0,0,K.x,K.y,Ot,Zt),de.unbindTexture()},this.copyTextureToTexture=function(K,xt,Lt,wt=0){let Ot=xt.image.width,Zt=xt.image.height,jt=J.convert(Lt.format),Te=J.convert(Lt.type);kt.setTexture2D(Lt,0),ft.pixelStorei(ft.UNPACK_FLIP_Y_WEBGL,Lt.flipY),ft.pixelStorei(ft.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Lt.premultiplyAlpha),ft.pixelStorei(ft.UNPACK_ALIGNMENT,Lt.unpackAlignment),xt.isDataTexture?ft.texSubImage2D(ft.TEXTURE_2D,wt,K.x,K.y,Ot,Zt,jt,Te,xt.image.data):xt.isCompressedTexture?ft.compressedTexSubImage2D(ft.TEXTURE_2D,wt,K.x,K.y,xt.mipmaps[0].width,xt.mipmaps[0].height,jt,xt.mipmaps[0].data):ft.texSubImage2D(ft.TEXTURE_2D,wt,K.x,K.y,jt,Te,xt.image),wt===0&&Lt.generateMipmaps&&ft.generateMipmap(ft.TEXTURE_2D),de.unbindTexture()},this.copyTextureToTexture3D=function(K,xt,Lt,wt,Ot=0){if(A.isWebGL1Renderer){console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");return}let Zt=K.max.x-K.min.x+1,jt=K.max.y-K.min.y+1,Te=K.max.z-K.min.z+1,ge=J.convert(wt.format),Ne=J.convert(wt.type),pe;if(wt.isData3DTexture)kt.setTexture3D(wt,0),pe=ft.TEXTURE_3D;else if(wt.isDataArrayTexture)kt.setTexture2DArray(wt,0),pe=ft.TEXTURE_2D_ARRAY;else{console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: only supports THREE.DataTexture3D and THREE.DataTexture2DArray.");return}ft.pixelStorei(ft.UNPACK_FLIP_Y_WEBGL,wt.flipY),ft.pixelStorei(ft.UNPACK_PREMULTIPLY_ALPHA_WEBGL,wt.premultiplyAlpha),ft.pixelStorei(ft.UNPACK_ALIGNMENT,wt.unpackAlignment);let Oe=ft.getParameter(ft.UNPACK_ROW_LENGTH),Tn=ft.getParameter(ft.UNPACK_IMAGE_HEIGHT),Bn=ft.getParameter(ft.UNPACK_SKIP_PIXELS),rr=ft.getParameter(ft.UNPACK_SKIP_ROWS),Ji=ft.getParameter(ft.UNPACK_SKIP_IMAGES),pr=Lt.isCompressedTexture?Lt.mipmaps[0]:Lt.image;ft.pixelStorei(ft.UNPACK_ROW_LENGTH,pr.width),ft.pixelStorei(ft.UNPACK_IMAGE_HEIGHT,pr.height),ft.pixelStorei(ft.UNPACK_SKIP_PIXELS,K.min.x),ft.pixelStorei(ft.UNPACK_SKIP_ROWS,K.min.y),ft.pixelStorei(ft.UNPACK_SKIP_IMAGES,K.min.z),Lt.isDataTexture||Lt.isData3DTexture?ft.texSubImage3D(pe,Ot,xt.x,xt.y,xt.z,Zt,jt,Te,ge,Ne,pr.data):Lt.isCompressedArrayTexture?(console.warn("THREE.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),ft.compressedTexSubImage3D(pe,Ot,xt.x,xt.y,xt.z,Zt,jt,Te,ge,pr.data)):ft.texSubImage3D(pe,Ot,xt.x,xt.y,xt.z,Zt,jt,Te,ge,Ne,pr),ft.pixelStorei(ft.UNPACK_ROW_LENGTH,Oe),ft.pixelStorei(ft.UNPACK_IMAGE_HEIGHT,Tn),ft.pixelStorei(ft.UNPACK_SKIP_PIXELS,Bn),ft.pixelStorei(ft.UNPACK_SKIP_ROWS,rr),ft.pixelStorei(ft.UNPACK_SKIP_IMAGES,Ji),Ot===0&&wt.generateMipmaps&&ft.generateMipmap(pe),de.unbindTexture()},this.initTexture=function(K){K.isCubeTexture?kt.setTextureCube(K,0):K.isData3DTexture?kt.setTexture3D(K,0):K.isDataArrayTexture||K.isCompressedArrayTexture?kt.setTexture2DArray(K,0):kt.setTexture2D(K,0),de.unbindTexture()},this.resetState=function(){z=0,$=0,q=null,de.reset(),X.reset()},typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return qa}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;let e=this.getContext();e.drawingBufferColorSpace=t===gm?"display-p3":"srgb",e.unpackColorSpace=yr.workingColorSpace===Zh?"display-p3":"srgb"}get physicallyCorrectLights(){return console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),!this.useLegacyLights}set physicallyCorrectLights(t){console.warn("THREE.WebGLRenderer: The property .physicallyCorrectLights has been removed. Set renderer.useLegacyLights instead."),this.useLegacyLights=!t}get outputEncoding(){return console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace===Wi?el:k1}set outputEncoding(t){console.warn("THREE.WebGLRenderer: Property .outputEncoding has been removed. Use .outputColorSpace instead."),this.outputColorSpace=t===el?Wi:Ya}get useLegacyLights(){return console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights}set useLegacyLights(t){console.warn("THREE.WebGLRenderer: The property .useLegacyLights has been deprecated. Migrate your lighting according to the following guide: https://discourse.threejs.org/t/updates-to-lighting-in-three-js-r155/53733."),this._useLegacyLights=t}},nm=class extends em{};nm.prototype.isWebGL1Renderer=!0;function Ch(r,t,e){return!r||!e&&r.constructor===t?r:typeof t.BYTES_PER_ELEMENT=="number"?new t(r):Array.prototype.slice.call(r)}function WO(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}var ec=class{constructor(t,e,o,a){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=a!==void 0?a:new e.constructor(o),this.sampleValues=e,this.valueSize=o,this.settings=null,this.DefaultSettings_={}}evaluate(t){let e=this.parameterPositions,o=this._cachedIndex,a=e[o],c=e[o-1];t:{e:{let p;n:{r:if(!(t<a)){for(let d=o+2;;){if(a===void 0){if(t<c)break r;return o=e.length,this._cachedIndex=o,this.copySampleValue_(o-1)}if(o===d)break;if(c=a,a=e[++o],t<a)break e}p=e.length;break n}if(!(t>=c)){let d=e[1];t<d&&(o=2,c=d);for(let g=o-2;;){if(c===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(o===g)break;if(a=c,c=e[--o-1],t>=c)break e}p=o,o=0;break n}break t}for(;o<p;){let d=o+p>>>1;t<e[d]?p=d:o=d+1}if(a=e[o],c=e[o-1],c===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(a===void 0)return o=e.length,this._cachedIndex=o,this.copySampleValue_(o-1)}this._cachedIndex=o,this.intervalChanged_(o,c,a)}return this.interpolate_(o,c,t,a)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){let e=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=t*a;for(let p=0;p!==a;++p)e[p]=o[c+p];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}},rm=class extends ec{constructor(t,e,o,a){super(t,e,o,a),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:k_,endingEnd:k_}}intervalChanged_(t,e,o){let a=this.parameterPositions,c=t-2,p=t+1,d=a[c],g=a[p];if(d===void 0)switch(this.getSettings_().endingStart){case H_:c=t,d=2*e-o;break;case V_:c=a.length-2,d=e+a[c]-a[c+1];break;default:c=t,d=o}if(g===void 0)switch(this.getSettings_().endingEnd){case H_:p=t,g=2*o-e;break;case V_:p=1,g=o+a[1]-a[0];break;default:p=t-1,g=e}let y=(o-e)*.5,_=this.valueSize;this._weightPrev=y/(e-d),this._weightNext=y/(g-o),this._offsetPrev=c*_,this._offsetNext=p*_}interpolate_(t,e,o,a){let c=this.resultBuffer,p=this.sampleValues,d=this.valueSize,g=t*d,y=g-d,_=this._offsetPrev,w=this._offsetNext,x=this._weightPrev,T=this._weightNext,P=(o-e)/(a-e),I=P*P,M=I*P,E=-x*M+2*x*I-x*P,N=(1+x)*M+(-1.5-2*x)*I+(-.5+x)*P+1,A=(-1-T)*M+(1.5+T)*I+.5*P,U=T*M-T*I;for(let z=0;z!==d;++z)c[z]=E*p[_+z]+N*p[y+z]+A*p[g+z]+U*p[w+z];return c}},im=class extends ec{constructor(t,e,o,a){super(t,e,o,a)}interpolate_(t,e,o,a){let c=this.resultBuffer,p=this.sampleValues,d=this.valueSize,g=t*d,y=g-d,_=(o-e)/(a-e),w=1-_;for(let x=0;x!==d;++x)c[x]=p[y+x]*w+p[g+x]*_;return c}},om=class extends ec{constructor(t,e,o,a){super(t,e,o,a)}interpolate_(t){return this.copySampleValue_(t-1)}},qs=class{constructor(t,e,o,a){if(t===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=Ch(e,this.TimeBufferType),this.values=Ch(o,this.ValueBufferType),this.setInterpolation(a||this.DefaultInterpolation)}static toJSON(t){let e=t.constructor,o;if(e.toJSON!==this.toJSON)o=e.toJSON(t);else{o={name:t.name,times:Ch(t.times,Array),values:Ch(t.values,Array)};let a=t.getInterpolation();a!==t.DefaultInterpolation&&(o.interpolation=a)}return o.type=t.ValueTypeName,o}InterpolantFactoryMethodDiscrete(t){return new om(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new im(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new rm(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case Ph:e=this.InterpolantFactoryMethodDiscrete;break;case Ih:e=this.InterpolantFactoryMethodLinear;break;case og:e=this.InterpolantFactoryMethodSmooth;break}if(e===void 0){let o="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(o);return console.warn("THREE.KeyframeTrack:",o),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Ph;case this.InterpolantFactoryMethodLinear:return Ih;case this.InterpolantFactoryMethodSmooth:return og}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){let e=this.times;for(let o=0,a=e.length;o!==a;++o)e[o]+=t}return this}scale(t){if(t!==1){let e=this.times;for(let o=0,a=e.length;o!==a;++o)e[o]*=t}return this}trim(t,e){let o=this.times,a=o.length,c=0,p=a-1;for(;c!==a&&o[c]<t;)++c;for(;p!==-1&&o[p]>e;)--p;if(++p,c!==0||p!==a){c>=p&&(p=Math.max(p,1),c=p-1);let d=this.getValueSize();this.times=o.slice(c,p),this.values=this.values.slice(c*d,p*d)}return this}validate(){let t=!0,e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);let o=this.times,a=this.values,c=o.length;c===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let p=null;for(let d=0;d!==c;d++){let g=o[d];if(typeof g=="number"&&isNaN(g)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,d,g),t=!1;break}if(p!==null&&p>g){console.error("THREE.KeyframeTrack: Out of order keys.",this,d,g,p),t=!1;break}p=g}if(a!==void 0&&WO(a))for(let d=0,g=a.length;d!==g;++d){let y=a[d];if(isNaN(y)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,d,y),t=!1;break}}return t}optimize(){let t=this.times.slice(),e=this.values.slice(),o=this.getValueSize(),a=this.getInterpolation()===og,c=t.length-1,p=1;for(let d=1;d<c;++d){let g=!1,y=t[d],_=t[d+1];if(y!==_&&(d!==1||y!==t[0]))if(a)g=!0;else{let w=d*o,x=w-o,T=w+o;for(let P=0;P!==o;++P){let I=e[w+P];if(I!==e[x+P]||I!==e[T+P]){g=!0;break}}}if(g){if(d!==p){t[p]=t[d];let w=d*o,x=p*o;for(let T=0;T!==o;++T)e[x+T]=e[w+T]}++p}}if(c>0){t[p]=t[c];for(let d=c*o,g=p*o,y=0;y!==o;++y)e[g+y]=e[d+y];++p}return p!==t.length?(this.times=t.slice(0,p),this.values=e.slice(0,p*o)):(this.times=t,this.values=e),this}clone(){let t=this.times.slice(),e=this.values.slice(),o=this.constructor,a=new o(this.name,t,e);return a.createInterpolant=this.createInterpolant,a}};qs.prototype.TimeBufferType=Float32Array;qs.prototype.ValueBufferType=Float32Array;qs.prototype.DefaultInterpolation=Ih;var il=class extends qs{};il.prototype.ValueTypeName="bool";il.prototype.ValueBufferType=Array;il.prototype.DefaultInterpolation=Ph;il.prototype.InterpolantFactoryMethodLinear=void 0;il.prototype.InterpolantFactoryMethodSmooth=void 0;var sm=class extends qs{};sm.prototype.ValueTypeName="color";var am=class extends qs{};am.prototype.ValueTypeName="number";var um=class extends ec{constructor(t,e,o,a){super(t,e,o,a)}interpolate_(t,e,o,a){let c=this.resultBuffer,p=this.sampleValues,d=this.valueSize,g=(o-e)/(a-e),y=t*d;for(let _=y+d;y!==_;y+=4)bu.slerpFlat(c,0,p,y-d,p,y,g);return c}},rf=class extends qs{InterpolantFactoryMethodLinear(t){return new um(this.times,this.values,this.getValueSize(),t)}};rf.prototype.ValueTypeName="quaternion";rf.prototype.DefaultInterpolation=Ih;rf.prototype.InterpolantFactoryMethodSmooth=void 0;var ol=class extends qs{};ol.prototype.ValueTypeName="string";ol.prototype.ValueBufferType=Array;ol.prototype.DefaultInterpolation=Ph;ol.prototype.InterpolantFactoryMethodLinear=void 0;ol.prototype.InterpolantFactoryMethodSmooth=void 0;var lm=class extends qs{};lm.prototype.ValueTypeName="vector";var cm=class{constructor(t,e,o){let a=this,c=!1,p=0,d=0,g,y=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=o,this.itemStart=function(_){d++,c===!1&&a.onStart!==void 0&&a.onStart(_,p,d),c=!0},this.itemEnd=function(_){p++,a.onProgress!==void 0&&a.onProgress(_,p,d),p===d&&(c=!1,a.onLoad!==void 0&&a.onLoad())},this.itemError=function(_){a.onError!==void 0&&a.onError(_)},this.resolveURL=function(_){return g?g(_):_},this.setURLModifier=function(_){return g=_,this},this.addHandler=function(_,w){return y.push(_,w),this},this.removeHandler=function(_){let w=y.indexOf(_);return w!==-1&&y.splice(w,2),this},this.getHandler=function(_){for(let w=0,x=y.length;w<x;w+=2){let T=y[w],P=y[w+1];if(T.global&&(T.lastIndex=0),T.test(_))return P}return null}}},qO=new cm,fm=class{constructor(t){this.manager=t!==void 0?t:qO,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){let o=this;return new Promise(function(a,c){o.load(t,a,e,c)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}};fm.DEFAULT_MATERIAL_NAME="__DEFAULT";var ym="\\\\[\\\\]\\\\.:\\\\/",XO=new RegExp("["+ym+"]","g"),vm="[^"+ym+"]",YO="[^"+ym.replace("\\\\.","")+"]",$O=/((?:WC+[\\/:])*)/.source.replace("WC",vm),ZO=/(WCOD+)?/.source.replace("WCOD",YO),JO=/(?:\\.(WC+)(?:\\[(.+)\\])?)?/.source.replace("WC",vm),KO=/\\.(WC+)(?:\\[(.+)\\])?/.source.replace("WC",vm),QO=new RegExp("^"+$O+ZO+JO+KO+"$"),jO=["material","materials","bones","map"],hm=class{constructor(t,e,o){let a=o||Nr.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,a)}getValue(t,e){this.bind();let o=this._targetGroup.nCachedObjects_,a=this._bindings[o];a!==void 0&&a.getValue(t,e)}setValue(t,e){let o=this._bindings;for(let a=this._targetGroup.nCachedObjects_,c=o.length;a!==c;++a)o[a].setValue(t,e)}bind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,o=t.length;e!==o;++e)t[e].bind()}unbind(){let t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,o=t.length;e!==o;++e)t[e].unbind()}},Nr=class r{constructor(t,e,o){this.path=e,this.parsedPath=o||r.parseTrackName(e),this.node=r.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,o){return t&&t.isAnimationObjectGroup?new r.Composite(t,e,o):new r(t,e,o)}static sanitizeNodeName(t){return t.replace(/\\s/g,"_").replace(XO,"")}static parseTrackName(t){let e=QO.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);let o={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},a=o.nodeName&&o.nodeName.lastIndexOf(".");if(a!==void 0&&a!==-1){let c=o.nodeName.substring(a+1);jO.indexOf(c)!==-1&&(o.nodeName=o.nodeName.substring(0,a),o.objectName=c)}if(o.propertyName===null||o.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return o}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){let o=t.skeleton.getBoneByName(e);if(o!==void 0)return o}if(t.children){let o=function(c){for(let p=0;p<c.length;p++){let d=c[p];if(d.name===e||d.uuid===e)return d;let g=o(d.children);if(g)return g}return null},a=o(t.children);if(a)return a}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){let o=this.resolvedProperty;for(let a=0,c=o.length;a!==c;++a)t[e++]=o[a]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){let o=this.resolvedProperty;for(let a=0,c=o.length;a!==c;++a)o[a]=t[e++]}_setValue_array_setNeedsUpdate(t,e){let o=this.resolvedProperty;for(let a=0,c=o.length;a!==c;++a)o[a]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){let o=this.resolvedProperty;for(let a=0,c=o.length;a!==c;++a)o[a]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node,e=this.parsedPath,o=e.objectName,a=e.propertyName,c=e.propertyIndex;if(t||(t=r.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(o){let y=e.objectIndex;switch(o){case"materials":if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let _=0;_<t.length;_++)if(t[_].name===y){y=_;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[o]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[o]}if(y!==void 0){if(t[y]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[y]}}let p=t[a];if(p===void 0){let y=e.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+y+"."+a+" but it wasn't found.",t);return}let d=this.Versioning.None;this.targetObject=t,t.needsUpdate!==void 0?d=this.Versioning.NeedsUpdate:t.matrixWorldNeedsUpdate!==void 0&&(d=this.Versioning.MatrixWorldNeedsUpdate);let g=this.BindingType.Direct;if(c!==void 0){if(a==="morphTargetInfluences"){if(!t.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[c]!==void 0&&(c=t.morphTargetDictionary[c])}g=this.BindingType.ArrayElement,this.resolvedProperty=p,this.propertyIndex=c}else p.fromArray!==void 0&&p.toArray!==void 0?(g=this.BindingType.HasFromToArray,this.resolvedProperty=p):Array.isArray(p)?(g=this.BindingType.EntireArray,this.resolvedProperty=p):this.propertyName=a;this.getValue=this.GetterByBindingType[g],this.setValue=this.SetterByBindingTypeAndVersioning[g][d]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}};Nr.Composite=hm;Nr.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};Nr.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};Nr.prototype.GetterByBindingType=[Nr.prototype._getValue_direct,Nr.prototype._getValue_array,Nr.prototype._getValue_arrayElement,Nr.prototype._getValue_toArray];Nr.prototype.SetterByBindingTypeAndVersioning=[[Nr.prototype._setValue_direct,Nr.prototype._setValue_direct_setNeedsUpdate,Nr.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Nr.prototype._setValue_array,Nr.prototype._setValue_array_setNeedsUpdate,Nr.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Nr.prototype._setValue_arrayElement,Nr.prototype._setValue_arrayElement_setNeedsUpdate,Nr.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Nr.prototype._setValue_fromArray,Nr.prototype._setValue_fromArray_setNeedsUpdate,Nr.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];var Oz=new Float32Array(1);typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:pm}}));typeof window!="undefined"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=pm);var Ri=63710088e-1,Fz={centimeters:Ri*100,centimetres:Ri*100,degrees:Ri/111325,feet:Ri*3.28084,inches:Ri*39.37,kilometers:Ri/1e3,kilometres:Ri/1e3,meters:Ri,metres:Ri,miles:Ri/1609.344,millimeters:Ri*1e3,millimetres:Ri*1e3,nauticalmiles:Ri/1852,radians:1,yards:Ri*1.0936},Uz={centimeters:100,centimetres:100,degrees:1/111325,feet:3.28084,inches:39.37,kilometers:1/1e3,kilometres:1/1e3,meters:1,metres:1,miles:1/1609.344,millimeters:1e3,millimetres:1e3,nauticalmiles:1/1852,radians:1/Ri,yards:1.0936133};function _o(r,t,e){e===void 0&&(e={});var o={type:"Feature"};return(e.id===0||e.id)&&(o.id=e.id),e.bbox&&(o.bbox=e.bbox),o.properties=t||{},o.geometry=r,o}function Tr(r,t,e){if(e===void 0&&(e={}),!r)throw new Error("coordinates is required");if(!Array.isArray(r))throw new Error("coordinates must be an Array");if(r.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!pa(r[0])||!pa(r[1]))throw new Error("coordinates must contain numbers");var o={type:"Point",coordinates:r};return _o(o,t,e)}function Or(r,t,e){e===void 0&&(e={});for(var o=0,a=r;o<a.length;o++){var c=a[o];if(c.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");for(var p=0;p<c[c.length-1].length;p++)if(c[c.length-1][p]!==c[0][p])throw new Error("First and last Position are not equivalent.")}var d={type:"Polygon",coordinates:r};return _o(d,t,e)}function Li(r,t,e){if(e===void 0&&(e={}),r.length<2)throw new Error("coordinates must be an array of two or more positions");var o={type:"LineString",coordinates:r};return _o(o,t,e)}function _m(r,t,e){e===void 0&&(e={});var o={type:"MultiPoint",coordinates:r};return _o(o,t,e)}function pa(r){return!isNaN(r)&&r!==null&&!Array.isArray(r)}function mi(r,t,e){if(r!==null)for(var o,a,c,p,d,g,y,_=0,w=0,x,T=r.type,P=T==="FeatureCollection",I=T==="Feature",M=P?r.features.length:1,E=0;E<M;E++){y=P?r.features[E].geometry:I?r.geometry:r,x=y?y.type==="GeometryCollection":!1,d=x?y.geometries.length:1;for(var N=0;N<d;N++){var A=0,U=0;if(p=x?y.geometries[N]:y,p!==null){g=p.coordinates;var z=p.type;switch(_=e&&(z==="Polygon"||z==="MultiPolygon")?1:0,z){case null:break;case"Point":if(t(g,w,E,A,U)===!1)return!1;w++,A++;break;case"LineString":case"MultiPoint":for(o=0;o<g.length;o++){if(t(g[o],w,E,A,U)===!1)return!1;w++,z==="MultiPoint"&&A++}z==="LineString"&&A++;break;case"Polygon":case"MultiLineString":for(o=0;o<g.length;o++){for(a=0;a<g[o].length-_;a++){if(t(g[o][a],w,E,A,U)===!1)return!1;w++}z==="MultiLineString"&&A++,z==="Polygon"&&U++}z==="Polygon"&&A++;break;case"MultiPolygon":for(o=0;o<g.length;o++){for(U=0,a=0;a<g[o].length;a++){for(c=0;c<g[o][a].length-_;c++){if(t(g[o][a][c],w,E,A,U)===!1)return!1;w++}U++}A++}break;case"GeometryCollection":for(o=0;o<p.geometries.length;o++)if(mi(p.geometries[o],t,e)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function J1(r,t,e,o){var a=e;return mi(r,function(c,p,d,g,y){p===0&&e===void 0?a=c:a=t(a,c,p,d,g,y)},o),a}function Tu(r,t){var e,o,a,c,p,d,g,y,_,w,x=0,T=r.type==="FeatureCollection",P=r.type==="Feature",I=T?r.features.length:1;for(e=0;e<I;e++){for(d=T?r.features[e].geometry:P?r.geometry:r,y=T?r.features[e].properties:P?r.properties:{},_=T?r.features[e].bbox:P?r.bbox:void 0,w=T?r.features[e].id:P?r.id:void 0,g=d?d.type==="GeometryCollection":!1,p=g?d.geometries.length:1,a=0;a<p;a++){if(c=g?d.geometries[a]:d,c===null){if(t(null,x,y,_,w)===!1)return!1;continue}switch(c.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":{if(t(c,x,y,_,w)===!1)return!1;break}case"GeometryCollection":{for(o=0;o<c.geometries.length;o++)if(t(c.geometries[o],x,y,_,w)===!1)return!1;break}default:throw new Error("Unknown Geometry Type")}}x++}}function cs(r,t){Tu(r,function(e,o,a,c,p){var d=e===null?null:e.type;switch(d){case null:case"Point":case"LineString":case"Polygon":return t(_o(e,a,{bbox:c,id:p}),o,0)===!1?!1:void 0}var g;switch(d){case"MultiPoint":g="Point";break;case"MultiLineString":g="LineString";break;case"MultiPolygon":g="Polygon";break}for(var y=0;y<e.coordinates.length;y++){var _=e.coordinates[y],w={type:g,coordinates:_};if(t(_o(w,a),o,y)===!1)return!1}})}function xm(r){var t=[1/0,1/0,-1/0,-1/0];return mi(r,function(e){t[0]>e[0]&&(t[0]=e[0]),t[1]>e[1]&&(t[1]=e[1]),t[2]<e[0]&&(t[2]=e[0]),t[3]<e[1]&&(t[3]=e[1])}),t}xm.default=xm;var xo=xm;function Xi(r){if(!r)throw new Error("coord is required");if(!Array.isArray(r)){if(r.type==="Feature"&&r.geometry!==null&&r.geometry.type==="Point")return r.geometry.coordinates;if(r.type==="Point")return r.coordinates}if(Array.isArray(r)&&r.length>=2&&!Array.isArray(r[0])&&!Array.isArray(r[1]))return r;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function Em(r,t,e){if(!r)throw new Error("No feature passed");if(!e)throw new Error(".featureOf() requires a name");if(!r||r.type!=="Feature"||!r.geometry)throw new Error("Invalid input to "+e+", Feature with geometry required");if(!r.geometry||r.geometry.type!==t)throw new Error("Invalid input to "+e+": must be a "+t+", given "+r.geometry.type)}function Yi(r){return r.type==="Feature"?r.geometry:r}var aD=Lr(Kh(),1);var yD=Lr(dx(),1);function Ni(r,t,e){if(e===void 0&&(e={}),!r)throw new Error("point is required");if(!t)throw new Error("polygon is required");var o=Xi(r),a=Yi(t),c=a.type,p=t.bbox,d=a.coordinates;if(p&&vD(o,p)===!1)return!1;c==="Polygon"&&(d=[d]);for(var g=!1,y=0;y<d.length&&!g;y++)if(gx(o,d[y][0],e.ignoreBoundary)){for(var _=!1,w=1;w<d[y].length&&!_;)gx(o,d[y][w],!e.ignoreBoundary)&&(_=!0),w++;_||(g=!0)}return g}function gx(r,t,e){var o=!1;t[0][0]===t[t.length-1][0]&&t[0][1]===t[t.length-1][1]&&(t=t.slice(0,t.length-1));for(var a=0,c=t.length-1;a<t.length;c=a++){var p=t[a][0],d=t[a][1],g=t[c][0],y=t[c][1],_=r[1]*(p-g)+d*(g-r[0])+y*(r[0]-p)===0&&(p-r[0])*(g-r[0])<=0&&(d-r[1])*(y-r[1])<=0;if(_)return!e;var w=d>r[1]!=y>r[1]&&r[0]<(g-p)*(r[1]-d)/(y-d)+p;w&&(o=!o)}return o}function vD(r,t){return t[0]<=r[0]&&t[1]<=r[1]&&t[2]>=r[0]&&t[3]>=r[1]}var vx=new ArrayBuffer(16),hG=new Float64Array(vx),pG=new Uint32Array(vx);var ND=Lr(Um(),1);var zk=function(){function r(t){this.points=t.points||[],this.duration=t.duration||1e4,this.sharpness=t.sharpness||.85,this.centers=[],this.controls=[],this.stepLength=t.stepLength||60,this.length=this.points.length,this.delay=0;for(var e=0;e<this.length;e++)this.points[e].z=this.points[e].z||0;for(var e=0;e<this.length-1;e++){var o=this.points[e],a=this.points[e+1];this.centers.push({x:(o.x+a.x)/2,y:(o.y+a.y)/2,z:(o.z+a.z)/2})}this.controls.push([this.points[0],this.points[0]]);for(var e=0;e<this.centers.length-1;e++){var c=this.points[e+1].x-(this.centers[e].x+this.centers[e+1].x)/2,p=this.points[e+1].y-(this.centers[e].y+this.centers[e+1].y)/2,d=this.points[e+1].z-(this.centers[e].y+this.centers[e+1].z)/2;this.controls.push([{x:(1-this.sharpness)*this.points[e+1].x+this.sharpness*(this.centers[e].x+c),y:(1-this.sharpness)*this.points[e+1].y+this.sharpness*(this.centers[e].y+p),z:(1-this.sharpness)*this.points[e+1].z+this.sharpness*(this.centers[e].z+d)},{x:(1-this.sharpness)*this.points[e+1].x+this.sharpness*(this.centers[e+1].x+c),y:(1-this.sharpness)*this.points[e+1].y+this.sharpness*(this.centers[e+1].y+p),z:(1-this.sharpness)*this.points[e+1].z+this.sharpness*(this.centers[e+1].z+d)}])}return this.controls.push([this.points[this.length-1],this.points[this.length-1]]),this.steps=this.cacheSteps(this.stepLength),this}return r.prototype.cacheSteps=function(t){var e=[],o=this.pos(0);e.push(0);for(var a=0;a<this.duration;a+=10){var c=this.pos(a),p=Math.sqrt((c.x-o.x)*(c.x-o.x)+(c.y-o.y)*(c.y-o.y)+(c.z-o.z)*(c.z-o.z));p>t&&(e.push(a),o=c)}return e},r.prototype.vector=function(t){var e=this.pos(t+10),o=this.pos(t-10);return{angle:180*Math.atan2(e.y-o.y,e.x-o.x)/3.14,speed:Math.sqrt((o.x-e.x)*(o.x-e.x)+(o.y-e.y)*(o.y-e.y)+(o.z-e.z)*(o.z-e.z))}},r.prototype.pos=function(t){var e=t-this.delay;e<0&&(e=0),e>this.duration&&(e=this.duration-1);var o=e/this.duration;if(o>=1)return this.points[this.length-1];var a=Math.floor((this.points.length-1)*o),c=(this.length-1)*o-a;return OD(c,this.points[a],this.controls[a][1],this.controls[a+1][0],this.points[a+1])},r}();function OD(r,t,e,o,a){var c=DD(r),p={x:a.x*c[0]+o.x*c[1]+e.x*c[2]+t.x*c[3],y:a.y*c[0]+o.y*c[1]+e.y*c[2]+t.y*c[3],z:a.z*c[0]+o.z*c[1]+e.z*c[2]+t.z*c[3]};return p}function DD(r){var t=r*r,e=t*r;return[e,3*t*(1-r),3*r*(1-r)*(1-r),(1-r)*(1-r)*(1-r)]}function lf(r,t){t===void 0&&(t={});var e=Number(r[0]),o=Number(r[1]),a=Number(r[2]),c=Number(r[3]);if(r.length===6)throw new Error("@turf/bbox-polygon does not support BBox with 6 positions");var p=[e,o],d=[e,c],g=[a,c],y=[a,o];return Or([[p,y,g,d,p]],t.properties,{bbox:r,id:t.id})}function FD(r){return lf(xo(r))}var Bm=FD;var jD=Lr(Px(),1);var T3=Lr(dp(),1);var C3=Lr(Kh(),1);var R3=Lr(Um(),1);var Yx=Math.PI/180,$x=180/Math.PI,mf=function(r,t){this.lon=r,this.lat=t,this.x=Yx*r,this.y=Yx*t};mf.prototype.view=function(){return String(this.lon).slice(0,4)+","+String(this.lat).slice(0,4)};mf.prototype.antipode=function(){var r=-1*this.lat,t=this.lon<0?180+this.lon:(180-this.lon)*-1;return new mf(t,r)};var Zx=function(){this.coords=[],this.length=0};Zx.prototype.move_to=function(r){this.length++,this.coords.push(r)};var i0=function(r){this.properties=r||{},this.geometries=[]};i0.prototype.json=function(){if(this.geometries.length<=0)return{geometry:{type:"LineString",coordinates:null},type:"Feature",properties:this.properties};if(this.geometries.length===1)return{geometry:{type:"LineString",coordinates:this.geometries[0].coords},type:"Feature",properties:this.properties};for(var r=[],t=0;t<this.geometries.length;t++)r.push(this.geometries[t].coords);return{geometry:{type:"MultiLineString",coordinates:r},type:"Feature",properties:this.properties}};i0.prototype.wkt=function(){for(var r="",t="LINESTRING(",e=function(c){t+=c[0]+" "+c[1]+","},o=0;o<this.geometries.length;o++){if(this.geometries[o].coords.length===0)return"LINESTRING(empty)";var a=this.geometries[o].coords;a.forEach(e),r+=t.substring(0,t.length-1)+")"}return r};var Jx=function(r,t,e){if(!r||r.x===void 0||r.y===void 0)throw new Error("GreatCircle constructor expects two args: start and end objects with x and y properties");if(!t||t.x===void 0||t.y===void 0)throw new Error("GreatCircle constructor expects two args: start and end objects with x and y properties");this.start=new mf(r.x,r.y),this.end=new mf(t.x,t.y),this.properties=e||{};var o=this.start.x-this.end.x,a=this.start.y-this.end.y,c=Math.pow(Math.sin(a/2),2)+Math.cos(this.start.y)*Math.cos(this.end.y)*Math.pow(Math.sin(o/2),2);if(this.g=2*Math.asin(Math.sqrt(c)),this.g===Math.PI)throw new Error("it appears "+r.view()+" and "+t.view()+" are 'antipodal', e.g diametrically opposite, thus there is no single route but rather infinite");if(isNaN(this.g))throw new Error("could not calculate great circle between "+r+" and "+t)};Jx.prototype.interpolate=function(r){var t=Math.sin((1-r)*this.g)/Math.sin(this.g),e=Math.sin(r*this.g)/Math.sin(this.g),o=t*Math.cos(this.start.y)*Math.cos(this.start.x)+e*Math.cos(this.end.y)*Math.cos(this.end.x),a=t*Math.cos(this.start.y)*Math.sin(this.start.x)+e*Math.cos(this.end.y)*Math.sin(this.end.x),c=t*Math.sin(this.start.y)+e*Math.sin(this.end.y),p=$x*Math.atan2(c,Math.sqrt(Math.pow(o,2)+Math.pow(a,2))),d=$x*Math.atan2(a,o);return[d,p]};Jx.prototype.Arc=function(r,t){var e=[];if(!r||r<=2)e.push([this.start.lon,this.start.lat]),e.push([this.end.lon,this.end.lat]);else for(var o=1/(r-1),a=0;a<r;++a){var c=o*a,p=this.interpolate(c);e.push(p)}for(var d=!1,g=0,y=t&&t.offset?t.offset:10,_=180-y,w=-180+y,x=360-y,T=1;T<e.length;++T){var P=e[T-1][0],I=e[T][0],M=Math.abs(I-P);M>x&&(I>_&&P<w||P>_&&I<w)?d=!0:M>g&&(g=M)}var E=[];if(d&&g<y){var N=[];E.push(N);for(var A=0;A<e.length;++A){var U=parseFloat(e[A][0]);if(A>0&&Math.abs(U-e[A-1][0])>x){var z=parseFloat(e[A-1][0]),$=parseFloat(e[A-1][1]),q=parseFloat(e[A][0]),D=parseFloat(e[A][1]);if(z>-180&&z<w&&q===180&&A+1<e.length&&e[A-1][0]>-180&&e[A-1][0]<w){N.push([-180,e[A][1]]),A++,N.push([e[A][0],e[A][1]]);continue}else if(z>_&&z<180&&q===-180&&A+1<e.length&&e[A-1][0]>_&&e[A-1][0]<180){N.push([180,e[A][1]]),A++,N.push([e[A][0],e[A][1]]);continue}if(z<w&&q>_){var G=z;z=q,q=G;var Q=$;$=D,D=Q}if(z>_&&q<w&&(q+=360),z<=180&&q>=180&&z<q){var _t=(180-z)/(q-z),Z=_t*D+(1-_t)*$;N.push([e[A-1][0]>_?180:-180,Z]),N=[],N.push([e[A-1][0]>_?-180:180,Z]),E.push(N)}else N=[],E.push(N);N.push([U,e[A][1]])}else N.push([e[A][0],e[A][1]])}}else{var Dt=[];E.push(Dt);for(var et=0;et<e.length;++et)Dt.push([e[et][0],e[et][1]])}for(var vt=new i0(this.properties),It=0;It<E.length;++It){var Pt=new Zx;vt.geometries.push(Pt);for(var Et=E[It],yt=0;yt<Et.length;++yt)Pt.move_to(Et[yt])}return vt};var O3=Lr(dp(),1);var pU=Lr(dp(),1);var dU=Lr(T0(),1);var yU=Lr(Kh(),1);var en=[],nn=[],rn=[],on=[],sn=[],an=[],un=[],ln=[],cn=[],fn=[],hn=[],pn=[],dn=[],gn=[],mn=[],yn=[],vn=[],_n=[],xn=[],En=[],wn=[],Mn=[],Sn=[],bn=[];un[85]=fn[85]=-1;ln[85]=hn[85]=0;cn[85]=pn[85]=1;xn[85]=Mn[85]=1;En[85]=Sn[85]=0;wn[85]=bn[85]=1;en[85]=on[85]=0;nn[85]=sn[85]=-1;rn[85]=mn[85]=0;yn[85]=dn[85]=0;vn[85]=gn[85]=1;an[85]=_n[85]=1;Mn[1]=Mn[169]=0;Sn[1]=Sn[169]=-1;bn[1]=bn[169]=0;dn[1]=dn[169]=-1;gn[1]=gn[169]=0;mn[1]=mn[169]=0;fn[4]=fn[166]=0;hn[4]=hn[166]=-1;pn[4]=pn[166]=1;yn[4]=yn[166]=1;vn[4]=vn[166]=0;_n[4]=_n[166]=0;un[16]=un[154]=0;ln[16]=ln[154]=1;cn[16]=cn[154]=1;on[16]=on[154]=1;sn[16]=sn[154]=0;an[16]=an[154]=1;xn[64]=xn[106]=0;En[64]=En[106]=1;wn[64]=wn[106]=0;en[64]=en[106]=-1;nn[64]=nn[106]=0;rn[64]=rn[106]=1;xn[2]=xn[168]=0;En[2]=En[168]=-1;wn[2]=wn[168]=1;Mn[2]=Mn[168]=0;Sn[2]=Sn[168]=-1;bn[2]=bn[168]=0;dn[2]=dn[168]=-1;gn[2]=gn[168]=0;mn[2]=mn[168]=0;yn[2]=yn[168]=-1;vn[2]=vn[168]=0;_n[2]=_n[168]=1;un[8]=un[162]=0;ln[8]=ln[162]=-1;cn[8]=cn[162]=0;fn[8]=fn[162]=0;hn[8]=hn[162]=-1;pn[8]=pn[162]=1;dn[8]=dn[162]=1;gn[8]=gn[162]=0;mn[8]=mn[162]=1;yn[8]=yn[162]=1;vn[8]=vn[162]=0;_n[8]=_n[162]=0;un[32]=un[138]=0;ln[32]=ln[138]=1;cn[32]=cn[138]=1;fn[32]=fn[138]=0;hn[32]=hn[138]=1;pn[32]=pn[138]=0;en[32]=en[138]=1;nn[32]=nn[138]=0;rn[32]=rn[138]=0;on[32]=on[138]=1;sn[32]=sn[138]=0;an[32]=an[138]=1;Mn[128]=Mn[42]=0;Sn[128]=Sn[42]=1;bn[128]=bn[42]=1;xn[128]=xn[42]=0;En[128]=En[42]=1;wn[128]=wn[42]=0;en[128]=en[42]=-1;nn[128]=nn[42]=0;rn[128]=rn[42]=1;on[128]=on[42]=-1;sn[128]=sn[42]=0;an[128]=an[42]=0;fn[5]=fn[165]=-1;hn[5]=hn[165]=0;pn[5]=pn[165]=0;Mn[5]=Mn[165]=1;Sn[5]=Sn[165]=0;bn[5]=bn[165]=0;yn[20]=yn[150]=0;vn[20]=vn[150]=1;_n[20]=_n[150]=1;on[20]=on[150]=0;sn[20]=sn[150]=-1;an[20]=an[150]=1;un[80]=un[90]=-1;ln[80]=ln[90]=0;cn[80]=cn[90]=1;xn[80]=xn[90]=1;En[80]=En[90]=0;wn[80]=wn[90]=1;dn[65]=dn[105]=0;gn[65]=gn[105]=1;mn[65]=mn[105]=0;en[65]=en[105]=0;nn[65]=nn[105]=-1;rn[65]=rn[105]=0;un[160]=un[10]=-1;ln[160]=ln[10]=0;cn[160]=cn[10]=1;fn[160]=fn[10]=-1;hn[160]=hn[10]=0;pn[160]=pn[10]=0;Mn[160]=Mn[10]=1;Sn[160]=Sn[10]=0;bn[160]=bn[10]=0;xn[160]=xn[10]=1;En[160]=En[10]=0;wn[160]=wn[10]=1;yn[130]=yn[40]=0;vn[130]=vn[40]=1;_n[130]=_n[40]=1;dn[130]=dn[40]=0;gn[130]=gn[40]=1;mn[130]=mn[40]=0;en[130]=en[40]=0;nn[130]=nn[40]=-1;rn[130]=rn[40]=0;on[130]=on[40]=0;sn[130]=sn[40]=-1;an[130]=an[40]=1;fn[37]=fn[133]=0;hn[37]=hn[133]=1;pn[37]=pn[133]=1;Mn[37]=Mn[133]=0;Sn[37]=Sn[133]=1;bn[37]=bn[133]=0;en[37]=en[133]=-1;nn[37]=nn[133]=0;rn[37]=rn[133]=0;on[37]=on[133]=1;sn[37]=sn[133]=0;an[37]=an[133]=0;yn[148]=yn[22]=-1;vn[148]=vn[22]=0;_n[148]=_n[22]=0;Mn[148]=Mn[22]=0;Sn[148]=Sn[22]=-1;bn[148]=bn[22]=1;xn[148]=xn[22]=0;En[148]=En[22]=1;wn[148]=wn[22]=1;on[148]=on[22]=-1;sn[148]=sn[22]=0;an[148]=an[22]=1;un[82]=un[88]=0;ln[82]=ln[88]=-1;cn[82]=cn[88]=1;yn[82]=yn[88]=1;vn[82]=vn[88]=0;_n[82]=_n[88]=1;dn[82]=dn[88]=-1;gn[82]=gn[88]=0;mn[82]=mn[88]=1;xn[82]=xn[88]=0;En[82]=En[88]=-1;wn[82]=wn[88]=0;un[73]=un[97]=0;ln[73]=ln[97]=1;cn[73]=cn[97]=0;fn[73]=fn[97]=0;hn[73]=hn[97]=-1;pn[73]=pn[97]=0;dn[73]=dn[97]=1;gn[73]=gn[97]=0;mn[73]=mn[97]=0;en[73]=en[97]=1;nn[73]=nn[97]=0;rn[73]=rn[97]=1;un[145]=un[25]=0;ln[145]=ln[25]=-1;cn[145]=cn[25]=0;dn[145]=dn[25]=1;gn[145]=gn[25]=0;mn[145]=mn[25]=1;Mn[145]=Mn[25]=0;Sn[145]=Sn[25]=1;bn[145]=bn[25]=1;on[145]=on[25]=-1;sn[145]=sn[25]=0;an[145]=an[25]=0;fn[70]=fn[100]=0;hn[70]=hn[100]=1;pn[70]=pn[100]=0;yn[70]=yn[100]=-1;vn[70]=vn[100]=0;_n[70]=_n[100]=1;xn[70]=xn[100]=0;En[70]=En[100]=-1;wn[70]=wn[100]=1;en[70]=en[100]=1;nn[70]=nn[100]=0;rn[70]=rn[100]=0;fn[101]=fn[69]=0;hn[101]=hn[69]=1;pn[101]=pn[69]=0;en[101]=en[69]=1;nn[101]=nn[69]=0;rn[101]=rn[69]=0;Mn[149]=Mn[21]=0;Sn[149]=Sn[21]=1;bn[149]=bn[21]=1;on[149]=on[21]=-1;sn[149]=sn[21]=0;an[149]=an[21]=0;yn[86]=yn[84]=-1;vn[86]=vn[84]=0;_n[86]=_n[84]=1;xn[86]=xn[84]=0;En[86]=En[84]=-1;wn[86]=wn[84]=1;un[89]=un[81]=0;ln[89]=ln[81]=-1;cn[89]=cn[81]=0;dn[89]=dn[81]=1;gn[89]=gn[81]=0;mn[89]=mn[81]=1;un[96]=un[74]=0;ln[96]=ln[74]=1;cn[96]=cn[74]=0;fn[96]=fn[74]=-1;hn[96]=hn[74]=0;pn[96]=pn[74]=1;xn[96]=xn[74]=1;En[96]=En[74]=0;wn[96]=wn[74]=0;en[96]=en[74]=1;nn[96]=nn[74]=0;rn[96]=rn[74]=1;un[24]=un[146]=0;ln[24]=ln[146]=-1;cn[24]=cn[146]=1;yn[24]=yn[146]=1;vn[24]=vn[146]=0;_n[24]=_n[146]=1;dn[24]=dn[146]=0;gn[24]=gn[146]=1;mn[24]=mn[146]=1;on[24]=on[146]=0;sn[24]=sn[146]=-1;an[24]=an[146]=0;fn[6]=fn[164]=-1;hn[6]=hn[164]=0;pn[6]=pn[164]=1;yn[6]=yn[164]=-1;vn[6]=vn[164]=0;_n[6]=_n[164]=0;Mn[6]=Mn[164]=0;Sn[6]=Sn[164]=-1;bn[6]=bn[164]=1;xn[6]=xn[164]=1;En[6]=En[164]=0;wn[6]=wn[164]=0;dn[129]=dn[41]=0;gn[129]=gn[41]=1;mn[129]=mn[41]=1;Mn[129]=Mn[41]=0;Sn[129]=Sn[41]=1;bn[129]=bn[41]=0;en[129]=en[41]=-1;nn[129]=nn[41]=0;rn[129]=rn[41]=0;on[129]=on[41]=0;sn[129]=sn[41]=-1;an[129]=an[41]=0;yn[66]=yn[104]=0;vn[66]=vn[104]=1;_n[66]=_n[104]=0;dn[66]=dn[104]=-1;gn[66]=gn[104]=0;mn[66]=mn[104]=1;xn[66]=xn[104]=0;En[66]=En[104]=-1;wn[66]=wn[104]=0;en[66]=en[104]=0;nn[66]=nn[104]=-1;rn[66]=rn[104]=1;un[144]=un[26]=-1;ln[144]=ln[26]=0;cn[144]=cn[26]=0;Mn[144]=Mn[26]=1;Sn[144]=Sn[26]=0;bn[144]=bn[26]=1;xn[144]=xn[26]=0;En[144]=En[26]=1;wn[144]=wn[26]=1;on[144]=on[26]=-1;sn[144]=sn[26]=0;an[144]=an[26]=1;fn[36]=fn[134]=0;hn[36]=hn[134]=1;pn[36]=pn[134]=1;yn[36]=yn[134]=0;vn[36]=vn[134]=1;_n[36]=_n[134]=0;en[36]=en[134]=0;nn[36]=nn[134]=-1;rn[36]=rn[134]=1;on[36]=on[134]=1;sn[36]=sn[134]=0;an[36]=an[134]=0;un[9]=un[161]=-1;ln[9]=ln[161]=0;cn[9]=cn[161]=0;fn[9]=fn[161]=0;hn[9]=hn[161]=-1;pn[9]=pn[161]=0;dn[9]=dn[161]=1;gn[9]=gn[161]=0;mn[9]=mn[161]=0;Mn[9]=Mn[161]=1;Sn[9]=Sn[161]=0;bn[9]=bn[161]=1;un[136]=0;ln[136]=1;cn[136]=1;fn[136]=0;hn[136]=1;pn[136]=0;yn[136]=-1;vn[136]=0;_n[136]=1;dn[136]=-1;gn[136]=0;mn[136]=0;Mn[136]=0;Sn[136]=-1;bn[136]=0;xn[136]=0;En[136]=-1;wn[136]=1;en[136]=1;nn[136]=0;rn[136]=0;on[136]=1;sn[136]=0;an[136]=1;un[34]=0;ln[34]=-1;cn[34]=0;fn[34]=0;hn[34]=-1;pn[34]=1;yn[34]=1;vn[34]=0;_n[34]=0;dn[34]=1;gn[34]=0;mn[34]=1;Mn[34]=0;Sn[34]=1;bn[34]=1;xn[34]=0;En[34]=1;wn[34]=0;en[34]=-1;nn[34]=0;rn[34]=1;on[34]=-1;sn[34]=0;an[34]=0;un[35]=0;ln[35]=1;cn[35]=1;fn[35]=0;hn[35]=-1;pn[35]=1;yn[35]=1;vn[35]=0;_n[35]=0;dn[35]=-1;gn[35]=0;mn[35]=0;Mn[35]=0;Sn[35]=-1;bn[35]=0;xn[35]=0;En[35]=1;wn[35]=0;en[35]=-1;nn[35]=0;rn[35]=1;on[35]=1;sn[35]=0;an[35]=1;un[153]=0;ln[153]=1;cn[153]=1;dn[153]=-1;gn[153]=0;mn[153]=0;Mn[153]=0;Sn[153]=-1;bn[153]=0;on[153]=1;sn[153]=0;an[153]=1;fn[102]=0;hn[102]=-1;pn[102]=1;yn[102]=1;vn[102]=0;_n[102]=0;xn[102]=0;En[102]=1;wn[102]=0;en[102]=-1;nn[102]=0;rn[102]=1;un[155]=0;ln[155]=-1;cn[155]=0;dn[155]=1;gn[155]=0;mn[155]=1;Mn[155]=0;Sn[155]=1;bn[155]=1;on[155]=-1;sn[155]=0;an[155]=0;fn[103]=0;hn[103]=1;pn[103]=0;yn[103]=-1;vn[103]=0;_n[103]=1;xn[103]=0;En[103]=-1;wn[103]=1;en[103]=1;nn[103]=0;rn[103]=0;un[152]=0;ln[152]=1;cn[152]=1;yn[152]=-1;vn[152]=0;_n[152]=1;dn[152]=-1;gn[152]=0;mn[152]=0;Mn[152]=0;Sn[152]=-1;bn[152]=0;xn[152]=0;En[152]=-1;wn[152]=1;on[152]=1;sn[152]=0;an[152]=1;un[156]=0;ln[156]=-1;cn[156]=1;yn[156]=1;vn[156]=0;_n[156]=1;dn[156]=-1;gn[156]=0;mn[156]=0;Mn[156]=0;Sn[156]=-1;bn[156]=0;xn[156]=0;En[156]=1;wn[156]=1;on[156]=-1;sn[156]=0;an[156]=1;un[137]=0;ln[137]=1;cn[137]=1;fn[137]=0;hn[137]=1;pn[137]=0;dn[137]=-1;gn[137]=0;mn[137]=0;Mn[137]=0;Sn[137]=-1;bn[137]=0;en[137]=1;nn[137]=0;rn[137]=0;on[137]=1;sn[137]=0;an[137]=1;un[139]=0;ln[139]=1;cn[139]=1;fn[139]=0;hn[139]=-1;pn[139]=0;dn[139]=1;gn[139]=0;mn[139]=0;Mn[139]=0;Sn[139]=1;bn[139]=0;en[139]=-1;nn[139]=0;rn[139]=0;on[139]=1;sn[139]=0;an[139]=1;un[98]=0;ln[98]=-1;cn[98]=0;fn[98]=0;hn[98]=-1;pn[98]=1;yn[98]=1;vn[98]=0;_n[98]=0;dn[98]=1;gn[98]=0;mn[98]=1;xn[98]=0;En[98]=1;wn[98]=0;en[98]=-1;nn[98]=0;rn[98]=1;un[99]=0;ln[99]=1;cn[99]=0;fn[99]=0;hn[99]=-1;pn[99]=1;yn[99]=1;vn[99]=0;_n[99]=0;dn[99]=-1;gn[99]=0;mn[99]=1;xn[99]=0;En[99]=-1;wn[99]=0;en[99]=1;nn[99]=0;rn[99]=1;fn[38]=0;hn[38]=-1;pn[38]=1;yn[38]=1;vn[38]=0;_n[38]=0;Mn[38]=0;Sn[38]=1;bn[38]=1;xn[38]=0;En[38]=1;wn[38]=0;en[38]=-1;nn[38]=0;rn[38]=1;on[38]=-1;sn[38]=0;an[38]=0;fn[39]=0;hn[39]=1;pn[39]=1;yn[39]=-1;vn[39]=0;_n[39]=0;Mn[39]=0;Sn[39]=-1;bn[39]=1;xn[39]=0;En[39]=1;wn[39]=0;en[39]=-1;nn[39]=0;rn[39]=1;on[39]=1;sn[39]=0;an[39]=0;var A0=function(r){return[[r.bottomleft,0],[0,0],[0,r.leftbottom]]},C0=function(r){return[[1,r.rightbottom],[1,0],[r.bottomright,0]]},P0=function(r){return[[r.topright,1],[1,1],[1,r.righttop]]},I0=function(r){return[[0,r.lefttop],[0,1],[r.topleft,1]]},R0=function(r){return[[r.bottomright,0],[r.bottomleft,0],[0,r.leftbottom],[0,r.lefttop]]},L0=function(r){return[[r.bottomright,0],[r.bottomleft,0],[1,r.righttop],[1,r.rightbottom]]},N0=function(r){return[[1,r.righttop],[1,r.rightbottom],[r.topleft,1],[r.topright,1]]},O0=function(r){return[[0,r.leftbottom],[0,r.lefttop],[r.topleft,1],[r.topright,1]]},vU=function(r){return[[0,0],[0,r.leftbottom],[1,r.rightbottom],[1,0]]},_U=function(r){return[[1,0],[r.bottomright,0],[r.topright,1],[1,1]]},xU=function(r){return[[1,1],[1,r.righttop],[0,r.lefttop],[0,1]]},EU=function(r){return[[r.bottomleft,0],[0,0],[0,1],[r.topleft,1]]},wU=function(r){return[[1,r.righttop],[1,r.rightbottom],[0,r.leftbottom],[0,r.lefttop]]},MU=function(r){return[[r.topleft,1],[r.topright,1],[r.bottomright,0],[r.bottomleft,0]]},SU=function(){return[[0,0],[0,1],[1,1],[1,0]]},bU=function(r){return[[1,r.rightbottom],[1,0],[0,0],[0,1],[r.topleft,1]]},TU=function(r){return[[r.topright,1],[1,1],[1,0],[0,0],[0,r.leftbottom]]},AU=function(r){return[[1,0],[r.bottomright,0],[0,r.lefttop],[0,1],[1,1]]},CU=function(r){return[[1,1],[1,r.righttop],[r.bottomleft,0],[0,0],[0,1]]},PU=function(r){return[[1,r.righttop],[1,r.rightbottom],[0,r.lefttop],[0,1],[r.topleft,1]]},IU=function(r){return[[1,1],[1,r.righttop],[r.bottomright,0],[r.bottomleft,0],[r.topright,1]]},RU=function(r){return[[1,r.rightbottom],[1,0],[r.bottomright,0],[0,r.leftbottom],[0,r.lefttop]]},LU=function(r){return[[r.topright,1],[r.bottomleft,0],[0,0],[0,r.leftbottom],[r.topleft,1]]},NU=function(r){return[[r.bottomright,0],[r.bottomleft,0],[0,r.lefttop],[0,1],[r.topleft,1]]},OU=function(r){return[[1,1],[1,r.righttop],[0,r.leftbottom],[0,r.lefttop],[r.topright,1]]},DU=function(r){return[[1,r.rightbottom],[1,0],[r.bottomright,0],[r.topleft,1],[r.topright,1]]},FU=function(r){return[[1,r.righttop],[1,r.rightbottom],[r.bottomleft,0],[0,0],[0,r.leftbottom]]},UU=function(r){return[[1,r.rightbottom],[1,0],[0,0],[0,r.leftbottom],[r.topleft,1],[r.topright,1]]},BU=function(r){return[[1,1],[1,0],[r.bottomright,0],[0,r.leftbottom],[0,r.lefttop],[r.topright,1]]},zU=function(r){return[[1,1],[1,r.righttop],[r.bottomright,0],[r.bottomleft,0],[0,r.lefttop],[0,1]]},GU=function(r){return[[1,r.righttop],[1,r.rightbottom],[r.bottomleft,0],[0,0],[0,1],[r.topleft,1]]},kU=function(r){return[[1,1],[1,r.righttop],[r.bottomleft,0],[0,0],[0,r.leftbottom],[r.topright,1]]},HU=function(r){return[[1,r.rightbottom],[1,0],[r.bottomright,0],[0,r.lefttop],[0,1],[r.topleft,1]]},VU=function(r){return[[1,r.righttop],[1,r.rightbottom],[r.bottomright,0],[r.bottomleft,0],[0,r.leftbottom],[0,r.lefttop],[r.topleft,1],[r.topright,1]]},WU=function(r){return[[1,1],[1,r.righttop],[r.bottomleft,0],[0,0],[0,r.leftbottom],[r.topright,1]]},qU=function(r){return[[1,r.rightbottom],[1,0],[r.bottomright,0],[0,r.lefttop],[0,1],[r.topleft,1]]},XU=function(r){return[[1,1],[1,r.righttop],[r.bottomright,0],[r.bottomleft,0],[0,r.leftbottom],[0,r.lefttop],[r.topright,1]]},YU=function(r){return[[1,r.righttop],[1,r.rightbottom],[r.bottomleft,0],[0,0],[0,r.leftbottom],[r.topleft,1],[r.topright,1]]},$U=function(r){return[[1,r.righttop],[1,r.rightbottom],[r.bottomright,0],[r.bottomleft,0],[0,r.lefttop],[0,1],[r.topleft,1]]},ZU=function(r){return[[1,r.rightbottom],[1,0],[r.bottomright,0],[0,r.leftbottom],[0,r.lefttop],[r.topleft,1],[r.topright,1]]},In=[],Rn=[],Ln=[],Nn=[],On=[],Dn=[],Fn=[],Un=[];Nn[1]=On[1]=18;Nn[169]=On[169]=18;Ln[4]=Rn[4]=12;Ln[166]=Rn[166]=12;In[16]=Un[16]=4;In[154]=Un[154]=4;Dn[64]=Fn[64]=22;Dn[106]=Fn[106]=22;Ln[2]=Dn[2]=17;Nn[2]=On[2]=18;Ln[168]=Dn[168]=17;Nn[168]=On[168]=18;In[8]=Nn[8]=9;Rn[8]=Ln[8]=12;In[162]=Nn[162]=9;Rn[162]=Ln[162]=12;In[32]=Un[32]=4;Rn[32]=Fn[32]=1;In[138]=Un[138]=4;Rn[138]=Fn[138]=1;On[128]=Un[128]=21;Dn[128]=Fn[128]=22;On[42]=Un[42]=21;Dn[42]=Fn[42]=22;Rn[5]=On[5]=14;Rn[165]=On[165]=14;Ln[20]=Un[20]=6;Ln[150]=Un[150]=6;In[80]=Dn[80]=11;In[90]=Dn[90]=11;Nn[65]=Fn[65]=3;Nn[105]=Fn[105]=3;In[160]=Dn[160]=11;Rn[160]=On[160]=14;In[10]=Dn[10]=11;Rn[10]=On[10]=14;Ln[130]=Un[130]=6;Nn[130]=Fn[130]=3;Ln[40]=Un[40]=6;Nn[40]=Fn[40]=3;Rn[101]=Fn[101]=1;Rn[69]=Fn[69]=1;On[149]=Un[149]=21;On[21]=Un[21]=21;Ln[86]=Dn[86]=17;Ln[84]=Dn[84]=17;In[89]=Nn[89]=9;In[81]=Nn[81]=9;In[96]=Fn[96]=0;Rn[96]=Dn[96]=15;In[74]=Fn[74]=0;Rn[74]=Dn[74]=15;In[24]=Ln[24]=8;Nn[24]=Un[24]=7;In[146]=Ln[146]=8;Nn[146]=Un[146]=7;Rn[6]=Dn[6]=15;Ln[6]=On[6]=16;Rn[164]=Dn[164]=15;Ln[164]=On[164]=16;Nn[129]=Un[129]=7;On[129]=Fn[129]=20;Nn[41]=Un[41]=7;On[41]=Fn[41]=20;Ln[66]=Fn[66]=2;Nn[66]=Dn[66]=19;Ln[104]=Fn[104]=2;Nn[104]=Dn[104]=19;In[144]=On[144]=10;Dn[144]=Un[144]=23;In[26]=On[26]=10;Dn[26]=Un[26]=23;Rn[36]=Un[36]=5;Ln[36]=Fn[36]=2;Rn[134]=Un[134]=5;Ln[134]=Fn[134]=2;In[9]=On[9]=10;Rn[9]=Nn[9]=13;In[161]=On[161]=10;Rn[161]=Nn[161]=13;Rn[37]=Un[37]=5;On[37]=Fn[37]=20;Rn[133]=Un[133]=5;On[133]=Fn[133]=20;Ln[148]=On[148]=16;Dn[148]=Un[148]=23;Ln[22]=On[22]=16;Dn[22]=Un[22]=23;In[82]=Ln[82]=8;Nn[82]=Dn[82]=19;In[88]=Ln[88]=8;Nn[88]=Dn[88]=19;In[73]=Fn[73]=0;Rn[73]=Nn[73]=13;In[97]=Fn[97]=0;Rn[97]=Nn[97]=13;In[145]=Nn[145]=9;On[145]=Un[145]=21;In[25]=Nn[25]=9;On[25]=Un[25]=21;Rn[70]=Fn[70]=1;Ln[70]=Dn[70]=17;Rn[100]=Fn[100]=1;Ln[100]=Dn[100]=17;In[34]=Nn[34]=9;Rn[34]=Ln[34]=12;On[34]=Un[34]=21;Dn[34]=Fn[34]=22;In[136]=Un[136]=4;Rn[136]=Fn[136]=1;Ln[136]=Dn[136]=17;Nn[136]=On[136]=18;In[35]=Un[35]=4;Rn[35]=Ln[35]=12;Nn[35]=On[35]=18;Dn[35]=Fn[35]=22;In[153]=Un[153]=4;Nn[153]=On[153]=18;Rn[102]=Ln[102]=12;Dn[102]=Fn[102]=22;In[155]=Nn[155]=9;On[155]=Un[155]=23;Rn[103]=Fn[103]=1;Ln[103]=Dn[103]=17;In[152]=Un[152]=4;Ln[152]=Dn[152]=17;Nn[152]=On[152]=18;In[156]=Ln[156]=8;Nn[156]=On[156]=18;Dn[156]=Un[156]=23;In[137]=Un[137]=4;Rn[137]=Fn[137]=1;Nn[137]=On[137]=18;In[139]=Un[139]=4;Rn[139]=Nn[139]=13;On[139]=Fn[139]=20;In[98]=Nn[98]=9;Rn[98]=Ln[98]=12;Dn[98]=Fn[98]=22;In[99]=Fn[99]=0;Rn[99]=Ln[99]=12;Nn[99]=Dn[99]=19;Rn[38]=Ln[38]=12;On[38]=Un[38]=21;Dn[38]=Fn[38]=22;Rn[39]=Un[39]=5;Ln[39]=On[39]=16;Dn[39]=Fn[39]=22;var ee=[];ee[1]=ee[169]=A0;ee[4]=ee[166]=C0;ee[16]=ee[154]=P0;ee[64]=ee[106]=I0;ee[168]=ee[2]=R0;ee[162]=ee[8]=L0;ee[138]=ee[32]=N0;ee[42]=ee[128]=O0;ee[5]=ee[165]=vU;ee[20]=ee[150]=_U;ee[80]=ee[90]=xU;ee[65]=ee[105]=EU;ee[160]=ee[10]=wU;ee[130]=ee[40]=MU;ee[85]=SU;ee[101]=ee[69]=bU;ee[149]=ee[21]=TU;ee[86]=ee[84]=AU;ee[89]=ee[81]=CU;ee[96]=ee[74]=PU;ee[24]=ee[146]=IU;ee[6]=ee[164]=RU;ee[129]=ee[41]=LU;ee[66]=ee[104]=NU;ee[144]=ee[26]=OU;ee[36]=ee[134]=DU;ee[9]=ee[161]=FU;ee[37]=ee[133]=UU;ee[148]=ee[22]=BU;ee[82]=ee[88]=zU;ee[73]=ee[97]=GU;ee[145]=ee[25]=kU;ee[70]=ee[100]=HU;ee[34]=function(r){return[O0(r),L0(r)]};ee[35]=VU;ee[136]=function(r){return[N0(r),R0(r)]};ee[153]=function(r){return[P0(r),A0(r)]};ee[102]=function(r){return[C0(r),I0(r)]};ee[155]=WU;ee[103]=qU;ee[152]=function(r){return[P0(r),R0(r)]};ee[156]=XU;ee[137]=function(r){return[N0(r),A0(r)]};ee[139]=YU;ee[98]=function(r){return[L0(r),I0(r)]};ee[99]=$U;ee[38]=function(r){return[C0(r),O0(r)]};ee[39]=ZU;function KU(r){return(r>0)-(r<0)||+r}function vc(r,t,e){var o=t[0]-r[0],a=t[1]-r[1],c=e[0]-t[0],p=e[1]-t[1];return KU(o*p-c*a)}function nM(r,t){var e=r.geometry.coordinates[0].map(function(p){return p[0]}),o=r.geometry.coordinates[0].map(function(p){return p[1]}),a=t.geometry.coordinates[0].map(function(p){return p[0]}),c=t.geometry.coordinates[0].map(function(p){return p[1]});return Math.max.apply(null,e)===Math.max.apply(null,a)&&Math.max.apply(null,o)===Math.max.apply(null,c)&&Math.min.apply(null,e)===Math.min.apply(null,a)&&Math.min.apply(null,o)===Math.min.apply(null,c)}function D0(r,t){return t.geometry.coordinates[0].every(function(e){return Ni(Tr(e),r)})}function rM(r,t){return r[0]===t[0]&&r[1]===t[1]}var QU=function(){function r(t){this.id=r.buildId(t),this.coordinates=t,this.innerEdges=[],this.outerEdges=[],this.outerEdgesSorted=!1}return r.buildId=function(t){return t.join(",")},r.prototype.removeInnerEdge=function(t){this.innerEdges=this.innerEdges.filter(function(e){return e.from.id!==t.from.id})},r.prototype.removeOuterEdge=function(t){this.outerEdges=this.outerEdges.filter(function(e){return e.to.id!==t.to.id})},r.prototype.addOuterEdge=function(t){this.outerEdges.push(t),this.outerEdgesSorted=!1},r.prototype.sortOuterEdges=function(){var t=this;this.outerEdgesSorted||(this.outerEdges.sort(function(e,o){var a=e.to,c=o.to;if(a.coordinates[0]-t.coordinates[0]>=0&&c.coordinates[0]-t.coordinates[0]<0)return 1;if(a.coordinates[0]-t.coordinates[0]<0&&c.coordinates[0]-t.coordinates[0]>=0)return-1;if(a.coordinates[0]-t.coordinates[0]===0&&c.coordinates[0]-t.coordinates[0]===0)return a.coordinates[1]-t.coordinates[1]>=0||c.coordinates[1]-t.coordinates[1]>=0?a.coordinates[1]-c.coordinates[1]:c.coordinates[1]-a.coordinates[1];var p=vc(t.coordinates,a.coordinates,c.coordinates);if(p<0)return 1;if(p>0)return-1;var d=Math.pow(a.coordinates[0]-t.coordinates[0],2)+Math.pow(a.coordinates[1]-t.coordinates[1],2),g=Math.pow(c.coordinates[0]-t.coordinates[0],2)+Math.pow(c.coordinates[1]-t.coordinates[1],2);return d-g}),this.outerEdgesSorted=!0)},r.prototype.getOuterEdges=function(){return this.sortOuterEdges(),this.outerEdges},r.prototype.getOuterEdge=function(t){return this.sortOuterEdges(),this.outerEdges[t]},r.prototype.addInnerEdge=function(t){this.innerEdges.push(t)},r}(),F0=QU;var jU=function(){function r(t,e){this.from=t,this.to=e,this.next=void 0,this.label=void 0,this.symetric=void 0,this.ring=void 0,this.from.addOuterEdge(this),this.to.addInnerEdge(this)}return r.prototype.getSymetric=function(){return this.symetric||(this.symetric=new r(this.to,this.from),this.symetric.symetric=this),this.symetric},r.prototype.deleteEdge=function(){this.from.removeOuterEdge(this),this.to.removeInnerEdge(this)},r.prototype.isEqual=function(t){return this.from.id===t.from.id&&this.to.id===t.to.id},r.prototype.toString=function(){return"Edge { "+this.from.id+" -> "+this.to.id+" }"},r.prototype.toLineString=function(){return Li([this.from.coordinates,this.to.coordinates])},r.prototype.compareTo=function(t){return vc(t.from.coordinates,t.to.coordinates,this.to.coordinates)},r}(),iM=jU;var tB=function(){function r(){this.edges=[],this.polygon=void 0,this.envelope=void 0}return r.prototype.push=function(t){this.edges.push(t),this.polygon=this.envelope=void 0},r.prototype.get=function(t){return this.edges[t]},Object.defineProperty(r.prototype,"length",{get:function(){return this.edges.length},enumerable:!0,configurable:!0}),r.prototype.forEach=function(t){this.edges.forEach(t)},r.prototype.map=function(t){return this.edges.map(t)},r.prototype.some=function(t){return this.edges.some(t)},r.prototype.isValid=function(){return!0},r.prototype.isHole=function(){var t=this,e=this.edges.reduce(function(p,d,g){return d.from.coordinates[1]>t.edges[p].from.coordinates[1]&&(p=g),p},0),o=(e===0?this.length:e)-1,a=(e+1)%this.length,c=vc(this.edges[o].from.coordinates,this.edges[e].from.coordinates,this.edges[a].from.coordinates);return c===0?this.edges[o].from.coordinates[0]>this.edges[a].from.coordinates[0]:c>0},r.prototype.toMultiPoint=function(){return _m(this.edges.map(function(t){return t.from.coordinates}))},r.prototype.toPolygon=function(){if(this.polygon)return this.polygon;var t=this.edges.map(function(e){return e.from.coordinates});return t.push(this.edges[0].from.coordinates),this.polygon=Or([t])},r.prototype.getEnvelope=function(){return this.envelope?this.envelope:this.envelope=Bm(this.toPolygon())},r.findEdgeRingContaining=function(t,e){var o=t.getEnvelope(),a,c;return e.forEach(function(p){var d=p.getEnvelope();if(c&&(a=c.getEnvelope()),!nM(d,o)&&D0(d,o)){for(var g=t.map(function(P){return P.from.coordinates}),y=void 0,_=function(P){p.some(function(I){return rM(P,I.from.coordinates)})||(y=P)},w=0,x=g;w<x.length;w++){var T=x[w];_(T)}y&&p.inside(Tr(y))&&(!c||D0(a,d))&&(c=p)}}),c},r.prototype.inside=function(t){return Ni(t,this.toPolygon())},r}(),U0=tB;function eB(r){if(!r)throw new Error("No geojson passed");if(r.type!=="FeatureCollection"&&r.type!=="GeometryCollection"&&r.type!=="MultiLineString"&&r.type!=="LineString"&&r.type!=="Feature")throw new Error("Invalid input type '"+r.type+"'. Geojson must be FeatureCollection, GeometryCollection, LineString, MultiLineString or Feature")}var CW=function(){function r(){this.edges=[],this.nodes={}}return r.fromGeoJson=function(t){eB(t);var e=new r;return cs(t,function(o){Em(o,"LineString","Graph::fromGeoJson"),J1(o,function(a,c){if(a){var p=e.getNode(a),d=e.getNode(c);e.addEdge(p,d)}return c})}),e},r.prototype.getNode=function(t){var e=F0.buildId(t),o=this.nodes[e];return o||(o=this.nodes[e]=new F0(t)),o},r.prototype.addEdge=function(t,e){var o=new iM(t,e),a=o.getSymetric();this.edges.push(o),this.edges.push(a)},r.prototype.deleteDangles=function(){var t=this;Object.keys(this.nodes).map(function(e){return t.nodes[e]}).forEach(function(e){return t._removeIfDangle(e)})},r.prototype._removeIfDangle=function(t){var e=this;if(t.innerEdges.length<=1){var o=t.getOuterEdges().map(function(a){return a.to});this.removeNode(t),o.forEach(function(a){return e._removeIfDangle(a)})}},r.prototype.deleteCutEdges=function(){var t=this;this._computeNextCWEdges(),this._findLabeledEdgeRings(),this.edges.forEach(function(e){e.label===e.symetric.label&&(t.removeEdge(e.symetric),t.removeEdge(e))})},r.prototype._computeNextCWEdges=function(t){var e=this;typeof t=="undefined"?Object.keys(this.nodes).forEach(function(o){return e._computeNextCWEdges(e.nodes[o])}):t.getOuterEdges().forEach(function(o,a){t.getOuterEdge((a===0?t.getOuterEdges().length:a)-1).symetric.next=o})},r.prototype._computeNextCCWEdges=function(t,e){for(var o=t.getOuterEdges(),a,c,p=o.length-1;p>=0;--p){var d=o[p],g=d.symetric,y=void 0,_=void 0;d.label===e&&(y=d),g.label===e&&(_=g),!(!y||!_)&&(_&&(c=_),y&&(c&&(c.next=y,c=void 0),a||(a=y)))}c&&(c.next=a)},r.prototype._findLabeledEdgeRings=function(){var t=[],e=0;return this.edges.forEach(function(o){if(!(o.label>=0)){t.push(o);var a=o;do a.label=e,a=a.next;while(!o.isEqual(a));e++}}),t},r.prototype.getEdgeRings=function(){var t=this;this._computeNextCWEdges(),this.edges.forEach(function(o){o.label=void 0}),this._findLabeledEdgeRings().forEach(function(o){t._findIntersectionNodes(o).forEach(function(a){t._computeNextCCWEdges(a,o.label)})});var e=[];return this.edges.forEach(function(o){o.ring||e.push(t._findEdgeRing(o))}),e},r.prototype._findIntersectionNodes=function(t){var e=[],o=t,a=function(){var c=0;o.from.getOuterEdges().forEach(function(p){p.label===t.label&&++c}),c>1&&e.push(o.from),o=o.next};do a();while(!t.isEqual(o));return e},r.prototype._findEdgeRing=function(t){var e=t,o=new U0;do o.push(e),e.ring=o,e=e.next;while(!t.isEqual(e));return o},r.prototype.removeNode=function(t){var e=this;t.getOuterEdges().forEach(function(o){return e.removeEdge(o)}),t.innerEdges.forEach(function(o){return e.removeEdge(o)}),delete this.nodes[t.id]},r.prototype.removeEdge=function(t){this.edges=this.edges.filter(function(e){return!e.isEqual(t)}),t.deleteEdge()},r}();var oB=Lr(B0(),1);var sB=Lr(B0(),1);var uB=Lr(pM(),1);var gB=Lr(MM(),1);function bM(r){for(var t=r,e=[];t.parent;)e.unshift(t),t=t.parent;return e}function yB(){return new TM(function(r){return r.f})}var H0={search:function(r,t,e,o){r.cleanDirty(),o=o||{};var a=o.heuristic||H0.heuristics.manhattan,c=o.closest||!1,p=yB(),d=t;for(t.h=a(t,e),p.push(t);p.size()>0;){var g=p.pop();if(g===e)return bM(g);g.closed=!0;for(var y=r.neighbors(g),_=0,w=y.length;_<w;++_){var x=y[_];if(!(x.closed||x.isWall())){var T=g.g+x.getCost(g),P=x.visited;(!P||T<x.g)&&(x.visited=!0,x.parent=g,x.h=x.h||a(x,e),x.g=T,x.f=x.g+x.h,r.markDirty(x),c&&(x.h<d.h||x.h===d.h&&x.g<d.g)&&(d=x),P?p.rescoreElement(x):p.push(x))}}}return c?bM(d):[]},heuristics:{manhattan:function(r,t){var e=Math.abs(t.x-r.x),o=Math.abs(t.y-r.y);return e+o},diagonal:function(r,t){var e=1,o=Math.sqrt(2),a=Math.abs(t.x-r.x),c=Math.abs(t.y-r.y);return e*(a+c)+(o-2*e)*Math.min(a,c)}},cleanNode:function(r){r.f=0,r.g=0,r.h=0,r.visited=!1,r.closed=!1,r.parent=null}};function wf(r,t){t=t||{},this.nodes=[],this.diagonal=!!t.diagonal,this.grid=[];for(var e=0;e<r.length;e++){this.grid[e]=[];for(var o=0,a=r[e];o<a.length;o++){var c=new kp(e,o,a[o]);this.grid[e][o]=c,this.nodes.push(c)}}this.init()}wf.prototype.init=function(){this.dirtyNodes=[];for(var r=0;r<this.nodes.length;r++)H0.cleanNode(this.nodes[r])};wf.prototype.cleanDirty=function(){for(var r=0;r<this.dirtyNodes.length;r++)H0.cleanNode(this.dirtyNodes[r]);this.dirtyNodes=[]};wf.prototype.markDirty=function(r){this.dirtyNodes.push(r)};wf.prototype.neighbors=function(r){var t=[],e=r.x,o=r.y,a=this.grid;return a[e-1]&&a[e-1][o]&&t.push(a[e-1][o]),a[e+1]&&a[e+1][o]&&t.push(a[e+1][o]),a[e]&&a[e][o-1]&&t.push(a[e][o-1]),a[e]&&a[e][o+1]&&t.push(a[e][o+1]),this.diagonal&&(a[e-1]&&a[e-1][o-1]&&t.push(a[e-1][o-1]),a[e+1]&&a[e+1][o-1]&&t.push(a[e+1][o-1]),a[e-1]&&a[e-1][o+1]&&t.push(a[e-1][o+1]),a[e+1]&&a[e+1][o+1]&&t.push(a[e+1][o+1])),t};wf.prototype.toString=function(){for(var r=[],t=this.grid,e,o,a,c,p=0,d=t.length;p<d;p++){for(e=[],o=t[p],a=0,c=o.length;a<c;a++)e.push(o[a].weight);r.push(e.join(" "))}return r.join(\`
|
|
3705
|
-
\`)};function kp(r,t,e){this.x=r,this.y=t,this.weight=e}kp.prototype.toString=function(){return"["+this.x+" "+this.y+"]"};kp.prototype.getCost=function(r){return r&&r.x!==this.x&&r.y!==this.y?this.weight*1.41421:this.weight};kp.prototype.isWall=function(){return this.weight===0};function TM(r){this.content=[],this.scoreFunction=r}TM.prototype={push:function(r){this.content.push(r),this.sinkDown(this.content.length-1)},pop:function(){var r=this.content[0],t=this.content.pop();return this.content.length>0&&(this.content[0]=t,this.bubbleUp(0)),r},remove:function(r){var t=this.content.indexOf(r),e=this.content.pop();t!==this.content.length-1&&(this.content[t]=e,this.scoreFunction(e)<this.scoreFunction(r)?this.sinkDown(t):this.bubbleUp(t))},size:function(){return this.content.length},rescoreElement:function(r){this.sinkDown(this.content.indexOf(r))},sinkDown:function(r){for(var t=this.content[r];r>0;){var e=(r+1>>1)-1,o=this.content[e];if(this.scoreFunction(t)<this.scoreFunction(o))this.content[e]=t,this.content[r]=o,r=e;else break}},bubbleUp:function(r){for(var t=this.content.length,e=this.content[r],o=this.scoreFunction(e);;){var a=r+1<<1,c=a-1,p=null,d;if(c<t){var g=this.content[c];d=this.scoreFunction(g),d<o&&(p=c)}if(a<t){var y=this.content[a],_=this.scoreFunction(y);_<(p===null?o:d)&&(p=a)}if(p!==null)this.content[r]=this.content[p],this.content[p]=e,r=p;else break}}};function V0(){this._=null}function xc(r){r.U=r.C=r.L=r.R=r.P=r.N=null}V0.prototype={constructor:V0,insert:function(r,t){var e,o,a;if(r){if(t.P=r,t.N=r.N,r.N&&(r.N.P=t),r.N=t,r.R){for(r=r.R;r.L;)r=r.L;r.L=t}else r.R=t;e=r}else this._?(r=AM(this._),t.P=null,t.N=r,r.P=r.L=t,e=r):(t.P=t.N=null,this._=t,e=null);for(t.L=t.R=null,t.U=e,t.C=!0,r=t;e&&e.C;)o=e.U,e===o.L?(a=o.R,a&&a.C?(e.C=a.C=!1,o.C=!0,r=o):(r===e.R&&(Mf(this,e),r=e,e=r.U),e.C=!1,o.C=!0,Sf(this,o))):(a=o.L,a&&a.C?(e.C=a.C=!1,o.C=!0,r=o):(r===e.L&&(Sf(this,e),r=e,e=r.U),e.C=!1,o.C=!0,Mf(this,o))),e=r.U;this._.C=!1},remove:function(r){r.N&&(r.N.P=r.P),r.P&&(r.P.N=r.N),r.N=r.P=null;var t=r.U,e,o=r.L,a=r.R,c,p;if(o?a?c=AM(a):c=o:c=a,t?t.L===r?t.L=c:t.R=c:this._=c,o&&a?(p=c.C,c.C=r.C,c.L=o,o.U=c,c!==a?(t=c.U,c.U=r.U,r=c.R,t.L=r,c.R=a,a.U=c):(c.U=t,t=c,r=c.R)):(p=r.C,r=c),r&&(r.U=t),!p){if(r&&r.C){r.C=!1;return}do{if(r===this._)break;if(r===t.L){if(e=t.R,e.C&&(e.C=!1,t.C=!0,Mf(this,t),e=t.R),e.L&&e.L.C||e.R&&e.R.C){(!e.R||!e.R.C)&&(e.L.C=!1,e.C=!0,Sf(this,e),e=t.R),e.C=t.C,t.C=e.R.C=!1,Mf(this,t),r=this._;break}}else if(e=t.L,e.C&&(e.C=!1,t.C=!0,Sf(this,t),e=t.L),e.L&&e.L.C||e.R&&e.R.C){(!e.L||!e.L.C)&&(e.R.C=!1,e.C=!0,Mf(this,e),e=t.L),e.C=t.C,t.C=e.L.C=!1,Sf(this,t),r=this._;break}e.C=!0,r=t,t=t.U}while(!r.C);r&&(r.C=!1)}}};function Mf(r,t){var e=t,o=t.R,a=e.U;a?a.L===e?a.L=o:a.R=o:r._=o,o.U=a,e.U=o,e.R=o.L,e.R&&(e.R.U=e),o.L=e}function Sf(r,t){var e=t,o=t.L,a=e.U;a?a.L===e?a.L=o:a.R=o:r._=o,o.U=a,e.U=o,e.L=o.R,e.L&&(e.L.U=e),o.R=e}function AM(r){for(;r.L;)r=r.L;return r}var W0=V0;function Ec(r,t,e,o){var a=[null,null],c=Di.push(a)-1;return a.left=r,a.right=t,e&&bf(a,r,t,e),o&&bf(a,t,r,o),Eo[r.index].halfedges.push(c),Eo[t.index].halfedges.push(c),a}function wc(r,t,e){var o=[t,e];return o.left=r,o}function bf(r,t,e,o){!r[0]&&!r[1]?(r[0]=o,r.left=t,r.right=e):r.left===e?r[1]=o:r[0]=o}function vB(r,t,e,o,a){var c=r[0],p=r[1],d=c[0],g=c[1],y=p[0],_=p[1],w=0,x=1,T=y-d,P=_-g,I;if(I=t-d,!(!T&&I>0)){if(I/=T,T<0){if(I<w)return;I<x&&(x=I)}else if(T>0){if(I>x)return;I>w&&(w=I)}if(I=o-d,!(!T&&I<0)){if(I/=T,T<0){if(I>x)return;I>w&&(w=I)}else if(T>0){if(I<w)return;I<x&&(x=I)}if(I=e-g,!(!P&&I>0)){if(I/=P,P<0){if(I<w)return;I<x&&(x=I)}else if(P>0){if(I>x)return;I>w&&(w=I)}if(I=a-g,!(!P&&I<0)){if(I/=P,P<0){if(I>x)return;I>w&&(w=I)}else if(P>0){if(I<w)return;I<x&&(x=I)}return!(w>0)&&!(x<1)||(w>0&&(r[0]=[d+w*T,g+w*P]),x<1&&(r[1]=[d+x*T,g+x*P])),!0}}}}}function _B(r,t,e,o,a){var c=r[1];if(c)return!0;var p=r[0],d=r.left,g=r.right,y=d[0],_=d[1],w=g[0],x=g[1],T=(y+w)/2,P=(_+x)/2,I,M;if(x===_){if(T<t||T>=o)return;if(y>w){if(!p)p=[T,e];else if(p[1]>=a)return;c=[T,a]}else{if(!p)p=[T,a];else if(p[1]<e)return;c=[T,e]}}else if(I=(y-w)/(x-_),M=P-I*T,I<-1||I>1)if(y>w){if(!p)p=[(e-M)/I,e];else if(p[1]>=a)return;c=[(a-M)/I,a]}else{if(!p)p=[(a-M)/I,a];else if(p[1]<e)return;c=[(e-M)/I,e]}else if(_<x){if(!p)p=[t,I*t+M];else if(p[0]>=o)return;c=[o,I*o+M]}else{if(!p)p=[o,I*o+M];else if(p[0]<t)return;c=[t,I*t+M]}return r[0]=p,r[1]=c,!0}function CM(r,t,e,o){for(var a=Di.length,c;a--;)(!_B(c=Di[a],r,t,e,o)||!vB(c,r,t,e,o)||!(Math.abs(c[0][0]-c[1][0])>vr||Math.abs(c[0][1]-c[1][1])>vr))&&delete Di[a]}function PM(r){return Eo[r.index]={site:r,halfedges:[]}}function xB(r,t){var e=r.site,o=t.left,a=t.right;return e===a&&(a=o,o=e),a?Math.atan2(a[1]-o[1],a[0]-o[0]):(e===o?(o=t[1],a=t[0]):(o=t[0],a=t[1]),Math.atan2(o[0]-a[0],a[1]-o[1]))}function q0(r,t){return t[+(t.left!==r.site)]}function EB(r,t){return t[+(t.left===r.site)]}function IM(){for(var r=0,t=Eo.length,e,o,a,c;r<t;++r)if((e=Eo[r])&&(c=(o=e.halfedges).length)){var p=new Array(c),d=new Array(c);for(a=0;a<c;++a)p[a]=a,d[a]=xB(e,Di[o[a]]);for(p.sort(function(g,y){return d[y]-d[g]}),a=0;a<c;++a)d[a]=o[p[a]];for(a=0;a<c;++a)o[a]=d[a]}}function RM(r,t,e,o){var a=Eo.length,c,p,d,g,y,_,w,x,T,P,I,M,E=!0;for(c=0;c<a;++c)if(p=Eo[c]){for(d=p.site,y=p.halfedges,g=y.length;g--;)Di[y[g]]||y.splice(g,1);for(g=0,_=y.length;g<_;)P=EB(p,Di[y[g]]),I=P[0],M=P[1],w=q0(p,Di[y[++g%_]]),x=w[0],T=w[1],(Math.abs(I-x)>vr||Math.abs(M-T)>vr)&&(y.splice(g,0,Di.push(wc(d,P,Math.abs(I-r)<vr&&o-M>vr?[r,Math.abs(x-r)<vr?T:o]:Math.abs(M-o)<vr&&e-I>vr?[Math.abs(T-o)<vr?x:e,o]:Math.abs(I-e)<vr&&M-t>vr?[e,Math.abs(x-e)<vr?T:t]:Math.abs(M-t)<vr&&I-r>vr?[Math.abs(T-t)<vr?x:r,t]:null))-1),++_);_&&(E=!1)}if(E){var N,A,U,z=1/0;for(c=0,E=null;c<a;++c)(p=Eo[c])&&(d=p.site,N=d[0]-r,A=d[1]-t,U=N*N+A*A,U<z&&(z=U,E=p));if(E){var $=[r,t],q=[r,o],D=[e,o],G=[e,t];E.halfedges.push(Di.push(wc(d=E.site,$,q))-1,Di.push(wc(d,q,D))-1,Di.push(wc(d,D,G))-1,Di.push(wc(d,G,$))-1)}}for(c=0;c<a;++c)(p=Eo[c])&&(p.halfedges.length||delete Eo[c])}var LM=[],Hp;function wB(){xc(this),this.x=this.y=this.arc=this.site=this.cy=null}function cl(r){var t=r.P,e=r.N;if(!(!t||!e)){var o=t.site,a=r.site,c=e.site;if(o!==c){var p=a[0],d=a[1],g=o[0]-p,y=o[1]-d,_=c[0]-p,w=c[1]-d,x=2*(g*w-y*_);if(!(x>=-NM)){var T=g*g+y*y,P=_*_+w*w,I=(w*T-y*P)/x,M=(g*P-_*T)/x,E=LM.pop()||new wB;E.arc=r,E.site=a,E.x=I+p,E.y=(E.cy=M+d)+Math.sqrt(I*I+M*M),r.circle=E;for(var N=null,A=Mc._;A;)if(E.y<A.y||E.y===A.y&&E.x<=A.x)if(A.L)A=A.L;else{N=A.P;break}else if(A.R)A=A.R;else{N=A;break}Mc.insert(N,E),N||(Hp=E)}}}}function fl(r){var t=r.circle;t&&(t.P||(Hp=t.N),Mc.remove(t),LM.push(t),xc(t),r.circle=null)}var DM=[];function MB(){xc(this),this.edge=this.site=this.circle=null}function OM(r){var t=DM.pop()||new MB;return t.site=r,t}function X0(r){fl(r),hl.remove(r),DM.push(r),xc(r)}function FM(r){var t=r.circle,e=t.x,o=t.cy,a=[e,o],c=r.P,p=r.N,d=[r];X0(r);for(var g=c;g.circle&&Math.abs(e-g.circle.x)<vr&&Math.abs(o-g.circle.cy)<vr;)c=g.P,d.unshift(g),X0(g),g=c;d.unshift(g),fl(g);for(var y=p;y.circle&&Math.abs(e-y.circle.x)<vr&&Math.abs(o-y.circle.cy)<vr;)p=y.N,d.push(y),X0(y),y=p;d.push(y),fl(y);var _=d.length,w;for(w=1;w<_;++w)y=d[w],g=d[w-1],bf(y.edge,g.site,y.site,a);g=d[0],y=d[_-1],y.edge=Ec(g.site,y.site,null,a),cl(g),cl(y)}function UM(r){for(var t=r[0],e=r[1],o,a,c,p,d=hl._;d;)if(c=BM(d,e)-t,c>vr)d=d.L;else if(p=t-SB(d,e),p>vr){if(!d.R){o=d;break}d=d.R}else{c>-vr?(o=d.P,a=d):p>-vr?(o=d,a=d.N):o=a=d;break}PM(r);var g=OM(r);if(hl.insert(o,g),!(!o&&!a)){if(o===a){fl(o),a=OM(o.site),hl.insert(g,a),g.edge=a.edge=Ec(o.site,g.site),cl(o),cl(a);return}if(!a){g.edge=Ec(o.site,g.site);return}fl(o),fl(a);var y=o.site,_=y[0],w=y[1],x=r[0]-_,T=r[1]-w,P=a.site,I=P[0]-_,M=P[1]-w,E=2*(x*M-T*I),N=x*x+T*T,A=I*I+M*M,U=[(M*N-T*A)/E+_,(x*A-I*N)/E+w];bf(a.edge,y,P,U),g.edge=Ec(y,r,null,U),a.edge=Ec(r,P,null,U),cl(o),cl(a)}}function BM(r,t){var e=r.site,o=e[0],a=e[1],c=a-t;if(!c)return o;var p=r.P;if(!p)return-1/0;e=p.site;var d=e[0],g=e[1],y=g-t;if(!y)return d;var _=d-o,w=1/c-1/y,x=_/y;return w?(-x+Math.sqrt(x*x-2*w*(_*_/(-2*y)-g+y/2+a-c/2)))/w+o:(o+d)/2}function SB(r,t){var e=r.N;if(e)return BM(e,t);var o=r.site;return o[1]===t?o[0]:1/0}var vr=1e-6,NM=1e-12,hl,Eo,Mc,Di;function bB(r,t,e){return(r[0]-e[0])*(t[1]-r[1])-(r[0]-t[0])*(e[1]-r[1])}function TB(r,t){return t[1]-r[1]||t[0]-r[0]}function Vp(r,t){var e=r.sort(TB).pop(),o,a,c;for(Di=[],Eo=new Array(r.length),hl=new W0,Mc=new W0;;)if(c=Hp,e&&(!c||e[1]<c.y||e[1]===c.y&&e[0]<c.x))(e[0]!==o||e[1]!==a)&&(UM(e),o=e[0],a=e[1]),e=r.pop();else if(c)FM(c.arc);else break;if(IM(),t){var p=+t[0][0],d=+t[0][1],g=+t[1][0],y=+t[1][1];CM(p,d,g,y),RM(p,d,g,y)}this.edges=Di,this.cells=Eo,hl=Mc=Di=Eo=null}Vp.prototype={constructor:Vp,polygons:function(){var r=this.edges;return this.cells.map(function(t){var e=t.halfedges.map(function(o){return q0(t,r[o])});return e.data=t.site.data,e})},triangles:function(){var r=[],t=this.edges;return this.cells.forEach(function(e,o){if(d=(c=e.halfedges).length)for(var a=e.site,c,p=-1,d,g,y=t[c[d-1]],_=y.left===a?y.right:y.left;++p<d;)g=_,y=t[c[p]],_=y.left===a?y.right:y.left,g&&_&&o<g.index&&o<_.index&&bB(a,g,_)<0&&r.push([a.data,g.data,_.data])}),r},links:function(){return this.edges.filter(function(r){return r.right}).map(function(r){return{source:r.left.data,target:r.right.data}})},find:function(r,t,e){for(var o=this,a,c=o._found||0,p=o.cells.length,d;!(d=o.cells[c]);)if(++c>=p)return null;var g=r-d.site[0],y=t-d.site[1],_=g*g+y*y;do d=o.cells[a=c],c=null,d.halfedges.forEach(function(w){var x=o.edges[w],T=x.left;if(!((T===d.site||!T)&&!(T=x.right))){var P=r-T[0],I=t-T[1],M=P*P+I*I;M<_&&(_=M,c=T.index)}});while(c!==null);return o._found=a,e==null||_<=e*e?d.site:null}};var OB=Lr(Sc(),1);var ay=Lr(HM(),1);function Vo(){return new Xp}function Xp(){this.reset()}Xp.prototype={constructor:Xp,reset:function(){this.s=this.t=0},add:function(r){VM(qp,r,this.t),VM(this,qp.s,this.s),this.s?this.t+=qp.t:this.s=qp.t},valueOf:function(){return this.s}};var qp=new Xp;function VM(r,t,e){var o=r.s=t+e,a=o-t,c=o-a;r.t=t-c+(e-a)}var Kn=1e-6;var fr=Math.PI,_i=fr/2,Yp=fr/4,ya=fr*2,pl=180/fr,Wo=fr/180,$r=Math.abs,Ys=Math.atan,qo=Math.atan2,Gn=Math.cos;var $p=Math.exp;var Tf=Math.log;var Qe=Math.sin;var Zi=Math.sqrt,Af=Math.tan;function Z0(r){return r>1?0:r<-1?fr:Math.acos(r)}function wo(r){return r>1?_i:r<-1?-_i:Math.asin(r)}function $s(){}var DB=Vo(),wX=Vo();function dl(r){var t=r[0],e=r[1],o=Gn(e);return[o*Gn(t),o*Qe(t),Qe(e)]}function Cf(r,t){return[r[1]*t[2]-r[2]*t[1],r[2]*t[0]-r[0]*t[2],r[0]*t[1]-r[1]*t[0]]}function Pf(r){var t=Zi(r[0]*r[0]+r[1]*r[1]+r[2]*r[2]);r[0]/=t,r[1]/=t,r[2]/=t}var LX=Vo();function qM(r,t){return[r>fr?r-ya:r<-fr?r+ya:r,t]}qM.invert=qM;function J0(){var r=[],t;return{point:function(e,o){t.push([e,o])},lineStart:function(){r.push(t=[])},lineEnd:$s,rejoin:function(){r.length>1&&r.push(r.pop().concat(r.shift()))},result:function(){var e=r;return r=[],t=null,e}}}function K0(r,t){return $r(r[0]-t[0])<Kn&&$r(r[1]-t[1])<Kn}function Zp(r,t,e,o){this.x=r,this.z=t,this.o=e,this.e=o,this.v=!1,this.n=this.p=null}function Q0(r,t,e,o,a){var c=[],p=[],d,g;if(r.forEach(function(P){if(!((I=P.length-1)<=0)){var I,M=P[0],E=P[I],N;if(K0(M,E)){for(a.lineStart(),d=0;d<I;++d)a.point((M=P[d])[0],M[1]);a.lineEnd();return}c.push(N=new Zp(M,P,null,!0)),p.push(N.o=new Zp(M,null,N,!1)),c.push(N=new Zp(E,P,null,!1)),p.push(N.o=new Zp(E,null,N,!0))}}),!!c.length){for(p.sort(t),XM(c),XM(p),d=0,g=p.length;d<g;++d)p[d].e=e=!e;for(var y=c[0],_,w;;){for(var x=y,T=!0;x.v;)if((x=x.n)===y)return;_=x.z,a.lineStart();do{if(x.v=x.o.v=!0,x.e){if(T)for(d=0,g=_.length;d<g;++d)a.point((w=_[d])[0],w[1]);else o(x.x,x.n.x,1,a);x=x.n}else{if(T)for(_=x.p.z,d=_.length-1;d>=0;--d)a.point((w=_[d])[0],w[1]);else o(x.x,x.p.x,-1,a);x=x.p}x=x.o,_=x.z,T=!T}while(!x.v);a.lineEnd()}}}function XM(r){if(t=r.length){for(var t,e=0,o=r[0],a;++e<t;)o.n=a=r[e],a.p=o,o=a;o.n=a=r[0],a.p=o}}function Ru(r,t){return r<t?-1:r>t?1:r>=t?0:NaN}function j0(r){return r.length===1&&(r=BB(r)),{left:function(t,e,o,a){for(o==null&&(o=0),a==null&&(a=t.length);o<a;){var c=o+a>>>1;r(t[c],e)<0?o=c+1:a=c}return o},right:function(t,e,o,a){for(o==null&&(o=0),a==null&&(a=t.length);o<a;){var c=o+a>>>1;r(t[c],e)>0?a=c:o=c+1}return o}}}function BB(r){return function(t,e){return Ru(r(t),e)}}var YM=j0(Ru),zB=YM.right,GB=YM.left;var $M=Array.prototype,HB=$M.slice,VB=$M.map;var S7=Math.sqrt(50),b7=Math.sqrt(10),T7=Math.sqrt(2);function Kp(r){for(var t=r.length,e,o=-1,a=0,c,p;++o<t;)a+=r[o].length;for(c=new Array(a);--t>=0;)for(p=r[t],e=p.length;--e>=0;)c[--a]=p[e];return c}var KB=1e9,l$=-KB;var ty=Vo();function ey(r,t){var e=t[0],o=t[1],a=[Qe(e),-Gn(e),0],c=0,p=0;ty.reset();for(var d=0,g=r.length;d<g;++d)if(_=(y=r[d]).length)for(var y,_,w=y[_-1],x=w[0],T=w[1]/2+Yp,P=Qe(T),I=Gn(T),M=0;M<_;++M,x=N,P=U,I=z,w=E){var E=y[M],N=E[0],A=E[1]/2+Yp,U=Qe(A),z=Gn(A),$=N-x,q=$>=0?1:-1,D=q*$,G=D>fr,Q=P*U;if(ty.add(qo(Q*q*Qe(D),I*z+Q*Gn(D))),c+=G?$+q*ya:$,G^x>=e^N>=e){var _t=Cf(dl(w),dl(E));Pf(_t);var Z=Cf(a,_t);Pf(Z);var Dt=(G^$>=0?-1:1)*wo(Z[2]);(o>Dt||o===Dt&&(_t[0]||_t[1]))&&(p+=G^$>=0?1:-1)}}return(c<-Kn||c<Kn&&ty<-Kn)^p&1}var _$=Vo();var B$=Vo(),z$=Vo();var tz=1/0;var H$=-tz;function ny(r){this._context=r}ny.prototype={_radius:4.5,pointRadius:function(r){return this._radius=r,this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){this._line===0&&this._context.closePath(),this._point=NaN},point:function(r,t){switch(this._point){case 0:{this._context.moveTo(r,t),this._point=1;break}case 1:{this._context.lineTo(r,t);break}default:{this._context.moveTo(r+this._radius,t),this._context.arc(r,t,this._radius,0,ya);break}}},result:$s};var Q$=Vo();function ry(){this._string=[]}ry.prototype={_radius:4.5,_circle:KM(4.5),pointRadius:function(r){return(r=+r)!==this._radius&&(this._radius=r,this._circle=null),this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){this._line===0&&this._string.push("Z"),this._point=NaN},point:function(r,t){switch(this._point){case 0:{this._string.push("M",r,",",t),this._point=1;break}case 1:{this._string.push("L",r,",",t);break}default:{this._circle==null&&(this._circle=KM(this._radius)),this._string.push("M",r,",",t,this._circle);break}}},result:function(){if(this._string.length){var r=this._string.join("");return this._string=[],r}else return null}};function KM(r){return"m0,"+r+"a"+r+","+r+" 0 1,1 0,"+-2*r+"a"+r+","+r+" 0 1,1 0,"+2*r+"z"}function iy(r,t,e,o){return function(a,c){var p=t(c),d=a.invert(o[0],o[1]),g=J0(),y=t(g),_=!1,w,x,T,P={point:I,lineStart:E,lineEnd:N,polygonStart:function(){P.point=A,P.lineStart=U,P.lineEnd=z,x=[],w=[]},polygonEnd:function(){P.point=I,P.lineStart=E,P.lineEnd=N,x=Kp(x);var $=ey(w,d);x.length?(_||(c.polygonStart(),_=!0),Q0(x,rz,$,e,c)):$&&(_||(c.polygonStart(),_=!0),c.lineStart(),e(null,null,1,c),c.lineEnd()),_&&(c.polygonEnd(),_=!1),x=w=null},sphere:function(){c.polygonStart(),c.lineStart(),e(null,null,1,c),c.lineEnd(),c.polygonEnd()}};function I($,q){var D=a($,q);r($=D[0],q=D[1])&&c.point($,q)}function M($,q){var D=a($,q);p.point(D[0],D[1])}function E(){P.point=M,p.lineStart()}function N(){P.point=I,p.lineEnd()}function A($,q){T.push([$,q]);var D=a($,q);y.point(D[0],D[1])}function U(){y.lineStart(),T=[]}function z(){A(T[0][0],T[0][1]),y.lineEnd();var $=y.clean(),q=g.result(),D,G=q.length,Q,_t,Z;if(T.pop(),w.push(T),T=null,!!G){if($&1){if(_t=q[0],(Q=_t.length-1)>0){for(_||(c.polygonStart(),_=!0),c.lineStart(),D=0;D<Q;++D)c.point((Z=_t[D])[0],Z[1]);c.lineEnd()}return}G>1&&$&2&&q.push(q.pop().concat(q.shift())),x.push(q.filter(nz))}}return P}}function nz(r){return r.length>1}function rz(r,t){return((r=r.x)[0]<0?r[1]-_i-Kn:_i-r[1])-((t=t.x)[0]<0?t[1]-_i-Kn:_i-t[1])}var iz=iy(function(){return!0},oz,az,[-fr,-_i]);function oz(r){var t=NaN,e=NaN,o=NaN,a;return{lineStart:function(){r.lineStart(),a=1},point:function(c,p){var d=c>0?fr:-fr,g=$r(c-t);$r(g-fr)<Kn?(r.point(t,e=(e+p)/2>0?_i:-_i),r.point(o,e),r.lineEnd(),r.lineStart(),r.point(d,e),r.point(c,e),a=0):o!==d&&g>=fr&&($r(t-o)<Kn&&(t-=o*Kn),$r(c-d)<Kn&&(c-=d*Kn),e=sz(t,e,c,p),r.point(o,e),r.lineEnd(),r.lineStart(),r.point(d,e),a=0),r.point(t=c,e=p),o=d},lineEnd:function(){r.lineEnd(),t=e=NaN},clean:function(){return 2-a}}}function sz(r,t,e,o){var a,c,p=Qe(r-e);return $r(p)>Kn?Ys((Qe(t)*(c=Gn(o))*Qe(e)-Qe(o)*(a=Gn(t))*Qe(r))/(a*c*p)):(t+o)/2}function az(r,t,e,o){var a;if(r==null)a=e*_i,o.point(-fr,a),o.point(0,a),o.point(fr,a),o.point(fr,0),o.point(fr,-a),o.point(0,-a),o.point(-fr,-a),o.point(-fr,0),o.point(-fr,a);else if($r(r[0]-t[0])>Kn){var c=r[0]<t[0]?fr:-fr;a=e*c/2,o.point(-c,a),o.point(0,a),o.point(c,a)}else o.point(t[0],t[1])}function Qp(r){return function(t){var e=new oy;for(var o in r)e[o]=r[o];return e.stream=t,e}}function oy(){}oy.prototype={constructor:oy,point:function(r,t){this.stream.point(r,t)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};var zZ=Gn(30*Wo);var jZ=Qp({point:function(r,t){this.stream.point(r*Wo,t*Wo)}});function jp(r){return function(t,e){var o=Gn(t),a=Gn(e),c=r(o*a);return[c*a*Qe(t),c*Qe(e)]}}function va(r){return function(t,e){var o=Zi(t*t+e*e),a=r(o),c=Qe(a),p=Gn(a);return[qo(t*c,o*p),wo(o&&e*c/o)]}}var iS=jp(function(r){return Zi(2/(1+r))});iS.invert=va(function(r){return 2*wo(r/2)});var oS=jp(function(r){return(r=Z0(r))&&r/Qe(r)});oS.invert=va(function(r){return r});function sy(r,t){return[r,Tf(Af((_i+t)/2))]}sy.invert=function(r,t){return[r,2*Ys($p(t))-_i]};function td(r,t){return[r,t]}td.invert=td;function sS(r,t){var e=Gn(t),o=Gn(r)*e;return[e*Qe(r)/o,Qe(t)/o]}sS.invert=va(Ys);function aS(r,t){var e=t*t,o=e*e;return[r*(.8707-.131979*e+o*(-.013791+o*(.003971*e-.001529*o))),t*(1.007226+e*(.015085+o*(-.044475+.028874*e-.005916*o)))]}aS.invert=function(r,t){var e=t,o=25,a;do{var c=e*e,p=c*c;e-=a=(e*(1.007226+c*(.015085+p*(-.044475+.028874*c-.005916*p)))-t)/(1.007226+c*(.015085*3+p*(-.044475*7+.028874*9*c-.005916*11*p)))}while($r(a)>Kn&&--o>0);return[r/(.8707+(c=e*e)*(-.131979+c*(-.013791+c*c*c*(.003971-.001529*c)))),e]};function uS(r,t){return[Gn(t)*Qe(r),Qe(t)]}uS.invert=va(wo);function lS(r,t){var e=Gn(t),o=1+Gn(r)*e;return[e*Qe(r)/o,Qe(t)/o]}lS.invert=va(function(r){return 2*Ys(r)});function cS(r,t){return[Tf(Af((_i+t)/2)),-r]}cS.invert=function(r,t){return[-t,2*Ys($p(r))-_i]};var pz=Lr(Sc(),1);var dz=Lr(Sc(),1);var mz=Lr(Sc(),1);var yz=Lr(Sc(),1);function Nu(r,t){return Math.sqrt((t[0]-r[0])**2+(t[1]-r[1])**2)}function uy(r){let t=0;for(let e=0;e<r.length-1;e++)t+=Nu(r[e],r[e+1]);return t}function hS(r,t,e){let o=new tr(t[0]-r[0],t[1]-r[1]),a=new tr(t[0]-e[0],t[1]-e[1]),p=o.angleTo(a)*180/Math.PI,d=new tr(t[0]-r[0],t[1]-r[1]);return new tr(e[0]-r[0],e[1]-r[1]).cross(d)>0?p:-p}var ed=Lr(pS(),1);var oo="___",nd=class{constructor(t=3){this.lift_priority=t;Pi(this,"roadInfo",[]);Pi(this,"facilities",[]);Pi(this,"pointMap",new Map);Pi(this,"nodeMap",new Map);Pi(this,"facilityMap",new Map);Pi(this,"straightLadderMap",new Map);Pi(this,"escalatorMap",new Map);Pi(this,"rampMap",new Map);Pi(this,"staircaseMap",new Map);Pi(this,"parkingMap",new Map);Pi(this,"lineMap",new Map);Pi(this,"baseRoute",new Ps.default);Pi(this,"escalatorRoute",new Ps.default);Pi(this,"straightLadderRoute",new Ps.default);Pi(this,"forwardLineMap",new Map);Pi(this,"forwardRoute",new Ps.default)}isFacilityByType(t){return["facility","escalator","straightLadder","staircase","ramp"].includes(t)}initFacilities(t){this.facilities=t.map(e=>{let o=[];try{o=JSON.parse(e.entry_end_floor)}catch(c){o=[]}let a=[];try{a=JSON.parse(e.entry_start_floor)}catch(c){a=[]}return Yv(Wc({},e),{entry_start_floor:a,entry_end_floor:o})})}initRoute(t,e){this.clear(),this.roadInfo=t,this.initFacilities(e),t.length&&(t.forEach(o=>{o.points.forEach(a=>{a.floor=o.floor;let c=\`\${o.floor}\${oo}\${a.id}\`;if(this.pointMap.set(c,a),this.nodeMap.set(\`\${o.floor}\${oo}\${a.nodeId}\`,c),this.isFacilityByType(a.type)){let p=this.facilities.find(d=>d.id===+a.targetId);if(p){switch(p.entry_infra_type){case"straightLadder":if(p.entry_end_floor.find(_=>_.floor===o.floor)&&p.entry_start_floor.find(_=>_.floor===o.floor)){let _=this.straightLadderMap.get(a.targetId)||[];_.push(Wc({},a)),this.straightLadderMap.set(a.targetId,_)}break;case"staircase":if(p.entry_end_floor.find(_=>_.floor===o.floor)&&p.entry_start_floor.find(_=>_.floor===o.floor)){let _=this.staircaseMap.get(a.targetId)||[];_.push(Wc({},a)),this.staircaseMap.set(a.targetId,_)}break;case"escalator":let g=this.escalatorMap.get(a.targetId)||[];if(p.entry_start_floor.find(_=>_.floor===o.floor)){let _=g.find(w=>{var x;return((x=w.end)==null?void 0:x.floor)!==o.floor&&!w.start});_?_.start=a:g.push({start:a})}if(p.entry_end_floor.find(_=>_.floor===o.floor)){let _=g.find(w=>{var x;return((x=w.start)==null?void 0:x.floor)!==o.floor&&!w.end});_?_.end=a:g.push({end:a})}this.escalatorMap.set(a.targetId,g);break;case"ramp":let y=this.rampMap.get(a.targetId)||[];if(p.entry_start_floor.find(_=>_.floor===o.floor)){let _=y.find(w=>{var x;return((x=w.end)==null?void 0:x.floor)!==o.floor&&!w.start});_?_.start=a:y.push({start:a})}if(p.entry_end_floor.find(_=>_.floor===o.floor)){let _=y.find(w=>{var x;return((x=w.start)==null?void 0:x.floor)!==o.floor&&!w.end});_?_.end=a:y.push({end:a})}this.rampMap.set(a.targetId,y);break}let d=this.facilityMap.get(a.targetId)||[];d.push(Wc({},a)),this.facilityMap.set(a.targetId,d)}}a.type==="parkingSpace"&&this.parkingMap.set(\`\${o.floor}\${oo}\${a.name}\`,a)}),o.lines.filter(a=>a.direction!=="no").forEach(a=>{var y,_;let c=\`\${o.floor}\${oo}\${a.from}\`,p=\`\${o.floor}\${oo}\${a.to}\`,d=(y=this.pointMap.get(c))==null?void 0:y.cds,g=(_=this.pointMap.get(p))==null?void 0:_.cds;if(d!=null&&d.length&&(g!=null&&g.length)){let w=Nu(d,g);switch(this.addLineItem(c,p,w),this.addLineItem(p,c,w),a.direction){case"double":this.addLineItem(c,p,w,this.forwardLineMap),this.addLineItem(p,c,w,this.forwardLineMap);break;case"single":this.addLineItem(c,p,w,this.forwardLineMap);break;case"back":this.addLineItem(p,c,w,this.forwardLineMap);break}}})}),this.initBaseRoute(),this.initEscalatorRoute(),this.initStraightLadderRoute(),this.initForwardRoute())}addLineItem(t,e,o,a=this.lineMap){let c=a.get(t)||new Map;c.set(e,o),a.set(t,c)}addFacilityToLineMap(t,e,o,a){[...this.straightLadderMap,...this.staircaseMap].forEach(([c,p])=>{var d,g;if(!(p.length<2))for(let y=0;y<p.length;y++){let _=\`\${p[y].floor}\${oo}\${p[y].id}\`;for(let w=0;w<p.length;w++)if(y!==w){let x=\`\${p[w].floor}\${oo}\${p[w].id}\`,T=(d=this.pointMap.get(_))==null?void 0:d.cds,P=(g=this.pointMap.get(x))==null?void 0:g.cds;if(T!=null&&T.length&&(P!=null&&P.length))if(p[y].type==="straightLadder"){let I=e;this.addLineItem(_,x,I,a)}else{let I=o;this.addLineItem(_,x,I,a)}}}}),this.escalatorMap.forEach((c,p)=>{c.forEach(d=>{var g,y;if(d.start&&d.end){let _=\`\${d.start.floor}\${oo}\${d.start.id}\`,w=\`\${d.end.floor}\${oo}\${d.end.id}\`,x=(g=this.pointMap.get(_))==null?void 0:g.cds,T=(y=this.pointMap.get(w))==null?void 0:y.cds;if(x!=null&&x.length&&(T!=null&&T.length)){let P=t;this.addLineItem(_,w,P,a)}}})})}initBaseRoute(){let t=new Map((0,ed.cloneDeep)([...this.lineMap]));this.addFacilityToLineMap(1,this.lift_priority,3e4,t),this.baseRoute=new Ps.default(t)}initEscalatorRoute(){let t=new Map((0,ed.cloneDeep)([...this.lineMap])),e=1e4;this.addFacilityToLineMap(1*e,this.lift_priority*e,3e4*e,t),this.escalatorRoute=new Ps.default(t)}initStraightLadderRoute(){let t=new Map((0,ed.cloneDeep)([...this.lineMap])),e=1e4;this.addFacilityToLineMap(3*e,1*e,3e4*e,t),this.straightLadderRoute=new Ps.default(t)}initForwardRoute(){this.rampMap.forEach((t,e)=>{t.forEach(o=>{var a,c;if(o.start&&o.end){let p=\`\${o.start.floor}\${oo}\${o.start.id}\`,d=\`\${o.end.floor}\${oo}\${o.end.id}\`,g=(a=this.pointMap.get(p))==null?void 0:a.cds,y=(c=this.pointMap.get(d))==null?void 0:c.cds;g!=null&&g.length&&(y!=null&&y.length)&&this.addLineItem(p,d,10,this.forwardLineMap)}})}),this.forwardRoute=new Ps.default(this.forwardLineMap)}checkStart(t){return!(!t.floor||!t.nodeId&&(!t.coord||t.coord.length<2))}checkEnd(t){return t.facility||t.parkingSpace&&t.floor?!0:this.checkStart(t)}transformStart(t){var e;if(t.nodeId){let o=this.nodeMap.get(\`\${t.floor}\${oo}\${t.nodeId}\`);if(o){let[a,c]=o.split(oo);return{floor:a,id:c}}}if((e=t.coord)!=null&&e.length){let o=this.roadInfo.find(c=>c.floor===t.floor);if(!o)return null;let a=o.points.reduce((c,p)=>{let d=Nu(t.coord,p.cds);return d<c.min&&(c.min=d,c.point=p),c},{min:1/0,point:o.points[0]});return{floor:o.floor,id:a.point.id}}return null}transformEnd(t){if(t.floor){if(t.parkingSpace){let o=this.parkingMap.get(\`\${t.floor}\${oo}\${t.parkingSpace}\`);if(o)return{floor:t.floor,id:o.id}}let e=this.transformStart(t);if(e)return e}if(t.facility){let e=this.facilityMap.get(t.facility);if(e!=null&&e.length)return{floor:t.floor,facility:t.facility}}return null}getPath(t,e,o=""){if(!this.checkStart(t))return"start-error";if(!this.checkEnd(e))return"end-error";let a=this.transformStart(t);if(!a)return"no-start";let c=this.transformEnd(e);if(!c)return"no-end";let p=this.getBasePath.bind(this);switch(o){case"escalator":p=this.getEscalatorPath.bind(this);break;case"straightLadder":p=this.getStraightLadderPath.bind(this);break;case"forward":p=this.getForwardPath.bind(this);break;default:p=this.getBasePath.bind(this);break}if(c.id)return p(a,c);if(c.facility){let d=this.facilityMap.get(c.facility).filter(y=>c.floor?y.floor===c.floor:!0);if(!d.length)return null;let g=d.map(y=>p(a,{floor:y.floor,id:y.id})).filter(y=>!!y);return g.reduce((y,_)=>{let w=_.reduce((x,T)=>x+uy(T.points),0);return w<y.distance&&(y.distance=w,y.path=_),y},{distance:1/0,path:g[0]}).path}}getRoutePath(t,e,o){let a=\`\${t.floor}\${oo}\${t.id}\`,c=\`\${e.floor}\${oo}\${e.id}\`,p=o.path(a,c);if(!p)return null;let d=[];return p.map(g=>{var _;let y=this.pointMap.get(g);if(y){let{floor:w}=y,x=y.type;if(this.isFacilityByType(y.type)){let T=this.facilities.find(P=>P.id===+y.targetId);T&&(x=T.entry_infra_type)}if(((_=d[d.length-1])==null?void 0:_.floor)===w){let T=d[d.length-1];T.points.push(y.cds),T.endType=x,T.destId=y.nodeId,T.distance=uy(T.points)}else d.push({floor:w,points:[y.cds],endType:x,destId:y.nodeId,distance:0})}}),d}getBasePath(t,e){return this.getRoutePath(t,e,this.baseRoute)}getEscalatorPath(t,e){return this.getRoutePath(t,e,this.escalatorRoute)}getStraightLadderPath(t,e){return this.getRoutePath(t,e,this.straightLadderRoute)}getForwardPath(t,e){return this.getRoutePath(t,e,this.forwardRoute)}clear(){this.roadInfo=[],this.pointMap.clear(),this.nodeMap.clear(),this.facilityMap.clear(),this.straightLadderMap.clear(),this.escalatorMap.clear(),this.staircaseMap.clear(),this.lineMap.clear(),this.baseRoute=new Ps.default,this.escalatorRoute=new Ps.default,this.straightLadderRoute=new Ps.default}};var Tz=Lr(vS(),1);function Az(r,t,e){let o=hS(r,t,e);return 180-Math.abs(o)<15?"front":o>135?"right_front":o<-135?"left_front":o<=135&&o>=60?"right":o>=-135&&o<=-60?"left":o<60&&o>0?"right_back":o>-60&&o<0?"left_back":"front"}function _S(r){if(!r.length)return[];let t=[{direction:"start",distance:Nu(r[0],r[1]),points:[r[0],r[1]]}];for(let e=2;e<r.length;e++){let o=Az(r[e-2],r[e-1],r[e]);if(o==="front"){let a=t[t.length-1],c=Nu(r[e-1],r[e]);a.distance+=c,e!==2&&a.points.push(r[e-1])}else t.push({direction:o,distance:Nu(r[e-1],r[e]),points:[r[e-1],r[e]]})}return t.push({direction:"end",distance:0,points:[r[r.length-1]]}),t}function xS(r){return r.replace(/[A-Z]/g,t=>"_"+t.toLowerCase()).replace(/^_/,"")}function ES(r){let t={};for(let o in r)o.startsWith("on")&&(t[xS(o.slice(2))]=r[o]);let e=async({data:o})=>{if(t[o.type])try{let a=await t[o.type](o.data);self.postMessage({type:\`\${o.type}_result\`,key:o.key,data:a})}catch(a){self.postMessage({type:\`\${o.type}_result\`,key:o.key,error:a})}else self.postMessage({type:\`\${o.type}_result\`,key:o.key,error:"no_event"})};return self.addEventListener("message",e),()=>{self.removeEventListener("message",e)}}var ly=new nd;ES({onSetRoadInfo({roadData:r,facilities:t}){ly.initRoute(r,t)},onGetPath({start:r,end:t,type:e}){return ly.getPath(r,t,e)},onGetDirectionPath(r){return _S(r)},onClear(){ly.clear()}});
|
|
3705
|
+
\`)};function kp(r,t,e){this.x=r,this.y=t,this.weight=e}kp.prototype.toString=function(){return"["+this.x+" "+this.y+"]"};kp.prototype.getCost=function(r){return r&&r.x!==this.x&&r.y!==this.y?this.weight*1.41421:this.weight};kp.prototype.isWall=function(){return this.weight===0};function TM(r){this.content=[],this.scoreFunction=r}TM.prototype={push:function(r){this.content.push(r),this.sinkDown(this.content.length-1)},pop:function(){var r=this.content[0],t=this.content.pop();return this.content.length>0&&(this.content[0]=t,this.bubbleUp(0)),r},remove:function(r){var t=this.content.indexOf(r),e=this.content.pop();t!==this.content.length-1&&(this.content[t]=e,this.scoreFunction(e)<this.scoreFunction(r)?this.sinkDown(t):this.bubbleUp(t))},size:function(){return this.content.length},rescoreElement:function(r){this.sinkDown(this.content.indexOf(r))},sinkDown:function(r){for(var t=this.content[r];r>0;){var e=(r+1>>1)-1,o=this.content[e];if(this.scoreFunction(t)<this.scoreFunction(o))this.content[e]=t,this.content[r]=o,r=e;else break}},bubbleUp:function(r){for(var t=this.content.length,e=this.content[r],o=this.scoreFunction(e);;){var a=r+1<<1,c=a-1,p=null,d;if(c<t){var g=this.content[c];d=this.scoreFunction(g),d<o&&(p=c)}if(a<t){var y=this.content[a],_=this.scoreFunction(y);_<(p===null?o:d)&&(p=a)}if(p!==null)this.content[r]=this.content[p],this.content[p]=e,r=p;else break}}};function V0(){this._=null}function xc(r){r.U=r.C=r.L=r.R=r.P=r.N=null}V0.prototype={constructor:V0,insert:function(r,t){var e,o,a;if(r){if(t.P=r,t.N=r.N,r.N&&(r.N.P=t),r.N=t,r.R){for(r=r.R;r.L;)r=r.L;r.L=t}else r.R=t;e=r}else this._?(r=AM(this._),t.P=null,t.N=r,r.P=r.L=t,e=r):(t.P=t.N=null,this._=t,e=null);for(t.L=t.R=null,t.U=e,t.C=!0,r=t;e&&e.C;)o=e.U,e===o.L?(a=o.R,a&&a.C?(e.C=a.C=!1,o.C=!0,r=o):(r===e.R&&(Mf(this,e),r=e,e=r.U),e.C=!1,o.C=!0,Sf(this,o))):(a=o.L,a&&a.C?(e.C=a.C=!1,o.C=!0,r=o):(r===e.L&&(Sf(this,e),r=e,e=r.U),e.C=!1,o.C=!0,Mf(this,o))),e=r.U;this._.C=!1},remove:function(r){r.N&&(r.N.P=r.P),r.P&&(r.P.N=r.N),r.N=r.P=null;var t=r.U,e,o=r.L,a=r.R,c,p;if(o?a?c=AM(a):c=o:c=a,t?t.L===r?t.L=c:t.R=c:this._=c,o&&a?(p=c.C,c.C=r.C,c.L=o,o.U=c,c!==a?(t=c.U,c.U=r.U,r=c.R,t.L=r,c.R=a,a.U=c):(c.U=t,t=c,r=c.R)):(p=r.C,r=c),r&&(r.U=t),!p){if(r&&r.C){r.C=!1;return}do{if(r===this._)break;if(r===t.L){if(e=t.R,e.C&&(e.C=!1,t.C=!0,Mf(this,t),e=t.R),e.L&&e.L.C||e.R&&e.R.C){(!e.R||!e.R.C)&&(e.L.C=!1,e.C=!0,Sf(this,e),e=t.R),e.C=t.C,t.C=e.R.C=!1,Mf(this,t),r=this._;break}}else if(e=t.L,e.C&&(e.C=!1,t.C=!0,Sf(this,t),e=t.L),e.L&&e.L.C||e.R&&e.R.C){(!e.L||!e.L.C)&&(e.R.C=!1,e.C=!0,Mf(this,e),e=t.L),e.C=t.C,t.C=e.L.C=!1,Sf(this,t),r=this._;break}e.C=!0,r=t,t=t.U}while(!r.C);r&&(r.C=!1)}}};function Mf(r,t){var e=t,o=t.R,a=e.U;a?a.L===e?a.L=o:a.R=o:r._=o,o.U=a,e.U=o,e.R=o.L,e.R&&(e.R.U=e),o.L=e}function Sf(r,t){var e=t,o=t.L,a=e.U;a?a.L===e?a.L=o:a.R=o:r._=o,o.U=a,e.U=o,e.L=o.R,e.L&&(e.L.U=e),o.R=e}function AM(r){for(;r.L;)r=r.L;return r}var W0=V0;function Ec(r,t,e,o){var a=[null,null],c=Di.push(a)-1;return a.left=r,a.right=t,e&&bf(a,r,t,e),o&&bf(a,t,r,o),Eo[r.index].halfedges.push(c),Eo[t.index].halfedges.push(c),a}function wc(r,t,e){var o=[t,e];return o.left=r,o}function bf(r,t,e,o){!r[0]&&!r[1]?(r[0]=o,r.left=t,r.right=e):r.left===e?r[1]=o:r[0]=o}function vB(r,t,e,o,a){var c=r[0],p=r[1],d=c[0],g=c[1],y=p[0],_=p[1],w=0,x=1,T=y-d,P=_-g,I;if(I=t-d,!(!T&&I>0)){if(I/=T,T<0){if(I<w)return;I<x&&(x=I)}else if(T>0){if(I>x)return;I>w&&(w=I)}if(I=o-d,!(!T&&I<0)){if(I/=T,T<0){if(I>x)return;I>w&&(w=I)}else if(T>0){if(I<w)return;I<x&&(x=I)}if(I=e-g,!(!P&&I>0)){if(I/=P,P<0){if(I<w)return;I<x&&(x=I)}else if(P>0){if(I>x)return;I>w&&(w=I)}if(I=a-g,!(!P&&I<0)){if(I/=P,P<0){if(I>x)return;I>w&&(w=I)}else if(P>0){if(I<w)return;I<x&&(x=I)}return!(w>0)&&!(x<1)||(w>0&&(r[0]=[d+w*T,g+w*P]),x<1&&(r[1]=[d+x*T,g+x*P])),!0}}}}}function _B(r,t,e,o,a){var c=r[1];if(c)return!0;var p=r[0],d=r.left,g=r.right,y=d[0],_=d[1],w=g[0],x=g[1],T=(y+w)/2,P=(_+x)/2,I,M;if(x===_){if(T<t||T>=o)return;if(y>w){if(!p)p=[T,e];else if(p[1]>=a)return;c=[T,a]}else{if(!p)p=[T,a];else if(p[1]<e)return;c=[T,e]}}else if(I=(y-w)/(x-_),M=P-I*T,I<-1||I>1)if(y>w){if(!p)p=[(e-M)/I,e];else if(p[1]>=a)return;c=[(a-M)/I,a]}else{if(!p)p=[(a-M)/I,a];else if(p[1]<e)return;c=[(e-M)/I,e]}else if(_<x){if(!p)p=[t,I*t+M];else if(p[0]>=o)return;c=[o,I*o+M]}else{if(!p)p=[o,I*o+M];else if(p[0]<t)return;c=[t,I*t+M]}return r[0]=p,r[1]=c,!0}function CM(r,t,e,o){for(var a=Di.length,c;a--;)(!_B(c=Di[a],r,t,e,o)||!vB(c,r,t,e,o)||!(Math.abs(c[0][0]-c[1][0])>vr||Math.abs(c[0][1]-c[1][1])>vr))&&delete Di[a]}function PM(r){return Eo[r.index]={site:r,halfedges:[]}}function xB(r,t){var e=r.site,o=t.left,a=t.right;return e===a&&(a=o,o=e),a?Math.atan2(a[1]-o[1],a[0]-o[0]):(e===o?(o=t[1],a=t[0]):(o=t[0],a=t[1]),Math.atan2(o[0]-a[0],a[1]-o[1]))}function q0(r,t){return t[+(t.left!==r.site)]}function EB(r,t){return t[+(t.left===r.site)]}function IM(){for(var r=0,t=Eo.length,e,o,a,c;r<t;++r)if((e=Eo[r])&&(c=(o=e.halfedges).length)){var p=new Array(c),d=new Array(c);for(a=0;a<c;++a)p[a]=a,d[a]=xB(e,Di[o[a]]);for(p.sort(function(g,y){return d[y]-d[g]}),a=0;a<c;++a)d[a]=o[p[a]];for(a=0;a<c;++a)o[a]=d[a]}}function RM(r,t,e,o){var a=Eo.length,c,p,d,g,y,_,w,x,T,P,I,M,E=!0;for(c=0;c<a;++c)if(p=Eo[c]){for(d=p.site,y=p.halfedges,g=y.length;g--;)Di[y[g]]||y.splice(g,1);for(g=0,_=y.length;g<_;)P=EB(p,Di[y[g]]),I=P[0],M=P[1],w=q0(p,Di[y[++g%_]]),x=w[0],T=w[1],(Math.abs(I-x)>vr||Math.abs(M-T)>vr)&&(y.splice(g,0,Di.push(wc(d,P,Math.abs(I-r)<vr&&o-M>vr?[r,Math.abs(x-r)<vr?T:o]:Math.abs(M-o)<vr&&e-I>vr?[Math.abs(T-o)<vr?x:e,o]:Math.abs(I-e)<vr&&M-t>vr?[e,Math.abs(x-e)<vr?T:t]:Math.abs(M-t)<vr&&I-r>vr?[Math.abs(T-t)<vr?x:r,t]:null))-1),++_);_&&(E=!1)}if(E){var N,A,U,z=1/0;for(c=0,E=null;c<a;++c)(p=Eo[c])&&(d=p.site,N=d[0]-r,A=d[1]-t,U=N*N+A*A,U<z&&(z=U,E=p));if(E){var $=[r,t],q=[r,o],D=[e,o],G=[e,t];E.halfedges.push(Di.push(wc(d=E.site,$,q))-1,Di.push(wc(d,q,D))-1,Di.push(wc(d,D,G))-1,Di.push(wc(d,G,$))-1)}}for(c=0;c<a;++c)(p=Eo[c])&&(p.halfedges.length||delete Eo[c])}var LM=[],Hp;function wB(){xc(this),this.x=this.y=this.arc=this.site=this.cy=null}function cl(r){var t=r.P,e=r.N;if(!(!t||!e)){var o=t.site,a=r.site,c=e.site;if(o!==c){var p=a[0],d=a[1],g=o[0]-p,y=o[1]-d,_=c[0]-p,w=c[1]-d,x=2*(g*w-y*_);if(!(x>=-NM)){var T=g*g+y*y,P=_*_+w*w,I=(w*T-y*P)/x,M=(g*P-_*T)/x,E=LM.pop()||new wB;E.arc=r,E.site=a,E.x=I+p,E.y=(E.cy=M+d)+Math.sqrt(I*I+M*M),r.circle=E;for(var N=null,A=Mc._;A;)if(E.y<A.y||E.y===A.y&&E.x<=A.x)if(A.L)A=A.L;else{N=A.P;break}else if(A.R)A=A.R;else{N=A;break}Mc.insert(N,E),N||(Hp=E)}}}}function fl(r){var t=r.circle;t&&(t.P||(Hp=t.N),Mc.remove(t),LM.push(t),xc(t),r.circle=null)}var DM=[];function MB(){xc(this),this.edge=this.site=this.circle=null}function OM(r){var t=DM.pop()||new MB;return t.site=r,t}function X0(r){fl(r),hl.remove(r),DM.push(r),xc(r)}function FM(r){var t=r.circle,e=t.x,o=t.cy,a=[e,o],c=r.P,p=r.N,d=[r];X0(r);for(var g=c;g.circle&&Math.abs(e-g.circle.x)<vr&&Math.abs(o-g.circle.cy)<vr;)c=g.P,d.unshift(g),X0(g),g=c;d.unshift(g),fl(g);for(var y=p;y.circle&&Math.abs(e-y.circle.x)<vr&&Math.abs(o-y.circle.cy)<vr;)p=y.N,d.push(y),X0(y),y=p;d.push(y),fl(y);var _=d.length,w;for(w=1;w<_;++w)y=d[w],g=d[w-1],bf(y.edge,g.site,y.site,a);g=d[0],y=d[_-1],y.edge=Ec(g.site,y.site,null,a),cl(g),cl(y)}function UM(r){for(var t=r[0],e=r[1],o,a,c,p,d=hl._;d;)if(c=BM(d,e)-t,c>vr)d=d.L;else if(p=t-SB(d,e),p>vr){if(!d.R){o=d;break}d=d.R}else{c>-vr?(o=d.P,a=d):p>-vr?(o=d,a=d.N):o=a=d;break}PM(r);var g=OM(r);if(hl.insert(o,g),!(!o&&!a)){if(o===a){fl(o),a=OM(o.site),hl.insert(g,a),g.edge=a.edge=Ec(o.site,g.site),cl(o),cl(a);return}if(!a){g.edge=Ec(o.site,g.site);return}fl(o),fl(a);var y=o.site,_=y[0],w=y[1],x=r[0]-_,T=r[1]-w,P=a.site,I=P[0]-_,M=P[1]-w,E=2*(x*M-T*I),N=x*x+T*T,A=I*I+M*M,U=[(M*N-T*A)/E+_,(x*A-I*N)/E+w];bf(a.edge,y,P,U),g.edge=Ec(y,r,null,U),a.edge=Ec(r,P,null,U),cl(o),cl(a)}}function BM(r,t){var e=r.site,o=e[0],a=e[1],c=a-t;if(!c)return o;var p=r.P;if(!p)return-1/0;e=p.site;var d=e[0],g=e[1],y=g-t;if(!y)return d;var _=d-o,w=1/c-1/y,x=_/y;return w?(-x+Math.sqrt(x*x-2*w*(_*_/(-2*y)-g+y/2+a-c/2)))/w+o:(o+d)/2}function SB(r,t){var e=r.N;if(e)return BM(e,t);var o=r.site;return o[1]===t?o[0]:1/0}var vr=1e-6,NM=1e-12,hl,Eo,Mc,Di;function bB(r,t,e){return(r[0]-e[0])*(t[1]-r[1])-(r[0]-t[0])*(e[1]-r[1])}function TB(r,t){return t[1]-r[1]||t[0]-r[0]}function Vp(r,t){var e=r.sort(TB).pop(),o,a,c;for(Di=[],Eo=new Array(r.length),hl=new W0,Mc=new W0;;)if(c=Hp,e&&(!c||e[1]<c.y||e[1]===c.y&&e[0]<c.x))(e[0]!==o||e[1]!==a)&&(UM(e),o=e[0],a=e[1]),e=r.pop();else if(c)FM(c.arc);else break;if(IM(),t){var p=+t[0][0],d=+t[0][1],g=+t[1][0],y=+t[1][1];CM(p,d,g,y),RM(p,d,g,y)}this.edges=Di,this.cells=Eo,hl=Mc=Di=Eo=null}Vp.prototype={constructor:Vp,polygons:function(){var r=this.edges;return this.cells.map(function(t){var e=t.halfedges.map(function(o){return q0(t,r[o])});return e.data=t.site.data,e})},triangles:function(){var r=[],t=this.edges;return this.cells.forEach(function(e,o){if(d=(c=e.halfedges).length)for(var a=e.site,c,p=-1,d,g,y=t[c[d-1]],_=y.left===a?y.right:y.left;++p<d;)g=_,y=t[c[p]],_=y.left===a?y.right:y.left,g&&_&&o<g.index&&o<_.index&&bB(a,g,_)<0&&r.push([a.data,g.data,_.data])}),r},links:function(){return this.edges.filter(function(r){return r.right}).map(function(r){return{source:r.left.data,target:r.right.data}})},find:function(r,t,e){for(var o=this,a,c=o._found||0,p=o.cells.length,d;!(d=o.cells[c]);)if(++c>=p)return null;var g=r-d.site[0],y=t-d.site[1],_=g*g+y*y;do d=o.cells[a=c],c=null,d.halfedges.forEach(function(w){var x=o.edges[w],T=x.left;if(!((T===d.site||!T)&&!(T=x.right))){var P=r-T[0],I=t-T[1],M=P*P+I*I;M<_&&(_=M,c=T.index)}});while(c!==null);return o._found=a,e==null||_<=e*e?d.site:null}};var OB=Lr(Sc(),1);var ay=Lr(HM(),1);function Vo(){return new Xp}function Xp(){this.reset()}Xp.prototype={constructor:Xp,reset:function(){this.s=this.t=0},add:function(r){VM(qp,r,this.t),VM(this,qp.s,this.s),this.s?this.t+=qp.t:this.s=qp.t},valueOf:function(){return this.s}};var qp=new Xp;function VM(r,t,e){var o=r.s=t+e,a=o-t,c=o-a;r.t=t-c+(e-a)}var Kn=1e-6;var fr=Math.PI,_i=fr/2,Yp=fr/4,ya=fr*2,pl=180/fr,Wo=fr/180,$r=Math.abs,Ys=Math.atan,qo=Math.atan2,Gn=Math.cos;var $p=Math.exp;var Tf=Math.log;var Qe=Math.sin;var Zi=Math.sqrt,Af=Math.tan;function Z0(r){return r>1?0:r<-1?fr:Math.acos(r)}function wo(r){return r>1?_i:r<-1?-_i:Math.asin(r)}function $s(){}var DB=Vo(),wX=Vo();function dl(r){var t=r[0],e=r[1],o=Gn(e);return[o*Gn(t),o*Qe(t),Qe(e)]}function Cf(r,t){return[r[1]*t[2]-r[2]*t[1],r[2]*t[0]-r[0]*t[2],r[0]*t[1]-r[1]*t[0]]}function Pf(r){var t=Zi(r[0]*r[0]+r[1]*r[1]+r[2]*r[2]);r[0]/=t,r[1]/=t,r[2]/=t}var LX=Vo();function qM(r,t){return[r>fr?r-ya:r<-fr?r+ya:r,t]}qM.invert=qM;function J0(){var r=[],t;return{point:function(e,o){t.push([e,o])},lineStart:function(){r.push(t=[])},lineEnd:$s,rejoin:function(){r.length>1&&r.push(r.pop().concat(r.shift()))},result:function(){var e=r;return r=[],t=null,e}}}function K0(r,t){return $r(r[0]-t[0])<Kn&&$r(r[1]-t[1])<Kn}function Zp(r,t,e,o){this.x=r,this.z=t,this.o=e,this.e=o,this.v=!1,this.n=this.p=null}function Q0(r,t,e,o,a){var c=[],p=[],d,g;if(r.forEach(function(P){if(!((I=P.length-1)<=0)){var I,M=P[0],E=P[I],N;if(K0(M,E)){for(a.lineStart(),d=0;d<I;++d)a.point((M=P[d])[0],M[1]);a.lineEnd();return}c.push(N=new Zp(M,P,null,!0)),p.push(N.o=new Zp(M,null,N,!1)),c.push(N=new Zp(E,P,null,!1)),p.push(N.o=new Zp(E,null,N,!0))}}),!!c.length){for(p.sort(t),XM(c),XM(p),d=0,g=p.length;d<g;++d)p[d].e=e=!e;for(var y=c[0],_,w;;){for(var x=y,T=!0;x.v;)if((x=x.n)===y)return;_=x.z,a.lineStart();do{if(x.v=x.o.v=!0,x.e){if(T)for(d=0,g=_.length;d<g;++d)a.point((w=_[d])[0],w[1]);else o(x.x,x.n.x,1,a);x=x.n}else{if(T)for(_=x.p.z,d=_.length-1;d>=0;--d)a.point((w=_[d])[0],w[1]);else o(x.x,x.p.x,-1,a);x=x.p}x=x.o,_=x.z,T=!T}while(!x.v);a.lineEnd()}}}function XM(r){if(t=r.length){for(var t,e=0,o=r[0],a;++e<t;)o.n=a=r[e],a.p=o,o=a;o.n=a=r[0],a.p=o}}function Ru(r,t){return r<t?-1:r>t?1:r>=t?0:NaN}function j0(r){return r.length===1&&(r=BB(r)),{left:function(t,e,o,a){for(o==null&&(o=0),a==null&&(a=t.length);o<a;){var c=o+a>>>1;r(t[c],e)<0?o=c+1:a=c}return o},right:function(t,e,o,a){for(o==null&&(o=0),a==null&&(a=t.length);o<a;){var c=o+a>>>1;r(t[c],e)>0?a=c:o=c+1}return o}}}function BB(r){return function(t,e){return Ru(r(t),e)}}var YM=j0(Ru),zB=YM.right,GB=YM.left;var $M=Array.prototype,HB=$M.slice,VB=$M.map;var S7=Math.sqrt(50),b7=Math.sqrt(10),T7=Math.sqrt(2);function Kp(r){for(var t=r.length,e,o=-1,a=0,c,p;++o<t;)a+=r[o].length;for(c=new Array(a);--t>=0;)for(p=r[t],e=p.length;--e>=0;)c[--a]=p[e];return c}var KB=1e9,l$=-KB;var ty=Vo();function ey(r,t){var e=t[0],o=t[1],a=[Qe(e),-Gn(e),0],c=0,p=0;ty.reset();for(var d=0,g=r.length;d<g;++d)if(_=(y=r[d]).length)for(var y,_,w=y[_-1],x=w[0],T=w[1]/2+Yp,P=Qe(T),I=Gn(T),M=0;M<_;++M,x=N,P=U,I=z,w=E){var E=y[M],N=E[0],A=E[1]/2+Yp,U=Qe(A),z=Gn(A),$=N-x,q=$>=0?1:-1,D=q*$,G=D>fr,Q=P*U;if(ty.add(qo(Q*q*Qe(D),I*z+Q*Gn(D))),c+=G?$+q*ya:$,G^x>=e^N>=e){var _t=Cf(dl(w),dl(E));Pf(_t);var Z=Cf(a,_t);Pf(Z);var Dt=(G^$>=0?-1:1)*wo(Z[2]);(o>Dt||o===Dt&&(_t[0]||_t[1]))&&(p+=G^$>=0?1:-1)}}return(c<-Kn||c<Kn&&ty<-Kn)^p&1}var _$=Vo();var B$=Vo(),z$=Vo();var tz=1/0;var H$=-tz;function ny(r){this._context=r}ny.prototype={_radius:4.5,pointRadius:function(r){return this._radius=r,this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){this._line===0&&this._context.closePath(),this._point=NaN},point:function(r,t){switch(this._point){case 0:{this._context.moveTo(r,t),this._point=1;break}case 1:{this._context.lineTo(r,t);break}default:{this._context.moveTo(r+this._radius,t),this._context.arc(r,t,this._radius,0,ya);break}}},result:$s};var Q$=Vo();function ry(){this._string=[]}ry.prototype={_radius:4.5,_circle:KM(4.5),pointRadius:function(r){return(r=+r)!==this._radius&&(this._radius=r,this._circle=null),this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){this._line===0&&this._string.push("Z"),this._point=NaN},point:function(r,t){switch(this._point){case 0:{this._string.push("M",r,",",t),this._point=1;break}case 1:{this._string.push("L",r,",",t);break}default:{this._circle==null&&(this._circle=KM(this._radius)),this._string.push("M",r,",",t,this._circle);break}}},result:function(){if(this._string.length){var r=this._string.join("");return this._string=[],r}else return null}};function KM(r){return"m0,"+r+"a"+r+","+r+" 0 1,1 0,"+-2*r+"a"+r+","+r+" 0 1,1 0,"+2*r+"z"}function iy(r,t,e,o){return function(a,c){var p=t(c),d=a.invert(o[0],o[1]),g=J0(),y=t(g),_=!1,w,x,T,P={point:I,lineStart:E,lineEnd:N,polygonStart:function(){P.point=A,P.lineStart=U,P.lineEnd=z,x=[],w=[]},polygonEnd:function(){P.point=I,P.lineStart=E,P.lineEnd=N,x=Kp(x);var $=ey(w,d);x.length?(_||(c.polygonStart(),_=!0),Q0(x,rz,$,e,c)):$&&(_||(c.polygonStart(),_=!0),c.lineStart(),e(null,null,1,c),c.lineEnd()),_&&(c.polygonEnd(),_=!1),x=w=null},sphere:function(){c.polygonStart(),c.lineStart(),e(null,null,1,c),c.lineEnd(),c.polygonEnd()}};function I($,q){var D=a($,q);r($=D[0],q=D[1])&&c.point($,q)}function M($,q){var D=a($,q);p.point(D[0],D[1])}function E(){P.point=M,p.lineStart()}function N(){P.point=I,p.lineEnd()}function A($,q){T.push([$,q]);var D=a($,q);y.point(D[0],D[1])}function U(){y.lineStart(),T=[]}function z(){A(T[0][0],T[0][1]),y.lineEnd();var $=y.clean(),q=g.result(),D,G=q.length,Q,_t,Z;if(T.pop(),w.push(T),T=null,!!G){if($&1){if(_t=q[0],(Q=_t.length-1)>0){for(_||(c.polygonStart(),_=!0),c.lineStart(),D=0;D<Q;++D)c.point((Z=_t[D])[0],Z[1]);c.lineEnd()}return}G>1&&$&2&&q.push(q.pop().concat(q.shift())),x.push(q.filter(nz))}}return P}}function nz(r){return r.length>1}function rz(r,t){return((r=r.x)[0]<0?r[1]-_i-Kn:_i-r[1])-((t=t.x)[0]<0?t[1]-_i-Kn:_i-t[1])}var iz=iy(function(){return!0},oz,az,[-fr,-_i]);function oz(r){var t=NaN,e=NaN,o=NaN,a;return{lineStart:function(){r.lineStart(),a=1},point:function(c,p){var d=c>0?fr:-fr,g=$r(c-t);$r(g-fr)<Kn?(r.point(t,e=(e+p)/2>0?_i:-_i),r.point(o,e),r.lineEnd(),r.lineStart(),r.point(d,e),r.point(c,e),a=0):o!==d&&g>=fr&&($r(t-o)<Kn&&(t-=o*Kn),$r(c-d)<Kn&&(c-=d*Kn),e=sz(t,e,c,p),r.point(o,e),r.lineEnd(),r.lineStart(),r.point(d,e),a=0),r.point(t=c,e=p),o=d},lineEnd:function(){r.lineEnd(),t=e=NaN},clean:function(){return 2-a}}}function sz(r,t,e,o){var a,c,p=Qe(r-e);return $r(p)>Kn?Ys((Qe(t)*(c=Gn(o))*Qe(e)-Qe(o)*(a=Gn(t))*Qe(r))/(a*c*p)):(t+o)/2}function az(r,t,e,o){var a;if(r==null)a=e*_i,o.point(-fr,a),o.point(0,a),o.point(fr,a),o.point(fr,0),o.point(fr,-a),o.point(0,-a),o.point(-fr,-a),o.point(-fr,0),o.point(-fr,a);else if($r(r[0]-t[0])>Kn){var c=r[0]<t[0]?fr:-fr;a=e*c/2,o.point(-c,a),o.point(0,a),o.point(c,a)}else o.point(t[0],t[1])}function Qp(r){return function(t){var e=new oy;for(var o in r)e[o]=r[o];return e.stream=t,e}}function oy(){}oy.prototype={constructor:oy,point:function(r,t){this.stream.point(r,t)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};var zZ=Gn(30*Wo);var jZ=Qp({point:function(r,t){this.stream.point(r*Wo,t*Wo)}});function jp(r){return function(t,e){var o=Gn(t),a=Gn(e),c=r(o*a);return[c*a*Qe(t),c*Qe(e)]}}function va(r){return function(t,e){var o=Zi(t*t+e*e),a=r(o),c=Qe(a),p=Gn(a);return[qo(t*c,o*p),wo(o&&e*c/o)]}}var iS=jp(function(r){return Zi(2/(1+r))});iS.invert=va(function(r){return 2*wo(r/2)});var oS=jp(function(r){return(r=Z0(r))&&r/Qe(r)});oS.invert=va(function(r){return r});function sy(r,t){return[r,Tf(Af((_i+t)/2))]}sy.invert=function(r,t){return[r,2*Ys($p(t))-_i]};function td(r,t){return[r,t]}td.invert=td;function sS(r,t){var e=Gn(t),o=Gn(r)*e;return[e*Qe(r)/o,Qe(t)/o]}sS.invert=va(Ys);function aS(r,t){var e=t*t,o=e*e;return[r*(.8707-.131979*e+o*(-.013791+o*(.003971*e-.001529*o))),t*(1.007226+e*(.015085+o*(-.044475+.028874*e-.005916*o)))]}aS.invert=function(r,t){var e=t,o=25,a;do{var c=e*e,p=c*c;e-=a=(e*(1.007226+c*(.015085+p*(-.044475+.028874*c-.005916*p)))-t)/(1.007226+c*(.015085*3+p*(-.044475*7+.028874*9*c-.005916*11*p)))}while($r(a)>Kn&&--o>0);return[r/(.8707+(c=e*e)*(-.131979+c*(-.013791+c*c*c*(.003971-.001529*c)))),e]};function uS(r,t){return[Gn(t)*Qe(r),Qe(t)]}uS.invert=va(wo);function lS(r,t){var e=Gn(t),o=1+Gn(r)*e;return[e*Qe(r)/o,Qe(t)/o]}lS.invert=va(function(r){return 2*Ys(r)});function cS(r,t){return[Tf(Af((_i+t)/2)),-r]}cS.invert=function(r,t){return[-t,2*Ys($p(r))-_i]};var pz=Lr(Sc(),1);var dz=Lr(Sc(),1);var mz=Lr(Sc(),1);var yz=Lr(Sc(),1);function Nu(r,t){return Math.sqrt((t[0]-r[0])**2+(t[1]-r[1])**2)}function uy(r){let t=0;for(let e=0;e<r.length-1;e++)t+=Nu(r[e],r[e+1]);return t}function hS(r,t,e){let o=new tr(t[0]-r[0],t[1]-r[1]),a=new tr(t[0]-e[0],t[1]-e[1]),p=o.angleTo(a)*180/Math.PI,d=new tr(t[0]-r[0],t[1]-r[1]);return new tr(e[0]-r[0],e[1]-r[1]).cross(d)>0?p:-p}var ed=Lr(pS(),1);var oo="___",nd=class{constructor(t=3){this.lift_priority=t;Pi(this,"roadInfo",[]);Pi(this,"facilities",[]);Pi(this,"pointMap",new Map);Pi(this,"nodeMap",new Map);Pi(this,"facilityMap",new Map);Pi(this,"straightLadderMap",new Map);Pi(this,"escalatorMap",new Map);Pi(this,"rampMap",new Map);Pi(this,"staircaseMap",new Map);Pi(this,"parkingMap",new Map);Pi(this,"lineMap",new Map);Pi(this,"baseRoute",new Ps.default);Pi(this,"escalatorRoute",new Ps.default);Pi(this,"straightLadderRoute",new Ps.default);Pi(this,"forwardLineMap",new Map);Pi(this,"forwardRoute",new Ps.default)}isFacilityByType(t){return["facility","escalator","straightLadder","staircase","ramp"].includes(t)}initFacilities(t){this.facilities=t.map(e=>{let o=[];try{o=JSON.parse(e.entry_end_floor)}catch(c){o=[]}let a=[];try{a=JSON.parse(e.entry_start_floor)}catch(c){a=[]}return Yv(Wc({},e),{entry_start_floor:a,entry_end_floor:o})})}initRoute(t,e){this.clear(),this.roadInfo=t,this.initFacilities(e),t.length&&(t.forEach(o=>{o.points.forEach(a=>{a.floor=o.floor;let c=\`\${o.floor}\${oo}\${a.id}\`;if(this.pointMap.set(c,a),this.nodeMap.set(\`\${o.floor}\${oo}\${a.nodeId}\`,c),this.isFacilityByType(a.type)){let p=this.facilities.find(d=>d.id===+a.targetId);if(p){switch(p.entry_infra_type){case"straightLadder":if(p.entry_end_floor.find(_=>_.floor===o.floor)&&p.entry_start_floor.find(_=>_.floor===o.floor)){let _=this.straightLadderMap.get(a.targetId)||[];_.push(Wc({},a)),this.straightLadderMap.set(a.targetId,_)}break;case"staircase":if(p.entry_end_floor.find(_=>_.floor===o.floor)&&p.entry_start_floor.find(_=>_.floor===o.floor)){let _=this.staircaseMap.get(a.targetId)||[];_.push(Wc({},a)),this.staircaseMap.set(a.targetId,_)}break;case"escalator":let g=this.escalatorMap.get(a.targetId)||[];if(p.entry_start_floor.find(_=>_.floor===o.floor)){let _=g.find(w=>{var x;return((x=w.end)==null?void 0:x.floor)!==o.floor&&!w.start});_?_.start=a:g.push({start:a})}if(p.entry_end_floor.find(_=>_.floor===o.floor)){let _=g.find(w=>{var x;return((x=w.start)==null?void 0:x.floor)!==o.floor&&!w.end});_?_.end=a:g.push({end:a})}this.escalatorMap.set(a.targetId,g);break;case"ramp":let y=this.rampMap.get(a.targetId)||[];if(p.entry_start_floor.find(_=>_.floor===o.floor)){let _=y.find(w=>{var x;return((x=w.end)==null?void 0:x.floor)!==o.floor&&!w.start});_?_.start=a:y.push({start:a})}if(p.entry_end_floor.find(_=>_.floor===o.floor)){let _=y.find(w=>{var x;return((x=w.start)==null?void 0:x.floor)!==o.floor&&!w.end});_?_.end=a:y.push({end:a})}this.rampMap.set(a.targetId,y);break}let d=this.facilityMap.get(a.targetId)||[];d.push(Wc({},a)),this.facilityMap.set(a.targetId,d)}}a.type==="parkingSpace"&&this.parkingMap.set(\`\${o.floor}\${oo}\${a.name}\`,a)}),o.lines.filter(a=>a.direction!=="no").forEach(a=>{var y,_;let c=\`\${o.floor}\${oo}\${a.from}\`,p=\`\${o.floor}\${oo}\${a.to}\`,d=(y=this.pointMap.get(c))==null?void 0:y.cds,g=(_=this.pointMap.get(p))==null?void 0:_.cds;if(d!=null&&d.length&&(g!=null&&g.length)){let w=Nu(d,g);switch(this.addLineItem(c,p,w),this.addLineItem(p,c,w),a.direction){case"double":this.addLineItem(c,p,w,this.forwardLineMap),this.addLineItem(p,c,w,this.forwardLineMap);break;case"single":this.addLineItem(c,p,w,this.forwardLineMap);break;case"back":this.addLineItem(p,c,w,this.forwardLineMap);break}}})}),this.initBaseRoute(),this.initEscalatorRoute(),this.initStraightLadderRoute(),this.initForwardRoute())}addLineItem(t,e,o,a=this.lineMap){let c=a.get(t)||new Map;c.set(e,o),a.set(t,c)}addFacilityToLineMap(t,e,o,a){[...this.straightLadderMap,...this.staircaseMap].forEach(([c,p])=>{var d,g;if(!(p.length<2))for(let y=0;y<p.length;y++){let _=\`\${p[y].floor}\${oo}\${p[y].id}\`;for(let w=0;w<p.length;w++)if(y!==w){let x=\`\${p[w].floor}\${oo}\${p[w].id}\`,T=(d=this.pointMap.get(_))==null?void 0:d.cds,P=(g=this.pointMap.get(x))==null?void 0:g.cds;if(T!=null&&T.length&&(P!=null&&P.length))if(p[y].type==="straightLadder"){let I=e;this.addLineItem(_,x,I,a)}else{let I=o;this.addLineItem(_,x,I,a)}}}}),this.escalatorMap.forEach((c,p)=>{c.forEach(d=>{var g,y;if(d.start&&d.end){let _=\`\${d.start.floor}\${oo}\${d.start.id}\`,w=\`\${d.end.floor}\${oo}\${d.end.id}\`,x=(g=this.pointMap.get(_))==null?void 0:g.cds,T=(y=this.pointMap.get(w))==null?void 0:y.cds;if(x!=null&&x.length&&(T!=null&&T.length)){let P=t;this.addLineItem(_,w,P,a)}}})})}initBaseRoute(){let t=new Map((0,ed.cloneDeep)([...this.lineMap]));this.addFacilityToLineMap(1,this.lift_priority,3e4,t),this.baseRoute=new Ps.default(t)}initEscalatorRoute(){let t=new Map((0,ed.cloneDeep)([...this.lineMap])),e=1e4;this.addFacilityToLineMap(1*e,this.lift_priority*e,3e4*e,t),this.escalatorRoute=new Ps.default(t)}initStraightLadderRoute(){let t=new Map((0,ed.cloneDeep)([...this.lineMap])),e=1e4;this.addFacilityToLineMap(3*e,1*e,3e4*e,t),this.straightLadderRoute=new Ps.default(t)}initForwardRoute(){this.rampMap.forEach((t,e)=>{t.forEach(o=>{var a,c;if(o.start&&o.end){let p=\`\${o.start.floor}\${oo}\${o.start.id}\`,d=\`\${o.end.floor}\${oo}\${o.end.id}\`,g=(a=this.pointMap.get(p))==null?void 0:a.cds,y=(c=this.pointMap.get(d))==null?void 0:c.cds;g!=null&&g.length&&(y!=null&&y.length)&&this.addLineItem(p,d,10,this.forwardLineMap)}})}),this.forwardRoute=new Ps.default(this.forwardLineMap)}checkStart(t){return!(!t.floor||!t.nodeId&&(!t.coord||t.coord.length<2))}checkEnd(t){return t.facility||t.parkingSpace&&t.floor?!0:this.checkStart(t)}transformStart(t){var e;if(t.nodeId){let o=this.nodeMap.get(\`\${t.floor}\${oo}\${t.nodeId}\`);if(o){let[a,c]=o.split(oo);return{floor:a,id:c}}}if((e=t.coord)!=null&&e.length){let o=this.roadInfo.find(c=>c.floor===t.floor);if(!o)return null;let a=o.points.reduce((c,p)=>{let d=Nu(t.coord,p.cds);return d<c.min&&(c.min=d,c.point=p),c},{min:1/0,point:o.points[0]});return{floor:o.floor,id:a.point.id}}return null}transformEnd(t){if(t.floor){if(t.parkingSpace){let o=this.parkingMap.get(\`\${t.floor}\${oo}\${t.parkingSpace}\`);if(o)return{floor:t.floor,id:o.id}}let e=this.transformStart(t);if(e)return e}if(t.facility){let o=this.facilities.filter(a=>+a.type_id==+t.facility).map(a=>a.id).map(a=>this.facilityMap.get(\`\${a}\`)).flat(2);if(o!=null&&o.length)return{floor:t.floor,facility:t.facility}}return null}getPath(t,e,o=""){if(!this.checkStart(t))return"start-error";if(!this.checkEnd(e))return"end-error";let a=this.transformStart(t);if(!a)return"no-start";let c=this.transformEnd(e);if(!c)return"no-end";let p=this.getBasePath.bind(this);switch(o){case"escalator":p=this.getEscalatorPath.bind(this);break;case"straightLadder":p=this.getStraightLadderPath.bind(this);break;case"forward":p=this.getForwardPath.bind(this);break;default:p=this.getBasePath.bind(this);break}if(c.id)return p(a,c);if(c.facility){let g=this.facilities.filter(_=>+_.type_id==+e.facility).map(_=>_.id).map(_=>this.facilityMap.get(\`\${_}\`)).flat(2).filter(_=>_).filter(_=>c.floor?_.floor===c.floor:!0);if(!g.length)return null;let y=g.map(_=>p(a,{floor:_.floor,id:_.id})).filter(_=>!!_);return y.reduce((_,w)=>{let x=w.reduce((T,P)=>T+uy(P.points),0);return x<_.distance&&(_.distance=x,_.path=w),_},{distance:1/0,path:y[0]}).path}}getRoutePath(t,e,o){let a=\`\${t.floor}\${oo}\${t.id}\`,c=\`\${e.floor}\${oo}\${e.id}\`,p=o.path(a,c);if(!p)return null;let d=[];return p.map(g=>{var _;let y=this.pointMap.get(g);if(y){let{floor:w}=y,x=y.type;if(this.isFacilityByType(y.type)){let T=this.facilities.find(P=>P.id===+y.targetId);T&&(x=T.entry_infra_type)}if(((_=d[d.length-1])==null?void 0:_.floor)===w){let T=d[d.length-1];T.points.push(y.cds),T.endType=x,T.destId=y.nodeId,T.distance=uy(T.points)}else d.push({floor:w,points:[y.cds],endType:x,destId:y.nodeId,distance:0})}}),d}getBasePath(t,e){return this.getRoutePath(t,e,this.baseRoute)}getEscalatorPath(t,e){return this.getRoutePath(t,e,this.escalatorRoute)}getStraightLadderPath(t,e){return this.getRoutePath(t,e,this.straightLadderRoute)}getForwardPath(t,e){return this.getRoutePath(t,e,this.forwardRoute)}clear(){this.roadInfo=[],this.pointMap.clear(),this.nodeMap.clear(),this.facilityMap.clear(),this.straightLadderMap.clear(),this.escalatorMap.clear(),this.staircaseMap.clear(),this.lineMap.clear(),this.baseRoute=new Ps.default,this.escalatorRoute=new Ps.default,this.straightLadderRoute=new Ps.default}};var Tz=Lr(vS(),1);function Az(r,t,e){let o=hS(r,t,e);return 180-Math.abs(o)<15?"front":o>135?"right_front":o<-135?"left_front":o<=135&&o>=60?"right":o>=-135&&o<=-60?"left":o<60&&o>0?"right_back":o>-60&&o<0?"left_back":"front"}function _S(r){if(!r.length)return[];let t=[{direction:"start",distance:Nu(r[0],r[1]),points:[r[0],r[1]]}];for(let e=2;e<r.length;e++){let o=Az(r[e-2],r[e-1],r[e]);if(o==="front"){let a=t[t.length-1],c=Nu(r[e-1],r[e]);a.distance+=c,e!==2&&a.points.push(r[e-1])}else t.push({direction:o,distance:Nu(r[e-1],r[e]),points:[r[e-1],r[e]]})}return t.push({direction:"end",distance:0,points:[r[r.length-1]]}),t}function xS(r){return r.replace(/[A-Z]/g,t=>"_"+t.toLowerCase()).replace(/^_/,"")}function ES(r){let t={};for(let o in r)o.startsWith("on")&&(t[xS(o.slice(2))]=r[o]);let e=async({data:o})=>{if(t[o.type])try{let a=await t[o.type](o.data);self.postMessage({type:\`\${o.type}_result\`,key:o.key,data:a})}catch(a){self.postMessage({type:\`\${o.type}_result\`,key:o.key,error:a})}else self.postMessage({type:\`\${o.type}_result\`,key:o.key,error:"no_event"})};return self.addEventListener("message",e),()=>{self.removeEventListener("message",e)}}var ly=new nd;ES({onSetRoadInfo({roadData:r,facilities:t}){ly.initRoute(r,t)},onGetPath({start:r,end:t,type:e}){return ly.getPath(r,t,e)},onGetDirectionPath(r){return _S(r)},onClear(){ly.clear()}});
|
|
3706
3706
|
/*! Bundled license information:
|
|
3707
3707
|
|
|
3708
3708
|
object-assign/index.js:
|